Created
June 23, 2011 13:12
-
-
Save jdlrobson/1042510 to your computer and use it in GitHub Desktop.
overriding fetchTiddler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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