can't add javascript. Trying to make a countup timer.

AtarashiPapaAtarashiPapa Registered Users Posts: 2 Beginner grinner
edited June 9, 2014 in SmugMug Customization
I've been interested in adding a countup timer to my entire site, but much of the code is ripped out, making the html useless. Maybe the best question to ask is how does one make a countdown/countup timer work in smugmug?

Comments

  • denisegoldbergdenisegoldberg Administrators Posts: 14,373 moderator
    edited June 9, 2014
    Javascript is not supported in new smugmug.

    --- Denise
  • AtarashiPapaAtarashiPapa Registered Users Posts: 2 Beginner grinner
    edited June 9, 2014
    Javascript is not supported in new smugmug.

    --- Denise

    Alrighty then. Thankyou. It's not very clear on the support pages, what is/isn't allowed for an html block, but it appears to be limited to simple code. So, what then will work when making a countup timer? Thanks for any help.
  • thenickdudethenickdude Registered Users Posts: 1,302 Major grins
    edited June 9, 2014
    The only way to do that on SmugMug at the moment would be to create a PHP (or other server-side language) page on another webserver which prints out an RSS feed with the counter in it. Then you could add that RSS feed to your SM site using the Social/Feeds content block. For example, if you create a PHP file called, say, feed.php, with this content:
    <?php
      header('Content-Type: application/rss+xml');
    ?><?xml version="1.0" encoding="utf-8"?>
    <rss version="2.0">
      <channel>
        <title>Countdown timer</title>
        <description></description>
        <link>http://www.sherlockphotography.org/</link>
        <item>
          <title>Timer</title>
          <link>http://www.sherlockphotography.org/</link>
          <description>
            <?php
    
            date_default_timezone_set('America/Los_Angeles');
    
            $now = new DateTime();
            $target = new DateTime('2014-07-01');
            $interval = $target->diff($now);
    
            echo $interval->format('%a days, %h hours left until the beginning of July!');
    
            ?>
          </description>
        </item>
      </channel>
    </rss>
    

    You can add the URL of that file to a Feeds content block, and the result looks like:

    yyE2IMQl.png

    Probably more trouble than it's worth, though.
Sign In or Register to comment.