VB/C# -> JS -> HTML



  • My programming job isn't WTF at all. The code I write/maintain is sometimes buggy/low-quality, but nothing so special about it.

    And of couse, everyone thinks of me as 'The IT Guy', so I find myself installing software, rebooting PC's, pluggin' in power cord's etc...

     So, when my friend came to me, asking to do some real programming job, I was all interested and willing to help.

    The task looked simple enough:  Online Gaming Championship ( my friend was one of the organizers ) needed to publish brackets on the web.

    Software they used was called Master of Tourneys, and it internally supported "HTML export" so it shouldn't be a problem, right?

    Not really. They wanted me to utilize my JS skills to add cool-looking tooltips to the bracket. If some user would point their mouse over a Team Name, tooltip containing all the various info will appear.

    I downloaded some JS lib, played with it, and it worked fine. Tooltips was a really easy feature to do, so I opened an archive sent to me by my friend, and started to work on a real thing.

    All "team info" was in .xml file, nicely organized and easy to use. At that moment I thought: "piece of cake".

    That is, until I opened the actual brackets .html file.

    And there was the WTF.

    Brackets where done with tables. And... I mean, that was no usual  HTML tables, they were fully JS-generated.

    Yes, actually at the beginning of the file there was this JS function^

    <script language="JavaScript" type="text/javascript">
    function t(r, h, w, c, i, t, s)
    {
    if (i.length==0) {i='';} else {i='<img src="icons/'+i+'">';}
    if (t.length==0) {t='&nbsp;';}
    if (s.length==0) {s='';}
    document.write('<td class="' + c + '" rowspan="' + r + '">');
    document.write('<table><tr>');
    document.write('<td class="' + c + 'Xi">' + i + '</td>');
    document.write('<td class="' + c + 'Xt">' + t + '</td>');
    document.write('<td class="' + c + 'Xs">' + s + '</td>');
    document.write('</tr></table>');
    document.write('</td>');
    }
    </script>

    So the table was generated kinda like this:

    <tr>
    <script>
    t(1, 25, 170, 'hc', '', 'Stage 1', '');
    t(2, 50, 25, 'ne', '', '', '');
    t(1, 25, 170, 'hc', '', 'Stage 2', '');
    t(3, 75, 25, 'ne', '', '', '');
    t(1, 25, 170, 'hc', '', 'Semi-Finals', '');
    t(5, 125, 25, 'ne', '', '', '');
    t(1, 25, 170, 'hc', '', 'Finals', '');
    </script>
    </tr>

     No matter, how I thought about that, I couldnt imagine why the f... they did that.

    They actually generated a fine XML in "export teams info" function, but in "HTML export" they did this.

     Ofc, I managed to get the job done, and it wasn't hard or anything.

    Still, I  cannot think of a reason for developer to generate HTML that way, when there is tons of nice XML libs out there. 

    And, if you think about it, this WTF wasn't made because of stupidity of something. Maybe they made JS developer to write this only function, because all other devs were absent.

    Who knows...


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.