boilerplate.js
Version:
Development Tools
37 lines (31 loc) • 1.32 kB
JavaScript
// Starts performance timer
measure('start', 'App.js Bootstrap');
// Set Dev Mode
window.dev = localStorage.getItem('dev') || false;
// Change to false for debugging
window.clearConsole = true;
// Headers for httpRequest
httpRequest.requestHeaders = [{
'request': 'X-CSRF-Token',
'value': 'CSRF-TOKEN'
}];
// Public Path (Change The Path In Config Using 'gulp') (used for External.js & External.css Defer functions)
window.PublicPathJS = '/js/';
window.PublicPathCSS = '/css/';
// Define global objects here
window.page = (path, func) => ensureObj(window.page, path, func);
window.components = (path, func) => ensureObj(window.components, path, func);
// Generates ID for body based on the current URL
window.customTag = () => {
const company = 'company';
const pathname = location.pathname;
if (pathname.length === 1) return document.body.className = 'home-' + company;
const text = (pathname.split('.')[0]).slice(1).split('/');
if (!text[text.length - 1]) text.pop();
const currentPage = text[text.length - 1] + '-' + company;
if (text.length === 1) {
document.body.className = currentPage;
} else {
document.body.className = currentPage + ' ' + text[0] + '-' + company + ' ' + text.join('-') + '-' + company;
}
};