var xbmc = angular.module('xbmc', ['ngResource', 'utility']);
xbmc.config(function ($interpolateProvider) {
$interpolateProvider.startSymbol("{/");
$interpolateProvider.endSymbol("/}");
});
xbmc.factory('XbmcApi', function($resource) {
return $resource(
'/api/v1/:type/:id/',
{
id: '@id',
limit: 20,
offset: 0,
callback: 'JSON_CALLBACK'
},
{
get:{
method: 'JSONP'
}
}
);
});
xbmc.directive('thumbnail', function() {
return {
restrict: 'E',
template: '
',
link: function(scope, element, attrs, ctrl) {
scope.url = '/static/img/movie-reel.jpg';
if (attrs['source']) {
url = $(scope.$eval(attrs['source'])).first().text();
if (url) {
scope.url = url;
}
}
}
}
});
xbmc.controller('MovieCtrl', function ($scope, XbmcApi) {
$scope.movies = XbmcApi.get({
type: 'movie'
}, function(value, responseHeaders) {
$scope.movies.meta.offset = value.objects.length;
}, function(httpResponse) {
console.log("Didn't get movies");
});
$scope.more = function() {
results = XbmcApi.get({
type: 'movie',
offset: $scope.movies.meta.offset
}, function(value, responseHeaders) {
for (var i=0, l=value.objects.length; i