<style type="text/css">
.gallery-item img {
      border-radius: 10px;
}

.disabled-color {
    cursor: not-allowed;
    background: #d3d3d3 !important;
    border: #d3d3d3 !important;
}



@media (max-width:576px) {
 .gallery-item img {
      width: 100%;
      height: 112px;
      border-radius: 10px;
    }

    .gallery-wrapper {
        margin-bottom: 220px;
    }

    .mobile-hide {
        display: none;
    }

    .mobile-show {
        display: block !important;
    }
}
</style>

<div class="body-content">

    <div class="top-area">
        <div class="search-box d-flex flex-wrap align-items-center">
            <h3 class="title d-none d-lg-block text-black">Album</h3>
        </div>
   
  
        <div class="flex-wrap justify-content-end align-items-center gap-4  d-none d-lg-flex filter-margin-bottom">
            <select class="form-select form--control ps-4 pe-5 w-auto" id="photoVideo" style="border-radius: 5px !important; cursor: pointer;">
                <option value="photos">Photos</option>
                <option value="videos">Videos</option>
            </select>
        </div>
        <ul class="nav-tabs nav justify-content-center mb-30 cmn--tabs d-lg-none">
            <li><a href="#photos" data-bs-toggle="tab" class="active">Photos</a></li>
            <li><a href="#videos" data-bs-toggle="tab">Videos</a></li>
        </ul>
    </div>
    <div class="tab-content" style="margin-bottom: 50px;"> 
        <?php 
            $paidUCount;
            foreach($paidusercount as $paidkey => $paidval){
              $paidUCount = $paidval['paidUserCount'];
            }
        ?>

        <div class="tab-pane fade  show active" id="photos">
            <div class="gallery-wrapper row gx-3 gx-sm-2 gallery-y-gap" id="lightgallery">
                <?php 
                if(count($album_list) > 0)
                {
                    foreach($album_list as $key => $val) 
                    { 
                       $file_url = explode('.', $val['process_file_url']);
                       if($file_url[1] != "mp4")
                       {

                            if($paidUCount == 0) 
                            {
                                $file_url = $val['process_file_url'];
                            } 
                            else 
                            {
                                $file_url = $val['staff_file_url'];
                            }

                            $file_url_set = 'https://d38x82mkkml5o1.cloudfront.net/'.$file_url;

                            if($val['isImage'] == 1)
                            {
                                if($paidUCount > 0)
                                {
                                    $downloadURL = "https://d38x82mkkml5o1.cloudfront.net/".$val['process_file_url'];
                                }
                                else
                                {
                                    $downloadURL = "https://d38x82mkkml5o1.cloudfront.net/".$val['staff_file_url'];
                                }   
                            }
                            else
                            {
                                if($paidUCount == 0)
                                {
                                    $downloadURL = "https://d38x82mkkml5o1.cloudfront.net/".$val['process_file_url'];
                                }
                                else
                                {
                                    $downloadURL = "https://d38x82mkkml5o1.cloudfront.net/".$val['staff_file_url'];
                                }       
                            }
                    ?>
                    <div class="col-lg-6 col-xl-4 col-6">
                        <div class="gallery-item position-relative">
                            
                                <a style="width: 100%;" data-download-url="<?=$downloadURL?>" href="<?=$file_url_set?>" >

                                <img style="cursor: pointer;object-fit: cover;max-height: 369px;"  onclick="show_func(<?php echo $val["id"];?>,<?php echo $paidUCount ?>)" src="http://d38x82mkkml5o1.cloudfront.net/<?php
                                                if($paidUCount == 0) 
                                                {
                                                    echo $val['process_file_url'];
                                                } 
                                                else 
                                                {
                                                    echo $val['staff_comp_file_url'];
                                                }
                                                                            
                                                    ?>" alt="GL Clix">
                                </a>

                            

                            <input type="checkbox" name="album_chk_id_pop[]" class="position-absolute d-lg-none getALLImage" data-type="1" id="<?php echo $val["id"];?>" data-val="<?php echo $paidUCount ?>" style="right: 9px; bottom: 9px" id="check01">
                        </div>
                    </div>

                    <?php }
                    }
                }
                ?>            
            </div>
        </div>



        <div class="tab-pane fade" id="videos">
            <div class="gallery-wrapper row gx-3 gx-sm-2 gallery-y-gap" id="lightgalleryVideo">
                <?php 
                if(count($album_list) > 0)
                {
                    foreach($album_list as $key => $val) 
                    { 
                       $file_url = explode('.', $val['process_file_url']);
                       if($file_url[1] == "mp4")
                       {

                            $file_url = $val['staff_comp_file_url'];

                            $file_url_set = 'http://d38x82mkkml5o1.cloudfront.net/'.$file_url;

                            if($val['isImage'] == 1)
                            {
                                if($paidUCount > 0)
                                {
                                    $downloadURL = "https://d38x82mkkml5o1.cloudfront.net/".$val['process_file_url'];
                                }
                                else
                                {
                                    $downloadURL = "https://d38x82mkkml5o1.cloudfront.net/".$val['staff_file_url'];
                                }   
                            }
                            else
                            {
                                if($paidUCount == 0)
                                {
                                    $downloadURL = "https://d38x82mkkml5o1.cloudfront.net/".$val['process_file_url'];
                                }
                                else
                                {
                                    $downloadURL = "https://d38x82mkkml5o1.cloudfront.net/".$val['staff_file_url'];
                                }       
                            }

                    ?>
                        <div class="col-lg-6 col-xl-4 col-6">
                            <div class="gallery-item video-item">
                                <div class="bg-overlay" style="cursor: pointer;">
                                    <a style="width: 100%;" data-lg-size="1080-720" data-download-url="<?=$val['id']?>"
                                        data-video='{"source": [{"src":"<?=$downloadURL?>", "type":"video/mp4"}], "attributes": {"preload": false, "controls": true}}'
                                        data-poster="http://d38x82mkkml5o1.cloudfront.net/<?php echo $val['process_comp_file_url'];?>"
                                        data-sub-html="">

                                        <img style="cursor: pointer;object-fit: cover;max-height: 369px;" src="http://d38x82mkkml5o1.cloudfront.net/<?php echo $val['process_comp_file_url'];?>" alt="GL Clix">

                                         <div href="javascript:;" onclick="show_func_video(<?php echo $val["id"];?>,<?php echo $paidUCount ?>)"  class="create-video text-center video-icon style--two">
                                        <i class="fas fa-play"></i>
                                    </div>
                                    </a>

                                    <input type="checkbox"  name="album_chk_id_pop_video[]" class="position-absolute d-lg-none getALLImage" data-type="2" id="<?php echo $val["id"];?>" data-val="<?php echo $paidUCount ?>" style="right: 9px; bottom: 11px" id="check01">
                                </div>
                            </div>
                        </div>

                 <?php }
                    }
                }
                ?> 
            </div>
        </div>
    </div>
</div>



    <div class="gallery-select-options d-flex justify-content-between">
        <span class="close-selection"><img src="<?php echo base_url();?>files/assets/images/icon/close.png" alt="icon"></span>
        <span><span class="selectedGalleryCount">0</span> Items Selected</span>
        <span class="check-all"><img src="<?php echo base_url();?>files/assets/images/icon/tasks.png" alt="icon"></span>
    </div>

    <div class="bottom-button-wrapper d-flex flex-column gap-2">
        
        <button class="cmn--btn d-block w-100 mt-sm-4 MultipleDownload MultipleDownloadProcess" id="1" type="button">Download</button>
        <button class="cmn--btn d-block w-100 mt-sm-4 MultipleDownload MultipleDownloadShare"  id="2" type="button">Share</button>
        <!-- <button data-bs-toggle="modal" data-bs-target="#shareModalOne" class="cmn--btn d-block w-100 active mb-2 mb-sm-0">Share</button> -->
    </div>

   
    <div class="modal fade" id="galleryModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content bg-transparent border-0">
                <div class="modal-body p-0">
                    <div class="popup-wrapper">
                        <div class="gallery-item style--two ">
                            <img id="getImageLink" style="height: auto;" src="<?php echo base_url();?>files/assets/images/thumb/gallery-modal01.png" alt="thumb">
                            <a href="" id="getDownloadImage"  target="_blank" onclick="getdownloadMyPhoto()" class="cmn--btn d-block w-100 mt-sm-4">Download</a>
                            <button id="getShareImage" data-url="" onclick="getShareMyPhoto()" style="background: #173f78;color: #fff;" class="cmn--btn d-block w-100 mb-2 mb-sm-0">Share</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <div class="modal fade" id="videoModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content bg-transparent border-0">
                <div class="modal-body p-0">
                    <div class="popup-wrapper">
                        <div class="gallery-item style--two">
                            <div class="gallery-item video-item mb--30">
                                <div class="bg-overlay" id="getVideoPreview">

                                    <img class="mb-0" src="<?php echo base_url();?>files/assets/images/thumb/video-modal1.png" alt="thumb">
                                    <a href="#0" class="create-video text-center video-icon style--two">
                                        <i class="fas fa-play"></i>
                                    </a>

                                </div>
                            </div>

                            <a href="" id="getDownloadVideo" target="_blank" onclick="getdownloadMyvideo()" download="" data-url="" class="cmn--btn w-100 mt-sm-4 mobile-hide">Download</a>

                            <button id="getShareVideoDownload" onclick="getdownloadMyvideoMobile()" data-url="" class="cmn--btn w-100 mt-sm-4 mobile-show" style="display: none;">Download</button>

                            <button id="getShareVideo" data-url="" onclick="getShareMyVideo()" style="background: #173f78;color: #fff;"  class="cmn--btn d-block w-100 mb-sm-0 mb-2 active">Share</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>



 <div class="modal fade" id="AddProfile" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content bg-transparent border-0">
            <div class="modal-body p-0">
                <div class="popup-wrapper">
                    <div class="gallery-item style--two">
                        <div class="gallery-item video-item mb--30">
                            <div class="text-center">
                                <img src="<?=base_url('files/assets/images/thumb/imgpsh_fullsize_anim(1).gif')?>" style="height: 92px;width: auto;" alt="thumb" class="mw-100">
                                <h4 class="mb-4 mb-sm-5 mt-4">Add Your Selfie</h4>
                            </div>
                        </div>
                        <a href="<?=base_url('face-recognition/'.$userdata['id'])?>" class="cmn--btn d-block w-100 mt-sm-4">Continue</a>
                        <button class="cmn--btn d-block w-100 mb-sm-0 mb-2 active CloseAddFace" type="button" style="margin-bottom: 4px !important; color: #000 !important;">Close</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<span id="getMultipleDownload" style="display: none;"></span>

