CSF_ACW_1/Application/views/encode_result.html

132 lines
6.6 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>
<style>
*{
padding: 0px;
margin: 0px;
}
html, body{
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<a style="text-decoration: none; color: white; display: inline-block; padding: 14px 16px; background-color: gray;" href="/encode">< Back</a>
</body>
<script>
$(document).ready(function(){
$.get('/get_session', function(response) {
console.log(response)
if(response.hasOwnProperty("image")){
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
<img src="upload/` + response["image"] + `" alt="Image Not Found">
</div>
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
<img src="upload/` + response["image2"] + `" alt="Image Not Found">
</div>
</section>`
$("body").append(html_content)
}
else if(response.hasOwnProperty("wav")){
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
<audio controls>
<source src="upload/` + response["wav"] + `" type="audio/wav">
Your browser does not support the audio element.
</audio>
</div>
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
<audio controls>
<source src="upload/` + response["wav2"] + `" type="audio/wav">
Your browser does not support the audio element.
</audio>
</div>
</section>`
$("body").append(html_content)
}
else if(response.hasOwnProperty("mp3")){
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
<audio controls>
<source src="upload/` + response["mp3"] + `" type="audio/wav">
Your browser does not support the audio element.
</audio>
</div>
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
<audio controls>
<source src="upload/` + response["mp3_2"] + `" type="audio/wav">
Your browser does not support the audio element.
</audio>
</div>
</section>`
$("body").append(html_content)
}
else if(response.hasOwnProperty("mp4")){
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
<video style="width: 100%" src="upload/` + response["mp4"] + `" controls autoplay>
Sorry, your browser doesn't support embedded videos.
</video>
</div>
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
<video style="width: 100%" src="upload/` + response["mp4_2"] + `" controls autoplay>
Sorry, your browser doesn't support embedded videos.
</video>
</div>
</section>`
$("body").append(html_content)
}
else if(response.hasOwnProperty("txt")){
fetch("upload/" + response["txt"])
.then(res => res.text())
.then(data => {
fetch("upload/" + response["txt2"])
.then(res2 => res2.text())
.then(data2 => {
var html_content = `<section style="margin: 100px auto; width:50%; height:50%; display: flex; justify-content: space-between;">
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Original</h1>
<textarea style="height:77%; width:100%">` + data + `</textarea>
</div>
<div style="border: 1px solid black; width:100%; height:100%; text-align:center;">
<h1 style="height:15%; width:90%; padding: 5%">Encoded</h1>
<textarea style="height:77%; width:100%">` + data2 + `</textarea>
</div>
</section>`
$("body").append(html_content)
})
.catch(error2 => {
console.error('Error:', error2);
});
})
.catch(error => {
console.error('Error:', error);
});
}
});
})
</script>
</html>