mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2026-10-23 16:50:42 +00:00
stylized UI to Material Design
This commit is contained in:
1 parent
5145012d59
commit
7be7d975e4
10 files changed
+158
-55
No files matched your search
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* material-design-lite - Material Design Components in CSS, JS and HTML
|
||||
* @version v1.1.1
|
||||
* @license Apache-2.0
|
||||
* @copyright 2015 Google, Inc.
|
||||
* @link https://github.com/google/material-design-lite
|
||||
*/
|
||||
@charset "UTF-8";html{color:rgba(0,0,0,.87)}::-moz-selection{background:#b3d4fc;text-shadow:none}::selection{background:#b3d4fc;text-shadow:none}fieldset,hr{border:0;padding:0}hr{display:block;height:1px;border-top:1px solid #ccc;margin:1em 0}audio,canvas,iframe,img,svg,video{vertical-align:middle}fieldset{margin:0}textarea{resize:vertical}.browserupgrade{margin:.2em 0;background:#ccc;color:#000;padding:.2em 0}.hidden{display:none!important}.visuallyhidden{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.visuallyhidden.focusable:active,.visuallyhidden.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.invisible{visibility:hidden}.clearfix:after,.clearfix:before{content:" ";display:table}.clearfix:after{clear:both}@media print{*,*:after,*:before,*:first-letter,*:first-line{background:0 0!important;color:#000!important;box-shadow:none!important;text-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href)")"}abbr[title]:after{content:" (" attr(title)")"}a[href^="#"]:after,a[href^="javascript:"]:after{content:""}blockquote,pre{border:1px solid #999}thead{display:table-header-group}blockquote,img,pre,tr{page-break-inside:avoid}img{max-width:100%!important}h2,h3,p{orphans:3;widows:3}h2,h3{page-break-after:avoid}}.mdl-accordion,.mdl-button,.mdl-card,.mdl-checkbox,.mdl-dropdown-menu,.mdl-icon-toggle,.mdl-item,.mdl-radio,.mdl-slider,.mdl-switch,.mdl-tabs__tab,a{-webkit-tap-highlight-color:transparent;-webkit-tap-highlight-color:rgba(255,255,255,0)}body,html{width:100%;font-family:"Helvetica","Arial",sans-serif;font-size:14px;font-weight:400;line-height:20px}html{height:100%;-ms-touch-action:manipulation;touch-action:manipulation}body{min-height:100%}main{display:block}*[hidden]{display:none!important}h1,h2,h3,h4,h5,h6,p{padding:0}h1,h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-family:"Roboto","Helvetica","Arial",sans-serif;letter-spacing:-.02em;line-height:1.35}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:400;opacity:.54;font-size:.6em}h1,h2{font-weight:400}h1{margin:24px 0;font-size:56px}h2,h3{font-family:"Roboto","Helvetica","Arial",sans-serif;margin:24px 0}h2{font-size:45px;line-height:48px}h3,h4{font-weight:400}h3{font-size:34px;line-height:40px}h4,h5{font-family:"Roboto","Helvetica","Arial",sans-serif}h4{-moz-osx-font-smoothing:grayscale;margin:24px 0 16px;font-size:24px;line-height:32px}h5,h6,p{margin:24px 0 16px}h5{font-size:20px;font-weight:500;line-height:1;letter-spacing:.02em}blockquote,h6{font-family:"Roboto","Helvetica","Arial",sans-serif}h6,p{font-size:16px;font-weight:400;line-height:24px;letter-spacing:.04em}p{font-size:14px;letter-spacing:0;margin:0 0 16px}a{color:rgb(255,171,64);font-weight:500}blockquote{position:relative;font-size:24px;font-weight:300;font-style:italic;line-height:1.35;letter-spacing:.08em}blockquote:before{position:absolute;left:-.5em;content:'“'}blockquote:after{content:'”';margin-left:-.05em}mark{background-color:#f4ff81}dt{font-weight:700}address,ol,ul{font-weight:400;letter-spacing:0}address{font-style:normal;font-size:12px;line-height:1}ol,ul{font-size:14px;line-height:24px}.mdl-typography--display-4,.mdl-typography--display-4-color-contrast{font-family:"Roboto","Helvetica","Arial",sans-serif;font-size:112px;font-weight:300;line-height:1;letter-spacing:-.04em}.mdl-typography--display-4-color-contrast{opacity:.54}.mdl-typography--display-3,.mdl-typography--display-3-color-contrast{font-family:"Roboto","Helvetica","Arial",sans-serif;font-size:56px;font-weight:400;line-height:1.35;letter-spacing:-.02em}.mdl-typography--display-3-color-contrast{opacity:.54}.mdl-typography--display-2,.mdl-typography--display-2-color-contrast{font-family:"Roboto","Helvetica","Arial",sans-serif;font-size:45px;font-weight:400;line-height:48px}.mdl-typography--display-2-color-contrast{opacity:.54}.mdl-typography--display-1,.mdl-typography--display-1-color-contrast{font-family:"Roboto","Helvetica","Arial",sans-serif;font-size:34px;font-weight:400;line-height:40px}.mdl-typography--display-1-color-contrast{opacity:.54}.mdl-typography--headline,.mdl-typography--headline-color-contrast{font-family:"Roboto","Helvetica","Arial",sans-serif;font-size:24px;font-weight:400;line-height:32px;-moz-osx-font-smoothing:grayscale}.mdl-typography--headline-color-contrast{opacity:.87}.mdl-typography--title,.mdl-typography--title-color-contrast{font-family:"Roboto","Helvetica","Arial",sans-serif;font-size:20px;font-weight:500;line-height:1;letter-spacing:.02em}.mdl-typography--title-color-contrast{opacity:.87}.mdl-typography--subhead,.mdl-typography--subhead-color-contrast{font-family:"Roboto","Helvetica","Arial",sans-serif;font-size:16px;font-weight:400;line-height:24px;letter-spacing:.04em}.mdl-typography--subhead-color-contrast{opacity:.87}.mdl-typography--body-2,.mdl-typography--body-2-color-contrast{font-size:14px;font-weight:700;line-heiLine truncated
|
||||
@@ -0,0 +1,51 @@
|
||||
.mdl-layout__header-row {
|
||||
color: #fff;
|
||||
}
|
||||
.mdl-button {
|
||||
color: #fff !important;
|
||||
}
|
||||
main {
|
||||
padding: 50px 100px;
|
||||
}
|
||||
.log-holder {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
#hostSettings {
|
||||
padding: 5px 10px;
|
||||
border: 1px dashed;
|
||||
margin: 10px 0;
|
||||
}
|
||||
#hostSettings p {
|
||||
margin: 0;
|
||||
}
|
||||
#hostSettings div {
|
||||
display: inline-block;
|
||||
}
|
||||
#hostSettings .mdl-textfield {
|
||||
width: 200px;
|
||||
margin-right: 20px;
|
||||
}
|
||||
#hostSettings #selectHost {
|
||||
line-height: 20px;
|
||||
height: 20px;
|
||||
background: none;
|
||||
}
|
||||
#hostSettings .button-holder {
|
||||
float: right;
|
||||
}
|
||||
#testingDiv {
|
||||
border: 1px dashed;
|
||||
padding: 10px;
|
||||
}
|
||||
#listener {
|
||||
overflow: hidden;
|
||||
margin-top: 20px;
|
||||
border: 1px solid;
|
||||
}
|
||||
.fullscreen {
|
||||
height: 100vh;
|
||||
overflow: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width 100%;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// just start the app in fullscreen
|
||||
chrome.app.runtime.onLaunched.addListener(function() {
|
||||
chrome.app.window.create('index.html', {
|
||||
state: "fullscreen",
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,473 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Set to true when the Document is loaded IFF "test=true" is in the query
|
||||
// string.
|
||||
var isTest = false;
|
||||
|
||||
// Set to true when loading a "Release" NaCl module, false when loading a
|
||||
// "Debug" NaCl module.
|
||||
var isRelease = true;
|
||||
|
||||
// Javascript module pattern:
|
||||
// see http://en.wikipedia.org/wiki/Unobtrusive_JavaScript#Namespaces
|
||||
// In essence, we define an anonymous function which is immediately called and
|
||||
// returns a new object. The new object contains only the exported definitions;
|
||||
// all other definitions in the anonymous function are inaccessible to external
|
||||
// code.
|
||||
var common = (function() {
|
||||
|
||||
function isHostToolchain(tool) {
|
||||
return tool == 'win' || tool == 'linux' || tool == 'mac';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mime type for NaCl plugin.
|
||||
*
|
||||
* @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc.
|
||||
* @return {string} The mime-type for the kind of NaCl plugin matching
|
||||
* the given toolchain.
|
||||
*/
|
||||
function mimeTypeForTool(tool) {
|
||||
// For NaCl modules use application/x-nacl.
|
||||
var mimetype = 'application/x-nacl';
|
||||
if (isHostToolchain(tool)) {
|
||||
// For non-NaCl PPAPI plugins use the x-ppapi-debug/release
|
||||
// mime type.
|
||||
if (isRelease)
|
||||
mimetype = 'application/x-ppapi-release';
|
||||
else
|
||||
mimetype = 'application/x-ppapi-debug';
|
||||
} else if (tool == 'pnacl') {
|
||||
mimetype = 'application/x-pnacl';
|
||||
}
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the browser supports NaCl plugins.
|
||||
*
|
||||
* @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc.
|
||||
* @return {bool} True if the browser supports the type of NaCl plugin
|
||||
* produced by the given toolchain.
|
||||
*/
|
||||
function browserSupportsNaCl(tool) {
|
||||
// Assume host toolchains always work with the given browser.
|
||||
// The below mime-type checking might not work with
|
||||
// --register-pepper-plugins.
|
||||
if (isHostToolchain(tool)) {
|
||||
return true;
|
||||
}
|
||||
var mimetype = mimeTypeForTool(tool);
|
||||
return navigator.mimeTypes[mimetype] !== undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject a script into the DOM, and call a callback when it is loaded.
|
||||
*
|
||||
* @param {string} url The url of the script to load.
|
||||
* @param {Function} onload The callback to call when the script is loaded.
|
||||
* @param {Function} onerror The callback to call if the script fails to load.
|
||||
*/
|
||||
function injectScript(url, onload, onerror) {
|
||||
var scriptEl = document.createElement('script');
|
||||
scriptEl.type = 'text/javascript';
|
||||
scriptEl.src = url;
|
||||
scriptEl.onload = onload;
|
||||
if (onerror) {
|
||||
scriptEl.addEventListener('error', onerror, false);
|
||||
}
|
||||
document.head.appendChild(scriptEl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all tests for this example.
|
||||
*
|
||||
* @param {Object} moduleEl The module DOM element.
|
||||
*/
|
||||
function runTests(moduleEl) {
|
||||
console.log('runTests()');
|
||||
common.tester = new Tester();
|
||||
|
||||
// All NaCl SDK examples are OK if the example exits cleanly; (i.e. the
|
||||
// NaCl module returns 0 or calls exit(0)).
|
||||
//
|
||||
// Without this exception, the browser_tester thinks that the module
|
||||
// has crashed.
|
||||
common.tester.exitCleanlyIsOK();
|
||||
|
||||
common.tester.addAsyncTest('loaded', function(test) {
|
||||
test.pass();
|
||||
});
|
||||
|
||||
if (typeof window.addTests !== 'undefined') {
|
||||
window.addTests();
|
||||
}
|
||||
|
||||
common.tester.waitFor(moduleEl);
|
||||
common.tester.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Native Client <embed> element as a child of the DOM element
|
||||
* named "listener".
|
||||
*
|
||||
* @param {string} name The name of the example.
|
||||
* @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc.
|
||||
* @param {string} path Directory name where .nmf file can be found.
|
||||
* @param {number} width The width to create the plugin.
|
||||
* @param {number} height The height to create the plugin.
|
||||
* @param {Object} attrs Dictionary of attributes to set on the module.
|
||||
*/
|
||||
function createNaClModule(name, tool, path, width, height, attrs) {
|
||||
var moduleEl = document.createElement('embed');
|
||||
moduleEl.setAttribute('name', 'nacl_module');
|
||||
moduleEl.setAttribute('id', 'nacl_module');
|
||||
moduleEl.setAttribute('width', width);
|
||||
moduleEl.setAttribute('height', height);
|
||||
moduleEl.setAttribute('path', path);
|
||||
moduleEl.setAttribute('src', path + '/' + name + '.nmf');
|
||||
|
||||
// Add any optional arguments
|
||||
if (attrs) {
|
||||
for (var key in attrs) {
|
||||
moduleEl.setAttribute(key, attrs[key]);
|
||||
}
|
||||
}
|
||||
|
||||
var mimetype = mimeTypeForTool(tool);
|
||||
moduleEl.setAttribute('type', mimetype);
|
||||
|
||||
// The <EMBED> element is wrapped inside a <DIV>, which has both a 'load'
|
||||
// and a 'message' event listener attached. This wrapping method is used
|
||||
// instead of attaching the event listeners directly to the <EMBED> element
|
||||
// to ensure that the listeners are active before the NaCl module 'load'
|
||||
// event fires.
|
||||
var listenerDiv = document.getElementById('listener');
|
||||
listenerDiv.appendChild(moduleEl);
|
||||
|
||||
// Request the offsetTop property to force a relayout. As of Apr 10, 2014
|
||||
// this is needed if the module is being loaded on a Chrome App's
|
||||
// background page (see crbug.com/350445).
|
||||
moduleEl.offsetTop;
|
||||
|
||||
// Host plugins don't send a moduleDidLoad message. We'll fake it here.
|
||||
var isHost = isHostToolchain(tool);
|
||||
if (isHost) {
|
||||
window.setTimeout(function() {
|
||||
moduleEl.readyState = 1;
|
||||
moduleEl.dispatchEvent(new CustomEvent('loadstart'));
|
||||
moduleEl.readyState = 4;
|
||||
moduleEl.dispatchEvent(new CustomEvent('load'));
|
||||
moduleEl.dispatchEvent(new CustomEvent('loadend'));
|
||||
}, 100); // 100 ms
|
||||
}
|
||||
|
||||
// This is code that is only used to test the SDK.
|
||||
if (isTest) {
|
||||
var loadNaClTest = function() {
|
||||
injectScript('nacltest.js', function() {
|
||||
runTests(moduleEl);
|
||||
});
|
||||
};
|
||||
|
||||
// Try to load test.js for the example. Whether or not it exists, load
|
||||
// nacltest.js.
|
||||
injectScript('test.js', loadNaClTest, loadNaClTest);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the default "load" and "message" event listeners to the element with
|
||||
* id "listener".
|
||||
*
|
||||
* The "load" event is sent when the module is successfully loaded. The
|
||||
* "message" event is sent when the naclModule posts a message using
|
||||
* PPB_Messaging.PostMessage() (in C) or pp::Instance().PostMessage() (in
|
||||
* C++).
|
||||
*/
|
||||
function attachDefaultListeners() {
|
||||
var listenerDiv = document.getElementById('listener');
|
||||
listenerDiv.addEventListener('load', moduleDidLoad, true);
|
||||
listenerDiv.addEventListener('message', handleMessage, true);
|
||||
listenerDiv.addEventListener('error', handleError, true);
|
||||
listenerDiv.addEventListener('crash', handleCrash, true);
|
||||
if (typeof window.attachListeners !== 'undefined') {
|
||||
window.attachListeners();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the NaCl module fails to load.
|
||||
*
|
||||
* This event listener is registered in createNaClModule above.
|
||||
*/
|
||||
function handleError(event) {
|
||||
// We can't use common.naclModule yet because the module has not been
|
||||
// loaded.
|
||||
var moduleEl = document.getElementById('nacl_module');
|
||||
updateStatus('ERROR [' + moduleEl.lastError + ']');
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Browser can not communicate with the Module
|
||||
*
|
||||
* This event listener is registered in attachDefaultListeners above.
|
||||
*/
|
||||
function handleCrash(event) {
|
||||
if (common.naclModule.exitStatus == -1) {
|
||||
updateStatus('CRASHED');
|
||||
} else {
|
||||
updateStatus('EXITED [' + common.naclModule.exitStatus + ']');
|
||||
}
|
||||
if (typeof window.handleCrash !== 'undefined') {
|
||||
window.handleCrash(common.naclModule.lastError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the NaCl module is loaded.
|
||||
*
|
||||
* This event listener is registered in attachDefaultListeners above.
|
||||
*/
|
||||
function moduleDidLoad() {
|
||||
common.naclModule = document.getElementById('nacl_module');
|
||||
updateStatus('RUNNING');
|
||||
|
||||
if (typeof window.moduleDidLoad !== 'undefined') {
|
||||
window.moduleDidLoad();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the NaCl module's embed element.
|
||||
*
|
||||
* We don't want to hide by default; if we do, it is harder to determine that
|
||||
* a plugin failed to load. Instead, call this function inside the example's
|
||||
* "moduleDidLoad" function.
|
||||
*
|
||||
*/
|
||||
function hideModule() {
|
||||
// Setting common.naclModule.style.display = "None" doesn't work; the
|
||||
// module will no longer be able to receive postMessages.
|
||||
common.naclModule.style.height = '0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the NaCl module from the page.
|
||||
*/
|
||||
function removeModule() {
|
||||
common.naclModule.parentNode.removeChild(common.naclModule);
|
||||
common.naclModule = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true when |s| starts with the string |prefix|.
|
||||
*
|
||||
* @param {string} s The string to search.
|
||||
* @param {string} prefix The prefix to search for in |s|.
|
||||
*/
|
||||
function startsWith(s, prefix) {
|
||||
// indexOf would search the entire string, lastIndexOf(p, 0) only checks at
|
||||
// the first index. See: http://stackoverflow.com/a/4579228
|
||||
return s.lastIndexOf(prefix, 0) === 0;
|
||||
}
|
||||
|
||||
/** Maximum length of logMessageArray. */
|
||||
var kMaxLogMessageLength = 20;
|
||||
|
||||
/** An array of messages to display in the element with id "log". */
|
||||
var logMessageArray = [];
|
||||
|
||||
/**
|
||||
* Add a message to an element with id "log".
|
||||
*
|
||||
* This function is used by the default "log:" message handler.
|
||||
*
|
||||
* @param {string} message The message to log.
|
||||
*/
|
||||
function logMessage(message) {
|
||||
logMessageArray.push(message);
|
||||
if (logMessageArray.length > kMaxLogMessageLength)
|
||||
logMessageArray.shift();
|
||||
|
||||
document.getElementById('log').textContent = logMessageArray.join('\n');
|
||||
console.log(message);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
var defaultMessageTypes = {
|
||||
'alert': alert,
|
||||
'log': logMessage
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when the NaCl module sends a message to JavaScript (via
|
||||
* PPB_Messaging.PostMessage())
|
||||
*
|
||||
* This event listener is registered in createNaClModule above.
|
||||
*
|
||||
* @param {Event} message_event A message event. message_event.data contains
|
||||
* the data sent from the NaCl module.
|
||||
*/
|
||||
function handleMessage(message_event) {
|
||||
if (typeof message_event.data === 'string') {
|
||||
for (var type in defaultMessageTypes) {
|
||||
if (defaultMessageTypes.hasOwnProperty(type)) {
|
||||
if (startsWith(message_event.data, type + ':')) {
|
||||
func = defaultMessageTypes[type];
|
||||
func(message_event.data.slice(type.length + 1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof window.handleMessage !== 'undefined') {
|
||||
window.handleMessage(message_event);
|
||||
} else {
|
||||
logMessage('Unhandled message: ' + message_event.data);
|
||||
}
|
||||
} // TODO: page reloads here???
|
||||
|
||||
/**
|
||||
* Called when the DOM content has loaded; i.e. the page's document is fully
|
||||
* parsed. At this point, we can safely query any elements in the document via
|
||||
* document.querySelector, document.getElementById, etc.
|
||||
*
|
||||
* @param {string} name The name of the example.
|
||||
* @param {string} tool The name of the toolchain, e.g. "glibc", "newlib" etc.
|
||||
* @param {string} path Directory name where .nmf file can be found.
|
||||
* @param {number} width The width to create the plugin.
|
||||
* @param {number} height The height to create the plugin.
|
||||
* @param {Object} attrs Optional dictionary of additional attributes.
|
||||
*/
|
||||
function domContentLoaded(name, tool, path, width, height, attrs) {
|
||||
// If the page loads before the Native Client module loads, then set the
|
||||
// status message indicating that the module is still loading. Otherwise,
|
||||
// do not change the status message.
|
||||
updateStatus('Page loaded.');
|
||||
if (!browserSupportsNaCl(tool)) {
|
||||
updateStatus(
|
||||
'Browser does not support NaCl (' + tool + '), or NaCl is disabled');
|
||||
} else if (common.naclModule == null) {
|
||||
updateStatus('Creating embed: ' + tool);
|
||||
|
||||
// We use a non-zero sized embed to give Chrome space to place the bad
|
||||
// plug-in graphic, if there is a problem.
|
||||
width = typeof width !== 'undefined' ? width : 200;
|
||||
height = typeof height !== 'undefined' ? height : 200;
|
||||
attachDefaultListeners();
|
||||
createNaClModule(name, tool, path, width, height, attrs);
|
||||
} else {
|
||||
// It's possible that the Native Client module onload event fired
|
||||
// before the page's onload event. In this case, the status message
|
||||
// will reflect 'SUCCESS', but won't be displayed. This call will
|
||||
// display the current message.
|
||||
updateStatus('Waiting.');
|
||||
}
|
||||
}
|
||||
|
||||
/** Saved text to display in the element with id 'statusField'. */
|
||||
var statusText = 'NO-STATUSES';
|
||||
|
||||
/**
|
||||
* Set the global status message. If the element with id 'statusField'
|
||||
* exists, then set its HTML to the status message as well.
|
||||
*
|
||||
* @param {string} opt_message The message to set. If null or undefined, then
|
||||
* set element 'statusField' to the message from the last call to
|
||||
* updateStatus.
|
||||
*/
|
||||
function updateStatus(opt_message) {
|
||||
if (opt_message) {
|
||||
statusText = opt_message;
|
||||
}
|
||||
var statusField = document.getElementById('statusField');
|
||||
if (statusField) {
|
||||
statusField.innerHTML = statusText;
|
||||
}
|
||||
}
|
||||
|
||||
// The symbols to export.
|
||||
return {
|
||||
/** A reference to the NaCl module, once it is loaded. */
|
||||
naclModule: null,
|
||||
|
||||
attachDefaultListeners: attachDefaultListeners,
|
||||
domContentLoaded: domContentLoaded,
|
||||
createNaClModule: createNaClModule,
|
||||
hideModule: hideModule,
|
||||
removeModule: removeModule,
|
||||
logMessage: logMessage,
|
||||
updateStatus: updateStatus
|
||||
};
|
||||
|
||||
}());
|
||||
|
||||
// Listen for the DOM content to be loaded. This event is fired when parsing of
|
||||
// the page's document has finished.
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var body = document.body;
|
||||
|
||||
// The data-* attributes on the body can be referenced via body.dataset.
|
||||
if (body.dataset) {
|
||||
var loadFunction;
|
||||
if (!body.dataset.customLoad) {
|
||||
loadFunction = common.domContentLoaded;
|
||||
} else if (typeof window.domContentLoaded !== 'undefined') {
|
||||
loadFunction = window.domContentLoaded;
|
||||
}
|
||||
|
||||
// From https://developer.mozilla.org/en-US/docs/DOM/window.location
|
||||
var searchVars = {};
|
||||
if (window.location.search.length > 1) {
|
||||
var pairs = window.location.search.substr(1).split('&');
|
||||
for (var key_ix = 0; key_ix < pairs.length; key_ix++) {
|
||||
var keyValue = pairs[key_ix].split('=');
|
||||
searchVars[unescape(keyValue[0])] =
|
||||
keyValue.length > 1 ? unescape(keyValue[1]) : '';
|
||||
}
|
||||
}
|
||||
|
||||
if (loadFunction) {
|
||||
var toolchains = body.dataset.tools.split(' ');
|
||||
var configs = body.dataset.configs.split(' ');
|
||||
|
||||
var attrs = {};
|
||||
if (body.dataset.attrs) {
|
||||
var attr_list = body.dataset.attrs.split(' ');
|
||||
for (var key in attr_list) {
|
||||
var attr = attr_list[key].split('=');
|
||||
var key = attr[0];
|
||||
var value = attr[1];
|
||||
attrs[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
var tc = toolchains.indexOf(searchVars.tc) !== -1 ?
|
||||
searchVars.tc : toolchains[0];
|
||||
|
||||
// If the config value is included in the search vars, use that.
|
||||
// Otherwise default to Release if it is valid, or the first value if
|
||||
// Release is not valid.
|
||||
if (configs.indexOf(searchVars.config) !== -1)
|
||||
var config = searchVars.config;
|
||||
else if (configs.indexOf('Release') !== -1)
|
||||
var config = 'Release';
|
||||
else
|
||||
var config = configs[0];
|
||||
|
||||
var pathFormat = body.dataset.path;
|
||||
var path = pathFormat.replace('{tc}', tc).replace('{config}', config);
|
||||
|
||||
isTest = searchVars.test === 'true';
|
||||
isRelease = path.toLowerCase().indexOf('release') != -1;
|
||||
|
||||
loadFunction(body.dataset.name, tc, path, body.dataset.width,
|
||||
body.dataset.height, attrs);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
// Called by the common.js module.
|
||||
function attachListeners() {
|
||||
document.getElementById('startButton').addEventListener('click', startPushed);
|
||||
document.getElementById('stopButton').addEventListener('click', stopPushed);
|
||||
document.getElementById('pairButton').addEventListener('click', pairPushed);
|
||||
document.getElementById('showAppsButton').addEventListener('click', showAppsPushed);
|
||||
}
|
||||
|
||||
function moduleDidLoad() {
|
||||
common.naclModule = document.getElementById('nacl_module');
|
||||
var logEl = document.getElementById('logField');
|
||||
logEl.innerHTML = "module loaded";
|
||||
}
|
||||
|
||||
// we want the user to progress through the streaming process
|
||||
// but to save from the PITA of inter-chrome-app-page JS message passing,
|
||||
// I'm opting to do it in a single page, and keep the data around.
|
||||
function hideAllWorkflowDivs() {
|
||||
document.getElementById('streamSettings').style.display = 'inline-block';
|
||||
document.getElementById('hostSettings').style.display = 'inline-block';
|
||||
document.getElementById('gameSelection').style.display = 'none';
|
||||
document.getElementById('listener').style.display = 'none';
|
||||
}
|
||||
|
||||
// pair button was pushed. pass what the user entered into the GFEHostIPField.
|
||||
function pairPushed() {
|
||||
common.naclModule.postMessage('pair:' + document.getElementById('GFEHostIPField').value);
|
||||
}
|
||||
|
||||
// someone pushed the "show apps" button.
|
||||
// if they entered something in the GFEHostIPField, use that.
|
||||
// otherwise, we assume they selected from the host history dropdown.
|
||||
// TODO: pass the host info to the appChoose screen
|
||||
function showAppsPushed() {
|
||||
var target = document.getElementById('GFEHostIPField').value;
|
||||
if (target == null || target == "127.0.0.1") {
|
||||
var e = document.getElementById("selectHost");
|
||||
target = e.options[e.selectedIndex].value;
|
||||
}
|
||||
common.naclModule.postMessage('showAppsPushed:' + target);
|
||||
// we just finished the hostSettings section. expose the next one
|
||||
showAppsMode();
|
||||
}
|
||||
|
||||
function showAppsMode() {
|
||||
document.getElementById('streamSettings').style.display = 'none';
|
||||
document.getElementById('hostSettings').style.display = 'none'
|
||||
document.getElementById('gameSelection').style.display = 'inline-block'
|
||||
document.getElementById('listener').style.display = 'none'
|
||||
}
|
||||
|
||||
// user wants to start a stream. We need the host, game ID, and video settings(?)
|
||||
// TODO: video settings.
|
||||
function startPushed() {
|
||||
var target = document.getElementById('GFEHostIPField').value;
|
||||
if (target == null || target == "127.0.0.1") {
|
||||
var e = document.getElementById("selectHost");
|
||||
target = e.options[e.selectedIndex].value;
|
||||
}
|
||||
var gameIDDropdown = document.getElementById("selectGame");
|
||||
var gameID = gameIDDropdown[gameIDDropdown.selectedIndex].value;
|
||||
common.naclModule.postMessage('setGFEHostIPField:' + target + ":" + gameID);
|
||||
// we just finished the gameSelection section. only expose the NaCl section
|
||||
playGameMode();
|
||||
}
|
||||
|
||||
function playGameMode() {
|
||||
$("body").children().not("#listener").hide();
|
||||
$("body").addClass("fullscreen");
|
||||
}
|
||||
|
||||
// user pushed the stop button. we should stop.
|
||||
function stopPushed() {
|
||||
common.naclModule.postMessage('stopPushed');
|
||||
}
|
||||
|
||||
// hook from main.cpp into the javascript
|
||||
function handleMessage(msg) {
|
||||
var quitStreamString = "quitStream";
|
||||
var logEl = document.getElementById('logField');
|
||||
logEl.innerHTML = msg.data;
|
||||
if (msg.data.lastIndexOf(quitStreamString, 0) === 0) {
|
||||
showAppsMode();
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
/*! jQuery v2.2.0 | (c) jQuery Foundation | jquery.org/license */
|
||||
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=a.document,e=c.slice,f=c.concat,g=c.push,h=c.indexOf,i={},j=i.toString,k=i.hasOwnProperty,l={},m="2.2.0",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return e.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:e.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a){return n.each(this,a)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(e.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor()},push:g,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){var b=a&&a.toString();return!n.isArray(a)&&b-parseFloat(b)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!k.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?i[j.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=d.createElement("script"),b.text=a,d.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b){var c,d=0;if(s(a)){for(c=a.length;c>d;d++)if(b.call(a[d],d,a[d])===!1)break}else for(d in a)if(b.call(a[d],d,a[d])===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):g.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:h.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,e,g=0,h=[];if(s(a))for(d=a.length;d>g;g++)e=b(a[g],g,c),null!=e&&h.push(e);else for(g in a)e=b(a[g],g,c),null!=e&&h.push(e);return f.apply([],h)},guid:1,proxy:function(a,b){var c,d,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(d=e.call(arguments,2),f=function(){return a.apply(b||this,d.concat(e.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:l}),"function"==typeof Symbol&&(n.fn[Symbol.iterator]=c[Symbol.iterator]),n.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(a,b){i["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=!!a&&"length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ga(),z=ga(),A=ga(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+M+"))|)"+L+"*\\]",O=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+N+")*)|.*)\\)|)",P=new RegExp(L+"+","g"),Q=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),R=new RegExp("^"+L+"*,"+L+"*"),S=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),T=new RegExp("="+L+"*(Line truncated
|
||||
}else c=void 0;return c}n.extend({hasData:function(a){return O.hasData(a)||N.hasData(a)},data:function(a,b,c){return O.access(a,b,c)},removeData:function(a,b){O.remove(a,b)},_data:function(a,b,c){return N.access(a,b,c)},_removeData:function(a,b){N.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=O.get(f),1===f.nodeType&&!N.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),R(f,d,e[d])));N.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){O.set(this,a)}):K(this,function(b){var c,d;if(f&&void 0===b){if(c=O.get(f,a)||O.get(f,a.replace(Q,"-$&").toLowerCase()),void 0!==c)return c;if(d=n.camelCase(a),c=O.get(f,d),void 0!==c)return c;if(c=R(f,d,void 0),void 0!==c)return c}else d=n.camelCase(a),this.each(function(){var c=O.get(this,d);O.set(this,d,b),a.indexOf("-")>-1&&void 0!==c&&O.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){O.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=N.get(a,b),c&&(!d||n.isArray(c)?d=N.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return N.get(a,c)||N.access(a,c,{empty:n.Callbacks("once memory").add(function(){N.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=N.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),U=["Top","Right","Bottom","Left"],V=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)};function W(a,b,c,d){var e,f=1,g=20,h=d?function(){return d.cur()}:function(){return n.css(a,b,"")},i=h(),j=c&&c[3]||(n.cssNumber[b]?"":"px"),k=(n.cssNumber[b]||"px"!==j&&+i)&&T.exec(n.css(a,b));if(k&&k[3]!==j){j=j||k[3],c=c||[],k=+i||1;do f=f||".5",k/=f,n.style(a,b,k+j);while(f!==(f=h()/i)&&1!==f&&--g)}return c&&(k=+k||+i||0,e=c[1]?k+(c[1]+1)*c[2]:+c[2],d&&(d.unit=j,d.start=k,d.end=e)),e}var X=/^(?:checkbox|radio)$/i,Y=/<([\w:-]+)/,Z=/^$|\/(?:java|ecma)script/i,$={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};$.optgroup=$.option,$.tbody=$.tfoot=$.colgroup=$.caption=$.thead,$.th=$.td;function _(a,b){var c="undefined"!=typeof a.getElementsByTagName?a.getElementsByTagName(b||"*"):"undefined"!=typeof a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function aa(a,b){for(var c=0,d=a.length;d>c;c++)N.set(a[c],"globalEval",!b||N.get(b[c],"globalEval"))}var ba=/<|&#?\w+;/;function ca(a,b,c,d,e){for(var f,g,h,i,j,k,l=b.createDocumentFragment(),m=[],o=0,p=a.length;p>o;o++)if(f=a[o],f||0===f)if("object"===n.type(f))n.merge(m,f.nodeType?[f]:f);else if(ba.test(f)){g=g||l.appendChild(b.createElement("div")),h=(Y.exec(f)||["",""])[1].toLowerCase(),i=$[h]||$._default,g.innerHTML=i[1]+n.htmlPrefilter(f)+i[2],k=i[0];while(k--)g=g.lastChild;n.merge(m,g.childNodes),g=l.firstChild,g.textContent=""}else m.push(b.createTextNode(f));l.textContent="",o=0;while(f=m[o++])if(d&&n.inArray(f,d)>-1)e&&e.push(f);else if(j=n.contains(f.ownerDocument,f),g=_(l.appendChild(f),"script"),j&&aa(g),c){k=0;while(f=g[k++])Z.test(f.type||"")&&c.push(f)}return l}!function(){var a=d.createDocumentFragment(),b=a.appendChild(d.createElement("div")),c=d.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var da=/^key/,ea=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,fa=/^([^.]*)(?:\.(.+)|)/;function ga(){return!0}function ha(){return!1}function ia(){try{return d.activeElement}catch(a){}}function ja(a,b,c,d,e,f){var g,h;if("object"==typeof b){"string"!=typeof c&&(d=d||c,c=void 0);for(h in b)ja(a,h,c,d,b[h]Line truncated
|
||||
},propHooks:{tabIndex:{get:function(a){var b=n.find.attr(a,"tabindex");return b?parseInt(b,10):cb.test(a.nodeName)||db.test(a.nodeName)&&a.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),l.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var eb=/[\t\r\n\f]/g;function fb(a){return a.getAttribute&&a.getAttribute("class")||""}n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h,i=0;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,fb(this)))});if("string"==typeof a&&a){b=a.match(G)||[];while(c=this[i++])if(e=fb(c),d=1===c.nodeType&&(" "+e+" ").replace(eb," ")){g=0;while(f=b[g++])d.indexOf(" "+f+" ")<0&&(d+=f+" ");h=n.trim(d),e!==h&&c.setAttribute("class",h)}}return this},removeClass:function(a){var b,c,d,e,f,g,h,i=0;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,fb(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof a&&a){b=a.match(G)||[];while(c=this[i++])if(e=fb(c),d=1===c.nodeType&&(" "+e+" ").replace(eb," ")){g=0;while(f=b[g++])while(d.indexOf(" "+f+" ")>-1)d=d.replace(" "+f+" "," ");h=n.trim(d),e!==h&&c.setAttribute("class",h)}}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):n.isFunction(a)?this.each(function(c){n(this).toggleClass(a.call(this,c,fb(this),b),b)}):this.each(function(){var b,d,e,f;if("string"===c){d=0,e=n(this),f=a.match(G)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(void 0===a||"boolean"===c)&&(b=fb(this),b&&N.set(this,"__className__",b),this.setAttribute&&this.setAttribute("class",b||a===!1?"":N.get(this,"__className__")||""))})},hasClass:function(a){var b,c,d=0;b=" "+a+" ";while(c=this[d++])if(1===c.nodeType&&(" "+fb(c)+" ").replace(eb," ").indexOf(b)>-1)return!0;return!1}});var gb=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(gb,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){return n.trim(a.value)}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],(c.selected||i===e)&&(l.optDisabled?!c.disabled:null===c.getAttribute("disabled"))&&(!c.parentNode.disabled||!n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(n.valHooks.option.get(d),f)>-1)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>-1:void 0}},l.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})});var hb=/^(?:focusinfocus|focusoutblur)$/;n.extend(n.event,{trigger:function(b,c,e,f){var g,h,i,j,l,m,o,p=[e||d],q=k.call(b,"type")?b.type:b,r=k.call(b,"namespace")?b.namespace.split("."):[];if(h=i=e=e||d,3!==e.nodeType&&8!==e.nodeType&&!hb.test(q+n.event.triggered)&&(q.indexOf(".")>-1&&(r=q.split("."),q=r.shift(),r.sort()),l=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=f?2:3,b.namespace=r.join("."),b.rnamespace=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=e),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},f||!o.trigger||o.trigger.apply(e,c)!==!1)){if(!f&&!o.noBubble&&!n.isWindow(e)){for(j=o.delegateType||q,hb.test(j+q)||(h=h.parentNode);h;h=h.parentNode)p.push(h),i=h;i===(e.ownerDocument||d)&&p.push(i.defaultView||i.parentWindow||a)}g=0;while((h=p[g++])&&!b.isPropagationStopped())b.type=g>1?j:o.bindType||q,m=(N.get(h,"events")||{})[b.type]&&N.get(h,"handle"),m&&m.apply(h,c),m=l&&h[l],m&&m.apply&&L(h)&&(b.result=m.apply(h,c),b.result===!1&&b.preventDefault());return b.type=q,f||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!L(e)||l&&n.isFunction(e[q])&&!n.isWindow(e)&&(i=e[l],i&&(e[l]=null),n.event.triggered=q,e[q](),n.event.triggered=void 0,i&&(e[l]=i)),b.result}},simulate:function(a,b,c){var d=n.extend(new n.Event,c,{type:a,isSimulated:!0});n.event.trigger(d,null,b),d.isDefaultPrevented()&&Line truncated
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* material-design-lite - Material Design Components in CSS, JS and HTML
|
||||
* @version v1.1.1
|
||||
* @license Apache-2.0
|
||||
* @copyright 2015 Google, Inc.
|
||||
* @link https://github.com/google/material-design-lite
|
||||
*/
|
||||
!function(){"use strict";function e(e,t){if(e){if(t.element_.classList.contains(t.CssClasses_.MDL_JS_RIPPLE_EFFECT)){var s=document.createElement("span");s.classList.add(t.CssClasses_.MDL_RIPPLE_CONTAINER),s.classList.add(t.CssClasses_.MDL_JS_RIPPLE_EFFECT);var i=document.createElement("span");i.classList.add(t.CssClasses_.MDL_RIPPLE),s.appendChild(i),e.appendChild(s)}e.addEventListener("click",function(s){s.preventDefault();var i=e.href.split("#")[1],n=t.element_.querySelector("#"+i);t.resetTabState_(),t.resetPanelState_(),e.classList.add(t.CssClasses_.ACTIVE_CLASS),n.classList.add(t.CssClasses_.ACTIVE_CLASS)})}}function t(e,t,s,i){function n(){var n=e.href.split("#")[1],a=i.content_.querySelector("#"+n);i.resetTabState_(t),i.resetPanelState_(s),e.classList.add(i.CssClasses_.IS_ACTIVE),a.classList.add(i.CssClasses_.IS_ACTIVE)}if(i.tabBar_.classList.contains(i.CssClasses_.JS_RIPPLE_EFFECT)){var a=document.createElement("span");a.classList.add(i.CssClasses_.RIPPLE_CONTAINER),a.classList.add(i.CssClasses_.JS_RIPPLE_EFFECT);var l=document.createElement("span");l.classList.add(i.CssClasses_.RIPPLE),a.appendChild(l),e.appendChild(a)}e.addEventListener("click",function(t){"#"===e.getAttribute("href").charAt(0)&&(t.preventDefault(),n())}),e.show=n,e.addEventListener("click",function(n){n.preventDefault();var a=e.href.split("#")[1],l=i.content_.querySelector("#"+a);i.resetTabState_(t),i.resetPanelState_(s),e.classList.add(i.CssClasses_.IS_ACTIVE),l.classList.add(i.CssClasses_.IS_ACTIVE)})}var s={upgradeDom:function(e,t){},upgradeElement:function(e,t){},upgradeElements:function(e){},upgradeAllRegistered:function(){},registerUpgradedCallback:function(e,t){},register:function(e){},downgradeElements:function(e){}};s=function(){function e(e,t){for(var s=0;s<h.length;s++)if(h[s].className===e)return"undefined"!=typeof t&&(h[s]=t),h[s];return!1}function t(e){var t=e.getAttribute("data-upgraded");return null===t?[""]:t.split(",")}function s(e,s){var i=t(e);return-1!==i.indexOf(s)}function i(t,s){if("undefined"==typeof t&&"undefined"==typeof s)for(var a=0;a<h.length;a++)i(h[a].className,h[a].cssClass);else{var l=t;if("undefined"==typeof s){var o=e(l);o&&(s=o.cssClass)}for(var r=document.querySelectorAll("."+s),_=0;_<r.length;_++)n(r[_],l)}}function n(i,n){if(!("object"==typeof i&&i instanceof Element))throw new Error("Invalid argument provided to upgrade MDL element.");var a=t(i),l=[];if(n)s(i,n)||l.push(e(n));else{var o=i.classList;h.forEach(function(e){o.contains(e.cssClass)&&-1===l.indexOf(e)&&!s(i,e.className)&&l.push(e)})}for(var r,_=0,d=l.length;d>_;_++){if(r=l[_],!r)throw new Error("Unable to find a registered component for the given class.");a.push(r.className),i.setAttribute("data-upgraded",a.join(","));var C=new r.classConstructor(i);C[p]=r,c.push(C);for(var u=0,E=r.callbacks.length;E>u;u++)r.callbacks[u](i);r.widget&&(i[r.className]=C);var m=document.createEvent("Events");m.initEvent("mdl-componentupgraded",!0,!0),i.dispatchEvent(m)}}function a(e){Array.isArray(e)||(e="function"==typeof e.item?Array.prototype.slice.call(e):[e]);for(var t,s=0,i=e.length;i>s;s++)t=e[s],t instanceof HTMLElement&&(n(t),t.children.length>0&&a(t.children))}function l(t){var s="undefined"==typeof t.widget&&"undefined"==typeof t.widget,i=!0;s||(i=t.widget||t.widget);var n={classConstructor:t.constructor||t.constructor,className:t.classAsString||t.classAsString,cssClass:t.cssClass||t.cssClass,widget:i,callbacks:[]};if(h.forEach(function(e){if(e.cssClass===n.cssClass)throw new Error("The provided cssClass has already been registered: "+e.cssClass);if(e.className===n.className)throw new Error("The provided className has already been registered")}),t.constructor.prototype.hasOwnProperty(p))throw new Error("MDL component classes must not have "+p+" defined as a property.");var a=e(t.classAsString,n);a||h.push(n)}function o(t,s){var i=e(t);i&&i.callbacks.push(s)}function r(){for(var e=0;e<h.length;e++)i(h[e].className)}function _(e){var t=c.indexOf(e);c.splice(t,1);var s=e.element_.getAttribute("data-upgraded").split(","),i=s.indexOf(e[p].classAsString);s.splice(i,1),e.element_.setAttribute("data-upgraded",s.join(","));var n=document.createEvent("Events");n.initEvent("mdl-componentdowngraded",!0,!0),e.element_.dispatchEvent(n)}function d(e){var t=function(e){c.filter(function(t){return t.element_===e}).forEach(_)};if(e instanceof Array||e instanceof NodeList)for(var s=0;s<e.length;s++)t(e[s]);else{if(!(e instanceof Node))throw new Error("Invalid argument provided to downgrade MDL nodes.");t(e)}}var h=[],c=[],p="mdlComponentConfigInternal_";return{upgradeDom:i,upgradeElement:n,upgradeElements:a,upgradeAllRegistered:r,registerUpgradedCallback:o,register:l,downgradeElements:d}}(),s.ComponentConfigPublic,s.ComponentConfig,s.Component,s.upgradeDom=s.upgradeDom,s.upgradeElement=s.upgradeElement,s.upgradeElements=s.upgradeElements,s.upgradeAllRegistered=s.upgradeAllRegistered,s.registerUpgradedCallback=s.registerUpgradedCallback,s.register=s.registeLine truncated
|
||||
this.actionElement_.addEventListener("click",this.actionHandler_),this.setActionHidden_(!1)),this.textElement_.textContent=this.message_,this.element_.classList.add(this.cssClasses_.ACTIVE),this.element_.setAttribute("aria-hidden","false"),setTimeout(this.cleanup_.bind(this),this.timeout_)},C.prototype.showSnackbar=function(e){if(void 0===e)throw new Error("Please provide a data object with at least a message to display.");if(void 0===e.message)throw new Error("Please provide a message to be displayed.");if(e.actionHandler&&!e.actionText)throw new Error("Please provide action text with the handler.");this.active?this.queuedNotifications_.push(e):(this.active=!0,this.message_=e.message,e.timeout?this.timeout_=e.timeout:this.timeout_=2750,e.actionHandler&&(this.actionHandler_=e.actionHandler),e.actionText&&(this.actionText_=e.actionText),this.displaySnackbar_())},C.prototype.showSnackbar=C.prototype.showSnackbar,C.prototype.checkQueue_=function(){this.queuedNotifications_.length>0&&this.showSnackbar(this.queuedNotifications_.shift())},C.prototype.cleanup_=function(){this.element_.classList.remove(this.cssClasses_.ACTIVE),setTimeout(function(){this.element_.setAttribute("aria-hidden","true"),this.textElement_.textContent="",Boolean(this.actionElement_.getAttribute("aria-hidden"))||(this.setActionHidden_(!0),this.actionElement_.textContent="",this.actionElement_.removeEventListener("click",this.actionHandler_)),this.actionHandler_=void 0,this.message_=void 0,this.actionText_=void 0,this.active=!1,this.checkQueue_()}.bind(this),this.Constant_.ANIMATION_LENGTH)},C.prototype.setActionHidden_=function(e){e?this.actionElement_.setAttribute("aria-hidden","true"):this.actionElement_.removeAttribute("aria-hidden")},s.register({constructor:C,classAsString:"MaterialSnackbar",cssClass:"mdl-js-snackbar",widget:!0});var u=function(e){this.element_=e,this.init()};window.MaterialSpinner=u,u.prototype.Constant_={MDL_SPINNER_LAYER_COUNT:4},u.prototype.CssClasses_={MDL_SPINNER_LAYER:"mdl-spinner__layer",MDL_SPINNER_CIRCLE_CLIPPER:"mdl-spinner__circle-clipper",MDL_SPINNER_CIRCLE:"mdl-spinner__circle",MDL_SPINNER_GAP_PATCH:"mdl-spinner__gap-patch",MDL_SPINNER_LEFT:"mdl-spinner__left",MDL_SPINNER_RIGHT:"mdl-spinner__right"},u.prototype.createLayer=function(e){var t=document.createElement("div");t.classList.add(this.CssClasses_.MDL_SPINNER_LAYER),t.classList.add(this.CssClasses_.MDL_SPINNER_LAYER+"-"+e);var s=document.createElement("div");s.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER),s.classList.add(this.CssClasses_.MDL_SPINNER_LEFT);var i=document.createElement("div");i.classList.add(this.CssClasses_.MDL_SPINNER_GAP_PATCH);var n=document.createElement("div");n.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER),n.classList.add(this.CssClasses_.MDL_SPINNER_RIGHT);for(var a=[s,i,n],l=0;l<a.length;l++){var o=document.createElement("div");o.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE),a[l].appendChild(o)}t.appendChild(s),t.appendChild(i),t.appendChild(n),this.element_.appendChild(t)},u.prototype.createLayer=u.prototype.createLayer,u.prototype.stop=function(){this.element_.classList.remove("is-active")},u.prototype.stop=u.prototype.stop,u.prototype.start=function(){this.element_.classList.add("is-active")},u.prototype.start=u.prototype.start,u.prototype.init=function(){if(this.element_){for(var e=1;e<=this.Constant_.MDL_SPINNER_LAYER_COUNT;e++)this.createLayer(e);this.element_.classList.add("is-upgraded")}},s.register({constructor:u,classAsString:"MaterialSpinner",cssClass:"mdl-js-spinner",widget:!0});var E=function(e){this.element_=e,this.init()};window.MaterialSwitch=E,E.prototype.Constant_={TINY_TIMEOUT:.001},E.prototype.CssClasses_={INPUT:"mdl-switch__input",TRACK:"mdl-switch__track",THUMB:"mdl-switch__thumb",FOCUS_HELPER:"mdl-switch__focus-helper",RIPPLE_EFFECT:"mdl-js-ripple-effect",RIPPLE_IGNORE_EVENTS:"mdl-js-ripple-effect--ignore-events",RIPPLE_CONTAINER:"mdl-switch__ripple-container",RIPPLE_CENTER:"mdl-ripple--center",RIPPLE:"mdl-ripple",IS_FOCUSED:"is-focused",IS_DISABLED:"is-disabled",IS_CHECKED:"is-checked"},E.prototype.onChange_=function(e){this.updateClasses_()},E.prototype.onFocus_=function(e){this.element_.classList.add(this.CssClasses_.IS_FOCUSED)},E.prototype.onBlur_=function(e){this.element_.classList.remove(this.CssClasses_.IS_FOCUSED)},E.prototype.onMouseUp_=function(e){this.blur_()},E.prototype.updateClasses_=function(){this.checkDisabled(),this.checkToggleState()},E.prototype.blur_=function(){window.setTimeout(function(){this.inputElement_.blur()}.bind(this),this.Constant_.TINY_TIMEOUT)},E.prototype.checkDisabled=function(){this.inputElement_.disabled?this.element_.classList.add(this.CssClasses_.IS_DISABLED):this.element_.classList.remove(this.CssClasses_.IS_DISABLED)},E.prototype.checkDisabled=E.prototype.checkDisabled,E.prototype.checkToggleState=function(){this.inputElement_.checked?this.element_.classList.add(this.CssClasses_.IS_CHECKED):this.element_.classList.remove(this.CssClasLine truncated
|
||||
//# sourceMappingURL=material.min.js.map
|
||||
@@ -0,0 +1,243 @@
|
||||
function getXMLString(xml, tagName) {
|
||||
var xmlDoc = xml.responseXML;
|
||||
return xmlDoc.getElementsByTagName(tagName)[0].childNodes[0].nodeValue;
|
||||
}
|
||||
|
||||
function verifyResponseStatus(xml) {
|
||||
var responseCode = parseInt(getXMLString(xml, "status_code"));
|
||||
if (responseCode !== 200) {
|
||||
throw "Error, expected status code 200, received status code: ".concat(responseCode.toString());
|
||||
}
|
||||
}
|
||||
|
||||
function getServerInfo() {
|
||||
var connectionResp = openHttpConnectionToString(baseUrlHttps + "/serverinfo?"+buildUniqueIdUuidString(), true);
|
||||
var serverResp = getServerVersion(connectionResp);
|
||||
|
||||
if(serverResp == 200) {
|
||||
return connectionResp;
|
||||
} else {
|
||||
if(serverResp == 401) {
|
||||
return openHttpConnectionToString(baseUrlHttp + "/serverinfo", true);
|
||||
}
|
||||
throw serverResp
|
||||
}
|
||||
}
|
||||
|
||||
function getComputerDetails() {
|
||||
var serverInfo = getServerInfo();
|
||||
var details = {
|
||||
name: getXMLString(serverinfo, "hostname"),
|
||||
uuid: UUID.fromString(getXmlString(serverInfo, "uniqueid").trim()),
|
||||
macAddress: getXmlString(serverInfo, "mac").trim(),
|
||||
localIPStr: getXmlString(serverInfo, "LocalIP"),
|
||||
externalIpStr: getXmlString(serverInfo, "ExternalIP"),
|
||||
pairState: parseInt(getXmlString(serverInfo, "PairStatus").trim()) == 1 ? PairState.PAIRED : PairState.NOT_PAIRED, // needs support for PiarState.FAILED
|
||||
runningGameId: getCurrentGame(serverInfo), // force to 0 if an error happens
|
||||
state: ONLINE
|
||||
};
|
||||
return details;
|
||||
}
|
||||
|
||||
function openHTTPRequest(destinationURL, enableReadTimeout, callbackFunction) {
|
||||
var xmlHttp = new XMLHttpRequest();
|
||||
if(enableReadTimeout) {
|
||||
xmlHttp.timeout = 5000;
|
||||
}
|
||||
xmlHttp.onreadystatechange = function() {
|
||||
callbackFunction(xmlHttp);
|
||||
// if (xmlHttp.readyState == 4 && xmlHttp.status == 200) callbackFunction(xmlHttp.responseText);
|
||||
}
|
||||
xmlHttp.open("GET", theUrl, true); // true for asynchronous
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
|
||||
|
||||
function getServerVersion(serverInfo) {
|
||||
return getXmlString(serverInfo, "appversion");
|
||||
}
|
||||
|
||||
function getPairState() {
|
||||
return pm.getPairState(getServerInfo());
|
||||
}
|
||||
|
||||
function getPairState(serverInfo) {
|
||||
return pm.getPairState(serverInfo);
|
||||
}
|
||||
|
||||
|
||||
function getMaxLumaPixelsH264(serverInfo) {
|
||||
var str = getXmlString(serverInfo, "MaxLumaPixelsH264");
|
||||
if (str !== null) {
|
||||
return parseInt(str);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function getMaxLumaPixelsHEVC(serverInfo) {
|
||||
var str = getXmlString(serverInfo, "MaxLumaPixelsHEVC");
|
||||
if (str !== null) {
|
||||
return parseInt(str);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function getGpuType(String serverInfo) {
|
||||
return getXmlString(serverInfo, "gputype");
|
||||
}
|
||||
|
||||
public boolean supports4K(String serverInfo) throws XmlPullParserException, IOException {
|
||||
// serverinfo returns supported resolutions in descending order, so getting the first
|
||||
// height will give us whether we support 4K. If this is not present, we don't support
|
||||
// 4K.
|
||||
var heightStr = getXmlString(serverInfo, "Height");
|
||||
if (heightStr == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// GFE 2.8 released without 4K support, even though it claims to have such
|
||||
// support using the SupportedDisplayMode element. We'll use the new ServerCodecModeSupport
|
||||
// element to tell whether 4K is supported or not. For now, we just check the existence
|
||||
// of this element. I'm hopeful that the production version that ships with 4K will
|
||||
// also be the first production version that has this element.
|
||||
if (getXmlString(serverInfo, "ServerCodecModeSupport") == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parseInt(heightStr) >= 2160) {
|
||||
// Found a 4K resolution in the list
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function getCurrentGame(String serverInfo) throws IOException, XmlPullParserException {
|
||||
// GFE 2.8 started keeping currentgame set to the last game played. As a result, it no longer
|
||||
// has the semantics that its name would indicate. To contain the effects of this change as much
|
||||
// as possible, we'll force the current game to zero if the server isn't in a streaming session.
|
||||
var serverState = getXmlString(serverInfo, "state").trim();
|
||||
if (serverState != null && !serverState.match("_SERVER_AVAILABLE" + "$")) { // an endsWith implementation.
|
||||
var game = getXmlString(serverInfo, "currentgame").trim();
|
||||
return parseInt(game);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function getAppById(appId) {
|
||||
var appList = getAppList();
|
||||
for (var i = 0, len = appList.length; i < len; i++) {
|
||||
if (appList[i].getAppId() == appId) {
|
||||
return appFromList;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* NOTE: Only use this function if you know what you're doing.
|
||||
* It's totally valid to have two apps named the same thing,
|
||||
* or even nothing at all! Look apps up by ID if at all possible
|
||||
* using the above function */
|
||||
function getAppByName(appName) {
|
||||
var appList = getAppList();
|
||||
for (var i = 0, len = appList.length; i < len; i++) {
|
||||
if (appList[i].getAppName().equalsIgnoreCase(appName)) {
|
||||
return appList[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function pair(pin) {
|
||||
return pm.pair(pin);
|
||||
}
|
||||
|
||||
function getAppListByReader(xml) {
|
||||
var rootElement = xml.getElementsByTagName("root")[0];
|
||||
var appElements = rootElement.getElementsByTagName("App");
|
||||
var returnVar;
|
||||
for(var i = 0, len = appElements.length; i < len; i++) {
|
||||
returnVar.push(
|
||||
var app {
|
||||
appTitle: appElements[i].getElementsByTagName("AppTitle")[0].nodeValue;
|
||||
ID: appElements[i].getElementsByTagName("ID")[0].nodeValue;
|
||||
isRunning: appElements[i].getElementsByTagName("IsRunning")[0].nodeValue;
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function getAppListRaw() {
|
||||
return openHttpConnectionToString(baseUrlHttps + "/applist?" + buildUniqueIdUuidString(), true);
|
||||
}
|
||||
|
||||
function getAppList() {
|
||||
if (verbose) {
|
||||
// Use the raw function so the app list is printed
|
||||
return getAppListByReader(new StringReader(getAppListRaw()));
|
||||
}
|
||||
else {
|
||||
var resp = openHttpConnection(baseUrlHttps + "/applist?" + buildUniqueIdUuidString(), true);
|
||||
var appList = getAppListByReader(new InputStreamReader(resp.byteStream()));
|
||||
resp.close();
|
||||
return appList;
|
||||
}
|
||||
}
|
||||
|
||||
function unpair() {
|
||||
openHttpConnectionToString(baseUrlHttps + "/unpair?"+buildUniqueIdUuidString(), true);
|
||||
}
|
||||
|
||||
|
||||
function getBoxArt(app) {
|
||||
var resp = openHttpConnection(baseUrlHttps + "/appasset?"+ buildUniqueIdUuidString() + "&appid=" + app.getAppId() + "&AssetType=2&AssetIdx=0", true);
|
||||
return resp.byteStream();
|
||||
}
|
||||
|
||||
|
||||
var hexChar = ["0", "1", "2", "3", "4", "5", "6", "7","8", "9", "A", "B", "C", "D", "E", "F"];
|
||||
function byteToHex(b) { // thanks, https://gist.github.com/amorri40/3430429
|
||||
if (b.constructor === Array) { // if we were given an array, then return an array.
|
||||
var returnVar;
|
||||
for(var i = 0, len = b.length; i < len; i++) {
|
||||
returnVar.push(hexChar[(b[i] >> 4) & 0x0f] + hexChar[b[i] & 0x0f]);
|
||||
}
|
||||
return returnVar;
|
||||
}
|
||||
return hexChar[(b >> 4) & 0x0f] + hexChar[b & 0x0f];
|
||||
}
|
||||
|
||||
function launchApp(context, appId){
|
||||
var xmlStr = openHttpConnectionToString(baseUrlHttps +
|
||||
"/launch?" + buildUniqueIdUuidString() +
|
||||
"&appid=" + appId +
|
||||
"&mode=" + context.negotiatedWidth + "x" + context.negotiatedHeight + "x" + context.negotiatedFps +
|
||||
"&additionalStates=1&sops=" + (context.streamConfig.getSops() ? 1 : 0) +
|
||||
"&rikey="+bytesToHex(context.riKey.getEncoded()) +
|
||||
"&rikeyid="+context.riKeyId +
|
||||
"&localAudioPlayMode=" + (context.streamConfig.getPlayLocalAudio() ? 1 : 0) +
|
||||
"&surroundAudioInfo=" + ((context.streamConfig.getAudioChannelMask() << 16) + context.streamConfig.getAudioChannelCount()),
|
||||
false);
|
||||
var gameSession = getXmlString(xmlStr, "gamesession");
|
||||
return gameSession != null && !gameSession.equals("0");
|
||||
}
|
||||
|
||||
function resumeApp(context) {
|
||||
var xmlStr = openHttpConnectionToString(baseUrlHttps + "/resume?" + buildUniqueIdUuidString() +
|
||||
"&rikey="+bytesToHex(context.riKey.getEncoded()) +
|
||||
"&rikeyid="+context.riKeyId, false);
|
||||
var resume = getXmlString(xmlStr, "resume");
|
||||
return parseInt(resume) != 0;
|
||||
}
|
||||
|
||||
function quitApp() {
|
||||
var xmlStr = openHttpConnectionToString(baseUrlHttps + "/cancel?" + buildUniqueIdUuidString(), false);
|
||||
var cancel = getXmlString(xmlStr, "cancel");
|
||||
return parseInt(cancel) != 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user