123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538 |
-
- var response;
- angular.module('RestaurantApp',[])
-
- angular.module('RestaurantApp')
- .factory('factoryRestInfo', [function() {
-
- jQuery.getJSON('http://136.145.231.48:5000/retrieveMenu', function(data) {
- alert(data);
- //var obj = JSON.parse(data);
- });
-
-
- var datos = jQuery.getJSON('http://136.145.231.48:5000/retrieveMenu', function(response) {
- // do something with response
- return response;
- });
- // INGREDIENTS datos = jQuery.get('http://136.145.231.48:5000/retrieveMenu');
-
- var ingredientArray = [];
- var Ingredients = function(name, cals, vegan, glutenFree, citrusFree) {
-
- this.name = name,
- this.cals = cals,
- this.vegan = vegan,
- this.glutenFree = glutenFree,
- this.citrusFree = citrusFree,
- ingredientArray.push(this)
- }
-
- var bread = new Ingredients (
-
- "desc dietetica",
- 600,
- true,
- false,
- true
-
- )
-
- var potatoes = new Ingredients (
-
- "desc dietetica",
- 200,
- true,
- true,
- true
-
- )
-
- var escargot = new Ingredients (
-
- "desc dietetica",
- 200,
- false,
- true,
- true
-
- )
-
- var vodka = new Ingredients (
-
- "desc dietetica",
- 250,
- true,
- true,
- true
-
- )
-
- var citrus = new Ingredients (
-
- "desc dietetica",
- 10,
- true,
- true,
- false
-
- )
-
- var soda = new Ingredients (
-
- "desc dietetica",
- 120,
- true,
- true,
- true
-
- )
-
- var lamb = new Ingredients (
-
- "desc dietetica",
- 600,
- false,
- true,
- true
-
- )
-
- var gravy = new Ingredients (
-
- "desc dietetica",
- 2000,
- false,
- false,
- true
-
- )
-
- // DRINKS
- var drinkArray = [];
- var DrinkItem = function(name, description, price, contents) {
- this.name = name;
- this.description = description;
- this.price = price;
- this.contents = contents;
- this.activeToolTip = false;
- drinkArray.push(this)
- }
- DrinkItem.prototype.isVegan = function(){
- var vegan = true;
-
- this.contents.forEach(function (element) {
- if(element.vegan === false) {
- vegan = false
- }
- })
- return vegan
- }
- DrinkItem.prototype.isGlutenFree = function(){
- var glutenFree = true;
-
- this.contents.forEach(function (element) {
- if(element.glutenFree === false) {
- glutenFree = false
- }
- })
- return glutenFree
- }
- DrinkItem.prototype.isCitrusFree = function(){
- var citrusFree = true;
-
- this.contents.forEach(function (element) {
- if(element.citrusFree === false) {
- citrusFree = false
- }
- })
- return citrusFree
- }
-
- var moscowMule = new DrinkItem (
-
- 'AGua',
- 'Agua',
- 10.0,
- [soda, citrus, vodka],
- true,
- true,
- false
-
- )
-
- var margie = new DrinkItem (
-
- 'sangria',
- 'Bro',
- 2.5,
- [vodka, citrus],
- true,
- true,
- false
-
- )
-
- // FOOD PLATES
-
-
- var plateArray = [];
- var FoodPlate = function(name, description, price, contents) {
-
- this.name = name;
- this.description = description;
- this.price = price;
- this.contents = contents;
- this.activeToolTip = false;
- plateArray.push(this)
-
- }
- FoodPlate.prototype.isVegan = function(){
- var vegan = true;
-
- this.contents.forEach(function (element) {
- if(element.vegan === false) {
- vegan = false
- }
- })
- return vegan
- }
- FoodPlate.prototype.isGlutenFree = function(){
- var glutenFree = true;
-
- this.contents.forEach(function (element) {
- if(element.glutenFree === false) {
- glutenFree = false
- }
- })
- return glutenFree
- }
- FoodPlate.prototype.isCitrusFree = function(){
- var citrusFree = true;
-
- this.contents.forEach(function (element) {
- if(element.citrusFree === false) {
- citrusFree = false
- }
- })
- return citrusFree
- }
-
-
- var banhMi = new FoodPlate (
-
- 'Hamburguer',
- 'Un hamburguer con pan, carne, tomate y lechuga',
- 7.25,
- [bread, lamb],
- false,
- true
- )
-
- var poutine = new FoodPlate (
-
- 'Vegan Burguer sike',
- 'un hamburguer con pan, habichuelas como carne, tomate y lechuga lmao',
- 10.9,
- [potatoes, gravy],
- false,
- true
-
- )
-
- var escargot = new FoodPlate (
-
- 'Food',
- 'Es una pizza muy buen',
- 10.0,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
- var bolaDeHamberguer = new FoodPlate (
-
- 'Hamburguesa doble',
- 'es una bola',
- 10.0,
- [escargot, gravy, citrus, bread],
- false,
- true
- )
-
- var lasagnita = new FoodPlate (
-
- 'Lasagna',
- 'una lasagna con c ingredientes',
- 5.5,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
-
- var lasagnaFake = new FoodPlate (
-
- 'Lasanga fake',
- 'tiene otros ingredientes',
- 5.3,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
- var pastaCarne = new FoodPlate (
-
- 'Pasta con carne',
- 'Esto es una pasta rotini con salsa algo con carne de cerdo con cebolla ajo cilantro y mas ingredientes',
- 5.5,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
- var pastaNoCarne = new FoodPlate (
-
- 'pasta sin carne',
- 'Esto es una pasta penne con salsa algo con carne de cerdo con cebolla ajo cilantro y mas ingredientes',
- 5.5,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
- var pizzaQueso = new FoodPlate (
-
- 'Pizza',
- 'Una pizza de queso',
- 9.99,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
- var pizzaQueso = new FoodPlate (
-
- 'Pizza',
- 'Una pizza de queso',
- 9.99,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
- var masFood = new FoodPlate (
-
- 'food',
- 'Es una comida buena',
- 20.0,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
- var moreeFood = new FoodPlate (
-
- 'Food',
- 'Comida',
- 5.15,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
- var masPastaConCarne = new FoodPlate (
-
- 'Pasta con carne',
- 'Comida',
- 8.99,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
- var pastaNoCarne2 = new FoodPlate (
-
- 'pasta sin carne',
- 'Esto es una pasta penne con salsa algo con carne de cerdo con cebolla ajo cilantro y mas ingredientes',
- 7.99,
- [escargot, gravy, citrus, bread],
- false,
- true
-
- )
-
-
-
- // MENU
-
- var menuArray = []
- var Menu = function(drinks, foods) {
- this.drinks = drinks;
- this.foods = foods;
- menuArray.push(this)
- }
-
- var menuArray = new Menu(drinkArray, plateArray)
-
- // INFO RESTAURANTE
-
- var Restaurant = function(name, address, phone, description, email, owners, menu) {
- this.name = name;
- this.address = address;
- this.phone = phone;
- this.description = description;
- this.email = email;
- this.owners = owners;
- this.menu = menuArray;
- }
-
- var restaurantInfo = new Restaurant (
- 'Linguini',
- 'Ave. Domenech #308 | San Juan, Puerto Rico 00918',
- 'Grupo 1',
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n Ordena en linea...',
- 'linguini@email-here.com',
- 'Alexotic',
- menuArray
- )
- // INFO CONSUMIDOR
-
- var custyArray = []
- var Customer = function(vegan, glutenFree, citrusFree){
- this.vegan = vegan
- this.glutenFree = glutenFree
- this.citrusFree = citrusFree
- custyArray.push(this)
- }
-
- ///////////////////////////////
-
- return {
- restaurant : restaurantInfo,
- menuArray : menuArray,
- custyArray : custyArray,
- ingredientArray : ingredientArray,
- drinkArray : drinkArray,
- plateArray : plateArray
- }
-
- }]);
-
- //////////////////////////////
-
- // Restaurant.prototype.stringify = function() {
- // 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}))) + '.'
- // }
- // console.log(restaurantInfo.stringify());
-
- angular.module('RestaurantApp')
- .controller('controllerRestaurant', ['$scope', 'factoryRestInfo', function($scope, factoryRestInfo) {
-
- // FACTORY CONTROLLER SCOPES
-
- $scope.custyArray = factoryRestInfo.custyArray;
- $scope.menuComplete = factoryRestInfo.menuArray;
- $scope.restaurantDeets = factoryRestInfo.restaurant;
- $scope.ingredientArray = factoryRestInfo.ingredientArray;
- $scope.drinkArray = factoryRestInfo.drinkArray;
- $scope.plateArray = factoryRestInfo.plateArray
-
- // FUNCION SHOW-HIDE
-
- $scope.userMessage = "Entre su información"
- $scope.messageList = function() {
- $scope.listAppearWhenClicked = !$scope.listAppearWhenClicked;
- if ($scope.listAppearWhenClicked === !true) {
- $scope.userMessage = "Entre su información"
- }
- else {
- $scope.userMessage = "Cerrar"
- }
- }
-
- // FUNCION TOTAL DE ORDEN
-
- $scope.rounded = 0
- $scope.orderTotal = 0
- $scope.order = [];
- $scope.addItem = function (item) {
- $scope.order.push(item)
- $scope.orderTotal = $scope.orderTotal+item.price;
- $scope.rounded = $scope.orderTotal.toFixed(2);
- }
-
- // INFO DEL CLIENTE Y TOOLTIPPER
-
- $scope.emptyForm = function () {
- $scope.diet = {
- name: "",
- address: "",
- phone: "",
- vegan : "",
- glutenFree : "",
- citrusFree : ""
- }
- }
-
- $scope.saveCusty = function() {
- $scope.listAppearWhenClicked = !$scope.listAppearWhenClicked;
- $scope.custyArray.push($scope.diet);
- console.log($scope.custyArray)
-
- for (var i = 0; i < $scope.custyArray.length; i++) {
-
- for (var j = 0; j < $scope.plateArray.length; j++) {
- if ( $scope.custyArray[i].vegan === true && $scope.plateArray[j].isVegan() === false) {
- $scope.plateArray[j].activeToolTip = true;
- }
- else if ($scope.custyArray[i].glutenFree === true && $scope.plateArray[j].isGlutenFree() === false){
- $scope.plateArray[j].activeToolTip = true;
- }
- else if ($scope.custyArray[i].citrusFree === true && $scope.plateArray[j].isCitrusFree() === false){
- $scope.plateArray[j].activeToolTip = true;
- }
- }
- for (var j = 0; j < $scope.drinkArray.length; j++) {
- if ( $scope.custyArray[i].vegan === true && $scope.drinkArray[j].isVegan() === false) {
- $scope.drinkArray[j].activeToolTip = true;
- }
- else if ($scope.custyArray[i].glutenFree === true && $scope.drinkArray[j].isGlutenFree() === false){
- $scope.drinkArray[j].activeToolTip = true;
- }
- else if ($scope.custyArray[i].citrusFree === true && $scope.drinkArray[j].isCitrusFree() === false){
- $scope.drinkArray[j].activeToolTip = true;
- }
- }
- }
- $scope.emptyForm();
- if ($scope.listAppearWhenClicked === !true) {
- $scope.userMessage = "Entre su información"
- }
- else {
- $scope.userMessage = "Cerrar"
- }
- }
-
- $scope.resetForm = function() {
- $scope.custyArray = []
- for (var i = 0; i < $scope.plateArray.length; i++) {
- $scope.plateArray[i].activeToolTip = false;
- }
- for (var j = 0; j < $scope.drinkArray.length; j++) {
- $scope.drinkArray[j].activeToolTip = false;
- }
- }
-
-
- }]);
|