diff --git a/CHANGELOG.md b/CHANGELOG.md index ba2930ee9..fcc3a9335 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +- Searching in the index will now show matched OPs by: + - comment + - subject + - filename + - name + - tripcode + - e-mail + ### 3.12.1 - *2013-11-04* - The index refreshing notification will now only appear on initial page load with slow connections. diff --git a/css/style.css b/css/style.css index 7968c10b4..07d983a9d 100644 --- a/css/style.css +++ b/css/style.css @@ -363,6 +363,7 @@ a[href="javascript:;"] { } /* Index */ +:root.index-loading .navLinks, :root.index-loading .board, :root.index-loading .pagelist { display: none; diff --git a/html/General/Index-navlinks.html b/html/General/Index-navlinks.html new file mode 100644 index 000000000..3ac6b2437 --- /dev/null +++ b/html/General/Index-navlinks.html @@ -0,0 +1,2 @@ +[Catalog]  + diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 715822858..e1818ec89 100644 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -162,39 +162,39 @@ Config = usercss: '' hotkeys: # Header, QR & Options - 'Toggle board list': ['Ctrl+b', 'Toggle the full board list.'] - 'Open empty QR': ['q', 'Open QR without post number inserted.'] - 'Open QR': ['Shift+q', 'Open QR with post number inserted.'] - 'Open settings': ['Alt+o', 'Open Settings.'] - 'Close': ['Esc', 'Close Settings, Notifications or QR.'] - 'Spoiler tags': ['Ctrl+s', 'Insert spoiler tags.'] - 'Code tags': ['Alt+c', 'Insert code tags.'] - 'Eqn tags': ['Alt+e', 'Insert eqn tags.'] - 'Math tags': ['Alt+m', 'Insert math tags.'] - 'Submit QR': ['Alt+s', 'Submit post.'] + 'Toggle board list': ['Ctrl+b', 'Toggle the full board list.'] + 'Open empty QR': ['q', 'Open QR without post number inserted.'] + 'Open QR': ['Shift+q', 'Open QR with post number inserted.'] + 'Open settings': ['Alt+o', 'Open Settings.'] + 'Close': ['Esc', 'Close Settings, Notifications or QR.'] + 'Spoiler tags': ['Ctrl+s', 'Insert spoiler tags.'] + 'Code tags': ['Alt+c', 'Insert code tags.'] + 'Eqn tags': ['Alt+e', 'Insert eqn tags.'] + 'Math tags': ['Alt+m', 'Insert math tags.'] + 'Submit QR': ['Alt+s', 'Submit post.'] # Index/Thread related - 'Update': ['r', 'Refresh the index/thread.'] - 'Watch': ['w', 'Watch thread.'] + 'Update': ['r', 'Refresh the index/thread.'] + 'Watch': ['w', 'Watch thread.'] # Images - 'Expand image': ['Shift+e', 'Expand selected image.'] - 'Expand images': ['e', 'Expand all images.'] + 'Expand image': ['Shift+e', 'Expand selected image.'] + 'Expand images': ['e', 'Expand all images.'] # Board Navigation - 'Front page': ['0', 'Jump to page 0.'] - 'Open front page': ['Shift+0', 'Open page 0 in a new tab.'] - 'Next page': ['Right', 'Jump to the next page.'] - 'Previous page': ['Left', 'Jump to the previous page.'] - 'Search form': ['Ctrl+Alt+s', 'Open the search field on the board index.'] + 'Front page': ['0', 'Jump to page 0.'] + 'Open front page': ['Shift+0', 'Open page 0 in a new tab.'] + 'Next page': ['Right', 'Jump to the next page.'] + 'Previous page': ['Left', 'Jump to the previous page.'] + 'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.'] # Thread Navigation - 'Next thread': ['Down', 'See next thread.'] - 'Previous thread': ['Up', 'See previous thread.'] - 'Expand thread': ['Ctrl+e', 'Expand thread.'] - 'Open thread': ['o', 'Open thread in current tab.'] - 'Open thread tab': ['Shift+o', 'Open thread in new tab.'] + 'Next thread': ['Down', 'See next thread.'] + 'Previous thread': ['Up', 'See previous thread.'] + 'Expand thread': ['Ctrl+e', 'Expand thread.'] + 'Open thread': ['o', 'Open thread in current tab.'] + 'Open thread tab': ['Shift+o', 'Open thread in new tab.'] # Reply Navigation - 'Next reply': ['j', 'Select next reply.'] - 'Previous reply': ['k', 'Select previous reply.'] - 'Deselect reply': ['Shift+d', 'Deselect reply.'] - 'Hide': ['x', 'Hide thread.'] + 'Next reply': ['j', 'Select next reply.'] + 'Previous reply': ['k', 'Select previous reply.'] + 'Deselect reply': ['Shift+d', 'Deselect reply.'] + 'Hide': ['x', 'Hide thread.'] updater: checkbox: 'Beep': [false, 'Beep on new post to completely read thread.'] diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 60dfed9e9..4591ee706 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -50,13 +50,21 @@ Index = className: 'pagelist' hidden: true innerHTML: <%= importHTML('General/Index-pagelist') %> + @navLinks = $.el 'div', + className: 'navLinks' + innerHTML: <%= importHTML('General/Index-navlinks') %> + @searchInput = $ '#index-search', @navLinks @currentPage = @getCurrentPage() $.on window, 'popstate', @cb.popstate $.on @pagelist, 'click', @cb.pageNav + $.on @searchInput, 'input', @onSearchInput $.asap (-> $('.pagelist', doc) or d.readyState isnt 'loading'), -> $.replace $('.board'), Index.root $.replace $('.pagelist'), Index.pagelist $.rmClass doc, 'index-loading' + for navLink in $$ '.navLinks' + $.rm navLink + $.after $.x('child::form/preceding-sibling::hr'), Index.navLinks cb: mode: -> @@ -276,13 +284,14 @@ Index = offset = 0 for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isSticky Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)... - return unless Conf['Filter'] - # Put the highlighted thread &
on top of the index - # while keeping the original order they appear in. - offset = 0 - for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isOnTop - Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)... - return + if Conf['Filter'] + # Put the highlighted thread &
on top of the index + # while keeping the original order they appear in. + offset = 0 + for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isOnTop + Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)... + if Index.searchInput.value + Index.sortedNodes = Index.querySearch(Index.searchInput.value) or Index.sortedNodes buildIndex: -> if Conf['Index Mode'] is 'paged' pageNum = Index.getCurrentPage() @@ -294,3 +303,24 @@ Index = Index.buildReplies nodes $.event 'IndexBuild', nodes $.add Index.root, nodes + + onSearchInput: -> + Index.sort() + Index.buildIndex() + querySearch: (query) -> + return unless keywords = query.toLowerCase().match /\S+/g + Index.search keywords + search: (keywords) -> + found = [] + for threadRoot, i in Index.sortedNodes by 2 + {OP} = Get.threadFromRoot threadRoot + text = [] + for key in ['comment', 'subject', 'name', 'tripcode', 'email'] + text.push OP.info[key] if key of OP.info + text.push OP.file.name if 'file' of OP + text = text.join(' ').toLowerCase() + for keyword in keywords + continue if -1 is text.indexOf keyword + found.push Index.sortedNodes[i], Index.sortedNodes[i + 1] + break + found diff --git a/src/General/Post.coffee b/src/General/Post.coffee index 901405495..5cb484309 100644 --- a/src/General/Post.coffee +++ b/src/General/Post.coffee @@ -49,7 +49,7 @@ class Post @parseComment() @parseQuotes() - @parseFile(that) + @parseFile that @clones = [] g.posts[@fullID] = thread.posts[@] = board.posts[@] = @ diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 5388ebc89..76d817825 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -87,7 +87,7 @@ Keybinds = return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged' $('.prev button', Index.pagelist).click() when Conf['Search form'] - $.id('search-btn').click() + Index.searchInput.focus() # Thread Navigation when Conf['Next thread'] return if g.VIEW isnt 'index'