Help with Penny-Arcade Active Desktop

Discussion in 'Windows Desktop Systems' started by Alvy, Feb 18, 2003.

  1. Alvy

    Alvy Guest

    Could anyone help me with an active desktop that will automatically update itself daily with the latest comic strip from
    http://www.penny-arcade.com/view.php3 ? I do not want to have the whole page on my desktop so simply putting the link is out of the question.
    Thanks a lot =)
     
  2. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    You'll need PHP to use this :
    Code:
    <html><head></head><body>
    <script language="JavaScript" type="text/javascript">
    function noImage(theImage)
    { theImage.src = "no.comic.today.png"; }
    </script>
    <?php
    $today = date(D);
    $pa = date(Ymd);
    if ($today == Tue) { $show = true; }
    elseif ($today == Wed) { $show = true; }
    elseif ($today == Fri) { $show = true; }
    else { $show = false; }
    if ( $show == true ) { print "<img src=\"http://penny-arcade.com/$pa"; print "l.gif\" border=\"0\" onError=\"noImage(this);\">"; }
    else { print "<img src=\"no.comic.today.png\" border=\"0\">"; }
    ?>
    </body></html>
    That's rather rough code though, I'm sure someone else will be able to do a better job, it may also be possible in just javascript.

    You could just visit the site everyday, I know I do ;)
     
  3. Alvy

    Alvy Guest

    Is it possible to show the previous day's comic if there ain't one available for the current day? =)

    Thanks Speedy, great job =) never knew someone would help me with such a big task.

    If possible, msg me on EFNet =)
    I'm Alv and idling in #NTFS too hehe

    --
    Oh yea, when I have it running, it keeps making the CPU do something (the LED blinks constantly until this active desktop is disabled), could you please fix that? I can't really use it now because of this =) Probably its because its checking for updates? Maybe you have to make this only at the beginning of a day?
     
  4. Piett

    Piett ...will circle this city

    Messages:
    528
    Location:
    Calgary, Alberta
    ohhh

    i'm definatly going to have to take a good look at this. that's for pounding that out speedy (btw: i go there everyday too =] )
     
  5. SPeedY_B

    SPeedY_B I may actually be insane.

    Messages:
    15,800
    Location:
    Midlands, England
    X-Istence helped me optmise the code a bit, so now we have this ..
    Code:
    <?php
    $today = date(D);
    $pa = date(Ymd);
    switch ($today) {
      case Mon:
          print "<img src=\"http://penny-arcade.com/images/2003/$pa"; print "l.gif\" border=\"0\" onError=\"noImage(this);\">";
          break;
      case Wed:
          print "<img src=\"http://penny-arcade.com/images/2003/$pa"; print "l.gif\" border=\"0\" onError=\"noImage(this);\">";
          break;
      case Fri:
          print "<img src=\"http://penny-arcade.com/images/2003/$pa"; print "l.gif\" border=\"0\" onError=\"noImage(this);\">";
          break;
      default:
         $date = date(d);
         $date--;
         $date2 = date(Ym);
         $pa = $date2 ."" . $date;
         print "<img src=\"http://penny-arcade.com/images/2003/$pa"; print "l.gif\" border=\"0\" onError=\"noImage(this);\">";
    }
    ?>
    Problems at present include end of month and viewing the page on a sunday, it'll be worked on tho :)

    I also found a Javascript version created by someone else.
    Code:
    <html>
    <head>
    <script language="JavaScript1.2">
    
      function reset_image(name, pad) {
    
         today = new Date();
         if (pad > 0) {
            today = new Date(today.getTime() - pad);
         }
    
         year = today.getYear();
         if (year > 2009) {
            year -= 2000;
            year = new String(year);
         }
         else if (year > 2000) {
            year -= 2000;
            year = '0' + new String(year);
         }
         else if (year > 9) {
            year = '0' + new String(year);
         }
         else {
            year = new String(year);
         }
    
         if (today.getMonth() > 8) {
            month = new String(today.getMonth() + 1);
         }
         else {
            month = '0' + new String(today.getMonth() + 1);
         }
    
         if (today.getDate() > 9) {
            day = new String(today.getDate());
         }
         else {
            day = '0' + new String(today.getDate());
         }
    
         setTimeout("reset_image('" + name + "', 0)", 3600000);
         if (name == 'penny') {
            url = 'http://www.penny-arcade.com/images/20' + year + '/20' + year + month + day + 'l.gif';
         }
         eval('document.' + name + '_invisible.src = url');
      }
    
    </script>
    </head>
    
    <body bgcolor="34629E" onLoad="reset_image('penny', 86400000);">
    <img name="penny_invisible" src="" onLoad="document.penny_visible.src=this.src" width="0" height="0" style="visibility: hidden">
    <img name="penny_visible" src="http://www.penny-arcade.com/images/2002/20020807l.gif" border="0">
    </body></html>