<?php

/*

 * *************************************************

 * Copyright (C) 2020 Earworks.                    *

 * Codeigniter Project Template Modification       *

 * Please contact our email for more information : *

 * contact@earworks.co.id                          *

 * *************************************************

 */



defined('BASEPATH') OR exit('No direct script access allowed');

Ci::set_style(<<<CSS

        .card-profile td {font-size:1.5em !important; font-family: Museo500;}

        .footer-copy{display:none;}

        .main-content {

    min-height: calc(100vh - 76px);

}

        .card-kupon .card-code2 {top:51%;}

        .card-kupon {opacity:0; height:0;transition:0.3s;}

        .card-kupon.expand {opacity:1; height:auto;}

CSS

        , 'embed');

?>

<section class="winner">

    <div class="container">

        <span class="separator half"></span>

        <div class="row">

            <div class="col-sm-8 col-sm-offset-2 text-center">

                <span style="font-size:38px;font-family:Museo500;">Selamat Kepada :</span>

                <br><br>

            </div>



            <div class="col-xs-12" id="refresh_area">

                <span class="separator half"></span>

            </div>

        </div>

    </div>

</section>

<script type="text/javascript">

    

    

</script>

<?php

$draw_url = base_url('home/ajax-winner');

Ci::set_script(<<<EOD

    var winner = function(){

        var the;

        var last_id = null;

        var draw_url = '{$draw_url}';

        return {

            init:function(){

                the = this;

                setInterval(the.draw, 1000);

            },

            draw: function(){

                $.ajax({

                    url: draw_url, type:'POST', 'dataType': 'JSON',

                    data:{last_id:last_id}, success:function(res){

                        if(res.status === 1){

                        console.log($('#refresh_area').length);

                            document.getElementById('refresh_area').innerHTML = res.html;

                            setTimeout(function(){

                                $('.card-kupon').addClass('expand');

                                    }, 500);

                            last_id = res.newId;

                        }

                    }

                });

            }

        };

    }();

    $(document).ready(function(){

       winner.init();

    });

EOD

        , 'embed');