<commit_before>include.routes({
	component: '/script/{0}/{1}.js',
	vendor: '/.reference/libjs/vendor-lib/{0}/{1}.js',
	script: '/script/{0}.js'
}) //
.instance().js({
	ruqq: ['dom/jquery', 'utils', 'arr', 'es5shim'],
	lib: ['compo','ranimate'],
	component: ['preview', 'tabs', 'dropdownMenu', 'shortend-dialog'],
	vendor: 'keymaster',
	script: ['presets', 'urlcode']
}) //
.ready(function(resp) {


	window.app = (new(Class({
		Base: Compo,
		attr: {
			template: document.getElementById('layout').innerHTML
		},
		compos: {
			preview: 'compo: preview',
			tabs: 'compo: tabs',
			ddMenu: 'compo: dropdownMenu',
			btnSetLink: '$: #setLink',
			btnShortend: '$: #getShortend'
		}
	}))).render({
		presets: resp.presets
	}).insert(document.body);


	window.editors = {};

	function createEditor(type, highlight) {
		editors[type] = ace.edit('editor-' + type);
		editors[type].setTheme("ace/theme/monokai");
		editors[type].getSession().setMode("ace/mode/" + (highlight || type));
	}

	createEditor('mask', 'coffee');
	createEditor('javascript');
	createEditor('style', 'css');

	/** SETUP */

	(function() {



		var editors = window.editors,
			preview = app.compos.preview,
			deferredTimer,
			types;

		function getSource(type) {
			return editors[type].getValue();
		}

		////function deferUpdate() {
		////	clearTimeout(deferredTimer);
		////	deferredTimer = setTimeout(update, 400);
		////}

		function deferUpdate(type){
			if (types && !types.push){
				debugger;
			}

			types = types ? types.concat([type]) : [type];

			cancelAnimationFrame(deferredTimer);
			deferredTimer = requestAnimationFrame(update);
		}

		function update() {
			if (types == null){
				return;
			}

			var source = {};
			for(var i = 0, x, length = types.length; i < length; i++){
				x = types[i];
				source[x] = getSource(x);
			}
			types = null;
			preview.update(source.javascript, source.style, source.mask);
		}

		////function setValue(editor, string) {
		////	var doc = new(editor.getSession().getDocument().constructor)(string);
		////
		////	editor.setSession(doc);
		////}

		function setValues(source){
			for (var key in editors) {
				if (!source[key]){
					continue;
				}
				editors[key].setValue(source[key], 1);
			}
			editors[app.compos.tabs.current()].focus();
		}

		var command = {
			name: "nextTab",
			bindKey: {
				mac: "Shift-Tab",
				win: "Shift-Tab"
			},
			exec: app.compos.tabs.next
		}

		for (var x in editors) {
			editors[x].on('change', deferUpdate.bind(this, x));
			editors[x].commands.addCommand(command);
			editors[x].setHighlightActiveLine(false);
			editors[x].setShowPrintMargin(false);
		}

		key('shift+tab', function(e) {
			app.compos.tabs.next();
			e.preventDefault();
			return false;
		});

		app.compos.ddMenu.$.on('selected', function(event, id) {
			setValues(ruqq.arr.first(resp.presets, 'id', '==', id));
		});

		var code = UrlCode.parse();
		if (code){
			setValues(code);
		}

		app.compos.btnSetLink.on('click', function(){
			UrlCode.set(getSource('javascript'), getSource('style'), getSource('mask'));
		});

		app.compos.btnShortend.on('click', function(){
			UrlCode.set(getSource('javascript'), getSource('style'), getSource('mask'));
			window.compo.shortendDialog.show().process(window.location.toString());
		});

	}());<commit_msg>[+] show collapsible sample if empty<commit_after>include.routes({
	component: '/script/{0}/{1}.js',
	vendor: '/.reference/libjs/vendor-lib/{0}/{1}.js',
	script: '/script/{0}.js'
}) //
.instance().js({
	ruqq: ['dom/jquery', 'utils', 'arr', 'es5shim'],
	lib: ['compo','ranimate'],
	component: ['preview', 'tabs', 'dropdownMenu', 'shortend-dialog'],
	vendor: 'keymaster',
	script: ['presets', 'urlcode']
}) //
.ready(function(resp) {


	window.app = (new(Class({
		Base: Compo,
		attr: {
			template: document.getElementById('layout').innerHTML
		},
		compos: {
			preview: 'compo: preview',
			tabs: 'compo: tabs',
			ddMenu: 'compo: dropdownMenu',
			btnSetLink: '$: #setLink',
			btnShortend: '$: #getShortend'
		}
	}))).render({
		presets: resp.presets
	}).insert(document.body);


	window.editors = {};

	function createEditor(type, highlight) {
		editors[type] = ace.edit('editor-' + type);
		editors[type].setTheme("ace/theme/monokai");
		editors[type].getSession().setMode("ace/mode/" + (highlight || type));
	}

	createEditor('mask', 'coffee');
	createEditor('javascript');
	createEditor('style', 'css');

	/** SETUP */

	(function() {



		var editors = window.editors,
			preview = app.compos.preview,
			deferredTimer,
			types;

		function getSource(type) {
			return editors[type].getValue();
		}

		////function deferUpdate() {
		////	clearTimeout(deferredTimer);
		////	deferredTimer = setTimeout(update, 400);
		////}

		function deferUpdate(type){
			if (types && !types.push){
				debugger;
			}

			types = types ? types.concat([type]) : [type];

			cancelAnimationFrame(deferredTimer);
			deferredTimer = requestAnimationFrame(update);
		}

		function update() {
			if (types == null){
				return;
			}

			var source = {};
			for(var i = 0, x, length = types.length; i < length; i++){
				x = types[i];
				source[x] = getSource(x);
			}
			types = null;
			preview.update(source.javascript, source.style, source.mask);
		}

		////function setValue(editor, string) {
		////	var doc = new(editor.getSession().getDocument().constructor)(string);
		////
		////	editor.setSession(doc);
		////}

		function setValues(source){
			for (var key in editors) {
				if (!source[key]){
					continue;
				}
				editors[key].setValue(source[key], 1);
			}
			editors[app.compos.tabs.current()].focus();
		}

		var command = {
			name: "nextTab",
			bindKey: {
				mac: "Shift-Tab",
				win: "Shift-Tab"
			},
			exec: app.compos.tabs.next
		}

		for (var x in editors) {
			editors[x].on('change', deferUpdate.bind(this, x));
			editors[x].commands.addCommand(command);
			editors[x].setHighlightActiveLine(false);
			editors[x].setShowPrintMargin(false);
		}

		key('shift+tab', function(e) {
			app.compos.tabs.next();
			e.preventDefault();
			return false;
		});

		app.compos.ddMenu.$.on('selected', function(event, id) {
			setValues(ruqq.arr.first(resp.presets, 'id', '==', id));
		});

		var code = UrlCode.parse();
		if (code){
			setValues(code);
		}else{
			setValues(resp.presets[1]);
		}

		app.compos.btnSetLink.on('click', function(){
			UrlCode.set(getSource('javascript'), getSource('style'), getSource('mask'));
		});

		app.compos.btnShortend.on('click', function(){
			UrlCode.set(getSource('javascript'), getSource('style'), getSource('mask'));
			window.compo.shortendDialog.show().process(window.location.toString());
		});

	}());
{'fraction_non_alphanumeric': 0.20348400660759874, 'fraction_numerical': 0.00345397206787806, 'mean_word_length': 3.6638655462184873, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4517985', 'n_tokens_mistral': 2704, 'n_tokens_neox': 2309, 'n_words': 399}