<commit_before>/*
 * Loads the depandancies in order and aggregates exports from various modules
 */

// NOTE: The entire bundle uses strict mode through the Babel transpiler

/*
 * Because we are going to attach listeners to these all over the place, have
 * to load soome core modules in specific order. Also avoids nasty circular
 * dependaancy, by placing some of the exports here and not in child modules.
 */
let $ = require('jquery'),
	_ = require('underscore'),
	Backbone = require('backbone'),
	Cookie = require('js-cookie'),
	radio = require('backbone.radio');

// Bind jQuery to backbone
Backbone.$ = $;
// Load standard library ES6 polyfills
require('core-js');

// Central aplication object and message bus
let main = module.exports = radio.channel('main');
_.extend(main, {
	// Bind dependancies to main object for pretier destructuring requires
	$, _, Backbone, Cookie,
	$script: require('scriptjs'),
	SockJS: require('sockjs-client'),
	stackBlur: require('stack-blur'),

	/*
	 Ofload expensive and not that neccessary initialisation logic till
	 after the core modules are started
	 */
	_deferred: [],
	defer(func) {
		main._deferred.push(func);
		return main;
	},
	execDeffered() {
		for (let func of this._deferred) {
			func();
		}
	},

	/*
	 These configs really should not be randomly toggled frequently. No need
	 to put them in state.js, as they should not be hot-loaded. Anything
	 that needs to be, can be moved to hot.js. Should prevent some bugs, but
	 also reduce flexibility, for frequent togglers. Hmm.
	 */
	config: window.config,
	clientHash: window.clientHash,
	isMobile: /Android|iP(?:hone|ad|od)|Windows Phone/.test(navigator.userAgent),
	// Websocket call handler map. Store them here, to avoid requiring
	// modules in the wrong order.
	dispatcher: {},
	// Read-only boards get expanded later
	readOnly: [],
	lang: require('lang')
});

// Clear cookies, if versions mismatch. Get regenerated each client start
// anyway.
// XXX: Does not clear cookies for all paths
if (localStorage.cookieVersion !== '1') {
	for (let cookie in Cookie.get()) {
		Cookie.remove(cookie);
	}
	localStorage.cookieVersion = 1;
}

// You can invoke the client-side debug mode with the `debug=true` query string
if (/[&\?]debug=true/.test(location.href))
	main.config.DEBUG = true;
if (main.config.DEBUG) {
	radio.DEBUG = true;
	// Export Backbone instance for easier debugging
	window.Backbone = Backbone;
	// Log all channel traffic
	radio.tuneIn('main');<commit_msg>Clear legacy cookies from all boards<commit_after>/*
 * Loads the depandancies in order and aggregates exports from various modules
 */

// NOTE: The entire bundle uses strict mode through the Babel transpiler

/*
 * Because we are going to attach listeners to these all over the place, have
 * to load soome core modules in specific order. Also avoids nasty circular
 * dependaancy, by placing some of the exports here and not in child modules.
 */
let $ = require('jquery'),
	_ = require('underscore'),
	Backbone = require('backbone'),
	Cookie = require('js-cookie'),
	radio = require('backbone.radio');

// Bind jQuery to backbone
Backbone.$ = $;
// Load standard library ES6 polyfills
require('core-js');

// Central aplication object and message bus
let main = module.exports = radio.channel('main');
_.extend(main, {
	// Bind dependancies to main object for pretier destructuring requires
	$, _, Backbone, Cookie,
	$script: require('scriptjs'),
	SockJS: require('sockjs-client'),
	stackBlur: require('stack-blur'),

	/*
	 Ofload expensive and not that neccessary initialisation logic till
	 after the core modules are started
	 */
	_deferred: [],
	defer(func) {
		main._deferred.push(func);
		return main;
	},
	execDeffered() {
		for (let func of this._deferred) {
			func();
		}
	},

	/*
	 These configs really should not be randomly toggled frequently. No need
	 to put them in state.js, as they should not be hot-loaded. Anything
	 that needs to be, can be moved to hot.js. Should prevent some bugs, but
	 also reduce flexibility, for frequent togglers. Hmm.
	 */
	config: window.config,
	clientHash: window.clientHash,
	isMobile: /Android|iP(?:hone|ad|od)|Windows Phone/.test(navigator.userAgent),
	// Websocket call handler map. Store them here, to avoid requiring
	// modules in the wrong order.
	dispatcher: {},
	// Read-only boards get expanded later
	readOnly: [],
	lang: require('lang')
});

// Clear cookies, if versions mismatch. Get regenerated each client start
// anyway.
const cookieVersion = 2;
if (localStorage.cookieVersion != cookieVersion) {
	for (let cookie in Cookie.get()) {

		// Clear legacy cookies that were set for each board separatly.
		// Otherwise, they would override the new ones.
		let paths = config.BOARDS.slice();
		paths.push('');
		for (let path of paths) {
			Cookie.remove(cookie, {path});
		}
	}
	localStorage.cookieVersion = cookieVersion;
}

// You can invoke the client-side debug mode with the `debug=true` query string
if (/[&\?]debug=true/.test(location.href))
	main.config.DEBUG = true;
if (main.config.DEBUG) {
	radio.DEBUG = true;
	// Export Backbone instance for easier debugging
	window.Backbone = Backbone;
	// Log all channel traffic
	radio.tuneIn('main');
{'fraction_non_alphanumeric': 0.11497788886752548, 'fraction_numerical': 0.0009613535858488752, 'mean_word_length': 3.973231357552581, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2303180', 'n_tokens_mistral': 1577, 'n_tokens_neox': 1508, 'n_words': 576}