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


Quick Links:



Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Compressed again. Wonder why JS doesn't support floating points in binary operations?

a & a, a >> 0, etc. seem to be fast alternatives to Math.floor.

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.

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Keep it up, mate. =)

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

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

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

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Looks fine to me. Just make sure you're targeting all the right pages.

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Another silly oversight on my part.

i[x].onclick = new Function("return confirm('" + nopming[k][1] + "')");

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Your onclick function grabs nopming[k][1] each time the user clicks a link. This is after your loop has run and k is at 2. So no matter what user they pm to, they'll get confirm("" + nopming[2][1]). The error comes from trying to access an element of an undefined value.

Easy fix:

i[x].onclick = new Function("return confirm(" + nopming[k][1] + ")");

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Maybe i'm tired, but it looks like you just forgot a } at the end. =)

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
With him and the kid, he's totally got a Willow thing going. 't is awesome.

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
Without the sleep deprivation and horrible shave. P=




:o Why would you cut that? DDD:


Last Edit: Aug 14, 2010 18:02:28 GMT by Aaron

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
so what should i do?

Whatever you want, mate.

And don't listen to Freddy. He just likes to antagonize people.

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
I vote we just give them all to torque. She's half of SZ's activity, anyway. :P

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
I agree with Eric that forums altogether are being phased out. And that the pb (coding) community is dead. In a sense, there is a mod for everything, so it's rare to see coders at all. Triad and Sub are the only new guys I can think of in the past three years.

If we had enough active members here (Chris, James, Eric, Fredy, Night, Richie, Sub?), I could start some 1k challenges or write js tips/optimization threads. And Fredy's busy with something already.