mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-10 17:34:47 +00:00
show busy indicator badge text
This commit is contained in:
parent
745a2b7ada
commit
1db3b504ec
1 changed files with 21 additions and 0 deletions
|
@ -1,12 +1,23 @@
|
||||||
|
var isBusy = false;
|
||||||
|
|
||||||
chrome.commands.onCommand.addListener(function(command) {
|
chrome.commands.onCommand.addListener(function(command) {
|
||||||
|
// alert(isBusy)
|
||||||
|
if (isBusy) {
|
||||||
|
alert('BUSY')
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (command === 'save-page') {
|
if (command === 'save-page') {
|
||||||
dispatch('extract-page', false, false);
|
dispatch('extract-page', false, false);
|
||||||
|
isBusy = true;
|
||||||
} else if (command === 'save-selection') {
|
} else if (command === 'save-selection') {
|
||||||
dispatch('extract-selection', false, false);
|
dispatch('extract-selection', false, false);
|
||||||
|
isBusy = true;
|
||||||
} else if (command === 'add-page') {
|
} else if (command === 'add-page') {
|
||||||
dispatch('extract-page', true, false);
|
dispatch('extract-page', true, false);
|
||||||
|
isBusy = true;
|
||||||
} else if (command === 'add-selection') {
|
} else if (command === 'add-selection') {
|
||||||
dispatch('extract-selection', true, false);
|
dispatch('extract-selection', true, false);
|
||||||
|
isBusy = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -14,6 +25,9 @@ function dispatch(action, justAddToBuffer, appliedStyles) {
|
||||||
if (!justAddToBuffer) {
|
if (!justAddToBuffer) {
|
||||||
removeEbook();
|
removeEbook();
|
||||||
}
|
}
|
||||||
|
chrome.browserAction.setBadgeBackgroundColor({color:"red"});
|
||||||
|
chrome.browserAction.setBadgeText({text: "Busy"});
|
||||||
|
|
||||||
chrome.tabs.query({
|
chrome.tabs.query({
|
||||||
currentWindow: true,
|
currentWindow: true,
|
||||||
active: true
|
active: true
|
||||||
|
@ -51,9 +65,14 @@ function sendMessage(tabId, action, justAddToBuffer, appliedStyles) {
|
||||||
} else {
|
} else {
|
||||||
alert('Cannot generate the eBook from an empty selection!');
|
alert('Cannot generate the eBook from an empty selection!');
|
||||||
}
|
}
|
||||||
|
isBusy = false;
|
||||||
|
chrome.browserAction.setBadgeText({text: ""});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (!justAddToBuffer) {
|
if (!justAddToBuffer) {
|
||||||
buildEbook([response]);
|
buildEbook([response]);
|
||||||
|
isBusy = false;
|
||||||
|
chrome.browserAction.setBadgeText({text: ""});
|
||||||
} else {
|
} else {
|
||||||
chrome.storage.local.get('allPages', function (data) {
|
chrome.storage.local.get('allPages', function (data) {
|
||||||
if (!data || !data.allPages) {
|
if (!data || !data.allPages) {
|
||||||
|
@ -61,6 +80,8 @@ function sendMessage(tabId, action, justAddToBuffer, appliedStyles) {
|
||||||
}
|
}
|
||||||
data.allPages.push(response);
|
data.allPages.push(response);
|
||||||
chrome.storage.local.set({'allPages': data.allPages});
|
chrome.storage.local.set({'allPages': data.allPages});
|
||||||
|
isBusy = false;
|
||||||
|
chrome.browserAction.setBadgeText({text: ""});
|
||||||
alert('Page or selection added as chapter!')
|
alert('Page or selection added as chapter!')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue