Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-17-2010, 02:25 PM   PM User | #1
spuntotheratboy
New to the CF scene

 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
spuntotheratboy is an unknown quantity at this point
building a js api, having browser problems

Hello,

I'm trying to build a simple API - it's running fine in Safari and Firefox but failing in IE and Opera. In order to isolate the problem I've stripped it right back 'til all the methods are just alerting their own name. Safari and Firefox give me loads of alerts, but in Opera and IE I just get one, LMSInitialize() when the page first loads - at least I know the browser is finding the API properly.

IE also runs LMSCommit() and LMSFinish() when you close the browser window; that's good, but not enough. Opera doesn't even do that. The trigger for all this is a Flash movie created in Adobe Captivate, and published with a whole lot of its own JS which I can't touch - it's running in an iframe, and it's the parent window which includes the API. I need to work out whether there's an issue in my code, or if it's to do with the movie or the publication settings - that side of things is out of my control.

Here's the full code of my test version of the API. I'd really appreciate any comments!

Thanks,
Ben

Code:
function SIScormAPI(){
	this.version = '1.2';

	this.LMSInitialize = LMSInitialize;
	this.LMSFinish = LMSFinish;
	this.LMSGetValue = LMSGetValue;
	this.LMSSetValue = LMSSetValue;
	this.LMSCommit = LMSCommit;
	this.LMSGetLastError = LMSGetLastError;
	this.LMSGetErrorString = LMSGetErrorString;
	this.LMSGetDiagnostic = LMSGetDiagnostic;
}

function LMSInitialize(){

	var alertStr1 = 'LMSInitialize() - v.'+this.version;
	alert(alertStr1);
}

function LMSFinish(){

	var alertStr2 = 'LMSFinish()';
	alert(alertStr2);
}

function LMSGetValue(){

	var alertStr3 = 'LMSGetValue()';
	alert(alertStr3);
}

function LMSSetValue(){

	var alertStr4 = 'LMSSetValue()';
	alert(alertStr4);
}

function LMSCommit(){

	var alertStr5 = 'LMSCommit()!!!!!';
	alert(alertStr5);
}

function LMSGetLastError(){

	var alertStr6 = 'LMSGetLastError()';
	alert(alertStr6);
}

function LMSGetErrorString(){

	var alertStr7 = 'LMSGetErrorString()';
	alert(alertStr7);
}

function LMSGetDiagnostic(){

	var alertStr8 = 'LMSGetDiagnostic()';
	alert(alertStr8);
}

API = new SIScormAPI();
spuntotheratboy is offline   Reply With Quote
Old 08-18-2010, 02:00 PM   PM User | #2
spuntotheratboy
New to the CF scene

 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
spuntotheratboy is an unknown quantity at this point
I've been working on this, of course, and substantially re-written the code after testing it in an on-line validator. Now it's started working in IE8 but stopped in Firefox, still working in Safari, failing in Chrome on a Mac but partly working (i.e. I'm seeing some alerts but not others) in Chrome in Windows... so that proves the error is in my code, somewhere, although it passes a fairly strict on-line validator. The 'increment' variable is just my own versioning so I can make sure that I'm not seeing results from a cached version of the API. Here's the new code in full:

Code:
var mySIScormAlertStr = '';
function LMSInitialize() {
	mySIScormAlertStr = 'LMSInitialize() - ' + this.increment;
	alert(mySIScormAlertStr);
	return true;
}
function LMSFinish() {
	mySIScormAlertStr = 'LMSFinish() - ' + this.increment;
	alert(mySIScormAlertStr);
	return true;
}
function LMSGetValue(varName) {
	mySIScormAlertStr = 'LMSGetValue() - ' + this.increment + '\nvarName\t' + varName;
	alert(mySIScormAlertStr);
	return true;
}
function LMSSetValue(varName, varValue) {
	mySIScormAlertStr = 'LMSSetValue() - ' + this.increment + '\nvarName\t' + varName + '\nvarValue\t' + varValue;
	alert(mySIScormAlertStr);
	return true;
}
function LMSCommit() {
	mySIScormAlertStr = 'LMSCommit() - ' + this.increment;
	alert(mySIScormAlertStr);
	return true;
}
function LMSGetLastError() {
	mySIScormAlertStr = 'LMSGetLastError() - ' + this.increment;
	alert(mySIScormAlertStr);
	return true;
}
function LMSGetErrorString() {
	mySIScormAlertStr = 'LMSGetErrorString() - ' + this.increment;
	alert(mySIScormAlertStr);
	return true;
}
function LMSGetDiagnostic() {
	mySIScormAlertStr = 'LMSGetDiagnostic() - ' + this.increment;
	alert(mySIScormAlertStr);
	return true;
}
function SIScormAPI() {
	this.version = '1.2';
	this.increment = '23';
	this.error = '0';
	this.initialized = false;
	this.keepValues = {};

	this.LMSInitialize = LMSInitialize;
	this.LMSFinish = LMSFinish;
	this.LMSGetValue = LMSGetValue;
	this.LMSSetValue = LMSSetValue;
	this.LMSCommit = LMSCommit;
	this.LMSGetLastError = LMSGetLastError;
	this.LMSGetErrorString = LMSGetErrorString;
	this.LMSGetDiagnostic = LMSGetDiagnostic;
}
var API = new SIScormAPI();
Thanks to everybody who's reading this - I'd be really grateful for any kind of hint as to why it's working on some browsers and not others!

Cheers,
Ben
spuntotheratboy is offline   Reply With Quote
Reply

Bookmarks

Tags
api, class, scorm

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:41 PM.


Advertisement
Log in to turn off these ads.