Browse Source

Added thee search bars (Any,Artesanias,Municipios)

carlos.diaz44 4 years ago
parent
commit
f16806e543

+ 29
- 109
.idea/workspace.xml View File

@@ -2,27 +2,26 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="eb079ee0-6a1e-46bc-8208-93306bafc623" name="Default Changelist" comment="">
5
-      <change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
6
-      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/calendar_files/css/theme1.css" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/calendar_files/css/theme1.css" afterDir="false" />
7
-      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/css/index.css" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/css/index.css" afterDir="false" />
5
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
6
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/artesano.html" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/artesano.html" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Barro.jpg" beforeDir="false" />
8
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Cristal.jpg" beforeDir="false" />
9
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Cuero.jpg" beforeDir="false" />
10
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Fibras.jpg" beforeDir="false" />
11
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Higüera.jpg" beforeDir="false" />
12
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Instrumento musical.jpg" beforeDir="false" />
13
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Juguetes tradicional.jpg" beforeDir="false" />
14
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Labores en aguja.jpg" beforeDir="false" />
15
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Madera.jpg" beforeDir="false" />
16
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Metal.jpg" beforeDir="false" />
17
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Tabacos.jpg" beforeDir="false" />
18
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/img/Textiles.jpg" beforeDir="false" />
8 19
       <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/index.html" afterDir="false" />
20
+      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/js/load.js" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/js/load.js" afterDir="false" />
9 21
       <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/js/renglones.js" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/js/renglones.js" afterDir="false" />
10 22
       <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/js/saveLocal.js" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/js/saveLocal.js" afterDir="false" />
11
-      <change beforePath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/lib/OnsenUI/css/onsenui.css" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/android/app/src/main/assets/www/lib/OnsenUI/css/onsenui.css" afterDir="false" />
12
-      <change beforePath="$PROJECT_DIR$/platforms/browser/www/calendar_files/css/theme1.css" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/browser/www/calendar_files/css/theme1.css" afterDir="false" />
13
-      <change beforePath="$PROJECT_DIR$/platforms/browser/www/css/index.css" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/browser/www/css/index.css" afterDir="false" />
14
-      <change beforePath="$PROJECT_DIR$/platforms/browser/www/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/browser/www/index.html" afterDir="false" />
15
-      <change beforePath="$PROJECT_DIR$/platforms/browser/www/js/renglones.js" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/browser/www/js/renglones.js" afterDir="false" />
16
-      <change beforePath="$PROJECT_DIR$/platforms/browser/www/js/saveLocal.js" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/browser/www/js/saveLocal.js" afterDir="false" />
17
-      <change beforePath="$PROJECT_DIR$/platforms/browser/www/lib/OnsenUI/css/onsenui.css" beforeDir="false" afterPath="$PROJECT_DIR$/platforms/browser/www/lib/OnsenUI/css/onsenui.css" afterDir="false" />
18
-      <change beforePath="$PROJECT_DIR$/www/calendar_files/css/theme1.css" beforeDir="false" afterPath="$PROJECT_DIR$/www/calendar_files/css/theme1.css" afterDir="false" />
19
-      <change beforePath="$PROJECT_DIR$/www/css/index.css" beforeDir="false" afterPath="$PROJECT_DIR$/www/css/index.css" afterDir="false" />
20 23
       <change beforePath="$PROJECT_DIR$/www/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/www/index.html" afterDir="false" />
21
-      <change beforePath="$PROJECT_DIR$/www/js/azar.js" beforeDir="false" afterPath="$PROJECT_DIR$/www/js/azar.js" afterDir="false" />
22
-      <change beforePath="$PROJECT_DIR$/www/js/saveLocal.js" beforeDir="false" afterPath="$PROJECT_DIR$/www/js/saveLocal.js" afterDir="false" />
23
-      <change beforePath="$PROJECT_DIR$/www/lib/OnsenUI/css/onsenui.css" beforeDir="false" afterPath="$PROJECT_DIR$/www/lib/OnsenUI/css/onsenui.css" afterDir="false" />
24 24
     </list>
25
-    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
26 25
     <option name="SHOW_DIALOG" value="false" />
27 26
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
28 27
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -32,23 +31,9 @@
32 31
     <option name="testRunner" value="GRADLE" />
33 32
     <option name="delegatedBuild" value="true" />
34 33
   </component>
35
-  <component name="ExecutionTargetManager" SELECTED_TARGET="Pixel_API_29" />
36 34
   <component name="FavoritesManager">
37 35
     <favorites_list name="artesanias" />
38 36
   </component>
39
-  <component name="FileEditorManager">
40
-    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
41
-      <file pinned="false" current-in-tab="true">
42
-        <entry file="file://$PROJECT_DIR$/www/index.html">
43
-          <provider selected="true" editor-type-id="text-editor">
44
-            <state relative-caret-position="-730">
45
-              <caret line="428" column="34" selection-start-line="428" selection-start-column="34" selection-end-line="428" selection-end-column="34" />
46
-            </state>
47
-          </provider>
48
-        </entry>
49
-      </file>
50
-    </leaf>
51
-  </component>
52 37
   <component name="Git.Settings">
53 38
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
54 39
   </component>
@@ -62,60 +47,17 @@
62 47
       </list>
63 48
     </option>
64 49
   </component>
65
-  <component name="ProjectFrameBounds" extendedState="6">
66
-    <option name="x" value="70" />
67
-    <option name="y" value="-20" />
68
-    <option name="width" value="1940" />
69
-    <option name="height" value="1050" />
70
-  </component>
71
-  <component name="ProjectView">
72
-    <navigator currentView="ProjectPane" proportions="" version="1">
73
-      <foldersAlwaysOnTop value="true" />
74
-    </navigator>
75
-    <panes>
76
-      <pane id="ProjectPane">
77
-        <subPane>
78
-          <expand>
79
-            <path>
80
-              <item name="artesanias" type="b2602c69:ProjectViewProjectNode" />
81
-              <item name="artesanias" type="462c0819:PsiDirectoryNode" />
82
-            </path>
83
-            <path>
84
-              <item name="artesanias" type="b2602c69:ProjectViewProjectNode" />
85
-              <item name="artesanias" type="462c0819:PsiDirectoryNode" />
86
-              <item name="platforms" type="462c0819:PsiDirectoryNode" />
87
-            </path>
88
-            <path>
89
-              <item name="artesanias" type="b2602c69:ProjectViewProjectNode" />
90
-              <item name="artesanias" type="462c0819:PsiDirectoryNode" />
91
-              <item name="platforms" type="462c0819:PsiDirectoryNode" />
92
-              <item name="android" type="462c0819:PsiDirectoryNode" />
93
-            </path>
94
-          </expand>
95
-          <select />
96
-        </subPane>
97
-      </pane>
98
-      <pane id="Scope" />
99
-      <pane id="PackagesPane" />
100
-    </panes>
50
+  <component name="ProjectId" id="1hkacnpBNwnsGBZKJXzugbTopNv" />
51
+  <component name="ProjectViewState">
52
+    <option name="hideEmptyMiddlePackages" value="true" />
53
+    <option name="showExcludedFiles" value="true" />
54
+    <option name="showLibraryContents" value="true" />
101 55
   </component>
102 56
   <component name="PropertiesComponent">
103 57
     <property name="android.sdk.path" value="$USER_HOME$/SDK" />
104 58
     <property name="last_opened_file_path" value="$PROJECT_DIR$" />
105 59
     <property name="settings.editor.selected.configurable" value="AndroidSdkUpdater" />
106 60
   </component>
107
-  <component name="RunDashboard">
108
-    <option name="ruleStates">
109
-      <list>
110
-        <RuleState>
111
-          <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
112
-        </RuleState>
113
-        <RuleState>
114
-          <option name="name" value="StatusDashboardGroupingRule" />
115
-        </RuleState>
116
-      </list>
117
-    </option>
118
-  </component>
119 61
   <component name="RunManager">
120 62
     <configuration name="C:/Users/Chuch/Documents/Cordova/artesanias/platforms/android/build.gradle" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
121 63
       <ExternalSystemSettings>
@@ -153,36 +95,14 @@
153 95
     </task>
154 96
     <servers />
155 97
   </component>
156
-  <component name="ToolWindowManager">
157
-    <frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
158
-    <layout>
159
-      <window_info id="Captures" order="0" weight="0.25" />
160
-      <window_info content_ui="combo" id="Project" order="1" sideWeight="0.4978903" visible="true" weight="0.3295302" />
161
-      <window_info id="Structure" order="2" side_tool="true" />
162
-      <window_info id="Image Layers" order="3" />
163
-      <window_info id="Designer" order="4" />
164
-      <window_info id="Resources Explorer" order="5" />
165
-      <window_info id="Capture Tool" order="6" />
166
-      <window_info id="Favorites" order="7" sideWeight="0.5021097" side_tool="true" weight="0.32980832" />
167
-      <window_info anchor="bottom" id="Run" order="0" sideWeight="0.49966952" visible="true" weight="0.3286119" />
168
-      <window_info anchor="bottom" id="TODO" order="1" />
169
-      <window_info anchor="bottom" id="Debug" order="2" />
170
-      <window_info anchor="bottom" id="Terminal" order="3" />
171
-      <window_info anchor="bottom" id="Event Log" order="4" sideWeight="0.50033045" side_tool="true" visible="true" weight="0.3286119" />
172
-      <window_info anchor="bottom" id="Version Control" order="5" />
173
-      <window_info anchor="right" id="Assistant" weight="0.33489934" />
174
-      <window_info anchor="right" id="Capture Analysis" order="0" />
175
-      <window_info anchor="right" id="Theme Preview" order="1" />
176
-      <window_info anchor="right" id="Palette&#9;" order="2" />
177
-    </layout>
178
-  </component>
179
-  <component name="editorHistoryManager">
180
-    <entry file="file://$PROJECT_DIR$/www/index.html">
181
-      <provider selected="true" editor-type-id="text-editor">
182
-        <state relative-caret-position="-730">
183
-          <caret line="428" column="34" selection-start-line="428" selection-start-column="34" selection-end-line="428" selection-end-column="34" />
184
-        </state>
185
-      </provider>
186
-    </entry>
98
+  <component name="WindowStateProjectService">
99
+    <state x="1060" y="100" width="721" height="853" key="com.android.tools.idea.avdmanager.AvdListDialog" timestamp="1600557814931">
100
+      <screen x="0" y="0" width="1920" height="1053" />
101
+    </state>
102
+    <state x="1060" y="100" width="721" height="853" key="com.android.tools.idea.avdmanager.AvdListDialog/0.0.1920.1053@0.0.1920.1053" timestamp="1600557814931" />
103
+    <state x="1103" y="354" key="com.intellij.ide.util.TipDialog" timestamp="1600557633060">
104
+      <screen x="0" y="0" width="1920" height="1053" />
105
+    </state>
106
+    <state x="1103" y="354" key="com.intellij.ide.util.TipDialog/0.0.1920.1053@0.0.1920.1053" timestamp="1600557633060" />
187 107
   </component>
188 108
 </project>

+ 11
- 0
platforms/android/android/.json View File

@@ -0,0 +1,11 @@
1
+{
2
+  "prepare_queue": {
3
+    "installed": [],
4
+    "uninstalled": []
5
+  },
6
+  "config_munge": {
7
+    "files": {}
8
+  },
9
+  "installed_plugins": {},
10
+  "dependent_plugins": {}
11
+}

+ 38
- 42
platforms/android/app/src/main/assets/www/artesano.html View File

@@ -1,72 +1,68 @@
1 1
 <!DOCTYPE html>
2 2
 <html>
3 3
 <head>
4
-	<title>Artesanos</title>
4
+    <title>Artesanos</title>
5 5
 
6
-	<script src="jquery/dist/jquery.min.js">
7
-	</script>
6
+    <script src="jquery/dist/jquery.min.js">
7
+    </script>
8 8
 
9 9
 
10 10
 </head>
11 11
 <body>
12 12
 
13
-	<ons-toolbar>
14
-  		<div class="left">
15
-    		<ons-back-button>Back</ons-back-button>
16
-  		</div>
17
-	</ons-toolbar>
13
+    <ons-toolbar>
14
+        <div class="left">
15
+            <ons-back-button>Back</ons-back-button>
16
+        </div>
17
+    </ons-toolbar>
18 18
 
19 19
 
20 20
 
21
-	<script type="text/javascript">
22
-	function getUrlVars() {
23
-    	var vars = [], hash;
24
-    	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
25
-    	for(var i = 0; i < hashes.length; i++)
26
-    	{
27
-        	hash = hashes[i].split('=');
28
-        	vars.push(hash[0]);
29
-        	vars[hash[0]] = hash[1];
30
-    	}
31
-    	return vars;
32
-	}
21
+    <script type="text/javascript">
22
+    function getUrlVars() {
23
+        var vars = [], hash;
24
+        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
25
+        for(var i = 0; i < hashes.length; i++)
26
+        {
27
+            hash = hashes[i].split('=');
28
+            vars.push(hash[0]);
29
+            vars[hash[0]] = hash[1];
30
+        }
31
+        return vars;
32
+    }
33 33
 
34
-	nombre = decodeURIComponent(getUrlVars()["nombre"]);
35
-	renglon = "json/MADERA.json";
36
-	
34
+    nombre = decodeURIComponent(getUrlVars()["nombre"]);
35
+    renglon = "json/MADERA.json";
36
+    
37 37
 
38
-	$.getJSON(renglon, function(json) {
39
-    	for (i = 0; i < json.length; i++) {
40
-    		if (json[i].Nombre == nombre) {
41
-    			break;
42
-    		}
43
-    	}
38
+    $.getJSON(renglon, function(json) {
39
+        for (i = 0; i < json.length; i++) {
40
+            if (json[i].Nombre == nombre) {
41
+                break;
42
+            }
43
+        }
44 44
 
45
-    	var telefono = "Teléfono 1";
46
-    	var clickTel = (((json[i]["Teléfono 1"].replace('(', "")).replace(')', "")).replace('-', "")).replace(' ', "");
45
+        console.log("entre a artesano.html...???");
47 46
 
48
-    	var email = "E-mail";
47
+        document.write("<h1 align='center'>" + json[i].Nombre + "</h1>");
49 48
 
49
+        document.write("<h2 align='center'>" + json[i].Municipio + "</h1>");
50 50
 
51
-    	document.write("<h1 align='center'>" + json[i].Nombre + "</h1>");
51
+        document.write("<h2 align='center'>" + json[i].Especificaciones + "</h2>");
52 52
 
53
-    	document.write("<h2 align='center'>" + json[i].Municipio + "</h1>");
53
+        document.write("<a class='button' href='tel://" + json[i]["Teléfono 1"] + "'>" + "<h2 align='center'>" + json[i]["Teléfono 1"] + "</h2>" + "</a>");
54 54
 
55
-    	document.write("<h2 align='center'>" + json[i].Especificaciones + "</h2>");
55
+        document.write("<a href='mailto:" + json[i]["E-mail"] + "'>" + "<h2 align='center'>" + json[i]["E-mail"] + "</h2>" + "</a>");
56 56
 
57
-    	document.write("<a class='button' href='tel://" + clickTel + "'>" + "<h2 align='center'>" + json[i][telefono] + "</h2>" + "</a>");
58 57
 
59
-    	document.write("<a href='mailto:" + json[i][email] + "'>" + "<h2 align='center'>" + json[i][email] + "</h2>" + "</a>");
60 58
 
59
+    });
61 60
 
62 61
 
63
-	});
64 62
 
65 63
 
66
-
67
-
68
-	
69
-	</script>
64
+    
65
+    </script>
70 66
 
71 67
 </body>
72 68
 </html>

platforms/android/app/src/main/assets/www/img/Barro.jpg → platforms/android/app/src/main/assets/www/img/BARRO.jpg View File


platforms/android/app/src/main/assets/www/img/Cristal.jpg → platforms/android/app/src/main/assets/www/img/CRISTAL.jpg View File


platforms/android/app/src/main/assets/www/img/Cuero.jpg → platforms/android/app/src/main/assets/www/img/CUERO.jpg View File


platforms/android/app/src/main/assets/www/img/Fibras.jpg → platforms/android/app/src/main/assets/www/img/FIBRAS.jpg View File


platforms/android/app/src/main/assets/www/img/Higüera.jpg → platforms/android/app/src/main/assets/www/img/HIGÜERA.jpg View File


platforms/android/app/src/main/assets/www/img/Instrumento musical.jpg → platforms/android/app/src/main/assets/www/img/INSTRUMENTO TÍPICO.jpg View File


