mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-18 00:56:38 +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)
|
// 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'
|
// it requires manually restoring window state to 'normal'
|
||||||
if (state == '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) {
|
if (chrome.storage) {
|
||||||
// load stored window state
|
// load stored window state
|
||||||
chrome.storage.sync.get('windowState', function(item) {
|
chrome.storage.sync.get('windowState', function(item) {
|
||||||
windowState = (item && item.windowState)
|
windowState = (item && item.windowState) ?
|
||||||
? item.windowState
|
item.windowState :
|
||||||
: windowState;
|
windowState;
|
||||||
createWindow(windowState);
|
createWindow(windowState);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,13 +35,15 @@ function fullscreenChromeWindow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadWindowState() {
|
function loadWindowState() {
|
||||||
if (!chrome.storage) { return; }
|
if (!chrome.storage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
chrome.storage.sync.get('windowState', function(item) {
|
chrome.storage.sync.get('windowState', function(item) {
|
||||||
// load stored window state
|
// load stored window state
|
||||||
windowState = (item && item.windowState)
|
windowState = (item && item.windowState) ?
|
||||||
? item.windowState
|
item.windowState :
|
||||||
: windowState;
|
windowState;
|
||||||
|
|
||||||
// subscribe to chrome's windowState events
|
// subscribe to chrome's windowState events
|
||||||
chrome.app.window.current().onFullscreened.addListener(onFullscreened);
|
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);
|
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) {
|
sendMessage('httpInit', [pairingCert.cert, pairingCert.privateKey, myUniqueid]).then(function(ret) {
|
||||||
restoreUiAfterNaClLoad();
|
restoreUiAfterNaClLoad();
|
||||||
}, function(failedInit) {
|
}, function(failedInit) {
|
||||||
@ -345,8 +346,7 @@ function addHost() {
|
|||||||
// Just update the addresses
|
// Just update the addresses
|
||||||
hosts[_nvhttpHost.serverUid].address = _nvhttpHost.address;
|
hosts[_nvhttpHost.serverUid].address = _nvhttpHost.address;
|
||||||
hosts[_nvhttpHost.serverUid].userEnteredAddress = _nvhttpHost.userEnteredAddress;
|
hosts[_nvhttpHost.serverUid].userEnteredAddress = _nvhttpHost.userEnteredAddress;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
beginBackgroundPollingOfHost(_nvhttpHost);
|
beginBackgroundPollingOfHost(_nvhttpHost);
|
||||||
addHostToGrid(_nvhttpHost);
|
addHostToGrid(_nvhttpHost);
|
||||||
}
|
}
|
||||||
@ -362,10 +362,28 @@ function addHost() {
|
|||||||
// host is an NvHTTP object
|
// host is an NvHTTP object
|
||||||
function addHostToGrid(host, ismDNSDiscovered) {
|
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 outerDiv = $("<div>", {
|
||||||
var cell = $("<div>", {class: 'mdl-card__title mdl-card--expand', id: 'hostgrid-' + host.serverUid });
|
class: 'host-container mdl-card mdl-shadow--4dp',
|
||||||
$(cell).prepend($("<h2>", {class: "mdl-card__title-text", html: host.hostname}));
|
id: 'host-container-' + host.serverUid,
|
||||||
var removalButton = $("<div>", {class: "remove-host", id: "removeHostButton-" + host.serverUid, role: 'button', tabindex: 0, 'aria-label': 'Remove host ' + host.hostname});
|
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.off('click');
|
||||||
removalButton.click(function() {
|
removalButton.click(function() {
|
||||||
removeClicked(host);
|
removeClicked(host);
|
||||||
@ -438,16 +456,25 @@ function sortTitles(list, sortOrder) {
|
|||||||
|
|
||||||
// A - Z
|
// A - Z
|
||||||
if (sortOrder === 'ASC') {
|
if (sortOrder === 'ASC') {
|
||||||
if (titleA < titleB) { return -1; }
|
if (titleA < titleB) {
|
||||||
if (titleA > titleB) { return 1; }
|
return -1;
|
||||||
|
}
|
||||||
|
if (titleA > titleB) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Z - A
|
// Z - A
|
||||||
if (sortOrder === 'DESC') {
|
if (sortOrder === 'DESC') {
|
||||||
if (titleA < titleB) { return 1; }
|
if (titleA < titleB) {
|
||||||
if (titleA > titleB) { return -1; }
|
return 1;
|
||||||
return 0; }
|
}
|
||||||
|
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.
|
// double clicking the button will cause multiple box arts to appear.
|
||||||
// to mitigate this we ensure we don't add a duplicate.
|
// 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
|
// 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-grid").append(outerDiv);
|
||||||
|
|
||||||
$('#game-' + app.id).on('click', function() {
|
$('#game-' + app.id).on('click', function() {
|
||||||
@ -498,11 +537,17 @@ function showApps(host) {
|
|||||||
}
|
}
|
||||||
host.getBoxArt(app.id).then(function(resolvedPromise) {
|
host.getBoxArt(app.id).then(function(resolvedPromise) {
|
||||||
// put the box art into the image holder
|
// 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) {
|
}, 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());
|
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) {
|
}, function(failedAppList) {
|
||||||
@ -612,7 +657,8 @@ function startGame(host, appID) {
|
|||||||
rikey, rikeyid, 0x030002 // Surround channel mask << 16 | Surround channel count
|
rikey, rikeyid, 0x030002 // Surround channel mask << 16 | Surround channel count
|
||||||
).then(function(ret) {
|
).then(function(ret) {
|
||||||
sendMessage('startRequest', [host.address, streamWidth, streamHeight, frameRate,
|
sendMessage('startRequest', [host.address, streamWidth, streamHeight, frameRate,
|
||||||
bitrate.toString(), rikey, rikeyid.toString(), host.appVersion]);
|
bitrate.toString(), rikey, rikeyid.toString(), host.appVersion
|
||||||
|
]);
|
||||||
}, function(failedResumeApp) {
|
}, function(failedResumeApp) {
|
||||||
console.eror('%c[index.js, startGame]', 'color:green;', 'Failed to resume the app! Returned error was' + failedResumeApp);
|
console.eror('%c[index.js, startGame]', 'color:green;', 'Failed to resume the app! Returned error was' + failedResumeApp);
|
||||||
return;
|
return;
|
||||||
@ -630,7 +676,8 @@ function startGame(host, appID) {
|
|||||||
gamepadMask
|
gamepadMask
|
||||||
).then(function(ret) {
|
).then(function(ret) {
|
||||||
sendMessage('startRequest', [host.address, streamWidth, streamHeight, frameRate,
|
sendMessage('startRequest', [host.address, streamWidth, streamHeight, frameRate,
|
||||||
bitrate.toString(), rikey, rikeyid.toString(), host.appVersion]);
|
bitrate.toString(), rikey, rikeyid.toString(), host.appVersion
|
||||||
|
]);
|
||||||
}, function(failedLaunchApp) {
|
}, function(failedLaunchApp) {
|
||||||
console.error('%c[index.js, launchApp]', 'color: green;', 'Failed to launch app width id: ' + appID + '\nReturned error was: ' + failedLaunchApp);
|
console.error('%c[index.js, launchApp]', 'color: green;', 'Failed to launch app width id: ' + appID + '\nReturned error was: ' + failedLaunchApp);
|
||||||
return;
|
return;
|
||||||
|
@ -11,7 +11,10 @@ var callbacks_ids = 1;
|
|||||||
var sendMessage = function(method, params) {
|
var sendMessage = function(method, params) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
var id = callbacks_ids++;
|
var id = callbacks_ids++;
|
||||||
callbacks[id] = {'resolve': resolve, 'reject': reject};
|
callbacks[id] = {
|
||||||
|
'resolve': resolve,
|
||||||
|
'reject': reject
|
||||||
|
};
|
||||||
|
|
||||||
common.naclModule.postMessage({
|
common.naclModule.postMessage({
|
||||||
'callbackId': id,
|
'callbackId': id,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
function guuid() {
|
function guuid() {
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
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);
|
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');
|
console.log('%c[utils.js, utils.js, getBoxArt]', 'color: gray;', 'Returning network-fetched box art');
|
||||||
resolve(this.result);
|
resolve(this.result);
|
||||||
}
|
}
|
||||||
reader.readAsDataURL(new Blob([boxArtBuffer], {type: "image/png"}));
|
reader.readAsDataURL(new Blob([boxArtBuffer], {
|
||||||
|
type: "image/png"
|
||||||
|
}));
|
||||||
}.bind(this), function(error) {
|
}.bind(this), function(error) {
|
||||||
console.error('%c[utils.js, utils.js, getBoxArt]', 'color: gray;', 'Box-art request failed!', error);
|
console.error('%c[utils.js, utils.js, getBoxArt]', 'color: gray;', 'Box-art request failed!', error);
|
||||||
reject(error);
|
reject(error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user