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.

64 lines
2.2 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

window.addEventListener('DOMContentLoaded', function () {
browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.cmd !== 'updatePopup') return;
var data = request.data;
var rows = new Array();
var makeCell = function(cell_text) {
return ['td', {}, cell_text];
};
var makeCellWarn = function(cell_text) {
return ['td', {
colspan: '2',
style: 'text-align: right; color: #B72C43'
}, cell_text];
};
var makeRow = function(cell1, cell2) {
if (typeof cell2 == 'undefined')
return ['tr', {}, cell1]
else
return ['tr', {}, cell1, cell2]
};
var jsonTable = [
'table', {
id: 'infotable',
cellpadding: '0',
cellspacing: '0'
}, ['tbody', {}, rows]
];
var labelColor = '';
if (data.iswarning) labelColor = 'color: #B72C43';
rows.push(makeRow(makeCell('Текущий баланс'), makeCell(['span', {}, ['a', {
style: labelColor,
target: '_blank',
href: 'https://cabinet.setitagila.ru/index.php?item=mainData'
}, data.balance + ' руб.']])))
rows.push(makeRow(makeCell('Текущий тариф'), makeCell(['span', {}, ['a', {
style: labelColor,
target: '_blank',
href: 'https://cabinet.setitagila.ru/index.php?item=bezlimit'
}, data.tariffnow], ' (' + (data.tariffstatus == 'on' ? 'включен' : 'ОТКЛЮЧЕН') + ')'])))
rows.push(makeRow(makeCell('Тариф в следующем месяце'), makeCell(['span', {}, data.tariffthen])));
rows.push(makeRow(makeCell('Стоимость тарифа в следующем месяце'), makeCell(['span', {}, data.tariffprice + ' руб.'])));
if (data.islowb)
rows.push(makeRow(makeCellWarn('У Вас мало денег на счету!')));
if (data.islowt)
rows.push(makeRow(makeCellWarn('Средств не хватит на начало следующего месяца!')));
var infotable = document.getElementById('infotable');
var newinfotable = jsonToDOM(jsonTable, document, {});
if (infotable)
document.body.replaceChild(newinfotable, infotable);
else
document.body.appendChild(newinfotable);
});
browser.runtime.sendMessage({ cmd: 'requestUpdatePopup' });
}, false);