Michael Moderator
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | Avatar Anywhere (8th Mar 08 at 11:20pm UTC) | | 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. | |
|
Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Avatar Anywhere (8th Mar 08 at 11:32pm UTC) | | You know its coming.....Were is the preview? | |
|
Michael Moderator
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | Re: Avatar Anywhere (8th Mar 08 at 11:36pm UTC) | | >.< Fine... | |
|
Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Avatar Anywhere (8th Mar 08 at 11:39pm UTC) | | <_> ^_- | |
|
Michael Moderator
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | Re: Avatar Anywhere (8th Mar 08 at 11:41pm UTC) | | Added, not very good though... | |
|
dog199200 Guest | Re: Avatar Anywhere (8th Mar 08 at 11:44pm UTC) | | 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? | |
|
Michael Moderator
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | Re: Avatar Anywhere (8th Mar 08 at 11:47pm UTC) | | No, but a code could be made to use the avatar as an on/off icon! | |
|
dog199200 Guest | Re: Avatar Anywhere (8th Mar 08 at 11:55pm UTC) | | no its ok, i was just wondering to what extent that it could be used. | |
|
Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Avatar Anywhere (9th Mar 08 at 1:05am UTC) | | 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. | |
|
Cryhavoc_ Full Member
Just do it. Posts: 238 Status: Offline Gender: Male Location: The wrong way. Age: 32 Joined:
pm | Re: Avatar Anywhere (9th Mar 08 at 1:49am UTC) | | Wrighty has a new soulmate: hidden_vars.
Whens the wedding Wrighty boy? | |
|
|
Fel!x Full Member
[AVATAR] Posts: 171 Status: Offline Gender: Male Location: Sydney Age: 31 Joined:
pmmsn | Re: Avatar Anywhere (9th Mar 08 at 5:16am UTC) | | 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 =] | |
|
|
Michael Moderator
Recoding the future Posts: 4,043 Status: Offline Gender: Male Location: UK Joined:
Additional Groups: Coding Team
pmvForum | Re: Avatar Anywhere (9th Mar 08 at 11:19am UTC) | | Wrighty has a new soulmate: hidden_vars. Whens the wedding Wrighty boy?
Tomorrow, you're the best man!
Thanks Fel!x | |
|
ashkir Full Member
Posts: 1,159 Status: Offline Gender: Male Location: Cali! Age: 35 Joined:
pmskypemsnyahoo | Re: Avatar Anywhere (28th Jul 08 at 12:30am UTC) | | 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. | |
|
Nick Very Senior Member
Posts: 3,012 Status: Offline Gender: Male Location: vForums Age: 34 Joined:
pmwww | Re: Avatar Anywhere (28th Jul 08 at 4:12am UTC) | | 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. | |
|