1
0
Fork 0
mirror of https://github.com/SunRed/haste-server.git synced 2025-09-06 05:20:14 +02:00

Made app.js proper Class, added support for non-absolute path

Something that would solve relevant upstream issues/prs: seejohnrun/haste-server#53 seejohnrun/haste-server#140
This commit is contained in:
zneix 2020-09-05 18:13:49 +02:00
parent 7c7fd10c29
commit 3d501c980f
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 911916E0523B22F6
2 changed files with 329 additions and 328 deletions

View file

@ -17,9 +17,9 @@
let app = null;
// Handle pops
let handlePop = function(evt){
let path = evt.target.location.pathname;
if (path == '/'){ app.newDocument(true); }
else { app.loadDocument(path.substring(1, path.length)); }
let path = evt.target.location.href;
if (path == app.baseUrl) app.newDocument(true);
else app.loadDocument(path.split('/').slice(-1)[0]);
};
// Set up the pop state to handle loads, skipping the first load
// to make chrome behave like others:
@ -31,7 +31,12 @@
}, 1000);
// Construct app and load initial path
$(function(){
app = new haste('hastebin', { twitter: true });
let baseUrl = window.location.href.split('/');
console.log(baseUrl);
baseUrl = baseUrl.slice(0, baseUrl.length - 1).join('/') + '/';
console.log(baseUrl);
// baseUrl = 'https://plazatest.zneix.eu/haste/';
app = new haste('hastebin', { twitter: true, baseUrl: baseUrl });
handlePop({ target: window });
});
</script>
@ -44,7 +49,7 @@
<div id="key">
<div id="pointer" style="display:none;"></div>
<div id="box1">
<a href="/about.md" class="logo"></a>
<a href="about.md" class="logo"></a>
</div>
<div id="box2">
<button class="save function button-picture">Save</button>