function th(cur_col, cur_asc, names) { var txt = ''; for (var i = 0; i < names.length; i++) { var v = names[i]; txt += '\n' + v; if (v) { let cls = (i == cur_col) ? ' class="active"' : ''; txt += ' '; txt += ''; txt += ''; txt += ''; txt += ''; } txt += ''; } return txt + ''; } function td(cols, id) { var txt = '\n'; for (var i = 0; i < cols.length; i++) { txt += '' + cols[i] + ''; } return txt + ''; } function prep(x, i) { return [ i+1 + '. ', '' + x[1] + '', x[2], HHmmss(x[3]), HHmmss(x[4]), as_pm(x[5]), as_pm(x[6]), x[7], x[8], as_percent(x[9]), x[10], dot1(x[11]), new Date(x[12] * 1000).toISOString().slice(0, 16).replace('T',' ') ]; } function update(col, asc) { let table = document.getElementById('rank-list'); let len = _data.length; let txt = ''; for (var i = 0; i < len; i++) { txt += td(prep(_data[i], i), _data[i][0]) } table.innerHTML = th(col, asc, [ '', 'Application', 'Number of recordings', 'Average recording time', 'Cumulative recording time', 'Average requests per minute', 'Total requests per minute', 'Number of domains', 'Number of subdomains', 'Tracker percentage', 'Total number of requests', 'Average number of requests', 'Last Update' ]) + txt; const observer = lozad(); observer.observe(); } function sort_by(col, asc) { let i = col; let o = asc; _data.sort(function(a, b){ return a[i] < b[i] ? -o : a[i] > b[i] ? o : 0; }); update(col, asc); } function rank_js(fname, column, order) { loadJSON(fname, function(response) { _data = JSON.parse(response); update(column, order); }); }