diff --git a/js/admin.js b/js/admin.js index e2a93470..7c7cefa0 100755 --- a/js/admin.js +++ b/js/admin.js @@ -6,7 +6,7 @@ function admin() adminTogg = !adminTogg; if(adminTogg) - if(adminTogg) $("#playlist").height($("#player").height()-250+30); //opening + if(adminTogg) $("#playlist").height($("#player").height()-270+30); //opening if(!adminTogg)$("#playlist").height($("#player").height()+30);; //closing $("#adminPanel").toggleClass("hiddenAdmin"); @@ -22,13 +22,14 @@ function submitAdmin(form) allvideos = form.allvideos.value; removeplay = form.removeplay.value; adminpass = form.pass.value; + skipping = form.skip.value; confRes = $.ajax({ type: "POST", url: "php/change.php", async: false, - data: "conf=start&vote="+voting+"&addsongs="+addsongs+"&longsongs="+longsongs+"&frontpage="+frontpage+"&allvideos="+allvideos+"&removeplay="+removeplay+"&pass="+adminpass, + data: "conf=start&vote="+voting+"&addsongs="+addsongs+"&longsongs="+longsongs+"&frontpage="+frontpage+"&allvideos="+allvideos+"&removeplay="+removeplay+"&pass="+adminpass+"&skip="+skipping, success: function() { console.log("configurations response: "+response); diff --git a/js/list.js b/js/list.js index a9fcebe6..0a62d4bf 100755 --- a/js/list.js +++ b/js/list.js @@ -83,7 +83,7 @@ function updateList() } if(!adminTogg) { - names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay"]; + names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip"]; for (var i = 0; i < names.length; i++) { document.getElementsByName(names[i])[0].checked = (conf[names[i]] === "true"); document.getElementsByName(names[i])[1].checked = (conf[names[i]] === "false"); @@ -144,23 +144,29 @@ function skip(){ }, }).responseText); - console.log(voteRes.split("/")); - skipVotes = voteRes.split("/"); - if(skipVotes[0]>= skipVotes[1]/2) + if(voteRes == "wrong!") { - document.getElementById("sBar").innerHTML = "Successfully skipped!"; - $("#sBar").addClass("opacityFull"); - }else - { - document.getElementById("pBar").innerHTML = "Vote registrated! "+skipVotes[0]+" of "+skipVotes[1]+" has skipped. "+(Math.ceil(skipVotes[1]/2))+" or more is needed!"; - $("#pBar").addClass("opacityFull"); + document.getElementById("eBar").innerHTML = "Error: Skipping disabled."; + $("#eBar").addClass("opacityFull"); + }else{ + skipVotes = voteRes.split("/"); + if(skipVotes[0]>= skipVotes[1]/2) + { + document.getElementById("sBar").innerHTML = "Successfully skipped!"; + $("#sBar").addClass("opacityFull"); + }else + { + document.getElementById("pBar").innerHTML = "Vote registrated! "+skipVotes[0]+" of "+skipVotes[1]+" has skipped. "+(Math.ceil(skipVotes[1]/2))+" or more is needed!"; + $("#pBar").addClass("opacityFull"); + } } - setTimeout(function(){ $("#search").removeClass("success"); $("#sBar").removeClass("opacityFull"); $("#pBar").removeClass("opacityFull"); + $("#eBar").removeClass("opacityFull"); },1500); + } function show(){ diff --git a/php/change.php b/php/change.php index d0011f8f..42f2b5e5 100755 --- a/php/change.php +++ b/php/change.php @@ -8,7 +8,7 @@ if($list[1]==""||!isset($list[1])||count($list)<=1)$list="videos"; else $list = preg_replace('/[^\da-z=?]/i', '', urldecode($list[1])); $list="../lists/".$list.".json"; //actually setting the list for the target. Under is the array for an empty list being created -$array = array("nowPlaying" => array("30H2Z8Lr-4c" => array("id" => "30H2Z8Lr-4c", "title" => "Empty Channel, search to add a video")), "songs" => array(), "conf" => array("startTime" => time(), "views" => array(), "skips" => array(), "vote" => "false", "addsongs" => "false", "longsongs" => "true", "frontpage" => "true", "allvideos" => "true", "removeplay" => "false", "adminpass" => "")); +$array = array("nowPlaying" => array("30H2Z8Lr-4c" => array("id" => "30H2Z8Lr-4c", "title" => "Empty Channel, search to add a video")), "songs" => array(), "conf" => array("startTime" => time(), "views" => array(), "skips" => array(), "vote" => "false", "addsongs" => "false", "longsongs" => "true", "frontpage" => "true", "allvideos" => "true", "removeplay" => "false", "skip" => "true", "adminpass" => "")); $array = json_encode($array); //encoding the array $f = @fopen($list,"x"); //opening a file, ignoring warnings if($f){ fwrite($f,$array); fclose($f); } //if the file doesn't exist, we create a new one, and adds the newly made array there @@ -124,7 +124,7 @@ else if(isset($_GET['v'])){ //if it $name = htmlspecialchars($_GET['n']); //name of the video if($np[0]["id"] == "30H2Z8Lr-4c") { - $q = array("nowPlaying" => array($video => array("id" => $video, "title" => $name, "votes" => 0, "added" => time(), "guids" => array())), "songs" => array(), "conf" => array("startTime" => time(), "views" => array(), "skips" => array(), "vote" => "false", "addsongs" => "false", "longsongs" => "true", "frontpage" => "true", "allvideos" => "true", "removeplay" => "false", "adminpass" => "")); + $q = array("nowPlaying" => array($video => array("id" => $video, "title" => $name, "votes" => 0, "added" => time(), "guids" => array())), "songs" => array(), "conf" => array("startTime" => time(), "views" => array(), "skips" => array(), "vote" => "false", "addsongs" => "false", "longsongs" => "true", "frontpage" => "true", "allvideos" => "true", "removeplay" => "false", "skip" => "true", "adminpass" => "")); //$q = array("nowPlaying" => array($video => array("id" => $video, "title" => $name, "votes" => 0, "added" => time(), "guids" => array())), "songs" => array(), "conf" => array("startTime" => time(), "views" => array(), "skips" => array())); $q["nowPlaying"][$video]["votes"] = 1; //Upping the votes, so it comes further up than the ones already played array_push($q["nowPlaying"][$video]["guids"], $guid); @@ -210,9 +210,11 @@ else if(isset($_GET['vote'])){ //if th } } else if(isset($_GET['skip'])){ //skip, really similar to the save function, not going in depth here. - $viewers=count($data["conf"]["views"]); + $q = $data["conf"]; + $q = array_key_exists("skip", $q); + $viewers=count($data["conf"]["views"]); $skips=count($data["conf"]["skips"]); //Counting how many GUIDS there are under the skip key - if(!in_array($guid, $data["conf"]["skips"])){ //If the users GUID isn't in the array, its added + if(!in_array($guid, $data["conf"]["skips"]) && ($data["conf"]["skip"] == "true" || $q != 1)){ //If the users GUID isn't in the array, its added array_push($data["conf"]["skips"], $guid); $skips+=1; //and the number of skips is upped //$data["conf"]["skips"]=$skips; @@ -236,8 +238,11 @@ else if(isset($_GET['skip'])){ //skip, array_multisort($sort['votes'], SORT_DESC, $sort['added'], SORT_ASC, $data["songs"]); } file_put_contents($list, json_encode($data)); - } - echo($skips."/".$viewers); //always printing out the skip/viewer ratio + echo($skips."/".$viewers); + }else if($data["conf"]["skip"] == "false") + { + echo("wrong!"); + } }else if(isset($_POST['conf'])) //conf, this is for admin settings/channel settings { @@ -247,6 +252,7 @@ else if(isset($_GET['skip'])){ //skip, $data["conf"]["frontpage"] = $_POST['frontpage']; $data["conf"]["allvideos"] = $_POST['allvideos']; $data["conf"]["removeplay"] = $_POST['removeplay']; + $data["conf"]["skip"] = $_POST['skip']; $pass = htmlspecialchars($_POST['pass']); if($pass != ""){ $x = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"]))); diff --git a/php/panel.php b/php/panel.php index d9186789..d4a37cf0 100755 --- a/php/panel.php +++ b/php/panel.php @@ -5,33 +5,37 @@
- / - + / +
- / - + / +
- / - + / +
- / - + / +
- / - + / +
- / - + / + +
+
+ / +
@@ -42,6 +46,7 @@ long songs
categories allowed
songs after playing
+ skipping
diff --git a/static/style.css b/static/style.css index 7cf8d51e..9725b33c 100755 --- a/static/style.css +++ b/static/style.css @@ -444,7 +444,7 @@ input[type="radio"] { #adminPanel { border-bottom:none; color:#fff; - height:230px; + height:250px; padding:10px; overflow:hidden; background-color:rgba(0,0,0,0.2);