Created
October 13, 2017 14:13
-
-
Save cajones/7043b1be0d10b7300fa1366773b89672 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getCustomStates: function() { | |
var isSuspendDataStoreEmpty = _.isEmpty(suspendDataStore); | |
if (!isSuspendDataStoreEmpty && suspendDataRestored) return _.clone(suspendDataStore); | |
var dataAsString = scorm.getSuspendData(); | |
if (dataAsString === "" || dataAsString === " " || dataAsString === undefined) return {}; | |
var dataAsJSON = this.tryParseJsonWithDefault(dataAsString, {}); | |
if (!isSuspendDataStoreEmpty && !suspendDataRestored) dataAsJSON = _.extend(dataAsJSON, suspendDataStore); | |
return dataAsJSON; | |
}, | |
tryParseJsonWithDefault: function (text, defaultValue) { | |
try { | |
return JSON.parse(text); | |
} | |
catch (ex) { | |
return defaultValue; | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment