diff --git a/docs.it4i/anselm-cluster-documentation/accessing-the-cluster/shell-and-data-access.md b/docs.it4i/anselm-cluster-documentation/accessing-the-cluster/shell-and-data-access.md index 000774923f9ff9d8a43123d3424bb16388e62cfe..27754e1fc4e07d0cbe235ffb32feb637ae0f22d3 100644 --- a/docs.it4i/anselm-cluster-documentation/accessing-the-cluster/shell-and-data-access.md +++ b/docs.it4i/anselm-cluster-documentation/accessing-the-cluster/shell-and-data-access.md @@ -35,6 +35,9 @@ local $ chmod 600 /path/to/id_rsa On **Windows**, use [PuTTY ssh client](../../../get-started-with-it4innovations/accessing-the-clusters/shell-access-and-data-transfer/putty/putty/). +### TTY Player - Access to the Salomon cluster +<tty-player play controls src=/src/login.ttyrec npt:32></tty-player> + After logging in, you will see the command prompt: ```bash diff --git a/docs.it4i/css/tty-player.css b/docs.it4i/css/tty-player.css new file mode 100644 index 0000000000000000000000000000000000000000..0f4e0b77a364642f6415ee0e4deb2bb15d9080ca --- /dev/null +++ b/docs.it4i/css/tty-player.css @@ -0,0 +1,218 @@ +.terminal { + font-family: monospace, monospace; + cursor: text; + line-height: initial; +} + +tty-player { + border: 2px solid #285577; + border-top: 1px solid #4c7899; +} + +tty-player .title { + background: #285577; + border-bottom: 1px solid #4c7899; + color: #fff; + font-family: sans-serif; + font-weight: bold; + padding: 0.2em; + line-height: 1; + height: 1em; + cursor: default; +} + +tty-player menu { + display: none; +} + +tty-player { + display: inline-block; + position: relative; +} + +tty-player:not([controls]) tty-player-controls { + display: none; +} + +tty-player-poster { + /* XXX: <video> has an overlay with play button if [controls] over the poster *image*, but here we have an overlay with play button regardless. Perhaps specifying a poster currentTime or script might work? */ + background: rgba(53, 47, 47, 0.5); + opacity: 0.5; + transition: opacity 0.2s linear; + background-repeat: no-repeat; + background-position: center; + background-image: url("data:image/svg+xml,%3C?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3E%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='66'%20height='66'%3E%3Cfilter%20id='f'%3E%3CfeColorMatrix%20type='matrix'%20values='0%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%200%20.5%200'/%3E%3CfeGaussianBlur%20result='r'%20stdDeviation='2'/%3E%3CfeComposite%20in='SourceGraphic'%20in2='r'/%3E%3C/filter%3E%3Cpath%20fill='%23ddd'%20stroke='%23ccc'%20stroke-width='1'%20d='M33,5.5A27.5,27.5%200%200%200%205.5,33%2027.5,27.5%200%200%200%2033,60.5%2027.5,27.5%200%200%200%2060.5,33%2027.5,27.5%200%200%200%2033,5.5Zm-9.5,13%2025,14.5-25,14.5%200,-29z'%20filter='url(%23f)'/%3E%3C/svg%3E"); + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; +} + +tty-player[controls] tty-player-poster { + bottom: 28px; +} + +tty-player:hover tty-player-poster { + opacity: 1; +} + +tty-player-controls { + position: absolute; + left: 0; + right: 0; + bottom: 0; + background: rgba(53, 47, 47, 0.5); + opacity: 0; + display: flex; + flex-direction: row; + transition: opacity 0.2s linear; + cursor: default; +} + +/* Browsers tend to show the controls when a <video> ends, too; I, however, am not doing this for now at least as the controls will overlap with what is often the most important part of the terminal (the bottom). For this reason, I haven’t hooked up any support for that either, only showing controls persistently when the poster is up. */ +tty-player-controls.poster, +tty-player:hover tty-player-controls { + opacity: 1; +} + +tty-player-controls input[type=range], tty-player-controls button { + margin: 0; + padding: 0; + border: none; + background: none; + font: inherit; + line-height: inherit; + -moz-appearance: none; + -webkit-appearance: none; +} + +tty-player-controls button { + padding: 0; + background: none; + opacity: 0.75; + flex: 0 1 auto; + line-height: 1; + width: 28px; + height: 28px; +} + +tty-player-controls button:hover { + color: #777; + opacity: 1; +} + +tty-player-controls input[type=range] { + flex: 1; + height: 8px; + margin: 10px 5px; +} + +tty-player-controls button { + background-repeat: no-repeat; + background-position: center; +} + +tty-player-controls button.play { + background-image: url("data:image/svg+xml,%3C?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3E%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='14'%20height='16'%3E%3Cpath%20fill='%23ccc'%20d='M0,0%200,16%2014,8Z'/%3E%3C/svg%3E"); +} + +tty-player-controls button.pause { + background-image: url("data:image/svg+xml,%3C?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3E%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='14'%20height='16'%3E%3Cpath%20fill='%23ccc'%20d='M1,0L1,16L5,16L5,0L0,0zM9,0L9,16L13,16L13,0L9,0z'/%3E%3C/svg%3E"); +} + +tty-player-controls input[type=range]:focus { + box-shadow: none; + outline: none; +} + +tty-player-controls input[type=range]::-moz-range-track, +tty-player-controls input[type=range]::-moz-range-thumb, +tty-player-controls input[type=range]::-moz-range-progress { + border-radius: 4px; + height: 8px; +} + +tty-player-controls input[type=range]::-moz-range-track { + background: rgba(255, 255, 255, 0.5); +} + +tty-player-controls input[type=range]::-moz-range-thumb { + -moz-appearance: none; + width: 0; + background: transparent; + border: 0; + border-radius: 0; + box-shadow: 0; + position: relative; +} + +tty-player-controls input[type=range]::-moz-range-progress { + background: #fff; +} + +input[type=range] { + overflow: hidden; +} + +tty-player-controls input[type=range]::-webkit-slider-runnable-track { + -webkit-appearance: none; + height: 8px; + background: rgba(255, 255, 255, 0.5); + //border-radius: 4px; +} + +tty-player-controls input[type=range]::-webkit-slider-thumb:before { + position: absolute; + top: 0; + right: 50%; + left: -9999px; + background: #fff; + content: ''; + height: 8px; + pointer-events: none; +} + +tty-player-controls input[type=range]::-webkit-slider-thumb { + -webkit-appearance: none; + width: 0; + height: 0; + position: relative; +} + +/* I have not altered IE’s styles because I feel them already satisfactory */ + +tty-player-controls .current-time { + position: absolute; + color: #ddd; + background: #888; + font-family: sans-serif; + font-size: 12px; + display: block; + box-shadow: 0 1px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 1px rgba(255, 255, 255, 0.2); + padding: 0 5px; + line-height: 16px; + border-radius: 4px; + top: -7px; +} + +tty-player-controls .current-time::after { + content: ""; + position: absolute; + width: 8px; + height: 8px; + background: linear-gradient(-45deg, #888 50%, transparent 50%); + box-shadow: 1px 1px rgba(0, 0, 0, 0.5), 1px 1px 1px rgba(0, 0, 0, 0.5); + bottom: -3px; + left: 50%; + margin-left: -5px; + transform: rotate(45deg); +} + +tty-player-controls .duration { + font-family: sans-serif; + font-size: 12px; + color: #999; + line-height: 18px; + padding: 5px; +} diff --git a/docs.it4i/js/tty-player.js b/docs.it4i/js/tty-player.js new file mode 100644 index 0000000000000000000000000000000000000000..d84f06367e66e76fffabf50bdfad9030d8dd8f4d --- /dev/null +++ b/docs.it4i/js/tty-player.js @@ -0,0 +1,1716 @@ +// W069 is “['x'] is better written in dot notation”, but Closure Compiler wants ['x']. +// jshint -W069 +// jshint bitwise: false +// ==ClosureCompiler== +// @output_file_name tty-player.min.js +// @compilation_level ADVANCED_OPTIMIZATIONS +// ==/ClosureCompiler== +/* global MediaError, TimeRanges, Terminal, HTMLElement */ +;(function() { +"use strict"; + +var textDecoder = "TextDecoder" in window ? new TextDecoder() : null; +/// @param {Array<number>|Uint8Array} array +function decodeUTF8(array) { + if (array instanceof Array || !textDecoder) { + return decodeURIComponent(Array.prototype.map.call(array, function(ord) { + return "%" + ("0" + ord.toString(16)).substr(-2); + }).join("")); + } else { + return textDecoder.decode(array); + } +} + +/// parseDataURI("data:foo/bar;base64,MTIzNA==#foo") === "1234" +/// @param {string} uri +function parseDataURI(uri) { + // [whole uri, "base64" or undefined, data] + var chunks = /^data:([^,]*),([^#]+)/.exec(uri); + if (chunks === null) { + return null; + } + var data = decodeURIComponent(chunks[2]); + var mime = chunks[1].replace(/;base64$/, ""); + return [mime, mime === chunks[1] ? data : atob(data)]; +} + +/// @param {Array<number>|Uint8Array} array +function byteArrayToString(array) { + // String.fromCharCode.apply can for too large values overflow the call stack. + // Hence this, though I doubt we actually use large enough strings to worry. + // http://stackoverflow.com/a/12713326 + var CHUNK_SIZE = 0x8000; + var c = []; + for (var i = 0; i < array.length; i += CHUNK_SIZE) { + c.push(String.fromCharCode.apply(null, array["subarray" in array ? "subarray" : "slice"](i, i + CHUNK_SIZE))); + } + return c.join(""); +} + +function parseNPT(npt) { + // Format: [npt:]([h:]mm:ss|seconds)[.subsecond] + // I’ve decided to be lazy and allow "1:2:3.4" as well as "1:02:03.4" + // This makes it [npt:][[h:]m:]s[.subsecond] + var match = /^(?:npt:)?(?:(?:(\d+):)?(\d+):)?(\d+(?:\.\d+)?)$/i.exec(npt); + return match ? (match[1] || 0) * 3600 + (match[2] || 0) * 60 + match[3] : null; +} + +function classifyPosterURL(url) { + if (!url) { + // There is no poster. + return {type: null}; + } + switch (/^(?:(.*):)?/.exec(url)[1]) { + case "npt": + var time = parseNPT(url); + return time ? {type: "npt", time: time} : {type: null}; + case "data": + var data = parseDataURI(url); + if (/^text\/plain$/i.test(data[0])) { + return {type: "text", data: data[1]}; + } + } + // TODO: treat all the other possibilities as images. + return {type: null}; +} + +/// @param {ArrayBuffer|Array<number>} source +function parseTTYRec(source) { + var isArray = source instanceof Array; + var utf8 = true; + var dimensions = null; + var data = []; + var byteOffset = 0; + var timeOffset = 0; + var sourceLength = isArray ? source.length : source.byteLength; + while (byteOffset < sourceLength) { + var sec, usec, len; + if (!isArray) { + var header = new DataView(source, byteOffset); + sec = header.getUint32(0, true); + usec = header.getUint32(4, true); + len = header.getUint32(8, true); + } else { + sec = source[byteOffset] + + (source[byteOffset + 1] << 8) + + (source[byteOffset + 2] << 16) + + (source[byteOffset + 3] << 24); + usec = source[byteOffset + 4] + + (source[byteOffset + 5] << 8) + + (source[byteOffset + 6] << 16) + + (source[byteOffset + 7] << 24); + len = source[byteOffset + 8] + + (source[byteOffset + 9] << 8) + + (source[byteOffset + 10] << 16) + + (source[byteOffset + 11] << 24); + } + var time = sec + (usec / 1000000); + byteOffset += 12; + var payload = isArray ? source.slice(byteOffset, byteOffset + len) + : new Uint8Array(source, byteOffset, len); + payload = utf8 ? decodeUTF8(payload) : byteArrayToString(payload); + if (byteOffset === 12) { + // First chunk might be metadata; this is how termrec does it, for example. + timeOffset = time; + var metadata = /^\x1b%(G|@)\x1b\[8;([0-9]+);([0-9]+)t$/.exec(payload); + if (metadata) { + utf8 = metadata[1] === "G"; + dimensions = { + rows: +metadata[2], + cols: +metadata[3] + }; + } + } + time -= timeOffset; + byteOffset += len; + data.push([payload, time]); + } + return { + // Heuristic: if the time offset is large enough, it’s probably a timestamp. + startDate: timeOffset >= 1e8 ? new Date(timeOffset * 1000) : null, + dimensions: dimensions, + data: data + }; +} + +function formatTime(time) { + var seconds = time | 0; + var minutes = seconds / 60 | 0; + seconds = ("0" + (seconds % 60)).substr(-2); + if (minutes >= 60) { + var hours = minutes / 60 | 0; + minutes = ("0" + (minutes % 60)).substr(-2); + return hours + ":" + minutes + ":" + seconds; + } else { + return minutes + ":" + seconds; + } +} + +function blankableAttributeProperty(name) { + return { + get: function() { + var value = this.getAttribute(name); + return value === null ? "" : value.trim(); + }, + set: function(value) { + this.setAttribute(name, value); + } + }; +} + +function attributeBooleanProperty(name) { + return { + get: function() { + return this.hasAttribute(name); + }, + set: function(bool) { + if (bool) { + this.setAttribute(name, ""); + } else { + this.removeAttribute(name); + } + } + }; +} + +function invalidStateError() { + document.createElement("video").currentTime = 1; +} + +/** @const */ var NETWORK_EMPTY = 0; +/** @const */ var NETWORK_IDLE = 1; +/** @const */ var NETWORK_LOADING = 2; +/** @const */ var NETWORK_NO_SOURCE = 3; + +/** @const */ var HAVE_NOTHING = 0; +/** @const */ var HAVE_METADATA = 1; +/** @const */ var HAVE_CURRENT_DATA = 2; +/** @const */ var HAVE_FUTURE_DATA = 3; +/** @const */ var HAVE_ENOUGH_DATA = 4; + +// Annoyingly, with things like MediaError, one apparently can’t construct them in any way. +// I might need to do something like this. +var My = {}; +// Note that the constants on MediaError are *not* on My.MediaError, though they are on instances. +My.MediaError = /** @constructor */ function(code) { + Object.defineProperty(this, "code", {value: code}); +}; +My.MediaError.prototype = Object.create(MediaError.prototype); + +/** @const */ var EMPTY_TIME_RANGES = document.createElement("video").played; + +My.TimeRanges = /** @constructor */ function(ranges) { + Object.defineProperty(this, "length", {value: ranges.length}); + this["_"] = ranges; +}; +My.TimeRanges.prototype = Object.create(TimeRanges.prototype); + +My.TimeRanges.prototype["start"] = function(i) { + if (i < this["length"]) { + return this["_"][i][0]; + } else { + return EMPTY_TIME_RANGES["end"](0); // Throws IndexSizeError + } +}; + +My.TimeRanges.prototype["end"] = function(i) { + if (i < this["length"]) { + return this["_"][i][1]; + } else { + return EMPTY_TIME_RANGES["end"](0); // Throws IndexSizeError + } +}; + +/** @const */ var MEDIA_ERR_ABORTED = 1; +/** @const */ var MEDIA_ERR_NETWORK = 2; +/** @const */ var MEDIA_ERR_DECODE = 3; +/** @const */ var MEDIA_ERR_SRC_NOT_SUPPORTED = 4; + +/** @const */ var ERROR_DETAILS = { + 1: ["MEDIA_ERR_ABORTED", "The fetching process for the media resource was aborted by the user agent at the user's request."], + 2: ["MEDIA_ERR_NETWORK", "A network error of some description caused the user agent to stop fetching the media resource, after the resource was established to be usable."], + 3: ["MEDIA_ERR_DECODE", "An error of some description occurred while decoding the media resource, after the resource was established to be usable."], + 4: ["MEDIA_ERR_SRC_NOT_SUPPORTED", "The media resource indicated by the \x1b[4msrc\x1b[24m attribute was not suitable."] +}; + +/** @const */ var FANCY_TECHNICAL_ERROR_EXPLANATIONS = true; + +var menuIdSequence = 0; + +function makeMenu(ttyPlayer) { + // Make a context menu with these items: + // - Play/Pause + // - Show/Hide Controls + // + // Firefox also has the following ones deemed unnecessary: + // + // - Mute/Unmute + // - Play Speed > + // - Slow Motion (0.5Ă—) + // - Normal Speed (1Ă—) + // - High Speed (1.5Ă—) + // - Ludicrous Speed (2Ă—) + // - Show Statistics + // - Full Screen + // + // Chrome has Show controls (lowercase c) as a toggle and adds a Loop item. + var menu = document.createElement("menu"); + if (!("type" in menu)) { + return null; + } + + try { + menu.type = "context"; + } catch (e) { + // IE 11, "Invalid argument." + } + if (menu.type !== "context") { + return null; + } + menu.id = "treplay-contextmenu-" + menuIdSequence++; + + var playPause = document.createElement("menuitem"); + playPause.onclick = function() { + if (ttyPlayer["paused"]) { + ttyPlayer["play"](); + } else { + ttyPlayer["pause"](); + } + }; + function setPlayPauseDetails(label, path) { + playPause.label = label; + playPause.icon = "data:image/svg+xml,%3C?xml version='1.0' encoding='UTF-8' standalone='no'?%3E%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath stroke='%23999' stroke-width='1' fill='%23eee' d='" + path + "'/%3E%3C/svg%3E"; + } + function onPlay() { + setPlayPauseDetails("Pause", "m2.5,1.5 0,13 4,0 0,-13zm7,0 0,13 4,0 0,-13z"); + } + function onPause() { + setPlayPauseDetails("Play", "m2.5,2 0,12 11,-6z"); + } + onPause(); + ttyPlayer.addEventListener("play", onPlay); + ttyPlayer.addEventListener("pause", onPause); + + var controls = document.createElement("menuitem"); + menu.onControlsShownOrHidden = function() { + if (ttyPlayer["controls"]) { + controls.label = "Hide Controls"; + } else { + controls.label = "Show Controls"; + } + }; + menu.onControlsShownOrHidden(); + controls.onclick = function() { + ttyPlayer["controls"] = !ttyPlayer["controls"]; + }; + + menu.appendChild(playPause); + menu.appendChild(controls); + return menu; +} + +// TODO: reset() hides the cursor; patch term.js so if useFocus === false it is shown by default? +var stockReset = Terminal.prototype["reset"]; +Terminal.prototype["reset"] = function() { + stockReset.call(this); + if ("useFocus" in this["options"] && !this["options"]["useFocus"]) { + this["showCursor"](); + } +}; + +// IDL for this code: +// +// interface HTMLTTYPlayerElement : HTMLMediaElement { +// attribute DOMString defaultTitle; +// attribute DOMString title; +// +// readonly attribute unsigned long cols; +// readonly attribute unsigned long rows; +// void resize(unsigned long cols, unsigned long rows); +// +// attribute EventHandler ontitlechange; +// +// // This one is straight from HTMLVideoElement. +// attribute DOMString poster; +// +// // s/void/avoid/ +// void pretendToBeAVideo(); +// } +// +// IDL taken from HTML 5 spec: +// +// enum CanPlayTypeEnum { "" /* empty string */, "maybe", "probably" }; +// interface HTMLMediaElement : HTMLElement { +// +// // error state +// readonly attribute MediaError? error; +// +// // network state +// attribute DOMString src; +// readonly attribute DOMString currentSrc; +// attribute DOMString crossOrigin; +// const unsigned short NETWORK_EMPTY = 0; +// const unsigned short NETWORK_IDLE = 1; +// const unsigned short NETWORK_LOADING = 2; +// const unsigned short NETWORK_NO_SOURCE = 3; +// readonly attribute unsigned short networkState; +// attribute DOMString preload; +// readonly attribute TimeRanges buffered; +// void load(); +// CanPlayTypeEnum canPlayType(DOMString type); +// +// // ready state +// const unsigned short HAVE_NOTHING = 0; +// const unsigned short HAVE_METADATA = 1; +// const unsigned short HAVE_CURRENT_DATA = 2; +// const unsigned short HAVE_FUTURE_DATA = 3; +// const unsigned short HAVE_ENOUGH_DATA = 4; +// readonly attribute unsigned short readyState; +// readonly attribute boolean seeking; +// +// // playback state +// attribute double currentTime; +// readonly attribute unrestricted double duration; +// Date getStartDate(); +// readonly attribute boolean paused; +// attribute double defaultPlaybackRate; +// attribute double playbackRate; +// readonly attribute TimeRanges played; +// readonly attribute TimeRanges seekable; +// readonly attribute boolean ended; +// attribute boolean autoplay; +// attribute boolean loop; +// void play(); +// void pause(); +// +// // media controller +// attribute DOMString mediaGroup; +// attribute MediaController? controller; +// +// // controls +// attribute boolean controls; +// attribute double volume; +// attribute boolean muted; +// attribute boolean defaultMuted; +// +// // tracks +// readonly attribute AudioTrackList audioTracks; +// readonly attribute VideoTrackList videoTracks; +// readonly attribute TextTrackList textTracks; +// TextTrack addTextTrack(TextTrackKind kind, optional DOMString label = "", optional DOMString language = ""); +// }; +// +// interface HTMLVideoElement : HTMLMediaElement { +// attribute unsigned long width; +// attribute unsigned long height; +// readonly attribute unsigned long videoWidth; +// readonly attribute unsigned long videoHeight; +// attribute DOMString poster; +// }; + +/** @constructor */ +function TTYPlayerInternalState(ttyPlayer) { + this.ttyPlayer = ttyPlayer; +} + +var ISP = TTYPlayerInternalState.prototype; + +ISP.setUp = function() { + var self = this; + var ttyPlayer = self.ttyPlayer; + self.titleElement = document.createElement("div"); + self.titleElement.className = "title"; + ttyPlayer.appendChild(self.titleElement); + + self.terminal = new Terminal({"useFocus": false}); + self.terminal.on("title", function(newTitle) { + ttyPlayer["title"] = newTitle; + }); + + self.terminal.open(ttyPlayer); + + if (FANCY_TECHNICAL_ERROR_EXPLANATIONS) { + ttyPlayer.addEventListener("error", function() { + var details = ERROR_DETAILS[self.error.code]; + self.terminal.reset(); + self.terminal.write( + "\x1b]2;Error :-(\x07" + + "\r\n\x1b[1mMediaError.\x1b[31m" + details[0] + "\x1b[m " + + "(numeric value " + self.error.code + ")\r\n\r\n" + + " " + details[1] + "\r\n\r\n(Sorry ’bout that.)"); + }); + } + + var rows = +ttyPlayer.getAttribute("rows"); + var cols = +ttyPlayer.getAttribute("cols"); + ttyPlayer["resize"](cols > 0 ? cols : ttyPlayer["cols"], + rows > 0 ? rows : ttyPlayer["rows"]); + + // XXX: properties with names used in the DOM don’t get shrunk by Closure + // Compiler’s advanced optimizations, for safety. We could get size down a + // smidgeon more by renaming them all, but that’d be uglier. + // Candidates: defaultPlaybackRate, playbackRate, currentSrc, readyState, networkState, paused, duration. + + self.defaultPlaybackRate = self.playbackRate = 1; + self.defaultPlaybackStartPosition = 0; + self.currentSrc = ""; + self.readyState = HAVE_NOTHING; + self.networkState = NETWORK_EMPTY; + self.paused = true; + self.duration = NaN; + self.defaultTitle = ttyPlayer.getAttribute("window-title") || ""; + self.posterOverlay = document.createElement("tty-player-poster"); + self.posterOverlay.onclick = function() { + ttyPlayer["play"](); + }; + + self.terminal.on("resize", function() { + // ttyPlayer.rows and ttyPlayer.cols have changed, fire an appropriate event + self.fireSimpleEvent("resize"); + }); + + self.menu = makeMenu(ttyPlayer); + if (self.menu) { + ttyPlayer.appendChild(self.menu); + ttyPlayer.setAttribute("contextmenu", self.menu.id); + } + + self.controlsElement = document.createElement("tty-player-controls"); + var play = document.createElement("button"); + play.className = "play"; + play.onclick = function() { + if (ttyPlayer["paused"]) { + ttyPlayer["play"](); + } else { + ttyPlayer["pause"](); + } + }; + ttyPlayer.addEventListener("play", function() { + play.className = "pause"; + }); + ttyPlayer.addEventListener("pause", function() { + play.className = "play"; + }); + self.currentTimeElement = document.createElement("span"); + self.currentTimeElement.className = "current-time"; + self.currentTimeElement.textContent = "0:00"; + self.durationElement = document.createElement("span"); + self.durationElement.className = "duration"; + self.durationElement.textContent = "0:00"; + self.progressElement = document.createElement("input"); + self.progressElement.type = "range"; + self.progressElement.value = 0; + self.progressElement.min = 0; + self.progressElement.step = "any"; + var skipChange = false; + self.progressElement.addEventListener("input", function() { + if (!skipChange) { + skipChange = true; + self.semipaused = true; + ttyPlayer["currentTime"] = self.progressElement.value; + self.updateCurrentTimeElement(); + skipChange = false; + } + }); + self.progressElement.addEventListener("change", function() { + if (!skipChange) { + skipChange = true; + self.semipaused = false; + ttyPlayer["currentTime"] = self.progressElement.value; + self.updateCurrentTimeElement(); + skipChange = false; + } + }); + ttyPlayer.addEventListener("durationchange", function() { + self.progressElement.max = self.duration; + self.durationElement.textContent = formatTime(self.duration); + }); + ttyPlayer.addEventListener("timeupdate", function() { + if (!skipChange) { + skipChange = true; + self.progressElement.value = self.currentTime; + self.updateCurrentTimeElement(); + skipChange = false; + } + }); + self.controlsElement.appendChild(play); + self.controlsElement.appendChild(self.currentTimeElement); + self.controlsElement.appendChild(self.progressElement); + self.controlsElement.appendChild(self.durationElement); + ttyPlayer.appendChild(self.posterOverlay); + ttyPlayer.appendChild(self.controlsElement); + self.showPoster = true; +}; + +Object.defineProperties(ISP, { + /** @lends {ISP} */ + showPoster: { + get: function() { + return this._showPoster; + }, + set: function(newValue) { + // TODO: this is problematic because it doesn’t keep track of what + // poster is active, it just uses the current value of poster. We + // should probably store the value of poster and use it for + // removing it. + var self = this; + var oldValue = self._showPoster; + newValue = !!newValue; + + var newPoster = classifyPosterURL(self.ttyPlayer["poster"]); + self._showPoster = !!newValue; + + // We don’t show the overlay if there is an error + var showOverlay = newValue && !self.error; + + self.posterOverlay.style.display = showOverlay ? "" : "none"; + self.controlsElement.classList[showOverlay ? "add" : "remove"]("poster"); + self.progressElement.disabled = newValue; + self.controlsShownOrHidden(); + + if (oldValue === newValue && self.activePoster === newPoster) { + // No change to make + return; + } + + // If we need to do anything special to remove a poster, here’s what we’ll do: + // if (oldValue) { + // switch (self.activePoster.type) { + // case "foo": + // … + // } + // } + + self.activePoster = newPoster; + + if (oldValue || newValue) { + // Yes, we’re missing the optimisation possibility of poster=npt:X + // changing to poster=npt:Y where Y > X. Seriously, adjusting + // poster *at all* is rare enough that I don’t care. + self.resetTerminal(); + } + + if (newValue) { + // Show the new poster + switch (newPoster.type) { + case "npt": + // We have an NPT poster to create. + self.resetTerminal(); + + var realShowPoster = function() { + if (newValue !== self._showPoster) { + // Sorry, you took too long and I don’t want to do anything now; + // something else is doing it. + return; + } + + if (newValue) { + var currentTime = self.currentTime; + var semipaused = self.semipaused; + self.semipaused = true; + self.currentTime = newPoster.time; + self.nextDataIndex = 0; + self.render(); + self.semipaused = semipaused; + self.currentTime = currentTime; + } + }; + + if (self.data) { + realShowPoster(); + } else { + var loaded = function() { + self.ttyPlayer.removeEventListener("canplaythrough", loaded); + realShowPoster(); + }; + self.ttyPlayer.addEventListener("canplaythrough", loaded); + self.loadIfNotLoading(); + } + break; + case "text": + self.resetTerminal(); + self.terminal.write(newPoster.data); + } + } + } + } +}); + +/// Firing a simple event named e means that a trusted event with the name +/// e, which does not bubble (except where otherwise stated) and is not +/// cancelable (except where otherwise stated), and which uses the Event +/// interface, must be created and dispatched at the given target. +/// INCONSISTENCY: isTrusted = false +ISP.fireSimpleEvent = function(name) { + var event = document.createEvent("HTMLEvents"); + event.initEvent(name, false, false); + var f = this.ttyPlayer["on" + name]; + if (typeof f === "function") { + f(event); + } + this.ttyPlayer.dispatchEvent(event); +}; + +ISP.controlsShownOrHidden = function() { + this.updateCurrentTimeElement(); + if (this.menu) { + this.menu.onControlsShownOrHidden(); + } +}; + +ISP.updateCurrentTimeElement = function() { + this.currentTimeElement.textContent = formatTime(this.currentTime); + var left = this.progressElement.offsetLeft - (this.currentTimeElement.offsetWidth / 2); + if (!isNaN(this.duration)) { + left += this.currentTime / this.duration * this.progressElement.offsetWidth; + } + this.currentTimeElement.style.left = left + "px"; +}; + +/** @const */ var TICK = 16; +/** @const */ var TIME_UPDATE_FREQUENCY = 100; +ISP.lastTimeUpdate = 0; + +ISP.render = function() { + // Should the currently rendered frame (next - 1) be drawn? + if (this.nextDataIndex > 0 && this.data[this.nextDataIndex - 1][1] > this.currentTime) { + // No, but undoing isn’t possible, so we must replay from the start. + // This is highly inefficient; for large scripts it’s utterly untenable. + this.resetTerminal(); + this.nextDataIndex = 0; + } + while (this.nextDataIndex < this.data.length && this.data[this.nextDataIndex][1] <= this.currentTime) { + this.terminal.write(this.data[this.nextDataIndex][0]); + this.nextDataIndex++; + } + + if (this.semipaused) { + return; + } + + // Have we reached the end? Let’s stop. + if ((this.currentTime >= this.duration && this.playbackRate > 0) || + (this.currentTime <= 0 && this.playbackRate < 0)) { + if (this.ttyPlayer["loop"]) { + this.ttyPlayer["currentTime"] = this.playbackRate > 0 ? 0 : this.duration; + } else { + this.fireSimpleEvent("timeupdate"); + this.ttyPlayer["pause"](); + this.fireSimpleEvent("ended"); + } + } else { + // Do we need to fire a timeupdate event? We should do them every 66–350ms; Firefox does 250 for video, but because the average length is going to be shorter and because I can, I’m going for 100ms. + var time = +new Date(); + if (time - this.lastTimeUpdate >= TIME_UPDATE_FREQUENCY) { + this.lastTimeUpdate = time; + this.fireSimpleEvent("timeupdate"); + } + } +}; + +ISP.resetTerminal = function() { + this.terminal.reset(); + this.ttyPlayer["title"] = this.defaultTitle; +}; + +ISP.loadIfNotLoading = function() { + if (this.networkState < NETWORK_LOADING) { + this.mediaLoadAlgorithm(); + } +}; + +ISP.mediaLoadAlgorithm = function() { + this.resetTerminal(); + + // > The media load algorithm consists of the following steps. + + // > 1. Abort any already-running instance of the resource selection + // > algorithm for this element. + if (this.resourceFetchXHR) { + this.resourceFetchXHR.abort(); + } + + // > 2. If there are any tasks from the media element's media element + // > event task source in one of the task queues, then remove those + // > tasks. + // > + // > If there are any tasks that were queued by the resource + // > selection algorithm (including the algorithms that it itself + // > invokes) for this same media element from the DOM manipulation + // > task source in one of the task queues, then remove those tasks. + // > + // > Note: Basically, pending events and callbacks for the media + // > element are discarded when the media element starts loading a + // > new resource. + // + // [Nothing to do, we aren’t queuing events.] + + // > 3. If the media element's networkState is set to NETWORK_LOADING + // > or NETWORK_IDLE, queue a task to fire a simple event named + // > abort at the media element. + if (this.networkState === NETWORK_LOADING || + this.networkState === NETWORK_IDLE) { + this.fireSimpleEvent("abort"); + } + + // > 4. If the media element's networkState is not set to + // > NETWORK_EMPTY, then run these substeps: + if (this.networkState !== NETWORK_EMPTY) { + // > 1. Queue a task to fire a simple event named emptied at the + // > media element. + this.fireSimpleEvent("emptied"); + + // > 2. If a fetching process is in progress for the media element, + // > the user agent should stop it. + // TODO. + + // > 3. Forget the media element's media-resource-specific tracks. + // [Not applicable.] + + // > 4. If readyState is not set to HAVE_NOTHING, then set it to + // > that state. + this.readyState = HAVE_NOTHING; + + // > 5. If the paused attribute is false, then set it to true. + this.paused = true; + clearInterval(this.ticker); + + // > 6. If seeking is true, set it to false. + // [Not applicable.] + + // > 7. Set the current playback position to 0. + // > + // > Set the official playback position to 0. + // > + // > If this changed the official playback position, then queue + // > a task to fire a simple event named timeupdate at the + // > media element. + var oldTime = this.currentTime; + this.currentTime = 0; + this.nextDataIndex = 0; + if (oldTime !== 0) { + this.fireSimpleEvent("timeupdate"); + } + + // > 8. Set the initial playback position to 0. + // Not applicable (TODO? Might be useful?) + + // > 9. Set the timeline offset to Not-a-Number (NaN). + // TODO (haven’t finished supporting timeline offsets) + + // > 10. Update the duration attribute to Not-a-Number (NaN). + // > + // > The user agent will not fire a durationchange event for + // > this particular change of the duration. + this.data = null; + this.duration = NaN; + } + + // > 5. Set the playbackRate attribute to the value of the defaultPlaybackRate attribute. + this.playbackRate = this.defaultPlaybackRate; + + // > 6. Set the error attribute to null and the autoplaying flag to true. + this.error = null; + // TODO. + + // > 7. Invoke the media element's resource selection algorithm. + this.resourceSelectionAlgorithm(); + + // > 8. Note: Playback of any previously playing media resource for this element stops. + // Already done. +}; + +ISP.resourceSelectionAlgorithm = function() { + var self = this; + // We use a simplified version of the resource selection algorithm, + // as we support only one type, don’t use <source> (src only) and + // handle synchronosity differently. + + // > 1. Set the element's networkState attribute to the + // > NETWORK_NO_SOURCE value. + self.networkState = NETWORK_NO_SOURCE; + + // > 2. Set the element's show poster flag to true. + self.showPoster = true; + + // > 3. Set the media element's delaying-the-load-event flag to + // > true (this delays the load event). + // TODO. + + // > 4. Asynchronously await a stable state, allowing the task that + // > invoked this algorithm to continue. The synchronous section + // > consists of all the remaining steps of this algorithm until + // > the algorithm says the synchronous section has ended. + // > (Steps in synchronous sections are marked with ⌛.) + + // > 5. ⌛ If the media element's blocked-on-parser flag is false, + // > then populate the list of pending text tracks. + // [Not applicable.] + + // > 6. ⌛ If the media element has a src attribute, then let mode + // > be attribute. + // > + // > ⌛ Otherwise, if the media element does not have a src + // > attribute but has a source element child, then let mode be + // > children and let candidate be the first such source element + // > child in tree order. + // > + // > ⌛ Otherwise the media element has neither a src attribute + // > nor a source element child: set the networkState to + // > NETWORK_EMPTY, and abort these steps; the synchronous + // > section ends. + // + // We don’t support <source> at present, so this is simpler. + var src = self.ttyPlayer.getAttribute("src"); + if (src === null) { + self.networkState = NETWORK_EMPTY; + return; + } + + // > 7. ⌛ Set the media element's networkState to NETWORK_LOADING. + self.networkState = NETWORK_LOADING; + + // > 8. ⌛ Queue a task to fire a simple event named loadstart at + // > the media element. + self.fireSimpleEvent("loadstart"); + + // > 9. If mode is attribute, then run these substeps: + // [We don’t support <source>, so this is guaranteed.] + + // > 1. ⌛ If the src attribute's value is the empty string, then + // > end the synchronous section, and jump down to the failed + // > with attribute step below. + if (src === "") { + return self.resourceSelectionAlgorithmFailedWithAttribute(); + } + + // > 2. ⌛ Let absolute URL be the absolute URL that would have + // > resulted from resolving the URL specified by the src + // > attribute's value relative to the media element when the + // > src attribute was last changed. + var absoluteURL = new URL(src.trim(), self.ttyPlayer.baseURI); + + // > 3. ⌛ If absolute URL was obtained successfully, set the + // > currentSrc attribute to absolute URL. + self.currentSrc = absoluteURL.toString(); + + // > 4. End the synchronous section, continuing the remaining steps + // > asynchronously. + setTimeout(function() { + + // > 5. If absolute URL was obtained successfully, run the resource + // > fetch algorithm with absolute URL. If that algorithm + // > returns without aborting this one, then the load failed. + // Due to the simpler model used, supporting aborting isn’t necessary. + self.resourceFetchAlgorithm(); + }, 0); +}; + +ISP.resourceSelectionAlgorithmFailedWithAttribute = function() { + // > 6. Failed with attribute: Reaching this step indicates that + // > the media resource failed to load or that the given URL + // > could not be resolved. Queue a task to run the following + // > steps, using the DOM manipulation task source: + + // > 1. Set the error attribute to a new MediaError object whose code attribute is set to MEDIA_ERR_SRC_NOT_SUPPORTED. + this.error = new My.MediaError(MEDIA_ERR_SRC_NOT_SUPPORTED); + + // > 2. Forget the media element's media-resource-specific tracks. + // [Nothing to do.] + + // > 3. Set the element's networkState attribute to the NETWORK_NO_SOURCE value. + this.networkState = NETWORK_NO_SOURCE; + + // > 4. Set the element's show poster flag to true. + this.showPoster = true; + + // > 5. Fire a simple event named error at the media element. + this.fireSimpleEvent("error"); + + // > 6. Set the element's delaying-the-load-event flag to false. This stops delaying the load event. + //this.delayingTheLoadEvent = false; + + // > 7. Wait for the task queued by the previous step to have executed. + // [Not queueing tasks, so nothing to do.] + + // > 8. Abort these steps. Until the load() method is invoked or the src attribute is changed, the element won't attempt to load another resource. +}; + +ISP.resourceFetchAlgorithm = function() { + var self = this; + function finishResourceFetchAlgorithm() { + delete self.resourceFetchXHR; + } + + function continueResourceFetchAlgorithm(data) { + // > Once enough of the media data has been fetched to determine + // > the duration of the media resource, its dimensions, and other + // > metadata: + // > + // > This indicates that the resource is usable. The user agent + // > must follow these substeps: + // > + // > 1. Establish the media timeline for the purposes of the + // > current playback position, the earliest possible position, + // > and the initial playback position, based on the media data. + // [TODO support such things?] + + // > 2. Update the timeline offset to the date and time that + // > corresponds to the zero time in the media timeline + // > established in the previous step, if any. If no explicit + // > time and date is given by the media resource, the timeline + // > offset must be set to Not-a-Number (NaN). + // [Nothing to do.] + + // > 3. Set the current playback position and the official playback + // > position to the earliest possible position. + self.currentTime = 0; + self.nextDataIndex = 0; + + // > 4. Update the duration attribute with the time of the last + // > frame of the resource, if known, on the media timeline + // > established above. If it is not known (e.g. a stream that + // > is in principle infinite), update the duration attribute to + // > the value positive Infinity. + // > + // > Note: The user agent will queue a task to fire a simple + // > event named durationchange at the element at this point. + self.data = data.data; + self.duration = data.data.length === 0 ? 0 : data.data[data.data.length - 1][1]; + self.fireSimpleEvent("durationchange"); + + // > 5. For video elements, set the videoWidth and videoHeight + // > attributes, and queue a task to fire a simple event named + // > resize at the media element. + // > + // > Note: Further resize events will be fired if the dimensions + // > subsequently change. + // TODO: allow this to be written on the HTML + // TODO: modify the file format to track window sizes, then do + // something like this (ttyWidth and ttyHeight, in chars, I + // think). + // These are taken straight from term.js; TODO: modify it to send resize events. + if (data.dimensions) { + self.ttyPlayer["resize"](data.dimensions.cols, data.dimensions.rows); + } + + // XXX: the spec mentions getStartDate(), which data.startDate + // covers, but Firefox and Chrome at least (dunno about others) + // don’t implement that, so I’m not doing anything with it yet. + + // We could render the first frame if we wanted to. Should we? + //self.render(); + + // > 6. Set the readyState attribute to HAVE_METADATA. + // > + // > Note: A loadedmetadata DOM event will be fired as part of + // > setting the readyState attribute to a new value. + self.readyState = HAVE_METADATA; + self.fireSimpleEvent("loadedmetadata"); + + // > 7. Let jumped be false. + var jumped = false; + + // > 8. If the media element's default playback start position is + // > greater than zero, then seek to that time, and let jumped + // > be true. + if (self.defaultPlaybackStartPosition > 0) { + self.currentTime = self.defaultPlaybackStartPosition; + jumped = true; + } + + // > 9. Let the media element's default playback start position be + // > zero. + self.defaultPlaybackStartPosition = 0; + + // > 10. If either the media resource or the address of the current + // > media resource indicate a particular start time, then set + // > the initial playback position to that time and, if jumped + // > is still false, seek to that time and let jumped be true. + // > + // > For example, with media formats that support the Media + // > Fragments URI fragment identifier syntax, the fragment + // > identifier can be used to indicate a start position. + // > [MEDIAFRAG] + // TODO: support Media Fragments, e.g. ?t=a,b#t=c will trim the + // range to [a, b) seconds, starting at c seconds into that range, + // ?t=,b is [0, b); ?t=a is [a, end), it uses NPT. + + // > 11. If either the media resource or the address of the current + // > media resource indicate a particular set of audio or video + // > tracks to enable, or if the user agent has information + // > that would enable it to select specific tracks to improve + // > the user's experience, then the relevant audio tracks must + // > be enabled in the element's audioTracks object, and, of + // > the relevant video tracks, the one that is listed first in + // > the element's videoTracks object must be selected. All + // > other tracks must be disabled. + // > + // > This could again be triggered by Media Fragments URI + // > fragment identifier syntax, but it could also be triggered + // > e.g. by the user agent selecting a 5.1 surround sound + // > audio track over a stereo audio track. [MEDIAFRAG] + // [Not applicable.] + + // > 12. If the media element has a current media controller, then: + // > if jumped is true and the initial playback position, + // > relative to the current media controller's timeline, is + // > greater than the current media controller's media + // > controller position, then seek the media controller to the + // > media element's initial playback position, relative to the + // > current media controller's timeline; otherwise, seek the + // > media element to the media controller position, relative + // > to the media element's timeline. + // [Not applicable.] + + // > Once the readyState attribute reaches HAVE_CURRENT_DATA, after the loadeddata event has been fired, set the element's delaying-the-load-event flag to false. This stops delaying the load event. + // > + // > A user agent that is attempting to reduce network usage while still fetching the metadata for each media resource would also stop buffering at this point, following the rules described previously, which involve the networkState attribute switching to the NETWORK_IDLE value and a suspend event firing. + // > + // > The user agent is required to determine the duration of the media resource and go through this step before playing. + + // > Once the entire media resource has been fetched (but + // > potentially before any of it has been decoded) + // > + // > Fire a simple event named progress at the media element. + self.fireSimpleEvent("progress"); + + // > Set the networkState to NETWORK_IDLE and fire a simple event named suspend at the media element. + self.networkState = NETWORK_IDLE; + self.fireSimpleEvent("suspend"); + + // > If the user agent ever discards any media data and then needs to resume the network activity to obtain it again, then it must queue a task to set the networkState to NETWORK_LOADING. + // [This won’t happen.] + + // > If the user agent can keep the media resource loaded, then the algorithm will continue to its final step below, which aborts the algorithm. + + // The description of when this is supposed to happen is + // surprisingly unclear. Hopefully this will do. + self.readyState = HAVE_ENOUGH_DATA; + self.fireSimpleEvent("loadeddata"); + self.fireSimpleEvent("canplay"); + self.fireSimpleEvent("canplaythrough"); + + finishResourceFetchAlgorithm(); + } + + function handleResponse(xhr, useResponseText) { + if (xhr.status === 200) { + var data; + try { + /** @type {Array<number>|ArrayBuffer} */ + var response; + if (useResponseText) { + var string = xhr.responseText; + response = []; + for (var i = 0; i < string.length; i++) { + response.push(string.charCodeAt(i) & 0xff); + } + } else { + response = xhr.response; + } + + data = parseTTYRec(response); + // TODO: add a bit of validation/sanity checking? + } catch (e) { + // window.console && console.warn && console.warn("parseTTYRec failed: ", e); + // > If the media data can be fetched but is found by + // > inspection to be in an unsupported format, or can + // > otherwise not be rendered at all + // > [Give up and go back to resource selection, which + // > we don’t need to return to due to our design.] + finishResourceFetchAlgorithm(); + self.resourceSelectionAlgorithmFailedWithAttribute(); + return; + } + + // TODO: implement something like this: + // + // > If the media resource is found to have a video track + // > + // > 1. Create a VideoTrack object to represent the + // > video track. + // > + // > 2. Update the media element's videoTracks + // > attribute's VideoTrackList object with the new + // > VideoTrack object. + // > + // > 3. Fire a trusted event with the name addtrack, + // > that does not bubble and is not cancelable, and + // > that uses the TrackEvent interface, with the + // > track attribute initialized to the new + // > VideoTrack object, at this VideoTrackList + // > object. + continueResourceFetchAlgorithm(data); + } else { + // > If the media data cannot be fetched at all, due to + // > network errors, causing the user agent to give up + // > trying to fetch the resource + // > [Give up and go back to resource selection, which + // > we don’t need to return to due to our design.] + finishResourceFetchAlgorithm(); + self.resourceSelectionAlgorithmFailedWithAttribute(); + return; + } + } + + // > 1. Let the current media resource be the resource given by the + // > absolute URL passed to this algorithm. This is now the + // > element's media resource. + // current media resource = self.currentSrc + + // > 2. Remove all media-resource-specific text tracks from the + // > media element's list of pending text tracks, if any. + // [Nothing to do.] + + // > 3. Optionally, run the following substeps. This is the expected + // > behavior if the user agent intends to not attempt to fetch + // > the resource until the user requests it explicitly (e.g. as + // > a way to implement the preload attribute's none keyword). + // [Substeps omitted as I don’t wish to implement no-preload.] + + // > 4. Perform a potentially CORS-enabled fetch of the current + // > media resource's absolute URL, with the mode being the + // > state of the media element's crossorigin content attribute, + // > the origin being the origin of the media element's + // > Document, and the default origin behaviour set to taint. + // > + // + // [Vast swathes of text follow, mostly irrelevant as we load the + // entire resource at once; we don’t need to bother about the + // "stalled" and "suspend" events, and won’t bother for now about + // "progress" every 350±200ms/every byte (whichever is least + // frequent)] + // + // INCORRECTNESS: the window’s origin is used instead of the media + // element’s document’s. Security prevents doing this right. + // Dunno about the taint bit. + + // Past here we go laissez-faire, mostly ignoring the specs. + + var useResponseText; + + // Some browsers (Firefox, Chrome) allow you to use data URIs with + // an XMLHttpRequest, others (IE) don’t. + // To be sure, let’s parse it ourself. (TODO: assess perf.) + var data = parseDataURI(self.currentSrc); + if (data !== null) { + handleResponse({status: 200, responseText: data[1]}, true); + } else { + var xhr = new XMLHttpRequest(); + if (self.ttyPlayer["crossOrigin"] === "use-credentials") { + xhr.withCredentials = true; + } else if (self.ttyPlayer["crossOrigin"] === "anonymous" && "mozAnon" in xhr) { + // INCORRECTNESS: no anonymous support outside Firefox. + // (No one has implemented AnonXMLHttpRequest âą.) + xhr.mozAnon = true; + } + xhr.onabort = finishResourceFetchAlgorithm; + xhr.open("GET", self.currentSrc); + useResponseText = !("responseType" in xhr); + xhr.responseType = "arraybuffer"; + if (xhr.responseType !== "arraybuffer") { + useResponseText = true; + } + if (useResponseText) { + xhr.overrideMimeType("text/plain; charset=x-user-defined"); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + handleResponse(xhr, true); + } + }; + } else { + xhr.onload = xhr.onerror = function() { handleResponse(xhr, false); }; + } + self.resourceFetchXHR = xhr; + try { + xhr.send(); + } catch (e) { + // e.g. relative URL on file: in some browsers. + handleResponse(xhr, undefined); + } + } +}; + +var TTYPlayerPrototype = Object.create(HTMLElement.prototype); + +TTYPlayerPrototype["createdCallback"] = function() { + this["_"] = new TTYPlayerInternalState(this); + this["_"].setUp(); + + // TODO: put no-preload in load(), as defined, rather than here. + // As it stands, changing src will preload even though it need not. + if (this["preload"] !== "none") { + this["load"](); + } + + if (this["autoplay"]) { + this["play"](); + } +}; + +TTYPlayerPrototype["attributeChangedCallback"] = function(name) { + if (name === "src" && this.hasAttribute("src")) { + this["pause"](); + // > If a src attribute of a media element is set or changed, the user + // > agent must invoke the media element's media element load + // > algorithm. (Removing the src attribute does not do this, even if + // > there are source elements present.) + this["load"](); + } else if (name === "controls" && this.hasAttribute("controls")) { + // While the controls are display: none, the position of + // this element is garbage, so we need to fix it now. + this["_"].controlsShownOrHidden(); + } else if (name === "poster") { + // Update the poster if necessary. + // + // > If the specified resource is to be used, then, when the element is + // > created or when the poster attribute is set, changed, or removed, + // > the user agent must run the following steps to determine the + // > element's poster frame (regardless of the value of the element's + // > show poster flag): + // + // Due to the poster=npt:… possibility and how we could otherwise palm + // it off to the browser, we *do* actually regard the show poster flag + // in deciding whether to “run these steps”. + this["_"].showPoster = this["_"].showPoster; + } +}; + +TTYPlayerPrototype["attachedCallback"] = function() { + this["_"].controlsShownOrHidden(); +}; + +Object.defineProperties(TTYPlayerPrototype, { + /** @lends {TTYPlayerPrototype} */ + + /// @idl readonly attribute MediaError? error; + "error": { + get: function() { + return this["_"].error; + } + }, + + /// @idl attribute DOMString src; + "src": { + get: function() { + // It needs to be an absolute URL, and we’re not doing <source> tags, + // so src and currentSrc will actually always be the same. + return this["_"].currentSrc; + }, + set: function(value) { + this.setAttribute("src", value); + } + }, + + /// @idl readonly attribute DOMString currentSrc; + "currentSrc": { + get: function() { + return this["_"].currentSrc; + } + }, + + /// @idl attribute DOMString crossOrigin; + "crossOrigin": { + get: function() { + var value = this.getAttribute("crossorigin"); + if (value === null || value === "anonymous" || value === "use-credentials") { + return value; + } else { + return "anonymous"; + } + }, + set: function(value) { + if (value === null) { + this.removeAttribute("crossorigin"); + } else if (value === "use-credentials") { + this.setAttribute("crossorigin", value); + } else { + // "" == invalid value == "anonymous" + this.setAttribute("crossorigin", "anonymous"); + } + } + }, + + /// @idl const unsigned short NETWORK_EMPTY = 0; + "NETWORK_EMPTY": { value: 0 }, + + /// @idl const unsigned short NETWORK_IDLE = 1; + "NETWORK_IDLE": { value: 1 }, + + /// @idl const unsigned short NETWORK_LOADING = 2; + "NETWORK_LOADING": { value: 2 }, + + /// @idl const unsigned short NETWORK_NO_SOURCE = 3; + "NETWORK_NO_SOURCE": { value: 3 }, + + /// @idl readonly attribute unsigned short networkState; + "networkState": { + get: function() { + return this["_"].networkState; + } + }, + + /// @idl attribute DOMString preload; + "preload": { + get: function() { + var value = this.getAttribute("preload"); + if (value === "none" || value === "metadata" || value === "auto") { + return value; + } else { + // "" == auto, nothing is said about malformed values, and the missing value default is user-agent defined and we have no use for Metadata. + return "auto"; + } + }, + set: function(value) { + if (value === "none" || value === "metadata" || value === "auto") { + this.setAttribute("metadata", value); + } else { + this.removeAttribute("metadata"); + } + } + }, + + /// @idl readonly attribute TimeRanges buffered; + "buffered": { + get: function() { + return this["seekable"]; + } + }, + + // Although they sit here in the IDL, load() and canPlayType() are defined + // later because they’re methods, not properties. + + /// @idl const unsigned short HAVE_NOTHING = 0; + "HAVE_NOTHING": { value: 0 }, + + /// @idl const unsigned short HAVE_METADATA = 1; + "HAVE_METADATA": { value: 1 }, + + /// @idl const unsigned short HAVE_CURRENT_DATA = 2; + "HAVE_CURRENT_DATA": { value: 2 }, + + /// @idl const unsigned short HAVE_FUTURE_DATA = 3; + "HAVE_FUTURE_DATA": { value: 3 }, + + /// @idl const unsigned short HAVE_ENOUGH_DATA = 4; + "HAVE_ENOUGH_DATA": { value: 4 }, + + /// @idl readonly attribute unsigned short readyState; + "readyState": { + get: function() { + return this["_"].readyState; + } + }, + + /// @idl readonly attribute boolean seeking; + // I’m sloppily ignoring the whole seeking thing. Meh, it’s fast, hopefully no one cares about the seeking and seeked events? (TODO evaluate further.) + "seeking": { + value: false + }, + + /// @idl attribute double currentTime; + "currentTime": { + get: function() { + return this["_"].currentTime; + }, + set: function(newTime) { + if (!this["_"].data) { + throw invalidStateError(); + } + this["_"].currentTime = Math.max(0, Math.min(newTime, this["duration"])); + this["_"].render(); + } + }, + + /// @idl readonly attribute unrestricted double duration; + "duration": { + get: function() { + return this["_"].duration; + } + }, + + // @idl Date getStartDate(); + // Firefox and Chrome don’t implement this on HTMLMediaElement, so I’m skipping it for now. + + /// @idl readonly attribute boolean paused + "paused": { + get: function() { + return this["_"].paused; + } + }, + + /// @idl attribute double defaultPlaybackRate; + "defaultPlaybackRate": { + get: function() { + return this["_"].defaultPlaybackRate; + }, + set: function(rate) { + rate = +rate; + var notify = this["_"].defaultPlaybackRate !== rate; + this["_"].defaultPlaybackRate = rate; + if (notify) { + this["_"].fireSimpleEvent("ratechange"); + } + } + }, + + /// @idl attribute double playbackRate; + "playbackRate": { + get: function() { + return this["_"].playbackRate; + }, + set: function(rate) { + rate = +rate; + var notify = this["_"].playbackRate !== rate; + this["_"].playbackRate = rate; + if (notify) { + this["_"].fireSimpleEvent("ratechange"); + } + } + }, + + /// @idl readonly attribute TimeRanges played; + /// @stub Tracking which ranges have been played would take effort! + "played": { + value: EMPTY_TIME_RANGES + }, + + /// @idl readonly attribute TimeRanges seekable; + "seekable": { + get: function() { + if (this["readyState"] === HAVE_ENOUGH_DATA) { + return new My.TimeRanges([0, this["duration"]]); + } else { + return EMPTY_TIME_RANGES; + } + } + }, + + /// @idl readonly attribute boolean ended; + "ended": { + get: function() { + // XXX: I’m guessing these semantics, haven’t checked them. + return this["paused"] && this["currentTime"] === (this["playbackRate"] < 0 ? 0 : this["duration"]); + } + }, + + /// @idl attribute boolean autoplay; + "autoplay": attributeBooleanProperty("autoplay"), + + /// @idl attribute boolean loop; + "loop": attributeBooleanProperty("loop"), + + // play() and pause() are simple properties and so appear later + + // @idl attribute DOMString mediaGroup; + // Firefox and Chrome don’t implement this on HTMLMediaElement, so I’m skipping it for now. + + // @idl attribute MediaController? controller; + // Firefox and Chrome don’t implement this on HTMLMediaElement, so I’m skipping it for now. + + /// @idl attribute boolean controls; + "controls": attributeBooleanProperty("controls"), + + // volume and muted are simple properties and so appear later + + /// @idl attribute boolean defaultMuted; + /// @stub volume is irrelevant + "defaultMuted": attributeBooleanProperty("muted"), + + // @idl readonly attribute AudioTrackList audioTracks; + // Firefox and Chrome don’t implement this on HTMLMediaElement, so I’m skipping it for now. + + // @idl readonly attribute VideoTrackList videoTracks; + // Firefox and Chrome don’t implement this on HTMLMediaElement, so I’m skipping it for now. + + /// @idl readonly attribute TextTrackList textTracks; + /// @stub text tracks aren’t implemented yet—will they be? + "textTracks": { + get: function() { + return document.createElement("video").textTracks; + } + }, + + // addTextTrack() is a simple property and so is added later. + + // The remainder is things that are not part of HTMLMediaElement, as noted earlier. + + /// The window title. + /// + /// @idl attribute DOMString title; + "title": { + get: function() { + return this["_"].titleElement.textContent; + }, + set: function(value) { + this["_"].titleElement.textContent = value; + this["_"].fireSimpleEvent("titlechange"); + } + }, + + /// defaultTitle is to title as defaultRateChange is to rateChange. + /// + /// @idl attribute DOMString defaultTitle; + "defaultTitle": { + get: function() { + return this["_"].defaultTitle; + }, + set: function(value) { + this["_"].defaultTitle = value; + this["_"].fireSimpleEvent("titlechange"); + } + }, + + /// The number of columns in the terminal. + /// This is like HTMLVideoElement.videoWidth but not in pixels. + /// + /// Read-only as it’s rarely altered alone; use this.resize(cols, this.rows) instead. + "cols": { + get: function() { + return this["_"].terminal.cols; + } + }, + + /// The number of rows in the terminal. + /// This is like HTMLVideoElement.videoHeight but not in pixels. + /// + /// Read-only as it’s rarely altered alone; use this.resize(this.cols, rows) instead. + "rows": { + get: function() { + return this["_"].terminal.rows; + } + }, + + // Borrowed from HTMLVideoElement. + /// @idl attribute DOMString poster; + "poster": { + get: function() { + return (this.getAttribute("poster") || "").trim(); + }, + set: function(value) { + this.setAttribute("poster", value); + } + } +}); + +// Here are the simple properties that don’t go in the defineProperties block above. + +/// @idl void load(); +TTYPlayerPrototype["load"] = function() { + this["_"].mediaLoadAlgorithm(); +}; + +/// @idl CanPlayTypeEnum canPlayType(DOMString type); +/// @stub we only support one format at present, anyway. +TTYPlayerPrototype["canPlayType"] = function() { + return "maybe"; +}; + +/// @idl void play(); +TTYPlayerPrototype["play"] = function() { + var self = this; + + function realPlay() { + if (self["ended"]) { + self["currentTime"] = self["playbackRate"] < 0 ? self["duration"] : 0; + } + self["_"].showPoster = false; + self["_"].paused = false; + var lastTime = new Date(); + self["_"].ticker = setInterval(function() { + var newTime = new Date(); + if (!self["_"].semipaused) { + self["currentTime"] += (newTime - lastTime) / 1000 * self["playbackRate"]; + } + lastTime = newTime; + }, TICK); + self["_"].fireSimpleEvent("play"); + } + + function loaded() { + self.removeEventListener("loadeddata", loaded); + realPlay(); + } + + if (this["_"].paused) { + if (this["_"].data) { + realPlay(); + } else { + this.addEventListener("loadeddata", loaded); + this["_"].loadIfNotLoading(); + } + } +}; + +/// @idl void pause(); +TTYPlayerPrototype["pause"] = function() { + if (!this["_"].paused) { + this["_"].paused = true; + clearInterval(this["_"].ticker); + this["_"].fireSimpleEvent("pause"); + } +}; + +/// @idl attribute double volume; +/// @stub volume is irrelevant +TTYPlayerPrototype["volume"] = 1; + +/// @idl attribute boolean muted; +/// @stub volume is irrelevant +TTYPlayerPrototype["muted"] = false; + +/// @idl TextTrack addTextTrack(TextTrackKind kind, optional DOMString label = "", optional DOMString language = ""); +/// @stub text tracks aren’t implemented yet—will they be? +TTYPlayerPrototype["addTextTrack"] = function() { + return null; +}; +// This should theoretically go on HTMLElement.prototype. Too bad. +/// @idl attribute EventHandler ontitlechange; +TTYPlayerPrototype["ontitlechange"] = null; + +TTYPlayerPrototype["resize"] = function(x, y) { + this["_"].terminal.resize(x, y); +}; + +TTYPlayerPrototype["pretendToBeAVideo"] = function() { + Object.defineProperties(this, { + /** @lends {TTYPlayerPrototype} */ + + // Let’s pretend (badly) that we’re an HTMLVideoElement! + "tagName": {value: "VIDEO"}, + "width": { + get: function() { + return this.offsetWidth; + }, + set: function(value) { + // TODO this is a little poor as a technique, refine it. + this.style.fontSize = "100%"; + this.style.fontSize = (value / this.offsetWidth * 100) + "%"; + } + }, + "height": { + get: function() { + return this.offsetHeight; + }, + set: function(value) { + // TODO this is a little poor as a technique, refine it. + this.style.fontSize = "100%"; + this.style.fontSize = (value / this.offsetHeight * 100) + "%"; + } + }, + "videoWidth": { + get: function() { + return this["width"]; + } + }, + "videoHeight": { + get: function() { + return this["height"]; + } + } + }); +}; + +document.registerElement("tty-player", {prototype: TTYPlayerPrototype}); +})(); diff --git a/docs.it4i/js/webcomponents-lite.min.js b/docs.it4i/js/webcomponents-lite.min.js new file mode 100644 index 0000000000000000000000000000000000000000..abb6ff6700e7b1ad880e305f521b53708ff49bff --- /dev/null +++ b/docs.it4i/js/webcomponents-lite.min.js @@ -0,0 +1,13 @@ +/** + * @license + * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt + */ +// @version 0.7.5 +window.WebComponents=window.WebComponents||{},function(e){var t=e.flags||{},n="webcomponents-lite.js",r=document.querySelector('script[src*="'+n+'"]');if(!t.noOpts){if(location.search.slice(1).split("&").forEach(function(e){var n,r=e.split("=");r[0]&&(n=r[0].match(/wc-(.+)/))&&(t[n[1]]=r[1]||!0)}),r)for(var o,i=0;o=r.attributes[i];i++)"src"!==o.name&&(t[o.name]=o.value||!0);if(t.log){var a=t.log.split(",");t.log={},a.forEach(function(e){t.log[e]=!0})}else t.log={}}t.shadow=t.shadow||t.shadowdom||t.polyfill,t.shadow="native"===t.shadow?!1:t.shadow||!HTMLElement.prototype.createShadowRoot,t.register&&(window.CustomElements=window.CustomElements||{flags:{}},window.CustomElements.flags.register=t.register),e.flags=t}(window.WebComponents),function(e){"use strict";function t(e){return void 0!==h[e]}function n(){s.call(this),this._isInvalid=!0}function r(e){return""==e&&n.call(this),e.toLowerCase()}function o(e){var t=e.charCodeAt(0);return t>32&&127>t&&-1==[34,35,60,62,63,96].indexOf(t)?e:encodeURIComponent(e)}function i(e){var t=e.charCodeAt(0);return t>32&&127>t&&-1==[34,35,60,62,96].indexOf(t)?e:encodeURIComponent(e)}function a(e,a,s){function c(e){b.push(e)}var d=a||"scheme start",u=0,l="",_=!1,w=!1,b=[];e:for(;(e[u-1]!=f||0==u)&&!this._isInvalid;){var g=e[u];switch(d){case"scheme start":if(!g||!m.test(g)){if(a){c("Invalid scheme.");break e}l="",d="no scheme";continue}l+=g.toLowerCase(),d="scheme";break;case"scheme":if(g&&v.test(g))l+=g.toLowerCase();else{if(":"!=g){if(a){if(f==g)break e;c("Code point not allowed in scheme: "+g);break e}l="",u=0,d="no scheme";continue}if(this._scheme=l,l="",a)break e;t(this._scheme)&&(this._isRelative=!0),d="file"==this._scheme?"relative":this._isRelative&&s&&s._scheme==this._scheme?"relative or authority":this._isRelative?"authority first slash":"scheme data"}break;case"scheme data":"?"==g?(this._query="?",d="query"):"#"==g?(this._fragment="#",d="fragment"):f!=g&&" "!=g&&"\n"!=g&&"\r"!=g&&(this._schemeData+=o(g));break;case"no scheme":if(s&&t(s._scheme)){d="relative";continue}c("Missing scheme."),n.call(this);break;case"relative or authority":if("/"!=g||"/"!=e[u+1]){c("Expected /, got: "+g),d="relative";continue}d="authority ignore slashes";break;case"relative":if(this._isRelative=!0,"file"!=this._scheme&&(this._scheme=s._scheme),f==g){this._host=s._host,this._port=s._port,this._path=s._path.slice(),this._query=s._query,this._username=s._username,this._password=s._password;break e}if("/"==g||"\\"==g)"\\"==g&&c("\\ is an invalid code point."),d="relative slash";else if("?"==g)this._host=s._host,this._port=s._port,this._path=s._path.slice(),this._query="?",this._username=s._username,this._password=s._password,d="query";else{if("#"!=g){var y=e[u+1],E=e[u+2];("file"!=this._scheme||!m.test(g)||":"!=y&&"|"!=y||f!=E&&"/"!=E&&"\\"!=E&&"?"!=E&&"#"!=E)&&(this._host=s._host,this._port=s._port,this._username=s._username,this._password=s._password,this._path=s._path.slice(),this._path.pop()),d="relative path";continue}this._host=s._host,this._port=s._port,this._path=s._path.slice(),this._query=s._query,this._fragment="#",this._username=s._username,this._password=s._password,d="fragment"}break;case"relative slash":if("/"!=g&&"\\"!=g){"file"!=this._scheme&&(this._host=s._host,this._port=s._port,this._username=s._username,this._password=s._password),d="relative path";continue}"\\"==g&&c("\\ is an invalid code point."),d="file"==this._scheme?"file host":"authority ignore slashes";break;case"authority first slash":if("/"!=g){c("Expected '/', got: "+g),d="authority ignore slashes";continue}d="authority second slash";break;case"authority second slash":if(d="authority ignore slashes","/"!=g){c("Expected '/', got: "+g);continue}break;case"authority ignore slashes":if("/"!=g&&"\\"!=g){d="authority";continue}c("Expected authority, got: "+g);break;case"authority":if("@"==g){_&&(c("@ already seen."),l+="%40"),_=!0;for(var L=0;L<l.length;L++){var M=l[L];if(" "!=M&&"\n"!=M&&"\r"!=M)if(":"!=M||null!==this._password){var T=o(M);null!==this._password?this._password+=T:this._username+=T}else this._password="";else c("Invalid whitespace in authority.")}l=""}else{if(f==g||"/"==g||"\\"==g||"?"==g||"#"==g){u-=l.length,l="",d="host";continue}l+=g}break;case"file host":if(f==g||"/"==g||"\\"==g||"?"==g||"#"==g){2!=l.length||!m.test(l[0])||":"!=l[1]&&"|"!=l[1]?0==l.length?d="relative path start":(this._host=r.call(this,l),l="",d="relative path start"):d="relative path";continue}" "==g||"\n"==g||"\r"==g?c("Invalid whitespace in file host."):l+=g;break;case"host":case"hostname":if(":"!=g||w){if(f==g||"/"==g||"\\"==g||"?"==g||"#"==g){if(this._host=r.call(this,l),l="",d="relative path start",a)break e;continue}" "!=g&&"\n"!=g&&"\r"!=g?("["==g?w=!0:"]"==g&&(w=!1),l+=g):c("Invalid code point in host/hostname: "+g)}else if(this._host=r.call(this,l),l="",d="port","hostname"==a)break e;break;case"port":if(/[0-9]/.test(g))l+=g;else{if(f==g||"/"==g||"\\"==g||"?"==g||"#"==g||a){if(""!=l){var N=parseInt(l,10);N!=h[this._scheme]&&(this._port=N+""),l=""}if(a)break e;d="relative path start";continue}" "==g||"\n"==g||"\r"==g?c("Invalid code point in port: "+g):n.call(this)}break;case"relative path start":if("\\"==g&&c("'\\' not allowed in path."),d="relative path","/"!=g&&"\\"!=g)continue;break;case"relative path":if(f!=g&&"/"!=g&&"\\"!=g&&(a||"?"!=g&&"#"!=g))" "!=g&&"\n"!=g&&"\r"!=g&&(l+=o(g));else{"\\"==g&&c("\\ not allowed in relative path.");var O;(O=p[l.toLowerCase()])&&(l=O),".."==l?(this._path.pop(),"/"!=g&&"\\"!=g&&this._path.push("")):"."==l&&"/"!=g&&"\\"!=g?this._path.push(""):"."!=l&&("file"==this._scheme&&0==this._path.length&&2==l.length&&m.test(l[0])&&"|"==l[1]&&(l=l[0]+":"),this._path.push(l)),l="","?"==g?(this._query="?",d="query"):"#"==g&&(this._fragment="#",d="fragment")}break;case"query":a||"#"!=g?f!=g&&" "!=g&&"\n"!=g&&"\r"!=g&&(this._query+=i(g)):(this._fragment="#",d="fragment");break;case"fragment":f!=g&&" "!=g&&"\n"!=g&&"\r"!=g&&(this._fragment+=g)}u++}}function s(){this._scheme="",this._schemeData="",this._username="",this._password=null,this._host="",this._port="",this._path=[],this._query="",this._fragment="",this._isInvalid=!1,this._isRelative=!1}function c(e,t){void 0===t||t instanceof c||(t=new c(String(t))),this._url=e,s.call(this);var n=e.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g,"");a.call(this,n,null,t)}var d=!1;if(!e.forceJURL)try{var u=new URL("b","http://a");u.pathname="c%20d",d="http://a/c%20d"===u.href}catch(l){}if(!d){var h=Object.create(null);h.ftp=21,h.file=0,h.gopher=70,h.http=80,h.https=443,h.ws=80,h.wss=443;var p=Object.create(null);p["%2e"]=".",p[".%2e"]="..",p["%2e."]="..",p["%2e%2e"]="..";var f=void 0,m=/[a-zA-Z]/,v=/[a-zA-Z0-9\+\-\.]/;c.prototype={toString:function(){return this.href},get href(){if(this._isInvalid)return this._url;var e="";return(""!=this._username||null!=this._password)&&(e=this._username+(null!=this._password?":"+this._password:"")+"@"),this.protocol+(this._isRelative?"//"+e+this.host:"")+this.pathname+this._query+this._fragment},set href(e){s.call(this),a.call(this,e)},get protocol(){return this._scheme+":"},set protocol(e){this._isInvalid||a.call(this,e+":","scheme start")},get host(){return this._isInvalid?"":this._port?this._host+":"+this._port:this._host},set host(e){!this._isInvalid&&this._isRelative&&a.call(this,e,"host")},get hostname(){return this._host},set hostname(e){!this._isInvalid&&this._isRelative&&a.call(this,e,"hostname")},get port(){return this._port},set port(e){!this._isInvalid&&this._isRelative&&a.call(this,e,"port")},get pathname(){return this._isInvalid?"":this._isRelative?"/"+this._path.join("/"):this._schemeData},set pathname(e){!this._isInvalid&&this._isRelative&&(this._path=[],a.call(this,e,"relative path start"))},get search(){return this._isInvalid||!this._query||"?"==this._query?"":this._query},set search(e){!this._isInvalid&&this._isRelative&&(this._query="?","?"==e[0]&&(e=e.slice(1)),a.call(this,e,"query"))},get hash(){return this._isInvalid||!this._fragment||"#"==this._fragment?"":this._fragment},set hash(e){this._isInvalid||(this._fragment="#","#"==e[0]&&(e=e.slice(1)),a.call(this,e,"fragment"))},get origin(){var e;if(this._isInvalid||!this._scheme)return"";switch(this._scheme){case"data":case"file":case"javascript":case"mailto":return"null"}return e=this.host,e?this._scheme+"://"+e:""}};var _=e.URL;_&&(c.createObjectURL=function(e){return _.createObjectURL.apply(_,arguments)},c.revokeObjectURL=function(e){_.revokeObjectURL(e)}),e.URL=c}}(this),"undefined"==typeof WeakMap&&!function(){var e=Object.defineProperty,t=Date.now()%1e9,n=function(){this.name="__st"+(1e9*Math.random()>>>0)+(t++ +"__")};n.prototype={set:function(t,n){var r=t[this.name];return r&&r[0]===t?r[1]=n:e(t,this.name,{value:[t,n],writable:!0}),this},get:function(e){var t;return(t=e[this.name])&&t[0]===e?t[1]:void 0},"delete":function(e){var t=e[this.name];return t&&t[0]===e?(t[0]=t[1]=void 0,!0):!1},has:function(e){var t=e[this.name];return t?t[0]===e:!1}},window.WeakMap=n}(),function(e){function t(e){g.push(e),b||(b=!0,m(r))}function n(e){return window.ShadowDOMPolyfill&&window.ShadowDOMPolyfill.wrapIfNeeded(e)||e}function r(){b=!1;var e=g;g=[],e.sort(function(e,t){return e.uid_-t.uid_});var t=!1;e.forEach(function(e){var n=e.takeRecords();o(e),n.length&&(e.callback_(n,e),t=!0)}),t&&r()}function o(e){e.nodes_.forEach(function(t){var n=v.get(t);n&&n.forEach(function(t){t.observer===e&&t.removeTransientObservers()})})}function i(e,t){for(var n=e;n;n=n.parentNode){var r=v.get(n);if(r)for(var o=0;o<r.length;o++){var i=r[o],a=i.options;if(n===e||a.subtree){var s=t(a);s&&i.enqueue(s)}}}}function a(e){this.callback_=e,this.nodes_=[],this.records_=[],this.uid_=++y}function s(e,t){this.type=e,this.target=t,this.addedNodes=[],this.removedNodes=[],this.previousSibling=null,this.nextSibling=null,this.attributeName=null,this.attributeNamespace=null,this.oldValue=null}function c(e){var t=new s(e.type,e.target);return t.addedNodes=e.addedNodes.slice(),t.removedNodes=e.removedNodes.slice(),t.previousSibling=e.previousSibling,t.nextSibling=e.nextSibling,t.attributeName=e.attributeName,t.attributeNamespace=e.attributeNamespace,t.oldValue=e.oldValue,t}function d(e,t){return E=new s(e,t)}function u(e){return L?L:(L=c(E),L.oldValue=e,L)}function l(){E=L=void 0}function h(e){return e===L||e===E}function p(e,t){return e===t?e:L&&h(e)?L:null}function f(e,t,n){this.observer=e,this.target=t,this.options=n,this.transientObservedNodes=[]}var m,v=new WeakMap;if(/Trident|Edge/.test(navigator.userAgent))m=setTimeout;else if(window.setImmediate)m=window.setImmediate;else{var _=[],w=String(Math.random());window.addEventListener("message",function(e){if(e.data===w){var t=_;_=[],t.forEach(function(e){e()})}}),m=function(e){_.push(e),window.postMessage(w,"*")}}var b=!1,g=[],y=0;a.prototype={observe:function(e,t){if(e=n(e),!t.childList&&!t.attributes&&!t.characterData||t.attributeOldValue&&!t.attributes||t.attributeFilter&&t.attributeFilter.length&&!t.attributes||t.characterDataOldValue&&!t.characterData)throw new SyntaxError;var r=v.get(e);r||v.set(e,r=[]);for(var o,i=0;i<r.length;i++)if(r[i].observer===this){o=r[i],o.removeListeners(),o.options=t;break}o||(o=new f(this,e,t),r.push(o),this.nodes_.push(e)),o.addListeners()},disconnect:function(){this.nodes_.forEach(function(e){for(var t=v.get(e),n=0;n<t.length;n++){var r=t[n];if(r.observer===this){r.removeListeners(),t.splice(n,1);break}}},this),this.records_=[]},takeRecords:function(){var e=this.records_;return this.records_=[],e}};var E,L;f.prototype={enqueue:function(e){var n=this.observer.records_,r=n.length;if(n.length>0){var o=n[r-1],i=p(o,e);if(i)return void(n[r-1]=i)}else t(this.observer);n[r]=e},addListeners:function(){this.addListeners_(this.target)},addListeners_:function(e){var t=this.options;t.attributes&&e.addEventListener("DOMAttrModified",this,!0),t.characterData&&e.addEventListener("DOMCharacterDataModified",this,!0),t.childList&&e.addEventListener("DOMNodeInserted",this,!0),(t.childList||t.subtree)&&e.addEventListener("DOMNodeRemoved",this,!0)},removeListeners:function(){this.removeListeners_(this.target)},removeListeners_:function(e){var t=this.options;t.attributes&&e.removeEventListener("DOMAttrModified",this,!0),t.characterData&&e.removeEventListener("DOMCharacterDataModified",this,!0),t.childList&&e.removeEventListener("DOMNodeInserted",this,!0),(t.childList||t.subtree)&&e.removeEventListener("DOMNodeRemoved",this,!0)},addTransientObserver:function(e){if(e!==this.target){this.addListeners_(e),this.transientObservedNodes.push(e);var t=v.get(e);t||v.set(e,t=[]),t.push(this)}},removeTransientObservers:function(){var e=this.transientObservedNodes;this.transientObservedNodes=[],e.forEach(function(e){this.removeListeners_(e);for(var t=v.get(e),n=0;n<t.length;n++)if(t[n]===this){t.splice(n,1);break}},this)},handleEvent:function(e){switch(e.stopImmediatePropagation(),e.type){case"DOMAttrModified":var t=e.attrName,n=e.relatedNode.namespaceURI,r=e.target,o=new d("attributes",r);o.attributeName=t,o.attributeNamespace=n;var a=e.attrChange===MutationEvent.ADDITION?null:e.prevValue;i(r,function(e){return!e.attributes||e.attributeFilter&&e.attributeFilter.length&&-1===e.attributeFilter.indexOf(t)&&-1===e.attributeFilter.indexOf(n)?void 0:e.attributeOldValue?u(a):o});break;case"DOMCharacterDataModified":var r=e.target,o=d("characterData",r),a=e.prevValue;i(r,function(e){return e.characterData?e.characterDataOldValue?u(a):o:void 0});break;case"DOMNodeRemoved":this.addTransientObserver(e.target);case"DOMNodeInserted":var s,c,h=e.target;"DOMNodeInserted"===e.type?(s=[h],c=[]):(s=[],c=[h]);var p=h.previousSibling,f=h.nextSibling,o=d("childList",e.target.parentNode);o.addedNodes=s,o.removedNodes=c,o.previousSibling=p,o.nextSibling=f,i(e.relatedNode,function(e){return e.childList?o:void 0})}l()}},e.JsMutationObserver=a,e.MutationObserver||(e.MutationObserver=a)}(this),window.HTMLImports=window.HTMLImports||{flags:{}},function(e){function t(e,t){t=t||f,r(function(){i(e,t)},t)}function n(e){return"complete"===e.readyState||e.readyState===_}function r(e,t){if(n(t))e&&e();else{var o=function(){("complete"===t.readyState||t.readyState===_)&&(t.removeEventListener(w,o),r(e,t))};t.addEventListener(w,o)}}function o(e){e.target.__loaded=!0}function i(e,t){function n(){c==d&&e&&e({allImports:s,loadedImports:u,errorImports:l})}function r(e){o(e),u.push(this),c++,n()}function i(e){l.push(this),c++,n()}var s=t.querySelectorAll("link[rel=import]"),c=0,d=s.length,u=[],l=[];if(d)for(var h,p=0;d>p&&(h=s[p]);p++)a(h)?(c++,n()):(h.addEventListener("load",r),h.addEventListener("error",i));else n()}function a(e){return l?e.__loaded||e["import"]&&"loading"!==e["import"].readyState:e.__importParsed}function s(e){for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)c(t)&&d(t)}function c(e){return"link"===e.localName&&"import"===e.rel}function d(e){var t=e["import"];t?o({target:e}):(e.addEventListener("load",o),e.addEventListener("error",o))}var u="import",l=Boolean(u in document.createElement("link")),h=Boolean(window.ShadowDOMPolyfill),p=function(e){return h?window.ShadowDOMPolyfill.wrapIfNeeded(e):e},f=p(document),m={get:function(){var e=window.HTMLImports.currentScript||document.currentScript||("complete"!==document.readyState?document.scripts[document.scripts.length-1]:null);return p(e)},configurable:!0};Object.defineProperty(document,"_currentScript",m),Object.defineProperty(f,"_currentScript",m);var v=/Trident/.test(navigator.userAgent),_=v?"complete":"interactive",w="readystatechange";l&&(new MutationObserver(function(e){for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)t.addedNodes&&s(t.addedNodes)}).observe(document.head,{childList:!0}),function(){if("loading"===document.readyState)for(var e,t=document.querySelectorAll("link[rel=import]"),n=0,r=t.length;r>n&&(e=t[n]);n++)d(e)}()),t(function(e){window.HTMLImports.ready=!0,window.HTMLImports.readyTime=(new Date).getTime();var t=f.createEvent("CustomEvent");t.initCustomEvent("HTMLImportsLoaded",!0,!0,e),f.dispatchEvent(t)}),e.IMPORT_LINK_TYPE=u,e.useNative=l,e.rootDocument=f,e.whenReady=t,e.isIE=v}(window.HTMLImports),function(e){var t=[],n=function(e){t.push(e)},r=function(){t.forEach(function(t){t(e)})};e.addModule=n,e.initializeModules=r}(window.HTMLImports),window.HTMLImports.addModule(function(e){var t=/(url\()([^)]*)(\))/g,n=/(@import[\s]+(?!url\())([^;]*)(;)/g,r={resolveUrlsInStyle:function(e,t){var n=e.ownerDocument,r=n.createElement("a");return e.textContent=this.resolveUrlsInCssText(e.textContent,t,r),e},resolveUrlsInCssText:function(e,r,o){var i=this.replaceUrls(e,o,r,t);return i=this.replaceUrls(i,o,r,n)},replaceUrls:function(e,t,n,r){return e.replace(r,function(e,r,o,i){var a=o.replace(/["']/g,"");return n&&(a=new URL(a,n).href),t.href=a,a=t.href,r+"'"+a+"'"+i})}};e.path=r}),window.HTMLImports.addModule(function(e){var t={async:!0,ok:function(e){return e.status>=200&&e.status<300||304===e.status||0===e.status},load:function(n,r,o){var i=new XMLHttpRequest;return(e.flags.debug||e.flags.bust)&&(n+="?"+Math.random()),i.open("GET",n,t.async),i.addEventListener("readystatechange",function(e){if(4===i.readyState){var n=i.getResponseHeader("Location"),a=null;if(n)var a="/"===n.substr(0,1)?location.origin+n:n;r.call(o,!t.ok(i)&&i,i.response||i.responseText,a)}}),i.send(),i},loadDocument:function(e,t,n){this.load(e,t,n).responseType="document"}};e.xhr=t}),window.HTMLImports.addModule(function(e){var t=e.xhr,n=e.flags,r=function(e,t){this.cache={},this.onload=e,this.oncomplete=t,this.inflight=0,this.pending={}};r.prototype={addNodes:function(e){this.inflight+=e.length;for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)this.require(t);this.checkDone()},addNode:function(e){this.inflight++,this.require(e),this.checkDone()},require:function(e){var t=e.src||e.href;e.__nodeUrl=t,this.dedupe(t,e)||this.fetch(t,e)},dedupe:function(e,t){if(this.pending[e])return this.pending[e].push(t),!0;return this.cache[e]?(this.onload(e,t,this.cache[e]),this.tail(),!0):(this.pending[e]=[t],!1)},fetch:function(e,r){if(n.load&&console.log("fetch",e,r),e)if(e.match(/^data:/)){var o=e.split(","),i=o[0],a=o[1];a=i.indexOf(";base64")>-1?atob(a):decodeURIComponent(a),setTimeout(function(){this.receive(e,r,null,a)}.bind(this),0)}else{var s=function(t,n,o){this.receive(e,r,t,n,o)}.bind(this);t.load(e,s)}else setTimeout(function(){this.receive(e,r,{error:"href must be specified"},null)}.bind(this),0)},receive:function(e,t,n,r,o){this.cache[e]=r;for(var i,a=this.pending[e],s=0,c=a.length;c>s&&(i=a[s]);s++)this.onload(e,i,r,n,o),this.tail();this.pending[e]=null},tail:function(){--this.inflight,this.checkDone()},checkDone:function(){this.inflight||this.oncomplete()}},e.Loader=r}),window.HTMLImports.addModule(function(e){var t=function(e){this.addCallback=e,this.mo=new MutationObserver(this.handler.bind(this))};t.prototype={handler:function(e){for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)"childList"===t.type&&t.addedNodes.length&&this.addedNodes(t.addedNodes)},addedNodes:function(e){this.addCallback&&this.addCallback(e);for(var t,n=0,r=e.length;r>n&&(t=e[n]);n++)t.children&&t.children.length&&this.addedNodes(t.children)},observe:function(e){this.mo.observe(e,{childList:!0,subtree:!0})}},e.Observer=t}),window.HTMLImports.addModule(function(e){function t(e){return"link"===e.localName&&e.rel===u}function n(e){var t=r(e);return"data:text/javascript;charset=utf-8,"+encodeURIComponent(t)}function r(e){return e.textContent+o(e)}function o(e){var t=e.ownerDocument;t.__importedScripts=t.__importedScripts||0;var n=e.ownerDocument.baseURI,r=t.__importedScripts?"-"+t.__importedScripts:"";return t.__importedScripts++,"\n//# sourceURL="+n+r+".js\n"}function i(e){var t=e.ownerDocument.createElement("style");return t.textContent=e.textContent,a.resolveUrlsInStyle(t),t}var a=e.path,s=e.rootDocument,c=e.flags,d=e.isIE,u=e.IMPORT_LINK_TYPE,l="link[rel="+u+"]",h={documentSelectors:l,importsSelectors:[l,"link[rel=stylesheet]","style","script:not([type])",'script[type="application/javascript"]','script[type="text/javascript"]'].join(","),map:{link:"parseLink",script:"parseScript",style:"parseStyle"},dynamicElements:[],parseNext:function(){var e=this.nextToParse();e&&this.parse(e)},parse:function(e){if(this.isParsed(e))return void(c.parse&&console.log("[%s] is already parsed",e.localName));var t=this[this.map[e.localName]];t&&(this.markParsing(e),t.call(this,e))},parseDynamic:function(e,t){this.dynamicElements.push(e),t||this.parseNext()},markParsing:function(e){c.parse&&console.log("parsing",e),this.parsingElement=e},markParsingComplete:function(e){e.__importParsed=!0,this.markDynamicParsingComplete(e),e.__importElement&&(e.__importElement.__importParsed=!0,this.markDynamicParsingComplete(e.__importElement)),this.parsingElement=null,c.parse&&console.log("completed",e)},markDynamicParsingComplete:function(e){var t=this.dynamicElements.indexOf(e);t>=0&&this.dynamicElements.splice(t,1)},parseImport:function(e){if(window.HTMLImports.__importsParsingHook&&window.HTMLImports.__importsParsingHook(e),e["import"]&&(e["import"].__importParsed=!0),this.markParsingComplete(e),e.dispatchEvent(e.__resource&&!e.__error?new CustomEvent("load",{bubbles:!1}):new CustomEvent("error",{bubbles:!1})),e.__pending)for(var t;e.__pending.length;)t=e.__pending.shift(),t&&t({target:e});this.parseNext()},parseLink:function(e){t(e)?this.parseImport(e):(e.href=e.href,this.parseGeneric(e))},parseStyle:function(e){var t=e;e=i(e),t.__appliedElement=e,e.__importElement=t,this.parseGeneric(e)},parseGeneric:function(e){this.trackElement(e),this.addElementToDocument(e)},rootImportForElement:function(e){for(var t=e;t.ownerDocument.__importLink;)t=t.ownerDocument.__importLink;return t},addElementToDocument:function(e){var t=this.rootImportForElement(e.__importElement||e);t.parentNode.insertBefore(e,t)},trackElement:function(e,t){var n=this,r=function(r){t&&t(r),n.markParsingComplete(e),n.parseNext()};if(e.addEventListener("load",r),e.addEventListener("error",r),d&&"style"===e.localName){var o=!1;if(-1==e.textContent.indexOf("@import"))o=!0;else if(e.sheet){o=!0;for(var i,a=e.sheet.cssRules,s=a?a.length:0,c=0;s>c&&(i=a[c]);c++)i.type===CSSRule.IMPORT_RULE&&(o=o&&Boolean(i.styleSheet))}o&&setTimeout(function(){e.dispatchEvent(new CustomEvent("load",{bubbles:!1}))})}},parseScript:function(t){var r=document.createElement("script");r.__importElement=t,r.src=t.src?t.src:n(t),e.currentScript=t,this.trackElement(r,function(t){r.parentNode.removeChild(r),e.currentScript=null}),this.addElementToDocument(r)},nextToParse:function(){return this._mayParse=[],!this.parsingElement&&(this.nextToParseInDoc(s)||this.nextToParseDynamic())},nextToParseInDoc:function(e,n){if(e&&this._mayParse.indexOf(e)<0){this._mayParse.push(e);for(var r,o=e.querySelectorAll(this.parseSelectorsForNode(e)),i=0,a=o.length;a>i&&(r=o[i]);i++)if(!this.isParsed(r))return this.hasResource(r)?t(r)?this.nextToParseInDoc(r["import"],r):r:void 0}return n},nextToParseDynamic:function(){return this.dynamicElements[0]},parseSelectorsForNode:function(e){var t=e.ownerDocument||e;return t===s?this.documentSelectors:this.importsSelectors},isParsed:function(e){return e.__importParsed},needsDynamicParsing:function(e){return this.dynamicElements.indexOf(e)>=0},hasResource:function(e){return t(e)&&void 0===e["import"]?!1:!0}};e.parser=h,e.IMPORT_SELECTOR=l}),window.HTMLImports.addModule(function(e){function t(e){return n(e,a)}function n(e,t){return"link"===e.localName&&e.getAttribute("rel")===t}function r(e){return!!Object.getOwnPropertyDescriptor(e,"baseURI")}function o(e,t){var n=document.implementation.createHTMLDocument(a);n._URL=t;var o=n.createElement("base");o.setAttribute("href",t),n.baseURI||r(n)||Object.defineProperty(n,"baseURI",{value:t});var i=n.createElement("meta");return i.setAttribute("charset","utf-8"),n.head.appendChild(i),n.head.appendChild(o),n.body.innerHTML=e,window.HTMLTemplateElement&&HTMLTemplateElement.bootstrap&&HTMLTemplateElement.bootstrap(n),n}var i=e.flags,a=e.IMPORT_LINK_TYPE,s=e.IMPORT_SELECTOR,c=e.rootDocument,d=e.Loader,u=e.Observer,l=e.parser,h={documents:{},documentPreloadSelectors:s,importsPreloadSelectors:[s].join(","),loadNode:function(e){p.addNode(e)},loadSubtree:function(e){var t=this.marshalNodes(e);p.addNodes(t)},marshalNodes:function(e){return e.querySelectorAll(this.loadSelectorsForNode(e))},loadSelectorsForNode:function(e){var t=e.ownerDocument||e;return t===c?this.documentPreloadSelectors:this.importsPreloadSelectors},loaded:function(e,n,r,a,s){if(i.load&&console.log("loaded",e,n),n.__resource=r,n.__error=a,t(n)){var c=this.documents[e];void 0===c&&(c=a?null:o(r,s||e),c&&(c.__importLink=n,this.bootDocument(c)),this.documents[e]=c),n["import"]=c}l.parseNext()},bootDocument:function(e){this.loadSubtree(e),this.observer.observe(e),l.parseNext()},loadedAll:function(){l.parseNext()}},p=new d(h.loaded.bind(h),h.loadedAll.bind(h));if(h.observer=new u,!document.baseURI){var f={get:function(){var e=document.querySelector("base");return e?e.href:window.location.href},configurable:!0};Object.defineProperty(document,"baseURI",f),Object.defineProperty(c,"baseURI",f)}e.importer=h,e.importLoader=p}),window.HTMLImports.addModule(function(e){var t=e.parser,n=e.importer,r={added:function(e){for(var r,o,i,a,s=0,c=e.length;c>s&&(a=e[s]);s++)r||(r=a.ownerDocument,o=t.isParsed(r)),i=this.shouldLoadNode(a),i&&n.loadNode(a),this.shouldParseNode(a)&&o&&t.parseDynamic(a,i)},shouldLoadNode:function(e){return 1===e.nodeType&&o.call(e,n.loadSelectorsForNode(e))},shouldParseNode:function(e){return 1===e.nodeType&&o.call(e,t.parseSelectorsForNode(e))}};n.observer.addCallback=r.added.bind(r);var o=HTMLElement.prototype.matches||HTMLElement.prototype.matchesSelector||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector}),function(e){function t(){window.HTMLImports.importer.bootDocument(o)}var n=e.initializeModules,r=e.isIE;if(!e.useNative){r&&"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,Boolean(t.bubbles),Boolean(t.cancelable),t.detail),n.preventDefault=function(){Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})},n},window.CustomEvent.prototype=window.Event.prototype),n();var o=e.rootDocument;"complete"===document.readyState||"interactive"===document.readyState&&!window.attachEvent?t():document.addEventListener("DOMContentLoaded",t)}}(window.HTMLImports),window.CustomElements=window.CustomElements||{flags:{}},function(e){var t=e.flags,n=[],r=function(e){n.push(e)},o=function(){n.forEach(function(t){t(e)})};e.addModule=r,e.initializeModules=o,e.hasNative=Boolean(document.registerElement),e.useNative=!t.register&&e.hasNative&&!window.ShadowDOMPolyfill&&(!window.HTMLImports||window.HTMLImports.useNative)}(window.CustomElements),window.CustomElements.addModule(function(e){function t(e,t){n(e,function(e){return t(e)?!0:void r(e,t)}),r(e,t)}function n(e,t,r){var o=e.firstElementChild;if(!o)for(o=e.firstChild;o&&o.nodeType!==Node.ELEMENT_NODE;)o=o.nextSibling;for(;o;)t(o,r)!==!0&&n(o,t,r),o=o.nextElementSibling;return null}function r(e,n){for(var r=e.shadowRoot;r;)t(r,n),r=r.olderShadowRoot}function o(e,t){i(e,t,[])}function i(e,t,n){if(e=window.wrap(e),!(n.indexOf(e)>=0)){n.push(e);for(var r,o=e.querySelectorAll("link[rel="+a+"]"),s=0,c=o.length;c>s&&(r=o[s]);s++)r["import"]&&i(r["import"],t,n);t(e)}}var a=window.HTMLImports?window.HTMLImports.IMPORT_LINK_TYPE:"none";e.forDocumentTree=o,e.forSubtree=t}),window.CustomElements.addModule(function(e){function t(e){return n(e)||r(e)}function n(t){return e.upgrade(t)?!0:void s(t)}function r(e){g(e,function(e){return n(e)?!0:void 0})}function o(e){s(e),h(e)&&g(e,function(e){s(e)})}function i(e){M.push(e),L||(L=!0,setTimeout(a))}function a(){L=!1;for(var e,t=M,n=0,r=t.length;r>n&&(e=t[n]);n++)e();M=[]}function s(e){E?i(function(){c(e)}):c(e)}function c(e){e.__upgraded__&&(e.attachedCallback||e.detachedCallback)&&!e.__attached&&h(e)&&(e.__attached=!0,e.attachedCallback&&e.attachedCallback())}function d(e){u(e),g(e,function(e){u(e)})}function u(e){E?i(function(){l(e)}):l(e)}function l(e){e.__upgraded__&&(e.attachedCallback||e.detachedCallback)&&e.__attached&&!h(e)&&(e.__attached=!1,e.detachedCallback&&e.detachedCallback())}function h(e){for(var t=e,n=wrap(document);t;){if(t==n)return!0;t=t.parentNode||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&t.host}}function p(e){if(e.shadowRoot&&!e.shadowRoot.__watched){b.dom&&console.log("watching shadow-root for: ",e.localName);for(var t=e.shadowRoot;t;)v(t),t=t.olderShadowRoot}}function f(e){if(b.dom){var n=e[0];if(n&&"childList"===n.type&&n.addedNodes&&n.addedNodes){for(var r=n.addedNodes[0];r&&r!==document&&!r.host;)r=r.parentNode;var o=r&&(r.URL||r._URL||r.host&&r.host.localName)||"";o=o.split("/?").shift().split("/").pop()}console.group("mutations (%d) [%s]",e.length,o||"")}e.forEach(function(e){"childList"===e.type&&(T(e.addedNodes,function(e){e.localName&&t(e)}),T(e.removedNodes,function(e){e.localName&&d(e)}))}),b.dom&&console.groupEnd()}function m(e){for(e=window.wrap(e),e||(e=window.wrap(document));e.parentNode;)e=e.parentNode;var t=e.__observer;t&&(f(t.takeRecords()),a())}function v(e){if(!e.__observer){var t=new MutationObserver(f);t.observe(e,{childList:!0,subtree:!0}),e.__observer=t}}function _(e){e=window.wrap(e),b.dom&&console.group("upgradeDocument: ",e.baseURI.split("/").pop()),t(e),v(e),b.dom&&console.groupEnd()}function w(e){y(e,_)}var b=e.flags,g=e.forSubtree,y=e.forDocumentTree,E=!window.MutationObserver||window.MutationObserver===window.JsMutationObserver;e.hasPolyfillMutations=E;var L=!1,M=[],T=Array.prototype.forEach.call.bind(Array.prototype.forEach),N=Element.prototype.createShadowRoot;N&&(Element.prototype.createShadowRoot=function(){var e=N.call(this);return window.CustomElements.watchShadow(this),e}),e.watchShadow=p,e.upgradeDocumentTree=w,e.upgradeSubtree=r,e.upgradeAll=t,e.attachedNode=o,e.takeRecords=m}),window.CustomElements.addModule(function(e){function t(t){if(!t.__upgraded__&&t.nodeType===Node.ELEMENT_NODE){var r=t.getAttribute("is"),o=e.getRegisteredDefinition(r||t.localName);if(o){if(r&&o.tag==t.localName)return n(t,o);if(!r&&!o["extends"])return n(t,o)}}}function n(t,n){return a.upgrade&&console.group("upgrade:",t.localName),n.is&&t.setAttribute("is",n.is),r(t,n),t.__upgraded__=!0,i(t),e.attachedNode(t),e.upgradeSubtree(t),a.upgrade&&console.groupEnd(),t}function r(e,t){Object.__proto__?e.__proto__=t.prototype:(o(e,t.prototype,t["native"]),e.__proto__=t.prototype)}function o(e,t,n){for(var r={},o=t;o!==n&&o!==HTMLElement.prototype;){for(var i,a=Object.getOwnPropertyNames(o),s=0;i=a[s];s++)r[i]||(Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(o,i)),r[i]=1);o=Object.getPrototypeOf(o)}}function i(e){e.createdCallback&&e.createdCallback()}var a=e.flags;e.upgrade=t,e.upgradeWithDefinition=n,e.implementPrototype=r}),window.CustomElements.addModule(function(e){function t(t,r){var c=r||{};if(!t)throw new Error("document.registerElement: first argument `name` must not be empty");if(t.indexOf("-")<0)throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '"+String(t)+"'.");if(o(t))throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '"+String(t)+"'. The type name is invalid.");if(d(t))throw new Error("DuplicateDefinitionError: a type with name '"+String(t)+"' is already registered");return c.prototype||(c.prototype=Object.create(HTMLElement.prototype)),c.__name=t.toLowerCase(),c.lifecycle=c.lifecycle||{},c.ancestry=i(c["extends"]),a(c),s(c),n(c.prototype),u(c.__name,c),c.ctor=l(c),c.ctor.prototype=c.prototype,c.prototype.constructor=c.ctor,e.ready&&_(document),c.ctor}function n(e){if(!e.setAttribute._polyfilled){var t=e.setAttribute;e.setAttribute=function(e,n){r.call(this,e,n,t)};var n=e.removeAttribute;e.removeAttribute=function(e){r.call(this,e,null,n); + +},e.setAttribute._polyfilled=!0}}function r(e,t,n){e=e.toLowerCase();var r=this.getAttribute(e);n.apply(this,arguments);var o=this.getAttribute(e);this.attributeChangedCallback&&o!==r&&this.attributeChangedCallback(e,r,o)}function o(e){for(var t=0;t<E.length;t++)if(e===E[t])return!0}function i(e){var t=d(e);return t?i(t["extends"]).concat([t]):[]}function a(e){for(var t,n=e["extends"],r=0;t=e.ancestry[r];r++)n=t.is&&t.tag;e.tag=n||e.__name,n&&(e.is=e.__name)}function s(e){if(!Object.__proto__){var t=HTMLElement.prototype;if(e.is){var n=document.createElement(e.tag),r=Object.getPrototypeOf(n);r===e.prototype&&(t=r)}for(var o,i=e.prototype;i&&i!==t;)o=Object.getPrototypeOf(i),i.__proto__=o,i=o;e["native"]=t}}function c(e){return b(T(e.tag),e)}function d(e){return e?L[e.toLowerCase()]:void 0}function u(e,t){L[e]=t}function l(e){return function(){return c(e)}}function h(e,t,n){return e===M?p(t,n):N(e,t)}function p(e,t){e&&(e=e.toLowerCase()),t&&(t=t.toLowerCase());var n=d(t||e);if(n){if(e==n.tag&&t==n.is)return new n.ctor;if(!t&&!n.is)return new n.ctor}var r;return t?(r=p(e),r.setAttribute("is",t),r):(r=T(e),e.indexOf("-")>=0&&g(r,HTMLElement),r)}function f(e,t){var n=e[t];e[t]=function(){var e=n.apply(this,arguments);return w(e),e}}var m,v=e.isIE11OrOlder,_=e.upgradeDocumentTree,w=e.upgradeAll,b=e.upgradeWithDefinition,g=e.implementPrototype,y=e.useNative,E=["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"],L={},M="http://www.w3.org/1999/xhtml",T=document.createElement.bind(document),N=document.createElementNS.bind(document);m=Object.__proto__||y?function(e,t){return e instanceof t}:function(e,t){for(var n=e;n;){if(n===t.prototype)return!0;n=n.__proto__}return!1},f(Node.prototype,"cloneNode"),f(document,"importNode"),v&&!function(){var e=document.importNode;document.importNode=function(){var t=e.apply(document,arguments);if(t.nodeType==t.DOCUMENT_FRAGMENT_NODE){var n=document.createDocumentFragment();return n.appendChild(t),n}return t}}(),document.registerElement=t,document.createElement=p,document.createElementNS=h,e.registry=L,e["instanceof"]=m,e.reservedTagList=E,e.getRegisteredDefinition=d,document.register=document.registerElement}),function(e){function t(){a(window.wrap(document)),window.HTMLImports&&(window.HTMLImports.__importsParsingHook=function(e){a(wrap(e["import"]))}),window.CustomElements.ready=!0,setTimeout(function(){window.CustomElements.readyTime=Date.now(),window.HTMLImports&&(window.CustomElements.elapsed=window.CustomElements.readyTime-window.HTMLImports.readyTime),document.dispatchEvent(new CustomEvent("WebComponentsReady",{bubbles:!0}))})}var n=e.useNative,r=e.initializeModules,o=/Trident/.test(navigator.userAgent);if(n){var i=function(){};e.watchShadow=i,e.upgrade=i,e.upgradeAll=i,e.upgradeDocumentTree=i,e.upgradeSubtree=i,e.takeRecords=i,e["instanceof"]=function(e,t){return e instanceof t}}else r();var a=e.upgradeDocumentTree;if(window.wrap||(window.ShadowDOMPolyfill?(window.wrap=window.ShadowDOMPolyfill.wrapIfNeeded,window.unwrap=window.ShadowDOMPolyfill.unwrapIfNeeded):window.wrap=window.unwrap=function(e){return e}),o&&"function"!=typeof window.CustomEvent&&(window.CustomEvent=function(e,t){t=t||{};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,Boolean(t.bubbles),Boolean(t.cancelable),t.detail),n.preventDefault=function(){Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})},n},window.CustomEvent.prototype=window.Event.prototype),"complete"===document.readyState||e.flags.eager)t();else if("interactive"!==document.readyState||window.attachEvent||window.HTMLImports&&!window.HTMLImports.ready){var s=window.HTMLImports&&!window.HTMLImports.ready?"HTMLImportsLoaded":"DOMContentLoaded";window.addEventListener(s,t)}else t();e.isIE11OrOlder=o}(window.CustomElements),"undefined"==typeof HTMLTemplateElement&&!function(){var e="template";HTMLTemplateElement=function(){},HTMLTemplateElement.prototype=Object.create(HTMLElement.prototype),HTMLTemplateElement.decorate=function(e){e.content||(e.content=e.ownerDocument.createDocumentFragment());for(var t;t=e.firstChild;)e.content.appendChild(t)},HTMLTemplateElement.bootstrap=function(t){for(var n,r=t.querySelectorAll(e),o=0,i=r.length;i>o&&(n=r[o]);o++)HTMLTemplateElement.decorate(n)},window.addEventListener("DOMContentLoaded",function(){HTMLTemplateElement.bootstrap(document)});var t=document.createElement;document.createElement=function(){"use strict";var e=t.apply(document,arguments);return"template"==e.localName&&HTMLTemplateElement.decorate(e),e}}(),function(e){var t=document.createElement("style");t.textContent="body {transition: opacity ease-in 0.2s; } \nbody[unresolved] {opacity: 0; display: block; overflow: hidden; position: relative; } \n";var n=document.querySelector("head");n.insertBefore(t,n.firstChild)}(window.WebComponents); \ No newline at end of file diff --git a/docs.it4i/src/login.ttyrec b/docs.it4i/src/login.ttyrec new file mode 100644 index 0000000000000000000000000000000000000000..7cca3d3f2257ed134e4ec77b9997dbcb1f8b4827 Binary files /dev/null and b/docs.it4i/src/login.ttyrec differ diff --git a/mkdocs.yml b/mkdocs.yml index 19872589b2acc1d006ff487516df11836ae6d50d..de1f5fbf2a1ce3125c2b27032154fa8d1d562206 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -200,6 +200,13 @@ extra: prev: 'Previous' next: 'Next' +extra_css: +- css/tty-player.css + +extra_javascript: +- js/webcomponents-lite.min.js +- js/tty-player.js + markdown_extensions: - codehilite(css_class=code) - admonition