inijs.blade.php 7.05 KB
Newer Older
Siti Aisah committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
<!-- BEGIN: Vendor JS-->
<script src="{{ url('theme/vendors/js/vendors.min.js') }}"></script>
<!-- BEGIN Vendor JS-->

<!-- BEGIN: Page Vendor JS-->
<script src="{{ url('theme/vendors/js/ui/jquery.sticky.js') }}"></script>
{{-- <script src="{{ url('theme/vendors/js/charts/apexcharts.min.js') }}"></script> --}}
<script src="{{ url('theme/vendors/js/extensions/toastr.min.js') }}"></script>
<!-- END: Page Vendor JS-->

<!-- BEGIN: Theme JS-->
<script src="{{ url('theme/js/core/app-menu.js') }}"></script>
<script src="{{ url('theme/js/core/app.js') }}"></script>
<!-- END: Theme JS-->

<!-- BEGIN: Page JS-->
{{-- <script src="{{ url('theme/js/scripts/pages/dashboard-ecommerce.js') }}"></script> --}}
<script src="{{ asset('js/sweetalert.js') }}"></script>
<!-- END: Page JS-->
<script src="{{ asset('theme/vendors/js/forms/select/select2.full.min.js') }}"></script>
<script src="{{ asset('theme/js/scripts/forms/form-select2.min.js') }}"></script>
{{-- <script src="{{ asset('theme/js/scripts/extensions/ext-component-blockui.js') }}"></script> --}}
<script>
    $(window).on('load', function() {
        if (feather) {
            feather.replace({
                width: 14,
                height: 14
            });
        }
    })
</script>
{{-- @livewireScripts --}}
@once
<script>
    window.addEventListener('notify-swal', function(e) {
        let data = e.detail;
        let title = data.title;
        let message = data.message;
        let type = data.type;

        Swal.fire({
            position: 'top-end',
            icon: type,
            title: title,
            showConfirmButton: false,
            timer: 1500
        })
    });
</script>
<script>
    @if(Session::has('error'))
    Swal.fire({
        position: 'top-end',
        icon: 'error',
        title: '{{ Session::get('error') }}',
        showConfirmButton: false,
        timer: 1500
    });
    @elseif (Session::has('success'))
    Swal.fire({
        position: 'top-end',
        icon: 'success',
        title: '{{ Session::get('success') }}',
        showConfirmButton: false,
        timer: 1500
    });
    @endif

    $(document).ready( function () {
        $('.dataTable').DataTable();
    } );

    $(document).ready(function() {
    $('.dataTableExcel').DataTable( {
        dom: 'Bfrtip',
        buttons: [
            'excel'
        ]
    } );
} );
</script>
<script>
    window.addEventListener('close-modal', e => {
        $('#'+e.detail.modal_id).modal('hide');
    });

    window.addEventListener('open-modal', e => {
        $('#'+e.detail.modal_id).modal('show');
    });

    $(document).ready(function() {
        $(".modal").on("show.bs.modal", function() {
            $(".dynamic").html('<div class="d-flex justify-content-center"><div class="spinner-border text-primary" role="status"></div></div>');
        });
    });

    window.addEventListener('refresh-icon', e => {
        feather.replace();
    });
</script>
@endonce
{{-- <script src="https://www.gstatic.com/firebasejs/7.23.0/firebase.js"></script>
<script>
    var firebaseConfig = {
        apiKey: "AIzaSyDASAxfCBxABno3XrIb7d1QPQJWw4cSYtM",
        authDomain: "umc-push-notification.firebaseapp.com",
        projectId: "umc-push-notification",
        storageBucket: "umc-push-notification.appspot.com",
        messagingSenderId: "539322685533",
        appId: "1:539322685533:web:69d3c15dcdf8ceb7a795b4",
        measurementId: "G-J4MT1RC45T"
    };

    var deviceToken = '';

    firebase.initializeApp(firebaseConfig);
    const messaging = firebase.messaging();

    initFirebaseMessaging();

    // function setNotificationSetting(element) {
    //     let notif = 0;

    //     if($(element).prop('checked')){
    //         notif = 1;
    //     }

    //     $.ajaxSetup({
    //         headers: {
    //             'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    //         }
    //     });

    //     $.ajax({
    //         url: "{{ route('save-firebase-token') }}",
    //         type: 'POST',
    //         data: {
    //             token: deviceToken,
    //             notif: notif
    //         },
    //         dataType: 'html',
    //         success: function (response) {
    //             // Swal.fire({
    //             //     position: 'top-end',
    //             //     icon: 'success',
    //             //     title: 'Setting berhasil disimpan',
    //             //     showConfirmButton: false,
    //             //     timer: 1500
    //             // });
    //             // alert('Token saved successfully.');
    //         },
    //         error: function (err) {
    //             Swal.fire({
    //                 position: 'top-end',
    //                 icon: 'error',
    //                 title: 'Setting gagal disimpan',
    //                 text: 'Mohon untuk refresh browser anda!',
    //                 showConfirmButton: false,
    //                 timer: 2500
    //             });
    //             // console.log('User Chat Token Error'+ err);
    //         },
    //     });
    // }

    function initFirebaseMessaging() {
            messaging
            .requestPermission()
            .then(function () {
                return messaging.getToken()
            })
            .then(function(token) {
                console.log(token);
                deviceToken = token;

                if(token == "{{ Auth::user()->firebase_token }}" && "{{ Auth::user()->notification }}" == 1){
                    console.log('podo');
                    $('#systemNotification').prop('checked', true);
                }
                else{
                    console.log('bedo');
                    $('#systemNotification').prop('checked', false);
                }

            }).catch(function (err) {
                console.log('User Chat Token Error'+ err);
            });
     }

    messaging.onMessage(function(payload) {
        Swal.fire({
            icon: 'success',
            title: payload.notification.title,
            text: payload.notification.body,
            showConfirmButton: true,
        });
        const noteTitle = payload.notification.title;
        const noteOptions = {
            body: payload.notification.body,
            icon: payload.notification.icon,
        };
        new Notification(noteTitle, noteOptions);
    });

    function testMessage(){
        let url = "{{ route('test-message') }}";
        let request = $.ajax({
            url: url,
            type: 'GET',
            dataType: 'html',
            success: function(response){
                // Swal.fire({
                //     position: 'top-end',
                //     icon: 'success',
                //     title: 'Terkirim',
                //     showConfirmButton: false,
                //     timer: 1500
                // });
            },
            error: function(err){
                Swal.fire({
                    position: 'top-end',
                    icon: 'error',
                    title: 'Gagal terkirim',
                    showConfirmButton: false,
                    timer: 2500
                });
            }
        });
    }
</script> --}}
@stack('js')
@yield('js')