This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () { | |
var Storage = function (type) { | |
function createCookie(name, value, days) { | |
var date, expires; | |
if (days) { | |
date = new Date(); | |
date.setTime(date.getTime()+(days*24*60*60*1000)); | |
expires = "; expires="+date.toGMTString(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// older way in jquery | |
$('ul').delegate('li','click',function(){ | |
// do something | |
}); | |
//newer way | |
$("ul").on("click","li",function(){ | |
// do something | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var employees = [ | |
{ | |
"firstName": "John", | |
"lastName": "Doe" | |
}, | |
{ | |
"firstName": "Anna", | |
"lastName": "Smith" | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var person ={ | |
"employee":{ | |
"name": "Mohit Seth", | |
"role": "Javascript Developer" | |
} | |
} | |
/*this should be avoided*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This should be avoided | |
<script> | |
// block A javascript code | |
</script> | |
<script> | |
//block B javascript code | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This should be avoided */ | |
<input type="button" id="click-button" onclick="doSomething();" /> | |
/* Better way to add javascript */ | |
<input type="button" id="click-button" /> | |
<script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This is a global variable*/ | |
var name = "Mohit Seth"; | |
var role = "UI Developer"; | |
/*It is how namespacing can be done*/ | |
var NS = { | |
name: "Mohit Seth", | |
role: "UI Developer" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Logger = { | |
log : function( msg ) { | |
if( console ) { | |
console.log(msg); | |
} | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
document.domain="parentdomain.com"; | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Author:Mohit Seth | |
Version : 1.1 | |
Date : '02/10/2012' | |
Performs sub domain call using an iframe. | |
Usage: | |
Create new object of CrossDomain object passing the initial parameters | |
E.g: | |
var cd = new CrossDomain($("#frameID"),$("#targetDivID"),"xyz.com","http://xyz.com",callbackFunction); |
NewerOlder