From 906f5e715ab25dccaa494c1f0e2981accf761064 Mon Sep 17 00:00:00 2001 From: "Brian J. Miller" Date: Fri, 28 Mar 2014 17:48:56 -0500 Subject: [PATCH 1/3] Switch to Grunt for building * Update npm dependencies to install grunt deps * Remove gear based build script * Improved JSHint restrictions and corrected code to match * Update Travis CI config file for new build * Bump to 0.30.0 --- .npmignore | 3 +- .travis.yml | 3 + Gruntfile.js | 113 ++++++++++++++++++++++ bower.json | 2 +- build.js | 182 ------------------------------------ build/.empty | 0 package.json | 9 +- src/Activity.js | 2 +- src/ActivityProfile.js | 6 +- src/Agent.js | 2 +- src/AgentAccount.js | 8 +- src/AgentProfile.js | 6 +- src/Context.js | 5 +- src/ContextActivities.js | 7 +- src/Environment/Browser.js | 4 +- src/Environment/Node.js | 3 +- src/InteractionComponent.js | 2 +- src/LRS.js | 6 +- src/Result.js | 5 +- src/Score.js | 5 +- src/State.js | 6 +- src/Statement.js | 18 ++-- src/StatementRef.js | 6 +- src/StatementsResult.js | 2 +- src/SubStatement.js | 16 +--- src/TinCan.js | 14 ++- src/Utils.js | 28 +++--- yuidoc.json | 2 +- 28 files changed, 187 insertions(+), 278 deletions(-) create mode 100644 Gruntfile.js delete mode 100755 build.js delete mode 100644 build/.empty diff --git a/.npmignore b/.npmignore index 9638ab5..4af7152 100644 --- a/.npmignore +++ b/.npmignore @@ -3,8 +3,7 @@ src test doc vendor -build.js -build/.empty +build/tincan-min.map .travis.yml yuidoc.json bower.json diff --git a/.travis.yml b/.travis.yml index 6e5919d..455116f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,6 @@ language: node_js node_js: - "0.10" +before_install: npm install -g grunt-cli +install: npm install +before_script: grunt build diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..c6cf8c9 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,113 @@ +/*global module:false*/ +module.exports = function(grunt) { + "use strict"; + var coreFileList = [ + "vendor/cryptojs-v3.0.2/rollups/sha1.js", + "vendor/cryptojs-v3.0.2/components/enc-base64.js", + "src/TinCan.js", + "src/Utils.js", + "src/LRS.js", + "src/AgentAccount.js", + "src/Agent.js", + "src/Group.js", + "src/Verb.js", + "src/Result.js", + "src/Score.js", + "src/InteractionComponent.js", + "src/ActivityDefinition.js", + "src/Activity.js", + "src/ContextActivities.js", + "src/Context.js", + "src/StatementRef.js", + "src/SubStatement.js", + "src/Statement.js", + "src/StatementsResult.js", + "src/State.js", + "src/ActivityProfile.js", + "src/AgentProfile.js" + ], + browserFileList = coreFileList.slice(), + nodeFileList = coreFileList.slice(); + + browserFileList.push( + "src/Environment/Browser.js" + ); + nodeFileList.push( + "src/Environment/Node.js" + ); + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON("package.json"), + + watch: { + files: ["src/**/*.js"], + tasks: ["build"], + options: { + interrupt: true + } + }, + + jshint: { + all: ["Gruntfile.js", "src/**/*.js"], + options: { + bitwise: true, + es3: true, // must use ES3 syntax (support for IE6/7/8/9) + curly: true, // Always use curlys {} + eqeqeq: true, // No more == for you, === only + forin: true, + freeze: true, + immed: true, // prohibits the use of immediate function invocations without wrapping them in parentheses + indent: 4, // force tab width of 4 spaces + latedef: true, // no setting variables before they are defined + newcap: true, // Always call constructors with a Cap + noarg: true, // prohibits arguments.caller and arguments.callee + noempty: true, // prevent empty blocks + nonbsp: true, + nonew: true, // don't allow non-captured constructor use + plusplus: true, // prevent use of ++ and -- + quotmark: "double", // require strings to be double quoted + undef: true, // prohibits the use of explicitly undeclared variables + unused: true, // Warns on unused variables + trailing: true, // Prohibits trailing whitespace + maxdepth: 6, // Max nesting of methods 6 layers deep + onevar: true, + strict: true, + globals: { + TinCan: true + } + } + }, + + concat: { + dist: { + files: { + "build/tincan.js": browserFileList, + "build/tincan-node.js": nodeFileList + }, + nonull: true + } + }, + + uglify: { + dist: { + files: { + "build/tincan-min.js": ["build/tincan.js"] + }, + options: { + sourceMap: true + } + } + } + }); + + // Load Tasks + grunt.loadNpmTasks("grunt-contrib-watch"); + grunt.loadNpmTasks("grunt-contrib-concat"); + grunt.loadNpmTasks("grunt-contrib-jshint"); + grunt.loadNpmTasks("grunt-contrib-uglify"); + + // Define tasks + grunt.registerTask("build", ["jshint", "concat", "uglify"]); + grunt.registerTask("default", "build"); +}; diff --git a/bower.json b/bower.json index 3707237..46ad62a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tincan", - "version": "0.22.2", + "version": "0.30.0", "homepage": "http://rusticisoftware.github.com/TinCanJS/", "authors": [ "Brian J. Miller " diff --git a/build.js b/build.js deleted file mode 100755 index a54eb4f..0000000 --- a/build.js +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/env node - -var gear = require('gear'), - gearRegistry = new gear.Registry( - { - module: 'gear-lib' - } - ), - coreFileList = [ - 'src/TinCan.js' - ,'src/Utils.js' - ,'src/LRS.js' - ,'src/AgentAccount.js' - ,'src/Agent.js' - ,'src/Group.js' - ,'src/Verb.js' - ,'src/Result.js' - ,'src/Score.js' - ,'src/InteractionComponent.js' - ,'src/ActivityDefinition.js' - ,'src/Activity.js' - ,'src/ContextActivities.js' - ,'src/Context.js' - ,'src/StatementRef.js' - ,'src/SubStatement.js' - ,'src/Statement.js' - ,'src/StatementsResult.js' - ,'src/State.js' - ,'src/ActivityProfile.js' - ,'src/AgentProfile.js' - ], - browserFileList = coreFileList.slice(), - nodeFileList = coreFileList.slice(); - -browserFileList.push( - 'src/Environment/Browser.js' -); -nodeFileList.push( - 'src/Environment/Node.js' -); - -new gear.Queue( - { - registry: gearRegistry - } -) -.log("Reading") -.read(browserFileList) -.log("Linting") -.jslint( - { - config: { - white: true, - nomen: true, - passfail: false, - - // for predefined environments - devel: true, // to get console, alert defined - browser: true, - node: true, - es5: false, - - // predefined globals - predef: [ - "TinCan", "XDomainRequest" - ] - }, - callback: function (linted) { - var messages = linted.jslint || [], - counter = 0 - ; - if (messages.length) { - console.log(' ' + linted.name + ' contains ' + messages.length + ' lint errors'); - messages.forEach( - function (item) { - if (item && item.reason) { - counter += 1; - console.log(' #' + counter + ': ' + item.reason); - if (item.evidence) { - console.log(' ' + String(item.evidence).trim() + (' // line ' + item.line + ', pos ' + item.character)); - } - } - } - ) - } - else { - console.log(' ' + linted.name + ' lint free!'); - } - } - } -) -.read( - [ - 'vendor/cryptojs-v3.0.2/rollups/sha1.js', - 'vendor/cryptojs-v3.0.2/components/enc-base64.js' - ] -) -.log("Concating") -.concat() -.log("Writing raw") -.write('build/tincan.js') -.log("Minifying") -.jsminify( - { - callback: function (e) { - console.log('compression failed: ' + e.message); - }, - config: { - mangle: true, - squeeze: true, - semicolon: false, - lift_vars: true, - mangle_toplevel: true, - no_mangle_functions: true, - max_line_length: 6000 - } - } -) -.log("Writing min") -.write('build/tincan-min.js') -.run(); - -new gear.Queue( - { - registry: gearRegistry - } -) -.log("Reading") -.read(nodeFileList) -.log("Linting") -.jslint( - { - config: { - white: true, - nomen: true, - passfail: false, - - // for predefined environments - devel: true, // to get console, alert defined - node: true, - es5: false, - - // predefined globals - predef: [ - "TinCan" - ] - }, - callback: function (linted) { - var messages = linted.jslint || [], - counter = 0 - ; - if (messages.length) { - console.log(' ' + linted.name + ' contains ' + messages.length + ' lint errors'); - messages.forEach( - function (item) { - if (item && item.reason) { - counter += 1; - console.log(' #' + counter + ': ' + item.reason); - if (item.evidence) { - console.log(' ' + String(item.evidence).trim() + (' // line ' + item.line + ', pos ' + item.character)); - } - } - } - ) - } - else { - console.log(' ' + linted.name + ' lint free!'); - } - } - } -) -.read( - [ - 'vendor/cryptojs-v3.0.2/rollups/sha1.js', - 'vendor/cryptojs-v3.0.2/components/enc-base64.js' - ] -) -.log("Concating") -.concat() -.log("Writing raw") -.write('build/tincan-node.js') -.run(); diff --git a/build/.empty b/build/.empty deleted file mode 100644 index e69de29..0000000 diff --git a/package.json b/package.json index 65cd8b2..f84f64a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tincanjs", "description": "Tin Can API Library", - "version": "0.22.2", + "version": "0.30.0", "private": false, "main": "build/tincan-node.js", "directories": { @@ -27,8 +27,11 @@ "e-learning" ], "devDependencies": { - "gear": "0.8.x", - "gear-lib": "0.8.x", + "grunt": "0.4.4", + "grunt-contrib-jshint": "0.9.2", + "grunt-contrib-watch": "0.6.1", + "grunt-contrib-concat": "0.3.0", + "grunt-contrib-uglify": "0.4.0", "qunit": "0.5.16" } } diff --git a/src/Activity.js b/src/Activity.js index 6b4ea59..938f996 100644 --- a/src/Activity.js +++ b/src/Activity.js @@ -55,7 +55,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Activity', + LOG_SRC: "Activity", /** @method log diff --git a/src/ActivityProfile.js b/src/ActivityProfile.js index 534a5e9..381842e 100644 --- a/src/ActivityProfile.js +++ b/src/ActivityProfile.js @@ -75,7 +75,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'ActivityProfile', + LOG_SRC: "ActivityProfile", /** @method log @@ -94,9 +94,7 @@ TinCan client library "contents", "etag", "contentType" - ], - val - ; + ]; cfg = cfg || {}; diff --git a/src/Agent.js b/src/Agent.js index 5cc0da6..0496f80 100644 --- a/src/Agent.js +++ b/src/Agent.js @@ -202,7 +202,7 @@ TinCan client library } }, - toString: function (lang) { + toString: function () { this.log("toString"); if (this.name !== null) { diff --git a/src/AgentAccount.js b/src/AgentAccount.js index 654e78a..c830165 100644 --- a/src/AgentAccount.js +++ b/src/AgentAccount.js @@ -48,7 +48,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'AgentAccount', + LOG_SRC: "AgentAccount", /** @method log @@ -65,9 +65,7 @@ TinCan client library directProps = [ "name", "homePage" - ], - val - ; + ]; cfg = cfg || {}; @@ -86,7 +84,7 @@ TinCan client library } }, - toString: function (lang) { + toString: function () { this.log("toString"); var result = ""; diff --git a/src/AgentProfile.js b/src/AgentProfile.js index 93a6f94..9b05d9a 100644 --- a/src/AgentProfile.js +++ b/src/AgentProfile.js @@ -75,7 +75,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'AgentProfile', + LOG_SRC: "AgentProfile", /** @method log @@ -94,9 +94,7 @@ TinCan client library "contents", "etag", "contentType" - ], - val - ; + ]; cfg = cfg || {}; diff --git a/src/Context.js b/src/Context.js index edc5739..f005582 100644 --- a/src/Context.js +++ b/src/Context.js @@ -90,7 +90,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Context', + LOG_SRC: "Context", /** @method log @@ -178,8 +178,7 @@ TinCan client library "contextActivities", "statement" ], - i, - prop; + i; version = version || TinCan.versions()[0]; diff --git a/src/ContextActivities.js b/src/ContextActivities.js index 284098f..1223fd2 100644 --- a/src/ContextActivities.js +++ b/src/ContextActivities.js @@ -60,7 +60,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'ContextActivities', + LOG_SRC: "ContextActivities", /** @method log @@ -120,7 +120,7 @@ TinCan client library } if (! (val instanceof TinCan.Activity)) { - val = typeof val === 'string' ? { id: val } : val; + val = typeof val === "string" ? { id: val } : val; val = new TinCan.Activity (val); } @@ -142,8 +142,7 @@ TinCan client library "other" ], i, - j, - prop; + j; version = version || TinCan.versions()[0]; diff --git a/src/Environment/Browser.js b/src/Environment/Browser.js index 2aede95..210b89c 100644 --- a/src/Environment/Browser.js +++ b/src/Environment/Browser.js @@ -21,6 +21,7 @@ TinCan client library @submodule TinCan.Environment.Browser **/ (function () { + /* globals window, XMLHttpRequest, XDomainRequest */ "use strict"; var LOG_SRC = "Environment.Browser", nativeRequest, @@ -364,7 +365,8 @@ TinCan client library // capabilities // TinCan.LRS.prototype._initByEnvironment = function (cfg) { - /*jslint regexp: true */ + /*jslint regexp: true, laxbreak: true */ + /* globals location */ log("_initByEnvironment", LOG_SRC); var urlParts, schemeMatches, diff --git a/src/Environment/Node.js b/src/Environment/Node.js index bcbffba..863fe0e 100644 --- a/src/Environment/Node.js +++ b/src/Environment/Node.js @@ -21,6 +21,7 @@ TinCan client library @submodule TinCan.Environment.Node **/ (function () { + /* globals require */ "use strict"; var LOG_SRC = "Environment.Node", log = TinCan.prototype.log, @@ -89,7 +90,7 @@ TinCan client library prop ; if (Object.keys(cfg.params).length > 0) { - url += '?' + querystring.stringify(cfg.params); + url += "?" + querystring.stringify(cfg.params); } xhr = new XMLHttpRequest(); diff --git a/src/InteractionComponent.js b/src/InteractionComponent.js index 82ecf4e..d252aba 100644 --- a/src/InteractionComponent.js +++ b/src/InteractionComponent.js @@ -48,7 +48,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'InteractionComponent', + LOG_SRC: "InteractionComponent", /** @method log diff --git a/src/LRS.js b/src/LRS.js index 48f54ec..4216f81 100644 --- a/src/LRS.js +++ b/src/LRS.js @@ -731,7 +731,7 @@ TinCan client library //or endpoint (though only the former is allowed in the spec) serverRoot = TinCan.Utils.getServerRoot(this.endpoint); if (parsedURL.path.indexOf("/statements") === 0){ - parsedURL.path = this.endpoint.replace(serverRoot, '') + parsedURL.path; + parsedURL.path = this.endpoint.replace(serverRoot, "") + parsedURL.path; this.log("converting non-standard more URL to " + parsedURL.path); } @@ -926,9 +926,7 @@ TinCan client library saveState: function (key, val, cfg) { this.log("saveState"); var requestParams, - requestCfg, - requestResult - ; + requestCfg; if (typeof cfg.contentType === "undefined") { cfg.contentType = "application/octet-stream"; diff --git a/src/Result.js b/src/Result.js index 4bbc5ef..81a9c6a 100644 --- a/src/Result.js +++ b/src/Result.js @@ -72,7 +72,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Result', + LOG_SRC: "Result", /** @method log @@ -135,8 +135,7 @@ TinCan client library optionalObjProps = [ "score" ], - i, - prop; + i; version = version || TinCan.versions()[0]; diff --git a/src/Score.js b/src/Score.js index 4141edb..0d1ac1d 100644 --- a/src/Score.js +++ b/src/Score.js @@ -60,7 +60,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Score', + LOG_SRC: "Score", /** @method log @@ -105,8 +105,7 @@ TinCan client library "min", "max" ], - i, - prop; + i; version = version || TinCan.versions()[0]; diff --git a/src/State.js b/src/State.js index e602448..473bd08 100644 --- a/src/State.js +++ b/src/State.js @@ -66,7 +66,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'State', + LOG_SRC: "State", /** @method log @@ -85,9 +85,7 @@ TinCan client library "contents", "etag", "contentType" - ], - val - ; + ]; cfg = cfg || {}; diff --git a/src/Statement.js b/src/Statement.js index c3aa53a..90cd093 100644 --- a/src/Statement.js +++ b/src/Statement.js @@ -157,7 +157,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Statement', + LOG_SRC: "Statement", /** @method log @@ -179,9 +179,7 @@ TinCan client library "version", "inProgress", "voided" - ], - val - ; + ]; cfg = cfg || {}; @@ -239,14 +237,10 @@ TinCan client library } } if (cfg.hasOwnProperty("target")) { - if (cfg.target instanceof TinCan.Activity - || - cfg.target instanceof TinCan.Agent - || - cfg.target instanceof TinCan.Group - || - cfg.target instanceof TinCan.SubStatement - || + if (cfg.target instanceof TinCan.Activity || + cfg.target instanceof TinCan.Agent || + cfg.target instanceof TinCan.Group || + cfg.target instanceof TinCan.SubStatement || cfg.target instanceof TinCan.StatementRef ) { this.target = cfg.target; diff --git a/src/StatementRef.js b/src/StatementRef.js index aec1d19..fd336dc 100644 --- a/src/StatementRef.js +++ b/src/StatementRef.js @@ -68,9 +68,7 @@ TinCan client library var i, directProps = [ "id" - ], - val - ; + ]; cfg = cfg || {}; @@ -85,7 +83,7 @@ TinCan client library @method toString @return {String} String representation of the statement */ - toString: function (lang) { + toString: function () { this.log("toString"); return this.id; }, diff --git a/src/StatementsResult.js b/src/StatementsResult.js index 4d03528..0c417f1 100644 --- a/src/StatementsResult.js +++ b/src/StatementsResult.js @@ -52,7 +52,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'StatementsResult', + LOG_SRC: "StatementsResult", /** @method log diff --git a/src/SubStatement.js b/src/SubStatement.js index de7ac86..3e9654a 100644 --- a/src/SubStatement.js +++ b/src/SubStatement.js @@ -103,9 +103,7 @@ TinCan client library var i, directProps = [ "timestamp" - ], - val - ; + ]; cfg = cfg || {}; @@ -140,14 +138,10 @@ TinCan client library } } if (cfg.hasOwnProperty("target")) { - if (cfg.target instanceof TinCan.Activity - || - cfg.target instanceof TinCan.Agent - || - cfg.target instanceof TinCan.Group - || - cfg.target instanceof TinCan.SubStatement - || + if (cfg.target instanceof TinCan.Activity || + cfg.target instanceof TinCan.Agent || + cfg.target instanceof TinCan.Group || + cfg.target instanceof TinCan.SubStatement || cfg.target instanceof TinCan.StatementRef ) { this.target = cfg.target; diff --git a/src/TinCan.js b/src/TinCan.js index 44b928b..ec1a293 100644 --- a/src/TinCan.js +++ b/src/TinCan.js @@ -131,10 +131,11 @@ var TinCan; @param {String} msg Message to output */ log: function (msg, src) { + /* globals console */ if (TinCan.DEBUG && typeof console !== "undefined" && console.log) { src = src || this.LOG_SRC || "TinCan"; - console.log("TinCan." + src + ': ' + msg); + console.log("TinCan." + src + ": " + msg); } }, @@ -199,7 +200,6 @@ var TinCan; qsParams = TinCan.Utils.parseURL(url).params, lrsProps = ["endpoint", "auth"], lrsCfg = {}, - activityCfg, contextCfg, extended = null ; @@ -225,10 +225,8 @@ var TinCan; } if ( - qsParams.hasOwnProperty("activity_platform") - || - qsParams.hasOwnProperty("registration") - || + qsParams.hasOwnProperty("activity_platform") || + qsParams.hasOwnProperty("registration") || qsParams.hasOwnProperty("grouping") ) { contextCfg = {}; @@ -519,7 +517,7 @@ var TinCan; { actor: actor, verb: { - id: "http://adlnet.gov/expapi/verbs/voided" + id: "http://adlnet.gov/expapi/verbs/voided" }, target: { objectType: "StatementRef", @@ -1249,7 +1247,7 @@ var TinCan; ]; }; - /*global exports*/ + /*global module*/ // Support the CommonJS method for exporting our single global if (typeof module === "object") { module.exports = TinCan; diff --git a/src/Utils.js b/src/Utils.js index 8cba5aa..49bc3ee 100644 --- a/src/Utils.js +++ b/src/Utils.js @@ -41,11 +41,11 @@ TinCan client library Dual licensed under the MIT and GPL licenses. */ getUUID: function () { - /*jslint bitwise: true eqeq: true */ - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace( + /*jslint bitwise: true, eqeq: true */ + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace( /[xy]/g, function (c) { - var r = Math.random() * 16|0, v = c == 'x' ? r : (r&0x3|0x8); + var r = Math.random() * 16|0, v = c == "x" ? r : (r&0x3|0x8); return v.toString(16); } ); @@ -71,20 +71,20 @@ TinCan client library tempVal = val.toString(); while (val < padder && padder > 1) { - tempVal = '0' + tempVal; + tempVal = "0" + tempVal; padder = padder / 10; } return tempVal; } - return d.getUTCFullYear() + '-' - + pad(d.getUTCMonth() + 1) + '-' - + pad(d.getUTCDate()) + 'T' - + pad(d.getUTCHours()) + ':' - + pad(d.getUTCMinutes()) + ':' - + pad(d.getUTCSeconds()) + '.' - + pad(d.getUTCMilliseconds(), 3) + 'Z'; + return d.getUTCFullYear() + "-" + + pad(d.getUTCMonth() + 1) + "-" + + pad(d.getUTCDate()) + "T" + + pad(d.getUTCHours()) + ":" + + pad(d.getUTCMinutes()) + ":" + + pad(d.getUTCSeconds()) + "." + + pad(d.getUTCMilliseconds(), 3) + "Z"; }, /** @@ -151,16 +151,16 @@ TinCan client library @private */ parseURL: function (url) { - var parts = String(url).split('?'), + var parts = String(url).split("?"), pairs, pair, i, params = {} ; if (parts.length === 2) { - pairs = parts[1].split('&'); + pairs = parts[1].split("&"); for (i = 0; i < pairs.length; i += 1) { - pair = pairs[i].split('='); + pair = pairs[i].split("="); if (pair.length === 2 && pair[0]) { params[pair[0]] = decodeURIComponent(pair[1]); } diff --git a/yuidoc.json b/yuidoc.json index b234485..9479227 100644 --- a/yuidoc.json +++ b/yuidoc.json @@ -1,5 +1,5 @@ { - "version": "0.22.2", + "version": "0.30.0", "name": "TinCanJS", "description": "Library for working with Tin Can API in JavaScript", "url": "http://rusticisoftware.github.com/TinCanJS/", From 99e9e81a50939fcc583eb8b4f419b1b3cb28a6c7 Mon Sep 17 00:00:00 2001 From: "Brian J. Miller" Date: Fri, 28 Mar 2014 18:03:21 -0500 Subject: [PATCH 2/3] Build 0.30.0 (first with Grunt) --- build/tincan-min.js | 20 +- build/tincan-min.map | 1 + build/tincan-node.js | 422 +++++++++++++++++++++--------------------- build/tincan.js | 423 +++++++++++++++++++++---------------------- 4 files changed, 421 insertions(+), 445 deletions(-) create mode 100644 build/tincan-min.map diff --git a/build/tincan-min.js b/build/tincan-min.js index 954fc3d..3a2bc1a 100644 --- a/build/tincan-min.js +++ b/build/tincan-min.js @@ -1,17 +1,3 @@ - -/*! - Copyright 2012 Rustici Software - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ -;var TinCan;(function(){"use strict";var a={statementId:!0,voidedStatementId:!0,verb:!0,object:!0,registration:!0,context:!0,actor:!0,since:!0,until:!0,limit:!0,authoritative:!0,sparse:!0,instructor:!0,ascending:!0,continueToken:!0,agent:!0,activityId:!0,stateId:!0,profileId:!0,activity_platform:!0,grouping:!0,"Accept-Language":!0};TinCan=function(a){this.log("constructor"),this.recordStores=[],this.actor=null,this.activity=null,this.registration=null,this.context=null,this.init(a)},TinCan.prototype={LOG_SRC:"TinCan",log:function(a,b){TinCan.DEBUG&&typeof console!="undefined"&&console.log&&(b=b||this.LOG_SRC||"TinCan",console.log("TinCan."+b+": "+a))},init:function(a){this.log("init");var b;a=a||{},a.hasOwnProperty("url")&&a.url!==""&&this._initFromQueryString(a.url);if(a.hasOwnProperty("recordStores")&&a.recordStores!==undefined)for(b=0;b0){typeof b=="function"&&(i=function(a,d){var g;c.log("sendStatement - callbackWrapper: "+f),f>1?(f-=1,j.push({err:a,xhr:d})):f===1?(j.push({err:a,xhr:d}),g=[j,e],b.apply(this,g)):c.log("sendStatement - unexpected record store count: "+f)});for(g=0;g0)return c=this.recordStores[0],c.retrieveStatement(a,{callback:b});this.log("[warning] getStatement: No LRSs added yet (statement not retrieved)")},voidStatement:function(a,b,c){this.log("voidStatement");var d=this,e,f,g,h=this.recordStores.length,i,j=[],k,l=[];a instanceof TinCan.Statement&&(a=a.id),typeof c.actor!="undefined"?f=c.actor:this.actor!==null&&(f=this.actor),g=new TinCan.Statement({actor:f,verb:{id:"http://adlnet.gov/expapi/verbs/voided"},target:{objectType:"StatementRef",id:a}});if(h>0){typeof b=="function"&&(k=function(a,c){var e;d.log("voidStatement - callbackWrapper: "+h),h>1?(h-=1,l.push({err:a,xhr:c})):h===1?(l.push({err:a,xhr:c}),e=[l,g],b.apply(this,e)):d.log("voidStatement - unexpected record store count: "+h)});for(i=0;i0)return c=this.recordStores[0],c.retrieveVoidedStatement(a,{callback:b});this.log("[warning] getVoidedStatement: No LRSs added yet (statement not retrieved)")},sendStatements:function(a,b){this.log("sendStatements");var c=this,d,e=[],f=this.recordStores.length,g,h=[],i,j=[];if(a.length===0)typeof b=="function"&&b.apply(this,[null,e]);else{for(g=0;g0){typeof b=="function"&&(i=function(a,d){var g;c.log("sendStatements - callbackWrapper: "+f),f>1?(f-=1,j.push({err:a,xhr:d})):f===1?(j.push({err:a,xhr:d}),g=[j,e],b.apply(this,g)):c.log("sendStatements - unexpected record store count: "+f)});for(g=0;g0)return c=this.recordStores[0],a=a||{},d=a.params||{},a.sendActor&&this.actor!==null&&(c.version==="0.9"||c.version==="0.95"?d.actor=this.actor:d.agent=this.actor),a.sendActivity&&this.activity!==null&&(c.version==="0.9"||c.version==="0.95"?d.target=this.activity:d.activity=this.activity),typeof d.registration=="undefined"&&this.registration!==null&&(d.registration=this.registration),b={params:d},typeof a.callback!="undefined"&&(b.callback=a.callback),c.queryStatements(b);this.log("[warning] getStatements: No LRSs added yet (statements not read)")},getState:function(a,b){this.log("getState");var c,d;if(this.recordStores.length>0)return d=this.recordStores[0],b=b||{},c={agent:typeof b.agent!="undefined"?b.agent:this.actor,activity:typeof b.activity!="undefined"?b.activity:this.activity},typeof b.registration!="undefined"?c.registration=b.registration:this.registration!==null&&(c.registration=this.registration),typeof b.callback!="undefined"&&(c.callback=b.callback),d.retrieveState(a,c);this.log("[warning] getState: No LRSs added yet (state not retrieved)")},setState:function(a,b,c){this.log("setState");var d,e;if(this.recordStores.length>0)return e=this.recordStores[0],c=c||{},d={agent:typeof c.agent!="undefined"?c.agent:this.actor,activity:typeof c.activity!="undefined"?c.activity:this.activity},typeof c.registration!="undefined"?d.registration=c.registration:this.registration!==null&&(d.registration=this.registration),typeof c.lastSHA1!="undefined"&&(d.lastSHA1=c.lastSHA1),typeof c.contentType!="undefined"&&(d.contentType=c.contentType),typeof c.callback!="undefined"&&(d.callback=c.callback),e.saveState(a,b,d);this.log("[warning] setState: No LRSs added yet (state not saved)")},deleteState:function(a,b){this.log("deleteState");var c,d;if(this.recordStores.length>0)return d=this.recordStores[0],b=b||{},c={agent:typeof b.agent!="undefined"?b.agent:this.actor,activity:typeof b.activity!="undefined"?b.activity:this.activity},typeof b.registration!="undefined"?c.registration=b.registration:this.registration!==null&&(c.registration=this.registration),typeof b.callback!="undefined"&&(c.callback=b.callback),d.dropState(a,c);this.log("[warning] deleteState: No LRSs added yet (state not deleted)")},getActivityProfile:function(a,b){this.log("getActivityProfile");var c,d;if(this.recordStores.length>0)return d=this.recordStores[0],b=b||{},c={activity:typeof b.activity!="undefined"?b.activity:this.activity},typeof b.callback!="undefined"&&(c.callback=b.callback),d.retrieveActivityProfile(a,c);this.log("[warning] getActivityProfile: No LRSs added yet (activity profile not retrieved)")},setActivityProfile:function(a,b,c){this.log("setActivityProfile");var d,e;if(this.recordStores.length>0)return e=this.recordStores[0],c=c||{},d={activity:typeof c.activity!="undefined"?c.activity:this.activity},typeof c.callback!="undefined"&&(d.callback=c.callback),typeof c.lastSHA1!="undefined"&&(d.lastSHA1=c.lastSHA1),typeof c.contentType!="undefined"&&(d.contentType=c.contentType),e.saveActivityProfile(a,b,d);this.log("[warning] setActivityProfile: No LRSs added yet (activity profile not saved)")},deleteActivityProfile:function(a,b){this.log("deleteActivityProfile");var c,d;if(this.recordStores.length>0)return d=this.recordStores[0],b=b||{},c={activity:typeof b.activity!="undefined"?b.activity:this.activity},typeof b.callback!="undefined"&&(c.callback=b.callback),d.dropActivityProfile(a,c);this.log("[warning] deleteActivityProfile: No LRSs added yet (activity profile not deleted)")},getAgentProfile:function(a,b){this.log("getAgentProfile");var c,d;if(this.recordStores.length>0)return d=this.recordStores[0],b=b||{},c={agent:typeof b.agent!="undefined"?b.agent:this.actor},typeof b.callback!="undefined"&&(c.callback=b.callback),d.retrieveAgentProfile(a,c);this.log("[warning] getAgentProfile: No LRSs added yet (agent profile not retrieved)")},setAgentProfile:function(a,b,c){this.log("setAgentProfile");var d,e;if(this.recordStores.length>0)return e=this.recordStores[0],c=c||{},d={agent:typeof c.agent!="undefined"?c.agent:this.actor},typeof c.callback!="undefined"&&(d.callback=c.callback),typeof c.lastSHA1!="undefined"&&(d.lastSHA1=c.lastSHA1),typeof c.contentType!="undefined"&&(d.contentType=c.contentType),e.saveAgentProfile(a,b,d);this.log("[warning] setAgentProfile: No LRSs added yet (agent profile not saved)")},deleteAgentProfile:function(a,b){this.log("deleteAgentProfile");var c,d;if(this.recordStores.length>0)return d=this.recordStores[0],b=b||{},c={agent:typeof b.agent!="undefined"?b.agent:this.actor},typeof b.callback!="undefined"&&(c.callback=b.callback),d.dropAgentProfile(a,c);this.log("[warning] deleteAgentProfile: No LRSs added yet (agent profile not deleted)")}},TinCan.DEBUG=!1,TinCan.enableDebug=function(){TinCan.DEBUG=!0},TinCan.disableDebug=function(){TinCan.DEBUG=!1},TinCan.versions=function(){return["1.0.1","1.0.0","0.95","0.9"]},typeof module=="object"&&(module.exports=TinCan)})(),function(){"use strict",TinCan.Utils={getUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=Math.random()*16|0,c=a=="x"?b:b&3|8;return c.toString(16)})},getISODateString:function(a){function b(a,b){var c,d;if(typeof a=="undefined"||a===null)a=0;if(typeof b=="undefined"||b===null)b=2;c=Math.pow(10,b-1),d=a.toString();while(a1)d="0"+d,c/=10;return d}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"."+b(a.getUTCMilliseconds(),3)+"Z"},getSHA1String:function(a){return CryptoJS.SHA1(a).toString(CryptoJS.enc.Hex)},getBase64String:function(a){return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Latin1.parse(a))},getLangDictionaryValue:function(a,b){var c=this[a],d;if(typeof b!="undefined"&&typeof c[b]!="undefined")return c[b];if(typeof c.und!="undefined")return c.und;if(typeof c["en-US"]!="undefined")return c["en-US"];for(d in c)if(c.hasOwnProperty(d))return c[d];return""},parseURL:function(a){var b=String(a).split("?"),c,d,e,f={};if(b.length===2){c=b[1].split("&");for(e=0;e0&&(a.name=a.firstName[0],a.firstName.length>1&&(this.degraded=!0)),a.name!==""&&(a.name+=" "),typeof a.lastName!="undefined"&&a.lastName.length>0&&(a.name+=a.lastName[0],a.lastName.length>1&&(this.degraded=!0));else if(typeof a.familyName!="undefined"||typeof a.givenName!="undefined")a.name="",typeof a.givenName!="undefined"&&a.givenName.length>0&&(a.name=a.givenName[0],a.givenName.length>1&&(this.degraded=!0)),a.name!==""&&(a.name+=" "),typeof a.familyName!="undefined"&&a.familyName.length>0&&(a.name+=a.familyName[0],a.familyName.length>1&&(this.degraded=!0));typeof a.name=="object"&&a.name!==null&&(a.name.length>1&&(this.degraded=!0),a.name=a.name[0]),typeof a.mbox=="object"&&a.mbox!==null&&(a.mbox.length>1&&(this.degraded=!0),a.mbox=a.mbox[0]),typeof a.mbox_sha1sum=="object"&&a.mbox_sha1sum!==null&&(a.mbox_sha1sum.length>1&&(this.degraded=!0),a.mbox_sha1sum=a.mbox_sha1sum[0]),typeof a.openid=="object"&&a.openid!==null&&(a.openid.length>1&&(this.degraded=!0),a.openid=a.openid[0]),typeof a.account=="object"&&a.account!==null&&typeof a.account.homePage=="undefined"&&typeof a.account.name=="undefined"&&(a.account.length===0?delete a.account:(a.account.length>1&&(this.degraded=!0),a.account=a.account[0])),a.hasOwnProperty("account")&&(a.account instanceof TinCan.AgentAccount?this.account=a.account:this.account=new TinCan.AgentAccount(a.account));for(b=0;b0){b.member=[];for(c=0;c0)for(c=0;c0)if(a==="0.9"||a==="0.95")this[c[d]].length>1&&this.log("[warning] version does not support multiple values in: "+c[d]),b[c[d]]=this[c[d]][0].asVersion(a);else{b[c[d]]=[];for(e=0;e0){if(a==="0.9"||a==="0.95")throw this.log("[error] version does not support the 'category' property: "+a),new Error(a+" does not support the 'category' property");b.category=[];for(d=0;d=200&&f<400||e))return d={err:f,xhr:a},f===0?log("[warning] There was a problem communicating with the Learning Record Store. Aborted, offline, or invalid CORS endpoint ("+f+")",LOG_SRC):log("[warning] There was a problem communicating with the Learning Record Store. ("+f+" | "+a.responseText+")",LOG_SRC),b.callback&&b.callback(f,a),d;if(!b.callback)return d={err:null,xhr:a},d;b.callback(null,a)},nativeRequest=function(a,b,c){log("sendRequest using XMLHttpRequest",LOG_SRC);var d=this,e,f,g=[],h,i={finished:!1,fakeStatus:null},j=typeof c.callback!="undefined";log("sendRequest using XMLHttpRequest - async: "+j,LOG_SRC);for(f in c.params)c.params.hasOwnProperty(f)&&g.push(f+"="+encodeURIComponent(c.params[f]));g.length>0&&(a+="?"+g.join("&")),typeof XMLHttpRequest!="undefined"?e=new XMLHttpRequest:e=new ActiveXObject("Microsoft.XMLHTTP"),e.open(c.method,a,j);for(f in b)b.hasOwnProperty(f)&&e.setRequestHeader(f,b[f]);typeof c.data!="undefined"&&(c.data+=""),h=c.data,j&&(e.onreadystatechange=function(){log("xhr.onreadystatechange - xhr.readyState: "+e.readyState,LOG_SRC),e.readyState===4&&requestComplete.call(d,e,c,i)});try{e.send(h)}catch(k){log("sendRequest caught send exception: "+k,LOG_SRC)}return j?e:requestComplete.call(this,e,c,i)},xdrRequest=function(a,b,c){log("sendRequest using XDomainRequest",LOG_SRC);var d=this,e,f=[],g,h,i,j={finished:!1,fakeStatus:null};a+="?method="+c.method;for(h in c.params)c.params.hasOwnProperty(h)&&f.push(h+"="+encodeURIComponent(c.params[h]));for(h in b)b.hasOwnProperty(h)&&f.push(h+"="+encodeURIComponent(b[h]));c.data!==null&&f.push("content="+encodeURIComponent(c.data)),g=f.join("&"),e=new XDomainRequest,e.open("POST",a),c.callback?(e.onload=function(){j.fakeStatus=200,requestComplete.call(d,e,c,j)},e.onerror=function(){j.fakeStatus=400,requestComplete.call(d,e,c,j)},e.ontimeout=function(){j.fakeStatus=0,requestComplete.call(d,e,c,j)}):(e.onload=function(){j.fakeStatus=200},e.onerror=function(){j.fakeStatus=400},e.ontimeout=function(){j.fakeStatus=0}),e.onprogress=function(){},e.timeout=0;try{e.send(g)}catch(k){log("sendRequest caught send exception: "+k,LOG_SRC)}if(!c.callback){i=1e4+Date.now(),log("sendRequest - until: "+i+", finished: "+j.finished,LOG_SRC);while(Date.now()>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;d>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16)),c.push((e&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return f.create(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,a=a.sigBytes,c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return f.create(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=f.create(),this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=e/(4*g),h=b?a.ceil(h):a.max((h|0)-this._minBufferSize,0),b=h*g,e=a.min(4*b,e);if(b){for(var i=0;ik;k++){if(16>k)d[k]=a[b+k]|0;else{var l=d[k-3]^d[k-8]^d[k-14]^d[k-16];d[k]=l<<1|l>>>31}l=(e<<5|e>>>27)+j+d[k],l=20>k?l+((f&g|~f&i)+1518500249):40>k?l+((f^g^i)+1859775393):60>k?l+((f&g|f&i|g&i)-1894007588):l+((f^g^i)-899497514),j=i,i=g,g=f<<30|f>>>2,f=e,e=l}c[0]=c[0]+e|0,c[1]=c[1]+f|0,c[2]=c[2]+g|0,c[3]=c[3]+i|0,c[4]=c[4]+j|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process()}});a.SHA1=b._createHelper(e),a.HmacSHA1=b._createHmacHelper(e)})(),function(){var a=CryptoJS,b=a.lib,c=b.WordArray,d=a.enc,e=d.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();var e=[];for(var f=0;f>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i;for(var k=0;k<4&&f+k*.75>>6*(3-k)&63))}var l=d.charAt(64);if(l)while(e.length%4)e.push(l);return e.join("")},parse:function(a){a=a.replace(/\s/g,"");var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);f!=-1&&(b=f)}var g=[],h=0;for(var i=0;i>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(); +var CryptoJS=CryptoJS||function(a,b){var c={},d=c.lib={},e=d.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;return b&&c.mixIn(b),c.$super=this,c},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),f=d.WordArray=e.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=c!=b?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;if(this.clamp(),d%4)for(var e=0;a>e;e++)b[d+e>>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535e;e+=4)b[d+e>>>2]=c[e>>>2];else b.push.apply(b,c);return this.sigBytes+=a,this},clamp:function(){var b=this.words,c=this.sigBytes;b[c>>>2]&=4294967295<<32-8*(c%4),b.length=a.ceil(c/4)},clone:function(){var a=e.clone.call(this);return a.words=this.words.slice(0),a},random:function(b){for(var c=[],d=0;b>d;d+=4)c.push(4294967296*a.random()|0);return f.create(c,b)}}),g=c.enc={},h=g.Hex={stringify:function(a){for(var b=a.words,a=a.sigBytes,c=[],d=0;a>d;d++){var e=b[d>>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16)),c.push((15&e).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return f.create(c,b/2)}},i=g.Latin1={stringify:function(a){for(var b=a.words,a=a.sigBytes,c=[],d=0;a>d;d++)c.push(String.fromCharCode(b[d>>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;b>d;d++)c[d>>>2]|=(255&a.charCodeAt(d))<<24-8*(d%4);return f.create(c,b)}},j=g.Utf8={stringify:function(a){try{return decodeURIComponent(escape(i.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data")}},parse:function(a){return i.parse(unescape(encodeURIComponent(a)))}},k=d.BufferedBlockAlgorithm=e.extend({reset:function(){this._data=f.create(),this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,d=c.words,e=c.sigBytes,g=this.blockSize,h=e/(4*g),h=b?a.ceil(h):a.max((0|h)-this._minBufferSize,0),b=h*g,e=a.min(4*b,e);if(b){for(var i=0;b>i;i+=g)this._doProcessBlock(d,i);i=d.splice(0,b),c.sigBytes-=e}return f.create(i,e)},clone:function(){var a=e.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});d.Hasher=k.extend({init:function(){this.reset()},reset:function(){k.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){return a&&this._append(a),this._doFinalize(),this._hash},clone:function(){var a=k.clone.call(this);return a._hash=this._hash.clone(),a},blockSize:16,_createHelper:function(a){return function(b,c){return a.create(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return l.HMAC.create(a,c).finalize(b)}}});var l=c.algo={};return c}(Math);!function(){var a=CryptoJS,b=a.lib,c=b.WordArray,b=b.Hasher,d=[],e=a.algo.SHA1=b.extend({_doReset:function(){this._hash=c.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,b){for(var c=this._hash.words,e=c[0],f=c[1],g=c[2],h=c[3],i=c[4],j=0;80>j;j++){if(16>j)d[j]=0|a[b+j];else{var k=d[j-3]^d[j-8]^d[j-14]^d[j-16];d[j]=k<<1|k>>>31}k=(e<<5|e>>>27)+i+d[j],k=20>j?k+((f&g|~f&h)+1518500249):40>j?k+((f^g^h)+1859775393):60>j?k+((f&g|f&h|g&h)-1894007588):k+((f^g^h)-899497514),i=h,h=g,g=f<<30|f>>>2,f=e,e=k}c[0]=c[0]+e|0,c[1]=c[1]+f|0,c[2]=c[2]+g|0,c[3]=c[3]+h|0,c[4]=c[4]+i|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;b[d>>>5]|=128<<24-d%32,b[(d+64>>>9<<4)+15]=c,a.sigBytes=4*b.length,this._process()}});a.SHA1=b._createHelper(e),a.HmacSHA1=b._createHmacHelper(e)}(),function(){{var a=CryptoJS,b=a.lib,c=b.WordArray,d=a.enc;d.Base64={stringify:function(a){var b=a.words,c=a.sigBytes,d=this._map;a.clamp();for(var e=[],f=0;c>f;f+=3)for(var g=b[f>>>2]>>>24-f%4*8&255,h=b[f+1>>>2]>>>24-(f+1)%4*8&255,i=b[f+2>>>2]>>>24-(f+2)%4*8&255,j=g<<16|h<<8|i,k=0;4>k&&c>f+.75*k;k++)e.push(d.charAt(j>>>6*(3-k)&63));var l=d.charAt(64);if(l)for(;e.length%4;)e.push(l);return e.join("")},parse:function(a){a=a.replace(/\s/g,"");var b=a.length,d=this._map,e=d.charAt(64);if(e){var f=a.indexOf(e);-1!=f&&(b=f)}for(var g=[],h=0,i=0;b>i;i++)if(i%4){var j=d.indexOf(a.charAt(i-1))<>>6-i%4*2;g[h>>>2]|=(j|k)<<24-h%4*8,h++}return c.create(g,h)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}}();var TinCan;!function(){"use strict";var a={statementId:!0,voidedStatementId:!0,verb:!0,object:!0,registration:!0,context:!0,actor:!0,since:!0,until:!0,limit:!0,authoritative:!0,sparse:!0,instructor:!0,ascending:!0,continueToken:!0,agent:!0,activityId:!0,stateId:!0,profileId:!0,activity_platform:!0,grouping:!0,"Accept-Language":!0};TinCan=function(a){this.log("constructor"),this.recordStores=[],this.actor=null,this.activity=null,this.registration=null,this.context=null,this.init(a)},TinCan.prototype={LOG_SRC:"TinCan",log:function(a,b){TinCan.DEBUG&&"undefined"!=typeof console&&console.log&&(b=b||this.LOG_SRC||"TinCan",console.log("TinCan."+b+": "+a))},init:function(a){this.log("init");var b;if(a=a||{},a.hasOwnProperty("url")&&""!==a.url&&this._initFromQueryString(a.url),a.hasOwnProperty("recordStores")&&void 0!==a.recordStores)for(b=0;b0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatement - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatement - unexpected record store count: "+h)}),d=0;h>d;d+=1)c=this.recordStores[d],i.push(c.saveStatement(g,{callback:e}));else this.log("[warning] sendStatement: No LRSs added yet (statement not sent)"),"function"==typeof b&&b.apply(this,[null,g]);return{statement:g,results:i}},getStatement:function(a,b){this.log("getStatement");var c;return this.recordStores.length>0?(c=this.recordStores[0],c.retrieveStatement(a,{callback:b})):void this.log("[warning] getStatement: No LRSs added yet (statement not retrieved)")},voidStatement:function(a,b,c){this.log("voidStatement");var d,e,f,g,h,i=this,j=this.recordStores.length,k=[],l=[];if(a instanceof TinCan.Statement&&(a=a.id),"undefined"!=typeof c.actor?e=c.actor:null!==this.actor&&(e=this.actor),f=new TinCan.Statement({actor:e,verb:{id:"http://adlnet.gov/expapi/verbs/voided"},target:{objectType:"StatementRef",id:a}}),j>0)for("function"==typeof b&&(h=function(a,c){var d;i.log("voidStatement - callbackWrapper: "+j),j>1?(j-=1,l.push({err:a,xhr:c})):1===j?(l.push({err:a,xhr:c}),d=[l,f],b.apply(this,d)):i.log("voidStatement - unexpected record store count: "+j)}),g=0;j>g;g+=1)d=this.recordStores[g],k.push(d.saveStatement(f,{callback:h}));else this.log("[warning] voidStatement: No LRSs added yet (statement not sent)"),"function"==typeof b&&b.apply(this,[null,f]);return{statement:f,results:k}},getVoidedStatement:function(a,b){this.log("getVoidedStatement");var c;return this.recordStores.length>0?(c=this.recordStores[0],c.retrieveVoidedStatement(a,{callback:b})):void this.log("[warning] getVoidedStatement: No LRSs added yet (statement not retrieved)")},sendStatements:function(a,b){this.log("sendStatements");var c,d,e,f=this,g=[],h=this.recordStores.length,i=[],j=[];if(0===a.length)"function"==typeof b&&b.apply(this,[null,g]);else{for(d=0;d0)for("function"==typeof b&&(e=function(a,c){var d;f.log("sendStatements - callbackWrapper: "+h),h>1?(h-=1,j.push({err:a,xhr:c})):1===h?(j.push({err:a,xhr:c}),d=[j,g],b.apply(this,d)):f.log("sendStatements - unexpected record store count: "+h)}),d=0;h>d;d+=1)c=this.recordStores[d],i.push(c.saveStatements(g,{callback:e}));else this.log("[warning] sendStatements: No LRSs added yet (statements not sent)"),"function"==typeof b&&b.apply(this,[null,g])}return{statements:g,results:i}},getStatements:function(a){this.log("getStatements");var b,c,d={};return this.recordStores.length>0?(b=this.recordStores[0],a=a||{},c=a.params||{},a.sendActor&&null!==this.actor&&("0.9"===b.version||"0.95"===b.version?c.actor=this.actor:c.agent=this.actor),a.sendActivity&&null!==this.activity&&("0.9"===b.version||"0.95"===b.version?c.target=this.activity:c.activity=this.activity),"undefined"==typeof c.registration&&null!==this.registration&&(c.registration=this.registration),d={params:c},"undefined"!=typeof a.callback&&(d.callback=a.callback),b.queryStatements(d)):void this.log("[warning] getStatements: No LRSs added yet (statements not read)")},getState:function(a,b){this.log("getState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveState(a,c)):void this.log("[warning] getState: No LRSs added yet (state not retrieved)")},setState:function(a,b,c){this.log("setState");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor,activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.registration?d.registration=c.registration:null!==this.registration&&(d.registration=this.registration),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType),"undefined"!=typeof c.callback&&(d.callback=c.callback),e.saveState(a,b,d)):void this.log("[warning] setState: No LRSs added yet (state not saved)")},deleteState:function(a,b){this.log("deleteState");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor,activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.registration?c.registration=b.registration:null!==this.registration&&(c.registration=this.registration),"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropState(a,c)):void this.log("[warning] deleteState: No LRSs added yet (state not deleted)")},getActivityProfile:function(a,b){this.log("getActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveActivityProfile(a,c)):void this.log("[warning] getActivityProfile: No LRSs added yet (activity profile not retrieved)")},setActivityProfile:function(a,b,c){this.log("setActivityProfile");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={activity:"undefined"!=typeof c.activity?c.activity:this.activity},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType),e.saveActivityProfile(a,b,d)):void this.log("[warning] setActivityProfile: No LRSs added yet (activity profile not saved)")},deleteActivityProfile:function(a,b){this.log("deleteActivityProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={activity:"undefined"!=typeof b.activity?b.activity:this.activity},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropActivityProfile(a,c)):void this.log("[warning] deleteActivityProfile: No LRSs added yet (activity profile not deleted)")},getAgentProfile:function(a,b){this.log("getAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.retrieveAgentProfile(a,c)):void this.log("[warning] getAgentProfile: No LRSs added yet (agent profile not retrieved)")},setAgentProfile:function(a,b,c){this.log("setAgentProfile");var d,e;return this.recordStores.length>0?(e=this.recordStores[0],c=c||{},d={agent:"undefined"!=typeof c.agent?c.agent:this.actor},"undefined"!=typeof c.callback&&(d.callback=c.callback),"undefined"!=typeof c.lastSHA1&&(d.lastSHA1=c.lastSHA1),"undefined"!=typeof c.contentType&&(d.contentType=c.contentType),e.saveAgentProfile(a,b,d)):void this.log("[warning] setAgentProfile: No LRSs added yet (agent profile not saved)")},deleteAgentProfile:function(a,b){this.log("deleteAgentProfile");var c,d;return this.recordStores.length>0?(d=this.recordStores[0],b=b||{},c={agent:"undefined"!=typeof b.agent?b.agent:this.actor},"undefined"!=typeof b.callback&&(c.callback=b.callback),d.dropAgentProfile(a,c)):void this.log("[warning] deleteAgentProfile: No LRSs added yet (agent profile not deleted)")}},TinCan.DEBUG=!1,TinCan.enableDebug=function(){TinCan.DEBUG=!0},TinCan.disableDebug=function(){TinCan.DEBUG=!1},TinCan.versions=function(){return["1.0.1","1.0.0","0.95","0.9"]},"object"==typeof module&&(module.exports=TinCan)}(),function(){"use strict";TinCan.Utils={getUUID:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},getISODateString:function(a){function b(a,b){var c,d;for(("undefined"==typeof a||null===a)&&(a=0),("undefined"==typeof b||null===b)&&(b=2),c=Math.pow(10,b-1),d=a.toString();c>a&&c>1;)d="0"+d,c/=10;return d}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"."+b(a.getUTCMilliseconds(),3)+"Z"},getSHA1String:function(a){return CryptoJS.SHA1(a).toString(CryptoJS.enc.Hex)},getBase64String:function(a){return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Latin1.parse(a))},getLangDictionaryValue:function(a,b){var c,d=this[a];if("undefined"!=typeof b&&"undefined"!=typeof d[b])return d[b];if("undefined"!=typeof d.und)return d.und;if("undefined"!=typeof d["en-US"])return d["en-US"];for(c in d)if(d.hasOwnProperty(c))return d[c];return""},parseURL:function(a){var b,c,d,e=String(a).split("?"),f={};if(2===e.length)for(b=e[1].split("&"),d=0;d0&&(a.name=a.firstName[0],a.firstName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.lastName&&a.lastName.length>0&&(a.name+=a.lastName[0],a.lastName.length>1&&(this.degraded=!0))):("undefined"!=typeof a.familyName||"undefined"!=typeof a.givenName)&&(a.name="","undefined"!=typeof a.givenName&&a.givenName.length>0&&(a.name=a.givenName[0],a.givenName.length>1&&(this.degraded=!0)),""!==a.name&&(a.name+=" "),"undefined"!=typeof a.familyName&&a.familyName.length>0&&(a.name+=a.familyName[0],a.familyName.length>1&&(this.degraded=!0))),"object"==typeof a.name&&null!==a.name&&(a.name.length>1&&(this.degraded=!0),a.name=a.name[0]),"object"==typeof a.mbox&&null!==a.mbox&&(a.mbox.length>1&&(this.degraded=!0),a.mbox=a.mbox[0]),"object"==typeof a.mbox_sha1sum&&null!==a.mbox_sha1sum&&(a.mbox_sha1sum.length>1&&(this.degraded=!0),a.mbox_sha1sum=a.mbox_sha1sum[0]),"object"==typeof a.openid&&null!==a.openid&&(a.openid.length>1&&(this.degraded=!0),a.openid=a.openid[0]),"object"==typeof a.account&&null!==a.account&&"undefined"==typeof a.account.homePage&&"undefined"==typeof a.account.name&&(0===a.account.length?delete a.account:(a.account.length>1&&(this.degraded=!0),a.account=a.account[0])),a.hasOwnProperty("account")&&(this.account=a.account instanceof TinCan.AgentAccount?a.account:new TinCan.AgentAccount(a.account)),b=0;b0)for(b.member=[],c=0;c0))for(c=0;c0)if("0.9"===a||"0.95"===a)this[e[b]].length>1&&this.log("[warning] version does not support multiple values in: "+e[b]),d[e[b]]=this[e[b]][0].asVersion(a);else for(d[e[b]]=[],c=0;c0){if("0.9"===a||"0.95"===a)throw this.log("[error] version does not support the 'category' property: "+a),new Error(a+" does not support the 'category' property");for(d.category=[],b=0;b=200&&400>f||e?b.callback?void b.callback(null,a):d={err:null,xhr:a}:(d={err:f,xhr:a},0===f?log("[warning] There was a problem communicating with the Learning Record Store. Aborted, offline, or invalid CORS endpoint ("+f+")",LOG_SRC):log("[warning] There was a problem communicating with the Learning Record Store. ("+f+" | "+a.responseText+")",LOG_SRC),b.callback&&b.callback(f,a),d))},nativeRequest=function(a,b,c){log("sendRequest using XMLHttpRequest",LOG_SRC);var d,e,f,g=this,h=[],i={finished:!1,fakeStatus:null},j="undefined"!=typeof c.callback;log("sendRequest using XMLHttpRequest - async: "+j,LOG_SRC);for(e in c.params)c.params.hasOwnProperty(e)&&h.push(e+"="+encodeURIComponent(c.params[e]));h.length>0&&(a+="?"+h.join("&")),d="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP"),d.open(c.method,a,j);for(e in b)b.hasOwnProperty(e)&&d.setRequestHeader(e,b[e]);"undefined"!=typeof c.data&&(c.data+=""),f=c.data,j&&(d.onreadystatechange=function(){log("xhr.onreadystatechange - xhr.readyState: "+d.readyState,LOG_SRC),4===d.readyState&&requestComplete.call(g,d,c,i)});try{d.send(f)}catch(k){log("sendRequest caught send exception: "+k,LOG_SRC)}return j?d:requestComplete.call(this,d,c,i)},xdrRequest=function(a,b,c){log("sendRequest using XDomainRequest",LOG_SRC);var d,e,f,g,h=this,i=[],j={finished:!1,fakeStatus:null};a+="?method="+c.method;for(f in c.params)c.params.hasOwnProperty(f)&&i.push(f+"="+encodeURIComponent(c.params[f]));for(f in b)b.hasOwnProperty(f)&&i.push(f+"="+encodeURIComponent(b[f]));null!==c.data&&i.push("content="+encodeURIComponent(c.data)),e=i.join("&"),d=new XDomainRequest,d.open("POST",a),c.callback?(d.onload=function(){j.fakeStatus=200,requestComplete.call(h,d,c,j)},d.onerror=function(){j.fakeStatus=400,requestComplete.call(h,d,c,j)},d.ontimeout=function(){j.fakeStatus=0,requestComplete.call(h,d,c,j)}):(d.onload=function(){j.fakeStatus=200},d.onerror=function(){j.fakeStatus=400},d.ontimeout=function(){j.fakeStatus=0}),d.onprogress=function(){},d.timeout=0;try{d.send(e)}catch(k){log("sendRequest caught send exception: "+k,LOG_SRC)}if(!c.callback){for(g=1e4+Date.now(),log("sendRequest - until: "+g+", finished: "+j.finished,LOG_SRC);Date.now()>>2]|=(c[f>>>2]>>>24-8*(f%4)&255)<<24-8*((d+f)%4);else if(65535>>2]=c[f>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<32-8*(b%4);a.length=i.ceil(b/4)},clone:function(){var a= +n.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c>>2]>>>24-8*(d%4)&255;c.push((f>>>4).toString(16));c.push((f&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return o.create(c,b/2)}},g=q.Latin1={stringify:function(a){for(var b= +a.words,a=a.sigBytes,c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return o.create(c,b)}},j=q.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},k=h.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=o.create(); +this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,f=this.blockSize,e=d/(4*f),e=a?i.ceil(e):i.max((e|0)-this._minBufferSize,0),a=e*f,d=i.min(4*a,d);if(a){for(var g=0;gb;b++){if(16>b)h[b]=o[i+b]|0;else{var c=h[b-3]^h[b-8]^h[b-14]^h[b-16];h[b]=c<<1|c>>>31}c=(g<<5|g>>>27)+a+h[b];c=20>b?c+((j&k|~j&l)+1518500249):40>b?c+((j^k^l)+1859775393):60>b?c+((j&k|j&l|k&l)-1894007588):c+((j^k^l)- +899497514);a=l;l=k;k=j<<30|j>>>2;j=g;g=c}e[0]=e[0]+g|0;e[1]=e[1]+j|0;e[2]=e[2]+k|0;e[3]=e[3]+l|0;e[4]=e[4]+a|0},_doFinalize:function(){var i=this._data,h=i.words,e=8*this._nDataBytes,g=8*i.sigBytes;h[g>>>5]|=128<<24-g%32;h[(g+64>>>9<<4)+15]=e;i.sigBytes=4*h.length;this._process()}});i.SHA1=m._createHelper(n);i.HmacSHA1=m._createHmacHelper(n)})(); + +/* +CryptoJS v3.0.2 +code.google.com/p/crypto-js +(c) 2009-2012 by Jeff Mott. All rights reserved. +code.google.com/p/crypto-js/wiki/License +*/ +(function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + + /** + * Base64 encoding strategy. + */ + var Base64 = C_enc.Base64 = { + /** + * Converts a word array to a Base64 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Base64 string. + * + * @static + * + * @example + * + * var base64String = CryptoJS.enc.Base64.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + var map = this._map; + + // Clamp excess bits + wordArray.clamp(); + + // Convert + var base64Chars = []; + for (var i = 0; i < sigBytes; i += 3) { + var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; + var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; + + var triplet = (byte1 << 16) | (byte2 << 8) | byte3; + + for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); + } + } + + // Add padding + var paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } + + return base64Chars.join(''); + }, + + /** + * Converts a Base64 string to a word array. + * + * @param {string} base64Str The Base64 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Base64.parse(base64String); + */ + parse: function (base64Str) { + // Ignore whitespaces + base64Str = base64Str.replace(/\s/g, ''); + + // Shortcuts + var base64StrLength = base64Str.length; + var map = this._map; + + // Ignore padding + var paddingChar = map.charAt(64); + if (paddingChar) { + var paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex != -1) { + base64StrLength = paddingIndex; + } + } + + // Convert + var words = []; + var nBytes = 0; + for (var i = 0; i < base64StrLength; i++) { + if (i % 4) { + var bitsHigh = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); + var bitsLow = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); + words[nBytes >>> 2] |= (bitsHigh | bitsLow) << (24 - (nBytes % 4) * 8); + nBytes++; + } + } + + return WordArray.create(words, nBytes); + }, + + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' + }; +}()); + /*! Copyright 2012 Rustici Software @@ -131,10 +259,11 @@ var TinCan; @param {String} msg Message to output */ log: function (msg, src) { + /* globals console */ if (TinCan.DEBUG && typeof console !== "undefined" && console.log) { src = src || this.LOG_SRC || "TinCan"; - console.log("TinCan." + src + ': ' + msg); + console.log("TinCan." + src + ": " + msg); } }, @@ -199,7 +328,6 @@ var TinCan; qsParams = TinCan.Utils.parseURL(url).params, lrsProps = ["endpoint", "auth"], lrsCfg = {}, - activityCfg, contextCfg, extended = null ; @@ -225,10 +353,8 @@ var TinCan; } if ( - qsParams.hasOwnProperty("activity_platform") - || - qsParams.hasOwnProperty("registration") - || + qsParams.hasOwnProperty("activity_platform") || + qsParams.hasOwnProperty("registration") || qsParams.hasOwnProperty("grouping") ) { contextCfg = {}; @@ -519,7 +645,7 @@ var TinCan; { actor: actor, verb: { - id: "http://adlnet.gov/expapi/verbs/voided" + id: "http://adlnet.gov/expapi/verbs/voided" }, target: { objectType: "StatementRef", @@ -1249,12 +1375,13 @@ var TinCan; ]; }; - /*global exports*/ + /*global module*/ // Support the CommonJS method for exporting our single global if (typeof module === "object") { module.exports = TinCan; } }()); + /* Copyright 2012 Rustici Software @@ -1298,11 +1425,11 @@ TinCan client library Dual licensed under the MIT and GPL licenses. */ getUUID: function () { - /*jslint bitwise: true eqeq: true */ - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace( + /*jslint bitwise: true, eqeq: true */ + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace( /[xy]/g, function (c) { - var r = Math.random() * 16|0, v = c == 'x' ? r : (r&0x3|0x8); + var r = Math.random() * 16|0, v = c == "x" ? r : (r&0x3|0x8); return v.toString(16); } ); @@ -1328,20 +1455,20 @@ TinCan client library tempVal = val.toString(); while (val < padder && padder > 1) { - tempVal = '0' + tempVal; + tempVal = "0" + tempVal; padder = padder / 10; } return tempVal; } - return d.getUTCFullYear() + '-' - + pad(d.getUTCMonth() + 1) + '-' - + pad(d.getUTCDate()) + 'T' - + pad(d.getUTCHours()) + ':' - + pad(d.getUTCMinutes()) + ':' - + pad(d.getUTCSeconds()) + '.' - + pad(d.getUTCMilliseconds(), 3) + 'Z'; + return d.getUTCFullYear() + "-" + + pad(d.getUTCMonth() + 1) + "-" + + pad(d.getUTCDate()) + "T" + + pad(d.getUTCHours()) + ":" + + pad(d.getUTCMinutes()) + ":" + + pad(d.getUTCSeconds()) + "." + + pad(d.getUTCMilliseconds(), 3) + "Z"; }, /** @@ -1408,16 +1535,16 @@ TinCan client library @private */ parseURL: function (url) { - var parts = String(url).split('?'), + var parts = String(url).split("?"), pairs, pair, i, params = {} ; if (parts.length === 2) { - pairs = parts[1].split('&'); + pairs = parts[1].split("&"); for (i = 0; i < pairs.length; i += 1) { - pair = pairs[i].split('='); + pair = pairs[i].split("="); if (pair.length === 2 && pair[0]) { params[pair[0]] = decodeURIComponent(pair[1]); } @@ -1462,6 +1589,7 @@ TinCan client library } }; }()); + /* Copyright 2012-2013 Rustici Software @@ -2195,7 +2323,7 @@ TinCan client library //or endpoint (though only the former is allowed in the spec) serverRoot = TinCan.Utils.getServerRoot(this.endpoint); if (parsedURL.path.indexOf("/statements") === 0){ - parsedURL.path = this.endpoint.replace(serverRoot, '') + parsedURL.path; + parsedURL.path = this.endpoint.replace(serverRoot, "") + parsedURL.path; this.log("converting non-standard more URL to " + parsedURL.path); } @@ -2390,9 +2518,7 @@ TinCan client library saveState: function (key, val, cfg) { this.log("saveState"); var requestParams, - requestCfg, - requestResult - ; + requestCfg; if (typeof cfg.contentType === "undefined") { cfg.contentType = "application/octet-stream"; @@ -2900,6 +3026,7 @@ TinCan client library } }; }()); + /* Copyright 2012 Rustici Software @@ -2950,7 +3077,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'AgentAccount', + LOG_SRC: "AgentAccount", /** @method log @@ -2967,9 +3094,7 @@ TinCan client library directProps = [ "name", "homePage" - ], - val - ; + ]; cfg = cfg || {}; @@ -2988,7 +3113,7 @@ TinCan client library } }, - toString: function (lang) { + toString: function () { this.log("toString"); var result = ""; @@ -3038,6 +3163,7 @@ TinCan client library return new AgentAccount(_acct); }; }()); + /* Copyright 2012 Rustici Software @@ -3242,7 +3368,7 @@ TinCan client library } }, - toString: function (lang) { + toString: function () { this.log("toString"); if (this.name !== null) { @@ -3332,6 +3458,7 @@ TinCan client library return new Agent(_agent); }; }()); + /* Copyright 2012 Rustici Software @@ -3493,6 +3620,7 @@ TinCan client library return new Group(_group); }; }()); + /* Copyright 2012 Rustici Software @@ -3681,6 +3809,7 @@ TinCan client library return new Verb(_verb); }; }()); + /* Copyright 2012 Rustici Software @@ -3755,7 +3884,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Result', + LOG_SRC: "Result", /** @method log @@ -3818,8 +3947,7 @@ TinCan client library optionalObjProps = [ "score" ], - i, - prop; + i; version = version || TinCan.versions()[0]; @@ -3860,6 +3988,7 @@ TinCan client library return new Result(_result); }; }()); + /* Copyright 2012 Rustici Software @@ -3922,7 +4051,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Score', + LOG_SRC: "Score", /** @method log @@ -3967,8 +4096,7 @@ TinCan client library "min", "max" ], - i, - prop; + i; version = version || TinCan.versions()[0]; @@ -3994,6 +4122,7 @@ TinCan client library return new Score(_score); }; }()); + /* Copyright 2012 Rustici Software @@ -4044,7 +4173,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'InteractionComponent', + LOG_SRC: "InteractionComponent", /** @method log @@ -4120,6 +4249,7 @@ TinCan client library return new InteractionComponent(_ic); }; }()); + /* Copyright 2012 Rustici Software @@ -4442,6 +4572,7 @@ TinCan client library return new ActivityDefinition(_definition); }; }()); + /* Copyright 2012 Rustici Software @@ -4499,7 +4630,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Activity', + LOG_SRC: "Activity", /** @method log @@ -4591,6 +4722,7 @@ TinCan client library return new Activity(_activity); }; }()); + /* Copyright 2013 Rustici Software @@ -4653,7 +4785,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'ContextActivities', + LOG_SRC: "ContextActivities", /** @method log @@ -4713,7 +4845,7 @@ TinCan client library } if (! (val instanceof TinCan.Activity)) { - val = typeof val === 'string' ? { id: val } : val; + val = typeof val === "string" ? { id: val } : val; val = new TinCan.Activity (val); } @@ -4735,8 +4867,7 @@ TinCan client library "other" ], i, - j, - prop; + j; version = version || TinCan.versions()[0]; @@ -4789,6 +4920,7 @@ TinCan client library return new ContextActivities(_contextActivities); }; }()); + /* Copyright 2012 Rustici Software @@ -4881,7 +5013,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Context', + LOG_SRC: "Context", /** @method log @@ -4969,8 +5101,7 @@ TinCan client library "contextActivities", "statement" ], - i, - prop; + i; version = version || TinCan.versions()[0]; @@ -5001,6 +5132,7 @@ TinCan client library return new Context(_context); }; }()); + /* Copyright 2012 Rustici Software @@ -5071,9 +5203,7 @@ TinCan client library var i, directProps = [ "id" - ], - val - ; + ]; cfg = cfg || {}; @@ -5088,7 +5218,7 @@ TinCan client library @method toString @return {String} String representation of the statement */ - toString: function (lang) { + toString: function () { this.log("toString"); return this.id; }, @@ -5124,6 +5254,7 @@ TinCan client library return new StatementRef(_stRef); }; }()); + /* Copyright 2012 Rustici Software @@ -5229,9 +5360,7 @@ TinCan client library var i, directProps = [ "timestamp" - ], - val - ; + ]; cfg = cfg || {}; @@ -5266,14 +5395,10 @@ TinCan client library } } if (cfg.hasOwnProperty("target")) { - if (cfg.target instanceof TinCan.Activity - || - cfg.target instanceof TinCan.Agent - || - cfg.target instanceof TinCan.Group - || - cfg.target instanceof TinCan.SubStatement - || + if (cfg.target instanceof TinCan.Activity || + cfg.target instanceof TinCan.Agent || + cfg.target instanceof TinCan.Group || + cfg.target instanceof TinCan.SubStatement || cfg.target instanceof TinCan.StatementRef ) { this.target = cfg.target; @@ -5383,6 +5508,7 @@ TinCan client library return new SubStatement(_subSt); }; }()); + /* Copyright 2012-3 Rustici Software @@ -5542,7 +5668,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Statement', + LOG_SRC: "Statement", /** @method log @@ -5564,9 +5690,7 @@ TinCan client library "version", "inProgress", "voided" - ], - val - ; + ]; cfg = cfg || {}; @@ -5624,14 +5748,10 @@ TinCan client library } } if (cfg.hasOwnProperty("target")) { - if (cfg.target instanceof TinCan.Activity - || - cfg.target instanceof TinCan.Agent - || - cfg.target instanceof TinCan.Group - || - cfg.target instanceof TinCan.SubStatement - || + if (cfg.target instanceof TinCan.Activity || + cfg.target instanceof TinCan.Agent || + cfg.target instanceof TinCan.Group || + cfg.target instanceof TinCan.SubStatement || cfg.target instanceof TinCan.StatementRef ) { this.target = cfg.target; @@ -5770,6 +5890,7 @@ TinCan client library return new Statement(_st); }; }()); + /* Copyright 2012 Rustici Software @@ -5824,7 +5945,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'StatementsResult', + LOG_SRC: "StatementsResult", /** @method log @@ -5891,6 +6012,7 @@ TinCan client library return new StatementsResult (_result); }; }()); + /* Copyright 2012 Rustici Software @@ -5959,7 +6081,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'State', + LOG_SRC: "State", /** @method log @@ -5978,9 +6100,7 @@ TinCan client library "contents", "etag", "contentType" - ], - val - ; + ]; cfg = cfg || {}; @@ -6006,6 +6126,7 @@ TinCan client library return new State(_state); }; }()); + /* Copyright 2012 Rustici Software @@ -6083,7 +6204,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'ActivityProfile', + LOG_SRC: "ActivityProfile", /** @method log @@ -6102,9 +6223,7 @@ TinCan client library "contents", "etag", "contentType" - ], - val - ; + ]; cfg = cfg || {}; @@ -6139,6 +6258,7 @@ TinCan client library return new ActivityProfile(_state); }; }()); + /* Copyright 2013 Rustici Software @@ -6216,7 +6336,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'AgentProfile', + LOG_SRC: "AgentProfile", /** @method log @@ -6235,9 +6355,7 @@ TinCan client library "contents", "etag", "contentType" - ], - val - ; + ]; cfg = cfg || {}; @@ -6272,6 +6390,7 @@ TinCan client library return new AgentProfile(_state); }; }()); + /* Copyright 2012-2013 Rustici Software @@ -6295,6 +6414,7 @@ TinCan client library @submodule TinCan.Environment.Node **/ (function () { + /* globals require */ "use strict"; var LOG_SRC = "Environment.Node", log = TinCan.prototype.log, @@ -6363,7 +6483,7 @@ TinCan client library prop ; if (Object.keys(cfg.params).length > 0) { - url += '?' + querystring.stringify(cfg.params); + url += "?" + querystring.stringify(cfg.params); } xhr = new XMLHttpRequest(); @@ -6396,129 +6516,3 @@ TinCan client library return requestComplete(xhr, cfg); }; }()); -/* -CryptoJS v3.0.2 -code.google.com/p/crypto-js -(c) 2009-2012 by Jeff Mott. All rights reserved. -code.google.com/p/crypto-js/wiki/License -*/ -var CryptoJS=CryptoJS||function(i,m){var p={},h=p.lib={},n=h.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;b&&c.mixIn(b);c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),o=h.WordArray=n.extend({init:function(a,b){a= -this.words=a||[];this.sigBytes=b!=m?b:4*a.length},toString:function(a){return(a||e).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;this.clamp();if(d%4)for(var f=0;f>>2]|=(c[f>>>2]>>>24-8*(f%4)&255)<<24-8*((d+f)%4);else if(65535>>2]=c[f>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<32-8*(b%4);a.length=i.ceil(b/4)},clone:function(){var a= -n.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c>>2]>>>24-8*(d%4)&255;c.push((f>>>4).toString(16));c.push((f&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return o.create(c,b/2)}},g=q.Latin1={stringify:function(a){for(var b= -a.words,a=a.sigBytes,c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return o.create(c,b)}},j=q.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},k=h.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=o.create(); -this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,f=this.blockSize,e=d/(4*f),e=a?i.ceil(e):i.max((e|0)-this._minBufferSize,0),a=e*f,d=i.min(4*a,d);if(a){for(var g=0;gb;b++){if(16>b)h[b]=o[i+b]|0;else{var c=h[b-3]^h[b-8]^h[b-14]^h[b-16];h[b]=c<<1|c>>>31}c=(g<<5|g>>>27)+a+h[b];c=20>b?c+((j&k|~j&l)+1518500249):40>b?c+((j^k^l)+1859775393):60>b?c+((j&k|j&l|k&l)-1894007588):c+((j^k^l)- -899497514);a=l;l=k;k=j<<30|j>>>2;j=g;g=c}e[0]=e[0]+g|0;e[1]=e[1]+j|0;e[2]=e[2]+k|0;e[3]=e[3]+l|0;e[4]=e[4]+a|0},_doFinalize:function(){var i=this._data,h=i.words,e=8*this._nDataBytes,g=8*i.sigBytes;h[g>>>5]|=128<<24-g%32;h[(g+64>>>9<<4)+15]=e;i.sigBytes=4*h.length;this._process()}});i.SHA1=m._createHelper(n);i.HmacSHA1=m._createHmacHelper(n)})(); -/* -CryptoJS v3.0.2 -code.google.com/p/crypto-js -(c) 2009-2012 by Jeff Mott. All rights reserved. -code.google.com/p/crypto-js/wiki/License -*/ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var C_enc = C.enc; - - /** - * Base64 encoding strategy. - */ - var Base64 = C_enc.Base64 = { - /** - * Converts a word array to a Base64 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The Base64 string. - * - * @static - * - * @example - * - * var base64String = CryptoJS.enc.Base64.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; - var map = this._map; - - // Clamp excess bits - wordArray.clamp(); - - // Convert - var base64Chars = []; - for (var i = 0; i < sigBytes; i += 3) { - var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; - var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; - - var triplet = (byte1 << 16) | (byte2 << 8) | byte3; - - for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { - base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); - } - } - - // Add padding - var paddingChar = map.charAt(64); - if (paddingChar) { - while (base64Chars.length % 4) { - base64Chars.push(paddingChar); - } - } - - return base64Chars.join(''); - }, - - /** - * Converts a Base64 string to a word array. - * - * @param {string} base64Str The Base64 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Base64.parse(base64String); - */ - parse: function (base64Str) { - // Ignore whitespaces - base64Str = base64Str.replace(/\s/g, ''); - - // Shortcuts - var base64StrLength = base64Str.length; - var map = this._map; - - // Ignore padding - var paddingChar = map.charAt(64); - if (paddingChar) { - var paddingIndex = base64Str.indexOf(paddingChar); - if (paddingIndex != -1) { - base64StrLength = paddingIndex; - } - } - - // Convert - var words = []; - var nBytes = 0; - for (var i = 0; i < base64StrLength; i++) { - if (i % 4) { - var bitsHigh = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); - var bitsLow = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); - words[nBytes >>> 2] |= (bitsHigh | bitsLow) << (24 - (nBytes % 4) * 8); - nBytes++; - } - } - - return WordArray.create(words, nBytes); - }, - - _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' - }; -}()); diff --git a/build/tincan.js b/build/tincan.js index 81efacf..be12ee7 100644 --- a/build/tincan.js +++ b/build/tincan.js @@ -1,3 +1,131 @@ +/* +CryptoJS v3.0.2 +code.google.com/p/crypto-js +(c) 2009-2012 by Jeff Mott. All rights reserved. +code.google.com/p/crypto-js/wiki/License +*/ +var CryptoJS=CryptoJS||function(i,m){var p={},h=p.lib={},n=h.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;b&&c.mixIn(b);c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),o=h.WordArray=n.extend({init:function(a,b){a= +this.words=a||[];this.sigBytes=b!=m?b:4*a.length},toString:function(a){return(a||e).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;this.clamp();if(d%4)for(var f=0;f>>2]|=(c[f>>>2]>>>24-8*(f%4)&255)<<24-8*((d+f)%4);else if(65535>>2]=c[f>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<32-8*(b%4);a.length=i.ceil(b/4)},clone:function(){var a= +n.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c>>2]>>>24-8*(d%4)&255;c.push((f>>>4).toString(16));c.push((f&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return o.create(c,b/2)}},g=q.Latin1={stringify:function(a){for(var b= +a.words,a=a.sigBytes,c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return o.create(c,b)}},j=q.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},k=h.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=o.create(); +this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,f=this.blockSize,e=d/(4*f),e=a?i.ceil(e):i.max((e|0)-this._minBufferSize,0),a=e*f,d=i.min(4*a,d);if(a){for(var g=0;gb;b++){if(16>b)h[b]=o[i+b]|0;else{var c=h[b-3]^h[b-8]^h[b-14]^h[b-16];h[b]=c<<1|c>>>31}c=(g<<5|g>>>27)+a+h[b];c=20>b?c+((j&k|~j&l)+1518500249):40>b?c+((j^k^l)+1859775393):60>b?c+((j&k|j&l|k&l)-1894007588):c+((j^k^l)- +899497514);a=l;l=k;k=j<<30|j>>>2;j=g;g=c}e[0]=e[0]+g|0;e[1]=e[1]+j|0;e[2]=e[2]+k|0;e[3]=e[3]+l|0;e[4]=e[4]+a|0},_doFinalize:function(){var i=this._data,h=i.words,e=8*this._nDataBytes,g=8*i.sigBytes;h[g>>>5]|=128<<24-g%32;h[(g+64>>>9<<4)+15]=e;i.sigBytes=4*h.length;this._process()}});i.SHA1=m._createHelper(n);i.HmacSHA1=m._createHmacHelper(n)})(); + +/* +CryptoJS v3.0.2 +code.google.com/p/crypto-js +(c) 2009-2012 by Jeff Mott. All rights reserved. +code.google.com/p/crypto-js/wiki/License +*/ +(function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + + /** + * Base64 encoding strategy. + */ + var Base64 = C_enc.Base64 = { + /** + * Converts a word array to a Base64 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Base64 string. + * + * @static + * + * @example + * + * var base64String = CryptoJS.enc.Base64.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + var map = this._map; + + // Clamp excess bits + wordArray.clamp(); + + // Convert + var base64Chars = []; + for (var i = 0; i < sigBytes; i += 3) { + var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; + var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; + + var triplet = (byte1 << 16) | (byte2 << 8) | byte3; + + for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); + } + } + + // Add padding + var paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } + + return base64Chars.join(''); + }, + + /** + * Converts a Base64 string to a word array. + * + * @param {string} base64Str The Base64 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Base64.parse(base64String); + */ + parse: function (base64Str) { + // Ignore whitespaces + base64Str = base64Str.replace(/\s/g, ''); + + // Shortcuts + var base64StrLength = base64Str.length; + var map = this._map; + + // Ignore padding + var paddingChar = map.charAt(64); + if (paddingChar) { + var paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex != -1) { + base64StrLength = paddingIndex; + } + } + + // Convert + var words = []; + var nBytes = 0; + for (var i = 0; i < base64StrLength; i++) { + if (i % 4) { + var bitsHigh = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); + var bitsLow = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); + words[nBytes >>> 2] |= (bitsHigh | bitsLow) << (24 - (nBytes % 4) * 8); + nBytes++; + } + } + + return WordArray.create(words, nBytes); + }, + + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' + }; +}()); + /*! Copyright 2012 Rustici Software @@ -131,10 +259,11 @@ var TinCan; @param {String} msg Message to output */ log: function (msg, src) { + /* globals console */ if (TinCan.DEBUG && typeof console !== "undefined" && console.log) { src = src || this.LOG_SRC || "TinCan"; - console.log("TinCan." + src + ': ' + msg); + console.log("TinCan." + src + ": " + msg); } }, @@ -199,7 +328,6 @@ var TinCan; qsParams = TinCan.Utils.parseURL(url).params, lrsProps = ["endpoint", "auth"], lrsCfg = {}, - activityCfg, contextCfg, extended = null ; @@ -225,10 +353,8 @@ var TinCan; } if ( - qsParams.hasOwnProperty("activity_platform") - || - qsParams.hasOwnProperty("registration") - || + qsParams.hasOwnProperty("activity_platform") || + qsParams.hasOwnProperty("registration") || qsParams.hasOwnProperty("grouping") ) { contextCfg = {}; @@ -519,7 +645,7 @@ var TinCan; { actor: actor, verb: { - id: "http://adlnet.gov/expapi/verbs/voided" + id: "http://adlnet.gov/expapi/verbs/voided" }, target: { objectType: "StatementRef", @@ -1249,12 +1375,13 @@ var TinCan; ]; }; - /*global exports*/ + /*global module*/ // Support the CommonJS method for exporting our single global if (typeof module === "object") { module.exports = TinCan; } }()); + /* Copyright 2012 Rustici Software @@ -1298,11 +1425,11 @@ TinCan client library Dual licensed under the MIT and GPL licenses. */ getUUID: function () { - /*jslint bitwise: true eqeq: true */ - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace( + /*jslint bitwise: true, eqeq: true */ + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace( /[xy]/g, function (c) { - var r = Math.random() * 16|0, v = c == 'x' ? r : (r&0x3|0x8); + var r = Math.random() * 16|0, v = c == "x" ? r : (r&0x3|0x8); return v.toString(16); } ); @@ -1328,20 +1455,20 @@ TinCan client library tempVal = val.toString(); while (val < padder && padder > 1) { - tempVal = '0' + tempVal; + tempVal = "0" + tempVal; padder = padder / 10; } return tempVal; } - return d.getUTCFullYear() + '-' - + pad(d.getUTCMonth() + 1) + '-' - + pad(d.getUTCDate()) + 'T' - + pad(d.getUTCHours()) + ':' - + pad(d.getUTCMinutes()) + ':' - + pad(d.getUTCSeconds()) + '.' - + pad(d.getUTCMilliseconds(), 3) + 'Z'; + return d.getUTCFullYear() + "-" + + pad(d.getUTCMonth() + 1) + "-" + + pad(d.getUTCDate()) + "T" + + pad(d.getUTCHours()) + ":" + + pad(d.getUTCMinutes()) + ":" + + pad(d.getUTCSeconds()) + "." + + pad(d.getUTCMilliseconds(), 3) + "Z"; }, /** @@ -1408,16 +1535,16 @@ TinCan client library @private */ parseURL: function (url) { - var parts = String(url).split('?'), + var parts = String(url).split("?"), pairs, pair, i, params = {} ; if (parts.length === 2) { - pairs = parts[1].split('&'); + pairs = parts[1].split("&"); for (i = 0; i < pairs.length; i += 1) { - pair = pairs[i].split('='); + pair = pairs[i].split("="); if (pair.length === 2 && pair[0]) { params[pair[0]] = decodeURIComponent(pair[1]); } @@ -1462,6 +1589,7 @@ TinCan client library } }; }()); + /* Copyright 2012-2013 Rustici Software @@ -2195,7 +2323,7 @@ TinCan client library //or endpoint (though only the former is allowed in the spec) serverRoot = TinCan.Utils.getServerRoot(this.endpoint); if (parsedURL.path.indexOf("/statements") === 0){ - parsedURL.path = this.endpoint.replace(serverRoot, '') + parsedURL.path; + parsedURL.path = this.endpoint.replace(serverRoot, "") + parsedURL.path; this.log("converting non-standard more URL to " + parsedURL.path); } @@ -2390,9 +2518,7 @@ TinCan client library saveState: function (key, val, cfg) { this.log("saveState"); var requestParams, - requestCfg, - requestResult - ; + requestCfg; if (typeof cfg.contentType === "undefined") { cfg.contentType = "application/octet-stream"; @@ -2900,6 +3026,7 @@ TinCan client library } }; }()); + /* Copyright 2012 Rustici Software @@ -2950,7 +3077,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'AgentAccount', + LOG_SRC: "AgentAccount", /** @method log @@ -2967,9 +3094,7 @@ TinCan client library directProps = [ "name", "homePage" - ], - val - ; + ]; cfg = cfg || {}; @@ -2988,7 +3113,7 @@ TinCan client library } }, - toString: function (lang) { + toString: function () { this.log("toString"); var result = ""; @@ -3038,6 +3163,7 @@ TinCan client library return new AgentAccount(_acct); }; }()); + /* Copyright 2012 Rustici Software @@ -3242,7 +3368,7 @@ TinCan client library } }, - toString: function (lang) { + toString: function () { this.log("toString"); if (this.name !== null) { @@ -3332,6 +3458,7 @@ TinCan client library return new Agent(_agent); }; }()); + /* Copyright 2012 Rustici Software @@ -3493,6 +3620,7 @@ TinCan client library return new Group(_group); }; }()); + /* Copyright 2012 Rustici Software @@ -3681,6 +3809,7 @@ TinCan client library return new Verb(_verb); }; }()); + /* Copyright 2012 Rustici Software @@ -3755,7 +3884,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Result', + LOG_SRC: "Result", /** @method log @@ -3818,8 +3947,7 @@ TinCan client library optionalObjProps = [ "score" ], - i, - prop; + i; version = version || TinCan.versions()[0]; @@ -3860,6 +3988,7 @@ TinCan client library return new Result(_result); }; }()); + /* Copyright 2012 Rustici Software @@ -3922,7 +4051,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Score', + LOG_SRC: "Score", /** @method log @@ -3967,8 +4096,7 @@ TinCan client library "min", "max" ], - i, - prop; + i; version = version || TinCan.versions()[0]; @@ -3994,6 +4122,7 @@ TinCan client library return new Score(_score); }; }()); + /* Copyright 2012 Rustici Software @@ -4044,7 +4173,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'InteractionComponent', + LOG_SRC: "InteractionComponent", /** @method log @@ -4120,6 +4249,7 @@ TinCan client library return new InteractionComponent(_ic); }; }()); + /* Copyright 2012 Rustici Software @@ -4442,6 +4572,7 @@ TinCan client library return new ActivityDefinition(_definition); }; }()); + /* Copyright 2012 Rustici Software @@ -4499,7 +4630,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Activity', + LOG_SRC: "Activity", /** @method log @@ -4591,6 +4722,7 @@ TinCan client library return new Activity(_activity); }; }()); + /* Copyright 2013 Rustici Software @@ -4653,7 +4785,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'ContextActivities', + LOG_SRC: "ContextActivities", /** @method log @@ -4713,7 +4845,7 @@ TinCan client library } if (! (val instanceof TinCan.Activity)) { - val = typeof val === 'string' ? { id: val } : val; + val = typeof val === "string" ? { id: val } : val; val = new TinCan.Activity (val); } @@ -4735,8 +4867,7 @@ TinCan client library "other" ], i, - j, - prop; + j; version = version || TinCan.versions()[0]; @@ -4789,6 +4920,7 @@ TinCan client library return new ContextActivities(_contextActivities); }; }()); + /* Copyright 2012 Rustici Software @@ -4881,7 +5013,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Context', + LOG_SRC: "Context", /** @method log @@ -4969,8 +5101,7 @@ TinCan client library "contextActivities", "statement" ], - i, - prop; + i; version = version || TinCan.versions()[0]; @@ -5001,6 +5132,7 @@ TinCan client library return new Context(_context); }; }()); + /* Copyright 2012 Rustici Software @@ -5071,9 +5203,7 @@ TinCan client library var i, directProps = [ "id" - ], - val - ; + ]; cfg = cfg || {}; @@ -5088,7 +5218,7 @@ TinCan client library @method toString @return {String} String representation of the statement */ - toString: function (lang) { + toString: function () { this.log("toString"); return this.id; }, @@ -5124,6 +5254,7 @@ TinCan client library return new StatementRef(_stRef); }; }()); + /* Copyright 2012 Rustici Software @@ -5229,9 +5360,7 @@ TinCan client library var i, directProps = [ "timestamp" - ], - val - ; + ]; cfg = cfg || {}; @@ -5266,14 +5395,10 @@ TinCan client library } } if (cfg.hasOwnProperty("target")) { - if (cfg.target instanceof TinCan.Activity - || - cfg.target instanceof TinCan.Agent - || - cfg.target instanceof TinCan.Group - || - cfg.target instanceof TinCan.SubStatement - || + if (cfg.target instanceof TinCan.Activity || + cfg.target instanceof TinCan.Agent || + cfg.target instanceof TinCan.Group || + cfg.target instanceof TinCan.SubStatement || cfg.target instanceof TinCan.StatementRef ) { this.target = cfg.target; @@ -5383,6 +5508,7 @@ TinCan client library return new SubStatement(_subSt); }; }()); + /* Copyright 2012-3 Rustici Software @@ -5542,7 +5668,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'Statement', + LOG_SRC: "Statement", /** @method log @@ -5564,9 +5690,7 @@ TinCan client library "version", "inProgress", "voided" - ], - val - ; + ]; cfg = cfg || {}; @@ -5624,14 +5748,10 @@ TinCan client library } } if (cfg.hasOwnProperty("target")) { - if (cfg.target instanceof TinCan.Activity - || - cfg.target instanceof TinCan.Agent - || - cfg.target instanceof TinCan.Group - || - cfg.target instanceof TinCan.SubStatement - || + if (cfg.target instanceof TinCan.Activity || + cfg.target instanceof TinCan.Agent || + cfg.target instanceof TinCan.Group || + cfg.target instanceof TinCan.SubStatement || cfg.target instanceof TinCan.StatementRef ) { this.target = cfg.target; @@ -5770,6 +5890,7 @@ TinCan client library return new Statement(_st); }; }()); + /* Copyright 2012 Rustici Software @@ -5824,7 +5945,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'StatementsResult', + LOG_SRC: "StatementsResult", /** @method log @@ -5891,6 +6012,7 @@ TinCan client library return new StatementsResult (_result); }; }()); + /* Copyright 2012 Rustici Software @@ -5959,7 +6081,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'State', + LOG_SRC: "State", /** @method log @@ -5978,9 +6100,7 @@ TinCan client library "contents", "etag", "contentType" - ], - val - ; + ]; cfg = cfg || {}; @@ -6006,6 +6126,7 @@ TinCan client library return new State(_state); }; }()); + /* Copyright 2012 Rustici Software @@ -6083,7 +6204,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'ActivityProfile', + LOG_SRC: "ActivityProfile", /** @method log @@ -6102,9 +6223,7 @@ TinCan client library "contents", "etag", "contentType" - ], - val - ; + ]; cfg = cfg || {}; @@ -6139,6 +6258,7 @@ TinCan client library return new ActivityProfile(_state); }; }()); + /* Copyright 2013 Rustici Software @@ -6216,7 +6336,7 @@ TinCan client library /** @property LOG_SRC */ - LOG_SRC: 'AgentProfile', + LOG_SRC: "AgentProfile", /** @method log @@ -6235,9 +6355,7 @@ TinCan client library "contents", "etag", "contentType" - ], - val - ; + ]; cfg = cfg || {}; @@ -6272,6 +6390,7 @@ TinCan client library return new AgentProfile(_state); }; }()); + /* Copyright 2012-2013 Rustici Software @@ -6295,6 +6414,7 @@ TinCan client library @submodule TinCan.Environment.Browser **/ (function () { + /* globals window, XMLHttpRequest, XDomainRequest */ "use strict"; var LOG_SRC = "Environment.Browser", nativeRequest, @@ -6638,7 +6758,8 @@ TinCan client library // capabilities // TinCan.LRS.prototype._initByEnvironment = function (cfg) { - /*jslint regexp: true */ + /*jslint regexp: true, laxbreak: true */ + /* globals location */ log("_initByEnvironment", LOG_SRC); var urlParts, schemeMatches, @@ -6748,129 +6869,3 @@ TinCan client library xhr.send(null); }; }()); -/* -CryptoJS v3.0.2 -code.google.com/p/crypto-js -(c) 2009-2012 by Jeff Mott. All rights reserved. -code.google.com/p/crypto-js/wiki/License -*/ -var CryptoJS=CryptoJS||function(i,m){var p={},h=p.lib={},n=h.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;b&&c.mixIn(b);c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),o=h.WordArray=n.extend({init:function(a,b){a= -this.words=a||[];this.sigBytes=b!=m?b:4*a.length},toString:function(a){return(a||e).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;this.clamp();if(d%4)for(var f=0;f>>2]|=(c[f>>>2]>>>24-8*(f%4)&255)<<24-8*((d+f)%4);else if(65535>>2]=c[f>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<32-8*(b%4);a.length=i.ceil(b/4)},clone:function(){var a= -n.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c>>2]>>>24-8*(d%4)&255;c.push((f>>>4).toString(16));c.push((f&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return o.create(c,b/2)}},g=q.Latin1={stringify:function(a){for(var b= -a.words,a=a.sigBytes,c=[],d=0;d>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return o.create(c,b)}},j=q.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},k=h.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=o.create(); -this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,f=this.blockSize,e=d/(4*f),e=a?i.ceil(e):i.max((e|0)-this._minBufferSize,0),a=e*f,d=i.min(4*a,d);if(a){for(var g=0;gb;b++){if(16>b)h[b]=o[i+b]|0;else{var c=h[b-3]^h[b-8]^h[b-14]^h[b-16];h[b]=c<<1|c>>>31}c=(g<<5|g>>>27)+a+h[b];c=20>b?c+((j&k|~j&l)+1518500249):40>b?c+((j^k^l)+1859775393):60>b?c+((j&k|j&l|k&l)-1894007588):c+((j^k^l)- -899497514);a=l;l=k;k=j<<30|j>>>2;j=g;g=c}e[0]=e[0]+g|0;e[1]=e[1]+j|0;e[2]=e[2]+k|0;e[3]=e[3]+l|0;e[4]=e[4]+a|0},_doFinalize:function(){var i=this._data,h=i.words,e=8*this._nDataBytes,g=8*i.sigBytes;h[g>>>5]|=128<<24-g%32;h[(g+64>>>9<<4)+15]=e;i.sigBytes=4*h.length;this._process()}});i.SHA1=m._createHelper(n);i.HmacSHA1=m._createHmacHelper(n)})(); -/* -CryptoJS v3.0.2 -code.google.com/p/crypto-js -(c) 2009-2012 by Jeff Mott. All rights reserved. -code.google.com/p/crypto-js/wiki/License -*/ -(function () { - // Shortcuts - var C = CryptoJS; - var C_lib = C.lib; - var WordArray = C_lib.WordArray; - var C_enc = C.enc; - - /** - * Base64 encoding strategy. - */ - var Base64 = C_enc.Base64 = { - /** - * Converts a word array to a Base64 string. - * - * @param {WordArray} wordArray The word array. - * - * @return {string} The Base64 string. - * - * @static - * - * @example - * - * var base64String = CryptoJS.enc.Base64.stringify(wordArray); - */ - stringify: function (wordArray) { - // Shortcuts - var words = wordArray.words; - var sigBytes = wordArray.sigBytes; - var map = this._map; - - // Clamp excess bits - wordArray.clamp(); - - // Convert - var base64Chars = []; - for (var i = 0; i < sigBytes; i += 3) { - var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; - var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; - var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; - - var triplet = (byte1 << 16) | (byte2 << 8) | byte3; - - for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { - base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); - } - } - - // Add padding - var paddingChar = map.charAt(64); - if (paddingChar) { - while (base64Chars.length % 4) { - base64Chars.push(paddingChar); - } - } - - return base64Chars.join(''); - }, - - /** - * Converts a Base64 string to a word array. - * - * @param {string} base64Str The Base64 string. - * - * @return {WordArray} The word array. - * - * @static - * - * @example - * - * var wordArray = CryptoJS.enc.Base64.parse(base64String); - */ - parse: function (base64Str) { - // Ignore whitespaces - base64Str = base64Str.replace(/\s/g, ''); - - // Shortcuts - var base64StrLength = base64Str.length; - var map = this._map; - - // Ignore padding - var paddingChar = map.charAt(64); - if (paddingChar) { - var paddingIndex = base64Str.indexOf(paddingChar); - if (paddingIndex != -1) { - base64StrLength = paddingIndex; - } - } - - // Convert - var words = []; - var nBytes = 0; - for (var i = 0; i < base64StrLength; i++) { - if (i % 4) { - var bitsHigh = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2); - var bitsLow = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2); - words[nBytes >>> 2] |= (bitsHigh | bitsLow) << (24 - (nBytes % 4) * 8); - nBytes++; - } - } - - return WordArray.create(words, nBytes); - }, - - _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' - }; -}()); From 3123e1642e16d8ddbe11a8c3a8be122adb88ff87 Mon Sep 17 00:00:00 2001 From: "Brian J. Miller" Date: Fri, 28 Mar 2014 18:06:49 -0500 Subject: [PATCH 3/3] Update README --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a7cfe89..be7b411 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,13 @@ -A JavaScript library for talking Tin Can to the world. +A JavaScript library for implementing Tin Can API. [![Build Status](https://travis-ci.org/RusticiSoftware/TinCanJS.png)](https://travis-ci.org/RusticiSoftware/TinCanJS) +For hosted API documentation, basic usage instructions, supported version listing, etc. visit the main project website at: + +http://rusticisoftware.github.io/TinCanJS/ + +For more information about the Tin Can API visit: + http://tincanapi.com/ Browser Usage