Preliminary support for new Kissu UI.
This commit is contained in:
parent
63d62c233d
commit
d0b492760c
@ -30,6 +30,15 @@ Main =
|
||||
new Notice 'error', 'Error: Multiple copies of 4chan X are enabled.'
|
||||
$.addClass doc, 'tainted'
|
||||
|
||||
# Detect "mounted" event from Kissu
|
||||
mountedCB = ->
|
||||
d.removeEventListener 'mounted', mountedCB, true
|
||||
Main.isMounted = true
|
||||
for cb in Main.mountedCBs
|
||||
try
|
||||
cb()
|
||||
d.addEventListener 'mounted', mountedCB, true
|
||||
|
||||
# Flatten default values from Config into Conf
|
||||
flatten = (parent, obj) ->
|
||||
if obj instanceof Array
|
||||
@ -332,14 +341,17 @@ Main =
|
||||
if g.VIEW is 'catalog'
|
||||
Main.initCatalog()
|
||||
else if !Index.enabled
|
||||
Main.initThread()
|
||||
if g.SITE.awaitBoard
|
||||
g.SITE.awaitBoard Main.initThread
|
||||
else
|
||||
Main.initThread()
|
||||
else
|
||||
Main.expectInitFinished = true
|
||||
$.event '4chanXInitFinished'
|
||||
|
||||
initThread: ->
|
||||
s = g.SITE.selectors
|
||||
if (board = $ s.board)
|
||||
if (board = $ (s.boardFor?[g.VIEW] or s.board))
|
||||
threads = []
|
||||
posts = []
|
||||
errors = []
|
||||
@ -388,7 +400,7 @@ Main =
|
||||
Main.addPostsObserver.observe threadRoot, {childList: true}
|
||||
|
||||
parsePosts: (postRoots, thread, posts, errors) ->
|
||||
for postRoot in postRoots when !postRoot.dataset.fullID and $(g.SITE.selectors.comment, postRoot)
|
||||
for postRoot in postRoots when !(postRoot.dataset.fullID and g.posts.get(postRoot.dataset.fullID)) and $(g.SITE.selectors.comment, postRoot)
|
||||
try
|
||||
posts.push new Post postRoot, thread, thread.board
|
||||
catch err
|
||||
@ -601,6 +613,14 @@ Main =
|
||||
$.ready ->
|
||||
(cb() if Main.isThisPageLegit())
|
||||
|
||||
mounted: (cb) ->
|
||||
if Main.isMounted
|
||||
cb()
|
||||
else
|
||||
Main.mountedCBs.push cb
|
||||
|
||||
mountedCBs: []
|
||||
|
||||
features: [
|
||||
['Polyfill', Polyfill]
|
||||
['Board Configuration', BoardConfig]
|
||||
|
||||
@ -40,6 +40,16 @@ SW.tinyboard =
|
||||
return properties
|
||||
false
|
||||
|
||||
awaitBoard: (cb) ->
|
||||
if (reactUI = $.id('react-ui'))
|
||||
s = @selectors = Object.create @selectors
|
||||
s.boardFor = {index: '.page-container'}
|
||||
s.thread = 'div[id^="thread_"]'
|
||||
s.threadDivider = 'page-container > hr'
|
||||
Main.mounted cb
|
||||
else
|
||||
cb()
|
||||
|
||||
urls:
|
||||
thread: ({siteID, boardID, threadID}, isArchived) ->
|
||||
"#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/#{if isArchived then 'archive/' else ''}res/#{threadID}.html"
|
||||
@ -196,7 +206,7 @@ SW.tinyboard =
|
||||
{text, link, thumb} = file
|
||||
return false if $.x("ancestor::#{@xpath.postContainer}[1]", text) isnt post.nodes.root # file belongs to a reply
|
||||
return false if not (infoNode = if '(' in link.nextSibling?.textContent then link.nextSibling else link.nextElementSibling)
|
||||
return false if not (info = infoNode.textContent.match /\((.*,\s*)?([\d.]+ [KMG]?B).*\)/)
|
||||
return false if not (info = infoNode.textContent.match /\((.*,\s*)?([\d.]+ ?[KMG]?B).*\)/)
|
||||
nameNode = $ '.postfilename', text
|
||||
$.extend file,
|
||||
name: if nameNode then (nameNode.title or nameNode.textContent) else link.pathname.match(/[^/]*$/)[0]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user