71 lines
No EOL
1.8 KiB
JavaScript
71 lines
No EOL
1.8 KiB
JavaScript
function Navigate(url) {
|
|
window.location = url;
|
|
}
|
|
|
|
function CreateCookie(name, value, days) {
|
|
var expires;
|
|
if (days) {
|
|
var date = new Date();
|
|
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
expires = "; expires=" + date.toGMTString();
|
|
}
|
|
else {
|
|
expires = "";
|
|
}
|
|
document.cookie = name + "=" + value + expires + "; path=/";
|
|
}
|
|
|
|
function round(value, decimals) {
|
|
return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
|
|
}
|
|
|
|
function isNumber(value){
|
|
return isFinite(String(value));
|
|
}
|
|
|
|
String.prototype.upperCaseFirst = function() {
|
|
var lower = this.toLowerCase();
|
|
return lower.charAt(0).toUpperCase() + lower.slice(1);
|
|
};
|
|
|
|
function twoDigitZeroPad(input){
|
|
input=input.toString();
|
|
return [!input[1] && '0' || "", input].join('');
|
|
}
|
|
|
|
Date.prototype.oldToString = Date.prototype.toString;
|
|
Date.prototype.toString = function(format) {
|
|
if (!format)
|
|
return this.oldToString();
|
|
var me=this;
|
|
return format.replace(/./g, function(match) {
|
|
switch(match){
|
|
case 'd': return twoDigitZeroPad(me.getDate());
|
|
case 'm': return twoDigitZeroPad(me.getMonth()+1);
|
|
case 'y': return me.getFullYear();
|
|
case "H": return twoDigitZeroPad(me.getHours());
|
|
case "i": return twoDigitZeroPad(me.getMinutes());
|
|
case "s": return twoDigitZeroPad(me.getSeconds());
|
|
default: return match;
|
|
}
|
|
});
|
|
};
|
|
|
|
Number.prototype.oldToString=Number.prototype.toString;
|
|
Number.prototype.toString=function(input, shouldRound){
|
|
if (!shouldRound)
|
|
return this.oldToString(input);
|
|
|
|
return round(this, input);
|
|
};
|
|
|
|
function documentReady(callback) {
|
|
if (document.readyState === "complete" || document.readyState === "interactive")
|
|
setTimeout(callback, 1);
|
|
else
|
|
document.addEventListener("DOMContentLoaded", callback);
|
|
}
|
|
|
|
window.onload = () => {
|
|
document.querySelector("html").style.opacity = 1;
|
|
}; |