#wip(ecma): Desarrollando la base de trabajo ECMA.
This commit is contained in:
		
							parent
							
								
									5412700a9d
								
							
						
					
					
						commit
						a7e967ce1e
					
				
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,5 +1,5 @@
 | 
				
			|||||||
[Ss]ecrets
 | 
					[Ss]ecrets
 | 
				
			||||||
Data
 | 
					Data
 | 
				
			||||||
CaritasSantaCruz.Mapeate.apache2.conf
 | 
					*.apache2.conf
 | 
				
			||||||
Public/data
 | 
					Public/data
 | 
				
			||||||
*[Ss]ecret*s*
 | 
					*[Ss]ecret*s*
 | 
				
			||||||
@ -12,15 +12,21 @@ Mapeate = function(entradas){
 | 
				
			|||||||
              texto_por_defecto : "", 
 | 
					              texto_por_defecto : "", 
 | 
				
			||||||
              configuracion_sobreescribir : false, 
 | 
					              configuracion_sobreescribir : false, 
 | 
				
			||||||
              i18n_sobreescribir : false, 
 | 
					              i18n_sobreescribir : false, 
 | 
				
			||||||
              formato_terminal : "[{tipo}] {yyyy}{mm}{dd} {hh}{ii}{ss}: {mensaje}", 
 | 
					              formato_terminal : "[{tipo}] {yyyy}{mm}{dd} {hh}{ii}{ss} [{linea}]{archivo}({metodo}): {mensaje}", 
 | 
				
			||||||
              terminal_tipos_por_defecto : [
 | 
					              terminal_tipos_por_defecto : [
 | 
				
			||||||
                  ["unkn", "unknown", "desconocido"], 
 | 
					                  ["unkn", "unknown", "desconocido"], 
 | 
				
			||||||
                  [" ok ", "ok", "si", "correcto"], 
 | 
					                  [" ok ", "ok", "si", "correcto"], 
 | 
				
			||||||
 | 
					                  ["info", "informacion", "information"], 
 | 
				
			||||||
 | 
					                  ["note", "nota", "comment", "comentario"], 
 | 
				
			||||||
                  ["warn", "warning", "aviso", "advertencia"], 
 | 
					                  ["warn", "warning", "aviso", "advertencia"], 
 | 
				
			||||||
                  ["erro", "error", "incrrecto"], 
 | 
					                  ["erro", "error", "incrrecto"], 
 | 
				
			||||||
                  ["fail", "failure", "fallo"], 
 | 
					                  ["fail", "failure", "fallo"], 
 | 
				
			||||||
                  ["exce", "excepcion"]
 | 
					                  ["exce", "excepcion"]
 | 
				
			||||||
              ]
 | 
					              ], 
 | 
				
			||||||
 | 
					              archivos_de_i18n_por_defecto : [
 | 
				
			||||||
 | 
					                  "/json/i18n/Mapeate.i18n.espanol.json"
 | 
				
			||||||
 | 
					              ], 
 | 
				
			||||||
 | 
					              ajax_timeout : 2000
 | 
				
			||||||
          }, 
 | 
					          }, 
 | 
				
			||||||
          configuracion = {}, 
 | 
					          configuracion = {}, 
 | 
				
			||||||
          textos = {}, 
 | 
					          textos = {}, 
 | 
				
			||||||
