1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Share plugin: Improve startup error handling

This commit is contained in:
Jeremy Ruston 2020-02-04 16:20:16 +00:00
parent 90366e9b3b
commit b9d20f1868

View File

@ -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);
}
}
}