Update for flag changes on /mlp/ and /pol/.
This commit is contained in:
parent
681b6f741f
commit
84e423d0d8
@ -4,30 +4,29 @@ BoardConfig =
|
||||
init: ->
|
||||
return unless g.SITE.software is 'yotsuba'
|
||||
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",
|
||||
onloadend: @load
|
||||
else
|
||||
{boards, troll_flags} = Conf['boardConfig']
|
||||
@set boards, troll_flags
|
||||
{boards} = Conf['boardConfig']
|
||||
@set boards
|
||||
|
||||
load: ->
|
||||
if @status is 200 and @response and @response.boards
|
||||
boards = $.dict()
|
||||
for board in @response.boards
|
||||
boards[board.board] = board
|
||||
{troll_flags} = @response
|
||||
$.set 'boardConfig', {boards, troll_flags, lastChecked: Date.now()}
|
||||
$.set 'boardConfig', {boards, lastChecked: Date.now()}
|
||||
else
|
||||
{boards, troll_flags} = Conf['boardConfig']
|
||||
{boards} = Conf['boardConfig']
|
||||
err = switch @status
|
||||
when 0 then 'Connection Error'
|
||||
when 200 then 'Invalid Data'
|
||||
else "Error #{@statusText} (#{@status})"
|
||||
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
|
||||
board.config = @boards[ID] or {}
|
||||
for cb in @cbs
|
||||
|
||||
@ -622,8 +622,8 @@ QR =
|
||||
addFlag = (value, textContent) ->
|
||||
$.add select, $.el 'option', {value, textContent}
|
||||
|
||||
addFlag '0', 'Geographic Location'
|
||||
for value, textContent of BoardConfig.troll_flags
|
||||
addFlag '0', (if g.BOARD.config.country_flags then 'Geographic Location' else 'None')
|
||||
for value, textContent of g.BOARD.config.board_flags
|
||||
addFlag value, textContent
|
||||
|
||||
select
|
||||
@ -635,7 +635,7 @@ QR =
|
||||
$.rm nodes.flag
|
||||
delete nodes.flag
|
||||
|
||||
if g.BOARD.config.troll_flags
|
||||
if g.BOARD.config.board_flags
|
||||
flag = QR.flags()
|
||||
flag.dataset.name = 'flag'
|
||||
flag.dataset.default = '0'
|
||||
|
||||
@ -38,7 +38,7 @@ class Post
|
||||
capcode: @nodes.capcode?.textContent.replace '## ', ''
|
||||
pass: @nodes.pass?.title.match(/\d*$/)[0]
|
||||
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
|
||||
date: if @nodes.date then g.SITE.parseDate(@nodes.date)
|
||||
|
||||
|
||||
@ -55,8 +55,8 @@ Build =
|
||||
pass: if data.since4pass? then "#{data.since4pass}" else undefined
|
||||
uniqueID: data.id
|
||||
flagCode: data.country
|
||||
flagCodeTroll: data.troll_country
|
||||
flag: $.unescape data.country_name
|
||||
flagCodeTroll: data.board_flag
|
||||
flag: $.unescape (data.country_name or data.flag_name)
|
||||
dateUTC: data.time
|
||||
dateText: data.now
|
||||
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">}
|
||||
?{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>}
|
||||
?{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 class="dateTime" data-utc="${dateUTC}">${dateText}</span>
|
||||
<span class="postNum?{!(boardID === "f" && !o.isReply)}{ desktop}">
|
||||
|
||||
@ -43,7 +43,7 @@ SW.yotsuba =
|
||||
uniqueID: '.posteruid > .hand'
|
||||
capcode: '.capcode.hand'
|
||||
pass: '.n-pu'
|
||||
flag: '.flag, .countryFlag'
|
||||
flag: '.flag, .bfl'
|
||||
date: '.dateTime'
|
||||
nameBlock: '.nameBlock'
|
||||
quote: '.postNum > a:nth-of-type(2)'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user