-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.js
31 lines (25 loc) · 1.08 KB
/
common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
*
*/
function clearliTagClass() {
const liTagList = document.querySelectorAll("li.nav-item");
for (let li of liTagList) {
li.removeAttribute("class");
}
}
function addClassliTag(index) {
document.querySelectorAll("li")[index].setAttribute("class", "active");
}
const token = $("meta[name='_csrf']").attr("content");
const header = $("meta[name='_csrf_header']").attr("content");
$(document).ajaxSend(function(e, xhr, options) {
xhr.setRequestHeader(header, token);
});
const empty = (value) => {
if (value === null) { return true; }
if (typeof value === "undefined") { return true; }
if (typeof value === "string" && value === "") { return true; }
if (Array.isArray(value) && value.length < 1) { return true; }
if (typeof value === "object" && value.constructor.name === "Object" && Object.keys(value).length < 1 && Object.getOwnPropertyNames(value) < 1) { return true; }
if (typeof value === "object" && value.constructor.name === "String" && Object.keys(value).length < 1) { return true; } // new String() return false }
};