pipwerks / scorm-api-wrapper

The pipwerks SCORM API Wrapper
http://pipwerks.com
362 stars 125 forks source link

pipwerks.SCORM.API.find doesnt search the window object for the API #13

Closed LukaszGrela closed 9 years ago

LukaszGrela commented 9 years ago

Why the find method ignores the window object and searches in window.parent or window.top.opener?

moloko commented 9 years ago

@LukaszGrela this is actually fixed in PR #12, just need it to be merged in

moloko commented 9 years ago

but to answer your question, 99.99% of the time, the API object is located in the containing frameset, the window.opener or the window.opener's frameset.

I've only ever seen one instance where the SCORM API was in the course window itself.

LukaszGrela commented 9 years ago

That's my case, injecting the API into the same window as course is

moloko commented 9 years ago

Amazing, in 12 years of working with SCORM I'd never seen an instance of the API being in the course window. Then it happens twice in the same month.

LukaszGrela commented 9 years ago

I'll tell you that this is for offline mobile player:) and only to work with the Adapt courses as other courses:) were working fine in the iframe:)

danielghost commented 9 years ago

I think the code probably omits the course window currently as it seems to follow the SCORM 2004 guidelines where some rules where put in place about where the API could reside, starting from the window.parent. Obviously as this wrapper is supposed to be 1.2 or 2004 it needs this little tweak to cover all bases.

pipwerks commented 9 years ago

The docs -- written in the last 90s and early 2000s -- were clearly aimed at framesets and pop-up windows. Personally, I've never seen an instance where the API was in the window itself. However, in this age of ajax-driven pages (built with React or other JS-based template systems), it is certainly possible for the API to be in the same window. The proposed merge makes sense and should have no impact on systems that rely on framesets. Thanks for the contribution.