platforms/android/app/src/main/assets/www/img/Juguetes tradicional.jpg → platforms/android/app/src/main/assets/www/img/JUGUETES TRADICIONAL.jpg View File


platforms/android/app/src/main/assets/www/img/Labores en aguja.jpg → platforms/android/app/src/main/assets/www/img/LABORES EN AGUJA.jpg View File


platforms/android/app/src/main/assets/www/img/Madera.jpg → platforms/android/app/src/main/assets/www/img/MADERA.jpg View File


platforms/android/app/src/main/assets/www/img/Metal.jpg → platforms/android/app/src/main/assets/www/img/METAL.jpg View File


platforms/android/app/src/main/assets/www/img/Tabacos.jpg → platforms/android/app/src/main/assets/www/img/TABACOS.jpg View File


platforms/android/app/src/main/assets/www/img/Textiles.jpg → platforms/android/app/src/main/assets/www/img/TEXTILES.jpg View File


+ 100
- 131
platforms/android/app/src/main/assets/www/index.html View File

@@ -53,7 +53,7 @@
53 53
 
54 54
       <script type="text/javascript" src="js/saveLocal.js"></script>
55 55
 
56
-
56
+      <script> console.log(window.localStorage.getItem("MADERA")); </script>
57 57
 
58 58
 
59 59
         <ons-navigator swipeable animation="slide" id="myNavigator">
