473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.captureEvents(Event.MOUSEMOVE)\n";
echo "window.onmousemove=overhere\n";
echo "topColor = \"#7D92A9\"\n";
echo "subColor = \"#A5B4C4\"\n";
echo "}\n";
echo "function MoveToolTip(layerName, FromTop, FromLeft, e){\n";
echo "if(ie){eval(doc + layerName + sty + \".top = \" + (eval(FromTop) +
document.body.scrollTop))}\n";
echo "if(ns){eval(doc + 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){document.all[layerName].innerHTML = ContentInfo}\n";
echo "if(ns){\n";
echo "with(document.layers[layerName].document)\n";
echo "{\n";
echo " open();\n";
echo " write(ContentInfo);\n";
echo " close();\n";
echo "}\n";
echo "}\n";
echo "}\n";
echo "function Activate(){initialize=1}\n";
echo "function deActivate(){initialize=0}\n";
echo "function overhere(e){\n";
echo "if(initialize){\n";
echo "MoveToolTip(\"ToolTip\", Ey, Ex, e)\n";
echo "eval(doc + \"ToolTip\" + sty + \".visibility = 'visible'\")\n";
echo "}\n";
echo "else{\n";
echo "MoveToolTip(\"ToolTip\", 0, 0)\n";
echo "eval(doc + \"ToolTip\" + sty + \".visibility = 'hidden'\")\n";
echo "}\n";
echo "}\n";
echo "function EnterContent(layerName, TTitle, TContent){\n";
echo "ContentInfo = '<table border=\"0\" width=\"150\" cellspacing=\"0\"
cellpadding=\"0\">'+\n";
echo "'<tr><td width=\"100%\" bgcolor=\"#000000\">'+\n";
echo "'<table border=\"0\" width=\"100%\" cellspacing=\"1\"
cellpadding=\"0\">'+\n";
echo "'<tr><td width=\"100%\" bgcolor='+topColor+'>'+\n";
echo "'<table border=\"0\" width=\"90%\" cellspacing=\"0\" cellpadding=\"0\"
align=\"center\">'+\n";
echo "'<tr><td width=\"100%\">'+\n";
echo "'<center><font
class=\"tooltiptitle\">&nbsp;'+TTitle+'</font></center>'+\n";
echo "'</td></tr>'+\n";
echo "'</table>'+\n";
echo "'</td></tr>'+\n";
echo "'<tr><td width=\"100%\" bgcolor='+subColor+'>'+\n";
echo "'<table border=\"0\" width=\"90%\" cellpadding=\"0\" cellspacing=\"1\"
align=\"center\">'+\n";
echo "'<tr><td width=\"100%\">'+\n";
echo "'<center><font
class=\"tooltipcontent\">'+TContent+'</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>";
Jul 16 '05 #1
4 2450

On 30-Jul-2003, "fartsniff" <fa**@sniff.com> wrote:
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.


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.captureEvents(Event.MOUSEMOVE)
window.onmousemove=overhere
topColor = "#7D92A9"
subColor = "#A5B4C4"
}
function MoveToolTip(layerName, FromTop, FromLeft, e){
if(ie){eval(doc + layerName + sty + ".top = " + (eval(FromTop) +
document.body.scrollTop))}
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.layers[layerName].document)
{
open();
write(ContentInfo);
close();
}
}
}
function Activate(){initialize=1}
function deActivate(){initialize=0}
function overhere(e){
if(initialize){
MoveToolTip("ToolTip", Ey, Ex, e)
eval(doc + "ToolTip" + sty + ".visibility = 'visible'")
}
else{
MoveToolTip("ToolTip", 0, 0)
eval(doc + "ToolTip" + sty + ".visibility = 'hidden'")
}
}
function EnterContent(layerName, TTitle, TContent){
ContentInfo = '<table border="0" width="150" cellspacing="0"
cellpadding="0">'+
'<tr><td width="100%" bgcolor="#000000">'+
'<table border="0" width="100%" cellspacing="1" cellpadding="0">'+
'<tr><td width="100%" bgcolor='+topColor+'>'+
'<table border="0" width="90%" cellspacing="0" cellpadding="0"
align="center">'+
'<tr><td width="100%">'+
'<center><font class="tooltiptitle">&nbsp;'+TTitle+'</font></center>'+
'</td></tr>'+
'</table>'+
'</td></tr>'+
'<tr><td width="100%" bgcolor='+subColor+'>'+
'<table border="0" width="90%" cellpadding="0" cellspacing="1"
align="center">'+
'<tr><td width="100%">'+
'<center><font class="tooltipcontent">'+TContent+'</font></center>'+
'</td></tr>'+
'</table>'+
'</td></tr>'+
'</table>'+
'</td></tr>'+
'</table>';
ReplaceContent(layerName)
}
//-->
</script>


