Load Tegaki from rawgit.com if loading from s.4cdn.org fails or is blocked.
This commit is contained in:
parent
ee44aa356e
commit
6027d94364
@ -55,23 +55,39 @@ QR.oekaki =
|
|||||||
bubbles: true
|
bubbles: true
|
||||||
detail: {file, name: FCX.oekakiName, source}
|
detail: {file, name: FCX.oekakiName, source}
|
||||||
}
|
}
|
||||||
if window.Tegaki
|
if $ 'link[href^="//s.4cdn.org/css/painter"]', d.head
|
||||||
document.querySelector('#qr .oekaki').hidden = false
|
QR.oekaki.load ->
|
||||||
|
$('#qr .oekaki').hidden = false
|
||||||
|
|
||||||
load: (cb) ->
|
load: (cb) ->
|
||||||
if $ 'script[src^="//s.4cdn.org/js/painter"]', d.head
|
n = 0
|
||||||
cb()
|
onload = ->
|
||||||
|
cb() if ++n is 2
|
||||||
|
onerror = ->
|
||||||
|
$.rm @
|
||||||
|
script = $.el 'script',
|
||||||
|
src: 'https://rawgit.com/desuwa/tegaki/master/tegaki.js'
|
||||||
|
$.on script, 'load', onload
|
||||||
|
$.add d.head, script
|
||||||
|
script = $ 'script[src^="//s.4cdn.org/js/painter"], script[src="https://rawgit.com/desuwa/tegaki/master/tegaki.js"]', d.head
|
||||||
|
if script
|
||||||
|
if !script.dataset.success
|
||||||
|
$.global ->
|
||||||
|
document.querySelector('script[src^="//s.4cdn.org/js/painter"], script[src="https://rawgit.com/desuwa/tegaki/master/tegaki.js"]').dataset.success = !!window.Tegaki
|
||||||
|
if script.dataset.success is 'true'
|
||||||
|
cb()
|
||||||
|
else
|
||||||
|
n = 1
|
||||||
|
onerror.call script
|
||||||
else
|
else
|
||||||
style = $.el 'link',
|
style = $.el 'link',
|
||||||
rel: 'stylesheet'
|
rel: 'stylesheet'
|
||||||
href: "//s.4cdn.org/css/painter.#{Date.now()}.css"
|
href: "//s.4cdn.org/css/painter.#{Date.now()}.css"
|
||||||
script = $.el 'script',
|
script = $.el 'script',
|
||||||
src: "//s.4cdn.org/js/painter.min.#{Date.now()}.js"
|
src: "//s.4cdn.org/js/painter.min.#{Date.now()}.js"
|
||||||
n = 0
|
|
||||||
onload = ->
|
|
||||||
cb() if ++n is 2
|
|
||||||
$.on style, 'load', onload
|
$.on style, 'load', onload
|
||||||
$.on script, 'load', onload
|
$.on script, 'load', onload
|
||||||
|
$.on script, 'error', onerror
|
||||||
$.add d.head, [style, script]
|
$.add d.head, [style, script]
|
||||||
|
|
||||||
draw: ->
|
draw: ->
|
||||||
|
|||||||
@ -832,6 +832,7 @@ Config =
|
|||||||
http://cdn.mathjax.org
|
http://cdn.mathjax.org
|
||||||
https://cdn.mathjax.org
|
https://cdn.mathjax.org
|
||||||
https://cdnjs.cloudflare.com
|
https://cdnjs.cloudflare.com
|
||||||
|
https://rawgit.com
|
||||||
'self'
|
'self'
|
||||||
'unsafe-inline'
|
'unsafe-inline'
|
||||||
'unsafe-eval'
|
'unsafe-eval'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user