diff --git a/Gruntfile.js b/Gruntfile.js index be511cb..9f6ec98 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,36 +10,37 @@ module.exports = function(grunt) { src: [ // jQuery - 'dev/lib/required/jquery-1.10.2.js', + 'src/lib/required/jquery-1.10.2.js', // underscore - 'dev/lib/required/underscore-min.js', + 'src/lib/required/underscore-min.js', // backbone - 'dev/lib/required/backbone.dev.js', - 'dev/lib/required/backbone.rpc.min.js', + 'src/lib/required/backbone.dev.js', + 'src/lib/required/backbone.rpc.min.js', // All our enabled js - 'dev/lib/enabled/*.js', + 'src/lib/enabled/*.js', // application js - 'dev/js/utils.js', - 'dev/js/app.js', + 'src/js/utils.js', + 'src/js/app.js', // application models - 'dev/js/models/*.js', + 'src/js/models/*.js', // application controllers - 'dev/js/controllers/*.js', + 'src/js/controllers/*.js', // application collections - need to be loaded in order - 'dev/js/collections/xbmc.js', - 'dev/js/collections/audio.js', - 'dev/js/collections/files.js', - 'dev/js/collections/video.js', + 'src/js/collections/xbmc.js', + 'src/js/collections/video.js', + 'src/js/collections/audio.js', + 'src/js/collections/files.js', + // application views - 'dev/js/views/*.js' + 'src/js/views/*.js' ], dest: 'dist/<%= pkg.name %>.js' @@ -56,7 +57,7 @@ module.exports = function(grunt) { } }, jshint: { - files: ['Gruntfile.js', 'dev/js/*.js', 'dev/js/*/*.js'], + files: ['Gruntfile.js', 'src/js/*.js', 'src/js/*/*.js'], options: { // options here to override JSHint defaults globals: { diff --git a/buildchorus.sh b/buildchorus.sh index 295876b..510f72b 100755 --- a/buildchorus.sh +++ b/buildchorus.sh @@ -2,8 +2,8 @@ echo "Running compass" echo "==============================================" -compass clean ./dev/theme -compass compile ./dev/theme -e production +compass clean ./src/theme +compass compile ./src/theme -e production echo "Running Grunt" echo "==============================================" diff --git a/changelog.txt b/changelog.txt new file mode 120000 index 0000000..04d8d50 --- /dev/null +++ b/changelog.txt @@ -0,0 +1 @@ +dist/changelog.txt \ No newline at end of file diff --git a/dev/changelog.txt b/dev/changelog.txt deleted file mode 100755 index 24a9005..0000000 --- a/dev/changelog.txt +++ /dev/null @@ -1,83 +0,0 @@ -Version 0.2.2: -- Framework for xbmc video integration -- Integrated XBMC video playback and video playlists into the UI -- Created full page view of a movie with navigation, vital statistics, cast and more. -- Ability to browse all movies with infinite scroll, url pagination, back button support and lazy loaded images -- Browse movies with a genre filter -- Upgraded to latest font-awesome and updated a few icons -- Lots of playlist fixes including empty lists if the items are not in the library -- Added the awesome breakpoint and singularitygs gems as a requirement for build -- Used breakpoint and singularity to start making things much more responsive (work in progress) -- many more general fixes (and maybe a few new bugs) - - -Version 0.2.1: -- Significant refactor of js and css -- Lots of playlist updates and refinements -- Improved song search -- Contextual menus now available on songs, artists, albums and files adding playlist tasks and a place for future functionality -- Better indications that something is playing (title, logo, tab icon) - - -Version 0.2.0: -- Implemented browser audio streaming from XBMC library -- Updated template to suit streaming -- Loads of style refinements, added some colour. Orange = XBMC, Blue = Local -- Added throttling of requests to XBMC if a lost connection is detected - - -Version 0.1.8: -- Increased max album count to 15000 -- Increased max artist count to 10000 - - -Version 0.1.7: -- Major update -- Integrated browser streaming, you can now play songs directly in your browser -- Many ui updates to accommodate the new functionality -- Logo gets some colour when playing via xbmc / browser -- lots more - - -Version 0.1.7: -- Heaps of fixes/updates to v0.1.6 landing pages -- Minor ui style updates -- logo gets angry when not connected -- throttle requests when not connected (every 20sec rather than every 5sec) -- loading box style - - -Version 0.1.6: -- Recreated landing pages for artist and albums, implemented freewall -- Context options added for new views -- Lots of styles, optimisations and bug fixes. - - -Version 0.1.5: -- fixed play button style bug on album -- fixed jsonRPC path so it now works via /addons/webinterface.chorus -- added changelog to Lab - - -Version 0.1.4: -- Code cleanup / refactor -- About dialog -- template loading on the fly - - -Version 0.1.3: -- Fixed song search -- Added ability to thumbs up, download or custom playlist the currently playing song - - -Version 0.1.2: -- Changed context options for album to be over artwork -- Clear playlist before adding a song if nothing is playing -- Local dump dev page -- removed context menus not in use -- fixed bug with thumbs up songs not showing - - -Version 0.1.0: -Initial release Jan 2014 -- First release of Chorus diff --git a/dist/changelog.txt b/dist/changelog.txt index 24a9005..4dab3b1 100755 --- a/dist/changelog.txt +++ b/dist/changelog.txt @@ -1,3 +1,9 @@ +Version 0.2.3: +- Project folder restructure, see "src" for development source and "dist" for compiled +- webinterface.chorus.zip is the "dist" folder renamed to "webinterface.chorus" and archived during build +- Enable jsLint checking on build and fixed 100+ warnings + + Version 0.2.2: - Framework for xbmc video integration - Integrated XBMC video playback and video playlists into the UI diff --git a/dist/chorus.js b/dist/chorus.js index 184f23b..73c0dd9 100755 --- a/dist/chorus.js +++ b/dist/chorus.js @@ -15578,7 +15578,7 @@ app.Router = Backbone.Router.extend({ } // scroll to page number - if(fullRange === true && scrolled !== true){ + if(fullRange === true && scrolled !== true && app.moviePageNum > 1){ $(window).scrollTo( '85%' ); } @@ -19014,6 +19014,156 @@ app.AllMovieXbmcCollection = Backbone.Collection.extend({ return app.helpers.buildUrls(resp.movies, 'movie', 'movieid'); } }); +; +/** + * A collection of Movies. + * + * a page number can be passed for pagination, when first init it caches a lightweight + * version on all movies for placeholders that can be found here app.stores.movies + * + * A fully loaded and range limited collection is provided in success callback + */ +app.MovieCollection = Backbone.Collection.extend({ + model: app.Movie, + + cached: [], + fullyLoaded: false, + + sync: function(method, model, options) { + if (method === "read") { + + var self = this, + fullRange = (typeof options.fullRange != 'undefined' && options.fullRange === true), + page = app.moviePageNum; + + // model for params + var args = { + range: app.helpers.createPaginationRange(app.moviePageNum, fullRange) + }; + + // CACHE GET + // empty cache if first load + if(app.moviePageNum === 0){ + app.stores.movies = []; + } + // prep empty cache + if(typeof app.stores.movies == 'undefined'){ + app.stores.movies = []; + } + // if fullrange called and cache exists + if(fullRange && app.stores.movies.length > 0){ + // we always return cache + // Could do some more checking for edge cases but is a simple solution + options.success(app.stores.movies); + return; + } + + // init the xbmc collection + app.cached.movieXbmcCollection = new app.MovieXbmcCollection(args); + // fetch results + app.cached.movieXbmcCollection.fetch({"success": function(data){ + // add models to cache + $.each(data.models,function(i,d){ + app.stores.movies.push(d); + }); + + // if models less than ipp then must be the end + if(data.models.length > app.itemsPerPage){ + self.fullyLoaded = true; + } + // return callback + options.success(data.models); + }}); + + } + } +}); + + +/** + * A collection of Recently added Movies. + */ +app.MovieRecentCollection = Backbone.Collection.extend({ + model: app.Movie, + + cached: [], + fullyLoaded: false, + + sync: function(method, model, options) { + + var opt = [app.movieFields, {'end': 100, 'start': 0}]; + app.xbmcController.command('VideoLibrary.GetRecentlyAddedMovies', opt, function(data){ + console.log(data); + options.success(data.result.movies); + }); + + } + +}); + + +/** + * A collection of movies matching a filter + */ +app.MovieFitleredCollection = Backbone.Collection.extend({ + model: app.Movie, + + cached: [], + fullyLoaded: false, + + sync: function(method, model, options) { + + var sort = {"sort": {"method": "title"}}, + opt = [app.movieFields, {'end': 500, 'start': 0}, sort, options.filter]; + console.log('result from ', opt); + + for(var k in options.filter){ + var key = k + ':' + options.filter[k]; + } + + app.xbmcController.command('VideoLibrary.GetMovies', opt, function(data){ + console.log('result from ', opt); + console.log('data ', data); + + options.success(data.result.movies); + }); + + } + +}); + + +/** + * A lightweight collection of all movies (cached). + */ +app.MovieAllCollection = Backbone.Collection.extend({ + model: app.Movie, + + cached: [], + fullyLoaded: false, + + sync: function(method, model, options) { + + if(typeof app.stores.allMovies == 'undefined'){ + // no cache, do a lookup + var allMovies = new app.AllMovieXbmcCollection(); + allMovies.fetch({"success": function(data){ + // Sort + data.models.sort(function(a,b){ return app.helpers.aphabeticalSort(a.attributes.label, b.attributes.label); }); + // Cache + app.stores.allMovies = data.models; + // Return + options.success(data.models); + }}); + } else { + // else return cache; + options.success(app.stores.allMovies); + } + + } + +}); + ; /** * A collection of Artists. @@ -19720,156 +19870,6 @@ app.FileCollection = Backbone.Collection.extend({ -}); - -; -/** - * A collection of Movies. - * - * a page number can be passed for pagination, when first init it caches a lightweight - * version on all movies for placeholders that can be found here app.stores.movies - * - * A fully loaded and range limited collection is provided in success callback - */ -app.MovieCollection = Backbone.Collection.extend({ - model: app.Movie, - - cached: [], - fullyLoaded: false, - - sync: function(method, model, options) { - if (method === "read") { - - var self = this, - fullRange = (typeof options.fullRange != 'undefined' && options.fullRange === true), - page = app.moviePageNum; - - // model for params - var args = { - range: app.helpers.createPaginationRange(app.moviePageNum, fullRange) - }; - - // CACHE GET - // empty cache if first load - if(app.moviePageNum === 0){ - app.stores.movies = []; - } - // prep empty cache - if(typeof app.stores.movies == 'undefined'){ - app.stores.movies = []; - } - // if fullrange called and cache exists - if(fullRange && app.stores.movies.length > 0){ - // we always return cache - // Could do some more checking for edge cases but is a simple solution - options.success(app.stores.movies); - return; - } - - // init the xbmc collection - app.cached.movieXbmcCollection = new app.MovieXbmcCollection(args); - // fetch results - app.cached.movieXbmcCollection.fetch({"success": function(data){ - // add models to cache - $.each(data.models,function(i,d){ - app.stores.movies.push(d); - }); - - // if models less than ipp then must be the end - if(data.models.length > app.itemsPerPage){ - self.fullyLoaded = true; - } - // return callback - options.success(data.models); - }}); - - } - } -}); - - -/** - * A collection of Recently added Movies. - */ -app.MovieRecentCollection = Backbone.Collection.extend({ - model: app.Movie, - - cached: [], - fullyLoaded: false, - - sync: function(method, model, options) { - - var opt = [app.movieFields, {'end': 100, 'start': 0}]; - app.xbmcController.command('VideoLibrary.GetRecentlyAddedMovies', opt, function(data){ - console.log(data); - options.success(data.result.movies); - }); - - } - -}); - - -/** - * A collection of movies matching a filter - */ -app.MovieFitleredCollection = Backbone.Collection.extend({ - model: app.Movie, - - cached: [], - fullyLoaded: false, - - sync: function(method, model, options) { - - var sort = {"sort": {"method": "title"}}, - opt = [app.movieFields, {'end': 500, 'start': 0}, sort, options.filter]; - console.log('result from ', opt); - - for(var k in options.filter){ - var key = k + ':' + options.filter[k]; - } - - app.xbmcController.command('VideoLibrary.GetMovies', opt, function(data){ - console.log('result from ', opt); - console.log('data ', data); - - options.success(data.result.movies); - }); - - } - -}); - - -/** - * A lightweight collection of all movies (cached). - */ -app.MovieAllCollection = Backbone.Collection.extend({ - model: app.Movie, - - cached: [], - fullyLoaded: false, - - sync: function(method, model, options) { - - if(typeof app.stores.allMovies == 'undefined'){ - // no cache, do a lookup - var allMovies = new app.AllMovieXbmcCollection(); - allMovies.fetch({"success": function(data){ - // Sort - data.models.sort(function(a,b){ return app.helpers.aphabeticalSort(a.attributes.label, b.attributes.label); }); - // Cache - app.stores.allMovies = data.models; - // Return - options.success(data.models); - }}); - } else { - // else return cache; - options.success(app.stores.allMovies); - } - - } - }); ;app.AlbumView = Backbone.View.extend({ diff --git a/dist/chorus.min.js b/dist/chorus.min.js index dde259f..1d1a9f7 100755 --- a/dist/chorus.min.js +++ b/dist/chorus.min.js @@ -10,7 +10,7 @@ return b&&11!==b.nodeType?b:null},parents:function(a){return kb.dir(a,"parentNod })},stop:function(){a(this).removeData("resizable-alsoresize")}}),a.ui.plugin.add("resizable","ghost",{start:function(){var b=a(this).data("ui-resizable"),c=b.options,d=b.size;b.ghost=b.originalElement.clone(),b.ghost.css({opacity:.25,display:"block",position:"relative",height:d.height,width:d.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof c.ghost?c.ghost:""),b.ghost.appendTo(b.helper)},resize:function(){var b=a(this).data("ui-resizable");b.ghost&&b.ghost.css({position:"relative",height:b.size.height,width:b.size.width})},stop:function(){var b=a(this).data("ui-resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}}),a.ui.plugin.add("resizable","grid",{resize:function(){var b=a(this).data("ui-resizable"),c=b.options,d=b.size,e=b.originalSize,f=b.originalPosition,g=b.axis,h="number"==typeof c.grid?[c.grid,c.grid]:c.grid,i=h[0]||1,j=h[1]||1,k=Math.round((d.width-e.width)/i)*i,l=Math.round((d.height-e.height)/j)*j,m=e.width+k,n=e.height+l,o=c.maxWidth&&m>c.maxWidth,p=c.maxHeight&&n>c.maxHeight,q=c.minWidth&&c.minWidth>m,r=c.minHeight&&c.minHeight>n;c.grid=h,q&&(m+=i),r&&(n+=j),o&&(m-=i),p&&(n-=j),/^(se|s|e)$/.test(g)?(b.size.width=m,b.size.height=n):/^(ne)$/.test(g)?(b.size.width=m,b.size.height=n,b.position.top=f.top-l):/^(sw)$/.test(g)?(b.size.width=m,b.size.height=n,b.position.left=f.left-k):(b.size.width=m,b.size.height=n,b.position.top=f.top-l,b.position.left=f.left-k)}})}(jQuery),function(a){a.widget("ui.selectable",a.ui.mouse,{version:"1.10.3",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var b,c=this;this.element.addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){b=a(c.options.filter,c.element[0]),b.addClass("ui-selectee"),b.each(function(){var b=a(this),c=b.offset();a.data(this,"selectable-item",{element:this,$element:b,left:c.left,top:c.top,right:c.left+b.outerWidth(),bottom:c.top+b.outerHeight(),startselected:!1,selected:b.hasClass("ui-selected"),selecting:b.hasClass("ui-selecting"),unselecting:b.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=b.addClass("ui-selectee"),this._mouseInit(),this.helper=a("
")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(b){var c=this,d=this.options;this.opos=[b.pageX,b.pageY],this.options.disabled||(this.selectees=a(d.filter,this.element[0]),this._trigger("start",b),a(d.appendTo).append(this.helper),this.helper.css({left:b.pageX,top:b.pageY,width:0,height:0}),d.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var d=a.data(this,"selectable-item");d.startselected=!0,b.metaKey||b.ctrlKey||(d.$element.removeClass("ui-selected"),d.selected=!1,d.$element.addClass("ui-unselecting"),d.unselecting=!0,c._trigger("unselecting",b,{unselecting:d.element}))}),a(b.target).parents().addBack().each(function(){var d,e=a.data(this,"selectable-item");return e?(d=!b.metaKey&&!b.ctrlKey||!e.$element.hasClass("ui-selected"),e.$element.removeClass(d?"ui-unselecting":"ui-selected").addClass(d?"ui-selecting":"ui-unselecting"),e.unselecting=!d,e.selecting=d,e.selected=d,d?c._trigger("selecting",b,{selecting:e.element}):c._trigger("unselecting",b,{unselecting:e.element}),!1):void 0}))},_mouseDrag:function(b){if(this.dragged=!0,!this.options.disabled){var c,d=this,e=this.options,f=this.opos[0],g=this.opos[1],h=b.pageX,i=b.pageY;return f>h&&(c=h,h=f,f=c),g>i&&(c=i,i=g,g=c),this.helper.css({left:f,top:g,width:h-f,height:i-g}),this.selectees.each(function(){var c=a.data(this,"selectable-item"),j=!1;c&&c.element!==d.element[0]&&("touch"===e.tolerance?j=!(c.left>h||f>c.right||c.top>i||g>c.bottom):"fit"===e.tolerance&&(j=c.left>f&&h>c.right&&c.top>g&&i>c.bottom),j?(c.selected&&(c.$element.removeClass("ui-selected"),c.selected=!1),c.unselecting&&(c.$element.removeClass("ui-unselecting"),c.unselecting=!1),c.selecting||(c.$element.addClass("ui-selecting"),c.selecting=!0,d._trigger("selecting",b,{selecting:c.element}))):(c.selecting&&((b.metaKey||b.ctrlKey)&&c.startselected?(c.$element.removeClass("ui-selecting"),c.selecting=!1,c.$element.addClass("ui-selected"),c.selected=!0):(c.$element.removeClass("ui-selecting"),c.selecting=!1,c.startselected&&(c.$element.addClass("ui-unselecting"),c.unselecting=!0),d._trigger("unselecting",b,{unselecting:c.element}))),c.selected&&(b.metaKey||b.ctrlKey||c.startselected||(c.$element.removeClass("ui-selected"),c.selected=!1,c.$element.addClass("ui-unselecting"),c.unselecting=!0,d._trigger("unselecting",b,{unselecting:c.element})))))}),!1}},_mouseStop:function(b){var c=this;return this.dragged=!1,a(".ui-unselecting",this.element[0]).each(function(){var d=a.data(this,"selectable-item");d.$element.removeClass("ui-unselecting"),d.unselecting=!1,d.startselected=!1,c._trigger("unselected",b,{unselected:d.element})}),a(".ui-selecting",this.element[0]).each(function(){var d=a.data(this,"selectable-item");d.$element.removeClass("ui-selecting").addClass("ui-selected"),d.selecting=!1,d.selected=!0,d.startselected=!0,c._trigger("selected",b,{selected:d.element})}),this._trigger("stop",b),this.helper.remove(),!1}})}(jQuery),function(a){function b(a,b,c){return a>b&&b+c>a}function c(a){return/left|right/.test(a.css("float"))||/inline|table-cell/.test(a.css("display"))}a.widget("ui.sortable",a.ui.mouse,{version:"1.10.3",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var a=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===a.axis||c(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData(this.widgetName+"-item");return this},_setOption:function(b,c){"disabled"===b?(this.options[b]=c,this.widget().toggleClass("ui-sortable-disabled",!!c)):a.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(b,c){var d=null,e=!1,f=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(b),a(b.target).parents().each(function(){return a.data(this,f.widgetName+"-item")===f?(d=a(this),!1):void 0}),a.data(b.target,f.widgetName+"-item")===f&&(d=a(b.target)),d?!this.options.handle||c||(a(this.options.handle,d).find("*").addBack().each(function(){this===b.target&&(e=!0)}),e)?(this.currentItem=d,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(b,c,d){var e,f,g=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(b),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(b),this.originalPageX=b.pageX,this.originalPageY=b.pageY,g.cursorAt&&this._adjustOffsetFromHelper(g.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),g.containment&&this._setContainment(),g.cursor&&"auto"!==g.cursor&&(f=this.document.find("body"),this.storedCursor=f.css("cursor"),f.css("cursor",g.cursor),this.storedStylesheet=a("").appendTo(f)),g.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",g.opacity)),g.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",g.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",b,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!d)for(e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("activate",b,this._uiHash(this));return a.ui.ddmanager&&(a.ui.ddmanager.current=this),a.ui.ddmanager&&!g.dropBehaviour&&a.ui.ddmanager.prepareOffsets(this,b),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(b),!0},_mouseDrag:function(b){var c,d,e,f,g=this.options,h=!1;for(this.position=this._generatePosition(b),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-b.pageY=0;c--)if(d=this.items[c],e=d.item[0],f=this._intersectsWithPointer(d),f&&d.instance===this.currentContainer&&e!==this.currentItem[0]&&this.placeholder[1===f?"next":"prev"]()[0]!==e&&!a.contains(this.placeholder[0],e)&&("semi-dynamic"===this.options.type?!a.contains(this.element[0],e):!0)){if(this.direction=1===f?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(d))break;this._rearrange(b,d),this._trigger("change",b,this._uiHash());break}return this._contactContainers(b),a.ui.ddmanager&&a.ui.ddmanager.drag(this,b),this._trigger("sort",b,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(b,c){if(b){if(a.ui.ddmanager&&!this.options.dropBehaviour&&a.ui.ddmanager.drop(this,b),this.options.revert){var d=this,e=this.placeholder.offset(),f=this.options.axis,g={};f&&"x"!==f||(g.left=e.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),f&&"y"!==f||(g.top=e.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,a(this.helper).animate(g,parseInt(this.options.revert,10)||500,function(){d._clear(b)})}else this._clear(b,c);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var b=this.containers.length-1;b>=0;b--)this.containers[b]._trigger("deactivate",null,this._uiHash(this)),this.containers[b].containerCache.over&&(this.containers[b]._trigger("out",null,this._uiHash(this)),this.containers[b].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),a.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?a(this.domPosition.prev).after(this.currentItem):a(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},a(c).each(function(){var c=(a(b.item||this).attr(b.attribute||"id")||"").match(b.expression||/(.+)[\-=_](.+)/);c&&d.push((b.key||c[1]+"[]")+"="+(b.key&&b.expression?c[1]:c[2]))}),!d.length&&b.key&&d.push(b.key+"="),d.join("&")},toArray:function(b){var c=this._getItemsAsjQuery(b&&b.connected),d=[];return b=b||{},c.each(function(){d.push(a(b.item||this).attr(b.attribute||"id")||"")}),d},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,d=this.positionAbs.top,e=d+this.helperProportions.height,f=a.left,g=f+a.width,h=a.top,i=h+a.height,j=this.offset.click.top,k=this.offset.click.left,l="x"===this.options.axis||d+j>h&&i>d+j,m="y"===this.options.axis||b+k>f&&g>b+k,n=l&&m;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>a[this.floating?"width":"height"]?n:b+this.helperProportions.width/2>f&&g>c-this.helperProportions.width/2&&d+this.helperProportions.height/2>h&&i>e-this.helperProportions.height/2},_intersectsWithPointer:function(a){var c="x"===this.options.axis||b(this.positionAbs.top+this.offset.click.top,a.top,a.height),d="y"===this.options.axis||b(this.positionAbs.left+this.offset.click.left,a.left,a.width),e=c&&d,f=this._getDragVerticalDirection(),g=this._getDragHorizontalDirection();return e?this.floating?g&&"right"===g||"down"===f?2:1:f&&("down"===f?2:1):!1},_intersectsWithSides:function(a){var c=b(this.positionAbs.top+this.offset.click.top,a.top+a.height/2,a.height),d=b(this.positionAbs.left+this.offset.click.left,a.left+a.width/2,a.width),e=this._getDragVerticalDirection(),f=this._getDragHorizontalDirection();return this.floating&&f?"right"===f&&d||"left"===f&&!d:e&&("down"===e&&c||"up"===e&&!c)},_getDragVerticalDirection:function(){var a=this.positionAbs.top-this.lastPositionAbs.top;return 0!==a&&(a>0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return 0!==a&&(a>0?"right":"left")},refresh:function(a){return this._refreshItems(a),this.refreshPositions(),this},_connectWith:function(){var a=this.options;return a.connectWith.constructor===String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(b){var c,d,e,f,g=[],h=[],i=this._connectWith();if(i&&b)for(c=i.length-1;c>=0;c--)for(e=a(i[c]),d=e.length-1;d>=0;d--)f=a.data(e[d],this.widgetFullName),f&&f!==this&&!f.options.disabled&&h.push([a.isFunction(f.options.items)?f.options.items.call(f.element):a(f.options.items,f.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),f]);for(h.push([a.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):a(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),c=h.length-1;c>=0;c--)h[c][0].each(function(){g.push(this)});return a(g)},_removeCurrentsFromItems:function(){var b=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=a.grep(this.items,function(a){for(var c=0;b.length>c;c++)if(b[c]===a.item[0])return!1;return!0})},_refreshItems:function(b){this.items=[],this.containers=[this];var c,d,e,f,g,h,i,j,k=this.items,l=[[a.isFunction(this.options.items)?this.options.items.call(this.element[0],b,{item:this.currentItem}):a(this.options.items,this.element),this]],m=this._connectWith();if(m&&this.ready)for(c=m.length-1;c>=0;c--)for(e=a(m[c]),d=e.length-1;d>=0;d--)f=a.data(e[d],this.widgetFullName),f&&f!==this&&!f.options.disabled&&(l.push([a.isFunction(f.options.items)?f.options.items.call(f.element[0],b,{item:this.currentItem}):a(f.options.items,f.element),f]),this.containers.push(f));for(c=l.length-1;c>=0;c--)for(g=l[c][1],h=l[c][0],d=0,j=h.length;j>d;d++)i=a(h[d]),i.data(this.widgetName+"-item",g),k.push({item:i,instance:g,width:0,height:0,left:0,top:0})},refreshPositions:function(b){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var c,d,e,f;for(c=this.items.length-1;c>=0;c--)d=this.items[c],d.instance!==this.currentContainer&&this.currentContainer&&d.item[0]!==this.currentItem[0]||(e=this.options.toleranceElement?a(this.options.toleranceElement,d.item):d.item,b||(d.width=e.outerWidth(),d.height=e.outerHeight()),f=e.offset(),d.left=f.left,d.top=f.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(c=this.containers.length-1;c>=0;c--)f=this.containers[c].element.offset(),this.containers[c].containerCache.left=f.left,this.containers[c].containerCache.top=f.top,this.containers[c].containerCache.width=this.containers[c].element.outerWidth(),this.containers[c].containerCache.height=this.containers[c].element.outerHeight();return this},_createPlaceholder:function(b){b=b||this;var c,d=b.options;d.placeholder&&d.placeholder.constructor!==String||(c=d.placeholder,d.placeholder={element:function(){var d=b.currentItem[0].nodeName.toLowerCase(),e=a("<"+d+">",b.document[0]).addClass(c||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===d?b.currentItem.children().each(function(){a(" ",b.document[0]).attr("colspan",a(this).attr("colspan")||1).appendTo(e)}):"img"===d&&e.attr("src",b.currentItem.attr("src")),c||e.css("visibility","hidden"),e},update:function(a,e){(!c||d.forcePlaceholderSize)&&(e.height()||e.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10)),e.width()||e.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")||0,10)))}}),b.placeholder=a(d.placeholder.element.call(b.element,b.currentItem)),b.currentItem.after(b.placeholder),d.placeholder.update(b,b.placeholder)},_contactContainers:function(d){var e,f,g,h,i,j,k,l,m,n,o=null,p=null;for(e=this.containers.length-1;e>=0;e--)if(!a.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(o&&a.contains(this.containers[e].element[0],o.element[0]))continue;o=this.containers[e],p=e}else this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",d,this._uiHash(this)),this.containers[e].containerCache.over=0);if(o)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",d,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(g=1e4,h=null,n=o.floating||c(this.currentItem),i=n?"left":"top",j=n?"width":"height",k=this.positionAbs[i]+this.offset.click[i],f=this.items.length-1;f>=0;f--)a.contains(this.containers[p].element[0],this.items[f].item[0])&&this.items[f].item[0]!==this.currentItem[0]&&(!n||b(this.positionAbs.top+this.offset.click.top,this.items[f].top,this.items[f].height))&&(l=this.items[f].item.offset()[i],m=!1,Math.abs(l-k)>Math.abs(l+this.items[f][j]-k)&&(m=!0,l+=this.items[f][j]),g>Math.abs(l-k)&&(g=Math.abs(l-k),h=this.items[f],this.direction=m?"up":"down"));if(!h&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[p])return;h?this._rearrange(d,h,null,!0):this._rearrange(d,null,this.containers[p].element,!0),this._trigger("change",d,this._uiHash()),this.containers[p]._trigger("change",d,this._uiHash(this)),this.currentContainer=this.containers[p],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[p]._trigger("over",d,this._uiHash(this)),this.containers[p].containerCache.over=1}},_createHelper:function(b){var c=this.options,d=a.isFunction(c.helper)?a(c.helper.apply(this.element[0],[b,this.currentItem])):"clone"===c.helper?this.currentItem.clone():this.currentItem;return d.parents("body").length||a("parent"!==c.appendTo?c.appendTo:this.currentItem[0].parentNode)[0].appendChild(d[0]),d[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!d[0].style.width||c.forceHelperSize)&&d.width(this.currentItem.width()),(!d[0].style.height||c.forceHelperSize)&&d.height(this.currentItem.height()),d},_adjustOffsetFromHelper:function(b){"string"==typeof b&&(b=b.split(" ")),a.isArray(b)&&(b={left:+b[0],top:+b[1]||0}),"left"in b&&(this.offset.click.left=b.left+this.margins.left),"right"in b&&(this.offset.click.left=this.helperProportions.width-b.right+this.margins.left),"top"in b&&(this.offset.click.top=b.top+this.margins.top),"bottom"in b&&(this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&a.contains(this.scrollParent[0],this.offsetParent[0])&&(b.left+=this.scrollParent.scrollLeft(),b.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&a.ui.ie)&&(b={top:0,left:0}),{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var a=this.currentItem.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var b,c,d,e=this.options;"parent"===e.containment&&(e.containment=this.helper[0].parentNode),("document"===e.containment||"window"===e.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a("document"===e.containment?document:window).width()-this.helperProportions.width-this.margins.left,(a("document"===e.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(e.containment)||(b=a(e.containment)[0],c=a(e.containment).offset(),d="hidden"!==a(b).css("overflow"),this.containment=[c.left+(parseInt(a(b).css("borderLeftWidth"),10)||0)+(parseInt(a(b).css("paddingLeft"),10)||0)-this.margins.left,c.top+(parseInt(a(b).css("borderTopWidth"),10)||0)+(parseInt(a(b).css("paddingTop"),10)||0)-this.margins.top,c.left+(d?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(a(b).css("borderLeftWidth"),10)||0)-(parseInt(a(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,c.top+(d?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(a(b).css("borderTopWidth"),10)||0)-(parseInt(a(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(b,c){c||(c=this.position);var d="absolute"===b?1:-1,e="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&a.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,f=/(html|body)/i.test(e[0].tagName);return{top:c.top+this.offset.relative.top*d+this.offset.parent.top*d-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():f?0:e.scrollTop())*d,left:c.left+this.offset.relative.left*d+this.offset.parent.left*d-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():f?0:e.scrollLeft())*d}},_generatePosition:function(b){var c,d,e=this.options,f=b.pageX,g=b.pageY,h="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&a.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=/(html|body)/i.test(h[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(b.pageX-this.offset.click.leftthis.containment[2]&&(f=this.containment[2]+this.offset.click.left),b.pageY-this.offset.click.top>this.containment[3]&&(g=this.containment[3]+this.offset.click.top)),e.grid&&(c=this.originalPageY+Math.round((g-this.originalPageY)/e.grid[1])*e.grid[1],g=this.containment?c-this.offset.click.top>=this.containment[1]&&c-this.offset.click.top<=this.containment[3]?c:c-this.offset.click.top>=this.containment[1]?c-e.grid[1]:c+e.grid[1]:c,d=this.originalPageX+Math.round((f-this.originalPageX)/e.grid[0])*e.grid[0],f=this.containment?d-this.offset.click.left>=this.containment[0]&&d-this.offset.click.left<=this.containment[2]?d:d-this.offset.click.left>=this.containment[0]?d-e.grid[0]:d+e.grid[0]:d)),{top:g-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():i?0:h.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():i?0:h.scrollLeft())}},_rearrange:function(a,b,c,d){c?c[0].appendChild(this.placeholder[0]):b.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?b.item[0]:b.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var e=this.counter;this._delay(function(){e===this.counter&&this.refreshPositions(!d)})},_clear:function(a,b){this.reverting=!1;var c,d=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(c in this._storedCSS)("auto"===this._storedCSS[c]||"static"===this._storedCSS[c])&&(this._storedCSS[c]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!b&&d.push(function(a){this._trigger("receive",a,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||b||d.push(function(a){this._trigger("update",a,this._uiHash())}),this!==this.currentContainer&&(b||(d.push(function(a){this._trigger("remove",a,this._uiHash())}),d.push(function(a){return function(b){a._trigger("receive",b,this._uiHash(this))}}.call(this,this.currentContainer)),d.push(function(a){return function(b){a._trigger("update",b,this._uiHash(this))}}.call(this,this.currentContainer)))),c=this.containers.length-1;c>=0;c--)b||d.push(function(a){return function(b){a._trigger("deactivate",b,this._uiHash(this))}}.call(this,this.containers[c])),this.containers[c].containerCache.over&&(d.push(function(a){return function(b){a._trigger("out",b,this._uiHash(this))}}.call(this,this.containers[c])),this.containers[c].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!b){for(this._trigger("beforeStop",a,this._uiHash()),c=0;d.length>c;c++)d[c].call(this,a);this._trigger("stop",a,this._uiHash())}return this.fromOutside=!1,!1}if(b||this._trigger("beforeStop",a,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!b){for(c=0;d.length>c;c++)d[c].call(this,a);this._trigger("stop",a,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){a.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(b){var c=b||this;return{helper:c.helper,placeholder:c.placeholder||a([]),position:c.position,originalPosition:c.originalPosition,offset:c.positionAbs,item:c.currentItem,sender:b?b.element:null}}})}(jQuery),function(a){var b,c,d,e,f="ui-button ui-widget ui-state-default ui-corner-all",g="ui-state-hover ui-state-active ",h="ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",i=function(){var b=a(this);setTimeout(function(){b.find(":ui-button").button("refresh")},1)},j=function(b){var c=b.name,d=b.form,e=a([]);return c&&(c=c.replace(/'/g,"\\'"),e=d?a(d).find("[name='"+c+"']"):a("[name='"+c+"']",b.ownerDocument).filter(function(){return!this.form})),e};a.widget("ui.button",{version:"1.10.3",defaultElement:"").button({label:this.options.closeText,icons:{primary:"ui-icon-closethick"},text:!1}).addClass("ui-dialog-titlebar-close").appendTo(this.uiDialogTitlebar),this._on(this.uiDialogTitlebarClose,{click:function(a){a.preventDefault(),this.close(a)}}),b=a("").uniqueId().addClass("ui-dialog-title").prependTo(this.uiDialogTitlebar),this._title(b),this.uiDialog.attr({"aria-labelledby":b.attr("id")})},_title:function(a){this.options.title||a.html(" "),a.text(this.options.title)},_createButtonPane:function(){this.uiDialogButtonPane=a("
").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),this.uiButtonSet=a("
").addClass("ui-dialog-buttonset").appendTo(this.uiDialogButtonPane),this._createButtons()},_createButtons:function(){var b=this,c=this.options.buttons;return this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),a.isEmptyObject(c)||a.isArray(c)&&!c.length?(this.uiDialog.removeClass("ui-dialog-buttons"),void 0):(a.each(c,function(c,d){var e,f;d=a.isFunction(d)?{click:d,text:c}:d,d=a.extend({type:"button"},d),e=d.click,d.click=function(){e.apply(b.element[0],arguments)},f={icons:d.icons,text:d.showText},delete d.icons,delete d.showText,a("",d).button(f).appendTo(b.uiButtonSet)}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog),void 0)},_makeDraggable:function(){function b(a){return{position:a.position,offset:a.offset}}var c=this,d=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(d,e){a(this).addClass("ui-dialog-dragging"),c._blockFrames(),c._trigger("dragStart",d,b(e))},drag:function(a,d){c._trigger("drag",a,b(d))},stop:function(e,f){d.position=[f.position.left-c.document.scrollLeft(),f.position.top-c.document.scrollTop()],a(this).removeClass("ui-dialog-dragging"),c._unblockFrames(),c._trigger("dragStop",e,b(f))}})},_makeResizable:function(){function b(a){return{originalPosition:a.originalPosition,originalSize:a.originalSize,position:a.position,size:a.size}}var c=this,d=this.options,e=d.resizable,f=this.uiDialog.css("position"),g="string"==typeof e?e:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:d.maxWidth,maxHeight:d.maxHeight,minWidth:d.minWidth,minHeight:this._minHeight(),handles:g,start:function(d,e){a(this).addClass("ui-dialog-resizing"),c._blockFrames(),c._trigger("resizeStart",d,b(e))},resize:function(a,d){c._trigger("resize",a,b(d))},stop:function(e,f){d.height=a(this).height(),d.width=a(this).width(),a(this).removeClass("ui-dialog-resizing"),c._unblockFrames(),c._trigger("resizeStop",e,b(f))}}).css("position",f)},_minHeight:function(){var a=this.options;return"auto"===a.height?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(){var a=this.uiDialog.is(":visible");a||this.uiDialog.show(),this.uiDialog.position(this.options.position),a||this.uiDialog.hide()},_setOptions:function(d){var e=this,f=!1,g={};a.each(d,function(a,d){e._setOption(a,d),a in b&&(f=!0),a in c&&(g[a]=d)}),f&&(this._size(),this._position()),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option",g)},_setOption:function(a,b){var c,d,e=this.uiDialog;"dialogClass"===a&&e.removeClass(this.options.dialogClass).addClass(b),"disabled"!==a&&(this._super(a,b),"appendTo"===a&&this.uiDialog.appendTo(this._appendTo()),"buttons"===a&&this._createButtons(),"closeText"===a&&this.uiDialogTitlebarClose.button({label:""+b}),"draggable"===a&&(c=e.is(":data(ui-draggable)"),c&&!b&&e.draggable("destroy"),!c&&b&&this._makeDraggable()),"position"===a&&this._position(),"resizable"===a&&(d=e.is(":data(ui-resizable)"),d&&!b&&e.resizable("destroy"),d&&"string"==typeof b&&e.resizable("option","handles",b),d||b===!1||this._makeResizable()),"title"===a&&this._title(this.uiDialogTitlebar.find(".ui-dialog-title")))},_size:function(){var a,b,c,d=this.options;this.element.show().css({width:"auto",minHeight:0,maxHeight:"none",height:0}),d.minWidth>d.width&&(d.width=d.minWidth),a=this.uiDialog.css({height:"auto",width:d.width}).outerHeight(),b=Math.max(0,d.minHeight-a),c="number"==typeof d.maxHeight?Math.max(0,d.maxHeight-a):"none","auto"===d.height?this.element.css({minHeight:b,maxHeight:c,height:"auto"}):this.element.height(Math.max(0,d.height-a)),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())},_blockFrames:function(){this.iframeBlocks=this.document.find("iframe").map(function(){var b=a(this);return a("
").css({position:"absolute",width:b.outerWidth(),height:b.outerHeight()}).appendTo(b.parent()).offset(b.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_allowInteraction:function(b){return a(b.target).closest(".ui-dialog").length?!0:!!a(b.target).closest(".ui-datepicker").length},_createOverlay:function(){if(this.options.modal){var b=this,c=this.widgetFullName;a.ui.dialog.overlayInstances||this._delay(function(){a.ui.dialog.overlayInstances&&this.document.bind("focusin.dialog",function(d){b._allowInteraction(d)||(d.preventDefault(),a(".ui-dialog:visible:last .ui-dialog-content").data(c)._focusTabbable())})}),this.overlay=a("
").addClass("ui-widget-overlay ui-front").appendTo(this._appendTo()),this._on(this.overlay,{mousedown:"_keepFocus"}),a.ui.dialog.overlayInstances++}},_destroyOverlay:function(){this.options.modal&&this.overlay&&(a.ui.dialog.overlayInstances--,a.ui.dialog.overlayInstances||this.document.unbind("focusin.dialog"),this.overlay.remove(),this.overlay=null)}}),a.ui.dialog.overlayInstances=0,a.uiBackCompat!==!1&&a.widget("ui.dialog",a.ui.dialog,{_position:function(){var b,c=this.options.position,d=[],e=[0,0];c?(("string"==typeof c||"object"==typeof c&&"0"in c)&&(d=c.split?c.split(" "):[c[0],c[1]],1===d.length&&(d[1]=d[0]),a.each(["left","top"],function(a,b){+d[a]===d[a]&&(e[a]=d[a],d[a]=b)}),c={my:d[0]+(0>e[0]?e[0]:"+"+e[0])+" "+d[1]+(0>e[1]?e[1]:"+"+e[1]),at:d.join(" ")}),c=a.extend({},a.ui.dialog.prototype.options.position,c)):c=a.ui.dialog.prototype.options.position,b=this.uiDialog.is(":visible"),b||this.uiDialog.show(),this.uiDialog.position(c),b||this.uiDialog.hide()}})}(jQuery),function(a,b){a.widget("ui.progressbar",{version:"1.10.3",options:{max:100,value:0,change:null,complete:null},min:0,_create:function(){this.oldValue=this.options.value=this._constrainedValue(),this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min}),this.valueDiv=a("
").appendTo(this.element),this._refreshValue()},_destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove()},value:function(a){return a===b?this.options.value:(this.options.value=this._constrainedValue(a),this._refreshValue(),b)},_constrainedValue:function(a){return a===b&&(a=this.options.value),this.indeterminate=a===!1,"number"!=typeof a&&(a=0),this.indeterminate?!1:Math.min(this.options.max,Math.max(this.min,a))},_setOptions:function(a){var b=a.value;delete a.value,this._super(a),this.options.value=this._constrainedValue(b),this._refreshValue()},_setOption:function(a,b){"max"===a&&(b=Math.max(this.min,b)),this._super(a,b)},_percentage:function(){return this.indeterminate?100:100*(this.options.value-this.min)/(this.options.max-this.min)},_refreshValue:function(){var b=this.options.value,c=this._percentage();this.valueDiv.toggle(this.indeterminate||b>this.min).toggleClass("ui-corner-right",b===this.options.max).width(c.toFixed(0)+"%"),this.element.toggleClass("ui-progressbar-indeterminate",this.indeterminate),this.indeterminate?(this.element.removeAttr("aria-valuenow"),this.overlayDiv||(this.overlayDiv=a("
").appendTo(this.valueDiv))):(this.element.attr({"aria-valuemax":this.options.max,"aria-valuenow":b}),this.overlayDiv&&(this.overlayDiv.remove(),this.overlayDiv=null)),this.oldValue!==b&&(this.oldValue=b,this._trigger("change")),b===this.options.max&&this._trigger("complete")}})}(jQuery),function(a){var b=5;a.widget("ui.slider",a.ui.mouse,{version:"1.10.3",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null,change:null,slide:null,start:null,stop:null},_create:function(){this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget ui-widget-content ui-corner-all"),this._refresh(),this._setOption("disabled",this.options.disabled),this._animateOff=!1},_refresh:function(){this._createRange(),this._createHandles(),this._setupEvents(),this._refreshValue()},_createHandles:function(){var b,c,d=this.options,e=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f="",g=[];for(c=d.values&&d.values.length||1,e.length>c&&(e.slice(c).remove(),e=e.slice(0,c)),b=e.length;c>b;b++)g.push(f);this.handles=e.add(a(g.join("")).appendTo(this.element)),this.handle=this.handles.eq(0),this.handles.each(function(b){a(this).data("ui-slider-handle-index",b)})},_createRange:function(){var b=this.options,c="";b.range?(b.range===!0&&(b.values?b.values.length&&2!==b.values.length?b.values=[b.values[0],b.values[0]]:a.isArray(b.values)&&(b.values=b.values.slice(0)):b.values=[this._valueMin(),this._valueMin()]),this.range&&this.range.length?this.range.removeClass("ui-slider-range-min ui-slider-range-max").css({left:"",bottom:""}):(this.range=a("
").appendTo(this.element),c="ui-slider-range ui-widget-header ui-corner-all"),this.range.addClass(c+("min"===b.range||"max"===b.range?" ui-slider-range-"+b.range:""))):this.range=a([])},_setupEvents:function(){var a=this.handles.add(this.range).filter("a");this._off(a),this._on(a,this._handleEvents),this._hoverable(a),this._focusable(a)},_destroy:function(){this.handles.remove(),this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-widget ui-widget-content ui-corner-all"),this._mouseDestroy()},_mouseCapture:function(b){var c,d,e,f,g,h,i,j,k=this,l=this.options;return l.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),c={x:b.pageX,y:b.pageY},d=this._normValueFromMouse(c),e=this._valueMax()-this._valueMin()+1,this.handles.each(function(b){var c=Math.abs(d-k.values(b));(e>c||e===c&&(b===k._lastChangedValue||k.values(b)===l.min))&&(e=c,f=a(this),g=b)}),h=this._start(b,g),h===!1?!1:(this._mouseSliding=!0,this._handleIndex=g,f.addClass("ui-state-active").focus(),i=f.offset(),j=!a(b.target).parents().addBack().is(".ui-slider-handle"),this._clickOffset=j?{left:0,top:0}:{left:b.pageX-i.left-f.width()/2,top:b.pageY-i.top-f.height()/2-(parseInt(f.css("borderTopWidth"),10)||0)-(parseInt(f.css("borderBottomWidth"),10)||0)+(parseInt(f.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(b,g,d),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(a){var b={x:a.pageX,y:a.pageY},c=this._normValueFromMouse(b);return this._slide(a,this._handleIndex,c),!1},_mouseStop:function(a){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(a,this._handleIndex),this._change(a,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(a){var b,c,d,e,f;return"horizontal"===this.orientation?(b=this.elementSize.width,c=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(b=this.elementSize.height,c=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),d=c/b,d>1&&(d=1),0>d&&(d=0),"vertical"===this.orientation&&(d=1-d),e=this._valueMax()-this._valueMin(),f=this._valueMin()+d*e,this._trimAlignValue(f)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};return this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("start",a,c)},_slide:function(a,b,c){var d,e,f;this.options.values&&this.options.values.length?(d=this.values(b?0:1),2===this.options.values.length&&this.options.range===!0&&(0===b&&c>d||1===b&&d>c)&&(c=d),c!==this.values(b)&&(e=this.values(),e[b]=c,f=this._trigger("slide",a,{handle:this.handles[b],value:c,values:e}),d=this.values(b?0:1),f!==!1&&this.values(b,c,!0))):c!==this.value()&&(f=this._trigger("slide",a,{handle:this.handles[b],value:c}),f!==!1&&this.value(c))},_stop:function(a,b){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._trigger("stop",a,c)},_change:function(a,b){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[b],value:this.value()};this.options.values&&this.options.values.length&&(c.value=this.values(b),c.values=this.values()),this._lastChangedValue=b,this._trigger("change",a,c)}},value:function(a){return arguments.length?(this.options.value=this._trimAlignValue(a),this._refreshValue(),this._change(null,0),void 0):this._value()},values:function(b,c){var d,e,f;if(arguments.length>1)return this.options.values[b]=this._trimAlignValue(c),this._refreshValue(),this._change(null,b),void 0;if(!arguments.length)return this._values();if(!a.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(b):this.value();for(d=this.options.values,e=arguments[0],f=0;d.length>f;f+=1)d[f]=this._trimAlignValue(e[f]),this._change(null,f);this._refreshValue()},_setOption:function(b,c){var d,e=0;switch("range"===b&&this.options.range===!0&&("min"===c?(this.options.value=this._values(0),this.options.values=null):"max"===c&&(this.options.value=this._values(this.options.values.length-1),this.options.values=null)),a.isArray(this.options.values)&&(e=this.options.values.length),a.Widget.prototype._setOption.apply(this,arguments),b){case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue();break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":for(this._animateOff=!0,this._refreshValue(),d=0;e>d;d+=1)this._change(null,d);this._animateOff=!1;break;case"min":case"max":this._animateOff=!0,this._refreshValue(),this._animateOff=!1;break;case"range":this._animateOff=!0,this._refresh(),this._animateOff=!1}},_value:function(){var a=this.options.value;return a=this._trimAlignValue(a)},_values:function(a){var b,c,d;if(arguments.length)return b=this.options.values[a],b=this._trimAlignValue(b);if(this.options.values&&this.options.values.length){for(c=this.options.values.slice(),d=0;c.length>d;d+=1)c[d]=this._trimAlignValue(c[d]);return c}return[]},_trimAlignValue:function(a){if(this._valueMin()>=a)return this._valueMin();if(a>=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b,d=a-c;return 2*Math.abs(c)>=b&&(d+=c>0?b:-b),parseFloat(d.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var b,c,d,e,f,g=this.options.range,h=this.options,i=this,j=this._animateOff?!1:h.animate,k={};this.options.values&&this.options.values.length?this.handles.each(function(d){c=100*((i.values(d)-i._valueMin())/(i._valueMax()-i._valueMin())),k["horizontal"===i.orientation?"left":"bottom"]=c+"%",a(this).stop(1,1)[j?"animate":"css"](k,h.animate),i.options.range===!0&&("horizontal"===i.orientation?(0===d&&i.range.stop(1,1)[j?"animate":"css"]({left:c+"%"},h.animate),1===d&&i.range[j?"animate":"css"]({width:c-b+"%"},{queue:!1,duration:h.animate})):(0===d&&i.range.stop(1,1)[j?"animate":"css"]({bottom:c+"%"},h.animate),1===d&&i.range[j?"animate":"css"]({height:c-b+"%"},{queue:!1,duration:h.animate}))),b=c}):(d=this.value(),e=this._valueMin(),f=this._valueMax(),c=f!==e?100*((d-e)/(f-e)):0,k["horizontal"===this.orientation?"left":"bottom"]=c+"%",this.handle.stop(1,1)[j?"animate":"css"](k,h.animate),"min"===g&&"horizontal"===this.orientation&&this.range.stop(1,1)[j?"animate":"css"]({width:c+"%"},h.animate),"max"===g&&"horizontal"===this.orientation&&this.range[j?"animate":"css"]({width:100-c+"%"},{queue:!1,duration:h.animate}),"min"===g&&"vertical"===this.orientation&&this.range.stop(1,1)[j?"animate":"css"]({height:c+"%"},h.animate),"max"===g&&"vertical"===this.orientation&&this.range[j?"animate":"css"]({height:100-c+"%"},{queue:!1,duration:h.animate}))},_handleEvents:{keydown:function(c){var d,e,f,g,h=a(c.target).data("ui-slider-handle-index");switch(c.keyCode){case a.ui.keyCode.HOME:case a.ui.keyCode.END:case a.ui.keyCode.PAGE_UP:case a.ui.keyCode.PAGE_DOWN:case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(c.preventDefault(),!this._keySliding&&(this._keySliding=!0,a(c.target).addClass("ui-state-active"),d=this._start(c,h),d===!1))return}switch(g=this.options.step,e=f=this.options.values&&this.options.values.length?this.values(h):this.value(),c.keyCode){case a.ui.keyCode.HOME:f=this._valueMin();break;case a.ui.keyCode.END:f=this._valueMax();break;case a.ui.keyCode.PAGE_UP:f=this._trimAlignValue(e+(this._valueMax()-this._valueMin())/b);break;case a.ui.keyCode.PAGE_DOWN:f=this._trimAlignValue(e-(this._valueMax()-this._valueMin())/b);break;case a.ui.keyCode.UP:case a.ui.keyCode.RIGHT:if(e===this._valueMax())return;f=this._trimAlignValue(e+g);break;case a.ui.keyCode.DOWN:case a.ui.keyCode.LEFT:if(e===this._valueMin())return;f=this._trimAlignValue(e-g)}this._slide(c,h,f)},click:function(a){a.preventDefault()},keyup:function(b){var c=a(b.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(b,c),this._change(b,c),a(b.target).removeClass("ui-state-active"))}}})}(jQuery),function(a,b){function c(){return++e}function d(a){return a.hash.length>1&&decodeURIComponent(a.href.replace(f,""))===decodeURIComponent(location.href.replace(f,""))}var e=0,f=/#.*$/;a.widget("ui.tabs",{version:"1.10.3",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var b=this,c=this.options;this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",c.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(b){a(this).is(".ui-state-disabled")&&b.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){a(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs(),c.active=this._initialActive(),a.isArray(c.disabled)&&(c.disabled=a.unique(c.disabled.concat(a.map(this.tabs.filter(".ui-state-disabled"),function(a){return b.tabs.index(a)}))).sort()),this.active=this.options.active!==!1&&this.anchors.length?this._findActive(c.active):a(),this._refresh(),this.active.length&&this.load(c.active)},_initialActive:function(){var c=this.options.active,d=this.options.collapsible,e=location.hash.substring(1);return null===c&&(e&&this.tabs.each(function(d,f){return a(f).attr("aria-controls")===e?(c=d,!1):b}),null===c&&(c=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===c||-1===c)&&(c=this.tabs.length?0:!1)),c!==!1&&(c=this.tabs.index(this.tabs.eq(c)),-1===c&&(c=d?!1:0)),!d&&c===!1&&this.anchors.length&&(c=0),c},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):a()}},_tabKeydown:function(c){var d=a(this.document[0].activeElement).closest("li"),e=this.tabs.index(d),f=!0;if(!this._handlePageNav(c)){switch(c.keyCode){case a.ui.keyCode.RIGHT:case a.ui.keyCode.DOWN:e++;break;case a.ui.keyCode.UP:case a.ui.keyCode.LEFT:f=!1,e--;break;case a.ui.keyCode.END:e=this.anchors.length-1;break;case a.ui.keyCode.HOME:e=0;break;case a.ui.keyCode.SPACE:return c.preventDefault(),clearTimeout(this.activating),this._activate(e),b;case a.ui.keyCode.ENTER:return c.preventDefault(),clearTimeout(this.activating),this._activate(e===this.options.active?!1:e),b;default:return}c.preventDefault(),clearTimeout(this.activating),e=this._focusNextTab(e,f),c.ctrlKey||(d.attr("aria-selected","false"),this.tabs.eq(e).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",e)},this.delay))}},_panelKeydown:function(b){this._handlePageNav(b)||b.ctrlKey&&b.keyCode===a.ui.keyCode.UP&&(b.preventDefault(),this.active.focus())},_handlePageNav:function(c){return c.altKey&&c.keyCode===a.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):c.altKey&&c.keyCode===a.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):b},_findNextTab:function(b,c){function d(){return b>e&&(b=0),0>b&&(b=e),b}for(var e=this.tabs.length-1;-1!==a.inArray(d(),this.options.disabled);)b=c?b+1:b-1;return b},_focusNextTab:function(a,b){return a=this._findNextTab(a,b),this.tabs.eq(a).focus(),a},_setOption:function(a,c){return"active"===a?(this._activate(c),b):"disabled"===a?(this._setupDisabled(c),b):(this._super(a,c),"collapsible"===a&&(this.element.toggleClass("ui-tabs-collapsible",c),c||this.options.active!==!1||this._activate(0)),"event"===a&&this._setupEvents(c),"heightStyle"===a&&this._setupHeightStyle(c),b)},_tabId:function(a){return a.attr("aria-controls")||"ui-tabs-"+c()},_sanitizeSelector:function(a){return a?a.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var b=this.options,c=this.tablist.children(":has(a[href])");b.disabled=a.map(c.filter(".ui-state-disabled"),function(a){return c.index(a)}),this._processTabs(),b.active!==!1&&this.anchors.length?this.active.length&&!a.contains(this.tablist[0],this.active[0])?this.tabs.length===b.disabled.length?(b.active=!1,this.active=a()):this._activate(this._findNextTab(Math.max(0,b.active-1),!1)):b.active=this.tabs.index(this.active):(b.active=!1,this.active=a()),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0) },_processTabs:function(){var b=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return a("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=a(),this.anchors.each(function(c,e){var f,g,h,i=a(e).uniqueId().attr("id"),j=a(e).closest("li"),k=j.attr("aria-controls");d(e)?(f=e.hash,g=b.element.find(b._sanitizeSelector(f))):(h=b._tabId(j),f="#"+h,g=b.element.find(f),g.length||(g=b._createPanel(h),g.insertAfter(b.panels[c-1]||b.tablist)),g.attr("aria-live","polite")),g.length&&(b.panels=b.panels.add(g)),k&&j.data("ui-tabs-aria-controls",k),j.attr({"aria-controls":f.substring(1),"aria-labelledby":i}),g.attr("aria-labelledby",i)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(b){return a("
").attr("id",b).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(b){a.isArray(b)&&(b.length?b.length===this.anchors.length&&(b=!0):b=!1);for(var c,d=0;c=this.tabs[d];d++)b===!0||-1!==a.inArray(d,b)?a(c).addClass("ui-state-disabled").attr("aria-disabled","true"):a(c).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=b},_setupEvents:function(b){var c={click:function(a){a.preventDefault()}};b&&a.each(b.split(" "),function(a,b){c[b]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,c),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(b){var c,d=this.element.parent();"fill"===b?(c=d.height(),c-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var b=a(this),d=b.css("position");"absolute"!==d&&"fixed"!==d&&(c-=b.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){c-=a(this).outerHeight(!0)}),this.panels.each(function(){a(this).height(Math.max(0,c-a(this).innerHeight()+a(this).height()))}).css("overflow","auto")):"auto"===b&&(c=0,this.panels.each(function(){c=Math.max(c,a(this).height("").height())}).height(c))},_eventHandler:function(b){var c=this.options,d=this.active,e=a(b.currentTarget),f=e.closest("li"),g=f[0]===d[0],h=g&&c.collapsible,i=h?a():this._getPanelForTab(f),j=d.length?this._getPanelForTab(d):a(),k={oldTab:d,oldPanel:j,newTab:h?a():f,newPanel:i};b.preventDefault(),f.hasClass("ui-state-disabled")||f.hasClass("ui-tabs-loading")||this.running||g&&!c.collapsible||this._trigger("beforeActivate",b,k)===!1||(c.active=h?!1:this.tabs.index(f),this.active=g?a():f,this.xhr&&this.xhr.abort(),j.length||i.length||a.error("jQuery UI Tabs: Mismatching fragment identifier."),i.length&&this.load(this.tabs.index(f),b),this._toggle(b,k))},_toggle:function(b,c){function d(){f.running=!1,f._trigger("activate",b,c)}function e(){c.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),g.length&&f.options.show?f._show(g,f.options.show,d):(g.show(),d())}var f=this,g=c.newPanel,h=c.oldPanel;this.running=!0,h.length&&this.options.hide?this._hide(h,this.options.hide,function(){c.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),e()}):(c.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),h.hide(),e()),h.attr({"aria-expanded":"false","aria-hidden":"true"}),c.oldTab.attr("aria-selected","false"),g.length&&h.length?c.oldTab.attr("tabIndex",-1):g.length&&this.tabs.filter(function(){return 0===a(this).attr("tabIndex")}).attr("tabIndex",-1),g.attr({"aria-expanded":"true","aria-hidden":"false"}),c.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(b){var c,d=this._findActive(b);d[0]!==this.active[0]&&(d.length||(d=this.active),c=d.find(".ui-tabs-anchor")[0],this._eventHandler({target:c,currentTarget:c,preventDefault:a.noop}))},_findActive:function(b){return b===!1?a():this.tabs.eq(b)},_getIndex:function(a){return"string"==typeof a&&(a=this.anchors.index(this.anchors.filter("[href$='"+a+"']"))),a},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeUniqueId(),this.tabs.add(this.panels).each(function(){a.data(this,"ui-tabs-destroy")?a(this).remove():a(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var b=a(this),c=b.data("ui-tabs-aria-controls");c?b.attr("aria-controls",c).removeData("ui-tabs-aria-controls"):b.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(c){var d=this.options.disabled;d!==!1&&(c===b?d=!1:(c=this._getIndex(c),d=a.isArray(d)?a.map(d,function(a){return a!==c?a:null}):a.map(this.tabs,function(a,b){return b!==c?b:null})),this._setupDisabled(d))},disable:function(c){var d=this.options.disabled;if(d!==!0){if(c===b)d=!0;else{if(c=this._getIndex(c),-1!==a.inArray(c,d))return;d=a.isArray(d)?a.merge([c],d).sort():[c]}this._setupDisabled(d)}},load:function(b,c){b=this._getIndex(b);var e=this,f=this.tabs.eq(b),g=f.find(".ui-tabs-anchor"),h=this._getPanelForTab(f),i={tab:f,panel:h};d(g[0])||(this.xhr=a.ajax(this._ajaxSettings(g,c,i)),this.xhr&&"canceled"!==this.xhr.statusText&&(f.addClass("ui-tabs-loading"),h.attr("aria-busy","true"),this.xhr.success(function(a){setTimeout(function(){h.html(a),e._trigger("load",c,i)},1)}).complete(function(a,b){setTimeout(function(){"abort"===b&&e.panels.stop(!1,!0),f.removeClass("ui-tabs-loading"),h.removeAttr("aria-busy"),a===e.xhr&&delete e.xhr},1)})))},_ajaxSettings:function(b,c,d){var e=this;return{url:b.attr("href"),beforeSend:function(b,f){return e._trigger("beforeLoad",c,a.extend({jqXHR:b,ajaxSettings:f},d))}}},_getPanelForTab:function(b){var c=a(b).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+c))}})}(jQuery),function(a,b,c){"use strict";a.fn.backstretch=function(d,f){return(d===c||0===d.length)&&a.error("No images were supplied for Backstretch"),0===a(b).scrollTop()&&b.scrollTo(0,0),this.each(function(){var b=a(this),c=b.data("backstretch");if(c){if("string"==typeof d&&"function"==typeof c[d])return c[d](f),void 0;f=a.extend(c.options,f),c.destroy(!0)}c=new e(this,d,f),b.data("backstretch",c)})},a.backstretch=function(b,c){return a("body").backstretch(b,c).data("backstretch")},a.expr[":"].backstretch=function(b){return a(b).data("backstretch")!==c},a.fn.backstretch.defaults={centeredX:!0,centeredY:!0,duration:5e3,fade:0};var d={wrap:{left:0,top:0,overflow:"hidden",margin:0,padding:0,height:"100%",width:"100%",zIndex:-999999},img:{position:"absolute",display:"none",margin:0,padding:0,border:"none",width:"auto",height:"auto",maxHeight:"none",maxWidth:"none",zIndex:-999999}},e=function(c,e,g){this.options=a.extend({},a.fn.backstretch.defaults,g||{}),this.images=a.isArray(e)?e:[e],a.each(this.images,function(){a("")[0].src=this}),this.isBody=c===document.body,this.$container=a(c),this.$root=this.isBody?f?a(b):a(document):this.$container;var h=this.$container.children(".backstretch").first();if(this.$wrap=h.length?h:a('
').css(d.wrap).appendTo(this.$container),!this.isBody){var i=this.$container.css("position"),j=this.$container.css("zIndex");this.$container.css({position:"static"===i?"relative":i,zIndex:"auto"===j?0:j,background:"none"}),this.$wrap.css({zIndex:-999998})}this.$wrap.css({position:this.isBody&&f?"fixed":"absolute"}),this.index=0,this.show(this.index),a(b).on("resize.backstretch",a.proxy(this.resize,this)).on("orientationchange.backstretch",a.proxy(function(){this.isBody&&0===b.pageYOffset&&(b.scrollTo(0,1),this.resize())},this))};e.prototype={resize:function(){try{var a,c={left:0,top:0},d=this.isBody?this.$root.width():this.$root.innerWidth(),e=d,f=this.isBody?b.innerHeight?b.innerHeight:this.$root.height():this.$root.innerHeight(),g=e/this.$img.data("ratio");g>=f?(a=(g-f)/2,this.options.centeredY&&(c.top="-"+a+"px")):(g=f,e=g*this.$img.data("ratio"),a=(e-d)/2,this.options.centeredX&&(c.left="-"+a+"px")),this.$wrap.css({width:d,height:f}).find("img:not(.deleteable)").css({width:e,height:g}).css(c)}catch(h){}return this},show:function(b){if(!(Math.abs(b)>this.images.length-1)){var c=this,e=c.$wrap.find("img").addClass("deleteable"),f={relatedTarget:c.$container[0]};return c.$container.trigger(a.Event("backstretch.before",f),[c,b]),this.index=b,clearInterval(c.interval),c.$img=a("").css(d.img).bind("load",function(d){var g=this.width||a(d.target).width(),h=this.height||a(d.target).height();a(this).data("ratio",g/h),a(this).fadeIn(c.options.speed||c.options.fade,function(){e.remove(),c.paused||c.cycle(),a(["after","show"]).each(function(){c.$container.trigger(a.Event("backstretch."+this,f),[c,b])})}),c.resize()}).appendTo(c.$wrap),c.$img.attr("src",c.images[b]),c}},next:function(){return this.show(this.index1&&(clearInterval(this.interval),this.interval=setInterval(a.proxy(function(){this.paused||this.next()},this),this.options.duration)),this},destroy:function(c){a(b).off("resize.backstretch orientationchange.backstretch"),clearInterval(this.interval),c||this.$wrap.remove(),this.$container.removeData("backstretch")}};var f=function(){var a=navigator.userAgent,c=navigator.platform,d=a.match(/AppleWebKit\/([0-9]+)/),e=!!d&&d[1],f=a.match(/Fennec\/([0-9]+)/),g=!!f&&f[1],h=a.match(/Opera Mobi\/([0-9]+)/),i=!!h&&h[1],j=a.match(/MSIE ([0-9]+)/),k=!!j&&j[1];return!((c.indexOf("iPhone")>-1||c.indexOf("iPad")>-1||c.indexOf("iPod")>-1)&&e&&534>e||b.operamini&&"[object OperaMini]"==={}.toString.call(b.operamini)||h&&7458>i||a.indexOf("Android")>-1&&e&&533>e||g&&6>g||"palmGetResource"in b&&e&&534>e||a.indexOf("MeeGo")>-1&&a.indexOf("NokiaBrowser/8.5.0")>-1||k&&6>=k)}()}(jQuery,window),!function(a){"use strict";a.fn.smack=function(b){b=a.extend({},{edge:"bottom"},b),b=a.extend({},{threshold:"top"===b.edge?0:1,deferred:new a.Deferred},b);var c=a(this),d=c.data("bum-smack")||{};return d[b.edge]=b,d.scrollTop=c.scrollTop(),c.data("bum-smack",d),c.off("scroll.smack").on("scroll.smack",function(){var b,e,f,g,h=c.scrollTop(),i=c[0]===window?c.height():c.innerHeight(),j=c[0]===window?a(document).height():c[0].scrollHeight,k=h>d.scrollTop?"down":h=g&&(d.bottom.deferred.resolve(),d.bottom=!1,c.data("bum-smack",d))),"up"===k&&d.top&&(e=-1!==d.top.threshold.toString().toLowerCase().indexOf("px"),f=e?parseInt(d.top.threshold,10):Math.floor(j*d.top.threshold),f>=h&&(d.top.deferred.resolve(),d.top=!1,c.data("bum-smack",d))),d.top||d.bottom||c.off("scroll.smack")}),b.deferred.promise()}}(window.jQuery),function($,undefined){$.extend({jsonRPC:{version:"2.0",endPoint:null,namespace:null,setup:function(a){return this._validateConfigParams(a),this.endPoint=a.endPoint,this.namespace=a.namespace,this.cache=a.cache!==undefined?cache:!0,this},withOptions:function(a,b){if(this._validateConfigParams(a),b===undefined)throw"No callback specified";origParams={endPoint:this.endPoint,namespace:this.namespace},this.setup(a),b.call(this),this.setup(origParams)},request:function(a,b){return b===undefined&&(b={id:1}),b.id===undefined&&(b.id=1),b.cache===undefined&&(b.cache=this.cache),this._validateRequestMethod(a),this._validateRequestParams(b.params),this._validateRequestCallbacks(b.success,b.error),this._doRequest(JSON.stringify(this._requestDataObj(a,b.params,b.id)),b),!0},batchRequest:function(a,b){if(b===undefined&&(b={}),!$.isArray(a)||0===a.length)throw"Invalid requests supplied for jsonRPC batchRequest. Must be an array object that contain at least a method attribute";var c=this;$.each(a,function(a,b){c._validateRequestMethod(b.method),c._validateRequestParams(b.params),b.id===undefined&&(b.id=a+1)}),this._validateRequestCallbacks(b.success,b.error);for(var d,e=[],f=0;f0&&"2.0"!==json[0].jsonrpc||!$.isArray(json)&&"2.0"!==json.jsonrpc)throw"Version error";return json}catch(e){return{error:"Internal server error: "+e,version:"2.0"}}}}})}(jQuery),function(a,b,c,d){var e=a(b);a.fn.lazyload=function(c){function f(){var b=0;h.each(function(){var c=a(this);if(!(i.skip_invisible&&!c.is(":visible")||a.abovethetop(this,i)||a.leftofbegin(this,i)))if(a.belowthefold(this,i)||a.rightoffold(this,i)){if(++b>i.failure_limit)return!1}else c.trigger("appear"),b=0})}var g,h=this,i={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!0,appear:null,load:null};return c&&(d!==c.failurelimit&&(c.failure_limit=c.failurelimit,delete c.failurelimit),d!==c.effectspeed&&(c.effect_speed=c.effectspeed,delete c.effectspeed),a.extend(i,c)),g=i.container===d||i.container===b?e:a(i.container),0===i.event.indexOf("scroll")&&g.bind(i.event,function(){return f()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,c.one("appear",function(){if(!this.loaded){if(i.appear){var d=h.length;i.appear.call(b,d,i)}a("").bind("load",function(){c.hide().attr("src",c.data(i.data_attribute))[i.effect](i.effect_speed),b.loaded=!0;var d=a.grep(h,function(a){return!a.loaded});if(h=a(d),i.load){var e=h.length;i.load.call(b,e,i)}}).attr("src",c.data(i.data_attribute))}}),0!==i.event.indexOf("scroll")&&c.bind(i.event,function(){b.loaded||c.trigger("appear")})}),e.bind("resize",function(){f()}),/iphone|ipod|ipad.*os 5/gi.test(navigator.appVersion)&&e.bind("pageshow",function(b){b.originalEvent.persisted&&h.each(function(){a(this).trigger("appear")})}),a(b).load(function(){f()}),this},a.belowthefold=function(c,f){var g;return g=f.container===d||f.container===b?e.height()+e.scrollTop():a(f.container).offset().top+a(f.container).height(),g<=a(c).offset().top-f.threshold},a.rightoffold=function(c,f){var g;return g=f.container===d||f.container===b?e.width()+e.scrollLeft():a(f.container).offset().left+a(f.container).width(),g<=a(c).offset().left-f.threshold},a.abovethetop=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollTop():a(f.container).offset().top,g>=a(c).offset().top+f.threshold+a(c).height()},a.leftofbegin=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollLeft():a(f.container).offset().left,g>=a(c).offset().left+f.threshold+a(c).width()},a.inviewport=function(b,c){return!(a.rightoffold(b,c)||a.leftofbegin(b,c)||a.belowthefold(b,c)||a.abovethetop(b,c))},a.extend(a.expr[":"],{"below-the-fold":function(b){return a.belowthefold(b,{threshold:0})},"above-the-top":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-screen":function(b){return a.rightoffold(b,{threshold:0})},"left-of-screen":function(b){return!a.rightoffold(b,{threshold:0})},"in-viewport":function(b){return a.inviewport(b,{threshold:0})},"above-the-fold":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-fold":function(b){return a.rightoffold(b,{threshold:0})},"left-of-fold":function(b){return!a.rightoffold(b,{threshold:0})}})}(jQuery,window,document),function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var e,f=b||window.event,g=[].slice.call(arguments,1),h=0,i=0,j=0,k=0,l=0;return b=a.event.fix(f),b.type="mousewheel",f.wheelDelta&&(h=f.wheelDelta),f.detail&&(h=-1*f.detail),f.deltaY&&(j=-1*f.deltaY,h=j),f.deltaX&&(i=f.deltaX,h=-1*i),void 0!==f.wheelDeltaY&&(j=f.wheelDeltaY),void 0!==f.wheelDeltaX&&(i=-1*f.wheelDeltaX),k=Math.abs(h),(!c||c>k)&&(c=k),l=Math.max(Math.abs(j),Math.abs(i)),(!d||d>l)&&(d=l),e=h>0?"floor":"ceil",h=Math[e](h/c),i=Math[e](i/d),j=Math[e](j/d),g.unshift(b,h,i,j),(a.event.dispatch||a.event.handle).apply(this,g)}var c,d,e=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],f="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"];if(a.event.fixHooks)for(var g=e.length;g;)a.event.fixHooks[e[--g]]=a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=f.length;a;)this.addEventListener(f[--a],b,!1);else this.onmousewheel=b},teardown:function(){if(this.removeEventListener)for(var a=f.length;a;)this.removeEventListener(f[--a],b,!1);else this.onmousewheel=null}},a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}),function(a){"use strict";"object"==typeof exports?a(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){"use strict";var b={},c=0;a.fn.once=function(d,e){"string"!=typeof d&&(d in b||(b[d]=++c),e||(e=d),d="jquery-once-"+b[d]);var f=d+"-processed",g=this.not("."+f).addClass(f);return a.isFunction(e)?g.each(e):g},a.fn.removeOnce=function(b,c){var d=b+"-processed",e=this.filter("."+d).removeClass(d);return a.isFunction(c)?e.each(c):e}}),function(a){function b(a){return"object"==typeof a?a:{top:a,left:a}}var c=a.scrollTo=function(b,c,d){a(window).scrollTo(b,c,d)};c.defaults={axis:"xy",duration:parseFloat(a.fn.jquery)>=1.3?0:1,limit:!0},c.window=function(){return a(window)._scrollable()},a.fn._scrollable=function(){return this.map(function(){var b=this,c=!b.nodeName||-1!=a.inArray(b.nodeName.toLowerCase(),["iframe","#document","html","body"]);if(!c)return b;var d=(b.contentWindow||b).document||b.ownerDocument||b;return/webkit/i.test(navigator.userAgent)||"BackCompat"==d.compatMode?d.body:d.documentElement})},a.fn.scrollTo=function(d,e,f){return"object"==typeof e&&(f=e,e=0),"function"==typeof f&&(f={onAfter:f}),"max"==d&&(d=9e9),f=a.extend({},c.defaults,f),e=e||f.duration,f.queue=f.queue&&f.axis.length>1,f.queue&&(e/=2),f.offset=b(f.offset),f.over=b(f.over),this._scrollable().each(function(){function g(a){j.animate(l,e,f.easing,a&&function(){a.call(this,k,f)})}if(null!=d){var h,i=this,j=a(i),k=d,l={},m=j.is("html,body");switch(typeof k){case"number":case"string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(k)){k=b(k);break}if(k=a(k,this),!k.length)return;case"object":(k.is||k.style)&&(h=(k=a(k)).offset())}a.each(f.axis.split(""),function(a,b){var d="x"==b?"Left":"Top",e=d.toLowerCase(),n="scroll"+d,o=i[n],p=c.max(i,b);if(h)l[n]=h[e]+(m?0:o-j.offset()[e]),f.margin&&(l[n]-=parseInt(k.css("margin"+d))||0,l[n]-=parseInt(k.css("border"+d+"Width"))||0),l[n]+=f.offset[e]||0,f.over[e]&&(l[n]+=k["x"==b?"width":"height"]()*f.over[e]);else{var q=k[e];l[n]=q.slice&&"%"==q.slice(-1)?parseFloat(q)/100*p:q}f.limit&&/^\d+$/.test(l[n])&&(l[n]=l[n]<=0?0:Math.min(l[n],p)),!a&&f.queue&&(o!=l[n]&&g(f.onAfterFirst),delete l[n])}),g(f.onAfter)}}).end()},c.max=function(b,c){var d="x"==c?"Width":"Height",e="scroll"+d;if(!a(b).is("html,body"))return b[e]-a(b)[d.toLowerCase()]();var f="client"+d,g=b.ownerDocument.documentElement,h=b.ownerDocument.body;return Math.max(g[e],h[e])-Math.min(g[f],h[f])}}(jQuery),function(a,b){var c,d;if("localStorage"in window)try{d="undefined"==typeof window.localStorage?b:window.localStorage,c="undefined"==typeof d||"undefined"==typeof window.JSON?!1:!0}catch(e){c=!1}a.totalStorage=function(b,c){return a.totalStorage.impl.init(b,c)},a.totalStorage.setItem=function(b,c){return a.totalStorage.impl.setItem(b,c)},a.totalStorage.getItem=function(b){return a.totalStorage.impl.getItem(b)},a.totalStorage.getAll=function(){return a.totalStorage.impl.getAll()},a.totalStorage.deleteItem=function(b){return a.totalStorage.impl.deleteItem(b)},a.totalStorage.impl={init:function(a,b){return"undefined"!=typeof b?this.setItem(a,b):this.getItem(a)},setItem:function(b,e){if(!c)try{return a.cookie(b,e),e}catch(f){console.log("Local Storage not supported by this browser. Install the cookie plugin on your site to take advantage of the same functionality. You can get it at https://github.com/carhartl/jquery-cookie")}var g=JSON.stringify(e);return d.setItem(b,g),this.parseResult(g)},getItem:function(b){if(!c)try{return this.parseResult(a.cookie(b))}catch(e){return null}return b=d.getItem(b),this.parseResult(b)},deleteItem:function(b){if(!c)try{return a.cookie(b,null),!0}catch(e){return!1}return d.removeItem(b),!0},getAll:function(){var b=[];if(c)for(var e in d)e.length&&b.push({key:e,value:this.parseResult(d.getItem(e))});else try{var f=document.cookie.split(";");for(e=0;ee;e++)z[e]()}}function b(a){E?a():z[z.length]=a}function c(a){if(typeof w.addEventListener!=q)w.addEventListener("load",a,!1);else if(typeof x.addEventListener!=q)x.addEventListener("load",a,!1);else if(typeof w.attachEvent!=q)w.attachEvent("onload",a);else if("function"==typeof w.onload){var b=w.onload;w.onload=function(){b(),a()}}else w.onload=a}function d(){for(var a=A.length,b=0;a>b;b++){var c=A[b].id;if(G.pv[0]>0){var d=l(c);d&&(A[b].width=d.getAttribute("width")?d.getAttribute("width"):"0",A[b].height=d.getAttribute("height")?d.getAttribute("height"):"0",n(A[b].swfVersion)?(G.webkit&&G.webkit<312&&e(d),p(c,!0)):A[b].expressInstall&&!F&&n("6.0.65")&&(G.win||G.mac)?g(A[b]):h(d))}else p(c,!0)}}function e(a){var b=a.getElementsByTagName(r)[0];if(b){var c=m("embed"),d=b.attributes;if(d)for(var e=d.length,f=0;e>f;f++)"data"==d[f].nodeName.toLowerCase()?c.setAttribute("src",d[f].nodeValue):c.setAttribute(d[f].nodeName,d[f].nodeValue);var g=b.childNodes;if(g)for(var h=g.length,i=0;h>i;i++)1==g[i].nodeType&&"param"==g[i].nodeName.toLowerCase()&&c.setAttribute(g[i].getAttribute("name"),g[i].getAttribute("value"));a.parentNode.replaceChild(c,a)}}function f(a){G.ie&&G.win&&n("8.0.0")&&w.attachEvent("onunload",function(){var b=l(a);if(b){for(var c in b)"function"==typeof b[c]&&(b[c]=function(){});b.parentNode.removeChild(b)}})}function g(a){F=!0;var b=l(a.id);if(b){if(a.altContentId){var c=l(a.altContentId);c&&(C=c,D=a.altContentId)}else C=i(b);!/%$/.test(a.width)&&parseInt(a.width,10)<310&&(a.width="310"),!/%$/.test(a.height)&&parseInt(a.height,10)<137&&(a.height="137"),x.title=x.title.slice(0,47)+" - Flash Player Installation";var d=G.ie&&G.win?"ActiveX":"PlugIn",e=x.title,f="MMredirectURL="+w.location+"&MMplayerType="+d+"&MMdoctitle="+e,g=a.id;if(G.ie&&G.win&&4!=b.readyState){var h=m("div");g+="SWFObjectNew",h.setAttribute("id",g),b.parentNode.insertBefore(h,b),b.style.display="none",w.attachEvent("onload",function(){b.parentNode.removeChild(b)})}j({data:a.expressInstall,id:v,width:a.width,height:a.height},{flashvars:f},g)}}function h(a){if(G.ie&&G.win&&4!=a.readyState){var b=m("div");a.parentNode.insertBefore(b,a),b.parentNode.replaceChild(i(a),b),a.style.display="none",w.attachEvent("onload",function(){a.parentNode.removeChild(a)})}else a.parentNode.replaceChild(i(a),a)}function i(a){var b=m("div");if(G.win&&G.ie)b.innerHTML=a.innerHTML;else{var c=a.getElementsByTagName(r)[0];if(c){var d=c.childNodes;if(d)for(var e=d.length,f=0;e>f;f++)1==d[f].nodeType&&"param"==d[f].nodeName.toLowerCase()||8==d[f].nodeType||b.appendChild(d[f].cloneNode(!0))}}return b}function j(a,b,c){var d,e=l(c);if(typeof a.id==q&&(a.id=c),G.ie&&G.win){var g="";for(var h in a)a[h]!=Object.prototype[h]&&("data"==h?b.movie=a[h]:"styleclass"==h.toLowerCase()?g+=' class="'+a[h]+'"':"classid"!=h&&(g+=" "+h+'="'+a[h]+'"'));var i="";for(var j in b)b[j]!=Object.prototype[j]&&(i+='');e.outerHTML='"+i+"",f(a.id),d=l(a.id)}else if(G.webkit&&G.webkit<312){var n=m("embed");n.setAttribute("type",u);for(var o in a)a[o]!=Object.prototype[o]&&("data"==o?n.setAttribute("src",a[o]):"styleclass"==o.toLowerCase()?n.setAttribute("class",a[o]):"classid"!=o&&n.setAttribute(o,a[o]));for(var p in b)b[p]!=Object.prototype[p]&&"movie"!=p&&n.setAttribute(p,b[p]);e.parentNode.replaceChild(n,e),d=n}else{var s=m(r);s.setAttribute("type",u);for(var t in a)a[t]!=Object.prototype[t]&&("styleclass"==t.toLowerCase()?s.setAttribute("class",a[t]):"classid"!=t&&s.setAttribute(t,a[t]));for(var v in b)b[v]!=Object.prototype[v]&&"movie"!=v&&k(s,v,b[v]);e.parentNode.replaceChild(s,e),d=s}return d}function k(a,b,c){var d=m("param");d.setAttribute("name",b),d.setAttribute("value",c),a.appendChild(d)}function l(a){return x.getElementById(a)}function m(a){return x.createElement(a)}function n(a){var b=G.pv,c=a.split(".");return c[0]=parseInt(c[0],10),c[1]=parseInt(c[1],10),c[2]=parseInt(c[2],10),b[0]>c[0]||b[0]==c[0]&&b[1]>c[1]||b[0]==c[0]&&b[1]==c[1]&&b[2]>=c[2]?!0:!1}function o(a,b){if(!G.ie||!G.mac){var c=x.getElementsByTagName("head")[0],d=m("style");if(d.setAttribute("type","text/css"),d.setAttribute("media","screen"),G.ie&&G.win||typeof x.createTextNode==q||d.appendChild(x.createTextNode(a+" {"+b+"}")),c.appendChild(d),G.ie&&G.win&&typeof x.styleSheets!=q&&x.styleSheets.length>0){var e=x.styleSheets[x.styleSheets.length-1];typeof e.addRule==r&&e.addRule(a,b)}}}function p(a,b){var c=b?"visible":"hidden";E?l(a).style.visibility=c:o("#"+a,"visibility:"+c)}{var q="undefined",r="object",s="Shockwave Flash",t="ShockwaveFlash.ShockwaveFlash",u="application/x-shockwave-flash",v="SWFObjectExprInst",w=window,x=document,y=navigator,z=[],A=[],B=null,C=null,D=null,E=!1,F=!1,G=function(){var a=typeof x.getElementById!=q&&typeof x.getElementsByTagName!=q&&typeof x.createElement!=q&&typeof x.appendChild!=q&&typeof x.replaceChild!=q&&typeof x.removeChild!=q&&typeof x.cloneNode!=q,b=[0,0,0],c=null;if(typeof y.plugins!=q&&typeof y.plugins[s]==r)c=y.plugins[s].description,c&&(c=c.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),b[0]=parseInt(c.replace(/^(.*)\..*$/,"$1"),10),b[1]=parseInt(c.replace(/^.*\.(.*)\s.*$/,"$1"),10),b[2]=/r/.test(c)?parseInt(c.replace(/^.*r(.*)$/,"$1"),10):0);else if(typeof w.ActiveXObject!=q){var d=null,e=!1;try{d=new ActiveXObject(t+".7")}catch(f){try{d=new ActiveXObject(t+".6"),b=[6,0,21],d.AllowScriptAccess="always"}catch(f){6==b[0]&&(e=!0)}if(!e)try{d=new ActiveXObject(t)}catch(f){}}if(!e&&d)try{c=d.GetVariable("$version"),c&&(c=c.split(" ")[1].split(","),b=[parseInt(c[0],10),parseInt(c[1],10),parseInt(c[2],10)])}catch(f){}}var g=y.userAgent.toLowerCase(),h=y.platform.toLowerCase(),i=/webkit/.test(g)?parseFloat(g.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,j=!1,k=h?/win/.test(h):/win/.test(g),l=h?/mac/.test(h):/mac/.test(g);return{w3cdom:a,pv:b,webkit:i,ie:j,win:k,mac:l}}();!function(){if(G.w3cdom){if(b(d),G.ie&&G.win)try{x.write("");var e=l("__ie_ondomload");e&&(e.onreadystatechange=function(){"complete"==this.readyState&&(this.parentNode.removeChild(this),a())})}catch(f){}G.webkit&&typeof x.readyState!=q&&(B=setInterval(function(){/loaded|complete/.test(x.readyState)&&a()},10)),typeof x.addEventListener!=q&&x.addEventListener("DOMContentLoaded",a,null),c(a)}}()}return{registerObject:function(a,b,c){if(G.w3cdom&&a&&b){var d={};d.id=a,d.swfVersion=b,d.expressInstall=c?c:!1,A[A.length]=d,p(a,!1)}},getObjectById:function(a){var b=null;if(G.w3cdom&&E){var c=l(a);if(c){var d=c.getElementsByTagName(r)[0];!d||d&&typeof c.SetVariable!=q?b=c:typeof d.SetVariable!=q&&(b=d)}}return b},embedSWF:function(a,c,d,e,f,h,i,k,l){if(G.w3cdom&&a&&c&&d&&e&&f)if(d+="",e+="",n(f)){p(c,!1);var m=typeof l==r?l:{};m.data=a,m.width=d,m.height=e;var o=typeof k==r?k:{};if(typeof i==r)for(var s in i)i[s]!=Object.prototype[s]&&(typeof o.flashvars!=q?o.flashvars+="&"+s+"="+i[s]:o.flashvars=s+"="+i[s]);b(function(){j(m,o,c),m.id==c&&p(c,!0)})}else h&&!F&&n("6.0.65")&&(G.win||G.mac)&&(p(c,!1),b(function(){var a={};a.id=a.altContentId=c,a.width=d,a.height=e,a.expressInstall=h,g(a)}))},getFlashPlayerVersion:function(){return{major:G.pv[0],minor:G.pv[1],release:G.pv[2]}},hasFlashPlayerVersion:n,createSWF:function(a,b,c){return G.w3cdom&&E?j(a,b,c):void 0},createCSS:function(a,b){G.w3cdom&&o(a,b)},addDomLoadEvent:b,addLoadEvent:c,getQueryParamValue:function(a){var b=x.location.search||x.location.hash;if(null==a)return b;if(b)for(var c=b.substring(1).split("&"),d=0;d0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},app.helpers.aphabeticalSort=function(a,b){var c=a.toLowerCase(),d=b.toLowerCase();return d>c?-1:c>d?1:0},app.helpers.isInt=function(a){return app.helpers.exists(a)?parseFloat(a)==parseInt(a)&&!isNaN(a):!1},app.helpers.getRandomInt=function(a,b){return Math.floor(Math.random()*(b-a+1))+a},app.helpers.secToTime=function(a){var b=parseInt(a/3600)%24,c=parseInt(a/60)%60,d=a%60;return(b>0?b+":":"")+(c>0?(b>0&&10>c?"0"+c:c)+":":b>0?"00:":"")+(10>d?"0"+d:d)},app.helpers.exists=function(a){return"undefined"!=typeof a},app.helpers.rating=function(a){return Math.round(10*a)/10},app.helpers.buildUrls=function(a,b,c){return $.each(a,function(d,e){a[d].url=app.helpers.buildUrl(b,e[c])}),a},app.helpers.buildUrl=function(a,b){return"song"==a||"file"==a?"#":"#"+a+"/"+b},app.helpers.setFirstSidebarContent=function(a,b){b="undefined"!=typeof b&&b===!0;var c=app.helpers.getFirstSidebarContent();b?c.append(a):c.html(a),app.helpers.firstSidebarBinds()},app.helpers.getFirstSidebarContent=function(){app.helpers.toggleSidebar("open");var a=$(app.helpers.getSelector("sidebar1"));return $(".sidebar-content",a)},app.helpers.firstSidebarBinds=function(){var a=app.helpers.getFirstSidebarContent();app.helpers.toggleSidebar("open"),$("img.lazy").lazyload({effect:"fadeIn",container:a}),a.trigger("scroll")},app.helpers.toggleSidebar=function(a){var b="sidebar",c="no-sidebar",d=$("body");void 0===a?d.toggleClass(b).toggleClass(c):("open"==a&&d.addClass(b).removeClass(c),"close"==a&&d.addClass(c).removeClass(b))},app.helpers.getDefaultImage=function(){var a=["wallpaper-443657.jpg","wallpaper-45040.jpg","wallpaper-765190.jpg","wallpaper-84050.jpg"],b=a[app.helpers.getRandomInt(0,a.length-1)];return"theme/images/fanart_default/"+b},app.helpers.isDefaultImage=function(a){return app.helpers.varGet("defaultImage")==a},app.helpers.addFreewall=function(a){var b=new freewall(a);b.reset({selector:"li",animate:!0,cellW:170,cellH:"230",onResize:function(){b.fitWidth()}}),b.fitWidth()},app.helpers.addPosterFreewall=function(a){var b=new freewall(a);b.reset({selector:"li",animate:!0,cellW:170,cellH:"305",onResize:function(){b.fitWidth()}}),b.fitWidth()},app.helpers.triggerContentLazy=function(){$("img.lazy").lazyload({threshold:200}),$(window).trigger("scroll")},app.helpers.getSongKey=function(a){var b={type:"file"==a.songid||"undefined"==typeof a.songid?"file":"songid"};return b.id="file"==b.type?a.file:a.songid,b},app.helpers.parseArtistsArray=function(a){var b,c=[];for(var d in a.artist)b=void 0!==a.artistid?''+a.artist[d]+"":a.artist[d],c.push(b);return c.join(", ")},app.helpers.parseArtistSummary=function(a){var b={songs:0,albums:0,time:0};for(var c in a.models){b.albums++;for(var d in a.models[c].attributes.songs)b.songs++,b.time=b.time+parseInt(a.models[c].attributes.songs[d].attributes.duration)}var e=[];return e.push(b.songs+" Songs"),e.push(b.albums+" Albums"),e.push(Math.floor(b.time/60)+" Mins"),e.join("
")},app.helpers.createPaginationRange=function(a,b){var c=void 0!==a?parseInt(a):0,d=c*app.itemsPerPage,e=d+app.itemsPerPage;return b&&b===!0&&(d=0),{end:e,start:d}},app.helpers.applyBackstretch=function(a,b){if("#"==location.hash||""===location.hash&&app.audioStreaming.getPlayer()==b){var c=$(".backstretch img"),d=c.attr("src"),e=app.parseImage(a,"fanart");c.length>0&&d!=e&&$.backstretch(e)}},app.helpers.setTitle=function(a,b){var c={addATag:!1,tabs:!1,activeTab:0},d=$.extend(c,b),e=$("#title");e.empty(),d.addATag&&e.append($(''+a+""));var f=0;if(d.tabs!==!1){var g=$('');for(var h in d.tabs){var i=$(''+d.tabs[h]+"");g.append(i),f++}e.append(g)}d.addATag||e.append('
'+a+"
"),app.currentPageTitle=a},app.helpers.getTitle=function(){return app.currentPageTitle},app.helpers.dialogInit=function(a){var b={autoOpen:!1,height:"auto",width:350,modal:!0,resizable:!1};b=jQuery.extend(b,a),$(app.helpers.getSelector("dialog")).dialog(b)},app.helpers.dialog=function(a,b){var c=$(app.helpers.getSelector("dialog"));c.hasClass("ui-dialog-content")||app.helpers.dialogInit(),c.dialog("option","title"," "),c.dialog("option","height","auto"),c.dialog("option","buttons",{}),c.html(a),c.dialog("option",b),c.bind("dialogopen",function(){$(".ui-widget-overlay, .ui-dialog").css("position","fixed"),$(".dialog-menu a:last").addClass("last"),c.keypress(function(a){if(a.keyCode==$.ui.keyCode.ENTER){var b=$(this).parent(),c=b.find(".bind-enter"),d=0===c.length?b.find(".ui-dialog-buttonpane button:first"):c;d.trigger("click")}})}),c.dialog("open")},app.helpers.dialogClose=function(){$(app.helpers.getSelector("dialog")).dialog("close")},app.helpers.confirm=function(a,b){var c={title:"Are you sure?",buttons:{OK:function(){b(),$(this).dialog("close")},Cancel:function(){$(this).dialog("close")}}};app.helpers.dialog(a,c)},app.helpers.prompt=function(a,b){var c={title:"Prompt",buttons:{OK:function(){var a=$("#promptText").val();""!==a&&(b(a),$(this).dialog("close"))},Cancel:function(){$(this).dialog("close")}}};a+='
',app.helpers.dialog(a,c)},app.helpers.aboutDialog=function(){var a={title:"About this thing",buttons:{"Cool!":function(){$(this).dialog("close")},ChangeLog:function(){document.location="#xbmc/changelog",$(this).dialog("close")}}};app.helpers.applyTemplate("About",app.addonData,function(b){app.helpers.dialog(b,a)})},app.helpers.menuDialog=function(a){var b=$('
    '),c=$('
  • '),d={};$.each(a.items,function(a,e){d=c.clone(),d.html(e.title).addClass(e.class),d.on("click",function(){app.helpers.dialogClose(),e.callback&&e.callback()}),b.append(d)}),app.helpers.dialog(b,{title:a.title})},app.helpers.makeDropdown=function(a){var b={key:"untitled",items:[],pull:"left",omitwrapper:!1},c="",d=$.extend(b,a);d.omitwrapper||(c+='
    '),c+='',c+='",d.omitwrapper||(c+="
    "),c},app.helpers.menuTemplates=function(a,b){var c={};switch(a){case"song":c={title:void 0!==b.label&&""!==b.label?b.label:""!==b.album?b.album:"",key:"song",omitwrapper:!0,items:[{url:"#","class":"song-download",title:"Download song",callback:function(){app.AudioController.downloadFile(b.file,function(a){window.location=a})}},{url:"#","class":"song-custom-playlist",title:"Add to custom playlist",callback:function(){b.songid&&app.playlists.playlistAddItems("lists","new","song",b.songid)}},{url:"#","class":"song-browser-play",title:"Play in browser",callback:function(){b.songid&&app.playlists.playlistAddItems("local","replace","song",b.songid)}}]};break;case"album":c={title:""!==b.album?b.album:b.label,key:"album",omitwrapper:!0,items:[{url:"#","class":"album-add-xbmc",title:"Add to XBMC",callback:function(){app.playlists.playlistAddItems("xbmc","append","album",b.albumid)}},{url:"#","class":"album-add-local",title:"Play in browser",callback:function(){app.playlists.playlistAddItems("local","replace","album",b.albumid)}},{url:"#","class":"album-add-lists",title:"Save to lists",callback:function(){app.playlists.playlistAddItems("lists","new","album",b.albumid)}}]};break;case"artist":c={title:b.label,key:"artist",omitwrapper:!0,items:[{url:"#","class":"artist-add-xbmc",title:"Add to XBMC",callback:function(){app.playlists.playlistAddItems("xbmc","append","artist",b.artistid)}},{url:"#","class":"artist-add-local",title:"Play in browser",callback:function(){app.playlists.playlistAddItems("local","replace","artist",b.artistid)}},{url:"#","class":"artist-add-lists",title:"Save to lists",callback:function(){app.playlists.playlistAddItems("lists","new","artist",b.artistid)}}]};break;case"movie":c={title:b.label,key:"movie",omitwrapper:!0,items:[{url:"#","class":"movie-download",title:"Download Movie",callback:function(){app.AudioController.downloadFile(b.file,function(a){window.location=a})}}]};break;case"playlistShell":c={key:"playlist",pull:"right",items:[{url:"#","class":"save-playlist",title:"Save XBMC Playlist"},{url:"#","class":"clear-playlist",title:"Clear Playlist"},{url:"#","class":"refresh-playlist",title:"Refresh Playlist"},{url:"#","class":"new-custom-playlist",title:"New Browser Playlist"}]}}return c},app.helpers.loadTemplates=function(a,b){var c=[];$.each(a,function(a,b){app[b]?c.push($.get("tpl/"+b+".html",function(a){app[b].prototype.template=_.template(a)},"html")):alert(b+" not found")}),$.when.apply(null,c).done(b)},app.helpers.loadTemplate=function(a,b){$.get("tpl/"+a+".html",function(c){app.tpl[a]=c,b&&b(app.tpl[a])})},app.helpers.applyTemplate=function(a,b,c){var d="";"undefined"!=typeof app.tpl[a]?(d=_.template(app.tpl[a],b),c(d)):app.helpers.loadTemplate(a,function(a){d=_.template(a,b),c(d)})},app.helpers.nearbottom=function(){var a=$(window),b=0+$(document).height()-a.scrollTop()-a.height(),c=600;return c>b},app.parseImage=function(a,b){return b="undefined"==typeof b?"default":b,"space"==b?"theme/images/space.png":void 0===a||""===a?"fanart"==b?app.helpers.getDefaultImage(b):app.helpers.varGet("defaultImage"):"/image/"+encodeURIComponent(a)},app.nl2br=function(a,b){var c=b||"undefined"==typeof b?"
    ":"
    ";return(a+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+c+"$2")},app.notification=function(a){var b=$("#notify");a!==!1&&""!==a&&(b.find(".content").html(a),b.removeClass("hidden").parent().removeClass("hidden"),clearTimeout(notificationTimoutObj),notificationTimoutObj=setTimeout(app.notificationHide,6e3))},app.notificationHide=function(){$notify=$("#notify").addClass("hidden").parent().addClass("hidden")},app.helpers.addScrollBar=function(a,b){scrollbarSettings={cursorwidth:8,cursorminheight:37,touchbehavior:!1,cursorcolor:"#606768"},settings=$.extend(scrollbarSettings,b)},app.storage={nameSpace:"chorus::",set:function(a,b){$.totalStorage(this.nameSpace+a,b)},get:function(a,b){var c=$.totalStorage(this.nameSpace+a);return void 0!==c&&""!==c?c:b}}}),function(a){$.fn.attr=function(){if(0===arguments.length){if(0===this.length)return null;var b={};return $.each(this[0].attributes,function(){this.specified&&(b[this.name]=this.value)}),b}return a.apply(this,arguments)}}($.fn.attr);var app={views:{},models:{},cached:{},counts:{503:0,"503total":0},state:"notconnected",jsonRpcUrl:"/jsonrpc",itemsPerPage:50,nextPageLoading:!1,vars:{lastHash:"#",defaultImage:"theme/images/default.png"},artistFields:["instrument","style","mood","born","formed","description","genre","died","disbanded","yearsactive","musicbrainzartistid","fanart","thumbnail"],albumFields:["title","description","artist","genre","theme","mood","style","type","albumlabel","rating","year","fanart","thumbnail","playcount","genreid","artistid","displayartist"],songFields:["title","artist","albumartist","genre","year","rating","album","track","duration","playcount","fanart","thumbnail","file","albumid","lastplayed","disc","genreid","artistid","displayartist","albumartistid"],movieFields:["title","genre","year","rating","director","trailer","tagline","plot","plotoutline","originaltitle","lastplayed","playcount","writer","studio","mpaa","cast","country","imdbnumber","runtime","set","showlink","streamdetails","top250","votes","fanart","thumbnail","file","sorttitle","resume","setid","dateadded","tag","art"],fileFields:["title","size","mimetype","file","dateadded","thumbnail","artistid","albumid","uniqueid"],albumFilters:[],songFilters:[],templates:["HomeView","ContactView","ShellView","ArtistView","ArtistSummaryView","ArtistListItemView","ArtistsView","AlbumView","AlbumItemView","SongView","AristsRandView","ArtistLargeItemView","AlbumItemSmallView","AlbumArtistView","PlaylistItemView","PlaylistCustomListItemView","CustomPlaylistSongView","FilesView","FileView","MovieListItemView","MovieView"],tpl:{}};app.Router=Backbone.Router.extend({routes:{"":"home",contact:"contact","artist/:id":"artist","artist/:id/:task":"artist",artists:"artists","album/:id":"album",albums:"albums","playlist/:id":"playlist","search/:q":"search","scan/:type":"scan",thumbsup:"thumbsup",files:"files","movies/page/:num":"movies","movies/genre/:genre":"moviesGenre",movies:"moviesLanding","movie/:id":"movie","xbmc/:op":"xbmc"},initialize:function(){app.shellView=new app.ShellView,$("body").html(app.shellView.render().el),$(window).trigger("shellReady"),this.$content=$("#content")},home:function(){var a="";this.$content.html(""),app.helpers.setTitle(""),app.shellView.selectMenuItem("home","no-sidebar"),app.AudioController.getNowPlayingSong(function(b){if("local"==app.audioStreaming.getPlayer()){var c=app.audioStreaming.getNowPlayingSong();a=void 0===c.fanart?"":c.fanart}else a=void 0===b.item.fanart?"":b.item.fanart;if(0===$(".backstretch").length){var d=app.parseImage(a,"fanart");$.backstretch(d)}})},search:function(a){$("#search").val(a),app.shellView.search(a)},artist:function(a,b){"undefined"==typeof b&&(b="view"),app.artistsView=new app.ArtistsView,app.artistsView.render();var c=new app.Artist({id:parseInt(a),fields:app.artistFields}),d=this;c.fetch({success:function(a){d.$content.html(new app.ArtistView({model:a}).render().el),app.helpers.setTitle('Artists'+a.attributes.artist),app.shellView.selectMenuItem("artists","sidebar")}})},artists:function(){var a=$('
    ');app.artistsView=new app.ArtistsView,a.html(app.artistsView.render().el),$("#content").html(a),app.helpers.setTitle("Artists",{addATag:"#artists"}),app.shellView.selectMenuItem("artists","sidebar")},album:function(a){var b={attributes:{albumid:a}};app.cached.albumView=new app.AlbumView({model:b,type:"album"}),0===$(".album-page").length?$("#content").html(app.cached.albumView.render().el):app.cached.albumView.render(),app.shellView.selectMenuItem("albums","sidebar")},albums:function(){app.shellView.selectMenuItem("album","no-sidebar");var a=this;$("#content").html('
    Loading Albums
    '),app.cached.recentlyAddedAlbums=new app.AlbumRecentlyAddedXbmcCollection,app.cached.recentlyAddedAlbums.fetch({success:function(b){app.cached.recentlyPlayedAlbums=new app.AlbumRecentlyPlayedXbmcCollection,app.cached.recentlyPlayedAlbums.fetch({success:function(c){var d=c.models,e={},f=$('
    ');_.each(d,function(a){e[a.attributes.albumid]=!0}),_.each(b.models,function(a){e[a.attributes.albumid]||d.push(a)}),d=app.helpers.shuffle(d),b.models=d,b.length=d.length,app.cached.recentlAlbums=b,app.cached.recentAlbumsView=new app.SmallAlbumsList({model:b,className:"album-list-landing"}),f.html(app.cached.recentAlbumsView.render().el),a.$content.html(f),app.helpers.setTitle("Recent",{addATag:"#albums"}),app.shellView.selectMenuItem("albums","no-sidebar"),app.helpers.addFreewall("ul.album-list-landing")}})}})},files:function(){app.cached.fileCollection=new app.FileCollection,app.cached.fileCollection.fetch({name:"sources",success:function(a){app.cached.fileAddonCollection=new app.FileCollection,app.cached.fileAddonCollection.fetch({name:"addons",success:function(b){app.shellView.selectMenuItem("files","sidebar"),app.cached.filesView=new app.FilesView({model:a});var c=app.cached.filesView.render().$el;app.cached.filesAddonsView=new app.FilesView({model:b}),b.length>0&&(c.append(''),c.append(app.cached.filesAddonsView.render().$el)),app.helpers.setFirstSidebarContent(c),app.helpers.setTitle('Files')}})}})},playlist:function(a){app.cached.playlistCustomListSongCollection=new app.PlaylistCustomListSongCollection,app.cached.playlistCustomListSongCollection.fetch({name:a,success:function(b){app.cached.customPlaylistSongListView=new app.CustomPlaylistSongListView({model:b}),$("#content").html(app.cached.customPlaylistSongListView.render().el);var c=app.playlists.getCustomPlaylist(a);app.helpers.setTitle(''+c.name+""),app.shellView.selectMenuItem("playlist","no-sidebar")}})},thumbsup:function(){var a=$("#content"),b=app.helpers.getFirstSidebarContent();a.html('
    '),app.helpers.setFirstSidebarContent('
    '),app.helpers.setTitle('ArtistsThumbs Up'),app.shellView.selectMenuItem("thumbsup","sidebar"),app.cached.thumbsUpCollection=new app.ThumbsUpCollection,app.cached.thumbsUpCollection.fetch({name:"song",success:function(b){app.cached.customPlaylistSongListView=new app.CustomPlaylistSongListView({model:b}),$("#tu-songs",a).html(app.cached.customPlaylistSongListView.render().el)}}),app.cached.thumbsUpCollection=new app.ThumbsUpCollection,app.cached.thumbsUpCollection.fetch({name:"artist",success:function(a){app.cached.thumbsupArtists=new app.AristsListView({model:a,className:"artist-thumbs-up"}),$("#tu-artists",b).html(app.cached.thumbsupArtists.render().el),app.helpers.firstSidebarBinds()}}),app.cached.thumbsUpCollection=new app.ThumbsUpCollection,app.cached.thumbsUpCollection.fetch({name:"album",success:function(a){app.cached.thumbsupAlbums=new app.SmallAlbumsList({model:a}),$("#tu-albums",b).html(app.cached.thumbsupAlbums.render().el).prepend(''),app.helpers.firstSidebarBinds()}})},movies:function(a){var b=$("#content"),c=$("ul.movie-list",b),d=!1,e=!1,f="page";0===c.length?(0===a&&(app.moviePageNum=0),b.html('
    Loading Movies
    '),app.helpers.setTitle("All Movies",{addATag:"#movies/page/0",tabs:{"#movies":"Recently Added"},activeTab:1}),app.shellView.selectMenuItem("movies","no-sidebar"),f&&a&&(app.moviePageNum=a,d=!0)):(app.moviePageNum++,void 0!==a&&(app.moviePageNum=a)),app.cached.movieCollection=new app.MovieCollection,app.cached.movieCollection.fetch({fullRange:d,success:function(a){if(app.cached.movieListView=new app.MovieListView({model:a}),0===app.moviePageNum||d===!0){if(b.html(app.cached.movieListView.render().$el),$(window).scrollTo(0),d===!0&&"undefined"!=typeof app.vars.backHash){var c=app.vars.backHash.split("/");"#movie"==c[0]&&($(window).scrollTo($(".movie-row-"+c[1]),0,{offset:-200}),e=!0)}d===!0&&e!==!0&&$(window).scrollTo("85%"),app.helpers.triggerContentLazy()}else{var f=$(".video-list").last();0===f.find("li").length?f.remove():(app.router.navigate("movies/page/"+app.moviePageNum),b.append(app.cached.movieListView.render().$el))}app.helpers.triggerContentLazy()}})},moviesLanding:function(){var a=this;app.helpers.setTitle("Recently Added",{addATag:"#movies",tabs:{"#movies/page/0":"Browse All"},activeTab:1}),a.$content.html('
    Loading Movies
    '),app.movieRecentCollection=new app.MovieRecentCollection,app.movieRecentCollection.fetch({success:function(b){app.cached.movieListView=new app.MovieListView({model:b}),a.$content.html(app.cached.movieListView.render().$el),a.$content.find(".next-page").remove(),a.$content.find("ul").removeClass("movie-list").addClass("movie-recent-list"),app.shellView.selectMenuItem("movies","no-sidebar"),app.helpers.triggerContentLazy(),$(window).scrollTo(0)}})},moviesGenre:function(a){console.log(a);var b=this;app.helpers.setTitle(a,{addATag:"#movies/genre/"+a,tabs:{"#movies/page/0":"Browse All","#movies":"Recent"}}),b.$content.html('
    Loading Movies
    '),app.movieFitleredCollection=new app.MovieFitleredCollection,app.movieFitleredCollection.fetch({filter:{genre:a},success:function(a){app.cached.movieListView=new app.MovieListView({model:a}),b.$content.html(app.cached.movieListView.render().$el),b.$content.find(".next-page").remove(),b.$content.find("ul").removeClass("movie-list").addClass("movie-genre-list"),app.shellView.selectMenuItem("movies","no-sidebar"),app.helpers.triggerContentLazy(),$(window).scrollTo(0)}})},movie:function(a){var b=new app.Movie({id:parseInt(a)}),c=this;c.$content.html('
    Loading Movie
    '),b.fetch({success:function(a){console.log(a),c.$content.html(new app.MovieView({model:a}).render().el),app.helpers.setTitle(a.attributes.title+" "+a.attributes.year+""),app.shellView.selectMenuItem("movie","sidebar")}})},scan:function(a){"audio"==a&&app.xbmcController.command("AudioLibrary.Scan",{},function(){app.notification("Started Audio Scan")})},xbmc:function(a){app.cached.xbmcView=new app.XbmcView({model:a}),$("#content").html(app.cached.xbmcView.render().$el),app.helpers.setTitle('XBMC'),app.shellView.selectMenuItem("xbmc","no-sidebar")}}),$(document).on("ready",function(){app.helpers.loadTemplates(app.templates,function(){app.router=new app.Router,Backbone.history.start()}),app.store.libraryCall(function(){$("body").addClass("artists-ready"),app.notification("Artists loaded")},"artistsReady"),app.store.libraryCall(function(){$("body").addClass("audio-library-ready"),app.notification("Library loaded")},"songsReady")}),app.Artist=Backbone.Model.extend({initialize:function(){},defaults:{artistid:1,thumbnail:"",fanart:"",artist:"",label:"",description:"",born:"",died:""},sync:function(a,b,c){"read"===a&&app.store.getArtist(parseInt(this.id),function(a){a.attributes.thumbsup=app.playlists.isThumbsUp("artist",a.attributes.artistid),c.success(a.attributes)})}}),app.Album=Backbone.Model.extend({initialize:function(){},defaults:{album:"",albumid:"",thumbnail:"",artist:"",artistid:"",songs:[],albumsitems:[]},sync:function(a){}}),app.Song=Backbone.Model.extend({initialize:function(){},defaults:{label:"",thumbnail:"",albumid:0,artistid:[0],type:"song",playlistId:0,url:"#",subLink:""},sync:function(a){}}),app.PlaylistItem=Backbone.Model.extend({initialize:function(){},defaults:{label:"",thumbnail:"",albumid:0,artistid:[0],songid:"file",file:"",list:"xbmc",playlistId:0,type:"file"}}),app.PlaylistCustomListItem=Backbone.Model.extend({initialize:function(){},defaults:{name:"",items:[],id:0,type:"file"}}),app.PlaylistCustomListItemSong=Backbone.Model.extend({initialize:function(){},defaults:{label:"",thumbnail:"",albumid:0,artistid:[0]}}),app.File=Backbone.Model.extend({initialize:function(){},defaults:{filetype:"",size:"",mimetype:"",file:"",lastmodified:"",id:0},sync:function(a){}}),app.Movie=Backbone.Model.extend({initialize:function(){},defaults:{movieid:1,thumbnail:"",fanart:"",year:"",url:"#movies",thumbsup:!1,libraryId:1},sync:function(a,b,c){"read"===a&&app.xbmcController.command("VideoLibrary.GetMovieDetails",[parseInt(this.id),app.movieFields],function(a){var b=a.result.moviedetails;b.thumbsup=app.playlists.getThumbsUp("movie",b.movieid),c.success(b)})}}),app.TVShow=Backbone.Model.extend({initialize:function(){},defaults:{album:"",albumid:"",thumbnail:"",artist:"",artistid:"",songs:[],albumsitems:[],url:"#tv"},sync:function(a){}}),app.TVEpisode=Backbone.Model.extend({initialize:function(){},defaults:{album:"",albumid:"",thumbnail:"",artist:"",artistid:"",songs:[],albumsitems:[],url:"#tv"},sync:function(a){}}),app.Video=Backbone.Model.extend({initialize:function(){},defaults:{album:"",albumid:"",thumbnail:"",artist:"",artistid:"",songs:[],albumsitems:[],url:"#video"},sync:function(a){}}),app.addOns={addon:{}},app.addOns.getSources=function(a){app.xbmcController.command("Addons.GetAddons",["xbmc.addon.audio","unknown","all",["name","thumbnail","enabled"]],function(b){var c=b.result.addons,d=[];for(var e in c){var f=c[e];f.enabled&&(f.file="plugin://"+f.addonid+"/",f.title=f.name,f.filetype="directory",f.id=f.addonid,d.push(f))}app.cached.addonSources=d,a&&a(d)})},app.addOns.ready=function(a){"undefined"!=typeof app.cached.addonSources?a(app.cached.addonSources):app.addOns.getSources(a)},app.addOns.getAddon=function(a){if("undefined"!=typeof app.cached.addonSources)for(var b in app.cached.addonSources){var c=app.cached.addonSources[b],d=app.addOns.slug(c);if(d==a)return c}return{}},app.addOns.invokeAll=function(a,b,c,d){if("undefined"!=typeof app.cached.addonSources)for(var e in app.cached.addonSources){var f=app.cached.addonSources[e],g=app.addOns.slug(f);b=app.addOns.invoke(g,a,b,c,d)}else app.addOns.getSources();return b},app.addOns.invoke=function(a,b,c,d,e){if("undefined"!=typeof app.addOns.addon[a]&&"function"==typeof app.addOns.addon[a][b]){var f=app.addOns.addon[a][b];c=f(c,d,e)}return c},app.addOns.slug=function(a){return a.addonid.split(".").join("")},app.addOns.addon.pluginaudiosoundcloud={waitTime:4e3,getAddon:function(){return app.addOns.getAddon("pluginaudiosoundcloud")},getSearchPath:function(){return"plugin://plugin.audio.soundcloud/SearchTracks?url=plugin%3A%2F%2Fmusic%2FSoundCloud%2Ftracks%2Fsearch&oauth_token=&mode=13"},parseFileRecord:function(a){return app.addOns.addon.pluginaudiosoundcloud.isSoundCloud(a)&&(a.file=a.file.replace("plugin://plugin.audio.soundcloud/","plugin://plugin.audio.soundcloud/"+encodeURIComponent(a.label))),a},clickDir:function(a){return app.addOns.addon.pluginaudiosoundcloud.isSoundCloud(a)&&"Search"==a.title&&(console.log(a),app.addOns.addon.pluginaudiosoundcloud.doSearchDialog()),a},postProcessFileView:function(a,b){if(app.addOns.addon.pluginaudiosoundcloud.isSoundCloud(b)){var c=app.addOns.addon.pluginaudiosoundcloud.getAddon();if(b.file==c.file){var d=$(".file-actions",a);d.html(''),$("#soundcloudSearch",d).on("click",function(a){a.stopPropagation(),app.addOns.addon.pluginaudiosoundcloud.doSearchDialog();var b=app.addOns.addon.pluginaudiosoundcloud.getSearchPath();app.cached.fileCollection=new app.FileCollection,app.cached.fileCollection.fetch({name:b,success:function(a){console.log(a),app.cached.filesSearchView=new app.FilesView({model:a}).render()}})}),a.find(".file-item").addClass("show-actions")}}return a},searchAddons:function(a,b){var c=$("
    ",{"class":"addon-box",id:"sc-search"}),d=app.addOns.addon.pluginaudiosoundcloud.getAddon(),e='',f=$('

    '+e+"SoundCloud search for: "+b+"

    "),g=app.addOns.addon.pluginaudiosoundcloud.cache("get",b,!1);return g!==!1?(a.html(g.render().$el),a.prepend(f)):(c.append(e+"search soundcloud for: "+b+""),a.append(c),$("#sc-search",a).on("click",function(){a.html($("",{"class":"addon-box",text:"Searching SoundCloud for "+b}).prepend($(e))),app.addOns.addon.pluginaudiosoundcloud.getSearchResults(b,function(c){a.html(c.render().$el),a.prepend(f),app.addOns.addon.pluginaudiosoundcloud.cache("set",b,c)})})),a},cache:function(a,b,c){switch("undefined"==typeof app.cached.soundCloudSearch&&(app.cached.soundCloudSearch={}),a){case"get":return"undefined"==typeof app.cached.soundCloudSearch[b]?c:app.cached.soundCloudSearch[b];case"set":return app.cached.soundCloudSearch[b]=c,app.cached.soundCloudSearch[b]}},doSearchDialog:function(){app.helpers.prompt("What do you want to search for?",function(a){app.xbmcController.command("Input.SendText",[a],function(){$("#folder-name").html('Search for "'+a+'"');var b="Searching for "+a;$("#files-container").html('
    '+b+"
    ")})})},getSearchResults:function(a,b){var c=app.addOns.addon.pluginaudiosoundcloud.getSearchPath();app.cached.fileCollection=new app.FileCollection,app.cached.fileCollection.fetch({name:c,success:function(a){app.cached.fileListView=new app.FilesListView({model:a}),b(app.cached.fileListView)}}),window.setTimeout(function(){app.xbmcController.command("Input.SendText",[a],function(a){console.log(a)})},app.addOns.addon.pluginaudiosoundcloud.waitTime)},isSoundCloud:function(a){return-1!=a.file.indexOf("plugin.audio.soundcloud")}},app.AudioController={playlistId:0,currentPlaylist:{items:[],status:"none"}},app.AudioController.playlistRender=function(a){app.playlists.renderXbmcPlaylist(app.AudioController.playlistId,a)},app.AudioController.playlistAdd=function(a,b,c){var d={};d[a]=b,app.xbmcController.command("Playlist.Add",[app.AudioController.playlistId,d],function(){app.AudioController.getPlaylistItems(function(a){app.AudioController.currentPlaylist=a,c(a)})})},app.AudioController.playlistAddMultiple=function(a,b,c){var d,e=[];for(var f in b)param={},d=b[f],"mixed"==a&&(a="number"==typeof d?"songid":"file"),param[a]=d,e.push({method:"Playlist.Add",params:[app.AudioController.playlistId,param]});app.xbmcController.multipleCommand(e,function(){app.AudioController.getPlaylistItems(function(a){app.AudioController.currentPlaylist=a,c(a)})})},app.AudioController.playlistSwap=function(a,b,c){app.playlists.playlistSwap(app.AudioController.playlistId,"songid",a,b,c)},app.AudioController.playlistClearAdd=function(a,b,c){app.xbmcController.command("Playlist.Clear",[app.AudioController.playlistId],function(){app.notification("Playlist Cleared"),app.AudioController.playlistAdd(a,b,c)})},app.AudioController.playlistClear=function(a){app.xbmcController.command("Playlist.Clear",[app.AudioController.playlistId],function(b){a&&a(b)})},app.AudioController.playlistPlaySongId=function(a){var b=!1;$.each(app.AudioController.currentPlaylist.items,function(c,d){d.id==a&&b===!1&&(app.AudioController.playPlaylistPosition(c,function(){app.AudioController.playlistRender(),app.notification('Now playing "'+d.label+'"')}),b=!0)})},app.AudioController.playSongById=function(a,b,c,d){app.helpers.exists(d)&&d===!0?app.AudioController.playlistClearAdd(b,c,function(){app.AudioController.playlistPlaySongId(a)}):app.AudioController.playlistAdd(b,c,function(){app.AudioController.playlistPlaySongId(a)})},app.AudioController.insertAndPlaySong=function(a,b,c){var d=app.cached.nowPlaying.player,e="undefined"!=typeof d.position?d.position:0,f=e+1,g={};g[a]=b,"notPlaying"==app.cached.nowPlaying.status?app.AudioController.playlistClear(function(){app.xbmcController.command("Playlist.Insert",[app.AudioController.playlistId,f,g],function(a){app.AudioController.playPlaylistPosition(f,function(){c&&c(a)})})}):app.xbmcController.command("Playlist.Insert",[app.AudioController.playlistId,f,g],function(a){app.AudioController.playPlaylistPosition(f,function(){c&&c(a)})})},app.AudioController.songLoadMultiple=function(a,b){var c=[];for(var d in a){var e=a[d];if("number"==typeof e)c.push({method:"AudioLibrary.GetSongDetails",params:[e,app.songFields]});else{var f={position:d,songid:"file",album:"",artist:"",duration:0},g=$.extend(f,a[d]);g.id=a[d].file,a[d]=g}}c.length>0?app.xbmcController.multipleCommand(c,function(c){var d={},e=[];_.each(c,function(a){"undefined"!=typeof a.result&&(d[a.result.songdetails.songid]=a.result.songdetails)});for(var f in a){var g=a[f]; -"number"==typeof g&&"undefined"!=typeof d[g]&&(a[f]=d[g])}var h=0;for(var i in a){var j=a[i];"object"==typeof j&&(j.position=h,e.push(j),h++)}b(e)}):b(a)},app.AudioController.downloadFile=function(a,b){app.xbmcController.command("Files.PrepareDownload",[a],function(a){b&&b(a.result.details.path)})},app.AudioController.sendPlayerCommand=function(a,b){app.xbmcController.command(a,[app.cached.nowPlaying.activePlayer,b],function(){app.AudioController.updatePlayerState()})},app.AudioController.playPlaylistPosition=function(a,b){app.xbmcController.command("Player.Open",[{playlistid:app.AudioController.playlistId,position:a}],function(a){b(a.result)})},app.AudioController.removePlaylistPosition=function(a,b){app.xbmcController.command("Playlist.Remove",[app.AudioController.playlistId,a],function(a){b(a.result)})},app.AudioController.seek=function(a,b){app.xbmcController.command("Player.Seek",[app.cached.nowPlaying.activePlayer,a],function(a){app.helpers.exists(b)&&b(a.result)})},app.AudioController.getPlaylistItems=function(a){app.playlists.getXbmcPlaylist(app.AudioController.playlistId,a)},app.AudioController.setVolume=function(a){app.xbmcController.command("Application.SetVolume",[a],function(){})},app.AudioController.audioLibraryScan=function(){app.xbmcController.command("AudioLibrary.Scan",[],function(){})},app.AudioController.getNowPlayingSong=function(a){var b=4;if(app.counts["503total"]>30&&(b=6,app.notification("No connection to XBMC for 10mins! I'll check if it's there less often now ")),app.counts["503total"]>70&&(b=12,app.notification("No connection to XBMC for 30mins! I'm pretty sure it has gone walkabout")),app.counts[503]>b&&(app.counts[503]=0,app.counts["503total"]++),0!==app.counts[503])return app.counts[503]++,app.state="notconnected",app.notification("Lost connection to XBMC"),void 0;app.counts[503]=1;var c={item:["title","artist","artistid","album","albumid","genre","track","duration","year","rating","playcount","albumartist","file","thumbnail","fanart"],player:["playlistid","speed","position","totaltime","time","percentage","shuffled","repeat","canrepeat","canshuffle","canseek"]},d={status:"notPlaying",item:{},player:{},activePlayer:0,volume:0},e=[];e=[{method:"Application.GetProperties",params:[["volume","muted"]]},{method:"Player.GetActivePlayers",params:[]}],app.xbmcController.multipleCommand(e,function(b){var f=b[0],g=b[1];app.counts[503]=0,app.counts["503total"]=0,d.volume=f.result,app.AudioController.activePlayers=g.result,app.state="connected",g.result.length>0?(d.activePlayer=g.result[0].playerid,app.state="playing",e=[{method:"Player.GetItem",params:[d.activePlayer,c.item]},{method:"Player.GetProperties",params:[d.activePlayer,c.player]}],app.xbmcController.multipleCommand(e,function(b){d.item=b[0].result.item,d.item.list="xbmc",d.player=b[1].result,d.status="playing",app.cached.nowPlaying=d,a&&a(d)})):(app.cached.nowPlaying=d,a(d))}),app.xbmcController.command("Application.GetProperties",[["volume","muted"]],function(b){d.volume=b.result,app.xbmcController.command("Player.GetActivePlayers",[],function(b){app.AudioController.activePlayers=b.result,b.result.length>0?(d.activePlayer=b.result[0].playerid,app.xbmcController.command("Player.GetItem",[d.activePlayer,c.item],function(b){d.item=b.result.item,d.status="playing",app.xbmcController.command("Player.GetProperties",[d.activePlayer,c.player],function(b){d.player=b.result,app.cached.nowPlaying=d,a(d)})})):(app.cached.nowPlaying=d,a(d))})})};var stateTimeout={};app.AudioController.updatePlayerState=function(){var a=$("body"),b="notconnected";app.state==b?a.addClass(b):a.removeClass(b),app.AudioController.getNowPlayingSong(function(a){app.shellView.updateState(a)})},$(window).on("shellReady",function(){app.audioStreaming.init()}),$(window).on("browserPlayerStart",function(a){app.audioStreaming.playbackInProgress=!0,app.audioStreaming.setTitle("playing",a.label)}),$(window).on("browserPlayerStop",function(a){app.audioStreaming.playbackInProgress=!1,app.audioStreaming.setTitle("stop",a.label)}),app.audioStreaming={localPlay:!1,nowplaying:{init:1},lastPos:0,defaultVol:60,progressEl:"#browser-progress-bar",volumeEl:"#browser-volume",playlistEl:"#playlist-local",playbackInProgress:!1,lastListKey:"lastBrowserList",classLocal:"player-view-local",classXbmc:"player-view-xbmc",classLocalPlaying:"browser-playing",classLocalPaused:"browser-paused",init:function(){app.audioStreaming.$body=$("body"),app.audioStreaming.$window=$(window),soundManager.setup({url:"lib/soundmanager/swf/",flashVersion:9,preferFlash:!0,useHTML5Audio:!0,useFlashBlock:!1,onready:function(){$(window).trigger("soundManagerReady"),app.audioStreaming.playList={items:[],playingPosition:0,id:0,repeat:"off",random:"off",mute:!1},soundManager.setVolume(app.audioStreaming.defaultVol);var a=app.storageController.getStorage(app.audioStreaming.lastListKey);void 0!==a&&a.length>0&&app.store.libraryCall(function(){app.playlists.playlistGetItems("items",a,function(a){if(app.audioStreaming.playList.items=a,app.audioStreaming.renderPlaylistItems(),void 0!==a.models&&void 0!==a.models[0]){var b=a.models[0];app.audioStreaming.loadSong(b),app.audioStreaming.updatePlayingState(b.attributes)}})},"songsReady")}}),app.audioStreaming.progressInit(),app.audioStreaming.volumeInit()},setPlayer:function(a){var b;"xbmc"==a&&(app.audioStreaming.$body.addClass(app.audioStreaming.classXbmc).removeClass(app.audioStreaming.classLocal),b=app.cached.nowPlaying.item,app.helpers.applyBackstretch(void 0!==b.fanart?b.fanart:"","xbmc")),"local"==a&&(app.audioStreaming.$body.removeClass(app.audioStreaming.classXbmc).addClass(app.audioStreaming.classLocal),0===$("ul.browser-playlist-song-list").length&&app.audioStreaming.renderPlaylistItems(),b=app.audioStreaming.getNowPlayingSong(),app.helpers.applyBackstretch(void 0!==b.fanart?b.fanart:"","local"))},getPlayer:function(){return app.audioStreaming.$body.hasClass(app.audioStreaming.classLocal)?"local":"xbmc"},getNowPlayingSong:function(){if(void 0!==app.audioStreaming.playList.items.models[app.audioStreaming.playList.playingPosition]){var a=app.audioStreaming.playList.items.models[app.audioStreaming.playList.playingPosition];return a.attributes}return{}},playPosition:function(a){if($("li.browser-player div.playlist-item").removeClass("browser-playing-row"),app.audioStreaming.playList.items.models.length>0){var b=app.audioStreaming.playList.items.models[parseInt(a)].attributes;app.audioStreaming.playList.playingPosition=a,app.audioStreaming.loadSong({attributes:b},function(){app.audioStreaming.play(),app.notification("Playing "+b.label+" in the browser")})}},setPlaylistItems:function(a){var b=[];$.each(a.models,function(c,d){"undefined"!=typeof d.attributes.songid&&(b.push(d.attributes.songid),a.models[c].attributes.type="song")}),app.storageController.setStorage(app.audioStreaming.lastListKey,b),app.audioStreaming.playList.items=a},appendPlaylistItems:function(a,b){var c;void 0===app.audioStreaming.playList?(c=a,console.log(c)):(c=app.audioStreaming.playList.items,$.each(a.models,function(a,b){c.models.push(b)}),c.length=c.models.length),app.audioStreaming.setPlaylistItems(c),app.audioStreaming.renderPlaylistItems(),b&&b()},replacePlaylistItems:function(a,b){app.audioStreaming.setPlaylistItems(a),app.audioStreaming.renderPlaylistItems(),app.audioStreaming.loadSong(a.models[0],function(){app.playlists.changePlaylistView("local"),app.audioStreaming.playPosition(0),b&&b()})},renderPlaylistItems:function(){if(void 0!==app.audioStreaming.playList){var a=app.audioStreaming.playList.items,b=new app.CustomPlaylistSongSmallListView({model:a}).render();$(app.audioStreaming.playlistEl).html(b.$el)}},loadSong:function(a,b){app.audioStreaming.stop();var c=soundManager,d=a.attributes;app.AudioController.downloadFile(d.file,function(a){app.audioStreaming.localPlay=c.createSound({id:"browser-"+d.songid,url:a,autoPlay:!1,autoLoad:!0,stream:!0,onerror:function(a){app.helpers.errorHandler("SoundManager failed to load: "+a.type,a)},onplay:function(){$("body").addClass("browser-playing").removeClass("browser-paused"),app.audioStreaming.updatePlayingState(d);var a=$("#browser-volume").slider("value");app.audioStreaming.localPlay.setVolume(a),$(window).trigger("browserPlayerStart",[d])},onstop:function(){$("body").removeClass("browser-playing").removeClass("browser-paused"),$(window).trigger("browserPlayerStop",[d])},onpause:function(){$("body").removeClass("browser-playing").addClass("browser-paused"),$(window).trigger("browserPlayerStop",[d])},onresume:function(){$("body").addClass("browser-playing").removeClass("browser-paused"),$(window).trigger("browserPlayerStart",[d])},onfinish:function(){var a=app.audioStreaming.playList,b=a.items.models,c=parseInt(a.playingPosition);if("one"==a.repeat)app.audioStreaming.playPosition(c);else if("on"==a.random){var d=app.helpers.getRandomInt(0,b.length-1);app.audioStreaming.playPosition(d)}else"all"==a.repeat?b.length==c+1&&app.audioStreaming.playPosition(0):b.length>c&&app.audioStreaming.playPosition(c+1)},whileplaying:function(){{var a=parseInt(this.position)/1e3,b=parseInt(this.duration)/1e3,c=Math.round(a/b*100),e=$("#browser-time");$("#browser-now-playing")}app.audioStreaming.nowplaying.player={position:a,duration:b,percentage:c},$(".time-cur",e).html(app.helpers.secToTime(Math.floor(a))),$(".time-total",e).html(app.helpers.secToTime(Math.floor(b))),c!=app.audioStreaming.lastPos&&($(app.audioStreaming.progressEl).slider("value",c),app.audioStreaming.updatePlayingState(d)),app.audioStreaming.lastPos=c}}),$(app.audioStreaming.progressEl).hasClass("ui-slider")||(app.audioStreaming.localPlay.setVolume(app.audioStreaming.defaultVol),app.audioStreaming.progressInit(),app.audioStreaming.volumeInit()),b&&b()})},updatePlayingState:function(a){$("#browser-playing-thumb").attr("src",app.parseImage(a.thumbnail)),$(".browser-playing-song-title").html(a.label),$(".browser-playing-song-meta").html(a.artist[0]);var b=$("li.browser-player .playlist-pos-"+app.audioStreaming.playList.playingPosition);b.hasClass("browser-playing-row")||b.addClass("browser-playing-row"),app.audioStreaming.setTitle("playing",a.label),app.helpers.applyBackstretch(void 0!==a.fanart?a.fanart:"","local")},bodyRandRepeat:function(){var a=app.audioStreaming.playList;if(void 0!==a.repeat){var b=$("body");"undefined"!=typeof app.audioStreaming.playList&&(b.removeClass("bp-repeat-one").removeClass("bp-repeat-all").removeClass("bp-repeat-off"),b.addClass("bp-repeat-"+a.repeat),b.removeClass("bp-random-on").removeClass("bp-random-off"),b.addClass("bp-random-"+a.random),b.removeClass("bp-mute"),a.mute&&b.addClass("bp-mute"))}},setTitle:function(a,b){"local"==app.audioStreaming.getPlayer()&&(document.title=("playing"==a?"â–¶ ":"")+(void 0!==b?b+" | ":"")+"Chorus.")},progressInit:function(){$(app.audioStreaming.progressEl).slider({range:"min",step:1,value:0,min:0,max:100,stop:function(a,b){var c=({playerid:0,value:b.value},b.value/100*app.audioStreaming.localPlay.duration);c=Math.round(c),app.audioStreaming.localPlay.setPosition(c)}})},volumeInit:function(){$(app.audioStreaming.volumeEl).slider({range:"min",step:5,value:app.audioStreaming.defaultVol,min:0,max:100,stop:function(a,b){app.audioStreaming.localPlay.setVolume(b.value)}})},isPlaying:function(){return $("body").hasClass("browser-playing")},togglePlay:function(){app.audioStreaming.localPlay!==!1&&(app.audioStreaming.isPlaying()?app.audioStreaming.pause():app.audioStreaming.play())},play:function(){app.audioStreaming.localPlay!==!1&&(app.audioStreaming.localPlay.play(),app.audioStreaming.setPlayer("local"))},stop:function(){app.audioStreaming.localPlay!==!1&&app.audioStreaming.localPlay.stop()},pause:function(){app.audioStreaming.localPlay!==!1&&app.audioStreaming.localPlay.pause()},prev:function(){if(app.audioStreaming.localPlay!==!1){var a=app.audioStreaming.playList;0===a.playingPosition?app.audioStreaming.playPosition(0):app.audioStreaming.playPosition(a.playingPosition-1)}},next:function(){if(app.audioStreaming.localPlay!==!1){var a=app.audioStreaming.playList;a.playingPosition==a.items.models.length-1?app.audioStreaming.playPosition(0):app.audioStreaming.playPosition(a.playingPosition+1)}},mute:function(){if(app.audioStreaming.localPlay!==!1){var a=app.audioStreaming.playList.mute,b=$(app.audioStreaming.volumeEl).slider("value");if(a){var c=app.helpers.varGet("localMuteLastVol",app.audioStreaming.defaultVol);app.audioStreaming.localPlay.setVolume(c),$(app.audioStreaming.volumeEl).slider("value",c)}else app.helpers.varSet("localMuteLastVol",b>5?b:app.audioStreaming.defaultVol),app.audioStreaming.localPlay.setVolume(0),$(app.audioStreaming.volumeEl).slider("value",0);app.audioStreaming.playList.mute=!a,app.audioStreaming.bodyRandRepeat()}},repeat:function(){if(app.audioStreaming.localPlay!==!1){var a,b=app.audioStreaming.playList;switch(b.repeat){case"off":a="all";break;case"all":a="one";break;case"one":a="off"}app.audioStreaming.playList.repeat=a,app.audioStreaming.bodyRandRepeat()}},random:function(){if(app.audioStreaming.localPlay!==!1){var a=app.audioStreaming.playList;app.audioStreaming.playList.random="off"==a.random?"on":"off",app.audioStreaming.bodyRandRepeat()}},deleteBrowserPlaylistSong:function(a){var b=app.audioStreaming.playList.items,c=b.models.filter(function(b){return b.attributes.pos!=a});b.models=c,b.length=c.length,app.audioStreaming.setPlaylistItems(b)},sortableChangePlaylistPosition:function(a){var b=[],c=app.audioStreaming.playList.items;$.each(a,function(a,d){b.push(c.models[d])}),c.models=b,c.length=b.length,app.audioStreaming.setPlaylistItems(c),app.audioStreaming.renderPlaylistItems()}},app.playlists={storageKeyLists:"playlist:lists",storageKeyThumbsUp:"playlist:thumbsUp"},$(window).on("shellReady",function(){app.playlists.getThumbsUp(),$(".playlist-actions-wrapper",this.$el).html(app.helpers.makeDropdown(app.helpers.menuTemplates("playlistShell"))),app.playlists.addCustomPlayLists(function(a){var b=$("#playlist-lists",self.$el);b.html(a.render().el)})}),app.playlists.playlistGetItems=function(a,b,c){var d=[],e={};switch(a){case"xbmc":e=new app.PlaylistCollection,e.fetch({success:function(a){a=app.playlists.addFileFieldToSongCollection(a),c(a)}});break;case"song":e=new app.CustomSongCollection,e.fetch({items:[b],success:function(a){a=app.playlists.addFileFieldToSongCollection(a),c(a)}});break;case"album":e=new app.SongFilteredXbmcCollection({filter:{albumid:b}}),e.fetch({success:function(a){res=app.playlists.addFileFieldToSongCollection(a),c(res)}});break;case"artist":e=new app.SongFilteredXbmcCollection({filter:{artistid:b}}),e.fetch({success:function(a){res=app.playlists.addFileFieldToSongCollection(a),c(res)}});break;case"movie":break;case"list":e=new app.PlaylistCustomListSongCollection,e.fetch({name:b,success:function(a){a=app.playlists.addFileFieldToSongCollection(a),c(a)}});break;case"thumbsup":e=new app.ThumbsUpCollection,e.fetch({name:b,success:function(a){a=app.playlists.addFileFieldToSongCollection(a),c(a)}});break;case"items":e=new app.CustomSongCollection,e.fetch({items:b,success:function(a){a=app.playlists.addFileFieldToSongCollection(a),c(a)}})}return c?(c(d),void 0):d},app.playlists.playlistAddItems=function(a,b,c,d,e){app.playlists.playlistGetItems(c,d,function(c){if(0!==c.length){var d=[];switch($.each(c.models,function(a,b){b.attributes.songid&&("file"==b.attributes.songid?d.push(b.attributes.file):d.push(b.attributes.songid))}),e="undefined"!=typeof e?e:function(){},a){case"xbmc":"append"==b?app.AudioController.playlistAddMultiple("mixed",d,function(){app.AudioController.playlistRender(),app.playlists.changePlaylistView("xbmc"),e()}):app.AudioController.playlistClear(function(){app.AudioController.playlistAddMultiple("mixed",d,function(){app.AudioController.playlistRender(),app.playlists.changePlaylistView("xbmc"),app.AudioController.playPlaylistPosition(i,function(){app.AudioController.playlistRender(),e()})})});break;case"local":"append"==b?(console.log("append",c),app.audioStreaming.appendPlaylistItems(c,e)):(console.log("replace",c),app.audioStreaming.replacePlaylistItems(c,e));break;case"lists":app.playlists.changePlaylistView("lists"),app.playlists.saveCustomPlayListsDialog("local",d)}}})},app.playlists.addFileFieldToSongCollection=function(a){return $.each(a.models,function(b,c){var d=app.store.getSongBy("id",c.attributes.songid);c.attributes.file=d.file,a.models[b]=c}),a},app.playlists.sortableChangePlaylistPosition=function(a,b){var c=$(b.item[0]).find("div.playlist-item"),d={},e=c.closest("ul.playlist"),f=1==c.data("playlistId")?"video":"audio";if(e.find("div.playlist-item").each(function(a,b){$d=$(b),$d.data("path")===c.data("path")&&(d={from:c.data("id"),to:a})}),void 0!==d.from&&d.from!==d.to){var g="audio"==f?app.AudioController:app.VideoController;g.playlistSwap(d.from,d.to,function(){g.playlistRender()})}},app.playlists.changeCustomPlaylistPosition=function(a,b){var c=$(b.item[0]).find("div.playlist-item"),d={},e=c.closest("ul.playlist");e.find("div.playlist-item").each(function(a,b){$d=$(b),$d.data("path")===c.data("path")&&(d={from:c.data("path"),to:a})}),console.log(d),void 0!==d.from&&d.from!==d.to&&app.AudioController.playlistSwap(d.from,d.to,function(){app.AudioController.playlistRender()})},app.playlists.changePlaylistView=function(a){var b=$("#sidebar-second"),c=$(".playlist-primary-tab[data-pane='"+a+"']");$(".playlist-primary-tab").removeClass("active"),c.addClass("active"),$(".sidebar-pane",b).hide(),$("#playlist-"+a,b).show(),("local"==a||"xbmc"==a)&&app.audioStreaming.setPlayer(a)},app.playlists.saveCustomPlayListsDialog=function(a,b,c){a="undefined"==typeof a?"xbmc":a,b="undefined"==typeof b?[]:b;var d=app.playlists.getCustomPlaylist(),e="";for(var f in d)e+='
  • '+d[f].name+"
  • ";"undefined"!=typeof c&&(e="");var g='

    Create a new playlist

    '+(""!==e?'

    Or add to an existing list

      '+e+"
    ":"");app.helpers.dialog(g,{title:"Add to a playlist"}),$("#savenewlist").on("click",function(){var c=$("#newlistname").val(),d=app.playlists.saveCustomPlayLists("new",c,a,b);app.helpers.dialogClose(),document.location="#playlist/"+d.id}),$("#existinglists li").on("click",function(){var c=$(this).data("id"),d=app.playlists.saveCustomPlayLists("existing",c,a,b);app.helpers.dialogClose(),document.location="#playlist/"+d.id})},app.playlists.saveCustomPlayLists=function(a,b,c,d){var e=[],f=app.playlists.getCustomPlaylist(),g=0,h={},i=0;switch("xbmc"==c?(console.log(app.cached.xbmcPlaylist),_.each(app.cached.xbmcPlaylist,function(a){"file"==a.id?(a=app.addOns.invokeAll("parseFileRecord",a),e.push(a)):e.push(a.id)})):e=d,a){case"new":for(i in f){var j=f[i];g0)for(var d in c)c[d].id==a&&(c[d].items=b);app.storageController.setStorage(app.playlists.storageKeyLists,c)},app.playlists.getDropdown=function(){var a=[],b=app.helpers.arg(0),c={append:"Add to playlist",replace:"Replace playlist","browser-replace":"Play in browser"};"thumbsup"!=b&&(c.delete="Delete");for(var d in c)a.push({url:"#","class":b+"-"+d,title:c[d]});return app.helpers.makeDropdown({key:b,items:a})},app.playlists.setThumbsUp=function(a,b,c){var d=app.playlists.getThumbsUp(),e=d[b],f=[],g=!1,h={items:[]},i=0;switch(("undefined"==typeof e||"undefined"==typeof e.items)&&(e=h),a){case"add":for(i in e.items)e.items[i]==c&&(g=!0);g||e.items.push(c);break;case"remove":for(i in e.items)e.items[i]!=c&&null!==e.items[i]&&f.push(e.items[i]);e.items=f}d[b]=e,app.storageController.setStorage(app.playlists.storageKeyThumbsUp,d),app.playlists.getThumbsUp()},app.playlists.getThumbsUp=function(a){var b=app.storageController.getStorage(app.playlists.storageKeyThumbsUp),c=null!==b?b:{},d=0,e=0;app.cached.thumbsUp={};for(d in c){app.cached.thumbsUp[d]={items:c[d].items,lookup:{}};var f=[];for(e in c[d].items){var g=c[d].items[e];null!==g&&(f.push(g),app.cached.thumbsUp[d].lookup[g]=!0)}c[d].items=f}return"undefined"!=typeof a?c[a]:c},app.playlists.isThumbsUp=function(a,b){return"undefined"!=typeof app.cached.thumbsUp[a]&&"undefined"!=typeof app.cached.thumbsUp[a].lookup[b]},app.playlists.getXbmcPlaylist=function(a,b){app.xbmcController.command("Playlist.GetItems",[a,["albumid","artist","albumartist","artistid","thumbnail","file","duration","year","album","track"]],function(c){var d=c.result;d.playlistId=a,$.each(d.items,function(b){d.items[b].playlistId=a}),b(d)})},app.playlists.renderXbmcPlaylist=function(a,b){app.playlists.getXbmcPlaylist(a,function(c){app.cached.xbmcPlaylist=c.items;var d=$("#playlist-xbmc");app.playlistView=new app.PlaylistView({model:{playlistId:a,models:c.items}}),d.html(app.playlistView.render().el),app.AudioController.getNowPlayingSong(function(a){app.shellView.updateState(a),app.playlistView.playlistBinds(this)}),app.helpers.exists(b)&&b(c)})},app.playlists.playlistSwap=function(a,b,c,d,e){app.playlists.getXbmcPlaylist(a,function(f){var g=f.items[c],h={},i=1==a?app.VideoController:app.AudioController;void 0!==g.id&&"number"==typeof g.id?h[b]=g.id:h.file=g.file,i.removePlaylistPosition(c,function(){app.xbmcController.command("Playlist.Insert",[a,d,h],function(){i.getPlaylistItems(function(a){i.currentPlaylist=a,e(a)})})})})},app.storageController={nameSpace:"chorusStorage:"},app.storageController.getStorage=function(a,b){var c=$.totalStorage(app.storageController.nameSpace+a);return b?(b(c),void 0):c},app.storageController.setStorage=function(a,b,c){$.totalStorage(app.storageController.nameSpace+a,b);return c?(c(b),void 0):b},app.VideoController={playlistId:1,currentPlaylist:[]},app.VideoController.playVideoId=function(a,b,c){console.log(b),app.VideoController.playlistClear(function(){console.log("cleard"),app.VideoController.addToPlaylist(a,b,"add",function(a){console.log(a),app.VideoController.playPlaylistPosition(0,function(){c(a.result)})})})},app.VideoController.addToPlaylist=function(a,b,c,d){var e={};e[b]=a,console.log(e),"add"==c&&app.xbmcController.command("Playlist.Add",[app.VideoController.playlistId,e],function(a){d(a.result)})},app.VideoController.playPlaylistPosition=function(a,b){app.xbmcController.command("Player.Open",[{playlistid:app.VideoController.playlistId,position:a}],function(a){b(a.result)})},app.VideoController.playlistClear=function(a){app.xbmcController.command("Playlist.Clear",[app.VideoController.playlistId],function(b){a&&a(b)})},app.VideoController.getPlaylistItems=function(a){app.playlists.getXbmcPlaylist(app.VideoController.playlistId,a)},app.VideoController.playlistRender=function(a){app.playlists.renderXbmcPlaylist(app.VideoController.playlistId,a)},app.VideoController.removePlaylistPosition=function(a,b){app.xbmcController.command("Playlist.Remove",[app.VideoController.playlistId,a],function(a){b(a.result)})},app.VideoController.playlistSwap=function(a,b,c){app.playlists.playlistSwap(app.VideoController.playlistId,"movieid",a,b,c)},$.jsonRPC.setup({endPoint:app.jsonRpcUrl}),app.xbmcController={},app.xbmcController.command=function(a,b,c,d){$.jsonRPC.request(a,{params:b,success:function(a){c&&c(a)},error:function(c){app.helpers.errorHandler("xbmc command call: "+a,[c,b]),d&&d([c,b])}})},app.xbmcController.multipleCommand=function(a,b){$.jsonRPC.batchRequest(a,{success:function(a){for(var c in a)"undefined"!=typeof a[c].error;b&&b(a)},error:function(){}})},app.SongXbmcCollection=Backbone.Collection.extend({url:app.jsonRpcUrl,rpc:new Backbone.Rpc({errorHandler:function(a){app.helpers.errorHandler("xbmc song call",a)},namespaceDelimiter:""}),model:app.Song,arg1:["file"],arg2:{start:0,end:5e4},arg3:{sort:{method:"dateadded",order:"descending"}},methods:{read:["AudioLibrary.GetSongs","arg1","arg2","arg3"]},parse:function(a){return $.each(a.songs,function(b,c){a.songs[b].id=c.songid}),a.songs}}),app.SongFilteredXbmcCollection=Backbone.Collection.extend({url:app.jsonRpcUrl,rpc:new Backbone.Rpc({errorHandler:function(a){app.helpers.errorHandler("xbmc song filtered call",a)},namespaceDelimiter:""}),model:app.Song,arg1:app.songFields,arg2:{start:0,end:500},arg3:{sort:{method:"dateadded",order:"descending"}},arg4:function(){return this.models[0].attributes.filter},methods:{read:["AudioLibrary.GetSongs","arg1","arg2","arg3","arg4"]},parse:function(a){return a.songs}}),app.AlbumXbmcCollection=Backbone.Collection.extend({url:app.jsonRpcUrl,rpc:new Backbone.Rpc({errorHandler:function(a){app.helpers.errorHandler("xbmc album call",a)},namespaceDelimiter:""}),model:app.Album,arg1:app.albumFields,arg2:{start:0,end:15e3},arg3:{sort:{method:"dateadded",order:"descending"}},methods:{read:["AudioLibrary.GetAlbums","arg1","arg2","arg3"]},parse:function(a){return a.albums}}),app.AlbumRecentlyAddedXbmcCollection=Backbone.Collection.extend({url:app.jsonRpcUrl,rpc:new Backbone.Rpc({errorHandler:function(a){app.helpers.errorHandler("xbmc album call",a)},namespaceDelimiter:""}),model:app.Album,arg1:app.albumFields,arg2:{start:0,end:200},methods:{read:["AudioLibrary.GetRecentlyAddedAlbums","arg1","arg2"]},parse:function(a){$.each(a.albums,function(b){a.albums[b].recent="added"});var b=app.helpers.shuffle(a.albums);return b}}),app.AlbumRecentlyPlayedXbmcCollection=Backbone.Collection.extend({url:app.jsonRpcUrl,rpc:new Backbone.Rpc({errorHandler:function(a){app.helpers.errorHandler("xbmc album call",a)},namespaceDelimiter:""}),model:app.Album,arg1:app.albumFields,arg2:{start:0,end:200},methods:{read:["AudioLibrary.GetRecentlyPlayedAlbums","arg1","arg2"]},parse:function(a){$.each(a.albums,function(b){a.albums[b].recent="played"});var b=app.helpers.shuffle(a.albums);return app.helpers.buildUrls(b,"album","albumid")}}),app.ArtistXbmcCollection=Backbone.Collection.extend({url:app.jsonRpcUrl,rpc:new Backbone.Rpc({errorHandler:function(a){app.helpers.errorHandler("xbmc artist call",a)},namespaceDelimiter:""}),model:app.Artist,arg1:!0,arg2:app.artistFields,arg3:{start:0,end:1e4},arg4:{sort:{method:"artist"}},methods:{read:["AudioLibrary.GetArtists","arg1","arg2","arg3","arg4"]},parse:function(a){return app.helpers.buildUrls(a.artists,"artist","artistid")}}),app.MovieXbmcCollection=Backbone.Collection.extend({url:app.jsonRpcUrl,rpc:new Backbone.Rpc({errorHandler:function(a){app.helpers.errorHandler("xbmc artist call",a)},namespaceDelimiter:""}),model:app.Movie,arg1:["year","thumbnail"],arg2:function(){return this.models[0].attributes.range},methods:{read:["VideoLibrary.GetMovies","arg1","arg2"]},parse:function(a){return app.helpers.buildUrls(a.movies,"movie","movieid")}}),app.AllMovieXbmcCollection=Backbone.Collection.extend({url:app.jsonRpcUrl,rpc:new Backbone.Rpc({errorHandler:function(a){app.helpers.errorHandler("xbmc artist call",a)},namespaceDelimiter:""}),model:app.Movie,methods:{read:["VideoLibrary.GetMovies"]},parse:function(a){return app.helpers.buildUrls(a.movies,"movie","movieid")}}),app.ArtistCollection=Backbone.Collection.extend({model:app.Artist,sync:function(a,b,c){if("read"===a){var d="undefined"==typeof c.type?"all":c.type;"all"==d&&app.store.allArtists(function(a){c.success(a.models)}),"rand"==d&&app.store.randomArtists(function(a){c.success(a)})}}}),app.AlbumsCollection=Backbone.Collection.extend({model:app.Album,sync:function(a,b,c){"read"===a&&(app.notification("Loading Albums"),app.store.allAlbums(function(a){c.success(a.models)}))}}),app.AlbumCollection=Backbone.Collection.extend({model:app.Album,sync:function(a,b,c){"read"===a&&(app.notification("Loading "+c.type+"s"),app.store.getAlbums(parseInt(c.id),c.type,function(a){c.success(a)}))}}),app.SongCollection=Backbone.Collection.extend({model:app.Song,sync:function(a,b,c){"read"===a&&c.success(app.stores.allSongs.models)}}),app.PlaylistCollection=Backbone.Collection.extend({model:app.PlaylistItem,sync:function(a,b,c){"read"===a&&app.AudioController.getPlaylistItems(function(a){c.success(a.items)})}}),app.PlaylistCustomListCollection=Backbone.Collection.extend({model:app.PlaylistCustomListItem,sync:function(a,b,c){if("read"===a){var d=app.playlists.getCustomPlaylist(),e=[],f=1;for(var g in d){var h=d[g];h.id=f,e.push(h),f++}c.success(e)}}}),app.PlaylistCustomListSongCollection=Backbone.Collection.extend({model:app.PlaylistCustomListItemSong,sync:function(a,b,c){if("read"===a){var d=app.playlists.getCustomPlaylist(c.name);app.AudioController.songLoadMultiple(d.items,function(a){c.success(a)})}}}),app.ThumbsUpCollection=Backbone.Collection.extend({model:app.PlaylistCustomListItemSong,sync:function(a,b,c){if("read"===a){var d=app.playlists.getThumbsUp(c.name);if(null===d||0===d.length)return{items:[]};switch(c.name){case"song":app.AudioController.songLoadMultiple(d.items,function(a){c.success(a)});break;case"artist":app.store.multipleArtists(d.items,function(a){c.success(a)});break;case"album":app.store.multipleAlbums(d.items,function(a){c.success(a)})}}}}),app.CustomSongCollection=Backbone.Collection.extend({model:app.Song,sync:function(a,b,c){"read"===a&&app.AudioController.songLoadMultiple(c.items,function(a){c.success(a)})}}),app.MemoryStore=function(a){this.state={ready:!1,msg:"connecting"},app.stores={songs:[],albums:[],artists:[],genres:[],all:[],allArtists:[]},this.syncAudio=function(){var a=this;a.songsIndexed=!1,a.songsIndexing=!1,a.albumsIndexed=!1,a.albumsIndexed=!1,this.allArtists(),this.allAlbums(),this.indexSongs()},this.indexSongs=function(a){var c=this;c.songsIndexed===!0?b(a,c):c.songsIndexing!==!0&&(c.songsIndexing=!0,this.allSongs=new app.SongXbmcCollection,this.allSongs.fetch({success:function(d){app.stores.allSongs=d,c.songsIndexed=!0,c.state={ready:!0,msg:"songs ready"},$(window).trigger("songsReady"),b(a,c)}}))},this.libraryCall=function(a,b){"undefined"==typeof b&&(b="songsReady"),app.store.state.ready===!0?a():$(window).bind(b,a)},this.allArtists=function(a){var c=this;if(c.artistsIndexed===!0){var d=app.stores.allArtists;return b(a,d),d}this.allXbmcArtists=new app.ArtistXbmcCollection,this.allXbmcArtists.fetch({success:function(d){d.models.sort(function(a,b){return app.helpers.aphabeticalSort(a.attributes.label,b.attributes.label)}),app.stores.allArtists=d,c.msg="artists ready",$(window).trigger("artistsReady"),c.artistsIndexed=!0;var e=app.stores.allArtists;return b(a,e),e}})},this.allAlbums=function(a){var c=this;if(c.albumsIndexed===!0){var d=app.stores.allAlbums; -return b(a,d),d}this.allXbmcAlbums=new app.AlbumXbmcCollection,this.allXbmcAlbums.fetch({success:function(d){app.stores.allAlbums=d,c.msg="albums ready",$(window).trigger("albumsReady"),c.albumsIndexed=!0;var e=app.stores.allAlbums;return b(a,e),e}})},this.multipleArtists=function(a,c){0!==a.length&&this.allArtists(function(d){var e=d.models.filter(function(b){return-1!=$.inArray(b.attributes.artistid,a)});b(c,e)})},this.getSongBy=function(a,c,d){var e=app.stores.allSongs.models,f=null;return $.each(e,function(b,d){if(null===f){var e=d.attributes;"id"==a&&e.id==c?f=e:"file"==a&&e.file==c?f=e:"title"==a&&e.label==c?f=e:"title"==a&&e.label.toLowerCase().indexOf(c.toLowerCase())>-1&&(f=e)}}),b(d,f),f},this.multipleAlbums=function(a,c){0!==a.length&&this.allAlbums(function(d){var e=d.models.filter(function(b){return-1!=$.inArray(b.attributes.albumid,a)});b(c,e)})},this.randomArtists=function(a){this.allArtists(function(c){var d=c.models,e=_.shuffle(d),f=[],g=30,h=0;_.each(e,function(a){g>h&&0!==a.attributes.fanart.length&&0!==a.attributes.thumbnail.length&&(f.push(a),h++)}),f.lengthh&&0!==a.attributes.thumbnail.length&&(f.push(a),h++)}),b(a,f)})},this.getArtist=function(a,c){this.allArtists(function(){$.each(app.stores.allArtists.models,function(d,e){"undefined"!=typeof e.attributes&&e.attributes.artistid==a&&b(c,e)})})},this.getAlbums=function(a,c,d){var e={},f=[],g=this,h=c+a,i=c+"id",j=c+"s";if(app.helpers.exists(app.stores[j])&&app.helpers.exists(app.stores[j][h])&&app.helpers.exists(app.stores[j][h].albumsitems)&&(f=app.stores[j][h].albumsitems,b(d,f)),0===f.length){e[i]=a;var k=new app.SongFilteredXbmcCollection({filter:e});k.fetch({success:function(a){f=g.parseArtistSongsToAlbums(a.models),app.stores[j][h]={albumsitems:f},b(d,f)}})}},this.parseArtistSongsToAlbums=function(a){var b={},c=[];for(var d in a){var e=a[d],f="undefined"!=typeof e.attributes?e.attributes:{},g="album"+f.albumid;if("undefined"==typeof b[g]){b[g]={};var h=["album","albumid","thumbnail","artist","artistid"];for(var i in h){var j=h[i];void 0!==f[j]&&(b[g][j]=f[j])}b[g].songs=[]}b[g].songs.push(e)}for(d in b)c.push(b[d]);return c},this.syncAudio(a);var b=function(a,b){a&&setTimeout(function(){a(b)})}},app.store=new app.MemoryStore(function(){}),app.FileCollection=Backbone.Collection.extend({model:app.File,sync:function(a,b,c){"read"===a&&("sources"==c.name?this.getSources(c.success):"addons"==c.name?this.getAddonSources(c.success):this.getDirectory(c.name,c.success))},getSources:function(a){var b=this;app.xbmcController.command("Files.GetSources",["music"],function(c){var d=b.parseData(c.result.sources);a(d)})},getAddonSources:function(a){app.addOns.getSources(a)},getDirectory:function(a,b){var c=this;app.xbmcController.command("Files.GetDirectory",[a,"music",app.fileFields,{method:"title",order:"ascending"}],function(a){var d=c.parseData(a.result.files);b(d)})},parseData:function(a){for(var b in a)("undefined"==typeof a[b].filetype||""===a[b].filetype)&&(a[b].filetype="directory"),("undefined"==typeof a[b].id||0===a[b].id)&&(a[b].id=a[b].file),"directory"==a[b].filetype?a[b].title=a[b].label:a[b].type="file",("undefined"==typeof a[b].title||""===a[b].title)&&(a[b].title=a[b].label),"undefined"==typeof a[b].thumbnail&&(a[b].thumbnail=""),a[b]=app.addOns.invokeAll("parseFileRecord",a[b]);return a}}),app.MovieCollection=Backbone.Collection.extend({model:app.Movie,cached:[],fullyLoaded:!1,sync:function(a,b,c){if("read"===a){var d=this,e="undefined"!=typeof c.fullRange&&c.fullRange===!0,f=(app.moviePageNum,{range:app.helpers.createPaginationRange(app.moviePageNum,e)});if(0===app.moviePageNum&&(app.stores.movies=[]),"undefined"==typeof app.stores.movies&&(app.stores.movies=[]),e&&app.stores.movies.length>0)return c.success(app.stores.movies),void 0;app.cached.movieXbmcCollection=new app.MovieXbmcCollection(f),app.cached.movieXbmcCollection.fetch({success:function(a){$.each(a.models,function(a,b){app.stores.movies.push(b)}),a.models.length>app.itemsPerPage&&(d.fullyLoaded=!0),c.success(a.models)}})}}}),app.MovieRecentCollection=Backbone.Collection.extend({model:app.Movie,cached:[],fullyLoaded:!1,sync:function(a,b,c){var d=[app.movieFields,{end:100,start:0}];app.xbmcController.command("VideoLibrary.GetRecentlyAddedMovies",d,function(a){console.log(a),c.success(a.result.movies)})}}),app.MovieFitleredCollection=Backbone.Collection.extend({model:app.Movie,cached:[],fullyLoaded:!1,sync:function(a,b,c){var d={sort:{method:"title"}},e=[app.movieFields,{end:500,start:0},d,c.filter];console.log("result from ",e);for(var f in c.filter)var g=f+":"+c.filter[f];app.xbmcController.command("VideoLibrary.GetMovies",e,function(a){console.log("result from ",e),console.log("data ",a),c.success(a.result.movies)})}}),app.MovieAllCollection=Backbone.Collection.extend({model:app.Movie,cached:[],fullyLoaded:!1,sync:function(a,b,c){if("undefined"==typeof app.stores.allMovies){var d=new app.AllMovieXbmcCollection;d.fetch({success:function(a){a.models.sort(function(a,b){return app.helpers.aphabeticalSort(a.attributes.label,b.attributes.label)}),app.stores.allMovies=a.models,c.success(a.models)}})}else c.success(app.stores.allMovies)}}),app.AlbumView=Backbone.View.extend({initialize:function(){},render:function(){var a=this;return this.$el.html(this.template(this.model.attributes)),a.albumList=new app.AlbumCollection,a.albumList.fetch({id:this.model.attributes.albumid,type:"album",success:function(b){a.albumsView=new app.AlbumsList({model:b,className:"album-list"});{var c=b.models[0].attributes,d="#sidebar-first .album-row-"+c.albumid;$("#album-list").html(a.albumsView.render().el)}app.helpers.setTitle(''+c.artist+""+c.album),$("#sidebar-first .album-small-row").removeClass("active"),0===$(d).length?(a.albumArtistView=new app.AlbumArtistView({model:b.models[0]}),app.helpers.setFirstSidebarContent(a.albumArtistView.render().el)):$(d).addClass("active")}}),this}}),app.AlbumArtistView=Backbone.View.extend({tagName:"div",className:"album-artist-item",initialize:function(){console.log(this.model.attributes),this.artistModel=new app.Artist({id:this.model.attributes.artistid,fields:app.artistFields}),this.artistAlbums={}},render:function(){var a=this;return this.artistModel.fetch({success:function(b){a.$el.html(a.template(b.attributes)),a.albumList=new app.AlbumCollection,a.albumList.fetch({id:b.attributes.artistid,type:"artist",success:function(b){a.albumsView=new app.SmallAlbumsList({model:b}),$("#sidebar-first .other-albums").html(a.albumsView.render().el),$(".album-row-"+a.model.attributes.albumid).addClass("active")}})}}),this}}),app.AlbumsList=Backbone.View.extend({tagName:"div",className:"artist-list-view",initialize:function(){var a=this;this.model.on("reset",this.render,this),this.model.on("add",function(b){a.$el.append(new app.AlbumItemView({model:b}).render().el)})},render:function(){return this.$el.empty(),_.each(this.model.models,function(a){this.$el.append(new app.AlbumItemView({model:a}).render().el)},this),this}}),app.AlbumItemView=Backbone.View.extend({tagName:"div",initialize:function(){this.model.on("change",this.render,this),this.model.on("destroy",this.close,this)},render:function(){return this.$el.html(this.template(this.model.attributes)),$(".album-info",this.$el).html(new app.AlbumItemSmallView({model:this.model}).render().$el),$(".tracks",this.$el).html(new app.SongListView({model:this.model.attributes.songs}).render().el),this}}),app.SmallAlbumsList=Backbone.View.extend({tagName:"ul",className:"album-list-small",render:function(){return this.$el.empty(),_.each(this.model.models,function(a){this.$el.append(new app.AlbumItemSmallView({model:a}).render().el)},this),this}}),app.AlbumItemSmallView=Backbone.View.extend({tagName:"li",className:"album-small-item card",events:{"click .album-play":"playAlbum","click .album-add":"addAlbum","click .album-thumbsup":"thumbsUp","click .actions-wrapper":"viewAlbum","click .album-menu":"menu"},initialize:function(){this.model.on("change",this.render,this),this.model.on("destroy",this.close,this)},render:function(){var a=this.model.attributes;return a.title="undefined"!=typeof a.label?a.label:a.album,a.url="#album/"+a.albumid,a.img=app.parseImage(a.thumbnail),a.recenttext="undefined"!=typeof a.recent?"Recently "+a.recent:"",a.artisturl=""!==a.artistid?"#artist/"+a.artistid:"#artists",this.$el.html(this.template(a)),app.helpers.isDefaultImage(a.img)||this.$el.addClass("has-thumb"),app.playlists.isThumbsUp("album",a.albumid)&&this.$el.addClass("thumbs-up"),"undefined"!=typeof a.recent&&this.$el.addClass("recent"),this},menu:function(a){a.stopPropagation(),a.preventDefault();var b=app.helpers.menuTemplates("album",this.model.attributes);app.helpers.menuDialog(b)},playAlbum:function(a){a.stopPropagation(),a.preventDefault();var b=this.model.attributes;"local"==app.audioStreaming.getPlayer()?app.playlists.playlistAddItems("local","replace","album",b.albumid):app.AudioController.playlistClearAdd("albumid",b.albumid,function(){app.AudioController.playPlaylistPosition(0,function(){app.AudioController.playlistRender()})})},addAlbum:function(a){a.stopPropagation(),a.preventDefault();var b=this.model.attributes;"local"==app.audioStreaming.getPlayer()?app.playlists.playlistAddItems("local","append","album",b.albumid):app.AudioController.playlistAdd("albumid",b.albumid,function(){app.notification(b.album+" added to the playlist"),app.AudioController.playlistRender()})},thumbsUp:function(a){a.stopPropagation(),a.preventDefault();var b=this.model.attributes,c=b.albumid,d=app.playlists.isThumbsUp("album",c)?"remove":"add",e=$(a.target).closest(".card");app.playlists.setThumbsUp(d,"album",c),e.toggleClass("thumbs-up")},viewAlbum:function(a){a.stopPropagation(),a.preventDefault();var b=this.model.attributes.albumid;window.location="#album/"+b}}),app.ArtistView=Backbone.View.extend({events:{"click .artist-play":"playArtist","click .artist-add":"addArtist","click .artist-thumbsup":"thumbsUp","click .artist-fanart":"toggleFanart","click .artist-menu":"menu"},initialize:function(){this.artistsList||(this.artistsList=new app.ArtistCollection,this.artistsListView=new app.AristsListView({model:this.artistsList,className:"artist-list"}))},render:function(){this.$el.html(this.template(this.model.attributes)),$("#artist-meta",this.el).html(new app.ArtistSummaryView({model:this.model}).render().el),$(".artist-row").removeClass("active");var a=$(".artist-row-"+this.model.id);return a.length>0&&(a.addClass("active"),$("#sidebar-first .sidebar-content").scrollTo(a)),this},menu:function(a){a.stopPropagation(),a.preventDefault();var b=app.helpers.menuTemplates("artist",this.model.attributes);app.helpers.menuDialog(b)},playArtist:function(){var a=this.model.attributes;"local"==app.audioStreaming.getPlayer()?app.playlists.playlistAddItems("local","replace","artist",a.artistid):app.AudioController.playlistClearAdd("artistid",a.artistid,function(){app.AudioController.playPlaylistPosition(0,function(){app.AudioController.playlistRender()})})},addArtist:function(){var a=this.model.attributes;"local"==app.audioStreaming.getPlayer()?app.playlists.playlistAddItems("local","append","artist",a.artistid):app.AudioController.playlistAdd("artistid",a.artistid,function(){app.notification(a.artist+" added to the playlist"),app.AudioController.playlistRender()})},thumbsUp:function(a){var b=(this.model.attributes,this.model.attributes.artistid),c=app.playlists.isThumbsUp("artist",b)?"remove":"add",d=$(a.target).closest(".artist-actions");app.playlists.setThumbsUp(c,"artist",b),d.toggleClass("thumbs-up")},toggleFanart:function(a){$(a.target).parent().toggleClass("full-size")}}),app.ArtistSummaryView=Backbone.View.extend({events:{"click p.description":"expandDetail"},initialize:function(){this.model.on("change",this.render,this)},render:function(){this.$el.html(this.template(this.model.attributes));var a=this;return a.albumList=new app.AlbumCollection,a.albumList.fetch({id:this.model.attributes.artistid,type:"artist",success:function(b){a.albumsView=new app.AlbumsList({model:b,className:"album-list"}),$("#album-list").html(a.albumsView.render().el);var c=app.helpers.parseArtistSummary(b);$(".artist-list .active .artist-meta").html(c),""!==a.model.attributes.fanart}}),this},expandDetail:function(){$(".artist-detail").toggleClass("full")}}),app.ArtistsView=Backbone.View.extend({initialize:function(){},render:function(){return this.$el.html(this.template()),this.renderSidebar(),this.artistsRand=new app.ArtistCollection,this.artistsRand.fetch({type:"rand",success:function(a){this.artistsRandView=new app.AristsRandView({model:a,className:"rand-list"}),$("#main-content").html(this.artistsRandView.render().el),app.helpers.addFreewall("ul.rand-list")}}),this},renderSidebar:function(){0===$(".artist-list .artist").length&&(this.artistsList=new app.ArtistCollection,this.artistsList.fetch({success:function(a){this.artistsListView=new app.AristsListView({model:a,className:"artist-list swiper-wrapper"}),app.helpers.setFirstSidebarContent(this.artistsListView.render().el)}}))}}),app.AristsListView=Backbone.View.extend({tagName:"ul",className:"nav nav-list",initialize:function(){var a=this;this.model.on("reset",this.render,this),this.model.on("add",function(b){a.$el.append(new app.ArtistListItemView({model:b}).render().el)})},render:function(){return this.$el.empty(),_.each(this.model.models,function(a){this.$el.append(new app.ArtistListItemView({model:a}).render().el)},this),this}}),app.ArtistListItemView=Backbone.View.extend({tagName:"li",className:"artist",events:{"click .play-artist":"playArtist"},initialize:function(){this.model.on("change",this.render,this),this.model.on("destroy",this.close,this)},render:function(){var a=this.model.attributes;return a.subtext="undefined"!=typeof a.genre?a.genre.join(", "):"",this.$el.html(this.template(a)),this},playArtist:function(a){a.preventDefault();var b=this.model.attributes;"local"==app.audioStreaming.getPlayer()?app.playlists.playlistAddItems("local","replace","artist",b.artistid):app.AudioController.playlistClearAdd("artistid",b.artistid,function(){app.AudioController.playPlaylistPosition(0,function(){app.AudioController.playlistRender()})})}}),app.AristsRandView=Backbone.View.extend({tagName:"ul",className:"random-block",initialize:function(){var a=this;this.model.on("reset",this.render,this),this.model.on("add",function(b){a.$el.append(new app.ArtistLargeItemView({model:b}).render().el)})},render:function(){return this.$el.empty(),_.each(this.model.models,function(a){this.$el.append(new app.ArtistLargeItemView({model:a}).render().el)},this),this}}),app.ArtistLargeItemView=Backbone.View.extend({tagName:"li",className:"artist-item-large card card-large",initialize:function(){this.model.on("change",this.render,this),this.model.on("destroy",this.close,this)},events:{"click .artist-play":"playArtist","click .artist-add":"addArtist","click .artist-thumbsup":"thumbsUp","click .actions-wrapper":"viewArtist","click .artist-menu":"menu"},render:function(){var a=this.model.attributes;return a.title="undefined"!=typeof a.label?a.label:a.artist,a.url="#album/"+a.artistid,a.img=""!==a.fanart?a.fanart:a.thumbnail,this.$el.html(this.template(a)),app.helpers.isDefaultImage(a.img)||this.$el.addClass("has-thumb"),app.playlists.isThumbsUp("artist",a.artistid)&&this.$el.addClass("thumbs-up"),this},menu:function(a){a.stopPropagation(),a.preventDefault();var b=app.helpers.menuTemplates("artist",this.model.attributes);app.helpers.menuDialog(b)},playArtist:function(a){a.stopPropagation(),a.preventDefault();var b=this.model.attributes;"local"==app.audioStreaming.getPlayer()?app.playlists.playlistAddItems("local","replace","artist",b.artistid):app.AudioController.playlistClearAdd("artistid",b.artistid,function(){app.AudioController.playPlaylistPosition(0,function(){app.notification("Now playing "+b.artist),app.AudioController.playlistRender()})})},addArtist:function(a){a.stopPropagation(),a.preventDefault();var b=this.model.attributes;"local"==app.audioStreaming.getPlayer()?app.playlists.playlistAddItems("local","append","artist",b.artistid):app.AudioController.playlistAdd("artistid",b.artistid,function(){app.notification(b.artist+" added to the playlist"),app.AudioController.playlistRender()})},thumbsUp:function(a){a.stopPropagation(),a.preventDefault();var b=this.model.attributes,c=b.artistid,d=app.playlists.isThumbsUp("artist",c)?"remove":"add",e=$(a.target).closest(".card");app.playlists.setThumbsUp(d,"artist",c),e.toggleClass("thumbs-up")},viewArtist:function(a){a.stopPropagation(),window.location="#artist/"+this.model.attributes.artistid}}),app.ContactView=Backbone.View.extend({render:function(){return this.$el.html(this.template()),this}}),app.CustomPlaylistSongListView=Backbone.View.extend({tagName:"ul",className:"playlist-song-list",events:{"click .playlist-append":"appendPlaylist","click .playlist-replace":"replacePlaylist","click .playlist-browser-replace":"browserReplacePlaylist","click .playlist-delete":"deleteCustomListPlaylist","click .thumbsup-append":"appendThumbsup","click .thumbsup-replace":"replaceThumbsup","click .thumbsup-browser-replace":"browserReplacePlaylist"},initialize:function(){},render:function(){var a=app.helpers.arg();"playlist"==a[0]&&(this.list=app.playlists.getCustomPlaylist(a[1])),"thumbsup"==a[0]&&(this.list=app.playlists.getThumbsUp("song")),this.$el.empty();var b=0;_.each(this.model.models,function(a){a.attributes.list=this.list,a.attributes.position=b,this.$el.append(new app.CustomPlaylistSongView({model:a}).render().el),b++},this),this.playlistBinds();var c=app.playlists.getDropdown();return this.$el.prepend(c),this},playlistBinds:function(){var a=this;$sortableCustom=this.$el,$sortableCustom.sortable({placeholder:"playlist-item-placeholder",handle:".song-title",items:"> li",axis:"y",update:function(){var b=[],c="thumbsup"==app.helpers.arg(0)?"thumbsup":app.helpers.arg(1),d=$("ul.playlist-song-list");d.find("div.playlist-item").each(function(c,d){var e=a.list.items[$(d).data("pos")];b.push(e)}),console.log(b,c),app.playlists.replaceCustomPlayList(c,b)}}).disableSelection()},appendPlaylist:function(a){a.preventDefault();var b=app.playlists.getCustomPlaylist(this.list.id);console.log(b.items),this.addCustomListToPlaylist(b.items),app.notification("Playlist updated")},replacePlaylist:function(a){a.preventDefault();var b=this.list.id,c=app.playlists.getCustomPlaylist(b);this.replacePlaylistItems(c.items)},browserReplacePlaylist:function(a){a.preventDefault(),"thumbsup"==app.helpers.arg(0)?app.playlists.playlistAddItems("local","replace","thumbsup","song"):app.playlists.playlistAddItems("local","replace","list",this.list.id)},deleteCustomListPlaylist:function(a){a.preventDefault();var b=this.list;app.helpers.confirm("Delete playlist for good? This cannot be undone",function(){app.playlists.deleteCustomPlaylist(b.id);var a=$("#content");a.find(".playlist-song-list").length>0&&a.html('
    Playlist removed
    ')})},appendThumbsup:function(a){a.preventDefault();var b=app.playlists.getThumbsUp("song");this.addCustomListToPlaylist(b.items),app.notification("Playlist updated")},replaceThumbsup:function(a){a.preventDefault();var b=app.playlists.getThumbsUp("song");this.replacePlaylistItems(b.items)},replacePlaylistItems:function(a){var b=this;app.helpers.confirm("Replace the current xbmc playlist with this list?",function(){app.AudioController.playlistClear(function(){b.addCustomListToPlaylist(a,function(){app.AudioController.playPlaylistPosition(0,function(){app.AudioController.playlistRender(),app.notification("Playlist updated and playing")})})})})},addCustomListToPlaylist:function(a,b){for(var c in a)"number"!=typeof a[c]&&(a[c]=a[c].file);app.AudioController.playlistAddMultiple("mixed",a,function(a){app.AudioController.playlistRender(),app.playlists.changePlaylistView("xbmc"),b&&b(a)})}}),app.CustomPlaylistSongSmallListView=Backbone.View.extend({tagName:"ul",className:"browser-playlist-song-list",render:function(){this.$el.empty();var a=0;return _.each(this.model.models,function(b){var c=b.attributes;c.pos=a,c.items=[],c.list="local",c.id||(c.id=c.songid),b.attributes=c,this.$el.append(new app.PlaylistItemView({model:c,className:"playlist-item browser-player"}).render().$el),a++},this),this.playlistBinds(),this},playlistBinds:function(){var a=this.$el,b=this;a.sortable({placeholder:"playlist-item-placeholder",handle:".playlist-play",items:"> li",axis:"y",update:function(){var a=[];b.$el.find("div.playlist-item").each(function(b,c){a.push($(c).data("id"))}),app.audioStreaming.sortableChangePlaylistPosition(a)}}).disableSelection()}}),app.CustomPlaylistSongView=Backbone.View.extend({tagName:"li",className:"song-row",events:{"dblclick .song-title":"loadSong","click .song-play":"loadSong","click .song-add":"addSong","click .song-thumbsup":"thumbsUp","click .song-remove":"removeSong","click .song-menu":"menu"},initialize:function(){},render:function(){return"undefined"==typeof this.model.attributes.position?(console.log("no position"),this):(app.playlists.isThumbsUp("song",this.model.attributes.songid)&&this.$el.addClass("thumbs-up"),this.$el.html(this.template(this.model.attributes)),this)},menu:function(){app.helpers.makeDropdown(app.helpers.menuDialog("song",this.model.attributes))},playSong:function(){var a=this.model.attributes,b=app.helpers.getSongKey(a);app.playlists.changePlaylistView("xbmc"),app.AudioController.insertAndPlaySong(b.type,b.id,function(){app.notification(a.label+" added to the playlist"),app.AudioController.playlistRender()})},addSong:function(){var a=this.model.attributes,b=app.helpers.getSongKey(a);app.AudioController.playlistAdd(b.type,b.id,function(){app.notification(a.label+" added to the playlist"),app.AudioController.playlistRender()})},thumbsUp:function(a){var b=this.model.attributes.songid,c=app.playlists.isThumbsUp("song",b)?"remove":"add",d=$(a.target).closest("li");app.playlists.setThumbsUp(c,"song",b),d.toggleClass("thumbs-up")},removeSong:function(a){var b=this.model.attributes.songid,c=this.model.attributes.list.id,d=$(a.target);app.playlists.deleteCustomPlaylistSong(c,b),d.closest("li").slideUp(function(){$(this).remove()})},downloadSong:function(a){var b=this.model.attributes.file;a.preventDefault(),app.AudioController.downloadFile(b,function(a){window.location=a})},addToCustomPlaylist:function(a){a.preventDefault();var b=this.model.attributes,c=app.helpers.getSongKey(b),d="file"==c.type?b:b.songid;console.log(d),app.playlists.saveCustomPlayListsDialog(c.type,[d])}}),app.FilesView=Backbone.View.extend({tagName:"ul",className:"files-list",initialize:function(){},render:function(){this.$el.empty();var a=$("#content"),b=$("#files-container",a),c=$('
      ');return 0===b.length&&a.html(this.template(this.model)),this.model.models.sort(function(a,b){return app.helpers.aphabeticalSort(a.attributes.title,b.attributes.title)}),_.each(this.model.models,function(a){""===a.attributes.filetype||"directory"==a.attributes.filetype?this.$el.append(new app.FileView({model:a}).render().el):c.append(new app.FileView({model:a}).render().el)},this),""!==c.html()?b.html(c):b.html('

      No music found in this folder

      '),this}}),app.FilesListView=Backbone.View.extend({tagName:"ul",className:"files-list",initialize:function(){},render:function(){return this.$el.empty(),this.model.models.sort(function(a,b){return app.helpers.aphabeticalSort(a.attributes.title,b.attributes.title)}),_.each(this.model.models,function(a){this.$el.append(new app.FileView({model:a}).render().el)},this),this}}),app.FileView=Backbone.View.extend({tagName:"li",className:"file-row",events:{"dblclick .file-item":"playDir","click .file-play":"playDir","click .file-type-directory":"clickDir","click .file-add":"addDir","click .file-menu":"menu"},initialize:function(){},render:function(){return this.$el.html(this.template(this.model.attributes)),this.$el=app.addOns.invokeAll("postProcessFileView",this.$el,this.model.attributes),this},menu:function(){this.model.attributes.label=this.model.attributes.title,app.helpers.menuDialog(app.helpers.menuTemplates("song",this.model.attributes))},clickDir:function(a){a.stopPropagation();var b=this.model.attributes,c=b.file,d=this,e=$(a.target).parent();app.addOns.invokeAll("clickDir",b),$("#sidebar-first li").removeClass("lowest"),e.addClass("loading"),app.cached.fileCollection=new app.FileCollection,app.cached.fileCollection.fetch({name:c,success:function(a){var c=new app.FilesView({model:a}).render().$el;0===d.$el.find("ul.files-list").length&&d.$el.append(c),e.addClass("lowest").removeClass("loading"),$("#folder-name").html(b.label)}})},playDir:function(a){a.stopPropagation();var b=this.model.attributes,c="file",d=b.file;("album"==b.type||"artist"==b.type||"song"==b.type)&&(c=b.type+"id",d=b.id),app.AudioController.insertAndPlaySong(c,d,function(){app.notification(b.label+" added to the playlist"),app.AudioController.playlistRender()})},addDir:function(a){a.stopPropagation();var b=this.model.attributes,c="file",d=b.file;("album"==b.type||"artist"==b.type||"song"==b.type)&&(c=b.type+"id",d=b.id),app.AudioController.playlistAdd(c,d,function(){app.notification(b.label+" added to the playlist"),app.AudioController.playlistRender()})},downloadSong:function(a){var b=this.model.attributes.file;a.preventDefault(),app.AudioController.downloadFile(b,function(a){window.location=a})},addToCustomPlaylist:function(a){a.preventDefault();var b=this.model.attributes;app.playlists.saveCustomPlayListsDialog("file",[b])}}),app.HomeView=Backbone.View.extend({events:{"click #logo":"showMeBtnClick"},render:function(){return this.$el.html(this.template(this.model)),this},showMeBtnClick:function(){}}),app.MoviesView=Backbone.View.extend({initialize:function(){},render:function(){return this}}),app.MovieListView=Backbone.View.extend({tagName:"ul",className:"video-list movie-list",initialize:function(){},events:{"click .next-page":"nextPage"},render:function(){if(this.$el.empty(),_.each(this.model.models,function(a){this.$el.append(new app.MovieListItemView({model:a}).render().el)},this),this.model.length>0){var a=$('
    • More...
    • ');this.$el.append(a)}return $(window).smack({threshold:.8}).then(function(){$("ul.movie-list").find(".next-page").trigger("click")}),this.$el.addClass("page-"+app.moviePageNum),this},nextPage:function(a){$(a.target).remove(),app.router.movies()}}),app.MovieListItemView=Backbone.View.extend({tagName:"li",className:"movie-item-content",events:{"click .movie-play":"playMovie","click .movie-add":"addMovie","click .movie-thumbsup":"thumbsUp","click .movie-menu":"menu","click .actions-wrapper":"view"},initialize:function(){this.model.on("change",this.render,this),this.model.on("destroy",this.close,this)},render:function(){var a=this.model.attributes;return a.thumbsup=app.playlists.isThumbsUp("movie",a.movieid),this.$el.html(this.template(a)),this},view:function(){document.location="#movie/"+this.model.attributes.movieid},menu:function(a){a.stopPropagation(),a.preventDefault();var b=app.helpers.menuTemplates("movie",this.model.attributes);app.helpers.menuDialog(b)},thumbsUp:function(a){a.stopPropagation(),a.preventDefault();var b=this.model.attributes,c=app.playlists.isThumbsUp("movie",b.movieid)?"remove":"add",d=$(a.target).closest(".movie-actions");app.playlists.setThumbsUp(c,"movie",b.movieid),d.toggleClass("thumbs-up")},playMovie:function(a){a.preventDefault(),a.stopPropagation(),app.VideoController.playVideoId(this.model.attributes.movieid,"movieid",function(){app.VideoController.playlistRender()})},addMovie:function(a){a.preventDefault(),a.stopPropagation(),app.VideoController.addToPlaylist(this.model.attributes.movieid,"movieid","add",function(){app.VideoController.playlistRender()})}}),app.MovieView=Backbone.View.extend({allMovieCache:[],initialize:function(){var a=this,b=new app.MovieAllCollection;b.fetch({success:function(b){console.log(b),a.allMovieCache=b}})},events:{"click .library-back":"libraryBack","click .library-next":"libraryNext","click .movie-play":"playMovie","click .movie-add":"addMovie","click .movie-thumbsup":"thumbsUp","click .movie-menu":"menu"},render:function(){var a=this.model.attributes;return a.thumbsup=app.playlists.isThumbsUp("movie",a.movieid),this.$el.html(this.template(a)),console.log(a),_.defer(function(){var b=$("#fanart-background",this.$el),c=app.parseImage(a.fanart,"fanart");b.backstretch(c)}),this},libraryBack:function(a){a.preventDefault(),window.history.back()},libraryNext:function(a){a.preventDefault();var b=!1,c=0,d=this;$.each(d.allMovieCache.models,function(a,e){var f=e.attributes;b===!0&&(c=parseInt(f.movieid),b=!1),f.movieid==d.model.attributes.id&&(b=!0)}),c>0&&(document.location="#movie/"+c)},menu:function(a){a.stopPropagation(),a.preventDefault();var b=app.helpers.menuTemplates("movie",this.model.attributes);app.helpers.menuDialog(b)},thumbsUp:function(a){a.stopPropagation(),a.preventDefault();var b=this.model.attributes,c=app.playlists.isThumbsUp("movie",b.movieid)?"remove":"add",d=$(a.target).closest(".movie-actions");app.playlists.setThumbsUp(c,"movie",b.movieid),d.toggleClass("thumbs-up")},playMovie:function(a){a.preventDefault(),app.VideoController.playVideoId(this.model.attributes.movieid,"movieid",function(){app.VideoController.playlistRender()})},addMovie:function(a){a.preventDefault(),app.VideoController.addToPlaylist(this.model.attributes.movieid,"movieid","add",function(){app.VideoController.playlistRender()})}}),app.playerStateView=Backbone.View.extend({initialize:function(){this.$body=$("body"),this.$nowPlaying=$("#now-playing")},render:function(){var a=this.model,b=$(window),c=app.helpers.varGet("lastPlaying","");this.$songs=$(".song"),a.playingItemChanged=c!=a.item.file,a.status=app.helpers.exists(a.player.speed)&&0===a.player.speed?"paused":a.status,app.state=a.status,this.model=a,app.helpers.varSet("lastPlaying",a.item.file),this.bodyClasses(),this.$songs.removeClass("playing-row"),"playing"==a.status||"paused"==a.status?(this.nowPlayingMinor(),a.playingItemChanged&&(this.nowPlayingMajor(),b.trigger("playingItemChange",a))):this.notPlaying(),this.playerCron(),b.trigger("playerUpdate",a)},bodyClasses:function(){var a=this.model;this.$body.removeClass("playing").removeClass("paused").removeClass("notPlaying").removeClass("random-on").removeClass("random-off").removeClass("repeat-off").removeClass("repeat-all").removeClass("repeat-one").addClass(a.status).addClass("random-"+(a.player.shuffled===!0?"on":"off")).addClass("repeat-"+a.player.repeat),this.$body.removeClass(function(a,b){return(b.match(/\bactivePlayer\S+/g)||[]).join(" ")}).addClass("activePlayer-"+a.activePlayer)},nowPlayingMinor:function(){this.tagPlayingRow(),this.setTitle();{var a=this.model,b=$("#time"),c=0,d=0,e=app.helpers.parseArtistsArray(a.item);$(".playlist .playing-row")}$(".playing-song-meta").html(e),app.shellView.$progressSlider.slider("value",a.player.percentage),1==a.activePlayer?(d=a.player.totaltime.hours+":"+a.player.totaltime.minutes+":"+a.player.totaltime.seconds,c=a.player.time.hours+":"+a.player.time.minutes+":"+a.player.time.seconds):0===a.activePlayer&&(d=app.helpers.secToTime(parseInt(a.item.duration)),c=app.helpers.secToTime(Math.floor(parseInt(a.player.percentage)/100*parseInt(a.item.duration)))),b.find(".time-cur").html(c),b.find(".time-total").html(d)},nowPlayingMajor:function(){var a=this.model;if(this.$nowPlaying.find("#playing-thumb").css("background-image","url('"+app.parseImage(a.item.thumbnail)+"')").attr("title",a.item.album).attr("href","#album/"+a.item.albumid),1==app.cached.nowPlaying.activePlayer&&this.$nowPlaying.find("#playing-thumb").attr("href","#"+a.item.type+"/"+a.item.albumid),$(".playing-song-title").html(a.item.label),"#"==location.hash||""===location.hash&&"xbmc"==app.audioStreaming.getPlayer()){var b=$(".backstretch img"),c=b.attr("src"),d=app.parseImage(a.item.fanart,"fanart"); -b.length>0&&c!=d&&$.backstretch(d)}0===app.cached.nowPlaying.activePlayer?app.AudioController.playlistRender():1==app.cached.nowPlaying.activePlayer&&app.VideoController.playlistRender()},tagPlayingRow:function(){var a=this.model;this.$songs.each(function(b,c){var d=$(c);d.attr("data-songid")!=a.item.id||d.hasClass("playlist-item")?d.hasClass("playlist-item")&&(d.data("id")!=a.player.position||d.parent().hasClass("browser-player")||d.data("playlistId")!=a.activePlayer||d.addClass("playing-row")):d.addClass("playing-row")})},setTitle:function(){var a=this.model,b=a.item.label;"xbmc"==app.audioStreaming.getPlayer()&&(document.title=("playing"==a.status?"â–¶ ":"")+(void 0!==b?b+" | ":"")+"Chorus.")},notPlaying:function(){this.model;document.title="Chorus.",$(".playing-song-title").html("Nothing Playing"),$(".playing-song-meta").html(""),$("ul.playlist div.playlist-item.playing-row").removeClass("playing-row"),app.shellView.$progressSlider.slider("value",0),this.$nowPlaying.find("#playing-thumb").attr("src",app.parseImage("")).attr("title","").parent().attr("href","#albums");var a=$("#time");a.find(".time-cur").html("0"),a.find(".time-total").html("0:00")},playerCron:function(){var a=this.model,b=app.helpers.varGet("lastState",""),c="undefined"==typeof b||"undefined"==typeof b.volume,d={},e="",f="";$("a.ui-slider-handle",app.shellView.$volumeSlider).hasClass(".ui-slider-active")||!c&&b.volume.volume==a.volume.volume||(app.shellView.$volumeSlider.slider("value",a.volume.volume),0===a.volume.volume?$("body").addClass("muted"):$("body").removeClass("muted")),(c||"undefined"==typeof b.player||b.player.repeat!=a.player.repeat)&&(d=$(".player-repeat"),e=d.attr("title"),f="off"==a.player.repeat?"Repeat is off":"Currently repeating "+a.player.repeat,e!=f&&d.attr("title",f)),(c||b.player.shuffled!=a.player.shuffled)&&(d=$(".player-random"),e=d.attr("title"),f="Random is "+(a.player.shuffled===!0?"On":"Off"),e!=f&&d.attr("title",f)),app.helpers.varSet("lastState",a)}}),app.PlaylistView=Backbone.View.extend({tagName:"div",className:"playlist-wrapper",events:{"click .player-audio":"viewAudio","click .player-video":"viewVideo"},initialize:function(){},render:function(){this.$el.empty();var a=0,b=$('
        '),c=$('
          '),d="undefined"!=typeof this.model.playlistId?this.model.playlistId:0;return _.each(this.model.models,function(b){b.pos=a,a++,b.playlistId=d,c.append(new app.PlaylistItemView({model:b}).render().el)},this),this.$el.append(c),app.playlists.getThumbsUp(),$(window).bind("playlistUpdate",this.playlistBinds()),b.append('
        • Audio
        • '),b.append('
        • Video
        • '),this.$el.prepend(b),this.$el.addClass("plid-"+d),this},playlistBinds:function(){$sortable=$("ul.playlist"),$sortable.sortable({placeholder:"playlist-item-placeholder",handle:".playlist-play",items:"> li",axis:"y",update:function(a,b){app.playlists.sortableChangePlaylistPosition(a,b)}}).disableSelection()},viewAudio:function(){app.AudioController.playlistRender()},viewVideo:function(){app.VideoController.playlistRender()}}),app.PlaylistItemView=Backbone.View.extend({tagName:"li",className:"playlist-item",events:{"dblclick .playlist-play":"playPosition","click .removebtn":"removePosition","click .playbtn":"playPosition","click .repeating":"cycleRepeat","click .playlist-song-thumbsup":"thumbsUp","click .playlist-song-menu":"menu"},initialize:function(){},render:function(){var a=this.model;return a.id="undefined"!=typeof a.id?a.id:"file",a.albumid="undefined"!=typeof a.albumid?a.albumid:"file",a.subLink=this.buildSubLink(a),a.url="file"!=a.albumid?"#album/"+a.albumid:app.helpers.buildUrl(a.type,a.id),this.$el.html(this.template(a)),"file"==this.model.id&&$(".song",this.$el).data("file",a.file),$(".song",this.$el).data("playlistId",a.playlistId),"file"!=this.model.id&&app.playlists.isThumbsUp("song",this.model.id)&&this.$el.addClass("thumbs-up"),this},menu:function(){1==this.model.playlistId?app.helpers.menuDialog(app.helpers.menuTemplates("movie",this.model)):app.helpers.menuDialog(app.helpers.menuTemplates("song",this.model))},playPosition:function(){if("local"==this.model.list)app.audioStreaming.playPosition(this.model.pos);else{var a=1==this.model.playlistId?app.VideoController:app.AudioController;a.playPlaylistPosition(this.model.pos,function(){a.playlistRender()})}},removePosition:function(){if("local"==this.model.list)app.audioStreaming.deleteBrowserPlaylistSong(this.model.pos),app.audioStreaming.renderPlaylistItems();else{var a=1==this.model.playlistId?app.VideoController:app.AudioController;a.removePlaylistPosition(this.model.pos,function(){a.playlistRender()})}},cycleRepeat:function(){$("#footer").find(".player-repeat").trigger("click")},thumbsUp:function(a){a.stopPropagation();var b=this.model.id,c=1==this.model.playlistId?"video":"song",d=app.playlists.isThumbsUp(c,b)?"remove":"add",e=$(a.target).closest("li");app.playlists.setThumbsUp(d,c,b),e.toggleClass("thumbs-up")},buildSubLink:function(a){var b,c,d;if("song"==a.type){if(a.albumArtistString="undefined"!=typeof a.albumartist&&"undefined"!=typeof a.albumartist[0]?a.albumartist[0]:"",a.artistString="undefined"!=typeof a.artist&&"undefined"!=typeof a.artist[0]?a.artist[0]:"",d="Track: "+this.model.track+" Duration: "+app.helpers.secToTime(this.model.duration),b="#search/"+(""!==a.albumArtistString?a.albumArtistString:a.artistString),c=""!==a.artistString?a.artistString:a.albumArtistString,""===a.artistString&&""===a.albumArtistString)return""}else{if("movie"!=a.type&&"tvshow"!=a.type&&"episode"!=a.type)return"";c=a.year,b="#movies/year/"+a.year,d="More movies from "+c}return''+c+""}}),app.PlaylistCustomListsView=Backbone.View.extend({tagName:"ul",className:"custom-lists",events:{"dblclick li":"replacePlaylist","click .name":"toggleDetail"},initialize:function(){},render:function(){this.$el.empty();var a=0;return _.each(this.model.models,function(b){b.pos=a,a++;var c=new app.PlaylistCustomListItemView({model:b}).render();this.$el.append(c.el)},this),this.$el.prepend(''),this},toggleDetail:function(a){var b=$(a.target),c=b.closest("li");c.hasClass("open")?c.removeClass("open"):(c.parent().find("li").removeClass("open"),c.addClass("open"))}}),app.PlaylistCustomListItemView=Backbone.View.extend({tagName:"li",className:"list-item",events:{"dblclick .name":"replacePlaylist"},initialize:function(){},render:function(){return this.$el.html(this.template(this.model.attributes)),this}}),app.searchView=Backbone.View.extend({initialize:function(){},render:function(){var a=this.model.key,b=this;if(a.length>1){document.location.hash="#search/"+a,app.shellView.selectMenuItem("search","sidebar");var c=$("#content"),d=$("#title"),e='
          No Artists found
          ',f=$('
          ');f.append('
          ').append('
          ').append('
          '),c.empty().html(f),d.html('Artists Albums'),app.cached.SearchArtistsList=new app.ArtistCollection,app.cached.SearchArtistsList.fetch({success:function(b){var c=b.models.filter(function(b){var c=b.attributes.artist;return c.toLowerCase().indexOf(a.toLowerCase())>-1});b.models=c,b.models.length>0?(app.cached.artistsListSearch=new app.AristsListView({model:b,className:"artist-search-list"}),app.helpers.setFirstSidebarContent(app.cached.artistsListSearch.render().el)):app.helpers.setFirstSidebarContent(e)}});var g=$("#search-albums"),h='
          '+b.getLogo("album")+"Loading Albums
          ",i='
          '+b.getLogo("album")+'No Albums found with "'+a+'" in the title
          ';g.html(h),app.cached.SearchAlbumList=new app.AlbumsCollection,app.cached.SearchAlbumList.fetch({success:function(c){g.empty();var d=c.models.filter(function(b){var c=b.attributes.label;return c.toLowerCase().indexOf(a.toLowerCase())>-1});c.models=d,c.models.length>0?(app.cached.SearchAlbumListSmall=new app.SmallAlbumsList({model:c,className:"album-generic-list"}),g.append(app.cached.SearchAlbumListSmall.render().el),g.prepend('

          '+b.getLogo("album")+"Album search for:"+a+"

          ")):g.html(i)}});var j=$("#search-addons");j.empty(),app.addOns.ready(function(){j=app.addOns.invokeAll("searchAddons",j,a)}),b.searchSongs(a)}},getLogo:function(a){return''},searchSongs:function(a){var b=$("#search-songs"),c=this;b.html('
          '+c.getLogo("song")+"Loading Songs
          "),app.store.indexSongs(function(){app.cached.SearchsongList=new app.SongCollection,app.cached.SearchsongList.fetch({success:function(d){var e=[];b.empty();var f=d.models.filter(function(b){var c=b.attributes.label;return c.toLowerCase().indexOf(a.toLowerCase())>-1});_.each(f,function(a){e.push(a.attributes.songid)}),e.length>0?(app.cached.SearchsongListFiltered=new app.CustomSongCollection,app.cached.SearchsongListFiltered.fetch({items:e,success:function(d){b.append('

          '+c.getLogo("song")+"Songs search for:"+a+"

          "),app.cached.SearchsongList=new app.SongListView({model:d.models,className:"song-search-list song-list"}),b.append(app.cached.SearchsongList.render().el)}})):b.html('
          '+c.getLogo("song")+"No Songs found
          ")}})})}}),app.ShellView=Backbone.View.extend({initialize:function(){var a=$(window),b=$("body"),c=this;app.cached.keyupTimeout=0,c.pageChange(location.hash,"#init"),a.bind("hashchange",function(a){var b=location.hash,d=app.vars.lastHash,e="undefined"==typeof d?"#":d;b!=e&&c.pageChange(b,e),app.vars.backHash=d,app.vars.lastHash=b,$(window).trigger("pageChange",[a,b,e])}),a.bind("scroll",function(){a.scrollTop()>50?b.addClass("fixed-header"):b.removeClass("fixed-header")})},render:function(){this.$el.html(this.template());return app.AudioController.playlistRender(),this.$progressSlider=$("#progress-bar",this.el),this.$progressSlider.slider({range:"min",value:0,min:0,max:100,stop:function(a,b){app.AudioController.seek(b.value)}}),this.$volumeSlider=$("#volume",this.el),this.$volumeSlider.slider({range:"min",value:0,min:0,max:100,stop:function(a,b){app.AudioController.setVolume(b.value)}}),setInterval(app.AudioController.updatePlayerState,5e3),this},events:{"keyup #search":"onkeyupSearch","click #search-this":"search","keypress #search":"onkeypressSearch","click #logo":"home","click .player-prev":"playerPrev","click .player-next":"playerNext","click .player-play":"playerPlay","click .player-mute":"playerMute","click .player-repeat":"playerRepeat","click .player-random":"playerRandom","click .playlist-primary-tab":"primaryTabClick","click .save-playlist":"savePlayList","click .clear-playlist":"clearPlaylist","click .refresh-playlist":"refreshPlaylist","click .new-custom-playlist":"newCustomPlaylist","click .about-dialog":"about","click .browser-view-xbmc":"viewXbmc","click .browser-view-local":"viewLocal","click .browser-player-play":"localTogglePlay","click .browser-player-prev":"localPrev","click .browser-player-next":"localNext","click .browser-player-repeat":"localRepeat","click .browser-player-random":"localRandom","click .browser-player-mute":"localMute"},pageChange:function(){var a=app.helpers.arg(0);$("body").removeClass(function(a,b){return(b.match(/\bsection\S+/g)||[]).join(" ")}).addClass("section-"+a)},primaryTabClick:function(a){$thisTab=$(a.target),$thisTab.hasClass("playlist-primary-tab")||($thisTab=$thisTab.closest("li.playlist-primary-tab"));var b=$thisTab.data("pane");app.playlists.changePlaylistView(b)},search:function(){var a=$("#search");app.cached.searchView=new app.searchView({model:{key:a.val()}}),app.cached.searchView.render()},onkeyupSearch:function(){var a=500,b=this;$("#search").keyup(function(){clearTimeout(app.cached.keyupTimeout),app.cached.keyupTimeout=setTimeout(function(){b.search()},a)})},onkeypressSearch:function(a){13===a.keyCode&&a.preventDefault()},selectMenuItem:function(a,b){var c=$("body"),d="undefined"!=typeof b&&"sidebar"==b?"open":"close";if(app.helpers.toggleSidebar(d),"home"==a)c.addClass("home");else switch($(".backstretch").length>0&&$.backstretch("destroy",!1),c.removeClass("home"),a){case"playlist":$("ul.custom-lists .custom-playlist-item").each(function(a,b){var c=$(b),d=c.parent();c.data("id")==app.helpers.arg(1)?d.addClass("open"):d.removeClass("open")});break;case"thumbsup":$(".custom-lists li").removeClass("open"),$(".thumbsup-link").addClass("open")}if(a){var e=$(".mainnav",this.el),f=e.find("li.nav-"+a);e.find("li").removeClass("active"),f.addClass("active")}},playerPrev:function(){app.AudioController.sendPlayerCommand("Player.GoTo","previous")},playerNext:function(){app.AudioController.sendPlayerCommand("Player.GoTo","next")},playerPlay:function(){app.AudioController.sendPlayerCommand("Player.PlayPause","toggle")},playerRepeat:function(){app.AudioController.sendPlayerCommand("Player.SetRepeat","cycle")},playerRandom:function(){app.AudioController.sendPlayerCommand("Player.SetShuffle","toggle")},playerMute:function(){var a,b=this.$volumeSlider.slider("value"),c=$("body");b>0?(this.lastVol=b,app.AudioController.setVolume(0),this.$volumeSlider.slider("value",0),c.addClass("muted")):(a=app.helpers.exists(this.lastVol)&&this.lastVol>0?this.lastVol:50,app.AudioController.setVolume(a),this.$volumeSlider.slider("value",a),c.removeClass("muted"))},updateState:function(a){app.cached.playerState=new app.playerStateView({model:a}),app.cached.playerState.render()},savePlayList:function(a){a.preventDefault(),app.playlists.saveCustomPlayListsDialog(),app.playlists.changePlaylistView("local")},refreshPlaylist:function(a){a.preventDefault(),app.AudioController.playlistRender()},newCustomPlaylist:function(a){a.preventDefault(),app.playlists.saveCustomPlayListsDialog("song",[])},clearPlaylist:function(a){a.preventDefault(),app.AudioController.playlistClear(function(){app.AudioController.playlistRender()})},about:function(a){a.preventDefault(),app.helpers.aboutDialog()},viewXbmc:function(a){a.preventDefault(),app.audioStreaming.setPlayer("xbmc")},viewLocal:function(a){a.preventDefault(),app.audioStreaming.setPlayer("local")},localTogglePlay:function(a){a.preventDefault(),app.audioStreaming.togglePlay()},localPrev:function(a){a.preventDefault(),app.audioStreaming.prev()},localNext:function(a){a.preventDefault(),app.audioStreaming.next()},localRepeat:function(a){a.preventDefault(),app.audioStreaming.repeat()},localRandom:function(a){a.preventDefault(),app.audioStreaming.random()},localMute:function(a){a.preventDefault(),app.audioStreaming.mute()}}),app.SongListView=Backbone.View.extend({tagName:"ul",className:"song-list",initialize:function(){},render:function(){return this.$el.empty(),_.each(this.model,function(a){this.$el.append(new app.SongView({model:a}).render().el)},this),this}}),app.SongView=Backbone.View.extend({tagName:"li",className:"song-row",events:{"dblclick .song-title":"playSong","click .song-play":"playSong","click .song-add":"addSong","click .song-thumbsup":"thumbsUp","click .song-menu":"menu"},initialize:function(){this.model.on("change",this.render,this),this.model.on("destroy",this.close,this)},render:function(){return app.playlists.isThumbsUp(this.model.attributes.songid)&&this.$el.addClass("thumbs-up"),this.$el.html(this.template(this.model.attributes)),this},menu:function(){app.helpers.menuDialog(app.helpers.menuTemplates("song",this.model.attributes))},playSong:function(){var a=this.model.attributes;"local"==app.audioStreaming.getPlayer()?app.playlists.playlistAddItems("local","append","song",a.songid,function(){app.audioStreaming.playPosition(app.audioStreaming.playList.items.models.length-1)}):(app.playlists.changePlaylistView("xbmc"),app.AudioController.insertAndPlaySong("songid",a.songid,function(){app.notification(a.label+" added to the playlist"),app.AudioController.playlistRender()}))},addSong:function(){var a=this.model.attributes;"local"==app.audioStreaming.getPlayer()?app.playlists.playlistAddItems("local","append","song",a.songid):app.AudioController.playlistAdd("songid",a.songid,function(){app.notification(a.label+" added to the playlist"),app.AudioController.playlistRender()})},thumbsUp:function(a){var b=this.model.attributes.songid,c=app.playlists.isThumbsUp("song",b)?"remove":"add",d=$(a.target).closest("li");app.playlists.setThumbsUp(c,"song",b),d.toggleClass("thumbs-up")}}),app.XbmcView=Backbone.View.extend({tagName:"div",className:"xbmc-page",initialize:function(){},render:function(){console.log(this.model);var a={jsonrpc:"An interface to deal directly with the xbmc jsonrpc",storage:"Local Storage Data Dump",changelog:"Updates to Chorus"};switch(this.model){case"jsonrpc":return this.$el=(new app.XbmcJSONrpcView).render().$el,this;case"storage":return this.$el=(new app.XbmcLocalDumpView).render().$el,this;case"changelog":return this.$el=(new app.XbmcChorusChangeLog).render().$el,this}this.$el=$('
            ');for(var b in a){var c=$("
          • ").append('

            '+b+"

            ").append("

            "+a[b]+"

            ");this.$el.append(c)}return this}}),app.XbmcLocalDumpView=Backbone.View.extend({tagName:"div",className:"xbmc-page",initialize:function(){},render:function(){var a=[app.playlists.storageKeyLists,app.playlists.storageKeyThumbsUp],b=this;return this.$el.empty(),$(a).each(function(a,c){var d=$("
            ");d.prependTo("

            "+c+"

            "),app.storageController.getStorage(c,function(a){console.log(a);var e={};e[c]=a,d.html(JSON.stringify(e,null,4)),b.$el.append(d)})}),this}}),app.XbmcChorusChangeLog=Backbone.View.extend({tagName:"div",className:"xbmc-page changelog",render:function(){var a=this;return this.$el.html("Loading ChangeLog"),$.get("changelog.txt",function(b){a.$el.html(app.nl2br(b)),app.helpers.setTitle('XBMCChorus ChangeLog')}),this}}),app.XbmcJSONrpcView=Backbone.View.extend({tagName:"div",className:"xbmc-page",events:{"change #method":"changeMethod","click #doit":"executeQuery"},initialize:function(){},render:function(){app.helpers.setTitle('XBMCjsonRPC'),this.$el.empty();var a='

            JSONrpc tester

            Use this to test out commands on the api, be careful - you could break something

            Method:
            Loading

            Result

            ';return this.$el.html(a),this.$select=$("#method",this.$el),this.$res=$("#result",this.$el),this.$params=$("#params",this.$el),this.executeForm(),this},executeForm:function(){var a=this;app.xbmcController.command("JSONRPC.Introspect",[],function(b){app.cached.Introspect=b.result,a.$select.empty();for(var c in b.result.methods)a.$select.append($("