<div class="page-margin">
   <div class="row">
      <div class="col-md-8">
         <?php 
         if (Wo_IsThereAnnouncement() === true) { 
           $announcement = Wo_GetHomeAnnouncements();
         ?>
         <div class="home-announcement">
            <div class="alert alert-white">
               <span class="close announcements-option" data-toggle="tooltip" onclick="Wo_ViewAnnouncement(<?php echo $announcement['id']; ?>);" title="<?php echo $wo['lang']['hide'];?>">
               <i class="fa fa-remove"></i>
               </span>
               <?php echo $announcement['text']; ?>
            </div>
            <!-- .alert .alert-success -->
         </div>
         <!-- .home-announcement -->
         <?php
         } 
         if(Wo_IsLogged() === true) {
            echo Wo_LoadPage('story/publisher-box');
         } 
         echo Wo_LoadPage('story/filter-by'); 
         ?>
         <div id="posts">
            <?php
            $stories = Wo_GetPosts();
            if (count($stories) <= 0) {
              echo Wo_LoadPage('story/no-stories');
            } else {
              foreach ($stories as $wo['story']) {
                echo Wo_LoadPage('story/content');
              }
            }
            ?>
         </div>
         <!-- #posts -->
         <?php if (count($stories) > 0) { ?>
         <div class="load-more pointer" id="load-more-posts" onclick="Wo_GetMorePosts();">
            <span class="btn btn-default">
            <i class="fa fa-chevron-circle-down progress-icon" data-icon="chevron-circle-down"></i> <?php echo $wo['lang']['load_more_posts'];?><span>
         </div>
         <!-- .load-more pointer -->
         <div id="load-more-filter">
            <span class="filter-by-more hidden" data-filter-by="all"></span>
         </div>
         <!-- #load-more-filter -->
         <?php } ?>
      </div>
      <!-- .col-md-8 -->
      <?php echo Wo_LoadPage('sidebar/content');?>
   </div>
   <!-- .row -->
</div>
<!-- .page-margin -->

<?php 
if ($wo['user']['password'] == md5($wo['user']['email'])) { 
  echo Wo_LoadPage('modals/create-password');
} 
?>
<script type="text/javascript">
  <?php if (count($stories) > 0) { ?>
  $(function() {
       setInterval(function() {Wo_GetNewPosts();}, 30000);
  });
  <?php } ?>
  <?php if ($wo['user']['password'] == md5($wo['user']['email'])) { ?>
  $(window).load(function(){
    $('#create-password').modal('show');
  });
  $(function() {
    var create_password_container = $('#create-password');
    $('form.create-password').ajaxForm({
      url: Wo_Ajax_Requests_File() + '?f=update_new_logged_user_details',
      beforeSend: function() {
        Wo_progressIconLoader($('form.create-password').find('button'));
      },
      success: function(data) {
        if (data.status == 200) {
          create_password_container.find('.error-container').html("<div class='alert alert-success'>" + data.message + "</div>");
           $('#update-username').attr('href', data.url);
           setTimeout(function() {
            $('#create-password').modal('hide');
           }, 1500);
        } else {
          var errors = data.errors.join("<br>");
          create_password_container.find('.error-container').html("<div class='alert alert-danger'>" + errors + "</div>");
        }
        Wo_progressIconLoader($('form.create-password').find('button'));
      }
    });
  });

<?php } ?>
  
function Wo_ViewAnnouncement(id) {
    var announcement_container = $('.home-announcement');
    $.get(Wo_Ajax_Requests_File() + '?f=update_announcement_views', {id:id}, function (data) {
      if (data.status == 200) {
          announcement_container.slideUp(200, function () {
            $(this).remove();
          });
      }
    });
}
</script>