mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
47 lines
1.1 KiB
JavaScript
Executable File
47 lines
1.1 KiB
JavaScript
Executable File
/*global require: false, exports: false */
|
|
"use strict";
|
|
|
|
var Tiddler = require("./Tiddler.js").Tiddler;
|
|
|
|
var TiddlyWiki = function TiddlyWiki(shadowStore) {
|
|
this.tiddlers = {};
|
|
this.shadows = shadowStore === undefined ? new TiddlyWiki(null) : shadowStore;
|
|
};
|
|
|
|
TiddlyWiki.prototype.clear = function() {
|
|
this.tiddlers = {};
|
|
};
|
|
|
|
TiddlyWiki.prototype.getTiddler = function(title) {
|
|
var t = this.tiddlers[title];
|
|
return t instanceof Tiddler ? t : null;
|
|
};
|
|
|
|
TiddlyWiki.prototype.getTiddlerText = function(title) {
|
|
var t = this.tiddlers[title];
|
|
return t instanceof Tiddler ? t.fields.text : null;
|
|
};
|
|
|
|
TiddlyWiki.prototype.deleteTiddler = function(title) {
|
|
delete this.tiddlers[title];
|
|
};
|
|
|
|
TiddlyWiki.prototype.isTiddler = function(title) {
|
|
return this.tiddlers[title] instanceof Tiddler;
|
|
};
|
|
|
|
TiddlyWiki.prototype.addTiddler = function(tiddler) {
|
|
this.tiddlers[tiddler.fields.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;
|