<commit_before>Vps.Connection = Ext.extend(Ext.data.Connection, {
    request: function(options)
    {
    
        if (options.url.match(/[\/a-zA-Z0-9]*\/json[a-zA-Z0-9]+(\/|\?|)/)) {

            if (options.mask) {
                if (Vps.Connection.masks == 0) {
                    if (Ext.get('loading')) {
                        Ext.getBody().mask();
                    } else {
                        Ext.getBody().mask('Loading...');
                    }
                }
                Vps.Connection.masks++;
            }
            options.vpsCallback = {
                success: options.success,
                failure: options.failure,
                callback: options.callback,
                scope: options.scope
            };
            options.success = this.vpsSuccess;
            options.failure = this.vpsFailure;
            options.callback = this.vpsCallback;
            options.scope = this;
        }
        if (!options.params) options.params = {};
        options.params.application_version = Vps.application.version;
        if (!options.url.match(':\/\/')) {
            //absolute url incl. http:// erstellen
            //wird benötigt wenn fkt über mozrepl aufgerufen wird
            var u = location.protocol + '/'+'/' + location.host;
            if (options.url.substr(0, 1) == '/') {
                options.url = u + options.url;
            } else {
                options.url = u + '/' + options.url;
            }
        }
        Vps.Connection.superclass.request.call(this, options);
    },
    repeatRequest: function(options) {
        delete options.vpsIsSuccess;
        Vps.Connection.superclass.request.call(this, options);
    },
    vpsSuccess: function(response, options)
    {
        options.vpsIsSuccess = false;
        options.vpsLogin = false;
        try {
            var r = Ext.decode(response.responseText);
        } catch(e) {
            var errorMsg = '<a href="'+options.url+'?'+Ext.urlEncode(options.params)+'">request-url</a><br />';
            errorMsg += e.toString()+': <br />'+response.responseText;
            var errorMsgTitle = 'Javascript Parse Exception';
        }

        if (!errorMsg && r.exception) {
            var errorMsg = '<a href="'+options.url+'?'+Ext.urlEncode(options.params)+'">request-url</a><br />';
            errorMsg += r.exception;
            var errorMsgTitle = 'PHP Exception';
        }
        if (errorMsg) {
            if (Vps.debug) {
                Ext.Msg.show({
                    title: errorMsgTitle,
                    msg: errorMsg,
                    buttons: Ext.Msg.OK,
                    modal: true,
                    width: 800
                });
            } else {
                Ext.Msg.alert('Error', "A Server failure occured.");
                Ext.Ajax.request({
                    url: '/error/jsonMail',
                    params: {msg: errorMsg}
                });
            }
            Ext.callback(options.vpsCallback.failure, options.vpsCallback.scope, [response, options]);
            return;
        }

        if (!r.success) {
            if (r.wrongversion) {
                Ext.Msg.alert('Error - wrong version',
                'Because of an application update the application has to be reloaded.',
                function(){
                    location.reload();
                });
                Ext.callback(options.vpsCallback.failure, options.vpsCallback.scope, [response, options]);
                return;
            }
            if (r.login) {
                options.vpsLogin = true;
                var dlg = new Vps.User.Login.Dialog({
                    success: function() {
                        //redo action...
                        this.repeatRequest(options);
                    },
                    scope: this
                });
                Ext.getBody().unmask();
                dlg.showLogin();
                return;
            }
            if (r.error) {
                Ext.Msg.alert('Error', r.error);
            } else if (!r.login) {
                Ext.Msg.alert('Error', "A Server failure occured.");
            }
            Ext.callback(options.vpsCallback.failure, options.vpsCallback.scope, [response, options]);
            return;
        }
        options.vpsIsSuccess = true;

        Vps.callWithErrorHandler(function() {
            Ext.callback(options.vpsCallback.success, options.vpsCallback.scope, [response, options, r]);
        });
    },

    vpsFailure: function(response, options)
    {
        options.vpsIsSuccess = false;
        var debugString = '';
        for (var dbg in options.params) {
            debugString += '<br />params.' + dbg + ' = ' + options.params[dbg];
        }
        Ext.Msg.alert('Error', "A connection problem occured.<br /><br /><b>Debug info:</b><br />"
            + "url: " + options.url + debugString);
        Ext.callback(options.vpsCallback.failure, options.vpsCallback.scope, [response, options]);
        return;
    },
    
    vpsCallback: function(options, success, response)
    {
        //wenn login-fenster angezeigt wird keinen callback aufrufen - weil der request
        //wird ja erneut gesendet und da dann der callback aufgerufen.
        if (options.vpsLogin) return;

        if (options.mask) {
            Vps.Connection.masks--;
            if (Vps.Connection.masks == 0) {
                Ext.getBody().unmask();
                if (Ext.get('loading')) {
                    Ext.get('loading').fadeOut({remove: true});
                }
            }
        }

        if(success && !options.vpsIsSuccess) {
            success = false;
        }
        Ext.callback(options.vpsCallback.callback, options.vpsCallback.scope, [options, success, response]);
    }
});
Vps.Connection.masks = 0; //static var that hols number of masked requests

Ext.Ajax = new Vps.Connection({
    /**
     * The timeout in milliseconds to be used for requests. (defaults
     * to 30000)
     * @type Number
     * @property  timeout
     */
    autoAbort : false,

    /**
     * Serialize the passed form into a url encoded string
     * @return {String}
     */
    serializeForm : function(form){
        return Ext.lib.Ajax.serializeForm(form);
    }
});

