<commit_before>jQuery(document).ready(function($){

	// load all relevant data first and prepare an intermediate array

	var github_logo_folders = 'https://api.github.com/repos/endofline/sabah.io/contents/logos/';
	var github_raw_url = 'https://raw.githubusercontent.com/endofline/sabah.io/master/'
	
	$.getJSON(github_logo_folders, function(folderlist){
		var image_store = [];

		$.each(folderlist, function(i, folderobj){
			image_store.push({
				'thumbnail-path': github_raw_url + folderobj.path + '/small.png',
			});
		});

		render_images(image_store);
	})
	.fail(function(e){
		console.log('something went wrong fetching data');
	});

	function render_images(image_store)
	{
		// randomly load images into the thumbnail grid

		var image_count = image_store.length;

		console.log(image_count, ' loaded');

		if(image_count > 0)
		{
			$.each($('#thumbnail-grid .thumbnail'), function(enumeration, thumbnailElement){
				var store_id = Math.floor(Math.random() * image_count); // use a better random number generator and tie it with votes?

				var imageObj = image_store[store_id];

				$(thumbnailElement).css('background-image', 'url(' + imageObj['thumbnail-path'] + ')');
				$(thumbnailElement).css('background-color', Math.floor(Math.random()*16777215).toString(16));
			});
		}
		else
		{
			console.log('nothing to display');
		}
	}

	// clicking/tapping will "pin" the label

	var $currentPinned = false;
	$('div.thumbnail').click(function(e){
		var $element = $(this);

		if($currentPinned)
		{
			$currentPinned.removeClass('pinned');

			if($currentPinned[0] == $element[0])
			{
				$currentPinned = false;
				return false;
			}
		}

		$currentPinned = $element;
		$currentPinned.addClass('pinned');
		console.log('on');
	});
	
	var thumbnailWidth = 150;
	var thumbnailHeight = 150;
	var $thumbnailCanvas = $('#thumbnail-grid');
	var $thumbnailTemplate = $('#thumbnail-template').detach();
	
	$(window).resize(function(e){
		var fullWidth = $(window).width();
		var fullHeight = $(window).height();
		
		var noOfColumns = Math.ceil(fullWidth / thumbnailWidth);
		var noOfRows = Math.ceil(fullHeight / thumbnailHeight);
		var totalNumberOfThumbnails = noOfColumns * noOfRows;
		
		$thumbnailCanvas.empty();
		
		for(var i = 0; i < totalNumberOfThumbnails; i++)
		{
			var _clone = $thumbnailTemplate.clone();
			_clone.removeAttr('id').appendTo($thumbnailCanvas);
		}
		
		$thumbnailCanvas.css({
			'width': (noOfColumns * thumbnailWidth) + 'px',
			'height': (noOfRows * thumbnailHeight) + 'px',
			'margin-top': '-' + Math.round(thumbnailHeight/3) + 'px',
			'margin-left': '-' + Math.round(thumbnailWidth/3) + 'px',
		});
	});
	
	$(window).resize();<commit_msg>minor ui tweak, need better calculation for width<commit_after>jQuery(document).ready(function($){

	// load all relevant data first and prepare an intermediate array

	var github_logo_folders = 'https://api.github.com/repos/endofline/sabah.io/contents/logos/';
	var github_raw_url = 'https://raw.githubusercontent.com/endofline/sabah.io/master/'
	
	$.getJSON(github_logo_folders, function(folderlist){
		var image_store = [];

		$.each(folderlist, function(i, folderobj){
			image_store.push({
				'thumbnail-path': github_raw_url + folderobj.path + '/small.png',
			});
		});

		render_images(image_store);
	})
	.fail(function(e){
		console.log('something went wrong fetching data');
	});

	function render_images(image_store)
	{
		// randomly load images into the thumbnail grid

		var image_count = image_store.length;

		console.log(image_count, ' loaded');

		if(image_count > 0)
		{
			$.each($('#thumbnail-grid .thumbnail'), function(enumeration, thumbnailElement){
				var store_id = Math.floor(Math.random() * image_count); // use a better random number generator and tie it with votes?

				var imageObj = image_store[store_id];

				$(thumbnailElement).css('background-image', 'url(' + imageObj['thumbnail-path'] + ')');
				$(thumbnailElement).css('background-color', Math.floor(Math.random()*16777215).toString(16));
			});
		}
		else
		{
			console.log('nothing to display');
		}
	}

	// clicking/tapping will "pin" the label

	var $currentPinned = false;
	$('div.thumbnail').click(function(e){
		var $element = $(this);

		if($currentPinned)
		{
			$currentPinned.removeClass('pinned');

			if($currentPinned[0] == $element[0])
			{
				$currentPinned = false;
				return false;
			}
		}

		$currentPinned = $element;
		$currentPinned.addClass('pinned');
		console.log('on');
	});
	
	var thumbnailWidth = 150;
	var thumbnailHeight = 150;
	var $thumbnailCanvas = $('#thumbnail-grid');
	var $thumbnailTemplate = $('#thumbnail-template').detach();
	
	$(window).resize(function(e){
		var fullWidth = $(window).width();
		var fullHeight = $(window).height();
		
		var noOfColumns = Math.ceil(fullWidth / thumbnailWidth);
		var noOfRows = Math.ceil(fullHeight / thumbnailHeight);
		var totalNumberOfThumbnails = noOfColumns * noOfRows;
		
		$thumbnailCanvas.empty();
		
		for(var i = 0; i < totalNumberOfThumbnails; i++)
		{
			var _clone = $thumbnailTemplate.clone();
			_clone.removeAttr('id').appendTo($thumbnailCanvas);
		}
		
		$thumbnailCanvas.css({
			// 'margin-top': '-' + Math.round(thumbnailHeight/3) + 'px',
			// 'margin-left': '-' + Math.round(thumbnailWidth/3) + 'px',
			'width': (noOfColumns * thumbnailWidth) + 'px',
			'height': (noOfRows * thumbnailHeight) + 'px'
		});
	});
	
	$(window).resize();
{'fraction_non_alphanumeric': 0.1666358765933863, 'fraction_numerical': 0.008128579346018844, 'mean_word_length': 4.235976789168278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '6751442', 'n_tokens_mistral': 2063, 'n_tokens_neox': 1790, 'n_words': 336}