@ -29,13 +35,29 @@ Mapeate = function(entradas){
 | 
				
			|||||||
        configuracion_sobreescribir = false, 
 | 
					        configuracion_sobreescribir = false, 
 | 
				
			||||||
        idioma_por_defecto = null, 
 | 
					        idioma_por_defecto = null, 
 | 
				
			||||||
        idioma = null, 
 | 
					        idioma = null, 
 | 
				
			||||||
        formato_terminal = "[{tipo}] {yyyy}{mm}{dd} {hh}{ii}{ss}: {mensaje}";
 | 
					        modo_dispositivo = "por_defecto", 
 | 
				
			||||||
 | 
					        modo_gui = "por_defecto", 
 | 
				
			||||||
 | 
					        terminal_unkn_oscuro, terminal_unkn_claro, 
 | 
				
			||||||
 | 
					        terminal_ok_oscuro, terminal_ok_claro, 
 | 
				
			||||||
 | 
					        terminal_info_oscuro, terminal_info_claro, 
 | 
				
			||||||
 | 
					        terminal_note_oscuro, terminal_note_claro, 
 | 
				
			||||||
 | 
					        modo_gui_oscuro = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches, 
 | 
				
			||||||
 | 
					        formato_terminal = "[{tipo}] {yyyy}{mm}{dd} {hh}{ii}{ss} [{linea}]{archivo}({metodo}): {mensaje}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const re_bloque_de_traza = new RegExp("^(" + [
 | 
				
			||||||
 | 
					        /\s*at\s+(([^\s]+)\s+\()?(([^\(\)\:]+\:)?[^\(\)\:]+)(\:([0-9]+)\:[0-9]+)?\)?/.source, // Webkit
 | 
				
			||||||
 | 
					        /([^\@]+)\@([^:]+\:[^\:]+)\:([0-9]+)\:[0-9]+/.source, // Gecko
 | 
				
			||||||
 | 
					    ].join("|") + ")$")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const constructor = () => {
 | 
					    const constructor = () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        configuracion_por_defecto.terminal_tipos_por_defecto.forEach(entrada => terminal_tipos.push(entrada));
 | 
					        configuracion_por_defecto.terminal_tipos_por_defecto.forEach(entrada => terminal_tipos.push(entrada));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.configuracion("autoiniciar") && self.iniciar();
 | 
					        self.print("info", "mapeate_construyendose");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.configuracion("autoiniciar") && self.iniciar(() => {
 | 
				
			||||||
 | 
					            self.print("ok", "mapeate_construido");
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -44,11 +66,20 @@ Mapeate = function(entradas){
 | 
				
			|||||||
        configuracion_sobreescribir = self.configuracion(["configuracion_sobreescribir", "sobreescribir"]);
 | 
					        configuracion_sobreescribir = self.configuracion(["configuracion_sobreescribir", "sobreescribir"]);
 | 
				
			||||||
        formato_terminal = self.configuracion("formato_terminal");
 | 
					        formato_terminal = self.configuracion("formato_terminal");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					        terminal_unkn_oscuro = self.configuracion("terminal_unkn_oscuro");
 | 
				
			||||||
 | 
					        terminal_unkn_claro = self.configuracion("terminal_ounkn_claro");
 | 
				
			||||||
 | 
					        terminal_ok_oscuro = self.configuracion("terminal_ok_oscuro");
 | 
				
			||||||
 | 
					        terminal_ok_claro = self.configuracion("terminal_ok_claro");
 | 
				
			||||||
 | 
					        terminal_info_oscuro = self.configuracion("terminal_info_oscuro");
 | 
				
			||||||
 | 
					        terminal_info_claro = self.configuracion("terminal_info_claro");
 | 
				
			||||||
 | 
					        terminal_note_oscuro = self.configuracion("terminal_note_oscuro");
 | 
				
			||||||
 | 
					        terminal_note_claro = self.configuracion("terminal_note_claro");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.iniciar = callback => {
 | 
					    this.iniciar = callback => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const terminar = estado => typeof callback == "function" && terminar(estado);
 | 
					        const terminar = estado => typeof callback == "function" && callback(estado);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(iniciado){
 | 
					        if(iniciado){
 | 
				
			||||||
            terminar(false);
 | 
					            terminar(false);
 | 
				
			||||||
@ -241,8 +272,8 @@ Mapeate = function(entradas){
 | 
				
			|||||||
        for(let i = 0; i < l; i ++)
 | 
					        for(let i = 0; i < l; i ++)
 | 
				
			||||||
            if(typeof idiomas[i] == "string" && textos[idiomas[i]])
 | 
					            if(typeof idiomas[i] == "string" && textos[idiomas[i]])
 | 
				
			||||||
                for(let j = 0; j < m; j ++)
 | 
					                for(let j = 0; j < m; j ++)
 | 
				
			||||||
                    if(idiomas[i][claves[j]] !== undefined)
 | 
					                    if(textos[idiomas[i]][claves[j]] !== undefined)
 | 
				
			||||||
                        return idiomas[i][claves[j]];
 | 
					                        return textos[idiomas[i]][claves[j]];
 | 
				
			||||||
        return (
 | 
					        return (
 | 
				
			||||||
            por_defecto !== undefined ? por_defecto : 
 | 
					            por_defecto !== undefined ? por_defecto : 
 | 
				
			||||||
            m ? claves[0] : 
 | 
					            m ? claves[0] : 
 | 
				
			||||||
@ -273,7 +304,7 @@ Mapeate = function(entradas){
 | 
				
			|||||||
                    textos[lenguage] === undefined && (textos[lenguage] = {});
 | 
					                    textos[lenguage] === undefined && (textos[lenguage] = {});
 | 
				
			||||||
                    if(entradas[i][lenguage] && typeof entradas[i][lenguage] == "object")
 | 
					                    if(entradas[i][lenguage] && typeof entradas[i][lenguage] == "object")
 | 
				
			||||||
                        for(const clave in entradas[i][lenguage])
 | 
					                        for(const clave in entradas[i][lenguage])
 | 
				
			||||||
                            if(sobreescribir || textos[lenguage][clave] !== undefined)
 | 
					                            if(sobreescribir || textos[lenguage][clave] === undefined)
 | 
				
			||||||
                                textos[lenguage][clave] = entradas[i][lenguage][clave];
 | 
					                                textos[lenguage][clave] = entradas[i][lenguage][clave];
 | 
				
			||||||
                };
 | 
					                };
 | 
				
			||||||
                terminar();
 | 
					                terminar();
 | 
				
			||||||
@ -333,7 +364,7 @@ Mapeate = function(entradas){
 | 
				
			|||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if(typeof entradas[i] == "string"){
 | 
					        if(typeof entradas[i] == "string"){
 | 
				
			||||||
            if(/^[a-z0-9]+$/i.test(entradas[i])){
 | 
					            if(/^ *[a-z0-9]+ *$/i.test(entradas[i])){
 | 
				
			||||||
                if(clave === undefined && !terminal_tipos.some((tipos, j) => tipos.includes(entradas[i]) && !isNaN(clave = j))){
 | 
					                if(clave === undefined && !terminal_tipos.some((tipos, j) => tipos.includes(entradas[i]) && !isNaN(clave = j))){
 | 
				
			||||||
                    clave = terminal_tipos.length;
 | 
					                    clave = terminal_tipos.length;
 | 
				
			||||||
                    terminal_tipos.push([entradas[i]]);
 | 
					                    terminal_tipos.push([entradas[i]]);
 | 
				
			||||||
@ -370,25 +401,63 @@ Mapeate = function(entradas){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.es_dispositivo_movil = () => modo_dispositivo == "movil" || (modo_dispositivo != "escritorio" && es_movil);
 | 
				
			||||||
 | 
					    this.modo_gui_oscuro = () => modo_gui == "oscuro" || (modo_gui != "claro" && modo_gui_oscuro);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.terminal_tipos_anadir = (entradas, callback) => terminal_tipos_anadir(entradas, callback, 0);
 | 
					    this.terminal_tipos_anadir = (entradas, callback) => terminal_tipos_anadir(entradas, callback, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    this.print = (tipo, mensaje, variables) => {
 | 
					    this.coger_id_tipo_terminal = tipo => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const l = terminal_tipos.length;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(typeof tipo == "string" && (tipo = tipo.trim().toLowerCase()))
 | 
				
			||||||
 | 
					            for(let i = 0; i < l; i ++)
 | 
				
			||||||
 | 
					                if(terminal_tipos[i].includes(tipo))
 | 
				
			||||||
 | 
					                    return i;
 | 
				
			||||||
 | 
					        return 0;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.coger_tipo_terminal = tipo => terminal_tipos[self.coger_id_tipo_terminal(tipo)][0].toUpperCase();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.coger_traza = i => (new Error()).stack.replace(/^Error\s*?[\r\n]+/, "").trim().split(/[\r\n]+/).slice(1 + (i || 0)).map(linea => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const matches = linea.match(re_bloque_de_traza);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return matches ? {
 | 
				
			||||||
 | 
					            archivo : matches[4] || matches[9], 
 | 
				
			||||||
 | 
					            metodo : matches[3] || matches[8] || "", 
 | 
				
			||||||
 | 
					            linea : Number(matches[7] || matches[10])
 | 
				
			||||||
 | 
					        } : null;
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.print = (tipo, mensaje, variables, i) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const fecha = new Date(), 
 | 
					        const fecha = new Date(), 
 | 
				
			||||||
              conjunto = {
 | 
					              conjunto = {
 | 
				
			||||||
                  tipo_crudo : tipo, 
 | 
					                  tipo_crudo : tipo, 
 | 
				
			||||||
                  tipo : tipo.upperCase().substring(0, 4), 
 | 
					                  tipo : self.coger_tipo_terminal(tipo), 
 | 
				
			||||||
                  i18n : mensaje, 
 | 
					                  i18n : mensaje, 
 | 
				
			||||||
                  ...(typeof variables == "object" ? variables : {})
 | 
					                  ...(typeof variables == "object" ? variables : {}), 
 | 
				
			||||||
              };
 | 
					                  ...(self.coger_traza((isNaN(i) ? 1 : i) + 1) || {
 | 
				
			||||||
 | 
					                      linea : -1, 
 | 
				
			||||||
 | 
					                      metodo : "UNKNOWN", 
 | 
				
			||||||
 | 
					                      archivo : "UNKNOWN"
 | 
				
			||||||
 | 
					                  })
 | 
				
			||||||
 | 
					              }, 
 | 
				
			||||||
 | 
					              clave_tipo = conjunto.tipo.trim().toLowerCase();
 | 
				
			||||||
 | 
					        let mensaje_procesado;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        conjunto.line = conjunto.linea;
 | 
				
			||||||
 | 
					        conjunto.method = conjunto.metodo;
 | 
				
			||||||
 | 
					        conjunto.file = conjunto.archivo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ["year", "month", "date", "hours", "minutes", "seconds"].forEach(clave => {
 | 
					        ["year", "month", "date", "hours", "minutes", "seconds"].forEach(clave => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const k = clave.substring(0, 1), 
 | 
					            let k = clave.substring(0, 1); 
 | 
				
			||||||
                  valor = fecha["get" + (clave == "year" ? "FullYear" : k.toUpperCase() + clave.substring(1))]();
 | 
					            const valor = fecha["get" + (clave == "year" ? "FullYear" : k.toUpperCase() + clave.substring(1))]();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            conjunto[clave == "date" ? "day" : clave] = valor;
 | 
					            conjunto[clave == "date" ? "day" : clave] = valor;
 | 
				
			||||||
            conjunto[k] = valor;
 | 
					            conjunto[clave == "minutes" ? k = "i" : k] = valor;
 | 
				
			||||||
            conjunto[k + k] = ("00" + valor).slice(-2);
 | 
					            conjunto[k + k] = ("00" + valor).slice(-2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
@ -396,7 +465,33 @@ Mapeate = function(entradas){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        conjunto.mensaje = self.i18n(mensaje, conjunto);
 | 
					        conjunto.mensaje = self.i18n(mensaje, conjunto);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        console.log(self.string_variables(formato_terminal, conjunto));
 | 
					        mensaje_procesado = self.string_variables(formato_terminal, conjunto);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        console.log(conjunto);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        switch(conjunto.tipo){
 | 
				
			||||||
 | 
					            case " OK ":
 | 
				
			||||||
 | 
					                console.log("%c" + mensaje_procesado, self.modo_gui_oscuro() ? terminal_ok_oscuro : terminal_ok_claro);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					            case "INFO":
 | 
				
			||||||
 | 
					                console.log("%c" + mensaje_procesado, self.modo_gui_oscuro() ? terminal_info_oscuro : terminal_info_claro);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					            case "UNKN":
 | 
				
			||||||
 | 
					                console.log("%c" + mensaje_procesado, self.modo_gui_oscuro() ? terminal_note_oscuro : terminal_note_claro);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					            case "ERRO":
 | 
				
			||||||
 | 
					            case "FAIL":
 | 
				
			||||||
 | 
					            case "EXCE":
 | 
				
			||||||
 | 
					                console.error(mensaje_procesado);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					            case "WARN":
 | 
				
			||||||
 | 
					                console.warn(mensaje_procesado);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					            case "UNKN":
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                console.log("%c" + mensaje_procesado, self.modo_gui_oscuro() ? terminal_unkn_oscuro : terminal_unkn_claro);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@
 | 
				
			|||||||
    "texto_por_defecto" : "", 
 | 
					    "texto_por_defecto" : "", 
 | 
				
			||||||
    "configuracion_sobreescribir" : false, 
 | 
					    "configuracion_sobreescribir" : false, 
 | 
				
			||||||
    "i18n_sobreescribir" : false, 
 | 
					    "i18n_sobreescribir" : false, 
 | 
				
			||||||
    "formato_terminal" : "[{tipo}] {yyyy}{mm}{dd} {hh}{ii}{ss}: {mensaje}", 
 | 
					    "formato_terminal" : "[{tipo}] {yyyy}{mm}{dd} {hh}{ii}{ss} [{linea}]{archivo}({metodo}): {mensaje}", 
 | 
				
			||||||
    "terminal_tipos_por_defecto" : [
 | 
					    "terminal_tipos_por_defecto" : [
 | 
				
			||||||
        ["unkn", "unknown", "desconocido"], 
 | 
					        ["unkn", "unknown", "desconocido"], 
 | 
				
			||||||
        [" ok ", "ok", "si", "correcto"], 
 | 
					        [" ok ", "ok", "si", "correcto"], 
 | 
				
			||||||
@ -17,5 +17,9 @@
 | 
				
			|||||||
        ["erro", "error", "incrrecto"], 
 | 
					        ["erro", "error", "incrrecto"], 
 | 
				
			||||||
        ["fail", "failure", "fallo"], 
 | 
					        ["fail", "failure", "fallo"], 
 | 
				
			||||||
        ["exce", "excepcion"]
 | 
					        ["exce", "excepcion"]
 | 
				
			||||||
    ]
 | 
					    ], 
 | 
				
			||||||
 | 
					    "archivos_de_i18n_por_defecto" : [
 | 
				
			||||||
 | 
					        "/json/i18n/Mapeate.i18n.espanol.json"
 | 
				
			||||||
 | 
					    ], 
 | 
				
			||||||
 | 
					    "ajax_timeout" : 2000
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										13
									
								
								Public/json/i18n/Mapeate.i18n.espanol.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								Public/json/i18n/Mapeate.i18n.espanol.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "espanol" : {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        "Mapeate_comun_empezar" : null, 
 | 
				
			||||||
 | 
					        "Mapeate_comun_terminar" : null, 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        "Mapeate_empezar" : null, 
 | 
				
			||||||
 | 
					        "mapeate_construyendose" : "La aplicación 'Mapeate' se está constryendo...", 
 | 
				
			||||||
 | 
					        "mapeate_construido" : "La aplicación 'Mapeate' se construyó completamente.", 
 | 
				
			||||||
 | 
					        "Mapeate_terminar" : null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -46,7 +46,7 @@
 | 
				
			|||||||
                            build_map(ajax.responseText);
 | 
					                            build_map(ajax.responseText);
 | 
				
			||||||
                        };
 | 
					                        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    ajax.open("get", "/data/World Map.svg", true);
 | 
					                    ajax.open("get", "../data/World Map.svg", true);
 | 
				
			||||||
                    ajax.timeout = 2000;
 | 
					                    ajax.timeout = 2000;
 | 
				
			||||||
                    ajax.onreadystatechange = () => {
 | 
					                    ajax.onreadystatechange = () => {
 | 
				
			||||||
                        if(ended)
 | 
					                        if(ended)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user