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


Quick Links:


newBookmarkLockedFalling

Singular

Singular Avatar
v4 Studios :: Coming Soon

***
Dedicated Member

238


September 2005
How should I go about an HTML interegation into posts? So if I post [shout]39[/shout], it will display the shoutbox from my site with an id of 39 in my post?

Please don't steal my ideas...

Further Solutions :: Hosting :: Scripts :: Templates
furthersolutions.com

v4 Studios - Coming soon

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
For ProBoards?

Anyways, you'd use RegExp.


data = data.replace(/\[shout\](\d+)\[\/shout\]/gi,"<iframe src='shoutbox.php?id=$1'></iframe>");

Something like that.

Singular

Singular Avatar
v4 Studios :: Coming Soon

***
Dedicated Member

238


September 2005
So that is all I would need to do for finding and converting? I can add the ubbc button so I guess the code will be done soon. :)

Cheers! :)


Last Edit: Jun 9, 2006 20:04:24 GMT by Singular
Further Solutions :: Hosting :: Scripts :: Templates
furthersolutions.com

v4 Studios - Coming soon

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
If you need anymore help with it, post here. :)

Singular

Singular Avatar
v4 Studios :: Coming Soon

***
Dedicated Member

238


September 2005
Do I need more than that one line? It doesn't work with just that?
Further Solutions :: Hosting :: Scripts :: Templates
furthersolutions.com

v4 Studios - Coming soon

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Well, you need JS to replace it. :P I thought you knew that and were just asking for an example of how to do it. Heck, that wouldn't even work cause I doubt that's how you load the boxes by ID.

You'd first need to loop through the loops.

var td = document.getElementsByTagName("TD");
for(a=0;a<td.length;a++){
if(td.width == "80%" && td.innerHTML.match(/\[shout\]\d+\[\/shout\]/i)){
td
.innerHTML = td.innerHTML.replace(/\[shout\](\d+)\[\/shout\]/gi,"<iframe src='shoutbox.php?id=$1'></iframe>");
}
}



That would work, just needs a little tweaking maybe. :P


Singular

Singular Avatar
v4 Studios :: Coming Soon

***
Dedicated Member

238


September 2005
Beastly. 8-)

How can I make it so it displays <script type="text/javascript" src="http://www.s-shouts.com/viewshoutbox.php?id=1"></script> instead of an iframe? I tried puting it in and it didn't work. :-/


Last Edit: Jun 9, 2006 22:47:03 GMT by Singular
Further Solutions :: Hosting :: Scripts :: Templates
furthersolutions.com

v4 Studios - Coming soon

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Or you can be an innerHTML-phobe like me and write complicated DOM-hoodoo to get the job done. :P

<script type="text/javascript">
<!--
function traverse(gNode) {
 if(gNode.nodeType == 3 && gNode.data.match(/(\[source\].+?\[\/source\])/i)) {
  var iString = RegExp.$1;
  var iFrame = document.createElement("iframe");
   iFrame.src = iString.split("[source]")[1].split("
[/source]")[0];
  var index = gNode.data.indexOf(iString);
   gNode = gNode.splitText(index).splitText(iString.length).previousSibling;
   gNode.parentNode.replaceChild(iFrame, gNode);
 } else if(gNode.nodeType == 1 && gNode.hasChildNodes()) {
  for(var i = 0; i < gNode.childNodes.length; i ++) {
   traverse(gNode.childNodes);
  }
 }
}
var gCell = document.getElementsByTagName("td");
for(var i = 0; i < gCell.length; i ++) {
 if(gCell.colSpan == "3" && gCell.vAlign == "top" && gCell.firstChild.nodeName == "HR" && gCell.firstChild.className == "hr") {
  traverse(gCell);
 }
}
//-->
</script>
[/size]

If you need a breakdown of the code i'll supply it. ;)


Last Edit: Jun 9, 2006 23:58:41 GMT by Aaron

Singular

Singular Avatar
v4 Studios :: Coming Soon

***
Dedicated Member

238


September 2005
Derfleurer, yours is still in a fram and it goes to the URL /1 instead of /shoutbox.php?id=1. Chris's is shorter and easier to understand for me, so I think that I will stick with Chris's as long as I can get it to write the actual JavaScript instead of the iframe.
Further Solutions :: Hosting :: Scripts :: Templates
furthersolutions.com

v4 Studios - Coming soon

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
[source]http://www.google.com[/source]

Is that what you're using? Because it works fine for me in both IE and FF.

kisrpg.proboards91.com/index.cgi

It opens up the URL provided in those tags in a frame.




Last Edit: Jun 10, 2006 0:52:38 GMT by Aaron

Singular

Singular Avatar
v4 Studios :: Coming Soon

***
Dedicated Member

238


September 2005
Oh, I see what you did. This script was going to be for a shoutbox from Singular Shouts, but I guess that would work too. :)
Further Solutions :: Hosting :: Scripts :: Templates
furthersolutions.com

v4 Studios - Coming soon

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Go with what you understand. I was just being a pest. :P

Singular

Singular Avatar
v4 Studios :: Coming Soon

***
Dedicated Member

238


September 2005
But I still can't use CD's code to make it JavaScript? It should work.
Further Solutions :: Hosting :: Scripts :: Templates
furthersolutions.com

v4 Studios - Coming soon

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
You can, you just need to change parts around... oh, AND you need to change </script> to <\/script>

Nate

Nate Avatar

**
Official Member

85


July 2007

newBookmarkLockedFalling