JSFiddle - React, Tailwind, and code Playground
by joplomacedo
JavaScript
window._abb_ = {};
//php.get('user_cfg', ( data ) => _abb_.boot( convertToObj(data) ) );
_abb_.boot = function( user_cfg ) {
//basics
var w = window,
d = document;
function isNodeList( $el ) {
return NodeList.prototype.isPrototypeOf($el);
}
function qs( arg0, arg1 ) {
return (arg1 || d).querySelector(arg0);
}
function qsa( arg0, arg1 ) {
return (arg1 || d).querySelectorAll(arg0);
}
function ael( $el, evt, cb, uc ) {
(isNodeList($el) ? $el : [$el]).forEach(node => {
node.addEventListener(evt, cb, uc);
});
}
function activate($el) {
(isNodeList($el) ? $el : [$el]).forEach(node => {
node.classList.remove('is-inactive');
node.classList.add('is-active');
});
}
function deactivate($el) {
(isNodeList($el) ? $el : [$el]).forEach(node => {
node.classList.remove('is-active');
node.classList.add('is-inactive');
});
}
//constants and cfgs
var SESSION_DURATION = 30 * 60 * 1000,
ACTIVITY_EVTS = ['mousedown', 'mousemove', 'keypress', 'scroll', 'touchstart'];
var cookies = {
_cache: {
last_activity_time_stamp: 'tbd',
adblock_enabled: 'tbd',
prompt_display_time_stamp: 'tbd',
total_session_count: 0,
total_page_count: 0,
total_time_count: 0,
session_page_count: 0,
session_time_count: 0,
page_time_count: 0,
},
_startPersisting: function () {
setInterval(function () {
cookies.set(cookies._cache);
}, 2000);
},
is_booted: false,
boot: function () {
var cookie = d.cookie.match(new RegExp('_abb_=([^;]+)'));
if ( !cookie )Â {
d.cookie = '_abb_=' + JSON.stringify(cookies._cache) + "; max-age="+ (30*24*60*60);
...