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.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
48
gaia/dev_apps/uitest/js/API/presentation_api.js
Executable file
48
gaia/dev_apps/uitest/js/API/presentation_api.js
Executable file
|
|
@ -0,0 +1,48 @@
|
|||
'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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue