$(function () {
    $("#post_ovpn").on("submit", function (e) {
        e.preventDefault();
        var formData = new FormData(this);
        formData.append('post_ovpn', '1');
        $.ajax({
            type: "post",
            url: "./includes/post_ottrun_orvpn_config.php",
            data: formData,
            processData: false,
            contentType: false,
            success: function () {
                location.reload();
            },
        });
    });
});

function deleteVpn(id) {
    if (confirm("Are you sure you want to delete this ovpn config?")) {
        $.ajax({
            type: "post",
            url: "./includes/post_ottrun_orvpn_config.php",
            data: {
                delete_ovpn: 1,
                id: id
            },
            success: function () {
                location.reload();
            },
        });
    }
}

function editVpn(vpn_country, vpn_location, vpn_config, vpn_status, auth_type, /*auth_embedded,*/ vpn_username, vpn_password) {
    $("#vpn_country").val(vpn_country);
    $("#vpn_country option[value='" + vpn_country + "']").prop("selected", true);
    $("#vpn_state").val(vpn_location);
    $("#vpn_config").val(vpn_config);
    $("#vpn_status").val(vpn_status);
    $("#auth_type").val(auth_type);
    // $("#auth_embedded").val(auth_embedded);
    $("#vpn_username").val(vpn_username);
    $("#vpn_password").val(vpn_password);
}