Shop OBEX P1 Docs P2 Docs Learn Events
div tag attribute corrupts page — Parallax Forums

div tag attribute corrupts page

doggiedocdoggiedoc Posts: 2,239
edited 2013-02-06 05:37 in Accessories
I can't figure out why, but when I add an attribute to the <div> tag below, it corrupts the html and the page does not render properly. Any suggestions anyone?
DAT
  index byte  "HTTP/1.1 200 OK", CR, LF, {
}             "Content-Type: text/html", CR, LF, CR, LF, {
}             "<HTML>", {
}             "<HEAD>", {
}             "<TITLE>Willoughby Farm</TITLE>", {
}             "</HEAD>",  {
}             "<SCRIPT LANGUAGE='JavaScript'>",CR,{
}             "Temp3 = 60",CR,  {
}             "function Counter() {",CR, {
}             "         Temp3 = Temp3 - 1;",CR, {
}             "         document.frm1.seconds.value=Temp3;",CR,{
}             "         timerID = setTimeout('Counter()',1000);",CR,{
}             "         timedRefresh()",CR, {
}             "         }",CR, {
}             "</SCRIPT>",CR, {
}             "<SCRIPT LANGUAGE='JavaScript'>",CR,{
}             "function timedRefresh() {",CR,{
}             "         setTimeout('location.reload(true);',60000);",CR,{
}             "         }",CR, {
}             "</SCRIPT>"
 
        byte  "<BODY Onload='Counter()'>"
        byte  "<center>"
        byte  "<FONT FACE=BOOKMAN OLD STYLE SIZE=8><BR>"
        byte  "Doc's Flock<BR></FONT>"
        byte  "<FONT FACE=BOOKMAN OLD STYLE SIZE=4><BR>"
        byte  "Coop Status Page  "
        byte  "(...a work in progress!)</FONT>"
        byte  "<BR><img src=http://www.tegacayanimalhospital.com/images/spinneret/coop.jpg><BR>"

        byte  "<div>"
        byte  "<FONT FACE=BOOKMAN OLD STYLE SIZE=2>Coop Date and Time: " 
time1   byte  "00/" '<--- This is a place holder ; number is dynamically updated
time2   byte  "00/20" '<--- This is a place holder ; number is dynamically updated
time3   byte  "   "'<--- This is a place holder ; number is dynamically updated
time4   byte  "  :" '<--- This is a place holder ; number is dynamically updated
time5   byte  "  :" '<--- This is a place holder ; number is dynamically updated
time6   byte  "  <BR>" '<--- This is a place holder ; number is dynamically updated
        byte  "</FONT>"
        byte  "<BR><B><FONT FACE=BOOKMAN OLD STYLE SIZE=4>Conditions inside Coop:</FONT></B> "
        byte  "<table><tr><td>" 'wrapper table
        byte  "<table border='1'>"
        byte  "<tr><td><FONT FACE=BOOKMAN OLD STYLE SIZE=4>Temp:</td> "
        byte  "<td><FONT FACE=BOOKMAN OLD STYLE SIZE=4 COLOR=RED>"
temp    byte  "      °F "'<--- This is a place holder ; number is dynamically updated
        byte  "</FONT></FONT></td></tr>"
        byte  "<tr><td><FONT FACE=BOOKMAN OLD STYLE SIZE=4>Humidity: </td>   "
        byte  "<td><FONT FACE=BOOKMAN OLD STYLE SIZE=4 COLOR=RED>"
humi    byte  "       % "'<--- This is a place holder ; number is dynamically updated
        byte  "</FONT></FONT></td></tr></table></td>"
        byte  "<td><table border='1'>"
        byte  "<tr><td><FONT FACE=BOOKMAN OLD STYLE SIZE=4>Current Light:</td> "
        byte  "<td><FONT FACE=BOOKMAN OLD STYLE SIZE=4 COLOR=RED>"
num1    byte  "0000 " '<--- This is a place holder ; number is dynamically updated
        byte  "</FONT></FONT></td></tr>"
        byte  "<tr><td><FONT FACE=BOOKMAN OLD STYLE SIZE=4>Average Light:</td> "
        byte  "<td><FONT FACE=BOOKMAN OLD STYLE SIZE=4 COLOR=RED>"
num2    byte  "0000 "'<--- This is a place holder ; number is dynamically updated
        byte  "</FONT></FONT></td></tr></table></td>"
        byte  "<td><table border='1'>"
        byte  "<tr><td><FONT FACE=BOOKMAN OLD STYLE SIZE=4>Door Position</td>"
        byte  "<td><FONT FACE=BOOKMAN OLD STYLE SIZE=4 COLOR=RED>"
str1    byte  "      "'<--- This is a place holder ; val is dynamically updated
        byte  "</FONT></FONT></td></tr>"
        byte  "<tr><td><FONT FACE=BOOKMAN OLD STYLE SIZE=4>Switch Position</td>"
        byte  "<td><FONT FACE=BOOKMAN OLD STYLE SIZE=4 COLOR=RED>"
str2    byte  "      " '<--- This is a place holder ; val is dynamically updated
        byte  "</FONT></FONT></td></tr></table>"
        byte  "</td></tr></table>"
        byte  "</div>"
        
        byte  "<FONT FACE=BOOKMAN OLD STYLE SIZE=2><BR>"
        byte  "<FORM NAME='frm1'>"
        byte  "Seconds Until Refresh ="
        byte  "<INPUT NAME='seconds' SIZE=4 VALUE=''>"
        byte  "</FORM>" 
        byte  "</FONT>"
        byte  "</FONT>"
        byte  "</center>"
        byte  "</BODY>"
        byte  "</HTML>"
        byte  0



  buff          byte  $0[BUFFER_2K] 
  resPtr        long $0[25]
  null          long  $00
  dhcpLease     long  $ff_ff_ff
  dns_addr      byte $61, $0A, $0B, $01
  

Paul

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-02-03 17:35
    When attributes (e.g. "BOOKMAN OLD STYLE") contain spaces, they need to be in quotes.

    -Phil
  • Mike GMike G Posts: 2,702
    edited 2013-02-03 17:47
    What attribute was added an what does not render properly mean?
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-03 17:47
    Thanks Phil.
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-03 17:53
    Mike G wrote: »
    What attribute was added an what does not render properly mean?
    Mike I am trying to add a name attribute to the div tag. Subsequently I've tried other attributes to the div tag and get the same results. The page display the html as plain text. (I'll paste it here).


    This is what chrome displays on Mac OSX 10.8
    </FONT></FONT></center></BODY></HTML>tml
    
    <HTML><HEAD><TITLE>Willoughby Farm</TITLE></HEAD><SCRIPT LANGUAGE='JavaScript'>
    Temp3 = 60
    function Counter() {
             Temp3 = Temp3 - 1;
             document.frm1.seconds.value=Temp3;
             timerID = setTimeout('Counter()',1000);
             timedRefresh()
             }
    </SCRIPT>
    <SCRIPT LANGUAGE='JavaScript'>
    function timedRefresh() {
             setTimeout('location.reload(true);',60000);
             }
    </SCRIPT><BODY Onload='Counter()'><center><FONT FACE='BOOKMAN OLD STYLE' SIZE=8><BR>Doc's Flock<BR></FONT><FONT FACE='BOOKMAN OLD STYLE' SIZE=4><BR>Coop Status Page  (...a work in progress!)</FONT><BR><img src=http://www.tegacayanimalhospital.com/images/spinneret/coop.jpg><BR><div id='content'><FONT FACE='BOOKMAN OLD STYLE' SIZE=2>Coop Date and Time: 01/29/2013 19:59:12<BR></FONT><BR><B><FONT FACE='BOOKMAN OLD STYLE' SIZE=4>Conditions inside Coop:</FONT></B> <table><tr><td><table border='1'><tr><td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4>Temp:</td> <td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4 COLOR=RED>32.00 °F </FONT></FONT></td></tr><tr><td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4>Humidity: </td>   <td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4 COLOR=RED> 0.00  % </FONT></FONT></td></tr></table></td><td><table border='1'><tr><td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4>Current Light:</td> <td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4 COLOR=RED> 0330</FONT></FONT></td></tr><tr><td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4>Average Light:</td> <td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4 COLOR=RED> 0490</FONT></FONT></td></tr></table></td><td><table border='1'><tr><td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4>Door Position</td><td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4 COLOR=RED>CLOSED</FONT></FONT></td></tr><tr><td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4>Switch Position</td><td><FONT FACE='BOOKMAN OLD STYLE' SIZE=4 COLOR=RED>OPEN  </FONT></FONT></td></tr></table></td></tr></table></div><FONT FACE='BOOKMAN OLD STYLE' SIZE=2><BR><FORM NAME='frm1'>Seconds Until Refresh =<INPUT NAME='seconds' SIZE=4 VALUE=''></FORM></FONT></FONT></center></BODY></HTML>
    
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-03 17:56
    if I take out the attribute e.g.
    <div name='content'>
    
    and replace it with
    <div>
    
    The page loads properly. I'm not sure I understand.
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-03 17:57
    @Phil - I enclosed all the font face attributes in single quotes but the problem persists.

    EDIT: It actually perpetuates the problem. If I now remove the div tag all together, which has resolved the problem before, the page doesn't display. I removed all the quotes from the face attributes and it works as expected.

    Now I'm really confused. :D
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-03 20:04
    It appears that I am at a buffer overflow issue. Adding more html anywhere is the problem - so expanding the buffer should help.


    EDIT: or not. :(
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-03 20:31
    The limit appears to be 2048 bytes sent, but I'm still working on how to increase the buffer cap. It's late and I have to work tomorrow so I'll figure it out later.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-02-03 20:50
    doggiedoc wrote:
    It's late and I have to work tomorrow so I'll figure it out later.
    'Sucks having to work, but work is what keeps us on our toes and interesting. I have friends who are either fully or partially retired and, frankly, they're getting kinda boring.

    Keep up the good work, doggiedoc! Your patients (and their humans) need you!

    -Phil
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-03 21:14
    Yes Sir! You can count on that.

    Good Night.
  • Mike GMike G Posts: 2,702
    edited 2013-02-04 05:34
    It's not the buffer size. It has to do with buffer pointers. I fix it later today.
  • Mike GMike G Posts: 2,702
    edited 2013-02-04 06:09
    Well, it could be buffer size related... Try updating the buff size in the DAT section. It forgot about this little bugger.
    DAT
      buff          byte  $0[BUFFER_2K+1]
    

    Otherwise, I'll fix it when I get home from work.
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-04 09:41
    Thanks Mike... I tried a bigger buffer, but increasing BUFFER_2K size didn't help. I just figured I had the wrong buffer.


    Thanks!
  • TumblerTumbler Posts: 323
    edited 2013-02-04 20:36
    I had the same problem with large html output;
    Like Mike said in another thread: use the spinneret xml service :put your coop sensor data etc; in an xml, and parse the xml in another website.

    btw Doc, nice project :)
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-05 06:51
    Tumbler wrote: »
    Like Mike said in another thread: use the spinneret xml service :put your coop sensor data etc; in an xml, and parse the xml in another website.
    Ultimately that's the goal. I looked at examples Mike Posted last night... still wrapping my head around that.

    Thanks!
  • Mike GMike G Posts: 2,702
    edited 2013-02-05 07:12
    doggiedoc, I'm just going to upgrade you to the AJAX style rather than fix the current top level object. Unfortunately, work is a bit intense this week. Plus I might have jury duty today... will find out at 10:15 AZ time.
  • doggiedocdoggiedoc Posts: 2,239
    edited 2013-02-05 08:55
    No worries Mike. I really appreciate all your help!! The example I was referring to was epin.htm you posted here. Is that a good example?
  • Mike GMike G Posts: 2,702
    edited 2013-02-05 09:20
    Yes, that's the one you'll want. There are a few moving parts which can be confusing. The AJAX stuff is really no different than coming up with a protocol over a serial connection. The difference being the protocol is wrapped in XML and sent via HTTP.
  • Mike GMike G Posts: 2,702
    edited 2013-02-06 05:37
    doggiedoc, give this code a shot. I still plan to upgrade your code (and Html5Graph) just no time.
    PUB MultiSocketServer | bytesToRead, page, sockId, bytesSent, ptr, i, fs, bytes 
      bytesToRead := bytesSent := sockId := i := 0
      repeat
    
        bytesToRead~ 
        CloseWait
    
        repeat until sock[sockId].Connected
          sockId := ++sockId // SOCKETS
        
        'Data in the buffer?
        repeat until bytesToRead := sock[sockId].Available
        
        'Check for a timeout error
        if(bytesToRead =< 0)
          pst.str(string(CR, "Timeout: "))
          pst.dec(bytesToRead) 
          if(i++ == 1)
            sock[sockId].Disconnect
            i := 0    
          next
      
        'Get the Rx buffer  
        sock[sockId].Receive(@buff, bytesToRead)
    
        'Display the request header
        'pst.str(@buff)
    
        page :=  ParseResource(@buff)
    
        pst.str(string("Byte to send...."))
        pst.dec(strsize(page))
        pst.char(CR)
    
        
        mtuBuff := sock[sockId].GetMtu
        fs := strsize(page)
        ptr := page
        repeat until fs =< 0     
          if(fs < mtuBuff)
            bytes := fs
          else
            bytes := mtuBuff
    
          fs -= sock[sockId].Send(ptr, bytes)
          ptr := page + bytes 
         
        sock[sockId].Disconnect
        sock[sockId].SetSocketIR($FF)
        
        sockId := ++sockId // SOCKETS
    
Sign In or Register to comment.