diff --git a/js/iscroll.js b/js/iscroll.js old mode 100755 new mode 100644 diff --git a/js/list.js b/js/list.js old mode 100755 new mode 100644 diff --git a/js/search.js b/js/search.js old mode 100755 new mode 100644 diff --git a/js/visualize.js b/js/visualize.js old mode 100755 new mode 100644 diff --git a/js/youtube.js b/js/youtube.js old mode 100755 new mode 100644 index 0deae4fc..52212c5d --- a/js/youtube.js +++ b/js/youtube.js @@ -41,8 +41,16 @@ $(document).ready(function() }).responseText; //console.log(response); response = $.parseJSON(response); - for(first in response["nowPlaying"]) break; - console.log(first); + console.log(response["nowPlaying"].length); + try{ + for(first in response["nowPlaying"]) break; + console.log(first); + response = first; + }catch(err){ + response = "1"; + } + + $.ajax({ type: 'get', url: 'php/timedifference.php', @@ -54,7 +62,7 @@ $(document).ready(function() }); console.log("timediff:"+timeDifference[0]); - response = first; + tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; diff --git a/php/admin.php b/php/admin.php old mode 100755 new mode 100644 diff --git a/php/change.php b/php/change.php old mode 100755 new mode 100644 index c5a1ace0..e5a2db32 --- a/php/change.php +++ b/php/change.php @@ -14,6 +14,7 @@ else $list=$list[1]; $list="../lists/".$list.".json"; $array = array("nowPlaying" => array(), "songs" => array(), "conf" => array("startTime" => time(), "views" => 0, "skips" => array())); +$array = json_encode($array); $f = @fopen($list,"x"); if($f){ fwrite($f,$array); fclose($f); } $file = file_get_contents($list); @@ -35,10 +36,14 @@ if(isset($_REQUEST['thisUrl'])){ $save = true; //array_shift($data["songs"]); //array_shift($data["nowPlaying"]); - array_shift($data["songs"]); - $data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array()); - array_shift($data["nowPlaying"]); - $data["nowPlaying"][$firstSong[0]["id"]] = array("id" => $firstSong[0]["id"], "title" => $firstSong[0]["title"], "votes" => 0, "added" => $firstSong[0]["added"], "guids" => $firstSong[0]["guids"]); + if(!is_null($np[0]["id"])){ + array_shift($data["songs"]); + $data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array()); + array_shift($data["nowPlaying"]); + $data["nowPlaying"][$firstSong[0]["id"]] = array("id" => $firstSong[0]["id"], "title" => $firstSong[0]["title"], "votes" => 0, "added" => $firstSong[0]["added"], "guids" => $firstSong[0]["guids"]); + + } + //array_push($data["songs"], $add); $data["conf"]["skips"] = array(); $data["conf"]["startTime"] = time(); @@ -53,6 +58,13 @@ if(isset($_REQUEST['thisUrl'])){ array_shift($firstSong[0]); }*/ file_put_contents($list, json_encode($data)); + }else if(is_null($np[0]["id"])) + { + array_shift($data["songs"]); + //$data["songs"][$np[0]["id"]] = array("id" => $np[0]["id"], "title" => $np[0]["title"], "votes" => $np[0]["votes"], "added" => time(), "guids" => array()); + array_shift($data["nowPlaying"]); + $data["nowPlaying"][$firstSong[0]["id"]] = array("id" => $firstSong[0]["id"], "title" => $firstSong[0]["title"], "votes" => 0, "added" => $firstSong[0]["added"], "guids" => $firstSong[0]["guids"]); + } if($action == "save" && !$save) //count views { @@ -67,25 +79,20 @@ else if(isset($_GET['v'])){ //add $name = htmlspecialchars($_GET['n']); if(!in_array($video, $data["songs"])) { - //$arrayAdd = array("id" => array("id" => $video, "title" => $name, "votes" => array())); - //array_push($data[0], $video); - $data["songs"][$video] = array("id" => $video, "title" => $name, "votes" => 0, "added" => time(), "guids" => array()); - $data["songs"][$video]["votes"] = 1; - array_push($data["songs"][$video]["guids"], $guid); + if(count($data["nowPlaying"]) > 0) $place = "songs"; + else $place = "nowPlaying"; + $data[$place][$video] = array("id" => $video, "title" => $name, "votes" => 0, "added" => time(), "guids" => array()); + $data[$place][$video]["votes"] = 1; + array_push($data[$place][$video]["guids"], $guid); $sort = array(); - foreach($data["songs"] as $k=>$v) { - $sort['votes'][$k] = $v['votes']; - $sort['added'][$k] = $v['added']; + if($place != "nowPlaying") + { + foreach($data["songs"] as $k=>$v) { + $sort['votes'][$k] = $v['votes']; + $sort['added'][$k] = $v['added']; + } + array_multisort($sort['votes'], SORT_DESC, $sort['added'], SORT_ASC, $data["songs"]); } - array_multisort($sort['votes'], SORT_DESC, $sort['added'], SORT_ASC, $data["songs"]); - //array_push($data["songs"], $arrayAdd); - /*$i = array_search(0, $data[2]); - if($i == 0)$i=1; - else if($i == false)$i=count($data[2]); - array_splice($data[3], $i, 0, array($name)); - array_splice($data[2], $i, 0, array(1)); - array_splice($data[0], $i, 0, array($video)); - file_put_contents($list, json_encode($data));*/ file_put_contents($list, json_encode($data)); print("added"); } diff --git a/php/convert_lists.php b/php/convert_lists.php old mode 100755 new mode 100644 diff --git a/php/header.php b/php/header.php old mode 100755 new mode 100644 diff --git a/php/index.html b/php/index.html old mode 100755 new mode 100644 diff --git a/php/nochan.php b/php/nochan.php old mode 100755 new mode 100644 index d25ea44e..344a2884 --- a/php/nochan.php +++ b/php/nochan.php @@ -19,7 +19,7 @@ foreach($dir as $files){
Zöff
- + ";} ?> diff --git a/php/timedifference.php b/php/timedifference.php old mode 100755 new mode 100644 diff --git a/php/videos.php b/php/videos.php old mode 100755 new mode 100644