Tuesday, October 19, 2010

Horrible Javascript Code

      var class_schedules_text = '';
class_schedules.each(function() {
class_schedules_text = class_schedules_text + $(this).html();
});
parts = class_schedules_text.split('</strong>');
class_schedules_text = parts[1];
class_schedules_text = '<div style="width: 280px; margin-bottom: 10px; float: left; margin-left:
5px;font-size: 12px;">'+class_schedules_text+'</div>';

What it was replaced with

var class_schedules_text = class_schedules.html().replace(/<[^b].*?>/g,'');

Remember, there are two ways of doing layout

  1. Know what you are doing and do it
  2. Use excessive markup to eventually coerce the elements into place


For instance,

box_content += "<p><div style='overflow: auto;'>
<label style='float: left; margin-right:3px;font
-size: 12px;'>Schedule:</label><ul style='margin
:0; padding:0; float: left; font-size:12px;'>"+c
lass_schedules_text+"</ul></div></p>";

Becomes:

box_content += "<p>"+class_schedules_text+"</p>";

4 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
    Replies
    1. This comment has been removed by a blog administrator.

      Delete
    2. This comment has been removed by a blog administrator.

      Delete
  2. This comment has been removed by a blog administrator.

    ReplyDelete

Followers