diff --git a/.gitignore b/.gitignore index ce47dfb..886b141 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /node_modules +/idea **.map diff --git a/.htaccess b/.htaccess index 65b9561..338c266 100644 --- a/.htaccess +++ b/.htaccess @@ -1,14 +1,11 @@ -RewriteEngine On - -# redirigir y eliminar php (Yay! Funciona c:) -RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC] -RewriteRule ^ /%1 [NC,L,R=301] - -RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC] -RewriteRule ^ /%1 [NC,L,R=301] - -RewriteCond %{REQUEST_FILENAME}.php -f -RewriteRule ^ %{REQUEST_URI}.php [NC,L] + + RewriteEngine On + RewriteBase / + RewriteRule ^index\.php$ - [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule . /ihc/index.php [L] + ## Desabilitar cache de Apache @@ -19,4 +16,4 @@ RewriteRule ^ %{REQUEST_URI}.php [NC,L] Header set Pragma "no-cache" Header set Expires "Wed, 12 Jan 1980 05:00:00 GMT" - \ No newline at end of file + diff --git a/css/base.css b/css/base.css deleted file mode 100644 index 70a5ae0..0000000 --- a/css/base.css +++ /dev/null @@ -1,428 +0,0 @@ -@import url("https://fonts.googleapis.com/css?family=Muli|Open+Sans"); -* { - box-sizing: border-box; -} - -html, body { - margin: 0; - padding: 0; - font-family: "Open Sans", sans-serif; -} - -header { - background-color: #44A; - box-shadow: 0 5px 5px #999999; -} - -nav { - background-color: #3d3d7c; - color: white; -} - -section { - overflow: hidden; - transition: height 150ms ease-out; - height: auto; -} - -footer { - background-color: #333; - color: #EEE; - box-shadow: inset 0 5px 5px #999999; - padding: 40px; -} - -.contenedor { - max-width: 1200px; - width: 80%; - margin: auto; -} - -.col-1 { - width: 8.33%; -} - -.col-2 { - width: 16.66%; -} - -.col-3 { - width: 25%; -} - -.col-4 { - width: 33.33%; -} - -.col-5 { - width: 41.66%; -} - -.col-6 { - width: 50%; -} - -.col-7 { - width: 58.33%; -} - -.col-8 { - width: 66.66%; -} - -.col-9 { - width: 75%; -} - -.col-10 { - width: 83.33%; -} - -.col-11 { - width: 91.66%; -} - -.col-12 { - width: 100%; -} - -[class*=col-] { - float: left; -} - -.row::after { - content: ""; - clear: both; - display: table; -} - -.center { - text-align: center; -} - -#tituloP { - padding: 30px; - color: white; - font-size: 50px; - font-family: "Muli"; -} - -#tituloP--descripcion { - padding: 10px; - font-size: large; - font-family: "Open Sans"; -} - -.center { - text-align: center; -} - -.boton { - display: inline-block; - margin: 20px; - border-radius: 3px; - box-shadow: 1px 1px 3px #090909; - padding: 10px 30px; - cursor: pointer; - text-decoration: none; -} - -.mySeccion { - overflow: hidden; - transition: height 150ms ease-out; - height: auto; -} - -#botonRegistro { - background-color: green; - color: white; - font-size: large; - transition: transform 200ms, box-shadow 200ms; -} - -#botonRegistro:hover { - transform: translate(-1px, -1px); - box-shadow: 2px 2px 7px #050505; -} - -#botonInicioSesion { - background-color: white; - transition: transform 200ms, box-shadow 200ms; -} - -#botonInicioSesion:hover { - transform: translate(-1px, -1px); - box-shadow: 2px 2px 7px #050505; -} - -#botonInicioSesion:visited { - color: black; -} - -.contenido { - margin: 40px 0; -} - -.image { - padding: 0 20px; - width: 100%; - height: auto; -} - -.descripcionComida { - padding: 0 30px; - text-align: center; - font-size: large; -} - -.inicio_registro { - color: white; -} - -input { - min-width: 80%; - min-height: 40px; - padding: 10px; - color: #44A; - font-size: large; -} - -.botonEnviarForm { - background-color: white; - box-shadow: 1px 1px 2px gray; - cursor: pointer; - border: none; - transition: background-color 250ms, color 250ms, transform 250ms, box-shadow 250ms; -} - -.botonEnviarForm:hover { - background-color: #4949e2; - color: white; - transform: translate(-1px, -1px); - box-shadow: 2px 2px 2px gray; -} - -.google-button { - height: 40px; - border-width: 0; - background: white; - color: #737373; - border-radius: 5px; - white-space: nowrap; - box-shadow: 1px 1px 0 1px rgba(0, 0, 0, 0.05); - transition-property: background-color, box-shadow; - transition-duration: 150ms; - transition-timing-function: ease-in-out; - padding: 0; - cursor: pointer; -} - -.google-button:focus, .google-button:hover { - box-shadow: 1px 4px 5px 1px rgba(0, 0, 0, 0.1); -} - -.google-button:active { - background-color: #e5e5e5; - box-shadow: none; - transition-duration: 10ms; -} - -.google-button__icon { - display: inline-block; - vertical-align: middle; - margin: 8px 0 8px 8px; - width: 18px; - height: 18px; - box-sizing: border-box; -} - -.google-button__text { - display: inline-block; - vertical-align: middle; - padding: 0 24px; - font-size: 14px; - font-weight: bold; - font-family: "Roboto", arial, sans-serif; -} - -.unseen { - visibility: hidden; -} - -.botonAddCart { - background-color: white; - padding: 5px; - color: #4444aa; - box-shadow: 0.1px 0.1px grey; - border-radius: 2px; - cursor: pointer; - font-size: large; - transition: background-color 250ms, color 250ms; - user-select: none; -} - -.botonAddCart:hover { - background-color: #4444AA; - color: white; -} - -.caja { - border-radius: 4px; - box-shadow: 1px 1px 2px gray; - padding: 15px; -} - -.botonPayPal, .botonVisa { - background-color: #0070ba; - color: white; - font-size: large; - padding: 10px; - border: none; - border-radius: 5px; - cursor: pointer; - margin: 0 5px; -} - -.botonVisa { - background-color: #1a1f5e; -} - -.linksNavBar { - margin: 0; -} -.linksNavBar li { - list-style: none; - float: left; - transition: background-color 250ms; -} -.linksNavBar li a { - cursor: pointer; - display: inline-block; - padding: 15px; - color: white; - text-decoration: none; -} -.linksNavBar li:after { - clear: both; -} -.linksNavBar li:hover { - background-color: #35356a; -} - -.plato--Titulo { - font-size: x-large; - font-weight: bold; - font-family: "Muli"; - color: #3d3d7c; -} - -.plato--Descripcion { - font-size: large; - color: #333333; -} - -.plato--Precio { - font-size: large; -} -.plato--Precio:before { - color: green; - content: "Precio unitario: "; -} -.plato--Precio:after { - content: " S/."; -} - -.plato--Cantidad { - font-size: large; - font-weight: bold; - display: inline-table; - padding: 15px; -} - -.plato--Cantidad--Icon { - display: table-cell; - vertical-align: top; - cursor: pointer; - transition: color 250ms; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.plato--Cantidad--Icon:hover { - color: #4444aa; -} - -.carrito { - text-align: left; -} - -#carrito--elementos, #carrito--precio { - padding: 0 10px; -} - -.carritoElem:after { - clear: both; -} - -.carritoElem--img { - float: left; - margin: 10px 20px; - width: 200px; -} - -.carrito--subTotal { - text-align: right; - font-weight: bold; - font-family: "Muli", sans-serif; - font-size: x-large; -} -.carrito--subTotal:before { - content: "Subtotal: "; -} -.carrito--subTotal:after { - content: " S/."; -} - -.carrito--precio--contenido--titulo { - text-align: center; - font-family: "Muli", sans-serif; - font-size: x-large; - font-weight: 900; -} - -.carrito--precio--contenido--botonPagar { - display: inline-block; - width: 100%; - text-align: center; - padding: 10px; - background-color: #4444aa; - color: white; - border-radius: 3px; - cursor: pointer; -} -.carrito--precio--contenido--botonPagar:hover { - background-color: #3d3d7c; -} - -#carrito--boton--seguircomprando { - margin: 10px 0; - padding: 10px 20px; - background-color: green; - color: white; - text-decoration: none; - border-radius: 4px; -} -#carrito--boton--seguircomprando:visited { - color: white; -} - -#carrito--tituloprincipal { - text-align: center; - font-size: xx-large; - font-family: "Muli", sans-serif; - font-weight: 900; - margin: 10px 0; -} - -/*# sourceMappingURL=base.css.map */ diff --git a/css/base.css.map b/css/base.css.map deleted file mode 100644 index af69bf5..0000000 --- a/css/base.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sourceRoot":"","sources":["base.sass"],"names":[],"mappings":"AAAQ;AAKR;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EAEE;EACA,aAvFY;;;AAyFhB;EACE;EAEE;EACA,aA5Fc;;;AA8FlB;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EAEE;;;AAEF;EACE;;AACA;EACE;EACA;EACA;;AACA;EACE;EACA;EACA;EACA;EACA;;AACF;EACE;;AACF;EACE;;;AAEN;EAEI;EACA;EACA,aAzQY;EA0Qd;;;AAEF;EAEI;EACF;;;AAEF;EACE;;AACA;EACE;EACA;;AACF;EACE;;;AAEJ;EAEI;EACA;EACF;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACE;;;AAEJ;EACE;;;AAEF;EACE;;;AAGA;EACE;;;AAEJ;EACE;EACA;EACA;;;AAEF;EACE;EAEE;EACA;EACA;;AACF;EACE;;AACF;EACE;;;AAEJ;EACE;EAEE;EACA;EACA;;;AAEJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;AACA;EACE;;;AAEJ;EACE;EACA;EACA;EACA;EACA;EACA;;AACA;EACE;;;AAEJ;EACE;EAEE;EACA;EACA;EACF","file":"base.css"} \ No newline at end of file diff --git a/css/base.sass b/css/base.sass deleted file mode 100644 index eca6e53..0000000 --- a/css/base.sass +++ /dev/null @@ -1,366 +0,0 @@ -@import url('https://fonts.googleapis.com/css?family=Muli|Open+Sans') - -$fuenteTitulos: 'Muli' -$fuentePrincipal: 'Open Sans' - -* - box-sizing: border-box - -html, body - margin: 0 - padding: 0 - font-family: $fuentePrincipal, sans-serif - -header - background-color: #44A - box-shadow: 0 5px 5px #999999 - -nav - background-color: #3d3d7c - color: white - -section - overflow: hidden - transition: height 150ms ease-out - height: auto - -footer - background-color: #333 - color: #EEE - box-shadow: inset 0 5px 5px #999999 - padding: 40px - -.contenedor - max-width: 1200px - width: 80% - margin: auto - -.col-1 - width: 8.33% - -.col-2 - width: 16.66% - -.col-3 - width: 25% - -.col-4 - width: 33.33% - -.col-5 - width: 41.66% - -.col-6 - width: 50% - -.col-7 - width: 58.33% - -.col-8 - width: 66.66% - -.col-9 - width: 75% - -.col-10 - width: 83.33% - -.col-11 - width: 91.66% - -.col-12 - width: 100% - -[class*="col-"] - float: left - -.row::after - content: "" - clear: both - display: table - -.center - text-align: center - -#tituloP - padding: 30px - color: white - font: - size: 50px - family: $fuenteTitulos - -#tituloP--descripcion - padding: 10px - font: - size: large - family: $fuentePrincipal - -.center - text-align: center - -.boton - display: inline-block - margin: 20px - border-radius: 3px - box-shadow: 1px 1px 3px #090909 - padding: 10px 30px - cursor: pointer - text-decoration: none - -.mySeccion - overflow: hidden - transition: height 150ms ease-out - height: auto - -#botonRegistro - background-color: green - color: white - font-size: large - transition: transform 200ms, box-shadow 200ms - -#botonRegistro:hover - transform: translate(-1px, -1px) - box-shadow: 2px 2px 7px #050505 - -#botonInicioSesion - background-color: white - transition: transform 200ms, box-shadow 200ms - -#botonInicioSesion:hover - transform: translate(-1px, -1px) - box-shadow: 2px 2px 7px #050505 - -#botonInicioSesion:visited - color: black - -.contenido - margin: 40px 0 - -.image - padding: 0 20px - width: 100% - height: auto - -.descripcionComida - padding: 0 30px - text-align: center - font-size: large - -.inicio_registro - color: white - -input - min-width: 80% - min-height: 40px - padding: 10px - color: #44A - font-size: large - -.botonEnviarForm - background-color: white - box-shadow: 1px 1px 2px gray - cursor: pointer - border: none - transition: background-color 250ms, color 250ms, transform 250ms, box-shadow 250ms - -.botonEnviarForm:hover - background-color: #4949e2 - color: white - transform: translate(-1px, -1px) - box-shadow: 2px 2px 2px gray - -.google-button - height: 40px - border-width: 0 - background: white - color: #737373 - border-radius: 5px - white-space: nowrap - box-shadow: 1px 1px 0 1px rgba(0, 0, 0, 0.05) - transition-property: background-color, box-shadow - transition-duration: 150ms - transition-timing-function: ease-in-out - padding: 0 - cursor: pointer - -.google-button:focus, .google-button:hover - box-shadow: 1px 4px 5px 1px rgba(0, 0, 0, 0.1) - -.google-button:active - background-color: #e5e5e5 - box-shadow: none - transition-duration: 10ms - -.google-button__icon - display: inline-block - vertical-align: middle - margin: 8px 0 8px 8px - width: 18px - height: 18px - box-sizing: border-box - -.google-button__text - display: inline-block - vertical-align: middle - padding: 0 24px - font-size: 14px - font-weight: bold - font-family: 'Roboto', arial, sans-serif - -.unseen - visibility: hidden - -.botonAddCart - background-color: white - padding: 5px - color: #4444aa - box-shadow: 0.1px 0.1px grey - border-radius: 2px - cursor: pointer - font-size: large - transition: background-color 250ms, color 250ms - user-select: none - -.botonAddCart:hover - background-color: #4444AA - color: white - -.caja - border-radius: 4px - box-shadow: 1px 1px 2px gray - padding: 15px - -.botonPayPal - background-color: #0070ba - color: white - font-size: large - padding: 10px - border: none - border-radius: 5px - cursor: pointer - margin: 0 5px - -.botonVisa - @extend .botonPayPal - background-color: #1a1f5e - -.linksNavBar - margin: 0 - li - list-style: none - float: left - transition: background-color 250ms - a - cursor: pointer - display: inline-block - padding: 15px - color: white - text-decoration: none - &:after - clear: both - &:hover - background-color: #35356a - -.plato--Titulo - font: - size: x-large - weight: bold - family: $fuenteTitulos - color: #3d3d7c - -.plato--Descripcion - font: - size: large - color: #333333 - -.plato--Precio - font-size: large - &:before - color: green - content: "Precio unitario: " - &:after - content: " S/." - -.plato--Cantidad - font: - size: large - weight: bold - display: inline-table - padding: 15px - -.plato--Cantidad--Icon - display: table-cell - vertical-align: top - cursor: pointer - transition: color 250ms - -webkit-user-select: none - -moz-user-select: none - -ms-user-select: none - user-select: none - &:hover - color: #4444aa - -.carrito - text-align: left - -#carrito--elementos, #carrito--precio - padding: 0 10px - -.carritoElem - &:after - clear: both - -.carritoElem--img - float: left - margin: 10px 20px - width: 200px - -.carrito--subTotal - text-align: right - font: - weight: bold - family: $fuenteTitulos, sans-serif - size: x-large - &:before - content: "Subtotal: " - &:after - content: " S/." - -.carrito--precio--contenido--titulo - text-align: center - font: - family: $fuenteTitulos, sans-serif - size: x-large - weight: 900 - -.carrito--precio--contenido--botonPagar - display: inline-block - width: 100% - text-align: center - padding: 10px - background-color: #4444aa - color: white - border-radius: 3px - cursor: pointer - &:hover - background-color: #3d3d7c - -#carrito--boton--seguircomprando - margin: 10px 0 - padding: 10px 20px - background-color: green - color: white - text-decoration: none - border-radius: 4px - &:visited - color: white - -#carrito--tituloprincipal - text-align: center - font: - size: xx-large - family: $fuenteTitulos, sans-serif - weight: 900 - margin: 10px 0 - - diff --git a/dist/css/anuma.css b/dist/css/anuma.css deleted file mode 100644 index 1e6663e..0000000 --- a/dist/css/anuma.css +++ /dev/null @@ -1 +0,0 @@ -.anuma-we{font-family:sans-serif;font-size:30px}.anuma-we--alv{color:#23bf87}/*# sourceMappingURL=anuma.css.map */ diff --git a/src/js/vue.js b/dist/dependencias/vue.js similarity index 100% rename from src/js/vue.js rename to dist/dependencias/vue.js diff --git a/dist/dependencias/vuerouter.min.js b/dist/dependencias/vuerouter.min.js new file mode 100644 index 0000000..555b88e --- /dev/null +++ b/dist/dependencias/vuerouter.min.js @@ -0,0 +1 @@ +!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):global.VueRouter=factory()}(this,function(){"use strict";function assert(condition,message){if(!condition)throw new Error("[vue-router] "+message)}function warn(condition,message){condition||"undefined"!=typeof console&&console.warn("[vue-router] "+message)}function isError(err){return Object.prototype.toString.call(err).indexOf("Error")>-1}var View={name:"router-view",functional:!0,props:{name:{type:String,default:"default"}},render:function(_,ref){var props=ref.props,children=ref.children,parent=ref.parent,data=ref.data;data.routerView=!0;for(var h=parent.$createElement,name=props.name,route=parent.$route,cache=parent._routerViewCache||(parent._routerViewCache={}),depth=0,inactive=!1;parent&&parent._routerRoot!==parent;)parent.$vnode&&parent.$vnode.data.routerView&&depth++,parent._inactive&&(inactive=!0),parent=parent.$parent;if(data.routerViewDepth=depth,inactive)return h(cache[name],data,children);var matched=route.matched[depth];if(!matched)return cache[name]=null,h();var component=cache[name]=matched.components[name];data.registerRouteInstance=function(vm,val){var current=matched.instances[name];(val&¤t!==vm||!val&¤t===vm)&&(matched.instances[name]=val)},(data.hook||(data.hook={})).prepatch=function(_,vnode){matched.instances[name]=vnode.componentInstance};var propsToPass=data.props=function(route,config){switch(typeof config){case"undefined":return;case"object":return config;case"function":return config(route);case"boolean":return config?route.params:void 0;default:warn(!1,'props in "'+route.path+'" is a '+typeof config+", expecting an object, function or boolean.")}}(route,matched.props&&matched.props[name]);if(propsToPass){propsToPass=data.props=function(to,from){for(var key in from)to[key]=from[key];return to}({},propsToPass);var attrs=data.attrs=data.attrs||{};for(var key in propsToPass)component.props&&key in component.props||(attrs[key]=propsToPass[key],delete propsToPass[key])}return h(component,data,children)}};var encodeReserveRE=/[!'()*]/g,encodeReserveReplacer=function(c){return"%"+c.charCodeAt(0).toString(16)},commaRE=/%2C/g,encode=function(str){return encodeURIComponent(str).replace(encodeReserveRE,encodeReserveReplacer).replace(commaRE,",")},decode=decodeURIComponent;function parseQuery(query){var res={};return(query=query.trim().replace(/^(\?|#|&)/,""))?(query.split("&").forEach(function(param){var parts=param.replace(/\+/g," ").split("="),key=decode(parts.shift()),val=parts.length>0?decode(parts.join("=")):null;void 0===res[key]?res[key]=val:Array.isArray(res[key])?res[key].push(val):res[key]=[res[key],val]}),res):res}function stringifyQuery(obj){var res=obj?Object.keys(obj).map(function(key){var val=obj[key];if(void 0===val)return"";if(null===val)return encode(key);if(Array.isArray(val)){var result=[];return val.forEach(function(val2){void 0!==val2&&(null===val2?result.push(encode(key)):result.push(encode(key)+"="+encode(val2)))}),result.join("&")}return encode(key)+"="+encode(val)}).filter(function(x){return x.length>0}).join("&"):null;return res?"?"+res:""}var trailingSlashRE=/\/?$/;function createRoute(record,location,redirectedFrom,router){var stringifyQuery$$1=router&&router.options.stringifyQuery,query=location.query||{};try{query=clone(query)}catch(e){}var route={name:location.name||record&&record.name,meta:record&&record.meta||{},path:location.path||"/",hash:location.hash||"",query:query,params:location.params||{},fullPath:getFullPath(location,stringifyQuery$$1),matched:record?function(record){var res=[];for(;record;)res.unshift(record),record=record.parent;return res}(record):[]};return redirectedFrom&&(route.redirectedFrom=getFullPath(redirectedFrom,stringifyQuery$$1)),Object.freeze(route)}function clone(value){if(Array.isArray(value))return value.map(clone);if(value&&"object"==typeof value){var res={};for(var key in value)res[key]=clone(value[key]);return res}return value}var START=createRoute(null,{path:"/"});function getFullPath(ref,_stringifyQuery){var path=ref.path,query=ref.query;void 0===query&&(query={});var hash=ref.hash;return void 0===hash&&(hash=""),(path||"/")+(_stringifyQuery||stringifyQuery)(query)+hash}function isSameRoute(a,b){return b===START?a===b:!!b&&(a.path&&b.path?a.path.replace(trailingSlashRE,"")===b.path.replace(trailingSlashRE,"")&&a.hash===b.hash&&isObjectEqual(a.query,b.query):!(!a.name||!b.name)&&(a.name===b.name&&a.hash===b.hash&&isObjectEqual(a.query,b.query)&&isObjectEqual(a.params,b.params)))}function isObjectEqual(a,b){if(void 0===a&&(a={}),void 0===b&&(b={}),!a||!b)return a===b;var aKeys=Object.keys(a),bKeys=Object.keys(b);return aKeys.length===bKeys.length&&aKeys.every(function(key){var aVal=a[key],bVal=b[key];return"object"==typeof aVal&&"object"==typeof bVal?isObjectEqual(aVal,bVal):String(aVal)===String(bVal)})}var _Vue,toTypes=[String,Object],eventTypes=[String,Array],Link={name:"router-link",props:{to:{type:toTypes,required:!0},tag:{type:String,default:"a"},exact:Boolean,append:Boolean,replace:Boolean,activeClass:String,exactActiveClass:String,event:{type:eventTypes,default:"click"}},render:function(h){var this$1=this,router=this.$router,current=this.$route,ref=router.resolve(this.to,current,this.append),location=ref.location,route=ref.route,href=ref.href,classes={},globalActiveClass=router.options.linkActiveClass,globalExactActiveClass=router.options.linkExactActiveClass,activeClassFallback=null==globalActiveClass?"router-link-active":globalActiveClass,exactActiveClassFallback=null==globalExactActiveClass?"router-link-exact-active":globalExactActiveClass,activeClass=null==this.activeClass?activeClassFallback:this.activeClass,exactActiveClass=null==this.exactActiveClass?exactActiveClassFallback:this.exactActiveClass,compareTarget=location.path?createRoute(null,location,null,router):route;classes[exactActiveClass]=isSameRoute(current,compareTarget),classes[activeClass]=this.exact?classes[exactActiveClass]:function(current,target){return 0===current.path.replace(trailingSlashRE,"/").indexOf(target.path.replace(trailingSlashRE,"/"))&&(!target.hash||current.hash===target.hash)&&function(current,target){for(var key in target)if(!(key in current))return!1;return!0}(current.query,target.query)}(current,compareTarget);var handler=function(e){guardEvent(e)&&(this$1.replace?router.replace(location):router.push(location))},on={click:guardEvent};Array.isArray(this.event)?this.event.forEach(function(e){on[e]=handler}):on[this.event]=handler;var data={class:classes};if("a"===this.tag)data.on=on,data.attrs={href:href};else{var a=function findAnchor(children){if(children)for(var child,i=0;i=0&&(hash=path.slice(hashIndex),path=path.slice(0,hashIndex));var queryIndex=path.indexOf("?");return queryIndex>=0&&(query=path.slice(queryIndex+1),path=path.slice(0,queryIndex)),{path:path,query:query,hash:hash}}(next.path||""),basePath=current&¤t.path||"/",path=parsedPath.path?resolvePath(parsedPath.path,basePath,append||next.append):basePath,query=function(query,extraQuery,_parseQuery){void 0===extraQuery&&(extraQuery={});var parsedQuery,parse=_parseQuery||parseQuery;try{parsedQuery=parse(query||"")}catch(e){warn(!1,e.message),parsedQuery={}}for(var key in extraQuery)parsedQuery[key]=extraQuery[key];return parsedQuery}(parsedPath.query,next.query,router&&router.options.parseQuery),hash=next.hash||parsedPath.hash;return hash&&"#"!==hash.charAt(0)&&(hash="#"+hash),{_normalized:!0,path:path,query:query,hash:hash}}function assign(a,b){for(var key in b)a[key]=b[key];return a}function createMatcher(routes,router){var ref=createRouteMap(routes),pathList=ref.pathList,pathMap=ref.pathMap,nameMap=ref.nameMap;function match(raw,currentRoute,redirectedFrom){var location=normalizeLocation(raw,currentRoute,!1,router),name=location.name;if(name){var record=nameMap[name];if(warn(record,"Route with name '"+name+"' does not exist"),!record)return _createRoute(null,location);var paramNames=record.regex.keys.filter(function(key){return!key.optional}).map(function(key){return key.name});if("object"!=typeof location.params&&(location.params={}),currentRoute&&"object"==typeof currentRoute.params)for(var key in currentRoute.params)!(key in location.params)&¶mNames.indexOf(key)>-1&&(location.params[key]=currentRoute.params[key]);if(record)return location.path=fillParams(record.path,location.params,'named route "'+name+'"'),_createRoute(record,location,redirectedFrom)}else if(location.path){location.params={};for(var i=0;i=queue.length?cb():queue[index]?fn(queue[index],function(){step(index+1)}):step(index+1)};step(0)}function resolveAsyncComponents(matched){return function(to,from,next){var hasAsync=!1,pending=0,error=null;flatMapComponents(matched,function(def,_,match,key){if("function"==typeof def&&void 0===def.cid){hasAsync=!0,pending++;var res,resolve=once(function(resolvedDef){var obj;((obj=resolvedDef).__esModule||hasSymbol&&"Module"===obj[Symbol.toStringTag])&&(resolvedDef=resolvedDef.default),def.resolved="function"==typeof resolvedDef?resolvedDef:_Vue.extend(resolvedDef),match.components[key]=resolvedDef,--pending<=0&&next()}),reject=once(function(reason){var msg="Failed to resolve async component "+key+": "+reason;warn(!1,msg),error||(error=isError(reason)?reason:new Error(msg),next(error))});try{res=def(resolve,reject)}catch(e){reject(e)}if(res)if("function"==typeof res.then)res.then(resolve,reject);else{var comp=res.component;comp&&"function"==typeof comp.then&&comp.then(resolve,reject)}}}),hasAsync||next()}}function flatMapComponents(matched,fn){return flatten(matched.map(function(m){return Object.keys(m.components).map(function(key){return fn(m.components[key],m.instances[key],m,key)})}))}function flatten(arr){return Array.prototype.concat.apply([],arr)}var hasSymbol="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;function once(fn){var called=!1;return function(){for(var args=[],len=arguments.length;len--;)args[len]=arguments[len];if(!called)return called=!0,fn.apply(this,args)}}var History=function(router,base){this.router=router,this.base=function(base){if(!base)if(inBrowser){var baseEl=document.querySelector("base");base=(base=baseEl&&baseEl.getAttribute("href")||"/").replace(/^https?:\/\/[^\/]+/,"")}else base="/";"/"!==base.charAt(0)&&(base="/"+base);return base.replace(/\/$/,"")}(base),this.current=START,this.pending=null,this.ready=!1,this.readyCbs=[],this.readyErrorCbs=[],this.errorCbs=[]};function extractGuards(records,name,bind,reverse){var guards=flatMapComponents(records,function(def,instance,match,key){var guard=function(def,key){"function"!=typeof def&&(def=_Vue.extend(def));return def.options[key]}(def,name);if(guard)return Array.isArray(guard)?guard.map(function(guard){return bind(guard,instance,match,key)}):bind(guard,instance,match,key)});return flatten(reverse?guards.reverse():guards)}function bindGuard(guard,instance){if(instance)return function(){return guard.apply(instance,arguments)}}History.prototype.listen=function(cb){this.cb=cb},History.prototype.onReady=function(cb,errorCb){this.ready?cb():(this.readyCbs.push(cb),errorCb&&this.readyErrorCbs.push(errorCb))},History.prototype.onError=function(errorCb){this.errorCbs.push(errorCb)},History.prototype.transitionTo=function(location,onComplete,onAbort){var this$1=this,route=this.router.match(location,this.current);this.confirmTransition(route,function(){this$1.updateRoute(route),onComplete&&onComplete(route),this$1.ensureURL(),this$1.ready||(this$1.ready=!0,this$1.readyCbs.forEach(function(cb){cb(route)}))},function(err){onAbort&&onAbort(err),err&&!this$1.ready&&(this$1.ready=!0,this$1.readyErrorCbs.forEach(function(cb){cb(err)}))})},History.prototype.confirmTransition=function(route,onComplete,onAbort){var this$1=this,current=this.current,abort=function(err){isError(err)&&(this$1.errorCbs.length?this$1.errorCbs.forEach(function(cb){cb(err)}):(warn(!1,"uncaught error during route navigation:"),console.error(err))),onAbort&&onAbort(err)};if(isSameRoute(route,current)&&route.matched.length===current.matched.length)return this.ensureURL(),abort();var ref=function(current,next){var i,max=Math.max(current.length,next.length);for(i=0;i=0?href.slice(0,i):href)+"#"+path}function pushHash(path){supportsPushState?pushState(getUrl(path)):window.location.hash=path}function replaceHash(path){supportsPushState?replaceState(getUrl(path)):window.location.replace(getUrl(path))}var AbstractHistory=function(History$$1){function AbstractHistory(router,base){History$$1.call(this,router,base),this.stack=[],this.index=-1}return History$$1&&(AbstractHistory.__proto__=History$$1),AbstractHistory.prototype=Object.create(History$$1&&History$$1.prototype),AbstractHistory.prototype.constructor=AbstractHistory,AbstractHistory.prototype.push=function(location,onComplete,onAbort){var this$1=this;this.transitionTo(location,function(route){this$1.stack=this$1.stack.slice(0,this$1.index+1).concat(route),this$1.index++,onComplete&&onComplete(route)},onAbort)},AbstractHistory.prototype.replace=function(location,onComplete,onAbort){var this$1=this;this.transitionTo(location,function(route){this$1.stack=this$1.stack.slice(0,this$1.index).concat(route),onComplete&&onComplete(route)},onAbort)},AbstractHistory.prototype.go=function(n){var this$1=this,targetIndex=this.index+n;if(!(targetIndex<0||targetIndex>=this.stack.length)){var route=this.stack[targetIndex];this.confirmTransition(route,function(){this$1.index=targetIndex,this$1.updateRoute(route)})}},AbstractHistory.prototype.getCurrentLocation=function(){var current=this.stack[this.stack.length-1];return current?current.fullPath:"/"},AbstractHistory.prototype.ensureURL=function(){},AbstractHistory}(History),VueRouter=function(options){void 0===options&&(options={}),this.app=null,this.apps=[],this.options=options,this.beforeHooks=[],this.resolveHooks=[],this.afterHooks=[],this.matcher=createMatcher(options.routes||[],this);var mode=options.mode||"hash";switch(this.fallback="history"===mode&&!supportsPushState&&!1!==options.fallback,this.fallback&&(mode="hash"),inBrowser||(mode="abstract"),this.mode=mode,mode){case"history":this.history=new HTML5History(this,options.base);break;case"hash":this.history=new HashHistory(this,options.base,this.fallback);break;case"abstract":this.history=new AbstractHistory(this,options.base);break;default:assert(!1,"invalid mode: "+mode)}},prototypeAccessors={currentRoute:{configurable:!0}};function registerHook(list,fn){return list.push(fn),function(){var i=list.indexOf(fn);i>-1&&list.splice(i,1)}}return VueRouter.prototype.match=function(raw,current,redirectedFrom){return this.matcher.match(raw,current,redirectedFrom)},prototypeAccessors.currentRoute.get=function(){return this.history&&this.history.current},VueRouter.prototype.init=function(app){var this$1=this;if(assert(install.installed,"not installed. Make sure to call `Vue.use(VueRouter)` before creating root instance."),this.apps.push(app),!this.app){this.app=app;var history=this.history;if(history instanceof HTML5History)history.transitionTo(history.getCurrentLocation());else if(history instanceof HashHistory){var setupHashListener=function(){history.setupListeners()};history.transitionTo(history.getCurrentLocation(),setupHashListener,setupHashListener)}history.listen(function(route){this$1.apps.forEach(function(app){app._route=route})})}},VueRouter.prototype.beforeEach=function(fn){return registerHook(this.beforeHooks,fn)},VueRouter.prototype.beforeResolve=function(fn){return registerHook(this.resolveHooks,fn)},VueRouter.prototype.afterEach=function(fn){return registerHook(this.afterHooks,fn)},VueRouter.prototype.onReady=function(cb,errorCb){this.history.onReady(cb,errorCb)},VueRouter.prototype.onError=function(errorCb){this.history.onError(errorCb)},VueRouter.prototype.push=function(location,onComplete,onAbort){this.history.push(location,onComplete,onAbort)},VueRouter.prototype.replace=function(location,onComplete,onAbort){this.history.replace(location,onComplete,onAbort)},VueRouter.prototype.go=function(n){this.history.go(n)},VueRouter.prototype.back=function(){this.go(-1)},VueRouter.prototype.forward=function(){this.go(1)},VueRouter.prototype.getMatchedComponents=function(to){var route=to?to.matched?to:this.resolve(to).route:this.currentRoute;return route?[].concat.apply([],route.matched.map(function(m){return Object.keys(m.components).map(function(key){return m.components[key]})})):[]},VueRouter.prototype.resolve=function(to,current,append){var location=normalizeLocation(to,current||this.history.current,append,this),route=this.match(location,current),fullPath=route.redirectedFrom||route.fullPath;return{location:location,route:route,href:function(base,fullPath,mode){var path="hash"===mode?"#"+fullPath:fullPath;return base?cleanPath(base+"/"+path):path}(this.history.base,fullPath,this.mode),normalizedTo:location,resolved:route}},VueRouter.prototype.addRoutes=function(routes){this.matcher.addRoutes(routes),this.history.current!==START&&this.history.transitionTo(this.history.getCurrentLocation())},Object.defineProperties(VueRouter.prototype,prototypeAccessors),VueRouter.install=install,VueRouter.version="3.0.1",inBrowser&&window.Vue&&window.Vue.use(VueRouter),VueRouter}); \ No newline at end of file diff --git a/dist/js/app.js b/dist/js/app.js new file mode 100644 index 0000000..f20a09d --- /dev/null +++ b/dist/js/app.js @@ -0,0 +1 @@ +const carritoUsuario=[];window.addEventListener("hashchange",()=>{render(decodeURI(window.location.hash))});const render=e=>{switch(e){case"#registro":abrirRegistro();break;case"#iniciar-sesion":abrirInicioSesion();break;case"#usuarios/":abrirUsuarios();break;case"#usuarios/mi-cuenta":abrirMiCuenta();break;case"#usuarios/pagos":abrirCarrito();break;case"#staff/":abrirStaff();break;default:return void abrirPagPrin()}},sectionP=document.getElementById("sectionP"),contenedorInicioRegistro=document.getElementById("contenedorInicio-Registro"),formInicioRegistro=document.getElementById("inicio_registro"),sectionS=document.getElementById("sectionS"),sectionCarrito=document.getElementById("sectionCarrito"),manipularTopBar=e=>{switch(e){case 1:cambiarProgreso(25);break;case 2:cancelarTransicion(),cambiarProgreso(50);break;case 3:cancelarTransicion(),cambiarProgreso(75);break;default:cancelarTransicion(),reiniciarTopBar()}},abrirUsuarios=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(formInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{200===e.status&&4===e.readyState?(cambiarProgreso(100).then(ocultarTopBar),abrirElemF(sectionS,()=>{sectionS.innerHTML=e.responseText,(()=>new Promise((e,t)=>{const r=new XMLHttpRequest;r.onreadystatechange=(()=>{if(200===r.status&&4===r.readyState){const t=JSON.parse(r.responseText),n=document.getElementById("productos");let a=document.createElement("div");a.className="row";let i=0;for(const e in t)if(t.hasOwnProperty(e)){const r=t[e];++i>=4&&(n.appendChild(a),n.appendChild(document.createElement("br")),(a=document.createElement("div")).className="row",i=1);const o=document.createElement("div");o.className="col-4 caja plato";const s=document.createElement("img");s.className="image",s.src=r.imgUrl,o.appendChild(s);const c=document.createElement("div");c.className="plato--Titulo",c.innerText=r.nombre,o.appendChild(c),o.appendChild(document.createElement("br"));const d=document.createElement("div");d.className="plato--Descripcion",d.innerText=r.descripcion,o.appendChild(d),o.appendChild(document.createElement("br"));const l=document.createElement("div");l.className="plato--Precio",l.innerText=`${r.precio}`,o.appendChild(l);const p=document.createElement("div");p.className="plato--Cantidad",p.appendChild(document.createTextNode("Cantidad: "));const m=document.createElement("span"),u=document.createElement("i");u.className="material-icons plato--Cantidad--Icon",u.innerText="remove",u.addEventListener("click",()=>{const e=parseInt(m.innerText);m.innerText=e>1?e-1:"1"}),p.appendChild(u),m.innerText="1",p.appendChild(m);const h=document.createElement("i");h.className="material-icons plato--Cantidad--Icon",h.innerText="add",h.addEventListener("click",()=>{const e=parseInt(m.innerText);m.innerText=e>0?e+1:"1"}),p.appendChild(h),o.appendChild(p),o.appendChild(document.createElement("br"));const E=document.createElement("button");E.className="botonAddCart",E.addEventListener("click",()=>{const r=parseInt(m.innerText);if(r>0){const n=t[e];n.cantidad=r,carritoUsuario.push(n),console.log(`JSON del usuario|>\n${JSON.stringify(carritoUsuario)}`),window.location.replace("./#usuarios/pagos")}else alert("")}),E.innerHTML="add_shopping_cart Añadir al carrito",o.appendChild(E),a.appendChild(o)}n.appendChild(a),e()}}),r.open("POST","./usuarios/platos.json",!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send()}))()})):manipularTopBar(e.readyState)}),e.open("POST","./usuarios/index.php",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirMiCuenta=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(formInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{200===e.status&&4===e.readyState?(cambiarProgreso(100).then(ocultarTopBar),abrirElemF(sectionS,()=>{sectionS.innerHTML=e.responseText})):manipularTopBar(e.readyState)}),e.open("POST","./usuarios/mi-cuenta.php",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirCarrito=()=>{reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(formInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionS),abrirElemF(sectionCarrito)},abrirStaff=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(formInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{200===e.status&&4===e.readyState?(cambiarProgreso(100).then(ocultarTopBar),abrirElemF(sectionS,()=>{sectionS.innerHTML=e.responseText})):manipularTopBar(e.readyState)}),e.open("POST","./staff/",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirInicioSesion=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{if(200===e.status&&4===e.readyState){cambiarProgreso(100).then(ocultarTopBar);const t=document.getElementById("inicio_registro");abrirElemF(t,()=>{t.innerHTML=e.responseText})}else manipularTopBar(e.readyState)}),e.open("POST","./iniciar-sesion.php",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirRegistro=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{if(200===e.status&&4===e.readyState){cambiarProgreso(100).then(ocultarTopBar);const t=document.getElementById("inicio_registro");abrirElemF(t,()=>{t.innerHTML=e.responseText})}else manipularTopBar(e.readyState)}),e.open("POST","./registro.php",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirPagPrin=()=>{const e=document.getElementById("inicio_registro");cerrarElemF(e,()=>e.innerHTML=""),cerrarElemF(sectionS,()=>sectionS.innerHTML=""),cerrarElemF(sectionCarrito),abrirElemF(contenedorInicioRegistro),abrirElemF(sectionP)},collapseSection=e=>new Promise((t,r)=>{let n=e.scrollHeight,a=e.style.transition;e.style.transition="",requestAnimationFrame(function(){e.style.height=n+"px",e.style.transition=a,requestAnimationFrame(function(){e.style.height="0px",setTimeout(()=>{t("Termine de ocultar we v':")},160)})}),e.setAttribute("data-collapsed","true")}),expandSection=e=>new Promise((t,r)=>{let n=e.scrollHeight;e.style.height=n+"px",e.addEventListener("transitionend",function(r){e.removeEventListener("transitionend",arguments.callee),e.style.height=null,setTimeout(()=>{t("Termine de ampliar we v':")},0)}),e.setAttribute("data-collapsed","false")}),abrirElemF=(e,t,r)=>{"true"===e.getAttribute("data-collapsed")?(void 0!==t&&t(),expandSection(e).then(()=>{void 0!==r&&r()})):collapseSection(e).then(()=>{void 0!==t&&t(),expandSection(e).then(()=>{void 0!==r&&r()})})},cerrarElemF=(e,t)=>{"false"===e.getAttribute("data-collapsed")&&collapseSection(e).then(()=>{void 0!==t&&t()})};render(decodeURI(window.location.hash));const carrito=new Vue({el:"#carrito",data:{item:carritoUsuario,descuento:0},computed:{cantidadItems:function(){let e=0;for(const t in this.item)e++;return e},subTotal:function(){let e=0;for(const t in this.item)if(this.item.hasOwnProperty(t)){const r=this.item[t];e+=r.precio*r.cantidad}return e},total:function(){return this.subTotal-this.descuento},noEstaVacio:function(){for(const e in this.item)return!0;return!1}},methods:{restarCantidad:function(e){const t=parseInt(e.cantidad);t>0&&(e.cantidad=t-1)},aumentarCantidad:function(e){const t=parseInt(e.cantidad);t>=0&&(e.cantidad=t+1)}}}),topBar=document.createElement("div");topBar.style.position="fixed",topBar.style.minHeight="3px",topBar.style.backgroundColor="red",topBar.style.zIndex="1";const transitionD=500;topBar.style.transition="min-width 500ms, opacity 250ms",topBar.style.minWidth="0";let promesaActual,widthDestino=0;document.body.appendChild(topBar);const cambiarProgreso=e=>(widthDestino=e,promesaActual=new Promise((t,r)=>{topBar.style.minWidth=`${e}%`,setTimeout(()=>t(),500)})),cancelarTransicion=()=>{const e=topBar.style.transition;topBar.style.transition="",topBar.style.minWidth=`${widthDestino}%`,topBar.style.transition=e},ocultarTopBar=()=>{topBar.style.opacity="0",setTimeout(()=>{topBar.style.minWidth="0%"},250)},reiniciarTopBar=()=>{const e=topBar.style.transition;topBar.style.transition="",topBar.style.minWidth="0",topBar.style.opacity="1",topBar.style.transition=e}; \ No newline at end of file diff --git a/dist/js/base.min.js b/dist/js/base.min.js new file mode 100644 index 0000000..53b62db --- /dev/null +++ b/dist/js/base.min.js @@ -0,0 +1 @@ +carritoUsuario=[];window.addEventListener("hashchange",()=>{render(decodeURI(window.location.hash))});const render=e=>{switch(e){case"#registro":abrirRegistro();break;case"#iniciar-sesion":abrirInicioSesion();break;case"#usuarios/":abrirUsuarios();break;case"#usuarios/mi-cuenta":abrirMiCuenta();break;case"#usuarios/pagos":abrirCarrito();break;case"#staff/":abrirStaff();break;default:return void abrirPagPrin()}},sectionP=document.getElementById("sectionP"),contenedorInicioRegistro=document.getElementById("contenedorInicio-Registro"),formInicioRegistro=document.getElementById("inicio_registro"),sectionS=document.getElementById("sectionS"),sectionCarrito=document.getElementById("sectionCarrito"),manipularTopBar=e=>{switch(e){case 1:cambiarProgreso(25);break;case 2:cancelarTransicion(),cambiarProgreso(50);break;case 3:cancelarTransicion(),cambiarProgreso(75);break;default:cancelarTransicion(),reiniciarTopBar()}},abrirUsuarios=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(formInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{200===e.status&&4===e.readyState?(cambiarProgreso(100).then(ocultarTopBar),abrirElemF(sectionS,()=>{sectionS.innerHTML=e.responseText,(()=>new Promise((e,t)=>{const r=new XMLHttpRequest;r.onreadystatechange=(()=>{if(200===r.status&&4===r.readyState){const t=JSON.parse(r.responseText),n=document.getElementById("productos");let a=document.createElement("div");a.className="row";let i=0;for(const e in t)if(t.hasOwnProperty(e)){const r=t[e];++i>=4&&(n.appendChild(a),n.appendChild(document.createElement("br")),(a=document.createElement("div")).className="row",i=1);const o=document.createElement("div");o.className="col-4 caja plato";const c=document.createElement("img");c.className="image",c.src=r.imgUrl,o.appendChild(c);const s=document.createElement("div");s.className="plato--Titulo",s.innerText=r.nombre,o.appendChild(s),o.appendChild(document.createElement("br"));const d=document.createElement("div");d.className="plato--Descripcion",d.innerText=r.descripcion,o.appendChild(d),o.appendChild(document.createElement("br"));const l=document.createElement("div");l.className="plato--Precio",l.innerText=`${r.precio}`,o.appendChild(l);const m=document.createElement("div");m.className="plato--Cantidad",m.appendChild(document.createTextNode("Cantidad: "));const p=document.createElement("span"),u=document.createElement("i");u.className="material-icons plato--Cantidad--Icon",u.innerText="remove",u.addEventListener("click",()=>{const e=parseInt(p.innerText);p.innerText=e>1?e-1:"1"}),m.appendChild(u),p.innerText="1",m.appendChild(p);const h=document.createElement("i");h.className="material-icons plato--Cantidad--Icon",h.innerText="add",h.addEventListener("click",()=>{const e=parseInt(p.innerText);p.innerText=e>0?e+1:"1"}),m.appendChild(h),o.appendChild(m),o.appendChild(document.createElement("br"));const E=document.createElement("button");E.className="botonAddCart",E.addEventListener("click",()=>{const r=parseInt(p.innerText);if(r>0){const n=t[e];n.cantidad=r,carritoUsuario.push(n),console.log(`JSON del usuario|>\n${JSON.stringify(carritoUsuario)}`),window.location.replace("./#usuarios/pagos")}else alert("")}),E.innerHTML="add_shopping_cart Añadir al carrito",o.appendChild(E),a.appendChild(o)}n.appendChild(a),e()}}),r.open("POST","./usuarios/platos.json",!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send()}))()})):manipularTopBar(e.readyState)}),e.open("POST","./usuarios/index.php",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirMiCuenta=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(formInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{200===e.status&&4===e.readyState?(cambiarProgreso(100).then(ocultarTopBar),abrirElemF(sectionS,()=>{sectionS.innerHTML=e.responseText})):manipularTopBar(e.readyState)}),e.open("POST","./usuarios/mi-cuenta.php",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirCarrito=()=>{reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(formInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionS),abrirElemF(sectionCarrito)},abrirStaff=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(formInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{200===e.status&&4===e.readyState?(cambiarProgreso(100).then(ocultarTopBar),abrirElemF(sectionS,()=>{sectionS.innerHTML=e.responseText})):manipularTopBar(e.readyState)}),e.open("POST","./staff/",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirInicioSesion=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{if(200===e.status&&4===e.readyState){cambiarProgreso(100).then(ocultarTopBar);const t=document.getElementById("inicio_registro");abrirElemF(t,()=>{t.innerHTML=e.responseText})}else manipularTopBar(e.readyState)}),e.open("POST","./iniciar-sesion.php",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirRegistro=()=>{const e=new XMLHttpRequest;reiniciarTopBar(),cerrarElemF(contenedorInicioRegistro),cerrarElemF(sectionP),cerrarElemF(sectionCarrito),e.onreadystatechange=(()=>{if(200===e.status&&4===e.readyState){cambiarProgreso(100).then(ocultarTopBar);const t=document.getElementById("inicio_registro");abrirElemF(t,()=>{t.innerHTML=e.responseText})}else manipularTopBar(e.readyState)}),e.open("POST","./registro.php",!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.send()},abrirPagPrin=()=>{const e=document.getElementById("inicio_registro");cerrarElemF(e,()=>e.innerHTML=""),cerrarElemF(sectionS,()=>sectionS.innerHTML=""),cerrarElemF(sectionCarrito),abrirElemF(contenedorInicioRegistro),abrirElemF(sectionP)},collapseSection=e=>new Promise((t,r)=>{let n=e.scrollHeight,a=e.style.transition;e.style.transition="",requestAnimationFrame(function(){e.style.height=n+"px",e.style.transition=a,requestAnimationFrame(function(){e.style.height="0px",setTimeout(()=>{t("Termine de ocultar we v':")},160)})}),e.setAttribute("data-collapsed","true")}),expandSection=e=>new Promise((t,r)=>{let n=e.scrollHeight;e.style.height=n+"px",e.addEventListener("transitionend",function(r){e.removeEventListener("transitionend",arguments.callee),e.style.height=null,setTimeout(()=>{t("Termine de ampliar we v':")},0)}),e.setAttribute("data-collapsed","false")}),abrirElemF=(e,t,r)=>{"true"===e.getAttribute("data-collapsed")?(void 0!==t&&t(),expandSection(e).then(()=>{void 0!==r&&r()})):collapseSection(e).then(()=>{void 0!==t&&t(),expandSection(e).then(()=>{void 0!==r&&r()})})},cerrarElemF=(e,t)=>{"false"===e.getAttribute("data-collapsed")&&collapseSection(e).then(()=>{void 0!==t&&t()})};render(decodeURI(window.location.hash));const carrito=new Vue({el:"#carrito",data:{item:carritoUsuario,descuento:0},computed:{cantidadItems:function(){let e=0;for(const t in this.item)e++;return e},subTotal:function(){let e=0;for(const t in this.item)if(this.item.hasOwnProperty(t)){const r=this.item[t];e+=r.precio*r.cantidad}return e},total:function(){return this.subTotal-this.descuento},noEstaVacio:function(){for(const e in this.item)return!0;return!1}},methods:{restarCantidad:function(e){const t=parseInt(e.cantidad);t>0&&(e.cantidad=t-1)},aumentarCantidad:function(e){const t=parseInt(e.cantidad);t>=0&&(e.cantidad=t+1)}}}); diff --git a/dist/js/topbar.min.js b/dist/js/topbar.min.js new file mode 100644 index 0000000..7cd51b6 --- /dev/null +++ b/dist/js/topbar.min.js @@ -0,0 +1 @@ +const topBar=document.createElement("div");topBar.style.position="fixed",topBar.style.minHeight="3px",topBar.style.backgroundColor="red",topBar.style.zIndex="1";const transitionD=500;topBar.style.transition="min-width 500ms, opacity 250ms",topBar.style.minWidth="0";let promesaActual,widthDestino=0;document.body.appendChild(topBar);const cambiarProgreso=t=>(widthDestino=t,promesaActual=new Promise((o,i)=>{topBar.style.minWidth=`${t}%`,setTimeout(()=>o(),500)})),cancelarTransicion=()=>{const t=topBar.style.transition;topBar.style.transition="",topBar.style.minWidth=`${widthDestino}%`,topBar.style.transition=t},ocultarTopBar=()=>{topBar.style.opacity="0",setTimeout(()=>{topBar.style.minWidth="0%"},250)},reiniciarTopBar=()=>{const t=topBar.style.transition;topBar.style.transition="",topBar.style.minWidth="0",topBar.style.opacity="1",topBar.style.transition=t}; \ No newline at end of file diff --git a/index.php b/index.php index 1f08fc1..5a27064 100644 --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ Cocina Francesa - + @@ -11,182 +11,119 @@ - + - - - -
-
-
- Plato Francés -
-
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip - ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu - fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia - deserunt mollit anim id est laborum. -
-
-
-
-
-
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et - dolore magna aliqua. Congue quisque egestas diam in arcu cursus euismod quis. Mi tempus imperdiet nulla - malesuada pellentesque elit eget gravida. Tempus imperdiet nulla malesuada pellentesque elit eget - gravida - cum. Commodo elit at imperdiet dui accumsan sit amet. In nulla posuere sollicitudin aliquam ultrices - sagittis. -
-
-
- Plato Francés -
-
-
-
- -
-
- -
-
-
-
-
- Carrito de compras -
-
- Seguir comprando -
-
-
- -
-
- - -
-
- -
- -
- - -
-
-
-
-
-
-
- -
-
- Cocina Francesa.
- Una Single Page Application para el curso de IHC, UNSA, 2018.
- Se utilizaron: Vue.js, BEM, Sass, npm, y PHP.
-
- Desarrollado por Fernando Araoz, 20173373. -
-
- - + - + + + + - + diff --git a/js/Router.js b/js/Router.js deleted file mode 100644 index 1e1d402..0000000 --- a/js/Router.js +++ /dev/null @@ -1,603 +0,0 @@ -/* global window, module */ - -;(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - global.Router = factory() -}(this, (function () { - - /** - * Router - * - * @version: 1.2.7 - * @author Graidenix - * - * @constructor - * - * @param {object} options - * @returns {Router} - */ - function Router(options) { - var settings = this._getSettings(options); - - - this.notFoundHandler = settings.page404; - this.mode = (!window.history || !window.history.pushState) ? "hash" : settings.mode; - this.root = settings.root === "/" ? "/" : "/" + this._trimSlashes(settings.root) + "/"; - this.beforeHook = settings.hooks.before; - this.securityHook = settings.hooks.secure; - - this.routes = []; - if (settings.routes && settings.routes.length > 0) { - var _this = this; - settings.routes.forEach(function (route) { - _this.add(route.rule, route.handler, route.options); - }); - } - - this._pageState = null; - this._currentPage = null; - this._skipCheck = false; - this._action = null; - - if (this.mode === "hash") { - this._historyStack = []; - this._historyIdx = 0; - this._historyState = "add" - } - - return this; - } - - /** - * Define Router Page - * - * @param {string} uri - * @param {object} query - * @param {Array} params - * @param {object} state - * @param {object} options - * - * @constructor - */ - Router.Page = function (uri, query, params, state, options) { - this.uri = uri || ""; - this.query = query || {}; - this.params = params || []; - this.state = state || null; - this.options = options || {}; - }; - - /** - * Sanitize options and add default values - * - * @param {object} options - * @returns {object} - * @private - */ - Router.prototype._getSettings = function (options) { - var settings = {}; - var defaults = { - routes: [], - mode: "history", - root: "/", - hooks: { - "before": function () { - }, - "secure": function () { - return true; - } - }, - page404: function (page) { - console.error({ - page: page, - message: "404. Page not found" - }); - } - }; - - options = options || {}; - ["routes", "mode", "root", "page404"].forEach(function (key) { - settings[key] = options[key] || defaults[key]; - }); - - settings.hooks = Object.assign({}, defaults.hooks, options.hooks || {}); - - return settings; - }; - - /** - * Get URI for Router "history" mode - * - * @private - * @returns {string} - */ - Router.prototype._getHistoryFragment = function () { - var fragment = decodeURI(window.location.pathname); - if (this.root !== "/") { - fragment = fragment.replace(this.root, ""); - } - return this._trimSlashes(fragment); - }; - - /** - * Get URI for router "hash" mode - * - * @private - * @returns {string} - */ - Router.prototype._getHashFragment = function () { - var hash = window.location.hash.substr(1).replace(/(\?.*)$/, ""); - return this._trimSlashes(hash); - }; - - /** - * Get current URI - * - * @private - * @returns {string} - */ - Router.prototype._getFragment = function () { - if (this.mode === "history") { - return this._getHistoryFragment(); - } else { - return this._getHashFragment(); - } - }; - - /** - * Trim slashes for path - * - * @private - * @param {string} path - * @returns {string} - */ - Router.prototype._trimSlashes = function (path) { - if (typeof path !== "string") { - return ""; - } - return path.toString().replace(/\/$/, "").replace(/^\//, ""); - }; - - /** - * 404 Page Handler - * - * @private - */ - Router.prototype._page404 = function (path) { - this._currentPage = new Router.Page(path); - this.notFoundHandler(path); - }; - - /** - * Convert the string route rule to RegExp rule - * - * @param {string} route - * @returns {RegExp} - * @private - */ - Router.prototype._parseRouteRule = function (route) { - if (typeof route !== "string") { - return route; - } - var uri = this._trimSlashes(route); - var rule = uri - .replace(/([\\\/\-\_\.])/g, "\\$1") - .replace(/\{[a-zA-Z]+\}/g, "(:any)") - .replace(/\:any/g, "[\\w\\-\\_\\.]+") - .replace(/\:word/g, "[a-zA-Z]+") - .replace(/\:num/g, "\\d+"); - - return new RegExp("^" + rule + "$", "i"); - }; - - /** - * Parse query string and return object for it - * - * @param {string} query - * @returns {object} - * @private - */ - Router.prototype._parseQuery = function (query) { - var _query = {}; - if (typeof query !== "string") { - return _query; - } - - if (query[0] === "?") { - query = query.substr(1); - } - - this._queryString = query; - query.split("&").forEach(function (row) { - var parts = row.split("="); - if (parts[0] !== "") { - if (parts[1] === undefined) { - parts[1] = true; - } - _query[decodeURIComponent(parts[0])] = parts[1]; - } - }); - return _query; - }; - - /** - * Get query for `history` mode - * - * @returns {Object} - * @private - */ - Router.prototype._getHistoryQuery = function () { - return this._parseQuery(window.location.search); - }; - - /** - * Get query for `hash` mode - * - * @returns {Object} - * @private - */ - Router.prototype._getHashQuery = function () { - var index = window.location.hash.indexOf("?"); - var query = (index !== -1) ? window.location.hash.substr(index) : ""; - return this._parseQuery(query); - }; - - /** - * Get query as object - * - * @private - * @returns {Object} - */ - Router.prototype._getQuery = function () { - if (this.mode === "history") { - return this._getHistoryQuery(); - } else { - return this._getHashQuery(); - } - }; - - /** - * Add route to routes list - * - * @param {string|RegExp} rule - * @param {function} handler - * @param {{}} options - * @returns {Router} - */ - Router.prototype.add = function (rule, handler, options) { - this.routes.push({ - rule: this._parseRouteRule(rule), - handler: handler, - options: options - }); - return this; - }; - - /** - * Remove a route from routes list - * - * @param param - * @returns {Router} - */ - Router.prototype.remove = function (param) { - var _this = this; - if (typeof param === "string") { - param = this._parseRouteRule(param).toString(); - } - this.routes.some(function (route, i) { - if (route.handler === param || route.rule.toString() === param) { - _this.routes.splice(i, 1); - return true; - } - return false; - }); - - return this; - }; - - /** - * Reset the state of Router - * - * @returns {Router} - */ - Router.prototype.reset = function () { - this.routes = []; - this.mode = null; - this.root = "/"; - this._pageState = {}; - this.removeUriListener(); - - return this; - }; - - /** - * Add current page in history stack - * @private - */ - Router.prototype._pushHistory = function () { - var _this = this, - fragment = this._getFragment(); - - if (this.mode === "hash") { - if (this._historyState === "add") { - if (this._historyIdx !== this._historyStack.length - 1) { - this._historyStack.splice(this._historyIdx + 1); - } - - this._historyStack.push({ - path: fragment, - state: _this._pageState - }); - - this._historyIdx = this._historyStack.length - 1; - } - this._historyState = "add"; - } - }; - - /** - * - * @param asyncRequest boolean - * @returns {PromiseResult | boolean} - * @private - */ - Router.prototype._unloadCallback = function (asyncRequest) { - var result; - - if (this._skipCheck) { - return asyncRequest ? Promise.resolve(true) : true; - } - - if (this._currentPage && this._currentPage.options && this._currentPage.options.unloadCb) { - result = this._currentPage.options.unloadCb(this._currentPage, asyncRequest); - if (!asyncRequest || result instanceof Promise) { - return result; - } - return result ? Promise.resolve(result) : Promise.reject(result); - } else { - return asyncRequest ? Promise.resolve(true) : true; - } - }; - - /** - * Check if router has the action for current path - * - * @returns {boolean} - * @private - */ - Router.prototype._findRoute = function () { - var _this = this, - fragment = this._getFragment(); - - return this.routes.some(function (route) { - var match = fragment.match(route.rule); - if (match) { - match.shift(); - var query = _this._getQuery(); - var page = new Router.Page(fragment, query, match, _this._pageState, route.options); - - if (!_this.securityHook(page)) { - return false; - } - - _this._currentPage = page; - if (_this._skipCheck) { - _this._skipCheck = false; - return true; - } - _this.beforeHook(page); - route.handler.apply(page, match); - _this._pageState = null; - - window.onbeforeunload = function (ev) { - if (_this._unloadCallback(false)) { - return; - } - ev.returnValue = true; - return true; - }; - - return true; - } - return false; - }); - }; - - /** - * - */ - Router.prototype._treatAsync = function () { - var result; - - result = this._currentPage.options.unloadCb(this._currentPage, true); - if (!(result instanceof Promise)) { - result = result ? Promise.resolve(result) : Promise.reject(result); - } - - result - .then(this._processUri.bind(this)) - .catch(this._resetState.bind(this)); - }; - - /** - * - * @private - */ - Router.prototype._resetState = function () { - this._skipCheck = true; - this.navigateTo(this._current, this._currentPage.state, true); - }; - - /** - * Replace current page with new one - */ - Router.prototype._processUri = function () { - var fragment = this._getFragment(), - found; - - this._current = fragment; - this._pushHistory(); - - found = this._findRoute.call(this); - if (!found) { - this._page404(fragment); - } - }; - - /** - * Check the URL and execute handler for its route - * - * @returns {Router} - */ - Router.prototype.check = function () { - if (this._skipCheck) return this; - - // if page has unload cb treat as promise - if (this._currentPage && this._currentPage.options && this._currentPage.options.unloadCb) { - this._treatAsync(); - } else { - this._processUri(); - } - return this; - }; - - /** - * Add the URI listener - * - * @returns {Router} - */ - Router.prototype.addUriListener = function () { - if (this.mode === "history") { - window.onpopstate = this.check.bind(this); - } else { - window.onhashchange = this.check.bind(this); - } - - return this; - }; - - /** - * Remove the URI listener - * - * @returns {Router} - */ - Router.prototype.removeUriListener = function () { - window.onpopstate = null; - window.onhashchange = null; - return this; - }; - - /** - * Redirect to a page with replace state - * - * @param {string} path - * @param {object} state - * @param {boolean} silent - * - * @returns {Router} - */ - Router.prototype.redirectTo = function (path, state, silent) { - path = this._trimSlashes(path) || ""; - this._pageState = state || null; - this._skipCheck = !!silent; - - if (this.mode === "history") { - history.replaceState(state, null, this.root + this._trimSlashes(path)); - return this.check(); - } else { - this._historyIdx--; - window.location.hash = path; - } - return this; - }; - - /** - * Navigate to a page - * - * @param {string} path - * @param {object} state - * @param {boolean} silent - * - * @returns {Router} - */ - Router.prototype.navigateTo = function (path, state, silent) { - path = this._trimSlashes(path) || ""; - this._pageState = state || null; - this._skipCheck = !!silent; - - if (this.mode === "history") { - history.pushState(state, null, this.root + this._trimSlashes(path)); - return this.check(); - } else { - window.location.hash = path; - } - return this; - }; - - /** - * Refresh page with recall route handler - * @returns {Router} - */ - Router.prototype.refresh = function () { - if (!this._currentPage) { - return this; - } - var path = this._currentPage.uri + "?" + this._queryString; - return this.navigateTo(path, this._currentPage.state); - }; - - /** - * Go Back in browser history - * Simulate "Back" button - * - * @returns {Router} - */ - Router.prototype.back = function () { - if (this.mode === "history") { - window.history.back(); - return this; - } - - return this.go(this._historyIdx - 1); - }; - - /** - * Go Forward in browser history - * Simulate "Forward" button - * - * @returns {Router} - */ - Router.prototype.forward = function () { - if (this.mode === "history") { - window.history.forward(); - return this; - } - - return this.go(this._historyIdx + 1); - }; - - /** - * Go to a specific history page - * - * @param {number} count - * @returns {Router} - */ - Router.prototype.go = function (count) { - if (this.mode === "history") { - window.history.go(count); - return this; - } - - var page = this._historyStack[count]; - if (!page) { - return this; - } - - this._historyIdx = count; - this._historyState = "hold"; - return this.navigateTo(page.path, page.state); - }; - - return Router; -}))); \ No newline at end of file diff --git a/js/base.js b/js/base.js deleted file mode 100644 index 47668e9..0000000 --- a/js/base.js +++ /dev/null @@ -1,563 +0,0 @@ -let navBar = new Vue({ - el: '#navBar', - data: { - visible: true - } -}); - -const carritoUsuario = []; - -window.addEventListener("hashchange", () => { - render(decodeURI(window.location.hash)); -}); - -const render = url => { - switch (url) { - case "#registro": - abrirRegistro(); - break; - case "#iniciar-sesion": - abrirInicioSesion(); - break; - case "#usuarios/": - abrirUsuarios(); - break; - case "#usuarios/mi-cuenta": - abrirMiCuenta(); - break; - case "#usuarios/pagos": - abrirCarrito(); - break; - case "#staff/": - abrirStaff(); - break; - default: - abrirPagPrin(); - return; - } -}; - -const sectionP = document.getElementById("sectionP"); -const contenedorInicioRegistro = document.getElementById("contenedorInicio-Registro"); -const formInicioRegistro = document.getElementById("inicio_registro"); -const sectionS = document.getElementById("sectionS"); -const sectionCarrito = document.getElementById("sectionCarrito"); - -const manipularTopBar = status => { - switch (status) { - case 1: - cambiarProgreso(25); - break; - case 2: - cancelarTransicion(); - cambiarProgreso(50); - break; - case 3: - cancelarTransicion(); - cambiarProgreso(75); - break; - default: - cancelarTransicion(); - reiniciarTopBar(); - } -}; - -const abrirUsuarios = () => { - - const crearPlatos = () => { - return new Promise((resolve, reject) => { - const ajax = new XMLHttpRequest(); - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - const data = JSON.parse(ajax.responseText); - const divR = document.getElementById("productos"); - - let contenedor = document.createElement("div"); - contenedor.className = "row"; - let contador = 0; - for (const itemI in data) { - if (data.hasOwnProperty(itemI)) { - const item = data[itemI]; - contador++; - if (contador >= 4) { - divR.appendChild(contenedor); - divR.appendChild(document.createElement("br")); - contenedor = document.createElement("div"); - contenedor.className = "row"; - contador = 1; - } - - const itemDiv = document.createElement("div"); - itemDiv.className = "col-4 caja plato"; - - const img = document.createElement("img"); - img.className = "image"; - img.src = item["imgUrl"]; - itemDiv.appendChild(img); - - const nombre = document.createElement("div"); - nombre.className = "plato--Titulo"; - nombre.innerText = item["nombre"]; - itemDiv.appendChild(nombre); - - itemDiv.appendChild(document.createElement("br")); - - const descripcion = document.createElement("div"); - descripcion.className = "plato--Descripcion"; - descripcion.innerText = item["descripcion"]; - itemDiv.appendChild(descripcion); - itemDiv.appendChild(document.createElement("br")); - - const precioUnitario = document.createElement("div"); - precioUnitario.className = "plato--Precio"; - precioUnitario.innerText = `${item["precio"]}`; - itemDiv.appendChild(precioUnitario); - - const cantidad = document.createElement("div"); - cantidad.className = "plato--Cantidad"; - cantidad.appendChild(document.createTextNode("Cantidad: ")); - const unidades = document.createElement("span"); - const botonMenos = document.createElement("i"); - botonMenos.className = "material-icons plato--Cantidad--Icon"; - botonMenos.innerText = "remove"; - botonMenos.addEventListener("click",() => { - const valorActual = parseInt(unidades.innerText); - if (valorActual > 1) { - unidades.innerText = valorActual-1; - } else { - unidades.innerText = "1"; - } - }); - - cantidad.appendChild(botonMenos); - unidades.innerText = "1"; - cantidad.appendChild(unidades); - const botonMas = document.createElement("i"); - botonMas.className = "material-icons plato--Cantidad--Icon"; - botonMas.innerText = "add"; - botonMas.addEventListener("click",() => { - const valorActual = parseInt(unidades.innerText); - if (valorActual > 0) { - unidades.innerText = valorActual+1; - } else { - unidades.innerText = "1"; - } - }); - cantidad.appendChild(botonMas); - - itemDiv.appendChild(cantidad); - itemDiv.appendChild(document.createElement("br")); - - const botonAddCart = document.createElement("button"); - botonAddCart.className = "botonAddCart"; - botonAddCart.addEventListener("click",() => { - const cantidad = parseInt(unidades.innerText); - if (cantidad > 0) { - const item = data[itemI]; - item["cantidad"] = cantidad; - - // carritoUsuario[itemI] = item; - - carritoUsuario.push(item); - console.log(`JSON del usuario|>\n${JSON.stringify(carritoUsuario)}`); - window.location.replace("./#usuarios/pagos"); - } else { - alert(""); - } - }); - botonAddCart.innerHTML = "add_shopping_cart Añadir al carrito"; - itemDiv.appendChild(botonAddCart); - - contenedor.appendChild(itemDiv); - } - } - divR.appendChild(contenedor); - - resolve(); - } - }; - - ajax.open("POST", "./usuarios/platos.json", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); - }); - }; - - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(formInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - abrirElemF(sectionS, () => { - sectionS.innerHTML = ajax.responseText; - crearPlatos(); - }); - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./usuarios/index.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirMiCuenta = () => { - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(formInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - abrirElemF(sectionS, () => { - sectionS.innerHTML = ajax.responseText; - }); - - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./usuarios/mi-cuenta.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirCarrito = () => { - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(formInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionS); - - /* Metodo antiguo - const ajax = new XMLHttpRequest(); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - abrirElemF(sectionCarrito, () => { - sectionCarrito.innerHTML = ajax.responseText; - crearCarrito(); - }); - - sectionCarrito.setAttribute("vacio","false"); - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./usuarios/pagos.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); - */ - - /* Metodo con Vue */ - abrirElemF(sectionCarrito); - -}; - -const abrirStaff = () => { - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(formInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - abrirElemF(sectionS, () => { - sectionS.innerHTML = ajax.responseText; - }); - - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./staff/", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirInicioSesion = () => { - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - const elem = document.getElementById("inicio_registro"); - abrirElemF(elem, () => { - elem.innerHTML = ajax.responseText - }); - - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./iniciar-sesion.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirRegistro = () => { - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - const elem = document.getElementById("inicio_registro"); - abrirElemF(elem, () => { - elem.innerHTML = ajax.responseText - }); - - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./registro.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirPagPrin = () => { - const inicio_registro = document.getElementById("inicio_registro"); - cerrarElemF(inicio_registro, () => inicio_registro.innerHTML = ""); - cerrarElemF(sectionS, () => sectionS.innerHTML = ""); - cerrarElemF(sectionCarrito); - abrirElemF(contenedorInicioRegistro); - abrirElemF(sectionP); -}; - -/* Height Transition by CSS Tricks. Returns a Promise */ -const collapseSection = element => { - return new Promise((resolve, reject) => { - - // get the height of the element's inner content, regardless of its actual size - let sectionHeight = element.scrollHeight; - - // temporarily disable all css transitions - let elementTransition = element.style.transition; - element.style.transition = ''; - - // on the next frame (as soon as the previous style change has taken effect), - // explicitly set the element's height to its current pixel height, so we - // aren't transitioning out of 'auto' - - - requestAnimationFrame(function () { - element.style.height = sectionHeight + 'px'; - element.style.transition = elementTransition; - - // on the next frame (as soon as the previous style change has taken effect), - // have the element transition to height: 0 - requestAnimationFrame(function () { - element.style.height = 0 + 'px'; - setTimeout(() => { - resolve("Termine de ocultar we v':"); - }, 160); - }); - }); - - // mark the section as "currently collapsed" - element.setAttribute('data-collapsed', 'true'); - }); -}; - -const expandSection = element => { - return new Promise((resolve, reject) => { - // get the height of the element's inner content, regardless of its actual size - let sectionHeight = element.scrollHeight; - - // have the element transition to the height of its inner content - element.style.height = sectionHeight + 'px'; - - // when the next css transition finishes (which should be the one we just triggered) - element.addEventListener('transitionend', function (e) { - // remove this event listener so it only gets triggered once - element.removeEventListener('transitionend', arguments.callee); - - // remove "height" from the element's inline styles, so it can return to its initial value - element.style.height = null; - setTimeout(() => { - resolve("Termine de ampliar we v':"); - }, 0); - }); - - // mark the section as "currently not collapsed" - element.setAttribute('data-collapsed', 'false'); - }); -}; - -const abrirElemF = (element, midF, postF) => { - if (element.getAttribute("data-collapsed") === "true") { - if (midF !== undefined) - midF(); - expandSection(element).then(() => { - if (postF !== undefined) - postF(); - }); - } else { - collapseSection(element).then(() => { - if (midF !== undefined) - midF(); - expandSection(element).then(() => { - if (postF !== undefined) - postF(); - }); - }); - } -}; - -const cerrarElemF = (element, postF) => { - if (element.getAttribute("data-collapsed") === "false") { - collapseSection(element).then(() => { - if (postF !== undefined) - postF(); - }); - } -}; - -render(decodeURI(window.location.hash)); - - -const carrito = new Vue({ - el: "#carrito", - data: { - item: carritoUsuario, - descuento: 0 - }, - computed: { - cantidadItems: function () { - let items = 0; - for (const i in this.item) - items++; - return items; - }, - subTotal: function () { - let subT = 0; - for (const itemI in this.item ) { - if (this.item.hasOwnProperty(itemI)){ - const item = this.item[itemI]; - subT += (item["precio"] * item["cantidad"]); - } - } - return subT; - }, - total: function () { - return this.subTotal - this.descuento; - }, - noEstaVacio: function () { - for (const i in this.item) { - return true; - } - return false; - }, - }, - methods: { - restarCantidad: function (elem) { - const cantidad = parseInt(elem.cantidad); - if (cantidad > 0) - elem.cantidad = cantidad -1; - }, - aumentarCantidad: function (elem) { - const cantidad = parseInt(elem.cantidad); - if (cantidad >= 0) - elem.cantidad = cantidad+1; - } - } -}); - -/* Metodo con Antiguo -const crearCarrito = () => { - carrito = new Vue({ - el: "#carrito", - data: { - item: carritoUsuario, - descuento: 0 - }, - computed: { - cantidadItems: function () { - let items = 0; - for (const i in this.item) - items++; - return items; - }, - subTotal: function () { - let subT = 0; - for (const itemI in this.item ) { - if (this.item.hasOwnProperty(itemI)){ - const item = this.item[itemI]; - subT += (item["precio"] * item["cantidad"]); - } - } - return subT; - }, - total: function () { - return this.subTotal - this.descuento; - }, - noEstaVacio: function () { - for (const i in this.item) { - return true; - } - return false; - }, - }, - methods: { - restarCantidad: function (elem) { - const cantidad = parseInt(elem.cantidad); - if (cantidad > 0) - elem.cantidad = cantidad -1; - }, - aumentarCantidad: function (elem) { - const cantidad = parseInt(elem.cantidad); - if (cantidad >= 0) - elem.cantidad = cantidad+1; - } - } - }); -}; -*/ - - diff --git a/js/topbar.js b/js/topbar.js deleted file mode 100644 index a6b170b..0000000 --- a/js/topbar.js +++ /dev/null @@ -1,46 +0,0 @@ -const topBar = document.createElement("div"); -topBar.style.position = "fixed"; -topBar.style.minHeight = "3px"; -topBar.style.backgroundColor = "red"; -topBar.style.zIndex = "1"; - -const transitionD = 500; -topBar.style.transition = `min-width ${transitionD}ms, opacity 250ms`; -topBar.style.minWidth = "0"; - -let widthDestino = 0; - -document.body.appendChild(topBar); - -let promesaActual; - -const cambiarProgreso = progreso => { - widthDestino = progreso; - promesaActual = new Promise((resolve, reject) => { - topBar.style.minWidth = `${progreso}%`; - setTimeout(() => resolve(),transitionD); - }); - return promesaActual; -}; - -const cancelarTransicion = () => { - const transiciones = topBar.style.transition; - topBar.style.transition = ""; - topBar.style.minWidth = `${widthDestino}%`; - topBar.style.transition = transiciones; -}; - -const ocultarTopBar = () => { - topBar.style.opacity = "0"; - setTimeout(() => { - topBar.style.minWidth = "0%"; - },250); -}; - -const reiniciarTopBar = () => { - const transiciones = topBar.style.transition; - topBar.style.transition = ""; - topBar.style.minWidth = `0`; - topBar.style.opacity = "1"; - topBar.style.transition = transiciones; -}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..14327f0 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "ihc", + "version": "1.0.0", + "description": "A simple meb application for a 'French Restaurant'", + "main": "index.php", + "scripts": { + "uglify": "uglifyjs src/js/*.js -m -c -o dist/js/app.js", + "sass": "sass -s compressed src/sass:dist/css" + }, + "repository": { + "type": "git", + "url": "git+https://gitlab.com/Araozu/ihc-proyect.git" + }, + "keywords": [ + "ihc", + "unsa", + "2018" + ], + "author": "Fernando Araoz Morales", + "license": "MIT", + "bugs": { + "url": "https://gitlab.com/Araozu/ihc-proyect/issues" + }, + "homepage": "https://gitlab.com/Araozu/ihc-proyect#readme" +} diff --git a/src/componentes/carrito.vue b/src/componentes/carrito.vue new file mode 100644 index 0000000..aa6e0cd --- /dev/null +++ b/src/componentes/carrito.vue @@ -0,0 +1,94 @@ +
+ + + + +
+
+
+
+
+ Carrito de compras +
+
+ Seguir comprando +
+
+
+ +
+
+ + +
+
+ +
+ +
+ + +
+
+
+
+
+
+
+ + +
diff --git a/src/componentes/header.vue b/src/componentes/header.vue new file mode 100644 index 0000000..1927d31 --- /dev/null +++ b/src/componentes/header.vue @@ -0,0 +1,10 @@ + diff --git a/src/componentes/headerMin.vue b/src/componentes/headerMin.vue new file mode 100644 index 0000000..e8f6259 --- /dev/null +++ b/src/componentes/headerMin.vue @@ -0,0 +1,23 @@ + diff --git a/src/componentes/inicio.vue b/src/componentes/inicio.vue new file mode 100644 index 0000000..a21226c --- /dev/null +++ b/src/componentes/inicio.vue @@ -0,0 +1,44 @@ +
+ + + + + +
+
+
+ Plato Francés +
+
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia + deserunt mollit anim id est laborum. +
+
+
+
+
+
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Congue quisque egestas diam in arcu cursus euismod quis. Mi tempus imperdiet nulla + malesuada pellentesque elit eget gravida. Tempus imperdiet nulla malesuada pellentesque elit eget + gravida + cum. Commodo elit at imperdiet dui accumsan sit amet. In nulla posuere sollicitudin aliquam ultrices + sagittis. +
+
+
+ Plato Francés +
+
+
+
+ + +
diff --git a/src/componentes/mi-footer.vue b/src/componentes/mi-footer.vue new file mode 100644 index 0000000..0c5749b --- /dev/null +++ b/src/componentes/mi-footer.vue @@ -0,0 +1,11 @@ +
+
+
+ Cocina Francesa.
+ Una Single Page Application para el curso de IHC, UNSA, 2018.
+ Se utilizaron: Vue.js, BEM, Sass, npm, y PHP.
+
+ Desarrollado por Fernando Araoz, 20173373. +
+
+
diff --git a/src/componentes/navBar.vue b/src/componentes/navBar.vue new file mode 100644 index 0000000..c0cab98 --- /dev/null +++ b/src/componentes/navBar.vue @@ -0,0 +1,10 @@ +
+ +
diff --git a/src/js/Router.js b/src/js/Router.js deleted file mode 100644 index 1e1d402..0000000 --- a/src/js/Router.js +++ /dev/null @@ -1,603 +0,0 @@ -/* global window, module */ - -;(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - global.Router = factory() -}(this, (function () { - - /** - * Router - * - * @version: 1.2.7 - * @author Graidenix - * - * @constructor - * - * @param {object} options - * @returns {Router} - */ - function Router(options) { - var settings = this._getSettings(options); - - - this.notFoundHandler = settings.page404; - this.mode = (!window.history || !window.history.pushState) ? "hash" : settings.mode; - this.root = settings.root === "/" ? "/" : "/" + this._trimSlashes(settings.root) + "/"; - this.beforeHook = settings.hooks.before; - this.securityHook = settings.hooks.secure; - - this.routes = []; - if (settings.routes && settings.routes.length > 0) { - var _this = this; - settings.routes.forEach(function (route) { - _this.add(route.rule, route.handler, route.options); - }); - } - - this._pageState = null; - this._currentPage = null; - this._skipCheck = false; - this._action = null; - - if (this.mode === "hash") { - this._historyStack = []; - this._historyIdx = 0; - this._historyState = "add" - } - - return this; - } - - /** - * Define Router Page - * - * @param {string} uri - * @param {object} query - * @param {Array} params - * @param {object} state - * @param {object} options - * - * @constructor - */ - Router.Page = function (uri, query, params, state, options) { - this.uri = uri || ""; - this.query = query || {}; - this.params = params || []; - this.state = state || null; - this.options = options || {}; - }; - - /** - * Sanitize options and add default values - * - * @param {object} options - * @returns {object} - * @private - */ - Router.prototype._getSettings = function (options) { - var settings = {}; - var defaults = { - routes: [], - mode: "history", - root: "/", - hooks: { - "before": function () { - }, - "secure": function () { - return true; - } - }, - page404: function (page) { - console.error({ - page: page, - message: "404. Page not found" - }); - } - }; - - options = options || {}; - ["routes", "mode", "root", "page404"].forEach(function (key) { - settings[key] = options[key] || defaults[key]; - }); - - settings.hooks = Object.assign({}, defaults.hooks, options.hooks || {}); - - return settings; - }; - - /** - * Get URI for Router "history" mode - * - * @private - * @returns {string} - */ - Router.prototype._getHistoryFragment = function () { - var fragment = decodeURI(window.location.pathname); - if (this.root !== "/") { - fragment = fragment.replace(this.root, ""); - } - return this._trimSlashes(fragment); - }; - - /** - * Get URI for router "hash" mode - * - * @private - * @returns {string} - */ - Router.prototype._getHashFragment = function () { - var hash = window.location.hash.substr(1).replace(/(\?.*)$/, ""); - return this._trimSlashes(hash); - }; - - /** - * Get current URI - * - * @private - * @returns {string} - */ - Router.prototype._getFragment = function () { - if (this.mode === "history") { - return this._getHistoryFragment(); - } else { - return this._getHashFragment(); - } - }; - - /** - * Trim slashes for path - * - * @private - * @param {string} path - * @returns {string} - */ - Router.prototype._trimSlashes = function (path) { - if (typeof path !== "string") { - return ""; - } - return path.toString().replace(/\/$/, "").replace(/^\//, ""); - }; - - /** - * 404 Page Handler - * - * @private - */ - Router.prototype._page404 = function (path) { - this._currentPage = new Router.Page(path); - this.notFoundHandler(path); - }; - - /** - * Convert the string route rule to RegExp rule - * - * @param {string} route - * @returns {RegExp} - * @private - */ - Router.prototype._parseRouteRule = function (route) { - if (typeof route !== "string") { - return route; - } - var uri = this._trimSlashes(route); - var rule = uri - .replace(/([\\\/\-\_\.])/g, "\\$1") - .replace(/\{[a-zA-Z]+\}/g, "(:any)") - .replace(/\:any/g, "[\\w\\-\\_\\.]+") - .replace(/\:word/g, "[a-zA-Z]+") - .replace(/\:num/g, "\\d+"); - - return new RegExp("^" + rule + "$", "i"); - }; - - /** - * Parse query string and return object for it - * - * @param {string} query - * @returns {object} - * @private - */ - Router.prototype._parseQuery = function (query) { - var _query = {}; - if (typeof query !== "string") { - return _query; - } - - if (query[0] === "?") { - query = query.substr(1); - } - - this._queryString = query; - query.split("&").forEach(function (row) { - var parts = row.split("="); - if (parts[0] !== "") { - if (parts[1] === undefined) { - parts[1] = true; - } - _query[decodeURIComponent(parts[0])] = parts[1]; - } - }); - return _query; - }; - - /** - * Get query for `history` mode - * - * @returns {Object} - * @private - */ - Router.prototype._getHistoryQuery = function () { - return this._parseQuery(window.location.search); - }; - - /** - * Get query for `hash` mode - * - * @returns {Object} - * @private - */ - Router.prototype._getHashQuery = function () { - var index = window.location.hash.indexOf("?"); - var query = (index !== -1) ? window.location.hash.substr(index) : ""; - return this._parseQuery(query); - }; - - /** - * Get query as object - * - * @private - * @returns {Object} - */ - Router.prototype._getQuery = function () { - if (this.mode === "history") { - return this._getHistoryQuery(); - } else { - return this._getHashQuery(); - } - }; - - /** - * Add route to routes list - * - * @param {string|RegExp} rule - * @param {function} handler - * @param {{}} options - * @returns {Router} - */ - Router.prototype.add = function (rule, handler, options) { - this.routes.push({ - rule: this._parseRouteRule(rule), - handler: handler, - options: options - }); - return this; - }; - - /** - * Remove a route from routes list - * - * @param param - * @returns {Router} - */ - Router.prototype.remove = function (param) { - var _this = this; - if (typeof param === "string") { - param = this._parseRouteRule(param).toString(); - } - this.routes.some(function (route, i) { - if (route.handler === param || route.rule.toString() === param) { - _this.routes.splice(i, 1); - return true; - } - return false; - }); - - return this; - }; - - /** - * Reset the state of Router - * - * @returns {Router} - */ - Router.prototype.reset = function () { - this.routes = []; - this.mode = null; - this.root = "/"; - this._pageState = {}; - this.removeUriListener(); - - return this; - }; - - /** - * Add current page in history stack - * @private - */ - Router.prototype._pushHistory = function () { - var _this = this, - fragment = this._getFragment(); - - if (this.mode === "hash") { - if (this._historyState === "add") { - if (this._historyIdx !== this._historyStack.length - 1) { - this._historyStack.splice(this._historyIdx + 1); - } - - this._historyStack.push({ - path: fragment, - state: _this._pageState - }); - - this._historyIdx = this._historyStack.length - 1; - } - this._historyState = "add"; - } - }; - - /** - * - * @param asyncRequest boolean - * @returns {PromiseResult | boolean} - * @private - */ - Router.prototype._unloadCallback = function (asyncRequest) { - var result; - - if (this._skipCheck) { - return asyncRequest ? Promise.resolve(true) : true; - } - - if (this._currentPage && this._currentPage.options && this._currentPage.options.unloadCb) { - result = this._currentPage.options.unloadCb(this._currentPage, asyncRequest); - if (!asyncRequest || result instanceof Promise) { - return result; - } - return result ? Promise.resolve(result) : Promise.reject(result); - } else { - return asyncRequest ? Promise.resolve(true) : true; - } - }; - - /** - * Check if router has the action for current path - * - * @returns {boolean} - * @private - */ - Router.prototype._findRoute = function () { - var _this = this, - fragment = this._getFragment(); - - return this.routes.some(function (route) { - var match = fragment.match(route.rule); - if (match) { - match.shift(); - var query = _this._getQuery(); - var page = new Router.Page(fragment, query, match, _this._pageState, route.options); - - if (!_this.securityHook(page)) { - return false; - } - - _this._currentPage = page; - if (_this._skipCheck) { - _this._skipCheck = false; - return true; - } - _this.beforeHook(page); - route.handler.apply(page, match); - _this._pageState = null; - - window.onbeforeunload = function (ev) { - if (_this._unloadCallback(false)) { - return; - } - ev.returnValue = true; - return true; - }; - - return true; - } - return false; - }); - }; - - /** - * - */ - Router.prototype._treatAsync = function () { - var result; - - result = this._currentPage.options.unloadCb(this._currentPage, true); - if (!(result instanceof Promise)) { - result = result ? Promise.resolve(result) : Promise.reject(result); - } - - result - .then(this._processUri.bind(this)) - .catch(this._resetState.bind(this)); - }; - - /** - * - * @private - */ - Router.prototype._resetState = function () { - this._skipCheck = true; - this.navigateTo(this._current, this._currentPage.state, true); - }; - - /** - * Replace current page with new one - */ - Router.prototype._processUri = function () { - var fragment = this._getFragment(), - found; - - this._current = fragment; - this._pushHistory(); - - found = this._findRoute.call(this); - if (!found) { - this._page404(fragment); - } - }; - - /** - * Check the URL and execute handler for its route - * - * @returns {Router} - */ - Router.prototype.check = function () { - if (this._skipCheck) return this; - - // if page has unload cb treat as promise - if (this._currentPage && this._currentPage.options && this._currentPage.options.unloadCb) { - this._treatAsync(); - } else { - this._processUri(); - } - return this; - }; - - /** - * Add the URI listener - * - * @returns {Router} - */ - Router.prototype.addUriListener = function () { - if (this.mode === "history") { - window.onpopstate = this.check.bind(this); - } else { - window.onhashchange = this.check.bind(this); - } - - return this; - }; - - /** - * Remove the URI listener - * - * @returns {Router} - */ - Router.prototype.removeUriListener = function () { - window.onpopstate = null; - window.onhashchange = null; - return this; - }; - - /** - * Redirect to a page with replace state - * - * @param {string} path - * @param {object} state - * @param {boolean} silent - * - * @returns {Router} - */ - Router.prototype.redirectTo = function (path, state, silent) { - path = this._trimSlashes(path) || ""; - this._pageState = state || null; - this._skipCheck = !!silent; - - if (this.mode === "history") { - history.replaceState(state, null, this.root + this._trimSlashes(path)); - return this.check(); - } else { - this._historyIdx--; - window.location.hash = path; - } - return this; - }; - - /** - * Navigate to a page - * - * @param {string} path - * @param {object} state - * @param {boolean} silent - * - * @returns {Router} - */ - Router.prototype.navigateTo = function (path, state, silent) { - path = this._trimSlashes(path) || ""; - this._pageState = state || null; - this._skipCheck = !!silent; - - if (this.mode === "history") { - history.pushState(state, null, this.root + this._trimSlashes(path)); - return this.check(); - } else { - window.location.hash = path; - } - return this; - }; - - /** - * Refresh page with recall route handler - * @returns {Router} - */ - Router.prototype.refresh = function () { - if (!this._currentPage) { - return this; - } - var path = this._currentPage.uri + "?" + this._queryString; - return this.navigateTo(path, this._currentPage.state); - }; - - /** - * Go Back in browser history - * Simulate "Back" button - * - * @returns {Router} - */ - Router.prototype.back = function () { - if (this.mode === "history") { - window.history.back(); - return this; - } - - return this.go(this._historyIdx - 1); - }; - - /** - * Go Forward in browser history - * Simulate "Forward" button - * - * @returns {Router} - */ - Router.prototype.forward = function () { - if (this.mode === "history") { - window.history.forward(); - return this; - } - - return this.go(this._historyIdx + 1); - }; - - /** - * Go to a specific history page - * - * @param {number} count - * @returns {Router} - */ - Router.prototype.go = function (count) { - if (this.mode === "history") { - window.history.go(count); - return this; - } - - var page = this._historyStack[count]; - if (!page) { - return this; - } - - this._historyIdx = count; - this._historyState = "hold"; - return this.navigateTo(page.path, page.state); - }; - - return Router; -}))); \ No newline at end of file diff --git a/src/js/base.js b/src/js/base.js index b6cdebc..2b5f2de 100644 --- a/src/js/base.js +++ b/src/js/base.js @@ -1,374 +1,5 @@ - el: '#navBar', - data: { - visible: true - } -}); - const carritoUsuario = []; -window.addEventListener("hashchange", () => { - render(decodeURI(window.location.hash)); -}); - -const render = url => { - switch (url) { - case "#registro": - abrirRegistro(); - break; - case "#iniciar-sesion": - abrirInicioSesion(); - break; - case "#usuarios/": - abrirUsuarios(); - break; - case "#usuarios/mi-cuenta": - abrirMiCuenta(); - break; - case "#usuarios/pagos": - abrirCarrito(); - break; - case "#staff/": - abrirStaff(); - break; - default: - abrirPagPrin(); - return; - } -}; - -const sectionP = document.getElementById("sectionP"); -const contenedorInicioRegistro = document.getElementById("contenedorInicio-Registro"); -const formInicioRegistro = document.getElementById("inicio_registro"); -const sectionS = document.getElementById("sectionS"); -const sectionCarrito = document.getElementById("sectionCarrito"); - -const manipularTopBar = status => { - switch (status) { - case 1: - cambiarProgreso(25); - break; - case 2: - cancelarTransicion(); - cambiarProgreso(50); - break; - case 3: - cancelarTransicion(); - cambiarProgreso(75); - break; - default: - cancelarTransicion(); - reiniciarTopBar(); - } -}; - -const abrirUsuarios = () => { - - const crearPlatos = () => { - return new Promise((resolve, reject) => { - const ajax = new XMLHttpRequest(); - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - const data = JSON.parse(ajax.responseText); - const divR = document.getElementById("productos"); - - let contenedor = document.createElement("div"); - contenedor.className = "row"; - let contador = 0; - for (const itemI in data) { - if (data.hasOwnProperty(itemI)) { - const item = data[itemI]; - contador++; - if (contador >= 4) { - divR.appendChild(contenedor); - divR.appendChild(document.createElement("br")); - contenedor = document.createElement("div"); - contenedor.className = "row"; - contador = 1; - } - - const itemDiv = document.createElement("div"); - itemDiv.className = "col-4 caja plato"; - - const img = document.createElement("img"); - img.className = "image"; - img.src = item["imgUrl"]; - itemDiv.appendChild(img); - - const nombre = document.createElement("div"); - nombre.className = "plato--Titulo"; - nombre.innerText = item["nombre"]; - itemDiv.appendChild(nombre); - - itemDiv.appendChild(document.createElement("br")); - - const descripcion = document.createElement("div"); - descripcion.className = "plato--Descripcion"; - descripcion.innerText = item["descripcion"]; - itemDiv.appendChild(descripcion); - itemDiv.appendChild(document.createElement("br")); - - const precioUnitario = document.createElement("div"); - precioUnitario.className = "plato--Precio"; - precioUnitario.innerText = `${item["precio"]}`; - itemDiv.appendChild(precioUnitario); - - const cantidad = document.createElement("div"); - cantidad.className = "plato--Cantidad"; - cantidad.appendChild(document.createTextNode("Cantidad: ")); - const unidades = document.createElement("span"); - const botonMenos = document.createElement("i"); - botonMenos.className = "material-icons plato--Cantidad--Icon"; - botonMenos.innerText = "remove"; - botonMenos.addEventListener("click",() => { - const valorActual = parseInt(unidades.innerText); - if (valorActual > 1) { - unidades.innerText = valorActual-1; - } else { - unidades.innerText = "1"; - } - }); - - cantidad.appendChild(botonMenos); - unidades.innerText = "1"; - cantidad.appendChild(unidades); - const botonMas = document.createElement("i"); - botonMas.className = "material-icons plato--Cantidad--Icon"; - botonMas.innerText = "add"; - botonMas.addEventListener("click",() => { - const valorActual = parseInt(unidades.innerText); - if (valorActual > 0) { - unidades.innerText = valorActual+1; - } else { - unidades.innerText = "1"; - } - }); - cantidad.appendChild(botonMas); - - itemDiv.appendChild(cantidad); - itemDiv.appendChild(document.createElement("br")); - - const botonAddCart = document.createElement("button"); - botonAddCart.className = "botonAddCart"; - botonAddCart.addEventListener("click",() => { - const cantidad = parseInt(unidades.innerText); - if (cantidad > 0) { - const item = data[itemI]; - item["cantidad"] = cantidad; - - // carritoUsuario[itemI] = item; - - carritoUsuario.push(item); - console.log(`JSON del usuario|>\n${JSON.stringify(carritoUsuario)}`); - window.location.replace("./#usuarios/pagos"); - } else { - alert(""); - } - }); - botonAddCart.innerHTML = "add_shopping_cart Añadir al carrito"; - itemDiv.appendChild(botonAddCart); - - contenedor.appendChild(itemDiv); - } - } - divR.appendChild(contenedor); - - resolve(); - } - }; - - ajax.open("POST", "./usuarios/platos.json", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); - }); - }; - - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(formInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - abrirElemF(sectionS, () => { - sectionS.innerHTML = ajax.responseText; - crearPlatos(); - }); - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./usuarios/index.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirMiCuenta = () => { - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(formInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - abrirElemF(sectionS, () => { - sectionS.innerHTML = ajax.responseText; - }); - - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./usuarios/mi-cuenta.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirCarrito = () => { - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(formInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionS); - - /* Metodo antiguo - const ajax = new XMLHttpRequest(); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - abrirElemF(sectionCarrito, () => { - sectionCarrito.innerHTML = ajax.responseText; - crearCarrito(); - }); - - sectionCarrito.setAttribute("vacio","false"); - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./usuarios/pagos.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); - */ - - /* Metodo con Vue */ - abrirElemF(sectionCarrito); - -}; - -const abrirStaff = () => { - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(formInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - abrirElemF(sectionS, () => { - sectionS.innerHTML = ajax.responseText; - }); - - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./staff/", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirInicioSesion = () => { - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - const elem = document.getElementById("inicio_registro"); - abrirElemF(elem, () => { - elem.innerHTML = ajax.responseText - }); - - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./iniciar-sesion.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirRegistro = () => { - const ajax = new XMLHttpRequest(); - - reiniciarTopBar(); - - cerrarElemF(contenedorInicioRegistro); - cerrarElemF(sectionP); - cerrarElemF(sectionCarrito); - - ajax.onreadystatechange = () => { - if (ajax.status === 200 && ajax.readyState === 4) { - - cambiarProgreso(100).then(ocultarTopBar); - - const elem = document.getElementById("inicio_registro"); - abrirElemF(elem, () => { - elem.innerHTML = ajax.responseText - }); - - } else { - manipularTopBar(ajax.readyState); - } - }; - - ajax.open("POST", "./registro.php", true); - ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - ajax.send(); -}; - -const abrirPagPrin = () => { - const inicio_registro = document.getElementById("inicio_registro"); - cerrarElemF(inicio_registro, () => inicio_registro.innerHTML = ""); - cerrarElemF(sectionS, () => sectionS.innerHTML = ""); - cerrarElemF(sectionCarrito); - abrirElemF(contenedorInicioRegistro); - abrirElemF(sectionP); -}; - /* Height Transition by CSS Tricks. Returns a Promise */ const collapseSection = element => { return new Promise((resolve, reject) => { @@ -458,9 +89,6 @@ const cerrarElemF = (element, postF) => { } }; -render(decodeURI(window.location.hash)); - - const carrito = new Vue({ el: "#carrito", data: { @@ -507,54 +135,3 @@ const carrito = new Vue({ } } }); - -/* Metodo con Antiguo -const crearCarrito = () => { - carrito = new Vue({ - el: "#carrito", - data: { - item: carritoUsuario, - descuento: 0 - }, - computed: { - cantidadItems: function () { - let items = 0; - for (const i in this.item) - items++; - return items; - }, - subTotal: function () { - let subT = 0; - for (const itemI in this.item ) { - if (this.item.hasOwnProperty(itemI)){ - const item = this.item[itemI]; - subT += (item["precio"] * item["cantidad"]); - } - } - return subT; - }, - total: function () { - return this.subTotal - this.descuento; - }, - noEstaVacio: function () { - for (const i in this.item) { - return true; - } - return false; - }, - }, - methods: { - restarCantidad: function (elem) { - const cantidad = parseInt(elem.cantidad); - if (cantidad > 0) - elem.cantidad = cantidad -1; - }, - aumentarCantidad: function (elem) { - const cantidad = parseInt(elem.cantidad); - if (cantidad >= 0) - elem.cantidad = cantidad+1; - } - } - }); -}; -*/ diff --git a/src/sass/anuma.sass b/src/sass/anuma.sass deleted file mode 100644 index d55cccf..0000000 --- a/src/sass/anuma.sass +++ /dev/null @@ -1,7 +0,0 @@ -.anuma-we - font: - family: sans-serif - size: 30px - -.anuma-we--alv - color: #23bf87