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")
setTimeout (=>
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
@displayGlobe()
), 600

View file

@ -1075,8 +1075,13 @@ window.initScrollable = function () {
if (this.tag.find(".globe").hasClass("loading")) {
return setTimeout(((function(_this) {
return function() {
var script_tag;
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 {
return _this.displayGlobe();
}