<commit_before>// Set vue settings
Vue.config.debug = {{ debug }};

// Vue instance
var app = null;
var update_interval = {{ update_interval }};

// <mod-box> - Displays a modbox
Vue.component('mod-box', {
    delimiters: ['${', '}'],
    props: ['mod', 'currentUser'],
    template: '<div class="item col-md-4">\
    <div class="thumbnail">\
        <div class="ksp-update">KSP ${mod.default_version.gameversion.friendly_version}</div>\
        <div class=\"following-mod\" v-if=\"currentUser != null && currentUser.following.hasObject(mod.id)\">Following</div>\
        <a v-bind:href="\'{{ path_for("mod.view", {"id": "<id>", "name": "<name>"}) }}\'.replace(/<id>/, mod.id).replace(/<name>/, mod.name)">\
            <div class="header-img" v-if="mod.meta.hasOwnProperty(\'background\')" v-bind:style="\'background-image: url(//{{ backend_url }}\' + mod.meta[\'background\'].replace(/.jpg/g, \'_thumb.jpg\').replace(/.png/g, \'_thumb.png\') + \');\'"></div>\
            <div class="header-img" v-else style="background-image: url({{ path_for('images', {'filename': 'background.png'}) }});"></div>\
        </a>\
        <div class="caption">\
            <h2 class="group inner list-group-item-heading">\
            ${mod.name}\
            </h2>\
            <p style="height: 75px; overflow: hidden;">\
            ${mod.short_description}\
            </p>\
        </div>\
    </div>\
</div>'
});

Array.prototype.hasObject = (
  !Array.indexOf ? function (o)
  {
    var l = this.length + 1;
    while (l -= 1)
    {
        if (this[l - 1] === o)
        {
            return true;
        }
    }
    return false;
  } : function (o)
  {
    return (this.indexOf(o) !== -1);
  }
);

function findGetParameter(parameterName) {
    var result = null;
    var tmp = [];
    var items = location.search.substr(1).split("&");
    var index = 0;
    while (index < items.length) {
        tmp = items[index].split("=");
        if (tmp[0] == parameterName) {
            result = decodeURIComponent(tmp[1]);
        }
        index++;
    }
    return result;
}

function showLoading() {
    $.loadingBlockShow({
        imgPath: "{{ path_for('images', {'filename': 'default.svg'}) }}",
        text: '',
        style: {
            position: 'fixed',
            width: '100%',
            height: '100%',
            background: '#333',
            left: 0,
            top: 0,
            zIndex: 10000
        }
    });
}

function loginUserHotbar() {
    loginUser($('input#username').val(), $('input#password').val(), $('input#remember-me').is(":checked"), window.location.href)
}

// $.getJSON clone that doesn't fail on 403
function getJSON(url, callback) {
    return $.ajax(url, {
        data: '',
        xhrFields: {
            withCredentials: true
        },
        type: "GET",
        dataType: "json",
        contentType: "application/json",
        success: function(data) {
            callback(data);
        },error: function(xhr, a, b) {
            callback($.parseJSON(xhr.responseText));
        }
    });    
}

function postJSON(url, callback) {
    $.ajax(url, {
        data: '',
        xhrFields: {
            withCredentials: true
        },
        type: "POST",
        dataType: "json",
        contentType: "application/json",
        success: function(data) {
            callback(data);
        },error: function(xhr, a, b) {
            callback($.parseJSON(xhr.responseText));
        }
    });
}

function postJSON(url, data, callback) {
    if (callback == null) {
        callback = data;
    }
    $.ajax(url, {
        data: JSON.stringify(data),
        xhrFields: {
            withCredentials: true
        },
        type: "POST",
        dataType: "json",
        contentType: "application/json",
        success: function(retData) {
            callback(retData);
        },error: function(xhr, a, b) {
            callback($.parseJSON(xhr.responseText));
        }
    });
}

function putJSON(url, data, callback) {
    $.ajax(url, {
        data: JSON.stringify(data),
        xhrFields: {
            withCredentials: true
        },
        type: "PUT",
        dataType: "json",
        contentType: "application/json",
        success: function(data) {
            callback(data);
        },error: function(xhr, a, b) {
            callback($.parseJSON(xhr.responseText));
        }
    });
}

function deleteJSON(url, callback) {
    $.ajax(url, {
        data: '',
        xhrFields: {
            withCredentials: true
        },
        type: "DELETE",
        dataType: "json",
        contentType: "application/json",
        success: function(data) {
            callback(data);
        },error: function(xhr, a, b) {
            callback($.parseJSON(xhr.responseText));
        }
    });
}

