Share plugin: Improve startup error handling

fix-syncer
Jeremy Ruston 2020-02-04 16:20:16 +00:00
rodzic 90366e9b3b
commit b9d20f1868
1 zmienionych plików z 20 dodań i 12 usunięć

Wyświetl plik

@ -15,20 +15,28 @@ Read tiddlers from the browser location hash
// Get the hash
var rawHash = document.location.hash.substring(1);
if(rawHash.charAt(0) === "#") {
var hash = decodeURIComponent(rawHash.substring(1));
// Try to parse the hash as JSON
var tiddlers;
try {
tiddlers= JSON.parse(hash);
var hash;
try{
hash = decodeURIComponent(rawHash.substring(1));
} catch(ex) {
console.log("Error decoding location hash",ex);
}
if(tiddlers) {
// Need to initialise these because we run before bootprefix.js and boot.js
window.$tw = window.$tw || {};
$tw.boot = $tw.boot || {};
$tw.preloadTiddlers = $tw.preloadTiddlers || [];
// Load our tiddlers
$tw.preloadTiddlers = $tw.preloadTiddlers.concat(tiddlers);
// Try to parse the hash as JSON
if(hash) {
var tiddlers;
try {
tiddlers= JSON.parse(hash);
} catch(ex) {
console.log("Error parsing JSON from location hash",ex);
}
if(tiddlers) {
// Need to initialise these because we run before bootprefix.js and boot.js
window.$tw = window.$tw || {};
$tw.boot = $tw.boot || {};
$tw.preloadTiddlers = $tw.preloadTiddlers || [];
// Load our tiddlers
$tw.preloadTiddlers = $tw.preloadTiddlers.concat(tiddlers);
}
}
}