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

['#stg_sports', '#stg_fc'].forEach(function (elementId) {
    $(elementId).picker({ 
        search: true 
    });
});

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

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