For the last few weeks I have been working on a new JavaScript Library. Its still not ready(I have to write some more test) for publishing - so I thought that I will create a small preview for it. My library is heavily influenced by jQuery. All the good features belong to jQuery - all the bugs belong to me.


The features in my library(apart from the standard stuff) include...

Sample Code

Enough talk - this is what you can do with the Library...

Add the class 'term' to all 'dt' elements


Using the Event Handler

JSL.dom("a").click(function(e) { // Adds a click event handler to all links
	alert(this.href); //Shows the link URL
	JSL.event(e).stop(); //And stops the event from propagating any further

Returns an array of all the external links of all the anchor in the para with ID 'intro'

JSL.dom('p#intro a[href^="http://"]').map(function(ele) { return(ele.href); }).get();
JSL.dom('p#intro a[href^="http://"]').map("ele.href").get(); //A shorter method to do the same thing as the above line

Attach a 'mouseover' handler to an element with the id 'an_id'

JSL.dom("an_id").on("mouseover", function(e) {
	//Do something here

Unlike jQuery, you don't have to specify # if it is an ID.

JSL.dom("an_id").innerHTML; // This works as well


And 1 to each element of the first array and return the result

JSL.array([4,10,65]).map(function(current_item){ return current_item+1; }).get();

Same as the above - except we use a shortcut - and we use an associative array.


Other functions like map, filter, grep, each, reduce are also supported.


Basic Ajax syntax

	alert(txt); //Fetches the URL data.php - and passes it to this function.

Send the data using POST method - and parsing the Json string.

	// Do stuff with 'data'
}, "json", "POST"); //The json argument will make the function eval the data before passing it.


The Todo list is much larger than the Done list.

Other Libraries

blog comments powered by Disqus