Archive for the ‘JavaScript’ Category

Intro

OOP is a great concept, it simplifies the programmer’s life, especially in the field of interface development. Nearly all modern web-interfaces use JS in some way – for field highlighting, validation, help etc. It’s OK when there are such simple things.
And now imagine, that we have a set of dialogue windows (HTML+CSS) for adding a comment, rating, sending to the friend. Each of these boxes has a number of functions – check if user is logged in(if not – show login form), send AJAX request, process response, show error/success messages, position the box on the page etc.

Continue reading ‘OOP in jQuery’ »

Recently I’ve learned one nice trick with for loop. When you use it, you should know he number of itereations. Most people do it like this:

  1.  
  2. $a = array(1,2,3,4,5);
  3. $s = sizeof($a);//you may use count(), but sizeof if 5% faster :)
  4. for ($i = 0; $i < $s; $i++)
  5. {
  6. //do something clever here
  7. echo $a[$i].
  8. ;
  9. }
  10.  

But this requires counting number of elements before using a loop. Continue reading ‘Nice trick with FOR loop’ »