You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

152 lines
3.6 KiB

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("<tr><td>filename</td><td>"+$.blayerwebif.newFilename+"</td></tr");
$.ajax({
url: SERVER_URL,
dataType: "json",
type: "POST",
data: JSON.stringify({"cmd": "getcurrentfileinfo"}),
success: function(data) {
$.each(data.currentfileinfo, function(key, value) {
$("#tagtable").append("<tr><td>"+key+"</td><td>"+value+"</td></tr");
});
}
});
}
});
};
function refreshFilenames() {
$.ajax({
url: SERVER_URL,
dataType: "json",
type: "POST",
data: JSON.stringify({"cmd": "getallfilenames"}),
success: function(data) {
$("#filenames").empty();
$.each(data.allfilenames, function(key, value) {
//alert("<li><a href=\"#\" onClick=\"playNext(\\\""+value+"\\\")\">"+value+"</a></li>");
$("#filenames").append("<li><a href=\"#\" class=\"playNextLink\">"+value+"</a></li>");
});
$("#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 = $("<span class=\"notificationtext\">queued...</span>");
else
item = $("<span class=\"notificationtext\">queue full :(</span>");
$(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("<span class=\"notificationtext\" id=\"uploadingnotification\">uploading...</span>");
},
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();
});
});
});