Permalink
Browse files

Repair the "New Script" dialog.

Broken by the RemoteScript refactor.  Fixes #1484
  • Loading branch information...
1 parent da3853d commit b6c632dc70d7b7237c84acc99d7a2209f565ba6c @arantius arantius committed Jan 2, 2012
Showing with 16 additions and 8 deletions.
  1. +8 −5 content/newscript.js
  2. +1 −1 modules/parseScript.js
  3. +7 −2 modules/remoteScript.js
View
@@ -39,17 +39,20 @@ function doInstall() {
// finish making the script object ready to install
// (put this created script into a file -- only way to install it)
- var tempFile = GM_util.getTempFile();
+ var scope = {};
+ Components.utils.import('resource://greasemonkey/remoteScript.js', scope);
+ var remoteScript = new scope.RemoteScript();
+ var tempFile = GM_util.getTempFile(
+ remoteScript._tempDir, scope.cleanFilename(script.name, 'gm_script'));
GM_util.writeToFile(scriptSrc, tempFile, function() {
- script.setDownloadedFile(tempFile);
-
// install this script
- config.install(script);
+ remoteScript.setScript(script, tempFile);
+ remoteScript.install();
// and fire up the editor!
GM_util.openInEditor(script);
+
// persist namespace value
GM_prefRoot.setValue("newscript_namespace", script.namespace);
-
// Now that async write is complete, close the window.
close();
});
@@ -30,7 +30,7 @@ function parse(aSource, aUri) {
meta = meta.match(gLineSplitRegexp);
var resourceNames = {};
- for (var i = 0, metaLine = ''; metaLine = meta[i]; i++) {
+ if (meta) for (var i = 0, metaLine = ''; metaLine = meta[i]; i++) {
metaLine = metaLine.replace(/\s+$/, '');
var match = metaLine.match(gMetaLineRegexp);
@@ -1,4 +1,4 @@
-var EXPORTED_SYMBOLS = ['RemoteScript'];
+var EXPORTED_SYMBOLS = ['cleanFilename', 'RemoteScript'];
var Cc = Components.classes;
var Ci = Components.interfaces;
@@ -259,10 +259,15 @@ RemoteScript.prototype.onScriptMeta = function(aCallback) {
* After calling this, calling .download() will only get dependencies. This
* RemoteScript can then safely be .install(oldScript)'ed.
*/
-RemoteScript.prototype.setScript = function(aScript) {
+RemoteScript.prototype.setScript = function(aScript, aTempFile) {
this._scriptFile = aScript.file;
this._baseName = aScript._basedir;
this.script = aScript;
+ if (aTempFile) {
+ // Special case for "new script" dialog.
+ this._scriptFile = aTempFile;
+ this._baseName = cleanFilename(aScript.name, 'gm-script');
+ }
this._postParseScriptFile();
};

0 comments on commit b6c632d

Please sign in to comment.