Hello, recently I've been having a few issues with the code in my chatbox.
Currently, I've used the codes from @Buttercup (I believe) to personalize my chat, but a few errors in certain codes have caused some scripts to stop working. I was wondering if anyone could resolve this problem.
When I use the code to make the avatars display in the memberlist, the code to make these notifications disappear began to show again.
Example: http://prntscr.com/8drwqf
But when I remove the code for the avatars to be shown in the memberlist, the notifications disappear and the code functions once again.
Example: http://prntscr.com/8drymm
I hope someone could resolve this problem, as it's getting quite annoying.
Thanks!
Tagging: @Ange Tuteur @Buttercup
EDIT:
These are the 2 scripts I am using at the moment:
This is the one to remove the little notifications in the chat.
and
This is the one I'm using for the avatars to display in the memberlist.
Thanks for the reminder! @APE
Currently, I've used the codes from @Buttercup (I believe) to personalize my chat, but a few errors in certain codes have caused some scripts to stop working. I was wondering if anyone could resolve this problem.
When I use the code to make the avatars display in the memberlist, the code to make these notifications disappear began to show again.
Example: http://prntscr.com/8drwqf
But when I remove the code for the avatars to be shown in the memberlist, the notifications disappear and the code functions once again.
Example: http://prntscr.com/8drymm
I hope someone could resolve this problem, as it's getting quite annoying.
Thanks!
Tagging: @Ange Tuteur @Buttercup
EDIT:
These are the 2 scripts I am using at the moment:
This is the one to remove the little notifications in the chat.
- Code:
$(window).load(function() {
var chatbox_script = function() {
$('#chatbox > p > .msg > span').filter('[style="color:green"],[style="color:red"]').closest('p').remove();
var overrided = Chatbox.prototype.refresh;
Chatbox.prototype.refresh = function(data) {
if (data.messages && data.messages.length) {
data.messages = $.grep(data.messages, function(v) {
return v.userId != -10 || $.inArray(v.msgColor, ["red", "green"]) == -1;
});
}
overrided.call(this, data);
};
};
var
s=document.createElement('script');s.text="("+chatbox_script.toString()+")();";$('object[data^="/chatbox/index.forum"],iframe[src^="/chatbox/index.forum"]').each(function(){try{$(this.contentDocument||this.contentWindow.document).find("#chatbox").closest("html").find("head").first().each(function(){this.appendChild(s.cloneNode(true))})}catch(a){}})
});
and
This is the one I'm using for the avatars to display in the memberlist.
- Code:
$(window).load(function() {
var chatbox_script = function() {
var default_avatar = 'http://2img.net/i/fa/invision/pp-blank-thumb-38px.png';
var ava_in_member_list = true;
var ava_in_indirect_message = true;
var avatars = {};
var d;
var set_avatar = function(pseudo, elem_to_prepend){
var avatar = avatars[pseudo];
var el = $(this);
elem_to_prepend.find('.cb-avatar').remove();
elem_to_prepend.prepend('<span class="cb-avatar"><img src="'+(avatar||default_avatar)+'"></span> ');
if(!avatar) {
if(!d) {
d = $.get('/memberlist?change_version=prosilver').done(function(c){
$('.avatar-mini img', c).each(function(){
avatars[$(this).parent().text().substr(1)]= $(this).attr('src')
})
})
}
d.done(function(){
var avatar = avatars[pseudo];
elem_to_prepend.find('.cb-avatar img').attr('src', avatar||default_avatar)
})
}
};
var overrided = Chatbox.prototype.refresh;
Chatbox.prototype.refresh = function(data) {
var next_scroll = false;
if (data.messages && data.messages.length) {
$.each(data.messages, function(_,m){
if(ava_in_indirect_message)
m.msgColor+='\' data-username=\''+$('<div/>').text(m.username).html();
if(m.user && m.user.avatar)
avatars[m.username] = m.user.avatar
});
next_scroll = !this.messages || this.messages.length != data.messages.length;
}
overrided.call(this, data);
d = null;
ava_in_member_list && $('#chatbox_members .chatbox-username').each(function(){
set_avatar($(this).text(), $(this).parent());
});
ava_in_indirect_message && $('#chatbox p > .msg').wrap('<span class="user-msg indirect-user-msg" />').each(function(){
set_avatar($(this).children().attr('data-username'), $(this).parent());
});
if(next_scroll) $("#chatbox")[0].scrollTop = $("#chatbox").prop('scrollHeight') * 2
};
};
var s=document.createElement('script');s.text="("+chatbox_script.toString()+")();";$('object[data^="/chatbox/index.forum"],iframe[src^="/chatbox/index.forum"]').each(function(){try{$(this.contentDocument||this.contentWindow.document).find("#chatbox").closest("html").find("head").first().each(function(){this.appendChild(s.cloneNode(true))})}catch(a){}})
});
Thanks for the reminder! @APE
Last edited by Luke Spike on September 8th 2015, 12:16 am; edited 2 times in total