Identifying call of copy of ((){ })();

A

Andrew Poulos

I have this (the name is fixed by the LMS):

var API_1484_11 = (function() {
// private variables

// private methods

// public methods
return {
get : function() {
if (called via API) {

} else {

}
}
};
})();

and because an older LMS expect a different name I have this

var API = API_1484_11;


The code is effectively identical for both but API has a few subtle
differences that I need to take into account.

Is there a someway to tell if the public methods are called via API or
API_1484_11?

Andrew Poulos
 
R

Richard Cornford

Andrew said:
I have this (the name is fixed by the LMS):

The London, Midland and Scottish railway company ceased trading in the
middle of the last century. It is unlikely that they could have dictated
anything relating to browser scripting.

The FAQ advises that acronyms (and particularly TLAs) should not be
posted without explanation unless they are truly unambiguous (and very
few are).
var API_1484_11 = (function() {
// private variables

// private methods

// public methods
return {
get : function() {
if (called via API) {

} else {

}
}
};
})();

and because an older LMS expect a different name I have this

var API = API_1484_11;


The code is effectively identical for both but API has a few subtle
differences that I need to take into account.

Is there a someway to tell if the public methods are called
via API or API_1484_11?

Not at all easily if they are the same object, and certainly not
reliably, efficiently or in a cross-browser manner. The only information
on the subject would be the source code that made the call, and although
in most cases (but certainly not all) - arguments.calleee.toString -
might expose that source code the work needed to extract the information
would be a huge (and pointless) overhead.

It would probably be simpler to wrap the fist object in a second that
implemented an identical public interface and then you could know which
was called based on the identity of the functions that made up the two
interfaces.

If the "code is effectively identical" there is no sense in asking this
question, or implementing any answer you may find.

Richard.
 
J

Jorge

Is there a someway to tell if the public methods are called via API or
API_1484_11?

Nope.
API === API_1484_11 : both point to the very same object and therefore
a call to API.get() is identical to a call to API_1484_11.get().
AFAIK there's no way to tell the name of the "object pointer" used in
the call.
For that I think you're going to need to wrap it with/into two
additional (wrapper) objects.

--Jorge.
 
R

RobG

I have this (the name is fixed by the LMS):

var API_1484_11 = (function() {
   // private variables

   // private methods

   // public methods
   return {
     get : function() {
       if (called via API) {

       } else {

       }
     }
   };

})();

and because an older LMS expect a different name I have this

var API = API_1484_11;

The code is effectively identical for both but API has a few subtle
differences that I need to take into account.

Is there a someway to tell if the public methods are called via API or
API_1484_11?

I would keep API as a deprecated interface in your library and
transition to API_1484_11, otherwise you are creating a maintenance
headache.

Your transition plan might be, over a convenient time frame, replace
all calls to API with calls to API_1484_11 as a maintenance
opportunity task (along with testing, etc.). When you've replaced all
calls to API with API_1484_11, get rid of API.
 
A

Andrew Poulos

Richard said:
The London, Midland and Scottish railway company ceased trading in the
middle of the last century. It is unlikely that they could have dictated
anything relating to browser scripting.

The FAQ advises that acronyms (and particularly TLAs) should not be
posted without explanation unless they are truly unambiguous (and very
few are).

Sorry, LMS = Learning Management System
<url: http://en.wikipedia.org/wiki/Learning_management_system >
Specifically I'm referring to Sharable Content Object Reference Model
(SCORM) compliant systems.
Not at all easily if they are the same object, and certainly not
reliably, efficiently or in a cross-browser manner. The only information
on the subject would be the source code that made the call, and although
in most cases (but certainly not all) - arguments.callee.toString -
might expose that source code the work needed to extract the information
would be a huge (and pointless) overhead.

It would probably be simpler to wrap the fist object in a second that
implemented an identical public interface and then you could know which
was called based on the identity of the functions that made up the two
interfaces.

I'll look into re-wrapping it.
If the "code is effectively identical" there is no sense in asking this
question, or implementing any answer you may find.

Yes you're right, I should have said "almost identical". Before data is
passed to the LMS it needs to be tested against requirements as laid out
in the relevant SCORM specification. The differences between the two
current "standards" are few and small, yet important.

Andrew Poulos
 
L

Laser Lips

Sorry, LMS = Learning Management System
<url:http://en.wikipedia.org/wiki/Learning_management_system>
Specifically I'm referring to Sharable Content Object Reference Model
(SCORM) compliant systems.






I'll look into re-wrapping it.


Yes you're right, I should have said "almost identical". Before data is
passed to the LMS it needs to be tested against requirements as laid out
in the relevant SCORM specification. The differences between the two
current "standards" are few and small, yet important.

Andrew Poulos


I built a fully compliant SCORM 1.2.6 LMS and API backend and front
end using a Java server, Java application for back end and Java
applets along with the javaScript API in 2004 . I called it
'Elements'. It never saw the light of day since it was a University
project but it did pass the SCORM test suit with flying colours and
was used by my Placement employer to test his E-Learning software.

Took me 2 years to build. Sorry just gets me going when someone talks
about SCORM and LMS's

Graham

Oh well, got a good grade from Uni for it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top