1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-13 07:49:42 +00:00
TiddlyWiki5/tw5dropbox/appwiki/plugins/dropbox-app.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

2012-10-10 20:59:25 +00:00
/*\
title: $:/plugins/dropbox/dropbox-app.js
type: application/javascript
module-type: dropbox-startup
Startup the Dropbox wiki app
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
2012-10-10 21:46:59 +00:00
var titleWikiName = "$:/plugins/dropbox/WikiName";
2012-10-10 20:59:25 +00:00
exports.startup = function() {
2012-10-10 21:46:59 +00:00
// Check that we've been loaded from the dropbox
var url = (window.location.protocol + "//" + window.location.host + window.location.pathname),
wikiName;
if(url.indexOf($tw.plugins.dropbox.userInfo.publicAppUrl) === 0) {
var p = url.indexOf("/",$tw.plugins.dropbox.userInfo.publicAppUrl.length + 1);
if(p !== -1 && url.substr(p) === "/index.html") {
wikiName = decodeURIComponent(url.substring($tw.plugins.dropbox.userInfo.publicAppUrl.length + 1,p));
}
}
if(wikiName) {
$tw.plugins.dropbox.wikiName = wikiName;
$tw.wiki.addTiddler({title: titleWikiName, text: $tw.plugins.dropbox.wikiName},true);
2012-10-10 21:46:59 +00:00
// Load tiddlers
$tw.plugins.dropbox.loadTiddlerFiles("/" + $tw.plugins.dropbox.wikiName + "/tiddlers",function() {
console.log("Loaded all tiddlers",$tw.wiki.tiddlers);
});
} else {
alert("This TiddlyWiki file must be in Dropbox");
}
2012-10-10 20:59:25 +00:00
};
})();