Add script nonce when loading js for globe in sidebar

This commit is contained in:
shortcutme 2018-11-26 00:14:30 +01:00
parent e0756a56a4
commit 46e694a5c8
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 11 additions and 2 deletions

View file

@ -564,7 +564,11 @@ class Sidebar extends Class
if @tag.find(".globe").hasClass("loading") if @tag.find(".globe").hasClass("loading")
setTimeout (=> setTimeout (=>
if typeof(DAT) == "undefined" # Globe script not loaded, do it first if typeof(DAT) == "undefined" # Globe script not loaded, do it first
$.getScript("/uimedia/globe/all.js", @displayGlobe) script_tag = $("<script>")
script_tag.attr("nonce", @wrapper.script_nonce)
script_tag.attr("src", "/uimedia/globe/all.js")
script_tag.on("load", @displayGlobe)
document.head.appendChild(script_tag[0])
else else
@displayGlobe() @displayGlobe()
), 600 ), 600

View file

@ -1075,8 +1075,13 @@ window.initScrollable = function () {
if (this.tag.find(".globe").hasClass("loading")) { if (this.tag.find(".globe").hasClass("loading")) {
return setTimeout(((function(_this) { return setTimeout(((function(_this) {
return function() { return function() {
var script_tag;
if (typeof DAT === "undefined") { if (typeof DAT === "undefined") {
return $.getScript("/uimedia/globe/all.js", _this.displayGlobe); script_tag = $("<script>");
script_tag.attr("nonce", _this.wrapper.script_nonce);
script_tag.attr("src", "/uimedia/globe/all.js");
script_tag.on("load", _this.displayGlobe);
return document.head.appendChild(script_tag[0]);
} else { } else {
return _this.displayGlobe(); return _this.displayGlobe();
} }