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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Exemple des Notifications Riches de Chrome</title> | |
<script> | |
/* | |
* Liste des callbacks | |
*/ | |
var notificationCreated = function(seqID) { | |
console.log("Notification '" + seqID + "' créée avec succès !"); |
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 isNumber(n) { | |
n = n.toString().replace(/,/g, '.'); // en chaine, puis convertir , en . | |
return !isNaN(parseFloat(n)) && isFinite(n); | |
} | |
console.log(isNumber(5)); // true | |
console.log(isNumber(4597)); // true | |
console.log(isNumber("lol")); // false | |
console.log(isNumber("9.489.")); // false | |
console.log(isNumber("9.489")); // 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 deepCopy(obj) { | |
if (Object.prototype.toString.call(obj) === '[object Array]') { | |
var len = obj.length, out = new Array(len), i = 0; | |
for ( ; i < len; i++ ) { | |
out[i] = arguments.callee(obj[i]); | |
} | |
return out; | |
} | |
if (typeof obj === 'object') { | |
var out = {}, i; |
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 AssertionError(msg) { | |
this.message = msg || ""; | |
this.name = "AssertionError"; | |
} | |
AssertionError.prototype = Error.prototype; | |
/* Call assert(cond, description1, ...) | |
An AssertionError will be thrown if the cond is false. All parameters will be logged to the console, | |
and be part of the error. | |
*/ |
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 isMap(m) { //similarly for Set, WeakMap, WeakSet | |
try { | |
Map.prototype.size.call(m); | |
return true; | |
} catch () {return false} | |
} | |
function isDataView(d) { | |
try { | |
DataView.prototype.buffer.call(d); |
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 rules = { | |
a:"àáâãäå", | |
A:"ÀÁÂ", | |
e:"èéêë", | |
E:"ÈÉÊË", | |
i:"ìíîï", | |
I:"ÌÍÎÏ", | |
o:"òóôõöø", | |
O:"ÒÓÔÕÖØ", | |
u:"ùúûü", |
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 (!Array.prototype.filter) { | |
Array.prototype.filter = function(fun /*, thisp */) { | |
"use strict"; | |
if (this == null) | |
throw new TypeError(); | |
var t = Object(this); | |
var len = t.length >>> 0; | |
if (typeof fun != "function") |
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
/* | |
* L'array le plus long doit être dans tab1 | |
*/ | |
Array.prototype.diff = function diff( tab1, tab2 ){ | |
var tab3 = []; | |
if (Array.isArray( tab1 ) && Array.isArray( tab2 )){ | |
tab3 = tab1.filter( function( value, index ){ | |
return this[ index ] && value[ Object.keys( value )[ 0 ] ] === this[ index ][ Object.keys( this[ index ] )[ 0 ] ]; | |
}, tab2 ); |
NewerOlder