Advertisement
Guest User

Untitled

a guest
Jul 18th, 2011
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Ext.regApplication({
  2.     name: "bandcast",
  3.     config: _config,
  4.     tabletStartupScreen: "resources/img/tablet_startup.png",
  5.     phoneStartupScreen: "resources/img/phone_startup.png",
  6.     icon: "resources/img/icon_57.png",
  7.     statusBarStyle: "black",
  8.     flashes: {},
  9.     launch: function() {
  10.         try {
  11.             this.hacks();
  12.             Ext.data.auth = Ext.ModelMgr.create({}, "Auth");
  13.             Ext.data.cookies = new Ext.util.LocalStorageCookie({
  14.                 proxyId: "com.bandcast.cookies"
  15.             });
  16.             this.setup();
  17.         } catch (a) {
  18.             Ext.Msg.alert("Fatal error", "Whoops! Something went horribly wrong. Please try again later.<br />(" + a + ")", Ext.emptyFn);
  19.             return false;
  20.         }
  21.     },
  22.     setup: function() {
  23.         this.defaultUrl = bandcast.config.event.type + "/index";
  24.         Ext.Dispatcher.addListener("before-dispatch", function(b) {
  25.             if (navigator.onLine) {
  26.                 this.online();
  27.             } else {
  28.                 this.offline();
  29.             }
  30.             if (!Ext.data.auth.get("sid")) {
  31.                 var a = Ext.getCmp("viewport");
  32.                 if (a) {
  33.                     a.destroy();
  34.                 }
  35.                 if (b.controller.id != "auth") {
  36.                     this.authorize(b.historyUrl);
  37.                     return false;
  38.                 }
  39.             }
  40.             return true;
  41.         }, this);
  42.     },
  43.     authorize: function(b) {
  44.         var a = new Ext.LoadMask(Ext.getBody(), {
  45.             msg: "Authorizing"
  46.         });
  47.         a.show();
  48.         Ext.data.auth.restore(Ext.createDelegate(function(d, e) {
  49.             a.hide();
  50.             var c = Ext.createDelegate(function() {
  51.                 a.msg = "Loading";
  52.                 a.show();
  53.                 bandcast.stores.Event.load({
  54.                     callback: function(g, f, h) {
  55.                         a.hide();
  56.                         delete a;
  57.                         if (h) {
  58.                             Ext.dispatch({
  59.                                 controller: bandcast.config.event.type,
  60.                                 action: "run",
  61.                                 url: b
  62.                             });
  63.                         } else {
  64.                             this.offline();
  65.                         }
  66.                     },
  67.                     scope: this
  68.                 });
  69.             }, this);
  70.             if (d) {
  71.                 c();
  72.             } else {
  73.                 Ext.dispatch({
  74.                     controller: "auth",
  75.                     action: "index",
  76.                     callback: c
  77.                 });
  78.             }
  79.         }, this));
  80.     },
  81.     offline: function() {
  82.         var a = Ext.getCmp("viewport");
  83.         if (a) {
  84.             a.addDocked({
  85.                 id: "offline",
  86.                 xtype: "toolbar",
  87.                 title: "offline mode - unable to establish a connection"
  88.             });
  89.         } else {
  90.             Ext.Msg.alert("Offline error", "Unable to establish a connection. Please try again later.", Ext.emptyFn);
  91.         }
  92.     },
  93.     online: function() {
  94.         var a = Ext.getCmp("offline");
  95.         if (a) {
  96.             Ext.getCmp("viewport").removeDocked(a, false);
  97.         }
  98.     },
  99.     timezoned: function(a) {
  100.         var c = new Date(a.getTime());
  101.         if (typeof this.config.event.date.timezone != "undefined") {
  102.             var b = a.getTimezoneOffset() + this.config.event.date.timezone * 60;
  103.             c.setTime(a.getTime() + b * 6e4);
  104.         }
  105.         return c;
  106.     },
  107.     timeago: function(b, a) {
  108.         if (typeof b == "string") {
  109.             b = new Date(Date.parseDate(b, "c"));
  110.         }
  111.         var d = [ "second", "minute", "hour", "day" ], f = [ 60, 60, 24, 7 ], e = Math.round(Ext.util.Date.getElapsed(b) / 1e3);
  112.         for (var c = 0; e >= f[c] && c < f.length - 1; c++) {
  113.             e /= f[c];
  114.         }
  115.         return (e = Math.round(e)) + (a ? d[c].substr(0, 1) : " " + d[c] + (e > 1 ? "s" : ""));
  116.     },
  117.     hacks: function() {
  118.         resetMsgBox = function() {
  119.             Ext.Msg = new Ext.MessageBox;
  120.             Ext.Msg.on({
  121.                 hide: function(a) {
  122.                     a.destroy();
  123.                 },
  124.                 destroy: function(a) {
  125.                     resetMsgBox();
  126.                 }
  127.             });
  128.         };
  129.         resetMsgBox();
  130.     }
  131. });
  132.  
  133. Ext.Router.draw(function(a) {
  134.     a.connect("user/-/:username", {
  135.         controller: "user",
  136.         action: "detail"
  137.     });
  138.     a.connect("event/-/:event", {
  139.         controller: "event",
  140.         action: "detail"
  141.     });
  142.     a.connect("artist/-/:artist", {
  143.         controller: "artist",
  144.         action: "detail"
  145.     });
  146.     a.connect("venue/-/:venue", {
  147.         controller: "venue",
  148.         action: "detail"
  149.     });
  150.     a.connect("qr/friend/:username/:qrcode", {
  151.         controller: "qrcode",
  152.         action: "friend"
  153.     });
  154.     a.connect(":controller/:action");
  155. });
  156.  
  157. Ext.util.LocalStorageCookie = Ext.extend(Object, {
  158.     proxyId: "com.domain.cookies",
  159.     constructor: function(a) {
  160.         this.config = Ext.apply(this, a);
  161.         Ext.regModel("LocalStorageCookie", {
  162.             fields: [ "id", "key", "value" ],
  163.             proxy: {
  164.                 type: "localstorage",
  165.                 id: this.proxyId
  166.             }
  167.         });
  168.         this.store = new Ext.data.Store({
  169.             model: "LocalStorageCookie"
  170.         });
  171.         this.store.load();
  172.     },
  173.     get: function(c) {
  174.         var b = this.store.find("key", c);
  175.         if (b == -1) {
  176.             return null;
  177.         } else {
  178.             var a = this.store.getAt(b);
  179.             return a.get("value");
  180.         }
  181.     },
  182.     set: function(c, d) {
  183.         var b = this.store.find("key", c);
  184.         if (b == -1) {
  185.             var a = Ext.ModelMgr.create({
  186.                 key: c,
  187.                 value: d
  188.             }, "LocalStorageCookie");
  189.         } else {
  190.             var a = this.store.getAt(b);
  191.             a.set("value", d);
  192.         }
  193.         return a.save();
  194.     }
  195. });
  196.  
  197. Ext.data.BandcastProxy = Ext.extend(Ext.data.RestProxy, {
  198.     apiHost: bandcast.config.defaults.urls.api,
  199.     appId: bandcast.config.event.id,
  200.     pageParam: "page",
  201.     limitParam: "num",
  202.     defaultPage: 1,
  203.     perPage: 50,
  204.     appendId: false,
  205.     constructor: function(a) {
  206.         a = a || {};
  207.         Ext.applyIf(a, {
  208.             extraParams: {
  209.                 page: this.defaultPage,
  210.                 num: this.perPage
  211.             }
  212.         });
  213.         Ext.data.BandcastProxy.superclass.constructor.call(this, a);
  214.     },
  215.     setUrl: function(a) {
  216.         this.url = a;
  217.     },
  218.     buildUrl: function(d) {
  219.         var b = Ext.data.BandcastProxy.superclass.buildUrl.call(this, d), c, a;
  220.         b = b.indexOf("?") == -1 ? b + ".json" : b.replace("?", ".json?");
  221.         if (Ext.data.cookies && (c = Ext.data.cookies.get("auth"))) {
  222.             b = Ext.urlAppend(b, Ext.util.Format.format("{0}={1}", "auth", c));
  223.         }
  224.         if (Ext.data.auth && (a = Ext.data.auth.get("sid"))) {
  225.             b = Ext.urlAppend(b, Ext.util.Format.format("{0}={1}", "sid", a));
  226.         }
  227.         return this.apiHost + b.replace("/proxy", "/proxy/app=" + this.appId);
  228.     }
  229. });
  230.  
  231. Ext.data.ProxyMgr.registerType("bandcast", Ext.data.BandcastProxy);
  232.  
  233. Ext.data.BandcastStore = Ext.extend(Ext.data.Store, {
  234.     proxyType: "online",
  235.     loaded: false,
  236.     constructor: function(a) {
  237.         Ext.data.BandcastStore.superclass.constructor.call(this, a);
  238.         this.onlineProxy = this.getProxy();
  239.         this.localProxy = Ext.data.ProxyMgr.create({
  240.             model: this.onlineProxy.getModel(),
  241.             type: "localstorage",
  242.             id: this.storeId + "Local"
  243.         });
  244.         this.addEvents("afterload");
  245.     },
  246.     swapProxy: function(a) {
  247.         switch (a) {
  248.           case "online":
  249.             if (this.setProxy(this.onlineProxy) instanceof Ext.data.ServerProxy) {
  250.                 return this.proxyType = "online";
  251.             }
  252.             break;
  253.           case "local":
  254.             if (this.setProxy(this.localProxy) instanceof Ext.data.LocalStorageProxy) {
  255.                 return this.proxyType = "local";
  256.             }
  257.             break;
  258.         }
  259.     },
  260.     listeners: {
  261.         beforesync: function(a) {
  262.             if (this.proxyType == "online") {
  263.                 if (this.swapProxy("local")) {
  264.                     this.proxy.batch(a, this.getBatchListeners());
  265.                     this.sync();
  266.                     this.swapProxy("online");
  267.                 }
  268.             }
  269.         },
  270.         beforeload: function(a) {
  271.             if (!navigator.onLine) {
  272.                 this.swapProxy("local");
  273.             }
  274.         },
  275.         load: function(b, a, c) {
  276.             if (c) {
  277.                 if (this.proxyType == "online") {
  278.                     if (this.swapProxy("local")) {
  279.                         this.each(function(d) {
  280.                             d.setDirty();
  281.                         });
  282.                         this.sync();
  283.                         this.swapProxy("online");
  284.                     }
  285.                 }
  286.                 this.loaded = true;
  287.             }
  288.             if (this.hasListener("afterload")) {
  289.                 this.fireEvent("afterload", b, a, c);
  290.             }
  291.         }
  292.     }
  293. });
  294.  
  295. Ext.util.BandcastFlash = new (Ext.extend(Object, {
  296.     messages: [],
  297.     add: function(b, a) {
  298.         a = Ext.applyIf(a || {}, {
  299.             id: (new Date).getTime(),
  300.             timer: 0
  301.         });
  302.         this.messages.unshift({
  303.             id: a.id,
  304.             message: b,
  305.             added: new Date
  306.         });
  307.         if (a.timer > 0) {
  308.             (new Ext.util.DelayedTask(function() {
  309.                 this.remove(a.id);
  310.             }, this)).delay(a.timer);
  311.         }
  312.         this.display();
  313.         return a.id;
  314.     },
  315.     remove: function(b) {
  316.         for (var a in this.messages) {
  317.             if (this.messages[a].id == b) {
  318.                 this.messages.splice(a, 1);
  319.                 break;
  320.             }
  321.         }
  322.         this.display();
  323.     },
  324.     display: function() {
  325.         if (!this.flashbar) {
  326.             Ext.getCmp("viewport").addDocked({
  327.                 id: "flashbar",
  328.                 xtype: "toolbar"
  329.             });
  330.             this.flashbar = Ext.getCmp("flashbar");
  331.         }
  332.         if (this.messages.length) {
  333.             this.flashbar.setTitle(this.messages[0].message);
  334.         } else {
  335.             Ext.getCmp("viewport").removeDocked(this.flashbar, false);
  336.             this.flashbar = null;
  337.         }
  338.     },
  339.     error: function(a, b) {
  340.         if (b && typeof b == "object") {
  341.             a += " " + b.join(". ") + ".";
  342.         }
  343.         Ext.Msg.alert("Error", a, Ext.emptyFn);
  344.     }
  345. }));
  346.  
  347. bandcast.models.Auth = Ext.regModel("Auth", {
  348.     fields: [ {
  349.         name: "sid",
  350.         type: "string"
  351.     }, {
  352.         name: "auth",
  353.         type: "string"
  354.     }, {
  355.         name: "user",
  356.         type: "auto"
  357.     } ],
  358.     proxy: {
  359.         type: "bandcast",
  360.         reader: {
  361.             type: "json",
  362.             root: "root"
  363.         }
  364.     },
  365.     persist: function() {
  366.         Ext.data.cookies.set("auth", this.get("auth"));
  367.     },
  368.     destroy: function() {
  369.         Ext.data.cookies.set("auth", null);
  370.         this.set("sid", null);
  371.         this.set("auth", null);
  372.         this.set("user", null);
  373.     },
  374.     restore: function(b) {
  375.         var a = Ext.data.cookies.get("auth");
  376.         if (a) {
  377.             this.request({
  378.                 method: "GET",
  379.                 url: this.getProxy().buildUrl({
  380.                     operation: new Ext.data.Operation({
  381.                         action: "read"
  382.                     }),
  383.                     url: "/proxy/auth/status"
  384.                 })
  385.             }, b);
  386.         } else {
  387.             b(false);
  388.         }
  389.     },
  390.     login: function(c, a, b) {
  391.         this.request({
  392.             method: "POST",
  393.             url: this.getProxy().buildUrl({
  394.                 operation: new Ext.data.Operation({
  395.                     action: "update"
  396.                 }),
  397.                 url: "/proxy/auth/login"
  398.             }),
  399.             params: {
  400.                 username: c,
  401.                 password: a
  402.             }
  403.         }, b);
  404.     },
  405.     register: function(d, b, a, c) {
  406.         this.request({
  407.             method: "POST",
  408.             url: this.getProxy().buildUrl({
  409.                 operation: new Ext.data.Operation({
  410.                     action: "create"
  411.                 }),
  412.                 url: "/proxy/auth/register"
  413.             }),
  414.             params: {
  415.                 username: d,
  416.                 password: b,
  417.                 email: a
  418.             }
  419.         }, c);
  420.     },
  421.     password: function(a, b) {
  422.         this.request({
  423.             method: "POST",
  424.             url: this.getProxy().buildUrl({
  425.                 operation: new Ext.data.Operation({
  426.                     action: "update"
  427.                 }),
  428.                 url: "/proxy/auth/password"
  429.             }),
  430.             params: {
  431.                 email: a
  432.             }
  433.         }, b);
  434.     },
  435.     settings: function(a, b) {
  436.         this.request({
  437.             method: "POST",
  438.             url: this.getProxy().buildUrl({
  439.                 operation: new Ext.data.Operation({
  440.                     action: "update"
  441.                 }),
  442.                 url: "/proxy/auth/settings"
  443.             }),
  444.             params: a
  445.         }, b);
  446.     },
  447.     request: function(a, b) {
  448.         Ext.Ajax.request(Ext.apply(a, {
  449.             success: function(c, d) {
  450.                 var e = Ext.decode(c.responseText);
  451.                 if (e.success) {
  452.                     if (e.sid) {
  453.                         this.set("sid", e.sid);
  454.                     }
  455.                     if (e.user) {
  456.                         this.set("user", e.user);
  457.                     }
  458.                     if (e.cookie) {
  459.                         this.set("auth", e.cookie);
  460.                         this.persist();
  461.                     }
  462.                     if (b) {
  463.                         b(true);
  464.                     }
  465.                 } else {
  466.                     if (b) {
  467.                         b(false, e.errors);
  468.                     }
  469.                 }
  470.             },
  471.             failure: function(c) {
  472.                 data = Ext.decode(c.responseText);
  473.                 if (b) {
  474.                     b(false);
  475.                 }
  476.             },
  477.             scope: this
  478.         }));
  479.     }
  480. });
  481.  
  482. bandcast.models.User = Ext.regModel("User", {
  483.     fields: [ {
  484.         name: "id",
  485.         type: "int"
  486.     }, {
  487.         name: "username",
  488.         type: "string"
  489.     }, {
  490.         name: "displayname",
  491.         type: "string"
  492.     }, {
  493.         name: "avatars",
  494.         type: "auto"
  495.     }, {
  496.         name: "noavatar",
  497.         type: "int"
  498.     }, {
  499.         name: "checkin",
  500.         type: "auto"
  501.     }, {
  502.         name: "relationship",
  503.         type: "auto"
  504.     } ],
  505.     associations: [ {
  506.         type: "hasMany",
  507.         model: "Activity",
  508.         name: "activity",
  509.         primaryKey: "id",
  510.         foreignKey: "userid"
  511.     } ],
  512.     proxy: {
  513.         type: "bandcast",
  514.         url: "/proxy/users",
  515.         id: "user",
  516.         reader: {
  517.             type: "json",
  518.             root: "users"
  519.         }
  520.     }
  521. });
  522.  
  523. bandcast.stores.User = new Ext.data.BandcastStore({
  524.     storeId: "user",
  525.     model: "User",
  526.     loadByUsername: function(c, b) {
  527.         var a = new Ext.data.Operation({
  528.             action: "read",
  529.             filters: [ new Ext.util.Filter({
  530.                 property: "username",
  531.                 value: c
  532.             }) ]
  533.         });
  534.         this.getProxy().read(a, function(e) {
  535.             var d = a.getRecords();
  536.             this.loadRecords(d, true);
  537.             if (b && typeof b == "function") {
  538.                 b(d);
  539.             }
  540.         }, this);
  541.     }
  542. });
  543.  
  544. bandcast.stores.Friend = new Ext.data.BandcastStore({
  545.     storeId: "friend",
  546.     model: "User",
  547.     pageSize: 50,
  548.     sorters: [ {
  549.         property: "username",
  550.         direction: "ASC"
  551.     } ],
  552.     addByQr: function(e, b, d) {
  553.         var a = this.getProxy().buildUrl({
  554.             operation: new Ext.data.Operation({
  555.                 action: "create"
  556.             }),
  557.             url: "/proxy/users"
  558.         });
  559.         var c = {
  560.             username: e,
  561.             qrcode: b
  562.         };
  563.         this.request(a, c, d);
  564.     },
  565.     addByUsername: function(d, c) {
  566.         var a = this.getProxy().buildUrl({
  567.             operation: new Ext.data.Operation({
  568.                 action: "create"
  569.             }),
  570.             url: "/proxy/users"
  571.         });
  572.         var b = {
  573.             username: d,
  574.             action: "add"
  575.         };
  576.         this.request(a, b, c);
  577.     },
  578.     approveByUsername: function(d, c) {
  579.         var a = this.getProxy().buildUrl({
  580.             operation: new Ext.data.Operation({
  581.                 action: "create"
  582.             }),
  583.             url: "/proxy/users"
  584.         });
  585.         var b = {
  586.             username: d,
  587.             action: "approve"
  588.         };
  589.         this.request(a, b, c);
  590.     },
  591.     denyByUsername: function(d, c) {
  592.         var a = this.getProxy().buildUrl({
  593.             operation: new Ext.data.Operation({
  594.                 action: "create"
  595.             }),
  596.             url: "/proxy/users"
  597.         });
  598.         var b = {
  599.             username: d,
  600.             action: "deny"
  601.         };
  602.         this.request(a, b, c);
  603.     },
  604.     request: function(a, b, c) {
  605.         Ext.Ajax.request({
  606.             method: "POST",
  607.             url: a,
  608.             params: b,
  609.             success: function(d, e) {
  610.                 var f = Ext.decode(d.responseText);
  611.                 if (c) {
  612.                     if (f.success) {
  613.                         c(true);
  614.                     } else {
  615.                         c(false, f.errors);
  616.                     }
  617.                 }
  618.             },
  619.             failure: function(d) {
  620.                 data = Ext.decode(d.responseText);
  621.                 if (c) {
  622.                     c(false);
  623.                 }
  624.             },
  625.             scope: this
  626.         });
  627.     }
  628. });
  629.  
  630. bandcast.stores.Request = new Ext.data.BandcastStore({
  631.     storeId: "requests",
  632.     model: "User",
  633.     remoteFilter: true,
  634.     pageSize: 50,
  635.     sorters: [ {
  636.         property: "username",
  637.         direction: "ASC"
  638.     } ],
  639.     filters: [ {
  640.         property: "relationship",
  641.         value: "pending"
  642.     } ]
  643. });
  644.  
  645. bandcast.models.Activity = Ext.regModel("Activity", {
  646.     fields: [ {
  647.         name: "id",
  648.         type: "int"
  649.     }, {
  650.         name: "activity",
  651.         type: "string"
  652.     }, {
  653.         name: "type",
  654.         type: "string"
  655.     }, {
  656.         name: "typeid",
  657.         type: "int"
  658.     }, {
  659.         name: "recipient",
  660.         type: "int"
  661.     }, {
  662.         name: "userid",
  663.         type: "int"
  664.     }, {
  665.         name: "username",
  666.         type: "string"
  667.     }, {
  668.         name: "displayname",
  669.         type: "string"
  670.     }, {
  671.         name: "avatars",
  672.         type: "auto"
  673.     }, {
  674.         name: "noavatar",
  675.         type: "int"
  676.     }, {
  677.         name: "created",
  678.         type: "date",
  679.         dateFormat: "c"
  680.     } ],
  681.     associations: [ {
  682.         type: "belongsTo",
  683.         model: "User",
  684.         name: "user",
  685.         primaryKey: "userid",
  686.         foreignKey: "id"
  687.     } ],
  688.     proxy: {
  689.         type: "bandcast",
  690.         url: "/proxy/activity",
  691.         id: "activity",
  692.         reader: {
  693.             type: "json",
  694.             root: "activities",
  695.             totalProperty: "total",
  696.             successProperty: "success"
  697.         }
  698.     }
  699. });
  700.  
  701. bandcast.stores.Activity = new Ext.data.BandcastStore({
  702.     storeId: "activityStore",
  703.     model: "Activity",
  704.     pageSize: 30,
  705.     sorters: [ {
  706.         property: "created",
  707.         direction: "DESC"
  708.     } ]
  709. });
  710.  
  711. bandcast.models.Event = Ext.regModel("Event", {
  712.     fields: [ {
  713.         name: "id",
  714.         type: "int"
  715.     }, {
  716.         name: "name",
  717.         type: "string"
  718.     }, {
  719.         name: "urlkey",
  720.         type: "string"
  721.     }, {
  722.         name: "started",
  723.         type: "date",
  724.         dateFormat: "c"
  725.     }, {
  726.         name: "ended",
  727.         type: "date",
  728.         dateFormat: "c"
  729.     }, {
  730.         name: "artists",
  731.         type: "auto"
  732.     }, {
  733.         name: "venues",
  734.         type: "auto"
  735.     }, {
  736.         name: "venue",
  737.         type: "string"
  738.     } ],
  739.     proxy: {
  740.         type: "bandcast",
  741.         url: "/proxy/event",
  742.         id: "id",
  743.         reader: {
  744.             type: "json",
  745.             root: "events"
  746.         }
  747.     }
  748. });
  749.  
  750. bandcast.stores.Event = new Ext.data.BandcastStore({
  751.     storeId: "event",
  752.     model: "Event",
  753.     pageSize: 250,
  754.     sortBy: null,
  755.     sorters: [ {
  756.         property: "name",
  757.         direction: "ASC"
  758.     } ],
  759.     getGroupString: function(a) {
  760.         switch (this.sortBy) {
  761.           case "venue":
  762.             return a.get("venue");
  763.           case "time":
  764.             return a.get("started").toLocaleDateString();
  765.           case "alpha":
  766.           default:
  767.             return a.get("name")[0];
  768.         }
  769.     },
  770.     sortAlpha: function() {
  771.         this.sortBy = "alpha";
  772.         this.sort("name", "ASC");
  773.     },
  774.     sortVenue: function() {
  775.         this.sortBy = "venue";
  776.         this.sort("started", "ASC");
  777.         this.sort("venue", "ASC");
  778.     },
  779.     sortTime: function() {
  780.         this.sortBy = "time";
  781.         this.sort("started", "ASC");
  782.     }
  783. });
  784.  
  785. bandcast.stores.Event.addListener("afterload", function(b, a, c) {
  786.     if (c) {
  787.         bandcast.stores.Artist.removeAll();
  788.         bandcast.stores.Venue.removeAll();
  789.         this.each(function(e) {
  790.             var h = e.get("venues"), f, d, g = "";
  791.             for (f = 0, d = h.length; f < d; f++) {
  792.                 if (!bandcast.stores.Venue.getById(parseInt(h[f].id, 10))) {
  793.                     bandcast.stores.Venue.add(h[f]);
  794.                 }
  795.                 g = g.length ? g + ", " + h[f].name : h[f].name;
  796.             }
  797.             e.set("venue", g ? g : "TBA");
  798.         });
  799.     }
  800. });
  801.  
  802. bandcast.models.Artist = Ext.regModel("Artist", {
  803.     fields: [ {
  804.         name: "id",
  805.         type: "int"
  806.     }, {
  807.         name: "name",
  808.         type: "string"
  809.     }, {
  810.         name: "urlkey",
  811.         type: "string"
  812.     }, {
  813.         name: "description",
  814.         type: "string"
  815.     }, {
  816.         name: "metadata",
  817.         type: "auto"
  818.     }, {
  819.         name: "updated",
  820.         type: "date",
  821.         dateFormat: "c"
  822.     } ],
  823.     proxy: {
  824.         type: "bandcast",
  825.         url: "/proxy/artist",
  826.         id: "id",
  827.         reader: {
  828.             type: "json",
  829.             root: "artists"
  830.         }
  831.     }
  832. });
  833.  
  834. bandcast.stores.Artist = new Ext.data.Store({
  835.     storeId: "artist",
  836.     model: "Artist",
  837.     pageSize: 500,
  838.     sorters: [ {
  839.         property: "name",
  840.         direction: "ASC"
  841.     } ]
  842. });
  843.  
  844. bandcast.models.Venue = Ext.regModel("Venue", {
  845.     fields: [ {
  846.         name: "id",
  847.         type: "int"
  848.     }, {
  849.         name: "name",
  850.         type: "string"
  851.     }, {
  852.         name: "urlkey",
  853.         type: "string"
  854.     }, {
  855.         name: "address",
  856.         type: "string"
  857.     }, {
  858.         name: "city",
  859.         type: "string"
  860.     }, {
  861.         name: "state",
  862.         type: "string"
  863.     }, {
  864.         name: "zip",
  865.         type: "string"
  866.     }, {
  867.         name: "countryid",
  868.         type: "int"
  869.     }, {
  870.         name: "latitude",
  871.         type: "float"
  872.     }, {
  873.         name: "longitude",
  874.         type: "float"
  875.     } ],
  876.     proxy: {
  877.         type: "bandcast",
  878.         url: "/proxy/venue",
  879.         id: "id",
  880.         reader: {
  881.             type: "json",
  882.             root: "venues"
  883.         }
  884.     }
  885. });
  886.  
  887. bandcast.stores.Venue = new Ext.data.Store({
  888.     storeId: "venue",
  889.     model: "Venue",
  890.     pageSize: 50,
  891.     sorters: [ {
  892.         property: "name",
  893.         direction: "ASC"
  894.     } ]
  895. });
  896.  
  897. bandcast.models.Schedule = Ext.regModel("Schedule", {
  898.     fields: [ {
  899.         name: "id",
  900.         type: "int"
  901.     }, {
  902.         name: "name",
  903.         type: "string"
  904.     }, {
  905.         name: "urlkey",
  906.         type: "string"
  907.     }, {
  908.         name: "started",
  909.         type: "date",
  910.         dateFormat: "c"
  911.     }, {
  912.         name: "users",
  913.         type: "auto"
  914.     }, {
  915.         name: "yes",
  916.         type: "int"
  917.     }, {
  918.         name: "maybe",
  919.         type: "int"
  920.     } ],
  921.     proxy: {
  922.         type: "bandcast",
  923.         url: "/proxy/schedule",
  924.         id: "schedule",
  925.         reader: {
  926.             type: "json",
  927.             root: "events",
  928.             totalProperty: "total",
  929.             successProperty: "success"
  930.         }
  931.     }
  932. });
  933.  
  934. bandcast.stores.Schedule = new Ext.data.BandcastStore({
  935.     storeId: "scheduleStore",
  936.     model: "Schedule",
  937.     pageSize: 200,
  938.     sorters: [ {
  939.         property: "started",
  940.         direction: "ASC"
  941.     } ],
  942.     getGroupString: function(a) {
  943.         var b = bandcast.timezoned(a.get("started"));
  944.         return b.format(bandcast.config.event.date.format.timelong);
  945.     }
  946. });
  947.  
  948. bandcast.models.Checkin = Ext.regModel("Checkin", {
  949.     fields: [ {
  950.         name: "id",
  951.         type: "int"
  952.     }, {
  953.         name: "userid",
  954.         type: "int"
  955.     }, {
  956.         name: "type",
  957.         type: "string"
  958.     }, {
  959.         name: "typeid",
  960.         type: "int"
  961.     }, {
  962.         name: "attending",
  963.         type: "int"
  964.     }, {
  965.         name: "checkin",
  966.         type: "date",
  967.         dateFormat: "c"
  968.     }, {
  969.         name: "checkout",
  970.         type: "date",
  971.         dateFormat: "c"
  972.     }, {
  973.         name: "created",
  974.         type: "date",
  975.         dateFormat: "c"
  976.     } ],
  977.     associations: [ {
  978.         type: "belongsTo",
  979.         model: "User",
  980.         name: "user",
  981.         primaryKey: "userid",
  982.         foreignKey: "id"
  983.     } ],
  984.     proxy: {
  985.         type: "bandcast",
  986.         url: "/proxy/checkin",
  987.         id: "checkin",
  988.         reader: {
  989.             type: "json",
  990.             root: "checkins",
  991.             totalProperty: "total",
  992.             successProperty: "success"
  993.         }
  994.     }
  995. });
  996.  
  997. bandcast.views.Login = Ext.extend(Ext.Panel, {
  998.     initComponent: function() {
  999.         if (!Ext.getCmp("loginform")) {
  1000.             var a = {
  1001.                 id: "loginform",
  1002.                 scroll: "vertical",
  1003.                 listeners: {
  1004.                     beforesubmit: function(c, b) {
  1005.                         Ext.dispatch({
  1006.                             controller: "auth",
  1007.                             action: "loginAction",
  1008.                             form: c,
  1009.                             values: b
  1010.                         });
  1011.                         return false;
  1012.                     }
  1013.                 },
  1014.                 items: [ {
  1015.                     xtype: "fieldset",
  1016.                     title: "log in to " + bandcast.config.defaults.title,
  1017.                     defaults: {
  1018.                         labelAlign: "left",
  1019.                         labelWidth: "40%"
  1020.                     },
  1021.                     items: [ {
  1022.                         xtype: "textfield",
  1023.                         name: "username",
  1024.                         label: "Username",
  1025.                         useClearIcon: true,
  1026.                         autoCapitalize: false
  1027.                     }, {
  1028.                         xtype: "passwordfield",
  1029.                         name: "password",
  1030.                         label: "Password",
  1031.                         useClearIcon: false
  1032.                     } ]
  1033.                 }, {
  1034.                     xtype: "button",
  1035.                     text: "Log in",
  1036.                     scope: this,
  1037.                     formBind: true,
  1038.                     handler: function(b) {
  1039.                         form.submit();
  1040.                     }
  1041.                 } ],
  1042.                 dockedItems: [ {
  1043.                     xtype: "toolbar",
  1044.                     dock: "bottom",
  1045.                     ui: "gray",
  1046.                     items: [ {
  1047.                         text: "Forgot password",
  1048.                         handler: function() {
  1049.                             form.destroy();
  1050.                             Ext.dispatch({
  1051.                                 controller: "auth",
  1052.                                 action: "password"
  1053.                             });
  1054.                         }
  1055.                     }, {
  1056.                         xtype: "spacer"
  1057.                     }, {
  1058.                         text: "Create an account",
  1059.                         ui: "confirm",
  1060.                         handler: function() {
  1061.                             form.destroy();
  1062.                             Ext.dispatch({
  1063.                                 controller: "auth",
  1064.                                 action: "register"
  1065.                             });
  1066.                         }
  1067.                     } ]
  1068.                 } ]
  1069.             };
  1070.             if (Ext.is.Phone) {
  1071.                 Ext.apply(a, {
  1072.                     fullscreen: true,
  1073.                     modal: false
  1074.                 });
  1075.             } else {
  1076.                 Ext.apply(a, {
  1077.                     autoRender: true,
  1078.                     floating: true,
  1079.                     modal: true,
  1080.                     centered: true,
  1081.                     hideOnMaskTap: false,
  1082.                     height: 385,
  1083.                     width: 440
  1084.                 });
  1085.             }
  1086.             form = new Ext.form.FormPanel(a);
  1087.             form.show();
  1088.         }
  1089.         bandcast.views.Login.superclass.initComponent.apply(this, arguments);
  1090.     }
  1091. });
  1092.  
  1093. Ext.reg("bandcast.views.Login", bandcast.views.Login);
  1094.  
  1095. bandcast.views.Password = Ext.extend(Ext.Panel, {
  1096.     initComponent: function() {
  1097.         if (!Ext.getCmp("passwordform")) {
  1098.             var a = {
  1099.                 id: "passwordform",
  1100.                 scroll: "vertical",
  1101.                 listeners: {
  1102.                     beforesubmit: function(c, b) {
  1103.                         Ext.dispatch({
  1104.                             controller: "auth",
  1105.                             action: "passwordAction",
  1106.                             form: c,
  1107.                             values: b
  1108.                         });
  1109.                         return false;
  1110.                     }
  1111.                 },
  1112.                 items: [ {
  1113.                     xtype: "fieldset",
  1114.                     title: "reset your password",
  1115.                     defaults: {
  1116.                         labelAlign: "left",
  1117.                         labelWidth: "40%"
  1118.                     },
  1119.                     items: [ {
  1120.                         xtype: "textfield",
  1121.                         name: "email",
  1122.                         label: "Email",
  1123.                         useClearIcon: true,
  1124.                         autoCapitalize: false
  1125.                     } ]
  1126.                 }, {
  1127.                     xtype: "button",
  1128.                     text: "Reset password",
  1129.                     scope: this,
  1130.                     formBind: true,
  1131.                     handler: function(b) {
  1132.                         form.submit();
  1133.                     }
  1134.                 } ],
  1135.                 dockedItems: [ {
  1136.                     xtype: "toolbar",
  1137.                     dock: "bottom",
  1138.                     ui: "gray",
  1139.                     items: [ {
  1140.                         text: "Remembered it",
  1141.                         handler: function() {
  1142.                             form.destroy();
  1143.                             Ext.dispatch({
  1144.                                 controller: "auth",
  1145.                                 action: "login"
  1146.                             });
  1147.                         }
  1148.                     }, {
  1149.                         xtype: "spacer"
  1150.                     }, {
  1151.                         text: "Create an account",
  1152.                         ui: "confirm",
  1153.                         handler: function() {
  1154.                             form.destroy();
  1155.                             Ext.dispatch({
  1156.                                 controller: "auth",
  1157.                                 action: "register"
  1158.                             });
  1159.                         }
  1160.                     } ]
  1161.                 } ]
  1162.             };
  1163.             if (Ext.is.Phone) {
  1164.                 Ext.apply(a, {
  1165.                     fullscreen: true,
  1166.                     modal: false
  1167.                 });
  1168.             } else {
  1169.                 Ext.apply(a, {
  1170.                     autoRender: true,
  1171.                     floating: true,
  1172.                     modal: true,
  1173.                     centered: true,
  1174.                     hideOnMaskTap: false,
  1175.                     height: 385,
  1176.                     width: 440
  1177.                 });
  1178.             }
  1179.             form = new Ext.form.FormPanel(a);
  1180.             form.show();
  1181.         }
  1182.         bandcast.views.Password.superclass.initComponent.apply(this, arguments);
  1183.     }
  1184. });
  1185.  
  1186. Ext.reg("bandcast.views.Password", bandcast.views.Password);
  1187.  
  1188. bandcast.views.Register = Ext.extend(Ext.Panel, {
  1189.     initComponent: function() {
  1190.         if (!Ext.getCmp("registerform")) {
  1191.             var a = {
  1192.                 id: "registerform",
  1193.                 scroll: "vertical",
  1194.                 listeners: {
  1195.                     beforesubmit: function(c, b) {
  1196.                         Ext.dispatch({
  1197.                             controller: "auth",
  1198.                             action: "registerAction",
  1199.                             form: c,
  1200.                             values: b
  1201.                         });
  1202.                         return false;
  1203.                     }
  1204.                 },
  1205.                 items: [ {
  1206.                     xtype: "fieldset",
  1207.                     title: "sign up for " + bandcast.config.defaults.title,
  1208.                     defaults: {
  1209.                         labelAlign: "left",
  1210.                         labelWidth: "40%"
  1211.                     },
  1212.                     items: [ {
  1213.                         xtype: "textfield",
  1214.                         name: "email",
  1215.                         label: "Email",
  1216.                         useClearIcon: true,
  1217.                         autoCapitalize: false
  1218.                     }, {
  1219.                         xtype: "textfield",
  1220.                         name: "username",
  1221.                         label: "Username",
  1222.                         useClearIcon: true,
  1223.                         autoCapitalize: false
  1224.                     }, {
  1225.                         xtype: "passwordfield",
  1226.                         name: "password",
  1227.                         label: "Password",
  1228.                         useClearIcon: false
  1229.                     } ]
  1230.                 }, {
  1231.                     xtype: "button",
  1232.                     text: "Create account",
  1233.                     scope: this,
  1234.                     formBind: true,
  1235.                     handler: function(b) {
  1236.                         form.submit();
  1237.                     }
  1238.                 } ],
  1239.                 dockedItems: [ {
  1240.                     xtype: "toolbar",
  1241.                     dock: "bottom",
  1242.                     ui: "gray",
  1243.                     items: [ {
  1244.                         text: "Forgot password",
  1245.                         handler: function() {
  1246.                             form.destroy();
  1247.                             Ext.dispatch({
  1248.                                 controller: "auth",
  1249.                                 action: "password"
  1250.                             });
  1251.                         }
  1252.                     }, {
  1253.                         xtype: "spacer"
  1254.                     }, {
  1255.                         text: "Have an account?",
  1256.                         ui: "gray",
  1257.                         handler: function() {
  1258.                             form.destroy();
  1259.                             Ext.dispatch({
  1260.                                 controller: "auth",
  1261.                                 action: "login"
  1262.                             });
  1263.                         }
  1264.                     } ]
  1265.                 } ]
  1266.             };
  1267.             if (Ext.is.Phone) {
  1268.                 Ext.apply(a, {
  1269.                     fullscreen: true,
  1270.                     modal: false
  1271.                 });
  1272.             } else {
  1273.                 Ext.apply(a, {
  1274.                     autoRender: true,
  1275.                     floating: true,
  1276.                     modal: true,
  1277.                     centered: true,
  1278.                     hideOnMaskTap: false,
  1279.                     height: 385,
  1280.                     width: 440
  1281.                 });
  1282.             }
  1283.             form = new Ext.form.FormPanel(a);
  1284.             form.show();
  1285.         }
  1286.         bandcast.views.Register.superclass.initComponent.apply(this, arguments);
  1287.     }
  1288. });
  1289.  
  1290. Ext.reg("bandcast.views.Register", bandcast.views.Register);
  1291.  
  1292. bandcast.views.UserDetail = Ext.extend(Ext.Panel, {
  1293.     id: "userdetail",
  1294.     layout: "card",
  1295.     initComponent: function() {
  1296.         var a = Ext.getCmp(this.id);
  1297.         if (a) {
  1298.             if (a.prevCard) {
  1299.                 a.ownerCt.setActiveItem(a.prevCard);
  1300.             }
  1301.             a.destroy();
  1302.         }
  1303.         this.toolbar = new Ext.Toolbar({
  1304.             items: [ {
  1305.                 ui: "back",
  1306.                 text: "Back",
  1307.                 scope: this,
  1308.                 handler: function() {
  1309.                     Ext.History.add(this.prevUrl);
  1310.                     this.ownerCt.setActiveItem(this.prevCard, {
  1311.                         type: "slide",
  1312.                         reverse: true,
  1313.                         scope: this,
  1314.                         after: function() {
  1315.                             this.destroy();
  1316.                         }
  1317.                     });
  1318.                 }
  1319.             }, {
  1320.                 xtype: "spacer",
  1321.                 flex: 1
  1322.             } ]
  1323.         });
  1324.         this.wrapper = new Ext.Panel({
  1325.             layout: "fit",
  1326.             dockedItems: [ this.toolbar ]
  1327.         });
  1328.         if (this.user) {
  1329.             this.toolbar.setTitle(this.user.get("username").toLowerCase());
  1330.             this.wrapper.addDocked({
  1331.                 id: "userinfo",
  1332.                 styleHtmlContent: true,
  1333.                 tpl: new Ext.XTemplate('<div class="detail">', '<div class="avatar"><tpl if="noavatar == 0 && avatars"><img src="{avatars.thumb}" width="45" height="45" alt="{username}" /></tpl></div>', '<div class="blurb">', '<div class="primary">{displayname}</div>', '<tpl if="self == false && loaded == true && friend == true">', '<div class="secondary">{displayname} is your friend</div>', "</tpl>", '<tpl if="self == false && loaded == true && friend == false">', '<div class="secondary">{displayname} is not your friend</div>', "</tpl>", '<tpl if="self == false && loaded == false">', '<div class="secondary">Loading relationship ...</div>', "</tpl>", '<tpl if="self == true">', '<div class="secondary">This is you!</div>', "</tpl>", "</div>", "</div>"),
  1334.                 data: Ext.apply(this.user.data, {
  1335.                     friend: this.friend,
  1336.                     loaded: this.loaded,
  1337.                     self: this.user.get("username") == Ext.data.auth.get("user").username
  1338.                 })
  1339.             });
  1340.             this.wrapper.doLayout();
  1341.         }
  1342.         Ext.apply(this, {
  1343.             items: [ this.wrapper ]
  1344.         });
  1345.         bandcast.views.UserDetail.superclass.initComponent.call(this);
  1346.     },
  1347.     buildList: function() {
  1348.         this.list = new Ext.List({
  1349.             store: this.user.activity(),
  1350.             loadingText: "Loading",
  1351.             plugins: [ {
  1352.                 ptype: "pullrefresh",
  1353.                 pullRefreshText: "Pull down to refresh",
  1354.                 releaseRefreshText: "Release to refresh",
  1355.                 loadingText: "Loading..."
  1356.             } ],
  1357.             itemTpl: new Ext.XTemplate('<tpl for=".">', '<div class="primary">{activity:this.unlink}</div>', '<div class="secondary">{created:this.timeago}</div>', "</tpl>", {
  1358.                 unlink: function(a) {
  1359.                     return a.replace(/(<a ([^>]+)>)/ig, "");
  1360.                 },
  1361.                 timeago: function(a) {
  1362.                     return bandcast.timeago(a, true);
  1363.                 }
  1364.             }),
  1365.             listeners: {
  1366.                 afterrender: {
  1367.                     fn: function(a) {
  1368.                         a.store.load();
  1369.                     },
  1370.                     scope: this
  1371.                 }
  1372.             }
  1373.         });
  1374.         this.wrapper.add(this.list);
  1375.         this.wrapper.doComponentLayout();
  1376.     },
  1377.     allowFriend: function() {
  1378.         this.toolbar.add({
  1379.             ui: "button",
  1380.             iconCls: "user_add",
  1381.             iconMask: true,
  1382.             scope: this,
  1383.             handler: function(a, b) {
  1384.                 Ext.dispatch({
  1385.                     controller: "friend",
  1386.                     action: "addAction",
  1387.                     username: this.user.get("username")
  1388.                 });
  1389.             }
  1390.         });
  1391.         this.wrapper.doComponentLayout();
  1392.         this.toolbar.doComponentLayout();
  1393.     },
  1394.     allowMessage: function() {
  1395.         this.toolbar.add({
  1396.             ui: "button",
  1397.             iconCls: "compose",
  1398.             iconMask: true,
  1399.             scope: this,
  1400.             handler: function(a, b) {
  1401.                 Ext.dispatch({
  1402.                     controller: "activity",
  1403.                     action: "add",
  1404.                     prevCard: this.wrapper,
  1405.                     parent: this,
  1406.                     recipient: this.user.get("username")
  1407.                 });
  1408.             }
  1409.         });
  1410.         this.toolbar.doComponentLayout();
  1411.     },
  1412.     invalidUser: function() {
  1413.         this.toolbar.setTitle("invalid user");
  1414.         this.wrapper.remove(Ext.getCmp("userinfo"));
  1415.     }
  1416. });
  1417.  
  1418. Ext.reg("bandcast.views.UserDetail", bandcast.views.UserDetail);
  1419.  
  1420. bandcast.views.ActivityAdd = Ext.extend(Ext.form.FormPanel, {
  1421.     id: "activityadd",
  1422.     initComponent: function() {
  1423.         var e = Ext.getCmp(this.id);
  1424.         if (e) {
  1425.             if (e.prevCard) {
  1426.                 e.ownerCt.setActiveItem(e.prevCard);
  1427.             }
  1428.             e.destroy();
  1429.         }
  1430.         if (this.recipient) {
  1431.             var f = "message", a = "Send a private message to " + this.recipient + ". You must be friends for the message to be received.", c = "Send message";
  1432.         } else {
  1433.             var f = "broadcast", a = "Tell your friends what you're doing, where you are, what you recommend, etc.", c = "Tell my friends";
  1434.         }
  1435.         var d = new Ext.Toolbar({
  1436.             title: f,
  1437.             items: [ {
  1438.                 ui: "back",
  1439.                 text: "Back",
  1440.                 scope: this,
  1441.                 handler: function() {
  1442.                     this.goBack();
  1443.                 }
  1444.             } ]
  1445.         });
  1446.         var b = [ {
  1447.             xtype: "fieldset",
  1448.             instructions: a,
  1449.             items: [ {
  1450.                 xtype: "textareafield",
  1451.                 name: "status",
  1452.                 maxLength: 140,
  1453.                 maxRows: 4,
  1454.                 useClearIcon: true
  1455.             } ]
  1456.         }, {
  1457.             xtype: "button",
  1458.             text: c,
  1459.             scope: this,
  1460.             formBind: true,
  1461.             handler: function(g) {
  1462.                 this.submit();
  1463.             }
  1464.         } ];
  1465.         Ext.apply(this, {
  1466.             dockedItems: d,
  1467.             items: b,
  1468.             scope: this,
  1469.             listeners: {
  1470.                 beforesubmit: function(h, g) {
  1471.                     if (g.status) {
  1472.                         Ext.dispatch({
  1473.                             controller: "activity",
  1474.                             action: "addAction",
  1475.                             form: h,
  1476.                             values: Ext.apply(g, {
  1477.                                 recipient: this.recipient
  1478.                             })
  1479.                         });
  1480.                         this.goBack();
  1481.                     } else {
  1482.                         Ext.Msg.alert("Missing message", "Whoops! You forgot to post your message.", Ext.emptyFn);
  1483.                     }
  1484.                     return false;
  1485.                 }
  1486.             }
  1487.         });
  1488.         bandcast.views.ActivityAdd.superclass.initComponent.call(this);
  1489.     },
  1490.     goBack: function() {
  1491.         this.ownerCt.setActiveItem(this.prevCard, {
  1492.             type: "slide",
  1493.             reverse: true,
  1494.             scope: this,
  1495.             after: function() {
  1496.                 this.destroy();
  1497.             }
  1498.         });
  1499.     }
  1500. });
  1501.  
  1502. Ext.reg("bandcast.views.ActivityAdd", bandcast.views.ActivityAdd);
  1503.  
  1504. bandcast.views.ActivityList = Ext.extend(Ext.Panel, {
  1505.     id: "activitylist",
  1506.     layout: "card",
  1507.     historyUrl: "activity/list",
  1508.     initComponent: function() {
  1509.         this.buttons = new Ext.SegmentedButton({
  1510.             defaults: {
  1511.                 flex: 1
  1512.             },
  1513.             items: [ {
  1514.                 text: bandcast.config.aliases.event.single + " check in",
  1515.                 scope: this,
  1516.                 handler: function(a, b) {
  1517.                     Ext.dispatch({
  1518.                         controller: "event",
  1519.                         action: "checkin",
  1520.                         btn: a,
  1521.                         callback: function() {
  1522.                             a.removeCls(a.pressedCls);
  1523.                         }
  1524.                     });
  1525.                 }
  1526.             }, {
  1527.                 text: bandcast.config.aliases.venue.single + " check in",
  1528.                 scope: this,
  1529.                 handler: function(a, b) {
  1530.                     Ext.dispatch({
  1531.                         controller: "venue",
  1532.                         action: "checkin",
  1533.                         btn: a,
  1534.                         callback: function() {
  1535.                             a.removeCls(a.pressedCls);
  1536.                         }
  1537.                     });
  1538.                 }
  1539.             } ],
  1540.             layout: {
  1541.                 pack: "center"
  1542.             },
  1543.             style: {
  1544.                 width: "100%",
  1545.                 fontSize: "80%"
  1546.             }
  1547.         });
  1548.         this.wrapper = new Ext.Panel({
  1549.             layout: "fit",
  1550.             items: this.buildList(),
  1551.             dockedItems: [ {
  1552.                 xtype: "toolbar",
  1553.                 title: "activity stream",
  1554.                 items: [ {
  1555.                     xtype: "spacer",
  1556.                     flex: 1
  1557.                 }, {
  1558.                     ui: "button",
  1559.                     iconCls: "compose",
  1560.                     iconMask: true,
  1561.                     scope: this,
  1562.                     handler: function(a, b) {
  1563.                         Ext.dispatch({
  1564.                             controller: "activity",
  1565.                             action: "add",
  1566.                             prevCard: this.wrapper,
  1567.                             parent: this
  1568.                         });
  1569.                     }
  1570.                 } ]
  1571.             }, {
  1572.                 xtype: "toolbar",
  1573.                 ui: "light",
  1574.                 items: this.buttons,
  1575.                 layout: {
  1576.                     pack: "center"
  1577.                 }
  1578.             } ]
  1579.         });
  1580.         Ext.apply(this, {
  1581.             items: [ this.wrapper ]
  1582.         });
  1583.         bandcast.views.ActivityList.superclass.initComponent.call(this);
  1584.     },
  1585.     buildList: function() {
  1586.         this.list = new Ext.List({
  1587.             store: bandcast.stores.Activity,
  1588.             loadingText: "Loading",
  1589.             plugins: [ {
  1590.                 ptype: "pullrefresh",
  1591.                 pullRefreshText: "Pull down to refresh",
  1592.                 releaseRefreshText: "Release to refresh",
  1593.                 loadingText: "Loading..."
  1594.             } ],
  1595.             itemTpl: new Ext.XTemplate('<tpl for=".">', '<div class="avatar"><tpl if="noavatar == 0 && avatars"><img src="{avatars.thumb}" width="45" height="45" alt="{username}" /></tpl></div>', '<div class="primary">{activity}</div>', '<div class="secondary">{created:this.timeago}</div>', "</tpl>", {
  1596.                 timeago: function(a) {
  1597.                     if (a) {
  1598.                         return bandcast.timeago(a, true);
  1599.                     } else {
  1600.                         return "pending";
  1601.                     }
  1602.                 }
  1603.             }),
  1604.             listeners: {
  1605.                 click: {
  1606.                     element: "el",
  1607.                     delegate: "a",
  1608.                     stopEvent: true,
  1609.                     fn: function(b, a) {
  1610.                         if (this.delayedTask != null) {
  1611.                             this.delayedTask.cancel();
  1612.                             this.delayedTask = null;
  1613.                         }
  1614.                         this.linkHandler(b, a);
  1615.                     },
  1616.                     scope: this
  1617.                 },
  1618.                 itemtap: {
  1619.                     fn: function(a, b, d, c) {
  1620.                         a.getSelectionModel().deselectAll();
  1621.                         if (this.delayedTask == null) {
  1622.                             this.delayedTask = new Ext.util.DelayedTask(function() {
  1623.                                 var e = a.getSelectionModel();
  1624.                                 e.select(b);
  1625.                                 (new Ext.util.DelayedTask(function() {
  1626.                                     a.getSelectionModel().deselectAll();
  1627.                                 }, this)).delay(400);
  1628.                                 this.showUser(a.getSelectedRecords()[0].data.username);
  1629.                                 this.delayedTask = null;
  1630.                             }, this);
  1631.                         }
  1632.                         this.delayedTask.delay(200);
  1633.                     },
  1634.                     scope: this
  1635.                 },
  1636.                 afterrender: {
  1637.                     fn: function(a) {
  1638.                         a.setLoading(true);
  1639.                         a.store.load();
  1640.                     },
  1641.                     scope: this
  1642.                 }
  1643.             }
  1644.         });
  1645.         return this.list;
  1646.     },
  1647.     linkHandler: function(h, b) {
  1648.         var g = h.getTarget(), d = g.outerHTML, c = /data-([^=]*)="([^"]*)"/g, f = {}, a;
  1649.         while (a = c.exec(d)) {
  1650.             f[a[1]] = a[2];
  1651.         }
  1652.         switch (f.type) {
  1653.           case "user":
  1654.             this.showUser(f.username);
  1655.             break;
  1656.           case "event":
  1657.             this.showEvent(f.event);
  1658.             break;
  1659.           case "venue":
  1660.             this.showVenue(f.venue);
  1661.             break;
  1662.           case "artist":
  1663.             this.showArtist(f.artist);
  1664.             break;
  1665.         }
  1666.     },
  1667.     showUser: function(a) {
  1668.         Ext.dispatch({
  1669.             controller: "user",
  1670.             action: "detail",
  1671.             historyUrl: "user/-/" + a,
  1672.             prevCard: this.wrapper,
  1673.             prevUrl: this.historyUrl,
  1674.             username: a,
  1675.             parent: this
  1676.         });
  1677.     },
  1678.     showEvent: function(a) {
  1679.         Ext.dispatch({
  1680.             controller: "event",
  1681.             action: "detail",
  1682.             historyUrl: "event/-/" + a,
  1683.             prevCard: this.wrapper,
  1684.             prevUrl: this.historyUrl,
  1685.             event: a,
  1686.             parent: this
  1687.         });
  1688.     },
  1689.     showVenue: function(a) {
  1690.         Ext.dispatch({
  1691.             controller: "venue",
  1692.             action: "detail",
  1693.             historyUrl: "venue/-/" + a,
  1694.             prevCard: this.wrapper,
  1695.             prevUrl: this.historyUrl,
  1696.             venue: a,
  1697.             parent: this
  1698.         });
  1699.     },
  1700.     showArtist: function(a) {
  1701.         Ext.dispatch({
  1702.             controller: "artist",
  1703.             action: "detail",
  1704.             historyUrl: "artist/-/" + a,
  1705.             prevCard: this.wrapper,
  1706.             prevUrl: this.historyUrl,
  1707.             artist: a,
  1708.             parent: this
  1709.         });
  1710.     }
  1711. });
  1712.  
  1713. Ext.reg("bandcast.views.ActivityList", bandcast.views.ActivityList);
  1714.  
  1715. bandcast.views.EventList = Ext.extend(Ext.Panel, {
  1716.     id: "eventlist",
  1717.     layout: "card",
  1718.     historyUrl: "event/list",
  1719.     listeners: {
  1720.         activate: function() {
  1721.             bandcast.stores.Event.clearFilter();
  1722.             var a = this.buttons.getPressed();
  1723.             if (a && a.sort) {
  1724.                 bandcast.stores.Event["sort" + a.sort]();
  1725.             }
  1726.         }
  1727.     },
  1728.     initComponent: function() {
  1729.         this.buttons = new Ext.SegmentedButton({
  1730.             defaults: {
  1731.                 flex: 1
  1732.             },
  1733.             listeners: {
  1734.                 afterlayout: function() {
  1735.                     this.setPressed(0, true, false);
  1736.                 }
  1737.             },
  1738.             items: [ {
  1739.                 text: "alphabetical",
  1740.                 sort: "Alpha",
  1741.                 scope: this,
  1742.                 handler: function(a, b) {
  1743.                     this.list.store.sortAlpha();
  1744.                     if (this.list.indexBar && this.list.indexBar.id) {
  1745.                         Ext.getCmp(this.list.indexBar.id).show();
  1746.                     }
  1747.                 }
  1748.             }, {
  1749.                 text: "by " + bandcast.config.aliases.venue.single,
  1750.                 sort: "Venue",
  1751.                 scope: this,
  1752.                 handler: function(a, b) {
  1753.                     this.list.store.sortVenue();
  1754.                     if (this.list.indexBar && this.list.indexBar.id) {
  1755.                         Ext.getCmp(this.list.indexBar.id).hide();
  1756.                     }
  1757.                 }
  1758.             }, {
  1759.                 text: "by time",
  1760.                 sort: "Time",
  1761.                 scope: this,
  1762.                 handler: function(a, b) {
  1763.                     this.list.store.sortTime();
  1764.                     if (this.list.indexBar && this.list.indexBar.id) {
  1765.                         Ext.getCmp(this.list.indexBar.id).hide();
  1766.                     }
  1767.                 }
  1768.             } ],
  1769.             layout: {
  1770.                 pack: "center"
  1771.             },
  1772.             style: {
  1773.                 width: "100%",
  1774.                 fontSize: "80%"
  1775.             }
  1776.         });
  1777.         this.wrapper = new Ext.Panel({
  1778.             layout: "fit",
  1779.             items: this.buildList(),
  1780.             dockedItems: [ {
  1781.                 xtype: "toolbar",
  1782.                 title: "the " + bandcast.config.aliases.event.plural
  1783.             }, {
  1784.                 xtype: "toolbar",
  1785.                 ui: "light",
  1786.                 items: this.buttons,
  1787.                 layout: {
  1788.                     pack: "center"
  1789.                 }
  1790.             } ]
  1791.         });
  1792.         Ext.apply(this, {
  1793.             items: [ this.wrapper ]
  1794.         });
  1795.         bandcast.views.EventList.superclass.initComponent.call(this);
  1796.     },
  1797.     buildList: function() {
  1798.         this.list = new Ext.List({
  1799.             store: bandcast.stores.Event,
  1800.             grouped: true,
  1801.             indexBar: Ext.is.Phone,
  1802.             loadingText: "Loading",
  1803.             itemTpl: new Ext.XTemplate('<tpl for=".">', '<div class="primary">{name}</div>', '<div class="secondary">{started:this.date} @ {venue}</div>', "</tpl>", {
  1804.                 date: function(a) {
  1805.                     var b = bandcast.timezoned(a);
  1806.                     return b.format(bandcast.config.event.date.format.timeshort);
  1807.                 },
  1808.                 compiled: true
  1809.             }),
  1810.             listeners: {
  1811.                 itemtap: {
  1812.                     fn: function(a, b, c, d) {
  1813.                         this.showEvent(a.store.getAt(b).data.urlkey);
  1814.                         (new Ext.util.DelayedTask(function() {
  1815.                             a.getSelectionModel().deselectAll();
  1816.                         }, this)).delay(700);
  1817.                     },
  1818.                     scope: this
  1819.                 },
  1820.                 afterrender: {
  1821.                     fn: function(a) {
  1822.                         if (!this.list.store.getCount()) {
  1823.                             a.setLoading(true);
  1824.                             a.store.load();
  1825.                         }
  1826.                     },
  1827.                     scope: this
  1828.                 }
  1829.             }
  1830.         });
  1831.         return this.list;
  1832.     },
  1833.     showEvent: function(a) {
  1834.         Ext.dispatch({
  1835.             controller: "event",
  1836.             action: "detail",
  1837.             historyUrl: "event/-/" + a,
  1838.             prevCard: this.wrapper,
  1839.             prevUrl: this.historyUrl,
  1840.             event: a,
  1841.             parent: this
  1842.         });
  1843.     }
  1844. });
  1845.  
  1846. Ext.reg("bandcast.views.EventList", bandcast.views.EventList);
  1847.  
  1848. bandcast.views.EventCheckin = Ext.extend(Ext.Sheet, {
  1849.     id: "eventcheckin",
  1850.     hideOnMaskTap: true,
  1851.     checked: null,
  1852.     scroll: "vertical",
  1853.     stretchX: true,
  1854.     stretchY: true,
  1855.     initComponent: function() {
  1856.         Ext.apply(this, {
  1857.             items: {
  1858.                 xtype: "fieldset",
  1859.                 cls: "radio-checkin",
  1860.                 defaults: {
  1861.                     xtype: "radiofield",
  1862.                     labelWidth: "100%",
  1863.                     listeners: {
  1864.                         render: function(a) {
  1865.                             if (a.labelEl) {
  1866.                                 a.labelEl.on("click", function() {
  1867.                                     a.setChecked(true);
  1868.                                 }, a);
  1869.                             }
  1870.                         },
  1871.                         check: {
  1872.                             fn: function(a) {
  1873.                                 this.checked = a;
  1874.                             },
  1875.                             scope: this
  1876.                         }
  1877.                     }
  1878.                 },
  1879.                 items: this.getEvents()
  1880.             },
  1881.             dockedItems: {
  1882.                 xtype: "button",
  1883.                 text: "Check in",
  1884.                 ui: "action",
  1885.                 dock: "bottom",
  1886.                 scope: this,
  1887.                 handler: function(a, b) {
  1888.                     Ext.dispatch({
  1889.                         controller: "event",
  1890.                         action: "checkinAction",
  1891.                         id: this.checked.value,
  1892.                         name: this.checked.label
  1893.                     });
  1894.                     a.up().destroy();
  1895.                     return false;
  1896.                 }
  1897.             },
  1898.             listeners: {
  1899.                 hide: function(a) {
  1900.                     if (typeof this.callback == "function") {
  1901.                         a.destroy();
  1902.                         this.callback();
  1903.                     }
  1904.                 }
  1905.             }
  1906.         });
  1907.         bandcast.views.EventCheckin.superclass.initComponent.apply(this, arguments);
  1908.     },
  1909.     getEvents: function() {
  1910.         var a = Ext.getStore("event"), b = [];
  1911.         if (a) {
  1912.             a.clearFilter();
  1913.             a.sort("name", "ASC");
  1914.             a.each(function(c) {
  1915.                 b.push({
  1916.                     name: "event",
  1917.                     label: c.get("name"),
  1918.                     value: c.get("id")
  1919.                 });
  1920.             });
  1921.         }
  1922.         return b;
  1923.     },
  1924.     alignTo: function(a, c, b) {
  1925.         b -= 10;
  1926.         bandcast.views.EventCheckin.superclass.alignTo.apply(this, [ a, c, b ]);
  1927.     }
  1928. });
  1929.  
  1930. Ext.reg("bandcast.views.EventCheckin", bandcast.views.EventCheckin);
  1931.  
  1932. bandcast.views.EventDetail = Ext.extend(Ext.Panel, {
  1933.     id: "eventdetail",
  1934.     scroll: "vertical",
  1935.     initComponent: function() {
  1936.         var a = Ext.getCmp(this.id);
  1937.         if (a) {
  1938.             if (a.prevCard) {
  1939.                 a.ownerCt.setActiveItem(a.prevCard);
  1940.             }
  1941.             a.destroy();
  1942.         }
  1943.         this.toolbar = new Ext.Toolbar({
  1944.             items: [ {
  1945.                 ui: "back",
  1946.                 text: "Back",
  1947.                 scope: this,
  1948.                 handler: function() {
  1949.                     Ext.History.add(this.prevUrl);
  1950.                     this.ownerCt.setActiveItem(this.prevCard, {
  1951.                         type: "slide",
  1952.                         reverse: true,
  1953.                         scope: this,
  1954.                         after: function() {
  1955.                             this.destroy();
  1956.                         }
  1957.                     });
  1958.                 }
  1959.             } ]
  1960.         });
  1961.         if (this.event) {
  1962.             this.toolbar.setTitle(this.event.get("name").toLowerCase());
  1963.             Ext.apply(this, {
  1964.                 items: [ {
  1965.                     styleHtmlContent: true,
  1966.                     tpl: new Ext.XTemplate('<div class="detail">', '<div class="avatar"><tpl if="metadata && metadata.images"><img src="{metadata.images.thumb}" width="45" height="45" alt="{name}" /></tpl></div>', '<div class="blurb">', '<div class="primary">{name}</div>', '<div class="secondary">{venue}, {started:this.date} - {ended:this.date}</div>', "</div>", "</div>", {
  1967.                         date: function(b) {
  1968.                             var d = new Date(b.getTime());
  1969.                             if (typeof bandcast.config.event.date.timezone != "undefined") {
  1970.                                 var c = b.getTimezoneOffset() + bandcast.config.event.date.timezone * 60;
  1971.                                 d.setTime(b.getTime() + c * 6e4);
  1972.                             }
  1973.                             return d.format(bandcast.config.event.date.format.timeshort);
  1974.                         },
  1975.                         compiled: true
  1976.                     }),
  1977.                     data: this.event.data
  1978.                 } ]
  1979.             });
  1980.             this.addArtists(this.event.get("artists"));
  1981.         }
  1982.         Ext.apply(this, {
  1983.             dockedItems: [ this.toolbar, this.buildCheckin() ]
  1984.         });
  1985.         this.buildCheckin();
  1986.         bandcast.views.EventDetail.superclass.initComponent.call(this);
  1987.     },
  1988.     buildCheckin: function() {
  1989.         return new Ext.Toolbar({
  1990.             xtype: "toolbar",
  1991.             ui: "light",
  1992.             layout: {
  1993.                 pack: "center"
  1994.             },
  1995.             items: new Ext.SegmentedButton({
  1996.                 defaults: {
  1997.                     flex: 1
  1998.                 },
  1999.                 items: [ {
  2000.                     text: "I'm going",
  2001.                     scope: this,
  2002.                     handler: function(a, b) {
  2003.                         Ext.dispatch({
  2004.                             controller: "event",
  2005.                             action: "rsvpAction",
  2006.                             eventid: this.event.get("id"),
  2007.                             value: 2,
  2008.                             btn: a
  2009.                         });
  2010.                     }
  2011.                 }, {
  2012.                     text: "Not going",
  2013.                     scope: this,
  2014.                     handler: function(a, b) {
  2015.                         Ext.dispatch({
  2016.                             controller: "event",
  2017.                             action: "rsvpAction",
  2018.                             eventid: this.event.get("id"),
  2019.                             value: 0,
  2020.                             btn: a
  2021.                         });
  2022.                     }
  2023.                 } ],
  2024.                 layout: {
  2025.                     pack: "center"
  2026.                 },
  2027.                 style: {
  2028.                     width: "100%",
  2029.                     fontSize: "80%"
  2030.                 }
  2031.             })
  2032.         });
  2033.     },
  2034.     addArtists: function(a) {
  2035.         var c = a ? a.length : 0;
  2036.         if (c) {
  2037.             for (var b = 0; b < c; b++) {
  2038.                 if (c > 1) {
  2039.                     this.items.push({
  2040.                         xtype: "toolbar",
  2041.                         title: a[b].name,
  2042.                         ui: "gray",
  2043.                         cls: "small_title"
  2044.                     });
  2045.                 }
  2046.                 this.items.push({
  2047.                     styleHtmlContent: true,
  2048.                     tpl: new Ext.XTemplate('<div id="artist-{id}" class="description">{id:this.description}</div>', {
  2049.                         description: function(e) {
  2050.                             var d = bandcast.stores.Artist.getById(e);
  2051.                             return d ? d.get("description") : "Loading ...";
  2052.                         }
  2053.                     }),
  2054.                     data: a[b]
  2055.                 });
  2056.             }
  2057.         }
  2058.     }
  2059. });
  2060.  
  2061. Ext.reg("bandcast.views.EventDetail", bandcast.views.EventDetail);
  2062.  
  2063. bandcast.views.FriendList = Ext.extend(Ext.Panel, {
  2064.     id: "friendlist",
  2065.     layout: "card",
  2066.     historyUrl: "friend/list",
  2067.     initComponent: function() {
  2068.         this.wrapper = new Ext.Panel({
  2069.             layout: "fit",
  2070.             items: this.buildList(),
  2071.             dockedItems: [ {
  2072.                 xtype: "toolbar",
  2073.                 title: "my friends",
  2074.                 items: [ {
  2075.                     ui: "button",
  2076.                     iconCls: "inbox2",
  2077.                     iconMask: true,
  2078.                     scope: this,
  2079.                     badgeText: bandcast.stores.Request.getCount(),
  2080.                     handler: function(a, b) {
  2081.                         Ext.dispatch({
  2082.                             controller: "friend",
  2083.                             action: "requests",
  2084.                             historyUrl: "friend/requests",
  2085.                             prevCard: this.wrapper,
  2086.                             parent: this
  2087.                         });
  2088.                     }
  2089.                 }, {
  2090.                     xtype: "spacer",
  2091.                     flex: 1
  2092.                 }, {
  2093.                     ui: "button",
  2094.                     iconCls: "search",
  2095.                     iconMask: true,
  2096.                     scope: this,
  2097.                     handler: function(a, b) {
  2098.                         Ext.dispatch({
  2099.                             controller: "friend",
  2100.                             action: "search",
  2101.                             historyUrl: "friend/search",
  2102.                             prevCard: this.wrapper,
  2103.                             parent: this
  2104.                         });
  2105.                     }
  2106.                 } ]
  2107.             } ]
  2108.         });
  2109.         Ext.apply(this, {
  2110.             items: [ this.wrapper ]
  2111.         });
  2112.         bandcast.views.FriendList.superclass.initComponent.call(this);
  2113.     },
  2114.     buildList: function() {
  2115.         this.list = new Ext.List({
  2116.             store: bandcast.stores.Friend,
  2117.             loadingText: "Loading",
  2118.             plugins: [ {
  2119.                 ptype: "pullrefresh",
  2120.                 pullRefreshText: "Pull down to refresh",
  2121.                 releaseRefreshText: "Release to refresh",
  2122.                 loadingText: "Loading..."
  2123.             } ],
  2124.             itemTpl: new Ext.XTemplate('<tpl for=".">', '<div class="avatar"><tpl if="noavatar == 0"><img src="{avatars.thumb}" width="45" height="45" alt="{username}" /></tpl></div>', '<div class="primary">{displayname}</div>', '<div class="secondary">{checkin:this.location}</div>', "</tpl>", {
  2125.                 location: function(b) {
  2126.                     if (b && !b.checkout) {
  2127.                         switch (b.type) {
  2128.                           case "event":
  2129.                             var a = bandcast.stores.Event.getById(b.typeid);
  2130.                             if (a) {
  2131.                                 return a.get("name") + " (" + bandcast.timeago(b.checkin, true) + " ago)";
  2132.                             }
  2133.                             break;
  2134.                           case "venue":
  2135.                             var c = bandcast.stores.Venue.getById(b.typeid);
  2136.                             if (c) {
  2137.                                 return c.get("name") + " (" + bandcast.timeago(b.checkin, true) + " ago)";
  2138.                             }
  2139.                             break;
  2140.                         }
  2141.                     }
  2142.                     return "off the grid";
  2143.                 }
  2144.             }),
  2145.             listeners: {
  2146.                 itemtap: {
  2147.                     fn: function(a, b, c, d) {
  2148.                         this.showUser(a.store.getAt(b).data.username);
  2149.                         (new Ext.util.DelayedTask(function() {
  2150.                             a.getSelectionModel().deselectAll();
  2151.                         }, this)).delay(700);
  2152.                     },
  2153.                     scope: this
  2154.                 },
  2155.                 afterrender: {
  2156.                     fn: function(a) {
  2157.                         a.setLoading(true);
  2158.                         a.store.load();
  2159.                     },
  2160.                     scope: this
  2161.                 }
  2162.             }
  2163.         });
  2164.         return this.list;
  2165.     },
  2166.     showUser: function(a) {
  2167.         Ext.dispatch({
  2168.             controller: "user",
  2169.             action: "detail",
  2170.             historyUrl: "user/-/" + a,
  2171.             prevCard: this.wrapper,
  2172.             prevUrl: this.historyUrl,
  2173.             username: a,
  2174.             parent: this
  2175.         });
  2176.     }
  2177. });
  2178.  
  2179. Ext.reg("bandcast.views.FriendList", bandcast.views.FriendList);
  2180.  
  2181. bandcast.views.FriendRequests = Ext.extend(Ext.Panel, {
  2182.     id: "friendrequests",
  2183.     layout: "card",
  2184.     historyUrl: "friend/requests",
  2185.     initComponent: function() {
  2186.         this.toolbar = new Ext.Toolbar({
  2187.             title: "friend requests",
  2188.             items: [ {
  2189.                 ui: "back",
  2190.                 text: "Back",
  2191.                 scope: this,
  2192.                 handler: function() {
  2193.                     this.ownerCt.setActiveItem(this.prevCard, {
  2194.                         type: "slide",
  2195.                         reverse: true,
  2196.                         scope: this,
  2197.                         after: function() {
  2198.                             this.destroy();
  2199.                         }
  2200.                     });
  2201.                 }
  2202.             } ]
  2203.         });
  2204.         Ext.apply(this, {
  2205.             dockedItems: this.toolbar,
  2206.             items: this.buildList()
  2207.         });
  2208.         bandcast.views.FriendList.superclass.initComponent.call(this);
  2209.     },
  2210.     buildList: function() {
  2211.         this.list = new Ext.List({
  2212.             store: bandcast.stores.Request,
  2213.             loadingText: "Loading",
  2214.             plugins: [ {
  2215.                 ptype: "pullrefresh",
  2216.                 pullRefreshText: "Pull down to refresh",
  2217.                 releaseRefreshText: "Release to refresh",
  2218.                 loadingText: "Loading..."
  2219.             } ],
  2220.             itemTpl: new Ext.XTemplate('<tpl for=".">', '<div class="avatar"><tpl if="noavatar == 0"><img src="{avatars.thumb}" width="45" height="45" alt="{username}" /></tpl></div>', '<div class="primary">{displayname}</div>', "</tpl>"),
  2221.             listeners: {
  2222.                 itemtap: {
  2223.                     fn: function(a, b, c, d) {
  2224.                         this.showPrompt(a.store.getAt(b).data.username);
  2225.                         (new Ext.util.DelayedTask(function() {
  2226.                             a.getSelectionModel().deselectAll();
  2227.                         }, this)).delay(700);
  2228.                     },
  2229.                     scope: this
  2230.                 },
  2231.                 afterrender: {
  2232.                     fn: function(a) {
  2233.                         a.setLoading(true);
  2234.                         a.store.load();
  2235.                     },
  2236.                     scope: this
  2237.                 }
  2238.             }
  2239.         });
  2240.         return this.list;
  2241.     },
  2242.     showPrompt: function(a) {
  2243.         this.actions = new Ext.ActionSheet({
  2244.             items: [ {
  2245.                 text: "Approve friendship",
  2246.                 ui: "confirm",
  2247.                 scope: this,
  2248.                 handler: function() {
  2249.                     Ext.dispatch({
  2250.                         controller: "friend",
  2251.                         action: "approveAction",
  2252.                         username: a
  2253.                     });
  2254.                     this.actions.hide(false);
  2255.                     this.actions.destroy();
  2256.                     delete this.actions;
  2257.                 }
  2258.             }, {
  2259.                 text: "Deny friendship",
  2260.                 ui: "decline",
  2261.                 scope: this,
  2262.                 handler: function() {
  2263.                     Ext.dispatch({
  2264.                         controller: "friend",
  2265.                         action: "denyAction",
  2266.                         username: a
  2267.                     });
  2268.                     this.actions.hide(false);
  2269.                     this.actions.destroy();
  2270.                     delete this.actions;
  2271.                 }
  2272.             }, {
  2273.                 text: "Cancel",
  2274.                 scope: this,
  2275.                 handler: function() {
  2276.                     this.actions.hide(false);
  2277.                     this.actions.destroy();
  2278.                     delete this.actions;
  2279.                 }
  2280.             } ]
  2281.         });
  2282.         this.actions.show();
  2283.     }
  2284. });
  2285.  
  2286. Ext.reg("bandcast.views.FriendRequests", bandcast.views.FriendRequests);
  2287.  
  2288. bandcast.views.FriendSearch = Ext.extend(Ext.form.FormPanel, {
  2289.     id: "friendsearch",
  2290.     initComponent: function() {
  2291.         this.toolbar = new Ext.Toolbar({
  2292.             title: "user search",
  2293.             items: [ {
  2294.                 ui: "back",
  2295.                 text: "Back",
  2296.                 scope: this,
  2297.                 handler: function() {
  2298.                     this.ownerCt.setActiveItem(this.prevCard, {
  2299.                         type: "slide",
  2300.                         reverse: true,
  2301.                         scope: this,
  2302.                         after: function() {
  2303.                             this.destroy();
  2304.                         }
  2305.                     });
  2306.                 }
  2307.             } ]
  2308.         });
  2309.         Ext.apply(this, {
  2310.             scroll: "vertical",
  2311.             defaults: {
  2312.                 xtype: "fieldset",
  2313.                 defaults: {
  2314.                     labelWidth: "35%"
  2315.                 }
  2316.             },
  2317.             listeners: {
  2318.                 beforesubmit: function(b, a) {
  2319.                     Ext.dispatch({
  2320.                         controller: "friend",
  2321.                         action: "searchAction",
  2322.                         form: b,
  2323.                         values: a
  2324.                     });
  2325.                     return false;
  2326.                 }
  2327.             },
  2328.             items: [ {
  2329.                 items: [ {
  2330.                     xtype: "textfield",
  2331.                     name: "username",
  2332.                     label: "Username",
  2333.                     autoCapitalize: false,
  2334.                     useClearIcon: true
  2335.                 } ]
  2336.             }, {
  2337.                 xtype: "button",
  2338.                 text: "Search",
  2339.                 scope: this,
  2340.                 formBind: true,
  2341.                 handler: function(a) {
  2342.                     this.submit();
  2343.                 }
  2344.             } ],
  2345.             dockedItems: [ this.toolbar ]
  2346.         });
  2347.         bandcast.views.FriendSearch.superclass.initComponent.call(this);
  2348.     }
  2349. });
  2350.  
  2351. Ext.reg("bandcast.views.FriendSearch", bandcast.views.FriendSearch);
  2352.  
  2353. bandcast.views.VenueList = Ext.extend(Ext.Panel, {
  2354.     id: "venuelist",
  2355.     layout: "card",
  2356.     historyUrl: "venue/list",
  2357.     initComponent: function() {
  2358.         this.wrapper = new Ext.Panel({
  2359.             layout: "fit",
  2360.             items: this.buildList(),
  2361.             dockedItems: [ {
  2362.                 xtype: "toolbar",
  2363.                 title: "the venues"
  2364.             } ]
  2365.         });
  2366.         Ext.apply(this, {
  2367.             items: [ this.wrapper ]
  2368.         });
  2369.         bandcast.views.VenueList.superclass.initComponent.call(this);
  2370.     },
  2371.     buildList: function() {
  2372.         this.list = new Ext.List({
  2373.             store: bandcast.stores.Venue,
  2374.             loadingText: "Loading",
  2375.             itemTpl: new Ext.XTemplate('<tpl for=".">', '<div class="primary">{name}</div>', "</tpl>"),
  2376.             listeners: {
  2377.                 itemtap: {
  2378.                     fn: function(a, b, f, d) {
  2379.                         var c = a.getSelectionModel();
  2380.                         c.select(b);
  2381.                         (new Ext.util.DelayedTask(function() {
  2382.                             a.getSelectionModel().deselectAll();
  2383.                         }, this)).delay(400);
  2384.                         this.showVenue(a.getSelectedRecords()[0].data.urlkey);
  2385.                     },
  2386.                     scope: this
  2387.                 },
  2388.                 afterrender: {
  2389.                     fn: function(a) {
  2390.                         if (!this.list.store.getCount()) {
  2391.                             a.setLoading(true);
  2392.                             a.store.load();
  2393.                         }
  2394.                     },
  2395.                     scope: this
  2396.                 }
  2397.             }
  2398.         });
  2399.         return this.list;
  2400.     },
  2401.     showVenue: function(a) {
  2402.         Ext.dispatch({
  2403.             controller: "venue",
  2404.             action: "detail",
  2405.             historyUrl: "venue/-/" + a,
  2406.             prevCard: this.wrapper,
  2407.             prevUrl: this.historyUrl,
  2408.             venue: a,
  2409.             parent: this
  2410.         });
  2411.     }
  2412. });
  2413.  
  2414. Ext.reg("bandcast.views.VenueList", bandcast.views.VenueList);
  2415.  
  2416. bandcast.views.VenueCheckin = Ext.extend(Ext.Sheet, {
  2417.     id: "venuecheckin",
  2418.     hideOnMaskTap: true,
  2419.     checked: null,
  2420.     scroll: "vertical",
  2421.     stretchX: true,
  2422.     stretchY: true,
  2423.     initComponent: function() {
  2424.         Ext.apply(this, {
  2425.             items: {
  2426.                 xtype: "fieldset",
  2427.                 cls: "radio-checkin",
  2428.                 defaults: {
  2429.                     xtype: "radiofield",
  2430.                     labelWidth: "100%",
  2431.                     listeners: {
  2432.                         render: function(a) {
  2433.                             if (a.labelEl) {
  2434.                                 a.labelEl.on("click", function() {
  2435.                                     a.setChecked(true);
  2436.                                 }, a);
  2437.                             }
  2438.                         },
  2439.                         check: {
  2440.                             fn: function(a) {
  2441.                                 this.checked = a;
  2442.                             },
  2443.                             scope: this
  2444.                         }
  2445.                     }
  2446.                 },
  2447.                 items: this.getVenues()
  2448.             },
  2449.             dockedItems: {
  2450.                 xtype: "button",
  2451.                 text: "Check in",
  2452.                 ui: "action",
  2453.                 dock: "bottom",
  2454.                 scope: this,
  2455.                 handler: function(a, b) {
  2456.                     Ext.dispatch({
  2457.                         controller: "venue",
  2458.                         action: "checkinAction",
  2459.                         id: this.checked.value,
  2460.                         name: this.checked.label
  2461.                     });
  2462.                     a.up().destroy();
  2463.                     return false;
  2464.                 }
  2465.             },
  2466.             listeners: {
  2467.                 hide: function(a) {
  2468.                     if (typeof this.callback == "function") {
  2469.                         a.destroy();
  2470.                         this.callback();
  2471.                     }
  2472.                 }
  2473.             }
  2474.         });
  2475.         bandcast.views.VenueCheckin.superclass.initComponent.apply(this, arguments);
  2476.     },
  2477.     getVenues: function() {
  2478.         var a = Ext.getStore("venue"), b = [];
  2479.         if (a) {
  2480.             a.sort("name", "ASC");
  2481.             a.each(function(c) {
  2482.                 b.push({
  2483.                     name: "venue",
  2484.                     label: c.get("name"),
  2485.                     value: c.get("id")
  2486.                 });
  2487.             });
  2488.         }
  2489.         return b;
  2490.     },
  2491.     alignTo: function(a, c, b) {
  2492.         b -= 10;
  2493.         bandcast.views.VenueCheckin.superclass.alignTo.apply(this, [ a, c, b ]);
  2494.     }
  2495. });
  2496.  
  2497. Ext.reg("bandcast.views.VenueCheckin", bandcast.views.VenueCheckin);
  2498.  
  2499. bandcast.views.VenueDetail = Ext.extend(Ext.Panel, {
  2500.     id: "venuedetail",
  2501.     layout: "card",
  2502.     initComponent: function() {
  2503.         var a = Ext.getCmp(this.id);
  2504.         if (a) {
  2505.             if (a.prevCard) {
  2506.                 a.ownerCt.setActiveItem(a.prevCard);
  2507.             }
  2508.             a.destroy();
  2509.         }
  2510.         this.toolbar = new Ext.Toolbar({
  2511.             items: !this.prevCard ? [] : [ {
  2512.                 ui: "back",
  2513.                 text: "Back",
  2514.                 scope: this,
  2515.                 handler: function() {
  2516.                     Ext.History.add(this.prevUrl);
  2517.                     this.ownerCt.setActiveItem(this.prevCard, {
  2518.                         type: "slide",
  2519.                         reverse: true,
  2520.                         scope: this,
  2521.                         after: function() {
  2522.                             this.destroy();
  2523.                         }
  2524.                     });
  2525.                 }
  2526.             } ]
  2527.         });
  2528.         if (this.venue) {
  2529.             this.toolbar.setTitle(this.venue.get("name").toLowerCase());
  2530.         }
  2531.         this.wrapper = new Ext.Panel({
  2532.             layout: "fit",
  2533.             items: this.buildList(),
  2534.             dockedItems: this.toolbar
  2535.         });
  2536.         Ext.apply(this, {
  2537.             items: [ this.wrapper ]
  2538.         });
  2539.         bandcast.views.VenueDetail.superclass.initComponent.call(this);
  2540.     },
  2541.     buildList: function() {
  2542.         this.list = new Ext.List({
  2543.             store: bandcast.stores.Event,
  2544.             grouped: true,
  2545.             indexBar: Ext.is.Phone,
  2546.             loadingText: "Loading",
  2547.             itemTpl: new Ext.XTemplate('<tpl for=".">', '<div class="primary">{name}</div>', '<div class="secondary">{started:this.date} to {ended:this.date}</div>', "</tpl>", {
  2548.                 date: function(a) {
  2549.                     var b = bandcast.timezoned(a);
  2550.                     return b.format(bandcast.config.event.date.format.timeshort);
  2551.                 },
  2552.                 compiled: true
  2553.             }),
  2554.             listeners: {
  2555.                 afterrender: {
  2556.                     fn: function(a) {
  2557.                         if (!this.list.store.getCount()) {
  2558.                             a.setLoading(true);
  2559.                             a.store.load({
  2560.                                 scope: this,
  2561.                                 callback: function(c, b, d) {
  2562.                                     this.filterStore(a.store);
  2563.                                 }
  2564.                             });
  2565.                         } else {
  2566.                             this.filterStore(a.store);
  2567.                         }
  2568.                     },
  2569.                     scope: this
  2570.                 }
  2571.             }
  2572.         });
  2573.         return this.list;
  2574.     },
  2575.     filterStore: function(a) {
  2576.         a.clearFilter();
  2577.         a.filter("venue", this.venue.get("name"));
  2578.         a.sortTime();
  2579.     }
  2580. });
  2581.  
  2582. Ext.reg("bandcast.views.VenueDetail", bandcast.views.VenueDetail);
  2583.  
  2584. bandcast.views.ScheduleList = Ext.extend(Ext.Panel, {
  2585.     id: "schedulelist",
  2586.     layout: "card",
  2587.     historyUrl: "schedule/list",
  2588.     initComponent: function() {
  2589.         this.wrapper = new Ext.Panel({
  2590.             layout: "fit",
  2591.             items: this.buildList(),
  2592.             dockedItems: [ {
  2593.                 xtype: "toolbar",
  2594.                 title: "schedule"
  2595.             } ]
  2596.         });
  2597.         Ext.apply(this, {
  2598.             items: [ this.wrapper ]
  2599.         });
  2600.         bandcast.views.ScheduleList.superclass.initComponent.call(this);
  2601.     },
  2602.     buildList: function() {
  2603.         this.list = new Ext.List({
  2604.             store: bandcast.stores.Schedule,
  2605.             loadingText: "Loading",
  2606.             grouped: true,
  2607.             plugins: [ {
  2608.                 ptype: "pullrefresh",
  2609.                 pullRefreshText: "Pull down to refresh",
  2610.                 releaseRefreshText: "Release to refresh",
  2611.                 loadingText: "Loading..."
  2612.             } ],
  2613.             itemTpl: new Ext.XTemplate('<tpl for=".">', '<div class="primary{users:this.mine}">', "{name}<br />", '<span class="tertiary">{users:this.users}</span>', "</div>", "</tpl>", {
  2614.                 users: function(d) {
  2615.                     if (d) {
  2616.                         var b, e = [];
  2617.                         for (var c = 0, a = d.length; c < a; c++) {
  2618.                             if (b = bandcast.stores.Friend.getById(d[c].id)) {
  2619.                                 e.push(b.get("displayname") + (d[c].attending != 2 ? " (Maybe)" : ""));
  2620.                             } else {
  2621.                                 if (d[c].id == Ext.data.auth.get("user").id) {
  2622.                                     e.push("Me" + (d[c].attending != 2 ? " (Maybe)" : ""));
  2623.                                 }
  2624.                             }
  2625.                         }
  2626.                         return e.join(", ");
  2627.                     }
  2628.                 },
  2629.                 mine: function(c) {
  2630.                     if (c) {
  2631.                         for (var b = 0, a = c.length; b < a; b++) {
  2632.                             if (c[b].id == Ext.data.auth.get("user").id) {
  2633.                                 return " self";
  2634.                             }
  2635.                         }
  2636.                     }
  2637.                 }
  2638.             }),
  2639.             listeners: {
  2640.                 afterrender: {
  2641.                     fn: function(a) {
  2642.                         a.setLoading(true);
  2643.                         if (!bandcast.stores.Friend.getCount()) {
  2644.                             bandcast.stores.Friend.load({
  2645.                                 scope: this,
  2646.                                 callback: function(c, b, d) {
  2647.                                     if (d) {
  2648.                                         a.store.load();
  2649.                                     }
  2650.                                 }
  2651.                             });
  2652.                         } else {
  2653.                             a.store.load();
  2654.                         }
  2655.                     },
  2656.                     scope: this
  2657.                 }
  2658.             }
  2659.         });
  2660.         return this.list;
  2661.     }
  2662. });
  2663.  
  2664. Ext.reg("bandcast.views.ScheduleList", bandcast.views.ScheduleList);
  2665.  
  2666. bandcast.views.MoreIndex = Ext.extend(Ext.Panel, {
  2667.     id: "moreindex",
  2668.     layout: "card",
  2669.     initComponent: function() {
  2670.         this.list = new Ext.Panel({
  2671.             scroll: "vertical",
  2672.             items: [ new Ext.Panel({
  2673.                 items: {
  2674.                     styleHtmlContent: true,
  2675.                     tpl: new Ext.Template([ '<div class="section centered">', '<div><img src="https://chart.googleapis.com/chart?chs={width}x{height}&cht=qr&chl={url}&choe=UTF-8&chld=L|3" id="qrcode" width="{width}" height="{height}" alt="{username}" /></div>', '<div class="blurb">', "Have your friends scan this using a barcode scanner (such as RedLaser or NeoReader) and you'll be able to see each other's checkins.", '<div class="tip">', "<strong>Tip</strong> Save this to your photo album for quick access.", "</div>", "</div>", "</div>" ]),
  2676.                     data: {
  2677.                         width: 200,
  2678.                         height: 200,
  2679.                         url: encodeURIComponent(bandcast.config.defaults.urls.mobile + "/#qr/friend/" + Ext.data.auth.get("user").username + "/" + Ext.data.auth.get("user").qrcode),
  2680.                         username: Ext.data.auth.get("user").username
  2681.                     }
  2682.                 },
  2683.                 dockedItems: {
  2684.                     xtype: "toolbar",
  2685.                     title: "connect with friends instantly",
  2686.                     ui: "light",
  2687.                     cls: "small_title"
  2688.                 }
  2689.             }), new Ext.Panel({
  2690.                 items: {
  2691.                     styleHtmlContent: true,
  2692.                     tpl: new Ext.Template([ '<div class="section centered">', '<div class="blurb">', "If you're having trouble checking in because the network is overwhelmed you can check in via phone. Just call {phone} and follow the instructions.", "</div>", "</div>" ]),
  2693.                     data: {
  2694.                         phone: '<a href="tel:' + bandcast.config.event.twilio.phone.replace(/[^0-9]/g, "") + '">' + bandcast.config.event.twilio.phone + "</a>"
  2695.                     }
  2696.                 },
  2697.                 dockedItems: {
  2698.                     xtype: "toolbar",
  2699.                     title: "having trouble checking in",
  2700.                     ui: "light",
  2701.                     cls: "small_title"
  2702.                 }
  2703.             }), new Ext.Panel({
  2704.                 items: {
  2705.                     styleHtmlContent: true,
  2706.                     html: [ '<div class="section centered">', '<div class="blurb">', 'Bandcast was developed by <a href="http://phorklabs.com" rel="external">Phork Labs</a>.', "</div>", "</div>" ].join("")
  2707.                 },
  2708.                 dockedItems: {
  2709.                     xtype: "toolbar",
  2710.                     title: "about bandcast",
  2711.                     ui: "light",
  2712.                     cls: "small_title"
  2713.                 }
  2714.             }) ],
  2715.             dockedItems: [ {
  2716.                 xtype: "toolbar",
  2717.                 title: "bandcast",
  2718.                 items: [ {
  2719.                     ui: "button",
  2720.                     iconCls: "settings",
  2721.                     iconMask: true,
  2722.                     scope: this,
  2723.                     handler: function(a, b) {
  2724.                         Ext.dispatch({
  2725.                             controller: "more",
  2726.                             action: "settings",
  2727.                             historyUrl: "more/settings",
  2728.                             prevCard: this.list,
  2729.                             parent: this
  2730.                         });
  2731.                     }
  2732.                 }, {
  2733.                     xtype: "spacer",
  2734.                     flex: 1
  2735.                 }, {
  2736.                     ui: "button",
  2737.                     text: "Logout",
  2738.                     scope: this,
  2739.                     handler: function(a, b) {
  2740.                         this.destroy();
  2741.                         Ext.dispatch({
  2742.                             controller: "auth",
  2743.                             action: "logout"
  2744.                         });
  2745.                     }
  2746.                 } ]
  2747.             } ]
  2748.         });
  2749.         Ext.apply(this, {
  2750.             items: [ this.list ]
  2751.         });
  2752.         bandcast.views.MoreIndex.superclass.initComponent.call(this);
  2753.     }
  2754. });
  2755.  
  2756. Ext.reg("bandcast.views.MoreIndex", bandcast.views.MoreIndex);
  2757.  
  2758. bandcast.views.MoreSettings = Ext.extend(Ext.form.FormPanel, {
  2759.     id: "moresettings",
  2760.     initComponent: function() {
  2761.         this.toolbar = new Ext.Toolbar({
  2762.             title: "settings",
  2763.             items: [ {
  2764.                 ui: "back",
  2765.                 text: "Back",
  2766.                 scope: this,
  2767.                 handler: function() {
  2768.                     this.ownerCt.setActiveItem(this.prevCard, {
  2769.                         type: "slide",
  2770.                         reverse: true,
  2771.                         scope: this,
  2772.                         after: function() {
  2773.                             this.destroy();
  2774.                         }
  2775.                     });
  2776.                 }
  2777.             } ]
  2778.         });
  2779.         Ext.apply(this, {
  2780.             scroll: "vertical",
  2781.             defaults: {
  2782.                 xtype: "fieldset",
  2783.                 defaults: {
  2784.                     labelWidth: "35%"
  2785.                 }
  2786.             },
  2787.             listeners: {
  2788.                 beforesubmit: function(b, a) {
  2789.                     Ext.dispatch({
  2790.                         controller: "more",
  2791.                         action: "settingsAction",
  2792.                         form: b,
  2793.                         values: a
  2794.                     });
  2795.                     return false;
  2796.                 }
  2797.             },
  2798.             items: [ {
  2799.                 instructions: "Optional account settings. Leave the password field blank to keep your existing password.",
  2800.                 items: [ {
  2801.                     xtype: "textfield",
  2802.                     name: "displayname",
  2803.                     label: "Name",
  2804.                     value: Ext.data.auth.get("user").displayname,
  2805.                     placeHolder: Ext.data.auth.get("user").username,
  2806.                     autoCapitalize: false,
  2807.                     useClearIcon: true
  2808.                 }, {
  2809.                     xtype: "textfield",
  2810.                     name: "email",
  2811.                     label: "Email",
  2812.                     value: Ext.data.auth.get("user").email,
  2813.                     autoCapitalize: false,
  2814.                     useClearIcon: true
  2815.                 }, {
  2816.                     xtype: "passwordfield",
  2817.                     name: "password",
  2818.                     label: "Password",
  2819.                     useClearIcon: true
  2820.                 } ]
  2821.             }, {
  2822.                 instructions: "Enter your US phone number and choose a pin number to check in by telephone.",
  2823.                 items: [ {
  2824.                     xtype: "textfield",
  2825.                     name: "phone",
  2826.                     label: "Phone",
  2827.                     value: Ext.data.auth.get("user").phone,
  2828.                     placeHolder: bandcast.config.event.twilio.phone,
  2829.                     autoCapitalize: false,
  2830.                     useClearIcon: true
  2831.                 }, {
  2832.                     xtype: "textfield",
  2833.                     name: "pin",
  2834.                     label: "Pin #",
  2835.                     value: Ext.data.auth.get("user").pin,
  2836.                     placeHolder: Ext.data.auth.get("user").pin || "1234",
  2837.                     autoCapitalize: false,
  2838.                     useClearIcon: true
  2839.                 } ]
  2840.             }, {
  2841.                 instructions: "Please enter your current password to make changes.",
  2842.                 items: [ {
  2843.                     xtype: "passwordfield",
  2844.                     name: "verify",
  2845.                     label: "Password",
  2846.                     useClearIcon: true
  2847.                 } ]
  2848.             }, {
  2849.                 xtype: "button",
  2850.                 text: "Save settings",
  2851.                 scope: this,
  2852.                 formBind: true,
  2853.                 handler: function(a) {
  2854.                     this.submit();
  2855.                 }
  2856.             } ],
  2857.             dockedItems: [ this.toolbar ]
  2858.         });
  2859.         bandcast.views.MoreSettings.superclass.initComponent.call(this);
  2860.     }
  2861. });
  2862.  
  2863. Ext.reg("bandcast.views.MoreSettings", bandcast.views.MoreSettings);
  2864.  
  2865. bandcast.views.MusicFest = Ext.extend(Ext.Panel, {
  2866.     initComponent: function() {
  2867.         if (typeof this.active == "string") {
  2868.             var b = this.active.split("/")[0], c = {
  2869.                 activity: 0,
  2870.                 user: 1,
  2871.                 friend: 1,
  2872.                 event: 2,
  2873.                 schedule: 3,
  2874.                 more: 4
  2875.             }, d = 0;
  2876.             if (typeof c[b] == "number") {
  2877.                 d = c[b];
  2878.             }
  2879.         }
  2880.         var a = new Ext.TabPanel({
  2881.             id: "viewport",
  2882.             cardSwitchAnimation: "fade",
  2883.             fullscreen: true,
  2884.             layout: "hbox",
  2885.             activeItem: d,
  2886.             listeners: {
  2887.                 cardswitch: function(g, h, f, e) {
  2888.                     Ext.History.add(h.historyUrl);
  2889.                 }
  2890.             },
  2891.             tabBar: {
  2892.                 ui: "gray",
  2893.                 dock: "bottom",
  2894.                 layout: {
  2895.                     pack: "center"
  2896.                 }
  2897.             },
  2898.             items: [ {
  2899.                 xtype: "bandcast.views.ActivityList",
  2900.                 title: "Activity",
  2901.                 iconCls: "chat3",
  2902.                 historyUrl: "activity/list"
  2903.             }, {
  2904.                 xtype: "bandcast.views.FriendList",
  2905.                 title: "Friends",
  2906.                 iconCls: "team1",
  2907.                 historyUrl: "friend/list"
  2908.             }, {
  2909.                 xtype: "bandcast.views.EventList",
  2910.                 title: "Bands",
  2911.                 iconCls: "music1",
  2912.                 historyUrl: "event/list"
  2913.             }, {
  2914.                 xtype: "bandcast.views.ScheduleList",
  2915.                 title: "Schedule",
  2916.                 iconCls: "calendar2",
  2917.                 historyUrl: "schedule/list"
  2918.             }, {
  2919.                 xtype: "bandcast.views.MoreIndex",
  2920.                 title: "More",
  2921.                 iconCls: "more",
  2922.                 historyUrl: "more/index"
  2923.             } ]
  2924.         });
  2925.         Ext.apply(this, {
  2926.             items: a
  2927.         });
  2928.         bandcast.views.MusicFest.superclass.initComponent.call(this);
  2929.     }
  2930. });
  2931.  
  2932. Ext.reg("bandcast.views.MusicFest", bandcast.views.MusicFest);
  2933.  
  2934. Ext.regController("auth", {
  2935.     index: function(a) {
  2936.         this.callback = a.callback;
  2937.         this.login(a);
  2938.     },
  2939.     login: function(a) {
  2940.         this.render({
  2941.             xtype: "bandcast.views.Login"
  2942.         });
  2943.     },
  2944.     loginAction: function(a) {
  2945.         var b = new Ext.LoadMask("loginform", {
  2946.             msg: "Logging in"
  2947.         });
  2948.         b.show();
  2949.         Ext.data.auth.login(a.values.username, a.values.password, Ext.createDelegate(function(c, d) {
  2950.             b.hide();
  2951.             delete b;
  2952.             if (c) {
  2953.                 a.form.destroy();
  2954.                 this.callback();
  2955.             } else {
  2956.                 Ext.Msg.alert("Log in error", (d ? d : "Something went wrong.") + ". Please try again.", Ext.emptyFn);
  2957.             }
  2958.         }, this));
  2959.     },
  2960.     register: function(a) {
  2961.         this.render({
  2962.             xtype: "bandcast.views.Register"
  2963.         });
  2964.     },
  2965.     registerAction: function(a) {
  2966.         var b = new Ext.LoadMask("registerform", {
  2967.             msg: "Registering"
  2968.         });
  2969.         b.show();
  2970.         Ext.data.auth.register(a.values.username, a.values.password, a.values.email, Ext.createDelegate(function(c, d) {
  2971.             b.hide();
  2972.             delete b;
  2973.             if (c) {
  2974.                 a.form.destroy();
  2975.                 this.callback();
  2976.             } else {
  2977.                 Ext.Msg.alert("Register error", (d ? d : "There was an error creating your account") + ". Please try again.", Ext.emptyFn);
  2978.             }
  2979.         }, this));
  2980.     },
  2981.     password: function(a) {
  2982.         this.render({
  2983.             xtype: "bandcast.views.Password"
  2984.         });
  2985.     },
  2986.     passwordAction: function(a) {
  2987.         var b = new Ext.LoadMask("passwordform", {
  2988.             msg: "Loading"
  2989.         });
  2990.         b.show();
  2991.         Ext.data.auth.password(a.values.email, Ext.createDelegate(function(c, d) {
  2992.             b.hide();
  2993.             delete b;
  2994.             if (c) {
  2995.                 a.form.destroy();
  2996.                 this.login(a);
  2997.                 Ext.Msg.alert("Check your email", "An email has been sent with instructions to reset your password.");
  2998.             } else {
  2999.                 Ext.Msg.alert("Password error", (d ? d : "There was an error resetting your password") + ". Please try again.", Ext.emptyFn);
  3000.             }
  3001.         }, this));
  3002.     },
  3003.     logout: function(a) {
  3004.         Ext.data.auth.destroy();
  3005.         Ext.redirect(bandcast.defaultUrl);
  3006.     }
  3007. });
  3008.  
  3009. Ext.regController("activity", {
  3010.     list: function(a) {
  3011.         this.activityList = this.render({
  3012.             xtype: "bandcast.views.ActivityList"
  3013.         });
  3014.     },
  3015.     add: function(a) {
  3016.         this.activityAdd = this.render({
  3017.             xtype: "bandcast.views.ActivityAdd",
  3018.             prevCard: a.prevCard,
  3019.             recipient: a.recipient
  3020.         });
  3021.         if (a.parent) {
  3022.             a.parent.setActiveItem(this.activityAdd, "slide");
  3023.         } else {
  3024.             this.activityAdd.show();
  3025.         }
  3026.     },
  3027.     addAction: function(b) {
  3028.         var c = Ext.ModelMgr.create({
  3029.             status: b.values.status,
  3030.             metadata: {
  3031.                 recipient: b.values.recipient
  3032.             },
  3033.             created: new Date
  3034.         }, "Activity");
  3035.         var a = Ext.util.BandcastFlash.add("Posting your message ...");
  3036.         c.save({
  3037.             callback: function(d, e) {
  3038.                 Ext.util.BandcastFlash.remove(a);
  3039.                 if (e.success === true) {
  3040.                     Ext.util.BandcastFlash.add("Your message was posted!", {
  3041.                         timer: 800
  3042.                     });
  3043.                     Ext.getCmp("activitylist").list.getStore().load();
  3044.                 } else {
  3045.                     Ext.util.BandcastFlash.error("Unable to save your message.");
  3046.                 }
  3047.             }
  3048.         });
  3049.     }
  3050. });
  3051.  
  3052. Ext.regController("friend", {
  3053.     list: function(a) {
  3054.         this.friendList = this.render({
  3055.             xtype: "bandcast.views.FriendList"
  3056.         });
  3057.     },
  3058.     requests: function(a) {
  3059.         this.friendRequests = this.render({
  3060.             xtype: "bandcast.views.FriendRequests",
  3061.             prevCard: a.prevCard
  3062.         });
  3063.         if (a.parent) {
  3064.             a.parent.setActiveItem(this.friendRequests, "slide");
  3065.         } else {
  3066.             this.friendRequests.show();
  3067.         }
  3068.     },
  3069.     search: function(a) {
  3070.         this.friendSearch = this.render({
  3071.             xtype: "bandcast.views.FriendSearch",
  3072.             prevCard: a.prevCard
  3073.         });
  3074.         if (a.parent) {
  3075.             a.parent.setActiveItem(this.friendSearch, "slide");
  3076.         } else {
  3077.             this.friendSearch.show();
  3078.         }
  3079.     },
  3080.     searchAction: function(a) {
  3081.         var b = a.values.username;
  3082.         Ext.dispatch({
  3083.             controller: "user",
  3084.             action: "detail",
  3085.             historyUrl: "user/-/" + b,
  3086.             username: b
  3087.         });
  3088.     },
  3089.     addAction: function(b) {
  3090.         var a = Ext.util.BandcastFlash.add("Requesting friendship ...");
  3091.         bandcast.stores.Friend.addByUsername(b.username, function(c, d) {
  3092.             Ext.util.BandcastFlash.remove(a);
  3093.             if (c) {
  3094.                 Ext.util.BandcastFlash.add("Your friendship request was sent!", {
  3095.                     timer: 800
  3096.                 });
  3097.             } else {
  3098.                 Ext.util.BandcastFlash.error("Unable to send your friendship request.");
  3099.             }
  3100.         });
  3101.     },
  3102.     approveAction: function(b) {
  3103.         var a = Ext.util.BandcastFlash.add("Approving friendship ...");
  3104.         bandcast.stores.Friend.approveByUsername(b.username, function(c, d) {
  3105.             Ext.util.BandcastFlash.remove(a);
  3106.             if (c) {
  3107.                 Ext.util.BandcastFlash.add("Friendship approved!", {
  3108.                     timer: 800
  3109.                 });
  3110.             } else {
  3111.                 Ext.util.BandcastFlash.error("Unable to approve friendship.");
  3112.             }
  3113.         });
  3114.     },
  3115.     denyAction: function(b) {
  3116.         var a = Ext.util.BandcastFlash.add("Denying friendship ...");
  3117.         bandcast.stores.Friend.denyByUsername(b.username, function(c, d) {
  3118.             Ext.util.BandcastFlash.remove(a);
  3119.             if (c) {
  3120.                 Ext.util.BandcastFlash.add("Friendship denied!", {
  3121.                     timer: 800
  3122.                 });
  3123.             } else {
  3124.                 Ext.util.BandcastFlash.error("Unable to deny friendship.");
  3125.             }
  3126.         });
  3127.     }
  3128. });
  3129.  
  3130. Ext.regController("user", {
  3131.     detail: function(d) {
  3132.         var b = bandcast.stores.Friend.findRecord("username", d.username), a = d.username == Ext.data.auth.get("user").username, e = b ? true : null, c = !!b, f = "slide";
  3133.         if (!b) {
  3134.             if (bandcast.stores.Friend.loaded) {
  3135.                 e = false;
  3136.             }
  3137.             if (b = bandcast.stores.User.findRecord("username", d.username)) {
  3138.                 c = true;
  3139.                 e = b.get("relationship").friend == "approved";
  3140.             } else {
  3141.                 b = Ext.ModelMgr.create({
  3142.                     username: d.username,
  3143.                     displayname: d.username
  3144.                 }, "User");
  3145.             }
  3146.         }
  3147.         if (!d.parent) {
  3148.             if (d.parent = Ext.getCmp("friendlist")) {
  3149.                 d.prevCard = d.parent.wrapper;
  3150.                 d.prevUrl = d.parent.historyUrl;
  3151.             }
  3152.             f = null;
  3153.         }
  3154.         this.userDetail = this.render({
  3155.             xtype: "bandcast.views.UserDetail",
  3156.             prevCard: d.prevCard,
  3157.             prevUrl: d.prevUrl,
  3158.             user: b,
  3159.             loaded: c,
  3160.             friend: e
  3161.         });
  3162.         if (d.parent) {
  3163.             d.parent.setActiveItem(this.userDetail, f);
  3164.         } else {
  3165.             this.userDetail.show();
  3166.         }
  3167.         this.detailLoad(b, e || a, c);
  3168.     },
  3169.     detailLoad: function(a, c, b) {
  3170.         if (!b) {
  3171.             bandcast.stores.User.loadByUsername(a.get("username"), Ext.createDelegate(function(d) {
  3172.                 if (typeof d[0] == "object") {
  3173.                     a = d[0];
  3174.                     c = c || a.get("relationship").friend == "approved";
  3175.                     Ext.getCmp("userinfo").update(Ext.apply(a.data, {
  3176.                         friend: c,
  3177.                         loaded: true,
  3178.                         self: a.get("username") == Ext.data.auth.get("user").username
  3179.                     }));
  3180.                     this.userDetail.user = a;
  3181.                     this.detailLoad(a, c, true);
  3182.                 } else {
  3183.                     this.userDetail.invalidUser();
  3184.                 }
  3185.             }, this));
  3186.         }
  3187.         if (a.get("id") && c !== false) {
  3188.             this.userDetail.allowMessage();
  3189.             this.userDetail.buildList();
  3190.         }
  3191.         if (a.get("id") && c === false) {
  3192.             this.userDetail.allowFriend();
  3193.         }
  3194.     }
  3195. });
  3196.  
  3197. Ext.regController("event", {
  3198.     list: function(a) {
  3199.         this.eventList = this.render({
  3200.             xtype: "bandcast.views.EventList"
  3201.         });
  3202.     },
  3203.     detail: function(a) {
  3204.         var b = bandcast.stores.Event.findRecord("urlkey", a.event), c = "slide";
  3205.         if (!a.parent) {
  3206.             if (a.parent = Ext.getCmp("eventlist")) {
  3207.                 a.prevCard = a.parent.wrapper;
  3208.                 a.prevUrl = a.parent.historyUrl;
  3209.                 c = null;
  3210.             }
  3211.         }
  3212.         this.eventDetail = this.render({
  3213.             xtype: "bandcast.views.EventDetail",
  3214.             prevCard: a.prevCard,
  3215.             prevUrl: a.prevUrl,
  3216.             event: b
  3217.         });
  3218.         this.detailLoad(b);
  3219.         if (a.parent) {
  3220.             a.parent.setActiveItem(this.eventDetail, c);
  3221.         } else {
  3222.             this.eventDetail.show();
  3223.         }
  3224.     },
  3225.     detailLoad: function(f) {
  3226.         var b = f.get("artists"), e = [];
  3227.         if (b) {
  3228.             for (var d = 0, a = b.length; d < a; d++) {
  3229.                 if (!bandcast.stores.Artist.getById(b[d].id)) {
  3230.                     e.push(b[d].id);
  3231.                 }
  3232.             }
  3233.             if (e.length) {
  3234.                 var c = new Ext.data.Operation({
  3235.                     action: "read",
  3236.                     filters: [ new Ext.util.Filter({
  3237.                         property: "id",
  3238.                         value: e
  3239.                     }) ]
  3240.                 });
  3241.                 bandcast.stores.Artist.getProxy().read(c, function(j) {
  3242.                     var h = c.getRecords();
  3243.                     bandcast.stores.Artist.loadRecords(h, true);
  3244.                     for (var k = 0, g = h.length; k < g; k++) {
  3245.                         var l = Ext.getDom("artist-" + h[k].get("id"));
  3246.                         if (l) {
  3247.                             Ext.DomHelper.overwrite(l, h[k].get("description") || "No information provided");
  3248.                         }
  3249.                     }
  3250.                     Ext.getCmp("eventdetail").doComponentLayout();
  3251.                 }, this);
  3252.             }
  3253.         }
  3254.     },
  3255.     checkin: function(a) {
  3256.         this.eventCheckin = this.render({
  3257.             xtype: "bandcast.views.EventCheckin",
  3258.             callback: a.callback
  3259.         });
  3260.         this.eventCheckin.showBy(a.btn.up(), "fade", false, false);
  3261.     },
  3262.     checkinAction: function(b) {
  3263.         var c = Ext.ModelMgr.create({
  3264.             type: "event",
  3265.             typeid: b.id,
  3266.             checkin: (new Date).format("c")
  3267.         }, "Checkin");
  3268.         var a = Ext.util.BandcastFlash.add("Checking in to " + b.name + " ...");
  3269.         c.save({
  3270.             callback: function(d, e) {
  3271.                 Ext.util.BandcastFlash.remove(a);
  3272.                 if (e.success === true) {
  3273.                     Ext.util.BandcastFlash.add("You are checked in!", {
  3274.                         timer: 800
  3275.                     });
  3276.                     Ext.getCmp("activitylist").list.getStore().load();
  3277.                 } else {
  3278.                     Ext.util.BandcastFlash.error("Unable to save your checkin.");
  3279.                 }
  3280.             }
  3281.         });
  3282.     },
  3283.     rsvpAction: function(b) {
  3284.         var c = Ext.ModelMgr.create({
  3285.             type: "event",
  3286.             typeid: b.eventid,
  3287.             attending: b.value
  3288.         }, "Checkin");
  3289.         var a = Ext.util.BandcastFlash.add("Sending your response ...");
  3290.         c.save({
  3291.             callback: function(d, e) {
  3292.                 Ext.util.BandcastFlash.remove(a);
  3293.                 if (e.success === true) {
  3294.                     Ext.util.BandcastFlash.add("Your response was sent!", {
  3295.                         timer: 800
  3296.                     });
  3297.                     Ext.getCmp("activitylist").list.getStore().load();
  3298.                 } else {
  3299.                     Ext.util.BandcastFlash.error("Unable to save your activity.");
  3300.                 }
  3301.             }
  3302.         });
  3303.     }
  3304. });
  3305.  
  3306. Ext.regController("venue", {
  3307.     list: function(a) {
  3308.         this.venueList = this.render({
  3309.             xtype: "bandcast.views.VenueList"
  3310.         });
  3311.     },
  3312.     detail: function(a) {
  3313.         var c = bandcast.stores.Venue.findRecord("urlkey", a.venue), b = "slide";
  3314.         if (!a.parent) {
  3315.             if (a.parent = Ext.getCmp("activitylist")) {
  3316.                 a.prevCard = a.parent.wrapper;
  3317.                 a.prevUrl = a.parent.historyUrl;
  3318.                 b = null;
  3319.             }
  3320.         }
  3321.         this.venueDetail = this.render({
  3322.             xtype: "bandcast.views.VenueDetail",
  3323.             prevCard: a.prevCard,
  3324.             prevUrl: a.prevUrl,
  3325.             venue: c
  3326.         });
  3327.         if (a.parent) {
  3328.             a.parent.setActiveItem(this.venueDetail, b);
  3329.         } else {
  3330.             this.venueDetail.show();
  3331.         }
  3332.     },
  3333.     checkin: function(a) {
  3334.         this.venueCheckin = this.render({
  3335.             xtype: "bandcast.views.VenueCheckin",
  3336.             callback: a.callback
  3337.         });
  3338.         this.venueCheckin.showBy(a.btn.up(), "fade", false, false);
  3339.     },
  3340.     checkinAction: function(b) {
  3341.         var c = Ext.ModelMgr.create({
  3342.             type: "venue",
  3343.             typeid: b.id,
  3344.             checkin: (new Date).format("c")
  3345.         }, "Checkin");
  3346.         var a = Ext.util.BandcastFlash.add("Checking in to " + b.name + " ...");
  3347.         c.save({
  3348.             callback: function(d, e) {
  3349.                 Ext.util.BandcastFlash.remove(a);
  3350.                 if (e.success === true) {
  3351.                     Ext.util.BandcastFlash.add("You have been checked in!", {
  3352.                         timer: 800
  3353.                     });
  3354.                     Ext.getCmp("activitylist").list.getStore().load();
  3355.                 } else {
  3356.                     Ext.util.BandcastFlash.error("Unable to save your checkin.");
  3357.                 }
  3358.             }
  3359.         });
  3360.     }
  3361. });
  3362.  
  3363. Ext.regController("schedule", {
  3364.     list: function(a) {
  3365.         this.scheduleList = this.render({
  3366.             xtype: "bandcast.views.ScheduleList"
  3367.         });
  3368.     }
  3369. });
  3370.  
  3371. Ext.regController("more", {
  3372.     index: function(a) {
  3373.         this.moreIndex = this.render({
  3374.             xtype: "bandcast.views.MoreIndex"
  3375.         });
  3376.     },
  3377.     settings: function(a) {
  3378.         this.moreSettings = this.render({
  3379.             xtype: "bandcast.views.MoreSettings",
  3380.             prevCard: a.prevCard
  3381.         });
  3382.         if (a.parent) {
  3383.             a.parent.setActiveItem(this.moreSettings, "slide");
  3384.         } else {
  3385.             this.moreSettings.show();
  3386.         }
  3387.     },
  3388.     settingsAction: function(b) {
  3389.         var a = Ext.util.BandcastFlash.add("Saving settings ...");
  3390.         Ext.data.auth.settings(b.values, Ext.createDelegate(function(c, d) {
  3391.             Ext.util.BandcastFlash.remove(a);
  3392.             if (c) {
  3393.                 Ext.util.BandcastFlash.add("Your settings were saved!", {
  3394.                     timer: 800
  3395.                 });
  3396.             } else {
  3397.                 Ext.util.BandcastFlash.error("Unable to save your settings.", d);
  3398.             }
  3399.         }, this));
  3400.     }
  3401. });
  3402.  
  3403. Ext.regController("qrcode", {
  3404.     friend: function(b) {
  3405.         if (b.username && b.qrcode) {
  3406.             var a = Ext.util.BandcastFlash.add("Adding connection ...");
  3407.             bandcast.stores.Friend.addByQr(b.username, b.qrcode, function(c, d) {
  3408.                 Ext.util.BandcastFlash.remove(a);
  3409.                 if (c) {
  3410.                     Ext.util.BandcastFlash.add("You are now connected!", {
  3411.                         timer: 800
  3412.                     });
  3413.                 } else {
  3414.                     Ext.util.BandcastFlash.error("Connection error.");
  3415.                 }
  3416.             });
  3417.         } else {
  3418.             Ext.util.BandcastFlash.error("Incomplete friend data.");
  3419.         }
  3420.     }
  3421. });
  3422.  
  3423. Ext.regController("musicfest", {
  3424.     run: function(a) {
  3425.         Ext.applyIf(bandcast.config, {
  3426.             aliases: {
  3427.                 event: {
  3428.                     single: "band",
  3429.                     plural: "bands"
  3430.                 },
  3431.                 venue: {
  3432.                     single: "stage",
  3433.                     plural: "stages"
  3434.                 },
  3435.                 meetup: {
  3436.                     single: "meetup",
  3437.                     plural: "meetups"
  3438.                 }
  3439.             }
  3440.         });
  3441.         this.render({
  3442.             xtype: "bandcast.views.MusicFest",
  3443.             active: a.url
  3444.         });
  3445.         if (a.url) {
  3446.             Ext.redirect(a.url);
  3447.         } else {
  3448.             this.index();
  3449.         }
  3450.     },
  3451.     index: function(a) {
  3452.         Ext.dispatch({
  3453.             controller: "activity",
  3454.             action: "list",
  3455.             historyUrl: "activity/list",
  3456.             options: a
  3457.         });
  3458.     }
  3459. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement