Created
December 16, 2009 02:30
-
-
Save andyed/257534 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
@author: Andy Edmonds | |
@url: http://www.uxagile.com | |
@update: http://uxagile.com/kiosk-tab-rotator-jetpack-for-firefox/ | |
@title: Jetpack Kiosk Tab Rotator | |
@description: For you information radiator screens | |
@license: MPL | |
*/ | |
// TODO | |
// Auto cancel when user interacts with page | |
// Provide ability to set delay | |
// Update state upon pause/resume in jetpack bar | |
// Latest developments at http://gist.github.com/169784 | |
// Stable version http://gist.github.com/gists/257534 | |
var tabDelaySeconds = 40; | |
var interval= false; | |
var curTab= 0; | |
var widgetHandle = false; | |
jetpack.statusBar.append({ | |
html: "<span id='cycleStats'><img id='tabRotateLogo' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTM5jWRgMAAAAVdEVYdENyZWF0aW9uIFRpbWUAOC8xOS8wORM0srMAAAHWSURBVDiNlZLdThNBGIaf2d/uCmkrFFJqAMGAqQcQEhM89Bq9Aw+8Bm/ARI0xmBBPlBRL2zS23aV/u53dHdaDjZB2i8T3bCbP9877vRnx7u2bvVK5fEEKALpl85BUJBGahu8NnhjuyuqFpmkUCgWOTl4BIEO5MJIC4vb088c5vj/AfbTS0oLJmMraJi9PX2NZBQBsx8Z2bIR2A6SMhj3Ozj5hOzarxSJHJ6dUN2tMR0OMVKl7o46uBwy8AWEYUK8fAxBFMyyrgBBZIuMvHEWznEGjcYFKBbs721iWhQwltmPPsdq/ylorVxACmlctvn75gEqCHJMz6HaaDP0+MpQ8Xi+j4ogX9WN0y+byV2OOFbqOJnQdRYwMJTKUNK+a+H4PlQQIzcR1HSI54eDZPt1O+5ZTxHcJ4lihkgCVBIyvPSzLIU6ycp/uHaLpBjOZDcxmY1QSEMdq+QqmaTEaebldPa+P47gPd7C+sUGn1SYM7wrz/R7dTptqbQvT0Od4Y9GgVttmMg34fv5t7sXdnX3K5QpxouZMcgYAhwfPCcMAz+vjug6lYgmhmcvQvEF6k5VVsE22qtXcfaYsQapU9pUn04Dfve7SF+7T0PcBEJ8/vk//a3JBfwADJstrx0pPAgAAAABJRU5ErkJggg==' width='16' height='16' vspace='2'></span>", | |
width: 16, | |
onReady: function(widget){ | |
widgetHandle = widget; | |
$(widget).click(function(){ | |
cycleInit(); | |
}); | |
}, | |
}); | |
function cycleInit() { | |
if(!interval) { | |
jetpack.notifications.show( "Rotating tab to:" + this.curTab ); | |
interval = setInterval( cycle, 1000*tabDelaySeconds ); | |
//$("#cycleStatus", widgetHandle).html("CYCLING") | |
var doc = jetpack.tabs.focused.contentDocument; | |
//doc.addEventListener("mousemove", cancelCycle) | |
} else { | |
jetpack.notifications.show( "Ending Tab Rotation"); | |
interval = clearInterval(interval); | |
//console.log($(widgetHandle)); | |
} | |
} | |
function cycle(){ | |
var doc = jetpack.tabs.focused.contentDocument; | |
//doc.removeEventListener("mousemove", cancelCycle) | |
if(this.curTab<jetpack.tabs.length ) { | |
this.curTab++; | |
} else { | |
this.curTab = 0; | |
} | |
jetpack.notifications.show( "Rotating tab to:" + this.curTab ); | |
jetpack.tabs[curTab].focus(); | |
}; | |
function cancelCycle () { | |
interval = clearInterval(interval); | |
var doc = jetpack.tabs.focused.contentDocument; | |
//doc.removeEventListener("mousemove", cancelCycle) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment