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