['#tsdb_background_color', '#tsdb_text_color'].forEach(function(elementId) {
    $(elementId).spectrum({
        preferredFormat: "hex",
        "showInput": true
    });
});

$('#tsdb_leagues').picker({search : true});

function getCsrfToken() {
    return $('input[name="csrf_token"]').val();
}

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