remyaaron / hcalendar

Automatically exported from code.google.com/p/hcalendar
0 stars 0 forks source link

to wrap your "loose" variables #90

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In order to prevent conflicts with other add-ons that may be installed by 
users, you need to wrap your "loose" variables and functions within a 
JavaScript object. You can see examples on how to do this at 
https://developer.mozilla.org/en/XUL_School/JavaScript_Object_Management.

Original issue reported on code.google.com by igor.zc on 25 Apr 2012 at 9:15

GoogleCodeExporter commented 8 years ago
sample https://developer.mozilla.org/@api/deki/files/5143/=HelloWorld3.zip
sample (browserOverlay.js):
---
Components.utils.import("resource://xulschoolhello/common.js");
Components.utils.import("resource://xulschoolhello/messageCount.js");

/**
 * XULSchoolChrome namespace.
 */
if ("undefined" == typeof(XULSchoolChrome)) {
  var XULSchoolChrome = {};
};

/**
 * Controls the browser overlay for the Hello World extension.
 */
XULSchoolChrome.BrowserOverlay = {
  /**
   * Says 'Hello' to the user.
   */
  sayHello : function(aEvent) {
    let stringBundle = document.getElementById("xulschoolhello-string-bundle");
    let messageCount;
    let message;

    XULSchool.MessageCount.increment();
    messageCount = XULSchool.MessageCount.count;
    message =
      stringBundle.getFormattedString(
        "xulschoolhello.greeting.label", [ messageCount ]);

    window.alert(message);
  }
};

Original comment by igor.zc on 25 Apr 2012 at 10:11