Added shuffle option

This commit is contained in:
KasperRT
2015-03-24 11:11:26 +01:00
parent 08bde98224
commit d50f193426
7 changed files with 67 additions and 60 deletions

View File

@@ -11,7 +11,7 @@ function admin()
eH = -10; eH = -10;
}else }else
eH = 30; eH = 30;
$("#playlist").height($("#player").height()-270+eH); //opening $("#playlist").height($("#player").height()-290+eH); //opening
}else if(!adminTogg) }else if(!adminTogg)
{ {
if(find) if(find)
@@ -35,13 +35,13 @@ function submitAdmin(form)
removeplay = form.removeplay.value; removeplay = form.removeplay.value;
adminpass = form.pass.value; adminpass = form.pass.value;
skipping = form.skip.value; skipping = form.skip.value;
shuffling = form.shuffle.value;
confRes = $.ajax({ confRes = $.ajax({
type: "POST", type: "POST",
url: "php/change.php", url: "php/change.php",
async: false, async: false,
data: "conf=start&vote="+voting+"&addsongs="+addsongs+"&longsongs="+longsongs+"&frontpage="+frontpage+"&allvideos="+allvideos+"&removeplay="+removeplay+"&pass="+adminpass+"&skip="+skipping, data: "conf=start&vote="+voting+"&addsongs="+addsongs+"&longsongs="+longsongs+"&frontpage="+frontpage+"&allvideos="+allvideos+"&removeplay="+removeplay+"&pass="+adminpass+"&skip="+skipping+"&shuffle="+shuffling,
success: function() { success: function() {
console.log("configurations response: "+response); console.log("configurations response: "+response);

View File

@@ -86,7 +86,7 @@ function updateList()
} }
if(!adminTogg) if(!adminTogg)
{ {
names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip"]; names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip", "shuffle"];
for (var i = 0; i < names.length; i++) { for (var i = 0; i < names.length; i++) {
document.getElementsByName(names[i])[0].checked = (conf[names[i]] === "true"); document.getElementsByName(names[i])[0].checked = (conf[names[i]] === "true");
document.getElementsByName(names[i])[1].checked = (conf[names[i]] === "false"); document.getElementsByName(names[i])[1].checked = (conf[names[i]] === "false");

0
js/searchlist.js Normal file → Executable file
View File

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])); 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 $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", "skip" => "true", "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", "shuffle" => "false", "adminpass" => ""));
$array = json_encode($array); //encoding the array $array = json_encode($array); //encoding the array
$f = @fopen($list,"x"); //opening a file, ignoring warnings $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 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
@@ -24,7 +24,7 @@ $save = false; //declares t
if(isset($_REQUEST['shuffle'])){ //shuffle songs in list if(isset($_REQUEST['shuffle'])){ //shuffle songs in list
$q = $data["conf"]; $q = $data["conf"];
$q = array_key_exists("adminpass", $q); $q = array_key_exists("shuffle", $q);
$pass = htmlspecialchars($_GET['pass']); $pass = htmlspecialchars($_GET['pass']);
$x = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"]))); $x = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"])));
if($pass != "") if($pass != "")
@@ -32,7 +32,8 @@ if(isset($_REQUEST['shuffle'])){ //shuffle songs in list
if(sizeof($data["songs"]) == 0){ if(sizeof($data["songs"]) == 0){
die("size"); die("size");
} }
if($pass == $data["conf"]["adminpass"] || $data["conf"]["adminpass"] == "") { if($pass == $data["conf"]["adminpass"] || $data["conf"]["adminpass"] == "" || $q != 1
|| $data["conf"]["shuffle"] == "true") {
//shuffle($data["songs"]); //shuffle($data["songs"]);
foreach($data["songs"] as $k=>$v) { foreach($data["songs"] as $k=>$v) {
@@ -124,7 +125,7 @@ else if(isset($_GET['v'])){ //if it
$name = htmlspecialchars($_GET['n']); //name of the video $name = htmlspecialchars($_GET['n']); //name of the video
if($np[0]["id"] == "30H2Z8Lr-4c") 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", "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(), "vote" => "false", "addsongs" => "false", "longsongs" => "true", "frontpage" => "true", "allvideos" => "true", "removeplay" => "false", "skip" => "true", "shuffle" => "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())); //$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 $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); array_push($q["nowPlaying"][$video]["guids"], $guid);
@@ -253,6 +254,7 @@ else if(isset($_GET['skip'])){ //skip,
$data["conf"]["allvideos"] = $_POST['allvideos']; $data["conf"]["allvideos"] = $_POST['allvideos'];
$data["conf"]["removeplay"] = $_POST['removeplay']; $data["conf"]["removeplay"] = $_POST['removeplay'];
$data["conf"]["skip"] = $_POST['skip']; $data["conf"]["skip"] = $_POST['skip'];
$data["conf"]["shuffle"] = $_POST['shuffle'];
$pass = htmlspecialchars($_POST['pass']); $pass = htmlspecialchars($_POST['pass']);
if($pass != ""){ if($pass != ""){
$x = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"]))); $x = explode("/", htmlspecialchars(strtolower($_SERVER["REQUEST_URI"])));

View File

@@ -37,6 +37,10 @@
<label><input type="radio" class="radio" name="skip" value="true"><span>Allow</span></label> / <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> <label><input type="radio" class="radio" name="skip" value="false"><span>Block</span></label>
</div> </div>
<div class="toggler">
<label><input type="radio" class="radio" name="shuffle" value="true"><span>Allow</span></label> /
<label><input type="radio" class="radio" name="shuffle" value="false"><span>Block</span></label>
</div>
</div> </div>
<div class="toggtext"> <div class="toggtext">
@@ -47,6 +51,7 @@
categories allowed<br> categories allowed<br>
songs after playing<br> songs after playing<br>
skipping<br> skipping<br>
shuffle<br>
</div> </div>
<input type="password" name="pass" id="passbox" class="passbox" placeholder="Password"> <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"> <input type="submit" class="button" value="Login/Save" onclick="submitAdmin(this.form);" title="Save settings/Login">

0
static/google_play.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@@ -495,7 +495,7 @@ input[type="radio"] {
#adminPanel { #adminPanel {
border-bottom:none; border-bottom:none;
color:#fff; color:#fff;
height:250px; height:270px;
padding:10px; padding:10px;
overflow:hidden; overflow:hidden;
background-color:rgba(0,0,0,0.2); background-color:rgba(0,0,0,0.2);