1
0
mirror of https://github.com/MatMoul/quickdial-webext.git synced 2024-12-23 15:36:12 +00:00

Add startpage timeout settings

This commit is contained in:
MatMoul 2019-01-03 21:06:23 +01:00
parent cc1006042d
commit 941772844a
3 changed files with 799 additions and 786 deletions

View File

@ -68,6 +68,10 @@
<td><input id="ButtonOpenInNewPage" type="checkbox"></td> <td><input id="ButtonOpenInNewPage" type="checkbox"></td>
</tr> </tr>
<tr>
<td>Startpage timeout :</td>
<td><input id="StartupTimeout" type="number"></td>
</tr>
</table> </table>

View File

@ -8,22 +8,26 @@ app.init = function(){ // Init module
if(app.settings.openQuickDialInNewPage) browser.tabs.create({}); if(app.settings.openQuickDialInNewPage) browser.tabs.create({});
else browser.tabs.update(e.id, {url: '/dial'}).then(); else browser.tabs.update(e.id, {url: '/dial'}).then();
}); });
app.GridNodes.sync(app.node, app.settings.grid.root, function(){ browser.runtime.sendMessage({ cmd: app.Messages.Commands.gridNodesLoaded });
browser.runtime.sendMessage({ cmd: app.Messages.Commands.gridNodesLoaded }); app.ContextMenus.initMenu();
app.Bookmarks.initListener(); window.setTimeout(function(){
app.ContextMenus.initMenu(); app.GridNodes.sync(app.node, app.settings.grid.root, function(){
}); app.Bookmarks.initListener();
});
}, 500);
// Start page workaround : // Start page workaround :
setTimeout(function(){ if(app.settings.startpageTimeout>0){
browser.tabs.query({}).then( function(tabs) { setTimeout(function(){
tabs.forEach(function(itm){ browser.tabs.query({}).then( function(tabs) {
if(itm.url=='about:blank'){ tabs.forEach(function(itm){
browser.tabs.update(itm.id, {url: browser.extension.getURL('dial')}); if(itm.url=='about:blank'){
} browser.tabs.update(itm.id, {url: browser.extension.getURL('dial')});
}); }
}); });
}, 500); });
}, app.settings.startpageTimeout);
}
}); });
}; };
@ -239,6 +243,9 @@ app.Settings.init = function(callback){ // Load settings and nodes
if(!data.settings.openQuickDialInNewPage && data.settings.openQuickDialInNewPage != false){ if(!data.settings.openQuickDialInNewPage && data.settings.openQuickDialInNewPage != false){
data.settings.openQuickDialInNewPage = true; data.settings.openQuickDialInNewPage = true;
} }
if(!data.settings.startpageTimeout){
data.settings.startpageTimeout = 500;
}
//app.Settings.save(); //app.Settings.save();
} }
app.settings = data.settings; app.settings = data.settings;
@ -521,7 +528,7 @@ app.GridNodes.sync = function(gridNode, rootPath, callback){ // Sync GridNodes w
delete app.GridNodes._syncing; delete app.GridNodes._syncing;
if(app.GridNodes._needSync == true) { if(app.GridNodes._needSync == true) {
delete app.GridNodes._needSync; delete app.GridNodes._needSync;
app.GridNodes.sync(gridNode, rootPath, callback); app.GridNodes.sync(gridNode, rootPath, callback);
} else { } else {
app.GridNodes.save(); app.GridNodes.save();
if(callback) callback(); if(callback) callback();

View File

@ -28,6 +28,7 @@ app.init = function(){
BackgroundPreview.style.backgroundRepeat = 'no-repeat'; BackgroundPreview.style.backgroundRepeat = 'no-repeat';
BackgroundPreview.style.backgroundSize = '100% 100%'; BackgroundPreview.style.backgroundSize = '100% 100%';
ButtonOpenInNewPage.checked = app.settings.openQuickDialInNewPage; ButtonOpenInNewPage.checked = app.settings.openQuickDialInNewPage;
StartupTimeout.value = app.settings.startpageTimeout;
GridRoot.value = app.settings.grid.root; GridRoot.value = app.settings.grid.root;
GridRows.value = app.settings.grid.rows; GridRows.value = app.settings.grid.rows;
GridRatioX.value = app.settings.grid.ratioX; GridRatioX.value = app.settings.grid.ratioX;
@ -88,6 +89,7 @@ app.init = function(){
app.settings.backgroundImage = BackgroundImage; app.settings.backgroundImage = BackgroundImage;
app.settings.backgroundMode = +(BackgroundMode.value); app.settings.backgroundMode = +(BackgroundMode.value);
app.settings.openQuickDialInNewPage = ButtonOpenInNewPage.checked; app.settings.openQuickDialInNewPage = ButtonOpenInNewPage.checked;
app.settings.startpageTimeout = StartupTimeout.value;
app.settings.grid.rows = +(GridRows.value); app.settings.grid.rows = +(GridRows.value);
app.settings.grid.margin = +(GridMargins.value); app.settings.grid.margin = +(GridMargins.value);
app.settings.grid.columns = +(GridColumns.value); app.settings.grid.columns = +(GridColumns.value);