|
|
|
@ -5,23 +5,25 @@ var CONSTANT_ESCAPE_KEY = 27;
|
|
|
|
|
var CONSTANT_S_KEY = 83;
|
|
|
|
|
var CONSTANT_s_KEY = 115;
|
|
|
|
|
|
|
|
|
|
// global sorting vars (new window is always last_changed, descending)
|
|
|
|
|
// globals
|
|
|
|
|
var loading;
|
|
|
|
|
var sort_column;
|
|
|
|
|
var sort_order;
|
|
|
|
|
var sort_column; // new window or tab is always last_changed
|
|
|
|
|
var sort_order; // new window or tab is always descending
|
|
|
|
|
var coordX;
|
|
|
|
|
var coordY;
|
|
|
|
|
|
|
|
|
|
// restore scroll position on submit/reload
|
|
|
|
|
document.addEventListener("DOMContentLoaded", function(event) {
|
|
|
|
|
var scrollpos = sessionStorage.getItem('scrollpos');
|
|
|
|
|
if (scrollpos) window.scrollTo(0, scrollpos);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// mobile scroll position retention
|
|
|
|
|
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
|
|
|
|
|
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
|
|
|
|
|
document.addEventListener("visibilitychange", function() {
|
|
|
|
|
storeScrollAndSearch();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
// non-mobile scroll position retention
|
|
|
|
|
window.onbeforeunload = function(e) {
|
|
|
|
|
storeScrollAndSearch();
|
|
|
|
@ -31,15 +33,23 @@ function storeScrollAndSearch() {
|
|
|
|
|
sessionStorage.setItem('scrollpos', window.pageYOffset);
|
|
|
|
|
sessionStorage.setItem('searchtxt', document.getElementById("txtInput").value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// (ctl)-alt-s search hotkey
|
|
|
|
|
document.onkeyup=function(e){
|
|
|
|
|
document.onkeyup = function(e) {
|
|
|
|
|
var e = e || window.event; // for IE to cover IEs window event-object
|
|
|
|
|
if(e.altKey && (e.which == CONSTANT_S_KEY || e.which == CONSTANT_s_KEY)) {
|
|
|
|
|
if (e.altKey && (e.which == CONSTANT_S_KEY || e.which == CONSTANT_s_KEY)) {
|
|
|
|
|
document.getElementById("txtInput").focus();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// keep track of click position for placement of checkbox-functions grid display
|
|
|
|
|
document.addEventListener("click", clickPos);
|
|
|
|
|
function clickPos(event) {
|
|
|
|
|
coordX = event.clientX;
|
|
|
|
|
coordY = event.clientY;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// page load functions
|
|
|
|
|
window.addEventListener('DOMContentLoaded', (event) => {
|
|
|
|
|
load_functions();
|
|
|
|
@ -57,7 +67,7 @@ function load_functions() {
|
|
|
|
|
// search
|
|
|
|
|
if (isSessionStorageSupported()) {
|
|
|
|
|
// retrieve search
|
|
|
|
|
if ( sessionStorage.getItem("searchtxt") != null ) {
|
|
|
|
|
if (sessionStorage.getItem("searchtxt") != null) {
|
|
|
|
|
document.getElementById("txtInput").value = sessionStorage.getItem("searchtxt");
|
|
|
|
|
tblSearch(this);
|
|
|
|
|
}
|
|
|
|
@ -66,7 +76,8 @@ function load_functions() {
|
|
|
|
|
|
|
|
|
|
// sorting
|
|
|
|
|
function sortTable(n) {
|
|
|
|
|
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0, sortimgs, sortableimgs;
|
|
|
|
|
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0,
|
|
|
|
|
sortimgs, sortableimgs;
|
|
|
|
|
table = document.getElementById("watch-table");
|
|
|
|
|
switching = true;
|
|
|
|
|
//Set the sorting direction, either default 9, 1 or saved
|
|
|
|
@ -74,8 +85,7 @@ function sortTable(n) {
|
|
|
|
|
getSort();
|
|
|
|
|
dir = (sort_order == 0) ? "asc" : "desc";
|
|
|
|
|
loading = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
dir = "asc";
|
|
|
|
|
}
|
|
|
|
|
/*Make a loop that will continue until
|
|
|
|
@ -108,7 +118,7 @@ function sortTable(n) {
|
|
|
|
|
if (dir == "asc") {
|
|
|
|
|
if (x > y) {
|
|
|
|
|
//if so, mark as a switch and break the loop:
|
|
|
|
|
shouldSwitch= true;
|
|
|
|
|
shouldSwitch = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else if (dir == "desc") {
|
|
|
|
@ -125,7 +135,7 @@ function sortTable(n) {
|
|
|
|
|
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
|
|
|
|
|
switching = true;
|
|
|
|
|
//Each time a switch is done, increase this count by 1:
|
|
|
|
|
switchcount ++;
|
|
|
|
|
switchcount++;
|
|
|
|
|
} else {
|
|
|
|
|
/*If no switching has been done AND the direction is "asc",
|
|
|
|
|
set the direction to "desc" and run the while loop again.*/
|
|
|
|
@ -143,8 +153,7 @@ function sortTable(n) {
|
|
|
|
|
// show current asc/desc sort arrow and set sort_order var
|
|
|
|
|
if (dir == "asc") {
|
|
|
|
|
document.getElementById("sort-" + n + "a").style.display = "";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementById("sort-" + n + "d").style.display = "";
|
|
|
|
|
}
|
|
|
|
|
// show all sortable indicators
|
|
|
|
@ -165,46 +174,44 @@ function sortTable(n) {
|
|
|
|
|
function checkAll(e) {
|
|
|
|
|
var i;
|
|
|
|
|
var checkboxes = document.getElementsByName('check');
|
|
|
|
|
var checkboxFunctions = document.querySelectorAll('[id=checkbox-functions]');
|
|
|
|
|
var checkboxFunctions = document.getElementById('checkbox-functions');
|
|
|
|
|
if (e.checked) {
|
|
|
|
|
for (i = 0; i < checkboxes.length; i++) {
|
|
|
|
|
checkboxes[i].checked = true;
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < checkboxFunctions.length; i++) {
|
|
|
|
|
checkboxFunctions[i].style.display = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
checkboxFunctions.style.left = coordX + 25 + "px";
|
|
|
|
|
checkboxFunctions.style.top = coordY + "px";
|
|
|
|
|
checkboxFunctions.style.display = "";
|
|
|
|
|
} else {
|
|
|
|
|
for (i = 0; i < checkboxes.length; i++) {
|
|
|
|
|
checkboxes[i].checked = false;
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < checkboxFunctions.length; i++) {
|
|
|
|
|
checkboxFunctions[i].style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
checkboxFunctions.style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// check/uncheck checkall checkbox if all other checkboxes are checked/unchecked
|
|
|
|
|
function checkChange(){
|
|
|
|
|
function checkChange() {
|
|
|
|
|
var i;
|
|
|
|
|
var totalCheckbox = document.querySelectorAll('input[name="check"]').length;
|
|
|
|
|
var totalChecked = document.querySelectorAll('input[name="check"]:checked').length;
|
|
|
|
|
var checkboxFunctions = document.querySelectorAll('[id=checkbox-functions]');
|
|
|
|
|
if(totalCheckbox == totalChecked) {
|
|
|
|
|
document.getElementsByName("showhide")[0].checked=true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
document.getElementsByName("showhide")[0].checked=false;
|
|
|
|
|
}
|
|
|
|
|
if(totalChecked == 0) {
|
|
|
|
|
for (i = 0; i < checkboxFunctions.length; i++) {
|
|
|
|
|
checkboxFunctions[i].style.display = "none";
|
|
|
|
|
var checkboxFunctions = document.getElementById('checkbox-functions'); //document.querySelectorAll('[id=checkbox-functions]');
|
|
|
|
|
if (totalCheckbox == totalChecked) {
|
|
|
|
|
document.getElementsByName("showhide")[0].checked = true;
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementsByName("showhide")[0].checked = false;
|
|
|
|
|
}
|
|
|
|
|
if (totalChecked > 0) {
|
|
|
|
|
checkboxFunctions.style.display = "";
|
|
|
|
|
checkboxFunctions.style.left = coordX + 25 + "px";
|
|
|
|
|
if ( coordY > ( window.innerHeight - checkboxFunctions.offsetHeight) ) {
|
|
|
|
|
checkboxFunctions.style.top = (window.innerHeight - checkboxFunctions.offsetHeight) + "px";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for (i = 0; i < checkboxFunctions.length; i++) {
|
|
|
|
|
checkboxFunctions[i].style.display = "";
|
|
|
|
|
checkboxFunctions.style.top = coordY + "px";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
checkboxFunctions.style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -225,8 +232,7 @@ function tblSearch(evt) {
|
|
|
|
|
txtValue = td.textContent || td.innerText;
|
|
|
|
|
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
|
|
|
|
tr[i].style.display = "";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
tr[i].style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -239,7 +245,7 @@ function tblSearch(evt) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// restripe after searching or sorting
|
|
|
|
|
function restripe () {
|
|
|
|
|
function restripe() {
|
|
|
|
|
var i, visrows = [];
|
|
|
|
|
var table = document.getElementById("watch-table");
|
|
|
|
|
var rows = table.getElementsByTagName("tr");
|
|
|
|
@ -249,19 +255,18 @@ function restripe () {
|
|
|
|
|
visrows.push(rows[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i=0 ; i<visrows.length; i++) {
|
|
|
|
|
for (i = 0; i < visrows.length; i++) {
|
|
|
|
|
var row = visrows[i];
|
|
|
|
|
if( i%2==0 ) {
|
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
|
row.classList.remove('pure-table-odd');
|
|
|
|
|
row.classList.add('pure-table-even');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
row.classList.remove('pure-table-even');
|
|
|
|
|
row.classList.add('pure-table-odd');
|
|
|
|
|
}
|
|
|
|
|
var cells = row.getElementsByTagName("td");
|
|
|
|
|
for(var j=0; j<cells.length; j++) {
|
|
|
|
|
if( i%2==0 ) {
|
|
|
|
|
for (var j = 0; j < cells.length; j++) {
|
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
|
cells[j].style.background = "#f2f2f2";
|
|
|
|
|
} else {
|
|
|
|
|
cells[j].style.background = "#ffffff";
|
|
|
|
@ -276,19 +281,18 @@ function restripe () {
|
|
|
|
|
function getChecked(items) {
|
|
|
|
|
var i, checkedArr, uuids = '';
|
|
|
|
|
|
|
|
|
|
if ( items === undefined ) {
|
|
|
|
|
if (items === undefined) {
|
|
|
|
|
checkedArr = document.querySelectorAll('input[name="check"]:checked');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
checkedArr = document.querySelectorAll('input[name="check"]');
|
|
|
|
|
}
|
|
|
|
|
if ( checkedArr.length > 0 ) {
|
|
|
|
|
if (checkedArr.length > 0) {
|
|
|
|
|
let output = [];
|
|
|
|
|
for (i = 0; i < checkedArr.length; i++ ) {
|
|
|
|
|
output.push( checkedArr[i].parentNode.parentNode.getAttribute("id") );
|
|
|
|
|
for (i = 0; i < checkedArr.length; i++) {
|
|
|
|
|
output.push(checkedArr[i].parentNode.parentNode.getAttribute("id"));
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < checkedArr.length; i++ ) {
|
|
|
|
|
if (i < checkedArr.length - 1 ) {
|
|
|
|
|
for (i = 0; i < checkedArr.length; i++) {
|
|
|
|
|
if (i < checkedArr.length - 1) {
|
|
|
|
|
uuids += output[i] + ",";
|
|
|
|
|
} else {
|
|
|
|
|
uuids += output[i];
|
|
|
|
@ -302,16 +306,15 @@ function getChecked(items) {
|
|
|
|
|
function processChecked(func, tag) {
|
|
|
|
|
var uuids, result;
|
|
|
|
|
|
|
|
|
|
if ( func == 'mark_all_notviewed' ) {
|
|
|
|
|
if (func == 'mark_all_notviewed') {
|
|
|
|
|
uuids = getChecked('all');
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
uuids = getChecked();
|
|
|
|
|
}
|
|
|
|
|
// confirm if deleting
|
|
|
|
|
if ( func == 'delete_selected' && uuids.length > 0 ) {
|
|
|
|
|
if (func == 'delete_selected' && uuids.length > 0) {
|
|
|
|
|
result = confirm('Deletions cannot be undone.\n\nAre you sure you want to continue?');
|
|
|
|
|
if ( result == false) {
|
|
|
|
|
if (result == false) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -326,17 +329,17 @@ function processChecked(func, tag) {
|
|
|
|
|
FD.append('tag', tag);
|
|
|
|
|
FD.append('uuids', uuids);
|
|
|
|
|
// success
|
|
|
|
|
XHR.addEventListener( 'load', function( event ) {
|
|
|
|
|
XHR.addEventListener('load', function(event) {
|
|
|
|
|
window.location = currenturl;
|
|
|
|
|
});
|
|
|
|
|
// error
|
|
|
|
|
XHR.addEventListener(' error', function( event ) {
|
|
|
|
|
alert( 'Error posting request.' );
|
|
|
|
|
XHR.addEventListener(' error', function(event) {
|
|
|
|
|
alert('Error posting request.');
|
|
|
|
|
});
|
|
|
|
|
// set up request
|
|
|
|
|
XHR.open( 'POST', posturl );
|
|
|
|
|
XHR.open('POST', posturl);
|
|
|
|
|
// send
|
|
|
|
|
XHR.send( FD );
|
|
|
|
|
XHR.send(FD);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function clearSearch() {
|
|
|
|
@ -358,11 +361,10 @@ function isSessionStorageSupported() {
|
|
|
|
|
function getSort() {
|
|
|
|
|
if (isSessionStorageSupported()) {
|
|
|
|
|
// retrieve sort settings if set
|
|
|
|
|
if ( sessionStorage.getItem("sort_column") != null ) {
|
|
|
|
|
if (sessionStorage.getItem("sort_column") != null) {
|
|
|
|
|
sort_column = sessionStorage.getItem("sort_column");
|
|
|
|
|
sort_order = sessionStorage.getItem("sort_order");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
sort_column = 7; // last changed
|
|
|
|
|
sort_order = 1; // desc
|
|
|
|
|
//alert("Your web browser does not support retaining sorting and page position.");
|
|
|
|
|