CSF_ACW_1/Application/views/decode_result.html

70 lines
3.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<title>RESULT</title>
</head>
<body>
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/decode">< Back</a>
</body>
<script>
$(document).ready(function(){
$.get('/get_session', function(response) {
if(response.hasOwnProperty("image")){
console.log(response)
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; text-align:center;">
<div style="width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Decoded</h1>
<img src="upload/` + response["image"] + `" alt="Image Not Found">
</div>
<div style="width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Secret Text:</h1>
<p style="color: red">` + response["payload"] + `</p>
</div>
</section>`
$("body").append(html_content)
}
else if(response.hasOwnProperty("wav")){
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Decoded</h1>
<audio controls>
<source src="upload/` + response["wav"] + `" type="audio/wav">
Your browser does not support the audio element.
</audio>
<div>
<h1 style="height:15%; width:90%; padding: 5%">Secret Text:</h1>
<p>` + response["payload"] + `</p>
</div>
</section>`
$("body").append(html_content)
}
else if(response.hasOwnProperty("txt")){
fetch("upload/" + response["txt"])
.then(res => res.text())
.then(data => {
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; text-align:center;">
<div style="width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Decoded</h1>
<textarea style="height:75%; width:90%; padding: 5%">` + data + `</textarea>
</div>
<div style="width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Secret Text:</h1>
<p>` + response["payload"] + `</p>
</div>
</section>`
$("body").append(html_content)
})
.catch(error => {
console.error('Error:', error);
});
}
});
})
</script>
</html>