Results 1 to 7 of 7

Thread: Search replace question

  1. #1
    Join Date
    Jun 2006
    Posts
    42
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Search replace question

    Hello all

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

    http://www.javascriptkit.com/script/...2/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.
    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Replace this:

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

    Code:
    <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.
    Last edited by jscheuer1; 06-03-2006 at 06:20 AM. Reason: Better Solution
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2006
    Posts
    42
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    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

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    <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','novembre','décembre']
    var Months=['Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','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>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jun 2006
    Posts
    42
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    What can i say
    Wonderfull
    You are simply the best !!!
    This is a complex solution.Let me some time to study it

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I just realized that this bit:

    Code:
    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','novembre','décembre']
    var Months=['Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','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:

    Code:
    var dm=['lundi','mardi','mercredi','jeudi','vendredi','samedi','dimanche','janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre']
    var DM=['Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi','Dimanche','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','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?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jun 2006
    Posts
    42
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default

    Great everything working well
    With an Css editor i can take control of everything in this .jsp file
    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

Bookmarks

Posting Permissions

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