We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Find and Replace Text
Topic Started: Jul 12 2012, 02:24 PM (1,505 Views)
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code Name: Find and Replace Text

What the code does: This is a simple snippet that is often requested that will allow you to change text across the board to whatever you'd like.

How to use the code: Replace CURRENT_TEXT and NEW_TEXT as necessary.

You may keep repeating the replace function to change other text selections, for example:
Code:
 
<script type="text/javascript">
//<![CDATA[
$("*").contents().each(function () {
if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace("CURRENT_TEXT", "NEW_TEXT").replace("CURRENT_TEXT", "NEW_TEXT");
});
//]]>
</script>
How to install the code:

Admin CP Posted Image Themes Posted Image Board Template Posted Image Below the Board
Code:
 
<script type="text/javascript">
//<![CDATA[
$("*").contents().each(function () {
if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace("CURRENT_TEXT", "NEW_TEXT");
});
//]]>
</script>
Edited by Cory, Oct 30 2016, 12:23 AM.
Online Profile Quote Post Goto Top
 
Chaotic_Dreamer
Member Avatar
Member
[ * ]
Is there a way to make this code work with this code?
Spoiler: click to toggle
Offline Profile Quote Post Goto Top
 
Ferby
Member Avatar
Developer
[ *  *  *  *  * ]
Isnt this what the filter system does?
Offline Profile Quote Post Goto Top
 
hissae2-ZNR
Member
[ * ]
When I added this code, the AIO money would show up twice and the shoutbox would no longer move to the top of the page. Judging by the above posts, it seems this does not work with many codes. :P Is there any way this could be fixed?
Edited by hissae2-ZNR, Jul 12 2012, 10:37 PM.
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
I have updated the code for an apparent better-working version that I found on Google. It shouldn't have the repeating content issue that the original version had.

Ferby: The word filter only replaces words in posts, this will replace text selections everywhere across the board.
Online Profile Quote Post Goto Top
 
Chaotic_Dreamer
Member Avatar
Member
[ * ]
Thank you so much it is working perfectly :)
Offline Profile Quote Post Goto Top
 
Professor Jango
Member Avatar
Member
[ * ]
Will this work with BBCode? For instance, we changed URLs a while back and a lot of old links still use the old URL. Could I use this to change the text of the link while still leaving the forum or thread numbers the same?
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Sorry, it only matches text nodes, not HTML. You may be interested in this: http://stackoverflow.com/questions/3947911/replace-part-of-an-href-attribute-in-a-link-with-jquery
Online Profile Quote Post Goto Top
 
Professor Jango
Member Avatar
Member
[ * ]
Thanks for your quick response. I'll check that option out.
Offline Profile Quote Post Goto Top
 
Ferby
Member Avatar
Developer
[ *  *  *  *  * ]
is there a way you could adapt this to usernames? So instead of searching the entire board to replace what you want it to, it just replaces the username you want it too with what you want?

Is there a way you can make it work with HTML?
Code: HTML
 
<script type="text/javascript">
$("*").contents().each(function () {
if (this.nodeType == 3) this.nodeValue = this.nodeValue.replace("Joinable Groups", "Factions").replace("Joinable Group", "Faction").replace("<th width='25%'>Group</th>", "<th width='25%'>Faction</th>").replace("<th width='45%'>Group Description</th>", "<th width='45%'>Faction Information</th>").replace("<th width='15%'>Join Group</th>", "<th width='15%'>Join Faction</th>");
});
</script>
Edited by Ferby, Jul 29 2012, 05:43 PM.
Offline Profile Quote Post Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
I suggest a different approach if you are trying to replace HTML:
Code:
 
<script type="text/javascript">
$('th[width="25%"]:contains(Group)').text('Faction');
$('th[width="45%"]:contains(Group Description)').text('Faction Information');
$('th[width="15%"]:contains(Join Group)').text('Join Faction');
</script>
Online Profile Quote Post Goto Top
 
0 users reading this topic
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply