Commit 39424616a344624b1e8e51aa0e845f1b6a4713a3

Authored by Edmar Moretti
1 parent 073e3540

Validação com JSLint

Showing 1 changed file with 116 additions and 89 deletions   Show diff stats
ferramentas/identifica/index.js
  1 +/*jslint plusplus:false,white:false,undef: false, rhino: true, onevar: true, evil: true */
  2 +
1 3 /*
2 4 Title: Ferramenta Identifica
3 5  
... ... @@ -23,8 +25,8 @@ GNU junto com este programa; se não, escreva para a
23 25 Free Software Foundation, Inc., no endereço
24 26 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA.
25 27 */
26   -if(typeof(i3GEOF) == 'undefined'){
27   - i3GEOF = new Array();
  28 +if(typeof(i3GEOF) === 'undefined'){
  29 + i3GEOF = [];
28 30 }
29 31 /*
30 32 Class: i3GEOF.identifica
... ... @@ -109,7 +111,7 @@ i3GEOF.identifica = {
109 111 Type:
110 112 {Array}
111 113 */
112   - sistemasAdicionais: new Array(),
  114 + sistemasAdicionais: [],
113 115 /*
114 116 Function: inicia
115 117  
... ... @@ -135,6 +137,7 @@ i3GEOF.identifica = {
135 137 */
136 138 inicia: function(locaplic,sid,tema,x,y,iddiv,mostraLinkGeohack,mostraSistemasAdicionais){
137 139 try{
  140 + var g_locidentifica;
138 141 $i(iddiv).innerHTML += i3GEOF.identifica.html();
139 142 i3GEOF.identifica.locaplic = locaplic;
140 143 i3GEOF.identifica.sid = sid;
... ... @@ -145,37 +148,40 @@ i3GEOF.identifica = {
145 148 i3GEOF.identifica.mostraSistemasAdicionais = mostraSistemasAdicionais;
146 149 i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia1","i3GEOidentificaguia");
147 150 //eventos das guias
148   - $i("i3GEOidentificaguia1").onclick = function(){i3GEOF.identifica.listaTemas("ligados");i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia1","i3GEOidentificaguia")}
149   - $i("i3GEOidentificaguia2").onclick = function(){i3GEOF.identifica.listaTemas("todos");i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia1","i3GEOidentificaguia")}
150   - $i("i3GEOidentificaguia3").onclick = function(){i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia3","i3GEOidentificaguia")}
  151 + $i("i3GEOidentificaguia1").onclick = function(){i3GEOF.identifica.listaTemas("ligados");i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia1","i3GEOidentificaguia");};
  152 + $i("i3GEOidentificaguia2").onclick = function(){i3GEOF.identifica.listaTemas("todos");i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia1","i3GEOidentificaguia");};
  153 + $i("i3GEOidentificaguia3").onclick = function(){i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia3","i3GEOidentificaguia");};
151 154 $i("i3GEOidentificaguia4").onclick = function(){
152 155 i3GEO.guias.mostraGuiaFerramenta("i3GEOidentificaguia4","i3GEOidentificaguia");
153 156 new YAHOO.widget.Button("i3GEOidentificabotao1",{onclick:{fn: function(){
154 157 //window.location.href = "../etiqueta/index.htm?tema="+tema;
155   - if(i3GEO.temaAtivo != "")
156   - i3GEO.tema.dialogo.etiquetas(i3GEO.temaAtivo);
  158 + if(i3GEO.temaAtivo !== "")
  159 + {i3GEO.tema.dialogo.etiquetas(i3GEO.temaAtivo);}
157 160 else
158 161 {alert("Nenhum tema definido");}
159 162 }}});
160   - }
161   - i3GEOF.identifica.listaTemas("ligados")
  163 + };
  164 + i3GEOF.identifica.listaTemas("ligados");
162 165 //
163 166 //verifica se existem sistemas para identificar
164 167 //
165   - if(i3GEOF.identifica.mostraSistemasAdicionais == true){
166   - var g_locidentifica = i3GEO.parametros.locidentifica;
167   - if (g_locidentifica != ""){
168   - if(window.parent.tempXMLSISTEMAS == undefined)
  168 + if(i3GEOF.identifica.mostraSistemasAdicionais === true){
  169 + g_locidentifica = i3GEO.parametros.locidentifica;
  170 + if (g_locidentifica !== ""){
  171 + if(window.parent.tempXMLSISTEMAS === undefined)
169 172 {i3GEO.util.ajaxexecASXml(g_locidentifica,"i3GEOF.identifica.montaListaSistemas");}
170 173 else
171 174 {i3GEOF.identifica.montaListaSistemas(window.parent.tempXMLSISTEMAS);}
172 175 }
173 176 }
174   - if (i3GEO.temaAtivo != "")
  177 + if (i3GEO.temaAtivo !== "")
175 178 {i3GEOF.identifica.buscaDadosTema(window.parent.i3GEO.temaAtivo);}
176 179 }
177 180 catch(erro){alert(erro);}
178 181 },
  182 + ativaFoco: function(){
  183 + i3GEOF.identifica.listaTemas("ligados");
  184 + },
179 185 /*
180 186 Function: html
181 187  
... ... @@ -225,7 +231,15 @@ i3GEOF.identifica = {
225 231 tipo {String} - ligados|todos lista apenas os temas que estão visíveis no mapa ou todos os temas
226 232 */
227 233 listaTemas: function(tipo){
228   - i3GEO.php.listaTemas(i3GEOF.identifica.montaListaTemas,tipo,i3GEOF.identifica.locaplic,i3GEOF.identifica.sid);
  234 + if(i3GEO.arvoreDeCamadas.CAMADAS !== ""){
  235 + var lista = i3GEO.arvoreDeCamadas.CAMADAS;
  236 + if(tipo === "ligados")
  237 + {lista = i3GEO.arvoreDeCamadas.filtraCamadas("status",2,"igual",lista);}
  238 + lista = i3GEO.arvoreDeCamadas.filtraCamadas("identifica","nao","diferente",lista);
  239 + i3GEOF.identifica.montaListaTemas(lista);
  240 + }
  241 + else
  242 + {i3GEO.php.listaTemas(i3GEOF.identifica.montaListaTemas,tipo,i3GEOF.identifica.locaplic,i3GEOF.identifica.sid);}
229 243 },
230 244 /*
231 245 Function: montaListaTemas
... ... @@ -236,30 +250,41 @@ i3GEOF.identifica = {
236 250  
237 251 Parametros:
238 252  
239   - retorno {JSON} - objeto retornado por i3GEO.php.listaTemas
  253 + retorno {JSON} - objeto retornado por i3GEO.php.listaTemas ou por i3GEO.arvoreDeCamadas.filtraCamadas
240 254 */
241 255 montaListaTemas: function(retorno){
242   - var lista = retorno.data;
  256 + var lista,linhas,linhas1,l,nome,tema,divResultado;
  257 + if(retorno.data)
  258 + {lista = retorno.data;}
  259 + else
  260 + {lista = retorno;}
243 261 //
244 262 //ativa o link para o site geohack
245 263 //
246   - if(i3GEOF.identifica.mostraLinkGeohack == true)
247   - {var linhas = i3GEOF.identifica.montaLinkGeohack();}
  264 + if(i3GEOF.identifica.mostraLinkGeohack === true)
  265 + {linhas = i3GEOF.identifica.montaLinkGeohack();}
248 266 else
249   - {var linhas = "";}
  267 + {linhas = "";}
250 268 //
251 269 //monta a lista de temas
252 270 //
253   - linhas += "Clique no tema para ver os dados"
254   - var linhas1 = "";
  271 + linhas += "Clique no tema para ver os dados";
  272 + linhas1 = "";
255 273 for (l=0;l<lista.length;l++)
256 274 {
257   - var nome = lista[l].nome
258   - var tema = lista[l].tema
259   - if(lista[l].identifica != "nao")
260   - {linhas1 += "<tr><td style='border-top:1px solid beige;'><input onclick='i3GEOF.identifica.buscaDadosTema(\""+tema+"\")' style=cursor:pointer type=radio name=i3GEOidentificatema /></td><td style='border-top:1px solid beige;' >"+nome+"</td></tr>"}
  275 + if(lista[l].nome){
  276 + nome = lista[l].nome;
  277 + tema = lista[l].tema;
  278 + }
  279 + else{
  280 + nome = lista[l].tema;
  281 + tema = lista[l].name;
  282 + }
  283 +
  284 + if(lista[l].identifica !== "nao")
  285 + {linhas1 += "<tr><td style='border-top:1px solid beige;'><input onclick='i3GEOF.identifica.buscaDadosTema(\""+tema+"\")' style=cursor:pointer type=radio name=i3GEOidentificatema /></td><td style='border-top:1px solid beige;' >"+nome+"</td></tr>";}
261 286 }
262   - var divResultado = $i("i3GEOidentificalistaTemas");
  287 + divResultado = $i("i3GEOidentificalistaTemas");
263 288 if(divResultado)
264 289 {divResultado.innerHTML = linhas+"<table class=lista2 ><tr><td style=text-align:left ><input onclick='i3GEOF.identifica.buscaDadosTema(\"ligados\")' style=cursor:pointer type=radio name=i3GEOidentificatema /></td><td>Todos</td></tr>"+linhas1+"</table>";}
265 290 },
... ... @@ -273,18 +298,23 @@ i3GEOF.identifica = {
273 298 {String}
274 299 */
275 300 montaLinkGeohack: function(){
276   - var b = i3GEO.calculo.dd2dms(i3GEOF.identifica.x,i3GEOF.identifica.y);
277   - var x = b[0].split(" ")
278   - var y = b[1].split(" ")
279   - var w = "W"
280   - var s = "S"
281   - if (x[0]*1 > 0){w = "L"}
282   - if (y[0]*1 > 0){s = "N"}
283   - if (x[0]*1 < 0){x[0] = x[0]*-1}
284   - if (y[0]*1 < 0){y[0] = y[0]*-1}
285   - var param = y[0]+"_"+y[1]+"_"+y[2]+"_"+s+"_"+x[0]+"_"+x[1]+"_"+x[2]+"_"+w
286   - var url = "http://tools.wikimedia.de/~magnus/geo/geohack.php?params="+param//15_48_00_S_47_51_50_W
287   - var linhas = "<a href='"+url+"' target=blank >Buscadores web</a><br>"
  301 + var b,x,y,w,s,param,url,linhas;
  302 + b = i3GEO.calculo.dd2dms(i3GEOF.identifica.x,i3GEOF.identifica.y);
  303 + x = b[0].split(" ");
  304 + y = b[1].split(" ");
  305 + w = "W";
  306 + s = "S";
  307 + if (x[0]*1 > 0)
  308 + {w = "L";}
  309 + if (y[0]*1 > 0)
  310 + {s = "N";}
  311 + if (x[0]*1 < 0)
  312 + {x[0] = x[0]*-1;}
  313 + if (y[0]*1 < 0)
  314 + {y[0] = y[0]*-1;}
  315 + param = y[0]+"_"+y[1]+"_"+y[2]+"_"+s+"_"+x[0]+"_"+x[1]+"_"+x[2]+"_"+w;
  316 + url = "http://tools.wikimedia.de/~magnus/geo/geohack.php?params="+param;
  317 + linhas = "<a href='"+url+"' target=blank >Buscadores web</a><br>";
288 318 return linhas;
289 319 },
290 320 /*
... ... @@ -303,43 +333,44 @@ i3GEOF.identifica = {
303 333 xmlDoc - documento xml
304 334 */
305 335 montaListaSistemas: function(xmlDoc){
306   - if (xmlDoc != undefined)
  336 + var divins,sisig,sistema,pub,exec,temp,t,linhas,ltema;
  337 + if (xmlDoc !== undefined)
307 338 {
308 339 window.parent.tempXMLSISTEMAS = xmlDoc;
309   - var divins = $i("i3GEOidentificalistaSistemas");
310   - var sis = xmlDoc.getElementsByTagName("FUNCAO")
  340 + divins = $i("i3GEOidentificalistaSistemas");
  341 + sis = xmlDoc.getElementsByTagName("FUNCAO");
311 342 for (ig=0;ig<sis.length;ig++)
312 343 {
313   - var sistema = sis[ig].getElementsByTagName("NOMESIS")[0].firstChild.nodeValue
  344 + sistema = sis[ig].getElementsByTagName("NOMESIS")[0].firstChild.nodeValue;
314 345 if(sis[ig].getElementsByTagName("PUBLICADO")[0])
315 346 {
316 347 if(sis[ig].getElementsByTagName("PUBLICADO")[0].firstChild)
317 348 {
318   - var pub = sis[ig].getElementsByTagName("PUBLICADO")[0].firstChild.nodeValue;
319   - if(pub == "NAO" || pub == "nao")
320   - {var sistema = "<s>"+sistema+"</s>";}
  349 + pub = sis[ig].getElementsByTagName("PUBLICADO")[0].firstChild.nodeValue;
  350 + if(pub === "NAO" || pub === "nao")
  351 + {sistema = "<s>"+sistema+"</s>";}
321 352 }
322 353 }
323   - var exec = sis[ig].getElementsByTagName("ABRIR")[0].firstChild.nodeValue
324   - var temp = exec.split('"')
325   - if(temp.length == 1)
326   - var exec = '"'+exec+'"'
327   - var temp = exec.split("?")
328   - if(temp.length != 2)
329   - exec += '+"?"'
330   - var t = "blank"
  354 + exec = sis[ig].getElementsByTagName("ABRIR")[0].firstChild.nodeValue;
  355 + temp = exec.split('"');
  356 + if(temp.length === 1)
  357 + {exec = '"'+exec+'"';}
  358 + temp = exec.split("?");
  359 + if(temp.length !== 2)
  360 + {exec += '+"?"';}
  361 + t = "blank";
331 362 if (sis[ig].getElementsByTagName("TARGET")[0])
332   - {t = sis[ig].getElementsByTagName("TARGET")[0].firstChild.nodeValue}
333   - i3GEOF.identifica.sistemasAdicionais.push(sistema+","+exec+","+t)
  363 + {t = sis[ig].getElementsByTagName("TARGET")[0].firstChild.nodeValue;}
  364 + i3GEOF.identifica.sistemasAdicionais.push(sistema+","+exec+","+t);
334 365 }
335 366 if (i3GEOF.identifica.sistemasAdicionais.length > 0)
336 367 {
337   - var linhas = ""
  368 + linhas = "";
338 369 for (l=0;l<i3GEOF.identifica.sistemasAdicionais.length;l++)
339 370 {
340   - var ltema = i3GEOF.identifica.sistemasAdicionais[l].split(",")
  371 + ltema = i3GEOF.identifica.sistemasAdicionais[l].split(",");
341 372 if (ltema.length > 1)
342   - linhas += "<tr><td style='border-top:1px solid beige;'><input onclick='i3GEOF.identifica.mostraDadosSistema("+ltema[1]+",\""+ltema[2]+"\")' style=cursor:pointer type=radio name=i3GEOidentificatema /></td><td style='border-top:1px solid beige;' >"+ltema[0]+"</td></tr>";
  373 + {linhas += "<tr><td style='border-top:1px solid beige;'><input onclick='i3GEOF.identifica.mostraDadosSistema("+ltema[1]+",\""+ltema[2]+"\")' style=cursor:pointer type=radio name=i3GEOidentificatema /></td><td style='border-top:1px solid beige;' >"+ltema[0]+"</td></tr>";}
343 374  
344 375 }
345 376 if(divins){
... ... @@ -356,18 +387,20 @@ i3GEOF.identifica = {
356 387 Obtém os dados de um tema para o ponto de coordenadas clicado no mapa
357 388 */
358 389 buscaDadosTema: function(tema){
  390 + var res,opcao,resolucao;
359 391 $i("i3GEOidentificaocorrencia").innerHTML = "<img src='"+i3GEOF.identifica.locaplic+"/imagens/aguarde.gif' />";
360   - var res = $i("i3GEOidentificaresolucao");
  392 + res = $i("i3GEOidentificaresolucao");
361 393 if(res)
362   - {var resolucao = res.value;}
  394 + {resolucao = res.value;}
363 395 else
364   - {var res = 5;}
  396 + {res = 5;}
365 397 i3GEO.temaAtivo = tema;
366 398 //var resolucao = "0.01"
367   - if (tema == "ligados"){var opcao = "ligados"}
  399 + if (tema === "ligados")
  400 + {opcao = "ligados";}
368 401 else
369   - {var opcao = "tema"}
370   - i3GEO.php.identifica2(i3GEOF.identifica.mostraDadosTema,i3GEOF.identifica.x,i3GEOF.identifica.y,resolucao,opcao,i3GEOF.identifica.locaplic,i3GEOF.identifica.sid,tema)
  402 + {opcao = "tema";}
  403 + i3GEO.php.identifica2(i3GEOF.identifica.mostraDadosTema,i3GEOF.identifica.x,i3GEOF.identifica.y,resolucao,opcao,i3GEOF.identifica.locaplic,i3GEOF.identifica.sid,tema);
371 404 },
372 405 /*
373 406 Function: mostraDadosSistema
... ... @@ -381,14 +414,8 @@ i3GEOF.identifica = {
381 414 target {String} (depreciado) - _self|self| onde a url será aberta. Se for "self", será aberta na mesma janela, caso contrário, em uma nova página do navegador
382 415 */
383 416 mostraDadosSistema: function(exec,target){
384   - exec += "&x="+i3GEOF.identifica.x+"&y="+i3GEOF.identifica.y
  417 + exec += "&x="+i3GEOF.identifica.x+"&y="+i3GEOF.identifica.y;
385 418 window.open(exec);
386   - /*
387   - if (target == "self" || target == "_self")
388   - {window.location.href = exec}
389   - else
390   - {window.open(exec)}
391   - */
392 419 },
393 420 /*
394 421 Function: mostraDadosTema
... ... @@ -402,30 +429,30 @@ i3GEOF.identifica = {
402 429 retorno {JSON} - objeto JSON com os dados <i3GEO.php.identifica2>
403 430 */
404 431 mostraDadosTema: function(retorno){
405   - var res = ""
406   - if (retorno.data != undefined)
  432 + var res,div0,ntemas,i,resultados,nres,cor,j;
  433 + if (retorno.data !== undefined)
407 434 {
408   - var retorno = retorno.data;
409   - var divO = $i("i3GEOidentificaocorrencia");
410   - divO.innerHTML=""
411   - var ntemas = retorno.length;
412   - for(var i=0;i<ntemas;i++)
  435 + retorno = retorno.data;
  436 + divO = $i("i3GEOidentificaocorrencia");
  437 + divO.innerHTML="";
  438 + ntemas = retorno.length;
  439 + for(i=0;i<ntemas;i++)
413 440 {
414   - var resultados = retorno[i].resultado[0];
415   - if(resultados != " ")
  441 + resultados = retorno[i].resultado[0];
  442 + if(resultados !== " ")
416 443 {
417   - res += "<div style='padding-top:6px;left:2px;text-align:left;width:80%;' >"+retorno[i].nome+"</div>"
418   - var nres = resultados.length;
419   - var cor = "RGB(250,250,250)";
420   - for(var j=0;j<nres;j++)
  444 + res += "<div style='padding-top:6px;left:2px;text-align:left;width:80%;' >"+retorno[i].nome+"</div>";
  445 + nres = resultados.length;
  446 + cor = "RGB(250,250,250)";
  447 + for(j=0;j<nres;j++)
421 448 {
422   - if(resultados[j].link == "")
  449 + if(resultados[j].link === "")
423 450 {res += "<div style='width:80%;text-align:left;background-color:"+cor+"' >&nbsp;&nbsp;"+resultados[j].alias+":&nbsp;"+resultados[j].valor+"</div>";}
424 451 else
425 452 {res += "<div style='width:80%;text-align:left;background-color:"+cor+"' >&nbsp;&nbsp;"+resultados[j].alias+":&nbsp;<a href='"+resultados[j].link+"' target=_blank >"+resultados[j].valor+"</a></div>";}
426   - if(resultados[j].img != "")
  453 + if(resultados[j].img !== "")
427 454 {res += "<div style='width:80%;text-align:left;background-color:"+cor+"' >"+resultados[j].img+"</div>";}
428   - if (cor == "RGB(250,250,250)"){cor = "beige";}
  455 + if (cor === "RGB(250,250,250)"){cor = "beige";}
429 456 else
430 457 {cor = "RGB(250,250,250)";}
431 458 }
... ...