PageSourceSearch

https://app.inventapalabras.com/assets/InventaPalabrasApp/src/Menu-48ccf637f752f5a8d09d206f4ffb7c19.js

js inventapalabras.com collected 2026-10-04 12:29:38 UTC 16,742 bytes, 431 lines download raw bytes

1function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2    try {
3        var info = gen[key](arg);
4        var value = info.value;
5    } catch (error) {
6        reject(error);
7        return;
8    }
9    if (info.done) {
10        resolve(value);
11    } else {
12        Promise.resolve(value).then(_next, _throw);
13    }
14}
15function _async_to_generator(fn) {
16    return function() {
17        var self = this, args = arguments;
18        return new Promise(function(resolve, reject) {
19            var gen = fn.apply(self, args);
20            function _next(value) {
21                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22            }
23            function _throw(err) {
24                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25            }
26            _next(undefined);
27        });
28    };
29}
30function _class_call_check(instance, Constructor) {
31    if (!(instance instanceof Constructor)) {
32        throw new TypeError("Cannot call a class as a function");
33    }
34}
35function _defineProperties(target, props) {
36    for(var i = 0; i < props.length; i++){
37        var descriptor = props[i];
38        descriptor.enumerable = descriptor.enumerable || false;
39        descriptor.configurable = true;
40        if ("value" in descriptor) descriptor.writable = true;
41        Object.defineProperty(target, descriptor.key, descriptor);
42    }
43}
44function _create_class(Constructor, protoProps, staticProps) {
45    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
46    if (staticProps) _defineProperties(Constructor, staticProps);
47    return Constructor;
48}
49function _define_property(obj, key, value) {
50    if (key in obj) {
51        Object.defineProperty(obj, key, {
52            value: value,
53            enumerable: true,
54            configurable: true,
55            writable: true
56        });
57    } else {
58        obj[key] = value;
59    }
60    return obj;
61}
62function _ts_generator(thisArg, body) {
63    var f, y, t, g, _ = {
64        label: 0,
65        sent: function() {
66            if (t[0] & 1) throw t[1];
67            return t[1];
68        },
69        trys: [],
70        ops: []
71    };
72    return g = {
73        next: verb(0),
74        "throw": verb(1),
75        "return": verb(2)
76    }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
77        return this;
78    }), g;
79    function verb(n) {
80        return function(v) {
81            return step([
82                n,
83                v
84            ]);
85        };
86    }
87    function step(op) {
88        if (f) throw new TypeError("Generator is already executing.");
89        while(_)try {
90            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
91            if (y = 0, t) op = [
92                op[0] & 2,
93                t.value
94            ];
95            switch(op[0]){
96                case 0:
97                case 1:
98                    t = op;
99                    break;
100                case 4:
101                    _.label++;
102                    return {
103                        value: op[1],
104                        done: false
105                    };
106                case 5:
107                    _.label++;
108                    y = op[1];
109                    op = [
110                        0
111                    ];
112                    continue;
113                case 7:
114                    op = _.ops.pop();
115                    _.trys.pop();
116                    continue;
117                default:
118                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
119                        _ = 0;
120                        continue;
121                    }
122                    if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
123                        _.label = op[1];
124                        break;
125                    }
126                    if (op[0] === 6 && _.label < t[1]) {
127                        _.label = t[1];
128                        t = op;
129                        break;
130                    }
131                    if (t && _.label < t[2]) {
132                        _.label = t[2];
133                        _.ops.push(op);
134                        break;
135                    }
136                    if (t[2]) _.ops.pop();
137                    _.trys.pop();
138                    continue;
139            }
140            op = body.call(thisArg, _);
141        } catch (e) {
142            op = [
143                6,
144                e
145            ];
146            y = 0;
147        } finally{
148            f = t = 0;
149        }
150        if (op[0] & 5) throw op[1];
151        return {
152            value: op[0] ? op[1] : void 0,
153            done: true
154        };
155    }
156}
157import $ from "jquery";
158import { Modal } from "bootstrap";
159import ExploradorCargarTareas from "./ExploradorCargarTareas.js";
160import ExploradorGuardarTareas from "./ExploradorGuardarTareas.js";
161export var Menu = /*#__PURE__*/ function() {
162    "use strict";
163    function Menu(state) {
164        var _this = this;
165        _class_call_check(this, Menu);
166        _define_property(this, "state", void 0);
167        _define_property(this, "cargarTareaOnline", void 0);
168        _define_property(this, "guardarTareaOnline", void 0);
169        _define_property(this, "documentoModificado", false);
170        _define_property(this, "saveData", function() {
171            var a = document.createElement("a");
172            document.body.appendChild(a);
173            a.style = "display: none";
174            return function(data, fileName) {
175                var blob = new Blob([
176                    data
177                ], {
178                    type: "octet/stream"
179                }), url = window.URL.createObjectURL(blob);
180                a.href = url;
181                a.download = fileName;
182                a.click();
183                window.URL.revokeObjectURL(url);
184            };
185        }());
186        var cargarTareaOnline = new ExploradorCargarTareas(state);
187        var guardarTareaOnline = new ExploradorGuardarTareas(state);
188        this.cargarTareaOnline = cargarTareaOnline;
189        this.guardarTareaOnline = guardarTareaOnline;
190        this.state = state;
191        this.addPropiedad(state, "nombre", "nombreTareaFichTareaGuardar");
192        this.addPropiedad(state, "descripcion", "descripcionFichTareaGuardar");
193        this.addPropiedad(state, "tipo", "tipoFichTareaGuardar");
194        this.addPropiedad(state, "enunciado", "enunciadoFichTareaGuardar");
195        this.state.on("load", function() {
196            _this.documentoModificado = false;
197        });
198        this.state.on("save", function() {
199            _this.documentoModificado = true;
200        });
201        var _this1 = this;
202        $(".importarFichero-cargar").on("click", /*#__PURE__*/ _async_to_generator(function() {
203            var continuar, selected, id, texto, data, fichero;
204            return _ts_generator(this, function(_state) {
205                switch(_state.label){
206                    case 0:
207                        return [
208                            4,
209                            _this1.confirmarCargarActividad()
210                        ];
211                    case 1:
212                        continuar = _state.sent();
213                        if (!continuar) {
214                            return [
215                                2
216                            ];
217                        }
218                        selected = $("ul#tabsSeleccionarFichero .nav-link.active").data("bs-target");
219                        if (selected == "#tabsSeleccionarFicheroOnline") {
220                            if (cargarTareaOnline.selected && cargarTareaOnline.selected.data && cargarTareaOnline.selected.data.tarea) {
221                                id = cargarTareaOnline.selected.data.tarea;
222                                cargarTareaOnline.cargarTareaAPI(id).then(function(res) {
223                                    Modal.getInstance(document.getElementById("importarFicheroModal")).hide();
224                                });
225                            } else {
226                                alert("Tiene que seleccionar una tarea de la lista");
227                            }
228                        }
229                        if (selected == "#tabsSeleccionarFicheroCopyPaste") {
230                            texto = document.getElementById("textAreaCopyPaste").value;
231                            data = state.migrarDatos(texto);
232                            state.loadState(data);
233                            Modal.getInstance(document.getElementById("importarFicheroModal")).hide();
234                        }
235                        if (selected == "#tabsSeleccionarFicheroLocal") {
236                            fichero = document.getElementById("formFile");
237                            if (fichero.files.length > 0) {
238                                fichero.files[0].text().then(function(texto) {
239                                    var data = state.migrarDatos(texto);
240                                    state.loadState(data);
241                                    _this1.state.setTareaActual(undefined);
242                                    Modal.getInstance(document.getElementById("importarFicheroModal")).hide();
243                                });
244                            }
245                        }
246                        return [
247                            2
248                        ];
249                }
250            });
251        }));
252        var _this2 = this;
253        $(".nueva-actividad-reset").on("click", /*#__PURE__*/ _async_to_generator(function() {
254            var continuar, url;
255            return _ts_generator(this, function(_state) {
256                switch(_state.label){
257                    case 0:
258                        return [
259                            4,
260                            _this2.confirmarCargarActividad()
261                        ];
262                    case 1:
263                        continuar = _state.sent();
264                        if (!continuar) {
265                            return [
266                                2
267                            ];
268                        }
269                        url = new URL(window.location.href);
270                        state.clearLocalStorage();
271                        document.location.href = url.origin + url.pathname;
272                        return [
273                            2
274                        ];
275                }
276            });
277        }));
278        var _this3 = this;
279        $(".nueva-actividad-default").on("click", /*#__PURE__*/ _async_to_generator(function() {
280            var continuar;
281            return _ts_generator(this, function(_state) {
282                switch(_state.label){
283                    case 0:
284                        return [
285                            4,
286                            _this3.confirmarCargarActividad()
287                        ];
288                    case 1:
289                        continuar = _state.sent();
290                        if (!continuar) {
291                            return [
292                                2
293                            ];
294                        }
295                        state.clearLocalStorage();
296                        state.setTareaActual(undefined);
297                        cargarTareaOnline.cargarTareaAPIDefault();
298                        return [
299                            2
300                        ];
301                }
302            });
303        }));
304        document.getElementById("guardarFicheroModal").addEventListener("show.bs.modal", function() {
305        // let data = state.build();
306        // let text = state.buildToString(data);
307        // console.log(text);
308        // $("#actividadTexto").text(text);
309        });
310        $(".guardarFichero-cargar").on("click", function() {
311            var selection = guardarTareaOnline.selected;
312            console.log("Menu", selection);
313            if (!selection) {
314                alert("Tiene que selccionar un directorio para almacenar la tarea");
315                return;
316            }
317            if (selection.data.carpeta === undefined) {
318                alert("Tiene que selccionar un directorio para almacenar la tarea");
319                return;
320            }
321            _this.guardarTareaOnline.guardarTareaNuevaAPI().then(function(res) {
322                if (res) {
323                    _this.documentoModificado = false;
324                    Modal.getInstance(document.getElementById("guardarFicheroModal")).hide();
325                }
326            });
327        });
328        $(".actualizarFichero-cargar").on("click", function() {
329            var selection = guardarTareaOnline.selected;
330            console.log("Menu", selection);
331            if (!selection) {
332                alert("Tiene que selccionar un directorio para almacenar la tarea");
333                return;
334            }
335            if (selection.data.carpeta === undefined) {
336                alert("Tiene que selccionar un directorio para almacenar la tarea");
337                return;
338            }
339            var id = state.getTareaActual();
340            if (!id) {
341                alert("No ha cargado ninguna tarea para actualizar");
342                return;
343            }
344            _this.guardarTareaOnline.guardarTareaNuevaAPI(id.id.toString()).then(function(res) {
345                if (res) {
346                    Modal.getInstance(document.getElementById("guardarFicheroModal")).hide();
347                    _this.documentoModificado = false;
348                }
349            });
350        });
351        $(".descargarFicheroActividad").on("click", function() {
352            var data = state.build();
353            var text = state.buildToString(data);
354            var nombre = document.getElementById("nombreTareaFichTareaGuardar").value;
355            if (!nombre) {
356                nombre = "Actividad InventaPalabras - " + new Date().toLocaleDateString() + ".tarea";
357            } else {
358                nombre = nombre + ".tarea";
359            }
360            _this.saveData(text, nombre);
361        });
362        var parametroTarea = this.obtenerParametro("tarea");
363        if (parametroTarea) {
364            this.cargarTareaOnline.cargarTareaAPI(parametroTarea);
365        // let url = new URL(window.location.href);
366        // history.pushState({}, "", url.origin + url.pathname);
367        }
368    }
369    _create_class(Menu, [
370        {
371            key: "addPropiedad",
372            value: function addPropiedad(state, nombreFichero, idField) {
373                var _this = this;
374                state.addProp(nombreFichero, function() {
375                    return document.getElementById(idField).value;
376                }, function(a) {
377                    document.getElementById(idField).value = a;
378                });
379                document.getElementById(idField).addEventListener("change", function() {
380                    return _this.state.saveLocalStorage();
381                });
382            }
383        },
384        {
385            key: "obtenerParametro",
386            value: function obtenerParametro(nombre) {
387                var parametros = document.location.search;
388                if (parametros.length > 0) {
389                    parametros = parametros.substring(1);
390                    var lista = parametros.split("&");
391                    for(var index = 0; index < lista.length; index++){
392                        var element = lista[index].split("=", 2);
393                        if (element.length == 1) {
394                            if (element[0] == nombre) {
395                                return true;
396                            }
397                        } else if (element.length == 2) {
398                            if (element[0] == nombre) {
399                                return element[1];
400                            }
401                        }
402                    }
403                }
404                return null;
405            }
406        },
407        {
408            key: "confirmarCargarActividad",
409            value: function confirmarCargarActividad() {
410                var _this = this;
411                return _async_to_generator(function() {
412                    return _ts_generator(this, function(_state) {
413                        if (_this.documentoModificado) {
414                            if (!confirm("Si continua se perder\xe1n los datos. Pulsa Cancelar para mantener los datos.")) {
415                                return [
416                                    2,
417                                    false
418                                ];
419                            }
420                        }
421                        return [
422                            2,
423                            true
424                        ];
425                    });
426                })();
427            }
428        }
429    ]);
430    return Menu;
431}();

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.