-
Notifications
You must be signed in to change notification settings - Fork 0
/
offline_API_wrapper.js
1 lines (1 loc) · 4.4 KB
/
offline_API_wrapper.js
1
function createResetButton(t){$("body").append($('<style id="spoor-clear-button">.spoor-clear-button { position:fixed; right:0px; bottom:0px; } </style>'));var e=$('<button class="spoor-clear-button">Reset</button>');$("body").append(e),e.on("click",function(){t&&t.LMSClear(),alert("Status Reset"),window.location.reload()})}function storageWarning(){var t,e=alert;this.__storageWarningTimeoutId=null,require&&(t=require("coreJS/adapt")),t&&t.config&&t.config.has("_spoor")&&t.config.get("_spoor")._advancedSettings&&!0===t.config.get("_spoor")._advancedSettings._suppressErrors&&(e=console.error),e("Warning: possible cookie storage limit exceeded - tracking may malfunction")}var API={__offlineAPIWrapper:!0,LMSInitialize:function(){return API.LMSFetch()||(this.data["cmi.core.lesson_status"]="not attempted",this.data["cmi.suspend_data"]="",this.data["cmi.core.student_name"]="Surname, Sam",this.data["cmi.core.student_id"]="[email protected]",API.LMSStore(!0)),"true"},LMSFinish:function(){return"true"},LMSGetValue:function(t){return this.data[t]},LMSSetValue:function(t,e){return-1!=t.indexOf("cmi.interactions.")||(this.data[t]=e,API.LMSStore()),"true"},LMSCommit:function(){return"true"},LMSGetLastError:function(){return 0},LMSGetErrorString:function(){return"Fake error string."},LMSGetDiagnostic:function(){return"Fake diagnostic information."},LMSStore:function(t){var e;!1!==window.ISCOOKIELMS&&(!t&&void 0===API.cookie("_spoor")||(e=JSON.stringify(this.data),API.cookie("_spoor",e),API.cookie("_spoor").length!=e.length&&null==this.__storageWarningTimeoutId&&(this.__storageWarningTimeoutId=setTimeout(function(){storageWarning.apply(API)},1e3))))},LMSFetch:function(){if(!1!==window.ISCOOKIELMS)return this.data=API.cookie("_spoor"),void 0===this.data?!(this.data={}):(this.data=JSON.parse(this.data),!0);this.data={}},LMSClear:function(){API.removeCookie("_spoor")}},API_1484_11={__offlineAPIWrapper:!0,Initialize:function(){return API_1484_11.LMSFetch()||(this.data["cmi.completion_status"]="not attempted",this.data["cmi.suspend_data"]="",this.data["cmi.learner_name"]="Surname, Sam",this.data["cmi.learner_id"]="[email protected]",API_1484_11.LMSStore(!0)),"true"},Terminate:function(){return"true"},GetValue:function(t){return this.data[t]},SetValue:function(t,e){return-1!=t.indexOf("cmi.interactions.")||(this.data[t]=e,API_1484_11.LMSStore()),"true"},Commit:function(){return"true"},GetLastError:function(){return 0},GetErrorString:function(){return"Fake error string."},GetDiagnostic:function(){return"Fake diagnostic information."},LMSStore:function(t){var e;!1!==window.ISCOOKIELMS&&(!t&&void 0===API_1484_11.cookie("_spoor")||(e=JSON.stringify(this.data),API_1484_11.cookie("_spoor",e),API_1484_11.cookie("_spoor").length!=e.length&&null==this.__storageWarningTimeoutId&&(this.__storageWarningTimeoutId=setTimeout(function(){storageWarning.apply(API_1484_11)},1e3))))},LMSFetch:function(){if(!1!==window.ISCOOKIELMS)return this.data=API_1484_11.cookie("_spoor"),void 0===this.data?!(this.data={}):(this.data=JSON.parse(this.data),!0);this.data={}},LMSClear:function(){API_1484_11.removeCookie("_spoor")}};!function(){for(var _,t=0,e=arguments.length;t<e;t++){(_=arguments[t]).extend=function(){var t,e,o,n=arguments[0]||{},i=1,r=arguments.length;for("object"!=typeof n&&"function"!=typeof n&&(n={}),i===r&&(n=this,i--);i<r;i++)if(null!=(o=arguments[i]))for(e in o)n[e],n!==(t=o[e])&&void 0!==t&&(n[e]=t);return n};var n=/\+/g;function l(t,e){var o=g.raw?t:function(t){0===t.indexOf('"')&&(t=t.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return t=decodeURIComponent(t.replace(n," ")),g.json?JSON.parse(t):t}catch(t){}}(t);return"function"==typeof e?e(o):o}var g=_.cookie=function(t,e,o){var n,i,r;if(1<arguments.length&&"function"!=typeof e)return"number"==typeof(o=_.extend({},g.defaults,o)).expires&&(n=o.expires,(i=o.expires=new Date).setTime(+i+864e5*n)),document.cookie=[t,"=",(r=e,(g.json?JSON.stringify(r):String(r)).replace(/,/g,"%2C")),o.expires?"; expires="+o.expires.toUTCString():"",o.path?"; path="+o.path:"",o.domain?"; domain="+o.domain:"",o.secure?"; secure":""].join("");for(var a=t?void 0:{},s=document.cookie?document.cookie.split("; "):[],u=0,c=s.length;u<c;u++){var d=s[u].split("="),f=d.shift(),p=d.join("=");if(t&&t===f){a=l(p,e);break}t||void 0===(p=l(p))||(a[f]=p)}return a};g.defaults={},_.removeCookie=function(t,e){return void 0!==_.cookie(t)&&(_.cookie(t,"",_.extend({},e,{expires:-1})),!_.cookie(t))}}}(API,API_1484_11);