-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathindex.js
115 lines (102 loc) · 2.65 KB
/
index.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
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
114
115
const primaryColor = '#4834d4'
const warningColor = '#f0932b'
const successColor = '#6ab04c'
const dangerColor = '#eb4d4b'
const themeCookieName = 'theme'
const themeDark = 'dark'
const themeLight = 'light'
const body = document.getElementsByTagName('body')[0]
function setCookie(cname, cvalue, exdays) {
var d = new Date()
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000))
var expires = "expires="+d.toUTCString()
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"
}
function getCookie(cname) {
var name = cname + "="
var ca = document.cookie.split(';')
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1)
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length)
}
}
return ""
}
loadTheme()
function loadTheme() {
var theme = getCookie(themeCookieName)
body.classList.add(theme === "" ? themeLight : theme)
}
function switchTheme() {
if (body.classList.contains(themeLight)) {
body.classList.remove(themeLight)
body.classList.add(themeDark)
setCookie(themeCookieName, themeDark)
} else {
body.classList.remove(themeDark)
body.classList.add(themeLight)
setCookie(themeCookieName, themeLight)
}
}
function collapseSidebar() {
body.classList.toggle('sidebar-expand')
}
window.onclick = function(event) {
openCloseDropdown(event)
}
function closeAllDropdown() {
var dropdowns = document.getElementsByClassName('dropdown-expand')
for (var i = 0; i < dropdowns.length; i++) {
dropdowns[i].classList.remove('dropdown-expand')
}
}
function openCloseDropdown(event) {
if (!event.target.matches('.dropdown-toggle')) {
//
// Close dropdown when click out of dropdown menu
//
closeAllDropdown()
} else {
var toggle = event.target.dataset.toggle
var content = document.getElementById(toggle)
if (content.classList.contains('dropdown-expand')) {
closeAllDropdown()
} else {
closeAllDropdown()
content.classList.add('dropdown-expand')
}
}
}
var ctx = document.getElementById('myChart')
ctx.height = 500
ctx.width = 500
var data = {
labels: ['January', 'February', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [{
fill: false,
label: 'Completed',
borderColor: successColor,
data: [120, 115, 130, 100, 123, 88, 99, 66, 120, 52, 59],
borderWidth: 2,
lineTension: 0,
}, {
fill: false,
label: 'Issues',
borderColor: dangerColor,
data: [66, 44, 12, 48, 99, 56, 78, 23, 100, 22, 47],
borderWidth: 2,
lineTension: 0,
}]
}
var lineChart = new Chart(ctx, {
type: 'line',
data: data,
options: {
maintainAspectRatio: false,
bezierCurve: false,
}
})