This file contains 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 tableToArray(selector){ | |
var data = []; | |
var rows = Array.prototype.filter.call( | |
document | |
.querySelectorAll(selector)[0] | |
.getElementsByTagName('tr'), | |
function(row){ | |
return row.className !== 'header'; | |
} | |
); |
This file contains 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 ( console && console.log ) { | |
console._timeStamps = {}; | |
console.time = function(name){ | |
console._timeStamps[name] = new Date(); | |
console.log(name + ': ' + console._timeStamps[name]); | |
}; | |
console.timeCapture = function(name){ |
This file contains 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
// Usage: loadStatic(staticFiles); | |
var staticFiles = [ | |
'//cdn.example.com/jquery.js', | |
'//example.com/static/css/common.css' | |
]; | |
function loadStatic(files){ | |
files.forEach(function(file){ | |
var tag; |
This file contains 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
/* | |
console.log output example: | |
===================================================================================== | |
Date Total Diff Message | |
===================================================================================== | |
Wed Jan 30 2013 3:3:47:376 0ms 0ms start | |
Wed Jan 30 2013 3:3:47:382 6ms +6ms started hotels loading | |
Wed Jan 30 2013 3:3:47:502 126ms +120ms loaded: /optimizely/main.js (1) |
This file contains 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 ajax(params){ | |
var request = new XMLHttpRequest(); | |
var responseTimer; | |
function handleError(e){ | |
console.error('Can\'t load data:', e.message, e); | |
params.error && params.error(e); | |
}; | |
request.open(params.method || 'GET', params.url, true); | |
request.onreadystatechange = function(){ | |
if ( request.readyState === 4 ) { |
This file contains 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 get_max_width_array(tables){ | |
var max_width_arr = []; | |
tables.each(function(i, table){ | |
$(table).find('tr').first().find('th, td').each(function(i, td){ | |
var width = $(td).width(); | |
if ( !max_width_arr[i] || max_width_arr[i] < width ) { | |
max_width_arr[i] = width; | |
}); | |
}); | |
return max_width_arr; |
This file contains 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
// Все комбинации чисел из массива, дающие в сумме 10 | |
// getCombinations([2,4,6,5,1]) // -> 4,6 и 4,5,1 | |
function getCombinations(array){ | |
var allCombinations = []; | |
function getLevelCombinations(arr, indexes){ | |
console.log('combinations > ', stringifyCombinations(allCombinations).split('\n')); |
This file contains 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 id="yandex_ad"></div> | |
<script type="text/javascript"> | |
(function(w, d, n, s, t) { | |
w[n] = w[n] || []; | |
w[n].push(function() { | |
Ya.Direct.insertInto(108006, "yandex_ad", { | |
site_charset: "utf-8", | |
ad_format: "direct", |
This file contains 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
// Плагин | |
$.fn.extend({ | |
fixFilterWidth: function(){ | |
this.hide().each(function(i, el){ | |
var input = $(el); | |
var margins = +input.css('marginLeft').replace(/px$/, '') + | |
+input.css('marginRight').replace(/px$/, '') + | |
+input.css('borderLeftWidth').replace(/px$/, '') + | |
+input.css('borderRightWidth').replace(/px$/, ''); | |
var width = input.parent().width() - margins; |
OlderNewer