Jump to content
xisto Community
Sign in to follow this  
Sharn

My Little Javascript Need Some Debugging Help

Recommended Posts

Ok, to start, the purpose of the script. I'm trying to make a script that puts a link on every page on an Invisionfree forum (IPB 1.3) that takes you to a thread and automatically put in the url from which you clicked. I already have the whole thing working, but when I go to edit my signature, it inputs most of the url into the box. It replaces my whole sig with that, so it's a big problem.

The code:

This part makes the link on every page.<script LANGUAGE="JavaScript">  		   <!--		   document.write('<A HREF="http://z14.invisionfree.com/worknplay/index.php?act=Post&CODE=02&f=25&t=31&Post=' + location.href +'">');		   document.write('Report Topic');		   document.write('</A>');		   // --></SCRIPT>

This part inputs the url variable into the post box.<FORM NAME="Post"><INPUT TYPE="hidden" NAME="Posturl"></FORM><script LANGUAGE="javascript">var locate = window.locationdocument.Post.Posturl.value = locatevar text = document.Post.Posturl.valuefunction delineate(str){theleft = str.indexOf("Post=") + 5;theright = str.lastIndexOf("&");return(str.substring(theleft, theright));}function delineat(str){theleft = str.indexOf("showtopic=") + 10;theright = str.lastIndexOf("&");return(str.substring(theleft, theright));}if(delineat(text) == "31") {eval('document.REPLIER.Post.value = delineate(text)');}</SCRIPT>

So the idea is to report a thread if it is spam. It brings you to a thread made for reporting them and automatically puts the URL of the bad thread in. As I said, when the "Post" variable is passed in the url, it works fine for it's purpose. However, if there is no Post variable in the url it reports everything after http (IE ://z14.invisionfree.com/worknplay/index.php?act=Post&CODE=02&f=26)

I just realised it did that to every post, and not just the signature. The thread I would like it to report into is "http://z14.invisionfree.com/worknplay/index.php?act=Post&CODE=02&f=26&t=7;, how would I get that if... loop to work to only make it put in the text in that certain thread? I'm new to Javascript, so I'm not sure how to use if statements with a str. =\

EDIT: Mmk, I got it to where it would only put it in one url, but that url just so happens to change for every topic. So what I need is some sort of wildcard after
"http://z14.invisionfree.com/worknplay/index.php?showtopic=31&st=0&%23last;
So it will enter the URL only on that thread.

Second edit: All right, I got it completely figured out. If anyone wants the code for whatever reason, feel free to PM me...
Edited by Sharn (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.