Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    115
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Problem with some bugs I have found

    Hi guys,

    I need your help. When I hired the PHP devloper, he created the list of code in my php which it seem to be a bit of mess. I have found some bugs that I need to get it fixing it asap.

    When I pressed on the keyboard right arrow button which it start to fire, I can see the first block start to change to blue from yellow and the next block will change from blue to yellow. When I pressed the right arrow button on the big block, it will move to the next page which it supposed to be stay on the first page. I believe the problem is somewhere in javascript.

    After when I pressed on the keyboard right arrow button on the big block, i pressed on the left arrow button of the keyboard, I can see that I will not be able to go back to the first page. This is only work on the small block.

    There is a missing text after when I pressed on the keyboard right arrow button on the big block, and the block size is come next to the channel blocks which it supposed to be get separate. I want to make them to get seperate. You will see it in the picture blockbugs.jpg.

    Here is the code:

    PHP Code:
    <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    >
    <
    html xmlns="http://www.w3.org/1999/xhtml">
    <
    head>
    <
    meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <
    script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    function GetXmlHttpObject()
    {
      if(window.XMLHttpRequest)
      {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
      }
      else
      {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
      }
      return null;
    }

    var current_col = 1;
    var current_row = 1;

    $(document).ready(function() {
      $("div").hide();
      $(".div_"+current_col+'_'+current_row).addClass( "yellowbg" );
      getAllChannels(); 
    });

    $(document).keyup(function(event){
    var yellowbg = $(".yellowbg");
    var rowwidth = $(".row").css( "width").split("px");
    var yellowbgdivclass = yellowbg.attr('class');
    var splitclass = yellowbgdivclass.split(" ");
    var getcurrentrow = splitclass[1].split("_");

    var mainWraptop = $(".mainWrap").position().top;
    var mainWrapheight = $(".mainWrap").height();
    var rowmove=$("#rowmove").val();
    //alert($(".row").length);
    var totalrowcount = 8;
    var displayrowcount = 6;
    var rowheight = 42;
    var rowwidth = 1053;
    var totalwidth_current = 0;
    var totalwidth_current1 = 0;

    if(parseInt(current_row)+parseInt(1) <=4)
    {
      for(var i=1; i<=(parseInt(current_row)+parseInt(1));i++ )
      {
        var yellowbgnextdivwidth = $(".div_"+current_col+'_'+i).css( "width"); 
        var yellowbgnextdivwidthsplit = yellowbgnextdivwidth.split("px");
        totalwidth_current=parseInt(totalwidth_current)+parseInt(yellowbgnextdivwidthsplit[0]);
      }
    }


      if (event.keyCode == 39) 
      {  //right
        if (yellowbg.next().length)
        {
          var currentrowleft = $(".rowSubPgm div.pgmFirstRow:first").css( "margin-left").split("px");
          currentrowleft1 = currentrowleft[0].split("-");
        
          if(typeof(currentrowleft1[1])!= "undefined")
            currentrowleft = currentrowleft1[1];
          else
            currentrowleft = currentrowleft[0];
                        
          var nextdivwidth = $(".div_"+current_col+'_'+(parseInt(current_row)+parseInt(1))).css( "width").split("px");    
                    
          //alert((parseInt(rowwidth)+parseInt(currentrowleft)));
          //alert(totalwidth_current);
          //alert((parseInt(rowwidth)+parseInt(currentrowleft)) < totalwidth_current);
          //alert(nextdivwidth);
          if((parseInt(rowwidth)+parseInt(currentrowleft)) < totalwidth_current)
          {
        $("body").find('.rowSubPgm').each(function(index) {
        $(this).find('.pgmFirstRow:first').css( "margin-left", "-"+rowwidth+"px" );
        });
        $(".rows div:nth-child(2)").css( "margin-left", "-"+parseInt(rowleft)-70 );
          }
          else if((parseInt(rowwidth)+parseInt(currentrowleft)) > totalwidth_current)
          {
        $("body").find('.rowSubPgm').each(function(index) {
        $(this).find('.pgmFirstRow:first').css( "margin-left", "-"+rowwidth+"px" );
        });
        $(".rows div:nth-child(2)").css( "margin-left", "-"+parseInt(rowleft)-170 );
          }
                          
          if(yellowbg.next().position().top == yellowbg.position().top)
          {
        $(".div_"+current_col+'_'+current_row).css( "margin-left", "-"+rowleft );
          }
          else
          {                
        currentrowleft = parseInt(currentrowleft)+rowwidth;
        var rowleft = currentrowleft+="px";
        $("body").find('.rowSubPgm').each(function(index) {
        $(this).find('.pgmFirstRow:first').css( "margin-left", "-"+rowleft );
        });
        $(".rows div:nth-child(2)").css( "margin-left", "-"+parseInt(rowleft)-70 );                
          }            
          current_row++;
        }
      }
      else if (event.keyCode == 37) 
      {   //left
        for(var i=2; i< parseInt(current_row);i++ )
        {
          var yellowbgnextdivwidth1 = $(".div_"+current_col+'_'+i).css( "width"); 
          var yellowbgnextdivwidthsplit1 = yellowbgnextdivwidth1.split("px");
          totalwidth_current1=parseInt(totalwidth_current1)+parseInt(yellowbgnextdivwidthsplit1[0]);
        }    
          var currentrowleft = $(".rowSubPgm div.pgmFirstRow:first").css( "margin-left").split("px");
          currentrowleft1 = currentrowleft[0].split("-");
          
          if(typeof(currentrowleft1[1])!= "undefined")
            currentrowleft = currentrowleft1[1];
          else
            currentrowleft = currentrowleft[0];
                    
          var currentdivwidth = yellowbg.css( "width").split("px");
                
          if(parseInt(currentrowleft) > totalwidth_current1 && parseInt(current_row) != 2)
          {
            //alert("-"+(parseInt(currentrowleft)-parseInt(currentdivwidth))+"px");
            
            if(currentdivwidth[0] == 517)
              currentdivwidth[0] = 533;
              $("body").find('.rowSubPgm').each(function(index) 
              {
              if(parseInt(current_row) == 3)
            $(this).find('.pgmFirstRow:first').css( "margin-left", "0px" );
          else
            $(this).find('.pgmFirstRow:first').css( "margin-left", "-"+(parseInt(currentdivwidth[0]))+"px" );
          });
          $(".rows div:nth-child(2)").css( "margin-left", "-"+parseInt(rowleft)-70 );
          
            if(currentdivwidth[0] == 1303)
            {
              alert("test");
            }
          }
          //yellowbg.prev().length
         /*var currentrowright = $(".mainWrap div.rowSubPgm .pgmFirstRow:first").css( "margin-left");
         var margin_right =currentrowright.replace('-', '').replace('px', '');
         
         if(margin_right > rowwidth)
         {
           currentrowright = parseInt(currentrowright)+rowwidth;
           var rowleft = currentrowright+="px";
           $("body").find('.rowSubPgm').each(function(index) {
           $(this).find('.pgmFirstRow:first').css( "margin-left", rowleft );
           });
           $(".rows div:nth-child(2)").css( "margin-left", rowleft);
         }
         else
         {
           $("body").find('.row').each(function(index) {
           $(this).find('.pgmFirstRow:first').css( "margin-left", "4px" );
           });
         }*/
         current_row--;
      }
      else if (event.keyCode == 38) 
      {  //up
        
        if(current_col > 1 && current_row == 1)
        {
          var currentrowtop = $(".mainWrap div.row:first-child").css( "margin-top");   
          var calcuatedrowtop = -(current_col*rowheight);
          currentrowtop = parseInt(currentrowtop)-rowheight;
          
          if((currentrowtop - calcuatedrowtop) < rowheight)
          {
         currentrowtop = parseInt(currentrowtop)+rowheight;
         currentrowtop = parseInt(currentrowtop)+rowheight;
         var rowtop = currentrowtop+="px";
         $(".mainWrap div.row:first-child").css( "margin-top", rowtop );            
          }
          current_col--;
        }
      }
      else if (event.keyCode == 40) 
      {    //down
        if(current_col < totalrowcount && current_row == 1)
        {
          if(current_col >= displayrowcount)
          {
            var currentrowtop = $(".mainWrap div.row:first-child").css( "margin-top");
            currentrowtop = parseInt(currentrowtop)-rowheight;
            var rowtop = currentrowtop+="px";
            $(".mainWrap div.row:first-child").css( "margin-top", rowtop );
          }
          current_col++;
        }
      }
      $('div').removeClass( "yellowbg" );
      //alert(".div_"+current_col+'_'+current_row);
      $(".div_"+current_col+'_'+current_row).addClass( "yellowbg" );
    });

    width=new Array();
    imagecontent = new Array();
    pgmcontent=new Array();

    var checksuminit = 0;
    var checksum = 0;
    function getAllChannels()
    {
      $.ajax({
      url:'get-listing.php',
      type:'POST',
      data:'',
      success: function(result)
      {
        var $doc = $(result);
        var i=1;
        $doc.filter('p#channels').each(function(index) {
        imagecontent[i] = $(this).html();
        i++;
      });
      var j=1;
      $doc.filter('#links').each(function(index) {
      var $link = $(this).html();
      $link1 = $link.replace("&amp;", "&"); 
      if($.trim($link1) !='')
      {
        checksuminit+=j;
        getSchule($link1,j);
      }
      j++;
      });
     }
    });
    }

    function getSchule($link,j)
    {
      //var widthval = 350;
      var widthval =  850;
      var parts = $link.split("/");
      var links = parts[parts.length-1];
      var programlength = 0;
        
      $.ajax({
      url:$.trim(links),
      type:'GET',
      data:'',
      success: function(data)
      {
        var $data = $(data);        
        var title1 = $data.filter("#title1").html();
        var title2 = $data.filter("#title2").html();
        var title3 = $data.filter("#title3").html();
        var title4 = $data.filter("#title4").html();
                
        var time1 = $data.filter("#time1").html();
        var time2 = $data.filter("#time2").html();
        var time3 = $data.filter("#time3").html();
        var time4 = $data.filter("#time4").html();
                
        time1 = time1.split(" ");
        var time1AMPM = time1[1];
        time1 = time1[0].split(":");
        time1= time1[0]+'.'+time1[1];
        if($.trim(time1AMPM) == 'PM' && time1<12)
        time1 = parseFloat(time1)+12;
                
        time2 = time2.split(" ");
        var time2AMPM = time2[1];
        time2 = time2[0].split(":");
        time2= time2[0]+'.'+time2[1];
        if($.trim(time2AMPM) == 'PM' && time2<12)
        time2 = parseFloat(time2)+12;
                
        time3 = time3.split(" ");
        var time3AMPM = time3[1];
        time3 = time3[0].split(":");
        time3= time3[0]+'.'+time3[1];
        if($.trim(time3AMPM) == 'PM' && time3<12)
        time3 = parseFloat(time3)+12;
                
        time4 = time4.split(" ");
        var time4AMPM = time4[1];
        time4 = time4[0].split(":");
        time4= time4[0]+'.'+time4[1];
        if($.trim(time4AMPM) == 'PM' && time4<12)
        time4 = parseFloat(time4)+12;
                
        var difftime2time1 = (parseFloat(time2) - parseFloat(time1)).toFixed(2);
        var difftime3time2 = (parseFloat(time3) - parseFloat(time2)).toFixed(2);
        var difftime4time3 = (parseFloat(time4) - parseFloat(time3)).toFixed(2);
                
        if(isNaN(difftime2time1))
        {
          difftime2time1=0;
        }
        if(isNaN(difftime3time2))
        {
          difftime3time2=0;
                }
        if(isNaN(difftime4time3))
        {
          difftime4time3=0;
        }
                        
        var currenttotal = 0;    
        var firstele = ((j-1)*3)+1;
        var lastele = parseInt(firstele)+2;
        var k=1;
        var programlength = 0;
        for(;firstele <= lastele;firstele++)
        {
          var nexttimedate = parseInt(k)+1;
          programlength = parseFloat(programlength) + parseFloat(eval('difftime'+nexttimedate+'time'+k));
          
          if((eval('difftime'+nexttimedate+'time'+k)) > 0.70 && (eval('difftime'+nexttimedate+'time'+k)) <=1.00 )
          {
            $('#programe'+firstele).addClass("span1hr");
            width[j]=517;
          }
          else if((eval('difftime'+nexttimedate+'time'+k)) > 1.00 && (eval('difftime'+nexttimedate+'time'+k)) <=1.30 )
          {
            $('#programe'+firstele).addClass("span1_5hr");
            width[j]=701;
          }
          else if((eval('difftime'+nexttimedate+'time'+k)) > 2.00 && (eval('difftime'+nexttimedate+'time'+k)) <=2.30 )
          {
            $('#programe'+firstele).addClass("span2hr");
            width[j]=1303;
          }
          else if((eval('difftime'+nexttimedate+'time'+k)) > 3.00 && (eval('difftime'+nexttimedate+'time'+k)) <=3.30 )
          {
            $('#programe'+firstele).addClass("span3hr");
            width[j]=1802;
          }
          else
          {
            width[j] = 250;
          }
          if(programlength == 1.00)
          {
            if(currenttotal==0)
            {
              $('#programe'+firstele).addClass("span1hr");
              width[j]=517;
            }
            else
            {
              $('#programe'+firstele).addClass("span0hr");
              width[j]=250;
            }            
          }
                      
          if(programlength >= 1.30)
          {
            if(currenttotal==0)
            {
              $('#programe'+firstele).addClass("span1_5hr");
              width[j]=701;
            }
            else
            {
              $('#programe'+firstele).addClass("span0hr");
              width[j]=250;
            }            
          }
              if(programlength == 2.00)
          {
            if(currenttotal==0)
            {
              $('#programe'+firstele).addClass("span2hr");
              width[j]=1303;
            }
            else
            {
              $('#programe'+firstele).addClass("span0hr");
              width[j]=250;
            }            
          }        
          currenttotal++;
          pgmcontent[firstele] = eval('title'+k);
          k++;        
        }
        checksum+=j;
                
        if(checksuminit == checksum)
        {
          for(var ii=1;ii<width.length-1;ii++)
          {
            widthval+=width[ii];
          }
          for(var jj=1;jj <= pgmcontent.length-1;jj++)
          {
            $('#programe'+jj).html(pgmcontent[jj]);
          }
          for(var kk=1;kk <= imagecontent.length-1;kk++)
          {
            $('#image'+kk).html(imagecontent[kk]);
          }
            $("body").find('.rowSubPgm').each(function(index) {
            $(this).css( "width", widthval+"px");
          });
          $("div").show();    
        }
      }   
      });
    }
    </body>
    </html> 

    If you know how to fix the bugs I have mention on above, i would be very grateful if you could help me out to solve my problem.

    Thanks in advance
    Last edited by mark103; 06-18-2013 at 04:00 PM.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,763
    Thanks
    23
    Thanked 548 Times in 547 Posts
    When I hired the PHP devloper??????? There is no php code here. It is all javascript. And your missing the end [</script>] tag. Plus, and this is the big one, You have no html code for the body so when this code is executed nothing shows up.

    Do you have a site you could link to or re-post the right code.
    Evolution - The non-random survival of random variants.

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    The described behaviour is also all client side, so this hasn't a thing to do with PHP.
    Moving from PHP forum to Javascript forum.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •