From 461b0862134ec2d71fcb3759fbd2b4a43b045321 Mon Sep 17 00:00:00 2001 From: ands <ands@andspad.(none)> Date: Sat, 18 Dec 2010 19:00:53 +0100 Subject: [PATCH] Added Jukezone widget --- webroot/config.php | 2 +- webroot/css/widget_dark.css | 82 +++++++++++++++++++++++++ webroot/index.php | 2 +- webroot/widgets/Jukezone/Jukezone.js | 68 ++++++++++++++++++++ webroot/widgets/Jukezone/Jukezone.php | 21 +++++++ webroot/widgets/Jukezone/ajax.php | 12 ++++ webroot/widgets/ZoneOffen/ZoneOffen.php | 3 +- 7 files changed, 187 insertions(+), 3 deletions(-) create mode 100644 webroot/widgets/Jukezone/Jukezone.js create mode 100644 webroot/widgets/Jukezone/Jukezone.php create mode 100644 webroot/widgets/Jukezone/ajax.php diff --git a/webroot/config.php b/webroot/config.php index ba2d461..b48d05e 100644 --- a/webroot/config.php +++ b/webroot/config.php @@ -13,7 +13,7 @@ array("Wettervorhersage", "widget_light", 3,1, 1,2), array("TwitterWall", "widget_light", 4,1, 2,4), array("Prepaid", "widget_light", 0,3, 2,3), - array("Dummy", "widget_dark", 2,3, 2,2), + array("Jukezone", "widget_dark", 2,3, 2,2), array("Dummy", "widget_light", 2,5, 2,1), array("Marvin", "widget_light", 4,5, 2,1) ); diff --git a/webroot/css/widget_dark.css b/webroot/css/widget_dark.css index a94e660..b2e4999 100644 --- a/webroot/css/widget_dark.css +++ b/webroot/css/widget_dark.css @@ -10,6 +10,82 @@ color:#ffffff; cursor:default; } + +.widget_dark .invisiblebox { + font-family: inherit; + margin: 10; + padding: 0; + cursor:default; +} + +.widget_dark .table { + border: 1px dashed #F2EFE5; + background-color:#261C13; + font-family: inherit; + margin: 0; + padding: 2; + cursor:default; +} + +.widget_dark .box { + background-color:#261C13; + border: 1px dashed #F2EFE5; + font-family: inherit; + color:#ffffff; + margin: 10; + position:relative; + cursor:default; +} + +.widget_dark h1 { + margin-top: 10; + margin-left: 10; + margin-bottom: 0; + padding: 0; + font-family: inherit; + font-size: 1.0em; + cursor:default; +} +.widget_dark h2 { + margin: 0; + padding: 0; + font-family: inherit; + font-size: 0.8em; + color: #dddddd; + cursor:default; +} +.widget_dark h3 { + margin: 0; + padding: 0; + font-family: inherit; + font-size: 0.6em; + color: #bbbbbb; + cursor:default; +} + +.widget_dark ul { + background-color:#261C13; + margin: 0; + padding: 0; + list-style: none; + overflow:hidden; + position:relative; + height:auto; + cursor:default; +} +.widget_dark li { + background-color:#261C13; + float: left; + border-bottom: 1px dashed #F2EFE5; + width: 100%; + color: #999999; + cursor:default; +} +.widget_dark li img { + padding: 4; + cursor:default; +} + .widget_dark a, .widget_dark a:hover, .widget_dark a:visited, .widget_dark a:active { text-decoration:none; font-family: inherit; @@ -18,3 +94,9 @@ color: #aaaaaa; cursor:default; } + +.widget_dark img +{ + float:left; + cursor:default; +} diff --git a/webroot/index.php b/webroot/index.php index 382148f..83e3773 100644 --- a/webroot/index.php +++ b/webroot/index.php @@ -23,7 +23,7 @@ include_once "widgets/$widgetname/$widgetname.php"; $widget = new $widgetname($widgetsizex,$widgetsizey); $widgetoutput = $widget->giveOutput(); - print("<div id='$widgetname' class='$widgetclass' + print("<div class='$widgetclass' style='position:absolute; left:".$widgetposx."px;top:".$widgetposy."px; width:".$widgetsizex."px;height:".$widgetsizey."px;'>"); diff --git a/webroot/widgets/Jukezone/Jukezone.js b/webroot/widgets/Jukezone/Jukezone.js new file mode 100644 index 0000000..01b8af3 --- /dev/null +++ b/webroot/widgets/Jukezone/Jukezone.js @@ -0,0 +1,68 @@ +function fillJukezone(response) { + var content = '<table class="box" align="center" width="95%">'; + content += '<tr><td width="30%"><h2>Status:</h2></td><td style="color:00aa00">Online</td></tr>'; + + content += '<tr><td width="30%"><h2>Volume:</h2></td><td>'; + content += '<table cellspacing="0" cellpadding="0"><tr>'; + content += '<td>[</td>'; + for(var i=0;i<response['volume'];i+=2) + content += '<td onclick="setVolume('+i+')">:</td>'; + content += '<td><b>||</b></td>'; + for(var i=response['volume']+2;i<=100;i+=2) + content += '<td onclick="setVolume('+i+')">:</td>'; + content += '<td>]</td>'; + content += '</tr></table>'; + content += '</td></tr>'; + + content += '<tr><td width="30%" valign="top"><h2>Streams:</h2></td><td><table>'; + var i=0; + $.each(response['streams'], function(k,v) { + if(response['nowplaying']==i) + content += '<tr><td><h2>[</h2></td><td><h2 onclick="playStream(\''+v+'\')">'+k+'</h2></td><td><h2>]</h2></td></tr>'; + else + content += '<tr><td></td><td><h2 onclick="playStream(\''+v+'\')">'+k+'</h2></td><td></td></tr>'; + i++; + }); + content += '</table></td></tr>'; + + content += '</table>'; + $("#Jukezone").html(content); +} + +function resetJukezone() { + var content = '<table class="box" style="align:center;width:95%;">'; + content += '<tr><td width="30%"><h2>Status:</h2></td><td style="color:aa0000">Offline</td></tr>'; + content += '</table>'; + $("#Jukezone").html(content); +} + +function setVolume(v) { + $.getJSON("widgets/Jukezone/ajax.php?volume="+v, function (response) + { + fillJukezone(response); + }); +} + +function playStream(v) { + $.getJSON("widgets/Jukezone/ajax.php?play="+v, function (response) + { + fillJukezone(response); + }); +} + +function updateJukezone() { + $.getJSON("widgets/Jukezone/ajax.php", function (response) + { + fillJukezone(response); + }); +} + +$(document).ready(function() + { + addFunctionToMinuteTimer(updateJukezone); + resetJukezone(); + updateJukezone(); + } +); + + diff --git a/webroot/widgets/Jukezone/Jukezone.php b/webroot/widgets/Jukezone/Jukezone.php new file mode 100644 index 0000000..1b65797 --- /dev/null +++ b/webroot/widgets/Jukezone/Jukezone.php @@ -0,0 +1,21 @@ +<?php + +require_once 'widgets/iWidget.php'; + +class Jukezone implements iWidget +{ + public function __construct($width, $height) + { + + } + + public function giveOutput() + { + $widgetOutput = '<h1>Jukezone</h1>'."\n"; + $widgetOutput .= '<script src="widgets/Jukezone/Jukezone.js" type="text/javascript"></script>'."\n"; + $widgetOutput .= '<span id="Jukezone"></span>'."\n"; + return $widgetOutput; + } +} + +?> diff --git a/webroot/widgets/Jukezone/ajax.php b/webroot/widgets/Jukezone/ajax.php new file mode 100644 index 0000000..8db34d9 --- /dev/null +++ b/webroot/widgets/Jukezone/ajax.php @@ -0,0 +1,12 @@ +<?php + $requesturl = 'http://192.168.123.104/ajax.php'; + //$requesturl = 'http://10.0.2.70/ajax.php'; + if(isset($_GET["volume"])) + $requesturl .= '?volume='.$_GET["volume"]; + if(isset($_GET["play"])) + $requesturl .= '?play='.$_GET["play"]; + + $httpRequest = new HttpRequest($requesturl, HttpRequest::METH_GET); + $httpRequest->send(); + print($httpRequest->getResponseBody()); +?> diff --git a/webroot/widgets/ZoneOffen/ZoneOffen.php b/webroot/widgets/ZoneOffen/ZoneOffen.php index fe280e4..77f3b3e 100644 --- a/webroot/widgets/ZoneOffen/ZoneOffen.php +++ b/webroot/widgets/ZoneOffen/ZoneOffen.php @@ -13,7 +13,8 @@ class ZoneOffen implements iWidget public function giveOutput() { $widgetOutput = '<script src="widgets/ZoneOffen/ZoneOffen.js" type="text/javascript"></script>'."\n"; - $widgetOutput .= '<center><table width="60%" height="100%" border="0" cellpadding="0" cellspacing="4">'."\n"; + $widgetOutput .= '<h1>Warpzone Live:</h1>'."\n"; + $widgetOutput .= '<center><table width="60%" border="0" cellpadding="0" cellspacing="4">'."\n"; $widgetOutput .= ' <tr>'."\n"; $widgetOutput .= ' <td width="50%" align="right"><b><p>Status: </p><p>Lounge: </p><p>Werkstatt: </p></b></td>'."\n"; $widgetOutput .= ' <td width="50%" align="right"><span id="ZoneOffen_values"><font color="#cc3300"><p>Unbekannt</p><p>Unbekannt</p><p>Unbekannt</p></font></span></td>'."\n"; -- GitLab