mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +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
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user