A local copy of website to fetch and display episode from server

This commit is contained in:
Kevin Midboe
2017-04-06 22:49:59 +02:00
parent 8f6cf9adf0
commit 81ed339787

120
webpage/verify.html Normal file
View File

@@ -0,0 +1,120 @@
<!DOCTYPE html>
<html>
<head>
<title>seasoned | verify</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<h1 id='title'></h1>
<div>
<!-- <span>path:</span>
<span id="path"></span><button onclick="foo('#path')">Edit</button><br>
<span>name:</span>
<span id="name"></span><button onclick="foo('#name')">Edit</button><br>
<span>season:</span>
<span id="season"></span><button onclick="foo('#season')">Edit</button><br>
<span>episode:</span>
<span id="episode"></span><button onclick="foo('#episode')">Edit</button><br>
<span>videoFiles:</span>
<span id="video_files"></span><button onclick="foo('#video_files')">Edit</button><br>
<span>subtitles:</span>
<span id="subtitles"></span><button onclick="foo('#subtitles')">Edit</button><br>
<span>trash:</span>
<span id="trash"></span><button onclick="foo('#trash')">Edit</button><br> -->
</div>
<form action="/" id="searchForm">
<span>Parent:</span><input type="text" size="100" name="parent" id="parent"><br>
<span>Name:</span><input type="text" size="100" name="name" id="name"><br>
<span>Season:</span><input type="text" size="100" name="season" id="season"><br>
<span>Episode:</span><input type="text" size="100" name="episode" id="episode"><br>
<span>Video_files:</span><input type="text" size="100" name="video_files" id="video_files"><br>
<span>Subtitles:</span><input type="text" size="100" name="subtitles" id="subtitles"><br>
<span>Trash:</span><input type="text" size="100" name="trash" id="trash"><br>
<input type="submit" value="Search" /><br>
</form>
</body>
<script>
function getEpisodeId() {
var sPageURL = window.location.search.substring(1);
var sParameterName = sPageURL.split('=');
if (sParameterName[0] == 'id') {
console.log(sParameterName[1]);
var query_id = document.getElementById('title').innerHTML = sParameterName[1];
return query_id;
}
}
$(document).ready(function() {
getShow();
});
function objectifyForm(formArray) {//serialize data function
var returnArray = {};
for (var i = 0; i < formArray.length; i++){
returnArray[formArray[i]['name']] = formArray[i]['value'];
}
return returnArray;
}
// this is the id of the form
$("#searchForm").submit(function(e) {
var formJsonObj = objectifyForm($("#searchForm").serializeArray());
formJsonObj['verified'] = 1;
formJsonObj['id'] = getEpisodeId();
console.log(formJsonObj);
var url = 'https://apollo.kevinmidboe.com/api/seasoned';
$.ajax({
url: url,
dataType: 'json',
type: 'POST',
data: JSON.stringify(formJsonObj),
success: function (data) {
console.log(episode);
},
error: function() {
console.log('erorr');
}
});
e.preventDefault(); // avoid to execute the actual submit of the form.
});
function foo(id) {
var el = $(id);
if (el.attr('contenteditable') == 'true'){
el.attr('contenteditable', 'false');
} else {
el.attr('contenteditable', 'true')
}
}
function getShow() {
var url = 'https://apollo.kevinmidboe.com/api/seasoned?id=' + getEpisodeId();
$.ajax({
url: url,
dataType: "json",
success: function (data) {
var episode = data['episode'];
$('#parent').val(episode['parent']);
$('#name').val(episode['name']);
$('#season').val(episode['season']);
$('#episode').val(episode['episode']);
$('#video_files').val(episode['video_files']);
$('#subtitles').val(episode['subtitles']);
$('#trash').val(episode['trash']);
console.log(episode);
},
error: function() {
console.log('erorr');
}
});
}
</script>
<script type="text/javascript"></script>
</html>