mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-11 01:44:44 +00:00
add timer to force reset the Busy indicator
This commit is contained in:
parent
791f523e8c
commit
37bd9328b8
1 changed files with 31 additions and 6 deletions
|
@ -28,8 +28,26 @@ chrome.runtime.onInstalled.addListener(details => {
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
|
||||||
|
// if (changeInfo.status == 'complete' && tab.active) {
|
||||||
|
|
||||||
|
// chrome.tabs.executeScript(null, {file: 'jquery.js'});
|
||||||
|
// chrome.tabs.executeScript(null, {file: 'jszip.js'});
|
||||||
|
// chrome.tabs.executeScript(null, {file: 'jszip-utils.js'});
|
||||||
|
// chrome.tabs.executeScript(null, {file: 'pure-parser.js'});
|
||||||
|
// chrome.tabs.executeScript(null, {file: 'cssjson.js'});
|
||||||
|
// chrome.tabs.executeScript(null, {file: 'filesaver.js'});
|
||||||
|
// chrome.tabs.executeScript(null, {file: 'saveEbook.js'});
|
||||||
|
// chrome.tabs.executeScript(null, {file: 'extractHtml.js'});
|
||||||
|
// chrome.tabs.executeScript(null, {file: 'utils.js'});
|
||||||
|
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var isBusy = false;
|
var isBusy = false;
|
||||||
|
var busyResetTimer = null
|
||||||
|
|
||||||
var defaultStyles = [
|
var defaultStyles = [
|
||||||
{
|
{
|
||||||
|
@ -168,17 +186,20 @@ function executeCommand(command) {
|
||||||
}
|
}
|
||||||
if (command.type === 'save-page') {
|
if (command.type === 'save-page') {
|
||||||
dispatch('extract-page', false, []);
|
dispatch('extract-page', false, []);
|
||||||
isBusy = true;
|
|
||||||
} else if (command.type === 'save-selection') {
|
} else if (command.type === 'save-selection') {
|
||||||
dispatch('extract-selection', false, []);
|
dispatch('extract-selection', false, []);
|
||||||
isBusy = true;
|
|
||||||
} else if (command.type === 'add-page') {
|
} else if (command.type === 'add-page') {
|
||||||
dispatch('extract-page', true, []);
|
dispatch('extract-page', true, []);
|
||||||
isBusy = true;
|
|
||||||
} else if (command.type === 'add-selection') {
|
} else if (command.type === 'add-selection') {
|
||||||
dispatch('extract-selection', true, []);
|
dispatch('extract-selection', true, []);
|
||||||
isBusy = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isBusy = true
|
||||||
|
|
||||||
|
//
|
||||||
|
busyResetTimer = setTimeout(() => {
|
||||||
|
resetBusy()
|
||||||
|
}, 20000)
|
||||||
}
|
}
|
||||||
|
|
||||||
function dispatch(action, justAddToBuffer, appliedStyles) {
|
function dispatch(action, justAddToBuffer, appliedStyles) {
|
||||||
|
@ -335,8 +356,12 @@ function applyAction(tab, action, justAddToBuffer, includeStyle, appliedStyles,
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetBusy() {
|
function resetBusy() {
|
||||||
isBusy = false;
|
if (busyResetTimer) {
|
||||||
chrome.browserAction.setBadgeText({text: ""});
|
clearTimeout(busyResetTimer)
|
||||||
|
busyResetTimer = null
|
||||||
|
}
|
||||||
|
isBusy = false
|
||||||
|
chrome.browserAction.setBadgeText({text: ""})
|
||||||
|
|
||||||
let popups = chrome.extension.getViews({type: "popup"});
|
let popups = chrome.extension.getViews({type: "popup"});
|
||||||
if (popups && popups.length > 0) {
|
if (popups && popups.length > 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue