It's more efficient for us for this to be where it was

But it doesn't help anyone else. IndexBuild shouldn't be thrown
until the Index is actually build so people can deal with the nodes
This commit is contained in:
Zixaphir 2014-01-10 19:52:38 -07:00
parent 44f2b5e434
commit b5f357bcfe
3 changed files with 18 additions and 5 deletions

View File

@ -2710,8 +2710,8 @@
if (Conf['Show Replies']) { if (Conf['Show Replies']) {
Index.buildReplies(nodes); Index.buildReplies(nodes);
} }
$.event('IndexBuild', nodes); $.add(Index.root, nodes);
return $.add(Index.root, nodes); return $.event('IndexBuild', nodes);
}, },
isSearching: false, isSearching: false,
clearSearch: function() { clearSearch: function() {

View File

@ -2720,8 +2720,8 @@
if (Conf['Show Replies']) { if (Conf['Show Replies']) {
Index.buildReplies(nodes); Index.buildReplies(nodes);
} }
$.event('IndexBuild', nodes); $.add(Index.root, nodes);
return $.add(Index.root, nodes); return $.event('IndexBuild', nodes);
}, },
isSearching: false, isSearching: false,
clearSearch: function() { clearSearch: function() {

View File

@ -224,6 +224,7 @@ Index =
, ,
whenModified: true whenModified: true
$.addClass Index.button, 'fa-spin' $.addClass Index.button, 'fa-spin'
load: (e, pageNum) -> load: (e, pageNum) ->
$.rmClass Index.button, 'fa-spin' $.rmClass Index.button, 'fa-spin'
{req, notice} = Index {req, notice} = Index
@ -255,6 +256,7 @@ Index =
timeEl.dataset.utc = Date.parse req.getResponseHeader 'Last-Modified' timeEl.dataset.utc = Date.parse req.getResponseHeader 'Last-Modified'
RelativeDates.update timeEl RelativeDates.update timeEl
Index.scrollToIndex() Index.scrollToIndex()
parse: (pages, pageNum) -> parse: (pages, pageNum) ->
Index.parseThreadList pages Index.parseThreadList pages
Index.buildThreads() Index.buildThreads()
@ -265,6 +267,7 @@ Index =
return return
Index.buildIndex() Index.buildIndex()
Index.setPage() Index.setPage()
parseThreadList: (pages) -> parseThreadList: (pages) ->
Index.pagesNum = pages.length Index.pagesNum = pages.length
Index.threadsNumPerPage = pages[0].threads.length Index.threadsNumPerPage = pages[0].threads.length
@ -273,6 +276,7 @@ Index =
for threadID, thread of g.BOARD.threads when thread.ID not in Index.liveThreadIDs for threadID, thread of g.BOARD.threads when thread.ID not in Index.liveThreadIDs
thread.collect() thread.collect()
return return
buildThreads: -> buildThreads: ->
Index.nodes = [] Index.nodes = []
threads = [] threads = []
@ -303,6 +307,7 @@ Index =
Main.callbackNodes Thread, threads Main.callbackNodes Thread, threads
Main.callbackNodes Post, posts Main.callbackNodes Post, posts
$.event 'IndexRefresh' $.event 'IndexRefresh'
buildReplies: (threadRoots) -> buildReplies: (threadRoots) ->
posts = [] posts = []
for threadRoot in threadRoots by 2 for threadRoot in threadRoots by 2
@ -327,6 +332,7 @@ Index =
Main.handleErrors errors if errors Main.handleErrors errors if errors
Main.callbackNodes Post, posts Main.callbackNodes Post, posts
sort: -> sort: ->
switch Conf['Index Sort'] switch Conf['Index Sort']
when 'bump' when 'bump'
@ -355,11 +361,13 @@ Index =
Index.sortOnTop((thread) -> thread.isOnTop) if Conf['Filter'] Index.sortOnTop((thread) -> thread.isOnTop) if Conf['Filter']
# Non-hidden threads # Non-hidden threads
Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads'] Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads']
sortOnTop: (match) -> sortOnTop: (match) ->
offset = 0 offset = 0
for threadRoot, i in Index.sortedNodes by 2 when match Get.threadFromRoot threadRoot for threadRoot, i in Index.sortedNodes by 2 when match Get.threadFromRoot threadRoot
Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)... Index.sortedNodes.splice offset++ * 2, 0, Index.sortedNodes.splice(i, 2)...
return return
buildIndex: -> buildIndex: ->
if Conf['Index Mode'] is 'paged' if Conf['Index Mode'] is 'paged'
pageNum = Index.getCurrentPage() pageNum = Index.getCurrentPage()
@ -370,14 +378,16 @@ Index =
$.rmAll Index.root $.rmAll Index.root
$.rmAll Header.hover $.rmAll Header.hover
Index.buildReplies nodes if Conf['Show Replies'] Index.buildReplies nodes if Conf['Show Replies']
$.event 'IndexBuild', nodes
$.add Index.root, nodes $.add Index.root, nodes
$.event 'IndexBuild', nodes
isSearching: false isSearching: false
clearSearch: -> clearSearch: ->
Index.searchInput.value = null Index.searchInput.value = null
Index.onSearchInput() Index.onSearchInput()
Index.searchInput.focus() Index.searchInput.focus()
onSearchInput: -> onSearchInput: ->
if Index.isSearching = !!Index.searchInput.value.trim() if Index.isSearching = !!Index.searchInput.value.trim()
unless Index.searchInput.dataset.searching unless Index.searchInput.dataset.searching
@ -404,15 +414,18 @@ Index =
Index.setPage() Index.setPage()
else else
Index.pageNav pageNum Index.pageNav pageNum
querySearch: (query) -> querySearch: (query) ->
return unless keywords = query.toLowerCase().match /\S+/g return unless keywords = query.toLowerCase().match /\S+/g
Index.search keywords Index.search keywords
search: (keywords) -> search: (keywords) ->
found = [] found = []
for threadRoot, i in Index.sortedNodes by 2 for threadRoot, i in Index.sortedNodes by 2
if Index.searchMatch Get.threadFromRoot(threadRoot), keywords if Index.searchMatch Get.threadFromRoot(threadRoot), keywords
found.push Index.sortedNodes[i], Index.sortedNodes[i + 1] found.push Index.sortedNodes[i], Index.sortedNodes[i + 1]
found found
searchMatch: (thread, keywords) -> searchMatch: (thread, keywords) ->
{info, file} = thread.OP {info, file} = thread.OP
text = [] text = []