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