Avatar on FM toolbar in a fastest way!
5 posters
Page 1 of 1
Avatar on FM toolbar in a fastest way!
* Description: This application displays the member avatar in Forumotion toolbar in a fastest way!
In your ACP: Modules -> HTML&JAVASCRIPT -> JavaScript codes management -> [Create a new JavaScript]
Title *: <- Whatever you want
Placement : <- In all the pages
Javascript Code * : <- Select, copy and paste the code below in this field:
Try it!
JS
In your ACP: Modules -> HTML&JAVASCRIPT -> JavaScript codes management -> [Create a new JavaScript]
Title *: <- Whatever you want
Placement : <- In all the pages
Javascript Code * : <- Select, copy and paste the code below in this field:
- Code:
/*
* Application: Toolbar with member avatar
* Description: This application displays the member avatar in Forumotion toolbar in a fastest way!
* Version: 1.08032014-jq1.9.1 - Keb (Horus)
* Made and Optimizations by JScript - 2014/03/08
* Copyright (c) 2014 JScript <jscriptbrasil at live dot com>
* This work is free. You can redistribute it and/or modify it
* under the terms of the WTFPL, Version 2
*/
jQuery(function() {
JS_faIsRead();
function JS_faIsRead() {
if (jQuery('#fa_welcome').length) {
jQuery('#fa_welcome').prepend(_userdata.avatar).children('img').css( {
'border-radius' : '3px 3px 3px 3px',
'height' : '25px',
'margin-bottom' : '-10px',
'margin-right' : '5px',
'position' : 'relative',
'top' : '-3px',
'width' : '25px'
});
} else {
setTimeout(JS_faIsRead, 100);
}
}
});
Try it!
JS
Re: Avatar on FM toolbar in a fastest way!
Nice Work but i have a problem with it it comes up 2 times
https://i.servimg.com/u/f18/12/23/10/57/captur36.png
https://i.servimg.com/u/f18/12/23/10/57/captur36.png
Re: Avatar on FM toolbar in a fastest way!
@APE
Well, I tested now on the console and only appeared once, in my forum is functioning normally, but I need you to install the code in your forum so that I can verify what is going ok?
I did signed up there,
JS
Well, I tested now on the console and only appeared once, in my forum is functioning normally, but I need you to install the code in your forum so that I can verify what is going ok?
I did signed up there,
JS
Re: Avatar on FM toolbar in a fastest way!
ok it has come back up as one but its moved my bar at the top down a bit
Re: Avatar on FM toolbar in a fastest way!
I think the two things you can do two improve this would be :
1. Check the login state before polling for fa_welcome. This way it wont be polling for fa_welcome while the user is logged out.
Example :
2. If possible, native getElementById() is normally a lot faster for getting elements by their ID. You could also just stick with jQuery, but cache it to a variable so it doesn't have to search for fa_welcome when the condition is triggered. Normally like you do with native after writing that loooong document.getElementById
Example :
This is also another example I wrote :
I usually like polling for modifications before the document is ready. The toolbar, sceditor.. can normally be accessed on a second doc ready event, mostly because they're launched with one.
1. Check the login state before polling for fa_welcome. This way it wont be polling for fa_welcome while the user is logged out.
Example :
- Code:
if (_userdata.session_logged_in) JS_faIsRead();
2. If possible, native getElementById() is normally a lot faster for getting elements by their ID. You could also just stick with jQuery, but cache it to a variable so it doesn't have to search for fa_welcome when the condition is triggered. Normally like you do with native after writing that loooong document.getElementById
Example :
- Code:
var welcome = document.getElementById('fa_welcome');
if (welcome) {
jQuery(welcome)
This is also another example I wrote :
- Code:
$(function() {
if (_userdata.session_logged_in) {
var avatar = document.createElement('SPAN'), right; // start up variables
avatar.innerHTML = _userdata.avatar.replace(/<img (src=".*)/,'<img style="height:25px;width:25px;vertical-align:middle;margin-bottom:1px;" $1'); // add avatar to the container
avatar.id = 'fa_avatar'; // apply id for user modifications
$(function() { // toolbar should be ready
right = document.getElementById('fa_right'); // get the right side of the toolbar
right && right.insertBefore(avatar, right.firstChild); // insert the avatar as the first node
});
}
});
I usually like polling for modifications before the document is ready. The toolbar, sceditor.. can normally be accessed on a second doc ready event, mostly because they're launched with one.
Re: Avatar on FM toolbar in a fastest way!
@Ange Tuteur
Perfect! Just as assembler is faster than C ++, your code is much faster than mine !!!
However, replacing the second "$ (function () {" to "setTimeout (JS_faIsRead, 100);" is much faster.
So far the best mod: https://help.forumotion.com/t141661-avatar-on-fm-toolbar-in-a-fastest-way#965096
JS
Perfect! Just as assembler is faster than C ++, your code is much faster than mine !!!
However, replacing the second "$ (function () {" to "setTimeout (JS_faIsRead, 100);" is much faster.
- Code:
jQuery(function() {
if (_userdata.session_logged_in) {
var avatar = document.createElement('SPAN'),
right; // start up variables
avatar.innerHTML = _userdata.avatar.replace(/<img (src=".*)/, '<img style="height:25px;width:25px;vertical-align:middle;margin-bottom:1px;" $1'); // add avatar to the container
avatar.id = 'fa_avatar'; // apply id for user modifications
function JS_faIsRead() {
var welcome = document.getElementById('fa_welcome');
if (welcome) {
right = document.getElementById('fa_right'); // get the right side of the toolbar
right && right.insertBefore(avatar, right.firstChild); // insert the avatar as the first node
} else {
setTimeout(JS_faIsRead, 100);
}
}
JS_faIsRead();
}
});
So far the best mod: https://help.forumotion.com/t141661-avatar-on-fm-toolbar-in-a-fastest-way#965096
JS
Re: Avatar on FM toolbar in a fastest way!
I run this code on my page...
- Code:
$(function() {
setTimeout(function() {
var av = $('#fa_usermenu img').attr('src');
$('#fa_welcome').prepend('<img src="' + av + '" class="toolbar_avatar" />');
});
});
Re: Avatar on FM toolbar in a fastest way!
ok my problem is now fixed i just made the avatar smaller in the toolbar and that fixed it
Thank you JS
Thank you JS
Re: Avatar on FM toolbar in a fastest way!
This will no longer be supported by JScript: https://help.forumotion.com/t151137-in-memory-of-jscript-joao-carlos.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Toolbar avatar like FM
» Display the avatar of a member on the toolbar
» How to display an avatar next to a notice of Toolbar
» Not Able To Post Avatar Pic With Toolbar Edit Profile
» Worlds Fastest man
» Display the avatar of a member on the toolbar
» How to display an avatar next to a notice of Toolbar
» Not Able To Post Avatar Pic With Toolbar Edit Profile
» Worlds Fastest man
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum