Fixed playerfaces not showing in sidebar.

This commit is contained in:
FrozenCow 2011-08-30 21:16:46 +02:00
parent 56faab71e2
commit d88763f179

View File

@ -9,35 +9,10 @@ function createMinecraftHead(player,size,completed,failed) {
faceImage.src = dynmap.options.tileUrl + 'faces/' + size + 'x' + size + '/' + player + '.png'; faceImage.src = dynmap.options.tileUrl + 'faces/' + size + 'x' + size + '/' + player + '.png';
} }
var playerHeads = {};
function getMinecraftHead(player,size,completed) { function getMinecraftHead(player,size,completed) {
var key = player + '.' + size; createMinecraftHead(player, size, completed, function() {
var head = playerHeads[key]; console.error('Failed to retrieve face of "', player, '" with size "', size, '"!')
// Synchronous
if (!completed) {
return (!head || head.working) ? null : head;
}
// Asynchronous
if (!head) {
playerHeads[key] = { working: true, hooks: [{f:completed}] };
createMinecraftHead(player, size, function(head) {
hooks = playerHeads[key].hooks;
playerHeads[key] = head;
var i;
for(i=0;i<hooks.length;i++) {
hooks[i].f(head);
}
}, function() {
}); });
} else if (head.working) {
//console.log('Other process working on head of ',player,', will add myself to hooks...');
head.hooks[head.hooks.length] = {f:completed};
} else {
completed(head);
}
} }
function getMinecraftTime(servertime) { function getMinecraftTime(servertime) {