Merge commit '375c717dea3ff136d8ebea8b938e9d90bd474c64'
This commit is contained in:
commit
6c31cbe54c
@ -1,5 +1,12 @@
|
||||
Header =
|
||||
init: ->
|
||||
$.onExists doc, 'body', =>
|
||||
return unless Main.isThisPageLegit()
|
||||
$.add @bar, [@noticesRoot, @toggle]
|
||||
$.prepend d.body, @bar
|
||||
$.add d.body, Header.hover
|
||||
@setBarPosition Conf['Bottom Header']
|
||||
|
||||
@menu = new UI.Menu 'header'
|
||||
|
||||
menuButton = $.el 'span',
|
||||
@ -86,12 +93,6 @@ Header =
|
||||
|
||||
@setBoardList()
|
||||
|
||||
$.onExists doc, 'body', =>
|
||||
return unless Main.isThisPageLegit()
|
||||
$.prepend d.body, @bar
|
||||
$.add d.body, Header.hover
|
||||
@setBarPosition Conf['Bottom Header']
|
||||
|
||||
$.onExists doc, "#{g.SITE.selectors.boardList} + *", Header.generateFullBoardList
|
||||
|
||||
Main.ready ->
|
||||
@ -102,7 +103,8 @@ Header =
|
||||
$('#navtopright', footer).id = 'navbotright'
|
||||
$('#settingsWindowLink', footer).id = 'settingsWindowLinkBot'
|
||||
$.before absbot, footer
|
||||
$.globalEval 'window.cloneTopNav = function() {};'
|
||||
$.global ->
|
||||
window.cloneTopNav = ->
|
||||
if (Header.bottomBoardList = $ g.SITE.selectors.boardListBottom)
|
||||
for a in $$ 'a', Header.bottomBoardList
|
||||
a.className = 'current' if a.hostname is location.hostname and a.pathname.split('/')[1] is g.BOARD.ID
|
||||
@ -154,7 +156,7 @@ Header =
|
||||
btn = $('.hide-board-list-button', boardList)
|
||||
$.on btn, 'click', Header.toggleBoardList
|
||||
|
||||
$.add Header.bar, [Header.boardList, Header.shortcuts, Header.noticesRoot, Header.toggle]
|
||||
$.prepend Header.bar, [Header.boardList, Header.shortcuts]
|
||||
|
||||
Header.setCustomNav Conf['Custom Board Navigation']
|
||||
Header.generateBoardList Conf['boardnav']
|
||||
@ -392,7 +394,7 @@ Header =
|
||||
Header.previousOffset = offsetY
|
||||
|
||||
setBarPosition: (bottom) ->
|
||||
Header.barPositionToggler.checked = bottom
|
||||
Header.barPositionToggler?.checked = bottom
|
||||
$.event 'CloseMenu'
|
||||
args = if bottom then [
|
||||
'bottom-header'
|
||||
|
||||
@ -21,7 +21,7 @@ Settings =
|
||||
$.on d, 'AddSettingsSection', Settings.addSection
|
||||
$.on d, 'OpenSettings', (e) -> Settings.open e.detail
|
||||
|
||||
if Conf['Disable Native Extension']
|
||||
if g.SITE.software is 'yotsuba' and Conf['Disable Native Extension']
|
||||
if $.hasStorage
|
||||
# Run in page context to handle case where 4chan X has localStorage access but not the page.
|
||||
# (e.g. Pale Moon 26.2.2, GM 3.8, cookies disabled for 4chan only)
|
||||
|
||||
@ -18,6 +18,10 @@ Test =
|
||||
Header.menu.addEntry
|
||||
el: a2
|
||||
|
||||
assert: (condition) ->
|
||||
unless condition()
|
||||
new Notice 'warning', "Assertion failed: #{condition}", 30
|
||||
|
||||
normalize: (root) ->
|
||||
root2 = root.cloneNode true
|
||||
for el in $$ '.mobile', root2
|
||||
|
||||
@ -71,7 +71,10 @@ Linkify =
|
||||
|
||||
if Linkify.regString.test word
|
||||
links.push Linkify.makeRange node, endNode, index, length
|
||||
<% if (readJSON('/.tests_enabled')) { %><%= assert('word is links[links.length-1].toString()') %><% } %>
|
||||
<% if (readJSON('/.tests_enabled')) { %>
|
||||
Test.assert ->
|
||||
word is links[links.length-1].toString()
|
||||
<% } %>
|
||||
|
||||
break unless test.lastIndex and node is endNode
|
||||
|
||||
|
||||
@ -12,17 +12,16 @@ Fourchan =
|
||||
unless $.hasClass pre, 'prettyprinted'
|
||||
pre.innerHTML = e.detail.html
|
||||
$.addClass pre, 'prettyprinted'
|
||||
$.globalEval '''
|
||||
window.addEventListener('prettyprint', function(e) {
|
||||
$.global ->
|
||||
window.addEventListener('prettyprint', (e) ->
|
||||
window.dispatchEvent(new CustomEvent('prettyprint:cb', {
|
||||
detail: {
|
||||
ID: e.detail.ID,
|
||||
i: e.detail.i,
|
||||
html: prettyPrintOne(e.detail.html)
|
||||
html: window.prettyPrintOne(e.detail.html)
|
||||
}
|
||||
}));
|
||||
}, false);
|
||||
'''
|
||||
}))
|
||||
, false)
|
||||
Callbacks.Post.push
|
||||
name: 'Parse [code] tags'
|
||||
cb: Fourchan.code
|
||||
|
||||
@ -99,6 +99,7 @@ Main =
|
||||
|
||||
# Fresh install
|
||||
else if !items.previousversion?
|
||||
Main.isFirstRun = true
|
||||
Main.ready ->
|
||||
$.set 'previousversion', g.VERSION
|
||||
Settings.open()
|
||||
@ -502,6 +503,16 @@ Main =
|
||||
new Notice 'error', 'Error: Multiple copies of 4chan X are enabled.'
|
||||
$.addClass doc, 'tainted'
|
||||
|
||||
# Detect conflicts with native extension
|
||||
if g.SITE.testNativeExtension and not $.hasClass(doc, 'tainted')
|
||||
{enabled} = g.SITE.testNativeExtension()
|
||||
if enabled
|
||||
$.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>.') %>
|
||||
new Notice 'error', msg
|
||||
|
||||
unless errors instanceof Array
|
||||
error = errors
|
||||
else if errors.length is 1
|
||||
@ -556,7 +567,7 @@ Main =
|
||||
addDetails data.error.stack.replace(data.error.toString(), '').trim() if data.error.stack
|
||||
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}') %>"
|
||||
url = '<%= meta.newIssue %>'.replace('%title', encodeURIComponent title).replace('%details', encodeURIComponent details)
|
||||
<%= html('<span class="report-error"> [<a href="${url}" target="_blank">report</a>]</span>') %>
|
||||
|
||||
isThisPageLegit: ->
|
||||
|
||||
@ -445,19 +445,19 @@ $.queueTask = do ->
|
||||
taskQueue.push arguments
|
||||
setTimeout execTask, 0
|
||||
|
||||
$.globalEval = (code, data) ->
|
||||
script = $.el 'script',
|
||||
textContent: code
|
||||
$.extend script.dataset, data if data
|
||||
$.add (d.head or doc), script
|
||||
$.rm script
|
||||
|
||||
$.global = (fn, data) ->
|
||||
if doc
|
||||
$.globalEval "(#{fn})();", data
|
||||
script = $.el 'script',
|
||||
textContent: "(#{fn}).call(document.currentScript.dataset);"
|
||||
$.extend script.dataset, data if data
|
||||
$.add (d.head or doc), script
|
||||
$.rm script
|
||||
script.dataset
|
||||
else
|
||||
# XXX dwb
|
||||
fn()
|
||||
try
|
||||
fn.call(data)
|
||||
data
|
||||
|
||||
$.bytesToString = (size) ->
|
||||
unit = 0 # Bytes
|
||||
|
||||
@ -225,3 +225,7 @@ SW.yotsuba =
|
||||
|
||||
isLinkified: (link) ->
|
||||
ImageHost.test(link.hostname)
|
||||
|
||||
testNativeExtension: ->
|
||||
$.global ->
|
||||
@enabled = 'true' if window.Parser.postMenuIcon
|
||||
|
||||
@ -168,11 +168,7 @@ tools.html = function(template) {
|
||||
if (stream.text) {
|
||||
throw new Error(`Unexpected characters in template (${stream.text}): ${template}`);
|
||||
}
|
||||
return `(innerHTML: \`${output}\`)`;
|
||||
};
|
||||
|
||||
tools.assert = function(statement) {
|
||||
return `throw new Error 'Assertion failed: ' + \`${constExpression(statement)}\` unless ${statement}`;
|
||||
return `\`{innerHTML: ${output}}\``;
|
||||
};
|
||||
|
||||
function includesDir(templateName) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user