Skip to content

Commit 4276a35

Browse files
Prevent setting img src to undefined due to imageSpinnerSrc being undefined.
1 parent 3669f55 commit 4276a35

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

www/js/app.js

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,9 @@ angular.module('zmApp', [
522522

523523
// show an image-missing image
524524
$element.bind('error', function () {
525-
526525
loader.remove();
527526

528-
529527
var url = 'img/noimage.png';
530-
531-
532528
var w = $attributes.imgSpinnerW;
533529
var h = $attributes.imgSpinnerH;
534530

@@ -540,8 +536,7 @@ angular.module('zmApp', [
540536
objectFit: 'fill'
541537
});*/
542538

543-
544-
// console.log ("**********"+w+"X"+h);
539+
console.log ("**********"+w+"X"+h);
545540
// var hurl = "holder.js/2000x$2000?auto=yes&theme=sky&text=...";
546541

547542
$attributes.$set('data-src', 'holder.js/' + w + 'x' + h + '?auto=yes&theme=industrial&text=...');
@@ -553,7 +548,6 @@ angular.module('zmApp', [
553548
// $element.prop ('width', w+'px');
554549
// $element.prop ('height', h+'px');
555550

556-
557551
// $element.css({backgroundImage: 'url("' + url + '")'});
558552
//$attributes.$set('src', url);
559553
// $element.prop('data-src', hurl);
@@ -564,8 +558,7 @@ angular.module('zmApp', [
564558
//console.log (">>>> ERROR CBK");
565559
$scope.imageOnError();
566560
// fn($scope, {});
567-
}
568-
else {
561+
} else {
569562
//console.log (">>>>>>>>>> NO ERROR CBK");
570563
}
571564

@@ -577,7 +570,6 @@ angular.module('zmApp', [
577570
imageLoadingDataShare.set(0);
578571
//console.log ("IMAGE LOADED");
579572
});
580-
581573
}
582574

583575
function loadImage() {
@@ -587,7 +579,6 @@ angular.module('zmApp', [
587579
loader.remove();
588580

589581
if ($attributes.imageonload) {
590-
591582
$scope.$apply($attributes.imageonload);
592583
// fn($scope, {});
593584
}
@@ -601,7 +592,6 @@ angular.module('zmApp', [
601592
function () {
602593
waitForFrame1();
603594
});
604-
605595
}
606596
});
607597

@@ -613,7 +603,6 @@ angular.module('zmApp', [
613603
}
614604
// set style attribute on element (it will load image)
615605
if (imageLoadingDataShare.get() != 1)
616-
617606
$element[0].style.backgroundImage = 'url(' + $attributes.imageSpinnerSrc + ')';
618607

619608
//$element[0].style.backgroundImage = 'url(' + 'img/noimage.png'+ ')';
@@ -623,16 +612,14 @@ angular.module('zmApp', [
623612
bgImg.src = $attributes.imageSpinnerSrc;
624613

625614
} else {
626-
627615
var ld = NVR.getLogin();
628-
if (ld.isUseAuth && $rootScope.authSession=='' ) {
629-
NVR.log ("waiting for authSession to have a value...");
630-
631-
} else {
616+
if (ld.isUseAuth && ($rootScope.authSession=='')) {
617+
NVR.log("waiting for authSession to have a value...");
618+
} else if ($attributes.imageSpinnerSrc) {
632619
$element[0].src = $attributes.imageSpinnerSrc; // set src
620+
} else {
621+
NVR.log("No imageSpinnerSrc!");
633622
}
634-
635-
636623
}
637624
}
638625

0 commit comments

Comments
 (0)