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.'
|
new Notice 'error', 'Error: Multiple copies of 4chan X are enabled.'
|
||||||
$.addClass doc, 'tainted'
|
$.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 default values from Config into Conf
|
||||||
flatten = (parent, obj) ->
|
flatten = (parent, obj) ->
|
||||||
if obj instanceof Array
|
if obj instanceof Array
|
||||||
@ -332,14 +341,17 @@ Main =
|
|||||||
if g.VIEW is 'catalog'
|
if g.VIEW is 'catalog'
|
||||||
Main.initCatalog()
|
Main.initCatalog()
|
||||||
else if !Index.enabled
|
else if !Index.enabled
|
||||||
Main.initThread()
|
if g.SITE.awaitBoard
|
||||||
|
g.SITE.awaitBoard Main.initThread
|
||||||
|
else
|
||||||
|
Main.initThread()
|
||||||
else
|
else
|
||||||
Main.expectInitFinished = true
|
Main.expectInitFinished = true
|
||||||
$.event '4chanXInitFinished'
|
$.event '4chanXInitFinished'
|
||||||
|
|
||||||
initThread: ->
|
initThread: ->
|
||||||
s = g.SITE.selectors
|
s = g.SITE.selectors
|
||||||
if (board = $ s.board)
|
if (board = $ (s.boardFor?[g.VIEW] or s.board))
|
||||||
threads = []
|
threads = []
|
||||||
posts = []
|
posts = []
|
||||||
errors = []
|
errors = []
|
||||||
@ -388,7 +400,7 @@ Main =
|
|||||||
Main.addPostsObserver.observe threadRoot, {childList: true}
|
Main.addPostsObserver.observe threadRoot, {childList: true}
|
||||||
|
|
||||||
parsePosts: (postRoots, thread, posts, errors) ->
|
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
|
try
|
||||||
posts.push new Post postRoot, thread, thread.board
|
posts.push new Post postRoot, thread, thread.board
|
||||||
catch err
|
catch err
|
||||||
@ -601,6 +613,14 @@ Main =
|
|||||||
$.ready ->
|
$.ready ->
|
||||||
(cb() if Main.isThisPageLegit())
|
(cb() if Main.isThisPageLegit())
|
||||||
|
|
||||||
|
mounted: (cb) ->
|
||||||
|
if Main.isMounted
|
||||||
|
cb()
|
||||||
|
else
|
||||||
|
Main.mountedCBs.push cb
|
||||||
|
|
||||||
|
mountedCBs: []
|
||||||
|
|
||||||
features: [
|
features: [
|
||||||
['Polyfill', Polyfill]
|
['Polyfill', Polyfill]
|
||||||
['Board Configuration', BoardConfig]
|
['Board Configuration', BoardConfig]
|
||||||
|
|||||||
@ -40,6 +40,16 @@ SW.tinyboard =
|
|||||||
return properties
|
return properties
|
||||||
false
|
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:
|
urls:
|
||||||
thread: ({siteID, boardID, threadID}, isArchived) ->
|
thread: ({siteID, boardID, threadID}, isArchived) ->
|
||||||
"#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/#{if isArchived then 'archive/' else ''}res/#{threadID}.html"
|
"#{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
|
{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 $.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 (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
|
nameNode = $ '.postfilename', text
|
||||||
$.extend file,
|
$.extend file,
|
||||||
name: if nameNode then (nameNode.title or nameNode.textContent) else link.pathname.match(/[^/]*$/)[0]
|
name: if nameNode then (nameNode.title or nameNode.textContent) else link.pathname.match(/[^/]*$/)[0]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user