mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 08:36:42 +00:00
Fixed indentation usign atom-beautify
This commit is contained in:
parent
49bdfcc33d
commit
28a76fa965
@ -10,7 +10,9 @@ function createWindow(state) {
|
||||
// state = 'normal' in some cases not work (e.g. starting app from 'chrome://extensions' always open window in fullscreen mode)
|
||||
// it requires manually restoring window state to 'normal'
|
||||
if (state == 'normal') {
|
||||
setTimeout(function() { window.restore(); }, 1000);
|
||||
setTimeout(function() {
|
||||
window.restore();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -22,9 +24,9 @@ chrome.app.runtime.onLaunched.addListener(function() {
|
||||
if (chrome.storage) {
|
||||
// load stored window state
|
||||
chrome.storage.sync.get('windowState', function(item) {
|
||||
windowState = (item && item.windowState)
|
||||
? item.windowState
|
||||
: windowState;
|
||||
windowState = (item && item.windowState) ?
|
||||
item.windowState :
|
||||
windowState;
|
||||
createWindow(windowState);
|
||||
});
|
||||
} else {
|
||||
|
@ -35,13 +35,15 @@ function fullscreenChromeWindow() {
|
||||
}
|
||||
|
||||
function loadWindowState() {
|
||||
if (!chrome.storage) { return; }
|
||||
if (!chrome.storage) {
|
||||
return;
|
||||
}
|
||||
|
||||
chrome.storage.sync.get('windowState', function(item) {
|
||||
// load stored window state
|
||||
windowState = (item && item.windowState)
|
||||
? item.windowState
|
||||
: windowState;
|
||||
windowState = (item && item.windowState) ?
|
||||
item.windowState :
|
||||
windowState;
|
||||
|
||||
// subscribe to chrome's windowState events
|
||||
chrome.app.window.current().onFullscreened.addListener(onFullscreened);
|
||||
@ -214,8 +216,7 @@ function moduleDidLoad() {
|
||||
console.error('%c[index.js, moduleDidLoad]', 'color: green;', 'Failed httpInit! Returned error was: ', failedInit);
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sendMessage('httpInit', [pairingCert.cert, pairingCert.privateKey, myUniqueid]).then(function(ret) {
|
||||
restoreUiAfterNaClLoad();
|
||||
}, function(failedInit) {
|
||||
@ -345,8 +346,7 @@ function addHost() {
|
||||
// Just update the addresses
|
||||
hosts[_nvhttpHost.serverUid].address = _nvhttpHost.address;
|
||||
hosts[_nvhttpHost.serverUid].userEnteredAddress = _nvhttpHost.userEnteredAddress;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
beginBackgroundPollingOfHost(_nvhttpHost);
|
||||
addHostToGrid(_nvhttpHost);
|
||||
}
|
||||
@ -362,10 +362,28 @@ function addHost() {
|
||||
// host is an NvHTTP object
|
||||
function addHostToGrid(host, ismDNSDiscovered) {
|
||||
|
||||
var outerDiv = $("<div>", {class: 'host-container mdl-card mdl-shadow--4dp', id: 'host-container-' + host.serverUid, role: 'link', tabindex: 0, 'aria-label': host.hostname });
|
||||
var cell = $("<div>", {class: 'mdl-card__title mdl-card--expand', id: 'hostgrid-' + host.serverUid });
|
||||
$(cell).prepend($("<h2>", {class: "mdl-card__title-text", html: host.hostname}));
|
||||
var removalButton = $("<div>", {class: "remove-host", id: "removeHostButton-" + host.serverUid, role: 'button', tabindex: 0, 'aria-label': 'Remove host ' + host.hostname});
|
||||
var outerDiv = $("<div>", {
|
||||
class: 'host-container mdl-card mdl-shadow--4dp',
|
||||
id: 'host-container-' + host.serverUid,
|
||||
role: 'link',
|
||||
tabindex: 0,
|
||||
'aria-label': host.hostname
|
||||
});
|
||||
var cell = $("<div>", {
|
||||
class: 'mdl-card__title mdl-card--expand',
|
||||
id: 'hostgrid-' + host.serverUid
|
||||
});
|
||||
$(cell).prepend($("<h2>", {
|
||||
class: "mdl-card__title-text",
|
||||
html: host.hostname
|
||||
}));
|
||||
var removalButton = $("<div>", {
|
||||
class: "remove-host",
|
||||
id: "removeHostButton-" + host.serverUid,
|
||||
role: 'button',
|
||||
tabindex: 0,
|
||||
'aria-label': 'Remove host ' + host.hostname
|
||||
});
|
||||
removalButton.off('click');
|
||||
removalButton.click(function() {
|
||||
removeClicked(host);
|
||||
@ -438,16 +456,25 @@ function sortTitles(list, sortOrder) {
|
||||
|
||||
// A - Z
|
||||
if (sortOrder === 'ASC') {
|
||||
if (titleA < titleB) { return -1; }
|
||||
if (titleA > titleB) { return 1; }
|
||||
if (titleA < titleB) {
|
||||
return -1;
|
||||
}
|
||||
if (titleA > titleB) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Z - A
|
||||
if (sortOrder === 'DESC') {
|
||||
if (titleA < titleB) { return 1; }
|
||||
if (titleA > titleB) { return -1; }
|
||||
return 0; }
|
||||
if (titleA < titleB) {
|
||||
return 1;
|
||||
}
|
||||
if (titleA > titleB) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -479,9 +506,21 @@ function showApps(host) {
|
||||
// double clicking the button will cause multiple box arts to appear.
|
||||
// to mitigate this we ensure we don't add a duplicate.
|
||||
// This isn't perfect: there's lots of RTTs before the logic prevents anything
|
||||
var outerDiv = $("<div>", {class: 'game-container mdl-card mdl-shadow--4dp', id: 'game-'+app.id, role: 'link', tabindex: 0, title: app.title, 'aria-label': app.title });
|
||||
var outerDiv = $("<div>", {
|
||||
class: 'game-container mdl-card mdl-shadow--4dp',
|
||||
id: 'game-' + app.id,
|
||||
role: 'link',
|
||||
tabindex: 0,
|
||||
title: app.title,
|
||||
'aria-label': app.title
|
||||
});
|
||||
|
||||
$(outerDiv).append($("<div>", {class: "game-title", html: $("<span>", {html: app.title} )}));
|
||||
$(outerDiv).append($("<div>", {
|
||||
class: "game-title",
|
||||
html: $("<span>", {
|
||||
html: app.title
|
||||
})
|
||||
}));
|
||||
$("#game-grid").append(outerDiv);
|
||||
|
||||
$('#game-' + app.id).on('click', function() {
|
||||
@ -498,11 +537,17 @@ function showApps(host) {
|
||||
}
|
||||
host.getBoxArt(app.id).then(function(resolvedPromise) {
|
||||
// put the box art into the image holder
|
||||
$(outerDiv).append($("<img \>", {src: resolvedPromise, name: app.title }));
|
||||
$(outerDiv).append($("<img \>", {
|
||||
src: resolvedPromise,
|
||||
name: app.title
|
||||
}));
|
||||
|
||||
}, function(failedPromise) {
|
||||
console.log('%c[index.js, showApps]', 'color: green;', 'Error! Failed to retrieve box art for app ID: ' + app.id + '. Returned value was: ' + failedPromise, '\n Host object:', host, host.toString());
|
||||
$(outerDiv).append($("<img \>", {src: "static/res/no_app_image.png", name: app.title }));
|
||||
$(outerDiv).append($("<img \>", {
|
||||
src: "static/res/no_app_image.png",
|
||||
name: app.title
|
||||
}));
|
||||
});
|
||||
});
|
||||
}, function(failedAppList) {
|
||||
@ -612,7 +657,8 @@ function startGame(host, appID) {
|
||||
rikey, rikeyid, 0x030002 // Surround channel mask << 16 | Surround channel count
|
||||
).then(function(ret) {
|
||||
sendMessage('startRequest', [host.address, streamWidth, streamHeight, frameRate,
|
||||
bitrate.toString(), rikey, rikeyid.toString(), host.appVersion]);
|
||||
bitrate.toString(), rikey, rikeyid.toString(), host.appVersion
|
||||
]);
|
||||
}, function(failedResumeApp) {
|
||||
console.eror('%c[index.js, startGame]', 'color:green;', 'Failed to resume the app! Returned error was' + failedResumeApp);
|
||||
return;
|
||||
@ -630,7 +676,8 @@ function startGame(host, appID) {
|
||||
gamepadMask
|
||||
).then(function(ret) {
|
||||
sendMessage('startRequest', [host.address, streamWidth, streamHeight, frameRate,
|
||||
bitrate.toString(), rikey, rikeyid.toString(), host.appVersion]);
|
||||
bitrate.toString(), rikey, rikeyid.toString(), host.appVersion
|
||||
]);
|
||||
}, function(failedLaunchApp) {
|
||||
console.error('%c[index.js, launchApp]', 'color: green;', 'Failed to launch app width id: ' + appID + '\nReturned error was: ' + failedLaunchApp);
|
||||
return;
|
||||
|
@ -11,7 +11,10 @@ var callbacks_ids = 1;
|
||||
var sendMessage = function(method, params) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var id = callbacks_ids++;
|
||||
callbacks[id] = {'resolve': resolve, 'reject': reject};
|
||||
callbacks[id] = {
|
||||
'resolve': resolve,
|
||||
'reject': reject
|
||||
};
|
||||
|
||||
common.naclModule.postMessage({
|
||||
'callbackId': id,
|
||||
|
@ -1,6 +1,7 @@
|
||||
function guuid() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
||||
var r = Math.random() * 16 | 0,
|
||||
v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
@ -379,7 +380,9 @@ NvHTTP.prototype = {
|
||||
console.log('%c[utils.js, utils.js, getBoxArt]', 'color: gray;', 'Returning network-fetched box art');
|
||||
resolve(this.result);
|
||||
}
|
||||
reader.readAsDataURL(new Blob([boxArtBuffer], {type: "image/png"}));
|
||||
reader.readAsDataURL(new Blob([boxArtBuffer], {
|
||||
type: "image/png"
|
||||
}));
|
||||
}.bind(this), function(error) {
|
||||
console.error('%c[utils.js, utils.js, getBoxArt]', 'color: gray;', 'Box-art request failed!', error);
|
||||
reject(error);
|
||||
|
Loading…
x
Reference in New Issue
Block a user