1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 12:07:19 +00:00
TiddlyWiki5/js/TiddlyWiki.js

34 lines
717 B
JavaScript
Executable File

var Tiddler = require("./Tiddler.js").Tiddler;
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 ? 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)
callback.call(this,t,tiddler);
}
}
exports.TiddlyWiki = TiddlyWiki