home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 June / PCpro_2006_06.ISO / files / firefox / quotecolors-moz.xpi / install.js next >
Encoding:
Text File  |  2005-11-19  |  1.9 KB  |  49 lines

  1. const APP_DISPLAY_NAME = "Quote Colors";
  2. const APP_NAME = "quotecolors";
  3. const APP_PACKAGE = "/quotecolors";
  4. const APP_VERSION = "0.2.7";
  5.  
  6. const APP_JAR_FILE = "quotecolors.jar";
  7. const APP_PREFS_FILE = "defaults/preferences/quotecolors.js";
  8. const APP_CONTENT_FOLDER = "content/quotecolors/";
  9. const APP_LOCALES = [ "en-US", "de-DE", "es-ES", "fr-FR", "it-IT", "ja-JP", "pl-PL", "cs-CZ" ];
  10.  
  11. const APP_SUCCESS_MESSAGE = "You need to restart Mozilla first.";
  12. const INST_TO_PROFILE = "Do you wish to install "+APP_DISPLAY_NAME+" to your profile?\nThis will mean it does not need reinstalling when you update Mozilla.\n(Click Cancel if you want "+APP_DISPLAY_NAME+" installing to the Mozilla directory.)";
  13.  
  14. initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);
  15.  
  16. // profile installs only work since 2003-03-06
  17. var instToProfile = confirm(INST_TO_PROFILE);
  18.  
  19. var chromefolder = instToProfile ? getFolder("Profile", "chrome") : getFolder("chrome");
  20. var profileflag = instToProfile ? PROFILE_CHROME : DELAYED_CHROME;
  21.  
  22. var err = addFile(APP_PACKAGE, APP_VERSION, "chrome/"+APP_JAR_FILE, chromefolder, null)
  23.  
  24. if(err == SUCCESS) {
  25.     var jar = getFolder(chromefolder, APP_JAR_FILE);
  26.  
  27.   addFile(APP_NAME, APP_PREFS_FILE, getFolder("Program", "defaults/pref/"), null);
  28.  
  29.     registerChrome(CONTENT | profileflag, jar, APP_CONTENT_FOLDER);
  30.  
  31.   for(var i in APP_LOCALES) {
  32.     registerChrome(LOCALE  | profileflag, jar, "locale/"+APP_LOCALES[i]+"/"+APP_NAME+"/");
  33.   }
  34.  
  35.     err = performInstall();
  36.     if(err == SUCCESS || err == 999) {
  37.         alert(APP_DISPLAY_NAME+" "+APP_VERSION+" has been succesfully installed.\n"+APP_SUCCESS_MESSAGE);
  38.     } else {
  39.         alert("Install failed. Error code:" + err);
  40.         cancelInstall(err);
  41.     }
  42. } else {
  43.     alert("Failed to create " +APP_JAR_FILE +"\n"
  44.         +"You probably don't have appropriate permissions \n"
  45.         +"(write access to your profile or chrome directory). \n"
  46.         +"_____________________________\nError code:" + err);
  47.     cancelInstall(err);
  48. }
  49.