<commit_before>/*
 * hide-threads.js
 * https://github.com/savetheinternet/Tinyboard/blob/master/js/hide-threads.js
 *
 * Released under the MIT license
 * Copyright (c) 2013 <NAME> <<EMAIL>>
 *
 * Usage:
 *   $config['additional_javascript'][] = 'js/jquery.min.js';
 *   $config['additional_javascript'][] = 'js/hide-threads.js';
 *
 */

$(document).ready(function(){
	if($('div.banner').length != 0)
		return; // not index
	
	var board = $('form input[name="board"]').val().toString();
	
	if (!localStorage.hiddenthreads)
		localStorage.hiddenthreads = '{}';
	
	// Load data from HTML5 localStorage
	var hidden_data = JSON.parse(localStorage.hiddenthreads);
	
	var store_data = function() {
		localStorage.hiddenthreads = JSON.stringify(hidden_data);
	};
	
	// Delete old hidden threads (7+ days old)
	for (var key in hidden_data) {
		for (var id in hidden_data[key]) {
			if (hidden_data[key][id] < Math.round(Date.now() / 1000) - 60 * 60 * 24 * 7) {
				delete hidden_data[key][id];
				store_data();
			}
		}
	}
	
	if (!hidden_data[board]) {
		hidden_data[board] = {}; // id : timestamp
	}
	
	$('div.post.op').each(function() {
		var id = $(this).children('p.intro').children('a.post_no:eq(1)').text();
		var thread_container = $(this).parent();
		$('<a class="hide-thread-link" style="float:left;margin-right:5px" href="javascript:void(0)">[–]</a><span> </span>')
			.insertBefore(thread_container.find(':first'))
			.click(function() {
				hidden_data[board][id] = Math.round(Date.now() / 1000);
				store_data();
				
				thread_container.find('div.post,img,p.fileinfo,a.hide-thread-link,br').hide();
				
				var hidden_div = thread_container.find('div.post.op > p.intro').clone();
				hidden_div.addClass('thread-hidden');
				hidden_div.find('a[href],input').remove();
				hidden_div.html(hidden_div.html().replace(' [] ', ' '));
				
				$('<a class="unhide-thread-link" style="float:left;margin-right:5px" href="javascript:void(0)">[+]</a><span> </span>')
					.insertAfter(thread_container.find('a.hide-thread-link'))
					.click(function() {
						delete hidden_data[board][id];
						store_data();
						thread_container.find('div.post,img,p.fileinfo,a.hide-thread-link,br').show();
						$(this).remove();
						hidden_div.remove();
					});
				
				hidden_div.insertAfter(thread_container.find('p.fileinfo:first'));
			});
		if (hidden_data[board][id])
			thread_container.find('.hide-thread-link').click();
	});
});<commit_msg>hide-threads.js: fix previous commit<commit_after>/*
 * hide-threads.js
 * https://github.com/savetheinternet/Tinyboard/blob/master/js/hide-threads.js
 *
 * Released under the MIT license
 * Copyright (c) 2013 <NAME> <<EMAIL>>
 *
 * Usage:
 *   $config['additional_javascript'][] = 'js/jquery.min.js';
 *   $config['additional_javascript'][] = 'js/hide-threads.js';
 *
 */

$(document).ready(function(){
	if($('div.banner').length != 0)
		return; // not index
	
	var board = $('form input[name="board"]').val().toString();
	
	if (!localStorage.hiddenthreads)
		localStorage.hiddenthreads = '{}';
	
	// Load data from HTML5 localStorage
	var hidden_data = JSON.parse(localStorage.hiddenthreads);
	
	var store_data = function() {
		localStorage.hiddenthreads = JSON.stringify(hidden_data);
	};
	
	// Delete old hidden threads (7+ days old)
	for (var key in hidden_data) {
		for (var id in hidden_data[key]) {
			if (hidden_data[key][id] < Math.round(Date.now() / 1000) - 60 * 60 * 24 * 7) {
				delete hidden_data[key][id];
				store_data();
			}
		}
	}
	
	if (!hidden_data[board]) {
		hidden_data[board] = {}; // id : timestamp
	}
	
	$('div.post.op').each(function() {
		var id = $(this).children('p.intro').children('a.post_no:eq(1)').text();
		var thread_container = $(this).parent();
		$('<a class="hide-thread-link" style="float:left;margin-right:5px" href="javascript:void(0)">[–]</a><span> </span>')
			.insertBefore(thread_container.find(':first'))
			.click(function() {
				hidden_data[board][id] = Math.round(Date.now() / 1000);
				store_data();
				
				thread_container.find('div.post,img,p.fileinfo,a.hide-thread-link,br').hide();
				
				var hidden_div = thread_container.find('div.post.op > p.intro').clone();
				hidden_div.addClass('thread-hidden');
				hidden_div.find('a[href],input').remove();
				hidden_div.html(hidden_div.html().replace(' [] ', ' '));
				
				$('<a class="unhide-thread-link" style="float:left;margin-right:5px" href="javascript:void(0)">[+]</a><span> </span>')
					.insertAfter(thread_container.find('a.hide-thread-link'))
					.click(function() {
						delete hidden_data[board][id];
						store_data();
						thread_container.find('div.post,img,p.fileinfo,a.hide-thread-link,br').show();
						$(this).remove();
						hidden_div.remove();
					});
				
				hidden_div.insertAfter(thread_container.find(':first'));
			});
		if (hidden_data[board][id])
			thread_container.find('.hide-thread-link').click();
	});
});
{'fraction_non_alphanumeric': 0.20623598940289384, 'fraction_numerical': 0.011004687181577339, 'mean_word_length': 4.075491209927611, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 2, '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': '4467773', 'n_tokens_mistral': 1997, 'n_tokens_neox': 1686, 'n_words': 243}