Parcourir la source

Despliegue de informacion de artesanias y artesanos en renglones. Cada artesano y artesania se oprime para obtener mas informacion. El boton de artesania ofrece cuales artesanos trabajan la artesania y de que municipio son. El boton de artesano despliega informacion basica y necesaria del artesano. Entiendase municipio, telefono, correo electronico y con que artesanias trabaja.

lyxaira.glass il y a 5 ans
Parent
révision
269e3b3ce2
4 fichiers modifiés avec 301 ajouts et 127 suppressions
  1. 142
    60
      platforms/browser/www/index.html
  2. 9
    2
      platforms/browser/www/js/load.js
  3. 141
    63
      www/index.html
  4. 9
    2
      www/js/load.js

+ 142
- 60
platforms/browser/www/index.html Voir le fichier

@@ -31,6 +31,7 @@
31 31
         <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *; img-src 'self' data: content:;">
32 32
         <!--these three for the calendar-->
33 33
         <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
34
+        <link href="css/robotocondensed.css" rel="stylesheet">
34 35
         <link rel="stylesheet" href="calendar_files/css/demo.css"/>
35 36
         <link rel="stylesheet" href="css/file.css"/>
36 37
         <link rel="stylesheet" href="calendar_files/css/theme1.css"/>
@@ -68,6 +69,31 @@
68 69
 
69 70
 
70 71
 
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
71 97
   <template id="artesanias.html">
72 98
     <ons-page id="artesanias">
73 99
 
@@ -81,7 +107,11 @@
81 107
     </ons-pull-hook>
82 108
 
83 109
     <ons-list id="artesania-list" src="">
84
-      <ons-list-header>Pull to refresh</ons-list-header>
110
+      <ons-list-header>Artesanias</ons-list-header>
111
+    </ons-list>
112
+
113
+    <ons-list id="artesanos-list" src="">
114
+      <ons-list-header>Artesanos</ons-list-header>
85 115
     </ons-list>
86 116
 
87 117
     <script>
@@ -89,68 +119,70 @@
89 119
       ons.getScriptPage().onInit = function () {
90 120
         this.querySelector('ons-toolbar div.center').textContent = this.data.title;
91 121
 
92
-    var File = this.data.title.toUpperCase() + '.json' ;
122
+    //var File = this.data.title.toUpperCase() + '.json' ;
93 123
     var Esp = this.data.esp.split(', ');
94
-    var art=new Array('Ta\u00edno - Ram\u00f3n Rivera','Aladino Mu\u00f1iz Ram\u00edrez','Alma L. Albino Ortiz','Jeanette H. Figueroa','Sonia Noem\u00ed Rodr\u00edguez Salgado');
95
-    var mun=new Array('Vega Baja PR','Sabana Grande PR','Naguabo PR','Ceiba PR','Fajardo PR');
96
-
97
-
98
-    var request = new XMLHttpRequest();
99
-    request.open('GET', 'Server/'+File, true);
100
-    request.onload = function() {
101
-    var info = JSON.parse(this.response)
102
-    var list = document.getElementById("artesania-list");
103
-    for (var i = 0; i < info.length; i++) {
104
-
105
-      art.push(info[i].Nombre);
106
-      mun.push(info[i].Municipio);
107
-        
108
-      /*var item = ons.createElement(`<ons-card onclick="fn.pushPage({'id':'artesanias.html','title':'${info[i].Renglones}', 
109
-      'esp': '${info[i].Especificaciones}'})">
110
-                    <div class="title">${info[i].Renglones}</div>
111
-                </ons-card>`);
112
-        list.appendChild(item);*/
113
-    }
114
-    console.log('Termino funcion',art)
115
-    }
116
-    //<div class="right"><img class="list-item__thumbnail" src="img/${info[i].Renglones}.png"></div>
117
-    request.send();
118
-
119
-    console.log('Fuera del codigo',art)
124
+    var artesanos_json = this.data.json;
120 125
 
121 126
     //Convertir en mayuscula primera letra del string.
122 127
     for(var i=0; i<Esp.length; i++) { 
123 128
       Esp[i] = Esp[i].charAt(0).toUpperCase() + Esp[i].slice(1);
124 129
     };
125 130
 
126
-        var pullHook = document.getElementById('pull-hook');
127
-        var icon = document.getElementById('pull-hook-icon');
128
-        pullHook.addEventListener('changestate', function (event) {
129
-          switch (event.state) {
130
-            case 'initial':
131
-              icon.setAttribute('icon', 'fa-arrow-down');
132
-              icon.removeAttribute('rotate');
133
-              icon.removeAttribute('spin');
134
-              break;
135
-            case 'preaction':
136
-              icon.setAttribute('icon', 'fa-arrow-down');
137
-              icon.setAttribute('rotate', '180');
138
-              icon.removeAttribute('spin');
139
-              break;
140
-            case 'action':
141
-              icon.setAttribute('icon', 'fa-spinner');
142
-              icon.removeAttribute('rotate');
143
-              icon.setAttribute('spin', true);
144
-              break;
145
-          } 
146
-
147
-        });
131
+    var pullHook = document.getElementById('pull-hook');
132
+    var icon = document.getElementById('pull-hook-icon');
133
+    pullHook.addEventListener('changestate', function (event) {
134
+      switch (event.state) {
135
+        case 'initial':
136
+          icon.setAttribute('icon', 'fa-arrow-down');
137
+          icon.removeAttribute('rotate');
138
+          icon.removeAttribute('spin');
139
+          break;
140
+        case 'preaction':
141
+          icon.setAttribute('icon', 'fa-arrow-down');
142
+          icon.setAttribute('rotate', '180');
143
+          icon.removeAttribute('spin');
144
+          break;
145
+        case 'action':
146
+          icon.setAttribute('icon', 'fa-spinner');
147
+          icon.removeAttribute('rotate');
148
+          icon.setAttribute('spin', true);
149
+          break;
150
+      } 
151
+    });
148 152
 
149 153
     var getArtesania = function (num) {
154
+
155
+          var Artesanos = ``;
156
+
157
+          console.log('Filtrado de ',Esp[num])
158
+
159
+          var results = [];
160
+          var searchVal = "my Name";
161
+          for (var i=0 ; i < artesanos_json.length ; i++)
162
+          {
163
+              if (artesanos_json[i].Especificaciones.includes(Esp[num])) {
164
+                  results.push(artesanos_json[i]);
165
+              }
166
+          }
167
+
168
+          /*var arr1=artesanos_json.filter(function(item){
169
+              return item.Nombre=="Ana";       
170
+          });*/
171
+
172
+          for(var i=0; i<results.length; i++) {
173
+
174
+            //if(Esp[num] in artesanos_json.) {}
175
+            Artesanos=Artesanos+`<a id='home.html'>${results[i].Nombre} | ${results[i].Municipio}<br>`
176
+            //`<a id='home.html'>${Artesania.artesano} | ${Artesania.municipio}</a> `
177
+          }
178
+
179
+
150 180
           return {
151
-            name: Esp[num]
181
+            name: Esp[num],
182
+            artesan: Artesanos
152 183
           };
153 184
         };
185
+
154 186
         var getData = function () {
155 187
           const data = [];
156 188
           for (var i = 0; i < Esp.length; i++) {
@@ -160,23 +192,20 @@
160 192
         };
161 193
         var createArtesania = function (Artesania) {
162 194
 
163
-      var Artesanos = ``;
164
-      for(var i=0; i<5; i++) {
165
-        Artesanos=Artesanos+`<a id='home.html'>${art[i]} | ${mun[i]}<br>`
166
-        //`<a id='home.html'>${Artesania.artesano} | ${Artesania.municipio}</a> `
167
-      }
168
-        console.log('Devuelto elemento')
195
+        //console.log('Devuelto elemento')
196
+
169 197
             return ons.createElement(`
170 198
               <ons-list-item expandable tappable>
171 199
                 <div class="center" >${Artesania.name}</div>
172
-                <div class="expandable-content"> Artesanos que trabajan con ${Artesania.name}:<br><br>
173
-        ${Artesanos}</div></ons-list-item>` 
200
+                <div class="expandable-content"> Artesanos que trabajan con ${Artesania.name}:<br><br>${Artesania.artesan}</div>
201
+                </ons-list-item>` 
174 202
           );
175 203
         };
204
+                
176 205
         var Artesanias = getData();
177 206
 
178 207
         for (Art of Artesanias) {
179
-  
208
+        
180 209
           var Artesania = createArtesania(Art);
181 210
           document.getElementById('artesania-list').appendChild(Artesania);
182 211
         };
@@ -187,6 +216,40 @@
187 216
             done();
188 217
           }, 400);
189 218
         }
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+        var createArtesano = function (Artesano) {
231
+
232
+            return ons.createElement(`
233
+              <ons-list-item expandable tappable>
234
+                <div class="center" >${Artesano.Nombre}</div>
235
+                <div class="expandable-content"> Municipio: ${Artesano.Municipio}<br>
236
+                                                 Tel\u00e9fono: ${Artesano["Tel\u00e9fono 1"]}<br>
237
+                                                 Correo Electr\u00f3nico: ${Artesano["E-mail"]}<br>
238
+                                                 Trabaja con: ${Artesano.Especificaciones}<br>
239
+                                                 </div>
240
+              </ons-list-item>` 
241
+          );
242
+        };
243
+
244
+        //var Artesanias = getData();
245
+        //artesanos_json
246
+
247
+        for (arte of artesanos_json) {
248
+        
249
+          var Artesano = createArtesano(arte);
250
+          document.getElementById('artesanos-list').appendChild(Artesano);
251
+        };
252
+        
190 253
       };
191 254
      </script>
192 255
 
@@ -201,6 +264,25 @@
201 264
 
202 265
 
203 266
 
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
204 286
         <template id="home.html">
205 287
         <ons-page id="home">
206 288
                 <p style="text-align: center;">

+ 9
- 2
platforms/browser/www/js/load.js Voir le fichier

@@ -14,10 +14,17 @@ window.fn.loadLink = function (url) {
14 14
 };
15 15
 
16 16
 window.fn.pushPage = function (page, anim) {
17
+
18
+	//Open and send json file that is equivalent with the especification.
19
+	var request = new XMLHttpRequest();
20
+	request.open("GET", "Server/" + page.title.toUpperCase() + ".json", false);
21
+	request.send(null)
22
+	var artesanos = JSON.parse(request.responseText);
23
+
17 24
   if (anim) {
18
-    document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp } , animation: anim });
25
+    document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp, json: artesanos } , animation: anim });
19 26
   } else {
20
-    document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp } });
27
+    document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp, json: artesanos } });
21 28
   }
22 29
 };
23 30
 

+ 141
- 63
www/index.html Voir le fichier

@@ -31,6 +31,7 @@
31 31
         <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *; img-src 'self' data: content:;">
32 32
         <!--these three for the calendar-->
33 33
         <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
34
+        <link href="css/robotocondensed.css" rel="stylesheet">
34 35
         <link rel="stylesheet" href="calendar_files/css/demo.css"/>
35 36
         <link rel="stylesheet" href="css/file.css"/>
36 37
         <link rel="stylesheet" href="calendar_files/css/theme1.css"/>
@@ -68,6 +69,31 @@
68 69
 
69 70
 
70 71
 
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
71 97
   <template id="artesanias.html">
72 98
     <ons-page id="artesanias">
73 99
 
@@ -81,7 +107,11 @@
81 107
     </ons-pull-hook>
82 108
 
83 109
     <ons-list id="artesania-list" src="">
84
-      <ons-list-header>Pull to refresh</ons-list-header>
110
+      <ons-list-header>Artesanias</ons-list-header>
111
+    </ons-list>
112
+
113
+    <ons-list id="artesanos-list" src="">
114
+      <ons-list-header>Artesanos</ons-list-header>
85 115
     </ons-list>
86 116
 
87 117
     <script>
@@ -89,68 +119,70 @@
89 119
       ons.getScriptPage().onInit = function () {
90 120
         this.querySelector('ons-toolbar div.center').textContent = this.data.title;
91 121
 
92
-    var File = this.data.title.toUpperCase() + '.json' ;
122
+    //var File = this.data.title.toUpperCase() + '.json' ;
93 123
     var Esp = this.data.esp.split(', ');
94
-    var art=new Array('Ta\u00edno - Ram\u00f3n Rivera','Aladino Mu\u00f1iz Ram\u00edrez','Alma L. Albino Ortiz','Jeanette H. Figueroa','Sonia Noem\u00ed Rodr\u00edguez Salgado');
95
-    var mun=new Array('Vega Baja PR','Sabana Grande PR','Naguabo PR','Ceiba PR','Fajardo PR');
96
-
97
-
98
-    var request = new XMLHttpRequest();
99
-    request.open('GET', 'Server/'+File, true);
100
-    request.onload = function() {
101
-    var info = JSON.parse(this.response)
102
-    var list = document.getElementById("artesania-list");
103
-    for (var i = 0; i < info.length; i++) {
104
-
105
-      art.push(info[i].Nombre);
106
-      mun.push(info[i].Municipio);
107
-        
108
-      /*var item = ons.createElement(`<ons-card onclick="fn.pushPage({'id':'artesanias.html','title':'${info[i].Renglones}', 
109
-      'esp': '${info[i].Especificaciones}'})">
110
-                    <div class="title">${info[i].Renglones}</div>
111
-                </ons-card>`);
112
-        list.appendChild(item);*/
113
-    }
114
-    console.log('Termino funcion',art)
115
-    }
116
-    //<div class="right"><img class="list-item__thumbnail" src="img/${info[i].Renglones}.png"></div>
117
-    request.send();
118
-
119
-    console.log('Fuera del codigo',art)
124
+    var artesanos_json = this.data.json;
120 125
 
121 126
     //Convertir en mayuscula primera letra del string.
122 127
     for(var i=0; i<Esp.length; i++) { 
123 128
       Esp[i] = Esp[i].charAt(0).toUpperCase() + Esp[i].slice(1);
124 129
     };
125 130
 
126
-        var pullHook = document.getElementById('pull-hook');
127
-        var icon = document.getElementById('pull-hook-icon');
128
-        pullHook.addEventListener('changestate', function (event) {
129
-          switch (event.state) {
130
-            case 'initial':
131
-              icon.setAttribute('icon', 'fa-arrow-down');
132
-              icon.removeAttribute('rotate');
133
-              icon.removeAttribute('spin');
134
-              break;
135
-            case 'preaction':
136
-              icon.setAttribute('icon', 'fa-arrow-down');
137
-              icon.setAttribute('rotate', '180');
138
-              icon.removeAttribute('spin');
139
-              break;
140
-            case 'action':
141
-              icon.setAttribute('icon', 'fa-spinner');
142
-              icon.removeAttribute('rotate');
143
-              icon.setAttribute('spin', true);
144
-              break;
145
-          } 
146
-
147
-        });
131
+    var pullHook = document.getElementById('pull-hook');
132
+    var icon = document.getElementById('pull-hook-icon');
133
+    pullHook.addEventListener('changestate', function (event) {
134
+      switch (event.state) {
135
+        case 'initial':
136
+          icon.setAttribute('icon', 'fa-arrow-down');
137
+          icon.removeAttribute('rotate');
138
+          icon.removeAttribute('spin');
139
+          break;
140
+        case 'preaction':
141
+          icon.setAttribute('icon', 'fa-arrow-down');
142
+          icon.setAttribute('rotate', '180');
143
+          icon.removeAttribute('spin');
144
+          break;
145
+        case 'action':
146
+          icon.setAttribute('icon', 'fa-spinner');
147
+          icon.removeAttribute('rotate');
148
+          icon.setAttribute('spin', true);
149
+          break;
150
+      } 
151
+    });
148 152
 
149 153
     var getArtesania = function (num) {
154
+
155
+          var Artesanos = ``;
156
+
157
+          console.log('Filtrado de ',Esp[num])
158
+
159
+          var results = [];
160
+          var searchVal = "my Name";
161
+          for (var i=0 ; i < artesanos_json.length ; i++)
162
+          {
163
+              if (artesanos_json[i].Especificaciones.includes(Esp[num])) {
164
+                  results.push(artesanos_json[i]);
165
+              }
166
+          }
167
+
168
+          /*var arr1=artesanos_json.filter(function(item){
169
+              return item.Nombre=="Ana";       
170
+          });*/
171
+
172
+          for(var i=0; i<results.length; i++) {
173
+
174
+            //if(Esp[num] in artesanos_json.) {}
175
+            Artesanos=Artesanos+`<a id='home.html'>${results[i].Nombre} | ${results[i].Municipio}<br>`
176
+            //`<a id='home.html'>${Artesania.artesano} | ${Artesania.municipio}</a> `
177
+          }
178
+
179
+
150 180
           return {
151
-            name: Esp[num]
181
+            name: Esp[num],
182
+            artesan: Artesanos
152 183
           };
153 184
         };
185
+
154 186
         var getData = function () {
155 187
           const data = [];
156 188
           for (var i = 0; i < Esp.length; i++) {
@@ -160,27 +192,20 @@
160 192
         };
161 193
         var createArtesania = function (Artesania) {
162 194
 
163
-        var jqxhr = $.getJSON( "Server/"+File, function() {
164
-          console.log( "success" );
165
-        });
195
+        //console.log('Devuelto elemento')
166 196
 
167
-      var Artesanos = ``;
168
-      for(var i=0; i<10; i++) {
169
-        Artesanos=Artesanos+`<a id='home.html'>${art[i]} | ${mun[i]}<br>`
170
-        //`<a id='home.html'>${Artesania.artesano} | ${Artesania.municipio}</a> `
171
-      }
172
-        console.log('Devuelto elemento')
173 197
             return ons.createElement(`
174 198
               <ons-list-item expandable tappable>
175 199
                 <div class="center" >${Artesania.name}</div>
176
-                <div class="expandable-content"> Artesanos que trabajan con ${Artesania.name}:<br><br>
177
-        ${Artesanos}</div></ons-list-item>` 
200
+                <div class="expandable-content"> Artesanos que trabajan con ${Artesania.name}:<br><br>${Artesania.artesan}</div>
201
+                </ons-list-item>` 
178 202
           );
179 203
         };
