Fixed some form placements in the HTML, placing of X button, removed doublesubmitting of switches and added disabled handling for togglebuttons

This commit is contained in:
Kasper Rynning-Tønnesen
2015-04-15 18:13:31 +02:00
parent e0b0b01f5a
commit a9d99e208a
5 changed files with 83 additions and 53 deletions

View File

@@ -11,26 +11,41 @@ socket.on("toast", function(msg)
remove_bar();*/
});
socket.on(chan.toLowerCase()+",conf", function(msg)
{
populate_list(msg);
});
$('input[class=conf]').change(function()
{
save();
});
function pass_save()
{
save();
}
//function used in html onlick
function save(){
submitAdmin($("#adminForm"));
submitAdmin(document.getElementById("adminForm").elements);
}
function submitAdmin(form)
{
voting = form.vote.value;
addsongs = form.addsongs.value;
longsongs = form.longsongs.value;
frontpage = form.frontpage.value;
allvideos = form.allvideos.value;
removeplay = form.removeplay.value;
adminpass = form.pass.value;
skipping = form.skip.value;
shuffling = form.shuffle.value;
console.log(form);
voting = form.vote.checked;
addsongs = form.addsongs.checked;
longsongs = form.longsongs.checked;
frontpage = form.frontpage.checked;
allvideos = form.allvideos.checked;
removeplay = form.removeplay.checked;
adminpass = document.getElementById("password").value;
skipping = form.skip.checked;
shuffling = form.shuffle.checked;
configs = [voting, addsongs, longsongs, frontpage, allvideos, removeplay, adminpass, skipping, shuffling];
alert(configs)
console.log(configs);
socket.emit("conf", configs);
}

View File

@@ -39,18 +39,21 @@ function populate_list(msg)
if(listeID.hasOwnProperty('startTime')) //check if its config part of list
{
console.log("startTime");
console.log(listeID.addsongs);
if(!adminTogg)
{
if(listeID['adminpass'] == "") hasadmin = false;
else hasadmin = true;
names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip", "shuffle"];
for (var i = 0; i < names.length; i++) {
document.getElementsByName(names[i])[0].checked = (listeID[names[i]] === 'true');
document.getElementsByName(names[i])[0].checked = (listeID[names[i]] === true);
if(hasadmin)
$("input[name="+names[i]+"]").attr("disabled", true);
}
if(hasadmin)
/*if(hasadmin)
$("#setpass").text("Channel has admin");
else
$("#setpass").text("Channel has no admin");
$("#setpass").text("Channel has no admin");*/
}
}else if(!listeID.now_playing){ //check that the song isnt playing