PageSourceSearch

https://www.meteorologia.gov.py/wp-content/themes/dmh/assets/plugins/productos/pronostico.js?ver=1,1

js meteorologia.gov.py collected 2026-09-24 09:11:28 UTC 4,604 bytes, 121 lines download raw bytes

1function autocomplete(inp, arr) {
2/*the autocomplete function takes two arguments,
3the text field element and an array of possible autocompleted values:*/
4var currentFocus;
5/*execute a function when someone writes in the text field:*/
6inp.addEventListener("input", function(e) {
7    var a, b, i, val = this.value;
8    /*close any already open lists of autocompleted values*/
9    closeAllLists();
10    if (!val) { return false;}
11    currentFocus = -1;
12    /*create a DIV element that will contain the items (values):*/
13    a = document.createElement("DIV");
14    a.setAttribute("id", this.id + "autocomplete-list");
15    a.setAttribute("class", "autocomplete-items");
16    /*append the DIV element as a child of the autocomplete container:*/
17    this.parentNode.appendChild(a);
18    /*for each item in the array...*/
19    for (i = 0; i < arr.length; i++) {
20      /*check if the item starts with the same letters as the text field value:*/
21      if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {
22        /*create a DIV element for each matching element:*/
23        b = document.createElement("DIV");
24        /*make the matching letters bold:*/
25        b.innerHTML = "<strong>" + arr[i].substr(0, val.length) + "</strong>";
26        b.innerHTML += arr[i].substr(val.length);
27        /*insert a input field that will hold the current array item's value:*/
28        b.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
29        /*execute a function when someone clicks on the item value (DIV element):*/
30        b.addEventListener("click", function(e) {
31            /*insert the value for the autocomplete text field:*/
32            inp.value = this.getElementsByTagName("input")[0].value;
33            /*close the list of autocompleted values,
34            (or any other open lists of autocompleted values:*/
35            closeAllLists();
36        });
37        a.appendChild(b);
38      }
39    }
40});
41/*execute a function presses a key on the keyboard:*/
42inp.addEventListener("keydown", function(e) {
43    var x = document.getElementById(this.id + "autocomplete-list");
44    if (x) x = x.getElementsByTagName("div");
45    if (e.keyCode == 40) {
46      /*If the arrow DOWN key is pressed,
47      increase the currentFocus variable:*/
48      currentFocus++;
49      /*and and make the current item more visible:*/
50      addActive(x);
51    } else if (e.keyCode == 38) { //up
52      /*If the arrow UP key is pressed,
53      decrease the currentFocus variable:*/
54      currentFocus--;
55      /*and and make the current item more visible:*/
56      addActive(x);
57    } else if (e.keyCode == 13) {
58      /*If the ENTER key is pressed, prevent the form from being submitted,*/
59      e.preventDefault();
60      if (currentFocus > -1) {
61        /*and simulate a click on the "active" item:*/
62        if (x) x[currentFocus].click();
63      }
64    }
65});
66function addActive(x) {
67  /*a function to classify an item as "active":*/
68  if (!x) return false;
69  /*start by removing the "active" class on all items:*/
70  removeActive(x);
71  if (currentFocus >= x.length) currentFocus = 0;
72  if (currentFocus < 0) currentFocus = (x.length - 1);
73  /*add class "autocomplete-active":*/
74  x[currentFocus].classList.add("autocomplete-active");
75}
76function removeActive(x) {
77  /*a function to remove the "active" class from all autocomplete items:*/
78  for (var i = 0; i < x.length; i++) {
79    x[i].classList.remove("autocomplete-active");
80  }
81}
82function closeAllLists(elmnt) {
83  /*close all autocomplete lists in the document,
84  except the one passed as an argument:*/
85  var x = document.getElementsByClassName("autocomplete-items");
86  for (var i = 0; i < x.length; i++) {
87    if (elmnt != x[i] && elmnt != inp) {
88      x[i].parentNode.removeChild(x[i]);
89    }
90  }
91}
92/*execute a function when someone clicks in the document:*/
93document.addEventListener("click", function (e) {
94    closeAllLists(e.target);
95  });
96}
97
98/*An array containing all the country names in the world:*/
99pronosticos = php_vars.pronosticos;
100lugares = [];
101
102jQuery.each( pronosticos, function( key, value ) {
103lugares.push(value.region.ciudad);
104});
105
106/*initiate the autocomplete function on the "myInput" element, and pass along the countries array as possible autocomplete values:*/
107autocomplete(document.getElementById("seleccionar"), lugares);
108
109var dict = {"á":"a", "é":"e", "í":"i", "ó":"o", "ú":"u"};
110
111function goToAnchor() {
112  var seleccion = jQuery('#seleccionar').val();
113  var loc = seleccion.replace(/[^\w ]/g, function(char) {
114      return dict[char] || char;
115  });
116
117  loc = loc.replace(/ /g,"_").toLowerCase();
118
119  document.location = '#' + loc;
120  return false;
121}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.