|
@@ -0,0 +1,538 @@
|
|
1
|
+
|
|
2
|
+var response;
|
|
3
|
+angular.module('RestaurantApp',[])
|
|
4
|
+
|
|
5
|
+angular.module('RestaurantApp')
|
|
6
|
+ .factory('factoryRestInfo', [function() {
|
|
7
|
+
|
|
8
|
+ jQuery.getJSON('http://136.145.231.48:5000/retrieveMenu', function(data) {
|
|
9
|
+ alert(data);
|
|
10
|
+ //var obj = JSON.parse(data);
|
|
11
|
+});
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+var datos = jQuery.getJSON('http://136.145.231.48:5000/retrieveMenu', function(response) {
|
|
15
|
+ // do something with response
|
|
16
|
+ return response;
|
|
17
|
+});
|
|
18
|
+// INGREDIENTS datos = jQuery.get('http://136.145.231.48:5000/retrieveMenu');
|
|
19
|
+
|
|
20
|
+var ingredientArray = [];
|
|
21
|
+var Ingredients = function(name, cals, vegan, glutenFree, citrusFree) {
|
|
22
|
+
|
|
23
|
+ this.name = name,
|
|
24
|
+ this.cals = cals,
|
|
25
|
+ this.vegan = vegan,
|
|
26
|
+ this.glutenFree = glutenFree,
|
|
27
|
+ this.citrusFree = citrusFree,
|
|
28
|
+ ingredientArray.push(this)
|
|
29
|
+}
|
|
30
|
+
|
|
31
|
+ var bread = new Ingredients (
|
|
32
|
+
|
|
33
|
+ "desc dietetica",
|
|
34
|
+ 600,
|
|
35
|
+ true,
|
|
36
|
+ false,
|
|
37
|
+ true
|
|
38
|
+
|
|
39
|
+ )
|
|
40
|
+
|
|
41
|
+ var potatoes = new Ingredients (
|
|
42
|
+
|
|
43
|
+ "desc dietetica",
|
|
44
|
+ 200,
|
|
45
|
+ true,
|
|
46
|
+ true,
|
|
47
|
+ true
|
|
48
|
+
|
|
49
|
+ )
|
|
50
|
+
|
|
51
|
+ var escargot = new Ingredients (
|
|
52
|
+
|
|
53
|
+ "desc dietetica",
|
|
54
|
+ 200,
|
|
55
|
+ false,
|
|
56
|
+ true,
|
|
57
|
+ true
|
|
58
|
+
|
|
59
|
+ )
|
|
60
|
+
|
|
61
|
+ var vodka = new Ingredients (
|
|
62
|
+
|
|
63
|
+ "desc dietetica",
|
|
64
|
+ 250,
|
|
65
|
+ true,
|
|
66
|
+ true,
|
|
67
|
+ true
|
|
68
|
+
|
|
69
|
+ )
|
|
70
|
+
|
|
71
|
+ var citrus = new Ingredients (
|
|
72
|
+
|
|
73
|
+ "desc dietetica",
|
|
74
|
+ 10,
|
|
75
|
+ true,
|
|
76
|
+ true,
|
|
77
|
+ false
|
|
78
|
+
|
|
79
|
+ )
|
|
80
|
+
|
|
81
|
+ var soda = new Ingredients (
|
|
82
|
+
|
|
83
|
+ "desc dietetica",
|
|
84
|
+ 120,
|
|
85
|
+ true,
|
|
86
|
+ true,
|
|
87
|
+ true
|
|
88
|
+
|
|
89
|
+ )
|
|
90
|
+
|
|
91
|
+ var lamb = new Ingredients (
|
|
92
|
+
|
|
93
|
+ "desc dietetica",
|
|
94
|
+ 600,
|
|
95
|
+ false,
|
|
96
|
+ true,
|
|
97
|
+ true
|
|
98
|
+
|
|
99
|
+ )
|
|
100
|
+
|
|
101
|
+ var gravy = new Ingredients (
|
|
102
|
+
|
|
103
|
+ "desc dietetica",
|
|
104
|
+ 2000,
|
|
105
|
+ false,
|
|
106
|
+ false,
|
|
107
|
+ true
|
|
108
|
+
|
|
109
|
+ )
|
|
110
|
+
|
|
111
|
+// DRINKS
|
|
112
|
+var drinkArray = [];
|
|
113
|
+var DrinkItem = function(name, description, price, contents) {
|
|
114
|
+ this.name = name;
|
|
115
|
+ this.description = description;
|
|
116
|
+ this.price = price;
|
|
117
|
+ this.contents = contents;
|
|
118
|
+ this.activeToolTip = false;
|
|
119
|
+ drinkArray.push(this)
|
|
120
|
+}
|
|
121
|
+DrinkItem.prototype.isVegan = function(){
|
|
122
|
+ var vegan = true;
|
|
123
|
+
|
|
124
|
+ this.contents.forEach(function (element) {
|
|
125
|
+ if(element.vegan === false) {
|
|
126
|
+ vegan = false
|
|
127
|
+ }
|
|
128
|
+ })
|
|
129
|
+ return vegan
|
|
130
|
+}
|
|
131
|
+DrinkItem.prototype.isGlutenFree = function(){
|
|
132
|
+ var glutenFree = true;
|
|
133
|
+
|
|
134
|
+ this.contents.forEach(function (element) {
|
|
135
|
+ if(element.glutenFree === false) {
|
|
136
|
+ glutenFree = false
|
|
137
|
+ }
|
|
138
|
+ })
|
|
139
|
+ return glutenFree
|
|
140
|
+}
|
|
141
|
+DrinkItem.prototype.isCitrusFree = function(){
|
|
142
|
+ var citrusFree = true;
|
|
143
|
+
|
|
144
|
+ this.contents.forEach(function (element) {
|
|
145
|
+ if(element.citrusFree === false) {
|
|
146
|
+ citrusFree = false
|
|
147
|
+ }
|
|
148
|
+ })
|
|
149
|
+ return citrusFree
|
|
150
|
+}
|
|
151
|
+
|
|
152
|
+ var moscowMule = new DrinkItem (
|
|
153
|
+
|
|
154
|
+ 'AGua',
|
|
155
|
+ 'Agua',
|
|
156
|
+ 10.0,
|
|
157
|
+ [soda, citrus, vodka],
|
|
158
|
+ true,
|
|
159
|
+ true,
|
|
160
|
+ false
|
|
161
|
+
|
|
162
|
+ )
|
|
163
|
+
|
|
164
|
+ var margie = new DrinkItem (
|
|
165
|
+
|
|
166
|
+ 'sangria',
|
|
167
|
+ 'Bro',
|
|
168
|
+ 2.5,
|
|
169
|
+ [vodka, citrus],
|
|
170
|
+ true,
|
|
171
|
+ true,
|
|
172
|
+ false
|
|
173
|
+
|
|
174
|
+ )
|
|
175
|
+
|
|
176
|
+// FOOD PLATES
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+var plateArray = [];
|
|
180
|
+ var FoodPlate = function(name, description, price, contents) {
|
|
181
|
+
|
|
182
|
+ this.name = name;
|
|
183
|
+ this.description = description;
|
|
184
|
+ this.price = price;
|
|
185
|
+ this.contents = contents;
|
|
186
|
+ this.activeToolTip = false;
|
|
187
|
+ plateArray.push(this)
|
|
188
|
+
|
|
189
|
+ }
|
|
190
|
+FoodPlate.prototype.isVegan = function(){
|
|
191
|
+ var vegan = true;
|
|
192
|
+
|
|
193
|
+ this.contents.forEach(function (element) {
|
|
194
|
+ if(element.vegan === false) {
|
|
195
|
+ vegan = false
|
|
196
|
+ }
|
|
197
|
+ })
|
|
198
|
+ return vegan
|
|
199
|
+}
|
|
200
|
+FoodPlate.prototype.isGlutenFree = function(){
|
|
201
|
+ var glutenFree = true;
|
|
202
|
+
|
|
203
|
+ this.contents.forEach(function (element) {
|
|
204
|
+ if(element.glutenFree === false) {
|
|
205
|
+ glutenFree = false
|
|
206
|
+ }
|
|
207
|
+ })
|
|
208
|
+ return glutenFree
|
|
209
|
+}
|
|
210
|
+FoodPlate.prototype.isCitrusFree = function(){
|
|
211
|
+ var citrusFree = true;
|
|
212
|
+
|
|
213
|
+ this.contents.forEach(function (element) {
|
|
214
|
+ if(element.citrusFree === false) {
|
|
215
|
+ citrusFree = false
|
|
216
|
+ }
|
|
217
|
+ })
|
|
218
|
+ return citrusFree
|
|
219
|
+}
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+ var banhMi = new FoodPlate (
|
|
223
|
+
|
|
224
|
+ 'Hamburguer',
|
|
225
|
+ 'Un hamburguer con pan, carne, tomate y lechuga',
|
|
226
|
+ 7.25,
|
|
227
|
+ [bread, lamb],
|
|
228
|
+ false,
|
|
229
|
+ true
|
|
230
|
+ )
|
|
231
|
+
|
|
232
|
+ var poutine = new FoodPlate (
|
|
233
|
+
|
|
234
|
+ 'Vegan Burguer sike',
|
|
235
|
+ 'un hamburguer con pan, habichuelas como carne, tomate y lechuga lmao',
|
|
236
|
+ 10.9,
|
|
237
|
+ [potatoes, gravy],
|
|
238
|
+ false,
|
|
239
|
+ true
|
|
240
|
+
|
|
241
|
+ )
|
|
242
|
+
|
|
243
|
+ var escargot = new FoodPlate (
|
|
244
|
+
|
|
245
|
+ 'Food',
|
|
246
|
+ 'Es una pizza muy buen',
|
|
247
|
+ 10.0,
|
|
248
|
+ [escargot, gravy, citrus, bread],
|
|
249
|
+ false,
|
|
250
|
+ true
|
|
251
|
+
|
|
252
|
+ )
|
|
253
|
+
|
|
254
|
+ var bolaDeHamberguer = new FoodPlate (
|
|
255
|
+
|
|
256
|
+ 'Hamburguesa doble',
|
|
257
|
+ 'es una bola',
|
|
258
|
+ 10.0,
|
|
259
|
+ [escargot, gravy, citrus, bread],
|
|
260
|
+ false,
|
|
261
|
+ true
|
|
262
|
+ )
|
|
263
|
+
|
|
264
|
+ var lasagnita = new FoodPlate (
|
|
265
|
+
|
|
266
|
+ 'Lasagna',
|
|
267
|
+ 'una lasagna con c ingredientes',
|
|
268
|
+ 5.5,
|
|
269
|
+ [escargot, gravy, citrus, bread],
|
|
270
|
+ false,
|
|
271
|
+ true
|
|
272
|
+
|
|
273
|
+ )
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+ var lasagnaFake = new FoodPlate (
|
|
277
|
+
|
|
278
|
+ 'Lasanga fake',
|
|
279
|
+ 'tiene otros ingredientes',
|
|
280
|
+ 5.3,
|
|
281
|
+ [escargot, gravy, citrus, bread],
|
|
282
|
+ false,
|
|
283
|
+ true
|
|
284
|
+
|
|
285
|
+ )
|
|
286
|
+
|
|
287
|
+ var pastaCarne = new FoodPlate (
|
|
288
|
+
|
|
289
|
+ 'Pasta con carne',
|
|
290
|
+ 'Esto es una pasta rotini con salsa algo con carne de cerdo con cebolla ajo cilantro y mas ingredientes',
|
|
291
|
+ 5.5,
|
|
292
|
+ [escargot, gravy, citrus, bread],
|
|
293
|
+ false,
|
|
294
|
+ true
|
|
295
|
+
|
|
296
|
+ )
|
|
297
|
+
|
|
298
|
+ var pastaNoCarne = new FoodPlate (
|
|
299
|
+
|
|
300
|
+ 'pasta sin carne',
|
|
301
|
+ 'Esto es una pasta penne con salsa algo con carne de cerdo con cebolla ajo cilantro y mas ingredientes',
|
|
302
|
+ 5.5,
|
|
303
|
+ [escargot, gravy, citrus, bread],
|
|
304
|
+ false,
|
|
305
|
+ true
|
|
306
|
+
|
|
307
|
+ )
|
|
308
|
+
|
|
309
|
+ var pizzaQueso = new FoodPlate (
|
|
310
|
+
|
|
311
|
+ 'Pizza',
|
|
312
|
+ 'Una pizza de queso',
|
|
313
|
+ 9.99,
|
|
314
|
+ [escargot, gravy, citrus, bread],
|
|
315
|
+ false,
|
|
316
|
+ true
|
|
317
|
+
|
|
318
|
+ )
|
|
319
|
+
|
|
320
|
+ var pizzaQueso = new FoodPlate (
|
|
321
|
+
|
|
322
|
+ 'Pizza',
|
|
323
|
+ 'Una pizza de queso',
|
|
324
|
+ 9.99,
|
|
325
|
+ [escargot, gravy, citrus, bread],
|
|
326
|
+ false,
|
|
327
|
+ true
|
|
328
|
+
|
|
329
|
+ )
|
|
330
|
+
|
|
331
|
+ var masFood = new FoodPlate (
|
|
332
|
+
|
|
333
|
+ 'food',
|
|
334
|
+ 'Es una comida buena',
|
|
335
|
+ 20.0,
|
|
336
|
+ [escargot, gravy, citrus, bread],
|
|
337
|
+ false,
|
|
338
|
+ true
|
|
339
|
+
|
|
340
|
+ )
|
|
341
|
+
|
|
342
|
+ var moreeFood = new FoodPlate (
|
|
343
|
+
|
|
344
|
+ 'Food',
|
|
345
|
+ 'Comida',
|
|
346
|
+ 5.15,
|
|
347
|
+ [escargot, gravy, citrus, bread],
|
|
348
|
+ false,
|
|
349
|
+ true
|
|
350
|
+
|
|
351
|
+ )
|
|
352
|
+
|
|
353
|
+ var masPastaConCarne = new FoodPlate (
|
|
354
|
+
|
|
355
|
+ 'Pasta con carne',
|
|
356
|
+ 'Comida',
|
|
357
|
+ 8.99,
|
|
358
|
+ [escargot, gravy, citrus, bread],
|
|
359
|
+ false,
|
|
360
|
+ true
|
|
361
|
+
|
|
362
|
+ )
|
|
363
|
+
|
|
364
|
+ var pastaNoCarne2 = new FoodPlate (
|
|
365
|
+
|
|
366
|
+ 'pasta sin carne',
|
|
367
|
+ 'Esto es una pasta penne con salsa algo con carne de cerdo con cebolla ajo cilantro y mas ingredientes',
|
|
368
|
+ 7.99,
|
|
369
|
+ [escargot, gravy, citrus, bread],
|
|
370
|
+ false,
|
|
371
|
+ true
|
|
372
|
+
|
|
373
|
+ )
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+// MENU
|
|
378
|
+
|
|
379
|
+var menuArray = []
|
|
380
|
+var Menu = function(drinks, foods) {
|
|
381
|
+ this.drinks = drinks;
|
|
382
|
+ this.foods = foods;
|
|
383
|
+ menuArray.push(this)
|
|
384
|
+}
|
|
385
|
+
|
|
386
|
+ var menuArray = new Menu(drinkArray, plateArray)
|
|
387
|
+
|
|
388
|
+// INFO RESTAURANTE
|
|
389
|
+
|
|
390
|
+var Restaurant = function(name, address, phone, description, email, owners, menu) {
|
|
391
|
+ this.name = name;
|
|
392
|
+ this.address = address;
|
|
393
|
+ this.phone = phone;
|
|
394
|
+ this.description = description;
|
|
395
|
+ this.email = email;
|
|
396
|
+ this.owners = owners;
|
|
397
|
+ this.menu = menuArray;
|
|
398
|
+}
|
|
399
|
+
|
|
400
|
+ var restaurantInfo = new Restaurant (
|
|
401
|
+ 'Linguini',
|
|
402
|
+ 'Ave. Domenech #308 | San Juan, Puerto Rico 00918',
|
|
403
|
+ 'Grupo 1',
|
|
404
|
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n Ordena en linea...',
|
|
405
|
+ 'linguini@email-here.com',
|
|
406
|
+ 'Alexotic',
|
|
407
|
+ menuArray
|
|
408
|
+ )
|
|
409
|
+// INFO CONSUMIDOR
|
|
410
|
+
|
|
411
|
+var custyArray = []
|
|
412
|
+var Customer = function(vegan, glutenFree, citrusFree){
|
|
413
|
+ this.vegan = vegan
|
|
414
|
+ this.glutenFree = glutenFree
|
|
415
|
+ this.citrusFree = citrusFree
|
|
416
|
+ custyArray.push(this)
|
|
417
|
+}
|
|
418
|
+
|
|
419
|
+///////////////////////////////
|
|
420
|
+
|
|
421
|
+ return {
|
|
422
|
+ restaurant : restaurantInfo,
|
|
423
|
+ menuArray : menuArray,
|
|
424
|
+ custyArray : custyArray,
|
|
425
|
+ ingredientArray : ingredientArray,
|
|
426
|
+ drinkArray : drinkArray,
|
|
427
|
+ plateArray : plateArray
|
|
428
|
+ }
|
|
429
|
+
|
|
430
|
+ }]);
|
|
431
|
+
|
|
432
|
+//////////////////////////////
|
|
433
|
+
|
|
434
|
+// Restaurant.prototype.stringify = function() {
|
|
435
|
+// return 'Welcome to ' + this.name + '! We\'re excited to have you.\n Conveniently located at ' + this.address + '. Our new menu consists of:\nThese drinks: ' + (drinkArray.map(function(item){return item.name})) + ', and this food: ' + ((plateArray.map(function(item){return item.name}))) + '.'
|
|
436
|
+// }
|
|
437
|
+// console.log(restaurantInfo.stringify());
|
|
438
|
+
|
|
439
|
+angular.module('RestaurantApp')
|
|
440
|
+ .controller('controllerRestaurant', ['$scope', 'factoryRestInfo', function($scope, factoryRestInfo) {
|
|
441
|
+
|
|
442
|
+ // FACTORY CONTROLLER SCOPES
|
|
443
|
+
|
|
444
|
+ $scope.custyArray = factoryRestInfo.custyArray;
|
|
445
|
+ $scope.menuComplete = factoryRestInfo.menuArray;
|
|
446
|
+ $scope.restaurantDeets = factoryRestInfo.restaurant;
|
|
447
|
+ $scope.ingredientArray = factoryRestInfo.ingredientArray;
|
|
448
|
+ $scope.drinkArray = factoryRestInfo.drinkArray;
|
|
449
|
+ $scope.plateArray = factoryRestInfo.plateArray
|
|
450
|
+
|
|
451
|
+ // FUNCION SHOW-HIDE
|
|
452
|
+
|
|
453
|
+ $scope.userMessage = "Entre su información"
|
|
454
|
+ $scope.messageList = function() {
|
|
455
|
+ $scope.listAppearWhenClicked = !$scope.listAppearWhenClicked;
|
|
456
|
+ if ($scope.listAppearWhenClicked === !true) {
|
|
457
|
+ $scope.userMessage = "Entre su información"
|
|
458
|
+ }
|
|
459
|
+ else {
|
|
460
|
+ $scope.userMessage = "Cerrar"
|
|
461
|
+ }
|
|
462
|
+ }
|
|
463
|
+
|
|
464
|
+ // FUNCION TOTAL DE ORDEN
|
|
465
|
+
|
|
466
|
+ $scope.rounded = 0
|
|
467
|
+ $scope.orderTotal = 0
|
|
468
|
+ $scope.order = [];
|
|
469
|
+ $scope.addItem = function (item) {
|
|
470
|
+ $scope.order.push(item)
|
|
471
|
+ $scope.orderTotal = $scope.orderTotal+item.price;
|
|
472
|
+ $scope.rounded = $scope.orderTotal.toFixed(2);
|
|
473
|
+ }
|
|
474
|
+
|
|
475
|
+ // INFO DEL CLIENTE Y TOOLTIPPER
|
|
476
|
+
|
|
477
|
+ $scope.emptyForm = function () {
|
|
478
|
+ $scope.diet = {
|
|
479
|
+ name: "",
|
|
480
|
+ address: "",
|
|
481
|
+ phone: "",
|
|
482
|
+ vegan : "",
|
|
483
|
+ glutenFree : "",
|
|
484
|
+ citrusFree : ""
|
|
485
|
+ }
|
|
486
|
+ }
|
|
487
|
+
|
|
488
|
+ $scope.saveCusty = function() {
|
|
489
|
+ $scope.listAppearWhenClicked = !$scope.listAppearWhenClicked;
|
|
490
|
+ $scope.custyArray.push($scope.diet);
|
|
491
|
+ console.log($scope.custyArray)
|
|
492
|
+
|
|
493
|
+ for (var i = 0; i < $scope.custyArray.length; i++) {
|
|
494
|
+
|
|
495
|
+ for (var j = 0; j < $scope.plateArray.length; j++) {
|
|
496
|
+ if ( $scope.custyArray[i].vegan === true && $scope.plateArray[j].isVegan() === false) {
|
|
497
|
+ $scope.plateArray[j].activeToolTip = true;
|
|
498
|
+ }
|
|
499
|
+ else if ($scope.custyArray[i].glutenFree === true && $scope.plateArray[j].isGlutenFree() === false){
|
|
500
|
+ $scope.plateArray[j].activeToolTip = true;
|
|
501
|
+ }
|
|
502
|
+ else if ($scope.custyArray[i].citrusFree === true && $scope.plateArray[j].isCitrusFree() === false){
|
|
503
|
+ $scope.plateArray[j].activeToolTip = true;
|
|
504
|
+ }
|
|
505
|
+ }
|
|
506
|
+ for (var j = 0; j < $scope.drinkArray.length; j++) {
|
|
507
|
+ if ( $scope.custyArray[i].vegan === true && $scope.drinkArray[j].isVegan() === false) {
|
|
508
|
+ $scope.drinkArray[j].activeToolTip = true;
|
|
509
|
+ }
|
|
510
|
+ else if ($scope.custyArray[i].glutenFree === true && $scope.drinkArray[j].isGlutenFree() === false){
|
|
511
|
+ $scope.drinkArray[j].activeToolTip = true;
|
|
512
|
+ }
|
|
513
|
+ else if ($scope.custyArray[i].citrusFree === true && $scope.drinkArray[j].isCitrusFree() === false){
|
|
514
|
+ $scope.drinkArray[j].activeToolTip = true;
|
|
515
|
+ }
|
|
516
|
+ }
|
|
517
|
+ }
|
|
518
|
+ $scope.emptyForm();
|
|
519
|
+ if ($scope.listAppearWhenClicked === !true) {
|
|
520
|
+ $scope.userMessage = "Entre su información"
|
|
521
|
+ }
|
|
522
|
+ else {
|
|
523
|
+ $scope.userMessage = "Cerrar"
|
|
524
|
+ }
|
|
525
|
+ }
|
|
526
|
+
|
|
527
|
+ $scope.resetForm = function() {
|
|
528
|
+ $scope.custyArray = []
|
|
529
|
+ for (var i = 0; i < $scope.plateArray.length; i++) {
|
|
530
|
+ $scope.plateArray[i].activeToolTip = false;
|
|
531
|
+ }
|
|
532
|
+ for (var j = 0; j < $scope.drinkArray.length; j++) {
|
|
533
|
+ $scope.drinkArray[j].activeToolTip = false;
|
|
534
|
+ }
|
|
535
|
+ }
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+ }]);
|