Results 1 to 6 of 6

Thread: Is there a "Weekly iframe content"-script?

  1. #1
    Join Date
    Jul 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Is there a "Weekly iframe content"-script?

    I've been looking all around for a quote of the day script and I really lite the style of the "Daily iframe content II"-script, partly because I don't want anything random about what content that's being showed. But my problem is that I don't want new content every day or new content every day of the month, I want a specific new quote to show every week. Every Monday to be more exact since I live in Sweden.

    And if the script can fetch the quotes from an easy to edit external text file I would be really happy, but thats not really necessary. I've found one solution but that included MySQL and a lot of shorts I don't even know what they stand for. I just wan't something that's easy to implement and easy to edit.

    Is there such a script or solution that has flown below my radar.

    Thank you in advance for your time and help.

    / Fizzgigg

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title>Weekly Quotes Script - Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript" src="quotes.js">
    /*//////////////////////////////////////////////////////
    * Weekly Quotes Script w/optional controls
    * 2007 - 2008 John Davenport Scheuer as first seen in Dynamic Drive Forums
    * http://www.dynamicdrive.com/forums - user name jscheuer1
    * This credit must remain for legal use.
    //////////////////////////////////////////////////////*/
    </script>
    <script type="text/javascript">
    function weekNum(){
    var thenum, d=new Date(), qs=quotes.split("^"), thelength=qs.length=qs.length-1;
    while (d.getDay()!=1)
    d=new Date(d.setDate(d.getDate()-1));
    thenum=(Math.ceil(((d.valueOf()-new Date(d.setMonth(0)).setDate(1))/(1000*60*60*24))/7))%(qs.length-1);
    document.getElementById('quote').innerHTML=qs[thenum].replace(/~/,'<br>~ ');
    }
    onload=weekNum;
    </script>
    </head>
    <body>
    <div id="quote"></div>
    </body>
    </html>
    You need the easily edited extrnal quotes.js file:

    Code:
    ////////////BEGIN QUOTES: (Start Editing after next line)//////////
    var quotes="\
    Sed ut perspiciatis unde omnis iste natus error sit voluptatem.~Plato^\
    Accusantium doloremque laudantium totam rem aperiam.^\
    Eaque ipsa quae ab illo inventore veritatis et quasi architecto.~Plato^\
    Beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia.^\
    Voluptas sit aspernatur aut odit aut fugit.~Plato^\
    Sed quia consequuntur magni dolores eos qui ratione.^\
    Voluptatem sequi nesciunt. Neque porro quisquam est.~Plato^\
    Qui dolorem ipsum quia dolor sit amet.^\
    Illegitimi Non Carborundum.~General 'Vinegar Joe' Stilwell^\
    At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.~Flavius Opus^\
    Consectetur, adipisci velit sed quia non numquam eius modi.~Plato^\
    Tempora incidunt ut labore et dolore magnam aliquam quaerat.^\
    Voluptatem. Ut enim ad minima veniam.~Plato^\
    Quis nostrum exercitationem ullam corporis suscipit laboriosam.^\
    Nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum.~Plato^\
    Iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur.^\
    Vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?~Socrates^\
    "; ///////////END QUOTES (Stop Editing, don't touch this line)////////////
    Any more than 52 quotes will be ignored, because it's based on the fact of 52 weeks per year. Less than 52 is fine, it will just start over at the beginning if there are still weeks left in the year and the last quote has already been used.
    Last edited by jscheuer1; 01-10-2008 at 03:03 PM. Reason: update code for beginning of the year bug
    - John
    ________________________

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

  3. #3
    Join Date
    Jul 2007
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Just to get things right: the code in the first frame goes into a quote.php and the code in the second frame in quotes.js. And it should really be 52 quote lines in quotes.js instead of the 17 that's there now, and each quote line should end with ^\.

    But I guess I do something wrong, I get a blank result where the quote should be.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    That pretty much sums it up. But you really don't need a full 52 quotes, that's just the upper limit. If you want to use your database for the quotes, that can be done, quotes.js becomes quotes.php and PHP code tokens may be used in the quotes.php file. I would suggest just getting it to work locally first with the first part copied exactly using a text only editor and saved as some_file.htm and having the quotes.js (also saved in a text only editor) in the same folder with it. One thing you left out, if you notice, each individual quote line may not have a line-break in it. Actually you should be able to break the line with a \ with no ^. That's just for typing it in, if you want a line-break in the output, use a <br> tag.

    Another thing, no actual quote (") characters may be used in the quotes without prefacing them with a \.

    You can style the division with the id of quote, just as you would any other division. If you give it a width, long quotes will wrap within it without needing a <br>.

    The code can be tweaked in several ways to suit, so if there is a formatting issue that you cannot solve, just ask.
    - John
    ________________________

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

  5. #5
    Join Date
    Jan 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Trouble with weekly quote code

    Hello!

    I am having a small problem. I used this script, it worked perfectly till the end of year 2007 but from this year on it doest want to work? Now I get a blank result where the quote should be. Why? Could you help me?

    Thanks in advance

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,190 Times in 3,154 Posts
    Blog Entries
    12

    Default

    I see what you mean, I wasn't rounding up at the right place. This results in a number that isn't an integer for the first weeks in any given year. I've corrected this in the original, but here is the new code with the additional parenthesis (there are two added) highlighted red:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title>Weekly Quotes Script - Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript" src="quotes.js">
    /*//////////////////////////////////////////////////////
    * Weekly Quotes Script w/optional controls
    * 2007 - 2008 John Davenport Scheuer as first seen in Dynamic Drive Forums
    * http://www.dynamicdrive.com/forums - user name jscheuer1
    * This credit must remain for legal use.
    //////////////////////////////////////////////////////*/
    </script>
    <script type="text/javascript">
    function weekNum(){
    var thenum, d=new Date(), qs=quotes.split("^"), thelength=qs.length=qs.length-1;
    while (d.getDay()!=1)
    d=new Date(d.setDate(d.getDate()-1));
    thenum=(Math.ceil(((d.valueOf()-new Date(d.setMonth(0)).setDate(1))/(1000*60*60*24))/7))%(qs.length-1);
    document.getElementById('quote').innerHTML=qs[thenum].replace(/~/,'<br>~ ');
    }
    onload=weekNum;
    </script>
    </head>
    <body>
    <div id="quote"></div>
    </body>
    </html>
    Last edited by jscheuer1; 01-10-2008 at 03:16 PM. Reason: get the highlights in the right place
    - John
    ________________________

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

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
  •