Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Support
  • Code University
  • Is this possible?
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
Is this possible?
Tweet Topic Started: Jun 6 2009, 05:40 PM (335 Views)
Lout Jun 6 2009, 05:40 PM Post #1
Member Avatar


Posts:
402
Group:
Dedicated
Member
#2,400
Joined:
Feb 19, 2009
Ok so I have found a Reputation code (on another board), which I am allowed to edit a fair bit.

So far I have managed to change it from being a "+ & -"Reputation code to just being a Thank Member code.

All that was easy as it was just changing a few settings rather than adding to the code (which is not my area of expertise), but what I would like to do, if possible, is add a snippet to it so that the Thank Member function is only accessible in certain forums that I specify via the code.

Is this possible, and if so, how?

I wont post the code here, but will PM it to staff members if required.

Thanks in advance. :)

Posted Image
Offline Profile Goto Top
 
Reid Jun 6 2009, 05:43 PM Post #2
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Code:
 
if (location.href.indexOf("SOME URL")!=-1 || location.href.indexOf("SOME URL")!=-1 || location.href.indexOf("SOME URL")!=-1 || location.href.indexOf("SOME URL")!=-1) {
...code here....
}
You can add or remove them as needed. || is the logical OR operator.

Or, you could always do this -
Code:
 
if (location.href.match(/(part of url|part of url|part of url|part of url|)/)) {
..code..
}
Of course if you do that you have to escape most characters, making it kind of hard to read.
The Resource Board
Offline Profile Goto Top
 
Lout Jun 6 2009, 05:59 PM Post #3
Member Avatar


Posts:
402
Group:
Dedicated
Member
#2,400
Joined:
Feb 19, 2009
I think I get that, I'll have a play around with it on my test board and let you know how it turns out.

Thanks for the quick reply though :D
Edited by Lout, Jun 6 2009, 06:00 PM.
Posted Image
Offline Profile Goto Top
 
Lout Jun 6 2009, 06:57 PM Post #4
Member Avatar


Posts:
402
Group:
Dedicated
Member
#2,400
Joined:
Feb 19, 2009
Hmm, not sure if I understand exactly where that should slot in. Tried a few variations, but my forums going mad at the moment so time is tricky, but basically the code starts and ends like so:-
Code:
 
//<![CDATA[
<script type="text/javascript">
..................
Code is here....

//]]>
</script>


So should it go between the <script> tags, or between the whole code?

I'm confuzzled :hmm:
Posted Image
Offline Profile Goto Top
 
Reid Jun 6 2009, 07:04 PM Post #5
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
LagerLout
Jun 6 2009, 06:57 PM
Hmm, not sure if I understand exactly where that should slot in. Tried a few variations, but my forums going mad at the moment so time is tricky, but basically the code starts and ends like so:-
Code:
 
//<![CDATA[
<script type="text/javascript">
..................
Code is here....

//]]>
</script>


So should it go between the <script> tags, or between the whole code?

I'm confuzzled :hmm:
The CDATA should be inside of the script, like so..
Code:
 
<script type='text/javascript'>
// <![CDATA[
..code...
// ]]>
</script>
So the end result would be something like
Code:
 
<script type='text/javascript'>
// <![CDATA[
if (location.href.indexOf('/topic/')!=-1 || location.href.indexOf('/single/')!=-1) {
..do some stuff
}
// ]]>
</script>
In that code, it makes sure you are either on a topic or viewing a single post from a topic.
Edited by Reid, Jun 6 2009, 07:05 PM.
The Resource Board
Offline Profile Goto Top
 
Lout Jun 6 2009, 07:17 PM Post #6
Member Avatar


Posts:
402
Group:
Dedicated
Member
#2,400
Joined:
Feb 19, 2009
I don't get it, I've tried every which way I can think of (which probably isn't enough) but still cant get it to work.

I'll PM you the original code and you might see something I'm missing.

It's late here so it may just be me though :hmm:
Posted Image
Offline Profile Goto Top
 
Lout Jul 3 2009, 02:42 PM Post #7
Member Avatar


Posts:
402
Group:
Dedicated
Member
#2,400
Joined:
Feb 19, 2009
Coming back to this (which thanks to Reid's help I got working perfectly), is there anything I can add to the current code to specify which usergroups have access to using it?

Here is the code in full that I'm now using:-
Code:
 
<script type="text/javascript">
//<![CDATA[
/* ZetaBoards Reputation System by GenerationStudio
Do not edit this code except for these variables: */
var _forums = [], _n = 0;
_forums[_n++] = 'Competitions';
_forums[_n++] = 'Staff';
_forums[_n++] = 'Swap Shop';
_forums[_n++] = 'Technical Problems / Solutions';
_forums[_n++] = 'PC / Technology';
_forums[_n++] = 'PC Discussion';
_forums[_n++] = 'The Charity Shop';
RepOptions = {
on: true,
customDomainCode: "uk360dotnet",
name: "Thanks",
addImg: "<img src='http://z2.ifrm.com/10710/37/0/f5007679/acerbicthanks.png' alt='' />",
minusImg: "</>",
version: "1.0.0"
};
// Don't edit below this line, thanks!
var _testForums = false, _navcont = $('#nav').html().toLowerCase(), _n = _forums.length;
while (_n--){
if (_navcont.indexOf(_forums[_n].toLowerCase()) != -1) {
_testForums = true;
break;
}}
if ((window.location.href.split(main_url)[1].split("/")[0] == "topic" || window.location.href.split(main_url)[1].split("/")[0] == "profile") && _testForums) {
document.write('<script src="http://z2.ifrm.com/10710/37/0/p1007052/thanksscript.js"><\/script>')
}
</script>


Thanks in advance guys :D
Posted Image
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Code University · Next Topic »
Locked Topic

Track Topic · E-mail Topic Time: 7:46 PM Jul 10
Hosted for free by ZetaBoards · Privacy Policy