<?php
    session_start();
    $phpself = $_SERVER['PHP_SELF'];
    if ( isset($_GET['about']) ) {
?>
<html>
<head>
    <title>About Square Wave</title>
</head>
<body>
<h1>About Square Wave</h1>
<p>
Hi! I'm Steve Hanov, the creator of Square Wave.
<p>
<a href="../blog/">My home page</a>
<p>
Square Wave started at the University of Waterloo in 2001. I was trying to
procrastinate while studying for exams, so instead of studying I drew comic
strips. I made ten initial strips, which I submitted to Imprint a few months
later. The student newspaper printed them, and all was good. The comic strip
ran under the name "Number's Game" because it was about math students trying to
get girlfriends -- which was my situation at the time.
<p>
Later on, I graduated and began to work at Research in Motion. I work as a
programmer, and every day I have to deal with expensive radio test equipment
and sheilded rooms and all of the things that you see in the comic today.

<p>
<a href="<?= $phpself ?>">Back to comics</a>
</body>
</html>
<?php } else { ?>


<?php
    $DATES = array(
'20020919' => "Girls always assume I'm trying to pick them up.",
'20021004' => "",
'20021018' => "",
'20021101' => "",
'20021115' => "",
'20021129' => "",
'20021213' => 
    "This is based on Pat O'Neil when we were both in the lab taking CS 370 ".
    "one night.",
'20021227' => "",
'20030110' => 
    "The math cafe is very small, but serves thousands each day.",
'20030124' => 
    "My most popular strip ever. I was in co-op through the tech bubble and ".
    "I saw a remarkable change when it burst.",
'20030207' =>
    "This was never published, because I accidentally drew the last panel ".
    "too small. Now, years later, it has been digitally remastered. (The ".
    "student is supposed to be Colin Bird)",
'20030217' =>
    "The previous week, the sex columnist had written a story on ".
    "'going commando', which is not wearing underwear.",
'20031024' => "",
'20031107' => 
    "Programmers hate ambiguous specifications.",
'20031205' => 
    "Its fun to watch people in the RIM parking lot.",
'20031219' => "",
'20040116' => "",
'20040213' => "",
'20040227' => 
    "I've been on dates where the girl just talked and talked and wouldn't ".
    "let me say anything.",
'20040312' => 
    "This is my <del>girlfriend's</del> wife's favourite.",
'20040326' => "",
'20040408' => 
    "Without warning one week, all these walls sprung up around our cubes.",
'20040506' => 
    "This happens a lot at RIM.",
'20040521' =>
    "\"My experiment is a failure. 500 monkeys typing on typewriters for 50 ".
    "years have failed to produce anything close to Shakespeare. All we get ".
    "are specifications describing some kind of telecommunications system.\"",
'20040604' => "",
'20040618' => 
    "People asked me to do a comic about one of the co-op students who had a ".
    "reputation for eating a lot.",
'20040701' => 
    "We had a canoe trip for a team-building event, but some of us couldn't ".
    "go because the deadline was the next day.",
'20040716' => "",
'20040730' => "",
'20040813' => 
    "I'm not proud of this one. In case you're wondering, the phone is ".
    "taking a picture of the inside of his pocket. Also, that day I did'nt ".
    "have my Sharpy marker, so I had to use a ball-point pen for the drawing.",
'20040827' => "",
'20041008' => "",
'20041022' => "It is perfectly logical. Why doesn't everybody do this?.",
'20041105' => "It's supposed to be like tetris, but a lot of people don't see it.",
'20041203' => "",
'20041215' => "",
'20050114' => "",
'20050128' => "",
'20050211' => "",
'20050311' => "",
'20050324' => "",
'20050408' => "",
'20050511' => "",
'20050610' => "",
'20050722' => "Cell phones have to go through lots of external testing.",
'20090708' => "Four years later. The comic strip is renamed Startup Ink here.",
'20090709' => "When programmers design web sites",
'20090711' => "If you've ever demo'd a web site, you have to be careful what you click on",
'20090712' => "Thanks to xkcd",
'20090719' => "Doesn't everybody dream of living the good life and hob-nobbing with royalty?",
'20090720' => "Microsoft is very helpful to entrepreneurs, compared to Apple.",
'20090721' => "Each year, a famous V.C. named Paul Graham publishes a list of his problems that he wants you to solve.",
'20090722' => "Many CEOs start out fixing toilets.",
'20091003' => "",
'20091004' => "I don't really like this one because it's too negative. Once I have a few more in the series I'll probably delete it from the collection.",

    );
    krsort($DATES);

if ( $_GET['whichdate'] ) {
    $whichdate = $_GET['whichdate'];
} elseif ( $_SESSION['whichdate'] ) {
    $whichdate = $_SESSION['whichdate'];
}
    
if ( !isset($whichdate) || !isset($DATES[$whichdate]) ) {
    $keys = array_keys($DATES);
    $whichdate = $keys[0];
}
?>
<html>
<head>
    <title>Square Wave</title>
    <style type="text/css">
        <!--
        div#main {
            margin-left: 90px;
            margin-top: 0px;
        }
        -->
    </style>
    <meta property="og:title" content="Square Wave">
    <meta name"twitter:title" content="Square Wave">
    <meta name="twitter:creator" content="@smhanov">
    <meta name="twitter:card" content="summary_large_image">
    <?php
    echo "<meta property=\"og:image\" content=\"https://stevehanov.ca/comics/comic_${whichdate}.png\">\n";
    echo "<meta name=\"twitter:image\" content=\"https://stevehanov.ca/comics/comic_${whichdate}.png\">\n";
    ?>
