Add index searching. Close #1318
This commit is contained in:
parent
c318fb37b9
commit
a8209eaa89
@ -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.
|
||||
|
||||
@ -363,6 +363,7 @@ a[href="javascript:;"] {
|
||||
}
|
||||
|
||||
/* Index */
|
||||
:root.index-loading .navLinks,
|
||||
:root.index-loading .board,
|
||||
:root.index-loading .pagelist {
|
||||
display: none;
|
||||
|
||||
2
html/General/Index-navlinks.html
Normal file
2
html/General/Index-navlinks.html
Normal file
@ -0,0 +1,2 @@
|
||||
[<a href="./catalog">Catalog</a>]
|
||||
<input type="search" id="index-search" placeholder="Search">
|
||||
@ -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.']
|
||||
|
||||
@ -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 & <hr> 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 & <hr> 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
|
||||
|
||||
@ -49,7 +49,7 @@ class Post
|
||||
|
||||
@parseComment()
|
||||
@parseQuotes()
|
||||
@parseFile(that)
|
||||
@parseFile that
|
||||
|
||||
@clones = []
|
||||
g.posts[@fullID] = thread.posts[@] = board.posts[@] = @
|
||||
|
||||
@ -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'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user