├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── api.json
├── apiapp.json
├── handlers
├── foodtrucks.js
├── foodtrucks
│ └── {id}.js
└── lib
│ ├── restaurants.json
│ └── store.js
├── html
├── index.html
├── scripts
│ ├── angular.min.js
│ ├── angular.min.js.map
│ ├── jquery-1.10.2.min.js
│ └── jquery-1.10.2.min.map
├── styles
│ └── bootstrap.min.css
└── swagger-ui
│ ├── css
│ ├── print.css
│ ├── reset.css
│ ├── screen.css
│ └── typography.css
│ ├── fonts
│ ├── droid-sans-v6-latin-700.eot
│ ├── droid-sans-v6-latin-700.svg
│ ├── droid-sans-v6-latin-700.ttf
│ ├── droid-sans-v6-latin-700.woff
│ ├── droid-sans-v6-latin-700.woff2
│ ├── droid-sans-v6-latin-regular.eot
│ ├── droid-sans-v6-latin-regular.svg
│ ├── droid-sans-v6-latin-regular.ttf
│ ├── droid-sans-v6-latin-regular.woff
│ └── droid-sans-v6-latin-regular.woff2
│ ├── images
│ ├── explorer_icons.png
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── favicon.ico
│ ├── logo_small.png
│ ├── pet_store_api.png
│ ├── throbber.gif
│ └── wordnik_api.png
│ ├── index.html
│ ├── lib
│ ├── backbone-min.js
│ ├── handlebars-2.0.0.js
│ ├── highlight.7.3.pack.js
│ ├── jquery-1.8.0.min.js
│ ├── jquery.ba-bbq.min.js
│ ├── jquery.slideto.min.js
│ ├── jquery.wiggle.min.js
│ ├── marked.js
│ ├── swagger-oauth.js
│ ├── underscore-min.js
│ └── underscore-min.map
│ ├── o2c.html
│ ├── swagger-ui.js
│ └── swagger-ui.min.js
├── package.json
└── server.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/*
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Azure samples
2 |
3 | Thank you for your interest in contributing to Azure samples!
4 |
5 | ## Ways to contribute
6 |
7 | You can contribute to [Azure samples](https://azure.microsoft.com/documentation/samples/) in a few different ways:
8 |
9 | - Submit feedback on [this sample page](https://azure.microsoft.com/documentation/samples/app-service-api-node-food-trucks/) whether it was helpful or not.
10 | - Submit issues through [issue tracker](https://github.com/Azure-Samples/app-service-api-node-food-trucks/issues) on GitHub. We are actively monitoring the issues and improving our samples.
11 | - If you wish to make code changes to samples, or contribute something new, please follow the [GitHub Forks / Pull requests model](https://help.github.com/articles/fork-a-repo/): Fork the sample repo, make the change and propose it back by submitting a pull request.
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Microsoft Corporation
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | services: app-service\api
3 | platforms: nodejs
4 | author: pkefal
5 | ---
6 |
7 | # FoodTrucks - Node API App for Azure App Service
8 | This sample application contains a Node.js app using Express. You can run it locally, or [learn how to deploy it to Azure and use Swagger to define the REST API.](http://azure.microsoft.com/en-us/documentation/articles/app-service-api-nodejs-api-app/)
9 |
10 |
11 | ## Quick Start
12 |
13 | 1. Clone the repo, install
14 | ```
15 | git clone https://github.com/Azure-Samples/app-service-api-node-food-trucks.git foodtrucks
16 | cd foodtrucks
17 | ```
18 |
19 | 2. Install the node packages
20 | ```
21 | npm install
22 | ```
23 |
24 | 3. Start the node server
25 | ```
26 | npm start
27 | ```
28 |
29 | 4. Open the browser to http://localhost:1337
30 |
31 | ## Deploy to Azure
32 | Follow the steps at this tutorial [Build and deploy a Node.js API app in Azure App Service](http://azure.microsoft.com/en-us/documentation/articles/app-service-api-nodejs-api-app/) to deploy it to Azure.
33 |
--------------------------------------------------------------------------------
/api.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "v1",
5 | "title": "FoodTrucks",
6 | "description": "An TryApp sample API App where you can find Food trucks."
7 | },
8 | "host": "microsoft-apiapp1fe6951749ff4b76b8cc9194bc29ba61.azurewebsites.net:443",
9 | "schemes": ["http", "https"],
10 | "basePath": "/api/data",
11 | "paths": {
12 | "/foodtrucks": {
13 | "get": {
14 | "tags": ["FoodTrucks"],
15 | "operationId": "getFoodTrucks",
16 | "consumes": [],
17 | "produces": ["application/json",
18 | "text/json",
19 | "application/xml",
20 | "text/xml"],
21 | "responses": {
22 | "200": {
23 | "description": "OK",
24 | "schema": {
25 | "type": "array",
26 | "items": {
27 | "$ref": "#/definitions/Restaurant"
28 | }
29 | }
30 | }
31 | },
32 | "deprecated": false
33 | }
34 | },
35 | "/foodtrucks/{id}": {
36 | "get": {
37 | "tags": ["FoodTrucks"],
38 | "operationId": "getFoodTruckDetails",
39 | "consumes": [],
40 | "produces": ["application/json",
41 | "text/json",
42 | "application/xml",
43 | "text/xml"],
44 | "parameters": [{
45 | "name": "id",
46 | "in": "path",
47 | "required": true,
48 | "type": "integer",
49 | "format": "int32"
50 | }],
51 | "responses": {
52 | "200": {
53 | "description": "OK",
54 | "schema": {
55 | "type": "array",
56 | "items": {
57 | "$ref": "#/definitions/Restaurant"
58 | }
59 | }
60 | }
61 | },
62 | "deprecated": false
63 | }
64 | }
65 | },
66 | "definitions": {
67 | "Restaurant": {
68 | "type": "object",
69 | "properties": {
70 | "id": {
71 | "format": "int32",
72 | "type": "integer"
73 | },
74 | "name": {
75 | "type": "string"
76 | },
77 | "likes": {
78 | "format": "int32",
79 | "type": "integer"
80 | },
81 | "savory": {
82 | "type": "boolean"
83 | },
84 | "sweet": {
85 | "type": "boolean"
86 | },
87 | "vegetarian": {
88 | "type": "boolean"
89 | },
90 | "bookable": {
91 | "type": "boolean"
92 | },
93 | "city": {
94 | "type": "string"
95 | }
96 | }
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/apiapp.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/schemas/2014-11-01/apiapp.json#",
3 | "id": "TryAppNodeApiApp",
4 | "namespace": "microsoft.com",
5 | "gateway": "2015-01-14",
6 | "version": "1.0.0",
7 | "title": "TryAppNodeApiApp",
8 | "summary": "",
9 | "author": "",
10 | "endpoints": {
11 | "apiDefinition": "/api/data/swagger",
12 | "status": null
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/handlers/foodtrucks.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var store = require('./lib/store');
4 |
5 | module.exports = {
6 | get: function (req, res) {
7 | res.json(store.all());
8 | }
9 | };
10 |
--------------------------------------------------------------------------------
/handlers/foodtrucks/{id}.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var store = require('../lib/store');
4 |
5 |
6 | module.exports = {
7 | get: function (req, res) {
8 | res.json(store.get(req.params['id']));
9 | }
10 | };
11 |
--------------------------------------------------------------------------------
/handlers/lib/restaurants.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": 1,
4 | "name": "Pizza Buildana",
5 | "likes": 10,
6 | "savory": true,
7 | "sweet": false,
8 | "vegetarian": true,
9 | "bookable": true,
10 | "city": "San Francisco"
11 | },
12 | {
13 | "id": 2,
14 | "name": "Grab and Dip",
15 | "likes": 5,
16 | "savory": false,
17 | "sweet": true,
18 | "vegetarian": true,
19 | "bookable": false,
20 | "city": "Seattle"
21 | },
22 |
23 | {
24 | "id": 3,
25 | "name": "Thai Cart",
26 | "likes": 17,
27 | "savory": true,
28 | "sweet": true,
29 | "vegetarian": true,
30 | "bookable": false,
31 | "city": "Seattle"
32 | },
33 |
34 | {
35 | "id": 4,
36 | "name": "Curry And Go",
37 | "likes": 54,
38 | "savory": true,
39 | "sweet": false,
40 | "vegetarian": true,
41 | "bookable": true,
42 | "city": "Redmond"
43 | },
44 |
45 | {
46 | "id": 5,
47 | "name": "The big fat pork",
48 | "likes": 9,
49 | "savory": true,
50 | "sweet": false,
51 | "vegetarian": true,
52 | "bookable": false,
53 | "city": "New York"
54 | },
55 | {
56 | "id": 6,
57 | "name": "The French corner",
58 | "likes": 2,
59 | "savory": true,
60 | "sweet": true,
61 | "vegetarian": true,
62 | "bookable": true,
63 | "city": "Chicago"
64 | },
65 | {
66 | "id": 7,
67 | "name": "Mexican Fiesta",
68 | "likes": 44,
69 | "savory": true,
70 | "sweet": false,
71 | "vegetarian": false,
72 | "bookable": false,
73 | "city": "Seattle"
74 | }
75 | ]
--------------------------------------------------------------------------------
/handlers/lib/store.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var rests = require('./restaurants.json');
4 | var jp = require('jsonpath')
5 |
6 | module.exports = {
7 | get: function (id) {
8 | return jp.query(rests, '$..[?(@.id=='+id+')]');
9 | },
10 | all: function () {
11 | return rests;
12 | }
13 | };
14 |
--------------------------------------------------------------------------------
/html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
20 |
21 |
22 |
37 |
38 |
47 |
48 |
49 |
50 |
Food trucks
51 |
{{status}}
52 |
53 |
54 |
55 | | ID |
56 | Name |
57 | City |
58 | Likes |
59 | Savory |
60 | Sweet |
61 | Vegeterian |
62 | Bookable |
63 |
64 |
65 |
66 |
67 | | {{res.id}} |
68 | {{res.name}} |
69 | {{res.city}} |
70 | {{res.likes}} |
71 | {{convertToBoolText(res.savory)}} |
72 | {{convertToBoolText(res.sweet)}} |
73 | {{convertToBoolText(res.vegetarian)}} |
74 | {{convertToBoolText(res.bookable)}} |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
87 |
88 |
89 |
115 |
124 |
125 |
126 |
--------------------------------------------------------------------------------
/html/swagger-ui/css/reset.css:
--------------------------------------------------------------------------------
1 | /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
2 | html,
3 | body,
4 | div,
5 | span,
6 | applet,
7 | object,
8 | iframe,
9 | h1,
10 | h2,
11 | h3,
12 | h4,
13 | h5,
14 | h6,
15 | p,
16 | blockquote,
17 | pre,
18 | a,
19 | abbr,
20 | acronym,
21 | address,
22 | big,
23 | cite,
24 | code,
25 | del,
26 | dfn,
27 | em,
28 | img,
29 | ins,
30 | kbd,
31 | q,
32 | s,
33 | samp,
34 | small,
35 | strike,
36 | strong,
37 | sub,
38 | sup,
39 | tt,
40 | var,
41 | b,
42 | u,
43 | i,
44 | center,
45 | dl,
46 | dt,
47 | dd,
48 | ol,
49 | ul,
50 | li,
51 | fieldset,
52 | form,
53 | label,
54 | legend,
55 | table,
56 | caption,
57 | tbody,
58 | tfoot,
59 | thead,
60 | tr,
61 | th,
62 | td,
63 | article,
64 | aside,
65 | canvas,
66 | details,
67 | embed,
68 | figure,
69 | figcaption,
70 | footer,
71 | header,
72 | hgroup,
73 | menu,
74 | nav,
75 | output,
76 | ruby,
77 | section,
78 | summary,
79 | time,
80 | mark,
81 | audio,
82 | video {
83 | margin: 0;
84 | padding: 0;
85 | border: 0;
86 | font-size: 100%;
87 | font: inherit;
88 | vertical-align: baseline;
89 | }
90 | /* HTML5 display-role reset for older browsers */
91 | article,
92 | aside,
93 | details,
94 | figcaption,
95 | figure,
96 | footer,
97 | header,
98 | hgroup,
99 | menu,
100 | nav,
101 | section {
102 | display: block;
103 | }
104 | body {
105 | line-height: 1;
106 | }
107 | ol,
108 | ul {
109 | list-style: none;
110 | }
111 | blockquote,
112 | q {
113 | quotes: none;
114 | }
115 | blockquote:before,
116 | blockquote:after,
117 | q:before,
118 | q:after {
119 | content: '';
120 | content: none;
121 | }
122 | table {
123 | border-collapse: collapse;
124 | border-spacing: 0;
125 | }
126 |
--------------------------------------------------------------------------------
/html/swagger-ui/css/typography.css:
--------------------------------------------------------------------------------
1 | /* droid-sans-regular - latin */
2 | @font-face {
3 | font-family: 'Droid Sans';
4 | font-style: normal;
5 | font-weight: 400;
6 | src: url('../fonts/droid-sans-v6-latin-regular.eot'); /* IE9 Compat Modes */
7 | src: local('Droid Sans'), local('DroidSans'),
8 | url('../fonts/droid-sans-v6-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
9 | url('../fonts/droid-sans-v6-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */
10 | url('../fonts/droid-sans-v6-latin-regular.woff') format('woff'), /* Modern Browsers */
11 | url('../fonts/droid-sans-v6-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */
12 | url('../fonts/droid-sans-v6-latin-regular.svg#DroidSans') format('svg'); /* Legacy iOS */
13 | }
14 | /* droid-sans-700 - latin */
15 | @font-face {
16 | font-family: 'Droid Sans';
17 | font-style: normal;
18 | font-weight: 700;
19 | src: url('../fonts/droid-sans-v6-latin-700.eot'); /* IE9 Compat Modes */
20 | src: local('Droid Sans Bold'), local('DroidSans-Bold'),
21 | url('../fonts/droid-sans-v6-latin-700.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
22 | url('../fonts/droid-sans-v6-latin-700.woff2') format('woff2'), /* Super Modern Browsers */
23 | url('../fonts/droid-sans-v6-latin-700.woff') format('woff'), /* Modern Browsers */
24 | url('../fonts/droid-sans-v6-latin-700.ttf') format('truetype'), /* Safari, Android, iOS */
25 | url('../fonts/droid-sans-v6-latin-700.svg#DroidSans') format('svg'); /* Legacy iOS */
26 | }
27 |
--------------------------------------------------------------------------------
/html/swagger-ui/fonts/droid-sans-v6-latin-700.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/fonts/droid-sans-v6-latin-700.eot
--------------------------------------------------------------------------------
/html/swagger-ui/fonts/droid-sans-v6-latin-700.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/fonts/droid-sans-v6-latin-700.ttf
--------------------------------------------------------------------------------
/html/swagger-ui/fonts/droid-sans-v6-latin-700.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/fonts/droid-sans-v6-latin-700.woff
--------------------------------------------------------------------------------
/html/swagger-ui/fonts/droid-sans-v6-latin-700.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/fonts/droid-sans-v6-latin-700.woff2
--------------------------------------------------------------------------------
/html/swagger-ui/fonts/droid-sans-v6-latin-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/fonts/droid-sans-v6-latin-regular.eot
--------------------------------------------------------------------------------
/html/swagger-ui/fonts/droid-sans-v6-latin-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/fonts/droid-sans-v6-latin-regular.ttf
--------------------------------------------------------------------------------
/html/swagger-ui/fonts/droid-sans-v6-latin-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/fonts/droid-sans-v6-latin-regular.woff
--------------------------------------------------------------------------------
/html/swagger-ui/fonts/droid-sans-v6-latin-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/fonts/droid-sans-v6-latin-regular.woff2
--------------------------------------------------------------------------------
/html/swagger-ui/images/explorer_icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/images/explorer_icons.png
--------------------------------------------------------------------------------
/html/swagger-ui/images/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/images/favicon-16x16.png
--------------------------------------------------------------------------------
/html/swagger-ui/images/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/images/favicon-32x32.png
--------------------------------------------------------------------------------
/html/swagger-ui/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/images/favicon.ico
--------------------------------------------------------------------------------
/html/swagger-ui/images/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/images/logo_small.png
--------------------------------------------------------------------------------
/html/swagger-ui/images/pet_store_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/images/pet_store_api.png
--------------------------------------------------------------------------------
/html/swagger-ui/images/throbber.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/images/throbber.gif
--------------------------------------------------------------------------------
/html/swagger-ui/images/wordnik_api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/app-service-api-node-food-trucks/12cf2a579e4b99bc137be89f059cf5b4791eb747/html/swagger-ui/images/wordnik_api.png
--------------------------------------------------------------------------------
/html/swagger-ui/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Swagger UI
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
82 |
83 |
84 |
85 |
95 |
96 |
97 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/html/swagger-ui/lib/backbone-min.js:
--------------------------------------------------------------------------------
1 | // Backbone.js 1.1.2
2 |
3 | (function(t,e){if(typeof define==="function"&&define.amd){define(["underscore","jquery","exports"],function(i,r,s){t.Backbone=e(t,s,i,r)})}else if(typeof exports!=="undefined"){var i=require("underscore");e(t,exports,i)}else{t.Backbone=e(t,{},t._,t.jQuery||t.Zepto||t.ender||t.$)}})(this,function(t,e,i,r){var s=t.Backbone;var n=[];var a=n.push;var o=n.slice;var h=n.splice;e.VERSION="1.1.2";e.$=r;e.noConflict=function(){t.Backbone=s;return this};e.emulateHTTP=false;e.emulateJSON=false;var u=e.Events={on:function(t,e,i){if(!c(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,r){if(!c(this,"once",t,[e,r])||!e)return this;var s=this;var n=i.once(function(){s.off(t,n);e.apply(this,arguments)});n._callback=e;return this.on(t,n,r)},off:function(t,e,r){var s,n,a,o,h,u,l,f;if(!this._events||!c(this,"off",t,[e,r]))return this;if(!t&&!e&&!r){this._events=void 0;return this}o=t?[t]:i.keys(this._events);for(h=0,u=o.length;h").attr(t);this.setElement(r,false)}else{this.setElement(i.result(this,"el"),false)}}});e.sync=function(t,r,s){var n=T[t];i.defaults(s||(s={}),{emulateHTTP:e.emulateHTTP,emulateJSON:e.emulateJSON});var a={type:n,dataType:"json"};if(!s.url){a.url=i.result(r,"url")||M()}if(s.data==null&&r&&(t==="create"||t==="update"||t==="patch")){a.contentType="application/json";a.data=JSON.stringify(s.attrs||r.toJSON(s))}if(s.emulateJSON){a.contentType="application/x-www-form-urlencoded";a.data=a.data?{model:a.data}:{}}if(s.emulateHTTP&&(n==="PUT"||n==="DELETE"||n==="PATCH")){a.type="POST";if(s.emulateJSON)a.data._method=n;var o=s.beforeSend;s.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",n);if(o)return o.apply(this,arguments)}}if(a.type!=="GET"&&!s.emulateJSON){a.processData=false}if(a.type==="PATCH"&&k){a.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var h=s.xhr=e.ajax(i.extend(a,s));r.trigger("request",r,h,s);return h};var k=typeof window!=="undefined"&&!!window.ActiveXObject&&!(window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent);var T={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};e.ajax=function(){return e.$.ajax.apply(e.$,arguments)};var $=e.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var S=/\((.*?)\)/g;var H=/(\(\?)?:\w+/g;var A=/\*\w+/g;var I=/[\-{}\[\]+?.,\\\^$|#\s]/g;i.extend($.prototype,u,{initialize:function(){},route:function(t,r,s){if(!i.isRegExp(t))t=this._routeToRegExp(t);if(i.isFunction(r)){s=r;r=""}if(!s)s=this[r];var n=this;e.history.route(t,function(i){var a=n._extractParameters(t,i);n.execute(s,a);n.trigger.apply(n,["route:"+r].concat(a));n.trigger("route",r,a);e.history.trigger("route",n,r,a)});return this},execute:function(t,e){if(t)t.apply(this,e)},navigate:function(t,i){e.history.navigate(t,i);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=i.result(this,"routes");var t,e=i.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(I,"\\$&").replace(S,"(?:$1)?").replace(H,function(t,e){return e?t:"([^/?]+)"}).replace(A,"([^?]*?)");return new RegExp("^"+t+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(t,e){var r=t.exec(e).slice(1);return i.map(r,function(t,e){if(e===r.length-1)return t||null;return t?decodeURIComponent(t):null})}});var N=e.History=function(){this.handlers=[];i.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var R=/^[#\/]|\s+$/g;var O=/^\/+|\/+$/g;var P=/msie [\w.]+/;var C=/\/$/;var j=/#.*$/;N.started=false;i.extend(N.prototype,u,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=decodeURI(this.location.pathname+this.location.search);var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.slice(i.length)}else{t=this.getHash()}}return t.replace(R,"")},start:function(t){if(N.started)throw new Error("Backbone.history has already been started");N.started=true;this.options=i.extend({root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var r=this.getFragment();var s=document.documentMode;var n=P.exec(navigator.userAgent.toLowerCase())&&(!s||s<=7);this.root=("/"+this.root+"/").replace(O,"/");if(n&&this._wantsHashChange){var a=e.$('