vForums Support > Programming & Coding :: Database of Codes/Hacks/Mods :: > Avatar Anywhere

Avatar Anywhere - Posted By Michael (wrighty) on 8th Mar 08 at 11:20pm
Preview

This code allows you to display the user's avatar anywhere that you so wish. It's rather awesome to be honest! {Tongue Out}

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! {Smile}

<div id='av_hold'></div>


Enjoy.

Re: Avatar Anywhere - Posted By Nick (nickb) on 8th Mar 08 at 11:32pm
You know its coming.....Were is the preview? {Tongue Out}

Re: Avatar Anywhere - Posted By Michael (wrighty) on 8th Mar 08 at 11:36pm
>.< Fine...

Re: Avatar Anywhere - Posted By Nick (nickb) on 8th Mar 08 at 11:39pm
<_> ^_-

Re: Avatar Anywhere - Posted By Michael (wrighty) on 8th Mar 08 at 11:41pm
Added, not very good though... {Unsure}

Re: Avatar Anywhere - Posted By dog199200 (dog199200) on 8th Mar 08 at 11:44pm
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?

Re: Avatar Anywhere - Posted By Michael (wrighty) on 8th Mar 08 at 11:47pm
No, but a code could be made to use the avatar as an on/off icon! {Tongue Out}

Re: Avatar Anywhere - Posted By dog199200 (dog199200) on 8th Mar 08 at 11:55pm
no its ok, i was just wondering to what extent that it could be used.

Re: Avatar Anywhere - Posted By Nick (nickb) on 9th Mar 08 at 1:05am
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. {Tongue Out}

Re: Avatar Anywhere - Posted By Cryhavoc_ (virtuoso) on 9th Mar 08 at 1:49am
Wrighty has a new soulmate: hidden_vars.

Whens the wedding Wrighty boy? {Tongue Out}

Re: Avatar Anywhere - Posted By Fel!x (felix) on 9th Mar 08 at 5:16am
 
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. {Tongue Out}


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 =]

Re: Avatar Anywhere - Posted By Michael (wrighty) on 9th Mar 08 at 11:19am
 
Wrighty has a new soulmate: hidden_vars.

Whens the wedding Wrighty boy? {Tongue Out}


Tomorrow, you're the best man! {Smile}


Thanks Fel!x

Re: Avatar Anywhere - Posted By ashkir (ashkir) on 28th Jul 08 at 12:30am
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.

Re: Avatar Anywhere - Posted By Nick (nickb) on 28th Jul 08 at 4:12am
 
 
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. {Tongue Out}


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.