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(month == 2){//Means if it is month of feborary | |
if(nyear %4 == 0 && ( nyear %400 != 0 || nyear %100 !== 0 ){//Leap year statement | |
return true | |
} | |
}else{ | |
return false; | |
} |
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
$(document).keyup(function(e) { | |
if (e.keyCode == 27) { // escape key maps to keycode `27` | |
// <DO YOUR WORK HERE> | |
} | |
}); |
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
$('<div>').append($('#ID').clone()).html(); |
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
/*Default string of IE 10: | |
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0) | |
Default string of IE 11: | |
Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko | |
Default string of IE 12 (aka Edge): | |
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0 | |
Default string of Edge 13 (thx @DrCord): |
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 exportToCsv(filename, rows) { | |
var processRow = function (row) { | |
var finalVal = ''; | |
for (var j = 0; j < row.length; j++) { | |
var innerValue = row[j] === null ? '' : row[j].toString(); | |
if (row[j] instanceof Date) { | |
innerValue = row[j].toLocaleString(); | |
}; | |
var result = innerValue.replace(/"/g, '""'); | |
if (result.search(/("|,|\n)/g) >= 0) |
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 data = [["name1", "city1", "some other info"], ["name2", "city2", "more info"]]; | |
var csvContent = "data:text/csv;charset=utf-8,"; | |
data.forEach(function(infoArray, index){ | |
dataString = infoArray.join(","); | |
csvContent += index < data.length ? dataString+ "\n" : dataString; | |
}); | |
var encodedUri = encodeURI(csvContent); | |
window.open(encodedUri); |
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
/* Custom filtering function which will search data in column four between two values */ | |
$.fn.dataTable.ext.search.push( | |
function( settings, data, dataIndex ) { | |
var min = parseInt( $('#min').val(), 10 ); | |
var max = parseInt( $('#max').val(), 10 ); | |
var age = parseFloat( data[3] ) || 0; // use data for the age column | |
if ( ( isNaN( min ) && isNaN( max ) ) || | |
( isNaN( min ) && age <= max ) || | |
( min <= age && isNaN( max ) ) || |
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
$([ | |
{"name":"Lenovo Thinkpad 41A4298","website":"google222"}, | |
{"name":"Lenovo Thinkpad 41A2222","website":"google"} | |
]) | |
.filter(function (i,n){ | |
return n.website==='google'; | |
}); |
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
$.grep( [{"name":"Lenovo Thinkpad 41A4298","website":"google"},{"name":"Lenovo Thinkpad 41A2222","website":"google"}], function( n, i ) { | |
return n.website==='google'; | |
}); |
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 depthOf(arr) { | |
if(!Array.isArray(arr)) | |
throw "Not an Array" | |
var depth = 1; | |
var i; | |
for(var i = 0; i< arr.length; i++){ | |
if (!Array.isArray(arr[i])) continue; | |
if(Array.isArray(arr[i])){ | |
var depth = depthOf(arr[i]) + 1; |