-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
113 lines (91 loc) · 3.21 KB
/
functions.js
File metadata and controls
113 lines (91 loc) · 3.21 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// -------------------- LEFT MENU BAR HANDLING --------------------
// Use this variable to set dashboard btn as the active sidebar button at app start.
// Later change the variable to the relavent class id when change the main content according to the button press.
let activeSideBarButtonId = "menu-dashboard-btn";
let activeBodyAreaId = "dashboard-area";
// Main content areas for buttons
let dashboardSection = document.getElementById("dashboard-area");
// Variables with main content areas relavent to left menubar buttons.
let btnDashboard = document.getElementById("menu-dashboard-btn");
let btnUser = document.getElementById("menu-user-btn");
let btnMessages = document.getElementById("menu-messages-btn");
let btnAnalytics = document.getElementById("menu-analytics-btn");
let btnFiles = document.getElementById("menu-files-btn");
let btnOrders = document.getElementById("menu-orders-btn");
let btnSave = document.getElementById("menu-saved-btn");
let btnSettings = document.getElementById("menu-settings-btn");
let btnLogOut = document.getElementById("menu-log-out-btn");
// change the active section to hidden.
function hideActiveArea() {
activeElement = document.getElementById(activeBodyAreaId);
activeElement.classList.toggle("hider");
}
function showElement(id) {
element = document.getElementById(id);
element.classList.toggle("hider")
activeBodyAreaId = id;
idSplit = id.split("-");
activeSideBarButtonId = "menu-" + idSplit[0] + "-btn";
}
btnDashboard.addEventListener("click", ()=>{
if (activeSideBarButtonId != "menu-dashboard-btn") {
hideActiveArea();
showElement("dashboard-area")
}
});
btnUser.addEventListener("click", ()=>{
if (activeSideBarButtonId != "menu-user-btn") {
hideActiveArea();
showElement("user-area")
}
});
btnMessages.addEventListener("click", ()=>{
if (activeSideBarButtonId != "menu-messages-btn") {
hideActiveArea();
showElement("messages-area")
}
});
btnAnalytics.addEventListener("click", ()=>{
if (activeSideBarButtonId != "menu-analytics-btn") {
hideActiveArea();
showElement("analytics-area")
}
});
btnFiles.addEventListener("click", ()=>{
if (activeSideBarButtonId != "menu-files-btn") {
hideActiveArea();
showElement("files-area")
}
});
btnOrders.addEventListener("click", ()=>{
if (activeSideBarButtonId != "menu-orders-btn") {
hideActiveArea();
showElement("orders-area")
}
});
btnSave.addEventListener("click", ()=>{
if (activeSideBarButtonId != "menu-saved-btn") {
hideActiveArea();
showElement("saved-area")
}
});
btnSettings.addEventListener("click", ()=>{
if (activeSideBarButtonId != "menu-settings-btn") {
hideActiveArea();
showElement("settings-area")
}
});
btnLogOut.addEventListener("click", ()=>{
app.quit();
});
// -------------------- NETWORK STATUS --------------------
let lbl_network_status = document.getElementById("home-internet-status")
function getNetworkStatus() {
if (navigator.onLine) {
lbl_network_status.textContent = "ONLINE"
}else{
lbl_network_status.textContent = "OFFLINE"
}
}
getNetworkStatus()
setInterval(getNetworkStatus, 5000)