$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
authorDan
Sun, 23 Mar 2008 20:58:51 -0400
changeset 3 e7447a6044ec
parent 2 860ba7141641
child 4 cde92f6ec29f
$allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon
ajax.php
amarok_icon.ico
apple-touch-icon.png
playlist.php
scripts/ajax.js
themes/funkymonkey/playlist.tpl
webcontrol.php
--- a/ajax.php	Sun Mar 23 20:24:33 2008 -0400
+++ b/ajax.php	Sun Mar 23 20:58:51 2008 -0400
@@ -32,7 +32,7 @@
 
 function ajax_request_handler($httpd)
 {
-  global $playlist, $mime_types, $json;
+  global $playlist, $mime_types, $json, $allowcontrol;
   
   // Set content type
   $httpd->header("Content-type: {$mime_types['js']}");
@@ -51,12 +51,18 @@
     case 'stop':
     case 'next':
     case 'prev':
+      if ( !$allowcontrol )
+        return false;
       echo dcop_action('player', 'stop');
       break;
     case 'play':
+      if ( !$allowcontrol )
+        return false;
       echo dcop_action('player', 'playPause');
       break;
     case 'jump':
+      if ( !$allowcontrol )
+        return false;
       $tid =& $params[1];
       if ( !preg_match('/^[0-9]+$/', $tid) )
       {
@@ -71,6 +77,8 @@
       echo $json->encode($return);
       break;
     case 'volume':
+      if ( !$allowcontrol )
+        return false;
       $volume =& $params[1];
       if ( !preg_match('/^[0-9]+$/', $volume) )
       {
Binary file amarok_icon.ico has changed
Binary file apple-touch-icon.png has changed
--- a/playlist.php	Sun Mar 23 20:24:33 2008 -0400
+++ b/playlist.php	Sun Mar 23 20:58:51 2008 -0400
@@ -11,7 +11,7 @@
 
 function amarok_playlist($server)
 {
-  global $smarty, $theme, $playlist;
+  global $smarty, $theme, $playlist, $allowcontrol;
   
   $active = dcop_action('playlist', 'getActiveIndex');
   $smarty->assign('theme', $theme);
@@ -22,6 +22,7 @@
       'domutils.js',
       'volume.js'
     ));
+  $smarty->assign('allow_control', $allowcontrol);
   $smarty->display('playlist.tpl');
 }
 
--- a/scripts/ajax.js	Sun Mar 23 20:24:33 2008 -0400
+++ b/scripts/ajax.js	Sun Mar 23 20:58:51 2008 -0400
@@ -66,11 +66,13 @@
 function setAjaxLoading()
 {
   $('ajax_status').object.src = img_ajax;
+  $('ajax_status').object.style.display = 'block';
 }
 
 function unsetAjaxLoading()
 {
   $('ajax_status').object.src = 'about:blank';
+  $('ajax_status').object.style.display = 'none';
 }
 
 var refresh_playlist = function()
@@ -111,15 +113,18 @@
           }
         }
         // update playing status
-        var img = $('btn_playpause').object.getElementsByTagName('img')[0];
         is_playing = response.is_playing;
-        if ( is_playing )
+        if ( allow_control )
         {
-          img.src = img_pause;
-        }
-        else
-        {
-          img.src = img_play;
+          var img = $('btn_playpause').object.getElementsByTagName('img')[0];
+          if ( is_playing )
+          {
+            img.src = img_pause;
+          }
+          else
+          {
+            img.src = img_play;
+          }
         }
         // update volume
         if ( response.volume != current_volume )
@@ -166,6 +171,8 @@
   setAjaxLoading();
   if ( tid == current_track )
     return false;
