mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-18 00:56:38 +00:00
fixed bugs where new hosts would get different icons, and where clicking the .svg would fail to load the app list
This commit is contained in:
parent
286bc316e6
commit
edc4a0ad29
@ -1,4 +1,7 @@
|
|||||||
var host = "";
|
// CURRENT ISSUE: host is not being saved. or it may have not been saved, and my state is screwed up.
|
||||||
|
// if (given host not in hosts) hosts.append(given host);
|
||||||
|
|
||||||
|
var _host = "";
|
||||||
var hosts = [];
|
var hosts = [];
|
||||||
var pairingCert;
|
var pairingCert;
|
||||||
var myUniqueid;
|
var myUniqueid;
|
||||||
@ -149,14 +152,19 @@ function pairTo(host, onSuccess, onFailure) {
|
|||||||
function hostChosen(sourceEvent) {
|
function hostChosen(sourceEvent) {
|
||||||
|
|
||||||
if(sourceEvent && sourceEvent.srcElement) {
|
if(sourceEvent && sourceEvent.srcElement) {
|
||||||
console.log('parsing host from grid element.');
|
if (sourceEvent.srcElement.innerText == "") {
|
||||||
host = sourceEvent.srcElement.innerText;
|
console.log('user clicked image. we gotta hack to parse out the host.');
|
||||||
|
host = sourceEvent.currentTarget.childNodes[1].textContent;
|
||||||
|
} else {
|
||||||
|
console.log('parsing host from grid element.');
|
||||||
|
host = sourceEvent.srcElement.innerText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
api = new NvHTTP(host, myUniqueid);
|
api = new NvHTTP(host, myUniqueid);
|
||||||
api.refreshServerInfo().then(function (ret) {
|
api.refreshServerInfo().then(function (ret) {
|
||||||
if(!api.paired) {
|
if(!api.paired) {
|
||||||
pairTo(host, function(){ showApps(); }, function(){});
|
pairTo(host, function(){ showApps(); saveHosts(); }, function(){});
|
||||||
} else {
|
} else {
|
||||||
showApps();
|
showApps();
|
||||||
}
|
}
|
||||||
@ -178,15 +186,15 @@ function cancelAddHost() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addHostToGrid(host) {
|
function addHostToGrid(host) {
|
||||||
if(hosts.indexOf(host) < 0) { // we don't have this host in our list. add it, and save it.
|
var cell = document.createElement('div');
|
||||||
var cell = document.createElement('div');
|
cell.className += 'mdl-cell mdl-cell--3-col host-cell mdl-button mdl-js-button mdl-js-ripple-effect';
|
||||||
cell.className += 'mdl-cell mdl-cell--3-col';
|
cell.id = 'hostgrid-' + host;
|
||||||
cell.id = 'hostgrid-' + host;
|
cell.innerHTML = host;
|
||||||
cell.innerHTML = host;
|
$(cell).prepend($("<img>", {src: "static/res/ic_desktop_windows_white_24px.svg"}));
|
||||||
$('#host-grid').append(cell);
|
$('#host-grid').append(cell);
|
||||||
cell.onclick = hostChosen;
|
cell.onclick = hostChosen;
|
||||||
|
if(hosts.indexOf(host) < 0) {
|
||||||
hosts.push(host);
|
hosts.push(host);
|
||||||
saveHosts();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +204,7 @@ function continueAddHost() {
|
|||||||
pairTo(inputHost,
|
pairTo(inputHost,
|
||||||
function() {
|
function() {
|
||||||
addHostToGrid(inputHost);
|
addHostToGrid(inputHost);
|
||||||
|
saveHosts();
|
||||||
document.querySelector('#addHostDialog').close();
|
document.querySelector('#addHostDialog').close();
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
@ -533,13 +542,7 @@ function onWindowLoad(){
|
|||||||
chrome.storage.sync.get('hosts', function(previousValue) {
|
chrome.storage.sync.get('hosts', function(previousValue) {
|
||||||
hosts = previousValue.hosts != null ? previousValue.hosts : [];
|
hosts = previousValue.hosts != null ? previousValue.hosts : [];
|
||||||
for(var i = 0; i < hosts.length; i++) { // programmatically add each new host.
|
for(var i = 0; i < hosts.length; i++) { // programmatically add each new host.
|
||||||
var cell = document.createElement('div');
|
addHostToGrid(hosts[i]);
|
||||||
cell.className += 'mdl-cell mdl-cell--3-col host-cell mdl-button mdl-js-button mdl-js-ripple-effect';
|
|
||||||
cell.id = 'hostgrid-' + hosts[i];
|
|
||||||
cell.innerHTML = hosts[i];
|
|
||||||
$(cell).prepend($("<img>", {src: "static/res/ic_desktop_windows_white_24px.svg"}));
|
|
||||||
$('#host-grid').append(cell);
|
|
||||||
cell.onclick = hostChosen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user