Hello,
I have on my testingforum the member title function with this script:
I have on my testingforum the member title function with this script:
- Code:
$(function() {
var formatBBCode = true;
// editing of profile field
if (/\/profile|\/u\d+/.test(window.location.href)) {
for (var a = document.getElementsByTagName('TEXTAREA'), i = 0, j = a.length; i < j; i++) {
if (/class="fa_personal_title"/.test(a[i].value) && /profile_field/.test(a[i].id)) {
a[i].onfocus = function() {
this.value = this.value.replace(/\n|\r/g, '').replace(/\[table class="fa_personal_title"\]\[tr\]\[td\](.*?)\[\/td\]\[\/tr\]\[\/table\]/, '$1');
};
a[i].onblur = function() {
this.value = '[table class="fa_personal_title"][tr][td]' + this.value + '[/td][/tr][/table]';
};
}
}
}
// parsing in messages
else if (/\/t\d+/.test(window.location.href)) {
var version = $('.bodylinewidth')[0] ? 0 : document.getElementById('phpbb') ? 1 : $('div.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : document.getElementById('modernbb') ? 4 : document.getElementById('fa_edge') ? 5 : 'badapple',
closest = ['.poster-profile', '.postprofile', '.user', '.postdetails', '.postprofile', '.postprofile'][version],
find = ['br:first', 'dt + dd', '.user-basic-info', 'dt + dd', '.postprofile-rank', '.rank-title'][version],
a = $('.fa_personal_title'),
i = 0,
j = a.length,
node, str, title;
if (version == 'badapple') {
if (window.console && console.warn) console.warn('Your forum version is not supported for the "Personal Title" plugin.');
return;
}
for (; i < j; i++) {
title = $('td', a[i]).eq(0);
title = formatBBCode ? title.html() : title.text();
if (title) {
node = $(a[i]).closest(closest).find(find);
str = '<span class="personal_title">' + title + '</span>';
version == 0 ? node.before(str) : node.append(str);
a[i].previousElementSibling.style.display = 'none';
a[i].style.display = 'none';
}
}
}
});