// Global volume variables. These get pulled from the PHP config by ajax. var maxVolume = 0; var minVolume = 0; var volFromServer = false; var refreshTimerObj; var gettingSongList = false; var gettingJukeboxList = false; var searchTimeout = null; var queueTarget = 0; $(document).ready(function() { $('#tabs').tabs({ activate: function(event, ui) { if ( ui.newTab.index() == 4 ) { $('#searchbox').val(""); } } }); getVolumeRange(); $('#volume_slider').slider({ animate: "fast", max: maxVolume, min: minVolume, step: 2 }); $('#volume_slider').slider({ change: function(event, ui) { if ( !volFromServer ) { setVolume(); } volFromServer = false; } }); $('#max_btn').click(function() { setSliderVolume(maxVolume); }); $('#min_btn').click(function() { setSliderVolume(minVolume); }); $('#skipsong_btn').click(function() { skipSong($(this)); }); $('#skipsong_playing_btn').click(function() { skipSong($(this)); }); $('#dropsong_btn').click(function() { dropSong($(this)); }); $('#mute_btn').click(function() { toggleMute($(this)); }); $('#mute_playing_btn').click(function() { toggleMute($(this)); }); $('#category_go_btn').click(function() { changeQueue(); }); $('#surpriseme_btn').click(function() { surpriseMe(); }); $('#christmas_btn').click(function() { toggleChristmas($(this)); }); $('#emptyjukebox_btn').click(function() { emptyJukebox($(this)); }); $('#clearsearch_btn').click(function() { $('#searchbox').val(""); }); $('#searchbox').keyup(function() { startSearchTimer(); }); $('#christmas_freq').change(function() { changeChristmasFreq($('#christmas_freq').val()); }); $('#queuetarget_sel').change(function() { changeQueueTarget(); }); $('#newqueue_btn').click(function() { createQueue(); }); $('#led_crazy_btn').click(function() { setPattern("crazy"); }); $('#led_christmas_btn').click(function() { setPattern("christmas"); }); $('#led_julyfourth_btn').click(function() { setPattern("julyfourth"); }); $('#led_easter_btn').click(function() { setPattern("easter"); }); $('#led_halloween_btn').click(function() { setPattern("halloween"); }); $('#led_mellow_btn').click(function() { setPattern("mellow"); }); $('#led_crazymellow_btn').click(function() { setPattern("crazymellow"); }); $('#led_disableauto_btn').click(function() { disableAuto(); }); $('#led_lightsoff_btn').click(function() { lightsOff(); }); $('body').swipe({ swipe:function(event, direction, distance, duration, fingerCount, fingerData) { if ( (direction != "left") && (direction != "right") ) return false; var tabIndex = $('#tabs').tabs('option', 'active'); if ( direction == "right" ) { if ( tabIndex > 0 ) $('#tabs').tabs('option', 'active', tabIndex - 1); $("html, body").animate({ scrollTop: 0}, 200); } else { if ( tabIndex < 4 ) $('#tabs').tabs('option', 'active', tabIndex + 1); $("html, body").animate({ scrollTop: 0}, 200); } }, allowPageScroll: "vertical" }); updateQueueSelects(); getVolume(); toggleMute($(this), 'show'); getSongList(); getQueueTarget(); refreshTimerObj = setInterval('getSongList()', 10000); //document.documentElement.requestFullscreen(); }); function startSearchTimer() { if ( searchTimeout != null ) { clearTimeout(searchTimeout); } searchTimeout = setTimeout(executeSearch, 1000); } function updateQueueSelects() { var surprisemeVal = $("#surpriseme_sel").val(); var queuetargetVal = $("#queuetarget_sel").val(); $.ajax({ url: 'ajax_getqueuelist.php', dataType: 'json', success: function(data, stat, jqo) { $("#queue_sel").html(""); $("#surpriseme_sel").html(""); $("#queuetarget_sel").html(""); jQuery.each( data.queues, function(i, val) { $("#queue_sel").append($('