]> git.evergreen-ils.org Git - Evergreen.git/blob - Evergreen/staff_client/install.js
pass patron id through payment_blob
[Evergreen.git] / Evergreen / staff_client / install.js
1 // XpiInstaller
2 // By Pike (Heavily inspired by code from Henrik Gemal and Stephen Clavering)
3 // Modified by Jason for Evergreen
4
5 var XpiInstaller = {
6
7         // --- Editable items begin ---
8         extFullName: 'Evergreen Staff Client Demo', // The name displayed to the user (don't include the version)
9         extShortName: 'evergreen', // The leafname of the JAR file (without the .jar part)
10         extVersion: '0.0.4',
11         extAuthor: 'GPLS',
12         extLocaleNames: ['en-US'], //null, // e.g. ['en-US', 'en-GB']
13         extSkinNames: null, // e.g. ['classic', 'modern']  I have this broken
14         extPostInstallMessage: 'Success! Please restart your browser to finish the installation.', // Set to null for no post-install message
15         // --- Editable items end ---
16
17         profileInstall: true,
18         silentInstall: true,
19
20         install: function()
21         {
22                 var jarName = this.extShortName + '.jar';
23                 var profileDir = Install.getFolder('Profile', 'chrome');
24
25                 // Parse HTTP arguments
26                 this.parseArguments();
27
28                 // Check if extension is already installed in profile
29                 if (File.exists(Install.getFolder(profileDir, jarName)))
30                 {
31                         if (!this.silentInstall)
32                         {
33                                 Install.alert('Updating existing Profile install of ' + this.extFullName + ' to version ' + this.extVersion + '.');
34                         }
35                         this.profileInstall = true;
36                 }
37                 else if (!this.silentInstall)
38                 {
39                         // Ask user for install location, profile or browser dir?
40                         this.profileInstall = Install.confirm('Install ' + this.extFullName + ' ' + this.extVersion + ' to your Profile directory (OK) or your Browser directory (Cancel)?');
41                 }
42
43                 // Init install
44                 var dispName = this.extFullName + ' ' + this.extVersion;
45                 var regName = '/' + this.extAuthor + '/' + this.extShortName;
46                 Install.initInstall(dispName, regName, this.extVersion);
47
48                 // Find directory to install into
49                 var installPath;
50                 if (this.profileInstall) installPath = profileDir;
51                 else installPath = Install.getFolder('chrome');
52
53                 // Add JAR file
54                 Install.addFile(null, 'chrome/' + jarName, installPath, null);
55
56                 // Register chrome
57                 var jarPath = Install.getFolder(installPath, jarName);
58                 var installType = this.profileInstall ? Install.PROFILE_CHROME : Install.DELAYED_CHROME;
59
60                 // Register content
61                 Install.registerChrome(Install.CONTENT | installType, jarPath, 'content/' + this.extShortName + '/');
62
63                 // Register locales
64                 for (var locale in this.extLocaleNames)
65                 {
66                         var regPath = 'locale/' + this.extLocaleNames[locale] + '/' + this.extShortName + '/';
67                         Install.registerChrome(Install.LOCALE | installType, jarPath, regPath);
68                 }
69
70                 // Register skins
71                 var regPath = 'skin/' + this.extShortName + '/';
72                 Install.registerChrome(Install.SKIN | installType, jarPath, regPath);
73
74                 // Perform install
75                 var err = Install.performInstall();
76                 if (err == Install.SUCCESS || err == Install.REBOOT_NEEDED)
77                 {
78                         if (!this.silentInstall && this.extPostInstallMessage)
79                         {
80                                 Install.alert(this.extPostInstallMessage);
81                         }
82                 }
83                 else
84                 {
85                         this.handleError(err);
86                         return;
87                 }
88         },
89
90         parseArguments: function()
91         {
92                 // Can't use string handling in install, so use if statement instead
93                 var args = Install.arguments;
94                 if (args == 'p=0')
95                 {
96                         this.profileInstall = false;
97                         this.silentInstall = true;
98                 }
99                 else if (args == 'p=1')
100                 {
101                         this.profileInstall = true;
102                         this.silentInstall = true;
103                 }
104         },
105
106         handleError: function(err)
107         {
108                 if (!this.silentInstall)
109                 {
110                         Install.alert('Error: Could not install ' + this.extFullName + ' ' + this.extVersion + ' (Error code: ' + err + ')');
111                 }
112                 Install.cancelInstall(err);
113         }
114 };
115
116 XpiInstaller.install(); 
117 /* 
118 Install.alert('The install.js file for Evergreen is currently broken for Mozilla browsers.  Any volunteers for fixing this?  The problem I see is with registering the skin component.  The install.rdf for Firefox should work');
119 Install.cancelInstall(Install.INSTALL_CANCELLED);
120 */