Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
38 lines
787 B
JavaScript
Executable file
38 lines
787 B
JavaScript
Executable file
/* exported controls */
|
|
'use strict';
|
|
|
|
function RemoteControls() {
|
|
this.controls = document.getElementById('controls');
|
|
this.controls.addEventListener('click', this);
|
|
|
|
this.playPauseButton = document.getElementById('playpause');
|
|
|
|
window.navigator.mozSetMessageHandler('connection', function(request) {
|
|
if (request.keyword !== 'mediacomms') {
|
|
return;
|
|
}
|
|
|
|
this.port = request.port;
|
|
}.bind(this));
|
|
}
|
|
|
|
RemoteControls.prototype = {
|
|
handleEvent: function(event) {
|
|
if (!this.port) {
|
|
return;
|
|
}
|
|
|
|
var command = null;
|
|
switch (event.target) {
|
|
case this.playPauseButton:
|
|
command = 'playpause';
|
|
break;
|
|
}
|
|
|
|
if (command) {
|
|
this.port.postMessage({command: command});
|
|
}
|
|
}
|
|
};
|
|
|
|
var controls = new RemoteControls();
|