Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Zelnen

Zelnen Avatar
Javascriptin'

**
Official Member

91


June 2006
Ok this code basically adds Whisper here:



When you click it it pops up asking you to type in the members name you would like to see the whisper.

Basically it works like this. [whisper:Zelnen]Hello[/whisper] if i was logged in as Zelnen i could see the whisper if i wasn't then i couldn't see it. So this code allows you to whisper things to other members without others seeing what there whispering.

Know bugs
  • FF only
  • Only one member is able to view each whisper
I will sort out all the bugs in v2. Which will come within the next week or two.

So put this into your footers.


<script>
// Add whisper tags
// Created by Zelnen 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.class = '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>


Also thanks for James for helping me with some of the regexp. Enjoy

newBookmarkLockedFalling