var hashchange = (function () { var exports = {}; var expected_hash = false; exports.changehash = function (newhash) { expected_hash = newhash; // Some browsers reset scrollTop when changing the hash to "", // so we save and restore it. // http://stackoverflow.com/questions/4715073/window-location-hash-prevent-scrolling-to-the-top var scrolltop = viewport.scrollTop(); window.location.hash = newhash; util.reset_favicon(); if (newhash === "" || newhash === "#") { viewport.scrollTop(scrolltop); } }; exports.save_narrow = function (operators) { if (operators === undefined) { exports.changehash('#'); } else { var new_hash = '#narrow'; $.each(operators, function (idx, elem) { new_hash += '/' + encodeURIComponent(elem[0]) + '/' + encodeURIComponent(elem[1]); }); exports.changehash(new_hash); } }; function parse_narrow(hash) { var i, operators = []; for (i=1; i