From 317a70c5a10b71d7bf4a83cb096ef9f5b7c9215b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 31 Aug 2010 11:05:48 -0400 Subject: [PATCH] Use the hash to store the path. --- web_frontend/main.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/web_frontend/main.js b/web_frontend/main.js index 5cd5101..ff39750 100644 --- a/web_frontend/main.js +++ b/web_frontend/main.js @@ -6,9 +6,14 @@ goog.require('goog.net.XhrIo'); goog.require('goog.Uri.QueryData'); armadillo = function() { - this.list('/'); - this.currentPath_ = '/'; + var start_path = '/'; + if (window.location.hash) { + start_path = window.location.hash.substr(1); + } + this.list(start_path); this.listeners_ = new Array(); + goog.events.listen(window, goog.events.EventType.HASHCHANGE, + this.hashChanged_, false, this); } /** @@ -42,6 +47,7 @@ armadillo.prototype.list = function(path) { // Update the listing. goog.dom.setTextContent(goog.dom.getElement('pwd'), path); app.currentPath_ = path; + window.location.hash = path; var list = goog.dom.getElement('ls'); goog.dom.removeChildren(list); @@ -67,6 +73,15 @@ armadillo.prototype.clickHandler_ = function(e) { } }; +/** + * Event for when the hash changes. + * @param {Event} e + */ +armadillo.prototype.hashChanged_ = function(e) { + if (window.location.hash.length) + this.list(window.location.hash.substr(1)); +}; + /** * Checks whether a path is a directory. * @param {string} path -- 2.22.5