forked from iclanzan/songpane-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
1 lines (1 loc) · 30.1 KB
/
app.js
1
app=angular.module("SongPane",[]),function(e){e.config(["$routeProvider",function(e){e.when("/").when("/set/:setId/:songId").when("/:view/:songId").otherwise("/")}]).run(["$rootScope","collection","util","transitioner","keyboard","modal","notifier","$window","locale",function(e,t,n,o,r,i,a,s,c){var u,l,d=(s.navigator,c._);s.notify=a.notify,e._=d,e.change=!1,e.$on("ready",function(){e.ready=!0}),u=e.sets=t({songs:[],isNeeded:function(e){var t=this.songs,o=e.songs;return o.forEach(function(e){var r=e._id;o[r]=e,n.list(t,r)}),!0},getSong:function(e,t){var n,o,r=this[e].songs;for(o=0,n=r.length;n>o;o++)if(r[o]._id==t)return r[o]},url:"sets.json"}),l=e.songs=t({url:"songs.json",getKey:function(e,t){var n=t&&u.getSong(t,e),o=l[e];return n&&n.key||o.key}}),u.run(function(){l.run(function(){e.$emit("ready")})}),e.modal=i,e.toggleState=function(t){e[t]=!e[t],e.changedState=!0},e.resetState=function(){return e.changedState?(e.changedState=!1,undefined):(["menu","em"].forEach(function(t){e[t]&&(e[t]=!1)}),undefined)},r.on("ctrl+shift",function(){e.slow=!e.slow}).on(["h","?"],function(){return i("keyboard"),e.$apply(),!1}).on("esc",function(){return!1})}])}(app),app.controller("addController",["$scope","$routeParams","$rootScope",function(e,t,n){var o=n.sets;n.songs,e.s=o.filter(function(e){return o.isWriter(e)}),e.addNew=function(e){var n=t.songId;return o.save({title:e,songs:[{_id:n}]})},e.addExisting=function(e){var n=t.songId,r=o[e],i=r.songs;return i[n]?!0:(i.push(i[n]={_id:n}),o.save(r))}}]),app.controller("confirmController",["$scope","$routeParams","$rootScope","util","$location",function(e,t,n,o,r){var i=n.sets,a=n.songs;e.trashSong=function(){var e=t.songId,n=t.setId;return i.forEach(function(t){o.unlist(t.songs,e)||i.remove(t._id)}),r.path((n?"set":t.view)+"/"+(i[n]?n+"/":"")),a.remove(e)}}]),app.controller("newController",["$scope","$rootScope","transposer","songMode","$routeParams","util","locale","notifier",function(e,t,n,o,r,i,a,s){var c=t.songs,u=r.edit,l=a._;e.songMode=o,e.langs=a.langs,u&&(e.song=i.extend({},c[r.songId]),"clone"==u&&delete e.song._id,e.song.tempo=e.song.tempo-0),e.saveSong=function(e,t){var o="("+n.getScale(e.key).join("|")+")";return~e.body.search("^(?:\\[[1-9BCPIO]\\]\\n(?:(?: *"+o+"[1-9adgijmsu,\\(\\)]*(?:\\/"+o+")?)*\\n[^\\[\\n].+\\S(?:\\n|$))+)+$")?(e._acl={},t&&(e._acl={gr:!1}),c.save(e)):(s.notify({message:l.checkBody,icon:"alert"}),void 0)},e.keys=n.getAllKeys()}]),app.controller("renameController",["$scope","$rootScope",function(e,t){var n=t.sets;e.renameSet=function(e,t){var o=n[e];return t!==o.title?(o.title=t,n.save(o)):!1}}]),app.controller("searchController",["$scope","$rootScope","locale",function(e,t,n){t.songs,e._=n._,e.message="",e.search=function(){}}]),app.controller("settingsController",["$scope","settings",function(e,t){e.s=t.settings,e.toggle=function(e){t.toggle(e)},e.setFont=function(e){t.set("fontSize",e)}}]),app.controller("shareController",["$scope","$routeParams","$rootScope","md5","util",function(e,t,n,o,r){var i=r.list,a=r.unlist,s=n.sets,c=t.setId,u=e.e=s.getWriters(c).slice(0),l=e.c=s.getReaders(c).slice(0);e.owner=s.getOwner(c),e.md5=o,e.allowAccess=function(e,t){return i(l,e),"edit"==t?i(u,e):a(u,e),!0},e.denyAccess=function(e){a(u,e),a(l,e)},e.isOwner=function(){return s.isOwner(s[c])},e.save=function(){return s.setReaders(c,l).setWriters(c,u).save(s[c])}}]),app.controller("uiController",["$scope","$rootScope","$routeParams","$location","settings","util","keyboard","transposer","transitioner","locale","$timeout","modal",function(e,t,n,o,r,i,a,s,c,u,l,d){function f(e,t,n){var o,r,a,c,u,l,d,f,p,h=[];return e.split("[").forEach(function(e){if(""!==e){for(o=e.split("]"),l="",a=o[1].replace(/[\r\t\v\f\0\x0B]|^\n+|\s+$/g,"").split("\n"),c=0,u=a.length;u>c;c+=2){for(r=a[c+1],r.length<a[c].length&&(r+=i.pad(a[c].length-r.length," ")),p=0,d=/\S+/g;f=d.exec(a[c]);)l+=r.substring(p,f.index)+'<span class="c"><span>'+(t!==n?s.transpose(f[0],t,n):f[0])+"</span></span>",p=f.index;l+=a[c+1].substr(p)+"\n"}h.push({type:o[0].toLowerCase(),text:l})}}),h}var p=u._,h=t.sets,g=t.songs,v=t.songSlide={to:"left"},m=t.viewSlide={to:"left"};t.r=n,t.p=function(e){o.path(e)},t.q=function(e,t){o.search(e,t)},t._=p,e.s=r.settings,e.nextSong=function(){var e,t,r=n.setId,i=n.songId;r&&i&&(e=h[r].songs,e.forEach(function(e,n){e._id==i&&(t=n)}),e.length-1>t?t++:t=0,o.path("/set/"+r+"/"+e[t]._id))},e.prevSong=function(){var e,t,r=n.setId,i=n.songId;r&&i&&(e=h[r].songs,e.forEach(function(e,n){e._id==i&&(t=n)}),t>0?t--:t=e.length-1,o.path("/set/"+r+"/"+e[t]._id))},e.getKeys=function(){return n.songId&&g[n.songId]&&s.getKeys("m"===g[n.songId].key.slice(-1))||[]},e.pad=i.pad,e.trashSet=function(){o.path("/"),h.remove(n.setId)},e.duplicateSet=function(){var e=h[n.setId];o.path("set/"+h.save({title:e.title+" ("+p.copy+")",songs:e.songs.slice(0)})+"/")},e.rmSong=function(t){var r=n.setId,i=h[r],a=i.songs;o.path("set/"+r+"/"),a.splice(t,1),a.length?h.save(i):e.trashSet()},e.curKey=function(){var e=n.songId;return e&&g.getKey(e,n.setId)},e.updateKey=function(t,o){var r,i,a=n.setId,s=n.songId,c=g[s];a&&(r=h[a],i=h.getSong(a,s),t!==c.key?i.key=t:delete i.key,!o&&h.save(r)),e.k!=t&&(v.model=f(c.body,c.key,t),e.k=t)},e.clean=function(e){delete this[e]},e.sortSet=function(e,t){i.move(h,e,t)},e.sortSong=function(e,t){var o=h[n.setId];i.move(o.songs,e,t),h.save(o)},e.isSongOwner=function(){return n.songId&&g.isOwner(g[n.songId])},e.editSong=function(e){o.search("edit",e?"clone":void 0),d("new")},e.canChangeKey=function(){var e=n.setId;return e?h.isWriter(h[e]):!0},e.$on("$routeChangeSuccess",function(t,n,r){if("/"===o.path())return h.length?o.path("sets/"):o.path("search/"),void 0;if(n){var i,a,s,u,l=n.params.view,d=n.params.setId,p=n.params.songId;if(r&&(i=r.params.view,a=r.params.setId,s=r.params.songId),l){if(-1==["sets","catalog","search"].indexOf(l))return h.length?o.path("sets/"):o.path("search/"),void 0;a?(m.to="right",m.model=l):l!=i&&(m.to="left",m.model=l)}if(d){if(!h[d])return h.length?o.path("sets/"):o.path("search/"),void 0;d!=a&&(m.force=!0,m.to="left",m.model="set")}if(p){if(!g[p])return o.path(l+"/"),void 0;u=f(g[p].body,g[p].key,g.getKey(p,d)),e.k=e.curKey(),r?p!==s&&(a&&a===d&&h[d].songs.indexOf(p)<h[d].songs.indexOf(s)?(v.to="right",v.model=u):(v.to="left",v.model=u)):(v.to="left",v.model=u)}else s&&c.apply("song-view",function(){v.model=""})}}),a.on(["left","k"],function(){return e.$apply(function(){e.prevSong()}),!1}).on("c",function(){return e.$apply(function(){r.toggle("hideChords")}),!1}).on("=",function(){var t=r.settings.fontSize||0;2>t&&(r.set("fontSize",t+1),e.$apply())}).on("-",function(){var t=r.settings.fontSize||0;t&&(r.set("fontSize",t-1),e.$apply())}),e.$emit("$routeChangeSuccess",{params:n})}]),app.directive("editor",["$window","util","parse",function(e,t,n){var o=e.document,r=e.setTimeout,i=e.clearTimeout;return{restrict:"E",replace:!0,transclude:!0,scope:{mode:"&",placeholder:"@",model:"="},template:'<div class="editor"><div class="editor-inner"><div></div><span class="hide"></span><textarea class="input" placeholder="{{placeholder}}" ng-model="model" ng-transclude></textarea></div></div>',link:function(e,a){a=a.children()[0];var s,c=a.children,u=c[0],l=t.element(c[1]),d=c[2],f=e.mode(),p=t.throttle,h=0,g=function(){var e=d.selectionStart||0;e!=h&&(l.attr("pad",d.value.substr(0,e)).removeClass("hide"),h=e)},v=function(){var e=o.createElement("div");g(),n(d.value,f,function(t,n){var r;n&&"chords"!=n?(r=e.appendChild(o.createElement("span")),r.className=n):r=e,r.appendChild(o.createTextNode(t))}),a.replaceChild(e,u),u=e};t.element(d).bind("input",p(v,10)).bind("focus",function(){(function e(){g(),i(s),s=r(e,100)})()}).bind("blur",function(){i(s),l.addClass("hide"),h=null}),r(v,50)}}}]),app.directive("spFocus",["$timeout","util",function(e){function t(e){if(e&&0!==e.length){var t=(""+e).toLowercase;e=!("f"==t||"0"==t||"false"==t||"no"==t||"n"==t||"[]"==t)}else e=!1;return e}return function(n,o,r){function i(){e(function(){a.focus()},400)}var a=o[0];0===r.spFocus.length?i():n.$watch(r.spFocus,function(e){t(e)&&a.focus()})}}]),app.directive("spIf",function(){return{transclude:"element",priority:1e3,terminal:!0,compile:function(e,t,n){return function(e,t,o){var r,i;e.$watch(o.spIf,function(o){o?r||(i=e.$new(),n(i,function(e){r=e,t.after(e)})):r&&(r.remove(),i.$destroy(),r=i=void 0)})}}}}),app.directive("spNotifier",["util","notifier","transitioner","$compile","touch","$timeout",function(e,t,n,o,r,i){return{link:function(a,s){function c(t){function c(){f||(f=!0,l.removeClass("tl"),n.after(l,function(){l.remove(),p.$destroy(),l=p=null}))}var l,d,f,p=a.$new();e.extend(p,t),l=e.element(s.prepend(u).children()[0]),o(l.contents())(p),i(function(){l.addClass("tl")}),r.tap(l,c),d=i(c,t.delay||5e3)}var u='<div class="notification"><article ng-class="\'icon-\'+icon"><h6>{{title}}</h6><p>{{message}}</p></article></div>';t.setCallback(c).get().forEach(c)}}}]),app.directive("spParse",["touch","util",function(){return function(e,t,n){var o=e.$eval(n.spParse),r=t.find("div"),i=t.find("textarea"),a=function(){var e=i.val();r.html(o(e)||"")};i.bind("keyup",a)}}]),app.directive("spSlide",["util","transitioner",function(e,t){return{transclude:"element",priority:1e3,terminal:!0,compile:function(e,n,o){return function(e,r){var i,a,s,c=n.spSlide,u=r.parent();u.addClass("t3d"),e.$watch(function(e){var n,l=e.$eval(c);!l.model&&s&&(a.remove(),i.$destroy(),a=i=s=null),l.model&&(l.model!=s||l.force)&&(l.force=!1,n=e.$new(),n.model=l.model,o(n,function(e){if(r.after(e),a){var o=a,c=i;"left"==l.to?(e.addClass("tr"),u.addClass("transition tl")):(e.addClass("tl"),u.addClass("transition tr")),a.bind("$destroy",function(){u.removeClass("transition tl tr"),e.removeClass("tr tl")}),t.apply(u[0].id,function(){o.remove(),c.$destroy()})}a=e,i=n,s=l.model}))})}}}}]),app.directive("spSortable",["touch","$timeout","util",function(e,t,n){function o(e){var t=0;do t+=e.prop("offsetTop")-e.prop("scrollTop"),e=n.element(e.prop("offsetParent"));while(void 0!==e.prop("offsetTop"));return t}function r(){c&&c.css("margin",""),d.length>s+1&&(c=d.eq(s+1),c.css("marginTop",u-1+"px"))}var i,a,s,c,u,l,d,f,p,h,g=Math.min,v=Math.max;return function(m,b,y){m.$watch(y.spSortable,function(C){C||void 0===C?(e.hold(b,function(e,n){e.preventDefault(),d=b.children();var c=d.eq(0);h=o(b),l=c.prop("offsetTop")-c.prop("scrollTop"),u=d[0].offsetHeight-1,p=u*d.length,f=g(v(0,n.y-h-l),p),a=s=g(Math.floor(f/u),d.length-1),i=d.eq(a),i.addClass("dragged").css("top",g(v(f+l-u/2,0),p-u/2)+"px"),t(function(){b.addClass("sorting")},0,!1),r()}),e.drag(b,function(e,t){e.preventDefault(),h=o(b);var n=g(v(0,t.y-h-l),p);if(i.css("top",g(v(n+l-u/2,l),p-u/2-l)+"px"),s!==g(Math.floor(n/u),d.length-1)){var a=Math.round(n/u);a!==s&&a!==s+1&&(a>s?(d.splice(a-1,0,d.splice(s,1)[0]),s=a-1):(d.splice(a,0,d.splice(s,1)[0]),s=a),r())}}),e.release(b,function(e){e.preventDefault(),b.removeClass("sorting"),c.css("margin",""),i.removeClass("dragged").css("top",""),m.$apply(y.onsort+"("+a+","+s+")")})):(e.hold(b,n.noop),e.drag(b,n.noop),e.release(b,n.noop))})}}]),app.directive("spTap",["touch","keyboard",function(e,t){return function(n,o,r){e.tap(o,function(){return n.$apply(r.spTap)}),r.spKbd&&t.on(n.$eval(r.spKbd),function(){return n.$apply(r.spTap)})}}]),app.value("songMode",{startState:function(){return{next:"part"}},token:function(e,t){var n=null;return"part"==t.next?e.match(/^\[[1-9BCPIO]\](?=$|\n)/)?(n="part",t.next="chords"):e.skip():"chords"==t.next?e.eat("\n")?(n="chords",t.next="chord"):e.skip():"chord"==t.next?e.eat("\n")?t.next="text":e.eatWhile(" ")?/^[A-G]$/.test(e.peek())||e.skip():e.match(/^[A-G][#b12345679adgijmsu,\(\)]*(?:\/[A-G][#b]?)?(?=($| +|\n))/)?n="chord":e.skip():"text"==t.next?e.match(/^.+\S/)?(n="text",t.next="partOrChords"):e.skip():"partOrChords"==t.next?e.match(/^\n(?=\[)/)?t.next="part":e.eat("\n")?(n="chords",t.next="chord"):e.skip():e.skip(),n}}),app.factory("collection",["$templateCache","$http","$timeout","util",function(e,t,n,o){var r=function(e){var t=this;return t.syncDown(e||o.noop),t},i=function(e){var n=this;return t.get(o.buildUrl(n.url,n.params)).success(function(e){e.forEach(function(e){n[e._id]?n.saveLocal(e):n.add(e,null,!0)})}).success(e||o.noop).error(e||o.noop),n},a=function(e){var t=this,n=e._id;"trash"==e.status?t.removeLocal(n):o.extend(t[n],e)},s=function(e,t){var n=this;o.toArray(e).forEach(function(e){"trash"!=e.status&&(n[e._id]||(n.isNeeded(e)?n.push(e):n.aux.push(e),n[e._id]=e))}),t&&t.call(n,e)},c=function(e){var t=this;o.unlist(t,t[e]),delete t[e]},u=function(e){var t=this;return t[e].status="trash",o.unlist(t,t[e]),t.save(t[e],function(){t.removeLocal(e)})},l=function(e,t){var n=this,r=e._id;if(r||(r=e._id=o.generateId(),e._acl||(e._acl={}),e._acl.creator="[email protected]",!n.onNew||n.onNew(e)))return n[r]?o.extend(n[r],e):n.push(n[r]=e),t&&t(),r},d=function(){return!0},f=function(e){return this.isOwner(e)||e._acl.w&&~e._acl.w.indexOf(auth.id())},p=function(e){return this[e]._acl.creator},h=function(e,t){var n=this,r=n[e]._acl.r;return r||(r=n[e]._acl.r=[]),o.list(r,t),n},g=function(e,t){var n=this,r=n[e]._acl.w;return r||(r=n[e]._acl.w=[]),o.list(r,t),n},v=function(e,t){var n=this,r=n[e]._acl.r;return r&&o.unlist(r,t),n},m=function(e,t){var n=this,r=n[e]._acl.w;return r&&o.unlist(r,t),n},b=function(e){var t=this[e]._acl;return t&&t.r||[]},y=function(e){var t=this[e]._acl;return t&&t.w||[]},C=function(e,t){var n=this,o=n[e]._acl;return o.r=t,n},S=function(e,t){var n=this,o=n[e]._acl;return o.w=t,n};return function(e){var t=[],n={url:"",run:r,save:l,remove:u,isOwner:d,isWriter:f,getOwner:p,syncDown:i,addWriter:g,addReader:h,removeWriter:m,removeReader:v,getReaders:b,getWriters:y,setReaders:C,setWriters:S,add:s,saveLocal:a,removeLocal:c,isNeeded:function(){return!0}};return o.extend(t,n,e),t}}]),app.factory("keyboard",["$document","$timeout",function(e,t){function n(e){var n,o,r,a=e.keyCode,s=e.type;if((93==a||224==a)&&(a=91),a>95&&106>a&&(a-=48),110==a&&(a=190),109==a&&(a=189),111==a&&(a=191),"keyup"==s&&(r=u.indexOf(a),-1!==r&&u.splice(r,1)),n=e.target,3==n.nodeType&&(n=n.parentNode),"INPUT"==n.tagName||"SELECT"==n.tagName||"TEXTAREA"==n.tagName||n.contentEditable&&"true"==n.contentEditable){if(27!=a)return;n.blur()}if("keydown"==s){if(-1!==u.indexOf(a))return;u.push(a),i&&t.cancel(i),i=t(function(){u.length=0},1e3,!1)}o=c[s+":"+u.join("+")],o&&o.forEach(function(t){t(e)===!1&&(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.returnValue=!1,e.cancelBubble=!0)})}function o(e,t){var n=[],o="+"===e?["+"]:e.split("+");return o.forEach(function(e){s[e]&&(n.push(16),e=s[e]),a[e]&&n.push(a[e])}),t+":"+n.join("+")}function r(e,t){var n,r;for(r in e)n=o(r,t),c[n]||(c[n]=[]),c[n].push(e[r])}var i,a={backspace:8,tab:9,enter:13,"return":13,shift:16,ctrl:17,control:17,alt:18,option:18,capslock:20,esc:27,escape:27,space:32,pageup:33,pagedown:34,end:35,home:36,left:37,up:38,right:39,down:40,ins:45,insert:45,del:46,"delete":46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,meta:91,command:91,"super":91,windows:91,"*":106,"+":107,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},s={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},c={},u=[];e.bind("keydown",n),e.bind("keyup",n);var l={on:function(){var e=arguments,t=e[0],n=e[2],o={};return"string"==typeof t?o[t]=e[1]:Array.isArray(t)?t.forEach(function(t){o[t]=e[1]}):(o=e[0],n=e[1]),r(o,n||"keydown"),this},off:function(e,t){var n=o(e,t);return c[n]&&delete c[n],this},reset:function(){return c={},this}};return l}]),app.factory("locale",function(){var e={},t=e.langs=[{code:"cs",name:"Czech","native":"Česky"},{code:"da",name:"Danish","native":"Dansk"},{code:"de",name:"German","native":"Deutsch"},{code:"en",name:"English","native":"English"},{code:"es",name:"Spanish","native":"Español"},{code:"fr",name:"French","native":"Français"},{code:"it",name:"Italian","native":"Italiano"},{code:"lv",name:"Latvian","native":"Latviešu"},{code:"lt",name:"Lithuanian","native":"Lietuvių"},{code:"hu",name:"Hungarian","native":"Magyar"},{code:"nl",name:"Dutch","native":"Nederlands"},{code:"no",name:"Norwegian","native":"Norsk"},{code:"pl",name:"Polish","native":"Polski"},{code:"pt",name:"Portuguese","native":"Português"},{code:"ro",name:"Romanian","native":"Română"},{code:"sq",name:"Albanian","native":"Shqip"},{code:"sk",name:"Slovak","native":"Slovenčina"},{code:"sl",name:"Slovene","native":"Slovenščina"},{code:"fi",name:"Finnish","native":"Suomi"},{code:"sv",name:"Swedish","native":"Svenska"},{code:"tr",name:"Turkish","native":"Türkçe"},{code:"el",name:"Greek","native":"Ελληνικά"},{code:"bg",name:"Bulgarian","native":"български"},{code:"ru",name:"Russian","native":"Pусский"},{code:"uk",name:"Ukrainian","native":"Українська"}];return e._={newSong:"New Song",editSong:"Edit Song",addToSet:"Add to Set",renameSet:"Rename Set",shareSet:"Share Set",settings:"Settings",noConnection:"Could not connect to the server!",outOfSync:"SongPane is out of sync. Please make sure you have an active internet connection.",quotaExceeded:"The local storage limit has been reached or local storage is disabled.",alert:"Alert",copy:"copy",keyboard:"Keyboard Shortcuts",illegalOperation:"You tried to perform an illegal operation!",key:"Key",currentKey:"Current Key",originalKey:"Original Key",tempo:"Tempo",signature:"Signature",timeSignature:"Time Signature",artist:"Artist(s)",copyright:"Copyright",profile:"Profile",buddies:"Buddies",remove:"Remove",owner:"Owner",save:"Save",add:"Add",addToNewSet:"Add the song to a new set",addToExistingSet:"or an existing set",selectSet:"Select a set",hideChords:"Hide chords",disconnect:"Disconnect",disconnectAccount:"Disconnect account",songTitle:"Song title",lyricsAndChords:"Lyrics and chords",nameSet:"Give this set a name",done:"Done",email:"Email",password:"Password",createAccount:"Create Account",resetPassword:"Reset Password",searchSongs:"Search songs",filterSongs:"Filter songs",sets:"Sets",catalog:"Catalog",search:"Search",noSets:"No Sets",creatingSets:"Sets are created by adding songs to them.",emptyCatalog:"Empty Catalog",aboutCatalog:"The catalog contains all the songs that you use or songs that you add to SongPane.",noResults:"No Results",searching:"Searching...",wait:"Wait...",standalone:"To enjoy this app to the fullest we recommend adding it to your Home Screen.",loggedOut:"You have been logged out.",notFound:"The resource was not found on the server.",genericError:"Something went wrong and it’s probably our fault.",confirm:"Are you sure?",explainDelSong:"Deleting the song makes it unavailable to any set that is currently using it!",del:"Delete",cancel:"Cancel",nextSongOrSet:"Next song or set",prevSongOrSet:"Previous song or set",toggleChords:"Toggle chord display",changeFontSize:"Decrease/increase font size",fontSize:"Font size",small:"Small",medium:"Medium",large:"Large",priv:"Private",pub:"Public",language:"Language",visibility:"Visibility",toggleFullscreen:"Toggle fullscreen",toggleInfo:"Toggle song info",toggleHelp:"Toggle help (this screen)",toggleSettings:"Toggle settings",esc:"Cancel actions, close modal windows",checkBody:"Please check the body of the song.",sharedSet:"A new set has been shared with you!",checkEmail:"Please check your email.",invalidCredentials:"Invalid credentials!",SPInvalidData:"The data you submitted was invalid.",SPOperationNotPermitted:"You are trying to perform an illegal operation.",SPInvalidQuery:""},t.forEach(function(e){t[e.code]=e}),e}),app.factory("md5",function(){function e(e,t){var a=e[0],s=e[1],c=e[2],u=e[3];a=n(a,s,c,u,t[0],7,-680876936),u=n(u,a,s,c,t[1],12,-389564586),c=n(c,u,a,s,t[2],17,606105819),s=n(s,c,u,a,t[3],22,-1044525330),a=n(a,s,c,u,t[4],7,-176418897),u=n(u,a,s,c,t[5],12,1200080426),c=n(c,u,a,s,t[6],17,-1473231341),s=n(s,c,u,a,t[7],22,-45705983),a=n(a,s,c,u,t[8],7,1770035416),u=n(u,a,s,c,t[9],12,-1958414417),c=n(c,u,a,s,t[10],17,-42063),s=n(s,c,u,a,t[11],22,-1990404162),a=n(a,s,c,u,t[12],7,1804603682),u=n(u,a,s,c,t[13],12,-40341101),c=n(c,u,a,s,t[14],17,-1502002290),s=n(s,c,u,a,t[15],22,1236535329),a=o(a,s,c,u,t[1],5,-165796510),u=o(u,a,s,c,t[6],9,-1069501632),c=o(c,u,a,s,t[11],14,643717713),s=o(s,c,u,a,t[0],20,-373897302),a=o(a,s,c,u,t[5],5,-701558691),u=o(u,a,s,c,t[10],9,38016083),c=o(c,u,a,s,t[15],14,-660478335),s=o(s,c,u,a,t[4],20,-405537848),a=o(a,s,c,u,t[9],5,568446438),u=o(u,a,s,c,t[14],9,-1019803690),c=o(c,u,a,s,t[3],14,-187363961),s=o(s,c,u,a,t[8],20,1163531501),a=o(a,s,c,u,t[13],5,-1444681467),u=o(u,a,s,c,t[2],9,-51403784),c=o(c,u,a,s,t[7],14,1735328473),s=o(s,c,u,a,t[12],20,-1926607734),a=r(a,s,c,u,t[5],4,-378558),u=r(u,a,s,c,t[8],11,-2022574463),c=r(c,u,a,s,t[11],16,1839030562),s=r(s,c,u,a,t[14],23,-35309556),a=r(a,s,c,u,t[1],4,-1530992060),u=r(u,a,s,c,t[4],11,1272893353),c=r(c,u,a,s,t[7],16,-155497632),s=r(s,c,u,a,t[10],23,-1094730640),a=r(a,s,c,u,t[13],4,681279174),u=r(u,a,s,c,t[0],11,-358537222),c=r(c,u,a,s,t[3],16,-722521979),s=r(s,c,u,a,t[6],23,76029189),a=r(a,s,c,u,t[9],4,-640364487),u=r(u,a,s,c,t[12],11,-421815835),c=r(c,u,a,s,t[15],16,530742520),s=r(s,c,u,a,t[2],23,-995338651),a=i(a,s,c,u,t[0],6,-198630844),u=i(u,a,s,c,t[7],10,1126891415),c=i(c,u,a,s,t[14],15,-1416354905),s=i(s,c,u,a,t[5],21,-57434055),a=i(a,s,c,u,t[12],6,1700485571),u=i(u,a,s,c,t[3],10,-1894986606),c=i(c,u,a,s,t[10],15,-1051523),s=i(s,c,u,a,t[1],21,-2054922799),a=i(a,s,c,u,t[8],6,1873313359),u=i(u,a,s,c,t[15],10,-30611744),c=i(c,u,a,s,t[6],15,-1560198380),s=i(s,c,u,a,t[13],21,1309151649),a=i(a,s,c,u,t[4],6,-145523070),u=i(u,a,s,c,t[11],10,-1120210379),c=i(c,u,a,s,t[2],15,718787259),s=i(s,c,u,a,t[9],21,-343485551),e[0]=l(a,e[0]),e[1]=l(s,e[1]),e[2]=l(c,e[2]),e[3]=l(u,e[3])}function t(e,t,n,o,r,i){return t=l(l(t,e),l(o,i)),l(t<<r|t>>>32-r,n)}function n(e,n,o,r,i,a,s){return t(n&o|~n&r,e,n,i,a,s)}function o(e,n,o,r,i,a,s){return t(n&r|o&~r,e,n,i,a,s)}function r(e,n,o,r,i,a,s){return t(n^o^r,e,n,i,a,s)}function i(e,n,o,r,i,a,s){return t(o^(n|~r),e,n,i,a,s)}function a(t){var n,o=t.length,r=[1732584193,-271733879,-1732584194,271733878];for(n=64;t.length>=n;n+=64)e(r,s(t.substring(n-64,n)));t=t.substring(n-64);var i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(n=0;t.length>n;n++)i[n>>2]|=t.charCodeAt(n)<<(n%4<<3);if(i[n>>2]|=128<<(n%4<<3),n>55)for(e(r,i),n=0;16>n;n++)i[n]=0;return i[14]=8*o,e(r,i),r}function s(e){var t,n=[];for(t=0;64>t;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function c(e){for(var t="",n=0;4>n;n++)t+=f[15&e>>8*n+4]+f[15&e>>8*n];return t}function u(e){for(var t=0;e.length>t;t++)e[t]=c(e[t]);return e.join("")}function l(e,t){return 4294967295&e+t}function d(e){return u(a(e||""))}var f="0123456789abcdef".split("");return d}),app.factory("modal",["$rootScope","$location","$routeParams","transitioner","$timeout",function(e,t,n,o,r){function i(e){t.search("modal",e||null)}var a=function(t){return e.modalClass?(e.modalClass="",o.apply("modal",function(){i(),t!=n.modal&&r(function(){i(t)})})):t&&i(t),!0};return a.isOn=function(t){return t?e.modalClass===t:e.modalClass},a}]),app.factory("notifier",function(){var e,t={title:"",icon:"info",delay:5e3},n=[],o=Object.keys;return{setCallback:function(t){return e=t,this},notify:function(r){return o(t).forEach(function(e){r[e]||(r[e]=t[e])}),n.push(r),e&&e(r),this},get:function(){return n}}}),app.factory("parse",["$window",function(){function e(e){var t=this;t.pos=t.start=0,t.string=e}return e.prototype={eof:function(){return this.pos>=this.string.length},sof:function(){return!this.pos},eol:function(){return this.pos>=this.string.length||"\n"==this.string.charAt(this.pos)},sol:function(){return!this.pos||"\n"==this.string.charAt(this.pos-1)},peek:function(){return this.string.charAt(this.pos)||null},next:function(){return this.pos<this.string.length&&this.string.charAt(this.pos++)},eat:function(e){var t,n=this.string.charAt(this.pos);return t="string"==typeof e?n==e:n&&(e.test?e.test(n):e(n)),t?(++this.pos,n):void 0},eatWhile:function(e){for(var t=this.pos;this.eat(e););return this.pos>t},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skip:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return~t?(this.pos=t,!0):void 0},skipLine:function(){return this.skipTo("\n")&&this.pos<this.string.length&&++this.pos},backUp:function(e){this.pos-=e},column:function(){return this.start},match:function(e,t){if("string"!=typeof e){var n=this.string.slice(this.pos).match(e);return n&&t!==!1&&(this.pos+=n[0].length),n}return this.string.indexOf(e,this.pos)==this.pos?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)}},function(t,n,o){var r,i,a=n.startState()||!0;for(r=new e(t);!r.eof();)i=n.token(r,a),o(r.current(),i),r.start=r.pos}}]),function(){var e,t=navigator.userAgent;/AppleWebKit/.test(t)&&/Mobile\/\w+/.test(t)?e="ios":~t.toLowerCase().indexOf("firefox")&&(e="ff"),e&&(document.documentElement.className+=" "+e),app.constant("platform",e)}(),app.factory("settings",["util",function(){var e={},t=function(t,n){e[t]=n};return{settings:e,set:t,toggle:function(n){t(n,!e[n])}}}]),app.factory("touch",["$window","$timeout","util",function(e,t){function n(e){return b&&(e=e.touches[0]||e.changedTouches[0]),{x:e.pageX,y:e.pageY}}function o(e){var t=n(e);return t.dx=t.x-g.x,t.dy=t.y-g.y,t}function r(e,t){return A(E(t.x-e.x,2)+E(t.y-e.y,2))}function i(e){f=!0,g=n(e),p=e.target,v=t(function(){c("hold",g,e),h=!0},1e3)}function a(e){f&&(h?c("drag",o(e),e):t.cancel(v))}function s(e){f&&(t.cancel(v),h?c("release",o(e),e):10>r(n(e),g)&&c("tap",e),p=f=h=!1)}function c(e,t,n){for(var o,r,i=p;i&&i!=y&&(o=i.parentNode,r=C.indexOf(i),-1==r||!S[r][e]||!1!==S[r][e](n,t));)i=o}var u,l,d,f,p,h,g,v,m={},b="ontouchstart"in e,y=e.document,C=[],S=[],E=Math.pow,A=Math.sqrt;return b?(u="touchstart",l="touchmove",d="touchend"):(u="mousedown",l="mousemove",d="mouseup"),y.addEventListener(u,i,!0),y.addEventListener(l,a,!0),y.addEventListener(d,s,!0),["tap","hold","drag","release"].forEach(function(e){m[e]=function(t,n){t.length&&(t=t[0]);var o=C.indexOf(t);-1==o&&(o=C.push(t)-1,S[o]={}),S[o][e]=n}}),m}]),app.factory("transitioner",["$rootScope","$document","util",function(e,t,n){function o(){var e,n=t[0].createElement("dummy"),o={transition:"transitionend",OTransition:"oTransitionEnd",MSTransition:"msTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in o)if(void 0!==n.style[e])return o[e]}var r=o(),i={},a=[];return r&&t.bind(r,function(t){var n=t.target.id;if(n&&n in i){for(;i[n].length;)e.$apply(i[n].shift());delete i[n]}}),{apply:function(e,t,n){return r?(e in i&&!n||(i[e]=[]),i[e].push(t),void 0):(t(),void 0)},after:function(e,t,o){e[0]&&(e=e[0]),e.id||(e.id=n.generateId()),this.apply(e.id||a.push(e)-1,t,o)}}}]),app.factory("transposer",function(){var e=/C##|D##|E##|F##|G##|A##|B##|Cbb|Dbb|Ebb|Fbb|Gbb|Abb|Bbb|C#|D#|E#|F#|G#|A#|B#|Cb|Db|Eb|Fb|Gb|Ab|Bb|C|D|E|F|G|A|B/g,t=[["C","C#","Db","D","Eb","E","F","F#","Gb","G","Ab","A","Bb","B","Cb"],["Am","A#m","Bbm","Bm","Cm","C#m","Dm","D#m","Ebm","Em","Fm","F#m","Gm","G#m","Abm"]],n=[["C","C#","Db","D","D#","Eb","E","E#","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bb","B","B#","Cb"],["C#","C##","D","D#","D##","E","E#","E##","F","F#","F##","G","G#","G##","A","A#","A##","B","B#","B##","C"],["Db","D","Ebb","Eb","E","Fb","F","F#","Gbb","Gb","G","Abb","Ab","A","Bbb","Bb","B","Cb","C","C#","Dbb"],["D","D#","Eb","E","E#","F","F#","F##","G#","G","G#","Ab","A","A#","Bb","B","B#","C","C#","C##","Db"],["Eb","E","Fb","F","F#","Gb","G","G#","Abb","Ab","A","Bbb","Bb","B","Cb","C","C#","Db","D","D#","Ebb"],["E","E#","F","F#","F##","G","G#","G##","Ab","A","A#","Bb","B","B#","C","C#","C##","D","D#","D##","Eb"],["F","F#","Gb","G","G#","Ab","A","A#","Bbb","Bb","B","Cb","C","C#","Db","D","D#","Eb","E","E#","Fb"],["F#","F##","G","G#","G##","A","A#","A##","Bb","B","B#","C","C#","C##","D","D#","D##","E","E#","E##","F"],["Gb","G","Abb","Ab","A","Bbb","Bb","B","Cbb","Cb","C","Dbb","Db","D","Ebb","Eb","E","Fb","F","F#","Gbb"],["G","G#","Ab","A","A#","Bb","B","B#","Cb","C","C#","Db","D","D#","Eb","E","E#","F","F#","F##","Gb"],["Ab","A","Bbb","Bb","B","Cb","C","C#","Dbb","Db","D","Ebb","Eb","E","Fb","F","F#","Gb","G","G#","Abb"],["A","A#","Bb","B","B#","C","C#","C##","Db","D","D#","Eb","E","E#","F","F#","F##","G","G#","G##","Ab"],["Bb","B","Cb","C","C#","Db","D","D#","Ebb","Eb","E","Fb","F","F#","Gb","G","G#","Ab","A","A#","Bbb"],["B","B#","C","C#","C##","D","D#","D##","Eb","E","E#","F","F#","F##","G","G#","G##","A","A#","A##","Bb"],["Cb","C","Dbb","Db","D","Ebb","Eb","E","Fbb","Fb","F","Gbb","Gb","G","Abb","Ab","A","Bbb","Bb","B","Cbb"]];return{getKeys:function(e){return t[Number(e)]},getAllKeys:function(){return t[0].concat(t[1])},getScale:function(e){return n[t["m"===e.slice(-1)?1:0].indexOf(e)]},transpose:function(o,r,i){var a="m"===r.slice(-1)?1:0,s=t[a].indexOf(r),c=t[a].indexOf(i);return o.replace(e,function(e){return n[c][n[s].indexOf(e)]})}}}),function(e,t){app.service("util",["$window",function(n){var o=this,r=n.document,i=n.setTimeout,a=n.clearTimeout;o.toArray=function(e){return e&&e.forEach?e:[e]},o.list=function(e,t){var n=e.length;return o.toArray(t).forEach(function(t){var n=e.indexOf(t);~n||e.push(t)}),e.length-n},o.unlist=function(e,t){var n=e.indexOf(t);return~n&&e.splice(n,1),e.length},o.move=function(e,t,n){return e.splice(n,0,e.splice(t,1)[0]),e},o.pad=function(e,t){return Array(e+1).join(t||" ")},o.buildUrl=function(n,r){if(!r)return n;var i=[];return e.forEach(r,function(n,r){null!==n&&n!==t&&(e.isObject(n)&&(n=o.toJson(n)),i.push(encodeURIComponent(r)+"="+encodeURIComponent(n)))}),n+(-1==n.indexOf("?")?"?":"&")+i.join("&")},o.element=function(t){return e.isString(t)&&(t=r.getElementById(t)),e.element(t)},o.randomHex=function(e){for(var t="";e>0;)t+=Math.floor(Math.random()*Math.pow(10,16)).toString(16).substr(0,8>e?e:8),e-=8;return t},o.generateId=function(){return Math.floor(Date.now()/1e3).toString(16)+o.randomHex(16)},o.throttle=function(e,t){var n=null;return function(){var o=this,r=arguments;a(n),n=i(function(){e.apply(o,r),n=null},t)}},o.keys=Object.keys,o.toJson=n.JSON.stringify,["copy","extend","forEach","identity","fromJson","isObject","isString","isArray","lowercase","noop"].forEach(function(t){o[t]=e[t]})}])}(angular);