Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Resources
  • Code Requests
  • Completed Requests
  • [Completed] [ZB] Color Code in shoutbox
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
[Completed] [ZB] Color Code in shoutbox
Topic Started: Dec 6 2009, 08:29 PM (418 Views)
Angel Pie Dec 6 2009, 08:29 PM Post #1
Member Avatar


Posts:
41
Group:
Member
Member
#1,893
Joined:
Dec 30, 2008
I came across this particular code: http://support.zetaboards.com/topic/282298/1/?x=20#new

and I was wondering if it could be possible to allow this code to also work in Zetaboard's built-in shoutbox.
For example, I would not have to type any bbcododes in if they are already set...in order to do this I would have to go into my profile and add some type of code like
Code:
 
[bbcode here]!post![/b][/endbbcode]
And it will come out the same way in the shoutbox.
Offline Profile Goto Top
 
RedBldSandman Dec 7 2009, 06:17 PM Post #2
Member Avatar
ZIPPY!

Posts:
479
Group:
Coding Staff
Member
#2,122
Joined:
Jan 25, 2009
Coding language
JavaScript
Try this:
Code:
 
<script type="text/javascript">
$(function() {
$("button[type=submit]:contains('Shout!')").click(function(e) {
if (e.preventDefault) e.preventDefault();
e.returnValue = false;
if ($(this).next("input").val()==undefined) {
$(this).text("Retrieving BBCode Info");
$.get(main_url+"home/?c=6",function(d) {
var ShoutBBs = $("td.c_desc:contains('ShoutboxBBCodes')",d).next().children("input").val();
$("button[type=submit]:contains('Retrieving BBCode Info')").after("<input type='hidden' name='ShoutboxBBCodes' id='ShoutboxBBCodes' value='"+ShoutBBs+"' />");
newShout();
});
} else {
newShout();
}
});
if (location.href.indexOf("/home/?c=6")!=-1) {
$("td.c_desc:contains('ShoutboxBBCodes')").next().append("<br /><small>To use this feature, enter \"!post!\" surrounded by your chosen BBCodes. An example would be:<br /><strong>[b][color=red]!post![/color][/b]</strong></small>");
}
});

function newShout() {
$("button[type=submit]:contains('Shout!')").text("Shouting!");
$("button[type=submit]:contains('Retrieving BBCode Info')").text("Shouting!");
var OrigShout = $("input[name=shouttext]").val();
if (OrigShout!="") {
var Additions = $("button[type=submit]:contains('Shouting!')").next("input").val().toLowerCase().split("!post!");
var NewShout = (Additions.length>1)?Additions[0]+OrigShout+Additions[1]:Additions[0]+OrigShout;
$.post(main_url+"tasks/",{msg:NewShout,task:document.shoutpost.task.value,xc:document.shoutpost.shoutxss.value,last:lastMsgID},function(d) {
if (!d.error) {
$("input[name=shouttext]").val("");
lastMsgID = "-1";
for(k=0;k<d.messages.length;k++) {
$("#shoutbox li:last").remove();
$("#shoutbox").prepend("<li id='shout-"+d.messages[k].i+"'><dl><dt>"+d.messages[k].t+"</dt><dd>"+d.messages[k].a+": "+d.messages[k].m+"</dd></dl></li>");
}
$("#shoutbox li:odd").addClass("odd");
$("button[type=submit]:contains('Shouting!')").text("Shout!");
} else {
alert(d.error);
$("button[type=submit]:contains('Shouting!')").text("Shout!");
}
},"json");
} else {
alert("Please enter a message");
$("button[type=submit]:contains('Shouting!')").text("Shout!");
}
}
</script>
WARNING: Will use 1 extra ad-credit the first time you post in the shoutbox on each page!
To set it up, just place that code anywhere in the board template and then make a Profile Field (1 line text) called ShoutboxBBCodes which is not Admin Only Edit.
To set the BBcodes you wish to use, just go to the Update Profile page and type in the BBcodes you wish to use with !post! where you wish the Post to go so, to get red and bold posts, you'd do this:
Code:
 
[color=red][b]!post![/b][/color]
You could even use it to add begginings and endings to your post such as:
Code:
 
RedBldSandman says...[color=blue][b]!post![/b][/color], what do you think?
Hope you like it, if there are any bugs just say and I'll sort them out. I could have used the Zetaboards shout functions themselves instead but I thought I'd have a bit of fun and it worked better then using the Zeta functions since I could add in some stuff :P
Posted Image
"To iterate is human, to recurse divine."

Offline Profile Goto Top
 
Angel Pie Dec 7 2009, 07:26 PM Post #3
Member Avatar


Posts:
41
Group:
Member
Member
#1,893
Joined:
Dec 30, 2008
Hmm,when I post in the shoutbox it says "undefined" and it does not show the bbcodes I placed into my profile field.
Offline Profile Goto Top
 
RedBldSandman Dec 8 2009, 04:50 PM Post #4
Member Avatar
ZIPPY!

Posts:
479
Group:
Coding Staff
Member
#2,122
Joined:
Jan 25, 2009
Coding language
JavaScript
Try this instead:
Code:
 
<script type="text/javascript">
$(function() {
$("#shoutpost button[type=submit]:first").attr("id","ShoutBtn");
$("#shoutpost").unbind("submit").submit(function(e) {
if (e.preventDefault) e.preventDefault();
e.returnValue = false;
if ($("#ShoutBtn").next("input").val()==undefined) {
$("#ShoutBtn").text("Retrieving BBCode Info").attr("disabled","disabled");
$.get(main_url+"home/?c=6",function(d) {
var ShoutBBs = $("td.c_desc:contains('ShoutboxBBCodes')",d).next().children("input").val();
$("#ShoutBtn").after("<input type='hidden' name='ShoutboxBBCodes' id='ShoutboxBBCodes' value='"+ShoutBBs+"' />");
newShout();
});
} else {
newShout();
}
});
if (location.href.indexOf("/home/?c=6")!=-1) {
$("td.c_desc:contains('ShoutboxBBCodes')").next().append("<br /><small>To use this feature, enter \"!post!\" surrounded by your chosen BBCodes. An example would be:<br /><strong>[b][color=red]!post![/color][/b]</strong></small>");
}
});

function newShout() {
$("#ShoutBtn").text("Shouting!").attr("disabled","disabled");
var OrigShout = $("input[name=shouttext]").val();
if (OrigShout!="") {
var Additions = $("#ShoutBtn").next("input").val().toLowerCase().split("!post!");
var NewShout = (Additions.length>1)?Additions[0]+OrigShout+Additions[1]:Additions[0]+OrigShout;
$.post(main_url+"tasks/",{msg:NewShout,task:document.shoutpost.task.value,xc:document.shoutpost.shoutxss.value,last:lastMsgID},function(d) {
if (!d.error) {
$("input[name=shouttext]").val("");
lastMsgID = "-1";
for(k=0;k<d.messages.length;k++) {
$("#shoutbox li:last").remove();
$("#shoutbox").prepend("<li id='shout-"+d.messages[k].i+"'><dl><dt>"+d.messages[k].t+"</dt><dd>"+d.messages[k].a+": "+d.messages[k].m+"</dd></dl></li>");
}
$("#shoutbox li:odd").addClass("odd");
$("#ShoutBtn").text("Shout!").removeAttr("disabled");
} else {
alert(d.error);
$("#ShoutBtn").text("Shout!").removeAttr("disabled");
}
},"json");
} else {
alert("Please enter a message");
$("#ShoutBtn").text("Shout!").removeAttr("disabled");
}
}
</script>
Could I have a link to your board as well? Both versions seem to work perfectly on my test board (though this version has some improvements) xD
Posted Image
"To iterate is human, to recurse divine."

Offline Profile Goto Top
 
Angel Pie Dec 8 2009, 11:11 PM Post #5
Member Avatar


Posts:
41
Group:
Member
Member
#1,893
Joined:
Dec 30, 2008
Unfortunately, I got the same thing again.
Offline Profile Goto Top
 
RedBldSandman Dec 9 2009, 02:16 PM Post #6
Member Avatar
ZIPPY!

Posts:
479
Group:
Coding Staff
Member
#2,122
Joined:
Jan 25, 2009
Coding language
JavaScript
All done, the Profile Field was incorrectly named but it's all sorted now :D

You're welcome.
See? We can read thoughts too. ;)

Your request has been completed, and we're moving it to the correct forum. We hope it works for you; if it doesn't, feel free to post another request topic in the requests forum. Just remember: read the rules first!

Thanks,
The ZBCode Staff
Posted Image
"To iterate is human, to recurse divine."

Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Completed Requests · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 5:29 PM Sep 3
Hosted for free by ZetaBoards