mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-17 03:20:02 +00:00
Fixes for permalinks not working on Firefox
Sigh. It’s frustrating that the few browser differences I’m running into in 2014 are mostly horribly familiar from 2005
This commit is contained in:
parent
ffb6c8ab81
commit
986a20b22b
10
boot/boot.js
10
boot/boot.js
@ -202,6 +202,14 @@ $tw.utils.htmlDecode = function(s) {
|
||||
return s.toString().replace(/</mg,"<").replace(/ /mg,"\xA0").replace(/>/mg,">").replace(/"/mg,"\"").replace(/&/mg,"&");
|
||||
};
|
||||
|
||||
/*
|
||||
Get the browser location.hash. We don't use location.hash because of the way that Firefox auto-urldecodes it (see http://stackoverflow.com/questions/1703552/encoding-of-window-location-hash)
|
||||
*/
|
||||
$tw.utils.getLocationHash = function() {
|
||||
var parts = window.location.href.split('#');
|
||||
return "#" + (parts.length > 1 ? parts[1] : "");
|
||||
};
|
||||
|
||||
/*
|
||||
Pad a string to a given length with "0"s. Length defaults to 2
|
||||
*/
|
||||
@ -1627,7 +1635,7 @@ $tw.boot.startup = function(options) {
|
||||
if(location.hash === "#:safe") {
|
||||
$tw.safeMode = true;
|
||||
} else {
|
||||
$tw.locationHash = location.hash;
|
||||
$tw.locationHash = $tw.utils.getLocationHash();
|
||||
}
|
||||
}
|
||||
// Initialise some more $tw properties
|
||||
|
@ -36,8 +36,9 @@ exports.startup = function() {
|
||||
});
|
||||
// Listen for changes to the browser location hash
|
||||
window.addEventListener("hashchange",function() {
|
||||
if(window.location.hash !== $tw.locationHash) {
|
||||
$tw.locationHash = window.location.hash;
|
||||
var hash = $tw.utils.getLocationHash();
|
||||
if(hash !== $tw.locationHash) {
|
||||
$tw.locationHash = hash;
|
||||
openStartupTiddlers({defaultToCurrentStory: true});
|
||||
}
|
||||
},false)
|
||||
@ -104,8 +105,11 @@ function updateLocationHash() {
|
||||
}
|
||||
$tw.locationHash = "#" + encodeURIComponent(targetTiddler) + ":" + encodeURIComponent($tw.utils.stringifyList(storyList));
|
||||
// Only change the location hash if we must, thus avoiding unnecessary onhashchange events
|
||||
if(window.location.hash !== $tw.locationHash) {
|
||||
// console.log("Testing",$tw.utils.getLocationHash(),$tw.locationHash)
|
||||
if($tw.utils.getLocationHash() !== $tw.locationHash) {
|
||||
window.location.hash = $tw.locationHash;
|
||||
console.log("Just set",$tw.locationHash,$tw.utils.getLocationHash())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user