Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         function loadInfoAsteroid (scope, num) {
  2.                 var $dataDiv = $('#data-div'),
  3.                     $secondDataDiv = $('#data-div-2'),
  4.                     $imageDiv = $('#image-div'),
  5.                     $this = $(scope.node);
  6.  
  7.                 $dataDiv.html('');
  8.                 $secondDataDiv.html('');
  9.                 $imageDiv.html('');
  10.  
  11.                 dataLoader.loadAttributes(num, function (data) {
  12.                     var len = data.length,
  13.                         $modalDiv = $('#asteroid-modal'),
  14.                         i = 0,
  15.                         img,
  16.                         p;
  17.  
  18.                     for(i = 0; i < len; i++){
  19.                         p = $('<p/>').html(data[i].key + ': ' + data[i].value);
  20.                         if(i < len/2) {
  21.                             $dataDiv.append(p);
  22.                         } else {
  23.                             $secondDataDiv.append(p);
  24.                         }
  25.                     }
  26.  
  27.                     img = $("<img />").attr('src', '/media/' + $this.attr('data-image-path'))
  28.                         .load(function() {
  29.                             if (!this.complete ||
  30.                                 typeof this.naturalWidth == "undefined" ||
  31.                                 this.naturalWidth == 0) {
  32.                                 console.log('Image broken');
  33.                             } else {
  34.                                 $imageDiv.append(img);
  35.                             }
  36.                         });
  37.  
  38.                     $modalDiv.modal('show');
  39.                 });
  40.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement