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*
|
### 3.12.1 - *2013-11-04*
|
||||||
|
|
||||||
- The index refreshing notification will now only appear on initial page load with slow connections.
|
- The index refreshing notification will now only appear on initial page load with slow connections.
|
||||||
|
|||||||
@ -363,6 +363,7 @@ a[href="javascript:;"] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Index */
|
/* Index */
|
||||||
|
:root.index-loading .navLinks,
|
||||||
:root.index-loading .board,
|
:root.index-loading .board,
|
||||||
:root.index-loading .pagelist {
|
:root.index-loading .pagelist {
|
||||||
display: none;
|
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: ''
|
usercss: ''
|
||||||
hotkeys:
|
hotkeys:
|
||||||
# Header, QR & Options
|
# Header, QR & Options
|
||||||
'Toggle board list': ['Ctrl+b', 'Toggle the full board list.']
|
'Toggle board list': ['Ctrl+b', 'Toggle the full board list.']
|
||||||
'Open empty QR': ['q', 'Open QR without post number inserted.']
|
'Open empty QR': ['q', 'Open QR without post number inserted.']
|
||||||
'Open QR': ['Shift+q', 'Open QR with post number inserted.']
|
'Open QR': ['Shift+q', 'Open QR with post number inserted.']
|
||||||
'Open settings': ['Alt+o', 'Open Settings.']
|
'Open settings': ['Alt+o', 'Open Settings.']
|
||||||
'Close': ['Esc', 'Close Settings, Notifications or QR.']
|
'Close': ['Esc', 'Close Settings, Notifications or QR.']
|
||||||
'Spoiler tags': ['Ctrl+s', 'Insert spoiler tags.']
|
'Spoiler tags': ['Ctrl+s', 'Insert spoiler tags.']
|
||||||
'Code tags': ['Alt+c', 'Insert code tags.']
|
'Code tags': ['Alt+c', 'Insert code tags.']
|
||||||
'Eqn tags': ['Alt+e', 'Insert eqn tags.']
|
'Eqn tags': ['Alt+e', 'Insert eqn tags.']
|
||||||
'Math tags': ['Alt+m', 'Insert math tags.']
|
'Math tags': ['Alt+m', 'Insert math tags.']
|
||||||
'Submit QR': ['Alt+s', 'Submit post.']
|
'Submit QR': ['Alt+s', 'Submit post.']
|
||||||
# Index/Thread related
|
# Index/Thread related
|
||||||
'Update': ['r', 'Refresh the index/thread.']
|
'Update': ['r', 'Refresh the index/thread.']
|
||||||
'Watch': ['w', 'Watch thread.']
|
'Watch': ['w', 'Watch thread.']
|
||||||
# Images
|
# Images
|
||||||
'Expand image': ['Shift+e', 'Expand selected image.']
|
'Expand image': ['Shift+e', 'Expand selected image.']
|
||||||
'Expand images': ['e', 'Expand all images.']
|
'Expand images': ['e', 'Expand all images.']
|
||||||
# Board Navigation
|
# Board Navigation
|
||||||
'Front page': ['0', 'Jump to page 0.']
|
'Front page': ['0', 'Jump to page 0.']
|
||||||
'Open front page': ['Shift+0', 'Open page 0 in a new tab.']
|
'Open front page': ['Shift+0', 'Open page 0 in a new tab.']
|
||||||
'Next page': ['Right', 'Jump to the next page.']
|
'Next page': ['Right', 'Jump to the next page.']
|
||||||
'Previous page': ['Left', 'Jump to the previous page.']
|
'Previous page': ['Left', 'Jump to the previous page.']
|
||||||
'Search form': ['Ctrl+Alt+s', 'Open the search field on the board index.']
|
'Search form': ['Ctrl+Alt+s', 'Focus the search field on the board index.']
|
||||||
# Thread Navigation
|
# Thread Navigation
|
||||||
'Next thread': ['Down', 'See next thread.']
|
'Next thread': ['Down', 'See next thread.']
|
||||||
'Previous thread': ['Up', 'See previous thread.']
|
'Previous thread': ['Up', 'See previous thread.']
|
||||||
'Expand thread': ['Ctrl+e', 'Expand thread.']
|
'Expand thread': ['Ctrl+e', 'Expand thread.']
|
||||||
'Open thread': ['o', 'Open thread in current tab.']
|
'Open thread': ['o', 'Open thread in current tab.']
|
||||||
'Open thread tab': ['Shift+o', 'Open thread in new tab.']
|
'Open thread tab': ['Shift+o', 'Open thread in new tab.']
|
||||||
# Reply Navigation
|
# Reply Navigation
|
||||||
'Next reply': ['j', 'Select next reply.']
|
'Next reply': ['j', 'Select next reply.']
|
||||||
'Previous reply': ['k', 'Select previous reply.']
|
'Previous reply': ['k', 'Select previous reply.']
|
||||||
'Deselect reply': ['Shift+d', 'Deselect reply.']
|
'Deselect reply': ['Shift+d', 'Deselect reply.']
|
||||||
'Hide': ['x', 'Hide thread.']
|
'Hide': ['x', 'Hide thread.']
|
||||||
updater:
|
updater:
|
||||||
checkbox:
|
checkbox:
|
||||||
'Beep': [false, 'Beep on new post to completely read thread.']
|
'Beep': [false, 'Beep on new post to completely read thread.']
|
||||||
|
|||||||
@ -50,13 +50,21 @@ Index =
|
|||||||
className: 'pagelist'
|
className: 'pagelist'
|
||||||
hidden: true
|
hidden: true
|
||||||
innerHTML: <%= importHTML('General/Index-pagelist') %>
|
innerHTML: <%= importHTML('General/Index-pagelist') %>
|
||||||
|
@navLinks = $.el 'div',
|
||||||
|
className: 'navLinks'
|
||||||
|
innerHTML: <%= importHTML('General/Index-navlinks') %>
|
||||||
|
@searchInput = $ '#index-search', @navLinks
|
||||||
@currentPage = @getCurrentPage()
|
@currentPage = @getCurrentPage()
|
||||||
$.on window, 'popstate', @cb.popstate
|
$.on window, 'popstate', @cb.popstate
|
||||||
$.on @pagelist, 'click', @cb.pageNav
|
$.on @pagelist, 'click', @cb.pageNav
|
||||||
|
$.on @searchInput, 'input', @onSearchInput
|
||||||
$.asap (-> $('.pagelist', doc) or d.readyState isnt 'loading'), ->
|
$.asap (-> $('.pagelist', doc) or d.readyState isnt 'loading'), ->
|
||||||
$.replace $('.board'), Index.root
|
$.replace $('.board'), Index.root
|
||||||
$.replace $('.pagelist'), Index.pagelist
|
$.replace $('.pagelist'), Index.pagelist
|
||||||
$.rmClass doc, 'index-loading'
|
$.rmClass doc, 'index-loading'
|
||||||
|
for navLink in $$ '.navLinks'
|
||||||
|
$.rm navLink
|
||||||
|
$.after $.x('child::form/preceding-sibling::hr'), Index.navLinks
|
||||||
|
|
||||||
cb:
|
cb:
|
||||||
mode: ->
|
mode: ->
|
||||||
@ -276,13 +284,14 @@ Index =
|
|||||||
offset = 0
|
offset = 0
|
||||||
for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isSticky
|
for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isSticky
|
||||||
Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)...
|
Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)...
|
||||||
return unless Conf['Filter']
|
if Conf['Filter']
|
||||||
# Put the highlighted thread & <hr> on top of the index
|
# Put the highlighted thread & <hr> on top of the index
|
||||||
# while keeping the original order they appear in.
|
# while keeping the original order they appear in.
|
||||||
offset = 0
|
offset = 0
|
||||||
for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isOnTop
|
for threadRoot, i in Index.sortedNodes by 2 when Get.threadFromRoot(threadRoot).isOnTop
|
||||||
Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)...
|
Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)...
|
||||||
return
|
if Index.searchInput.value
|
||||||
|
Index.sortedNodes = Index.querySearch(Index.searchInput.value) or Index.sortedNodes
|
||||||
buildIndex: ->
|
buildIndex: ->
|
||||||
if Conf['Index Mode'] is 'paged'
|
if Conf['Index Mode'] is 'paged'
|
||||||
pageNum = Index.getCurrentPage()
|
pageNum = Index.getCurrentPage()
|
||||||
@ -294,3 +303,24 @@ Index =
|
|||||||
Index.buildReplies nodes
|
Index.buildReplies nodes
|
||||||
$.event 'IndexBuild', nodes
|
$.event 'IndexBuild', nodes
|
||||||
$.add Index.root, 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()
|
@parseComment()
|
||||||
@parseQuotes()
|
@parseQuotes()
|
||||||
@parseFile(that)
|
@parseFile that
|
||||||
|
|
||||||
@clones = []
|
@clones = []
|
||||||
g.posts[@fullID] = thread.posts[@] = board.posts[@] = @
|
g.posts[@fullID] = thread.posts[@] = board.posts[@] = @
|
||||||
|
|||||||
@ -87,7 +87,7 @@ Keybinds =
|
|||||||
return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged'
|
return unless g.VIEW is 'index' and Conf['Index Mode'] is 'paged'
|
||||||
$('.prev button', Index.pagelist).click()
|
$('.prev button', Index.pagelist).click()
|
||||||
when Conf['Search form']
|
when Conf['Search form']
|
||||||
$.id('search-btn').click()
|
Index.searchInput.focus()
|
||||||
# Thread Navigation
|
# Thread Navigation
|
||||||
when Conf['Next thread']
|
when Conf['Next thread']
|
||||||
return if g.VIEW isnt 'index'
|
return if g.VIEW isnt 'index'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user