Mithril as main method
This commit is contained in:
17
assets/js/others/cookie.js
Normal file
17
assets/js/others/cookie.js
Normal file
@@ -0,0 +1,17 @@
|
||||
module.exports = {
|
||||
get: function(cname) {
|
||||
var name = cname + "=";
|
||||
var decodedCookie = decodeURIComponent(document.cookie);
|
||||
var ca = decodedCookie.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 "";
|
||||
}
|
||||
}
|
||||
32
assets/js/others/fitText.js
Normal file
32
assets/js/others/fitText.js
Normal file
@@ -0,0 +1,32 @@
|
||||
var fitText = {
|
||||
fitAll: function(cl) {
|
||||
var elFS, elH
|
||||
|
||||
cl = document.getElementsByClassName(cl)
|
||||
var h = window.innerHeight
|
||||
|| document.documentElement.clientHeight
|
||||
|| document.body.clientHeight
|
||||
|
||||
// console.log(h, window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight);
|
||||
for (var i = 0; i < cl.length; i++) {
|
||||
elFS = parseInt(window.getComputedStyle(cl[i].children[0]).fontSize)
|
||||
cl[i].children[0].style.fontSize = elFS + 'px'
|
||||
elH = parseInt(window.getComputedStyle(cl[i].children[0]).height)
|
||||
|
||||
while (elH < h - (h*.15)) {
|
||||
elFS++
|
||||
cl[i].children[0].style.fontSize = elFS + 'px'
|
||||
elH = parseInt(window.getComputedStyle(cl[i].children[0]).height)
|
||||
}
|
||||
|
||||
while (elH > h - (h*.15)) {
|
||||
elFS--
|
||||
cl[i].children[0].style.fontSize = elFS + 'px'
|
||||
elH = parseInt(window.getComputedStyle(cl[i].children[0]).height)
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = fitText
|
||||
25
assets/js/others/idleTimeout.js
Normal file
25
assets/js/others/idleTimeout.js
Normal file
@@ -0,0 +1,25 @@
|
||||
let user = require('../models/user')
|
||||
|
||||
var idleTimeout = {
|
||||
timeoutId: 0,
|
||||
setup: function() {
|
||||
window.addEventListener("mousemove", idleTimeout.resetTimer, false);
|
||||
window.addEventListener("mousedown", idleTimeout.resetTimer, false);
|
||||
window.addEventListener("keypress", idleTimeout.resetTimer, false);
|
||||
window.addEventListener("DOMMouseScroll", idleTimeout.resetTimer, false);
|
||||
window.addEventListener("mousewheel", idleTimeout.resetTimer, false);
|
||||
window.addEventListener("touchmove", idleTimeout.resetTimer, false);
|
||||
window.addEventListener("MSPointerMove", idleTimeout.resetTimer, false);
|
||||
|
||||
idleTimeout.startTimer();
|
||||
},
|
||||
startTimer: function() {
|
||||
idleTimeout.timeoutId = window.setTimeout(user.logout, 60000*5);
|
||||
},
|
||||
resetTimer: function() {
|
||||
window.clearTimeout(idleTimeout.timeoutId);
|
||||
idleTimeout.startTimer();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = idleTimeout
|
||||
Reference in New Issue
Block a user