Javascript Namespacing

classic Classic list List threaded Threaded
5 messages Options
Steven Githens Steven Githens
Reply | Threaded
Open this post in threaded view
|

Javascript Namespacing

Hello OpenMRS Dev,

Do we have a convention for namespacing any new javascript being written
in OpenMRS? Most of the functions I've seen so far are in the global
namespace.

While working on a portlet for my reporting ticket last week I started
using openmrs.reporting [1] for the time being.

Cheers,
Steve


[1] Just using the idiom:
var openmrs = openmrs || {};
openmrs.reporting = openmrs.reporting || {};

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [hidden email] with "SIGNOFF openmrs-devel-l" in the  body (not the subject) of your e-mail.

[mailto:[hidden email]?body=SIGNOFF%20openmrs-devel-l]
Ben Wolfe (openmrs) Ben Wolfe (openmrs)
Reply | Threaded
Open this post in threaded view
|

Re: Javascript Namespacing

We haven't done it in core, but it would be a good habit to get into for modules to prevent overwriting core or other modules.

Ben

On Mon, Apr 16, 2012 at 5:51 AM, Steven Githens <[hidden email]> wrote:
Hello OpenMRS Dev,

Do we have a convention for namespacing any new javascript being written in OpenMRS? Most of the functions I've seen so far are in the global namespace.

While working on a portlet for my reporting ticket last week I started using openmrs.reporting [1] for the time being.

Cheers,
Steve


[1] Just using the idiom:
var openmrs = openmrs || {};
openmrs.reporting = openmrs.reporting || {};

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [hidden email] with "SIGNOFF openmrs-devel-l" in the  body (not the subject) of your e-mail.

[mailto:[hidden email]?body=SIGNOFF%20openmrs-devel-l]


[hidden email] from OpenMRS Developers' mailing list
Mark Goodrich-2 Mark Goodrich-2
Reply | Threaded
Open this post in threaded view
|

FW: [OPENMRS-DEV] Javascript Namespacing

In reply to this post by Steven Githens
Steve--

We don't really have any javascript conventions, as far as I know.  

The convention of using an "openmrs" namespace (and using "openmrs.your_module" for module namespaces) seems good to me.

Mark

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Steven Githens
Sent: Monday, April 16, 2012 5:51 AM
To: [hidden email]
Subject: [OPENMRS-DEV] Javascript Namespacing

Hello OpenMRS Dev,

Do we have a convention for namespacing any new javascript being written in OpenMRS? Most of the functions I've seen so far are in the global namespace.

While working on a portlet for my reporting ticket last week I started using openmrs.reporting [1] for the time being.

Cheers,
Steve


[1] Just using the idiom:
var openmrs = openmrs || {};
openmrs.reporting = openmrs.reporting || {};

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [hidden email] with "SIGNOFF openmrs-devel-l" in the  body (not the subject) of your e-mail.

[mailto:[hidden email]?body=SIGNOFF%20openmrs-devel-l]

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [hidden email] with "SIGNOFF openmrs-devel-l" in the  body (not the subject) of your e-mail.

[mailto:[hidden email]?body=SIGNOFF%20openmrs-devel-l]
Darius Jazayeri-3 Darius Jazayeri-3
Reply | Threaded
Open this post in threaded view
|

Re: FW: [OPENMRS-DEV] Javascript Namespacing

Steve,

We don't have such a convention. I strongly approve of this one. Can you add this to a relevant wiki page, or start a Javascript Conventions page?

-Darius

On Mon, Apr 16, 2012 at 9:34 AM, Mark Goodrich <[hidden email]> wrote:
Steve--

We don't really have any javascript conventions, as far as I know.

The convention of using an "openmrs" namespace (and using "openmrs.your_module" for module namespaces) seems good to me.

Mark

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Steven Githens
Sent: Monday, April 16, 2012 5:51 AM
To: [hidden email]
Subject: [OPENMRS-DEV] Javascript Namespacing

Hello OpenMRS Dev,

Do we have a convention for namespacing any new javascript being written in OpenMRS? Most of the functions I've seen so far are in the global namespace.

While working on a portlet for my reporting ticket last week I started using openmrs.reporting [1] for the time being.

Cheers,
Steve


[1] Just using the idiom:
var openmrs = openmrs || {};
openmrs.reporting = openmrs.reporting || {};

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [hidden email] with "SIGNOFF openmrs-devel-l" in the  body (not the subject) of your e-mail.

[mailto:[hidden email]?body=SIGNOFF%20openmrs-devel-l]

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [hidden email] with "SIGNOFF openmrs-devel-l" in the  body (not the subject) of your e-mail.

[mailto:[hidden email]?body=SIGNOFF%20openmrs-devel-l]


[hidden email] from OpenMRS Developers' mailing list
Steven Githens Steven Githens
Reply | Threaded
Open this post in threaded view
|

Re: FW: [OPENMRS-DEV] Javascript Namespacing

I didn't see an existing 'general' javascript page so I started one in the Developer->Conventions area.

https://wiki.openmrs.org/display/docs/Javascript+Conventions

-Steve

On 04/16/2012 12:56 PM, Darius Jazayeri wrote:
Steve,

We don't have such a convention. I strongly approve of this one. Can you add this to a relevant wiki page, or start a Javascript Conventions page?

-Darius

On Mon, Apr 16, 2012 at 9:34 AM, Mark Goodrich <[hidden email]> wrote:
Steve--

We don't really have any javascript conventions, as far as I know.

The convention of using an "openmrs" namespace (and using "openmrs.your_module" for module namespaces) seems good to me.

Mark

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Steven Githens
Sent: Monday, April 16, 2012 5:51 AM
To: [hidden email]
Subject: [OPENMRS-DEV] Javascript Namespacing

Hello OpenMRS Dev,

Do we have a convention for namespacing any new javascript being written in OpenMRS? Most of the functions I've seen so far are in the global namespace.

While working on a portlet for my reporting ticket last week I started using openmrs.reporting [1] for the time being.

Cheers,
Steve


[1] Just using the idiom:
var openmrs = openmrs || {};
openmrs.reporting = openmrs.reporting || {};

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [hidden email] with "SIGNOFF openmrs-devel-l" in the  body (not the subject) of your e-mail.

[mailto:[hidden email]?body=SIGNOFF%20openmrs-devel-l]

_________________________________________

To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [hidden email] with "SIGNOFF openmrs-devel-l" in the  body (not the subject) of your e-mail.

[mailto:[hidden email]?body=SIGNOFF%20openmrs-devel-l]


[hidden email] from OpenMRS Developers' mailing list


[hidden email] from OpenMRS Developers' mailing list