Advertisement
Guest User

function loop problem

a guest
Nov 29th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function buildThumbs() {
  2.         // voeg materiaal aan thumbs query toe
  3.         if (!(materiaal === 'undefined')) {
  4.             album += '&materiaal=' + materiaal;
  5.         }
  6.         current = 1;
  7.         $('#imageWrapper').empty();
  8.         $('#loading').show();
  9.         $.get(baseurl + 'thumbs?album=' + album, function (data) {
  10.             var countImages = getDataLength(data),
  11.                 count = 0,
  12.                 $tContainer = $('<div/>', {id: 'thumbsContainer', style: 'visibility:hidden;'}),
  13.                 thumb, // filling thumbswrapper here
  14.                 i = 0,
  15.                 $this;
  16.             while (i < countImages) {
  17.                 if (countImages === 1) {
  18.                     thumb = data;
  19.                 } else {
  20.                     thumb = data[i];
  21.                 }                
  22.                 $('<img  desc="' + thumb.desc + '" alt="' + thumb.alt + '" height="75" />').load(function () {
  23.                     $this = $(this);
  24.                     $tContainer.append($this);
  25.                     count = count + 1;
  26.                     if (count === 1) {
  27.                         loadPhoto($this, "cursorPlus");
  28.                     }
  29.                     if (count === countImages) {
  30.                         $('#thumbsWrapper').empty().append($tContainer);
  31.                         thumbsDim($tContainer);
  32.                         makeScrollable($('#thumbsWrapper'), $tContainer, 15);
  33.                     }
  34.                 }).attr('src', thumb.src);
  35.                 i = i + 1;
  36.             }
  37.         }, 'json');
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement