<commit_before>function Initclass(j){
    if(typeof j !== 'object'){
        throw new Error('j was expected to be an object, '+(typeof j+' was received.'));
    }

    var data = (j.data !== undefined) ? j.data : {};
    var defaults = (j.defaults !== undefined) ? j.defaults : {};
    var synonyms = (j.synonyms !== undefined) ? j.synonyms : {};
        
    for(var k in synonyms){
        if(data[k] !== undefined){
            data[ synonyms[k] ] = data[k];
        }
    }

    var types = {};
    for (var llave in defaults){
        types[llave] = typeof defaults[llave];
    }
    
    for(var key in defaults){
        data[key] = (typeof data[key] === 'undefined') ? defaults[key] : data[key];    
    }
    
    for(var key in data){
        var t = typeof data[key];
        if(t !== types[key] && types[k] !== undefined){
            throw new Error ('Error : '+key+' was expected to be '+types[key]+', but was received: '+t);
        }else{
            this[key] = data[key];
        }
    }
}

(function(){
    // 
    // JSONHttpRequest 0.3.0
    //
    // Copyright 2011 <NAME> <http://pixelsvsbytes.com/>
    // 
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU General Public License as published by
    // the Free Software Foundation, either version 3 of the License, or
    // (at your option) any later version.
    // 
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    // 
    // You should have received a copy of the GNU General Public License
    // along with _self program. If not, see <http://www.gnu.org/licenses/>.
    // 
    ///////////////////////////////////////////////////////////////////////

    function JSONHttpRequest() {
        var _xmlHttpRequest = getXMLHTTPRequest();
        var _responseJSON = null;
        var _userContentType = false;
        // INFO Defining 'this' as '_self' improves compression, since keywords won't be shortened,
        //      but variables will, and it delivers us from the need to reset the scope of the anonymous
        //      function in the for-loop via call() or apply().
        var _self = this;

        var property = {
            get: function() {
                try {
                    _responseJSON = _xmlHttpRequest.responseText ? (!_responseJSON ? JSON.parse(_xmlHttpRequest.responseText) : _responseJSON) : null;
                }
                catch (e) {
                    if (_self.strictJSON)
                        throw e;
                }
                return _responseJSON;
            },
            enumerable: true,
            configurable: true
        }
        
        _self.strictJSON = true;
        Object.defineProperty(_self, 'responseJSON', property);
        
        _self.sendJSON = function(data) {
            try {
                data = JSON.stringify(data);
                _responseJSON = null;
                if (!_userContentType)
                    _xmlHttpRequest.setRequestHeader('Content-Type', 'application/json;charset=encoding');          
                _userContentType = false;
            }
            catch (e) {
                if (_self.strictJSON)
                    throw e;
            }
            _xmlHttpRequest.send(data);
        }
        
        // INFO proxy setup
        
        function proxy(name) {
            try {
                if ((typeof _xmlHttpRequest[name]) == 'function') {
                    _self[name] = function() {
                        if (name == 'setRequestHeader')
                            _userContentType = arguments[0].toLowerCase() == 'content-type';
                        return _xmlHttpRequest[name].apply(_xmlHttpRequest, Array.prototype.slice.apply(arguments));
                    };
                }
                else {
                    property.get = function() { return _xmlHttpRequest[name]; }
                    property.set = function(value) { _xmlHttpRequest[name] = value; }
                    Object.defineProperty(_self, name, property);   
                }
            }
            catch (e) {
                // NOTE Swallow any exceptions, which may rise here.
            }
        }
        
        // FIX onreadystatechange is not enumerable [Opera]
        proxy('onreadystatechange');
        
        for (n in _xmlHttpRequest)
            proxy(n);
    }

    // Ajax Stuff
    // =======================
    var _Vi = function(j){

        var json = (j === undefined ) ? {} : j;
        
        var defaults = {
            url: '',
            cache: false,
            header:'Content-Type',
            valorHeader:'application/x-www-form-urlencoded',
            div:'',
            cargando:'...',
            modo:'GET',
            datos:{},
            respuesta:'text',
            input:'',
            formulario:'',
            enviaArchivo:false,
            historial:false,
            urlH: '/',
            mensajeH: '',
            mClass: false,
            mensaje:{}
        }

        // The original variables are in spanish, so I added translated variables as well
        synonyms = {
            headerValue: 'valorHeader',
            container: 'div',
            loading: 'cargando',
            mode: 'modo',
            data: 'datos',
            response: 'respuesta',
            sendFile: 'enviaArchivo',
            history: 'historial',
            messageH: 'mensajeH',
            message: 'mensaje',
        }

        var js = {data:j, defaults:defaults, synonyms:synonyms};
        Initclass.call(this, js);
    }

    function getXMLHTTPRequest() {
        var req;
        if(XMLHttpRequest){
            req = new XMLHttpRequest();
        }else{
            try {
                req = new XMLHttpRequest();
            } catch(err1) {
                try {
                    req = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (err2) {
                    try {
                        req = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (err3) {
                        req = false;
                    } 
                } 
            }
        }
        return req;
    }

    _Vi.prototype.httpHandler = function(){
        var http;
        switch(this.respuesta){
            case 'objeto':
            case 'object':
            case 'json':
                http = new JSONHttpRequest();
            break;
            default:
                if(XMLHttpRequest){
                    http = new XMLHttpRequest();
                }else{
                    http = getXMLHTTPRequest();
                }
            break;
        }

        return http;
    };

    _Vi.prototype.ajax = function(callback){
        var http = this.httpHandler();
        this.http = http;
        
        var myRand = '';
        if(this.cache === false){
            myRand = "?rand="+ parseInt(Math.random()*999999999999999);
        }
        
        var url = this.url+myRand;
        if(this.mod === 'GET' && this.enviaArchivo === false){
            var datos = '';
            
            for(var llave in this.datos){
                datos += '&' + encodeURIComponent(llave) + '=' + encodeURIComponent(this.datos[llave]);
            }
            
            url += datos;
        }
        
        if(this.modo === 'POST' && this.enviaArchivo === false){
            var datos = '';
            for(var llave in this.datos){
                if(typeof this.datos[llave] === "object"){
                    this.datos[llave] = JSON.pruned(this.datos[llave]);
                }
                datos +=encodeURIComponent(llave)+'='+encodeURIComponent(this.datos[llave])+'&';
            }
        }
        
        var esto = this;
        if(http.open !== undefined){
            http.open(this.modo, url, true);
            if(this.enviaArchivo == false) {
                http.setRequestHeader(this.header, this.valorHeader);
            }

            http.send(datos);
        }else{
            http.sendJSON();
        }
        

        http.onreadystatechange = function(){
            if(http.readyState === 4){
                if(http.status === 200){
                    esto.success(callback);
                }else{
                    switch(http.status){
                        case 500:
                        case 404:
                        case 413:
                            esto.failed(callback, http.status);
                        break;
                    }
                }
            } 
        }
    }

    _Vi.prototype.failed = function(callback, status){
        if(typeof callback === 'function'){
            r = {success: false, status:status};
            callback(r);
        }
    }

    _Vi.prototype.success = function(callback){                    
        if(this.historial == true){
            if(window.dhtmlHistory === undefined){
                console.log('Para que el historial funcione, necesitas implementar RSH');
            }else{
                dhtmlHistory.add(
                    this.urlH,
                    {message: this.mensajeH});
            }
        }
        
        var respuesta;
        switch(this.respuesta){
            case 'xml':
                respuesta = this.http.responseXML.documentElement;
            break;
            case 'texto':
            case 'text':
            default:
                respuesta = this.http.responseText;
            break;
            case 'objeto':
            case 'object':
            case 'json':
                respuesta = this.http.responseJSON;
                this.messageHandler();
            break;
        }

        if(this.dom !== null && this.dom !== undefined){
            this.showInDOM(callback, respuesta);
        }else{
            if(typeof callback === 'function'){
                callback(respuesta);
            }
        }
    }

    _Vi.prototype.messageHandler = function(){
        if(window.Mensaje !== undefined && this.mClass === true){
            if(this.respuesta.exito !== undefined && this.mensaje.tipo === undefined){
                var t;
                switch(this.respuesta.exito){
                    case true:
                        t = 'info';
                    break;
                    case false:
                        t = 'danger';
                    break;
                    default:
                        t = respuesta.exito;
                }
                this.mensaje.tipo = t;
            }
            if(respuesta.titulo !== undefined && this.mensaje.titulo === undefined){
                this.mensaje.titulo = respuesta.titulo;
            }
            if(respuesta.mensaje !== undefined && this.mensaje.mensaje === undefined){
                this.mensaje.mensaje = respuesta.mensaje;
            }
            var m = Mensaje(this.mensaje);
            m.insertar();
        }
    }

    _Vi.prototype.uploader = function(callback){
        var uri = this.url;
        var xhr = new XMLHttpRequest();
        var fd = new FormData();
        var metodo;
        
        fd = this.datos;
        
        xhr.open(this.modo, uri, true);
        xhr.send(fd);

        xhr.onreadystatechange = function(){
            if (xhr.readyState == 4 && xhr.status == 200) {
                respuesta = eval('('+xhr.responseText+')');
                
                if(callback!=undefined){
                    callback(respuesta);
                }else{
                    return respuesta;
                }
                
            }
        }
        
        delete xhr;
        delete fd;
    }

    _Vi.prototype.DOMHandler = function(){
        if(typeof this.div !== 'object' && this.div.appendChild === undefined){
            var dom = document.querySelector(this.div);
        }else{
            var dom = this.div
        }
        this.dom = dom;
    }

    _Vi.prototype.showInDOM = function(callback, response){
        this.dom.innerHTML = response;
        if(typeof callback === 'function'){
            callback();
        }
    }

    _Vi.prototype.content = function(callback){
        this.contenido(callback);
    }

    _Vi.prototype.contenido = function(callback){
        this.respuesta = 'string';
        this.modo = 'GET';
        this.DOMHandler();

        if(this.dom !== null){
            return this.ajax(callback);
        }else{
            console.log('No se ha encontrado el elemento DOM '.this.div);
        }
    }

    _Vi.prototype.server = function(callback){
        this.response = 'object';
        this.respondo(callback);
    }

    _Vi.prototype.respondo = function(callback){
        
        this.modo = 'POST';
        this.div = undefined;
        return this.ajax(callback);
    }

    _Vi.prototype.form = function(json, callback){
        
        for(var llave in json){
            this.llave = json.llave;
        }
        
        var datos = {};
        var esto = this;

        var dom = document.querySelector(this.input);
        for(var i = 0, len = dom.length; i < len; i++){
            var d = dom[i];
            var vlr = d.value;
            var nombre = d.name;
            if(nombre==''){
                nombre = d.id;
            }
            datos[nombre]=vlr;
        }

        this.datos = datos;
        
        this.modo = 'POST';
        var respondo = esto.ajax(callback);
        
        return respondo;
        
    }

    window.Vi = function(json){
        return new _Vi(json);
    }

})();

(function(){
    "use strict";

    var App = function(j){
        var defaults = {
            currents: {language: 'en', languages: {}},
            modules: {},
            div: '',
            loaded: false
        }

        var js = {defaults: defaults, data: j};
        Initclass.call(this, js);

        if(typeof this.currentLang !== 'undefined'){
            this.currents.language = this.currentLang;
        }

        this.currents.div = this.div;

        for(var m in this.modules){
            if(this.modules.hasOwnProperty(m)){
                this.setModule(m, this.modules[m]);
            }
        }
    }

    App.prototype.init = function(callback) {
        callback = (typeof callback !== 'function') ? function(){} : callback;
        callback();
    };

    App.prototype.setModule = function(name, json) {
        json.currents = this.currents;
        json.parent = this;
        this.modules[name] = new Module(json);
    };

    App.prototype.getModule = function(name) {
        this.current = this.modules[name];
        return this.current;
    };

    App.prototype.startModule = function(callback) {
        var all = (this.loaded === true) ? false : true;
        var params = {translate: {all: all}};
        this.current.start(callback, params);
        this.loaded = true;
    };

    App.prototype.getLanguage = function() {
        return this.getLang();
    };

    App.prototype.getLang = function() {
        return this.currents.language
    };

    App.prototype.setLanguage = function(language) {
        this.setLang(language);
    };

    App.prototype.setLang = function(language) {
        this.currents.language = language;
    };

    App.prototype.translate = function(callback) {
        this.current.translate(callback);
    };

    App.prototype.translateTo = function(language) {
        this.setLanguage(language);
        this.current.translateTo(this.getLanguage());
    };

    var Module = function(j){
        var defaults = {
            nombre: '',
            url: '',
            data: {},
            currents: {},
            name: '',
            parent: {}
        }

        // The original variables are in spanish, so I added translated variables as well
        synonyms = {
            nombre: 'name'
        }

        var js = {data:j, defaults:defaults, synonyms:synonyms};
        Initclass.call(this, js);
    }

    Module.prototype.getCSS = function(parameters, callback){
        callback = (typeof callback !== 'function') ? function(){} : callback;

        if(parameters.load === true){
            var href = this.getUrl()+'/css/'+parameters.file;      
            var antiq = document.querySelector('head link[data-'+this.name+']');
            if(antiq !== null){
                antiq.parentNode.removeChild(antiq);
            }

            var l = document.createElement('link');
            l.setAttribute('href', href);
            l.setAttribute('data-'+this.name, this.name);
            l.type = 'text/css';
            l.rel = 'stylesheet';

            var head = document.getElementsByTagName('head')[0];
            head.appendChild(l);
        }

        callback();
    };
        
    Module.prototype.getHTML = function(parameters, callback){
        callback = (typeof callback !== 'function') ? function(){} : callback;

        if(parameters.load === true){
            var json = {
                url: this.getUrl()+'/html/'+parameters.file,
                div: this.parent.div
            }
            if(typeof callback !== 'function'){
                callback = function(){};
            }

            new Vi(json).content(callback);
        }else{
            callback();
        }
    };
        
    Module.prototype.getJS = function(parameters, callback){

        callback = (typeof callback !== 'function') ? function(){} : callback;

        if(parameters.load === true){
            var head    = document.getElementsByTagName("head")[0];
            var script  = document.createElement("script");
            var done    = false; // Handle Script loading
            
            var url = './'+this.getUrl()+'/js/'+parameters.file;
            script.src  = url;
            script.onload = script.onreadystatechange = function() { // Attach handlers for all browsers
                if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
                    done = true;
                    callback();
                    script.onload = script.onreadystatechange = null; // Handle memory leak in IE
                }
            };

            head.appendChild(script);
        }else{
            callback();
        }
    }

    Module.prototype.translateTo = function(language, parameters) {
        this.currents.language = language;
        parameters = this.preLoad(parameters);
        parameters.translate.all = true;
        this.translate(parameters);
    };

    Module.prototype.translate = function(parameters, callback) {
        parameters = (typeof parameters !== 'object') ? this.preLoad().translate : parameters;
        callback = (typeof callback !== 'function') ? function(){} : callback;

        var t = this;
        if(parameters.load === true){
            this.getXML(parameters, callback);
        }else{
            callback(t);
        }
    };

    Module.prototype.isTranslated = function(file) {
        var r = false;
        if(typeof this.currents.languages === 'object'){
            var lang = this.currents.languages;
            if(typeof lang[this.name] === 'object'){
                var l = lang[this.name];
                if(typeof l[file] === 'object'){
                    r = true
                }
            }
        }

        return r;
    };

    Module.prototype.getXML = function(parameters, callback) {
        callback = (typeof callback !== 'function') ? function(){} : callback;

        var t = this;
        if(this.isTranslated(parameters.file) === false){
            new Vi({url: this.getLanguageUrl()+parameters.file, response: 'xml', cache: true}).server(function(r){
                t.setLanguageJson(r, parameters.file);
                t.translateModule(parameters, callback);
            });
        }else{
            t.setLanguageJson(this.getLanguageJson(parameters.file), parameters.file);
            this.translateModule(parameters, callback);
        }


    };

    Module.prototype.translateModule = function(parameters, callback) {
        callback = (typeof callback !== 'function') ? function(){} : callback;

        var xmls = {};
        if(parameters.all === true || typeof this.currents.mainXML === 'undefined'){
            var t = this;
            this.setMainXML(function(){
                xmls = {'00': t.currents.mainXML};
                xmls.current = t.getLanguageJson(parameters.file);
                languageToDOM(xmls);

                callback(t);
            });
        }else{
            xmls.current = this.getLanguageJson(parameters.file);
            languageToDOM(xmls);
            callback(this);
        }
        
    };

    Module.prototype.setMainXML = function(callback) {
        var t = this;
        if(typeof t.currents.mainXML === undefined || t.currents.mainLang !== t.currents.language){
            callback = (typeof callback !== 'function') ? function(){} : callback;
            new Vi({url: 'language/'+this.currents.language+'/main.xml', response: 'xml', cache: true}).server(function(r){
                t.currents.mainXML = r;
                t.currents.mainLang = t.currents.language;
                callback();
            });
        }else{
            callback();
        }
    };

    Module.prototype.getMainXML = function() {
        return (t.currents.mainXML !== undefined) ? t.currents.mainXML : {};
    };

    Module.prototype.setLanguageJson = function(j, file) {
        if(typeof file === 'undefined'){
            file = 'content.xml';
        }

        this.currents.jlang = j;
        this.currents.jlangfile = file;
        if(typeof this.currents.languages[this.currents.language] !== 'object'){
            this.currents.languages[this.currents.language] = {};
        }

        if(typeof this.currents.languages[this.currents.language][this.name] !== 'object'){
            this.currents.languages[this.currents.language][this.name] = {};
        }
        this.currents.languages[this.currents.language][this.name][file] = j;
    };
<commit_msg>Fixed bug getting main text<commit_after>function Initclass(j){
    if(typeof j !== 'object'){
        throw new Error('j was expected to be an object, '+(typeof j+' was received.'));
    }

    var data = (j.data !== undefined) ? j.data : {};
    var defaults = (j.defaults !== undefined) ? j.defaults : {};
    var synonyms = (j.synonyms !== undefined) ? j.synonyms : {};
        
    for(var k in synonyms){
        if(data[k] !== undefined){
            data[ synonyms[k] ] = data[k];
        }
    }

    var types = {};
    for (var llave in defaults){
        types[llave] = typeof defaults[llave];
    }
    
    for(var key in defaults){
        data[key] = (typeof data[key] === 'undefined') ? defaults[key] : data[key];    
    }
    
    for(var key in data){
        var t = typeof data[key];
        if(t !== types[key] && types[k] !== undefined){
            throw new Error ('Error : '+key+' was expected to be '+types[key]+', but was received: '+t);
        }else{
            this[key] = data[key];
        }
    }
}

(function(){
    // 
    // JSONHttpRequest 0.3.0
    //
    // Copyright 2011 <NAME> <http://pixelsvsbytes.com/>
    // 
    // This program is free software: you can redistribute it and/or modify
    // it under the terms of the GNU General Public License as published by
    // the Free Software Foundation, either version 3 of the License, or
    // (at your option) any later version.
    // 
    // This program is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    // GNU General Public License for more details.
    // 
    // You should have received a copy of the GNU General Public License
    // along with _self program. If not, see <http://www.gnu.org/licenses/>.
    // 
    ///////////////////////////////////////////////////////////////////////

    function JSONHttpRequest() {
        var _xmlHttpRequest = getXMLHTTPRequest();
        var _responseJSON = null;
        var _userContentType = false;
        // INFO Defining 'this' as '_self' improves compression, since keywords won't be shortened,
        //      but variables will, and it delivers us from the need to reset the scope of the anonymous
        //      function in the for-loop via call() or apply().
        var _self = this;

        var property = {
            get: function() {
                try {
                    _responseJSON = _xmlHttpRequest.responseText ? (!_responseJSON ? JSON.parse(_xmlHttpRequest.responseText) : _responseJSON) : null;
                }
                catch (e) {
                    if (_self.strictJSON)
                        throw e;
                }
                return _responseJSON;
            },
            enumerable: true,
            configurable: true
        }
        
        _self.strictJSON = true;
        Object.defineProperty(_self, 'responseJSON', property);
        
        _self.sendJSON = function(data) {
            try {
                data = JSON.stringify(data);
                _responseJSON = null;
                if (!_userContentType)
                    _xmlHttpRequest.setRequestHeader('Content-Type', 'application/json;charset=encoding');          
                _userContentType = false;
            }
            catch (e) {
                if (_self.strictJSON)
                    throw e;
            }
            _xmlHttpRequest.send(data);
        }
        
        // INFO proxy setup
        
        function proxy(name) {
            try {
                if ((typeof _xmlHttpRequest[name]) == 'function') {
                    _self[name] = function() {
                        if (name == 'setRequestHeader')
                            _userContentType = arguments[0].toLowerCase() == 'content-type';
                        return _xmlHttpRequest[name].apply(_xmlHttpRequest, Array.prototype.slice.apply(arguments));
                    };
                }
                else {
                    property.get = function() { return _xmlHttpRequest[name]; }
                    property.set = function(value) { _xmlHttpRequest[name] = value; }
                    Object.defineProperty(_self, name, property);   
                }
            }
            catch (e) {
                // NOTE Swallow any exceptions, which may rise here.
            }
        }
        
        // FIX onreadystatechange is not enumerable [Opera]
        proxy('onreadystatechange');
        
        for (n in _xmlHttpRequest)
            proxy(n);
    }

    // Ajax Stuff
    // =======================
    var _Vi = function(j){

        var json = (j === undefined ) ? {} : j;
        
        var defaults = {
            url: '',
            cache: false,
            header:'Content-Type',
            valorHeader:'application/x-www-form-urlencoded',
            div:'',
            cargando:'...',
            modo:'GET',
            datos:{},
            respuesta:'text',
            input:'',
            formulario:'',
            enviaArchivo:false,
            historial:false,
            urlH: '/',
            mensajeH: '',
            mClass: false,
            mensaje:{}
        }

        // The original variables are in spanish, so I added translated variables as well
        synonyms = {
            headerValue: 'valorHeader',
            container: 'div',
            loading: 'cargando',
            mode: 'modo',
            data: 'datos',
            response: 'respuesta',
            sendFile: 'enviaArchivo',
            history: 'historial',
            messageH: 'mensajeH',
            message: 'mensaje',
        }

        var js = {data:j, defaults:defaults, synonyms:synonyms};
        Initclass.call(this, js);
    }

    function getXMLHTTPRequest() {
        var req;
        if(XMLHttpRequest){
            req = new XMLHttpRequest();
        }else{
            try {
                req = new XMLHttpRequest();
            } catch(err1) {
                try {
                    req = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (err2) {
                    try {
                        req = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (err3) {
                        req = false;
                    } 
                } 
            }
        }
        return req;
    }

    _Vi.prototype.httpHandler = function(){
        var http;
        switch(this.respuesta){
            case 'objeto':
            case 'object':
            case 'json':
                http = new JSONHttpRequest();
            break;
            default:
                if(XMLHttpRequest){
                    http = new XMLHttpRequest();
                }else{
                    http = getXMLHTTPRequest();
                }
            break;
        }

        return http;
    };

    _Vi.prototype.ajax = function(callback){
        var http = this.httpHandler();
        this.http = http;
        
        var myRand = '';
        if(this.cache === false){
            myRand = "?rand="+ parseInt(Math.random()*999999999999999);
        }
        
        var url = this.url+myRand;
        if(this.mod === 'GET' && this.enviaArchivo === false){
            var datos = '';
            
            for(var llave in this.datos){
                datos += '&' + encodeURIComponent(llave) + '=' + encodeURIComponent(this.datos[llave]);
            }
            
            url += datos;
        }
        
        if(this.modo === 'POST' && this.enviaArchivo === false){
            var datos = '';
            for(var llave in this.datos){
                if(typeof this.datos[llave] === "object"){
                    this.datos[llave] = JSON.pruned(this.datos[llave]);
                }
                datos +=encodeURIComponent(llave)+'='+encodeURIComponent(this.datos[llave])+'&';
            }
        }
        
        var esto = this;
        if(http.open !== undefined){
            http.open(this.modo, url, true);
            if(this.enviaArchivo == false) {
                http.setRequestHeader(this.header, this.valorHeader);
            }

            http.send(datos);
        }else{
            http.sendJSON();
        }
        

        http.onreadystatechange = function(){
            if(http.readyState === 4){
                if(http.status === 200){
                    esto.success(callback);
                }else{
                    switch(http.status){
                        case 500:
                        case 404:
                        case 413:
                            esto.failed(callback, http.status);
                        break;
                    }
                }
            } 
        }
    }

    _Vi.prototype.failed = function(callback, status){
        if(typeof callback === 'function'){
            r = {success: false, status:status};
            callback(r);
        }
    }

    _Vi.prototype.success = function(callback){                    
        if(this.historial == true){
            if(window.dhtmlHistory === undefined){
                console.log('Para que el historial funcione, necesitas implementar RSH');
            }else{
                dhtmlHistory.add(
                    this.urlH,
                    {message: this.mensajeH});
            }
        }
        
        var respuesta;
        switch(this.respuesta){
            case 'xml':
                respuesta = this.http.responseXML.documentElement;
            break;
            case 'texto':
            case 'text':
            default:
                respuesta = this.http.responseText;
            break;
            case 'objeto':
            case 'object':
            case 'json':
                respuesta = this.http.responseJSON;
                this.messageHandler();
            break;
        }

        if(this.dom !== null && this.dom !== undefined){
            this.showInDOM(callback, respuesta);
        }else{
            if(typeof callback === 'function'){
                callback(respuesta);
            }
        }
    }

    _Vi.prototype.messageHandler = function(){
        if(window.Mensaje !== undefined && this.mClass === true){
            if(this.respuesta.exito !== undefined && this.mensaje.tipo === undefined){
                var t;
                switch(this.respuesta.exito){
                    case true:
                        t = 'info';
                    break;
                    case false:
                        t = 'danger';
                    break;
                    default:
                        t = respuesta.exito;
                }
                this.mensaje.tipo = t;
            }
            if(respuesta.titulo !== undefined && this.mensaje.titulo === undefined){
                this.mensaje.titulo = respuesta.titulo;
            }
            if(respuesta.mensaje !== undefined && this.mensaje.mensaje === undefined){
                this.mensaje.mensaje = respuesta.mensaje;
            }
            var m = Mensaje(this.mensaje);
            m.insertar();
        }
    }

    _Vi.prototype.uploader = function(callback){
        var uri = this.url;
        var xhr = new XMLHttpRequest();
        var fd = new FormData();
        var metodo;
        
        fd = this.datos;
        
        xhr.open(this.modo, uri, true);
        xhr.send(fd);

        xhr.onreadystatechange = function(){
            if (xhr.readyState == 4 && xhr.status == 200) {
                respuesta = eval('('+xhr.responseText+')');
                
                if(callback!=undefined){
                    callback(respuesta);
                }else{
                    return respuesta;
                }
                
            }
        }
        
        delete xhr;
        delete fd;
    }

    _Vi.prototype.DOMHandler = function(){
        if(typeof this.div !== 'object' && this.div.appendChild === undefined){
            var dom = document.querySelector(this.div);
        }else{
            var dom = this.div
        }
        this.dom = dom;
    }

    _Vi.prototype.showInDOM = function(callback, response){
        this.dom.innerHTML = response;
        if(typeof callback === 'function'){
            callback();
        }
    }

    _Vi.prototype.content = function(callback){
        this.contenido(callback);
    }

    _Vi.prototype.contenido = function(callback){
        this.respuesta = 'string';
        this.modo = 'GET';
        this.DOMHandler();

        if(this.dom !== null){
            return this.ajax(callback);
        }else{
            console.log('No se ha encontrado el elemento DOM '.this.div);
        }
    }

    _Vi.prototype.server = function(callback){
        this.response = 'object';
        this.respondo(callback);
    }

    _Vi.prototype.respondo = function(callback){
        
        this.modo = 'POST';
        this.div = undefined;
        return this.ajax(callback);
    }

    _Vi.prototype.form = function(json, callback){
        
        for(var llave in json){
            this.llave = json.llave;
        }
        
        var datos = {};
        var esto = this;

        var dom = document.querySelector(this.input);
        for(var i = 0, len = dom.length; i < len; i++){
            var d = dom[i];
            var vlr = d.value;
            var nombre = d.name;
            if(nombre==''){
                nombre = d.id;
            }
            datos[nombre]=vlr;
        }

        this.datos = datos;
        
        this.modo = 'POST';
        var respondo = esto.ajax(callback);
        
        return respondo;
        
    }

    window.Vi = function(json){
        return new _Vi(json);
    }

})();

(function(){
    "use strict";

    var App = function(j){
        var defaults = {
            currents: {language: 'en', languages: {}},
            modules: {},
            div: '',
            loaded: false
        }

        var js = {defaults: defaults, data: j};
        Initclass.call(this, js);

        if(typeof this.currentLang !== 'undefined'){
            this.currents.language = this.currentLang;
        }

        this.currents.div = this.div;

        for(var m in this.modules){
            if(this.modules.hasOwnProperty(m)){
                this.setModule(m, this.modules[m]);
            }
        }
    }

    App.prototype.init = function(callback) {
        callback = (typeof callback !== 'function') ? function(){} : callback;
        callback();
    };

    App.prototype.setModule = function(name, json) {
        json.currents = this.currents;
        json.parent = this;
        this.modules[name] = new Module(json);
    };

    App.prototype.getModule = function(name) {
        this.current = this.modules[name];
        return this.current;
    };

    App.prototype.startModule = function(callback) {
        var all = (this.loaded === true) ? false : true;
        var params = {translate: {all: all}};
        this.current.start(callback, params);
        this.loaded = true;
    };

    App.prototype.getLanguage = function() {
        return this.getLang();
    };

    App.prototype.getLang = function() {
        return this.currents.language
    };

    App.prototype.setLanguage = function(language) {
        this.setLang(language);
    };

    App.prototype.setLang = function(language) {
        this.currents.language = language;
    };

    App.prototype.translate = function(callback) {
        this.current.translate(callback);
    };

    App.prototype.translateTo = function(language) {
        this.setLanguage(language);
        this.current.translateTo(this.getLanguage());
    };

    var Module = function(j){
        var defaults = {
            nombre: '',
            url: '',
            data: {},
            currents: {},
            name: '',
            parent: {}
        }

        // The original variables are in spanish, so I added translated variables as well
        synonyms = {
            nombre: 'name'
        }

        var js = {data:j, defaults:defaults, synonyms:synonyms};
        Initclass.call(this, js);
    }

    Module.prototype.getCSS = function(parameters, callback){
        callback = (typeof callback !== 'function') ? function(){} : callback;

        if(parameters.load === true){
            var href = this.getUrl()+'/css/'+parameters.file;      
            var antiq = document.querySelector('head link[data-'+this.name+']');
            if(antiq !== null){
                antiq.parentNode.removeChild(antiq);
            }

            var l = document.createElement('link');
            l.setAttribute('href', href);
            l.setAttribute('data-'+this.name, this.name);
            l.type = 'text/css';
            l.rel = 'stylesheet';

            var head = document.getElementsByTagName('head')[0];
            head.appendChild(l);
        }

        callback();
    };
        
    Module.prototype.getHTML = function(parameters, callback){
        callback = (typeof callback !== 'function') ? function(){} : callback;

        if(parameters.load === true){
            var json = {
                url: this.getUrl()+'/html/'+parameters.file,
                div: this.parent.div
            }
            if(typeof callback !== 'function'){
                callback = function(){};
            }

            new Vi(json).content(callback);
        }else{
            callback();
        }
    };
        
    Module.prototype.getJS = function(parameters, callback){

        callback = (typeof callback !== 'function') ? function(){} : callback;

        if(parameters.load === true){
            var head    = document.getElementsByTagName("head")[0];
            var script  = document.createElement("script");
            var done    = false; // Handle Script loading
            
            var url = './'+this.getUrl()+'/js/'+parameters.file;
            script.src  = url;
            script.onload = script.onreadystatechange = function() { // Attach handlers for all browsers
                if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
                    done = true;
                    callback();
                    script.onload = script.onreadystatechange = null; // Handle memory leak in IE
                }
            };

            head.appendChild(script);
        }else{
            callback();
        }
    }

    Module.prototype.translateTo = function(language, parameters) {
        this.currents.language = language;
        parameters = this.preLoad(parameters);
        parameters.translate.all = true;
        this.translate(parameters);
    };

    Module.prototype.translate = function(parameters, callback) {
        parameters = (typeof parameters !== 'object') ? this.preLoad().translate : parameters;
        callback = (typeof callback !== 'function') ? function(){} : callback;

        var t = this;
        if(parameters.load === true){
            this.getXML(parameters, callback);
        }else{
            callback(t);
        }
    };

    Module.prototype.isTranslated = function(file) {
        var r = false;
        if(typeof this.currents.languages === 'object'){
            var lang = this.currents.languages;
            if(typeof lang[this.name] === 'object'){
                var l = lang[this.name];
                if(typeof l[file] === 'object'){
                    r = true
                }
            }
        }

        return r;
    };

    Module.prototype.getXML = function(parameters, callback) {
        callback = (typeof callback !== 'function') ? function(){} : callback;

        var t = this;
        if(this.isTranslated(parameters.file) === false){
            new Vi({url: this.getLanguageUrl()+parameters.file, response: 'xml', cache: true}).server(function(r){
                t.setLanguageJson(r, parameters.file);
                t.translateModule(parameters, callback);
            });
        }else{
            t.setLanguageJson(this.getLanguageJson(parameters.file), parameters.file);
            this.translateModule(parameters, callback);
        }


    };

    Module.prototype.translateModule = function(parameters, callback) {
        callback = (typeof callback !== 'function') ? function(){} : callback;

        var xmls = {};
        if(parameters.all === true || typeof this.currents.mainXML === 'undefined'){
            var t = this;
            this.setMainXML(function(){
                xmls = {'00': t.currents.mainXML};
                xmls.current = t.getLanguageJson(parameters.file);
                languageToDOM(xmls);

                callback(t);
            });
        }else{
            xmls.current = this.getLanguageJson(parameters.file);
            languageToDOM(xmls);
            callback(this);
        }
        
    };

    Module.prototype.setMainXML = function(callback) {
        var t = this;
        if(typeof t.currents.mainXML === undefined || t.currents.mainLang !== t.currents.language){
            callback = (typeof callback !== 'function') ? function(){} : callback;
            new Vi({url: 'language/'+this.currents.language+'/main.xml', response: 'xml', cache: true}).server(function(r){
                t.currents.mainXML = r;
                t.currents.mainLang = t.currents.language;
                callback();
            });
        }else{
            callback();
        }
    };

    Module.prototype.getMainXML = function() {
        return (this.currents.mainXML !== undefined) ? this.currents.mainXML : {};
    };

    Module.prototype.setLanguageJson = function(j, file) {
        if(typeof file === 'undefined'){
            file = 'content.xml';
        }

        this.currents.jlang = j;
        this.currents.jlangfile = file;
        if(typeof this.currents.languages[this.currents.language] !== 'object'){
            this.currents.languages[this.currents.language] = {};
        }

        if(typeof this.currents.languages[this.currents.language][this.name] !== 'object'){
            this.currents.languages[this.currents.language][this.name] = {};
        }
        this.currents.languages[this.currents.language][this.name][file] = j;
    };

{'fraction_non_alphanumeric': 0.1276844806627347, 'fraction_numerical': 0.0022511368240961684, 'mean_word_length': 1.4585201173280204, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 46}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4755432', 'n_tokens_mistral': 12137, 'n_tokens_neox': 11614, 'n_words': 2520}