Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadInfoAsteroid (scope, num) {
- var $dataDiv = $('#data-div'),
- $secondDataDiv = $('#data-div-2'),
- $imageDiv = $('#image-div'),
- $this = $(scope.node);
- $dataDiv.html('');
- $secondDataDiv.html('');
- $imageDiv.html('');
- dataLoader.loadAttributes(num, function (data) {
- var len = data.length,
- $modalDiv = $('#asteroid-modal'),
- i = 0,
- img,
- p;
- for(i = 0; i < len; i++){
- p = $('<p/>').html(data[i].key + ': ' + data[i].value);
- if(i < len/2) {
- $dataDiv.append(p);
- } else {
- $secondDataDiv.append(p);
- }
- }
- img = $("<img />").attr('src', '/media/' + $this.attr('data-image-path'))
- .load(function() {
- if (!this.complete ||
- typeof this.naturalWidth == "undefined" ||
- this.naturalWidth == 0) {
- console.log('Image broken');
- } else {
- $imageDiv.append(img);
- }
- });
- $modalDiv.modal('show');
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement