var oReloadTimer = null;
var oCounterTimer = null;
function reloadDocument() {
if(!withquery) history.pushState('', document.title, window.location.pathname);
else if (window.location.href.match(/(&|&)action=\w+/)) history.pushState('', document.title, window.location.href.replace(/(&|&)action=\w+/,''));
window.location.reload();
};
function cdpause() {
clearTimeout(oReloadTimer);
};
function runReloadCounter() {
var oReloadContent = document.getElementById("ReloadContent");
if (oReloadContent) {
if (counter < 0) {
counter = counterfull;
}
counter--;
}
};
function initDoc() {
if (oReloadTimer) window.clearInterval(oReloadTimer);
oReloadTimer = window.setInterval("reloadDocument();", counterfull * 1000);
if (oCounterTimer) window.clearInterval(oCounterTimer);
oCounterTimer = window.setInterval("runReloadCounter();", 1000);
};
/* Function for add new reader/user in readers.html/userconfig.html */
function addinsert() {
cdpause();
$("#searchTable").fadeOut('slow', function() {
$("#newinsert").fadeIn('slow');
});
}
/* Function for add new reader/user in readers.html/userconfig.html */
function chkinsert(chkvalue) {
if(existing_inserts.indexOf(encodeURIComponent(chkvalue))!=-1){
alert('Entry "' + chkvalue + '" already exists!');
return false;
}
}
/* Function for del entry in readers.html/userconfig.html */
function cleaninsert(deleteinsert) {
var tmp_array = existing_inserts.slice();
existing_inserts.length = 0;
var i2 = 0;
for (i = 0; i < tmp_array.length; i++) {
if (tmp_array[i] != deleteinsert){
existing_inserts[i2] = tmp_array[i];
i2++;
}
}
}
var beep = (function () {
var contextClass = (window.AudioContext ||
window.webkitAudioContext ||
window.mozAudioContext ||
window.oAudioContext ||
window.msAudioContext);
if (contextClass) {
var ctx = new contextClass();
return function (duration, type, freq, vol, finishedCallback) {
duration = +duration;
// Only 0-4 are valid types.
type = (type % 5) || 0;
if (typeof finishedCallback != "function") {
finishedCallback = function () {};
}
var osc = ctx.createOscillator();
var gainNode = ctx.createGain();
osc.type = type;
osc.connect(gainNode);
gainNode.connect(ctx.destination);
gainNode.gain.value = vol;
osc.type = type;
osc.frequency.value = freq; // value in hertz
osc.detune.value = 100; // value in cents
osc.start(0);
setTimeout(function () {
osc.stop(0);
finishedCallback();
}, duration);
};
} else {
return function (duration, type, freq, vol, finishedCallback) {return;};
}
})();
String.prototype.toHHMMSS = function () {
if (this.length < 1) {
return ''
}
var sec_num = parseInt(this, 10); // don't forget the second param
var years = Math.floor(sec_num / (86400*365));
var days = Math.floor(sec_num / 86400);
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
hours = hours - (24 * days);
days = days - (365 * years);
if (years < 1) {
years = "";
} else {
years = years + "y ";
}
if (days < 1) {
days = "";
} else {
days = days + "d ";
}
if (hours < 10) {
hours = "0" + hours;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
var time = days + hours + ':' + minutes + ':' + seconds;
return time;
}
/*
* General: Eventhandler
*/
$(function () {
// Pollinterval UP
$("#inc").click(function () {
if (pollintervall > 98000 || polling) return;
$(":text[name='pintervall']").val(Number($(":text[name='pintervall']").val()) + 1);
pollintervall = $(":text[name='pintervall']").val() * 1000;
if (!nostorage) {
sessionStorage.pollintervall = pollintervall;
}
});
// Pollinterval PAUSE
$("#polling").click(function () {
if (polling < 1) {
polling = 1;
$(":text[name='pintervall']").val('--');
$('#polling').attr('class','pollingdisabled');
$('#inc, #dec').attr('disabled','disabled');
} else {
polling = 0;
$(":text[name='pintervall']").val(pollintervall/1000);
$('#polling').attr('class','pollingenabled');
$('#inc, #dec').removeAttr('disabled');
clearTimeout(timer_ID);
timer_ID = setTimeout("waitForMsg()", pollintervall);
}
if (!nostorage) {
sessionStorage.polling = polling;
}
});
// Pollinterval DOWN
$("#dec").click(function () {
if (pollintervall < 2000 || polling) return;
$(":text[name='pintervall']").val(Number($(":text[name='pintervall']").val()) - 1);
pollintervall = $(":text[name='pintervall']").val() * 1000;
if (!nostorage) {
sessionStorage.pollintervall = pollintervall;
}
});
// Hover for showing Chart on Statuspage
$('table.status').on('mouseover', 'tr > td.statuscol14', function (e) {
var uid = '#' + $(this).parent().attr('id');
if ('pcr'.indexOf($(uid).attr('class')) >= 0) {
if ($(uid).data('ecmhistory')) {
var head = $(uid + ' > td:nth-child(3)').attr('title').indexOf('(') > -1 ? $(uid + ' > td:nth-child(3)').attr('title').substring(0, $(uid + ' > td:nth-child(3)').attr('title').indexOf('(')-1) : $(uid + ' > td:nth-child(3)').attr('title');
$('#charthead').text(head + ' History');
$("#graph").html('');
var arry = $(uid).data('ecmhistory').split(",");
$.each(arry, function (index, value) {
$("#graph").append(generateBar(value));
});
$("#chart").show();
}
$("#chart").offset({
left: e.pageX + 20,
top: e.pageY - 20
});
}
});
// Mousout for hiding Chart on Statuspage
$('table.status').on('mouseout', 'tr > td.statuscol14', function () {
$("#chart").hide();
});
$("#add1regex").click(function () {
if (MAX_SEARCH_PATTERN > 98) return;
MAX_SEARCH_PATTERN++;
localStorage.MAX_SEARCH_PATTERN = MAX_SEARCH_PATTERN;
var i = MAX_SEARCH_PATTERN;
var beep_disabled = ' disabled="disabled" title="Not supported by your browser"';
var contextClass = (window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.oAudioContext || window.msAudioContext);
if (contextClass) { beep_disabled = ''; }
var prefix = "0";
if ( i > 9 ) { prefix = ""; }
$('
Search' + prefix + i + ': Found only: Hide: Back Color: Color: Beep:
').insertBefore(".regexdata_save");
$('#color' + i).val($('.colorPicker_def_color').css('color'));
$('#fcolor' + i).val($('.colorPicker_def_fcolor').css('color'));
$('#color' + i).colorPicker();
$('#fcolor' + i).colorPicker();
});
$("#del1regex").click(function () {
var i = MAX_SEARCH_PATTERN;
if (i < 2) return;
if ($('#regex' + i).val() != '') if (!confirm('Search' + i + ' is not empty! Delete?')) return;
$("#regexrow" + i).remove();
localStorage.removeItem('regex' + i);
localStorage.removeItem('color' + i);
localStorage.removeItem('fcolor' + i);
localStorage.removeItem('whitelisted' + i);
localStorage.removeItem('hidden' + i);
localStorage.removeItem('beep' + i);
MAX_SEARCH_PATTERN--;
localStorage.MAX_SEARCH_PATTERN = MAX_SEARCH_PATTERN;
});
$("#regexok").click(function () {
for (var i = 1; i < MAX_SEARCH_PATTERN + 1; i++) {
var pattern = $('#regex' + i).val();
if (pattern) {
var color = $('#color' + i).val();
var fcolor = $('#fcolor' + i).val();
} else {
var color = '';
var fcolor = '';
}
localStorage['regex' + i] = pattern ? pattern : '';
localStorage['color' + i] = color ? color : '';
localStorage['fcolor' + i] = fcolor ? fcolor : '';
localStorage['whitelisted' + i] = $('#whitelisted' + i).prop('checked') ? '1' : '0';
localStorage['hidden' + i] = $('#hidden' + i).prop('checked') ? '1' : '0';
localStorage['beep' + i] = $('#beep' + i).prop('checked') ? '1' : '0';
}
});
$("#regexreset").click(function () {
if (confirm('Delete all Filters and Colors?')) {
for (var i = 1; i < MAX_SEARCH_PATTERN + 1; i++) {
$('#regex' + i).val('');
$('#whitelisted' + i).prop('checked', false);
$('#hidden' + i).prop('checked', false);
$('#color' + i).val($('.colorPicker_def_color').css('color'));
$('#color' + i).change();
$('#fcolor' + i).val($('.colorPicker_def_fcolor').css('color'));
$('#fcolor' + i).change();
$('#beep' + i).prop('checked', false);
localStorage['regex' + i] = '';
localStorage['color' + i] = '';
localStorage['fcolor' + i] = '';
localStorage['whitelisted' + i] = '0';
localStorage['hidden' + i] = '0';
localStorage['beep' + i] = '0';
}
}
});
$(".sizemls a, .sizeml a").click(function () {
maxloglines = parseInt($(this).attr('sendval'));
$("#sizemfrom").text(' Switch displayed log lines from ' + maxloglines + ' to ');
for (var i = 32; i <= 512; i *= 2) {
$("#sizem" + i).attr('class', (maxloglines == i) ? 'sizemls' : 'sizeml');
}
return false;
});
$(".debugls a, .debugl a").click(function () {
parameters = parameters + "&debug=" + $(this).attr('sendval');
return false;
});
$("#savelog").on('click', function (event) {
var txt = '';
$("#livelogdata li").each(function (i) {
txt += $(this).text() + '\n';
});
// Data URI
txtData = 'data:application/txt;charset=utf-8,' + encodeURIComponent(txt);
$(this).attr({
'href': txtData,
'target': '_blank'
});
});
$("#showhidesettings").click(function () {
if ($("#showhidesettings").val() == 'Show Settings') {
$("#showhidesettings").val('Hide Settings');
$("#regexdata").fadeIn('slow');
} else {
$("#showhidesettings").val('Show Settings');
$("#regexdata").fadeOut('slow');
}
});
$("#stoplog").click(function () {
if ($("#stoplog").val() == 'Stop Log') {
$("#stoplog").val('Start Log');
stoppoll = 1;
} else {
$("#stoplog").val('Stop Log');
stoppoll = 0;
waitForMsg();
}
});
$("#onlineidle").click(function () {
if ($("#onlineidle").text() == 'Login*') {
$("#onlineidle")
.text('Online & Idle*')
.attr('title', 'Login info (click to switch)');
} else {
$("#onlineidle")
.text('Login*')
.attr('title', 'Online & Idle info (click to switch)');
}
if (!nostorage) localStorage.loi = $("#onlineidle").text();
waitForMsg();
});
// switch reader ON/OFF
$("a.switchreader").click(function (e) {
e.preventDefault();
var parameters_old = parameters;
parameters += '&label=' + $(this).data('reader-name') + '&action=' + $(this).data('next-action');
var rowid = '#' + $(this).data('md5');
var img = $(this).children("img");
waitForMsg();
if ($(this).data('next-action') == 'enable') {
$(this).data('next-action', 'disable').attr('title', 'Disable Reader: ' + $(this).data('reader-name') + $(this).data('desc'));
$(rowid).attr('class', 'enabledreader');
img.attr('src', 'image?i=ICDIS').attr('alt', 'Disable');
} else {
$(this).data('next-action', 'enable').attr('title', 'Enable Reader: ' + $(this).data('reader-name') + $(this).data('desc'));
$(rowid).attr('class', 'disabledreader');
img.attr('src', 'image?i=ICENA').attr('alt', 'Enable');
}
parameters = parameters_old;
});
// delete reader
$("a.deletereader").click(function (e) {
e.preventDefault();
if (confirm("Delete Reader " + $(this).data('reader-name') + "?")) {
var parameters_old = parameters;
parameters += '&label=' + $(this).data('reader-name') + '&action=' + $(this).data('next-action');
cleaninsert($(this).data('reader-name'));
waitForMsg();
parameters = parameters_old;
$('#' + $(this).data('md5')).fadeOut('slow');
}
});
// switch user ON/OFF
$("a.switchuser").click(function (e) {
e.preventDefault();
var parameters_old = parameters;
parameters += '&user=' + $(this).data('user-name') + '&action=' + $(this).data('next-action');
var rowid = '#' + $(this).data('md5');
var img = $(this).children("img");
waitForMsg();
if ($(this).data('next-action') == 'enable') {
$(this).data('next-action', 'disable').attr('title', 'Disable User: ' + $(this).data('user-name') + $(this).data('desc'));
$(rowid).attr('class', 'offline');
$(rowid + ' > td.usercol2').text('offline');
img.attr('src', 'image?i=ICDIS').attr('alt', 'Disable');
} else {
$(this).data('next-action', 'enable').attr('title', 'Enable User: ' + $(this).data('user-name') + $(this).data('desc'));
$(rowid).attr('class', 'disabled');
$(rowid + ' > td.usercol2').text('offline (disabled)');
img.attr('src', 'image?i=ICENA').attr('alt', 'Enable');
}
parameters = parameters_old;
});
// reset user stats
$("a.resetuser").click(function (e) {
e.preventDefault();
if (confirm("Reset Stats for " + $(this).data('user-name') + "?")) {
var parameters_old = parameters;
parameters += '&user=' + $(this).data('user-name') + '&action=' + $(this).data('next-action');
waitForMsg();
parameters = parameters_old;
}
});
// delete user
$("a.deleteuser").click(function (e) {
e.preventDefault();
if (confirm("Delete User " + $(this).data('user-name') + "?")) {
var parameters_old = parameters;
parameters += '&user=' + $(this).data('user-name') + '&action=' + $(this).data('next-action');
cleaninsert($(this).data('user-name'));
waitForMsg();
parameters = parameters_old;
$('#' + $(this).data('md5')).fadeOut('slow');
}
});
// search related events
$("#searchTerm").keyup(function () {
var value = $("#searchTerm").val().toLowerCase().trim();
$("#dataTable tr").each(function (index) {
if (!index) return;
$(this).find("td").each(function () {
var id = (($(this).data('sort-value') == undefined || $(this).hasClass("usercol2")) ? $(this).text() : $(this).data('sort-value').toString()).toLowerCase().trim();
var not_found = (id.indexOf(value) == -1);
$(this).closest('tr').toggle(!not_found);
return not_found;
});
});
});
$("#searchTerm").click(function () {
cdpause();
});
$("#searchTerm").blur(function () {
initDoc();
});
var table = $('#dataTable').stupidtable();
table.bind('beforetablesort', function (event, data) {
lockpoll = 1;
table.addClass("disabledtable");
});
table.bind('aftertablesort', function (event, data) {
// data.column - the index of the column sorted after a click
// data.direction - the sorting direction (either asc or desc)
lockpoll = 0;
table.removeClass("disabledtable");
});
// copy emm to single write emm
$("a.tosingleemm").click(function (e) {
var ins_emm = (/\s+[0-9a-fA-F]+\s+([0-9a-fA-F]+)\s+/).exec($(this).text());
$('#singleemm').val(ins_emm[1]);
$('#singleemm').change();
});
});
/*
* General: Update page footer and failbannotifier
*/
function updateFooter(data) {
$("#curtime").text(' ' + data.oscam.curdate + ' | ' + data.oscam.curtime + ' ');
$("#runtime").text(' ' + data.oscam.runtime);
$("#uptime") .text(' ' + data.oscam.uptime);
if ($("#fbnotifier > span.span_notifier").length) {
if (data.oscam.failbannotifier > 0) {
$("#fbnotifier > span.span_notifier")
.text(data.oscam.failbannotifier);
}
else {
$("#fbnotifier > span.span_notifier").remove();
}
}
else if (data.oscam.failbannotifier > 0) {
$("#fbnotifier")
.append(''+ data.oscam.failbannotifier + '');
}
}
/*
* identfy an element within string of elements
*/
var poll_excluded;
function is_nopoll(value) {
return (poll_excluded.indexOf(value) > (-1)) ? true : false;
}
/*
* Userpage Functions: Update Page
*/
function updateUserpage(data) {
// update user lines
$.each(data.oscam.users, function (i, item) {
var uid = "#" + item.user.usermd5;
poll_excluded = ($(uid).attr('nopoll') != undefined) ? $(uid).attr('nopoll') : '';
switch (item.user.classname) {
case 'online':
$(uid).attr('class', item.user.classname);
if (!is_nopoll('usercol1')) {
if ($(uid + " td.usercol1 > span.span_notifier").length) {
if(item.user.unotify){
$(uid + " td.usercol1 > span.span_notifier")
.text(item.user.unotify);
}
else {
$(uid + " td.usercol1 > span.span_notifier").remove();
}
}
else if(item.user.unotify) {
$(uid + " td.usercol1")
.append(''+ item.user.unotify + '');
}
}
if (!is_nopoll('usercol2')) {
$(uid + " td.usercol2")
.attr('title', item.user.stats.expectsleep != 'undefined' ? (item.user.stats.expectsleep > 0 ? 'Sleeping in ' + item.user.stats.expectsleep + ' minutes' : 'Sleeping') : '')
.data('sort-value', item.user.ip)
.html("" + item.user.status + " " + item.user.ip);
}
if (!is_nopoll('usercol3')) {
$(uid + " td.usercol3").html(item.user.stats.idle + " " + item.user.stats.timeonchannel.toHHMMSS());
}
if (!is_nopoll('usercol4')) {
if (item.user.protoicon.length > 0) {
if (!$(uid + " td.usercol4 > img").length || $(uid + " td.usercol4 > img").attr('src')!='image?i=IC_' + item.user.protoicon) {
var protoimage = $('');
protoimage.hide();
$(uid + " td.usercol4").html(protoimage);
protoimage.fadeIn('slow');
}
} else {
$(uid + " td.usercol4").text(item.user.protocol);
}
$(uid + " td.usercol4")
.attr('title', item.user.prototitle)
.data('sort-value', item.user.protosort);
}
// channel icon
if (!is_nopoll('usercol6')) {
$(uid + " td.usercol6")
.attr('title', item.user.lastchanneltitle)
.data('sort-value', item.user.lastchannelsort);
if (item.user.lca.length > 0) {
// if we already have a picon within link
if ($(uid + " > td.usercol6 > img.usericon").length) {
// we compare the picon name and switch if different
var image = $(uid + " > td.usercol6 > img.usericon");
if (image.attr('src') != 'image?i=IC_' + item.user.lca) {
// set title of link as tooltip
image.hide();
image.attr('src', 'image?i=IC_' + item.user.lca);
image.fadeIn('slow');
image.attr('alt', item.user.lastchanneltitle);
image.attr('title', item.user.lastchanneltitle);
}
} else {
// we have no image so we have to create one
// if we have picon clear text
$(uid + " > td.usercol6").text('');
// just to be sure that class of image is set
if ($(uid + " > td.usercol6 > img").length) {
$(uid + " > td.usercol6 > img").attr('class', 'usericon');
}
newimage = $('');
newimage.hide();
$(uid + " > td.usercol6").append(newimage);
newimage.fadeIn('slow');
newimage.attr('alt', item.user.lastchanneltitle);
newimage.attr('title', item.user.lastchanneltitle);
}
} else {
$(uid + " td.usercol6").html(item.user.lastchannel);
}
}
if (!is_nopoll('usercol7')) {
$(uid + " td.usercol7")
.text(item.user.stats.cwlastresptimems);
}
//usercol8 ???
if (!is_nopoll('usercol9')) {
$(uid + " td.usercol9").text(item.user.stats.cwok);
}
if (!is_nopoll('usercol10')) {
$(uid + " td.usercol10").text(item.user.stats.cwnok);
}
if (!is_nopoll('usercol11')) {
$(uid + " td.usercol11").text(item.user.stats.cwignore);
}
if (!is_nopoll('usercol12')) {
$(uid + " td.usercol12").text(item.user.stats.cwtimeout);
}
if (!is_nopoll('usercol13')) {
$(uid + " td.usercol13").text(item.user.stats.cwccyclechecked + ' / ' + item.user.stats.cwcycleok + ' / ' + item.user.stats.cwcyclenok + ' / ' + item.user.stats.cwcycleign);
}
if (!is_nopoll('usercol14')) {
$(uid + " td.usercol14").text(item.user.stats.cwcache);
}
if (!is_nopoll('usercol15')) {
$(uid + " td.usercol15").text(item.user.stats.cwtun);
}
if (!is_nopoll('usercol16')) {
$(uid + " td.usercol16").text(item.user.stats.cwcache);
}
if (!is_nopoll('usercol17')) {
$(uid + " td.usercol17").text(item.user.stats.emmok);
}
if (!is_nopoll('usercol18')) {
$(uid + " td.usercol18").text(item.user.stats.emmnok);
}
if (!is_nopoll('usercol19')) {
$(uid + " td.usercol19").text(item.user.stats.cwrate + item.user.stats.cwrate2);
}
if (!is_nopoll('usercol22')) {
$(uid + " td.usercol22").text(item.user.stats.cascusercomb);
}
if (!is_nopoll('usercol21')) {
$(uid + " td.usercol21").text(item.user.stats.n_requ_m);
}
if (!is_nopoll('usercol20')) {
$(uid + " td.usercol20")
.attr('title', item.user.expview)
.text(item.user.stats.expdate);
}
break;
case 'connected':
$(uid).attr('class', item.user.classname);
if (!is_nopoll('usercol1')) {
if ($(uid + " td.usercol1 > span.span_notifier").length) {
if(item.user.unotify){
$(uid + " td.usercol1 > span.span_notifier")
.text(item.user.unotify);
}
else {
$(uid + " td.usercol1 > span.span_notifier").remove();
}
}
else if(item.user.unotify) {
$(uid + " td.usercol1")
.append(''+ item.user.unotify + '');
}
}
if (!is_nopoll('usercol2')) {
$(uid + " td.usercol2")
.attr('title', '')
.data('sort-value', item.user.ip)
.html("" + item.user.status + " " + item.user.ip);
}
if (!is_nopoll('usercol3')) {
$(uid + " td.usercol3").html(item.user.stats.idle + " " + item.user.stats.timeonchannel.toHHMMSS());
}
if (!is_nopoll('usercol4')) {
if (item.user.protoicon.length > 0) {
if (!$(uid + " td.usercol4 > img").length || $(uid + " td.usercol4 > img").attr('src')!='image?i=IC_' + item.user.protoicon) {
var protoimage = $('');
protoimage.hide();
$(uid + " td.usercol4").html(protoimage);
protoimage.fadeIn('slow');
}
} else {
$(uid + " td.usercol4").text(item.user.protocol);
}
$(uid + " td.usercol4")
.attr('title', item.user.prototitle)
.data('sort-value', item.user.protosort);
}
if (!is_nopoll('usercol6')) {
// channel icon
$(uid + " td.usercol6")
.attr('title', item.user.lastchanneltitle)
.data('sort-value', item.user.lastchannelsort);
if (item.user.lca.length > 0) {
var image;
if ($(uid + " td.usercol6").html().length == 0) {
image = $('');
image.hide();
$(uid + " td.usercol6").prepend(image);
image.fadeIn('slow');
} else {
image = $(uid + " td.usercol6 img.usericon");
if (image.attr('src') != ('image?i=IC_' + item.user.lca)) {
image.fadeOut('fast', function () {
image.attr('src', 'image?i=IC_' + item.user.lca);
image.fadeIn('slow');
});
image.attr('alt', item.user.lcb);
image.attr('title', item.user.lastchanneltitle);
}
}
} else {
$(uid + " td.usercol6").html(item.user.lastchannel);
}
}
if (!is_nopoll('usercol7')) {
$(uid + " td.usercol7")
.text(item.user.stats.cwlastresptimems);
}
if (!is_nopoll('usercol19')) {
$(uid + " td.usercol19").text(item.user.stats.cwrate);
}
break;
default:
//check the last status
if ('online,connected'.indexOf($(uid).attr('class')) > (-1)) {
// last status was online so cleanup offline
$(uid).attr('class', item.user.classname);
if (!is_nopoll('usercol1')) {
if ($(uid + " td.usercol1 > span.span_notifier").length) {
$(uid + " td.usercol1 > span.span_notifier").remove();
}
}
if (!is_nopoll('usercol2')) {
$(uid + " td.usercol2")
.attr('title', '')
.html(item.user.status);
}
if (!is_nopoll('usercol3')) {
$(uid + " td.usercol3").text('');
}
if (!is_nopoll('usercol4')) {
$(uid + " td.usercol4")
.text('')
.attr('title', '');
var protoimage = $(uid + " td.usercol4 img.protoicon");
if (image) {
protoimage.fadeOut('slow');
protoimage.remove();
}
}
//channelicon
if (!is_nopoll('usercol6')) {
$(uid + " td.usercol6")
.text('')
.data('sort-value', '');
var image = $(uid + " td.usercol6 img.usericon");
if (image) {
image.fadeOut('slow');
image.remove();
}
}
if (!is_nopoll('usercol7')) {
$(uid + " td.usercol7")
.text('');
}
}
break;
}
if (typeof custompoll == 'function') {
custompoll(item);
}
});
// update user totals + ECM
updateTotals(data);
// update footer
updateFooter(data);
}
/*
* Readerpage Functions: Update Page
*/
function updateReaderpage(data) {
// update reader lines
$.each(data.oscam.readers, function (i, item) {
var uid = "#" + item.labelmd5;
poll_excluded = ($(uid).attr('nopoll') != undefined) ? $(uid).attr('nopoll') : '';
$(uid).attr('class', item.classname);
if (!is_nopoll('readercol4')) {
$(uid + " td.readercol4").text(item.stats.ecmsok + item.stats.ecmsokrel)
.data('sort-value', item.stats.ecmsok);
}
if (!is_nopoll('readercol19')) {
$(uid + " td.readercol19").text(item.stats.ecmsoklg + item.stats.ecmsoklgrel)
.data('sort-value', item.stats.ecmsoklg);
}
if (!is_nopoll('readercol5')) {
$(uid + " td.readercol5").text(item.stats.ecmsnok + item.stats.ecmsnokrel)
.data('sort-value', item.stats.ecmsnok);
}
if (!is_nopoll('readercol6')) {
$(uid + " td.readercol6").text(item.stats.ecmstout + item.stats.ecmstoutrel)
.data('sort-value', item.stats.ecmstout);
}
if (!is_nopoll('readercol7')) {
$(uid + " td.readercol7").text(item.stats.ecmsfiltered);
}
if (!is_nopoll('readercol8')) {
$(uid + " td.readercol8").text(item.stats.emmerror);
}
if (!is_nopoll('readercol9')) {
$(uid + " td.readercol9").text(item.stats.emmwritten);
}
if (!is_nopoll('readercol20')) {
$(uid + " td.readercol20").html(item.status + " " + item.ip);
}
if (!is_nopoll('readercol10')) {
$(uid + " td.readercol10").text(item.stats.emmskipped);
}
if (!is_nopoll('readercol11')) {
$(uid + " td.readercol11").text(item.stats.emmblocked);
}
if (!is_nopoll('readercol12')) {
$(uid + " td.readercol12").text(item.stats.lbweight);
}
if (!is_nopoll('readercol2')) {
if (data.oscam.piconenabled == "1" && item.protoicon) {
$(uid + " td.readercol2").html('');
} else {
$(uid + " td.readercol2").text(item.protocol);
}
$(uid + " td.readercol2")
.data('sort-value', item.protosort);
}
if (typeof custompoll == 'function') {
custompoll(item);
}
});
// update user totals + ECM
updateTotals(data);
// update footer
updateFooter(data);
}
/*
* LiveLog Functions: format the debuglevel switcher
*/
function setDebuglevel(debug, maxdebug) {
var cs_dblevel = parseInt(debug);
var maxlevel = parseInt(maxdebug);
if (lastdebuglevel != cs_dblevel) {
var lvl = 0;
$("#debugfrom").text(' Switch Debug from ' + cs_dblevel + ' to ');
for (var i = 0; i < maxlevel; i++) {
lvl = 1 << i;
if (cs_dblevel & lvl) {
$("#debug" + lvl).attr('sendval', cs_dblevel - lvl);
} else {
$("#debug" + lvl).attr('sendval', cs_dblevel + lvl);
}
$("#debug" + lvl).attr('class', (cs_dblevel & lvl) ? 'debugls' : 'debugl');
}
lastdebuglevel = cs_dblevel;
}
}
/*
* Livelog Functions: get filter color
*/
function getLogColor(text) {
if (nostorage) {
return null;
}
for (var i = 1; i < MAX_SEARCH_PATTERN + 1; i++) {
var pattern = localStorage['regex' + i];
var color = localStorage['color' + i];
var fcolor = localStorage['fcolor' + i];
var hidden = localStorage['hidden' + i];
var beep = localStorage['beep' + i];
var regex = new RegExp(pattern);
if (pattern && (pattern != '') && (regex.exec(text))) {
return {
color: color,
fcolor: fcolor,
hidden: hidden,
beep: beep
}
}
}
return null;
}
/*
* Livelog Functions: get whitelist state
*/
function isWhitelisted(text) {
if (nostorage) {
return 1;
}
var numwhite = 0;
for (var i = 1; i < MAX_SEARCH_PATTERN + 1; i++) {
numwhite += parseInt(localStorage['whitelisted' + i]);
}
if (numwhite > 0) {
for (var i = 1; i < MAX_SEARCH_PATTERN + 1; i++) {
var whitelisted = localStorage['whitelisted' + i];
var pattern = localStorage['regex' + i];
var regex = new RegExp(pattern);
if (pattern && (pattern != '') && (whitelisted == '1') && (regex.exec(text))) {
return 1;
}
}
return 0;
} else {
return 1;
}
}
/*
* LiveLog Functions: manage the delivered data / loglines
*/
function updateLogpage(data) {
lockpoll = 1;
if (data.oscam.debug) {
setDebuglevel(data.oscam.debug, data.oscam.maxdebug);
}
if (data.oscam.logdisabled) {
stoppoll = 1;
$("#livelogdata").append('
Log is disabled
\n');
}
$.each(data.oscam.lines, function (i, item) {
if (isWhitelisted(Base64.decode(item.line))) {
var newcolor = getLogColor(Base64.decode(item.line));
var newline = $('
' + Base64.decode(item.line) + '
\n');
var hiddenline = 0;
if (newcolor) {
if (newcolor.hidden != '1') {
if (newcolor.color && newcolor.color != '') {
newline.css('background-color', newcolor.color);
}
if (newcolor.fcolor && newcolor.fcolor != '') {
newline.css('color', newcolor.fcolor);
}
$("#livelogdata").append(newline);
if (newcolor.beep == 1) {
beep(50, 4, 1000, 0.2);
}
} else {
hiddenline = 1;
}
} else {
$("#livelogdata").append(newline);
}
if (!hiddenline) {
if ($("#livelog:hover").length) {
$('#livelog').stop(true);
} else {
$("#livelog").scrollTop($("#livelog").prop("scrollHeight"));
}
}
}
parameters = "?lastid=" + item.id;
});
var len = $("#livelogdata li").length;
if (len > maxloglines) {
$("#livelogdata li").slice(0, len - maxloglines).remove();
}
// update footer
updateFooter(data);
lockpoll = 0;
}
/*
* Statuspage Functions: JQuery Extensions
*/
$.fn.toHtmlString = function () {
return $('
').html($(this).clone()).html();
};
/*
* Statuspage Functions: Generate a Bar for Barchart
*/
function generateBar(value) {
var bar = $('');
var maxheight = 75; //$( "#graph" ).height() -15;
var numval = parseInt(value);
numval = Math.floor(numval / 30);
if (numval >= maxheight) {
bar.css('background-color', '#FF0000');
numval = maxheight;
}
bar.css('height', numval + 'px');
return bar;
}
/*
* Statuspage Functions: Add/Remove Subheadline
*/
function addremoveSubheadline(remove, data, container, subheadline, type) {
if (remove == 1 && $("#" + subheadline).length) {
$("#" + subheadline)
.fadeOut('slow')
.remove();
$(".status tbody:empty").hide();
}
if (remove == 0 && !$("#" + subheadline).length) {
$(container).removeAttr('style');
var strheadline = '
';
if (type == 'c') {
if (data.oscam.status.ucac != '') { //hide idle clients
strheadline += '
Clients ' + data.oscam.status.ucs + '/' + data.oscam.status.uca + ' (' + data.oscam.status.ucac + ' with ECM within last ' + data.oscam.status.cfgh + ' seconds)
'
);
}
});
});
});
function formatWikiText(text) {
if (!text) return '';
/* Convert escaped newlines to real newlines first */
text = text.replace(/\\n/g, '\n');
text = text.replace(/&/g, '&').replace(//g, '>');
text = text.replace(/```(\w*)\n([\s\S]*?)```/g, '
$2
');
text = text.replace(/```([\s\S]*?)```/g, '
$1
');
text = text.replace(/`([^`]+)`/g, '$1');
text = text.replace(/\*\*([^*]+)\*\*/g, '$1');
text = text.replace(/^### (.+)$/gm, '
$1
');
text = text.replace(/^## (.+)$/gm, '
$1
');
text = text.replace(/\n/g, ' ');
text = text.replace(/<\/pre> /g, '');
return '