<div class="page-margin">
    <div class="row">
        <div class="col-md-2 leftcol"><?php echo Wo_LoadPage("sidebar/left-sidebar"); ?></div>
        <div class="col-md-7 singlecol" data-page-type="watch">
			<div class="page-margin mt-0">
				<div class="wow_content popular_posts_hdr">
					<h2><svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5 19V19C5 20.6569 6.34315 22 8 22H16C17.6569 22 19 20.6569 19 19V19M5 5V5C5 3.34315 6.34315 2 8 2H16C17.6569 2 19 3.34315 19 5V5M14.0031 13.3313L12.4875 14.3417C11.6795 14.8804 11.2754 15.1497 10.9404 15.1297C10.6485 15.1123 10.3789 14.968 10.2025 14.7348C10 14.4671 10 13.9815 10 13.0104V10.9896C10 10.0185 10 9.53288 10.2025 9.26521C10.3789 9.03202 10.6485 8.88772 10.9404 8.87029C11.2754 8.85029 11.6795 9.11964 12.4875 9.65835L14.0031 10.6687C14.6708 11.1138 15.0046 11.3364 15.1209 11.6169C15.2227 11.8622 15.2227 12.1378 15.1209 12.3831C15.0046 12.6636 14.6708 12.8862 14.0031 13.3313Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><rect x="2" y="5" width="20" height="14" rx="4" class="icon_main" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></rect></svg>&nbsp;<?php echo $wo['lang']['watch']; ?></h2>
				</div>
			</div>

            <div class="watch_posts">
                <?php
                $stories = Wo_GetPosts(array('filter_by' => 'local_video','not_monetization' => true));
                if (count($stories) <= 0) {
                    echo Wo_LoadPage('watch/no-watch-videos');
                } else {
                    foreach ($stories as $wo['story']) {
                        echo Wo_LoadPage('story/content');
                    }
                }
                ?>
            </div>
            <?php if (count($stories) > 0) { ?>
            <div class="load-more pointer" id="load-more-posts" onclick="Wo_GetMoreWatchPosts();">
                <span class="btn btn-default">
                    <i class="fa fa-chevron-circle-down progress-icon" data-icon="chevron-circle-down"></i> &nbsp;<?php echo $wo['lang']['load_more_posts'];?>
                </span>
            </div>
            <?php } ?>
        </div>
    </div>
</div>
<script>
    var scrolledW = 0;
    $(function () {
        $(window).scroll(function () {
          var nearToBottom = 100;
          if($('.watch_posts').length > 0) {
              if ($(window).scrollTop() + $(window).height() > $(document).height() - nearToBottom) {
                if (scrolledW == 0) {
                   scrolledW = 1;
                   Wo_GetMoreWatchPosts();
                }
              }
          }
        });
    });

    function Wo_GetMoreWatchPosts() {
        var after_post_id = $('div.post:last').attr('data-post-id');
        $('.watch_posts').append('<div class="hidden loading-status loading-single"></div>');
          $('#load-more-posts').hide();
          $('.loading-status').hide().html('<div class="wo_loading_post"><div class="wo_post_skel_head"><div class="skel skel_avatar"></div><div><div class="skel skel_noti_name"></div><div class="skel skel_noti_time"></div></div></div><div class="wo_post_skel_body"><div class="skel skel_desc"></div><div class="skel skel_desc"></div><div class="skel skel_desc"></div></div><div class="wo_post_skel_foot"><div class="skel skel_action"></div><div class="skel skel_action"></div><div class="skel skel_action"></div></div></div>').removeClass('hidden').show();
          Wo_progressIconLoader($('#load-more-posts'));

        $.get(Wo_Ajax_Requests_File(), {
            f: 'watch',
            s: 'load_more_posts',
            after_post_id: after_post_id
          }, function (data) {
            if (data.length == 0) {
              $('body').attr('no-more-posts', "true");
              $('#load-more-posts').html('<div class="white-loading list-group"><div class="cs-loader"><div class="no-more-posts-to-show">' + $('#get_no_posts_name').val() + '</div></div>');
              scrolledW = 1;
            }
            else{
                $('body').removeAttr('no-more-posts');
                $('.watch_posts').append(data);
                scrolledW = 0;
            }
            $('#load-more-posts').show();
            $('.loading-status').remove();
            Wo_progressIconLoader($('#load-more-posts'));
                
        });
    }

    <?php if(isset($wo['single_story'])) { ?>
    var single_post_id = <?php echo $wo['single_story']->id;?>;
    setTimeout(() => {
        Wo_CloseLightbox()
        Wo_OpenLightBox(single_post_id)}, 100)
    <?php } ?>
</script>

