var api_host = document.location.origin + '/capi/' var upload_path = '../face/images/card/' var db_alert = false function setAlert(boo) { db_alert = boo; console.log("db_alert = " + boo) } function db() { if (db_alert) { alert(arguments) } else { console.table(arguments) } } function display_alert(id, before, after, action){ var er = document.getElementById(id) er.style.display = before er.classList.add(action); setTimeout(function(){ er.style.display = after er.classList.remove("action"); }, 5000); } function gup(name, url) { if (!url) url = location.href; name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(url); return results == null ? null : results[1]; } function getUsername() { return localStorage.username || null } function setLocalStorage(k, v) { var json = localStorage.register_obj if (json) { var obj = JSON.parse(json) if (obj) { obj[k] = v; localStorage.register_obj = JSON.stringify(obj) return true } } return false } function getUserField(k) { var json = localStorage.register_obj if (json) { var c = JSON.parse(json) return c[k] || '' } else { return '' } } function validateEmail (sEmail) { var filter = /^[\w-.+]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/; return filter.test(sEmail) } function bytesToSize(bytes) { var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; if (bytes == 0) return '0 Byte'; var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i]; } function formatBytes(a, b = 2) { if (0 === a) return "0 Bytes"; const c = 0 > b ? 0 : b, d = Math.floor(Math.log(a) / Math.log(1024)); return parseFloat((a / Math.pow(1024, d)).toFixed(c)) + " " + ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][d] } function niceBytes(x) { const units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; let l = 0, n = parseInt(x, 10) || 0; while (n >= 1024 && ++l) { n = n / 1024; } return (n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l]); } // viewer functions function sign_profile(v) { localStorage.setItem("sign_type", v); console.log("sign_profile() type is " + v) } function get_sign_profile() { console.log(localStorage.sign_type) return localStorage.sign_type || 'gen_white' } function push_search() { if(event.key === 'Enter') { if (router.currentRoute.path != "/alldocument") { router.push("alldocument") } else { window.myApp.txt_search = navApp.searchHeader window.myApp.show_all_table() window.myApp.search_table() window.myApp.set_table() } } } // viewer end