Revert "Remove /pol/ flags properly." #1403

This reverts commit 930a8a4307a32b5e75cd0ab1bbdf08367414afe3.
This commit is contained in:
ccd0 2017-06-13 08:18:07 -07:00
parent 6a0dc74639
commit 7b604d5662
4 changed files with 73 additions and 7 deletions

View File

@ -11,7 +11,13 @@
?{boardID === "f" && !o.isReply || capcodeDescription}{}{ }
?{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>}
?{flagCode}{
?{boardID === "pol"}{
\ <img src="${staticPath}country/troll/${flagCode.toLowerCase()}.gif" alt="${flagCode}" title="${flag}" class="countryFlag">
}{
\ <span title="${flag}" class="flag flag-${flagCode.toLowerCase()}"></span>
}
}
</span>
<span class="dateTime" data-utc="${dateUTC}">${dateText}</span>
<span class="postNum?{!(boardID === "f" && !o.isReply)}{ desktop}">

View File

@ -524,6 +524,8 @@ QR =
QR.setCustomCooldown customCooldownEnabled
$.sync 'customCooldownEnabled', QR.setCustomCooldown
QR.flagsInput()
$.on nodes.autohide, 'change', QR.toggleHide
$.on nodes.close, 'click', QR.close
$.on nodes.form, 'submit', QR.submit
@ -556,7 +558,7 @@ QR =
new MutationObserver(QR.pasteFF).observe nodes.pasteArea, {childList: true}
# save selected post's data
items = ['thread', 'name', 'email', 'sub', 'com', 'filename']
items = ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']
i = 0
save = -> QR.selected.save @
while name = items[i++]
@ -587,6 +589,57 @@ QR =
# Use it to extend the QR's functionalities, or for XTRM RICE.
$.event 'QRDialogCreation', null, dialog
flags: ->
select = $.el 'select',
name: 'flag'
className: 'flagSelector'
fn = (val) ->
$.add select, $.el 'option',
value: val[0]
textContent: val[1]
fn flag for flag in [
['0', 'None']
['US', 'American']
['KP', 'Best Korean']
['BL', 'Black Nationalist']
['CM', 'Communist']
['CF', 'Confederate']
['RE', 'Conservative']
['EU', 'European']
['GY', 'Gay']
['PC', 'Hippie']
['IL', 'Israeli']
['DM', 'Liberal']
['RP', 'Libertarian']
['MF', 'Muslim']
['NZ', 'Nazi']
['OB', 'Obama']
['PR', 'Pirate']
['RB', 'Rebel']
['TP', 'Tea Partier']
['TX', 'Texan']
['TR', 'Tree Hugger']
['WP', 'White Supremacist']
]
select
flagsInput: ->
{nodes} = QR
return if not nodes
if nodes.flag
$.rm nodes.flag
delete nodes.flag
if g.BOARD.ID is 'pol'
flag = QR.flags()
flag.dataset.name = 'flag'
flag.dataset.default = '0'
nodes.flag = flag
$.add nodes.form, flag
submit: (e) ->
e?.preventDefault()
@ -652,6 +705,7 @@ QR =
upfile: post.file
filetag: filetag
spoiler: post.spoiler
flag: post.flag
mode: 'regist'
pwd: QR.persona.getPassword()

View File

@ -60,4 +60,5 @@ QR.persona =
$.get 'QR.persona', {}, ({'QR.persona': persona}) ->
persona =
name: post.name
flag: post.flag
$.set 'QR.persona', persona

View File

@ -54,6 +54,11 @@ QR.post = class
else
''
if QR.nodes.flag
@flag = if prev
prev.flag
else
persona.flag
(@load() if QR.selected is @) # load persona
@select() if select
@unlock()
@ -78,7 +83,7 @@ QR.post = class
lock: (lock=true) ->
@isLocked = lock
return unless @ is QR.selected
for name in ['thread', 'name', 'email', 'sub', 'com', 'fileButton', 'filename', 'spoiler'] when node = QR.nodes[name]
for name in ['thread', 'name', 'email', 'sub', 'com', 'fileButton', 'filename', 'spoiler', 'flag'] when node = QR.nodes[name]
node.disabled = lock
@nodes.rm.style.visibility = if lock then 'hidden' else ''
@nodes.spoiler.disabled = lock
@ -103,7 +108,7 @@ QR.post = class
load: ->
# Load this post's values.
for name in ['thread', 'name', 'email', 'sub', 'com', 'filename']
for name in ['thread', 'name', 'email', 'sub', 'com', 'filename', 'flag']
continue if not (node = QR.nodes[name])
node.value = @[name] or node.dataset.default or ''
@ -129,8 +134,8 @@ QR.post = class
return unless @file
@saveFilename()
@updateFilename()
when 'name'
if @name isnt prev # only save manual changes, not values filled in by persona settings
when 'name', 'flag'
if @[name] isnt prev # only save manual changes, not values filled in by persona settings
QR.persona.set @
@preventAutoPost() unless forced
@ -138,7 +143,7 @@ QR.post = class
return unless @ is QR.selected
# Do this in case people use extensions
# that do not trigger the `input` event.
for name in ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler']
for name in ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler', 'flag']
continue if not (node = QR.nodes[name])
@save node, true
return