2 // By Pike (Heavily inspired by code from Henrik Gemal and Stephen Clavering)
\r
6 // --- Editable items begin ---
\r
7 extFullName: 'QuoteCollapse', // The name displayed to the user (don't include the version)
\r
8 extShortName: 'quotecollapse', // The leafname of the JAR file (without the .jar part)
\r
10 extAuthor: 'Michael J Gruber',
\r
11 extLocaleNames: null, // e.g. ['en-US', 'en-GB']
\r
12 extSkinNames: ['classic','mcrystal'], // e.g. ['classic', 'modern']
\r
13 extPostInstallMessage: 'Success! Please restart your browser to finish the installation.', // Set to null for no post-install message
\r
14 // --- Editable items end ---
\r
16 profileInstall: true,
\r
17 silentInstall: false,
\r
21 var jarName = this.extShortName + '.jar';
\r
22 var profileDir = Install.getFolder('Profile', 'chrome');
\r
24 // Parse HTTP arguments
\r
25 this.parseArguments();
\r
27 // Check if extension is already installed in profile
\r
28 if (File.exists(Install.getFolder(profileDir, jarName)))
\r
30 if (!this.silentInstall)
\r
32 Install.alert('Updating existing Profile install of ' + this.extFullName + ' to version ' + this.extVersion + '.');
\r
34 this.profileInstall = true;
\r
36 else if (!this.silentInstall)
\r
38 // Ask user for install location, profile or browser dir?
\r
39 this.profileInstall = Install.confirm('Install ' + this.extFullName + ' ' + this.extVersion + ' to your Profile directory (OK) or your Browser directory (Cancel)?');
\r
43 var dispName = this.extFullName + ' ' + this.extVersion;
\r
44 var regName = '/' + this.extAuthor + '/' + this.extShortName;
\r
45 Install.initInstall(dispName, regName, this.extVersion);
\r
47 // Find directory to install into
\r
49 if (this.profileInstall) installPath = profileDir;
\r
50 else installPath = Install.getFolder('chrome');
\r
53 Install.addFile(null, 'chrome/' + jarName, installPath, null);
\r
56 var jarPath = Install.getFolder(installPath, jarName);
\r
57 var installType = this.profileInstall ? Install.PROFILE_CHROME : Install.DELAYED_CHROME;
\r
60 Install.registerChrome(Install.CONTENT | installType, jarPath, 'content/' + this.extShortName + '/');
\r
63 for (var locale in this.extLocaleNames)
\r
65 var regPath = 'locale/' + this.extLocaleNames[locale] + '/' + this.extShortName + '/';
\r
66 Install.registerChrome(Install.LOCALE | installType, jarPath, regPath);
\r
70 for (var skin in this.extSkinNames)
\r
72 var regPath = 'skin/' + this.extSkinNames[skin] + '/' + this.extShortName + '/';
\r
73 Install.registerChrome(Install.SKIN | installType, jarPath, regPath);
\r
77 var err = Install.performInstall();
\r
78 if (err == Install.SUCCESS || err == Install.REBOOT_NEEDED)
\r
80 if (!this.silentInstall && this.extPostInstallMessage)
\r
82 Install.alert(this.extPostInstallMessage);
\r
87 this.handleError(err);
\r
92 parseArguments: function()
\r
94 // Can't use string handling in install, so use if statement instead
\r
95 var args = Install.arguments;
\r
98 this.profileInstall = false;
\r
99 this.silentInstall = true;
\r
101 else if (args == 'p=1')
\r
103 this.profileInstall = true;
\r
104 this.silentInstall = true;
\r
108 handleError: function(err)
\r
110 if (!this.silentInstall)
\r
112 Install.alert('Error: Could not install ' + this.extFullName + ' ' + this.extVersion + ' (Error code: ' + err + ')');
\r
114 Install.cancelInstall(err);
\r
118 XpiInstaller.install();
\r