user can now forget hosts

- hosts are never unpaired, so re-adding the hostname will not require pairing
GFEHostIP field marked as `dirty` when mDNS found
- thanks to https://github.com/google/material-design-lite/issues/903
- untested.
This commit is contained in:
R. Aidan Campbell 2016-04-16 13:07:47 -04:00
parent 55275b8c4b
commit 5d4f191b07
2 changed files with 21 additions and 0 deletions

View File

@ -54,6 +54,7 @@
</div>
<div class="button-holder">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored" id="hostChosen">Connect</button>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent" id="forgetHost">Forget</button>
</div>
</div>

View File

@ -11,6 +11,7 @@ function attachListeners() {
$('#bitrateSlider').on('input', updateBitrateField); // input occurs every notch you slide
$('#bitrateSlider').on('change', saveBitrate); // change occurs once the mouse lets go.
$('#hostChosen').on('click', hostChosen);
$('#forgetHost').on('click', forgetHost);
$('#cancelPairingDialog').on('click', pairingPopupCanceled);
$('#selectGame').on('change', gameSelectUpdated);
$('#startGameButton').on('click', startSelectedGame);
@ -142,9 +143,27 @@ function hostChosen() {
if(!api.paired) {
pairTo(target);
}
if(hosts.indexOf(target) < 0) { // we don't have this host in our list. add it, and save it.
var opt = document.createElement('option');
opt.appendChild(document.createTextNode(target));
opt.value = target;
$('#selectHost')[0].appendChild(opt);
hosts.push(target);
saveHosts();
$('#GFEHostIPField').val(''); // eat the contents of the textbox
}
showApps();
});
}
// locally remove the hostname/ip from the saved `hosts` array.
// 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.
function forgetHost() {
updateTarget();
$("#selectHost option:selected").remove();
hosts.splice(hosts.indexOf(target), 1); // remove the host from the array;
saveHosts();
}
function pairingPopupCanceled() {
@ -419,6 +438,7 @@ function onWindowLoad(){
var ip = Object.keys(finder.byService_['_nvstream._tcp'])[0];
if (finder.byService_['_nvstream._tcp'][ip]) {
$('#GFEHostIPField').val(ip);
$('#GFEHostIPField').parent().addClass('is-dirty'); // mark it as dirty to float the textfield label
updateTarget();
}
}