function deleteJSON(url, data, callback) {
    if (callback == null) {
        callback = data;
    }
    $.ajax(url, {
        data: JSON.stringify(data),
        xhrFields: {
            withCredentials: true
        },
        type: "DELETE",
        dataType: "json",
        contentType: "application/json",
        success: function(retData) {
            callback(retData);
        },error: function(xhr, a, b) {
            callback($.parseJSON(xhr.responseText));
        }
    });
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');<commit_msg>Preparing the request Methods for parallel requests.<commit_after>// Set vue settings
Vue.config.debug = {{ debug }};

// Vue instance
var app = null;
var update_interval = {{ update_interval }};

// <mod-box> - Displays a modbox
Vue.component('mod-box', {
    delimiters: ['${', '}'],
    props: ['mod', 'currentUser'],
    template: '<div class="item col-md-4">\
    <div class="thumbnail">\
        <div class="ksp-update">KSP ${mod.default_version.gameversion.friendly_version}</div>\
        <div class=\"following-mod\" v-if=\"currentUser != null && currentUser.following.hasObject(mod.id)\">Following</div>\
        <a v-bind:href="\'{{ path_for("mod.view", {"id": "<id>", "name": "<name>"}) }}\'.replace(/<id>/, mod.id).replace(/<name>/, mod.name)">\
            <div class="header-img" v-if="mod.meta.hasOwnProperty(\'background\')" v-bind:style="\'background-image: url(//{{ backend_url }}\' + mod.meta[\'background\'].replace(/.jpg/g, \'_thumb.jpg\').replace(/.png/g, \'_thumb.png\') + \');\'"></div>\
            <div class="header-img" v-else style="background-image: url({{ path_for('images', {'filename': 'background.png'}) }});"></div>\
        </a>\
        <div class="caption">\
            <h2 class="group inner list-group-item-heading">\
            ${mod.name}\
            </h2>\
            <p style="height: 75px; overflow: hidden;">\
            ${mod.short_description}\
            </p>\
        </div>\
    </div>\
</div>'
});

Array.prototype.hasObject = (
  !Array.indexOf ? function (o)
  {
    var l = this.length + 1;
    while (l -= 1)
    {
        if (this[l - 1] === o)
        {
            return true;
        }
    }
    return false;
  } : function (o)
  {
    return (this.indexOf(o) !== -1);
  }
);

function findGetParameter(parameterName) {
    var result = null;
    var tmp = [];
    var items = location.search.substr(1).split("&");
    var index = 0;
    while (index < items.length) {
        tmp = items[index].split("=");
        if (tmp[0] == parameterName) {
            result = decodeURIComponent(tmp[1]);
        }
        index++;
    }
    return result;
}

function showLoading() {
    $.loadingBlockShow({
        imgPath: "{{ path_for('images', {'filename': 'default.svg'}) }}",
        text: '',
        style: {
            position: 'fixed',
            width: '100%',
            height: '100%',
            background: '#333',
            left: 0,
            top: 0,
            zIndex: 10000
        }
    });
}

function loginUserHotbar() {
    loginUser($('input#username').val(), $('input#password').val(), $('input#remember-me').is(":checked"), window.location.href)
}

// Base method for *JSON methods (get, post, put, delete)
function requestJSON(url, data, method, callback) {
    return $.ajax(url, {
        data: data,
        xhrFields: {
            withCredentials: true
        },
        type: method,
        dataType: "json",
        contentType: "application/json",
        success: function(data) {
            if (callback) {
                callback(data);
            }
        },error: function(xhr, a, b) {
            if (callback) {
                callback($.parseJSON(xhr.responseText));
            }
        }
    }).then(null, function(jqXHR, textStatus, errorThrown) {
        return $.parseJSON(jqXHR.responseText);
    }).then(function (data) {
        return data;
    }, function (err) {
        console.log(err);
    });  
}

// Submits a GET request to the URL
function getJSON(url, data, callback) {
    if (callback == null) {
        callback = data;
        data = '';
    }
    return requestJSON(url, '', 'GET', callback);
}

// Submits a POST request to the URL
function postJSON(url, data, callback) {
    if (callback == null) {
        callback = data;
        data = '';
    } else {
        data = JSON.stringify(data);
    }
    return requestJSON(url, data, 'POST', callback);
}

// Submits a PUT request to the URL
function putJSON(url, data, callback) {
    if (callback == null) {
        callback = data;
        data = '';
    } else {
        data = JSON.stringify(data);
    }
    return requestJSON(url, data, 'PUT', callback);
}

// Submits a DELETE request to the URL
function deleteJSON(url, data, callback) {
    if (callback == null) {
        callback = data;
        data = '';
    } else {
        data = JSON.stringify(data);
    }
    return requestJSON(url, data, 'DELETE', callback);
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
{'fraction_non_alphanumeric': 0.1803212445701586, 'fraction_numerical': 0.006162238609960602, 'mean_word_length': 2.0659646949519974, 'pattern_counts': {'":': 6, '<': 55, '<?xml version=': 0, '>': 53, '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': '459770', 'n_tokens_mistral': 3130, 'n_tokens_neox': 3071, 'n_words': 653}