Made the webserver a bit smarter. It handles running as root properly (only allows it if user/group specified and port < 1024) and directory listing is massively smarter.
/**
* Volume widget presentation code
*
* Greyhound - real web management for Amarok
* Copyright (C) 2008 Dan Fuhry
*
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
*/
var current_volume = 0;
function set_volume_fill(amount)
{
amount = 10 * ( Math.round(amount / 10) );
if ( amount == 0 )
amount = -10;
for ( var i = 0; i <= amount; i += 10 )
{
if ( !$('volbtn_' + i).hasClass('volume_button_active') )
{
$('volbtn_' + i).addClass('volume_button_active');
}
}
for ( ; i <= 100; i += 10 )
{
if ( $('volbtn_' + i).hasClass('volume_button_active') )
{
$('volbtn_' + i).rmClass('volume_button_active');
}
}
}
function volume_over(amount)
{
set_volume_fill(amount);
}
function volume_out()
{
set_volume_fill(current_volume);
}
function set_volume(level)
{
setAjaxLoading();
if ( level == current_volume )
return false;
ajaxGet('/action.json/volume/' + level, function()
{
if ( ajax.readyState == 4 && ajax.status == 200 )
{
unsetAjaxLoading();
var response = (' ' + ajax.responseText).substr(1);
// quickie JSON parser :)
response = eval('(' + response + ')');
// update volume
if ( response.volume != current_volume )
{
set_volume_fill(response.volume);
current_volume = response.volume;
}
}
});
}