...

View Full Version : change text?



nolvorite
06-20-2010, 07:46 PM
OK right I got a modification from here that someone requested a few weeks ago. It was supposed to replace text in the userlinks. Since I'm in IPB I find it very useful. But here's the thing

I try to replace "0 New Messages" to "Inbox[0]" it worked but when I get new PM's it doesn't work like it should. So I rearranged the code but it doesn't work

var mb = document.getElementById("userlinks").getElementsByTagName("a");
for(bm = 0;bm < mb.length;bm++){
if(mb[bm].innerHTML=="My Controls"){mb[bm].innerHTML="Preferences"}
for(fi=0;fi < mb[bm].innerHTML.length;fi++){
if(fi[mb['bm']].innerHTML==""+fi+" New Messages"){fi[mb[bm]].innerHTML="Inbox "+fi+""}
}
}
^^ My part there in the code is retarded lol

nolvorite
06-21-2010, 06:32 PM
anyone?

nolvorite
06-22-2010, 06:59 PM
omg lol......... any help?

Old Pedant
06-22-2010, 09:20 PM
I, for one, do not at all understand what you want. I can't make any sense of that code, at all.


var mb = document.getElementById("userlinks").getElementsByTagName("a");
for(bm = 0;bm < mb.length;bm++)
{
if(mb.innerHTML=="My Controls")
{
mb[bm].innerHTML="Preferences"
}
// okay...if we just changed "My Controls" to "Preferences" then presumably
// this particular <a> link is irrelevant...
// so the code that follows is for *other* <a> links, right?
//
for(fi=0;fi < mb[bm].innerHTML.length; fi++)
// but innerHTML.length is the NUMBER OF CHARACTERS in the text of a given link!
// so this FOR loop will iterate through the *characters*!
// fi is a *number* that goes from 0 to however many characters there are in the text of the link
{
if(fi[mb[[B]'bm']].innerHTML==""+fi+" New Messages")
// but now you are treating fi as an *ARRAY*!!! That's what the fi[ ] means!
// and in any case mb['bm'] will find nothing at all
// and....well, sorry, but it's just nonsense
{
fi[mb[bm]].innerHTML="Inbox "+fi+""
}
}
}


Instead of showing us code that can't possibly be doing anything, show us the actual HTML and then show us what you want it transformed into.

Old Pedant
06-22-2010, 09:20 PM
Oh...and what is "IPB"??

nolvorite
06-23-2010, 06:14 PM
ok here's (http://stereo.b1.jcink.com) my site- The #userlinks is the one right under the ads/menu on the top. When you log in the forum it says "My Controls" - "0 New Messages" etc. in the userlinks. I want to change the text from 0 New Messages to Inbox[0] or Inbox[1] or Inbox[2] if there's 2 new messages

here's an HTML code if you're logged in as someone named nolvorite

<table width="100%" id="userlinks" cellspacing="6">
<tr>
<td><strong>Logged in as: <a href='http://stereo.b1.jcink.com/index.php?showuser=1'>ǝтιɹoʌlou</a></strong> ( <a href='http://stereo.b1.jcink.com/index.php?act=Login&amp;CODE=03&amp;key=1a4dcf998504e8aa43a9a5cfd6757336'>Log Out</a>&middot; <b><a href='http://stereo.b1.jcink.com/index.php?act=modcp'>Mod CP</a></b> )</td>

<td align='right'>
<b><a href='http://stereo.b1.jcink.com/index.php?act=UserCP&amp;CODE=00' title='Edit my settings, such as signature, avatar and more...'>My Controls</a></b> &middot;

<!-- HHHHHHHHHHHHHnote: I want to change this from 0 New Messages to Inbox[0],1 New Messages if it's Inbox[1], or 2 Messages to Inbox[2] If there's 0/one/two new PM's (Private Messages) using javascript--><a href='http://stereo.b1.jcink.com/index.php?act=Msg&amp;CODE=01'>0 New Messages</a>

&middot; <a href='http://stereo.b1.jcink.com/index.php?act=Search&amp;CODE=getnew'>View New Posts</a> &middot; <a href='javascript:buddy_pop();' title='View posts since your last visit, moderator lists and more...'>My Assistant</a> &middot; <a href="javascript:window.open('index.php?showuser=1&CODE=friends','Friends','width=620,height=460,resizable=yes,scrollbars=yes');void(0);">My Friends</a><br />

</td>
</tr>
</table>


<!-- HHHHHHHHHHHHHnote: I want to change this from 0 New Messages to Inbox[0], Inbox[1], or Inbox[2] If there's one/two new PM's (Private Messages) using javascript--><a href='http://stereo.b1.jcink.com/index.php?act=Msg&amp;CODE=01'>0 New Messages</a>

Old Pedant
06-24-2010, 01:06 AM
Not to ask a dumb *** question, but...Why not go into the PHP and change it there???

Surely would be simpler than doing this ex post fact stuff.

Old Pedant
06-24-2010, 02:48 AM
Okay...here's my effort. Could be more efficient, but seems to work:


<html>
<head>
<script>
var check1 = /My Controls/;
var check2 = /(\d+) New Messages/;

function fixit( )
{
var links = document.getElementsByTagName("a");
for ( var n = 0; n < links.length; ++n )
{
a = links[n];
a.innerHTML = a.innerHTML.replace( check1, "Preferences" );
a.innerHTML = a.innerHTML.replace( check2, "Inbox[$1]" );
}
}
</script>
</head>
<body onload="fixit()">

<table width="100%" id="userlinks" cellspacing="6">
<tr>
<td><strong>Logged in as: <a href='http://stereo.b1.jcink.com/index.php?showuser=1'>ǝтιɹoʌlou</a></strong> ( <a

href='http://stereo.b1.jcink.com/index.php?act=Login&amp;CODE=03&amp;key=1a4dcf998504e8aa43a9a5cfd6757336'>Log Out</a>&middot; <b><a

href='http://stereo.b1.jcink.com/index.php?act=modcp'>Mod CP</a></b> )</td>

<td align='right'>
<b><a href='http://stereo.b1.jcink.com/index.php?act=UserCP&amp;CODE=00' title='Edit my settings, such as signature, avatar and

more...'>My Controls</a></b>
&middot;
<a href='http://stereo.b1.jcink.com/index.php?act=Msg&amp;CODE=01'>0 New Messages</a>
&middot; <a href='http://stereo.b1.jcink.com/index.php?act=Search&amp;CODE=getnew'>View New Posts</a>
&middot; <a href='javascript:buddy_pop();' title='View posts since your last visit, moderator lists and more...'>My Assistant</a>
&middot; <a ref="javascript:window.open('index.php?showuser=1&CODE=friends','Friends',
'width=620,height=460,resizable=yes,scrollbars=yes');void(0);"

>My Friends</a><br />
</td>
</tr>
</table>
</body>
</html>

nolvorite
06-24-2010, 06:49 PM
Not to ask a dumb *** question, but...Why not go into the PHP and change it there???

Surely would be simpler than doing this ex post fact stuff.
that's because my forum's hosted on a free host and I can't directly edit the HTML template because it's disabled to edit because they want to save some serious bandwidth.

anyways it worked, I love you man. I could never do that



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum