~ubuntu-branches/ubuntu/natty/adblock-plus/natty

« back to all changes in this revision

Viewing changes to chrome/content/ui/about.js

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-11-05 18:42:36 UTC
  • mto: (25.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: james.westby@ubuntu.com-20101105184236-h7dnu8mbfjaoya62
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
}
29
29
catch (e) {}
30
30
 
31
 
const addonID = "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}";
32
 
 
33
31
function init()
34
32
{
35
 
  E("version").value = abp.getInstalledVersion();
36
 
 
37
33
  let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
38
34
  if (typeof AddonManager != "undefined")
39
35
  {
40
 
    let addon = AddonManager.getAddonByID(addonID, function(addon)
 
36
    let addon = AddonManager.getAddonByID(Utils.addonID, function(addon)
41
37
    {
42
 
      loadInstallManifest(addon.getResourceURI("install.rdf"));
 
38
      loadInstallManifest(addon.getResourceURI("install.rdf"), addon.name, addon.homepageURL);
43
39
    });
44
40
  }
45
41
  else
46
42
  {
47
43
    let extensionManager = Cc["@mozilla.org/extensions/manager;1"].getService(Ci.nsIExtensionManager);
48
 
    let installLocation = extensionManager.getInstallLocation(addonID);
49
 
    let installManifestFile = installLocation.getItemFile(addonID, "install.rdf");
50
 
    loadInstallManifest(ioService.newFileURI(installManifestFile));
 
44
    let rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
 
45
    let root = rdf.GetResource("urn:mozilla:item:" + Utils.addonID);
 
46
 
 
47
    function emResource(prop)
 
48
    {
 
49
      return rdf.GetResource("http://www.mozilla.org/2004/em-rdf#" + prop);
 
50
    }
 
51
  
 
52
    function getTarget(prop)
 
53
    {
 
54
      let target = extensionManager.datasource.GetTarget(root, emResource(prop), true);
 
55
      if (target)
 
56
        return target.QueryInterface(Ci.nsIRDFLiteral).Value;
 
57
      else
 
58
        return null;
 
59
    }
 
60
    
 
61
    let installLocation = extensionManager.getInstallLocation(Utils.addonID);
 
62
    let installManifestFile = installLocation.getItemFile(Utils.addonID, "install.rdf");
 
63
    loadInstallManifest(ioService.newFileURI(installManifestFile), getTarget("name"), getTarget("homepageURL"));
51
64
  }
52
65
}
53
66
 
54
 
function loadInstallManifest(installManifestURI)
 
67
function loadInstallManifest(installManifestURI, name, homepage)
55
68
{
56
69
  let rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
57
70
  let ds = rdf.GetDataSource(installManifestURI.spec);
73
86
 
74
87
  function dataSourceLoaded()
75
88
  {
76
 
    setContributors(getTargets("contributor"), getTargets("translator"));
 
89
    setExtensionData(name, getTargets("version")[0],
 
90
                     homepage, getTargets("creator"),
 
91
                     getTargets("contributor"), getTargets("translator"));
77
92
  }
78
93
 
79
94
  if (ds instanceof Ci.nsIRDFRemoteDataSource && ds.loaded)
106
121
    return 0;
107
122
}
108
123
 
109
 
function setContributors(contributors, translators)
 
124
function setExtensionData(name, version, homepage, authors, contributors, translators)
110
125
{
 
126
  authors.sort(cmpNoCase);
111
127
  contributors.sort(cmpNoCase);
112
128
  translators.sort(cmpNoCase);
113
129
 
114
 
  E("developers").textContent = contributors.join(", ");
 
130
  E("title").value = name;
 
131
  E("version").value = version;
 
132
  E("homepage").value = homepage;
 
133
  E("authors").textContent = authors.join(", ");
 
134
  E("contributors").textContent = contributors.join(", ");
115
135
  E("translators").textContent = translators.join(", ");
116
136
 
117
137
  let request = new XMLHttpRequest();
148
168
 
149
169
  list.sort(cmpNoCase)
150
170
  E("subscriptionAuthors").textContent = list.join(", ");
 
171
 
 
172
  E("mainBox").setAttribute("loaded", "true");
151
173
}