mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
golf / normalize window.location
This commit is contained in:
parent
c47047c30d
commit
72fc76ef48
|
@ -26,8 +26,8 @@ a {
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var a = document.getElementById('redir'),
|
var a = document.getElementById('redir'),
|
||||||
proto = window.location.protocol.indexOf('https') === 0 ? 'https' : 'http',
|
proto = location.protocol.indexOf('https') === 0 ? 'https' : 'http',
|
||||||
loc = window.location.hostname || '127.0.0.1',
|
loc = location.hostname || '127.0.0.1',
|
||||||
port = a.getAttribute('href').split(':').pop().split('/')[0],
|
port = a.getAttribute('href').split(':').pop().split('/')[0],
|
||||||
url = proto + '://' + loc + ':' + port + '/';
|
url = proto + '://' + loc + ':' + port + '/';
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ a.setAttribute('href', url);
|
||||||
document.getElementById('desc').innerHTML = 'redirecting to';
|
document.getElementById('desc').innerHTML = 'redirecting to';
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
window.location.href = url;
|
location.href = url;
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -875,7 +875,7 @@ window.baguetteBox = (function () {
|
||||||
|
|
||||||
if (loopB !== null) {
|
if (loopB !== null) {
|
||||||
timer.add(loopchk);
|
timer.add(loopchk);
|
||||||
sethash(window.location.hash.slice(1).split('&')[0] + '&t=' + (loopA || 0) + '-' + loopB);
|
sethash(location.hash.slice(1).split('&')[0] + '&t=' + (loopA || 0) + '-' + loopB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3915,9 +3915,9 @@ var showfile = (function () {
|
||||||
window.Prism = { 'manual': true };
|
window.Prism = { 'manual': true };
|
||||||
var em = QS('#bdoc>pre');
|
var em = QS('#bdoc>pre');
|
||||||
if (em)
|
if (em)
|
||||||
em = [r.sname(window.location.search), location.hash, em.textContent];
|
em = [r.sname(location.search), location.hash, em.textContent];
|
||||||
else {
|
else {
|
||||||
var m = /[?&]doc=([^&]+)/.exec(window.location.search);
|
var m = /[?&]doc=([^&]+)/.exec(location.search);
|
||||||
if (m) {
|
if (m) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
r.show(uricom_dec(m[1]), true);
|
r.show(uricom_dec(m[1]), true);
|
||||||
|
@ -3937,7 +3937,7 @@ var showfile = (function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
r.active = function () {
|
r.active = function () {
|
||||||
return document.location.search.indexOf('doc=') + 1;
|
return location.search.indexOf('doc=') + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
r.getlang = function (fn) {
|
r.getlang = function (fn) {
|
||||||
|
@ -5702,7 +5702,7 @@ var treectl = (function () {
|
||||||
}
|
}
|
||||||
var href = this.getAttribute('href');
|
var href = this.getAttribute('href');
|
||||||
if (R && !href.startsWith(SR)) {
|
if (R && !href.startsWith(SR)) {
|
||||||
window.location = href;
|
location = href;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
r.reqls(href, true);
|
r.reqls(href, true);
|
||||||
|
@ -5758,7 +5758,7 @@ var treectl = (function () {
|
||||||
var res = JSON.parse(this.responseText);
|
var res = JSON.parse(this.responseText);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
window.location = this.top;
|
location = this.top;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5818,7 +5818,7 @@ var treectl = (function () {
|
||||||
|
|
||||||
for (var a = 0; a < res.files.length; a++)
|
for (var a = 0; a < res.files.length; a++)
|
||||||
if (/^index.html?(\?|$)/i.exec(res.files[a].href)) {
|
if (/^index.html?(\?|$)/i.exec(res.files[a].href)) {
|
||||||
window.location = vjoin(top, res.files[a].href);
|
location = vjoin(top, res.files[a].href);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -507,11 +507,12 @@ dom_navtgl.onclick = function () {
|
||||||
redraw();
|
redraw();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!HTTPS)
|
if (!HTTPS && location.hostname != '127.0.0.1') try {
|
||||||
ebi('edit2').onclick = function (e) {
|
ebi('edit2').onclick = function (e) {
|
||||||
toast.err(0, "the fancy editor is only available over https");
|
toast.err(0, "the fancy editor is only available over https");
|
||||||
return ev(e);
|
return ev(e);
|
||||||
}
|
}
|
||||||
|
} catch (ex) { }
|
||||||
|
|
||||||
if (sread('hidenav') == 1)
|
if (sread('hidenav') == 1)
|
||||||
dom_navtgl.onclick();
|
dom_navtgl.onclick();
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
{%- if redir %}
|
{%- if redir %}
|
||||||
<script>
|
<script>
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
window.location.replace("{{ redir }}");
|
location.replace("{{ redir }}");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
</script>
|
</script>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
|
@ -807,7 +807,7 @@ function up2k_init(subtle) {
|
||||||
function init_deps() {
|
function init_deps() {
|
||||||
if (!loading_deps && !got_deps()) {
|
if (!loading_deps && !got_deps()) {
|
||||||
var fn = 'sha512.' + sha_js + '.js',
|
var fn = 'sha512.' + sha_js + '.js',
|
||||||
m = L.u_https1 + ' <a href="' + (window.location + '').replace(':', 's:') + '">' + L.u_https2 + '</a> ' + L.u_https3;
|
m = L.u_https1 + ' <a href="' + (location + '').replace(':', 's:') + '">' + L.u_https2 + '</a> ' + L.u_https3;
|
||||||
|
|
||||||
showmodal('<h1>loading ' + fn + '</h1>');
|
showmodal('<h1>loading ' + fn + '</h1>');
|
||||||
import_js(SR + '/.cpr/deps/' + fn, unmodal);
|
import_js(SR + '/.cpr/deps/' + fn, unmodal);
|
||||||
|
@ -1588,7 +1588,7 @@ function up2k_init(subtle) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
st.oserr = true;
|
st.oserr = true;
|
||||||
var msg = HTTPS ? L.u_emtleak3 : L.u_emtleak2.format((window.location + '').replace(':', 's:'));
|
var msg = HTTPS ? L.u_emtleak3 : L.u_emtleak2.format((location + '').replace(':', 's:'));
|
||||||
modal.alert(L.u_emtleak1 + msg + (CHROME ? L.u_emtleakc : FIREFOX ? L.u_emtleakf : ''));
|
modal.alert(L.u_emtleak1 + msg + (CHROME ? L.u_emtleakc : FIREFOX ? L.u_emtleakf : ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ var wah = '',
|
||||||
R = SR.slice(1),
|
R = SR.slice(1),
|
||||||
RS = R ? "/" + R : "",
|
RS = R ? "/" + R : "",
|
||||||
HALFMAX = 8192 * 8192 * 8192 * 8192,
|
HALFMAX = 8192 * 8192 * 8192 * 8192,
|
||||||
HTTPS = (window.location + '').indexOf('https:') === 0,
|
HTTPS = ('' + location).indexOf('https:') === 0,
|
||||||
TOUCH = 'ontouchstart' in window,
|
TOUCH = 'ontouchstart' in window,
|
||||||
MOBILE = TOUCH,
|
MOBILE = TOUCH,
|
||||||
CHROME = !!window.chrome,
|
CHROME = !!window.chrome,
|
||||||
|
|
Loading…
Reference in a new issue