<?php 
include('view/new_header_file.php');
?>

      <div class="container">
                <?php 
                include('view/stockwit.view.php');
                ?>
              
    </div>


<?php
include('view/new_footer_file.php');
?>

  <script type="text/javascript">
    function swFunc()
    {

       $(".swtwits").hide();
                $("#loader").show();

        
        var un = $("#usernamesw").val();

         $.post('controller/sw-search.controller.php', {username:un})
                    
            .done(function(data){

                 $(".swtwits").show();
                $("#loader").hide();

                var json_sw = JSON.parse(data);
              for (var i = 0; i < json_sw.length; i++) {
                  


                  var per_sw = json_sw[i];

                  var per_sw = JSON.parse(per_sw);

                  var name = per_sw['name'];

                  var username = per_sw['username'];

                  var img = per_sw['image'];

                  var body = per_sw['body'];

                  var created = per_sw['created'];

                  var imgid = "#swimage"+i;
                  var titleid = "#swtbody"+i;
                  var swdate = "#swdate"+i;
                  var un = "#un"+i;


                  $(imgid).attr('src', img);
                  $(titleid).html(body);
                  $(swdate).html(created);
                  $(un).html(name);


                  
              }


          });

    }
  </script>


   <script type="text/javascript">
      stockwit();
        setInterval(function(){
          stockwit();
        }, 60000);

          

          function stockwit()
          {

            $.post('controller/sw.controller.php', {})
                    
            .done(function(data){

               $(".swtwits").show();
                $("#loader").hide(); 

              var json_sw = JSON.parse(data);
              for (var i = 0; i < json_sw.length; i++) {
                  


                  var per_sw = json_sw[i];

                  var per_sw = JSON.parse(per_sw);

                  var name = per_sw['name'];

                  var username = per_sw['username'];

                  var img = per_sw['image'];

                  var body = per_sw['body'];

                  var created = per_sw['created'];

                  var imgid = "#swimage"+i;
                  var titleid = "#swtbody"+i;
                  var swdate = "#swdate"+i;
                  var un = "#un"+i;


                  $(imgid).attr('src', img);
                  $(titleid).html(body);
                  $(swdate).html(created);
                  $(un).html(name);


                  
              }

            });

          }
        </script>


