VulpesOS/assets/webapps/uitest.gaiamobile.org/js/API/presentation_api.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

48 lines
1.2 KiB
JavaScript

'use strict';
window.addEventListener('DOMContentLoaded', function() {
function log(aMsg) {
console.log('-*- mdns.js : ' + aMsg + '\n');
}
if (typeof navigator.mozPresentationDeviceInfo !== 'undefined') {
navigator.mozPresentationDeviceInfo.addEventListener('devicechange',
function(e) {
log('device changed');
getAll();
});
document.getElementById('discovery').onclick = function _discovery() {
log('discovery');
navigator.mozPresentationDeviceInfo.forceDiscovery();
getAll();
};
getAll();
}
function appendDevice(device) {
var node = document.createElement('li');
var textnode = document.createTextNode(device.name);
node.appendChild(textnode);
document.getElementById('devices').appendChild(node);
}
function clearDevices() {
var devNode = document.getElementById('devices');
while (devNode.firstChild) {
devNode.removeChild(devNode.firstChild);
}
}
function getAll() {
log('getAll');
navigator.mozPresentationDeviceInfo.getAll().then(function(devices) {
log('devices found: ' + devices.length);
clearDevices();
for (var device of devices) {
appendDevice(device);
}
});
}
});