function bunker_logout() { localStorage.removeItem("xtoken"); localStorage.removeItem("login"); document.location = "/"; } var ui_configuration; function loadUIConfiguration() { if (ui_configuration) { return ui_configuration; } var xhr10 = new XMLHttpRequest(); xhr10.open('GET', "/v1/sys/uiconfiguration", false); xhr10.onload = function () { if (xhr10.status === 200) { //console.log(xhr10.responseText); var data = JSON.parse(xhr10.responseText); if (data && data.status == "ok") { ui_configuration = data.ui; } } } xhr10.send(); return ui_configuration; } function displayFooterLinks() { conf = loadUIConfiguration(); if (conf["TermOfServiceTitle"]) { document.write("
"+conf["TermOfServiceTitle"]+"
" ); } if (conf["TermOfServiceTitle"]) { document.write("
"+conf["PrivacyPolicyTitle"]+"
" ); } if (conf["CompanyTitle"]) { document.write("
"+conf["CompanyTitle"]+"
" ); } } function dateFormat(value, row, index) { //return moment(value).format('DD/MM/YYYY'); var d = new Date(parseInt(value) * 1000); let f_date = d.getFullYear() + "-" + ("0" + (d.getMonth() + 1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2) + " " + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2) + ":" + ("0" + d.getSeconds()).slice(-2); //return d.toUTCString(); return f_date; } function shortString(value, row, index) { if (!value) { return "N/A"; } return "" + value + ""; } function showAlert(message) { var alertModal = $(''); alertModal.modal('show'); } function showForm(title, message, btn) { if (!btn) { btn = ""; } var formModal = $(''); formModal.modal('show'); return formModal; } function prepareDropdownMenu(menu) { const currentFile = document.location.pathname.split(/[\/]+/).pop(); var code = ''; for (var index = 0; index < menu.length; index++) { const name = menu[index]["name"]; const file = menu[index]["file"]; const style = (file == currentFile) ? ' active' : ''; code += ''+name+''+"\n"; } return code; } function prepareMenu(menu) { const currentFile = document.location.pathname.split(/[\/]+/).pop(); var code = ''; for (var index = 0; index < menu.length; index++) { const name = menu[index]["name"]; if (menu[index]["dropdown"]) { code += ''; } else { const file = menu[index]["file"]; const style = (file == currentFile) ? ' active' : ''; code += ''+"\n"; } } return code; } function showAdminMenu() { const code = prepareMenu(adminMenu); const m = document.getElementById("admin-menu"); if (m) { m.innerHTML = code; } } function showUserMenu() { const code = prepareMenu(userMenu); document.write(code); } function getUserStartPage() { return userMenu[0].file; } function showSuccess(msg) { const st = document.getElementById("status-message"); if (st) { st.innerHTML = `
`+ ``+ `Success! `+msg+`
`; $("#success-alert").fadeTo(2000, 500).fadeOut(500); } } function showError(msg) { const st = document.getElementById("status-message"); if (st) { st.innerHTML = `
`+ ``+ `Error! `+msg+`
`; $("#success-alert").fadeTo(2000, 500).fadeOut(500); } } function loadAgreements(method, address, cb) { var xhr1 = new XMLHttpRequest(); xhr1.open('GET', "/v1/agreements/" + method + "/" + address); xhr1.setRequestHeader("X-Bunker-Token", xtoken) xhr1.setRequestHeader('Content-type', 'application/json'); xhr1.onload = function () { if (xhr1.status === 200) { var data = JSON.parse(xhr1.responseText); if (cb) { cb(data); } else { console.log("loadAgreements cb is empty") } } else if (xhr1.status > 400 && xhr1.status < 404) { document.location = "/"; } } xhr1.send(); } function acceptAgreement(method, address, brief, options, cb) { var xhr1 = new XMLHttpRequest(); var params = ''; if (options) { params = JSON.stringify(options); } xhr1.open('POST', "/v1/agreement/" + brief + "/" + method + "/" + address); xhr1.setRequestHeader("X-Bunker-Token", xtoken) xhr1.setRequestHeader('Content-type', 'application/json'); xhr1.onload = function() { if (xhr1.status === 200) { var data = JSON.parse(xhr1.responseText); if (cb) { cb(data); } return } else if (xhr1.status === 401) { document.location = "/"; } } xhr1.send(params); }