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


Quick Links:


newBookmarkLockedFalling

Joe Kerr

Joe Kerr Avatar
Why So Serious?



769


June 2010
<script type="text/javascript">
/* Alert modifying the headers by Nightwalker
Do not use this code until it is released */

var winkyding="admin|nightwalker" //users that the popup does NOT show for
var winkydong="Please do not edit the Headers/Footers without permission of the admin. If you have permission please remember to backup the Headers/Footers before changing them. If you do not follow these you will have your staff privileges taken away." //Popup Message

if (pb_username != (winkyding)) {
if(/^(admin)$/.test(pb_action)) {
var i = document.links;
for(var x = 0; x < i.length; x ++)
if(i[x].href.indexOf("action=headersfooters") > -1)
i[x].onclick = function() { return confirm(""+ winkydong) }
}
}
</script>

This doesn't work..i guess i just don't understand variables...


Last Edit: Aug 17, 2010 1:50:52 GMT by Joe Kerr
Building Your Proboard, a Basic Guide to Getting Your Forum Started



Need somewhere to host files?[/url]

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Interesting variable names. :P

Your code is checking proboards usernames that equate to admin|nightwalker. Noone's pb_username is admin|nightwalker. You're thinking of RegExp. Which is a special type of data in JavaScript which describes patterns in strings.

var winkyding = /^(admin|nightwalker)$/;
if(winkyding.test(pb_username))

Edit: Added pretty colors. :3


Last Edit: Aug 17, 2010 2:10:33 GMT by Aaron

Joe Kerr

Joe Kerr Avatar
Why So Serious?



769


June 2010
thanks

so this is what i want?

<script type="text/javascript">
/* Alert modifying the headers by Nightwalker
Do not use this code until it is released */

var winkyding = /^(admin|nightwalker)$/ //users that the popup does NOT show for
if(winkyding.test(pb_username))
var winkydong="Please do not edit the Headers/Footers without permission of the admin. If you have permission please remember to backup the Headers/Footers before changing them. If you do not follow these you will have your staff privileges taken away." //Popup Message

if (pb_username != (winkyding)) {
if(/^(admin)$/.test(pb_action)) {
var i = document.links;
for(var x = 0; x < i.length; x ++)
if(i[x].href.indexOf("action=headersfooters") > -1)
i[x].onclick = function() { return confirm(""+ winkydong) }
}
}
</script>




obviously not..


Last Edit: Aug 17, 2010 2:18:59 GMT by Joe Kerr
Building Your Proboard, a Basic Guide to Getting Your Forum Started



Need somewhere to host files?[/url]

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
No, no. Replace your pb_username != winkydings conditional with the RegExp one. =)

<script type="text/javascript">
/* Alert modifying the headers by Nightwalker
Do not use this code until it is released */

var winkyding = /^(admin|nightwalker)$/; //users that the popup does NOT show for
var winkydong="Please do not edit the Headers/Footers without permission of the admin. If you have permission please remember to backup the Headers/Footers before changing them. If you do not follow these you will have your staff privileges taken away." //Popup Message

if(winkyding.test(pb_username)) {
if(/^(admin)$/.test(pb_action)) {
var i = document.links;
for(var x = 0; x < i.length; x ++)
if(i[x].href.indexOf("action=headersfooters") > -1)
i[x].onclick = function() { return confirm(""+ winkydong) }
}
}
</script>

Edit: Oh, use !winkyding.test(pb_username), btw. :-X



Last Edit: Aug 17, 2010 2:22:43 GMT by Aaron

Joe Kerr

Joe Kerr Avatar
Why So Serious?



769


June 2010
Oops sorry...haven't learned that one

For some reason it isn't working...the popup always pops up even if i am admin or nightwalker...


see your edit now

Thought it looked weird but like i said i haven't learned that way of doing it...

thanks for all the help today Aaron...i got two codes written in one day..that is a record for me no matter how easy they were...


Last Edit: Aug 17, 2010 2:26:41 GMT by Joe Kerr
Building Your Proboard, a Basic Guide to Getting Your Forum Started



Need somewhere to host files?[/url]

Joe Kerr

Joe Kerr Avatar
Why So Serious?



769


June 2010
is there a way to edit the text in a popup?

Like i would like to use breaks in the popup but have never been able to figure out how...
Building Your Proboard, a Basic Guide to Getting Your Forum Started



Need somewhere to host files?[/url]

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Edit: Line breaks: confirm("Line 1\nLine 2")

I won't be altogether on point here, but that's for brevity and simplicity.

pb_username == "Guest"

This line works by checking if the pb_username variable has a value equivalent to the string Guest. Just the same,

pb_username != "Guest"

checks if the variable's value isn't equivalent to the string "Guest".

So when you used

pb_username != "nightwalker|admin"

It was checking for that exact string as pb_username's value. RegExp, as aforementioned, is a way to describe patterns in strings.

/something/

This is how we declare a regular expression. Just like "this" is how we declare a string. In a regular expression, | means or. ^ marks the beginning of a string. And $ marks the end of a string.

/admin|nightwalker/

This pattern describes any string containing the words admin or nightwalker. However, this description includes usernames like admin2. Which isn't what we want. We want either admin or nightwalker specifically. So we use ^ and $.

/^admin|nightwalker$/

Issue here is that it looks for any string beginning with admin or ending with nightwalker. So let's group the two.

/^(admin|nightwalker)$/

This looks for a string that starts with either admin or nightwalker and ends immediately after.

Lastly, the match, test, exec, and search methods all run uniquely to compare strings with regular expressions.


Last Edit: Aug 17, 2010 2:38:28 GMT by Aaron

Joe Kerr

Joe Kerr Avatar
Why So Serious?



769


June 2010
ok now i get it...thanks
Building Your Proboard, a Basic Guide to Getting Your Forum Started



Need somewhere to host files?[/url]

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Keep it up, mate. =)

Joe Kerr

Joe Kerr Avatar
Why So Serious?



769


June 2010
well i have yet to do a big code but i am starting to understand more and more...most of my codes so far are alerts onclick...but that doesn't mean they aren't usefull. I will want to know alot when v5 comes out because i would like to write codes for it. Should be fun IF it comes out...
Building Your Proboard, a Basic Guide to Getting Your Forum Started



Need somewhere to host files?[/url]

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
v5 will outmode almost all current JS codes that just rearrange the DOM. Dynamic effects are probably going to be the big attraction then.

newBookmarkLockedFalling