1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 17:40:29 +00:00

Improved usability of addTiddler()

This commit is contained in:
Jeremy Ruston 2012-03-14 18:57:04 +00:00
parent 7970745f58
commit 1cf54ce08c

View File

@ -149,12 +149,22 @@ WikiStore.prototype.tiddlerExists = function(title) {
};
WikiStore.prototype.addTiddler = function(tiddler) {
// Check if we're passed a fields hashmap instead of a tiddler
if(!(tiddler instanceof Tiddler)) {
tiddler = new Tiddler(tiddler);
}
var status = tiddler.title in this.tiddlers ? "modified" : "created";
this.clearCache(tiddler.title);
this.tiddlers[tiddler.title] = tiddler;
this.touchTiddler(status,tiddler.title);
};
WikiStore.prototype.addTiddlers = function(tiddlers) {
for(var t=0; t<tiddlers.length; t++) {
this.addTiddler(tiddlers[t]);
}
};
WikiStore.prototype.forEachTiddler = function(/* [sortField,[excludeTag,]]callback */) {
var a = 0,
sortField = arguments.length > 1 ? arguments[a++] : null,