You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
6 years ago
|
lib_cmn = {
|
||
|
// Utils functions
|
||
|
hasProperty: function(obj, propName) {
|
||
|
/* Checks if an object has a property with given name */
|
||
|
if ( (obj == null) || (!propName) )
|
||
|
return false;
|
||
|
else if (obj.hasOwnProperty('propName') || propName in obj)
|
||
|
return true;
|
||
|
else
|
||
|
return false;
|
||
|
},
|
||
|
|
||
|
// Go to default page
|
||
|
goToDefaultPage: function() {
|
||
|
const baseUri = conf['adminTool']['baseUri'];
|
||
|
sessionStorage.setItem('activeTab', '#link-pairing');
|
||
|
window.location = baseUri + '/tool/';
|
||
|
},
|
||
|
|
||
|
// Go to home page
|
||
|
goToHomePage: function() {
|
||
|
sessionStorage.setItem('activeTab', null);
|
||
|
window.location = conf['adminTool']['baseUri'] + '/';
|
||
|
},
|
||
|
|
||
|
// Loads html snippet
|
||
|
includeHTML: function(cb) {
|
||
|
let self = this;
|
||
|
let z, i, elmnt, file, xhttp;
|
||
|
z = document.getElementsByTagName('*');
|
||
|
for (i = 0; i < z.length; i++) {
|
||
|
elmnt = z[i];
|
||
|
file = elmnt.getAttribute('include-html');
|
||
|
if (file) {
|
||
|
xhttp = new XMLHttpRequest();
|
||
|
xhttp.onreadystatechange = function() {
|
||
|
if (this.readyState == 4 && this.status == 200) {
|
||
|
elmnt.innerHTML = this.responseText;
|
||
|
elmnt.removeAttribute('include-html');
|
||
|
self.includeHTML(cb);
|
||
|
}
|
||
|
}
|
||
|
xhttp.open('GET', file, true);
|
||
|
xhttp.send();
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (cb) cb();
|
||
|
}
|
||
|
|
||
|
}
|