1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00
TiddlyWiki5/js/TiddlyWiki.js
2011-11-22 17:42:03 +00:00

34 lines
725 B
JavaScript
Executable File

var tiddler = require("./Tiddler.js");
var TiddlyWiki = function() {
this.tiddlers = {};
};
TiddlyWiki.prototype.clear = function() {
this.tiddlers = {};
}
TiddlyWiki.prototype.fetchTiddler = function(title) {
var t = this.tiddlers[title];
return t instanceof tiddler.Tiddler ? t : null;
}
TiddlyWiki.prototype.deleteTiddler = function(title) {
delete this.tiddlers[title];
}
TiddlyWiki.prototype.addTiddler = function(tiddler) {
this.tiddlers[tiddler.title] = tiddler;
}
TiddlyWiki.prototype.forEachTiddler = function(callback) {
var t;
for(t in this.tiddlers) {
var tiddler = this.tiddlers[t];
if(tiddler instanceof tiddler.Tiddler)
callback.call(this,t,tiddler);
}
}
exports.TiddlyWiki = TiddlyWiki