diff --git a/js/catalog.js b/js/catalog.js index 18da6d6b..065fba7b 100644 --- a/js/catalog.js +++ b/js/catalog.js @@ -6,26 +6,6 @@ if (active_page == 'catalog') $(function(){ localStorage.catalog = JSON.stringify(catalog); } - if (localStorage.hiddenthreads) { - var hidden_data = JSON.parse(localStorage.hiddenthreads); - - if (hidden_data[board_name] && !$.isEmptyObject(hidden_data[board_name])) { - $.each(hidden_data[board_name], function(k, v) { - $('a[href$="/'+k+'.html"]').parents('.mix').remove(); - }); - } - } else { - hidden_data = {}; - } - - $(document).on('click', '.mix', function(e) { - if (e.shiftKey) { - hidden_data[board_name][$(this).data('id')] = Math.round(Date.now() / 1000); - $(this).remove(); - localStorage.hiddenthreads = JSON.stringify(hidden_data); - } - }); - $("#sort_by").change(function(){ var value = this.value; $('#Grid').mixItUp('sort', (value == "random" ? value : "sticky:desc " + value)); diff --git a/js/post-filter.js b/js/post-filter.js index 9ec28262..28e02f78 100644 --- a/js/post-filter.js +++ b/js/post-filter.js @@ -1,4 +1,4 @@ -if (active_page === 'thread' || active_page === 'index') { +if (active_page === 'thread' || active_page === 'index' || active_page === 'catalog') { $(document).ready(function () { 'use strict'; // returns blacklist object from storage @@ -408,13 +408,13 @@ if (active_page === 'thread' || active_page === 'index') { if (!forcedAnon && hasTrip) trip = $post.find('.trip').text(); if (hasSub) - subject = ' '+ $post.find('.subject').text() +' '; + subject = $post.find('.subject').text(); array = $post.find('.body').contents().filter(function () {if ($(this).text() !== '') return true;}).toArray(); array = $.map(array, function (ele) { return $(ele).text(); }); - comment = ' '+ array.join(' ') +' '; + comment = array.join(' '); for (i = 0, length = list.generalFilter.length; i < length; i++) { @@ -430,7 +430,7 @@ if (active_page === 'thread' || active_page === 'index') { } break; case 'trip': - if (!forcedAnon && pattern.test(trip)) { + if (!forcedAnon && hasTrip && pattern.test(trip)) { $post.data('hiddenByTrip', true); hide(post); } @@ -463,13 +463,15 @@ if (active_page === 'thread' || active_page === 'index') { } break; case 'sub': - if (hasSub && subject.indexOf(' '+ rule.value +' ') != -1) { + pattern = new RegExp('\\b'+ rule.value+ '\\b'); + if (hasSub && pattern.test(subject)) { $post.data('hiddenBySubject', true); hide(post); } break; case 'com': - if (comment.indexOf(' '+ rule.value +' ') != -1) { + pattern = new RegExp('\\b'+ rule.value+ '\\b'); + if (pattern.test(comment)) { $post.data('hiddenByComment', true); hide(post); } @@ -502,43 +504,63 @@ if (active_page === 'thread' || active_page === 'index') { function filterPage(pageData) { var list = getList(); - // empty the local and no-reply list - pageData.localList = []; - pageData.noReplyList = []; + if (active_page != 'catalog') { - $('.thread').each(function () { - var $thread = $(this); - // disregard the hidden threads constructed by post-hover.js - if ($thread.css('display') == 'none') - return; + // empty the local and no-reply list + pageData.localList = []; + pageData.noReplyList = []; + + $('.thread').each(function () { + var $thread = $(this); + // disregard the hidden threads constructed by post-hover.js + if ($thread.css('display') == 'none') + return; - var threadId = $thread.attr('id').replace('thread_', ''); - var op = $thread.children('.op')[0]; - var i, array; // temp variables + var threadId = $thread.attr('id').replace('thread_', ''); + var op = $thread.children('.op')[0]; + var i, array; // temp variables - // add posts to localList and noReplyList - if (typeof list.postFilter[pageData.boardId] != 'undefined' && typeof list.postFilter[pageData.boardId][threadId] != 'undefined') { - array = list.postFilter[pageData.boardId][threadId]; - for (i=0; i'); $row.append( - ''+ typeName[obj.type] +'', - ''+ val +'', - $('').append( - $('').html('X') - .addClass('del-btn') - .attr('href', '#') - .data('type', obj.type) - .data('val', obj.value) - .data('useRegex', obj.regex) - ) - ); + ''+ typeName[obj.type] +'', + ''+ val +'', + $('').append( + $('').html('X') + .addClass('del-btn') + .attr('href', '#') + .data('type', obj.type) + .data('val', obj.value) + .data('useRegex', obj.regex) + ) + ); $ele.append($row); } } @@ -754,33 +776,6 @@ if (active_page === 'thread' || active_page === 'index') { }); } - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Migrate from previous version of post filter - * Remember to remove next time anyone touches this file - */ - (function () { - var list = getList(); - if (typeof list.nameFilter != 'undefined') { - var filter = list.nameFilter; - list.generalFilter = []; - - for (var i = 0; i < filter.length; i++) { - var obj = filter[i]; - for (var key in obj) { - list.generalFilter.push({ - type: key, - value: obj[key], - regex: false - }); - } - } - - delete list.nameFilter; - localStorage.postFilter = JSON.stringify(list); - } - })(); - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - var pageData = { boardId: board_name, // get the id from the global variable localList: [], // all the blacklisted post IDs or UIDs that apply to the current page @@ -812,6 +807,17 @@ if (active_page === 'thread' || active_page === 'index') { filterPage(pageData); }); + // shift+click on catalog to hide thread + if (active_page == 'catalog') { + $(document).on('click', '.mix', function(e) { + if (e.shiftKey) { + var threadId = $(this).data('id'); + var postId = threadId; + blacklist.add.post(pageData.boardId, threadId, postId, false); + } + }); + } + // clear out the old threads purge(); }