messages in saving procedure added. related to #12
This commit is contained in:
parent
83de26b16c
commit
5b44e3147e
2 changed files with 61 additions and 0 deletions
|
|
@ -59,6 +59,41 @@
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"customPrompts_start_saving": {
|
||||||
|
"message": "Saving prompts...",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
|
"customPrompts_reindexing_list": {
|
||||||
|
"message": "Reindexing list...",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
|
"customPrompts_filtering_prompts": {
|
||||||
|
"message": "Filtering prompts...",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
|
"customPrompts_saving_default_prompts": {
|
||||||
|
"message": "Saving default prompts...",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
|
"customPrompts_saving_custom_prompts": {
|
||||||
|
"message": "Saving custom prompts...",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
|
"customPrompts_reloading_menus": {
|
||||||
|
"message": "Reloading menus...",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
|
"customPrompts_saved": {
|
||||||
|
"message": "Prompts saved!",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
|
||||||
"customPrompts_managePrompts_statement": {
|
"customPrompts_managePrompts_statement": {
|
||||||
"message": "Manage your custom prompts.",
|
"message": "Manage your custom prompts.",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ var somethingChanged = false;
|
||||||
var positionMax_compose = 0;
|
var positionMax_compose = 0;
|
||||||
var positionMax_display = 0;
|
var positionMax_display = 0;
|
||||||
var idnumMax = 0;
|
var idnumMax = 0;
|
||||||
|
var msgTimeout = null;
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
let options = {
|
let options = {
|
||||||
|
|
@ -421,6 +422,7 @@ function inputClearError(input) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSomethingChanged(){
|
function setSomethingChanged(){
|
||||||
|
clearTimeout(msgTimeout);
|
||||||
somethingChanged = true;
|
somethingChanged = true;
|
||||||
document.getElementById('btnSaveAll').disabled = false;
|
document.getElementById('btnSaveAll').disabled = false;
|
||||||
let msgDisplay = document.getElementById('msgDisplay');
|
let msgDisplay = document.getElementById('msgDisplay');
|
||||||
|
|
@ -463,8 +465,10 @@ function checkSelectedBoxes(checkboxes = null) {
|
||||||
|
|
||||||
//Save all prompts
|
//Save all prompts
|
||||||
async function saveAll() {
|
async function saveAll() {
|
||||||
|
setMessage(browser.i18n.getMessage('customPrompts_start_saving'));
|
||||||
setNothingChanged();
|
setNothingChanged();
|
||||||
if(promptsList != null) {
|
if(promptsList != null) {
|
||||||
|
setMessage(browser.i18n.getMessage('customPrompts_reindexing_list'));
|
||||||
promptsList.reIndex();
|
promptsList.reIndex();
|
||||||
let newPrompts = promptsList.items.map(item => {
|
let newPrompts = promptsList.items.map(item => {
|
||||||
// For each item in the array, return only the '_values' part
|
// For each item in the array, return only the '_values' part
|
||||||
|
|
@ -474,15 +478,37 @@ async function saveAll() {
|
||||||
// console.log('>>>>>>>>>>>>> id: ' + JSON.stringify(prompt));
|
// console.log('>>>>>>>>>>>>> id: ' + JSON.stringify(prompt));
|
||||||
// });
|
// });
|
||||||
//console.log('>>>>>>>>>>>>> saveAll: ' + JSON.stringify(newPrompts));
|
//console.log('>>>>>>>>>>>>> saveAll: ' + JSON.stringify(newPrompts));
|
||||||
|
setMessage(browser.i18n.getMessage('customPrompts_filtering_prompts'));
|
||||||
let newDefaultPrompts = newPrompts.filter(item => item.is_default == 1);
|
let newDefaultPrompts = newPrompts.filter(item => item.is_default == 1);
|
||||||
//console.log('>>>>>>>>>>>>> newDefaultPrompts: ' + JSON.stringify(newDefaultPrompts));
|
//console.log('>>>>>>>>>>>>> newDefaultPrompts: ' + JSON.stringify(newDefaultPrompts));
|
||||||
let newCustomPrompts = newPrompts.filter(item => item.is_default == 0);
|
let newCustomPrompts = newPrompts.filter(item => item.is_default == 0);
|
||||||
|
setMessage(browser.i18n.getMessage('customPrompts_saving_default_prompts'));
|
||||||
await setDefaultPromptsProperties(newDefaultPrompts);
|
await setDefaultPromptsProperties(newDefaultPrompts);
|
||||||
|
setMessage(browser.i18n.getMessage('customPrompts_saving_custom_prompts'));
|
||||||
await setCustomPrompts(newCustomPrompts);
|
await setCustomPrompts(newCustomPrompts);
|
||||||
|
setMessage(browser.i18n.getMessage('customPrompts_reloading_menus'));
|
||||||
browser.runtime.sendMessage({command: "reload_menus"});
|
browser.runtime.sendMessage({command: "reload_menus"});
|
||||||
|
setMessage(browser.i18n.getMessage('customPrompts_saved'),'green');
|
||||||
|
msgTimeout = setTimeout(() => {
|
||||||
|
clearMessage();
|
||||||
|
}, 10000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setMessage(msg, color = '') {
|
||||||
|
clearTimeout(msgTimeout);
|
||||||
|
let msgDisplay = document.getElementById('msgDisplay');
|
||||||
|
msgDisplay.innerHTML = msg;
|
||||||
|
msgDisplay.style.display = 'inline';
|
||||||
|
msgDisplay.style.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearMessage() {
|
||||||
|
let msgDisplay = document.getElementById('msgDisplay');
|
||||||
|
msgDisplay.innerHTML = '';
|
||||||
|
msgDisplay.style.display = 'none';
|
||||||
|
msgDisplay.style.color = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// window.addEventListener('beforeunload', function (event) {
|
// window.addEventListener('beforeunload', function (event) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue