Changeset 656

Show
Ignore:
Timestamp:
02/10/08 03:17:29 (10 months ago)
Author:
ma..@jesperkristensen.dk
Message:

Move uninstall into config.js

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/config-service/src/chrome/chromeFiles/content/config.js

    r655 r656  
    258258}; 
    259259 
     260Config.prototype.uninstall = function(script, uninstallPrefs) 
     261{ 
     262  var idx = this.find(script.namespace, script.name); 
     263  this.scripts.splice(idx, 1); 
     264 
     265  if (script.basedir) // if script has its own dir, remove the dir + contents 
     266    script.basedirFile.remove(true); 
     267  else // if script is in the root, just remove the file 
     268    script.file.remove(false); 
     269 
     270  if (uninstallPrefs) // Remove saved preferences 
     271     GM_prefRoot.remove("scriptvals." + script.namespace + "/" + script.name + "."); 
     272} 
     273 
    260274Config.prototype.installDependency = function(script, req){ 
    261275  GM_log("Installing dependency: " + req.url  + " from " + req.tempFile.path); 
  • branches/config-service/src/chrome/chromeFiles/content/manage.js

    r655 r656  
    1313 
    1414function handleOkButton() { 
     15  var uninstallPrefs = document.getElementById('chkUninstallPrefs').checked; 
     16 
    1517  for (var i = 0, script = null; (script = uninstallList[i]); i++) { 
    16     var idx = config.find(script.namespace, script.name); 
    17     config.scripts.splice(idx, 1); 
     18    config.uninstall(script, uninstallPrefs); 
    1819  } 
    1920  config.save(); 
    20  
    21   var chkUninstallPrefs = document.getElementById('chkUninstallPrefs'); 
    22   for (var i = 0, script = null; (script = uninstallList[i]); i++) { 
    23     file = script.basedirFile; 
    24     file.normalize(); 
    25     if (!file.equals(config.scriptDir)) { 
    26       if (file.exists()) { 
    27         file.remove(true); // file==base directory recursive delete 
    28       } 
    29     } else { 
    30       file = script.file; 
    31       if (file.exists()) { 
    32         file.remove(false); 
    33       } 
    34     } 
    35     if (chkUninstallPrefs.checked) { 
    36        // Remove saved preferences 
    37        var scriptPrefRoot = ["scriptvals.", 
    38                   script.namespace, 
    39                   "/", 
    40                   script.name, 
    41                   "."].join(""); 
    42        GM_prefRoot.remove(scriptPrefRoot); 
    43     } 
    44   } 
    4521  return true; 
    4622};