No Description

main_2.js 10KB

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