Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions content/settings.xul
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Licensed under MPL (http://www.mozilla.org/MPL/MPL-1.1.html)
<preference id="pref_refresh" name="tabslideshow.refresh" type="bool" />
<preference id="pref_time" name="tabslideshow.time" type="int" />
<preference id="pref_ignorehidden" name="tabslideshow.ignorehidden" type="bool" />
<preference id="pref_randomorder" name="tabslideshow.randomorder" type="bool" />
</preferences>

<checkbox preference="pref_start" id="pane0_start" label="Begin on startup" />
Expand All @@ -33,6 +34,7 @@ Licensed under MPL (http://www.mozilla.org/MPL/MPL-1.1.html)
<textbox preference="pref_time" id="pane0_time" type="number" maxlength="4"
size="6" min="5" max="1800" />
</hbox>
<checkbox preference="pref_randomorder" id="pane0_randomorder" label="Random tab cycle order" />
</prefpane>

</prefwindow>
Expand Down
22 changes: 21 additions & 1 deletion content/tabslideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var tabslideshow = {
refresh: false,
timer: null,
ignorehidden: true,
randomorder: false,

// initialize the extension
startup: function()
Expand All @@ -36,6 +37,7 @@ var tabslideshow = {
this.delay = this.prefs.getIntPref('time');
this.refresh = this.prefs.getBoolPref('refresh');
this.ignorehidden = this.prefs.getBoolPref('ignorehidden');
this.randomorder = this.prefs.getBoolPref('randomorder');

// add tab context menu entries and hook
var tabmenu = tabslideshow_gettabcontextmenu();
Expand Down Expand Up @@ -95,6 +97,9 @@ var tabslideshow = {
case 'ignorehidden':
this.ignorehidden = this.prefs.getBoolPref('ignorehidden');
break;
case 'randomorder':
this.randomorder = this.prefs.getBoolPref('randomorder');
break;
}
},

Expand Down Expand Up @@ -172,7 +177,22 @@ var tabslideshow = {
var currenttab = gBrowser.tabContainer.childNodes[currenttabnum];

// cycle all tabs or current tab group to find next viable tab
var nexttabnum = (currenttabnum + 1) % numtabs;
var nexttabnum;
if(this.randomorder)
{
if(numtabs === 1)
nexttabnum = 0;
else
{
do
{
nexttabnum = Math.floor((Math.random() * numtabs));

}while(nexttabnum === currenttabnum);
}
}
else
nexttabnum = (currenttabnum + 1) % numtabs;
var nexttab = gBrowser.tabContainer.childNodes[nexttabnum];
while (nexttab != currenttab && this.ignorehidden && nexttab.hidden) {
nexttabnum = (nexttabnum + 1) % numtabs;
Expand Down
1 change: 1 addition & 0 deletions defaults/preferences/tabslideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pref("tabslideshow.start", false);
pref("tabslideshow.refresh", false);
pref("tabslideshow.time", 30);
pref("tabslideshow.ignorehidden", true);
pref("tabslideshow.randomorder", false);