mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 09:22:31 -06:00
fix sandbox lag by helping the iframe cache js
This commit is contained in:
parent
25931e62fd
commit
f74ac1f18b
|
@ -135,6 +135,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var SR = {{ r|tojson }},
|
var SR = {{ r|tojson }},
|
||||||
|
TS = "{{ ts }}",
|
||||||
acct = "{{ acct }}",
|
acct = "{{ acct }}",
|
||||||
perms = {{ perms }},
|
perms = {{ perms }},
|
||||||
themes = {{ themes }},
|
themes = {{ themes }},
|
||||||
|
|
|
@ -6585,6 +6585,28 @@ var globalcss = (function () {
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
var sandboxjs = (function () {
|
||||||
|
var ret = '',
|
||||||
|
busy = false,
|
||||||
|
url = SR + '/.cpr/util.js?_=' + TS,
|
||||||
|
tag = '<script src="' + url + '"></script>';
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
if (ret || busy)
|
||||||
|
return ret || tag;
|
||||||
|
|
||||||
|
var xhr = new XHR();
|
||||||
|
xhr.open('GET', url, true);
|
||||||
|
xhr.onload = function () {
|
||||||
|
if (this.status == 200)
|
||||||
|
ret = '<script>' + this.responseText + '</script>';
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
|
busy = true;
|
||||||
|
return tag;
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
function show_md(md, name, div, url, depth) {
|
function show_md(md, name, div, url, depth) {
|
||||||
var errmsg = L.md_eshow + name + ':\n\n',
|
var errmsg = L.md_eshow + name + ':\n\n',
|
||||||
|
@ -6696,8 +6718,7 @@ function sandbox(tgt, rules, cls, html) {
|
||||||
|
|
||||||
html = '<html class="iframe ' + document.documentElement.className + '"><head><style>' + globalcss() +
|
html = '<html class="iframe ' + document.documentElement.className + '"><head><style>' + globalcss() +
|
||||||
'</style><base target="_parent"></head><body id="b" class="logue ' + cls + '">' + html +
|
'</style><base target="_parent"></head><body id="b" class="logue ' + cls + '">' + html +
|
||||||
'<script>' + env + '</script>' +
|
'<script>' + env + '</script>' + sandboxjs() +
|
||||||
'<script src="' + SR + '/.cpr/util.js?_={{ ts }}"></script>' +
|
|
||||||
'<script>var ebi=document.getElementById.bind(document),d=document.documentElement,' +
|
'<script>var ebi=document.getElementById.bind(document),d=document.documentElement,' +
|
||||||
'loc=new URL("' + location.href.split('?')[0] + '");' +
|
'loc=new URL("' + location.href.split('?')[0] + '");' +
|
||||||
'function say(m){window.parent.postMessage(m,"*")};' +
|
'function say(m){window.parent.postMessage(m,"*")};' +
|
||||||
|
|
Loading…
Reference in a new issue