mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
now with unpairing button. The button location and styling is very broken.
This commit is contained in:
parent
cd5cfc1609
commit
19d207a4c8
13
index.html
13
index.html
@ -104,6 +104,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
|
<dialog id="unpairHostDialog" class="mdl-dialog">
|
||||||
|
<h3 class="mdl-dialog__title">Unpair from this host?</h3>
|
||||||
|
<div class="mdl-dialog__content">
|
||||||
|
<p id="unpairHostDialogText">
|
||||||
|
Are you sure you want to unpair from this host?
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="mdl-dialog__actions">
|
||||||
|
<button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" id="cancelUnpairHost">No</button>
|
||||||
|
<button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" id="continueUnpairHost">Yes</button>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
<dialog id="addHostDialog" class="mdl-dialog">
|
<dialog id="addHostDialog" class="mdl-dialog">
|
||||||
<h3 class="mdl-dialog__title">Add PC Manually</h3>
|
<h3 class="mdl-dialog__title">Add PC Manually</h3>
|
||||||
<div class="mdl-dialog__content">
|
<div class="mdl-dialog__content">
|
||||||
|
@ -9,11 +9,14 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.mdl-cell {
|
.mdl-cell {
|
||||||
background:#44c763;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color:#fff;
|
color:#fff;
|
||||||
padding:25px;
|
padding:25px;
|
||||||
}
|
}
|
||||||
|
.host-container {
|
||||||
|
position: relative;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
#backIcon {
|
#backIcon {
|
||||||
height: 32px;
|
height: 32px;
|
||||||
width: 32px;
|
width: 32px;
|
||||||
@ -107,8 +110,26 @@ main {
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
.remove-host {
|
||||||
|
position:absolute;
|
||||||
|
right:0px;
|
||||||
|
top:0px;
|
||||||
|
width:24px;
|
||||||
|
height:24px;
|
||||||
|
margin-top: 10px;
|
||||||
|
margin-right: 15px;
|
||||||
|
/*to account for the shadow*/
|
||||||
|
cursor:pointer;
|
||||||
|
z-index: 5;
|
||||||
|
background: url('\\static\\res\\ic_remove_circle_white_24px.svg') no-repeat;
|
||||||
|
border: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
/*.remove-host:hover, .remove-host:focus {
|
||||||
|
background-image: url('\\static\\res\\ic_remove_circle_white_24px.svg');
|
||||||
|
}*/
|
||||||
#pairButton {
|
#pairButton {
|
||||||
margin: 3px;s
|
margin: 3px;
|
||||||
}
|
}
|
||||||
#showAppsButton {
|
#showAppsButton {
|
||||||
margin: 3px;
|
margin: 3px;
|
||||||
@ -127,7 +148,7 @@ main {
|
|||||||
border: none !important;
|
border: none !important;
|
||||||
}
|
}
|
||||||
.box-art {
|
.box-art {
|
||||||
background-color: transparent;;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
.box-art > img {
|
.box-art > img {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
@ -175,7 +196,7 @@ main {
|
|||||||
filter: invert(100%);
|
filter: invert(100%);
|
||||||
}
|
}
|
||||||
.host-cell img {
|
.host-cell img {
|
||||||
width: 80px;;
|
width: 80px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.cancel-current:hover {
|
.cancel-current:hover {
|
||||||
|
@ -4,6 +4,7 @@ var pairingCert;
|
|||||||
var myUniqueid;
|
var myUniqueid;
|
||||||
var api;
|
var api;
|
||||||
var relaunchSourceEvent;
|
var relaunchSourceEvent;
|
||||||
|
var unpairHostSourceEvent;
|
||||||
|
|
||||||
// Called by the common.js module.
|
// Called by the common.js module.
|
||||||
function attachListeners() {
|
function attachListeners() {
|
||||||
@ -18,7 +19,8 @@ function attachListeners() {
|
|||||||
$('#addHostCell').on('click', addHost);
|
$('#addHostCell').on('click', addHost);
|
||||||
$('#cancelAddHost').on('click', cancelAddHost);
|
$('#cancelAddHost').on('click', cancelAddHost);
|
||||||
$('#continueAddHost').on('click', continueAddHost);
|
$('#continueAddHost').on('click', continueAddHost);
|
||||||
$('#forgetHost').on('click', forgetHost);
|
$('#continueUnpairHost').on('click', unpairHost);
|
||||||
|
$('#cancelUnpairHost').on('click', cancelUnpairHost);
|
||||||
$('#cancelPairingDialog').on('click', pairingPopupCanceled);
|
$('#cancelPairingDialog').on('click', pairingPopupCanceled);
|
||||||
$('#cancelQuitApp').on('click', cancelQuitApp);
|
$('#cancelQuitApp').on('click', cancelQuitApp);
|
||||||
$('#backIcon').on('click', showHostsAndSettingsMode);
|
$('#backIcon').on('click', showHostsAndSettingsMode);
|
||||||
@ -199,14 +201,20 @@ function pairTo(nvhttpHost, onSuccess, onFailure) {
|
|||||||
|
|
||||||
function hostChosen(sourceEvent) {
|
function hostChosen(sourceEvent) {
|
||||||
|
|
||||||
if(sourceEvent && sourceEvent.srcElement) {
|
// if(sourceEvent && sourceEvent.srcElement) {
|
||||||
if (sourceEvent.srcElement.innerText == "") {
|
// if (sourceEvent.srcElement.innerText == "") {
|
||||||
console.log('user clicked image. we gotta hack to parse out the host.');
|
// console.log('user clicked image. we gotta hack to parse out the host.');
|
||||||
var serverUid = sourceEvent.currentTarget.id.substring("hostgrid-".length);
|
// var serverUid = sourceEvent.currentTarget.id.substring("hostgrid-".length);
|
||||||
} else {
|
// } else {
|
||||||
console.log('parsing host from grid element.');
|
// console.log('parsing host from grid element.');
|
||||||
var serverUid = sourceEvent.srcElement.id.substring("hostgrid-".length);
|
// var serverUid = sourceEvent.srcElement.id.substring("hostgrid-".length);
|
||||||
}
|
// }
|
||||||
|
// } else
|
||||||
|
if (sourceEvent && sourceEvent.target && sourceEvent.target.id ) {
|
||||||
|
console.log('hacking out the host');
|
||||||
|
var serverUid = sourceEvent.target.id.substring("hostgrid-".length);
|
||||||
|
} else if (sourceEvent.target.parentElement && sourceEvent.target.parentElement.id) {
|
||||||
|
var serverUid = sourceEvent.target.parentElement.id.substring("hostgrid-".length);
|
||||||
} else {
|
} else {
|
||||||
console.log('Failed to find host! This should never happen!');
|
console.log('Failed to find host! This should never happen!');
|
||||||
console.log(sourceEvent);
|
console.log(sourceEvent);
|
||||||
@ -250,13 +258,15 @@ function cancelAddHost() {
|
|||||||
|
|
||||||
// host is an NvHTTP object
|
// host is an NvHTTP object
|
||||||
function addHostToGrid(host) {
|
function addHostToGrid(host) {
|
||||||
var cell = document.createElement('div');
|
var outerDiv = $("<div>", {class: 'host-container mdl-cell--3-col', id: 'host-container-' + host.serverUid });
|
||||||
cell.className += 'mdl-cell mdl-cell--3-col host-cell mdl-button mdl-js-button mdl-js-ripple-effect';
|
var cell = $("<div>", {class: 'mdl-cell mdl-cell--3-col host-cell mdl-button mdl-js-button mdl-js-ripple-effect', id: 'hostgrid-' + host.serverUid, html:host.hostname });
|
||||||
cell.id = 'hostgrid-' + host.serverUid;
|
|
||||||
cell.innerHTML = host.hostname;
|
|
||||||
$(cell).prepend($("<img>", {src: "static/res/ic_desktop_windows_white_24px.svg"}));
|
$(cell).prepend($("<img>", {src: "static/res/ic_desktop_windows_white_24px.svg"}));
|
||||||
$('#host-grid').append(cell);
|
var removalButton = $("<div>", {class: "remove-host", id: "removeHostButton-" + host.serverUid});
|
||||||
cell.onclick = hostChosen;
|
removalButton.click(confirmUnpairHost);
|
||||||
|
cell.click(hostChosen);
|
||||||
|
$(outerDiv).append(cell);
|
||||||
|
$(outerDiv).append(removalButton);
|
||||||
|
$('#host-grid').append(outerDiv);
|
||||||
hosts[host.serverUid] = host;
|
hosts[host.serverUid] = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,15 +288,37 @@ function continueAddHost() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function confirmUnpairHost(sourceEvent) {
|
||||||
|
snackbarLog('Need to parse host from event: ' + sourceEvent);
|
||||||
|
var unpairHostDialog = document.querySelector('#unpairHostDialog');
|
||||||
|
document.getElementById('unpairHostDialogText').innerHTML =
|
||||||
|
' Are you sure you want like to unpair from ' + hosts[sourceEvent.target.id.substring("removeHostButton-".length)].hostname + '?';
|
||||||
|
unpairHostDialog.showModal();
|
||||||
|
unpairHostSourceEvent = sourceEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelUnpairHost() {
|
||||||
|
var unpairHostDialog = document.querySelector('#unpairHostDialog');
|
||||||
|
unpairHostDialog.close();
|
||||||
|
}
|
||||||
|
|
||||||
// locally remove the hostname/ip from the saved `hosts` array.
|
// locally remove the hostname/ip from the saved `hosts` array.
|
||||||
// note: this does not make the host forget the pairing to us.
|
// note: this does not make the host forget the pairing to us.
|
||||||
// this means we can re-add the host, and will still be paired.
|
// this means we can re-add the host, and will still be paired.
|
||||||
// TODO: use the chrome context menu to add right-click support to remove the host in grid-ui
|
function unpairHost() {
|
||||||
// https://github.com/GoogleChrome/chrome-app-samples/blob/master/samples/context-menu/main.js
|
var sourceEvent = unpairHostSourceEvent;
|
||||||
function forgetHost(host) {
|
unpairHostSourceEvent = null;
|
||||||
snackbarLog('Feature not yet ported to grid-ui');
|
host = hosts[sourceEvent.target.id.substring("removeHostButton-".length)];
|
||||||
hosts.splice(hosts.indexOf(host.serverUid), 1); // remove the host from the array;
|
host.unpair().then(function (onSuccess) {
|
||||||
saveHosts();
|
var unpairHostDialog = document.querySelector('#unpairHostDialog');
|
||||||
|
unpairHostDialog.close();
|
||||||
|
$('#host-container-' + host.serverUid).remove();
|
||||||
|
snackbarLog('Successfully unpaired from host');
|
||||||
|
delete hosts[host.serverUid]; // remove the host from the array;
|
||||||
|
saveHosts();
|
||||||
|
}, function (onFailure) {
|
||||||
|
snackbarLog('Failed to unpair from host!');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function pairingPopupCanceled() {
|
function pairingPopupCanceled() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user