Created
August 18, 2009 15:33
-
-
Save andyed/169784 to your computer and use it in GitHub Desktop.
Kiosk TabRotater JetPack
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 | |
var tabDelaySeconds = 40; | |
var interval= false; | |
var curTab= 0; | |
var widgetHandle = false; | |
jetpack.statusBar.append({ | |
html: "<span id='cycleStats' style='font-variant:smallcaps;font-size:8px;'><img src='data:image/gif;base64,R0lGODlhEAAQALMAAKWfkNfVycXDtejm4LaypM3Ive/v5+De062pmrm4q/X17+Xi1srIuN/czs/NvqaikyH5BAAHAP8ALAAAAAAQABAAAASE0AlCkr2XCJdEM8YgjmIgJE+hKCA4cMZaAIDKgpIzgMpct6CTbmfwFYBFC2EBMoICh0FDMOg0Hw+GKOFYHBiLBkLEwAoWCwT0wA4gDguBGU1gsNkTuPxxjqvZDghdcXNeCQgUBAVshHxobRsNd419DZaXl3E0XA6dnp8OBAAMpKWmpwwRADs=' width='16' height='16' vspace='2'></span>", | |
width: 45, | |
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