<commit_before>"use strict";
var columns = 0,
	target = '',
	API_KEY = 'd1b885b8d202ab320717b54d9265e360db151e69be811f38da2f24fdd09333a5',
	VTRANS_API = 'https://vtransapi.aot.state.vt.us/api/v2/',
	searchIndex=[],
	tags = [],
	tagIcons = {chart:"pie-chart", map:"map",data:"database"},
    iconPath = "http://www.aot.state.vt.us/legos/display/resources/icons/",
	extended = {};

function getView(name, callback) {
	$.get(VTRANS_API + "legos/_table/views?fields=*&related=*&order=layout_order asc&filter=view%3D" + name + "&api_key=" + API_KEY, function (response) {
		$.each(response.resource, function (i, r) {
			var block = {
				order: r.layout_order,
				className: r.className + " show-short",
				title: r.blocks.name,
				template: r.blocks.template,
				query: r.blocks.query,
				short: r.blocks.short,
				extended: r.blocks.extended,
				tags: [], 
                icons: [],
				blockId: 'block' + Math.random().toString().substring(4) + "-" + Math.random().toString().substring(3)
			};
			
			extended[block.blockId] = r.blocks.extended;
			
			$.each(r.tags, function (i, tag) {				            
                if (tag.tag in tagIcons){                 
                    block.icons.push('<i class="fa fa-' + tagIcons[tag.tag] + '" aria-hidden="true"></i>');               
                }else{
                    block.tags.push(tag.tag); 
                }
			});
			callback(block);
		});
	});
}

function createBrick(brick) {
	var firstNumber = /(\d+)/, // finds the first number, with no spaces, letters, etc.
		size = parseInt(firstNumber.exec(brick.className)[1]); //TODO different screen sizes?

	if (size + columns > 12) {
		$('body .container-fluid.bricks').append('<div class="row">');
		columns = 0;
	}
	
	var $html = $(Mustache.render('<div class="brick {{className}}" data-tags="{{#tags}}{{.}} {{/tags}}"><div class="card"></div></div>', brick));
	$('body .container-fluid.bricks>.row:last-of-type').append($html);
	
	columns += size;
	return $html;
}

function fillBrick(brick, data, template) {
	var $html = $(Mustache.render(template, data));
	$('.card', $(brick)).append($html);
	prepSearch();
}

function prepSearch() {
	searchIndex = [];
	tags = [];
	$('.brick').each(function (i, v) {
		searchIndex[i] = $('.short:not(".btn")', v).text().toLowerCase();
		searchIndex[i] += " " + $('.extended:not(".btn")', v).text().toLowerCase();
		searchIndex[i] += " " + (extended[$('.card-text', $(this))[0].id]).toLowerCase();
		searchIndex[i] += " " + $('h4', v).text().toLowerCase();<commit_msg>Don't need multiple rows because we're in flexbox<commit_after>"use strict";
var columns = 0,
	target = '',
	API_KEY = 'd1b885b8d202ab320717b54d9265e360db151e69be811f38da2f24fdd09333a5',
	VTRANS_API = 'https://vtransapi.aot.state.vt.us/api/v2/',
	searchIndex=[],
	tags = [],
	tagIcons = {chart:"pie-chart", map:"map",data:"database"},
    iconPath = "http://www.aot.state.vt.us/legos/display/resources/icons/",
	extended = {};

function getView(name, callback) {
	$.get(VTRANS_API + "legos/_table/views?fields=*&related=*&order=layout_order asc&filter=view%3D" + name + "&api_key=" + API_KEY, function (response) {
		$.each(response.resource, function (i, r) {
			var block = {
				order: r.layout_order,
				className: r.className + " show-short",
				title: r.blocks.name,
				template: r.blocks.template,
				query: r.blocks.query,
				short: r.blocks.short,
				extended: r.blocks.extended,
				tags: [], 
                icons: [],
				blockId: 'block' + Math.random().toString().substring(4) + "-" + Math.random().toString().substring(3)
			};
			
			extended[block.blockId] = r.blocks.extended;
			
			$.each(r.tags, function (i, tag) {				            
                if (tag.tag in tagIcons){                 
                    block.icons.push('<i class="fa fa-' + tagIcons[tag.tag] + '" aria-hidden="true"></i>');               
                }else{
                    block.tags.push(tag.tag); 
                }
			});
			callback(block);
		});
	});
}

function createBrick(brick) {
	var firstNumber = /(\d+)/, // finds the first number, with no spaces, letters, etc.
		size = parseInt(firstNumber.exec(brick.className)[1]); //TODO different screen sizes?

	/* if (size + columns > 12) { // i don't think we need this anymore now that we're flexboxing.
		$('body .container-fluid.bricks').append('<div class="row">');
		columns = 0;
	}*/
	
	var $html = $(Mustache.render('<div class="brick {{className}}" data-tags="{{#tags}}{{.}} {{/tags}}"><div class="card"></div></div>', brick));
	$('body .container-fluid.bricks>.row:last-of-type').append($html);
	
	columns += size;
	return $html;
}

function fillBrick(brick, data, template) {
	var $html = $(Mustache.render(template, data));
	$('.card', $(brick)).append($html);
	prepSearch();
}

function prepSearch() {
	searchIndex = [];
	tags = [];
	$('.brick').each(function (i, v) {
		searchIndex[i] = $('.short:not(".btn")', v).text().toLowerCase();
		searchIndex[i] += " " + $('.extended:not(".btn")', v).text().toLowerCase();
		searchIndex[i] += " " + (extended[$('.card-text', $(this))[0].id]).toLowerCase();
		searchIndex[i] += " " + $('h4', v).text().toLowerCase();
{'fraction_non_alphanumeric': 0.21243222308288148, 'fraction_numerical': 0.020526723470178157, 'mean_word_length': 3.2405582922824303, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '204659', 'n_tokens_mistral': 1988, 'n_tokens_neox': 1785, 'n_words': 313}