-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogue.js
57 lines (42 loc) · 2.45 KB
/
dialogue.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
window.onload = function() {
//Localisation
document.getElementById("dialogueTitle").textContent = browser.i18n.getMessage("dialogueTitle");
document.getElementById("dialogueCountLabel").textContent = browser.i18n.getMessage("dialogueCountLabel");
document.getElementById("dialogueLimitLabel").textContent = browser.i18n.getMessage("dialogueLimitLabel");
document.getElementById("dialogueQuestion").textContent = browser.i18n.getMessage("dialogueQuestion");
document.getElementById("dialogueQuestionOK").value = browser.i18n.getMessage("dialogueQuestionOK");
document.getElementById("dialogueQuestionCancel").value = browser.i18n.getMessage("dialogueQuestionCancel");
document.getElementById("dialogueCheckboxLabel").textContent = browser.i18n.getMessage("dialogueCheckboxLabel");
strictLimitWarning = browser.i18n.getMessage("strictLimitWarning");
// Arguments
count = document.URL.match(/\?[0-9]*\&/)[0] ;
limit = document.URL.match(/\&m[0-9]*\&/)[0] ;
strict = document.URL.match(/\&s./)[0] ;
// console.log("count: " + count.substring(1,count.length-1) + " limit: " + limit.substring(2,limit.length-1) + " strict: " + strict.substring(2) );
document.getElementById("dialogueCount").textContent = count.substring(1,count.length-1) ;
document.getElementById("dialogueLimit").textContent = limit.substring(2,limit.length-1) ;
if (strict.substring(2) == "1") {strictLimit = true } else {strictLimit = false}
document.getElementById("checkbox").checked = strictLimit ;
}
document.getElementById("dialogueQuestionOK").addEventListener('click', okpressed);
document.getElementById("dialogueQuestionCancel").addEventListener('click', cancelpressed);
document.getElementById("checkbox").addEventListener('change', checkboxChanged);
function okpressed() {
const bccall = document.getElementById('checkbox').checked;
// console.log("OK pressed");
// console.log("Checkbox: " + bccall);
browser.runtime.sendMessage({msg:"bcc_ok_"+bccall}).catch();
}
function cancelpressed() {
const bccall = document.getElementById('checkbox').checked;
// console.log("CANCEL pressed");
// console.log("Checkbox: " + bccall);
browser.runtime.sendMessage({msg:"bcc_cancel"}).catch();
}
function checkboxChanged(){
// Cannot change if Strict Limit: reset and issue warning
if (strictLimit) {
document.getElementById("checkbox").checked = strictLimit ;
document.getElementById("messageLine").textContent = strictLimitWarning
}
}