Browse Source

Ordenar usando aplicacion

pablo.loyola 4 years ago
parent
commit
5ce018e71a

+ 110
- 0
OrdenarPorApp/css/index.css View File

@@ -0,0 +1,110 @@
1
+/*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements.  See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership.  The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License.  You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied.  See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+* {
20
+    -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
21
+}
22
+
23
+body {
24
+    -webkit-touch-callout: none;                /* prevent callout to copy image, etc when tap to hold */
25
+    -webkit-text-size-adjust: none;             /* prevent webkit from resizing text to fit */
26
+    -webkit-user-select: none;                  /* prevent copy paste, to allow, change 'none' to 'text' */
27
+    background-color:#E4E4E4;
28
+    /*background-image:linear-gradient(to bottom, #A7A7A7 0%, #E4E4E4 51%);*/
29
+    font-family: system-ui, -apple-system, -apple-system-font, 'Segoe UI', 'Roboto', sans-serif;
30
+    font-size:12px;
31
+    height:100vh;
32
+    margin:0px;
33
+    padding:0px;
34
+    /* Padding to avoid the "unsafe" areas behind notches in the screen */
35
+    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
36
+    text-transform:uppercase;
37
+    width:100%;
38
+}
39
+
40
+/* Portrait layout (default) */
41
+.app {
42
+    background: #E4E4E4 no-repeat center top; /* 170px x 200px */
43
+    position:absolute;             /* position in the center of the screen */
44
+    left:50%;
45
+    top:50%;
46
+    height:50px;                   /* text area height */
47
+    width:225px;                   /* text area width */
48
+    text-align:center;
49
+    padding:180px 0px 0px 0px;     /* image height is 200px (bottom 20px are overlapped with text) */
50
+    margin:-115px 0px 0px -112px;  /* offset vertical: half of image height and text area height */
51
+                                   /* offset horizontal: half of text area width */
52
+}
53
+
54
+/* Landscape layout (with min-width) */
55
+@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
56
+    .app {
57
+        background-position:left center;
58
+        padding:75px 0px 75px 170px;  /* padding-top + padding-bottom + text area = image height */
59
+        margin:-90px 0px 0px -198px;  /* offset vertical: half of image height */
60
+                                      /* offset horizontal: half of image width and text area width */
61
+    }
62
+}
63
+
64
+h1 {
65
+    font-size:24px;
66
+    font-weight:normal;
67
+    margin:0px;
68
+    overflow:visible;
69
+    padding:0px;
70
+    text-align:center;
71
+}
72
+
73
+.event {
74
+    border-radius:4px;
75
+    color:#FFFFFF;
76
+    font-size:12px;
77
+    margin:0px 30px;
78
+    padding:2px 0px;
79
+}
80
+
81
+.event.listening {
82
+    background-color:#333333;
83
+    display:block;
84
+}
85
+
86
+.event.received {
87
+    background-color:#4B946A;
88
+    display:none;
89
+}
90
+
91
+#deviceready.ready .event.listening { display: none; }
92
+#deviceready.ready .event.received { display: block; }
93
+
94
+@keyframes fade {
95
+    from { opacity: 1.0; }
96
+    50% { opacity: 0.4; }
97
+    to { opacity: 1.0; }
98
+}
99
+
100
+.blink {
101
+    animation:fade 3000ms infinite;
102
+    -webkit-animation:fade 3000ms infinite;
103
+}
104
+
105
+
106
+@media screen and (prefers-color-scheme: dark) {
107
+    body {
108
+        background-image:linear-gradient(to bottom, #585858 0%, #1B1B1B 51%);
109
+    }
110
+}

BIN
OrdenarPorApp/img/Pasta.png View File


BIN
OrdenarPorApp/img/Pizzeta.png View File


BIN
OrdenarPorApp/img/logo.png View File


+ 41
- 0
OrdenarPorApp/index.html View File

@@ -0,0 +1,41 @@
1
+<!DOCTYPE html>
2
+<html>
3
+    <head>
4
+        <meta charset="utf-8">
5
+        <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />
6
+        <meta name="format-detection" content="telephone=no">
7
+        <meta name="msapplication-tap-highlight" content="no">
8
+        <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
9
+        <meta name="color-scheme" content="light dark">
10
+        <script src="js/script.js"></script>
11
+        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
12
+        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
13
+        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
14
+        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
15
+        <link rel="stylesheet" href="css/index.css">
16
+        <title>Linguini Rest.</title>
17
+    </head>
18
+    
19
+    <body>
20
+        <div>
21
+            <h3>Escoja lo que vaya a ordenar:</h3>
22
+            <h3>Pastas:</h3>
23
+            <br>
24
+            <div id = "PastaDiv">
25
+                <script>
26
+                    item_display("Pasta");
27
+                </script>
28
+            </div>
29
+
30
+            <h3>Pizzetas:</h3>
31
+            <br>
32
+    
33
+            <div id = "PizzetaDiv">
34
+                <script>
35
+                    item_display("Pizzeta");
36
+                </script>
37
+            </div>
38
+            <a type = "button" class = "btn btn-primary btn-sm" href = "order_summary.html">Someter Orden</a>
39
+        </div>
40
+    </body>
41
+</html>

+ 83
- 0
OrdenarPorApp/js/script.js View File

@@ -0,0 +1,83 @@
1
+var orden = new Map();
2
+var menu = new Map();
3
+menu.set('Pasta',[
4
+    "Gardenia",
5
+    "Primavera",
6
+    "Carbonara",
7
+    "Carnivorum",
8
+    "Primavera con pollo",
9
+    "Chicken carbonara",
10
+    "Al pesto",
11
+    "Pollo marsala",
12
+    "Chicken and shrimp"
13
+]);
14
+menu.set('Pizzeta', [
15
+    "Simply Cheese",
16
+    "Carbonara",
17
+    "Al pesto",
18
+    "Beef & Onion",
19
+    "Pepperoni",
20
+    "Bacon & Mushroom",
21
+    "Churrasco Hollandaise",
22
+    "Mr Wedge",
23
+    "BBQ Meatlovers"
24
+]);
25
+
26
+function add_item(item, category, num){
27
+    var val = parseInt(document.getElementsByName(category + 'qty' + num)[0].value);
28
+    var selection = category + " " + item;
29
+    if (!orden.get(selection)){
30
+        orden.set(selection, val);
31
+    }
32
+
33
+    else{
34
+        orden.set(selection, orden.get(selection) + val);    
35
+    }
36
+    localStorage.orden_local = JSON.stringify(Array.from(orden.entries()));
37
+    console.log(orden);
38
+}
39
+
40
+function item_display(category){
41
+    var cat_list = menu.get(category);
42
+    var page = document.getElementById(category + "Div");
43
+    var card_collection = "";
44
+    for(var i = 0; i < cat_list.length; i++){
45
+        card_collection += `<div class="card" style="width: 18rem;">
46
+       <img class="card-img-top" src="img/` + category + `.png" alt="Image of ` + category + `">
47
+       <div class="card-body">
48
+           <h5 class="card-title">` + cat_list[i] + `</h5>
49
+           <div style = "width: 100px; display: table; margin: 4px; padding: 1px;">
50
+                <div style = "display: table-cell; width: 100%;">
51
+                    <input style = "width: 100%; margin: 1px;" type = "number" min = "1" value = "1" name = "`+ category + `qty` + i + `">
52
+                </div>
53
+                <div style = "padding: 5px">
54
+                    <button class="btn btn-primary btn-sm" onclick = "add_item('` + cat_list[i] + `', '` + category + `', `+ i + `)">Add</buton>
55
+                </div>
56
+           </div>
57
+        </div>
58
+        </div>`;
59
+    }
60
+    card_collection += "<br>";
61
+    page.innerHTML = card_collection;
62
+}
63
+
64
+function order_summary(){
65
+    try{
66
+        orden = new Map(JSON.parse(localStorage.orden_local));
67
+    }
68
+    catch(err){
69
+        alert("ERROR: Orden invalida")
70
+        window.location.href = "index.html";
71
+    }
72
+    localStorage.orden_local = []
73
+    var page = document.getElementById("rows");
74
+    var orden_table = "";
75
+    for(let [key,value] of orden){
76
+        orden_table += `<tr>
77
+            <td>` + key + `</td>
78
+            <td>` + value + `</td>
79
+        </tr>`
80
+    }
81
+    page.innerHTML = orden_table;
82
+}
83
+

+ 38
- 0
OrdenarPorApp/order_summary.html View File

@@ -0,0 +1,38 @@
1
+<!DOCTYPE html>
2
+<html>
3
+    <head>
4
+        <meta charset="utf-8">
5
+        <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />
6
+        <meta name="format-detection" content="telephone=no">
7
+        <meta name="msapplication-tap-highlight" content="no">
8
+        <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
9
+        <meta name="color-scheme" content="light dark">
10
+        <script src="js/script.js"></script>
11
+        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
12
+        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
13
+        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
14
+        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
15
+        <link rel="stylesheet" href="css/index.css">
16
+        <title>Linguini Rest.</title>
17
+    </head>
18
+    
19
+    <body>
20
+        <div>
21
+            <h3>Su orden:</h3>
22
+            <table class="table table-sm table-striped" style = "border: 1px solid black; width: 250px;">
23
+                <thead>
24
+                  <tr>
25
+                    <th scope="col">Item</th>
26
+                    <th scope="col">Cantidad</th>
27
+                  </tr>
28
+                </thead>
29
+                <tbody id = "rows">
30
+                <script>
31
+                    order_summary();
32
+                </script>
33
+                </tbody>
34
+            </table>
35
+
36
+        </div>
37
+    </body>
38
+</html>