PageSourceSearch

https://libano-tolima.gov.co/SiteAssets/V3/maintramites/js/main/services.js

js libano-tolima.gov.co collected 2026-10-02 13:38:54 UTC 2,844 bytes, 93 lines download raw bytes

1// Ingrese en el objeto los parametros que vaa consultar de la lista
2
3const nombreSitio = "Ciudadanos";
4const nombreBiblioteca = "TramitesyServicios";
5
6const parametros = {
7  id: "ID",
8  titleTramite: "Title",
9  Dependencia: "Dependencia",
10  Recaudo: "Recaudo",
11  urlTramite: "Tr_x00e1_mite_x0020_Online",
12  suit: "Categor_x00ed_a_x0020_SUIT",
13  descripcion: "Descripci_x00f3_n",
14  activo: "activo",
15  duracionTramite: "DuracionTramite",
16};
17const URL_API = `${location.protocol}//${location.host}/${nombreSitio}/_api/web/lists/getbytitle('${nombreBiblioteca}')/items?$select=${parametros.id},${parametros.titleTramite},${parametros.Dependencia},${parametros.Recaudo},${parametros.urlTramite},${parametros.suit},${parametros.descripcion},${parametros.activo},${parametros.duracionTramite}`;
18
19export const getData = async () => {
20  try {
21    const response = await fetch(URL_API, {
22      method: "GET",
23      headers: {
24        Accept: "application/json; odata=verbose",
25      },
26    });
27    const data = await response.json();
28    let tramites = [];
29    let filters = [];
30    if (data?.d?.results?.length != 0) {
31      tramites = formarterData(data.d.results);
32      filters = fillFilters(data.d.results);
33    }
34
35    return [tramites, filters];
36  } catch (error) {
37    console.log(error);
38  }
39};
40
41function formarterData(array) {
42  let tram = [];
43
44  array.forEach((item) => {
45    const newTra = {
46      id: Number(item.ID),
47      title: item?.Title.trim(),
48      description: formatDescription(item["Descripci_x00f3_n"]),
49      type: obtaintype(item["Tr_x00e1_mite_x0020_Online"]?.Url),
50      duration: item.duracionTramite,
51      active: item.activo,
52      url: item["Tr_x00e1_mite_x0020_Online"]?.Url
53        ? item["Tr_x00e1_mite_x0020_Online"].Url
54        : "",
55      cost: obtainCost(item.tipoTramite),
56      dependencia: item.Dependencia,
57      suit: item["Categor_x00ed_a_x0020_SUIT"]?.Description
58        ? item["Categor_x00ed_a_x0020_SUIT"].Description
59        : "",
60    };
61    tram.push(newTra);
62  });
63
64  return tram;
65}
66
67function formatDescription(rawDescripcion) {
68  // Crear un elemento div temporal y establecer su HTML al de la descripción
69  let tempDiv = document.createElement("div");
70  tempDiv.innerHTML = rawDescripcion;
71  // Extraer y devolver solo el texto del div temporal, independientemente de la estructura HTML
72  return tempDiv.textContent || tempDiv.innerText || "";
73}
74
75function obtaintype(type) {
76  return type?.length ? 0 : 3;
77}
78
79function obtainCost(cost) {
80  return cost === "No" ? false : true;
81}
82
83function fillFilters(array) {
84  let filt = [];
85  if (array.length != 0) {
86    array.forEach((item) => {
87      if (!filt.includes(item.Dependencia)) {
88        filt.push(item.Dependencia);
89      }
90    });
91  }
92  return filt;
93}

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.