[Pkg-mozext-commits] [firebug] 51/68: issue6133: Default include() alias for jQuery
David Prévot
taffit at moszumanska.debian.org
Mon Mar 31 22:45:54 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag fbtest-1.11.4
in repository firebug.
commit 709ec79c75adaff21bbc9e88c1bd716345795e78
Author: Florent FAYOLLE <florent.fayolle69 at gmail.com>
Date: Tue Apr 23 23:17:28 2013 +0200
issue6133: Default include() alias for jQuery
---
extension/content/firebug/console/commandLineInclude.js | 17 +++++++++++++++--
extension/modules/storageService.js | 15 +++++++++++++--
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/extension/content/firebug/console/commandLineInclude.js b/extension/content/firebug/console/commandLineInclude.js
index 7d30508..a7faa96 100644
--- a/extension/content/firebug/console/commandLineInclude.js
+++ b/extension/content/firebug/console/commandLineInclude.js
@@ -25,6 +25,7 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
const removeConfirmation = "commandline.include.removeConfirmation";
const prompts = Xpcom.CCSV("@mozilla.org/embedcomp/prompt-service;1", "nsIPromptService");
+const storeFilename = "includeAliases.json";
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -44,6 +45,10 @@ catch(ex)
var storageScope = {};
Cu.import("resource://firebug/storageService.js", storageScope);
+var defaultAliases = {
+ "jquery": "http://code.jquery.com/jquery-latest.js"
+};
+
// ********************************************************************************************* //
// Implementation
@@ -340,14 +345,22 @@ var CommandLineInclude = Obj.extend(Firebug.Module,
{
if (!this.store)
{
+ var isNewStore = !storageScope.StorageService.hasStorage(storeFilename);
// Pass also the parent window to the new storage. The window will be
// used to figure out whether the browser is running in private mode.
// If yes, no data will be persisted.
- this.store = storageScope.StorageService.getStorage("includeAliases.json",
+ this.store = storageScope.StorageService.getStorage(storeFilename,
Firebug.chrome.window);
+
+ // If the file did not exist, we put in there the default aliases.
+ if (isNewStore)
+ {
+ for (var alias in defaultAliases)
+ this.store.setItem(alias, defaultAliases[alias]);
+ }
}
- // let's log when the store could not be opened:
+ // Let's log when the store could not be opened.
if (!this.store)
{
if (FBTrace.DBG_COMMANDLINE)
diff --git a/extension/modules/storageService.js b/extension/modules/storageService.js
index da540fa..d4e1b8a 100644
--- a/extension/modules/storageService.js
+++ b/extension/modules/storageService.js
@@ -159,6 +159,12 @@ var StorageService =
removeStorage: function(leafName)
{
ObjectPersister.deleteObject(leafname);
+ },
+
+ hasStorage: function(leafName)
+ {
+ var file = ObjectPersister.getFile(leafName);
+ return file.exists();
}
};
@@ -175,7 +181,7 @@ var ObjectPersister =
if (FBTrace.DBG_STORAGE)
FBTrace.sysout("ObjectPersister read from leafName "+leafName);
- var file = FileUtils.getFile("ProfD", ["firebug", leafName]);
+ var file = this.getFile(leafName);
if (!file.exists())
{
@@ -235,6 +241,11 @@ var ObjectPersister =
}
},
+ getFile: function(leafName)
+ {
+ return FileUtils.getFile("ProfD", ["firebug", leafName]);
+ },
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Batch the writes for each event loop
@@ -276,7 +287,7 @@ var ObjectPersister =
{
// Convert data to JSON.
var jsonString = JSON.stringify(obj);
- var file = FileUtils.getFile("ProfD", ["firebug", leafName]);
+ var file = this.getFile(leafName);
ObjectPersister.writeTextToFile(file, jsonString);
}
catch(exc)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git
More information about the Pkg-mozext-commits
mailing list