
const pokerWidgetData241742416328 = {"filterOptions":{"rooms":["PokerStars","888poker"],"types":"Texas Hold'em","buyin":{"min":1,"max":22}},"da":[{"cols":{"Brand":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/\"><img src=\"https:\/\/widget.tournaments.pokernews.com\/\/img\/uploads\/ns92ckabrsh71fkeo3rnc71q6i\/169443824964ff13694d6d74.09895858.svg\" loading=\"lazy\" alt=\"888poker\" \/><span style=\"display: none\">888poker<\/span><\/a>","Date":"<div class=\"countdown\" data-sort=\"1742416200\" data-timestamp=\"1742416200\"><span style=\"display: none\">1742416200<\/span><\/div>","Buy-In":"<span data-buyinfilter=\"22\" data-sort=\"22\">$22<\/span>","Type":"Texas Hold'em","Event":"Late Big Shot 109 - 3 Seats GTD - Lowered Fee","State":"<span class=\"stateUpcoming\">Upcoming<\/span><span class=\"stateRegistering\">Registering<\/span><span class=\"stateLateReg\">Late Registration<\/span>","Max Players":1000,"Guarantee":"<span data-guaranteefilter=\"327\" data-sort=\"327\">$327<\/span>","MobileSep":"","Cta":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/ext\/tournaments.htm\" class=\"pn-btn full-width medium primary\" target=\"_blank\" rel=\"nofollow noopener\">Register<\/a>"},"currency":"$"},{"cols":{"Brand":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/\"><img src=\"https:\/\/widget.tournaments.pokernews.com\/\/img\/uploads\/ns92ckabrsh71fkeo3rnc71q6i\/169443824964ff13694d6d74.09895858.svg\" loading=\"lazy\" alt=\"888poker\" \/><span style=\"display: none\">888poker<\/span><\/a>","Date":"<div class=\"countdown\" data-sort=\"1742416200\" data-timestamp=\"1742416200\"><span style=\"display: none\">1742416200<\/span><\/div>","Buy-In":"<span data-buyinfilter=\"6\" data-sort=\"6\">$6<\/span>","Type":"Texas Hold'em","Event":"Late PKO Rumble 11","State":"<span class=\"stateUpcoming\">Upcoming<\/span><span class=\"stateRegistering\">Registering<\/span><span class=\"stateLateReg\">Late Registration<\/span>","Max Players":3000,"Guarantee":"<span data-guaranteefilter=\"1500\" data-sort=\"1500\">$1500<\/span>","MobileSep":"","Cta":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/ext\/tournaments.htm\" class=\"pn-btn full-width medium primary\" target=\"_blank\" rel=\"nofollow noopener\">Register<\/a>"},"currency":"$"},{"cols":{"Brand":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/\"><img src=\"https:\/\/widget.tournaments.pokernews.com\/\/img\/uploads\/ns92ckabrsh71fkeo3rnc71q6i\/169443824964ff13694d6d74.09895858.svg\" loading=\"lazy\" alt=\"888poker\" \/><span style=\"display: none\">888poker<\/span><\/a>","Date":"<div class=\"countdown\" data-sort=\"1742416380\" data-timestamp=\"1742416380\"><span style=\"display: none\">1742416380<\/span><\/div>","Buy-In":"<span data-buyinfilter=\"1\" data-sort=\"1\">$1<\/span>","Type":"Texas Hold'em","Event":"Turbo 8.80 - 5 Seats GTD","State":"<span class=\"stateUpcoming\">Upcoming<\/span><span class=\"stateRegistering\">Registering<\/span><span class=\"stateLateReg\">Late Registration<\/span>","Max Players":1000,"Guarantee":"<span data-guaranteefilter=\"44\" data-sort=\"44\">$44<\/span>","MobileSep":"","Cta":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/ext\/tournaments.htm\" class=\"pn-btn full-width medium primary\" target=\"_blank\" rel=\"nofollow noopener\">Register<\/a>"},"currency":"$"},{"cols":{"Brand":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/\"><img src=\"https:\/\/widget.tournaments.pokernews.com\/\/img\/uploads\/ns92ckabrsh71fkeo3rnc71q6i\/169443824964ff13694d6d74.09895858.svg\" loading=\"lazy\" alt=\"888poker\" \/><span style=\"display: none\">888poker<\/span><\/a>","Date":"<div class=\"countdown\" data-sort=\"1742417100\" data-timestamp=\"1742417100\"><span style=\"display: none\">1742417100<\/span><\/div>","Buy-In":"<span data-buyinfilter=\"2.2\" data-sort=\"2.2\">$2.2<\/span>","Type":"Omaha","Event":"PLO R&amp;A Turbo 2.20","State":"<span class=\"stateUpcoming\">Upcoming<\/span><span class=\"stateRegistering\">Registering<\/span><span class=\"stateLateReg\">Late Registration<\/span>","Max Players":1000,"Guarantee":"<span data-guaranteefilter=\"300\" data-sort=\"300\">$300<\/span>","MobileSep":"","Cta":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/ext\/tournaments.htm\" class=\"pn-btn full-width medium primary\" target=\"_blank\" rel=\"nofollow noopener\">Register<\/a>"},"currency":"$"},{"cols":{"Brand":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/\"><img src=\"https:\/\/widget.tournaments.pokernews.com\/\/img\/uploads\/ns92ckabrsh71fkeo3rnc71q6i\/169443824964ff13694d6d74.09895858.svg\" loading=\"lazy\" alt=\"888poker\" \/><span style=\"display: none\">888poker<\/span><\/a>","Date":"<div class=\"countdown\" data-sort=\"1742418000\" data-timestamp=\"1742418000\"><span style=\"display: none\">1742418000<\/span><\/div>","Buy-In":"<span data-buyinfilter=\"1\" data-sort=\"1\">$1<\/span>","Type":"Texas Hold'em","Event":"Micro Rollers - Mystery Bounty Turbo 1","State":"<span class=\"stateUpcoming\">Upcoming<\/span><span class=\"stateRegistering\">Registering<\/span><span class=\"stateLateReg\">Late Registration<\/span>","Max Players":3000,"Guarantee":"<span data-guaranteefilter=\"300\" data-sort=\"300\">$300<\/span>","MobileSep":"","Cta":"<a href=\"https:\/\/www.pokernews.com\/888-poker\/ext\/tournaments.htm\" class=\"pn-btn full-width medium primary\" target=\"_blank\" rel=\"nofollow noopener\">Register<\/a>"},"currency":"$"}]};

