function TOSTER(input) {
var first = input[0];
var s = "";
var col_search = -1;
var col_name = -1;
var col_code = -1;
var x,y;
for (x=0;x < first.length; x++) {
if (first[x] == 'SEORCH_VALUE') col_search = x;
else if (first[x] == 'NAME') col_name = x;
else if (first[x] == 'CODE') col_code = x;
}
if (col_search === -1) return "Ошибка! Нет колонки с шаблонами поиска.";
if (col_name === -1) return "Ошибка! Нет колонки со значениями.";
if (col_code === -1) return "Ошибка! Нет колонки с кодами значений.";
var table = [['RESULT']];
for (y=1; y < input.length; y++) {
var search_text = input[y][col_search];
if (!search_text || search_text === "") continue;
var result = "";
for (var yy=1; yy<input.length; yy++) {
if (search_text == input[yy][col_name]) { //Совпадение
if (result !== "") result += ", ";
var code = input[yy][col_code];
result += code;
}
}
if (result === "") result = "Not found.";
table[y] = [result];
}
return table;
}
=TOSTER(A1:C23)
function getDockedRect($target, searchSekector) {
var $targetCoordinates = getCoordinates($target);
var result = [];
$(searchSekector).each(function (i, el) {
var $el = $(el);
var coordinates = getCoordinates($el);
isDokked = !!(coordinates.top === $targetCoordinates.bottom
|| coordinates.bottom === $targetCoordinates.top
|| coordinates.left === $targetCoordinates.right
|| coordinates.right === $targetCoordinates.left);
if (isDokked) result.push(el);
});
return result;
}
function getCoordinates($target) {
var coordinates = $target.offset();
coordinates.bottom = coordinates.top + $target.height();
coordinates.right = coordinates.left + $target.width();
return coordinates;
}
$myBlock = $('#block_1');
var dockIds = getDockedRect($myBlock, '.rects').map(el => $(el).attr('id'));
alert('С #block_1 стоят рядом: ' + dockIds.join(','));
window.videoPercentage = 0;
video.addEventListener('progress', function() {
var range = 0;
var bf = this.buffered;
var time = this.currentTime;
while(!(bf.start(range) <= time && time <= bf.end(range))) {
range += 1;
}
var loadStartPercentage = bf.start(range) / this.duration;
var loadEndPercentage = bf.end(range) / this.duration;
var loadPercentage = loadEndPercentage - loadStartPercentage;
videoPercentage = loadPercentage;
});
$('video').on('click', function() {
console.log(videoPercentage);
});
var $test = $(".test"),
tm = null;
$test.on("input, keypress", function () {
log();
});
function log () {
clearTimeout(tm);
tm = setTimeout(function () {
console.log($test.prop("value"));
}, 300);
}
var a = {"a": "17","b": "1","d": "3","v": "10","e": "4","f": "9"};
var b = {"a": "1", "b": "3","d": "4","v": "5", "e": "6","f": "7"};
function search(a, b) {
var result = [];
for(var akey in a) {
var found = false;
for(var bkey in b) {
if (a[akey] == b[bkey]) {
found = true;
continue;
}
}
if (!found) {
result.push(a[akey]);
}
}
return result;
}
console.log(search(a, b));
var a = [17, 1, 3, 0, 4, 9];
var b = [1, 3, 4, 5, 6, 7];
function search(a, b) {
var result = [];
for(var i = 0; i < a.length; i++) {
if (b.indexOf(a[i]) == -1) {
result.push(a[i]);
}
}
return result;
}
console.log(search(a, b));
console.log(search(b, a));
var a = [17, 1, 3, 0, 4, 9];
var b = [1, 3, 4, 5, 6, 7];
function search(a, b) {
var result = [];
a.forEach(function(v) {
if (b.indexOf(v) == -1) {
result.push(v);
}
});
return result;
}
console.log(search(a, b));
console.log(search(b, a));