jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/voice/voicecommands.js

53 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-02-16 23:58:07 -07:00
// <date>09.10.2015</date>
// <summary>voicecommands class</summary>
2016-07-06 12:30:29 -07:00
define(['require'], function (require) {
2016-10-17 22:06:48 -07:00
'use strict';
2016-02-16 23:58:07 -07:00
/// <summary> Process the command. </summary>
/// <param name="commandPath"> Full pathname of the command file. </param>
/// <param name="result"> The result. </param>
/// <returns> . </returns>
function processCommand(commandPath, result) {
return new Promise(function (resolve, reject) {
require([commandPath], function (command) {
2016-07-06 13:16:56 -07:00
var fn = command(result);
if (fn) {
result.fn = fn;
2016-02-16 23:58:07 -07:00
resolve(result);
2016-07-06 13:16:56 -07:00
} else {
reject();
2016-02-16 23:58:07 -07:00
}
});
});
}
return function (result) {
2016-07-06 13:16:56 -07:00
switch (result.item.actionid) {
case 'show':
return processCommand('./commands/showcommands.js', result);
case 'play':
return processCommand('./commands/playcommands.js', result);
case 'shuffle':
return processCommand('./commands/playcommands.js', result);
case 'search':
return processCommand('./commands/searchcommands.js', result);
case 'control':
return processCommand('./commands/controlcommands.js', result);
case 'enable':
return processCommand('./commands/enablecommands.js', result);
case 'disable':
return processCommand('./commands/disablecommands.js', result);
case 'toggle':
return processCommand('./commands/togglecommands.js', result);
default:
return Promise.reject();
}
2016-10-17 22:06:48 -07:00
};
2016-02-16 23:58:07 -07:00
});