1
0
mirror of https://github.com/MatMoul/quickdial-webext.git synced 2024-12-23 07:26:11 +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>
</tr>
<tr>
<td>Startpage timeout :</td>
<td><input id="StartupTimeout" type="number"></td>
</tr>
</table>

View File

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

View File

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