public
Last active

  • Download Gist
Jetpack Kiosk Rotator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
/*
@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)
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.