mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-25 23:03:15 +00:00
Share plugin: Improve startup error handling
This commit is contained in:
parent
90366e9b3b
commit
b9d20f1868
|
@ -15,20 +15,28 @@ Read tiddlers from the browser location hash
|
||||||
// Get the hash
|
// Get the hash
|
||||||
var rawHash = document.location.hash.substring(1);
|
var rawHash = document.location.hash.substring(1);
|
||||||
if(rawHash.charAt(0) === "#") {
|
if(rawHash.charAt(0) === "#") {
|
||||||
var hash = decodeURIComponent(rawHash.substring(1));
|
var hash;
|
||||||
// Try to parse the hash as JSON
|
try{
|
||||||
var tiddlers;
|
hash = decodeURIComponent(rawHash.substring(1));
|
||||||
try {
|
|
||||||
tiddlers= JSON.parse(hash);
|
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
|
console.log("Error decoding location hash",ex);
|
||||||
}
|
}
|
||||||
if(tiddlers) {
|
// Try to parse the hash as JSON
|
||||||
// Need to initialise these because we run before bootprefix.js and boot.js
|
if(hash) {
|
||||||
window.$tw = window.$tw || {};
|
var tiddlers;
|
||||||
$tw.boot = $tw.boot || {};
|
try {
|
||||||
$tw.preloadTiddlers = $tw.preloadTiddlers || [];
|
tiddlers= JSON.parse(hash);
|
||||||
// Load our tiddlers
|
} catch(ex) {
|
||||||
$tw.preloadTiddlers = $tw.preloadTiddlers.concat(tiddlers);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user