PDA

View Full Version : Search replace question



glucarelli
06-02-2006, 10:06 AM
Hello all :)

I've created a website where i iplemented the excellent javascript Post-it note:

http://www.javascriptkit.com/script/script2/postit.shtml

In this Post-it note i put this external .jsp file from:
http://www.ephemeride.com/generic/53/#citation

like this
<script language="javascript" src="http://www.ephemeride.com/free/ephem.jsp"></script>

All work very well but i have a problem with the dimension of the.jsp box.:mad:
My Post-it note have a width of 141 and the .jsp a width of 380.

As you can see the box does not fit in my Post-it.
Due to limitation of my website,is there a way to resize the .jsp box to fit in my Post-it note(i have no choice the maximun value of width="141")

Any help would be nice.
Thank you

jscheuer1
06-03-2006, 05:39 AM
Replace this:


<script language="javascript" src="http://www.ephemeride.com/free/ephem.jsp"></script>

with this:


<style type="text/css">
table.fma {
width:141px;
}
</style>
<script type="text/javascript" src="http://www.ephemeride.com/free/ephem.jsp"></script>

You can edit the 141 to be whatever you like but, that is what you say you want.

glucarelli
06-03-2006, 08:40 AM
Thank you very mutch jscheuer1

Working well :)
Just another question :
How to replace some text inside table.fma.
Example i would like to capitalize the days and the months when they are displayed on my site,and get rid of the visibility attribute because when i close the Post-it note some words from this script still remaining on the screen.

Regards

jscheuer1
06-03-2006, 10:55 PM
What you are asking for is a little complex. I played around a bit and came up with this which looked pretty good in Opera, IE and FF. the div with the id of ephem2 is the division that ends up with the content and the long script must follow it on your page but can go anywhere after it. The short script must be enclosed in the div with the id of ephem and must come before the ephem2 div and the long script. The style section can go in the head or be external:


<div id="ephem">
<script language="javascript" src="http://www.ephemeride.com/free/ephem.jsp?css=perso"></script>
</div><style type="text/css">
#ephem {
display:none;
}
.FeteHomme {/*The space before this brace must remain!*/
color:#003399;
}
.FeteFemme {/*The space before this brace must remain!*/
color:#CC3399;
}
table.fma b {
display:block;
padding:0.25em 0;
font-variant:small-caps;
text-transform:lowercase;
text-align:center;
text-indent:0;
}
table.fma br {
display:none;
}
table.fma {
width:141px;
font-family:tahoma,arial,sans-serif;
font-size:70%;
text-align:center;
}
td.fmb {
background-color:#ffffc0;
color:#000;
padding:5px;
padding-bottom:8px;
}
td.fma {
color:#fff;
background-color:#5b02d4;
padding:2px;
font-variant:small-caps;
text-transform:lowercase;
font-weight:bold;
}
td.fma:first-letter {
font-variant:normal;
text-transform:uppercase;
}
table.fma td.fmb {
text-align:justify;
text-indent:10px;
}
.fma img, .fma a {
font-size:9px;
}
.fma u,.fma center {
text-decoration:none;
text-align:left;
}
.fma img {
margin:6px -18px 2px 18px;
}

</style>
<div id="ephem2"></div>
<script type="text/javascript">
function getcontent(){
styles=document.getElementsByTagName('style')
for (var i_tem = 0; i_tem < styles.length; i_tem++)
if(styles[i_tem].innerHTML.indexOf('FeteFemme{')>-1)
styles[i_tem].parentNode.removeChild(styles[i_tem])
var theHTML=document.getElementById('ephem').innerHTML
theHTML=theHTML.replace(/&nbsp;/g, '')
theHTML=theHTML.replace(/<[sS][tT][yY][lL][eE][^>]*>[^>]*>/g, '')
theHTML=theHTML.replace(/<[sS][cC][rR][iI][pP][tT][^>]*>[^>]*>/g, '')
theHTML=theHTML.replace(/[sS][tT][yY][lL][eE]=['"][^"']*['"]/g, '')
theHTML=theHTML.replace(/<\/[bB]><[bB][rR]><[bB]>/g, '')
theHTML=theHTML.replace(/<\/[bB]> :/g, '</b>')
theHTML=theHTML.replace(/<\/[bB]>/g, '</b><div>')
var days=['lundi','mardi','mercredi','jeudi','vendredi','samedi','dimanche']
var Days=['Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche']
var months=['lundi','mardi','mercredi','jeudi','vendredi','samedi','dimanche','janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novemb re','décembre']
var Months=['Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novemb re','Décembre']
for (i_tem = 0; i_tem < days.length; i_tem++){
var re=new RegExp(days[i_tem],'g')
theHTML=theHTML.replace(re, Days[i_tem])
}
for (i_tem = 0; i_tem < months.length; i_tem++){
var re2=new RegExp(months[i_tem],'g')
theHTML=theHTML.replace(re2, Months[i_tem])
}
document.getElementById('ephem2').innerHTML=theHTML
document.getElementById('ephem').parentNode.removeChild(document.getElementById('ephem'))
}
function pollcontent(){
if(/<\/[tT][aA][bB][lL][eE]>/.test(document.getElementById('ephem').innerHTML)){
getcontent();
return;
}
else
setTimeout("pollcontent",200)
}
pollcontent();
</script>

glucarelli
06-03-2006, 11:54 PM
What can i say :)
Wonderfull
You are simply the best !!!
This is a complex solution.Let me some time to study it :rolleyes:

jscheuer1
06-04-2006, 02:57 AM
I just realized that this bit:


var days=['lundi','mardi','mercredi','jeudi','vendredi','samedi','dimanche']
var Days=['Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche']
var months=['lundi','mardi','mercredi','jeudi','vendredi','samedi','dimanche','janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novemb re','décembre']
var Months=['Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novemb re','Décembre']
for (i_tem = 0; i_tem < days.length; i_tem++){
var re=new RegExp(days[i_tem],'g')
theHTML=theHTML.replace(re, Days[i_tem])
}
for (i_tem = 0; i_tem < months.length; i_tem++){
var re2=new RegExp(months[i_tem],'g')
theHTML=theHTML.replace(re2, Months[i_tem])
}

Could be condensed to:


var dm=['lundi','mardi','mercredi','jeudi','vendredi','samedi','dimanche','janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novemb re','décembre']
var DM=['Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novemb re','Décembre']
for (i_tem = 0; i_tem < dm.length; i_tem++){
var re=new RegExp(dm[i_tem],'g')
theHTML=theHTML.replace(re, DM[i_tem])
}

There are probably other efficiencies that could be made. Also, this whole set up perhaps gives you more control over the style than you need but, you never know what you might want to change. Virtually all of the style is now in the stylesheet. If they decide to change the general layout of the output for this service, changes may be required in the code I've written but, I think I've followed the current layout closely enough that it should work with every day of the year, as currently laid out.

BTW, do you know of any English language equivalent of this service?

glucarelli
06-04-2006, 07:59 PM
Great everything working well :)
With an Css editor i can take control of everything in this .jsp file :D
Thank you very mutch.
It"s a french "habitude" to have this kind of news at the end of our newspapers,so except translating in the fly i don't know if you could find this kind of service in english btw i'm continuing searching for you ;)