20 December 2010

Bad Coding Habits -- Don't try this at home!

The first semester of college has concluded, which means that I have time to indulge in my hobbies, specifically photography! I was fortunate enough to have went to B&H, one of the largest pro creative shops, this past weekend and brought home a nice tripod, which I have been using extensively these past days mainly for low-light photography. The shots, one of which was posted yesterday, came out great; now I need a place to upload them.

Ah, what better place to upload than my own server.

That's right; a bit over a year ago, I wrote a nice little AJAX photo gallery, which could definitely use some work. So rather than exporting said photographs for the web, I got distracted by the dysfunction of the gallery and cracked open the code. I scroll down and see the following javascript:

function showAlbum(a) {
    path = a;
    var xmlhttp;
    if(window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if(xmlhttp.readyState == 4) {
            document.getElementById('ulfilmstrip').innerHTML = xmlhttp.responseText;
            var aaa = document.images;
            img_array = new Array();
            for(var bb = 0; bb < aaa.length; bb++) {
                if(aaa[bb].src.indexOf("cover") < 0) {
                    var cc = aaa[bb].src.split("/");
                    cc = cc[cc.length-1].split("_thmb");
            document.getElementById('filmHeader').innerHTML = a;


            window.onresize = resizeGal;
    xmlhttp.open("GET", "fetch.php?dir="+a, true);


Okay, so a is probably the album that we want to display…wait, what is aaa?! And bb?! And cc?!

No comments:

Post a Comment