Make HTML templates output Javascript, part 3. #829
This commit is contained in:
parent
375c717dea
commit
fba3d2d18e
@ -283,7 +283,7 @@ Filter =
|
||||
$('span', notice.el).textContent = "#{notice.filters.length} MD5s filtered."
|
||||
else
|
||||
msg = $.el 'div',
|
||||
<%= html('<span>MD5 filtered.</span> [<a href="javascript:;">show</a>] [<a href="javascript:;">undo</a>]') %>
|
||||
`<%= html('<span>MD5 filtered.</span> [<a href="javascript:;">show</a>] [<a href="javascript:;">undo</a>]') %>`
|
||||
notice = Filter.quickFilterMD5.notice = new Notice 'info', msg, undefined, ->
|
||||
delete Filter.quickFilterMD5.notice
|
||||
notice.filters = [filter]
|
||||
|
||||
@ -139,7 +139,7 @@ ThreadHiding =
|
||||
a = $.el 'a',
|
||||
className: "#{type}-thread-button"
|
||||
href: 'javascript:;'
|
||||
$.extend a, <%= html('<span class="fa fa-?{type === "hide"}{minus}{plus}-square"></span>') %>
|
||||
$.extend a, `<%= html('<span class="fa fa-?{type === "hide"}{minus}{plus}-square"></span>') %>`
|
||||
a.dataset.fullID = thread.fullID
|
||||
$.on a, 'click', ThreadHiding.toggle
|
||||
a
|
||||
|
||||
@ -11,7 +11,7 @@ Header =
|
||||
|
||||
menuButton = $.el 'span',
|
||||
className: 'menu-button'
|
||||
$.extend menuButton, <%= html('<i></i>') %>
|
||||
$.extend menuButton, `<%= html('<i></i>') %>`
|
||||
|
||||
box = UI.checkbox
|
||||
|
||||
@ -142,7 +142,7 @@ Header =
|
||||
setBoardList: ->
|
||||
Header.boardList = boardList = $.el 'span',
|
||||
id: 'board-list'
|
||||
$.extend boardList, <%= html(
|
||||
$.extend boardList, `<%= html(
|
||||
'<span id="custom-board-list"></span>' +
|
||||
'<span id="full-board-list" hidden>' +
|
||||
'<span class="hide-board-list-container brackets-wrap">' +
|
||||
@ -151,7 +151,7 @@ Header =
|
||||
' ' +
|
||||
'<span class="boardList"></span>' +
|
||||
'</span>'
|
||||
) %>
|
||||
) %>`
|
||||
|
||||
btn = $('.hide-board-list-button', boardList)
|
||||
$.on btn, 'click', Header.toggleBoardList
|
||||
@ -547,11 +547,11 @@ Header =
|
||||
return
|
||||
|
||||
el = $.el 'span',
|
||||
<%= html(
|
||||
`<%= html(
|
||||
meta.name + ' needs your permission to show desktop notifications. ' +
|
||||
'[<a href="' + meta.faq + '#why-is-4chan-x-asking-for-permission-to-show-desktop-notifications" target="_blank">FAQ</a>]<br>' +
|
||||
'<button>Authorize</button> or <button>Disable</button>'
|
||||
) %>
|
||||
) %>`
|
||||
[authorize, disable] = $$ 'button', el
|
||||
$.on authorize, 'click', ->
|
||||
Notification.requestPermission (status) ->
|
||||
|
||||
@ -85,7 +85,7 @@ Index =
|
||||
|
||||
# Navigation links at top of index
|
||||
@navLinks = $.el 'div', className: 'navLinks json-index'
|
||||
$.extend @navLinks, <%= readHTML('NavLinks.html') %>
|
||||
$.extend @navLinks, `<%= readHTML('NavLinks.html') %>`
|
||||
$('.cataloglink a', @navLinks).href = CatalogLinks.catalog()
|
||||
$('.archlistlink', @navLinks).hidden = true unless BoardConfig.isArchived(g.BOARD.ID)
|
||||
$.on $('#index-last-refresh a', @navLinks), 'click', @cb.refreshFront
|
||||
@ -134,7 +134,7 @@ Index =
|
||||
|
||||
# Page list
|
||||
@pagelist = $.el 'div', className: 'pagelist json-index'
|
||||
$.extend @pagelist, <%= readHTML('PageList.html') %>
|
||||
$.extend @pagelist, `<%= readHTML('PageList.html') %>`
|
||||
$('.cataloglink a', @pagelist).href = CatalogLinks.catalog()
|
||||
$.on @pagelist, 'click', @cb.pageNav
|
||||
|
||||
@ -206,7 +206,7 @@ Index =
|
||||
el: $.el 'a',
|
||||
href: 'javascript:;'
|
||||
className: 'has-shortcut-text'
|
||||
, <%= html('<span></span><span class="shortcut-text">Shift+click</span>') %>
|
||||
, `<%= html('<span></span><span class="shortcut-text">Shift+click</span>') %>`
|
||||
order: 20
|
||||
open: ({thread}) ->
|
||||
return false if Conf['Index Mode'] isnt 'catalog'
|
||||
|
||||
@ -44,7 +44,7 @@ Settings =
|
||||
Settings.dialog = dialog = $.el 'div',
|
||||
id: 'overlay'
|
||||
,
|
||||
<%= readHTML('Settings.html') %>
|
||||
`<%= readHTML('Settings.html') %>`
|
||||
|
||||
$.on $('.export', dialog), 'click', Settings.export
|
||||
$.on $('.import', dialog), 'click', Settings.import
|
||||
@ -112,16 +112,16 @@ Settings =
|
||||
$.onExists doc, '.adg-rects > .desktop', (ad) -> $.onExists ad, 'iframe', ->
|
||||
url = Redirect.to 'thread', {boardID: 'qa', threadID: 362590}
|
||||
cb $.el 'li',
|
||||
<%= html(
|
||||
`<%= html(
|
||||
'To protect yourself from <a href="${url}" target="_blank">malicious ads</a>,' +
|
||||
' you should <a href="https://github.com/gorhill/uBlock#ublock-origin" target="_blank">block ads</a> on 4chan.'
|
||||
) %>
|
||||
) %>`
|
||||
|
||||
main: (section) ->
|
||||
warnings = $.el 'fieldset',
|
||||
hidden: true
|
||||
,
|
||||
<%= html('<legend>Warnings</legend><ul></ul>') %>
|
||||
`<%= html('<legend>Warnings</legend><ul></ul>') %>`
|
||||
addWarning = (item) ->
|
||||
$.add $('ul', warnings), item
|
||||
warnings.hidden = false
|
||||
@ -136,7 +136,7 @@ Settings =
|
||||
for key, arr of obj when arr instanceof Array
|
||||
description = arr[1]
|
||||
div = $.el 'div',
|
||||
<%= html('<label><input type="checkbox" name="${key}">${key}</label><span class="description">: ${description}</span>') %>
|
||||
`<%= html('<label><input type="checkbox" name="${key}">${key}</label><span class="description">: ${description}</span>') %>`
|
||||
div.dataset.name = key
|
||||
input = $ 'input', div
|
||||
$.on input, 'change', $.cb.checked
|
||||
@ -154,11 +154,11 @@ Settings =
|
||||
|
||||
for keyFS, obj of Config.main
|
||||
fs = $.el 'fieldset',
|
||||
<%= html('<legend>${keyFS}</legend>') %>
|
||||
`<%= html('<legend>${keyFS}</legend>') %>`
|
||||
addCheckboxes fs, obj
|
||||
if keyFS is 'Posting and Captchas'
|
||||
$.add fs, $.el 'p',
|
||||
<%= html('For more info on captcha options and issues, see the <a href="' + meta.captchaFAQ + '" target="_blank">captcha FAQ</a>.') %>
|
||||
`<%= html('For more info on captcha options and issues, see the <a href="' + meta.captchaFAQ + '" target="_blank">captcha FAQ</a>.') %>`
|
||||
$.add section, fs
|
||||
addCheckboxes $('div[data-name="JSON Index"] > .suboption-list', section), Config.Index
|
||||
|
||||
@ -175,7 +175,7 @@ Settings =
|
||||
return
|
||||
|
||||
div = $.el 'div',
|
||||
<%= html('<button></button><span class="description">: Clear manually-hidden threads and posts on all boards. Reload the page to apply.') %>
|
||||
`<%= html('<button></button><span class="description">: Clear manually-hidden threads and posts on all boards. Reload the page to apply.') %>`
|
||||
button = $ 'button', div
|
||||
$.get {hiddenThreads: {}, hiddenPosts: {}}, ({hiddenThreads, hiddenPosts}) ->
|
||||
hiddenNum = 0
|
||||
@ -515,7 +515,7 @@ Settings =
|
||||
window.location.reload()
|
||||
|
||||
filter: (section) ->
|
||||
$.extend section, <%= readHTML('Filter-select.html') %>
|
||||
$.extend section, `<%= readHTML('Filter-select.html') %>`
|
||||
select = $ 'select', section
|
||||
$.on select, 'change', Settings.selectFilter
|
||||
Settings.selectFilter.call select
|
||||
@ -534,12 +534,12 @@ Settings =
|
||||
$.add div, ta
|
||||
return
|
||||
filterTypes = Object.keys(Config.filter).filter((x) -> x isnt 'general').map (x, i) ->
|
||||
<%= html('?{i}{,}<wbr>${x}') %>
|
||||
$.extend div, <%= readHTML('Filter-guide.html') %>
|
||||
`<%= html('?{i}{,}<wbr>${x}') %>`
|
||||
$.extend div, `<%= readHTML('Filter-guide.html') %>`
|
||||
$('.warning', div).hidden = Conf['Filter']
|
||||
|
||||
sauce: (section) ->
|
||||
$.extend section, <%= readHTML('Sauce.html') %>
|
||||
$.extend section, `<%= readHTML('Sauce.html') %>`
|
||||
$('.warning', section).hidden = Conf['Sauce']
|
||||
ta = $ 'textarea', section
|
||||
$.get 'sauces', Conf['sauces'], (item) ->
|
||||
@ -548,7 +548,7 @@ Settings =
|
||||
$.on ta, 'change', $.cb.value
|
||||
|
||||
advanced: (section) ->
|
||||
$.extend section, <%= readHTML('Advanced.html') %>
|
||||
$.extend section, `<%= readHTML('Advanced.html') %>`
|
||||
warning.hidden = Conf[warning.dataset.feature] for warning in $$ '.warning', section
|
||||
|
||||
inputs = {}
|
||||
@ -702,7 +702,7 @@ Settings =
|
||||
textContent: archive[1]
|
||||
}
|
||||
|
||||
$.extend td, <%= html('<select></select>') %>
|
||||
$.extend td, `<%= html('<select></select>') %>`
|
||||
select = td.firstElementChild
|
||||
if not (select.disabled = length is 1)
|
||||
# XXX GM can't into datasets
|
||||
@ -790,7 +790,7 @@ Settings =
|
||||
$.cb.checked.call @
|
||||
|
||||
keybinds: (section) ->
|
||||
$.extend section, <%= readHTML('Keybinds.html') %>
|
||||
$.extend section, `<%= readHTML('Keybinds.html') %>`
|
||||
$('.warning', section).hidden = Conf['Keybinds']
|
||||
|
||||
tbody = $ 'tbody', section
|
||||
@ -798,7 +798,7 @@ Settings =
|
||||
inputs = {}
|
||||
for key, arr of Config.hotkeys
|
||||
tr = $.el 'tr',
|
||||
<%= html('<td>${arr[1]}</td><td><input class="field"></td>') %>
|
||||
`<%= html('<td>${arr[1]}</td><td><input class="field"></td>') %>`
|
||||
input = $ 'input', tr
|
||||
input.name = key
|
||||
input.spellcheck = false
|
||||
|
||||
@ -43,7 +43,7 @@ Gallery =
|
||||
|
||||
nodes.el = dialog = $.el 'div',
|
||||
id: 'a-gallery'
|
||||
$.extend dialog, <%= readHTML('Gallery.html') %>
|
||||
$.extend dialog, `<%= readHTML('Gallery.html') %>`
|
||||
|
||||
nodes[key] = $ value, dialog for key, value of {
|
||||
buttons: '.gal-buttons'
|
||||
@ -388,7 +388,7 @@ Gallery =
|
||||
createSubEntries: ->
|
||||
subEntries = (Gallery.menu.createSubEntry item for item in ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Stretch to Fit', 'Scroll to Post'])
|
||||
|
||||
delayLabel = $.el 'label', <%= html('Slide Delay: <input type="number" name="Slide Delay" min="0" step="any" class="field">') %>
|
||||
delayLabel = $.el 'label', `<%= html('Slide Delay: <input type="number" name="Slide Delay" min="0" step="any" class="field">') %>`
|
||||
delayInput = delayLabel.firstElementChild
|
||||
delayInput.value = Gallery.delay
|
||||
$.on delayInput, 'change', Gallery.cb.setDelay
|
||||
|
||||
@ -12,7 +12,7 @@ ImageExpand =
|
||||
Header.addShortcut 'expand-all', @EAI, 520
|
||||
$.on d, 'scroll visibilitychange', @cb.playVideos
|
||||
@videoControls = $.el 'span', className: 'video-controls'
|
||||
$.extend @videoControls, <%= html(' <a href="javascript:;" title="You can also contract the video by dragging it to the left.">contract</a>') %>
|
||||
$.extend @videoControls, `<%= html(' <a href="javascript:;" title="You can also contract the video by dragging it to the left.">contract</a>') %>`
|
||||
|
||||
Callbacks.Post.push
|
||||
name: 'Image Expansion'
|
||||
|
||||
@ -17,7 +17,7 @@ ImageLoader =
|
||||
return unless Conf['Image Prefetching'] and g.VIEW in ['index', 'thread']
|
||||
|
||||
prefetch = $.el 'label',
|
||||
<%= html('<input type="checkbox" name="prefetch"> Prefetch Images') %>
|
||||
`<%= html('<input type="checkbox" name="prefetch"> Prefetch Images') %>`
|
||||
|
||||
@el = prefetch.firstElementChild
|
||||
$.on @el, 'change', @toggle
|
||||
|
||||
@ -15,7 +15,7 @@ Metadata =
|
||||
className: 'webm-title'
|
||||
el.dataset.index = i
|
||||
$.extend el,
|
||||
<%= html('<a href="javascript:;"></a>') %>
|
||||
`<%= html('<a href="javascript:;"></a>') %>`
|
||||
$.add file.text, [$.tn(' '), el]
|
||||
$.one el.lastElementChild, 'mouseover focus', Metadata.load if el.children.length is 1
|
||||
return
|
||||
|
||||
@ -29,7 +29,7 @@ Volume =
|
||||
volumeEntry = $.el 'label',
|
||||
title: 'Default volume for videos.'
|
||||
$.extend volumeEntry,
|
||||
<%= html('<input name="Default Volume" type="range" min="0" max="1" step="0.01" value="${Conf["Default Volume"]}"> Volume') %>
|
||||
`<%= html('<input name="Default Volume" type="range" min="0" max="1" step="0.01" value="${Conf["Default Volume"]}"> Volume') %>`
|
||||
|
||||
@inputs =
|
||||
unmute: unmuteEntry.firstElementChild
|
||||
|
||||
@ -6,7 +6,7 @@ Embedding =
|
||||
|
||||
if Conf['Embedding'] and g.VIEW isnt 'archive'
|
||||
@dialog = UI.dialog 'embedding',
|
||||
<%= readHTML('Embed.html') %>
|
||||
`<%= readHTML('Embed.html') %>`
|
||||
@media = $ '#media-embed', @dialog
|
||||
$.one d, '4chanXInitFinished', @ready
|
||||
$.on d, 'IndexRefreshInternal', ->
|
||||
@ -62,7 +62,7 @@ Embedding =
|
||||
className: 'embedder'
|
||||
href: 'javascript:;'
|
||||
,
|
||||
<%= html('(<span>un</span>embed)') %>
|
||||
`<%= html('(<span>un</span>embed)') %>`
|
||||
|
||||
embed.dataset[name] = value for name, value of {key, uid, options, href}
|
||||
|
||||
@ -216,7 +216,7 @@ Embedding =
|
||||
regExp: /^[^?#]+\.(?:gif|png|jpg|jpeg|bmp)(?::\w+)?(?:[?#]|$)/i
|
||||
style: ''
|
||||
el: (a) ->
|
||||
$.el 'div', <%= html('<a target="_blank" href="${a.dataset.href}"><img src="${a.dataset.href}" style="max-width: 80vw; max-height: 80vh;"></a>') %>
|
||||
$.el 'div', `<%= html('<a target="_blank" href="${a.dataset.href}"><img src="${a.dataset.href}" style="max-width: 80vw; max-height: 80vh;"></a>') %>`
|
||||
,
|
||||
key: 'video'
|
||||
regExp: /^[^?#]+\.(?:og[gv]|webm|mp4)(?:[?#]|$)/i
|
||||
|
||||
@ -93,7 +93,7 @@ DeleteLink =
|
||||
|
||||
link.textContent = DeleteLink.linkText fileOnly
|
||||
if resDoc.title is '4chan - Banned' # Ban/warn check
|
||||
el = $.el 'span', <%= html('You can't delete posts because you are <a href="//www.4chan.org/banned" target="_blank">banned</a>.') %>
|
||||
el = $.el 'span', `<%= html('You can't delete posts because you are <a href="//www.4chan.org/banned" target="_blank">banned</a>.') %>`
|
||||
new Notice 'warning', el, 20
|
||||
else if msg = resDoc.getElementById 'errmsg' # error!
|
||||
new Notice 'warning', msg.textContent, 20
|
||||
|
||||
@ -6,7 +6,7 @@ Menu =
|
||||
className: 'menu-button'
|
||||
href: 'javascript:;'
|
||||
|
||||
$.extend @button, <%= html('<i class="fa fa-angle-down"></i>') %>
|
||||
$.extend @button, `<%= html('<i class="fa fa-angle-down"></i>') %>`
|
||||
|
||||
@menu = new UI.Menu 'post'
|
||||
Callbacks.Post.push
|
||||
|
||||
@ -29,9 +29,9 @@ FileInfo =
|
||||
output.push if c of FileInfo.formatters
|
||||
FileInfo.formatters[c].call post
|
||||
else
|
||||
<%= html('${s}') %>
|
||||
`<%= html('${s}') %>`
|
||||
''
|
||||
$.extend outputNode, <%= html('@{output}') %>
|
||||
$.extend outputNode, `<%= html('@{output}') %>`
|
||||
for a in $$ '.download-button', outputNode
|
||||
$.on a, 'click', ImageCommon.download
|
||||
for a in $$ '.quick-filter-md5', outputNode
|
||||
@ -39,25 +39,25 @@ FileInfo =
|
||||
return
|
||||
|
||||
formatters:
|
||||
t: -> <%= html('${this.file.url.match(/[^\/]*$/)[0]}') %>
|
||||
T: -> <%= html('<a href="${this.file.url}" target="_blank">&{FileInfo.formatters.t.call(this)}</a>') %>
|
||||
l: -> <%= html('<a href="${this.file.url}" target="_blank">&{FileInfo.formatters.n.call(this)}</a>') %>
|
||||
L: -> <%= html('<a href="${this.file.url}" target="_blank">&{FileInfo.formatters.N.call(this)}</a>') %>
|
||||
t: -> `<%= html('${this.file.url.match(/[^\/]*$/)[0]}') %>`
|
||||
T: -> `<%= html('<a href="${this.file.url}" target="_blank">&{FileInfo.formatters.t.call(this)}</a>') %>`
|
||||
l: -> `<%= html('<a href="${this.file.url}" target="_blank">&{FileInfo.formatters.n.call(this)}</a>') %>`
|
||||
L: -> `<%= html('<a href="${this.file.url}" target="_blank">&{FileInfo.formatters.N.call(this)}</a>') %>`
|
||||
n: ->
|
||||
fullname = @file.name
|
||||
shortname = g.SITE.Build.shortFilename @file.name, @isReply
|
||||
if fullname is shortname
|
||||
<%= html('${fullname}') %>
|
||||
`<%= html('${fullname}') %>`
|
||||
else
|
||||
<%= html('<span class="fnswitch"><span class="fntrunc">${shortname}</span><span class="fnfull">${fullname}</span></span>') %>
|
||||
N: -> <%= html('${this.file.name}') %>
|
||||
d: -> <%= html('<a href="${this.file.url}" download="${this.file.name}" class="fa fa-download download-button"></a>') %>
|
||||
f: -> <%= html('<a href="javascript:;" class="fa fa-times quick-filter-md5"></a>') %>
|
||||
p: -> <%= html('?{this.file.isSpoiler}{Spoiler, }') %>
|
||||
s: -> <%= html('${this.file.size}') %>
|
||||
B: -> <%= html('${Math.round(this.file.sizeInBytes)} Bytes') %>
|
||||
K: -> <%= html('${Math.round(this.file.sizeInBytes/1024)} KB') %>
|
||||
M: -> <%= html('${Math.round(this.file.sizeInBytes/1048576*100)/100} MB') %>
|
||||
r: -> <%= html('${this.file.dimensions || "PDF"}') %>
|
||||
g: -> <%= html('?{this.file.tag}{, ${this.file.tag}}{}') %>
|
||||
'%': -> <%= html('%') %>
|
||||
`<%= html('<span class="fnswitch"><span class="fntrunc">${shortname}</span><span class="fnfull">${fullname}</span></span>') %>`
|
||||
N: -> `<%= html('${this.file.name}') %>`
|
||||
d: -> `<%= html('<a href="${this.file.url}" download="${this.file.name}" class="fa fa-download download-button"></a>') %>`
|
||||
f: -> `<%= html('<a href="javascript:;" class="fa fa-times quick-filter-md5"></a>') %>`
|
||||
p: -> `<%= html('?{this.file.isSpoiler}{Spoiler, }') %>`
|
||||
s: -> `<%= html('${this.file.size}') %>`
|
||||
B: -> `<%= html('${Math.round(this.file.sizeInBytes)} Bytes') %>`
|
||||
K: -> `<%= html('${Math.round(this.file.sizeInBytes/1024)} KB') %>`
|
||||
M: -> `<%= html('${Math.round(this.file.sizeInBytes/1048576*100)/100} MB') %>`
|
||||
r: -> `<%= html('${this.file.dimensions || "PDF"}') %>`
|
||||
g: -> `<%= html('?{this.file.tag}{, ${this.file.tag}}{}') %>`
|
||||
'%': -> `<%= html('%') %>`
|
||||
|
||||
@ -16,19 +16,19 @@ ModContact =
|
||||
$.add @nodes.post, moveNote
|
||||
|
||||
template: (capcode) ->
|
||||
<%= html(
|
||||
`<%= html(
|
||||
'<a href="https://www.4chan.org/feedback" target="_blank">feedback</a>&{ModContact.specific[capcode]()}'
|
||||
) %>
|
||||
) %>`
|
||||
|
||||
specific:
|
||||
Mod: -> <%= html(' <a href="https://www.4chan-x.net/4chan-irc.html" target="_blank">IRC</a>') %>
|
||||
Mod: -> `<%= html(' <a href="https://www.4chan-x.net/4chan-irc.html" target="_blank">IRC</a>') %>`
|
||||
Manager: -> ModContact.specific.Mod()
|
||||
Developer: -> <%= html(' <a href="https://github.com/4chan" target="_blank">github</a>') %>
|
||||
Admin: -> <%= html(' <a href="https://twitter.com/hiroyuki_ni" target="_blank">twitter</a>') %>
|
||||
Developer: -> `<%= html(' <a href="https://github.com/4chan" target="_blank">github</a>') %>`
|
||||
Admin: -> `<%= html(' <a href="https://twitter.com/hiroyuki_ni" target="_blank">twitter</a>') %>`
|
||||
|
||||
moveNote:
|
||||
qa: <%= html(
|
||||
qa: `<%= html(
|
||||
'Moving a thread to /qa/ does not imply mods will read it. If you wish to contact mods, use ' +
|
||||
'<a href="https://www.4chan.org/feedback" target="_blank">feedback</a><span class="invisible"> (https://www.4chan.org/feedback)</span> or ' +
|
||||
'<a href="https://www.4chan-x.net/4chan-irc.html" target="_blank">IRC</a><span class="invisible"> (https://www.4chan-x.net/4chan-irc.html)</span>.'
|
||||
) %>
|
||||
) %>`
|
||||
|
||||
@ -56,7 +56,7 @@ PostJumper =
|
||||
classNext = 'next'
|
||||
span = $.el 'span',
|
||||
className: 'postJumper'
|
||||
$.extend span, <%= html('<a href="javascript:;" class="${classPrev}">${charPrev}</a><a href="javascript:;" class="${classNext}">${charNext}</a>') %>
|
||||
$.extend span, `<%= html('<a href="javascript:;" class="${classPrev}">${charPrev}</a><a href="javascript:;" class="${classNext}">${charNext}</a>') %>`
|
||||
span
|
||||
|
||||
scroll: (fromJumper, toJumper) ->
|
||||
|
||||
@ -35,7 +35,7 @@ Report =
|
||||
id: 'archive-report'
|
||||
hidden: true
|
||||
,
|
||||
<%= readHTML('ArchiveReport.html') %>
|
||||
`<%= readHTML('ArchiveReport.html') %>`
|
||||
enabled = $ '#archive-report-enabled', fieldset
|
||||
reason = $ '#archive-report-reason', fieldset
|
||||
submit = $ '#archive-report-submit', fieldset
|
||||
|
||||
@ -16,7 +16,7 @@ ReplyPruning =
|
||||
el = $.el 'span',
|
||||
title: 'Maximum number of replies to show.'
|
||||
,
|
||||
<%= html(' <input type="number" name="Max Replies" min="0" step="1" value="${Conf["Max Replies"]}" class="field">') %>
|
||||
`<%= html(' <input type="number" name="Max Replies" min="0" step="1" value="${Conf["Max Replies"]}" class="field">') %>`
|
||||
$.prepend el, label
|
||||
|
||||
@inputs =
|
||||
|
||||
@ -9,11 +9,11 @@ ThreadStats =
|
||||
if Conf['Page Count in Stats']
|
||||
@[if g.SITE.isPrunedByAge?(g.BOARD) then 'showPurgePos' else 'showPage'] = true
|
||||
|
||||
statsHTML = <%= html(
|
||||
statsHTML = `<%= html(
|
||||
'<span id="post-count">?</span> / <span id="file-count">?</span>' +
|
||||
'?{Conf["IP Count in Stats"] && g.SITE.hasIPCount}{ / <span id="ip-count">?</span>}' +
|
||||
'?{Conf["Page Count in Stats"]}{ / <span id="page-count">?</span>}'
|
||||
) %>
|
||||
) %>`
|
||||
statsTitle = 'Posts / Files'
|
||||
statsTitle += ' / IPs' if Conf['IP Count in Stats'] and g.SITE.hasIPCount
|
||||
statsTitle += (if @showPurgePos then ' / Purge Position' else ' / Page') if Conf['Page Count in Stats']
|
||||
@ -27,7 +27,7 @@ ThreadStats =
|
||||
|
||||
else
|
||||
@dialog = sc = UI.dialog 'thread-stats',
|
||||
<%= html('<div class="move" title="${statsTitle}">&{statsHTML}</div>') %>
|
||||
`<%= html('<div class="move" title="${statsTitle}">&{statsHTML}</div>') %>`
|
||||
$.addClass doc, 'float'
|
||||
$.ready ->
|
||||
$.add d.body, sc
|
||||
|
||||
@ -12,11 +12,11 @@ ThreadUpdater =
|
||||
if Conf['Updater and Stats in Header']
|
||||
@dialog = sc = $.el 'span',
|
||||
id: 'updater'
|
||||
$.extend sc, <%= html('<span id="update-status" class="empty"></span><span id="update-timer" class="empty" title="Update now"></span>') %>
|
||||
$.extend sc, `<%= html('<span id="update-status" class="empty"></span><span id="update-timer" class="empty" title="Update now"></span>') %>`
|
||||
Header.addShortcut 'updater', sc, 100
|
||||
else
|
||||
@dialog = sc = UI.dialog 'updater',
|
||||
<%= html('<div class="move"></div><span id="update-status" class="empty"></span><span id="update-timer" class="empty" title="Update now"></span>') %>
|
||||
`<%= html('<div class="move"></div><span id="update-status" class="empty"></span><span id="update-timer" class="empty" title="Update now"></span>') %>`
|
||||
$.addClass doc, 'float'
|
||||
$.ready ->
|
||||
$.add d.body, sc
|
||||
@ -31,7 +31,7 @@ ThreadUpdater =
|
||||
|
||||
updateLink = $.el 'span',
|
||||
className: 'brackets-wrap updatelink'
|
||||
$.extend updateLink, <%= html('<a href="javascript:;">Update</a>') %>
|
||||
$.extend updateLink, `<%= html('<a href="javascript:;">Update</a>') %>`
|
||||
Main.ready ->
|
||||
($.add navLinksBot, [$.tn(' '), updateLink] if (navLinksBot = $ '.navLinksBot'))
|
||||
$.on updateLink.firstElementChild, 'click', @update
|
||||
@ -50,7 +50,7 @@ ThreadUpdater =
|
||||
subEntries.push el: el
|
||||
|
||||
@settings = $.el 'span',
|
||||
<%= html('<a href="javascript:;">Interval</a>') %>
|
||||
`<%= html('<a href="javascript:;">Interval</a>') %>`
|
||||
|
||||
$.on @settings, 'click', @intervalShortcut
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ ThreadWatcher =
|
||||
|
||||
@db = new DataBoard 'watchedThreads', @refresh, true
|
||||
@dbLM = new DataBoard 'watcherLastModified', null, true
|
||||
@dialog = UI.dialog 'thread-watcher', <%= readHTML('ThreadWatcher.html') %>
|
||||
@dialog = UI.dialog 'thread-watcher', `<%= readHTML('ThreadWatcher.html') %>`
|
||||
@status = $ '#watcher-status', @dialog
|
||||
@list = @dialog.lastElementChild
|
||||
@refreshButton = $ '.refresh', @dialog
|
||||
@ -50,7 +50,7 @@ ThreadWatcher =
|
||||
el: $.el 'a',
|
||||
href: 'javascript:;'
|
||||
className: 'has-shortcut-text'
|
||||
, <%= html('<span></span><span class="shortcut-text">Alt+click</span>') %>
|
||||
, `<%= html('<span></span><span class="shortcut-text">Alt+click</span>') %>`
|
||||
order: 6
|
||||
open: ({thread}) ->
|
||||
return false if Conf['Index Mode'] isnt 'catalog'
|
||||
|
||||
@ -12,9 +12,9 @@ Captcha.v2 =
|
||||
$.on d, 'CaptchaCount', @count.bind(@)
|
||||
|
||||
root = $.el 'div', className: 'captcha-root'
|
||||
$.extend root, <%= html(
|
||||
$.extend root, `<%= html(
|
||||
'<div class="captcha-counter"><a href="javascript:;"></a></div>'
|
||||
) %>
|
||||
) %>`
|
||||
counter = $ '.captcha-counter > a', root
|
||||
@nodes = {root, counter}
|
||||
@count()
|
||||
|
||||
@ -8,7 +8,7 @@ PassLink =
|
||||
|
||||
passLink = $.el 'span',
|
||||
className: 'brackets-wrap pass-link-container'
|
||||
$.extend passLink, <%= html('<a href="javascript:;">4chan Pass</a>') %>
|
||||
$.extend passLink, `<%= html('<a href="javascript:;">4chan Pass</a>') %>`
|
||||
$.on passLink.firstElementChild, 'click', ->
|
||||
window.open "//sys.#{location.hostname.split('.')[1]}.org/auth",
|
||||
Date.now()
|
||||
|
||||
@ -72,7 +72,7 @@ QR =
|
||||
if (origToggle = $.id 'togglePostFormLink')
|
||||
link = $.el 'h1',
|
||||
className: "qr-link-container"
|
||||
$.extend link, <%= html('<a href="javascript:;" class="qr-link">?{g.VIEW === "thread"}{Reply to Thread}{Start a Thread}</a>') %>
|
||||
$.extend link, `<%= html('<a href="javascript:;" class="qr-link">?{g.VIEW === "thread"}{Reply to Thread}{Start a Thread}</a>') %>`
|
||||
|
||||
QR.link = link.firstElementChild
|
||||
$.on link.firstChild, 'click', ->
|
||||
@ -85,7 +85,7 @@ QR =
|
||||
if g.VIEW is 'thread'
|
||||
linkBot = $.el 'div',
|
||||
className: "brackets-wrap qr-link-container-bottom"
|
||||
$.extend linkBot, <%= html('<a href="javascript:;" class="qr-link-bottom">Reply to Thread</a>') %>
|
||||
$.extend linkBot, `<%= html('<a href="javascript:;" class="qr-link-bottom">Reply to Thread</a>') %>`
|
||||
|
||||
$.on linkBot.firstElementChild, 'click', ->
|
||||
QR.open()
|
||||
@ -243,10 +243,10 @@ QR =
|
||||
|
||||
connectionError: ->
|
||||
$.el 'span',
|
||||
<%= html(
|
||||
`<%= html(
|
||||
'Connection error while posting. ' +
|
||||
'[<a href="' + meta.faq + '#connection-errors" target="_blank">More info</a>]'
|
||||
) %>
|
||||
) %>`
|
||||
|
||||
notifications: []
|
||||
|
||||
@ -363,7 +363,7 @@ QR =
|
||||
|
||||
openError: ->
|
||||
div = $.el 'div'
|
||||
$.extend div, <%= html('Could not open file. [<a href="' + meta.faq + '#error-reading-metadata" target="_blank">More info</a>]') %>
|
||||
$.extend div, `<%= html('Could not open file. [<a href="' + meta.faq + '#error-reading-metadata" target="_blank">More info</a>]') %>`
|
||||
QR.error div
|
||||
|
||||
setFile: (e) ->
|
||||
@ -490,7 +490,7 @@ QR =
|
||||
dialog: ->
|
||||
QR.nodes = nodes =
|
||||
el: dialog = UI.dialog 'qr',
|
||||
<%= readHTML('QuickReply.html') %>
|
||||
`<%= readHTML('QuickReply.html') %>`
|
||||
|
||||
setNode = (name, query) ->
|
||||
nodes[name] = $ query, dialog
|
||||
|
||||
@ -4,7 +4,7 @@ QR.post = class
|
||||
className: 'qr-preview'
|
||||
draggable: true
|
||||
href: 'javascript:;'
|
||||
$.extend el, <%= html('<a class="remove fa fa-times-circle" title="Remove"></a><label class="qr-preview-spoiler"><input type="checkbox"> Spoiler</label><span></span>') %>
|
||||
$.extend el, `<%= html('<a class="remove fa fa-times-circle" title="Remove"></a><label class="qr-preview-spoiler"><input type="checkbox"> Spoiler</label><span></span>') %>`
|
||||
|
||||
@nodes =
|
||||
el: el
|
||||
@ -177,7 +177,7 @@ QR.post = class
|
||||
|
||||
error: (className, message, link) ->
|
||||
div = $.el 'div', {className}
|
||||
$.extend div, <%= html('${message}?{link}{ [<a href="${link}" target="_blank">More info</a>]}<br>[<a href="javascript:;">delete post</a>] [<a href="javascript:;">delete all</a>]') %>
|
||||
$.extend div, `<%= html('${message}?{link}{ [<a href="${link}" target="_blank">More info</a>]}<br>[<a href="javascript:;">delete post</a>] [<a href="javascript:;">delete all</a>]') %>`
|
||||
(@errors or= []).push div
|
||||
[rm, rmAll] = $$ 'a', div
|
||||
$.on div, 'click', =>
|
||||
|
||||
@ -7,12 +7,12 @@ QuoteThreading =
|
||||
return unless Conf['Quote Threading'] and g.VIEW is 'thread'
|
||||
|
||||
@controls = $.el 'label',
|
||||
<%= html('<input id="threadingControl" name="Thread Quotes" type="checkbox"> Threading') %>
|
||||
`<%= html('<input id="threadingControl" name="Thread Quotes" type="checkbox"> Threading') %>`
|
||||
|
||||
@threadNewLink = $.el 'span',
|
||||
className: 'brackets-wrap threadnewlink'
|
||||
hidden: true
|
||||
$.extend @threadNewLink, <%= html('<a href="javascript:;">Thread New Posts</a>') %>
|
||||
$.extend @threadNewLink, `<%= html('<a href="javascript:;">Thread New Posts</a>') %>`
|
||||
|
||||
@input = $('input', @controls)
|
||||
@input.checked = Conf['Thread Quotes']
|
||||
|
||||
@ -59,7 +59,7 @@ QuoteYou =
|
||||
label = $.el 'label',
|
||||
className: 'toggle-you'
|
||||
,
|
||||
<%= html('<input type="checkbox"> You') %>
|
||||
`<%= html('<input type="checkbox"> You') %>`
|
||||
input = $ 'input', label
|
||||
$.on input, 'change', QuoteYou.menu.toggle
|
||||
Menu.menu?.addEntry
|
||||
|
||||
@ -149,10 +149,10 @@ class Fetcher
|
||||
greentext = text[0] is '>'
|
||||
text = text.replace /(\[\/?[a-z]+):lit(\])/g, '$1$2'
|
||||
text = for text2, j in text.split /(>>(?:>\/[a-z\d]+\/)?\d+)/g
|
||||
<%= html('?{j % 2}{<span class="deadlink">${text2}</span>}{${text2}}') %>
|
||||
text = <%= html('?{greentext}{<span class="quote">@{text}</span>}{@{text}}') %>
|
||||
`<%= html('?{j % 2}{<span class="deadlink">${text2}</span>}{${text2}}') %>`
|
||||
text = `<%= html('?{greentext}{<span class="quote">@{text}</span>}{@{text}}') %>`
|
||||
text
|
||||
comment = <%= html('@{comment}') %>
|
||||
comment = `<%= html('@{comment}') %>`
|
||||
|
||||
@threadID = +data.thread_num
|
||||
o =
|
||||
@ -219,24 +219,24 @@ class Fetcher
|
||||
@insert post
|
||||
|
||||
archiveTags:
|
||||
'\n': <%= html('<br>') %>
|
||||
'[b]': <%= html('<b>') %>
|
||||
'[/b]': <%= html('</b>') %>
|
||||
'[spoiler]': <%= html('<s>') %>
|
||||
'[/spoiler]': <%= html('</s>') %>
|
||||
'[code]': <%= html('<pre class="prettyprint">') %>
|
||||
'[/code]': <%= html('</pre>') %>
|
||||
'[moot]': <%= html('<div style="padding:5px;margin-left:.5em;border-color:#faa;border:2px dashed rgba(255,0,0,.1);border-radius:2px">') %>
|
||||
'[/moot]': <%= html('</div>') %>
|
||||
'[banned]': <%= html('<strong style="color: red;">') %>
|
||||
'[/banned]': <%= html('</strong>') %>
|
||||
'[fortune]': (text) -> <%= html('<span class="fortune" style="color:${text.match(/#\\w+|$/)[0]}"><b>') %>
|
||||
'[/fortune]': <%= html('</b></span>') %>
|
||||
'[i]': <%= html('<span class="mu-i">') %>
|
||||
'[/i]': <%= html('</span>') %>
|
||||
'[red]': <%= html('<span class="mu-r">') %>
|
||||
'[/red]': <%= html('</span>') %>
|
||||
'[green]': <%= html('<span class="mu-g">') %>
|
||||
'[/green]': <%= html('</span>') %>
|
||||
'[blue]': <%= html('<span class="mu-b">') %>
|
||||
'[/blue]': <%= html('</span>') %>
|
||||
'\n': `<%= html('<br>') %>`
|
||||
'[b]': `<%= html('<b>') %>`
|
||||
'[/b]': `<%= html('</b>') %>`
|
||||
'[spoiler]': `<%= html('<s>') %>`
|
||||
'[/spoiler]': `<%= html('</s>') %>`
|
||||
'[code]': `<%= html('<pre class="prettyprint">') %>`
|
||||
'[/code]': `<%= html('</pre>') %>`
|
||||
'[moot]': `<%= html('<div style="padding:5px;margin-left:.5em;border-color:#faa;border:2px dashed rgba(255,0,0,.1);border-radius:2px">') %>`
|
||||
'[/moot]': `<%= html('</div>') %>`
|
||||
'[banned]': `<%= html('<strong style="color: red;">') %>`
|
||||
'[/banned]': `<%= html('</strong>') %>`
|
||||
'[fortune]': (text) -> `<%= html('<span class="fortune" style="color:${text.match(/#\\w+|$/)[0]}"><b>') %>`
|
||||
'[/fortune]': `<%= html('</b></span>') %>`
|
||||
'[i]': `<%= html('<span class="mu-i">') %>`
|
||||
'[/i]': `<%= html('</span>') %>`
|
||||
'[red]': `<%= html('<span class="mu-r">') %>`
|
||||
'[/red]': `<%= html('</span>') %>`
|
||||
'[green]': `<%= html('<span class="mu-g">') %>`
|
||||
'[/green]': `<%= html('</span>') %>`
|
||||
'[blue]': `<%= html('<span class="mu-b">') %>`
|
||||
'[/blue]': `<%= html('</span>') %>`
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
class Notice
|
||||
constructor: (type, content, @timeout, @onclose) ->
|
||||
@el = $.el 'div',
|
||||
<%= html('<a href="javascript:;" class="close fa fa-times" title="Close"></a><div class="message"></div>') %>
|
||||
`<%= html('<a href="javascript:;" class="close fa fa-times" title="Close"></a><div class="message"></div>') %>`
|
||||
@el.style.opacity = 0
|
||||
@setType type
|
||||
$.on @el.firstElementChild, 'click', @close
|
||||
|
||||
@ -121,7 +121,7 @@ Main =
|
||||
$.set changes, ->
|
||||
if items['Show Updated Notifications'] ? true
|
||||
el = $.el 'span',
|
||||
<%= html(meta.name + ' has been updated to <a href="' + meta.changelog + '" target="_blank">version ${g.VERSION}</a>.') %>
|
||||
`<%= html(meta.name + ' has been updated to <a href="' + meta.changelog + '" target="_blank">version ${g.VERSION}</a>.') %>`
|
||||
new Notice 'info', el, 15
|
||||
|
||||
parseURL: (site=g.SITE, url=location) ->
|
||||
@ -316,7 +316,7 @@ Main =
|
||||
|
||||
if g.SITE.isIncomplete?()
|
||||
msg = $.el 'div',
|
||||
<%= html('The page didn't load completely.<br>Some features may not work unless you <a href="javascript:;">reload</a>.') %>
|
||||
`<%= html('The page didn't load completely.<br>Some features may not work unless you <a href="javascript:;">reload</a>.') %>`
|
||||
$.on $('a', msg), 'click', -> location.reload()
|
||||
new Notice 'warning', msg
|
||||
|
||||
@ -510,7 +510,7 @@ Main =
|
||||
$.addClass doc, 'tainted'
|
||||
if Conf['Disable Native Extension'] and !Main.isFirstRun
|
||||
msg = $.el 'div',
|
||||
<%= html('Failed to disable the native extension. You may need to <a href="' + meta.faq + '#blocking-native-extension" target="_blank">block it</a>.') %>
|
||||
`<%= html('Failed to disable the native extension. You may need to <a href="' + meta.faq + '#blocking-native-extension" target="_blank">block it</a>.') %>`
|
||||
new Notice 'error', msg
|
||||
|
||||
unless errors instanceof Array
|
||||
@ -522,7 +522,7 @@ Main =
|
||||
return
|
||||
|
||||
div = $.el 'div',
|
||||
<%= html('${errors.length} errors occurred.&{Main.reportLink(errors)} [<a href="javascript:;">show</a>]') %>
|
||||
`<%= html('${errors.length} errors occurred.&{Main.reportLink(errors)} [<a href="javascript:;">show</a>]') %>`
|
||||
$.on div.lastElementChild, 'click', ->
|
||||
[@textContent, logs.hidden] = if @textContent is 'show' then (
|
||||
['hide', false]
|
||||
@ -540,7 +540,7 @@ Main =
|
||||
parseError: (data, reportLink) ->
|
||||
c.error data.message, data.error.stack
|
||||
message = $.el 'div',
|
||||
<%= html('${data.message}?{reportLink}{&{reportLink}}') %>
|
||||
`<%= html('${data.message}?{reportLink}{&{reportLink}}') %>`
|
||||
error = $.el 'div',
|
||||
textContent: "#{data.error.name or 'Error'}: #{data.error.message or 'see console for details'}"
|
||||
lines = data.error.stack?.match(/\d+(?=:\d+\)?$)/mg)?.join().replace(/^/, ' at ') or ''
|
||||
@ -568,7 +568,7 @@ Main =
|
||||
addDetails '\n`' + data.html + '`' if data.html
|
||||
details = details.replace /file:\/{3}.+\//g, '' # Remove local file paths
|
||||
url = '<%= meta.newIssue %>'.replace('%title', encodeURIComponent title).replace('%details', encodeURIComponent details)
|
||||
<%= html('<span class="report-error"> [<a href="${url}" target="_blank">report</a>]</span>') %>
|
||||
`<%= html('<span class="report-error"> [<a href="${url}" target="_blank">report</a>]</span>') %>`
|
||||
|
||||
isThisPageLegit: ->
|
||||
# not 404 error page or similar.
|
||||
|
||||
@ -527,7 +527,7 @@ $.crxWorking = ->
|
||||
return true
|
||||
unless $.crxWarningShown
|
||||
msg = $.el 'div',
|
||||
<%= html('4chan X seems to have been updated. You will need to <a href="javascript:;">reload</a> the page.') %>
|
||||
`<%= html('4chan X seems to have been updated. You will need to <a href="javascript:;">reload</a> the page.') %>`
|
||||
$.on $('a', msg), 'click', -> location.reload()
|
||||
new Notice 'warning', msg
|
||||
$.crxWarningShown = true
|
||||
|
||||
@ -144,7 +144,7 @@ Build =
|
||||
else
|
||||
"#{url}#q#{ID}"
|
||||
|
||||
postInfo = <%= readHTML('PostInfo.html') %>
|
||||
postInfo = `<%= readHTML('PostInfo.html') %>`
|
||||
|
||||
### File Info ###
|
||||
|
||||
@ -154,13 +154,13 @@ Build =
|
||||
shortFilename = Build.shortFilename file.name
|
||||
fileThumb = if file.isSpoiler then Build.spoilerThumb(boardID) else file.thumbURL.replace(protocol, '')
|
||||
|
||||
fileBlock = <%= readHTML('File.html') %>
|
||||
fileBlock = `<%= readHTML('File.html') %>`
|
||||
|
||||
### Whole Post ###
|
||||
|
||||
postClass = if o.isReply then 'reply' else 'op'
|
||||
|
||||
wholePost = <%= readHTML('Post.html') %>
|
||||
wholePost = `<%= readHTML('Post.html') %>`
|
||||
|
||||
container = $.el 'div',
|
||||
className: "postContainer #{postClass}Container"
|
||||
@ -237,7 +237,7 @@ Build =
|
||||
postCount = data.replies + 1
|
||||
fileCount = data.images + !!data.ext
|
||||
|
||||
container = $.el 'div', <%= readHTML('CatalogThread.html') %>
|
||||
container = $.el 'div', `<%= readHTML('CatalogThread.html') %>`
|
||||
$.before thread.OP.nodes.info, [container.childNodes...]
|
||||
|
||||
for br in $$('br', thread.OP.nodes.comment) when br.previousSibling and br.previousSibling.nodeName is 'BR'
|
||||
@ -265,6 +265,6 @@ Build =
|
||||
|
||||
link = Build.postURL thread.board.ID, thread.ID, data.no
|
||||
$.el 'div', {className: 'catalog-reply'},
|
||||
<%= readHTML('CatalogReply.html') %>
|
||||
`<%= readHTML('CatalogReply.html') %>`
|
||||
|
||||
SW.yotsuba.Build = Build
|
||||
|
||||
@ -168,7 +168,7 @@ tools.html = function(template) {
|
||||
if (stream.text) {
|
||||
throw new Error(`Unexpected characters in template (${stream.text}): ${template}`);
|
||||
}
|
||||
return `\`{innerHTML: ${output}}\``;
|
||||
return `{innerHTML: ${output}}`;
|
||||
};
|
||||
|
||||
function includesDir(templateName) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user