mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Merge branch 'tiddlerexistsloops' of https://github.com/Skeeve/TiddlyWiki5 into Skeeve-tiddlerexistsloops
This commit is contained in:
commit
274c52005d
@ -322,11 +322,10 @@ NavigatorWidget.prototype.handleNewTiddlerEvent = function(event) {
|
||||
// Create the new tiddler
|
||||
var baseTitle = (templateTiddler && templateTiddler.fields.title) || "New Tiddler",
|
||||
title;
|
||||
for(var t=0; true; t++) {
|
||||
title = baseTitle + (t ? " " + t : "");
|
||||
if(!this.wiki.tiddlerExists(title)) {
|
||||
break;
|
||||
}
|
||||
var t = 0,
|
||||
title = baseTitle;
|
||||
while (this.wiki.tiddlerExists(title)) {
|
||||
title = baseTitle + " " + (++t);
|
||||
}
|
||||
var tiddler = new $tw.Tiddler(this.wiki.getCreationFields(),{
|
||||
text: "Newly created tiddler",
|
||||
|
@ -173,11 +173,11 @@ exports.tiddlerExists = function(title) {
|
||||
Generate an unused title from the specified base
|
||||
*/
|
||||
exports.generateNewTitle = function(baseTitle) {
|
||||
var c = 0;
|
||||
do {
|
||||
var title = baseTitle + (c ? " " + (c + 1) : "");
|
||||
c++;
|
||||
} while(this.tiddlerExists(title));
|
||||
var c = 0,
|
||||
title = baseTitle;
|
||||
while(this.tiddlerExists(title) {
|
||||
title = baseTitle + " " + (++c);
|
||||
};
|
||||
return title;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user