0

hashchange triggered by setHash is now properly ignored

This commit is contained in:
Kang Seonghoon
2013-05-12 00:32:44 +09:00
parent 372b4e5e44
commit e466f891e1

View File

@@ -4,6 +4,8 @@ overviewer.util = {
readyQueue: [],
isReady: false,
lastHash: null,
/* fuzz tester!
*/
'testMaths': function(t) {
@@ -466,18 +468,23 @@ overviewer.util = {
});
},
'initHash': function() {
if(window.location.hash.split("/").length > 1) {
overviewer.util.goToHash();
// Clean up the hash.
overviewer.util.updateHash();
var newHash = window.location.hash;
if (overviewer.util.lastHash !== newHash) {
overviewer.util.lastHash = newHash;
if(newHash.split("/").length > 1) {
overviewer.util.goToHash();
// Clean up the hash.
overviewer.util.updateHash();
}
}
},
'setHash': function(x, y, z, zoom, w, maptype) {
// save this info is a nice easy to parse format
var currentWorldView = overviewer.mapModel.get("currentWorldView");
currentWorldView.options.lastViewport = [x,y,z,zoom];
window.location.replace("#/" + Math.floor(x) + "/" + Math.floor(y) + "/" + Math.floor(z) + "/" + zoom + "/" + w + "/" + maptype);
var newHash = "#/" + Math.floor(x) + "/" + Math.floor(y) + "/" + Math.floor(z) + "/" + zoom + "/" + w + "/" + maptype;
overviewer.util.lastHash = newHash; // this should not trigger initHash
window.location.replace(newHash);
},
'updateHash': function() {
var currTileset = overviewer.mapView.options.currentTileSet;