From 84e423d0d88648cec81542093a2c1198fc9b99b6 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Thu, 6 May 2021 12:48:28 -0700 Subject: [PATCH] Update for flag changes on /mlp/ and /pol/. --- src/General/BoardConfig.coffee | 15 +++++++-------- src/Posting/QR.coffee | 6 +++--- src/classes/Post.coffee | 2 +- src/site/SW.yotsuba.Build.coffee | 4 ++-- src/site/SW.yotsuba.Build/PostInfo.html | 2 +- src/site/SW.yotsuba.coffee | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/General/BoardConfig.coffee b/src/General/BoardConfig.coffee index 4a9c79970..6adc6d6fc 100644 --- a/src/General/BoardConfig.coffee +++ b/src/General/BoardConfig.coffee @@ -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 diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 48ca1077e..fa50ceee0 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -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' diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index 4b78411f1..8551aa718 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -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) diff --git a/src/site/SW.yotsuba.Build.coffee b/src/site/SW.yotsuba.Build.coffee index 5dc213f56..a13534dc8 100644 --- a/src/site/SW.yotsuba.Build.coffee +++ b/src/site/SW.yotsuba.Build.coffee @@ -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 ''} diff --git a/src/site/SW.yotsuba.Build/PostInfo.html b/src/site/SW.yotsuba.Build/PostInfo.html index 1b159fd89..f35d019de 100644 --- a/src/site/SW.yotsuba.Build/PostInfo.html +++ b/src/site/SW.yotsuba.Build/PostInfo.html @@ -13,7 +13,7 @@ ?{capcodeDescription}{ ${capcode} Icon} ?{uniqueID && !capcode}{ (ID: ${uniqueID})} ?{flagCode}{ } - ?{flagCodeTroll}{ ${flagCodeTroll}} + ?{flagCodeTroll}{ } ${dateText} diff --git a/src/site/SW.yotsuba.coffee b/src/site/SW.yotsuba.coffee index 9fb99ecb2..d706775ea 100644 --- a/src/site/SW.yotsuba.coffee +++ b/src/site/SW.yotsuba.coffee @@ -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)'