Wednesday, October 27, 2010

Web page slideshow

So I was tasked with making a web page slideshow for some community televisions at work, but after some research, all I was able to find were image slideshows.  Here's a simple page I threw together that uses a json configuration file to display multiple web pages for a defined period of time, and then slide to the next one.  Below is the html and javascript.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Slideshow</title>

<style>
body {
    overflow: hidden;
    cursor: none;
}

#page2 {
    display: none;
}
</style>

<script src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
    var slideshow;

    var iteration = 0;
    var timer;
    var slideshow_count = 0;
    var op;
    var fade_timer;
    var current_page = 1;

    //Initialize the slideshow settings from the json config file
    $(document).ready(function() {
        //This primes the loop and gets everything going

        //We're using the ajax method instead of getJSON because caching is automatically
        //turned off with the .ajax call.  Also, when specifying the dataType jsonp,
        //the returned json data is automatically placed into a script tag and executed
        //with the callback function.  Our data source here has a static callback called
        //slideshow_settings, so we don't have to pass anything extra in.
        $.ajax({
            url: "slideshow_settings.json",
            dataType: "jsonp"
        });
    });

    function get_next_iteration () {
        if (iteration + 1 >= slideshow_count) {
            return 0;
        }
        else {
            return iteration + 1;
        }
    }
   
    function other_page () {
        if (current_page == 1) {
            return 2;
        }
        else {
            return 1;
        }
    }

    function slideshow_settings (settings) {
        iteration = -1;

        slideshow = settings;
        slideshow_count = settings.dashboards.length;

        do_next();
    }

    function switch_pages () {
        $('#page' + current_page).fadeOut(1000, function() {
            $(this).css('display', 'none')
            $('#page' + other_page()).fadeOut(0, function() {
                $(this).fadeIn(1000, function() {
                    current_page = other_page();
                    $('#page' + other_page()).attr('src', slideshow.dashboards[get_next_iteration()].url);
                    timer = setTimeout(do_next, (slideshow.dashboards[iteration].duration * 1000));
                });
            });
        });
    }

    function do_next () {
        //Clean up after ourselves to prevent memory leaks
        clearTimeout(timer);

        //Loop has started anew.  Check our config file again.
        if (iteration+1 >= slideshow_count ) {
            $.ajax({
                url: "slideshow_settings.json",
                dataType: "jsonp"
            });
        }
        //Do the work
        else {
            iteration++;
            switch_pages();
        }
    }   
</script>
</head>

<body style="margin: 0px; scroll: off; background: black;">

<iframe id="page1" style="width: 1920px; height: 1080px; border: 0px;"></iframe>
<iframe id="page2" style="width: 1920px; height: 1080px; border: 0px;"></iframe>

</body>
</html>

Friday, October 8, 2010

Busy busy Daddy

I suppose this is the way all new parents feel.  The combination of contract work plus staying busy at the full time job keep me a very busy person.

Fiona is growing like a weed.  I noticed while Kim was holding her a few weeks ago that her legs were hanging down further than before.  It's weird how she can change so much when I see her every day.  Also, I'm not sure when it happened, but within the last month she has started sleeping through the night completely.  I feel fairly confident that it has to do with Kim's feeding schedule which was suggested by a book she read called Baby Wise.

The basic concept (that I've been able to glean from her discussions about it) is that the baby needs to get X number of ounces of milk a day.  As long as she's getting those ounces, you can slowly start giving her more during the day on a set schedule (meaning we have to wake her up if she's asleep) and at night, we don't bother waking her.  The result is that she eventually started sleeping longer at night.  I know for a couple of weeks that she was only getting up once at night and we were ecstatic about that.  Then, within the past two weeks (I think) we've had to wake her up at 7:30 to feed her.  After the horror stories I've heard about babies not sleeping through the night for the whole first year, I feel like we're very fortunate in the sleep department.

On the other hand, Fiona is still having some colicky symptoms during the day.  I think some folks think we're exaggerating about her fits of pain, but they're hard to ignore.  It got so bad that we took her to the doctor again a few days ago.  When we described the symptoms (Fiona's screams were blood curdling, she constantly clenched and unclenched her hands leaving scratch marks on herself and our arms and hands.  Her whole body was tensed and she thrashed around a lot.) the doc gave us a prescription for a medicine to help relax a spasmodic stomach and a new reflux medicine.  We've only had an opportunity to use the new anti-spasmodic drops a couple of times, but she seems to calm down immediately when we do.  I'm not sold on the idea, but anything that will relieve her pain is worth it.

She got to meet her grandmother and great grandmother on Kim's side a couple of weekends ago.  I'd met Kim's mother before, but had only heard about her grandmother and wasn't quite sure how the visit would turn out.  As it ends up, her grandmother is a riot and I ended up having a pretty good weekend.  I believe Kim's tension was higher than normal due to it being her family.  I get the same way with my family if I'm expecting a certain reaction and don't actually get it ;).

I should mention now that Fiona is smiling much more.  She doesn't even have to be on her changing table!  She's always in a good mood in the morning, and she gives mommy and daddy tons of big smiles.  I have to say, nothing makes my day more than to see her smile at me.  I can be in the worst of crap moods and instantly I'm better.  I long for the days of her laughing, talking, and running to see me when I come home from work.  I'm a sap like that.

And now....Pictures!!!

Super Fiona!

Package for you Daddy!

Mommy, that medicine is yucky.

Wearing down your defenses in 3...2...1...

It doesn't get cuter than this.


Going to try and update Facebook with all of the pictures I have of her, and upload any videos to Youtube.  Hopefully the next post will be about her laughing, or playing.  So far she doesn't do any of that...but any day now.