1
0
Fork 0
mirror of https://github.com/SunRed/haste-server.git synced 2024-11-01 01:30:21 +01:00

Fix annoying chrome dual-load bug

This commit is contained in:
John Crepezzi 2011-11-28 01:27:41 -05:00
parent 6e2955d60c
commit 1ed980150c
2 changed files with 11 additions and 16 deletions

View file

@ -1,6 +1,5 @@
# TODO for OSS # TODO for OSS
* tests * tests
* fix that chrome bug where it loads the doc twice
* Add file extensions ourselves to push state * Add file extensions ourselves to push state
* add feedback for errors to UI - esp. too long * add feedback for errors to UI - esp. too long
* make sure file store still functions appropriately * make sure file store still functions appropriately

View file

@ -19,22 +19,18 @@
// Handle pops // Handle pops
var handlePop = function(evt) { var handlePop = function(evt) {
var path = evt.target.location.pathname; var path = evt.target.location.pathname;
if (path === '/') { if (path === '/') { app.newDocument(true); }
app.newDocument(true); else { app.loadDocument(path.substring(1, path.length)); }
}
else {
app.loadDocument(path.substring(1, path.length));
}
}; };
// If pop before loading jquery, delay load // Set up the pop state to handle loads, skipping the first load
window.onpopstate = function(evt) { // to make chrome behave like others:
try { // http://code.google.com/p/chromium/issues/detail?id=63040
handlePop(evt); setTimeout(function() {
} catch(err) { window.onpopstate = function(evt) {
// not loaded yet try { handlePop(evt); } catch(err) { /* not loaded yet */ }
} };
}; }, 1000);
// Construct app and load if not loaded // Construct app and load initial path
$(function() { $(function() {
app = new haste('hastebin', { twitter: true }); app = new haste('hastebin', { twitter: true });
handlePop({ target: window }); handlePop({ target: window });