Skip to content

Instantly share code, notes, and snippets.

@jdlrobson
Created June 23, 2011 13:12
Show Gist options
  • Save jdlrobson/1042510 to your computer and use it in GitHub Desktop.
Save jdlrobson/1042510 to your computer and use it in GitHub Desktop.
overriding fetchTiddler
function TiddlyWiki()
{
var tiddlers = {}; // Hashmap by name of tiddlers
this.tiddlersUpdated = false;
this.namedNotifications = []; // Array of {name:,notify:} of notification functions
this.notificationLevel = 0;
this.slices = {}; // map tiddlerName->(map sliceName->sliceValue). Lazy.
this.clear = function() {
tiddlers = {};
this.setDirty(false);
};
var cache = {};
this.fetchTiddler = function(title) {
var tid = new Tiddler("bar");
tid.text = "hello";
return tid;
};
this.deleteTiddler = function(title) {
delete this.slices[title];
delete tiddlers[title];
};
this.addTiddler = function(tiddler) {
delete this.slices[tiddler.title];
tiddlers[tiddler.title] = tiddler;
};
this.forEachTiddler = function(callback) {
for(var t in tiddlers) {
var tiddler = tiddlers[t];
if(tiddler instanceof Tiddler)
callback.call(this,t,tiddler);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment