From 8303028a8526ea6dd416a0bca5cd4d2836a708bf Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 22 Sep 2006 23:53:16 +0000 Subject: [PATCH] Closes #228, Use a unique default "Untitled" name for new saved searches Collections too - Also fixed JS strict warning in Item.erase() --- chrome/chromeFiles/content/scholar/overlay.js | 14 +++++--- .../content/scholar/xpcom/data_access.js | 6 ++-- .../chromeFiles/content/scholar/xpcom/db.js | 34 +++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index 2ed743387..0da4a218f 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -155,7 +155,11 @@ var ScholarPane = new function() var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); - var newName = { value: Scholar.getString('pane.collections.untitled') }; + var untitled = Scholar.getString('pane.collections.untitled'); + untitled = Scholar.DB.getNextName('collections', 'collectionName', + Scholar.getString('pane.collections.untitled')); + + var newName = { value: untitled }; var result = promptService.prompt(window, "", Scholar.getString('pane.collections.name'), newName, "", {}); @@ -166,7 +170,7 @@ var ScholarPane = new function() if (!newName.value) { - newName.value = Scholar.getString('pane.collections.untitled'); + newName.value = untitled; } Scholar.Collections.add(newName.value); @@ -177,8 +181,10 @@ var ScholarPane = new function() var s = new Scholar.Search(); s.addCondition('title','contains',''); - // TODO: add integer to 'Untitled' if more than one - var io = {dataIn: {search: s, name: 'Untitled'}, dataOut: null}; + var untitled = Scholar.getString('pane.collections.untitled'); + untitled = Scholar.DB.getNextName('savedSearches', 'savedSearchName', + Scholar.getString('pane.collections.untitled')); + var io = {dataIn: {search: s, name: untitled}, dataOut: null}; window.openDialog('chrome://scholar/content/searchDialog.xul','','chrome,modal',io); } diff --git a/chrome/chromeFiles/content/scholar/xpcom/data_access.js b/chrome/chromeFiles/content/scholar/xpcom/data_access.js index 90d43f047..f0e489f20 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/data_access.js +++ b/chrome/chromeFiles/content/scholar/xpcom/data_access.js @@ -1374,8 +1374,10 @@ Scholar.Item.prototype.erase = function(deleteChildren){ // Remove item from parent collections var parentCollectionIDs = this.getCollections(); - for (var i=0; i