-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="referrer" content="origin" /> | ||
<script> | ||
/* jshint ignore:start */ | ||
// jscs:disable | ||
// https://gist.github.com/982883 | ||
var uuid = function(a) { | ||
return a // if the placeholder was passed, return | ||
? ( // a random number from 0 to 15 | ||
a ^ // unless b is 8, | ||
Math.random() // in which case | ||
* 16 // a random number from | ||
>> a/4 // 8 to 11 | ||
).toString(16) // in hexadecimal | ||
: ( // or otherwise a concatenated string: | ||
[1e7] + // 10000000 + | ||
-1e3 + // -1000 + | ||
-4e3 + // -4000 + | ||
-8e3 + // -80000000 + | ||
-1e11 // -100000000000, | ||
).replace( // replacing | ||
/[018]/g, // zeroes, ones, and eights with | ||
uuid // random hex digits | ||
); | ||
}; | ||
|
||
window.frameHash = window.location.hash.replace(/^#/, ''); | ||
|
||
var postToParent = function(message) { | ||
if (window.parent.postMessage != null) { | ||
window.parent.postMessage(message, '*'); | ||
} | ||
}; | ||
|
||
var onDidReceiveMessage = function(e) { | ||
if (e.data.id === frameHash) { | ||
var xhr = new XMLHttpRequest(), | ||
now = new Date(), | ||
data = { | ||
messageId: uuid(), | ||
sentAt: now.toISOString(), | ||
batch: [ { | ||
event: e.data.event, | ||
properties: e.data.properties, | ||
type: 'track', | ||
messageId: uuid(), | ||
timestamp: now.toISOString(), | ||
context: { | ||
ip: '0.0.0.0', | ||
page: { | ||
path: '/', | ||
referrer: '', | ||
search: '', | ||
title: '', | ||
url: 'http://' | ||
} | ||
}, | ||
integrations: {}, | ||
userId: e.data.aid | ||
} ] | ||
}; | ||
|
||
xhr.onreadystatechange = function() { | ||
if (xhr.readyState === 4) { | ||
postToParent({ | ||
id: frameHash, | ||
message: 'xhr sent' | ||
}); | ||
window.onDidReceiveMessage = null; | ||
} | ||
}; | ||
|
||
xhr.open('POST', 'https://metrics.articulate.com/v1/import'); | ||
xhr.setRequestHeader('Content-Type', 'application/json'); | ||
xhr.send(JSON.stringify(data)); | ||
} | ||
}; | ||
|
||
if ('onmessage' in window) { | ||
window.addEventListener('message', onDidReceiveMessage, false); | ||
} else { | ||
// coming from flash, we will use older JS since we can expect some older IE versions | ||
var validProps = [ | ||
'os', 'browser', 'playerVersion', 'playerType', 'lmsPresent', 'tinCanPresent', | ||
'aoSupport', 'publishSource', 'protocol', 'productChannel', 'cid', 'screenResolution', | ||
'pixelRatio' | ||
]; | ||
var aid, | ||
props = window.location.search.replace(/^\?/, '').split('&'), | ||
config = {}; | ||
|
||
for (var i = 0, ii = props.length, currProp; i < ii; i++) { | ||
currProp = props[i].split('='); | ||
if (validProps.indexOf(currProp[0]) > -1 && currProp.length === 2) { | ||
config[currProp[0]] = currProp[1]; | ||
} else if (currProp[0] === 'aid') { | ||
aid = currProp[1]; | ||
} | ||
} | ||
|
||
window.onDidReceiveMessage({ | ||
data: { | ||
id: frameHash, | ||
event: 'player_course_load', | ||
properties: config, | ||
aid: aid | ||
} | ||
}) | ||
|
||
} | ||
/* jshint ignore:end */ | ||
// jscs:enable | ||
</script> | ||
</head> | ||
<body> | ||
</body> | ||
<script> | ||
postToParent({ | ||
id: window.frameHash, | ||
message: 'loaded' | ||
}); | ||
</script> | ||
</html> |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="utf-8"?><meta xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><project id="6DwFbYCM9o7" courseid="6UQyNk6gytz" thumburl="story_content/thumbnail.jpg" title="Formatting-thesis" datepublished="2024-05-07T21:51:44" version="1.0.0.0" flashdata="story_content/data.swf" html5data="mobile/data.json" mobiledata="mobile/data.gz" enabledownload="false" duration="About 1 minute" totalaudio="0" totalvideo="0"><description /><keywords /><slidemeta moniker="slide" monikerplural="slides" viewslides="14" slidecountdescription="14 slides" /><author name="Ameeta Prakash" email="" website="" /><application name="Articulate Storyline" version="3.78.30747.0" xmlversion="4.0" /></project></meta> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,261 @@ | ||
(function () { | ||
function getParams(url) { | ||
const querystring = url.split('?')[1] | ||
if (!querystring) { | ||
return {} | ||
} | ||
|
||
return querystring.split('&').reduce(function (memo, param) { | ||
const tuple = param.split('=', 2) | ||
memo[tuple[0]] = decodeURIComponent(tuple[1].replace(/\+/g, ' ')) | ||
|
||
return memo | ||
}, {}) | ||
} | ||
|
||
function buildFlashVars(params) { | ||
const flashParams = { | ||
vEnableOne: 'true', | ||
vInterfaceObject: 'vInterfaceObject', | ||
vRestoreStateData: params.state | ||
} | ||
|
||
return Object.keys(flashParams).reduce(function (memo, key) { | ||
if (flashParams[key]) { | ||
memo.push(key.concat('=', flashParams[key])) | ||
} | ||
|
||
return memo | ||
}, []).join('&') | ||
} | ||
|
||
const params = getParams(window.location.href) | ||
const debug = !!params.debug | ||
|
||
const handlers = { | ||
'frame:loaded': frameLoaded, | ||
'slide:capture': captureSlide, | ||
'player:pause': triggerPause, | ||
'player:play': triggerPlay, | ||
'player:focus': focusPlayer, | ||
'preview:navigate': jumpToContext, | ||
'preview:changeset': livePreview | ||
} | ||
|
||
if (Object.prototype.hasOwnProperty.call(params, 'wmode')) { | ||
window.g_strWMode = params['wmode'] | ||
} | ||
|
||
window.autoSpider = true | ||
window.g_strFlashVars = buildFlashVars(params) | ||
window.vEnableOne = true | ||
window.addEventListener('message', handleMessage) | ||
|
||
window.vRestoreStateData = params.state | ||
|
||
window.vInterfaceObject = { | ||
isRise: !!params.rise, | ||
OnSlideStarted: function (id) { | ||
sendParentMessage({ | ||
type: 'slide:change', | ||
data: id | ||
}) | ||
}, | ||
OnSlideTransition: function (id, duration) { | ||
sendParentMessage({ | ||
type: 'slide:transition', | ||
data: { | ||
id: id, | ||
duration: duration | ||
} | ||
}) | ||
}, | ||
OnPlayButtonShown: function () { | ||
sendParentMessage({ | ||
type: 'playButton:shown' | ||
}) | ||
}, | ||
OnEnterFullscreen: function () { | ||
sendParentMessage({ | ||
type: 'fullscreen:enter', | ||
windowName: window.name | ||
}) | ||
}, | ||
OnExitFullscreen: function () { | ||
sendParentMessage({ | ||
type: 'fullscreen:exit', | ||
windowName: window.name | ||
}) | ||
}, | ||
OnPlayerClicked: function () { | ||
sendParentMessage({ | ||
type: 'player:click' | ||
}) | ||
}, | ||
LmsUpdate: function (data) { | ||
sendParentMessage({ | ||
type: 'course:update', | ||
payload: data, | ||
windowName: window.name | ||
}) | ||
} | ||
} | ||
|
||
let playerTimeupdateWaiting = false | ||
|
||
function throttledPlayerTimeupdate() { | ||
if (!playerTimeupdateWaiting) { | ||
playerTimeupdateWaiting = true | ||
|
||
sendParentMessage({ | ||
type: 'player:timeupdate' | ||
}) | ||
|
||
setTimeout(() => { | ||
playerTimeupdateWaiting = false | ||
}, 2000) | ||
} | ||
} | ||
|
||
function frameLoaded() { | ||
const videoNodes = document.querySelectorAll('video') | ||
|
||
videoNodes.forEach(video => | ||
video.addEventListener('timeupdate', throttledPlayerTimeupdate) | ||
) | ||
} | ||
|
||
function captureSlide(data) { | ||
const player = window.GetPlayer() | ||
if (typeof player.CaptureSlideImage !== 'function') { | ||
log('player-interface.js: player.CaptureSlideImage is not a function! returning early') | ||
|
||
return | ||
} | ||
sendParentMessage({ | ||
type: 'slide:capture', | ||
data: { | ||
commentId: data.commentId, | ||
snapshot: player.CaptureSlideImage() | ||
} | ||
}) | ||
} | ||
|
||
function triggerPause() { | ||
const player = window.GetPlayer() | ||
if (typeof player.TriggerPause !== 'function') { | ||
log('player-interface.js: player.TriggerPause is not a function! returning early') | ||
|
||
return | ||
} | ||
player.TriggerPause() | ||
} | ||
|
||
function jumpToContext(data) { | ||
const player = window.GetPlayer() | ||
if (typeof player.JumpToLocation !== 'function') { | ||
log('player-interface.js: player.JumpToLocation is not a function! returning early') | ||
|
||
return | ||
} | ||
player.JumpToLocation(data.path) | ||
} | ||
|
||
function triggerPlay() { | ||
const player = window.GetPlayer() | ||
if (typeof player.TriggerPlay !== 'function') { | ||
log('player-interface.js: player.TriggerPlay is not a function! returning early') | ||
|
||
return | ||
} | ||
player.TriggerPlay() | ||
} | ||
|
||
function focusPlayer() { | ||
window.focus() | ||
} | ||
|
||
function livePreview(data) { | ||
const player = window.GetPlayer() | ||
if (typeof player.UpdateSegmentPartText !== 'function') { | ||
log('player-interface.js: player.UpdateSegmentPartText is not a function! returning early') | ||
|
||
return | ||
} | ||
data.forEach(change => { | ||
if (change?.updatedXlifTarget) { | ||
return player.UpdateSegmentPartText(change?.path[1], change?.updatedXlifTarget) | ||
} | ||
|
||
player.UpdateTextLibItem(change?.path, change?.updatedTarget) | ||
}) | ||
} | ||
|
||
function handleMessage(e) { | ||
const event = e.data | ||
log('player-interface.js: received post message from parent window', event) | ||
if (typeof event !== 'object') { | ||
return | ||
} | ||
const handler = handlers[event.type] | ||
if (!handler) { | ||
return | ||
} | ||
try { | ||
handler(event.data) | ||
} catch (err) { | ||
log('player-interface.js: error executing ' + event.type + ' message handler', err) | ||
window.playerInterfaceError = err | ||
sendParentMessage({ | ||
type: 'error', | ||
data: { | ||
eventType: event.type, | ||
eventData: event.data, | ||
errorJson: stringifyError(err), | ||
playerVersion: (window.globals && window.globals.playerVersion) || 'unknown' | ||
} | ||
}) | ||
} | ||
} | ||
|
||
function sendParentMessage(message) { | ||
log('player-interface.js: sending post message to parent window', message) | ||
window.parent.postMessage(message, '*') | ||
} | ||
|
||
function log(...args) { | ||
if (!debug) { | ||
return | ||
} | ||
console.log(args) | ||
} | ||
|
||
function stringifyError(err) { | ||
const jsonify = function (obj) { | ||
return JSON.stringify(obj, Object.getOwnPropertyNames(obj)) | ||
} | ||
|
||
const safeToString = function (obj, fallback) { | ||
return typeof obj.toString === 'function' ? obj.toString() || fallback : fallback | ||
} | ||
|
||
let json = jsonify(err) | ||
|
||
if (json !== '{}') { | ||
const rehydrated = JSON.parse(json) | ||
|
||
if (!rehydrated.message) { | ||
rehydrated.message = err.message || safeToString(err, '[failed to obtain error message]') | ||
json = jsonify(rehydrated) | ||
} | ||
|
||
return json | ||
} | ||
|
||
const pseudoError = { | ||
message: safeToString(err, '[unable to convert error to json/string]') | ||
} | ||
|
||
return jsonify(pseudoError) | ||
} | ||
})() |