<script src="<?php echo base_url();?>files/assets/js/lib/jquery-3.6.0.min.js"></script>


<script type="text/javascript">

<?php 
    if(empty($totalFaceUpload))
    {
    ?>
    
        setTimeout(function(){
            $('#AddProfile').modal('show');
        }, 1000);

        $('body').delegate('.CloseAddFace', 'click', function() {
             $('#AddProfile').modal('hide');
        });

<?php }
?>

  
     
    $('body').delegate('.lg-download', 'click', function(e) {
        e.preventDefault();
        var url = $(this).attr('href');
        var extension = getUrlExtension(url);
        if($.isNumeric(url))
        {
            TotalidsAlbum = url;
            SiteDataStore('Download', 'Video');   
            $.ajax({
                method: "POST",
                url: "https://makeabl.net/api/make_zip",
                data: {
                    images: TotalidsAlbum
                },
                dataType: 'json',
            }).done((res) => {
               
                window.location.href = res.message;                           
            });    
        }
        else
        {
            SiteDataStore('Download', 'Photo');    
            window.open(url, '_blank');
        }

         // window.location.href = url;
        
    });

    $('body').delegate('.lg-share', 'click', function(e) {
        e.preventDefault();
        var url = $(this).attr('href');
        var extension = getUrlExtension(url);
        if(extension == 'mp4')
        {
            getShareMyVideo(url) 
        }
        else
        {
            getShareMyPhoto(url) 
        }
        
    });



    function getUrlExtension(url) 
    {
          var filename = url.split('/').pop();
          var extension = filename.split('.').pop();
          return extension;
    }
    

    $('.MultipleDownload').click(function() {
        $('#getMultipleDownload').html('');
        var id_type = $(this).attr('id');
        var TotalidsAlbum = '';
        var Totalids = '';
        var SiteData = '';
        if(id_type == 1)
        {
            $('.MultipleDownloadProcess').html('Processing...');
            $('.MultipleDownloadProcess').prop("disabled", true); 
            $('.MultipleDownloadProcess').addClass("disabled-color"); 

            var timeout = 1500;
            $('.getALLImage').each(function() {
                if(this.checked)
                {
                    var edit_id = $(this).attr('id');
                    var type = $(this).attr('data-type');
                    TotalidsAlbum += edit_id+',';

                    if(type == 1)
                    {
                        SiteData += edit_id+'-Download-Photo,';
                    }
                    else
                    {
                        SiteData += edit_id+'-Download-Video,';
                    }
                }
            });
            
            if(TotalidsAlbum != "")
            {      
                $.ajax({
                    method: "POST",
                    url: "https://makeabl.net/api/make_zip",
                    data: {
                        images: TotalidsAlbum
                    },
                    dataType: 'json',
                }).done((res) => {

                    var downloadURL = res.message;

                    $.ajax({
                        method: "POST",
                        url: "<?php echo base_url(); ?>GalleryController/downloadSharePhotoVideo",
                        data: {
                            images: SiteData,
                        },
                        dataType: 'json',
                    })
                    .done(function (res) 
                    {   
                        $('.MultipleDownloadProcess').html('Download');     
                        $('.MultipleDownloadProcess').prop("disabled", false);     
                        $('.MultipleDownloadProcess').removeClass("disabled-color"); 
                        window.location.href = downloadURL;                        
                    });                        
                });                         
            }           
        }
        else if(id_type == 2)
        {
            var totalShare = 0;
            $('.MultipleDownloadShare').html('Processing...');
            $('.MultipleDownloadShare').prop("disabled", true); 
            $('.MultipleDownloadShare').addClass("disabled-color"); 


            $('.getALLImage').each(function() {
                if(this.checked)
                {
                    var edit_id = $(this).attr('id');
                    var paidUCount = $(this).attr('data-val');
                    var type = $(this).attr('data-type');
                    Totalids += edit_id+'-'+paidUCount+'-'+type+',';

                    if(type == 1)
                    {
                        SiteData += edit_id+'-Share-Photo,';
                    }
                    else
                    {
                        SiteData += edit_id+'-Share-Video,';
                    }
                    
                    TotalidsAlbum += edit_id+',';                    
                    totalShare = totalShare + 1;
                }
            });

            if(totalShare > 20)
            {
                $.ajax({
                    method: "POST",
                    url: "https://makeabl.net/api/make_zip",
                    data: {
                        images: TotalidsAlbum
                    },
                    dataType: 'json',
                }).done((res) => {
                    var ShareURL = res.message;
                    $.ajax({
                        method: "POST",
                        url: "<?php echo base_url(); ?>GalleryController/downloadSharePhotoVideo",
                        data: {
                            images: SiteData,
                        },
                        dataType: 'json',
                    })
                    .done(function (res) 
                    {   
                        $('.MultipleDownloadShare').html('Share');     
                        $('.MultipleDownloadShare').prop("disabled", false); 
                        $('.MultipleDownloadShare').removeClass("disabled-color"); 
                        ShareLink(ShareURL)                     
                    });                       
                }); 
            }
            else
            {
                $.ajax({
                    method: "POST",
                    url: "<?php echo base_url(); ?>GalleryController/downloadShareFile",
                    data: {
                        ids: Totalids,
                    },
                    dataType: 'json',
                })
                .done(function (res) 
                {            
                    $('.MultipleDownloadShare').html('Share');
                    $('.MultipleDownloadShare').prop("disabled", false); 
                    $('.MultipleDownloadShare').removeClass("disabled-color"); 
                    getShareMyPhotoMultiple(res.success);
                });    
            }
        }
        
    });

    async function getShareMyPhotoMultiple(res) 
    {   
        console.log(res);

        var MultifilesArray = [];
        var i;
        for (i = 0; i < res.length; ++i) {
            
                const response = await fetch(res[i].name);
                const blob = await response.blob();
                if(res[i].type == 1)    
                {
                    const filesArray =
                    new File(
                              [blob],
                              'Glclix.jpg',
                              {
                                type: "image/jpeg",
                                lastModified: new Date().getTime()
                              }
                           );

                    MultifilesArray.push(filesArray);
                }                
                else
                {
                    const filesArray =
                    new File(
                          [blob],
                          'Glclix.mp4',
                          {
                            type: "video/mp4",
                            lastModified: new Date().getTime()
                          }
                    );    
                    MultifilesArray.push(filesArray);
                }
                
                
        }

        const shareData = {
            files: MultifilesArray
        }

        try 
        {
            navigator.share(shareData)
        } 
        catch (err) 
        {
            
        }
        

    }

    function show_func_video(edit_id, paidUCount) 
    {
        var checked_items = document.querySelectorAll("input[name='album_chk_id_pop_video[]']:checked").length;
        // var screen_width = screen.width;
        if(checked_items == 0)
        {
            $.ajax({
                method: "POST",
                url: "<?php echo base_url();?>GalleryController/get_album_info",
                data: {
                    edit_id: edit_id
                }
            })
            .done(function(msg) {
                var json_obj = JSON.parse(msg);
                var shtml = '';
                let footer = "";
                let url =" <?php echo base_url();?>gallery/download";
                let func_name = "";
                let downloadURL;
                
                if(paidUCount == 0) {
                    downloadURL = "https://d38x82mkkml5o1.cloudfront.net/"+json_obj.process_file_url;
                } else {
                    downloadURL = "https://d38x82mkkml5o1.cloudfront.net/"+json_obj.staff_file_url;
                }
                
                var downurl = "<?php echo base_url();?>GalleryController/download_video/"+edit_id+"/"+paidUCount;
                
        
                shtml += '<video width="100%" controls autoplay>';

                if(json_obj.isImage == 1)
                {
                    if(paidUCount > 0)
                    {
                        shtml += '<source src="https://d38x82mkkml5o1.cloudfront.net/'+json_obj.process_file_url+'" type="video/mp4">';
                        downloadURL = "https://d38x82mkkml5o1.cloudfront.net/" + json_obj.process_file_url;
                    } 
                    else 
                    {
                        shtml += '<source src="https://d38x82mkkml5o1.cloudfront.net/'+json_obj.staff_file_url+'" type="video/mp4">';
                        downloadURL = "https://d38x82mkkml5o1.cloudfront.net/" + json_obj.staff_file_url;
                    }
                }
                else
                {
                    if(paidUCount == 0)
                    {
                        shtml += '<source src="https://d38x82mkkml5o1.cloudfront.net/'+json_obj.process_file_url+'" type="video/mp4">';
                        downloadURL = "https://d38x82mkkml5o1.cloudfront.net/" + json_obj.process_file_url;
                    } 
                    else 
                    {
                        shtml += '<source src="https://d38x82mkkml5o1.cloudfront.net/'+json_obj.staff_file_url+'" type="video/mp4">';
                        downloadURL = "https://d38x82mkkml5o1.cloudfront.net/" + json_obj.staff_file_url;
                    }
                }
                    
                shtml += '</video>';

                $('#getVideoPreview').html(shtml);
                
                
                
                // $.ajax({
                //     method: "POST",
                //     url: "<?php echo base_url();?>GalleryController/download_video_ajax",
                //     data: {
                //         edit_id: edit_id,
                //         paidUCount : paidUCount,
                //     },
                //     dataType: 'json',
                // })
                // .done(function(responseRe) {          
                    // $('#getDownloadVideo').attr('href', responseRe.url);
                    // $('#getShareVideo').attr('data-url', downloadURL);
                    // $('#getShareVideoDownload').attr('data-url', downloadURL);
                    // $('#videoModal').modal('show');
                // });


                 
                // $('#getDownloadVideo').attr('href', downurl);
                // $('#getShareVideo').attr('data-url', downloadURL);
                // $('#videoModal').modal('show');

            });

        }
    }

    function show_func(edit_id, paidUCount)
    {

        var checked_items = document.querySelectorAll("input[name='album_chk_id_pop[]']:checked").length;
        // var screen_width = screen.width;
        if(checked_items == 0)
        {

            $.ajax({
                method: "POST",
                url: "<?php echo base_url();?>GalleryController/get_album_info",
                data: {
                    edit_id: edit_id
                }
            })
            .done(function(msg) {
                var json_obj = JSON.parse(msg);
                var shtml = '';
                let footer = "";
                let url =" <?php echo base_url();?>gallery/download";
                let func_name = "";
                let downloadURL;
                
                if(paidUCount == 0) {
                    downloadURL = "https://d38x82mkkml5o1.cloudfront.net/"+json_obj.process_file_url;
                } else {
                    downloadURL = "https://d38x82mkkml5o1.cloudfront.net/"+json_obj.staff_file_url;
                }
                
                var downurl = "<?php echo base_url();?>GalleryController/download_video/"+edit_id+"/"+paidUCount;
                
                if(json_obj.isImage == 1)
                {
                    if(paidUCount > 0) 
                    {
                        
                        downloadURL = "https://d38x82mkkml5o1.cloudfront.net/" + json_obj.process_file_url;
                    }
                    else
                    {
                        downloadURL = "https://d38x82mkkml5o1.cloudfront.net/" + json_obj.staff_file_url;  
                    }

                    $('#getImageLink').attr('src', downloadURL);
                    $('#getShareImage').attr('data-url', downloadURL);
                    
                }
                else if(json_obj.isImage == 0)
                {
                    if(paidUCount == 0) 
                    {
                       downloadURL = "http://d38x82mkkml5o1.cloudfront.net/"+json_obj.process_file_url;
                    } 
                    else 
                    {
                        downloadURL = "http://d38x82mkkml5o1.cloudfront.net/"+json_obj.staff_file_url;
                    }

                    $('#getImageLink').attr('src', downloadURL);
                    $('#getShareImage').attr('data-url', downloadURL);
                }
                 
                //  $.ajax({
                //     method: "POST",
                //     url: "<?php echo base_url();?>GalleryController/download_video_ajax",
                //     data: {
                //         edit_id: edit_id,
                //         paidUCount : paidUCount,
                //     },
                //     dataType: 'json',
                // })
                // .done(function(responseRe) {                    
                //     $('#getDownloadImage').attr('href', responseRe.url);
                    // $('#galleryModal').modal('show');
                // });

            });
        }
    }


     function getShareMyPhoto(url = '') 
     {
            SiteDataStore('Share', 'Photo');
            if(url != '')
            {
                var dataID = url;    
                $(".lg-share").addClass("lg-share-green");
            }
            else
            {
                var dataID = $("#getShareImage").attr('data-url');
            }
            

            $.ajax({
                method: "POST",
                url: "<?php echo base_url(); ?>GalleryController/downloadShareFileSingle",
                data: {
                    dataID: dataID,
                    type:1
                },
                dataType: 'json',
            })
            .done(function (res) 
            {   
                getShareMyPhotoMultiple(res.success);
                $(".lg-share").removeClass("lg-share-green");                        
            });   

            // const shareData = {
            //     title: 'glclix.co',
            //     text: '',
            //     url: dataID
            // }

            // const btn = document.querySelector('.share_button');
            // try {
            //         navigator.share(shareData)
            // } catch (err) {
            //         resultPara.textContent = 'Error: ' + err
            // }
            
            //  $.ajax({
            //     method: "POST",
            //     url: "<?php echo base_url(); ?>GalleryController/share_count_click",
            //     data: {
            //         guest_id: "<?php echo $guest_detail['id'];?>"
            //     }
            // })
            // .done(function (res) {
            //     if (res["result"] = "success") {
            //         $('#msg').html("Success");
            //     } else {
            //         $('#msg').html("Failed please try again.");
            //     }
            // });
    }


    async function getShareMyVideoMultiple(res) 
    {   
        var MultifilesArray = [];
        var i;
        for (i = 0; i < res.length; ++i) {
                const response = await fetch(res[i]);
                const blob = await response.blob();
                
                const filesArray =
                    new File(
                          [blob],
                          'Glclix.mp4',
                          {
                            type: "video/mp4",
                            lastModified: new Date().getTime()
                          }
                       );

                MultifilesArray.push(filesArray);
        }

        const shareData = {
            files: MultifilesArray
        }

        try 
        {
            navigator.share(shareData)
        } 
        catch (err) 
        {
            
        }
    }



     function getdownloadMyvideoMobile() {

            SiteDataStore('Download', 'Video');
            var dataID = $("#getShareVideoDownload").attr('data-url');
            $('#getShareVideoDownload').html('Processing...');

            $.ajax({
                method: "POST",
                url: "<?php echo base_url(); ?>GalleryController/downloadShareFileSingleVideo",
                data: {
                    dataID: dataID,
                },
                dataType: 'json',
            })
            .done(function (res) 
            {            
                 $('#getShareVideoDownload').html('Download');
                  getShareMyVideoMultiple(res.success);
            });   

       
     }




     function getShareMyVideo(url = '') {

            SiteDataStore('Share', 'Video');
            if(url != '')
            {
                var dataID = url;
                $(".lg-share").addClass("lg-share-green");    
            }
            else
            {
                var dataID = $("#getShareVideo").attr('data-url');    
            }
            


            $.ajax({
                method: "POST",
                url: "<?php echo base_url(); ?>GalleryController/downloadShareFileSingleVideo",
                data: {
                    dataID: dataID,
                },
                dataType: 'json',
            })
            .done(function (res) 
            {            
                   getShareMyVideoMultiple(res.success);
                   $(".lg-share").removeClass("lg-share-green");    
            });   

            // SiteDataStore('Share', 'Video');
            // var dataID = $("#getShareVideo").attr('data-url');
            // console.log(dataID);

            // const shareData = {
            //     title: 'glclix.co',
            //     text: '',
            //     url: dataID
            // }

            // const btn = document.querySelector('.share_button');
            // try {
            //         navigator.share(shareData)
            // } catch (err) {
                    
            // }


            
            // $.ajax({
            //     method: "POST",
            //     url: "<?php echo base_url(); ?>GalleryController/share_count_click",
            //     data: {
            //         guest_id: "<?php echo $guest_detail['id'];?>"
            //     }
            // })
            // .done(function (res) {
            //     if (res["result"] = "success") {
            //         $('#msg').html("Success");
            //     } else {
            //         $('#msg').html("Failed please try again.");
            //     }
            // });
        }


        function ShareLink(dataID) 
        {
            const shareData = {
                title: 'glclix.co',
                text: '',
                url: dataID
            }

            try {
                navigator.share(shareData)
            } catch (err) {
                    
            }
        }


        function getdownloadMyPhoto() 
        {

            SiteDataStore('Download', 'Photo');

            // $.ajax({
            //     method: "POST",
            //     url: "<?php echo base_url(); ?>GalleryController/count_click",
            //     data: {
            //         guest_id: "<?php echo $guest_detail['id'];?>"
            //     }
            // })
            // .done(function (res) {
            //     if (res["result"] = "success") {
            //     } else {
                
            //     }
            // });
        }
            
        function getdownloadMyvideo() 
        {        

            SiteDataStore('Download', 'Video');

            // $.ajax({
            //     method: "POST",
            //     url: "<?php echo base_url(); ?>GalleryController/count_video_click",
            //     data: {
            //         guest_id: "<?php echo $guest_detail['id'];?>",
            //         video_url:$('#getDownloadVideo').data('url')
            //     }
            // })
            // .done(function (res) 
            // {            
            //     if (res["result"] = "success") {
                   
            //     } else {
                   
            //     }
            // });
        }


        function SiteDataStore(type, desc) 
        {
            $.ajax({
                    url : '<?=base_url()?>SiteDataStoreController/SiteDataStore',
                    type : 'POST',
                    data : {
                        id: '',
                        type : type,
                        desc : desc,
                    },
                    success : function(msg){
                      
                    }
                });

        }
    
            
</script>