Help with "un-PHP'ing" some code...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fartsniff

    Help with "un-PHP'ing" some code...

    Hello all.
    Can someone help out ? I found this PHP code that works just fine, however,
    I am trying to put it back into its original Javascript form.

    I am still learning the syntax, etc. for Javascript, so I'm not really sure
    what needs
    to be removed and kept.

    I was trying the basic search/replaces, but always ended up with Javascript
    errors.
    Here is the code:

    Ultimately, all it does it allow me to create a "tooltip" box which I use to
    float over
    images (i.e. copyright information and such). Eventually, I would like to
    completely
    replace the JS code with either some fancy CSS or something else (since more
    and
    more I read I see about trying to cut back on JS code)

    echo "<script language = \"javascript\"> \n";
    echo "<!--\n";
    echo "var ie = document.all ? 1 : 0\n";
    echo "var ns = document.layers ? 1 : 0\n";
    echo "if(ns){doc = \"document.\ "; sty = \"\"}\n";
    echo "if(ie){doc = \"document.all. \"; sty = \".style\"}\ n";
    echo "var initialize = 0\n";
    echo "var Ex, Ey, topColor, subColor, ContentInfo\n";
    echo "if(ie){\n" ;
    echo "Ex = \"event.x\"\ n";
    echo "Ey = \"event.y\"\ n";
    echo "topColor = \"#7D92A9\"\ n";
    echo "subColor = \"#A5B4C4\"\ n";
    echo "}\n";
    echo "if(ns){\n" ;
    echo "Ex = \"e.pageX\"\ n";
    echo "Ey = \"e.pageY\"\ n";
    echo "window.capture Events(Event.MO USEMOVE)\n";
    echo "window.onmouse move=overhere\n ";
    echo "topColor = \"#7D92A9\"\ n";
    echo "subColor = \"#A5B4C4\"\ n";
    echo "}\n";
    echo "function MoveToolTip(lay erName, FromTop, FromLeft, e){\n";
    echo "if(ie){eval(do c + layerName + sty + \".top = \" + (eval(FromTop) +
    document.body.s crollTop))}\n";
    echo "if(ns){eval(do c + layerName + sty + \".top = \" +
    eval(FromTop))} \n";
    echo "eval(doc + layerName + sty + \".left = \" + (eval(FromLeft) + 15))\n";
    echo "}\n";
    echo "function ReplaceContent( layerName){\n";
    echo "if(ie){documen t.all[layerName].innerHTML = ContentInfo}\n" ;
    echo "if(ns){\n" ;
    echo "with(document. layers[layerName].document)\n";
    echo "{\n";
    echo " open();\n";
    echo " write(ContentIn fo);\n";
    echo " close();\n";
    echo "}\n";
    echo "}\n";
    echo "}\n";
    echo "function Activate(){init ialize=1}\n";
    echo "function deActivate(){in itialize=0}\n";
    echo "function overhere(e){\n" ;
    echo "if(initialize) {\n";
    echo "MoveToolTip(\" ToolTip\", Ey, Ex, e)\n";
    echo "eval(doc + \"ToolTip\" + sty + \".visibilit y = 'visible'\")\n" ;
    echo "}\n";
    echo "else{\n";
    echo "MoveToolTip(\" ToolTip\", 0, 0)\n";
    echo "eval(doc + \"ToolTip\" + sty + \".visibilit y = 'hidden'\")\n";
    echo "}\n";
    echo "}\n";
    echo "function EnterContent(la yerName, TTitle, TContent){\n";
    echo "ContentInf o = '<table border=\"0\" width=\"150\" cellspacing=\"0 \"
    cellpadding=\"0 \">'+\n";
    echo "'<tr><td width=\"100%\" bgcolor=\"#0000 00\">'+\n";
    echo "'<table border=\"0\" width=\"100%\" cellspacing=\"1 \"
    cellpadding=\"0 \">'+\n";
    echo "'<tr><td width=\"100%\" bgcolor='+topCo lor+'>'+\n";
    echo "'<table border=\"0\" width=\"90%\" cellspacing=\"0 \" cellpadding=\"0 \"
    align=\"center\ ">'+\n";
    echo "'<tr><td width=\"100%\"> '+\n";
    echo "'<center>< font
    class=\"tooltip title\">&nbsp;' +TTitle+'</font></center>'+\n";
    echo "'</td></tr>'+\n";
    echo "'</table>'+\n";
    echo "'</td></tr>'+\n";
    echo "'<tr><td width=\"100%\" bgcolor='+subCo lor+'>'+\n";
    echo "'<table border=\"0\" width=\"90%\" cellpadding=\"0 \" cellspacing=\"1 \"
    align=\"center\ ">'+\n";
    echo "'<tr><td width=\"100%\"> '+\n";
    echo "'<center>< font
    class=\"tooltip content\">'+TCo ntent+'</font></center>'+\n";
    echo "'</td></tr>'+\n";
    echo "'</table>'+\n";
    echo "'</td></tr>'+\n";
    echo "'</table>'+\n";
    echo "'</td></tr>'+\n";
    echo "'</table>';\n";
    echo "ReplaceContent (layerName)\n";
    echo "}\n";
    echo "//-->\n";
    echo "</script>";


  • Tom Thackrey

    #2
    Re: Help with &quot;un-PHP'ing&quot; some code...


    On 30-Jul-2003, "fartsniff" <fart@sniff.com > wrote:
    [color=blue]
    > Can someone help out ? I found this PHP code that works just fine,
    > however,
    > I am trying to put it back into its original Javascript form.
    >
    > I am still learning the syntax, etc. for Javascript, so I'm not really
    > sure
    > what needs
    > to be removed and kept.[/color]

    remove the echo " and the \n"; from each line
    change the \" to "

    this should be it, I haven't tested it--
    <script language = "javascript ">
    <!--
    var ie = document.all ? 1 : 0
    var ns = document.layers ? 1 : 0
    if(ns){doc = "document." ; sty = ""}
    if(ie){doc = "document.all." ; sty = ".style"}
    var initialize = 0
    var Ex, Ey, topColor, subColor, ContentInfo
    if(ie){
    Ex = "event.x"
    Ey = "event.y"
    topColor = "#7D92A9"
    subColor = "#A5B4C4"
    }
    if(ns){
    Ex = "e.pageX"
    Ey = "e.pageY"
    window.captureE vents(Event.MOU SEMOVE)
    window.onmousem ove=overhere
    topColor = "#7D92A9"
    subColor = "#A5B4C4"
    }
    function MoveToolTip(lay erName, FromTop, FromLeft, e){
    if(ie){eval(doc + layerName + sty + ".top = " + (eval(FromTop) +
    document.body.s crollTop))}
    if(ns){eval(doc + layerName + sty + ".top = " + eval(FromTop))}
    eval(doc + layerName + sty + ".left = " + (eval(FromLeft) + 15))
    }
    function ReplaceContent( layerName){
    if(ie){document .all[layerName].innerHTML = ContentInfo}
    if(ns){
    with(document.l ayers[layerName].document)
    {
    open();
    write(ContentIn fo);
    close();
    }
    }
    }
    function Activate(){init ialize=1}
    function deActivate(){in itialize=0}
    function overhere(e){
    if(initialize){
    MoveToolTip("To olTip", Ey, Ex, e)
    eval(doc + "ToolTip" + sty + ".visibilit y = 'visible'")
    }
    else{
    MoveToolTip("To olTip", 0, 0)
    eval(doc + "ToolTip" + sty + ".visibilit y = 'hidden'")
    }
    }
    function EnterContent(la yerName, TTitle, TContent){
    ContentInfo = '<table border="0" width="150" cellspacing="0"
    cellpadding="0" >'+
    '<tr><td width="100%" bgcolor="#00000 0">'+
    '<table border="0" width="100%" cellspacing="1" cellpadding="0" >'+
    '<tr><td width="100%" bgcolor='+topCo lor+'>'+
    '<table border="0" width="90%" cellspacing="0" cellpadding="0"
    align="center"> '+
    '<tr><td width="100%">'+
    '<center><font class="tooltipt itle">&nbsp;'+T Title+'</font></center>'+
    '</td></tr>'+
    '</table>'+
    '</td></tr>'+
    '<tr><td width="100%" bgcolor='+subCo lor+'>'+
    '<table border="0" width="90%" cellpadding="0" cellspacing="1"
    align="center"> '+
    '<tr><td width="100%">'+
    '<center><font class="tooltipc ontent">'+TCont ent+'</font></center>'+
    '</td></tr>'+
    '</table>'+
    '</td></tr>'+
    '</table>'+
    '</td></tr>'+
    '</table>';
    ReplaceContent( layerName)
    }
    //-->
    </script>




    --
    Tom Thackrey

    Comment

    • fartsniff

      #3
      Re: Help with &quot;un-PHP'ing&quot; some code...

      i am such a boob. i cannot believe it ;) i concentrate on things so hard
      some times
      that i overlook the obvious.

      thanks for the tip/help.

      "jack" <jack@croatiabi z.com> wrote in message
      news:bgaei5$2pf $1@ls219.htnet. hr...[color=blue]
      > fartsniff wrote:[color=green]
      > > Hello all.
      > > Can someone help out ? I found this PHP code that works just fine,
      > > however, I am trying to put it back into its original Javascript form.[/color]
      >
      > execute it in php, then view source :))))))
      >
      > --
      > --- --- --- --- --- --- ---
      > jack@croatiabiz .com
      >
      >[/color]


      Comment

      • fartsniff

        #4
        Re: Help with &quot;un-PHP'ing&quot; some code...

        thank you also. i am still playing with CSS, and was able to come up with
        this so far since
        my original post.

        <style type="text/css">
        p.link a:hover {background-color: #2B2E21;;color: #fff;}
        p.link a:link span{display: none;}
        p.link a:visited span{display: none;}
        p.link a:hover span {
        position: absolute;
        margin:5px 0px 0px 10px;
        background-color: beige;
        max-width:220;
        padding: 2px 10px 2px 10px;
        border: 1px solid #C0C0C0;
        font-family: Verdana;
        font-size: 12px;
        color: #336699;
        text-align:left;
        display: block;
        }
        </style>
        <p class="link"><a
        href="#">sample <span>line1<br> line2<br>line3</span></a></p>

        not sure which is better, but just in case JS isnt enabled i think the CSS
        would still work.
        thanks again.

        "Tom Thackrey" <tomnr@creati ve-light.com> wrote in message
        news:o73Wa.2452 $vJ7.305@newssv r24.news.prodig y.com...[color=blue]
        >
        > On 30-Jul-2003, "fartsniff" <fart@sniff.com > wrote:
        >[color=green]
        > > Can someone help out ? I found this PHP code that works just fine,
        > > however,
        > > I am trying to put it back into its original Javascript form.
        > >
        > > I am still learning the syntax, etc. for Javascript, so I'm not really
        > > sure
        > > what needs
        > > to be removed and kept.[/color]
        >
        > remove the echo " and the \n"; from each line
        > change the \" to "
        >
        > this should be it, I haven't tested it--
        > <script language = "javascript ">
        > <!--
        > var ie = document.all ? 1 : 0
        > var ns = document.layers ? 1 : 0
        > if(ns){doc = "document." ; sty = ""}
        > if(ie){doc = "document.all." ; sty = ".style"}
        > var initialize = 0
        > var Ex, Ey, topColor, subColor, ContentInfo
        > if(ie){
        > Ex = "event.x"
        > Ey = "event.y"
        > topColor = "#7D92A9"
        > subColor = "#A5B4C4"
        > }
        > if(ns){
        > Ex = "e.pageX"
        > Ey = "e.pageY"
        > window.captureE vents(Event.MOU SEMOVE)
        > window.onmousem ove=overhere
        > topColor = "#7D92A9"
        > subColor = "#A5B4C4"
        > }
        > function MoveToolTip(lay erName, FromTop, FromLeft, e){
        > if(ie){eval(doc + layerName + sty + ".top = " + (eval(FromTop) +
        > document.body.s crollTop))}
        > if(ns){eval(doc + layerName + sty + ".top = " + eval(FromTop))}
        > eval(doc + layerName + sty + ".left = " + (eval(FromLeft) + 15))
        > }
        > function ReplaceContent( layerName){
        > if(ie){document .all[layerName].innerHTML = ContentInfo}
        > if(ns){
        > with(document.l ayers[layerName].document)
        > {
        > open();
        > write(ContentIn fo);
        > close();
        > }
        > }
        > }
        > function Activate(){init ialize=1}
        > function deActivate(){in itialize=0}
        > function overhere(e){
        > if(initialize){
        > MoveToolTip("To olTip", Ey, Ex, e)
        > eval(doc + "ToolTip" + sty + ".visibilit y = 'visible'")
        > }
        > else{
        > MoveToolTip("To olTip", 0, 0)
        > eval(doc + "ToolTip" + sty + ".visibilit y = 'hidden'")
        > }
        > }
        > function EnterContent(la yerName, TTitle, TContent){
        > ContentInfo = '<table border="0" width="150" cellspacing="0"
        > cellpadding="0" >'+
        > '<tr><td width="100%" bgcolor="#00000 0">'+
        > '<table border="0" width="100%" cellspacing="1" cellpadding="0" >'+
        > '<tr><td width="100%" bgcolor='+topCo lor+'>'+
        > '<table border="0" width="90%" cellspacing="0" cellpadding="0"
        > align="center"> '+
        > '<tr><td width="100%">'+
        > '<center><font class="tooltipt itle">&nbsp;'+T Title+'</font></center>'+
        > '</td></tr>'+
        > '</table>'+
        > '</td></tr>'+
        > '<tr><td width="100%" bgcolor='+subCo lor+'>'+
        > '<table border="0" width="90%" cellpadding="0" cellspacing="1"
        > align="center"> '+
        > '<tr><td width="100%">'+
        > '<center><font class="tooltipc ontent">'+TCont ent+'</font></center>'+
        > '</td></tr>'+
        > '</table>'+
        > '</td></tr>'+
        > '</table>'+
        > '</td></tr>'+
        > '</table>';
        > ReplaceContent( layerName)
        > }
        > //-->
        > </script>
        >
        >
        >
        >
        > --
        > Tom Thackrey
        > www.creative-light.com[/color]


        Comment

        • David Mackenzie

          #5
          Re: Help with &quot;un-PHP'ing&quot; some code...

          On Wed, 30 Jul 2003 22:44:44 -0800, "fartsniff" <fart@sniff.com >
          wrote:
          [color=blue]
          >Ultimately, all it does it allow me to create a "tooltip" box which I use to
          >float over
          >images (i.e. copyright information and such). Eventually, I would like to
          >completely
          >replace the JS code with either some fancy CSS or something else (since more
          >and
          >more I read I see about trying to cut back on JS code)[/color]

          You can use the title attriute to create a tooltip, e.g.

          <img src='image.gif' alt='appropriat e alt text' title='This image is
          copyright, and not to be used without permission'>

          --
          David (please modify address to david@ before replying!)

          Comment

          Working...