added viewers on hover for the channels

This commit is contained in:
Kasper Rynning-Tønnesen
2015-02-13 12:32:16 +01:00
parent 4300a93361
commit ebdc36d4f7

View File

@@ -11,11 +11,13 @@ $all_channels = array();
$time = 60*60*24*4; //4 dager $time = 60*60*24*4; //4 dager
$to = 60*60*24*2; $to = 60*60*24*2;
$i = 0; $i = 0;
$v = 0;
$tooMany = false; $tooMany = false;
$dir = "./lists"; $dir = "./lists";
chdir($dir); chdir($dir);
array_multisort(array_map('filemtime', ($fil = glob("*.json"))), SORT_DESC, $fil); array_multisort(array_map('filemtime', ($fil = glob("*.json"))), SORT_DESC, $fil);
$viewers = array();
foreach($fil as $files){ foreach($fil as $files){
if(strpos($files, '.json') !== FALSE){ if(strpos($files, '.json') !== FALSE){
@@ -33,6 +35,7 @@ foreach($fil as $files){
$data = json_decode($file, TRUE); $data = json_decode($file, TRUE);
if(!array_key_exists("frontpage", $data['conf']) || $data['conf']['frontpage'] == "true" && $i <= 8){ //If it is true, the channelname will be shown on the frontpage if(!array_key_exists("frontpage", $data['conf']) || $data['conf']['frontpage'] == "true" && $i <= 8){ //If it is true, the channelname will be shown on the frontpage
array_push($channels, ucfirst(str_replace(".json", "", $files))); array_push($channels, ucfirst(str_replace(".json", "", $files)));
array_push($viewers, sizeof($data["conf"]["views"]));
} }
} }
$i++; $i++;
@@ -41,6 +44,8 @@ foreach($fil as $files){
} }
} }
print_r($viewers[$v]);
?> ?>
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml"
@@ -70,7 +75,7 @@ foreach($fil as $files){
</div> </div>
<center> <center>
<div class="channels" id="channels">Active Channels<br> <div class="channels" id="channels">Active Channels<br>
<?php foreach($channels as $channel){echo "<a class='channel' href='./".htmlspecialchars($channel)."'>".htmlspecialchars($channel)."</a>";} ?> <?php foreach($channels as $channel){echo "<a class='channel' href='./".htmlspecialchars($channel)."' title='Viewers: ".$viewers[$v]."'>".htmlspecialchars($channel)."</a>"; $v++;} ?>
</div> </div>
</center> </center>
</div> </div>