Commit 1ed98015 authored by John Crepezzi's avatar John Crepezzi
Browse files

Fix annoying chrome dual-load bug

parent 6e2955d6
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
# TODO for OSS
* tests
* fix that chrome bug where it loads the doc twice
* Add file extensions ourselves to push state
* add feedback for errors to UI - esp. too long
* make sure file store still functions appropriately
+11 −15
Original line number Diff line number Diff line
@@ -19,22 +19,18 @@
			// Handle pops
			var handlePop = function(evt) {
				var path = evt.target.location.pathname;
				if (path === '/') {
					app.newDocument(true);	
				}
				else {
					app.loadDocument(path.substring(1, path.length));
				}
				if (path === '/') { app.newDocument(true); }
				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
			// to make chrome behave like others:
			// http://code.google.com/p/chromium/issues/detail?id=63040
			setTimeout(function() {
				window.onpopstate = function(evt) {
				try {
					handlePop(evt);
				} catch(err) {
					// not loaded yet
				}
					try { handlePop(evt); } catch(err) { /* not loaded yet */ }
				};
			// Construct app and load if not loaded
			}, 1000);
			// Construct app and load initial path
			$(function() {
				app = new haste('hastebin', { twitter: true });
				handlePop({ target: window });