204
+                
180 205
         var Artesanias = getData();
181 206
 
182 207
         for (Art of Artesanias) {
183
-  
208
+        
184 209
           var Artesania = createArtesania(Art);
185 210
           document.getElementById('artesania-list').appendChild(Artesania);
186 211
         };
@@ -191,6 +216,40 @@
191 216
             done();
192 217
           }, 400);
193 218
         }
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+        var createArtesano = function (Artesano) {
231
+
232
+            return ons.createElement(`
233
+              <ons-list-item expandable tappable>
234
+                <div class="center" >${Artesano.Nombre}</div>
235
+                <div class="expandable-content"> Municipio: ${Artesano.Municipio}<br>
236
+                                                 Tel\u00e9fono: ${Artesano["Tel\u00e9fono 1"]}<br>
237
+                                                 Correo Electr\u00f3nico: ${Artesano["E-mail"]}<br>
238
+                                                 Trabaja con: ${Artesano.Especificaciones}<br>
239
+                                                 </div>
240
+              </ons-list-item>` 
241
+          );
242
+        };
243
+
244
+        //var Artesanias = getData();
245
+        //artesanos_json
246
+
247
+        for (arte of artesanos_json) {
248
+        
249
+          var Artesano = createArtesano(arte);
250
+          document.getElementById('artesanos-list').appendChild(Artesano);
251
+        };
252
+        
194 253
       };
195 254
      </script>
196 255
 
@@ -205,6 +264,25 @@
205 264
 
206 265
 
207 266
 
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
208 286
         <template id="home.html">
209 287
         <ons-page id="home">
210 288
                 <p style="text-align: center;">

+ 9
- 2
www/js/load.js Voir le fichier

@@ -14,10 +14,17 @@ window.fn.loadLink = function (url) {
14 14
 };
15 15
 
16 16
 window.fn.pushPage = function (page, anim) {
17
+
18
+	//Open and send json file that is equivalent with the especification.
19
+	var request = new XMLHttpRequest();
20
+	request.open("GET", "Server/" + page.title.toUpperCase() + ".json", false);
21
+	request.send(null)
22
+	var artesanos = JSON.parse(request.responseText);
23
+
17 24
   if (anim) {
18
-    document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp } , animation: anim });
25
+    document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp, json: artesanos } , animation: anim });
19 26
   } else {
20
-    document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp } });
27
+    document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp, json: artesanos } });
21 28
   }
22 29
 };
23 30