Skip to content

Commit

Permalink
Added jslint to build, fixed all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jez500 committed Feb 23, 2014
1 parent 12310d3 commit dc0205a
Show file tree
Hide file tree
Showing 33 changed files with 3,119 additions and 3,270 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = function(grunt) {
}
},
jshint: {
files: ['Gruntfile.js', 'dev/**/*.js', 'test/**/*.js'],
files: ['Gruntfile.js', 'dev/js/*.js', 'dev/js/*/*.js'],
options: {
// options here to override JSHint defaults
globals: {
Expand Down
6 changes: 3 additions & 3 deletions buildchorus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

echo "Running compass"
echo "=============================================="
compass clean ./theme
compass compile ./theme -e production
compass clean ./dev/theme
compass compile ./dev/theme -e production

echo "Running Grunt"
echo "=============================================="
Expand All @@ -16,7 +16,7 @@ rm webinterface.chorus.zip
echo "Building zip"
echo "=============================================="
cp -r ./dist ./webinterface.chorus
zip -r webinterface.chorus.zip ./webinterface.chorus
zip -r -q webinterface.chorus.zip ./webinterface.chorus
rm -rf ./webinterface.chorus

echo "Build complete"
Expand Down
23 changes: 11 additions & 12 deletions dev/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ app.Router = Backbone.Router.extend({
if(app.audioStreaming.getPlayer() == 'local'){
// get the local playing item
var browserPlaying = app.audioStreaming.getNowPlayingSong();
backstretchImage = (browserPlaying.fanart == undefined ? '' : browserPlaying.fanart);
backstretchImage = (browserPlaying.fanart === undefined ? '' : browserPlaying.fanart);
} else {
// xbmc playing image
backstretchImage = (data.item.fanart == undefined ? '' : data.item.fanart);
backstretchImage = (data.item.fanart === undefined ? '' : data.item.fanart);
}

// Add Backstretch if image
if($('.backstretch').length == 0){
if($('.backstretch').length === 0){
var fa = app.parseImage(backstretchImage, 'fanart');
$.backstretch(fa);
}
Expand Down Expand Up @@ -314,7 +314,7 @@ app.Router = Backbone.Router.extend({
app.cached.albumView = new app.AlbumView({"model": model, "type":"album"});

// only render if not on album page already
if($('.album-page').length == 0){
if($('.album-page').length === 0){
$('#content').html(app.cached.albumView.render().el);
} else {
//just call render, don't update content
Expand Down Expand Up @@ -461,7 +461,7 @@ app.Router = Backbone.Router.extend({

thumbsup: function(){

var $content = $('#content')
var $content = $('#content'),
$sidebar = app.helpers.getFirstSidebarContent();

// so we get things in the correct order, we have lots of sub wrappers for the different lists
Expand Down Expand Up @@ -525,10 +525,9 @@ app.Router = Backbone.Router.extend({
page = 'page';

// init pager
if($results.length == 0){
if($results.length === 0){
// empty page
if(typeof page == 'undefined'){
var page = 'page', num = 0;
if(num === 0){
app.moviePageNum = 0;
}
// Loading
Expand All @@ -546,7 +545,7 @@ app.Router = Backbone.Router.extend({
// appending to page no other setup required
app.moviePageNum++;
// force a page via url
if(page && num > 0){
if(num !== undefined){
app.moviePageNum = num;
}
}
Expand All @@ -558,14 +557,14 @@ app.Router = Backbone.Router.extend({
// get the view of results
app.cached.movieListView = new app.MovieListView({model: collection});
// do we append or replace
if(app.moviePageNum == 0 || fullRange === true){
if(app.moviePageNum === 0 || fullRange === true){
$content.html(app.cached.movieListView.render().$el);

// scroll to top
$(window).scrollTo(0);

// back from a movie, scrollto that movie
if(fullRange == true && typeof app.vars.backHash != 'undefined'){
if(fullRange === true && typeof app.vars.backHash != 'undefined'){
var parts = app.vars.backHash.split('/');
if(parts[0] == '#movie'){
$(window).scrollTo( $('.movie-row-' + parts[1]) , 0, {offset: -200});
Expand All @@ -584,7 +583,7 @@ app.Router = Backbone.Router.extend({
// if last page was empty, dont change hash
// or render
var $lastList = $('.video-list').last();
if($lastList.find('li').length == 0){
if($lastList.find('li').length === 0){
// dont render
$lastList.remove();
} else {
Expand Down
97 changes: 25 additions & 72 deletions dev/js/collections/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ app.PlaylistCustomListCollection = Backbone.Collection.extend({
o = [], i = 1;

// success
for(n in lists){
for (var n in lists){
var item = lists[n];
item.id = i;
o.push(item);
Expand Down Expand Up @@ -151,7 +151,7 @@ app.ThumbsUpCollection = Backbone.Collection.extend({
var list = app.playlists.getThumbsUp(options.name);

// no further parsing if empty
if(list == null || list.length == 0){
if(list === null || list.length === 0){
return {items: []};
}

Expand Down Expand Up @@ -283,7 +283,7 @@ app.MemoryStore = function (successCallback, errorCallback) {
$(window).trigger('songsReady');

// ready action
callLater(successCallback, self)
callLater(successCallback, self);
}});
}

Expand Down Expand Up @@ -382,7 +382,7 @@ app.MemoryStore = function (successCallback, errorCallback) {
* @param callback
*/
this.multipleArtists = function(artistIds, callback){
if(artistIds.length == 0){
if(artistIds.length === 0){
return;
}
this.allArtists(function(artists){
Expand Down Expand Up @@ -415,7 +415,7 @@ app.MemoryStore = function (successCallback, errorCallback) {
$.each(songs, function(i,d){

// already have a song
if(song != null){
if(song !== null){
return;
}

Expand Down Expand Up @@ -451,7 +451,7 @@ app.MemoryStore = function (successCallback, errorCallback) {
* @param callback
*/
this.multipleAlbums = function(albumIds, callback){
if(albumIds.length == 0){
if(albumIds.length === 0){
return;
}
this.allAlbums(function(albums){
Expand All @@ -474,14 +474,14 @@ app.MemoryStore = function (successCallback, errorCallback) {

// get a random collection
this.allArtists(function(data){
artists = data.models,
var artists = data.models,
randArtists = _.shuffle(artists),
farts = [], count = 30, i = 0;

// only add content with artwork
_.each(randArtists,function(a){
if(i < count){
if(a.attributes.fanart.length != 0 && a.attributes.thumbnail.length != 0){
if(a.attributes.fanart.length !== 0 && a.attributes.thumbnail.length !== 0){
farts.push(a);
i++;
}
Expand All @@ -491,7 +491,7 @@ app.MemoryStore = function (successCallback, errorCallback) {
if(farts.length < count){
_.each(randArtists,function(a){
if(i < count){
if(a.attributes.thumbnail.length != 0){
if(a.attributes.thumbnail.length !== 0){
farts.push(a);
i++;
}
Expand Down Expand Up @@ -526,16 +526,16 @@ app.MemoryStore = function (successCallback, errorCallback) {
var data = {}, albums = [], self = this, key = type + id, filter = type + 'id', plural = type + 's';

// if cache exists
if(app.helpers.exists(app.stores[plural])
&& app.helpers.exists(app.stores[plural][key])
&& app.helpers.exists(app.stores[plural][key].albumsitems)
if(app.helpers.exists(app.stores[plural]) &&
app.helpers.exists(app.stores[plural][key]) &&
app.helpers.exists(app.stores[plural][key].albumsitems)
){
// get cache?
albums = app.stores[plural][key].albumsitems;
callLater(callback, albums);
}
// if no cache get/refresh a collection from xbmc
if(albums.length == 0) {
if(albums.length === 0) {
// songs by filter
data[filter] = id;

Expand All @@ -554,11 +554,11 @@ app.MemoryStore = function (successCallback, errorCallback) {

/* parse songs into albums */
this.parseArtistSongsToAlbums = function(songs){
albums = {}, ret = [];
for(i in songs){
var albums = {}, ret = [];
for(var i in songs){
// vars
var model = songs[i],
item = (typeof model.attributes != 'undefined' ? model.attributes : 0),
item = (typeof model.attributes != 'undefined' ? model.attributes : {}),
albumkey = 'album' + item.albumid;

// parse into albums
Expand All @@ -567,12 +567,14 @@ app.MemoryStore = function (successCallback, errorCallback) {

// populate album info from first item
var fields = ['album', 'albumid', 'thumbnail', 'artist', 'artistid'];
$.each(fields, function(b, field){
if($.isArray(item[field])){
item[field] = item[field][0];

// merge fields
for(var f in fields){
var field = fields[f];
if(item[field] !== undefined){
albums[albumkey][field] = item[field];
}
albums[albumkey][field] = item[field];
});
}

// setup for songlist
albums[albumkey].songs = [];
Expand All @@ -589,55 +591,6 @@ app.MemoryStore = function (successCallback, errorCallback) {
this.syncAudio(successCallback);



/*
* Force sync songs with xbmc DEPRECATED
*/
/* this.parseAudio = function(songs){
//loop over each song
$.each(songs, function(i,data){
//vars
var item = data.attributes
, songsDefault = { songs:[], artist: {}, albums: [], albumsitems: [] }
, songkey = item.songid
, albumid = (typeof item.albumid != "undefined" ? item.albumid : 0)
, artistid = (typeof item.artistid != "undefined" ? item.artistid[0] : 0)
, genreid = (typeof item.genreid != "undefined" ? item.genreid[0] : 0)
, albumkey = 'album' + albumid
, artistkey = 'artist' + artistid
, genrekey = 'genre' + genreid
;
// default songs
if(typeof app.stores.songs[artistkey] == "undefined"){
app.stores.songs[artistkey] = songsDefault;
}
// default artists get more parsing
if(typeof app.stores.artists[artistkey] == "undefined"){
app.stores.artists[artistkey] = songsDefault;
}
// default genres
if(typeof app.stores.genres[genrekey] == "undefined"){
app.stores.genres[genrekey] = songsDefault;
}
//app.stores.albums[albumkey].songs.push(data);
app.stores.songs[artistkey].songs.push(data);
//app.stores.artists[artistkey].songs.push(data);
app.stores.genres[genrekey].songs.push(data);
app.stores.all.push(data);
});
};*/


// Used to simulate async calls. This is done to provide a consistent
// interface with stores that use async data access APIs
var callLater = function (callback, data) {
Expand All @@ -646,9 +599,9 @@ app.MemoryStore = function (successCallback, errorCallback) {
callback(data);
});
}
}
};

}
};

app.store = new app.MemoryStore(function(){

Expand Down
12 changes: 6 additions & 6 deletions dev/js/collections/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ app.FileCollection = Backbone.Collection.extend({
// add a title before return
var sources = self.parseData(res.result.sources);
callback(sources);
})
});

},

Expand All @@ -48,7 +48,7 @@ app.FileCollection = Backbone.Collection.extend({

callback(files);

})
});

},

Expand All @@ -58,13 +58,13 @@ app.FileCollection = Backbone.Collection.extend({
* @returns {*}
*/
parseData: function(models){
for(i in models){
for(var i in models){

if(typeof models[i].filetype == 'undefined' || models[i].filetype == ''){
if(typeof models[i].filetype == 'undefined' || models[i].filetype === ''){
models[i].filetype = 'directory';
}

if(typeof models[i].id == 'undefined' || models[i].id == 0){
if(typeof models[i].id == 'undefined' || models[i].id === 0){
models[i].id = models[i].file;
}

Expand All @@ -77,7 +77,7 @@ app.FileCollection = Backbone.Collection.extend({
models[i].type = 'file';
}

if(typeof models[i].title == 'undefined' || models[i].title == ''){
if(typeof models[i].title == 'undefined' || models[i].title === ''){
models[i].title = models[i].label;
}

Expand Down
8 changes: 4 additions & 4 deletions dev/js/collections/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ app.MovieCollection = Backbone.Collection.extend({

// CACHE GET
// empty cache if first load
if(app.moviePageNum == 0){
if(app.moviePageNum === 0){
app.stores.movies = [];
}
// prep empty cache
Expand Down Expand Up @@ -79,7 +79,7 @@ app.MovieRecentCollection = Backbone.Collection.extend({
app.xbmcController.command('VideoLibrary.GetRecentlyAddedMovies', opt, function(data){
console.log(data);
options.success(data.result.movies);
})
});

}

Expand All @@ -101,7 +101,7 @@ app.MovieFitleredCollection = Backbone.Collection.extend({
opt = [app.movieFields, {'end': 500, 'start': 0}, sort, options.filter];
console.log('result from ', opt);

for(k in options.filter){
for(var k in options.filter){
var key = k + ':' + options.filter[k];
}

Expand All @@ -110,7 +110,7 @@ app.MovieFitleredCollection = Backbone.Collection.extend({
console.log('data ', data);

options.success(data.result.movies);
})
});

}

Expand Down
Loading

0 comments on commit dc0205a

Please sign in to comment.