SERVER_URL="http://volta:8080/do_request";
UPLOAD_URL="http://volta:8080/do_upload";
function refreshStatus() {
$.ajax({
url: SERVER_URL,
dataType: "json",
type: "POST",
data: JSON.stringify({"cmd": "getcurrentfilename"}),
success: function(data) {
$.blayerwebif.newFilename = data.currentfilename;
if($.blayerwebif.oldFilename == $.blayerwebif.newFilename)
return;
$.blayerwebif.oldFilename = $.blayerwebif.newFilename;
$("#tagtable").empty();
$("#tagtable").append("
filename | "+$.blayerwebif.newFilename+" |
"+key+" | "+value+" | "+value+"");
$("#filenames").append(""+value+"");
});
$("#animationcount").text(data.allfilenames.length);
$(".playNextLink").click(function() {
linkNode = this;
$.ajax({
url: SERVER_URL,
dataType: "json",
type: "POST",
data: JSON.stringify({"cmd": "playnext", "filename": $(this).text()}),
success: function(data) {
if(data.playnext == "ok")
item = $("queued...");
else
item = $("queue full :(");
$(linkNode).after(item);
$(item).delay(1000).fadeOut("slow");
}
});
});
},
});
}
function refreshStatusPeriodic() {
refreshStatus();
setTimeout(refreshStatusPeriodic, 1000);
}
$(document).ready(function() {
$.blayerwebif = {};
$.blayerwebif.oldFilename = "";
setTimeout(refreshStatusPeriodic, 1000);
refreshFilenames();
refreshStatus();
$("#uploadbutton").click(function() {
$.ajax({
url: UPLOAD_URL,
type: "POST",
beforeSend: function() {
$("#uploadform").after("uploading...");
},
success: function() {
$("#uploadingnotification").text("done! :)").delay(1000).fadeOut("slow");
refreshFilenames();
},
error: function() {
$("#uploadingnotification").text("failed! :(").delay(1000).fadeOut("slow");
},
contentType: false,
cache: false,
processData: false,
data: new FormData($("#uploadform")[0])
});
});
$("#next").click(function() {
$.ajax({
url: SERVER_URL,
dataType: "json",
type: "POST",
data: JSON.stringify({"cmd": "next"}),
success: function() {
refreshStatus();
}
});
});
$("#pause").click(function() {
button = this;
$.ajax({
url: SERVER_URL,
dataType: "json",
type: "POST",
data: JSON.stringify({"cmd": "togglepaused"}),
success: function(data) {
refreshStatus();
if(data.paused)
$(button).text("play");
else
$(button).text("pause");
}
});
});
$("#filtertext").keyup(function() {
keyword = $("#filtertext").val().toLowerCase();
$("#filenames li").each(function(key, value) {
if($(value).children("a").text().toLowerCase().indexOf(keyword) >= 0)
$(value).show();
else
$(value).hide();
});
});
});