restyle getAvatar()

This commit is contained in:
Simon Grim 2016-01-17 23:45:38 +05:00
parent 65c5278169
commit e82959efde

View File

@ -365,7 +365,7 @@ function cleanupStorage() {
// get avatar and set it in img.attr("src") // get avatar and set it in img.attr("src")
// TODO rename to getAvatarImgToELem(), move nin theme related stuff to nin's theme_option.js // TODO rename to getAvatarImgToELem(), move nin theme related stuff to nin's theme_option.js
function getAvatar( username, img ){ function getAvatar(username, img) {
if (!img.length) if (!img.length)
return; return;
@ -375,24 +375,25 @@ function getAvatar( username, img ){
return; return;
} }
if( username in _avatarMap ) { if (_avatarMap[username]) {
//img.attr('src', "data:image/jpg;base64,"+avatarMap[username]); //img.attr('src', 'data:image/jpg;base64,'+avatarMap[username]);
img.attr('src', _avatarMap[username]); img.attr('src', _avatarMap[username]);
} else { } else {
var data = _getResourceFromStorage("avatar:" + username); var data = _getResourceFromStorage('avatar:' + username);
if( data ) { if (data) {
_avatarMap[username] = data; _avatarMap[username] = data;
img.attr('src', data); img.attr('src', data);
} else { } else {
dhtget( username, "avatar", "s", dhtget(username, 'avatar', 's',
function(args, imagedata) { function(req, imagedata) {
if( imagedata && imagedata.length ) { if (imagedata && imagedata.length) {
_avatarMap[args.username] = imagedata; _avatarMap[req.username] = imagedata;
_putResourceIntoStorage("avatar:" + username, imagedata); _putResourceIntoStorage('avatar:' + username, imagedata);
args.img.attr('src', imagedata); req.img.attr('src', imagedata);
} }
}, {username:username,img:img} ); }, {username: username, img: img}
);
} }
} }
} }