mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-24 02:27:19 +00:00
Improved usability of addTiddler()
This commit is contained in:
parent
7970745f58
commit
1cf54ce08c
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user