|
|
@ -6,6 +6,7 @@ function Images(callback) { |
|
|
|
this.images = {}; |
|
|
|
this.imageBroken = {}; |
|
|
|
this.callback = callback; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -14,7 +15,7 @@ function Images(callback) { |
|
|
|
* @param {string} url Url of an image to use if the url image is not found |
|
|
|
* @return {Image} img The image object |
|
|
|
*/ |
|
|
|
Images.prototype.load = function(url, brokenUrl) { |
|
|
|
Images.prototype.load = function(url, brokenUrl, id) { |
|
|
|
var img = this.images[url]; // make a pointer
|
|
|
|
if (img === undefined) { |
|
|
|
// create the image
|
|
|
@ -44,7 +45,7 @@ Images.prototype.load = function(url, brokenUrl) { |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
if (me.imageBroken[url] === true) { |
|
|
|
if (me.imageBroken[id] && me.imageBroken[id][url] === true) { |
|
|
|
console.error("Could not load brokenImage:", brokenUrl); |
|
|
|
delete this.src; |
|
|
|
if (me.callback) { |
|
|
@ -54,7 +55,10 @@ Images.prototype.load = function(url, brokenUrl) { |
|
|
|
else { |
|
|
|
console.error("Could not load image:", url); |
|
|
|
this.src = brokenUrl; |
|
|
|
me.imageBroken[url] = true; |
|
|
|
if (me.imageBroken[id] === undefined) { |
|
|
|
me.imageBroken[id] = {}; |
|
|
|
} |
|
|
|
me.imageBroken[id][url] = true; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|