--
Tom Thackrey
www.creative-light.com
Jul 16 '05 #2
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" <ja**@croatiabiz.com> wrote in message
news:bg**********@ls219.htnet.hr...
fartsniff wrote:
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.


execute it in php, then view source :))))))

--
--- --- --- --- --- --- ---
ja**@croatiabiz.com

Jul 16 '05 #3
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" <to***@creative-light.com> wrote in message
news:o7****************@newssvr24.news.prodigy.com ...

On 30-Jul-2003, "fartsniff" <fa**@sniff.com> wrote:
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.


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.captureEvents(Event.MOUSEMOVE)
window.onmousemove=overhere
topColor = "#7D92A9"
subColor = "#A5B4C4"
}
function MoveToolTip(layerName, FromTop, FromLeft, e){
if(ie){eval(doc + layerName + sty + ".top = " + (eval(FromTop) +
document.body.scrollTop))}
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.layers[layerName].document)
{
open();
write(ContentInfo);
close();
}
}
}
function Activate(){initialize=1}
function deActivate(){initialize=0}
function overhere(e){
if(initialize){
MoveToolTip("ToolTip", Ey, Ex, e)
eval(doc + "ToolTip" + sty + ".visibility = 'visible'")
}
else{
MoveToolTip("ToolTip", 0, 0)
eval(doc + "ToolTip" + sty + ".visibility = 'hidden'")
}
}
function EnterContent(layerName, TTitle, TContent){
ContentInfo = '<table border="0" width="150" cellspacing="0"
cellpadding="0">'+
'<tr><td width="100%" bgcolor="#000000">'+
'<table border="0" width="100%" cellspacing="1" cellpadding="0">'+
'<tr><td width="100%" bgcolor='+topColor+'>'+
'<table border="0" width="90%" cellspacing="0" cellpadding="0"
align="center">'+
'<tr><td width="100%">'+
'<center><font class="tooltiptitle">&nbsp;'+TTitle+'</font></center>'+
'</td></tr>'+
'</table>'+
'</td></tr>'+
'<tr><td width="100%" bgcolor='+subColor+'>'+
'<table border="0" width="90%" cellpadding="0" cellspacing="1"
align="center">'+
'<tr><td width="100%">'+
'<center><font class="tooltipcontent">'+TContent+'</font></center>'+
'</td></tr>'+
'</table>'+
'</td></tr>'+
'</table>'+
'</td></tr>'+
'</table>';
ReplaceContent(layerName)
}
//-->
</script>


--
Tom Thackrey
www.creative-light.com

Jul 16 '05 #4
On Wed, 30 Jul 2003 22:44:44 -0800, "fartsniff" <fa**@sniff.com>
wrote:
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)


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

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

--
David (please modify address to david@ before replying!)
Jul 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: newseater | last post by:
Hello. I need to be able to control how objects are created. Sometimes when creating an object, i want to reuse another object instead. I've searched for factory method implementations and...
11
by: Rupesh | last post by:
Hello all, See the code .... int i=-3,j=2,k=0,m; m=++i;&&++j||++k; printf ("%d %d %d %d",i,j,k,m); I executed this code on gcc. the o/p i had got is:- -2 3 0 1
7
by: Shapper | last post by:
Hello, I have an ASP:ImageButton where I want to call a function and pass a string: OnClick="Change_Photo("John")" I am having problems with "". I tried
44
by: Viken Karaguesian | last post by:
Hello all, On occasion I want to open hyperlinks (images, etc.) in a new window. In the past, I've used target="_blank" to open the link in a new window. However, using the "target" attribute...
6
by: Simple Simon | last post by:
[posted separately to comp.unix.programmer and Can't figure out why this code generates a SIGSEGV in fillGlobalBuffer() (below). globalBuffer is allocated in caller.c, then its address is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.