Preview
This code allows you to display the user's avatar anywhere that you so wish. It's rather awesome to be honest!
Global Header:
<script type="text/javascript">
/*Avatar Anywhere
Coded By Wrighty*/
var functions = {
av: document.createElement('img'),
save: function(prefix, item, place){
if(get(place,'name')[0].value.match('{'+prefix+': (.+?)}')){
get(place,'name')[0].value = get(place,'name')[0].value.replace(RegExp.$1, item);
}else{
get(place,'name')[0].value += '{'+prefix+': '+item+'}';
}
},
load: function(prefix){
if(vf_hiddenvars.match('{'+prefix+': (.+?)}')){
return RegExp.$1.replace(/(\[|\])/g,'');
}else{
return '';
}
},
build: function(){
with(this.av){
src = this.load('av-url');
height = this.load('av-height');
width = this.load('av-width');
}
get('av_hold','id').appendChild(this.av);
}
}
</script>
Global Footer:
<script type="text/javascript">
/*Avatar Anywhere
Coded By Wrighty*/
if(location.href.match(/\/modify_profile\/user\/(.+?)($|\/$)/) && RegExp.$1 == vf_username){
var f = document.profile_form
if(document.addEventListener){
f.addEventListener('submit', function(){ functions.save('av-url','['+get("avatar_url","name")[0].value+']','hidden'); functions.save('av-width', '['+get("avatar_width","name")[0].value+']', 'hidden'); functions.save('av-height', '['+get("avatar_height","name")[0].value+']', 'hidden');} , false);
}else{
f.attachEvent('onsubmit', function(){ functions.save('av-url','['+get("avatar_url","name")[0].value+']','hidden'); functions.save('av-width', '['+get("avatar_width","name")[0].value+']', 'hidden'); functions.save('av-height', '['+get("avatar_height","name")[0].value+']', 'hidden');});
}
}
functions.build();
</script>
Now, to decide where to put the avatar, we use a simple 'div' with id: 'av_hold'. The code will then put the avatar in that div with the correct height and width too!
<div id='av_hold'></div>
Enjoy.
You know its coming.....Were is the preview?
>.< Fine...
<_> ^_-
Added, not very good though...
wondering, this may sound a little weird but could it even be used an a place where you put in a url such as the on/off icon places?
No, but a code could be made to use the avatar as an on/off icon!
no its ok, i was just wondering to what extent that it could be used.
it looks ok I guess, but pointless, you can just add Html Tags from Photobucket or image shack. and put it any were in the head/foot of any board, even the board Description.
Wrighty has a new soulmate: hidden_vars.
Whens the wedding Wrighty boy?
it looks ok I guess, but pointless, you can just add Html Tags from Photobucket or image shack. and put it any were in the head/foot of any board, even the board Description.
But this code makes it so whoever is logged in's avatar appears, if you logged in you'd see your avatar in that place while I'd see mine. If you wanted everyone to see your avatar you could do what you said ;]
Nice code Wrighty, could come in handy very soon =]
Wrighty has a new soulmate: hidden_vars.
Whens the wedding Wrighty boy?
Tomorrow, you're the best man!
Thanks Fel!x
Nice concept of a code. o_o. I can see people using JavaScript to make their own Welcome Table and using this to be a part of it. o_o.
Bloody brilliant, mate.
it looks ok I guess, but pointless, you can just add Html Tags from Photobucket or image shack. and put it any were in the head/foot of any board, even the board Description.
But this code makes it so whoever is logged in's avatar appears, if you logged in you'd see your avatar in that place while I'd see mine. If you wanted everyone to see your avatar you could do what you said ;]
Nice code Wrighty, could come in handy very soon =]
For that point, then that's alright.