Hein (fub) wrote,

  • Mood:

Hacking Javascript

This week, I have been hacking a site together for klik's photo expedition.

She gave me a raw sketch of how it should look, and how it should behave. Re-using the CMS I wrote for Creative Contraptions (which still isn't online) for this site would be overkill and require some rework of the system, so that was not a viable option. But building every page by hand also was not an option.

So I devised a cunning plan to create a site that is completely built up through DHTML. Specifying the site structure is only a matter of calling a Javascript function repeatedly with the right parameters -- something that klik can do herself. Maintaining the site then doesn't require any intervention from me, as it should be.

I decided to take the plunge and use Javascript OOP (or maybe I should call it 'OIP': Object Inspired Programming...). Works pretty well, except for one quirk that took me an hour to solve.
If you have an Array of objects, you can traverse the array in two ways: either you use a for-loop with an integer to index every item in the Array, or you use a "for (var x in Array)" construct. In the latter manner, your variable is not recognised as an Object -- but in the first, it is.

Why this is, is completely beyond me.
Tags: technology

  • Update

    Wow, what with one thing and another, I haven’t posted on here in a month! Time to give a short update on what’s been happening.…

  • Final RPG-a-Day: Thank

    The last prompt for RPG-a-Day this year is ‘Thank’. If you have read every entry of this year’s RPG-a-Day, then I certainly…

  • Next-to-last RPG-a-Day: Mention

    Today’s prompt is ‘Mention’. I guess this is where I mention people I look up to, or websites I frequent? Ok, here’s…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded