--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/volume.js Sun Mar 23 20:24:33 2008 -0400
@@ -0,0 +1,65 @@
+/**
+ * Volume widget presentation code
+ *
+ * Web control interface script for Amarok
+ * Written by Dan Fuhry - 2008
+ *
+ * This script is in the public domain. Use it for good, not evil.
+ */
+
+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;
+ }
+ }
+ });
+}
+