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 reveal = function(msgIn, msgOut){ | |
msgIn = msgIn || "Reveal it!"; | |
msgOut = msgOut || "Hide It!"; | |
$("input[type=password]").each(function(){ | |
var self = $(this); | |
$(this).after("<span id='revealctrl'></span>") | |
.next() | |
.append("<input type=checkbox id='revealCheckbox'>") |
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
<link href="http://fonts.googleapis.com/css?family=Squada+One" rel="stylesheet" type="text/css"> | |
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> | |
<link href="style.css" rel="stylesheet" type="text/css"> | |
<script src="script.js"></script> | |
<body> | |
<span id="pos"> | |
</span> | |
<span id="text"> |
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(localStorage in window) | |
if(typeof localStorage.view == 'undefined') localStorage.view = 0 | |
localStorage.view++; | |
maxView = 10; | |
if(maxView > localStorage.view){ | |
// display a message 10 times | |
} |
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
myElement.addEventListener("transitionend", function() { | |
alert('transition completed') | |
}, true); |
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
(function(window){ | |
// add ability to save an object | |
if(localStorage){ | |
Storage.prototype.setObj = function (key, obj) { | |
return this.setItem(key, JSON.stringify(obj)); | |
} | |
Storage.prototype.getObj = function(key) { | |
return JSON.parse(this.getItem(key)); |
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
// create an object a and clone it in b | |
var a = { | |
init:function(){return 'hello'} | |
}, b = Object.create(a); | |
// check the values | |
a.init(); // hello | |
b.init(); // hello | |
// set a new return value to init |
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
class Author { | |
private $firstName; | |
private $lastName; | |
public function __construct($firstName, $lastName) { | |
$this->firstName = $firstName; | |
$this->lastName = $lastName; | |
} | |
public function getFirstName() { | |
return $this->firstName; | |
} |
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
//compare two distinct array | |
// check for length and value at each index | |
function equalArrays(a,b) { | |
if (a.length != b.length) return false; | |
for(var i = 0; i < a.length; i++) | |
if (a[i] !== b[i]) return false; | |
return true; | |
} |
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 MyClass = function(options) { | |
/* create a private variable */ | |
privateOpt = options; | |
/* create a public variable*/ | |
this.opt = options; | |
/* to access this variable into the method */ | |
var that = this; |
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
false == false // true | |
0 == false // true | |
-0 == false // true | |
'' == false //true | |
// converting to a Number will return 0 | |
// exemple: |
OlderNewer