</head>
<body>

<SCRIPT LANGUAGE="JavaScript">
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+"<?php echo $_SERVER['PHP_SELF'] ?>?whichdate="+selObj.options[selObj.selectedIndex].value+"'"); 
  if (restore) selObj.selectedIndex=0;
}
</SCRIPT>
<center>

<font face="Verdana,Arial,Helvetica" color="#800000"><h1>Square Wave</h1></font>
<table width=700>
<tr>
<td>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method=get>
<select name=whichdate onChange="MM_jumpMenu('self',this,0)">
<?php

    function nice_date($date)
    {
        $Months = array( '', 'January', 'February', 'March', 'April', 
                'May', 'June', 'July', 'August', 
                'September', 'October', 'November', 'December' );

        if ( preg_match('/(\d\d\d\d)(\d\d)(\d\d)/', $date, $captured ) ) {
            //echo("$date: $captured[1] $captured[2] $captured[3]");
            return sprintf("%s %d, %d", $Months[(int)$captured[2]], $captured[3],
                $captured[1]);
        } else {
            return "Bad date";
        }
    }

    $_SESSION['whichdate'] = $whichdate;
    $prev = 0;

    foreach( $DATES as $date => $text ) {
        $selected = "";
        if ( $date == $whichdate ) {
            $selected = 'selected';
            $prev = 1;
            $next = $temp;
        } elseif ( $prev == 1 ) {
            $prev = $date;
        }
        $temp = $date;
        printf("<option $selected $date value=\"%s\">%s</option>\n", $date,
            nice_date($date));
    }
?>
</select>
</form>
</td>
<td>
<p align=right>
<?php
    if ( $prev > 1 ) {
        echo "<a href=\"${_SERVER['PHP_SELF']}?whichdate=$prev\">Previous</a>";
    } else {
        echo "Previous";
    }
    echo " | ";
    if ( $next > 1 ) {
        echo "<a href=\"${_SERVER['PHP_SELF']}?whichdate=$next\">Next</a>";
    } else {
        echo "Next";
    }
?>
</p>
</td>
</tr>
</table>
<p>
<?php
    echo "<img src=\"comic_${whichdate}.png\"\\>\n";
?>
</p>
<p>
<font color="#800000" face="Comic Sans MS">
<?php
    if ( $DATES[$whichdate] ) {
        echo $DATES[$whichdate];
    }
?>
</font>
</p>
<p>
<a href="?about">About Square Wave</a> | <a href="mailto:steve.hanov@gmail.com">Email Steve</a>
</center>
</body>
</html>
<?php } ?>
