Thursday, September 25th, 2008
Pi.js: Simple JavaScript Library
<p>
Azer Koculu has released his Pi.js framework, which is a lightweight system that includes a minimal set of modules, and the ability to use and provide plugins.
By default you get:
- pi.env: browser detection
- pi.get: DOM access
- pi.util: Extensions to JavaScript (e.g. support currying, includes, viewport config, and more)
- pi.base: OO subsystem
- pi.element: Create and modify the DOM
- p.xhr: Remoting
- Extensions to native objects such as Array, Function, Number, and String
There are then plugins to provide functionality such as Comet support, and a storage wrapper.
Pi has been used in the excellent Firebug Lite update that Azer worked on.
Related Content:











whats the fuzz ?
Who would use this framework?
I took a quick look at the documentation and I didn’t find anything interesting/different/cool. Apologies if I missed something obvious.
How about a slickspeed competition?
pi.env = {
ie: /MSIE/i.test(navigator.userAgent),
ie6: /MSIE 6/i.test(navigator.userAgent),
ie7: /MSIE 7/i.test(navigator.userAgent),
ie8: /MSIE 8/i.test(navigator.userAgent),
firefox: /Firefox/i.test(navigator.userAgent),
opera: /Opera/i.test(navigator.userAgent),
webkit: /Webkit/i.test(navigator.userAgent)
};
Oh, boy!
Holy crip it’s a crapple:
.
var MyForm = new pi.element("form").attribute.addClass("MyForm").child.add(
new pi.element("label").update("Username:"),
new pi.element("input").attribute.set("type","text"),
new pi.element("button").event.addListener("click",function(){
alert("Hello World!");
}).update("Submit")
).insert(document.body);
.
.
to create:
Username:
Submit
Ajaxian fail…corrected result from above code:
to create:
<form class=”MyForm”>
<label>Username:</label>
<input type=”text”>
<button>Submit</button>
</form>
</code>