PageSourceSearch

https://unitel.ao/wp-content/themes/unitel/assets/js/script.js?ver=1786591975

js unitel.ao collected 2026-09-24 10:01:26 UTC 23,294 bytes, 761 lines download raw bytes

1(function ($) {
2  $.extend($.expr[":"], {
3    missing: function (elem, index, match) {
4      return (
5        (elem.title || elem.textContent || elem.innerText || "")
6          .toLowerCase()
7          .indexOf(match[3]) == -1
8      );
9    },
10  });
11
12  
13
14  $.extend($.expr[":"], {
15    exists: function (elem, i, match, array) {
16      return (
17        (elem.title || elem.textContent || elem.innerText || "")
18          .toLowerCase()
19          .indexOf((match[3] || "").toLowerCase()) >= 0
20      );
21    },
22  });
23
24  $.extend($.fn, {
25    quickfilter: function (el) {
26      return this.each(function () {
27        var _this = $(this);
28        var query = _this.val().toLowerCase();
29
30        _this.keyup(function () {
31          query = $(this).val().toLowerCase();
32
33          if (query.replace(/\s/g, "") != "") {
34            $(el + ':exists("' + query.toString() + '")').show();
35            $(el + ':missing("' + query.toString() + '")').hide();
36          } else {
37            $(el).show();
38          }
39        });
40      });
41    },
42  });
43})(jQuery);
44
45/* Matomo */
46if (window.MATOMO_URL) {
47  var _paq = window._paq = window._paq || [];
48  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
49  _paq.push(['trackPageView']);
50  _paq.push(['enableLinkTracking']);
51  (function() {
52    var u=window.MATOMO_URL;
53    
54    _paq.push(['setTrackerUrl', u+'matomo.php']);
55    _paq.push(['setSiteId', '1']);
56    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
57    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
58  })();
59}
60/* End Matomo Code */
61
62function serializeToFormData(formDataArray) {
63  var formData = new FormData();
64  jQuery.each(formDataArray, function (index, field) {
65    formData.append(field.name, field.value);
66  });
67  return formData;
68}
69
70function changeHashWithoutReload(hash) {
71  if (hash != "all") {
72    history.pushState(null, null, "#" + hash);
73  } else {
74    history.pushState(
75      "",
76      document.title,
77      window.location.pathname + window.location.search
78    );
79  }
80}
81
82function request(
83  formData,
84  successCallBack,
85  beforeCallBack = null,
86  completeCallback = null,
87  errorCallback = null
88) {
89  if (!(formData instanceof FormData)) {
90    formData = objToFormData(formData);
91  }
92  jQuery.ajax({
93    url: (window.UnitelConfig && window.UnitelConfig.ajax_url) || (window.ajax_object && window.ajax_object.ajax_url),
94    type: "post",
95    dataType: "json",
96    contentType: false,
97    cache: false,
98    processData: false,
99    data: formData,
100    beforeSend:
101      beforeCallBack != null
102        ? beforeCallBack
103        : function () {
104            showLoader();
105          },
106    success: successCallBack,
107    complete:
108      completeCallback != null
109        ? completeCallback
110        : function () {
111            hideLoader();
112          },
113    error:
114      errorCallback != null
115        ? errorCallback
116        : function (request, status, error) {
117            console.error(request.responseText);
118          },
119  });
120}
121
122function objToFormData(obj) {
123  let form_data = new FormData();
124  let json = false;
125  for (var key in obj) {
126    let item = obj[key];
127    //not stringify binary upload
128    if (typeof obj[key] == "object" && !key.includes("__file")) {
129      if (!json) {
130        json = true;
131      }
132      item = JSON.stringify(obj[key]);
133    }
134    form_data.append(key, item);
135  }
136
137  if (json) {
138    form_data.append("json_encode", true);
139  }
140
141  return form_data;
142}
143
144function showLoader() {
145  jQuery(".untl-loader").removeClass("untl-hidden");
146  jQuery(".untl-card-list-container").addClass("untl-hidden");
147  jQuery(".unitel-blocks-form-step").addClass("untl-hidden");
148  jQuery(".unitel-blocks-form-childrens").addClass("untl-hidden");
149}
150
151function hideLoader() {
152  jQuery(".untl-loader").addClass("untl-hidden");
153  jQuery(".untl-card-list-container").removeClass("untl-hidden");
154  jQuery(".unitel-blocks-form-step").removeClass("untl-hidden");
155  jQuery(".unitel-blocks-form-childrens").removeClass("untl-hidden");
156}
157
158function updateRoamingCountry(countryCode, self) {
159  jQuery(".untl-dropdown-option, .untl-country-flag").removeClass("active");
160  jQuery(self).addClass("active");
161  jQuery("#option-" + countryCode).addClass("active");
162
163  // update country name and code
164  jQuery("#untl-r-country, .untl-country-name").text(
165    jQuery("#option-" + countryCode).text()
166  );
167  jQuery("form #untl-r-country-code").val(countryCode);
168
169  // close dropdown
170  jQuery(self).closest(".untl-form-select").removeClass("active");
171  scrollToId("#untl-r-country-code-label");
172
173  // show results
174  jQuery(".untl-loader").removeClass("untl-hidden");
175  jQuery(".untl-top-countries").addClass("untl-hidden");
176  jQuery(".untl-form-result").addClass("untl-hidden");
177  // Shows updated list - Just for test
178  setTimeout(function () {
179    // Show loading wheel while updates list
180    jQuery(".untl-loader").addClass("untl-hidden");
181    jQuery(".untl-form-result").removeClass("untl-hidden");
182    jQuery(".untl-form-result .country")
183      .not("#result-" + countryCode)
184      .addClass("untl-hidden");
185    jQuery("#result-" + countryCode).removeClass("untl-hidden");
186  }, 500);
187}
188
189function updateFindStoresProvincia(provincia, self) {
190  const list = jQuery("#untl-list.stores-list");
191  const loader = list.find(".untl-loader");
192  const results = list.find(".untl-card-list-result");
193  //const stores = results.find(".untl-card-item:not(:hidden)"); //get only the current stores
194  const stores = results.find(".untl-card-item");
195
196  loader.removeClass("untl-hidden");
197  results.addClass("untl-hidden");
198
199  jQuery("#clear_filters").removeClass("untl-hidden");
200
201  stores.each(function () {
202    const storeProvincia = jQuery(this).attr("provincia");
203    if (storeProvincia != provincia) {
204      jQuery(this).hide();
205    } else {
206      jQuery(this).show();
207    }
208  });
209
210  setTimeout(() => {
211    loader.addClass("untl-hidden");
212    results.removeClass("untl-hidden");
213  }, 1000);
214
215  //close
216  jQuery(self).closest(".untl-form-select").find("#untl-r-country").text(provincia);
217  jQuery(self).closest(".untl-form-select").removeClass("active");
218}
219
220// Função delay para debounce
221function delay(callback, ms) {
222  var timer = 0;
223  return function() {
224    var context = this, args = arguments;
225    clearTimeout(timer);
226    timer = setTimeout(function () {
227      callback.apply(context, args);
228    }, ms || 0);
229  };
230}
231
232(function($) {
233$(function () {
234  function applyFilters() {
235    let selectedYear = $("#press-release-section #untl-ci-year").val().trim();
236    let search = $("#press-release-section #untl-ci-search").val().trim().toLowerCase();
237
238    $("#press-release-section #untl-list .untl-card-item").each(function () {
239      let year = $(this).attr("year");
240      let title = $(this).find(".untl-title-xsb").text().toLowerCase();
241
242      if ((year != selectedYear && selectedYear != "") || !title.includes(search)) {
243        $(this).addClass("untl-hidden");
244      } else {
245        $(this).removeClass("untl-hidden");
246      }
247    });
248  }
249
250  // Search com keyup + delay
251  $("#press-release-section #untl-ci-search").keyup(delay(function () {
252    showLoader();
253    applyFilters();
254    setTimeout(function () {
255      hideLoader();
256    }, 500);
257  }, 500));
258
259  // Year dropdown com change + remove untl-empty
260  $("#press-release-section #untl-ci-year").change(function () {
261    $(this).removeClass('untl-empty');
262    showLoader();
263    applyFilters();
264    setTimeout(function () {
265      hideLoader();
266    }, 500);
267  });
268
269  // Ponte: Hash navigation → AJAX filter (menu filho → tabs)
270  $(window).on("load", function () {
271    if (window.location.hash) {
272      let hashValue = window.location.hash.slice(1);
273      let element = $("#category-filter [slug='" + hashValue + "']");
274      
275      if (element.length > 0) {
276        // Simular clique no botão - dispara todo o fluxo AJAX automaticamente
277        element.trigger('click');
278      }
279    }
280  });
281
282  // Reagir a mudanças de hash (navegação via menu)
283  $(window).on('hashchange', function() {
284    let hashValue = window.location.hash.slice(1);
285    let element = $("#category-filter [slug='" + hashValue + "']");
286    
287    if (element.length > 0 && !element.hasClass('unt-category--active')) {
288      element.trigger('click');
289    }
290  });
291
292  $("#category-filter .unt-category").click(function (e) {
293    e.preventDefault();
294    let cat = $(this).attr("slug");
295    let action = $('input[name="action"]').val();
296    let tax = $('input[name="taxonomy"]').val();
297    let post_type = $('input[name="post_type"]').val();
298    let perPage = $('input[name="perPage"]').val();
299    changeHashWithoutReload(cat);
300    
301    // Atualizar menu visual diretamente (sem disparar hashchange)
302    var hash = '#' + cat;
303    $('.untl-navbar-menu a[href*="#"]').removeClass('active');
304    $('.untl-navbar-menu a[href$="' + hash + '"]').addClass('active');
305    
306    // Marcar <li> pai como ativo
307    $('.untl-navbar-menu .untl-nav-sub').each(function() {
308      var $parentLi = $(this);
309      var $submenu = $parentLi.find('.untl-nav-sub-opts');
310      var hasActiveChild = $submenu.find('a.active').length > 0;
311      
312      if (hasActiveChild) {
313        $parentLi.addClass('active');
314      } else {
315        $parentLi.removeClass('active');
316      }
317    });
318    
319    $('input[name="page"]').val(0);
320    $("#category-filter .unt-category")
321      .not($(this))
322      .removeClass("unt-category--active");
323    $(this).addClass("unt-category--active");
324    $("#filtered-items .untl-card-item").remove();
325    request(
326      {
327        action: action,
328        slug: cat,
329        tax: tax,
330        post_type: post_type,
331      },
332      function (data) {
333        if (perPage >= data.numberOfPosts) {
334          $("#category_load_more").hide();
335        } else {
336          $("#category_load_more").show();
337        }
338        $('input[name="category"]').val(cat);
339        $("#filtered-items").append(data.html);
340      }
341    );
342  });
343
344  jQuery(document).ready(function($) {
345    $("#category_load_more .wsu_load_more").click(function (e) {
346        e.preventDefault();
347
348        let action = $('#category_load_more input[name="action"]').val();
349        let tax = $('input[name="taxonomy"]').val();
350        let cat = $('input[name="category"]').val();
351        let post_type = $('input[name="post_type"]').val();
352        let page = parseInt($('input[name="page"]').val());
353        let maxPages = parseInt($('input[name="maxPages"]').val());
354        let newpage = page + 1;
355        var container = document.getElementById('filtered-items');
356        var cardItems = container.getElementsByClassName('untl-card-item');
357        var tenthItemIndex = 9 * (newpage - 1);
358        var tenthItemScrollTop = cardItems[tenthItemIndex] ? cardItems[tenthItemIndex].offsetTop : 0;
359
360        $.ajax({
361            url: (window.UnitelConfig && window.UnitelConfig.ajax_url) || (window.ajax_object && window.ajax_object.ajax_url),
362            type: 'POST',
363            data: {
364                action: action,
365                slug: cat,
366                tax: tax,
367                post_type: post_type,
368                page: newpage,
369            },
370            success: function (response) {
371                $('input[name="page"]').val(newpage);
372                if (newpage == maxPages) {
373                    $(".wsu_load_more").hide();
374                }
375                $("#filtered-items").append(response.html);
376                
377            },
378            error: function (jqXHR, textStatus, errorThrown) {
379                }
380        });
381    });
382});
383
384  function checkValidation(step) {
385    let next = true;
386    step.find(".untl-field").each(function () {
387      if (!$(this).get(0).checkValidity()) {
388        next = false;
389        $(this).get(0).reportValidity();
390        return;
391      }
392    });
393    return next;
394  }
395
396  $(".untl-next-step").click(function (e) {
397    e.preventDefault();
398    const form = $(this).closest(".untl-form");
399    form.submit(false);
400    const step = $(this).closest(".unitel-blocks-form-step");
401    const currentStep = parseInt(step.attr("step"));
402    if (checkValidation(step)) {
403      showLoader();
404      $("html,body").animate({
405        scrollTop: $(".untl-form-wrapper").offset().top - 50,
406      });
407      const nextStepValue = currentStep + 1;
408      const nextStep = form.find(`[step='${nextStepValue}']`);
409      step.removeClass("active");
410      nextStep.addClass("active");
411      $(`#step-${currentStep}`)
412        .removeClass("untl-active")
413        .addClass("untl-done");
414      $(`#step-${nextStepValue}`).addClass("untl-active");
415      setTimeout(function () {
416        hideLoader();
417      }, 500);
418    }
419  });
420
421  $(".untl-form .untl-submit").click(function (event) {
422    event.preventDefault(); // Impede o envio padrão do formulário
423    const form = $(this).closest(".untl-form");
424    const step = $(this).closest(".unitel-blocks-form-step");
425    
426    //form.submit(false);
427    if (!form[0].checkValidity()) {
428      // Se o formulário não for válido, exibe a validação HTML5
429      event.preventDefault(); // Impede o envio do formulário
430      form[0].reportValidity(); // Exibe mensagens de erro para campos obrigatórios
431      return; // Sai da função sem processar a lógica personalizada
432  }
433
434    if (checkValidation(step)) {
435      event.preventDefault(); // Impede o envio padrão do formulário
436      const formToSubmit = {};
437      form.find(":input").each(function () {
438        
439        let slug = $(this).attr("name");
440        let label = $(this)
441          .closest(".unitel-blocks-form-item")
442          .find("label span")
443          .text().replace('(obrigatório)','');
444        let value = $(this).val();
445        if (value.length > 0) {
446          
447          if (!["hidden", "file"].includes($(this).attr("type"))) {
448            
449            formToSubmit[slug] = {
450              label: label,
451              value: value,
452            };
453          } else if ($(this).attr("type") == "file") {
454            if ($(this)[0].files[0] != undefined) {
455              formToSubmit[`${slug}__file`] = $(this)[0].files[0];
456            }
457          } else {
458            formToSubmit[slug] = value;
459          }
460        }
461      });
462
463      //console.log("Dados do formulário:", JSON.stringify(formToSubmit, null, 2));
464
465      request(formToSubmit, function (data) {
466        try{
467          const parentBlock = form.closest(".unitel-blocks-form");
468          parentBlock.find(".untl-form-wrapper").hide();
469          parentBlock.find(".response").html(data);
470
471          sessionStorage.clear();
472        }catch(error){
473          console.error("Erro ao processar a resposta do servidor", error);
474
475        }
476
477        
478      });
479 
480    }
481  });
482
483  
484  $("#menu-top-menu a").click(function () {
485    Cookies.set("current_main_tab", $(this).attr("slug"));
486    Cookies.set("current_home_url", $(this).attr("href"));
487  });
488
489  function showNetPrice() {
490    const filterValidity = $(`[name="filter_validity"]`).val();
491    const filterInternet = $(`[name="filter_internet"]`).val();
492
493    if (filterValidity != "" && filterInternet != "") {
494      const price = $(
495        `[validity="${filterValidity}"][internet="${filterInternet}"]`
496      );
497      if (price.length) {
498        const parent = price.closest(".unitel-blocks-net-simulator-item");
499        $(".unitel-blocks-net-simulator-item")
500          .not(parent)
501          .removeClass("current");
502        parent.addClass("current");
503        $(".unitel-blocks-net-simulator .price").addClass("active");
504      } else {
505        $(".unitel-blocks-net-simulator .price").removeClass("active");
506      }
507    }
508  }
509
510  $(".unitel-blocks-net-simulator .unt-category").click(function (e) {
511    e.preventDefault();
512    const group = $(this).attr("group");
513    const value = $(this).attr("value");
514    $(`.unitel-blocks-net-simulator [group="${group}"]`)
515      .not($(this))
516      .removeClass("unt-category--active");
517    $(this).addClass("unt-category--active");
518    $(`[name="filter_${group}"]`).val(value);
519    showNetPrice();
520  });
521
522  $(document).ready(function() {
523    showNetPrice();
524  });
525
526  $(".check-simulator-results").click(function (e) {
527    e.preventDefault();
528    const parent = $(this).closest("#simulator-price");
529    const price = parseFloat(parent.find('input[name="price"]').val());
530    const categories = $.map(
531      parent.find('input[name="category[]"]:checked'),
532      function (c) {
533        return c.value;
534      }
535    );
536
537    request(
538      {
539        action: "simulate_plan",
540        price: price,
541        categories: categories,
542      },
543      function (data) {
544        $("#simulator-results .untl-card-list").html("");
545        $("#simulator-results .untl-card-list").append(data.plansHTML);
546        $("#simulator-sugestions .untl-card-list").html("");
547        $("#simulator-sugestions .untl-card-list").append(data.sugestionHTML);
548      },
549      function () {
550        // hide questions and start loading heel
551        $("#simulator-questions").addClass("untl-hidden");
552        $(".untl-loader").removeClass("untl-hidden");
553        scrollToId(".untl-navbar");
554      },
555      function () {
556        // Show loading wheel while updates list
557        $(".untl-loader").addClass("untl-hidden");
558        $("#simulator-results").removeClass("untl-hidden");
559        $("#simulator-sugestions").removeClass("untl-hidden");
560      }
561    );
562  });
563
564  $("#untl-cr-address").on("keyup", function () {
565    const search = $(this).val();
566    const list = $("#untl-list.stores-list");
567    const loader = list.find(".untl-loader");
568    const results = list.find(".untl-card-list-result");
569    const stores = results.find('.untl-card-item:not([style*="display:none"])');
570
571    $("#clear_filters").removeClass("untl-hidden");
572
573    loader.removeClass("untl-hidden");
574    results.addClass("untl-hidden");
575
576    stores.each(function () {
577      const storeTitle = $(this).attr("title");
578      if (storeTitle.indexOf(search) === -1) {
579        $(this).hide();
580      }
581    });
582
583    setTimeout(() => {
584      loader.addClass("untl-hidden");
585      results.removeClass("untl-hidden");
586    }, 1000);
587  });
588
589  $("#clear_filters > a").click(function (e) {
590    e.preventDefault();
591
592    const list = $("#untl-list.stores-list");
593    const loader = list.find(".untl-loader");
594    const results = list.find(".untl-card-list-result");
595    const stores = results.find(".untl-card-item");
596
597    $("#untl-cr-address").val("");
598    $("#untl-r-country").text("Pesquisa por província");
599    $("#clear_filters").addClass("untl-hidden");
600
601    loader.removeClass("untl-hidden");
602    results.addClass("untl-hidden");
603
604    stores.each(function () {
605      $(this).show();
606    });
607
608    setTimeout(() => {
609      loader.addClass("untl-hidden");
610      results.removeClass("untl-hidden");
611    }, 1000);
612  });
613
614  $("#untl-search-input").on("keyup", function (event) {
615    if (event.key === "Enter") {
616        const value = $(this).val();
617        if (value.length >= 3) {
618            history.pushState(null, null, `?s=${value}`);
619            location.reload();
620        }
621    }
622  });
623
624  $("#searchLoadMore").click(function (e) {
625    e.preventDefault();
626    const perPage = parseInt($(`[name="perPage"]`).val());
627    const page = parseInt($(`[name="page"]`).val());
628    const maxPages = parseInt($(`[name="maxPages"]`).val());
629    const newPage = page + 1;
630    if (newPage == maxPages) {
631      $(this).addClass("untl-hidden");
632    }
633    if (maxPages > page) {
634      $(`[name="page"]`).val(newPage);
635      $("#untl-list .untl-card-list .untl-hidden").each(function (index) {
636        if (index < perPage) {
637          $(this).removeClass("untl-hidden");
638        } else {
639          return false;
640        }
641      });
642    }
643  });
644
645  $(".unitel-blocks-tabs .untl-tab-section-button").click(function (e) {
646    e.preventDefault();
647    const id = $(this).attr("id");
648    const parent = $(this).closest(".unitel-blocks-tabs");
649    const content = parent.find(`#content_${id}`);
650    //change tab button
651    $(this).addClass("untl-active");
652    parent
653      .find(".untl-tab-section-button")
654      .not($(this))
655      .removeClass("untl-active");
656    //change tab content
657    content.removeClass("hidden");
658    parent.find(".untl-tab-section__content").not(content).addClass("hidden");
659  });
660
661  $("#untl-global-search").on("keyup", function () {
662    const value = $(this).val();
663    if (value.length >= 3) {
664      }
665  });
666
667  $("#benefit_load_more").submit(function (e) {
668    e.preventDefault();
669    const formDataArray = $(this).serializeArray();
670    request(serializeToFormData(formDataArray), function (data) {
671      $("#untl-list .untl-card-list").append(data.html);
672      $("#benefit_load_more").find('input[name="page"]').val(data.nextPage);
673      if (data.hide) {
674        $("#benefit_load_more").hide();
675      }
676    });
677  });
678
679  $(".untl-woo-attribute").click(function (e) {
680    e.preventDefault();
681    const name = $(this).attr("attribute_name");
682    const value = $(this).attr("attribute_value");
683    const index = $(this).attr("attribute_index");
684    const active =
685      name == "pa_color" ? "untl-circles-item--active" : "unt-category--active";
686
687    $(`#${name}_selection .untl-woo-attribute`)
688      .not($(this))
689      .removeClass(active);
690    $(this).addClass(active);
691
692    $(`#${name}`).val(value).trigger("change");
693  });
694
695  $(".reset_variations").click(function () {
696    $(".untl-woo-attribute").removeClass(
697      "untl-circles-item--active unt-category--active"
698    );
699  });
700
701  $('input[name="untl-comparar"]').click(function () {
702    const productList = $("#comparador_products").val();
703    let newValue = productList;
704    if (productList != "") {
705      newValue = productList + ",";
706    }
707    $("#comparador_products").val(newValue + $(this).val());
708  });
709}); //close
710
711jQuery(document).on("woocommerce_update_variation_values", function (e) {
712  if (jQuery(".variations ul[id$='_selection']").length) {
713    jQuery(".variations ul[id$='_selection']").each(function () {
714      const attribute = $(this)
715        .attr("id")
716        .replace(/_selection$/, "");
717      const childs = $(this).find(".untl-woo-attribute");
718      const inative =
719        attribute == "pa_color"
720          ? "untl-circles-item--disabled"
721          : "untl-category--disabled";
722      const options = $(`#${attribute}`).find("option:disabled");
723      if (options.length) {
724        const disabled = [];
725        options.each(function () {
726          disabled.push($(this).val());
727        });
728        childs.each(function () {
729          const child = $(this);
730          if (disabled.includes(child.attr("attribute_value"))) {
731            child.addClass(inative);
732          }
733        });
734      }
735    });
736  }
737});
738
739function activateTabFromHash() {
740  const hash = window.location.hash;
741  if (hash) {
742      // Find the corresponding link with the matching href
743      const tabLink = $(`#filter-event-categories-list a[href="${hash}"]`);
744      if (tabLink.length) {
745          const index = tabLink.index(); // Get the index of the matching link
746          if (typeof window.toggleTab === 'function') {
747              window.toggleTab(tabLink[0], index); // Trigger the tab toggle
748          }
749      }
750  }
751}
752// Call the function to activate the tab when the page loads
753$(document).ready(function() {
754  activateTabFromHash();
755
756  // Optionally, listen for hash changes
757  $(window).on('hashchange', function() {
758      activateTabFromHash();
759  });
760});
761})(jQuery);

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.