<commit_msg>bugfix pfad von error controller<commit_after>Vps.Connection = Ext.extend(Ext.data.Connection, {
    request: function(options)
    {
    
        if (options.url.match(/[\/a-zA-Z0-9]*\/json[a-zA-Z0-9]+(\/|\?|)/)) {

            if (options.mask) {
                if (Vps.Connection.masks == 0) {
                    if (Ext.get('loading')) {
                        Ext.getBody().mask();
                    } else {
                        Ext.getBody().mask('Loading...');
                    }
                }
                Vps.Connection.masks++;
            }
            options.vpsCallback = {
                success: options.success,
                failure: options.failure,
                callback: options.callback,
                scope: options.scope
            };
            options.success = this.vpsSuccess;
            options.failure = this.vpsFailure;
            options.callback = this.vpsCallback;
            options.scope = this;
        }
        if (!options.params) options.params = {};
        options.params.application_version = Vps.application.version;
        if (!options.url.match(':\/\/')) {
            //absolute url incl. http:// erstellen
            //wird benötigt wenn fkt über mozrepl aufgerufen wird
            var u = location.protocol + '/'+'/' + location.host;
            if (options.url.substr(0, 1) == '/') {
                options.url = u + options.url;
            } else {
                options.url = u + '/' + options.url;
            }
        }
        Vps.Connection.superclass.request.call(this, options);
    },
    repeatRequest: function(options) {
        delete options.vpsIsSuccess;
        Vps.Connection.superclass.request.call(this, options);
    },
    vpsSuccess: function(response, options)
    {
        options.vpsIsSuccess = false;
        options.vpsLogin = false;
        try {
            var r = Ext.decode(response.responseText);
        } catch(e) {
            var errorMsg = '<a href="'+options.url+'?'+Ext.urlEncode(options.params)+'">request-url</a><br />';
            errorMsg += e.toString()+': <br />'+response.responseText;
            var errorMsgTitle = 'Javascript Parse Exception';
        }

        if (!errorMsg && r.exception) {
            var errorMsg = '<a href="'+options.url+'?'+Ext.urlEncode(options.params)+'">request-url</a><br />';
            errorMsg += r.exception;
            var errorMsgTitle = 'PHP Exception';
        }
        if (errorMsg) {
            if (Vps.debug) {
                Ext.Msg.show({
                    title: errorMsgTitle,
                    msg: errorMsg,
                    buttons: Ext.Msg.OK,
                    modal: true,
                    width: 800
                });
            } else {
                Ext.Msg.alert('Error', "A Server failure occured.");
                Ext.Ajax.request({
                    url: '/vps/error/error/jsonMail',
                    params: {msg: errorMsg}
                });
            }
            Ext.callback(options.vpsCallback.failure, options.vpsCallback.scope, [response, options]);
            return;
        }

        if (!r.success) {
            if (r.wrongversion) {
                Ext.Msg.alert('Error - wrong version',
                'Because of an application update the application has to be reloaded.',
                function(){
                    location.reload();
                });
                Ext.callback(options.vpsCallback.failure, options.vpsCallback.scope, [response, options]);
                return;
            }
            if (r.login) {
                options.vpsLogin = true;
                var dlg = new Vps.User.Login.Dialog({
                    success: function() {
                        //redo action...
                        this.repeatRequest(options);
                    },
                    scope: this
                });
                Ext.getBody().unmask();
                dlg.showLogin();
                return;
            }
            if (r.error) {
                Ext.Msg.alert('Error', r.error);
            } else if (!r.login) {
                Ext.Msg.alert('Error', "A Server failure occured.");
            }
            Ext.callback(options.vpsCallback.failure, options.vpsCallback.scope, [response, options]);
            return;
        }
        options.vpsIsSuccess = true;

        Vps.callWithErrorHandler(function() {
            Ext.callback(options.vpsCallback.success, options.vpsCallback.scope, [response, options, r]);
        });
    },

    vpsFailure: function(response, options)
    {
        options.vpsIsSuccess = false;
        var debugString = '';
        for (var dbg in options.params) {
            debugString += '<br />params.' + dbg + ' = ' + options.params[dbg];
        }
        Ext.Msg.alert('Error', "A connection problem occured.<br /><br /><b>Debug info:</b><br />"
            + "url: " + options.url + debugString);
        Ext.callback(options.vpsCallback.failure, options.vpsCallback.scope, [response, options]);
        return;
    },
    
    vpsCallback: function(options, success, response)
    {
        //wenn login-fenster angezeigt wird keinen callback aufrufen - weil der request
        //wird ja erneut gesendet und da dann der callback aufgerufen.
        if (options.vpsLogin) return;

        if (options.mask) {
            Vps.Connection.masks--;
            if (Vps.Connection.masks == 0) {
                Ext.getBody().unmask();
                if (Ext.get('loading')) {
                    Ext.get('loading').fadeOut({remove: true});
                }
            }
        }

        if(success && !options.vpsIsSuccess) {
            success = false;
        }
        Ext.callback(options.vpsCallback.callback, options.vpsCallback.scope, [options, success, response]);
    }
});
Vps.Connection.masks = 0; //static var that hols number of masked requests

Ext.Ajax = new Vps.Connection({
    /**
     * The timeout in milliseconds to be used for requests. (defaults
     * to 30000)
     * @type Number
     * @property  timeout
     */
    autoAbort : false,

    /**
     * Serialize the passed form into a url encoded string
     * @return {String}
     */
    serializeForm : function(form){
        return Ext.lib.Ajax.serializeForm(form);
    }
});


{'fraction_non_alphanumeric': 0.1295604482950481, 'fraction_numerical': 0.0027024878785470155, 'mean_word_length': 1.4579019339714787, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '3583008', 'n_tokens_mistral': 3503, 'n_tokens_neox': 3349, 'n_words': 684}