+  if ( !allow_control )
+    return false;
   ajaxGet('/action.json/jump/' + tid, function()
     {
       if ( ajax.readyState == 4 && ajax.status == 200 )
--- a/themes/funkymonkey/playlist.tpl	Sun Mar 23 20:24:33 2008 -0400
+++ b/themes/funkymonkey/playlist.tpl	Sun Mar 23 20:58:51 2008 -0400
@@ -12,11 +12,13 @@
     <title>AmaroK playlist</title>
     <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
     <link rel="stylesheet" type="text/css" href="/themes/{$theme|escape}/style.css" />
+    <link rel="favorite icon" type="image/ico" href="/favicon.ico" />
     <script type="text/javascript">
     var img_play = '/themes/{$theme|escape}/images/play.png';
     var img_pause = '/themes/{$theme|escape}/images/pause.png';
     var img_ajax = '/themes/{$theme|escape}/images/ajax.gif';
     var class_current = 'current';
+    var allow_control = {if $allow_control}true{else}false{/if};
     </script>
     {foreach from=$scripts item=script}
     <script type="text/javascript" src="/scripts/{$script}"></script>
@@ -25,14 +27,17 @@
   <body>
     <div id="playbar">
       <div class="playbar-inner">
-        <img alt=" " id="ajax_status" style="display: block; float: right; margin: 3px 0;" src="about:blank" />
+        <img alt=" " id="ajax_status" style="display: none; float: right; margin: 3px 0;" src="about:blank" />
         <img alt="AmaroK web control" src="/themes/{$theme|escape}/images/amarok.gif" style="margin-right: 20px;" />
+        {if $allow_control}
         <a href="#action:prev" onclick="player_action('prev'); return false;"><img alt="&laquo; PrevTrk" src="/themes/{$theme|escape}/images/prev.png" /></a>
         <a href="#action:play" onclick="player_action('play'); return false;" id="btn_playpause"><img alt="Play" src="/themes/{$theme|escape}/images/play.png" /></a>
         <a href="#action:stop" onclick="player_action('stop'); return false;"><img alt="Stop" src="/themes/{$theme|escape}/images/stop.png" /></a>
         <a href="#action:next" onclick="player_action('next'); return false;"><img alt="NextTrk &raquo;" src="/themes/{$theme|escape}/images/next.png" /></a>
+        {/if}
         <span style="margin-right: 50px;">&nbsp;</span>
         <span id="playmeter">--:--/--:--</span>
+        {if $allow_control}
         <span style="margin-right: 50px;">&nbsp;</span>
         <img hspace="4" alt="Volume: " src="/themes/{$theme|escape}/images/volume.png" />
         <span id="volume_wrap"><a
@@ -48,6 +53,7 @@
           class="volume_button" href="#volume:90"  onmouseover="volume_over(90);"  onmouseout="volume_out();" id="volbtn_90"  onclick="set_volume(90);  return false;">&nbsp;</a><a
           class="volume_button" href="#volume:100" onmouseover="volume_over(100);" onmouseout="volume_out();" id="volbtn_100" onclick="set_volume(100); return false;">&nbsp;</a>
         </span>
+        {/if}
       </div>
     </div>
     <div class="tblholder" id="playlist">
--- a/webcontrol.php	Sun Mar 23 20:24:33 2008 -0400
+++ b/webcontrol.php	Sun Mar 23 20:58:51 2008 -0400
@@ -54,7 +54,7 @@
 
 // startup webserver
 $ip = ( $public ) ? '0.0.0.0' : '127.0.0.1';
-$port = mt_rand(1025, 65534); // 7447;
+$port = 7447;
 
 try
 {
@@ -66,6 +66,8 @@
   $httpd->add_handler('index', 'function', 'amarok_playlist');
   $httpd->add_handler('action.json', 'function', 'ajax_request_handler');
   $httpd->add_handler('scripts', 'dir', './scripts');
+  $httpd->add_handler('favicon.ico', 'file', './amarok_icon.ico');
+  $httpd->add_handler('apple-touch-icon.png', 'file', './apple-touch-icon.png');
   $httpd->add_handler("themes/$theme", 'dir', "./themes/$theme");
   $httpd->allow_dir_list = true;
   $httpd->default_document = 'index';