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

133 lines
4.2 KiB
JavaScript
Raw Normal View History

2016-07-06 12:25:58 -07:00
define(['inputManager', 'connectionManager', 'embyRouter'], function (inputManager, connectionManager, embyRouter) {
2016-07-06 13:16:56 -07:00
function getMusicCommand(result) {
return function () {
inputManager.trigger('music');
};
}
function getMoviesCommand(result) {
return function () {
if (result.properties.movieName) {
2016-07-06 12:25:58 -07:00
2016-07-06 13:16:56 -07:00
//TODO: Find a way to display movie
var query = {
Limit: 1,
UserId: result.userId,
ExcludeLocationTypes: "Virtual",
NameStartsWith: result.item.itemType
};
2016-07-06 12:25:58 -07:00
2016-07-06 13:16:56 -07:00
if (result.item.itemType) {
query.IncludeItemTypes = result.item.itemType;
}
var apiClient = connectionManager.currentApiClient();
apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (queryResult) {
if (queryResult.Items.length) {
embyRouter.showItem(queryResult.Items[0]);
2016-07-06 12:25:58 -07:00
}
2016-07-06 13:16:56 -07:00
});
2016-07-06 12:25:58 -07:00
2016-07-06 13:16:56 -07:00
} else {
inputManager.trigger('movies');
}
};
}
2016-07-06 12:25:58 -07:00
2016-07-06 13:16:56 -07:00
function getTVCommand(result) {
return function () {
inputManager.trigger('tv');
};
}
2016-07-06 12:25:58 -07:00
2016-07-06 13:16:56 -07:00
function getLiveTVCommand(result) {
return function () {
var act = result.item.menuid;
if (act) {
if (act.indexOf('livetv') != -1) {
inputManager.trigger('livetv');
} else if (act.indexOf('guide') != -1) {
inputManager.trigger('guide');
} else if (act.indexOf('channels') != -1) {
inputManager.trigger('livetv');
} else if (act.indexOf('recordings') != -1) {
inputManager.trigger('recordedtv');
} else if (act.indexOf('scheduled') != -1) {
inputManager.trigger('recordedtv');
} else if (act.indexOf('series') != -1) {
inputManager.trigger('recordedtv');
2016-07-06 12:25:58 -07:00
} else {
2016-07-06 13:16:56 -07:00
inputManager.trigger('livetv');
}
} else {
inputManager.trigger('livetv');
}
};
}
function getRecordingsCommand(result) {
return function () {
inputManager.trigger('recordedtv');
};
}
function getLatestEpisodesCommand(result) {
return function () {
inputManager.trigger('latestepisodes');
};
}
function getHomeCommand(result) {
return function () {
var act = result.item.menuid;
if (act) {
if (act.indexOf('home') != -1) {
inputManager.trigger('home');
}
else if (act.indexOf('nextup') != -1) {
inputManager.trigger('nextup');
2016-07-06 12:25:58 -07:00
}
2016-07-06 13:16:56 -07:00
else if (act.indexOf('favorites') != -1) {
inputManager.trigger('favorites');
} else if (act.indexOf('upcoming') != -1) {
inputManager.trigger('upcomingtv');
}
else if (act.indexOf('nowplaying') != -1) {
inputManager.trigger('nowplaying');
}
else {
inputManager.trigger('home');
}
} else {
inputManager.trigger('home');
}
};
}
return function (result) {
2016-07-06 12:25:58 -07:00
2016-07-06 13:16:56 -07:00
switch (result.item.sourceid) {
case 'music':
return getMusicCommand(result);
case 'movies':
return getMoviesCommand(result);
2016-07-06 12:25:58 -07:00
case 'tvseries':
2016-07-06 13:16:56 -07:00
return getTVCommand(result);
2016-07-06 12:25:58 -07:00
case 'livetv':
2016-07-06 13:16:56 -07:00
return getLiveTVCommand(result);
2016-07-06 12:25:58 -07:00
case 'recordings':
2016-07-06 13:16:56 -07:00
return getRecordingsCommand(result);
2016-07-06 12:25:58 -07:00
case 'latestepisodes':
2016-07-06 13:16:56 -07:00
return getLatestEpisodesCommand(result);
2016-07-06 12:25:58 -07:00
case 'home':
2016-07-06 13:16:56 -07:00
return getHomeCommand(result);
2016-07-06 12:25:58 -07:00
case 'group':
2016-07-06 13:16:56 -07:00
return;
2016-07-06 12:25:58 -07:00
default:
return;
}
}
});