@@ -117,12 +117,12 @@
117 117
                     ons.getScriptPage().onInit = function () {
118 118
                         this.querySelector('ons-toolbar div.center').textContent = this.data.title;
119 119
 
120
-                        console.log("test");
121 120
 
122 121
                         //var File = this.data.title.toUpperCase() + '.json' ;
123
-                        var Esp = this.data.esp.split(';');
122
+                        var Esp = this.data.esp.split(', ');
124 123
                         var artesanos_json = this.data.json;
125 124
 
125
+
126 126
                         //Convertir en mayuscula primera letra del string.
127 127
                         for(var i=0; i<Esp.length; i++) {
128 128
                             Esp[i] = Esp[i].charAt(0).toUpperCase() + Esp[i].slice(1);
@@ -160,7 +160,7 @@
160 160
                             var searchVal = "my Name";
161 161
                             for (var i=0 ; i < artesanos_json.length ; i++)
162 162
                             {
163
-                                if (artesanos_json[i].Especificaciones1.includes(Esp[num])) {
163
+                                if (artesanos_json[i].Especificaciones.includes(Esp[num])) {
164 164
                                     results.push(artesanos_json[i]);
165 165
                                 }
166 166
                             }
@@ -198,8 +198,8 @@
198 198
               <ons-list-item expandable tappable>
199 199
                 <div class="center" >${Artesano.Nombre}</div>
200 200
                 <div class="expandable-content"> Municipio: ${Artesano.Municipio}<br>
201
-                                                 Tel\u00e9fono: ${Artesano["Telefono1"]}<br>
202
-                                                 Correo Electr\u00f3nico: ${Artesano["E-mail1"]}<br>
201
+                                                 Tel\u00e9fono: ${Artesano["Telefono 1"]}<br>
202
+                                                 Correo Electr\u00f3nico: ${Artesano["E-mail"]}<br>
203 203
                                                  </div>
204 204
               </ons-list-item>`
205 205
                                                     );
@@ -217,20 +217,20 @@
217 217
                             if (Artesano.Municipio.trim().length != 0) {
218 218
                                 cont ++;
219 219
                             }
220
-                            if (Artesano["Telefono1"].trim().length != 0) {
220
+                            if (Artesano["Telefono 1"].trim().length != 0) {
221 221
                                 cont ++;
222 222
                             }
223
-                            if (Artesano["E-mail1"].trim().length != 0) {
223
+                            if (Artesano["E-mail"].trim().length != 0 & Artesano["E-mail"].toUpperCase().trim() != "NO TIENE") {
224 224
                                 cont ++;
225 225
                             }
226
-                            if (Artesano.Especificaciones1.trim().length != 0) {
226
+                            if (Artesano.Especificacion.trim().length != 0) {
227 227
                                 cont ++;
228 228
                             }
229 229
 
230 230
 
231 231
                             //info a pasar
232 232
                             //'title':'${Artesano.Nombre}','esp': '${info}'
233
-                            var item = ons.createElement(`<ons-list-item onclick="myNavigator.pushPage('artesano.html', { data: { title: '${Artesano.Nombre}', mun: '${Artesano.Municipio}', tel: '${Artesano["Telefono1"]}', email: '${Artesano["E-mail1"]}', esp: '${Artesano.Especificaciones1}' } })" tappable>
233
+                            var item = ons.createElement(`<ons-list-item onclick="myNavigator.pushPage('artesano.html', { data: { title: '${Artesano.Nombre}', mun: '${Artesano.Municipio}', tel: '${Artesano["Telefono 1"]}', email: '${Artesano["E-mail"]}', redes: '${Artesano["E-Commerce1"]}', esp: '${Artesano.Especificacion}' } })" tappable>
234 234
                         <div class="title">${Artesano.Nombre}</div>
235 235
                     </ons-list-item>`);
236 236
 
@@ -324,7 +324,7 @@
324 324
                              var searchVal = "my Name";
325 325
                              for (var i=0 ; i < artesanos_json.length ; i++)
326 326
                              {
327
-                                 if (artesanos_json[i].Especificaciones.includes(Esp[num])) {
327
+                                 if (artesanos_json[i].Especificacion.includes(Esp[num])) {
328 328
                                      results.push(artesanos_json[i]);
329 329
                                  }
330 330
                              }
@@ -337,7 +337,7 @@
337 337
 
338 338
                                  //if(Esp[num] in artesanos_json.) {}
339 339
                                  Artesanos+=`${results[i].Nombre}|`
340
-                                 ArtesanosInfo+=`${results[i].Municipio}|${results[i]["Tel\u00e9fono 1"]}|${results[i]["E-mail"]}|${results[i].Especificaciones}&&`
340
+                                 ArtesanosInfo+=`${results[i].Municipio}|${results[i]["Telefono 1"]}|${results[i]["E-mail"]}|${results[i].Especificacion}&&`
341 341
                                  //`<a id='home.html'>${Artesania.artesano} | ${Artesania.municipio}</a> `
342 342
                              }
343 343
 
@@ -410,139 +410,93 @@
410 410
         </template>
411 411
 
412 412
 <!-- ------------------------------------------------------------------------------------------------------------------------------------------------------- -->
413
-
414
-        <template id="artesano.html">
415
-            <ons-page id="artesano">
416
-                <ons-toolbar>
417
-                    <div class="left"><ons-back-button>Atras</ons-back-button></div>
418
-                    <div class="center"></div>
419
-                </ons-toolbar>
420
-                <body>
421
-                    <ons-card id="all"></ons-card>
422
-                </body>
423
-                <script>
424
-                    ons.getScriptPage().onInit = function () {
425
-                        this.querySelector('ons-toolbar div.center').textContent = this.data.title;
426
-
427
-                        var info = ``,
428
-                            mun = this.data.mun,
429
-                            tel = this.data.tel,
430
-                            email = this.data.email,
431
-                            esp = this.data.esp;
432
-
433
-                        if(mun.trim() != '') {
434
-                            info = info + `Municipio: ` + mun + `<br>`;
435
-                        }
436
-                        if(tel.trim() != '') {
437
-                            info = info + `Tel\u00e9fono: <a href="tel:+1` + tel + `">` + tel + `</a><br>`;
438
-                        }
439
-                        if(email.trim() != '') {
440
-                            info = info + `Correo Electr\u00f3nico: ` + email + `<br>`;
441
-                        }
442
-                        if(esp.trim() != '') {
443
-                            info = info + `Trabaja con: ` + esp + `<br>`;
444
-                        }
445
-
446
-                        document.getElementById("all").innerHTML = `${info}`;
447
-
448
-                    }
449
-                </script>
450
-
451
-            </ons-page>
452
-        </template>
453
-
454
-<!-- ------------------------------------------------------------------------------------------------------------------------------------------------------- -->
455
-
413
+<!----------------------------------------------------------------------------------->
414
+        <script src = "js/searchfunctions.js"></script>
456 415
         <script>
457
-            var Madera = JSON.parse(window.localStorage.getItem("TODOS"));
416
+            //JSON file that has all the artesanos 
417
+            var all_artesanos = JSON.parse(window.localStorage.getItem("TODOS"));
458 418
             function filter(){
459
-
460
-
461
-                // var request = new XMLHttpRequest()
462
-                // request.open('GET','json/MADERA.json',true)
463
-                // request.onload = function(){
464
-                //   var Madera = JSON.parse(this.response)
465
-                // }
466
-                // request.send()
467
-                // var input = document.getElementById('searchbar').value
468
-                // var firstwood = Madera[0].Nombre
469
-                // ons.notification.alert('Searched for: ' + firstwood)
470
-                var input = document.getElementById('searchbar').value
419
+                var input = document.getElementById('searchbar').value;
420
+                var inputarte = document.getElementById('searchartesania').value;
421
+                var inputmuni = document.getElementById('searchbarmunicipio').value;
471 422
                 var x = document.getElementsByClassName('artists');
423
+                //making sure they're all in the same format
472 424
                 input = input.trim().toLowerCase();
473
-                if (input.length == 0){
474
-                    for (i = 0; Madera.length; i++){
425
+                inputarte = inputarte.trim().toLowerCase();
426
+                inputmuni = inputmuni.trim().toLowerCase();
427
+                input = acento_replace(input);
428
+                inputarte = acento_replace(inputarte);
429
+                inputmuni = acento_replace(inputmuni);
430
+                //default case is where evey one of them has nothing or less than 3 characters (displays every artist)
431
+                if (input.length <= 3 && inputarte.length <= 3 && inputmuni.length <= 3){
432
+                    for (var i = 0; all_artesanos.length; i++){
475 433
                         x[i].style.display = "list-item";
476 434
                     }
477 435
                 }
478 436
                 else{
479
-                    var foundesp = 0;
480
-                    for (i = 0; i < Madera.length; i++){
481
-                        console.log("damn")
482
-                        //try checking the especificacion first
483
-                        var especificaciones = Madera[i].Especificaciones1;
484
-                        especificaciones = especificaciones.split(';');
485
-                        for (var j = 0; j < especificaciones.length; j++){
486
-                            var especificacion = especificaciones[j];
487
-                            especificacion = especificacion.trim().toLowerCase();
488
-                            if (input == especificacion){
489
-                                x[i].style.display = "list-item";
490
-                                foundesp = 1;
491
-                                break;
492
-                            }
493
-                            else{
494
-                                x[i].style.display = "none";
495
-                            }
496
-                        }
437
+                    var cases = 0;
438
+                    cases = getcasenum(input,inputarte,inputmuni);
439
+                    //take every one of them out first (dont display any)
440
+                    for (var i = 0; i < all_artesanos.length; i++){
441
+                        x[i].style.display = "none";
497 442
                     }
498
-                    if (foundesp != 1){
499
-                        input = input.trim().toLowerCase().split(' ')
500
-                        //changing the input into something that can be searched
501
-                        for (var i = 0; i < input.length; i++){
502
-                            input[i] = input[i].charAt(0).toUpperCase() + input[i].slice(1);
503
-                        }
504
-                        console.log(input);
505
-                        for(var i = 0; i < Madera.length; i++){
506
-                            count = 0;
507
-                            artist = Madera[i].Nombre.trim().split(' ');
508
-                            for (k = 0; k < input.length; k++){
509
-                                for (var l = 0; l < artist.length; l++){
510
-                                    if(artist[l] == input[k]){
511
-                                        x[i].style.display = "list-item";
512
-                                        break;
513
-                                    }
514
-                                    else{
515
-                                        x[i].style.display = "none";
516
-                                    }
517
-                                }
518
-                            }
519
-                        }
443
+                    switch(cases){
444
+                        //cases == 1 when only inputmuni has been writen on
445
+                        case 1:
446
+                            filter_municipios(inputmuni);
447
+                            break;
448
+                        //cases == 2 when only inputarte has been written on
449
+                        case 2:
450
+                            filter_artesanias(inputarte);
451
+                            break;
452
+                        //cases == 3 when inputarte and inputmuni has been written on
453
+                        case 3:
454
+                            search_art_mun(inputarte,inputmuni);
455
+                            break;
456
+                        //cases == 4 when input has been writen on
457
+                        case 4:
458
+                            filter_any(input);
459
+                            break;
460
+                        //cases == 5 when input and inputmuni has been written on
461
+                        case 5:
462
+                            search_any_mun(input,inputmuni);
463
+                            break;
464
+                        //cases == 6 when input and inputart has been written on
465
+                        case 6:
466
+                            search_any_art(input,inputarte);
467
+                            break;
468
+                        //cases == 7 when input, inputart and inputmuni has been writen on
469
+                        case 7:
470
+                            search_any_art_mun(input,inputarte,inputmuni);
471
+                            break;
520 472
                     }
521 473
                 }
522
-            }
474
+            }            
523 475
         </script>
524 476
 
525 477
         <template id="search.html">
526 478
             <ons-page id="Buscar">
527
-
528 479
                 <p style="text-align: center; margin-top: 10px;">
529
-                    <ons-search-input placeholder="Search" id = "searchbar"
530
-                                      onchange = "filter()"
531
-                                      ></ons-search-input>
480
+                    <ons-search-input placeholder="Search anything" id = "searchbar"
481
+                        onkeyup = "filter()"></ons-search-input>
482
+                    <ons-search-input placeholder="Tipo de artesania" id = "searchartesania" 
483
+                        onkeyup = "filter()"></ons-search-input>
484
+                    <ons-search-input placeholder = "Municipio" id = "searchbarmunicipio"
485
+                        onkeyup = "filter()"></ons-search-input>
532 486
                 </p>
533 487
 
534 488
                 <ons-list id="results" src="">
535 489
                 </ons-list>
536 490
 
537 491
                 <script>
538
-                    for (i = 0; i < Madera.length;i++){
492
+                    for (i = 0; i < all_artesanos.length;i++){
539 493
                         var artesano = ons.createElement(`<ons-list-item class = "artists"
540
-                        onclick="myNavigator.pushPage('artesano.html', { data: {title: '${Madera[i].Nombre}', mun: '${Madera[i].Municipio}', tel: '${Madera[i]["Telefono1"]}', email: '${Madera[i]["E-mail1"]}', esp: '${Madera[i].Especificaciones1}' } })" tappable>
541
-                        <div>${Madera[i].Nombre}</div>
494
+                        onclick="myNavigator.pushPage('artesano.html', { data: {title: '${all_artesanos[i].Nombre}', mun: '${all_artesanos[i].Municipio}', tel: '${all_artesanos[i]["Telefono 1"]}', email: '${all_artesanos[i]["E-mail"]}', redes: '${all_artesanos[i]["E-Commerce"]}', esp: '${all_artesanos[i].Especificacion}' } })" tappable>
495
+                        <div>${all_artesanos[i].Nombre}</div>
542 496
                     </ons-list-item>`);
543 497
                         // var artesano = ons.createElement(`
544 498
                         //   <ons-list-item class = "artists">
545
-                        //     <div class="center" >${Madera[i].Nombre}</div>
499
+                        //     <div class="center" >${all_artesanos[i].Nombre}</div>
546 500
                         //   </ons-list-item>`
547 501
                         // );
548 502
                         document.getElementById('results').appendChild(artesano);
@@ -567,26 +521,41 @@
567 521
                     ons.getScriptPage().onInit = function () {
568 522
                         this.querySelector('ons-toolbar div.center').textContent = this.data.title;
569 523
 
570
-                        var info = ``,
524
+                        var data = '',
571 525
                             mun = this.data.mun,
572 526
                             tel = this.data.tel,
573
-                            email = this.data.email,
527
+                            em = this.data.email,
574 528
                             esp = this.data.esp;
575 529
 
576
-                        if(mun.trim() != '') {
577
-                            info = info + `Municipio: ` + mun + `<br>`;
530
+                        email = em.slice(0, em.search("#"));
531
+                        if(esp.trim() != ""){
532
+                            if(esp.includes(";", 0)){
533
+                                esp=esp.replace(/;/g,", ");
534
+                                data+='Tipos de artesanias: '+esp+'<br>';
535
+                            }
536
+                            else {
537
+                                data+='Tipo de artesania: '+esp+'<br>';
538
+                            }
578 539
                         }
579
-                        if(tel.trim() != '') {
580
-                            info = info + `Tel\u00e9fono: <a href="tel:+1` + tel + `">` + tel + `</a><br>`;
540
+
541
+                        //console.log("Las redes son..."+this.data.redes);
542
+
543
+                        if(mun.trim() != ""){
544
+                            data+='Municipio: '+ mun +'<br>';
581 545
                         }
582
-                        if(email.trim() != '') {
583
-                            info = info + `Correo Electr\u00f3nico: ` + email + `<br>`;
546
+                        
547
+                        if(email.trim() != "" & email.toUpperCase().trim() != "NO TIENE"){
548
+                            data+='Correo Electr\u00f3nico: <a style="color:blue" href="mailto: '+email+'"><u>'+email+'</u></a><br>';
584 549
                         }
585
-                        if(esp.trim() != '') {
586
-                            info = info + `Trabaja con: ` + esp + `<br>`;
550
+
551
+                        //Underlined <u></u>
552
+                        //Color blue <p style="color:blue"></p>
553
+
554
+                        if(tel.trim() != "" ){
555
+                            data+='Tel\u00e9fono: <a style="color:blue" href="tel: '+ tel +'"><u>'+ tel +'</u></a><br>';
587 556
                         }
588 557
 
589
-                        document.getElementById("all").innerHTML = `${info}`;
558
+                        document.getElementById("all").innerHTML = `${data}`;
590 559
 
591 560
                     }
592 561
                 </script>
@@ -710,4 +679,4 @@
710 679
         <script type="text/javascript" src="cordova.js"></script>
711 680
         <script type="text/javascript" src="js/index.js"></script>
712 681
     </body>
713
-</html>
682
+</html>

+ 3
- 3
platforms/android/app/src/main/assets/www/js/load.js View File

@@ -15,12 +15,12 @@ window.fn.loadLink = function (url) {
15 15
 
16 16
 window.fn.pushPage = function (page, anim) {
17 17
 
18
-	//Open and send json file that is equivalent with the especification.
19
-	var artesanos = JSON.parse(window.localStorage.getItem(page.title.toUpperCase()));
18
+  //Open and send json file that is equivalent with the especification.
19
+  var artesanos = JSON.parse(window.localStorage.getItem(page.title.toUpperCase()));
20 20
 
21 21
   if (anim) {
22 22
     document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp, json: artesanos } , animation: anim });
23 23
   } else {
24 24
     document.getElementById('myNavigator').pushPage(page.id, { data: { title: page.title, esp: page.esp, json: artesanos } });
25 25
   }
26
-};
26
+};

+ 7
- 4
platforms/android/app/src/main/assets/www/js/renglones.js View File

@@ -1,9 +1,12 @@
1 1
 var info = JSON.parse(window.localStorage.getItem("RENGLONES"));
2
-console.log("TEST!!!");
2
+
3
+
4
+
3 5
 var list = document.getElementById("list");
4 6
 
5
-console.log(info.length);
6
-  for (var i = 0; i < info.length(); i++) {
7
+  for (var i = 0; i < info.length; i++) {
8
+
9
+          
7 10
 
8 11
           var item = ons.createElement(`<ons-list-item expandable onclick="hideAll()">
9 12
                       <div class="center">${info[i].Renglones}</div>
@@ -21,4 +24,4 @@ console.log(info.length);
21 24
   /*`<ons-card onclick="fn.pushPage({'id':'artesanias.html','title':'${info[i].Renglones}','esp': '${info[i].Especificaciones}'})">
22 25
                         <div class="title">${info[i].Renglones}</div>
23 26
                         <div class="content"><img class="list-item__thumbnail" src="img/${info[i].Renglones}.png"></div>
24
-                    </ons-card>`*/
27
+                    </ons-card>`*/

+ 1
- 1
platforms/android/app/src/main/assets/www/js/saveLocal.js View File

@@ -38,4 +38,4 @@ try {
38 38
   }
39 39
   } catch {
40 40
     console.log("error");
41
-  }
41
+  }

+ 260
- 0
platforms/android/app/src/main/assets/www/js/searchfunctions.js View File

@@ -0,0 +1,260 @@
1
+//Basic shit to understand
2
+//all_artesanos is the json that has the file that contains all the artesanos, this includes the studd they do,municipio,telefono,email and name
3
+//x is going to be what is displayed in the app, it basically has the same infromation as all_artesanos
4
+//THe basic mechanic is to display each artist in the search tab whenever something of them is found
5
+//You need at least 3 characters in one of the searchbars for it to display something
6
+//If nothing is written then it will display every artists
7
+//Some of these functions also try to make sure that the inputs are the same format as the thing they're looking up so that they dont have to follow a specific syntax to look for stuff
8
+
9
+//Tries to filter by the type of work that the artists do, if what they wrote in inputarte is included in one of them then the artists is displayed in the search bar
10
+function filter_artesanias(inputarte){
11
+    var x = document.getElementsByClassName('artists');
12
+    for (var i = 0; i < all_artesanos.length; i++){
13
+        var especificaciones = all_artesanos[i].Especificacion;
14
+        especificaciones = especificaciones.trim().toLowerCase();
15
+        especificaciones = acento_replace(especificaciones);
16
+        if (especificaciones.search(inputarte) != -1){
17
+            x[i].style.display = "list-item";
18
+        }
19
+        //before it did this down here but im keeping it just in case...
20
+        //especificaciones = especificaciones.split(',');
21
+        //for (var j = 0; j < especificaciones.length; j++){
22
+            //var especificacion = especificaciones[j];
23
+            //especificacion = especificacion.trim().toLowerCase();
24
+            //especificacion = acento_replace(especificacion);
25
+            //if (especificacion.search(inputarte) != -1){
26
+                //x[i].style.display = "list-item";
27
+                //break;
28
+            //}
29
+
30
+        }
31
+    return;
32
+}
33
+
34
+//Tries to filter by the municipio that they reside in or work in (not sure which one of the two it is)
35
+function filter_municipios(inputmuni){
36
+    var x = document.getElementsByClassName('artists');
37
+    for (var i = 0; i < all_artesanos.length; i++){
38
+        var municipio = all_artesanos[i].Municipio;
39
+        municipio = municipio.trim().toLowerCase();
40
+        municipio = acento_replace(municipio);
41
+        if (municipio.search(inputmuni)!= -1){
42
+            x[i].style.display = "list-item";
43
+        }
44
+    }
45
+    return;
46
+}
47
+
48
+//Tries to filter by any kind of information provided (name,artesania,municipio,telefono,email)
49
+function filter_any(input){
50
+    var x = document.getElementsByClassName('artists');
51
+    for (var i = 0; i < all_artesanos.length; i++){
52
+        if (find_name(i,input)){
53
+            x[i].style.display = "list-item";
54
+            continue;
55
+        }
56
+        else if (find_artesania(i,input)){
57
+            x[i].style.display = "list-item";
58
+            continue;
59
+        }
60
+        else if (find_municipio(i,input)){
61
+            x[i].style.display = "list-item";
62
+            continue;
63
+        }
64
+        else if (find_telefono(i,input)){
65
+            x[i].style.display = "list-item";
66
+            continue;
67
+        }
68
+        else if (find_email(i,input)){
69
+            x[i].style.display = "list-item";
70
+            continue;
71
+        }
72
+    }
73
+    return;
74
+}
75
+
76
+//Te trata de buscar si cualquiera de ellos tienen el input que se dio aplica a ese artista especifico (i)
77
+function find_any(i,input){
78
+    //if you find any of these in that space then return 1 if you didnt find that anything matched with the input then return 0
79
+    if (find_name(i,input) || find_telefono(i,input) || find_email(i,input) || find_artesania(i,input) || find_municipio(i,input)){
80
+        return 1;
81
+    }
82
+    else{
83
+        return 0;
84
+    }
85
+}
86
+
87
+//Trata de ver si el input es parte del nombre del artista i
88
+//Mayuscula y acento proof
89
+function find_name(i,input){
90
+    var name = all_artesanos[i].Nombre;
91
+    name = name.trim().toLowerCase();
92
+    name = acento_replace(name);
93
+    if(name.search(input) != -1){
94
+        return 1;
95
+    }
96
+    return 0;
97
+}
98
+
99
+//trata de ver si el input es parte de alguna artesania que trabaja el artista i
100
+//Mayuscula y acento proof
101
+function find_artesania(i,input){
102
+    var artesanias = all_artesanos[i].Especificacion;
103
+    artesanias = artesanias.trim().toLowerCase();
104
+    artesanias = acento_replace(artesanias);
105
+    if(artesanias.search(input) != -1){
106
+        return 1;
107
+    }
108
+    //artesanias = artesanias.split(',');
109
+    //for (var j = 0; j < artesanias.length; j++){
110
+        //var artesania = artesanias[j];
111
+        //artesania = artesania.trim().toLowerCase();
112
+        //artesania = acento_replace(artesania);
113
+        //if (artesania.search(input) != -1){
114
+            //return 1;
115
+        //}
116
+    //}
117
+    return 0;
118
+}
119
+
120
+//trata de ver si el input es parte del municipio del artista i
121
+//Mayuscula y acento proof
122
+function find_municipio(i,input){
123
+    var mun = all_artesanos[i].Municipio;
124
+    mun = mun.trim().toLowerCase();
125
+    mun = acento_replace(mun);
126
+    if(mun.search(input) != -1){
127
+        return 1;
128
+    }
129
+    return 0;
130
+}
131
+
132
+//trata de ver si el input es parte del telefono del artista i
133
+//'(',')','-' and ' ' proof
134
+function find_telefono(i,input){
135
+    var tel = all_artesanos[i]["Telefono 1"];
136
+    tel = tel.trim();
137
+    //To make sure they're both the same im taking out spaces,'(',')' and '-' to make sure they're both the same format
138
+    tel = tel.replace(/\s/g,'').replace(/\u0028/g,'').replace(/\u0029/g,'').replace(/\u002D/g,'');
139
+    input = input.replace(/\s/g,'').replace(/\u0028/g,'').replace(/\u0029/g,'').replace(/\u002D/g,'');
140
+    if(tel.search(input) != -1){
141
+        return 1;
142
+    }
143
+    return 0;
144
+}
145
+
146
+//trata de ver si el input es parte del email del artista i
147
+//Mayuscula and acento proof
148
+function find_email(i,input){
149
+    var email = all_artesanos[i]["E-mail"];
150
+    email = email.trim().toLowerCase();
151
+    email = acento_replace(email);
152
+    if(email.search(input) != -1){
153
+        return 1;
154
+    }
155
+    return 0;
156
+}
157
+
158
+//Esta funcion trata de coger el numero de caso que se esta buscando, esto es para saber que 
159
+//caso del switch para considerar
160
+//LOs casos dependen de lo que esta escrito en cada search bar, cada vez que se escribe en uno nuevo o cuando se borra completamente uno entonces es un caso nuevo
161
+function getcasenum(input,inputarte,inputmuni){
162
+    //this will get the case number
163
+    //think of this as 3 binary numbers where 001 would mean that only its input muni
164
+    //010 is only inputarte and 100 is only input
165
+    //max number is 7
166
+    var casenum = 0;
167
+    if (input.length != 0){
168
+        casenum += 4;
169
+    }
170
+    if (inputarte.length != 0){
171
+        casenum += 2;
172
+    }
173
+    if (inputmuni.length != 0){
174
+        casenum += 1;
175
+    }
176
+    return casenum;
177
+}
178
+
179
+//case 3: artesania y municipio
180
+//Busca todos los artistas que trabajan con esa artesania y en ese municipio
181
+function search_art_mun(inputarte,inputmuni){
182
+    var x = document.getElementsByClassName('artists');
183
+        for (var i = 0; i < all_artesanos.length; i++){
184
+            if (find_artesania(i,inputarte) && find_municipio(i,inputmuni)){
185
+                x[i].style.display = "list-item";
186
+            }
187
+        }
188
+}
189
+
190
+//Busca todos los artistas que salen con el primer input y trabajan en ese municipio
191
+function search_any_mun(input,inputmuni){
192
+    var x = document.getElementsByClassName('artists');
193
+        for (var i = 0; i < all_artesanos.length; i++){
194
+            if(find_any(i,input) && find_municipio(i,inputmuni)){
195
+                x[i].style.display = "list-item";
196
+            }
197
+        }
198
+}
199
+
200
+//Busca todos los artistas que salen con el primer input y trabajan con esa artesania
201
+function search_any_art(input,inputarte){
202
+    var x = document.getElementsByClassName('artists');
203
+    for (var i = 0; i < all_artesanos.length; i++){
204
+        if(find_any(i,input) && find_artesania(i,inputarte)){
205
+            x[i].style.display = "list-item";
206
+        }
207
+    }
208
+}
209
+
210
+//Busca todos los artistas que salen con el primer input, trabajan con esa artesania y trabajan en ese municipio
211
+function search_any_art_mun(input,inputarte,inputmuni){
212
+    var x = document.getElementsByClassName('artists');
213
+    for (var i = 0; i < all_artesanos.length; i++){
214
+        if(find_any(i,input) && find_artesania(i,inputarte) && find_municipio(i,inputmuni)){
215
+            x[i].style.display = "list-item";
216
+        }
217
+    }
218
+}
219
+
220
+//Replacing special characters with non special characters in case input doesnt include it
221
+function acento_replace(string){
222
+    var precstring = "";
223
+    var poststring = "";
224
+    for( i = 0; i < string.length ; i++){
225
+        if (string.charAt(i) == 'á' || string.charAt(i) == 'é' || string.charAt(i) == 'í'|| string.charAt(i) == 'ó' || string.charAt(i) == 'ú' || string.charAt(i) == 'ü' || string.charAt(i) == 'ñ' || string.charAt(i) == 'ö'){
226
+            precstring = string.slice(0,i);
227
+            postcstring = "";
228
+            if(i != string.length-1){
229
+              postcstring = string.slice(i+1,string.length);
230
+            }
231
+            switch(string.charAt(i)){
232
+                case 'á':
233
+                    string = precstring.concat('a',postcstring);
234
+                    break;
235
+                case 'é':
236
+                    string = precstring.concat('e',postcstring);
237
+                    break;
238
+                case 'í':
239
+                    string = precstring.concat('i',postcstring);
240
+                    break;
241
+                case 'ó':
242
+                    string = precstring.concat('o',postcstring);
243
+                    break;
244
+                case 'ú':
245
+                    string = precstring.concat('u',postcstring);
246
+                    break;
247
+                case 'ü':
248
+                    string = precstring.concat('u',postcstring);
249
+                    break;
250
+                case 'ñ':
251
+                    string = precstring.concat('n',postcstring);
252
+                    break;
253
+                case 'ö':
254
+                    string = precstring.concat('o',postcstring);
255
+                    break;
256
+            }
257
+        }
258
+    }
259
+    return string;
260
+}

+ 61
- 65
www/index.html View File

@@ -410,97 +410,93 @@
410 410
         </template>
411 411
 
412 412
 <!-- ------------------------------------------------------------------------------------------------------------------------------------------------------- -->
413
-
413
+<!----------------------------------------------------------------------------------->
414
+        <script src = "js/searchfunctions.js"></script>
414 415
         <script>
415
-            var Madera = JSON.parse(window.localStorage.getItem("TODOS"));
416
+            //JSON file that has all the artesanos 
417
+            var all_artesanos = JSON.parse(window.localStorage.getItem("TODOS"));
416 418
             function filter(){
417
-
418
-
419
-                // var request = new XMLHttpRequest()
420
-                // request.open('GET','json/MADERA.json',true)
421
-                // request.onload = function(){
422
-                //   var Madera = JSON.parse(this.response)
423
-                // }
424
-                // request.send()
425
-                // var input = document.getElementById('searchbar').value
426
-                // var firstwood = Madera[0].Nombre
427
-                // ons.notification.alert('Searched for: ' + firstwood)
428
-                var input = document.getElementById('searchbar').value
419
+                var input = document.getElementById('searchbar').value;
420
+                var inputarte = document.getElementById('searchartesania').value;
421
+                var inputmuni = document.getElementById('searchbarmunicipio').value;
429 422
                 var x = document.getElementsByClassName('artists');
423
+                //making sure they're all in the same format
430 424
                 input = input.trim().toLowerCase();
431
-                if (input.length == 0){
432
-                    for (i = 0; Madera.length; i++){
425
+                inputarte = inputarte.trim().toLowerCase();
426
+                inputmuni = inputmuni.trim().toLowerCase();
427
+                input = acento_replace(input);
428
+                inputarte = acento_replace(inputarte);
429
+                inputmuni = acento_replace(inputmuni);
430
+                //default case is where evey one of them has nothing or less than 3 characters (displays every artist)
431
+                if (input.length <= 3 && inputarte.length <= 3 && inputmuni.length <= 3){
432
+                    for (var i = 0; all_artesanos.length; i++){
433 433
                         x[i].style.display = "list-item";
434 434
                     }
435 435
                 }
436 436
                 else{
437
-                    var foundesp = 0;
438
-                    for (i = 0; i < Madera.length; i++){
439
-                        console.log("damn")
440
-                        //try checking the especificacion first
441
-                        var especificaciones = Madera[i].Especificaciones1;
442
-                        especificaciones = especificaciones.split(';');
443
-                        for (var j = 0; j < especificaciones.length; j++){
444
-                            var especificacion = especificaciones[j];
445
-                            especificacion = especificacion.trim().toLowerCase();
446
-                            if (input == especificacion){
447
-                                x[i].style.display = "list-item";
448
-                                foundesp = 1;
449
-                                break;
450
-                            }
451
-                            else{
452
-                                x[i].style.display = "none";
453
-                            }
454
-                        }
437
+                    var cases = 0;
438
+                    cases = getcasenum(input,inputarte,inputmuni);
439
+                    //take every one of them out first (dont display any)
440
+                    for (var i = 0; i < all_artesanos.length; i++){
441
+                        x[i].style.display = "none";
455 442
                     }
456
-                    if (foundesp != 1){
457
-                        input = input.trim().toLowerCase().split(' ')
458
-                        //changing the input into something that can be searched
459
-                        for (var i = 0; i < input.length; i++){
460
-                            input[i] = input[i].charAt(0).toUpperCase() + input[i].slice(1);
461
-                        }
462
-                        console.log(input);
463
-                        for(var i = 0; i < Madera.length; i++){
464
-                            count = 0;
465
-                            artist = Madera[i].Nombre.trim().split(' ');
466
-                            for (k = 0; k < input.length; k++){
467
-                                for (var l = 0; l < artist.length; l++){
468
-                                    if(artist[l] == input[k]){
469
-                                        x[i].style.display = "list-item";
470
-                                        break;
471
-                                    }
472
-                                    else{
473
-                                        x[i].style.display = "none";
474
-                                    }
475
-                                }
476
-                            }
477
-                        }
443
+                    switch(cases){
444
+                        //cases == 1 when only inputmuni has been writen on
445
+                        case 1:
446
+                            filter_municipios(inputmuni);
447
+                            break;
448
+                        //cases == 2 when only inputarte has been written on
449
+                        case 2:
450
+                            filter_artesanias(inputarte);
451
+                            break;
452
+                        //cases == 3 when inputarte and inputmuni has been written on
453
+                        case 3:
454
+                            search_art_mun(inputarte,inputmuni);
455
+                            break;
456
+                        //cases == 4 when input has been writen on
457
+                        case 4:
458
+                            filter_any(input);
459
+                            break;
460
+                        //cases == 5 when input and inputmuni has been written on
461
+                        case 5:
462
+                            search_any_mun(input,inputmuni);
463
+                            break;
464
+                        //cases == 6 when input and inputart has been written on
465
+                        case 6:
466
+                            search_any_art(input,inputarte);
467
+                            break;
468
+                        //cases == 7 when input, inputart and inputmuni has been writen on
469
+                        case 7:
470
+                            search_any_art_mun(input,inputarte,inputmuni);
471
+                            break;
478 472
                     }
479 473
                 }
480
-            }
474
+            }            
481 475
         </script>
482 476
 
483 477
         <template id="search.html">
484 478
             <ons-page id="Buscar">
485
-
486 479
                 <p style="text-align: center; margin-top: 10px;">
487
-                    <ons-search-input placeholder="Search" id = "searchbar"
488
-                                      onchange = "filter()"
489
-                                      ></ons-search-input>
480
+                    <ons-search-input placeholder="Search anything" id = "searchbar"
481
+                        onkeyup = "filter()"></ons-search-input>
482
+                    <ons-search-input placeholder="Tipo de artesania" id = "searchartesania" 
483
+                        onkeyup = "filter()"></ons-search-input>
484
+                    <ons-search-input placeholder = "Municipio" id = "searchbarmunicipio"
485
+                        onkeyup = "filter()"></ons-search-input>
490 486
                 </p>
491 487
 
492 488
                 <ons-list id="results" src="">
493 489
                 </ons-list>
494 490
 
495 491
                 <script>
496
-                    for (i = 0; i < Madera.length;i++){
492
+                    for (i = 0; i < all_artesanos.length;i++){
497 493
                         var artesano = ons.createElement(`<ons-list-item class = "artists"
498
-                        onclick="myNavigator.pushPage('artesano.html', { data: {title: '${Madera[i].Nombre}', mun: '${Madera[i].Municipio}', tel: '${Madera[i]["Telefono1"]}', email: '${Madera[i]["E-mail1"]}', redes: '${Madera[i]["E-Commerce1"]}', esp: '${Madera[i].Especificaciones1}' } })" tappable>
499
-                        <div>${Madera[i].Nombre}</div>
494
+                        onclick="myNavigator.pushPage('artesano.html', { data: {title: '${all_artesanos[i].Nombre}', mun: '${all_artesanos[i].Municipio}', tel: '${all_artesanos[i]["Telefono 1"]}', email: '${all_artesanos[i]["E-mail"]}', redes: '${all_artesanos[i]["E-Commerce"]}', esp: '${all_artesanos[i].Especificacion}' } })" tappable>
495
+                        <div>${all_artesanos[i].Nombre}</div>
500 496
                     </ons-list-item>`);
501 497
                         // var artesano = ons.createElement(`
502 498
                         //   <ons-list-item class = "artists">
503
-                        //     <div class="center" >${Madera[i].Nombre}</div>
499
+                        //     <div class="center" >${all_artesanos[i].Nombre}</div>
504 500
                         //   </ons-list-item>`
505 501
                         // );
506 502
                         document.getElementById('results').appendChild(artesano);

+ 260
- 0
www/js/searchfunctions.js View File

@@ -0,0 +1,260 @@
1
+//Basic shit to understand
2
+//all_artesanos is the json that has the file that contains all the artesanos, this includes the studd they do,municipio,telefono,email and name
3
+//x is going to be what is displayed in the app, it basically has the same infromation as all_artesanos
4
+//THe basic mechanic is to display each artist in the search tab whenever something of them is found
5
+//You need at least 3 characters in one of the searchbars for it to display something
6
+//If nothing is written then it will display every artists
7
+//Some of these functions also try to make sure that the inputs are the same format as the thing they're looking up so that they dont have to follow a specific syntax to look for stuff
8
+
9
+//Tries to filter by the type of work that the artists do, if what they wrote in inputarte is included in one of them then the artists is displayed in the search bar
10
+function filter_artesanias(inputarte){
11
+    var x = document.getElementsByClassName('artists');
12
+    for (var i = 0; i < all_artesanos.length; i++){
13
+        var especificaciones = all_artesanos[i].Especificacion;
14
+        especificaciones = especificaciones.trim().toLowerCase();
15
+        especificaciones = acento_replace(especificaciones);
16
+        if (especificaciones.search(inputarte) != -1){
17
+            x[i].style.display = "list-item";
18
+        }
19
+        //before it did this down here but im keeping it just in case...
20
+        //especificaciones = especificaciones.split(',');
21
+        //for (var j = 0; j < especificaciones.length; j++){
22
+            //var especificacion = especificaciones[j];
23
+            //especificacion = especificacion.trim().toLowerCase();
24
+            //especificacion = acento_replace(especificacion);
25
+            //if (especificacion.search(inputarte) != -1){
26
+                //x[i].style.display = "list-item";
27
+                //break;
28
+            //}
29
+
30
+        }
31
+    return;
32
+}
33
+
34
+//Tries to filter by the municipio that they reside in or work in (not sure which one of the two it is)
35
+function filter_municipios(inputmuni){
36
+    var x = document.getElementsByClassName('artists');
37
+    for (var i = 0; i < all_artesanos.length; i++){
38
+        var municipio = all_artesanos[i].Municipio;
39
+        municipio = municipio.trim().toLowerCase();
40
+        municipio = acento_replace(municipio);
41
+        if (municipio.search(inputmuni)!= -1){
42
+            x[i].style.display = "list-item";
43
+        }
44
+    }
45
+    return;
46
+}
47
+
48
+//Tries to filter by any kind of information provided (name,artesania,municipio,telefono,email)
49
+function filter_any(input){
50
+    var x = document.getElementsByClassName('artists');
51
+    for (var i = 0; i < all_artesanos.length; i++){
52
+        if (find_name(i,input)){
53
+            x[i].style.display = "list-item";
54
+            continue;
55
+        }
56
+        else if (find_artesania(i,input)){
57
+            x[i].style.display = "list-item";
58
+            continue;
59
+        }
60
+        else if (find_municipio(i,input)){
61
+            x[i].style.display = "list-item";
62
+            continue;
63
+        }
64
+        else if (find_telefono(i,input)){
65
+            x[i].style.display = "list-item";
66
+            continue;
67
+        }
68
+        else if (find_email(i,input)){
69
+            x[i].style.display = "list-item";
70
+            continue;
71
+        }
72
+    }
73
+    return;
74
+}
75
+
76
+//Te trata de buscar si cualquiera de ellos tienen el input que se dio aplica a ese artista especifico (i)
77
+function find_any(i,input){
78
+    //if you find any of these in that space then return 1 if you didnt find that anything matched with the input then return 0
79
+    if (find_name(i,input) || find_telefono(i,input) || find_email(i,input) || find_artesania(i,input) || find_municipio(i,input)){
80
+        return 1;
81
+    }
82
+    else{
83
+        return 0;
84
+    }
85
+}
86
+
87
+//Trata de ver si el input es parte del nombre del artista i
88
+//Mayuscula y acento proof
89
+function find_name(i,input){
90
+    var name = all_artesanos[i].Nombre;
91
+    name = name.trim().toLowerCase();
92
+    name = acento_replace(name);
93
+    if(name.search(input) != -1){
94
+        return 1;
95
+    }
96
+    return 0;
97
+}
98
+
99
+//trata de ver si el input es parte de alguna artesania que trabaja el artista i
100
+//Mayuscula y acento proof
101
+function find_artesania(i,input){
102
+    var artesanias = all_artesanos[i].Especificacion;
103
+    artesanias = artesanias.trim().toLowerCase();
104
+    artesanias = acento_replace(artesanias);
105
+    if(artesanias.search(input) != -1){
106
+        return 1;
107
+    }
108
+    //artesanias = artesanias.split(',');
109
+    //for (var j = 0; j < artesanias.length; j++){
110
+        //var artesania = artesanias[j];
111
+        //artesania = artesania.trim().toLowerCase();
112
+        //artesania = acento_replace(artesania);
113
+        //if (artesania.search(input) != -1){
114
+            //return 1;
115
+        //}
116
+    //}
117
+    return 0;
118
+}
119
+
120
+//trata de ver si el input es parte del municipio del artista i
121
+//Mayuscula y acento proof
122
+function find_municipio(i,input){
123
+    var mun = all_artesanos[i].Municipio;
124
+    mun = mun.trim().toLowerCase();
125
+    mun = acento_replace(mun);
126
+    if(mun.search(input) != -1){
127
+        return 1;
128
+    }
129
+    return 0;
130
+}
131
+
132
+//trata de ver si el input es parte del telefono del artista i
133
+//'(',')','-' and ' ' proof
134
+function find_telefono(i,input){
135
+    var tel = all_artesanos[i]["Telefono 1"];
136
+    tel = tel.trim();
137
+    //To make sure they're both the same im taking out spaces,'(',')' and '-' to make sure they're both the same format
138
+    tel = tel.replace(/\s/g,'').replace(/\u0028/g,'').replace(/\u0029/g,'').replace(/\u002D/g,'');
139
+    input = input.replace(/\s/g,'').replace(/\u0028/g,'').replace(/\u0029/g,'').replace(/\u002D/g,'');
140
+    if(tel.search(input) != -1){
141
+        return 1;
142
+    }
143
+    return 0;
144
+}
145
+
146
+//trata de ver si el input es parte del email del artista i
147
+//Mayuscula and acento proof
148
+function find_email(i,input){
149
+    var email = all_artesanos[i]["E-mail"];
150
+    email = email.trim().toLowerCase();
151
+    email = acento_replace(email);
152
+    if(email.search(input) != -1){
153
+        return 1;
154
+    }
155
+    return 0;
156
+}
157
+
158
+//Esta funcion trata de coger el numero de caso que se esta buscando, esto es para saber que 
159
+//caso del switch para considerar
160
+//LOs casos dependen de lo que esta escrito en cada search bar, cada vez que se escribe en uno nuevo o cuando se borra completamente uno entonces es un caso nuevo
161
+function getcasenum(input,inputarte,inputmuni){
162
+    //this will get the case number
163
+    //think of this as 3 binary numbers where 001 would mean that only its input muni
164
+    //010 is only inputarte and 100 is only input
165
+    //max number is 7
166
+    var casenum = 0;
167
+    if (input.length != 0){
168
+        casenum += 4;
169
+    }
170
+    if (inputarte.length != 0){
171
+        casenum += 2;
172
+    }
173
+    if (inputmuni.length != 0){
174
+        casenum += 1;
175
+    }
176
+    return casenum;
177
+}
178
+
179
+//case 3: artesania y municipio
180
+//Busca todos los artistas que trabajan con esa artesania y en ese municipio
181
+function search_art_mun(inputarte,inputmuni){
182
+    var x = document.getElementsByClassName('artists');
183
+        for (var i = 0; i < all_artesanos.length; i++){
184
+            if (find_artesania(i,inputarte) && find_municipio(i,inputmuni)){
185
+                x[i].style.display = "list-item";
186
+            }
187
+        }
188
+}
189
+
190
+//Busca todos los artistas que salen con el primer input y trabajan en ese municipio
191
+function search_any_mun(input,inputmuni){
192
+    var x = document.getElementsByClassName('artists');
193
+        for (var i = 0; i < all_artesanos.length; i++){
194
+            if(find_any(i,input) && find_municipio(i,inputmuni)){
195
+                x[i].style.display = "list-item";
196
+            }
197
+        }
198
+}
199
+
200
+//Busca todos los artistas que salen con el primer input y trabajan con esa artesania
201
+function search_any_art(input,inputarte){
202
+    var x = document.getElementsByClassName('artists');
203
+    for (var i = 0; i < all_artesanos.length; i++){
204
+        if(find_any(i,input) && find_artesania(i,inputarte)){
205
+            x[i].style.display = "list-item";
206
+        }
207
+    }
208
+}
209
+
210
+//Busca todos los artistas que salen con el primer input, trabajan con esa artesania y trabajan en ese municipio
211
+function search_any_art_mun(input,inputarte,inputmuni){
212
+    var x = document.getElementsByClassName('artists');
213
+    for (var i = 0; i < all_artesanos.length; i++){
214
+        if(find_any(i,input) && find_artesania(i,inputarte) && find_municipio(i,inputmuni)){
215
+            x[i].style.display = "list-item";
216
+        }
217
+    }
218
+}
219
+
220
+//Replacing special characters with non special characters in case input doesnt include it
221
+function acento_replace(string){
222
+    var precstring = "";
223
+    var poststring = "";
224
+    for( i = 0; i < string.length ; i++){
225
+        if (string.charAt(i) == 'á' || string.charAt(i) == 'é' || string.charAt(i) == 'í'|| string.charAt(i) == 'ó' || string.charAt(i) == 'ú' || string.charAt(i) == 'ü' || string.charAt(i) == 'ñ' || string.charAt(i) == 'ö'){
226
+            precstring = string.slice(0,i);
227
+            postcstring = "";
228
+            if(i != string.length-1){
229
+              postcstring = string.slice(i+1,string.length);
230
+            }
231
+            switch(string.charAt(i)){
232
+                case 'á':
233
+                    string = precstring.concat('a',postcstring);
234
+                    break;
235
+                case 'é':
236
+                    string = precstring.concat('e',postcstring);
237
+                    break;
238
+                case 'í':
239
+                    string = precstring.concat('i',postcstring);
240
+                    break;
241
+                case 'ó':
242
+                    string = precstring.concat('o',postcstring);
243
+                    break;
244
+                case 'ú':
245
+                    string = precstring.concat('u',postcstring);
246
+                    break;
247
+                case 'ü':
248
+                    string = precstring.concat('u',postcstring);
249
+                    break;
250
+                case 'ñ':
251
+                    string = precstring.concat('n',postcstring);
252
+                    break;
253
+                case 'ö':
254
+                    string = precstring.concat('o',postcstring);
255
+                    break;
256
+            }
257
+        }
258
+    }
259
+    return string;
260
+}