Adding ability to deregister event listeners

This commit is contained in:
Jonathan Putney
2020-12-14 12:17:43 -05:00
parent cae17ee511
commit 28fe544ef5
8 changed files with 309 additions and 19 deletions

View File

@@ -177,6 +177,16 @@ window.API.on("LMSSetValue.cmi.*", function(CMIElement, value) {
});
```
You also have to ability to remove specific callback listeners:
```javascript
window.API.off("LMSInitialize", callback);
```
Or, you can clear all callbacks for a particular event:
```javascript
window.API.clear("LMSInitialize");
```
### SCORM 2004 Listeners
For convenience, hooks are available for all the SCORM API Signature functions:
@@ -220,6 +230,16 @@ window.API_1484_11.on("SetValue.cmi.* ", function(CMIElement, value) {
});
```
You also have to ability to remove specific callback listeners:
```javascript
window.API_1484_11.off("Initialize", callback);
```
Or, you can clear all callbacks for a particular event:
```javascript
window.API_1484_11.clear("Initialize");
```
### Total Time Calculation
The APIs provide a convenience method `getCurrentTotalTime()` that can be used for calculating the current `total_time` value, based on the current `session_time` and the `total_time` supplied when the module was launched. This works for both ISO 8601 duration time formats in SCORM 2004 as well as the HH:MM:SS format in SCORM 1.2 and AICC, and outputs the correct format based on the version used.