You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.8 KiB
JavaScript
111 lines
3.8 KiB
JavaScript
window.addEventListener('DOMContentLoaded', function () {
|
|
|
|
function isNumeric(string) {
|
|
var numericExpression = /^[0-9]+$/;
|
|
if(string.match(numericExpression)) { return true; } else { return false; }
|
|
}
|
|
|
|
var storage = widget.preferences;
|
|
|
|
var notify1 = document.getElementById('notify1');
|
|
var notify2 = document.getElementById('notify2');
|
|
var warn1 = document.getElementById('warn1');
|
|
var warn2 = document.getElementById('warn2');
|
|
var balanceRub = document.getElementById('balanceRub');
|
|
var balanceDay = document.getElementById('balanceDay');
|
|
|
|
switch (storage.informst_notify1) {
|
|
case '0': notify1.checked = false; break;
|
|
case '1': notify1.checked = true; break;
|
|
default: notify1.checked = true;
|
|
}
|
|
|
|
switch (storage.informst_notify2) {
|
|
case '0': notify2.checked = false; break;
|
|
case '1': notify2.checked = true; break;
|
|
default: notify2.checked = true;
|
|
}
|
|
|
|
switch (storage.informst_warn2) {
|
|
case '0': warn1.checked = true; break;
|
|
case '1': warn2.checked = true; break;
|
|
default: warn1.checked = true;
|
|
}
|
|
|
|
if (storage.informst_balanceRub) balanceRub.value = storage.informst_balanceRub; else balanceRub.value = 30;
|
|
if (storage.informst_balanceDay) balanceDay.value = storage.informst_balanceDay; else balanceDay.value = 7;
|
|
|
|
notify1.addEventListener('change', function(e) {
|
|
if (notify1.checked) storage.informst_notify1 = 1; else storage.informst_notify1 = 0;
|
|
opera.extension.postMessage({informst: 'doNotify'});
|
|
}, true);
|
|
|
|
notify2.addEventListener('change', function(e) {
|
|
if (notify2.checked) storage.informst_notify2 = 1; else storage.informst_notify2 = 0;
|
|
opera.extension.postMessage({informst: 'doNotify'});
|
|
}, true);
|
|
|
|
warn1.addEventListener('change', function(e) {
|
|
if (warn1.checked) storage.informst_warn2 = 0;
|
|
opera.extension.postMessage({informst: 'doNotify'});
|
|
}, true);
|
|
|
|
warn2.addEventListener('change', function(e) {
|
|
if (warn2.checked) storage.informst_warn2 = 1;
|
|
opera.extension.postMessage({informst: 'doNotify'});
|
|
}, true);
|
|
|
|
balanceRub.addEventListener('change', function(e) {
|
|
if (isNumeric(balanceRub.value)) storage.informst_balanceRub = balanceRub.value;
|
|
opera.extension.postMessage({informst: 'doNotify'});
|
|
}, true);
|
|
|
|
balanceDay.addEventListener('change', function(e) {
|
|
if (isNumeric(balanceDay.value)) storage.informst_balanceDay = balanceDay.value;
|
|
opera.extension.postMessage({informst: 'doNotify'});
|
|
}, true);
|
|
|
|
var bstyle = storage.informst_bstyle;
|
|
if (bstyle != null)
|
|
document.getElementById('badgeStyle' + bstyle).checked = true;
|
|
else
|
|
document.getElementById('badgeStyle2').checked = true;
|
|
|
|
function varScope(i)
|
|
{
|
|
document.getElementById('badgeStyle' + i).addEventListener('change', function(e) {
|
|
storage.informst_bstyle = i;
|
|
|
|
var cl, bcl;
|
|
switch (i)
|
|
{
|
|
case 0: cl = ''; bcl = ''; break;
|
|
case 1: cl = 'white'; bcl = 'black'; break;
|
|
case 2: cl = 'black'; bcl = 'white'; break;
|
|
case 3: cl = '#1B392C'; bcl = 'white'; break;
|
|
case 4: cl = '#7499B2'; bcl = 'white'; break;
|
|
case 5: cl = '#555555'; bcl = '#F5EED3'; break;
|
|
case 6: cl = '#3E0A02'; bcl = '#F1DADA'; break;
|
|
case 7: cl = '#023E1F'; bcl = '#DBF1DA'; break;
|
|
case 8: cl = '#DEDEE7'; bcl = '#464959'; break;
|
|
case 9: cl = '#E3DEE7'; bcl = '#4F435C'; break;
|
|
case 10: cl = '#DEE7DE'; bcl = '#3F5446'; break;
|
|
default: cl = 'white'; bcl = 'black';
|
|
}
|
|
|
|
storage.informst_bstyle_bcolor = bcl;
|
|
storage.informst_bstyle_fcolor = cl;
|
|
opera.extension.postMessage({informst: 'doNotify'});
|
|
}, true);
|
|
};
|
|
|
|
for (var i = 1; i <= 10; i++) varScope(i);
|
|
|
|
function blink()
|
|
{
|
|
text = document.getElementById('warnBadge2');
|
|
if (text.style.color != 'rgb(255, 0, 0)') text.style.color = '#FF0000'; else text.style.color = 'black';
|
|
}
|
|
setInterval(blink, 1000);
|
|
|
|
}, false ); |