<script src="views/public/js/jquery3.js"></script>
<script src="views/public/js/popper.min.js"></script>
<script src="views/public/js/bootstrap.min.js"></script>
<script type="text/javascript" src="views/public/plugins/DataTables/datatables.min.js"></script>
<script>
    $(document).ready(function() {
        $('.table').DataTable();
        $("#thumbnail").change(function(e) {
            for (var i = 0; i < e.originalEvent.srcElement.files.length; i++) {
                
                var file = e.originalEvent.srcElement.files[i];
                
                var thumbnailDiv = document.getElementById("displayThumbnail");

                thumbnailDiv.innerHTML = "";

                var img = document.createElement("img");
                
                img.classList.add("img-fluid");

                var reader = new FileReader();

                reader.onloadend = function() {
                    img.src = reader.result;
                }

                reader.readAsDataURL(file);
                thumbnailDiv.appendChild(img);
            }
        });
    });
</script>
<!-- Graphs -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.min.js"></script>
<!-- <script>
    var ctx = document.getElementById("myChart");
    var myChart = new Chart(ctx, {
    type: 'line',
    data: {
        labels: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
        datasets: [{
        data: [15339, 21345, 18483, 24003, 23489, 24092, 12034],
        lineTension: 0,
        backgroundColor: 'transparent',
        borderColor: '#007bff',
        borderWidth: 4,
        pointBackgroundColor: '#007bff'
        }]
    },
    options: {
        scales: {
        yAxes: [{
            ticks: {
            beginAtZero: false
            }
        }]
        },
        legend: {
        display: false,
        }
    }
    });
</script> -->

<script language="javascript" type="text/javascript" src="views/public/plugins/ckeditor/ckeditor.js"></script>
<script language="javascript" type="text/javascript" src="views/public/plugins/ckfinder/ckfinder.js"></script>

<script language="javascript" type="text/javascript">

$(document).ready(function() {

    var allMainEditors = document.querySelectorAll('.editor-main');

    for (var i = 0; i < allMainEditors.length; ++i) {
        ClassicEditor
                .create( allMainEditors[i], {
                    ckfinder: {
                        uploadUrl: 'views/public/plugins/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json',
                    },
                    toolbar: ['heading', '|', 'bold', 'italic','link','blockQuote','|',
                    'bulletedList','numberedList','insertTable','|',
                    'ckfinder','imageUpload','mediaEmbed','|']
                })
                .catch( error => {
                    console.error( error );
        } );
    }

    var allSubEditors = document.querySelectorAll('.editor-sub');

    for (var i = 0; i < allSubEditors.length; ++i) {
        ClassicEditor
                .create( allSubEditors[i], {
                    ckfinder: {
                        uploadUrl: 'views/public/plugins/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json',
                    },
                    toolbar: ['heading', '|', 'bold', 'italic','link','blockQuote','|',
                    'bulletedList','numberedList','insertTable','|']
                })
                .catch( error => {
                    console.error( error );
        } );
    }

});
</script>

<script type="text/javascript">

    function deleteModal(id) {
        let deleteId = document.getElementById('deleteId');
        deleteId.setAttribute('value', id);
        $('#delete').show();
    }

</script>

<script language="javascript" type="text/javascript" src="views/public/js/notify.min.js"></script>
<?php if(isset($_SESSION['message']))  {
    echo "<script type='text/javascript'>";
    echo "$(document).ready(function(){";
    echo "$.notify('";
    echo $_SESSION["message"];
    echo "','";
    echo $_SESSION["messageType"];            
    echo "');";
    echo "});";
    echo "</script>";
} ?>

<?php
if (isset($_SESSION['displayed'])) {
    if($_SESSION['displayed'] == "false") {
        $_SESSION['displayed'] = "true";
    } else {
        unset($_SESSION['message']);
        unset($_SESSION['messageType']);
    }
}
?>
