Clean DOM-Object





ranking Sort Sort   |   date Sort Sort   |   member Sort Sort
Syndication

« Previous 1 2 3 4 5 6 7 8 9  ...  11 12 Next »
5
Date Submitted Mon. Dec. 24th, 2007 2:34 AM
Revision 1
Scripter Fordiman
Tags "data hidng" | Class | JavaScript | Prototype
Comments 3 comments
Ok, so I was getting frustrated with the inability to hide data in javascript, as well as a number of other concerns with existing class structures (the requirement to use this.constructor in lieu of self, for example).

As a result, I've thrown together a nice little class constructor that accepts a class definition, as well as a class extender that allows you to build a new class from an existing one, with full access to all that private stuff.
5
Date Submitted Thu. Nov. 29th, 2007 12:46 PM
Revision 1
Helper HRCerqueira
Tags images | JavaScript | sl
Comments 0 comments
This is a simple fade in / fade out javascript slideshow, search engine friendly with low resource usage.

More info here.

Cheers
5
Date Submitted Mon. Oct. 22nd, 2007 8:43 AM
Revision 1
Beginner richard123
Tags JavaScript | PHP | resolution
Comments 3 comments
This detects screen resolution using javascript and makes it available to php by way of cookies.
5
Date Submitted Wed. Aug. 9th, 2006 4:36 AM
Revision 1
Syntax Master sundaramkumar
Tags JavaScript
Comments 0 comments
Proper case a string
5
Date Submitted Thu. Aug. 10th, 2006 2:17 AM
Revision 1
Syntax Master sundaramkumar
Tags JavaScript
Comments 1 comments
convert An integer to a string
6
Date Submitted Tue. Feb. 28th, 2006 5:42 AM
Revision 1
Scripter TimYates
Tags CSS | Element | JavaScript | visibility
Comments 9 comments
Toggles the visibility of an HTML element. Should be part of everyone's javascript toolkit
6
Date Submitted Mon. Jun. 4th, 2007 3:06 PM
Revision 1
Scripter Fordiman
Tags "object passing" | JavaScript | PHP | serialize
Comments 6 comments
This is a quick set of overrides for Javascript so that any variable can be passed to PHP in a GET/POST activity. Just call myVar.toPHP();

I use this little set of functions extensively in a little Javascript/PHP RPC handler I wrote. I don't have the reverse function, as I pass JSON back to the browser for the return value.

Note: This lib is not safe for binaries or HTML Elements. The former will come out similar to FTP ASCII breaks, and the latter will cause infinite recursion. If you want to make a speical case for HTML Elements, do so; you could probably just test for parentNode and create a 'safe' object from that. I didn't need it, so I didn't code it.

As for binary safety, at some point between toPHP/escape/post/urldecode/unserialize, the object breaks. Rather than create a huge fix for something I didn't need to do, I put in a quick match/hack. Don't like it? Write the fix yourself.
6
Date Submitted Fri. Sep. 28th, 2007 2:08 AM
Revision 1
Scripter Fordiman
Tags JavaScript | promise | Prototype
Comments 6 comments
Here's a quick lil' addon for Prototype that I use often.

Prototype.Promise(condition, action, interval)
condition is a string that you want met before an action is run.
action is a function that does the action.
interval is the polling rate for condition in seconds, and defaults to 1

So, for example, you may want function foo to run, but only once bar has been set:

function foo(a,b) {
this.retVal=a+b;
}
var thingy = {
retVal:0
};
Prototype.Promise(
'thingy.retVal=5',
foo.bind(thingy,5,10),
5
);


Then, in some point in the mysterious future, thingy.retVal gets set to 5, at which point, the Promise goes into effect, and thingy.retVal becomes 10.

Where I find this particularly useful is in making sure that a document is loaded before doing something (condition="$$('body').length>=1), as you can see it used for the include functions.

Speaking of which, the following include functions are great for getting scripts and stylesheets into your page. I won't bother with examples, as they're pretty straightforward.

Meanwhile, Prototype.scriptPath will point to wherever in your server's heirarchy Prototype was loaded from. The regex, you'll note allows for names like prototype.compressed.js, prototype.modified.js, 2007-09-28.prototype.js, etc - just in case you want to keep track of your various hacks of Prototype, as I do.
6
Date Submitted Thu. Oct. 26th, 2006 6:59 PM
Revision 1
Helper brendo
Tags forms | JavaScript | message | textarea
Comments 3 comments
This snippet also you to limit the input in a form field to a specified number of characters. It displays a counter so users can see how many characters they have left, and once they reach the limit the field just trims the length to your limit.

The following is a snippet from what I used when I implemented a tagboard to my site. Further revisions could/should read the LIMIT from the maxlength attribute
6
Date Submitted Fri. Jul. 20th, 2007 11:17 PM
Revision 1
Helper lavaramano
Tags DOM | JavaScript | Key | onkeyup
Comments 0 comments
Returns the keycode of the key we wrote on a textarea/input. works on IE and Firefox
« Previous 1 2 3 4 5 6 7 8 9  ...  11 12 Next »