PageSourceSearch

https://oma.org.ar/utils/utils.js

js oma.org.ar collected 2026-10-02 11:43:49 UTC 3,191 bytes, 98 lines download raw bytes

1
2function complete_year_select(select){
3    url = "/contents/valid_years.json";
4    fetch(url, {"cache": "no-store"}).then(r => r.json()).then(function(years){
5        years.sort();
6        years.reverse();
7        years.forEach(function(year){
8            const opt = document.createElement("option");
9            opt.value = year;
10            opt.text = year;
11            select.appendChild(opt);
12        })
13    });
14}
15
16function show_modal(title, body){
17    var old_modal = document.getElementById("modal_id");
18    if (old_modal){
19        old_modal.remove();
20    }
21    var new_modal = create_modal_element(title, body);
22    document.getElementsByTagName("body")[0].appendChild(new_modal);
23    var modal_obj = new bootstrap.Modal(new_modal);
24    modal_obj.show();
25}
26
27
28function create_modal_element(title, body){
29    var modal_div = document.createElement("div");
30    modal_div.className = "modal fade";
31    modal_div.id = "modal-id";
32    modal_div.tabIndex = -1;
33
34    var modal_dialog = document.createElement("div");
35    modal_dialog.className = "modal-dialog modal-dialog-centered";
36    modal_div.appendChild(modal_dialog);
37
38    var modal_content = document.createElement("div");
39    modal_content.className = "modal-content";
40    modal_dialog.appendChild(modal_content);
41
42    var modal_header = document.createElement("div");
43    modal_header.className = "modal-header";
44    modal_content.appendChild(modal_header);
45
46    var h4_title = document.createElement("h4");
47    h4_title.className = "modal-title";
48    h4_title.innerHTML = title;
49    modal_header.appendChild(h4_title);
50
51    var close_button_x = document.createElement("button");
52    close_button_x.className = "btn-close";
53    close_button_x.setAttribute("data-bs-dismiss", "modal");
54    modal_header.appendChild(close_button_x);
55
56    var modal_body = document.createElement("div");
57    modal_body.className = "modal-body";
58    modal_content.appendChild(modal_body);
59
60    var h5_body = document.createElement("h5");
61    h5_body.innerHTML = body;
62    modal_body.appendChild(h5_body);
63
64    var modal_footer = document.createElement("div");
65    modal_footer.className = "modal-footer";
66    modal_content.appendChild(modal_footer);
67
68    var close_button = document.createElement("button");
69    close_button.className = "btn btn-primary";
70    close_button.setAttribute("data-bs-dismiss", "modal");
71    close_button.innerHTML = "Close"
72    modal_footer.appendChild(close_button);
73
74    return modal_div;
75}
76
77
78function upload_image(url, info, button){
79    var url = BASE_URL + url;
80    var prev_innerHTML = button.innerHTML;
81    button.innerHTML = "";
82    var span = document.createElement("span")
83    span.className = "spinner-border spinner-border-sm";
84    span.setAttribute("role", "status");
85    span.setAttribute("aria-hidden", "true");
86    button.appendChild(span);
87    button.append(" Loading");
88    button.disabled = true;
89    fetch(url, {
90       method: "POST",
91       body: info
92   }).then(function (response) {
93        button.innerHTML = prev_innerHTML;
94        button.disabled = false;
95        var title = response.ok ? "Subido correctamente" : "Error"
96        response.text().then(data => show_modal(title, data));
97    });
98}

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.