Update for flag changes on /mlp/ and /pol/.
This commit is contained in:
parent
681b6f741f
commit
84e423d0d8
@ -4,30 +4,29 @@ BoardConfig =
|
|||||||
init: ->
|
init: ->
|
||||||
return unless g.SITE.software is 'yotsuba'
|
return unless g.SITE.software is 'yotsuba'
|
||||||
now = Date.now()
|
now = Date.now()
|
||||||
unless now - 2 * $.HOUR < (Conf['boardConfig'].lastChecked or 0) <= now and Conf['boardConfig'].troll_flags
|
unless now - 2 * $.HOUR < (Conf['boardConfig'].lastChecked or 0) <= now
|
||||||
$.ajax "#{location.protocol}//a.4cdn.org/boards.json",
|
$.ajax "#{location.protocol}//a.4cdn.org/boards.json",
|
||||||
onloadend: @load
|
onloadend: @load
|
||||||
else
|
else
|
||||||
{boards, troll_flags} = Conf['boardConfig']
|
{boards} = Conf['boardConfig']
|
||||||
@set boards, troll_flags
|
@set boards
|
||||||
|
|
||||||
load: ->
|
load: ->
|
||||||
if @status is 200 and @response and @response.boards
|
if @status is 200 and @response and @response.boards
|
||||||
boards = $.dict()
|
boards = $.dict()
|
||||||
for board in @response.boards
|
for board in @response.boards
|
||||||
boards[board.board] = board
|
boards[board.board] = board
|
||||||
{troll_flags} = @response
|
$.set 'boardConfig', {boards, lastChecked: Date.now()}
|
||||||
$.set 'boardConfig', {boards, troll_flags, lastChecked: Date.now()}
|
|
||||||
else
|
else
|
||||||
{boards, troll_flags} = Conf['boardConfig']
|
{boards} = Conf['boardConfig']
|
||||||
err = switch @status
|
err = switch @status
|
||||||
when 0 then 'Connection Error'
|
when 0 then 'Connection Error'
|
||||||
when 200 then 'Invalid Data'
|
when 200 then 'Invalid Data'
|
||||||
else "Error #{@statusText} (#{@status})"
|
else "Error #{@statusText} (#{@status})"
|
||||||
new Notice 'warning', "Failed to load board configuration. #{err}", 20
|
new Notice 'warning', "Failed to load board configuration. #{err}", 20
|
||||||
BoardConfig.set boards, troll_flags
|
BoardConfig.set boards
|
||||||
|
|
||||||
set: (@boards, @troll_flags) ->
|
set: (@boards) ->
|
||||||
for ID, board of g.boards
|
for ID, board of g.boards
|
||||||
board.config = @boards[ID] or {}
|
board.config = @boards[ID] or {}
|
||||||
for cb in @cbs
|
for cb in @cbs
|
||||||
|
|||||||
@ -622,8 +622,8 @@ QR =
|
|||||||
addFlag = (value, textContent) ->
|
addFlag = (value, textContent) ->
|
||||||
$.add select, $.el 'option', {value, textContent}
|
$.add select, $.el 'option', {value, textContent}
|
||||||
|
|
||||||
addFlag '0', 'Geographic Location'
|
addFlag '0', (if g.BOARD.config.country_flags then 'Geographic Location' else 'None')
|
||||||
for value, textContent of BoardConfig.troll_flags
|
for value, textContent of g.BOARD.config.board_flags
|
||||||
addFlag value, textContent
|
addFlag value, textContent
|
||||||
|
|
||||||
select
|
select
|
||||||
@ -635,7 +635,7 @@ QR =
|
|||||||
$.rm nodes.flag
|
$.rm nodes.flag
|
||||||
delete nodes.flag
|
delete nodes.flag
|
||||||
|
|
||||||
if g.BOARD.config.troll_flags
|
if g.BOARD.config.board_flags
|
||||||
flag = QR.flags()
|
flag = QR.flags()
|
||||||
flag.dataset.name = 'flag'
|
flag.dataset.name = 'flag'
|
||||||
flag.dataset.default = '0'
|
flag.dataset.default = '0'
|
||||||
|
|||||||
@ -38,7 +38,7 @@ class Post
|
|||||||
capcode: @nodes.capcode?.textContent.replace '## ', ''
|
capcode: @nodes.capcode?.textContent.replace '## ', ''
|
||||||
pass: @nodes.pass?.title.match(/\d*$/)[0]
|
pass: @nodes.pass?.title.match(/\d*$/)[0]
|
||||||
flagCode: @nodes.flag?.className.match(/flag-(\w+)/)?[1].toUpperCase()
|
flagCode: @nodes.flag?.className.match(/flag-(\w+)/)?[1].toUpperCase()
|
||||||
flagCodeTroll: @nodes.flag?.src?.match(/(\w+)\.gif$/)?[1].toUpperCase()
|
flagCodeTroll: @nodes.flag?.className.match(/bfl-(\w+)/)?[1].toUpperCase()
|
||||||
flag: @nodes.flag?.title
|
flag: @nodes.flag?.title
|
||||||
date: if @nodes.date then g.SITE.parseDate(@nodes.date)
|
date: if @nodes.date then g.SITE.parseDate(@nodes.date)
|
||||||
|
|
||||||
|
|||||||
@ -55,8 +55,8 @@ Build =
|
|||||||
pass: if data.since4pass? then "#{data.since4pass}" else undefined
|
pass: if data.since4pass? then "#{data.since4pass}" else undefined
|
||||||
uniqueID: data.id
|
uniqueID: data.id
|
||||||
flagCode: data.country
|
flagCode: data.country
|
||||||
flagCodeTroll: data.troll_country
|
flagCodeTroll: data.board_flag
|
||||||
flag: $.unescape data.country_name
|
flag: $.unescape (data.country_name or data.flag_name)
|
||||||
dateUTC: data.time
|
dateUTC: data.time
|
||||||
dateText: data.now
|
dateText: data.now
|
||||||
commentHTML: {innerHTML: data.com or ''}
|
commentHTML: {innerHTML: data.com or ''}
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
?{capcodeDescription}{ <img src="${staticPath}${capcodeLC}icon${gifIcon}" alt="${capcode} Icon" title="This user is ${capcodeDescription}." class="identityIcon retina">}
|
?{capcodeDescription}{ <img src="${staticPath}${capcodeLC}icon${gifIcon}" alt="${capcode} Icon" title="This user is ${capcodeDescription}." class="identityIcon retina">}
|
||||||
?{uniqueID && !capcode}{ <span class="posteruid id_${uniqueID}">(ID: <span class="hand" title="Highlight posts by this ID">${uniqueID}</span>)</span>}
|
?{uniqueID && !capcode}{ <span class="posteruid id_${uniqueID}">(ID: <span class="hand" title="Highlight posts by this ID">${uniqueID}</span>)</span>}
|
||||||
?{flagCode}{ <span title="${flag}" class="flag flag-${flagCode.toLowerCase()}"></span>}
|
?{flagCode}{ <span title="${flag}" class="flag flag-${flagCode.toLowerCase()}"></span>}
|
||||||
?{flagCodeTroll}{ <img src="${staticPath}country/troll/${flagCodeTroll.toLowerCase()}.gif" alt="${flagCodeTroll}" title="${flag}" class="countryFlag">}
|
?{flagCodeTroll}{ <span title="${flag}" class="bfl bfl-${flagCodeTroll.toLowerCase()}"></span>}
|
||||||
</span>
|
</span>
|
||||||
<span class="dateTime" data-utc="${dateUTC}">${dateText}</span>
|
<span class="dateTime" data-utc="${dateUTC}">${dateText}</span>
|
||||||
<span class="postNum?{!(boardID === "f" && !o.isReply)}{ desktop}">
|
<span class="postNum?{!(boardID === "f" && !o.isReply)}{ desktop}">
|
||||||
|
|||||||
@ -43,7 +43,7 @@ SW.yotsuba =
|
|||||||
uniqueID: '.posteruid > .hand'
|
uniqueID: '.posteruid > .hand'
|
||||||
capcode: '.capcode.hand'
|
capcode: '.capcode.hand'
|
||||||
pass: '.n-pu'
|
pass: '.n-pu'
|
||||||
flag: '.flag, .countryFlag'
|
flag: '.flag, .bfl'
|
||||||
date: '.dateTime'
|
date: '.dateTime'
|
||||||
nameBlock: '.nameBlock'
|
nameBlock: '.nameBlock'
|
||||||
quote: '.postNum > a:nth-of-type(2)'
|
quote: '.postNum > a:nth-of-type(2)'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user