aboutDialog.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This Source Code Form is subject to the terms of the Mozilla Public
  2. // License, v. 2.0. If a copy of the MPL was not distributed with this
  3. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. // Services = object with smart getters for common XPCOM services
  5. Components.utils.import("resource://gre/modules/Services.jsm");
  6. function init(aEvent)
  7. {
  8. if (aEvent.target != document) {
  9. return;
  10. }
  11. try {
  12. var distroId = Services.prefs.getCharPref("distribution.id");
  13. if (distroId) {
  14. var distroVersion = Services.prefs.getCharPref("distribution.version");
  15. var distroIdField = document.getElementById("distributionId");
  16. distroIdField.value = distroId + " - " + distroVersion;
  17. distroIdField.style.display = "block";
  18. try {
  19. // This is in its own try catch due to bug 895473 and bug 900925.
  20. var distroAbout = Services.prefs.getComplexValue("distribution.about",
  21. Components.interfaces.nsISupportsString);
  22. var distroField = document.getElementById("distribution");
  23. distroField.value = distroAbout;
  24. distroField.style.display = "block";
  25. } catch (ex) {
  26. // Pref is unset
  27. Components.utils.reportError(ex);
  28. }
  29. }
  30. } catch(e) {
  31. // Pref is unset
  32. }
  33. // Include the build ID if this is an "a#" or "b#" build
  34. let version = Services.appinfo.version;
  35. if (/[ab]\d+$/.test(version)) {
  36. let buildID = Services.appinfo.appBuildID;
  37. let buildDate = buildID.slice(0,4) + "-" + buildID.slice(4,6) + "-" + buildID.slice(6,8);
  38. document.getElementById("aboutVersion").textContent += " (" + buildDate + ")";
  39. }
  40. // get release notes URL from prefs
  41. var formatter = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"]
  42. .getService(Components.interfaces.nsIURLFormatter);
  43. var releaseNotesURL = formatter.formatURLPref("app.releaseNotesURL");
  44. if (releaseNotesURL != "about:blank") {
  45. var relnotes = document.getElementById("releaseNotesURL");
  46. relnotes.setAttribute("href", releaseNotesURL);
  47. }
  48. }