Changes so the lists are printed out more nicely.

This commit is contained in:
Kevin Midboe
2017-04-13 13:27:14 +02:00
parent 4971433c18
commit d73597d7f1
2 changed files with 47 additions and 16 deletions

View File

@@ -1,9 +1,14 @@
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
function getURLId() {
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;
@@ -17,15 +22,16 @@ $(document).ready(function() {
// this is the id of the form
$("#searchForm").submit(function(e) {
var url = env_variables.url + 'verify/' + getURLId();
var url = env_variables.url + 'verify/' + getUrlParameter('id');
$.ajax({
url: url,
type: 'POST',
success: function (data) {
Materialize.toast('Verification successfully sent!', 4000);
},
error: function() {
console.log('erorr');
error: function(data) {
console.log(data.responseJSON.error);
e.preventDefault(); // avoid to execute the actual submit of the form.
}
});
e.preventDefault(); // avoid to execute the actual submit of the form.
@@ -41,8 +47,12 @@ function foo(id) {
}
}
var toType = function(obj) {
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}
function getShow() {
var url = env_variables.url + getURLId();
var url = env_variables.url + getUrlParameter('id');
$.ajax({
url: url,
dataType: "json",
@@ -51,14 +61,26 @@ function getShow() {
$('#name').val(data['name']);
$('#season').val(data['season']);
$('#episode').val(data['episode']);
$('#video_files').val(data['video_files']);
$('#subtitles').val(data['subtitles']);
$('#trash').val(data['trash']);
var itemList= JSON.parse(data['video_files']);
for (item in itemList) {
$('#video_files').append('<p>' + itemList[item][0] + '</p>');
$('#video_files').append('<p>' + itemList[item][1] + '</p>');
}
var itemList= JSON.parse(data['subtitles']);
for (item in itemList) {
$('#subtitles').append('<p>' + itemList[item][0] + '</p>');
$('#subtitles').append('<p>' + itemList[item][1] + '</p>');
}
var itemList= JSON.parse(data['trash']);
for (item in itemList) {
$('#trash').append('<p>' + itemList[item] + '</p>');
}
console.log(data);
},
error: function() {
console.log('erorr');
error: function(data) {
console.log(data.responseJSON.error);
}
});
}