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:
parent
7c7fd10c29
commit
3d501c980f
2 changed files with 329 additions and 328 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue