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] Converting a whisper code
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] Converting a whisper code; Converting from IF to ZETA
Tweet Topic Started: Sep 8 2009, 04:12 PM (247 Views)
Wrench Sep 8 2009, 04:12 PM Post #1


Posts:
12
Group:
Member
Member
#3,448
Joined:
Aug 29, 2009
Coding language
Everything
Hi, i recently found this code on your previous web site and figured i would try to change it to work on zetaboards.

Whisper code


Quote:
 
<script>
// Add whisper tags
// Created by Zelnen http://s15.invisionfree.com/ifcodingzone

function whis(){

var names = prompt("Please type in the members name you would like to see the whisper.","")
forms = document.forms['REPLIER']
forms.Post.value += "[whisper:" + names + "] [/whisper]"
}

if(location.href.match("act=Post&CODE=")){
tds = document.getElementsByTagName("td")
for(i=0; i < tds.length; i++){
if(tds.innerHTML.match("Open Tags:")){

var newelement = document.createElement("input")
newelement.type = 'button'
newelement.value = 'whisper'
newelement.className = 'codebuttons'
newelement.name = 'blink'
newelement.onclick = whis

var node = null
inputs = tds.getElementsByTagName("input")
for(x=0; x < inputs.length; x++){
if(inputs[x].name == 'LIST'){
node = inputs[x]
}
}

tds.insertBefore(newelement, node);

}}}

if(location.href.match("showtopic=")){
divs = document.getElementsByTagName("div")
for(x=0; x < divs.length; x++){
if(divs[x].className == 'postcolor' && divs[x].innerHTML.match(/whisper/)){
var userlink = document.getElementById('userlinks').getElementsByTagName('A')[0].innerHTML

var myText = divs[x].innerHTML
var myReg = new RegExp( "\\[whisper\\:(\\w+)\\](.*)\\[\\/whisper\\]" , "i" )
var myTest = myReg.exec(myText)
if(myTest[1] == userlink){
divs[x].innerHTML = divs[x].innerHTML.replace(/\[whisper:(\w+)\]/i,"<b>Whisper:</b> <i>")
divs[x].innerHTML = divs[x].innerHTML.replace(/\[\/whisper\]/gi,"</i>")

}
else{
divs[x].innerHTML = divs[x].innerHTML.replace(/\[whisper:(\w+)\](.*)\[\/whisper\]/i," ")

}}}}
</script>


Could someone walk me through how i would do this so i know how to convert it in the future?
I might be making this sound easier then it is though.
Offline Profile Goto Top
 
Reid Sep 8 2009, 05:17 PM Post #2
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Yes, converting is not very simple... I'll have this done shortly.
The Resource Board
Offline Profile Goto Top
 
Dorith Sep 8 2009, 05:20 PM Post #3
Member Avatar
Has just entered the Matrix

Posts:
2,069
Group:
Former Staff
Member
#1,854
Joined:
Dec 23, 2008
Oh and there is an [i] in there. You might notice how it becomes italics all of a sudden. Thought I might point that out for ya Reid :)
Posted Image
Posted Image
(Made emoticon using Codes Rock's Smiley Generator)
Offline Profile Goto Top
 
Reid Sep 8 2009, 05:23 PM Post #4
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
There... I just rewrote the script because we aren't allowed to edit other peoples':
Code:
 
<script type='text/javascript'>
// <![CDATA[
(function(){
var whisp_regex = /\[whisper=([\w\d]+?)\](.+?)\[\/whisper\]/i;
$('td:contains([whisper=)').each(function(){
if (this.innerHTML.match(whisp_regex)) {
this.innerHTML = this.innerHTML.replace(whisp_regex, function(m, o, t) {
if ($('#top_info strong a').text().toLowerCase() == o.toLowerCase()) {
return "<span style='font-style:italic'>Whisper to you: " + t + "</span>";
} else {
return "";
}
});
}
});
if (location.href.indexOf('/post')!=-1) {
$('#c_bbcode button:contains(S):not(:contains(Smaller))').after(" <button type='button' id='whisp_but'>Whisper</button>");
$('#whisp_but').click(function(){
var b = prompt("Please enter the username you want to whisper: ", "");
if (b) {
var c = prompt("Please enter the message you wish to give: ", "");
if (c) {
$('#c_post-text').val($('#c_post-text').val() + "[whisper=" + b + "]" + c + "[/whisper]");
}
}
});
}
})();
// ]]>
</script>
If you stick that in the 'below the board' spot it should work. The syntax is:
Code:
 
[whisper=name]message[/whisper]
and there should also be a button on the posting page. :)
The Resource Board
Offline Profile Goto Top
 
HolySavior Sep 23 2009, 02:43 PM Post #5
Member Avatar
Modifying The World Around You

Posts:
2,488
Group:
Distinguished Coder
Member
#7
Joined:
Jul 2, 2008
Coding language
Everything
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
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: 2:27 PM Jul 11
Hosted for free by ZetaBoards · Privacy Policy