Tuesday, April 16, 2013

Comparision of Javascript Frameworks | Newbies in the block

Its jQuery everywhere. The web industry seems to have stabilized on that. But the battle just seems to have begun in the world of client side MVC frameworks. Today's complex web applications more just jQuery (which is a DOM Manipulation Library). Lets have a quick looks on the current client-side frameworks available.

  • BackboneJS
  • AngularJS
  • EmberJS
  • Knockout

Backbone

Features

  • Most simplicit in the list
  • Huge community
  • Less Opinioned
  • Most Minimal of the Libraries
  • Lots of Plugins Available, so that we can pick the features based on our requirement
  • Easy to manage large projects
  • Not a full fledged framework, need plugins to add features that are available buildin in some other libraries
  • More Boilerplate code required when compared with other frameworks

AngularJS

Features

  • Open Source & Backed by Google
  • Full Fledged Framework
  • Incredibly powerful 2 way binding support
  • Great Performance as it uses DOM nodes instead of strings for templating.
  • MVW (Model View Whatever)
  • More Clean Code is produced as it typically enhances the functionality of HTML
  • Easy to manage large projects
  • Intended to control your whole page at runtime, so not suitable for use in small “islands of richness” on a wider page

EmberJS

Features

  • Full Fledged Framework
  • A very ambitious framework
  • Pretty heavily opinionated about files, URLs, etc
  • Avoid a lot of boilerplate code.










Sunday, March 4, 2012

Miltery Proof Strong Javascript EMail Validation

After several hours of stunt with my tester, I think I made something very much useful. Email validation is very much common requirement for almost all project. However, the codes which are available for the same on the internet seems in-effective.

You are free to use this on your open source as-well-as commercial projects.



/*
* E-mail Validation
* @param value
*/
function validateEmail(elementValue){
var ind=elementValue.indexOf("@");
var email_local_part=elementValue.slice(0,ind);

if(email_local_part.length > 64) return false;
if(elementValue > 256) return false;
var x,y=email_local_part;

if(email_local_part.charAt(((email_local_part.length)-1)) == ".") return false;

while(y.indexOf(".")!=-1){
x = y.indexOf(".");
if(y.charAt(x+1) == ".") return false;
x++;
y=y.substr(x);
}
var dot = ".";
if( isInteger( elementValue.charAt(0) )) return false;
if( elementValue.charAt(0) == dot ) return false;

var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
return emailPattern.test(elementValue);

}

/*
* Trim implementation for Javascript
*/
function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}

/*
* Checks whether the input is an Integer
*/
function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
return true;
}




Implementation

if(!validateEmail("abc@gmail.com")){
alert("Invalid Email");
}