-
Notifications
You must be signed in to change notification settings - Fork 0
/
statimize.js
131 lines (111 loc) · 3.64 KB
/
statimize.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* Prepare footer links for passing to theme based functions
*
* @function prepareFooter
* @param {string} theme Active theme
*
*/
prepareFooter = (theme) => {
// Prepare footer links
let html = '';
const re = /\[([^\[]*)\]\((.*)\)/;
for (let i=0; i<items.length; i++) {
myMatch = items[i].match(re);
if (myMatch != null && myMatch.length == 3) {
html += '<a class="text-warning" href="' + myMatch[2] + '">' + myMatch[1] + '</a>';
}
}
// Passing to theme based functions
theme === 'smart' ? editSmart(html) : null;
theme === 'alternative' || theme === 'blogx' ? editBludit(html) : null;
theme === 'darktheme' ? editDark(html) : null;
};
/**
* Implement links and additional text to footer for smart theme
*
* @function editSmart
* @param {string} html Prepared dom for additional links
*
*/
editSmart = (html) => {
// Add footer links
if (html.length !== 0) {
let footerLinks = document.getElementById('footer-links');
footerLinks.classList.add('col', 'footer-col', 'footer-right');
footerLinks.innerHTML = html;
let footerSource = document.getElementById('footer-source');
footerSource.classList.remove('footer-right');
footerSource.classList.add('footer-center');
}
// Add footer text
if (text.length !== 0) {
let footerText = document.getElementById('footer-additional-text');
footerText.innerHTML = text;
}
};
/**
* Implement links and additional text to footer for bludit default themes
*
* @function editBludit
* @param {string} html Prepared dom for additional links
*
*/
editBludit = (html) => {
// Prepare setting
let target = document.getElementsByTagName('footer')[0];
let footerContainer = document.createElement('div');
footerContainer.classList.add('bg-dark');
let footerRow = document.createElement('div');
footerRow.classList.add('row');
footerRow.style.justifyContent = 'center';
footerRow.style.marginTop = '-20px';
footerRow.style.columnGap = '3em';
footerContainer.append(footerRow);
target.append(footerContainer);
// Add footer text
if (text.length !== 0) {
let footerText = document.createElement('div');
footerText.innerHTML = text;
footerText.classList.add('text-white');
footerRow.append(footerText);
}
// Add footer links
if (html.length !== 0) {
let footerLinks = document.createElement('div');
footerLinks.innerHTML = html;
footerLinks.style.display = 'flex';
footerLinks.style.columnGap = '10px';
footerRow.append(footerLinks);
}
};
/**
* Implement links and additional text to footer for dark theme
*
* @function editDark
* @param {string} html Prepared dom for additional links
*
*/
editDark = (html) => {
// Prepare setting
let footer = document.getElementsByClassName('container');
footer = footer[footer.length - 1];
let footerRow = document.createElement('div');
footerRow.classList.add('row');
footer.append(footerRow);
// Add footer text
if (text.length !== 0) {
let footerText = document.createElement('small');
footerText.innerHTML = text;
footerText.classList.add('text-secondary');
footerRow.append(footerText);
}
// Add footer links
if (html.length !== 0) {
let footerLinks = document.createElement('div');
footerLinks.innerHTML = html;
footerLinks.style.display = 'flex';
footerLinks.style.columnGap = '10px';
footerLinks.style.justifyContent = 'center';
footerRow.append(footerLinks);
}
};