// 2025-03-19 21:32:08// Europe/Rome
//<script>
    // Isolate global widget vars by scoping into function
    (function wrapper() {

        let otcWidget = document.querySelector('.widget-container[data-id="24"]');
        init(otcWidget);

        function init(parentEl) {

            // Include main css file
            const style = document.createElement( "link" );
            style.href = "https://widget.tournaments.pokernews.com/build/style.css?v=1741779552";
            style.type = "text/css";
            style.rel = "stylesheet";
            document.getElementsByTagName( "head" )[0].appendChild( style );

            const loadScript = function (src, runAfterLoad, needdefer) {
                const script = document.createElement('script');
                script.src = src;
                if(needdefer) {
                    script.defer = true;
                }
                if(runAfterLoad) {
                    script.onload = runAfterLoad;
                }
                document.body.append(script);
            }
            const repeatFunctionUntilTrue = function (callback, index) {
                index = index || 1;
                if (!callback() && index < 10) {
                    //should wait
                    var delay = 200 * index;
                    setTimeout(function () {
                        repeatFunctionUntilTrue(callback, 1 + index)
                    }, delay);
                }
            }
            const buildOTC = function() {

                let $container = jQuery('.widget-container[data-id="24"]');

                // Make each widget with unique classes
                const prefix = 'pokerroom-widget-241742416328-';

                // Widget container jquery selector. Here we inject widget

                const data = pokerWidgetData241742416328;

                if ($container.length > 0) {

                    // Wrapper DIV
                    $wrapper = jQuery('<section class="otc" />');

                    $header = jQuery(
                    `
                        <header class="otc__header">
                            <img src="https://widget.tournaments.pokernews.com/img/calendar.svg" height="40" loading="lazy">
                            <h2 class="otc__header__desktop">Discover Your Winning Edge: Explore the PokerNews Online Tournament Calendar</h2>
                            <h2 class="otc__header__mobile">PokerNews Online Tournament Calendar</h2>
                        </header>
                    `
                    );

                    // FILTER SECTION
                    
                    if (data.da && data.da.length > 0) {
                        $table = jQuery('<table class="otc__list customArticleTable" />');
                        $thead = jQuery(`
                            <thead class="otc__event otc__event--heading forDesktop">
                                <tr>
                                    <th class="otc__event__brand">
                                        Brand                                    </th>
                                    <th class="otc__event__countdown">
                                        Start Date/Time                                    </th>
                                    <th class="otc__event__buyIn">
                                        Buy-In                                    </th>
                                    <th class="otc__event__type">
                                        Game Type                                    </th>
                                    <th class="otc__event__name">
                                        Name                                    </th>
                                    <th class="otc__event__state">State</th>
                                    <th class="otc__event__players">
                                        Max Players                                    </th>
                                    <th class="otc__event__prize">
                                        Guarantee                                    </th>
                                    <th class="otc__event__mobilesep"></th>
                                    <th class="otc__event__cta"></th>
                                </tr>
                            </thead>
                        `);
                        $table.append($thead);
                            $rows = data.da.map(
                                row => {
                                    const rowdata = jQuery('<tr class="otc__event otc__event--upcoming">' + (
                                        row.cols && Object.keys(row.cols).map(
                                            col => '<td class="otc__event__' + (col.replace(' ', '_').toLowerCase()) + '" data-title="'+ col +'"><div>' + row.cols[col] + '</div></td>'
                                        )
                                    ) + '</tr>'
                                )
                                return rowdata
                            }
                        );
                        $table.append('<tbody/>').append($rows);
                                                $wrapper.append(
                                                                                    $table);
                        } else {
                            // Message about empty events calendar
                            $wrapper.append('<p class="' + prefix + 'no-events poker-room-24-widget-noevents poker-room-widget-noevents">There are no tournaments available through PokerNews in your region.</p>');
                            // turnOffPreloader();
                            jQuery('.preloaderBox', $container).addClass("hidePreloader");
                        }

                    $container.append($wrapper);

                    if (data.da === null) {
                        return false;
                    }

                                    }

                jQuery('.otc__event__date').each(function(){
                    $(this).attr('data-sort', jQuery('div', $(this)).attr('data-timestamp'));
                })

                // Initiate datatable and set datatable options
                repeatFunctionUntilTrue(() => {
                    const datatableEl = parentEl.querySelector('.otc__list');
                    if (typeof window.DataTable === 'function' && datatableEl) {

                        DataTable.ext.pager.numbers_length = 6;

                        parentEl.datatable = new DataTable(datatableEl, {
                            lengthChange: false,
                            autoWidth: false,
                            order: [[1, 'asc']],
                            "drawCallback": function( settings ) {

                                // Hide paging if only one page is
                                // settings._iDisplayLength = datatable settings how many items show per page
                                // settings.fnRecordsDisplay() = return how many items we receive from DB

                                if (settings._iDisplayLength >= settings.fnRecordsDisplay()) {
                                    $(settings.nTableWrapper).addClass("hidePagination");
                                } else {
                                    $(settings.nTableWrapper).removeClass("hidePagination");
                                }

                                // after table page changes need to reinitiate countdown function for setting date values.
                                repeatFunctionUntilTrue(() => {
                                    if (window.countdown) {
                                        window.countdown(parentEl);
                                        return true;
                                    }
                                    return false;
                                });
                            },
                            "language": {
                                "paginate": {
                                    "previous": '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m12.5 5-5 5 5 5"/></svg>',
                                    "next": '<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none"><path stroke="#000" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="m7.5 15 5-5-5-5"/></svg>'
                                },
                                info: 'Showing _START_ to _END_ of _TOTAL_ entries',
                                infoFiltered: '(filtered from _MAX_ total entries)',
                                zeroRecords: 'No matching records found',
                            }
                        });



                        if(parentEl.querySelector('.otc__list')) {
                            const paginationWraper = document.createElement('div');
                            paginationWraper.className = "paginationWraper";

                            parentEl.querySelector('.otc__list').insertAdjacentElement('afterend', paginationWraper);
                            const pagingInfo = parentEl.querySelector('.dataTables_info');
                            const paging = parentEl.querySelector('.dataTables_paginate');
                            paginationWraper.appendChild(pagingInfo);
                            paginationWraper.appendChild(paging);
                        }

                                                // load custom component script
                        loadScript("https://widget.tournaments.pokernews.com/build/script.js?v=1741779552", false);
                        // turnOffPreloader();
                        jQuery('.preloaderBox', $container).addClass("hidePreloader");
                        return true;
                    }
                    return false;
                });
            }

            const loadDataTable = function () {
                                        loadScript("https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js", buildOTC, false);

                            }
            const loadDateRangePicker = function() {
                loadScript("https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js", buildOTC, true);
            }
            if (typeof jQuery === 'undefined') {
                loadScript("https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js", loadDataTable);
            } else {
                loadDataTable();
            }

        }
    })();

//</script>
