I recently had to add some minor features to an old web site that was developed by an ex collegue of mine. I knew the web site was some years old and I know he was not the best developer of the world…. but what I’ve found exceeds the worst of my nightmares!
I can’t even imagine why someone would ever write such an idiot piece of code (I’ve replaced the links text with OMISSIS):
protected void Page_Load(object sender, EventArgs e) { StringBuilder r = new StringBuilder(); r.Append("<ul>"); r.Append("<li><a href='?1' class='firstLev01'>(OMISSIS)</a></li>"); r.Append("<li><a href='?2' class='firstLev02'>(OMISSIS)</a></li>"); r.Append("<li><a href='?3' class='firstLev03'>(OMISSIS)</a></li>"); r.Append("<li><a href='?4' class='firstLev04'>(OMISSIS)</a></li>"); r.Append("<li><a href='?5' class='firstLev05'>(OMISSIS)</a></li>"); r.Append("<li><a href='?6' class='firstLev06'>(OMISSIS)</a></li>"); r.Append("<li><a href='?7' class='firstLev07'>(OMISSIS)</a></li>"); r.Append("<li><a href='?8' class='firstLev08'>(OMISSIS)</a></li>"); r.Append("<li><a href='?9' class='firstLev09'>(OMISSIS)</a></li>"); r.Append("<li><a href='?10' class='firstLev10'>(OMISSIS)</a></li>"); r.Append("<li><a href='?11' class='firstLev11'>(OMISSIS)</a></li>"); r.Append("<li><a href='?12' class='firstLev12'>(OMISSIS)</a></li>"); r.Append("<li><a href='?13' class='firstLev13'>(OMISSIS)</a></li>"); r.Append("</ul>"); menu1.InnerHtml = r.ToString(); }
and another, artistic (?), one:
strJs = "<SCRIPT LANGUAGE=\"javascript\">"; strJs += "var num_menu=" + numeroVoci + ";"; strJs += "var active_menu=0;"; strJs += "var obj;"; strJs += "var img;"; strJs += "var link;"; strJs += "var aperto=0;"; strJs += "function change(menu,objlink)"; strJs += "{"; strJs += " for (var i=1;i<=num_menu;i++)"; strJs += " {"; strJs += " obj=MM_findObj(\"sub\"+i);"; strJs += " link=MM_findObj(\"link\"+i);"; strJs += " if(obj)"; strJs += " {"; strJs += " if (i==menu )"; strJs += " {"; strJs += " MM_swapImage(\'freccia\'+i,\'\',\'images/leftNavFreccia01Over.gif\',1);"; strJs += " link.className=\"linkBlueBold\";"; strJs += " active_menu=i;"; strJs += " }"; strJs += " else"; strJs += " {"; strJs += " MM_swapImage(\'freccia\'+i,\'\',\'images/leftNavFreccia01Out.gif\',1);"; strJs += " link.className=\"linkGrey\";"; strJs += " }"; strJs += " }"; strJs += " }"; strJs += "}"; strJs += " function showOrHideControl(id)"; strJs += " {"; strJs += " if (document.getElementById(id).style.display == 'none')"; strJs += " {"; strJs += " if (aperto!=0)"; strJs += " document.getElementById(aperto).style.display='none';"; strJs += " document.getElementById(id).style.display='block';"; strJs += " aperto=id;"; strJs += " }"; strJs += " else"; strJs += " document.getElementById(id).style.display='none';"; strJs += " }"; strJs += "</SCRIPT>";
I usually laugh when I see something like that, but this time I have to put my hands in this shit so I’m really angry… I can’t forgive him for his heritage!