# HG changeset patch # User Dan # Date 1206320331 14400 # Node ID e7447a6044ec0021cd68f68dbf9121e2f09f9f57 # Parent 860ba7141641b006431ca97be3c3cd5278aaaa37 $allowcontrol = false working and turned on now; switched default port back to 7447 instead of random; added favicon and apple-touch-icon diff -r 860ba7141641 -r e7447a6044ec ajax.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) ) { diff -r 860ba7141641 -r e7447a6044ec amarok_icon.ico Binary file amarok_icon.ico has changed diff -r 860ba7141641 -r e7447a6044ec apple-touch-icon.png Binary file apple-touch-icon.png has changed diff -r 860ba7141641 -r e7447a6044ec playlist.php --- 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'); } diff -r 860ba7141641 -r e7447a6044ec scripts/ajax.js --- 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 ) diff -r 860ba7141641 -r e7447a6044ec themes/funkymonkey/playlist.tpl --- 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 @@ AmaroK playlist + {foreach from=$scripts item=script} @@ -25,14 +27,17 @@
-  + AmaroK web control + {if $allow_control} « PrevTrk Play Stop NextTrk » + {/if}   --:--/--:-- + {if $allow_control}   Volume:    + {/if}
diff -r 860ba7141641 -r e7447a6044ec webcontrol.php --- 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';