Add setting to disable or enable skipping. Default is enabled

This commit is contained in:
KasperRT
2015-02-19 16:56:36 +01:00
parent d189b8ea18
commit 3674822d64
5 changed files with 50 additions and 32 deletions

View File

@@ -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);

View File

@@ -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(){

View File

@@ -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"])));

View File

@@ -5,33 +5,37 @@
<form id="adminForm" onsubmit="return false" name="ufo" action="" class="daform nomargin" id="base">
<div class="toggles">
<div class="toggler">
<label><input type="radio" class="radio"name="frontpage" value="true"><span>Display</span></label> /
<label><input type="radio" class="radio"name="frontpage" value="false"><span>Hide</span></label>
<label><input type="radio" class="radio" name="frontpage" value="true"><span>Display</span></label> /
<label><input type="radio" class="radio" name="frontpage" value="false"><span>Hide</span></label>
</div>
<div class="toggler">
<label><input type="radio" class="radio"name="vote" value="true"><span>Admin</span></label> /
<label><input type="radio" class="radio"name="vote" value="false"><span>Anyone</span></label>
<label><input type="radio" class="radio" name="vote" value="true"><span>Admin</span></label> /
<label><input type="radio" class="radio" name="vote" value="false"><span>Anyone</span></label>
</div>
<div class="toggler">
<label><input type="radio" class="radio"name="addsongs" value="true"><span>Admin</span></label> /
<label><input type="radio" class="radio"name="addsongs" value="false"><span>Anyone</span></label>
<label><input type="radio" class="radio" name="addsongs" value="true"><span>Admin</span></label> /
<label><input type="radio" class="radio" name="addsongs" value="false"><span>Anyone</span></label>
</div>
<div class="toggler">
<label><input type="radio" class="radio"name="longsongs" value="true"><span>Allow</span></label> /
<label><input type="radio" class="radio"name="longsongs" value="false"><span>Block</span></label>
<label><input type="radio" class="radio" name="longsongs" value="true"><span>Allow</span></label> /
<label><input type="radio" class="radio" name="longsongs" value="false"><span>Block</span></label>
</div>
<div class="toggler">
<label><input type="radio" class="radio"name="allvideos" value="true"><span>All</span></label> /
<label><input type="radio" class="radio"name="allvideos" value="false"><span>Song</span></label>
<label><input type="radio" class="radio" name="allvideos" value="true"><span>All</span></label> /
<label><input type="radio" class="radio" name="allvideos" value="false"><span>Song</span></label>
</div>
<div class="toggler">
<label><input type="radio" class="radio"name="removeplay" value="true"><span>Remove</span></label> /
<label><input type="radio" class="radio"name="removeplay" value="false"><span>Keep</span></label>
<label><input type="radio" class="radio" name="removeplay" value="true"><span>Remove</span></label> /
<label><input type="radio" class="radio" name="removeplay" value="false"><span>Keep</span></label>
</div>
<div class="toggler">
<label><input type="radio" class="radio" name="skip" value="true"><span>Allow</span></label> /
<label><input type="radio" class="radio" name="skip" value="false"><span>Block</span></label>
</div>
</div>
@@ -42,6 +46,7 @@
<span title="(>12 min)">long songs</span><br>
categories allowed<br>
songs after playing<br>
skipping<br>
</div>
<input type="password" name="pass" id="passbox" class="passbox" placeholder="Password">
<input type="submit" class="button" value="Login/Save" onclick="submitAdmin(this.form);" title="Save settings/Login">

View File

@@ -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);