From 97a22e57c1ef3c3e41ed5666255c1e941df21f3e Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 20 Jul 2013 22:47:26 -0400 Subject: Remove imgcaptcha, this code is unused in any of our forks and needs work to get here back. Revert "Merge branch 'imgcaptcha' of https://github.com/asiekierka/Tinyboard" This reverts commit 49afb685c8e658c0f36b8171e176363538eb9419, reversing changes made to 2451a0f29c08e23ff36ef113082c112224f7e576. Conflicts: js/imgcaptcha.js --- js/imgcaptcha.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 js/imgcaptcha.js (limited to 'js') diff --git a/js/imgcaptcha.js b/js/imgcaptcha.js deleted file mode 100644 index 99aad414..00000000 --- a/js/imgcaptcha.js +++ /dev/null @@ -1,12 +0,0 @@ -function ic_odswiezKapcze() { - $.get(configRoot + "imgcaptcha_p.php", function(data) { - $("#imgcaptcha_hash").val(data); - $("#imgcaptcha_img").prop("src",configRoot + "imgcaptcha_im.php?cr=" + data); - }); -} -//function resetujKapcze() { -// $("#imgcaptcha_img").prop("src",configRoot + "zakrytek.png"); -//} -//$(document).ready(function(){ -// //resetujKapcze(); - to nie powinno byc na razie potrzebne -//}); -- cgit v1.3 From 9123161870f0bf935624f7668d28fd62d2a60f8e Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 21 Jul 2013 21:12:30 -0400 Subject: js/hide-threads.js: Simple thread-minimizing script --- js/hide-threads.js | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 js/hide-threads.js (limited to 'js') diff --git a/js/hide-threads.js b/js/hide-threads.js new file mode 100644 index 00000000..42475d2a --- /dev/null +++ b/js/hide-threads.js @@ -0,0 +1,74 @@ +/* + * hide-threads.js + * https://github.com/savetheinternet/Tinyboard/blob/master/js/hide-threads.js + * + * Released under the MIT license + * Copyright (c) 2013 Michael Save + * + * 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(); + $('[-] ') + .insertBefore(thread_container.find('p.fileinfo')) + .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(); + + $('[+] ') + .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')); + }); + if (hidden_data[board][id]) + thread_container.find('.hide-thread-link').click(); + }); +}); -- cgit v1.3 From 51361d02fb4b66a198dcdb5cd6350e6dada0aac9 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 21 Jul 2013 21:18:57 -0400 Subject: Strange bug in last commit --- js/hide-threads.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/hide-threads.js b/js/hide-threads.js index 42475d2a..135fbf51 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -45,7 +45,7 @@ $(document).ready(function(){ var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); var thread_container = $(this).parent(); $('[-] ') - .insertBefore(thread_container.find('p.fileinfo')) + .insertBefore(thread_container.find('p.fileinfo:first')) .click(function() { hidden_data[board][id] = Math.round(Date.now() / 1000); store_data(); @@ -66,7 +66,7 @@ $(document).ready(function(){ hidden_div.remove(); }); - hidden_div.insertAfter(thread_container.find('p.fileinfo')); + hidden_div.insertAfter(thread_container.find('p.fileinfo:first')); }); if (hidden_data[board][id]) thread_container.find('.hide-thread-link').click(); -- cgit v1.3 From e5663953b534f8098acff8f2942fdb81c2942acf Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 22 Jul 2013 10:14:08 -0400 Subject: Remove our post-hider script in favour of STI's one, leave symlink for compatibility --- js/post-hider.js | 54 +----------------------------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) mode change 100644 => 120000 js/post-hider.js (limited to 'js') diff --git a/js/post-hider.js b/js/post-hider.js deleted file mode 100644 index f4cde66a..00000000 --- a/js/post-hider.js +++ /dev/null @@ -1,53 +0,0 @@ -function phGetCookieName(board, id) { - return "ph_hide_" + board + "_" + id; -} -function phPostHidden(board, id) { - return (localStorage.getItem(phGetCookieName(board, id)) != null); -} -function phPostToggle(board, id) { - if(phPostHidden(board, id)) { localStorage.removeItem(phGetCookieName(board, id)); } - else { localStorage.setItem(phGetCookieName(board, id),"yes"); } -} -function phGetInnerText(board, id) { - if(phPostHidden(board, id)) { return "[+]"; } - else { return "[–]"; } -} -function phGetOpID(element) { - return Number(element.children("div.post.op").children("p.intro").children("a.post_no:eq(1)").text()); -} -function phGetOpBoard(element) { - return element.data("board"); -} -function phPostHandle(element) { - var id = phGetOpID(element); - var board = phGetOpBoard(element); - var preplies = element.children("div.post.reply"); - var pbody = element.children("div.post.op").children("div.body"); - var pimage = element.children("a:first").children("img"); - var pbutton = element.children("div.post.op").children("p.intro").children("a.posthider"); - var pomitted = element.children("div.post.op").children("span.omitted"); - if(phPostHidden(board, id)) { element.addClass("thread-hidden"); pomitted.hide(); preplies.hide(); pbody.hide(); pimage.hide(); pbutton.text("[+]"); } - else { element.removeClass("thread-hidden"); pomitted.show(); preplies.show(); pbody.show(); pimage.show(); pbutton.text("[–]"); } -} - -function phHandleThread(index, element) { - // Get thread ID. - var pin = $(this).children("div.post.op").children("p.intro"); - var tid = phGetOpID($(this)); - if(tid != NaN) { - $("[?]").insertAfter(pin.children('a:last')).click(function(e) { - var eO = $(e.target); - var par = eO.parent().parent().parent(); - phPostToggle(phGetOpBoard(par), phGetOpID(par)); - phPostHandle(par); - return false; - }); - phPostHandle($(this)); - } -} - -$(document).ready(function(){ - if (active_page != "thread") { - $('form[name="postcontrols"] > div[id^="thread"]').each(phHandleThread); - } -}); diff --git a/js/post-hider.js b/js/post-hider.js new file mode 120000 index 00000000..693c14d6 --- /dev/null +++ b/js/post-hider.js @@ -0,0 +1 @@ +hide-threads.js \ No newline at end of file -- cgit v1.3 From d111c6ab8c9ef12440c52974fc12ea61aa5c6ca1 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 22 Jul 2013 10:26:14 -0400 Subject: hide-threads.js: a bigger minus character --- js/hide-threads.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/hide-threads.js b/js/hide-threads.js index 135fbf51..5a9908f1 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -44,7 +44,7 @@ $(document).ready(function(){ $('div.post.op').each(function() { var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); var thread_container = $(this).parent(); - $('[-] ') + $('[–] ') .insertBefore(thread_container.find('p.fileinfo:first')) .click(function() { hidden_data[board][id] = Math.round(Date.now() / 1000); -- cgit v1.3 From 163df14b50eea0fd4b84342055130459c3b8035d Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 22 Jul 2013 10:26:14 -0400 Subject: hide-threads.js: a bigger minus character --- js/hide-threads.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/hide-threads.js b/js/hide-threads.js index 135fbf51..5a9908f1 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -44,7 +44,7 @@ $(document).ready(function(){ $('div.post.op').each(function() { var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); var thread_container = $(this).parent(); - $('[-] ') + $('[–] ') .insertBefore(thread_container.find('p.fileinfo:first')) .click(function() { hidden_data[board][id] = Math.round(Date.now() / 1000); -- cgit v1.3 From 51bd267764f7820c239b6c2a5e93be089c3e064d Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 20 Jul 2013 17:50:52 -0400 Subject: youtube.js: prevent default action of opening new window --- js/youtube.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js') diff --git a/js/youtube.js b/js/youtube.js index 482a9bc8..035796d8 100644 --- a/js/youtube.js +++ b/js/youtube.js @@ -29,6 +29,8 @@ onready(function(){ var videoID = $(this).data('video'); $(this).html('