repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
Cerealkillerway/materialNote | src/js/base/core/dom.js | function (node, pred) {
pred = pred || func.ok;
var siblings = [];
if (node.previousSibling && pred(node.previousSibling)) {
siblings.push(node.previousSibling);
}
siblings.push(node);
if (node.nextSibling && pred(node.nextSibling)) {
siblings.push(node.nextSibling);
}
return siblings;
} | javascript | function (node, pred) {
pred = pred || func.ok;
var siblings = [];
if (node.previousSibling && pred(node.previousSibling)) {
siblings.push(node.previousSibling);
}
siblings.push(node);
if (node.nextSibling && pred(node.nextSibling)) {
siblings.push(node.nextSibling);
}
return siblings;
} | [
"function",
"(",
"node",
",",
"pred",
")",
"{",
"pred",
"=",
"pred",
"||",
"func",
".",
"ok",
";",
"var",
"siblings",
"=",
"[",
"]",
";",
"if",
"(",
"node",
".",
"previousSibling",
"&&",
"pred",
"(",
"node",
".",
"previousSibling",
")",
")",
"{",
"siblings",
".",
"push",
"(",
"node",
".",
"previousSibling",
")",
";",
"}",
"siblings",
".",
"push",
"(",
"node",
")",
";",
"if",
"(",
"node",
".",
"nextSibling",
"&&",
"pred",
"(",
"node",
".",
"nextSibling",
")",
")",
"{",
"siblings",
".",
"push",
"(",
"node",
".",
"nextSibling",
")",
";",
"}",
"return",
"siblings",
";",
"}"
] | returns array of closest siblings with node
@param {Node} node
@param {function} [pred] - predicate function
@return {Node[]} | [
"returns",
"array",
"of",
"closest",
"siblings",
"with",
"node"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/dom.js#L178-L190 | train |
|
Cerealkillerway/materialNote | src/js/base/core/dom.js | function (node, pred) {
node = node.parentNode;
while (node) {
if (nodeLength(node) !== 1) { break; }
if (pred(node)) { return node; }
if (isEditable(node)) { break; }
node = node.parentNode;
}
return null;
} | javascript | function (node, pred) {
node = node.parentNode;
while (node) {
if (nodeLength(node) !== 1) { break; }
if (pred(node)) { return node; }
if (isEditable(node)) { break; }
node = node.parentNode;
}
return null;
} | [
"function",
"(",
"node",
",",
"pred",
")",
"{",
"node",
"=",
"node",
".",
"parentNode",
";",
"while",
"(",
"node",
")",
"{",
"if",
"(",
"nodeLength",
"(",
"node",
")",
"!==",
"1",
")",
"{",
"break",
";",
"}",
"if",
"(",
"pred",
"(",
"node",
")",
")",
"{",
"return",
"node",
";",
"}",
"if",
"(",
"isEditable",
"(",
"node",
")",
")",
"{",
"break",
";",
"}",
"node",
"=",
"node",
".",
"parentNode",
";",
"}",
"return",
"null",
";",
"}"
] | find nearest ancestor only single child blood line and predicate hit
@param {Node} node
@param {Function} pred - predicate function | [
"find",
"nearest",
"ancestor",
"only",
"single",
"child",
"blood",
"line",
"and",
"predicate",
"hit"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/dom.js#L272-L283 | train |
|
Cerealkillerway/materialNote | src/js/base/core/dom.js | function (node, wrapperName) {
var parent = node.parentNode;
var wrapper = $('<' + wrapperName + '>')[0];
parent.insertBefore(wrapper, node);
wrapper.appendChild(node);
return wrapper;
} | javascript | function (node, wrapperName) {
var parent = node.parentNode;
var wrapper = $('<' + wrapperName + '>')[0];
parent.insertBefore(wrapper, node);
wrapper.appendChild(node);
return wrapper;
} | [
"function",
"(",
"node",
",",
"wrapperName",
")",
"{",
"var",
"parent",
"=",
"node",
".",
"parentNode",
";",
"var",
"wrapper",
"=",
"$",
"(",
"'<'",
"+",
"wrapperName",
"+",
"'>'",
")",
"[",
"0",
"]",
";",
"parent",
".",
"insertBefore",
"(",
"wrapper",
",",
"node",
")",
";",
"wrapper",
".",
"appendChild",
"(",
"node",
")",
";",
"return",
"wrapper",
";",
"}"
] | wrap node with new tag.
@param {Node} node
@param {Node} tagName of wrapper
@return {Node} - wrapper | [
"wrap",
"node",
"with",
"new",
"tag",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/dom.js#L393-L401 | train |
|
Cerealkillerway/materialNote | src/js/base/core/dom.js | function (node, preceding) {
var next = preceding.nextSibling, parent = preceding.parentNode;
if (next) {
parent.insertBefore(node, next);
} else {
parent.appendChild(node);
}
return node;
} | javascript | function (node, preceding) {
var next = preceding.nextSibling, parent = preceding.parentNode;
if (next) {
parent.insertBefore(node, next);
} else {
parent.appendChild(node);
}
return node;
} | [
"function",
"(",
"node",
",",
"preceding",
")",
"{",
"var",
"next",
"=",
"preceding",
".",
"nextSibling",
",",
"parent",
"=",
"preceding",
".",
"parentNode",
";",
"if",
"(",
"next",
")",
"{",
"parent",
".",
"insertBefore",
"(",
"node",
",",
"next",
")",
";",
"}",
"else",
"{",
"parent",
".",
"appendChild",
"(",
"node",
")",
";",
"}",
"return",
"node",
";",
"}"
] | insert node after preceding
@param {Node} node
@param {Node} preceding - predicate function | [
"insert",
"node",
"after",
"preceding"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/dom.js#L409-L417 | train |
|
Cerealkillerway/materialNote | src/js/base/core/dom.js | function (node, aChild) {
$.each(aChild, function (idx, child) {
node.appendChild(child);
});
return node;
} | javascript | function (node, aChild) {
$.each(aChild, function (idx, child) {
node.appendChild(child);
});
return node;
} | [
"function",
"(",
"node",
",",
"aChild",
")",
"{",
"$",
".",
"each",
"(",
"aChild",
",",
"function",
"(",
"idx",
",",
"child",
")",
"{",
"node",
".",
"appendChild",
"(",
"child",
")",
";",
"}",
")",
";",
"return",
"node",
";",
"}"
] | append elements.
@param {Node} node
@param {Collection} aChild | [
"append",
"elements",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/dom.js#L425-L430 | train |
|
Cerealkillerway/materialNote | src/js/base/core/dom.js | function (point) {
if (!isText(point.node)) {
return false;
}
var ch = point.node.nodeValue.charAt(point.offset - 1);
return ch && (ch !== ' ' && ch !== NBSP_CHAR);
} | javascript | function (point) {
if (!isText(point.node)) {
return false;
}
var ch = point.node.nodeValue.charAt(point.offset - 1);
return ch && (ch !== ' ' && ch !== NBSP_CHAR);
} | [
"function",
"(",
"point",
")",
"{",
"if",
"(",
"!",
"isText",
"(",
"point",
".",
"node",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"ch",
"=",
"point",
".",
"node",
".",
"nodeValue",
".",
"charAt",
"(",
"point",
".",
"offset",
"-",
"1",
")",
";",
"return",
"ch",
"&&",
"(",
"ch",
"!==",
"' '",
"&&",
"ch",
"!==",
"NBSP_CHAR",
")",
";",
"}"
] | returns whether point has character or not.
@param {Point} point
@return {Boolean} | [
"returns",
"whether",
"point",
"has",
"character",
"or",
"not",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/dom.js#L675-L682 | train |
|
Cerealkillerway/materialNote | src/js/base/editing/Table.js | setVirtualTablePosition | function setVirtualTablePosition(rowIndex, cellIndex, baseRow, baseCell, isRowSpan, isColSpan, isVirtualCell) {
var objPosition = {
'baseRow': baseRow,
'baseCell': baseCell,
'isRowSpan': isRowSpan,
'isColSpan': isColSpan,
'isVirtual': isVirtualCell
};
if (!_virtualTable[rowIndex]) {
_virtualTable[rowIndex] = [];
}
_virtualTable[rowIndex][cellIndex] = objPosition;
} | javascript | function setVirtualTablePosition(rowIndex, cellIndex, baseRow, baseCell, isRowSpan, isColSpan, isVirtualCell) {
var objPosition = {
'baseRow': baseRow,
'baseCell': baseCell,
'isRowSpan': isRowSpan,
'isColSpan': isColSpan,
'isVirtual': isVirtualCell
};
if (!_virtualTable[rowIndex]) {
_virtualTable[rowIndex] = [];
}
_virtualTable[rowIndex][cellIndex] = objPosition;
} | [
"function",
"setVirtualTablePosition",
"(",
"rowIndex",
",",
"cellIndex",
",",
"baseRow",
",",
"baseCell",
",",
"isRowSpan",
",",
"isColSpan",
",",
"isVirtualCell",
")",
"{",
"var",
"objPosition",
"=",
"{",
"'baseRow'",
":",
"baseRow",
",",
"'baseCell'",
":",
"baseCell",
",",
"'isRowSpan'",
":",
"isRowSpan",
",",
"'isColSpan'",
":",
"isColSpan",
",",
"'isVirtual'",
":",
"isVirtualCell",
"}",
";",
"if",
"(",
"!",
"_virtualTable",
"[",
"rowIndex",
"]",
")",
"{",
"_virtualTable",
"[",
"rowIndex",
"]",
"=",
"[",
"]",
";",
"}",
"_virtualTable",
"[",
"rowIndex",
"]",
"[",
"cellIndex",
"]",
"=",
"objPosition",
";",
"}"
] | Define virtual table position info object.
@param {int} rowIndex Index position in line of virtual table.
@param {int} cellIndex Index position in column of virtual table.
@param {object} baseRow Row affected by this position.
@param {object} baseCell Cell affected by this position.
@param {bool} isSpan Inform if it is an span cell/row. | [
"Define",
"virtual",
"table",
"position",
"info",
"object",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/editing/Table.js#L48-L60 | train |
Cerealkillerway/materialNote | src/js/base/editing/Table.js | getActionCell | function getActionCell(virtualTableCellObj, resultAction, virtualRowPosition, virtualColPosition) {
return {
'baseCell': virtualTableCellObj.baseCell,
'action': resultAction,
'virtualTable': {
'rowIndex': virtualRowPosition,
'cellIndex': virtualColPosition
}
};
} | javascript | function getActionCell(virtualTableCellObj, resultAction, virtualRowPosition, virtualColPosition) {
return {
'baseCell': virtualTableCellObj.baseCell,
'action': resultAction,
'virtualTable': {
'rowIndex': virtualRowPosition,
'cellIndex': virtualColPosition
}
};
} | [
"function",
"getActionCell",
"(",
"virtualTableCellObj",
",",
"resultAction",
",",
"virtualRowPosition",
",",
"virtualColPosition",
")",
"{",
"return",
"{",
"'baseCell'",
":",
"virtualTableCellObj",
".",
"baseCell",
",",
"'action'",
":",
"resultAction",
",",
"'virtualTable'",
":",
"{",
"'rowIndex'",
":",
"virtualRowPosition",
",",
"'cellIndex'",
":",
"virtualColPosition",
"}",
"}",
";",
"}"
] | Create action cell object.
@param {object} virtualTableCellObj Object of specific position on virtual table.
@param {enum} resultAction Action to be applied in that item. | [
"Create",
"action",
"cell",
"object",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/editing/Table.js#L68-L77 | train |
Cerealkillerway/materialNote | src/js/base/editing/Table.js | recoverCellIndex | function recoverCellIndex(rowIndex, cellIndex) {
if (!_virtualTable[rowIndex]) {
return cellIndex;
}
if (!_virtualTable[rowIndex][cellIndex]) {
return cellIndex;
}
var newCellIndex = cellIndex;
while (_virtualTable[rowIndex][newCellIndex]) {
newCellIndex++;
if (!_virtualTable[rowIndex][newCellIndex]) {
return newCellIndex;
}
}
} | javascript | function recoverCellIndex(rowIndex, cellIndex) {
if (!_virtualTable[rowIndex]) {
return cellIndex;
}
if (!_virtualTable[rowIndex][cellIndex]) {
return cellIndex;
}
var newCellIndex = cellIndex;
while (_virtualTable[rowIndex][newCellIndex]) {
newCellIndex++;
if (!_virtualTable[rowIndex][newCellIndex]) {
return newCellIndex;
}
}
} | [
"function",
"recoverCellIndex",
"(",
"rowIndex",
",",
"cellIndex",
")",
"{",
"if",
"(",
"!",
"_virtualTable",
"[",
"rowIndex",
"]",
")",
"{",
"return",
"cellIndex",
";",
"}",
"if",
"(",
"!",
"_virtualTable",
"[",
"rowIndex",
"]",
"[",
"cellIndex",
"]",
")",
"{",
"return",
"cellIndex",
";",
"}",
"var",
"newCellIndex",
"=",
"cellIndex",
";",
"while",
"(",
"_virtualTable",
"[",
"rowIndex",
"]",
"[",
"newCellIndex",
"]",
")",
"{",
"newCellIndex",
"++",
";",
"if",
"(",
"!",
"_virtualTable",
"[",
"rowIndex",
"]",
"[",
"newCellIndex",
"]",
")",
"{",
"return",
"newCellIndex",
";",
"}",
"}",
"}"
] | Recover free index of row to append Cell.
@param {int} rowIndex Index of row to find free space.
@param {int} cellIndex Index of cell to find free space in table. | [
"Recover",
"free",
"index",
"of",
"row",
"to",
"append",
"Cell",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/editing/Table.js#L85-L100 | train |
Cerealkillerway/materialNote | src/js/base/editing/Table.js | addCellInfoToVirtual | function addCellInfoToVirtual(row, cell) {
var cellIndex = recoverCellIndex(row.rowIndex, cell.cellIndex);
var cellHasColspan = (cell.colSpan > 1);
var cellHasRowspan = (cell.rowSpan > 1);
var isThisSelectedCell = (row.rowIndex === _startPoint.rowPos && cell.cellIndex === _startPoint.colPos);
setVirtualTablePosition(row.rowIndex, cellIndex, row, cell, cellHasRowspan, cellHasColspan, false);
// Add span rows to virtual Table.
var rowspanNumber = cell.attributes.rowSpan ? parseInt(cell.attributes.rowSpan.value, 10) : 0;
if (rowspanNumber > 1) {
for (var rp = 1; rp < rowspanNumber; rp++) {
var rowspanIndex = row.rowIndex + rp;
adjustStartPoint(rowspanIndex, cellIndex, cell, isThisSelectedCell);
setVirtualTablePosition(rowspanIndex, cellIndex, row, cell, true, cellHasColspan, true);
}
}
// Add span cols to virtual table.
var colspanNumber = cell.attributes.colSpan ? parseInt(cell.attributes.colSpan.value, 10) : 0;
if (colspanNumber > 1) {
for (var cp = 1; cp < colspanNumber; cp++) {
var cellspanIndex = recoverCellIndex(row.rowIndex, (cellIndex + cp));
adjustStartPoint(row.rowIndex, cellspanIndex, cell, isThisSelectedCell);
setVirtualTablePosition(row.rowIndex, cellspanIndex, row, cell, cellHasRowspan, true, true);
}
}
} | javascript | function addCellInfoToVirtual(row, cell) {
var cellIndex = recoverCellIndex(row.rowIndex, cell.cellIndex);
var cellHasColspan = (cell.colSpan > 1);
var cellHasRowspan = (cell.rowSpan > 1);
var isThisSelectedCell = (row.rowIndex === _startPoint.rowPos && cell.cellIndex === _startPoint.colPos);
setVirtualTablePosition(row.rowIndex, cellIndex, row, cell, cellHasRowspan, cellHasColspan, false);
// Add span rows to virtual Table.
var rowspanNumber = cell.attributes.rowSpan ? parseInt(cell.attributes.rowSpan.value, 10) : 0;
if (rowspanNumber > 1) {
for (var rp = 1; rp < rowspanNumber; rp++) {
var rowspanIndex = row.rowIndex + rp;
adjustStartPoint(rowspanIndex, cellIndex, cell, isThisSelectedCell);
setVirtualTablePosition(rowspanIndex, cellIndex, row, cell, true, cellHasColspan, true);
}
}
// Add span cols to virtual table.
var colspanNumber = cell.attributes.colSpan ? parseInt(cell.attributes.colSpan.value, 10) : 0;
if (colspanNumber > 1) {
for (var cp = 1; cp < colspanNumber; cp++) {
var cellspanIndex = recoverCellIndex(row.rowIndex, (cellIndex + cp));
adjustStartPoint(row.rowIndex, cellspanIndex, cell, isThisSelectedCell);
setVirtualTablePosition(row.rowIndex, cellspanIndex, row, cell, cellHasRowspan, true, true);
}
}
} | [
"function",
"addCellInfoToVirtual",
"(",
"row",
",",
"cell",
")",
"{",
"var",
"cellIndex",
"=",
"recoverCellIndex",
"(",
"row",
".",
"rowIndex",
",",
"cell",
".",
"cellIndex",
")",
";",
"var",
"cellHasColspan",
"=",
"(",
"cell",
".",
"colSpan",
">",
"1",
")",
";",
"var",
"cellHasRowspan",
"=",
"(",
"cell",
".",
"rowSpan",
">",
"1",
")",
";",
"var",
"isThisSelectedCell",
"=",
"(",
"row",
".",
"rowIndex",
"===",
"_startPoint",
".",
"rowPos",
"&&",
"cell",
".",
"cellIndex",
"===",
"_startPoint",
".",
"colPos",
")",
";",
"setVirtualTablePosition",
"(",
"row",
".",
"rowIndex",
",",
"cellIndex",
",",
"row",
",",
"cell",
",",
"cellHasRowspan",
",",
"cellHasColspan",
",",
"false",
")",
";",
"var",
"rowspanNumber",
"=",
"cell",
".",
"attributes",
".",
"rowSpan",
"?",
"parseInt",
"(",
"cell",
".",
"attributes",
".",
"rowSpan",
".",
"value",
",",
"10",
")",
":",
"0",
";",
"if",
"(",
"rowspanNumber",
">",
"1",
")",
"{",
"for",
"(",
"var",
"rp",
"=",
"1",
";",
"rp",
"<",
"rowspanNumber",
";",
"rp",
"++",
")",
"{",
"var",
"rowspanIndex",
"=",
"row",
".",
"rowIndex",
"+",
"rp",
";",
"adjustStartPoint",
"(",
"rowspanIndex",
",",
"cellIndex",
",",
"cell",
",",
"isThisSelectedCell",
")",
";",
"setVirtualTablePosition",
"(",
"rowspanIndex",
",",
"cellIndex",
",",
"row",
",",
"cell",
",",
"true",
",",
"cellHasColspan",
",",
"true",
")",
";",
"}",
"}",
"var",
"colspanNumber",
"=",
"cell",
".",
"attributes",
".",
"colSpan",
"?",
"parseInt",
"(",
"cell",
".",
"attributes",
".",
"colSpan",
".",
"value",
",",
"10",
")",
":",
"0",
";",
"if",
"(",
"colspanNumber",
">",
"1",
")",
"{",
"for",
"(",
"var",
"cp",
"=",
"1",
";",
"cp",
"<",
"colspanNumber",
";",
"cp",
"++",
")",
"{",
"var",
"cellspanIndex",
"=",
"recoverCellIndex",
"(",
"row",
".",
"rowIndex",
",",
"(",
"cellIndex",
"+",
"cp",
")",
")",
";",
"adjustStartPoint",
"(",
"row",
".",
"rowIndex",
",",
"cellspanIndex",
",",
"cell",
",",
"isThisSelectedCell",
")",
";",
"setVirtualTablePosition",
"(",
"row",
".",
"rowIndex",
",",
"cellspanIndex",
",",
"row",
",",
"cell",
",",
"cellHasRowspan",
",",
"true",
",",
"true",
")",
";",
"}",
"}",
"}"
] | Recover info about row and cell and add information to virtual table.
@param {object} row Row to recover information.
@param {object} cell Cell to recover information. | [
"Recover",
"info",
"about",
"row",
"and",
"cell",
"and",
"add",
"information",
"to",
"virtual",
"table",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/editing/Table.js#L108-L134 | train |
Cerealkillerway/materialNote | src/js/base/editing/Table.js | adjustStartPoint | function adjustStartPoint(rowIndex, cellIndex, cell, isSelectedCell) {
if (rowIndex === _startPoint.rowPos && _startPoint.colPos >= cell.cellIndex && cell.cellIndex <= cellIndex && !isSelectedCell) {
_startPoint.colPos++;
}
} | javascript | function adjustStartPoint(rowIndex, cellIndex, cell, isSelectedCell) {
if (rowIndex === _startPoint.rowPos && _startPoint.colPos >= cell.cellIndex && cell.cellIndex <= cellIndex && !isSelectedCell) {
_startPoint.colPos++;
}
} | [
"function",
"adjustStartPoint",
"(",
"rowIndex",
",",
"cellIndex",
",",
"cell",
",",
"isSelectedCell",
")",
"{",
"if",
"(",
"rowIndex",
"===",
"_startPoint",
".",
"rowPos",
"&&",
"_startPoint",
".",
"colPos",
">=",
"cell",
".",
"cellIndex",
"&&",
"cell",
".",
"cellIndex",
"<=",
"cellIndex",
"&&",
"!",
"isSelectedCell",
")",
"{",
"_startPoint",
".",
"colPos",
"++",
";",
"}",
"}"
] | Process validation and adjust of start point if needed
@param {int} rowIndex
@param {int} cellIndex
@param {object} cell
@param {bool} isSelectedCell | [
"Process",
"validation",
"and",
"adjust",
"of",
"start",
"point",
"if",
"needed"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/editing/Table.js#L144-L148 | train |
Cerealkillerway/materialNote | src/js/base/editing/Table.js | createVirtualTable | function createVirtualTable() {
var rows = domTable.rows;
for (var rowIndex = 0; rowIndex < rows.length; rowIndex++) {
var cells = rows[rowIndex].cells;
for (var cellIndex = 0; cellIndex < cells.length; cellIndex++) {
addCellInfoToVirtual(rows[rowIndex], cells[cellIndex]);
}
}
} | javascript | function createVirtualTable() {
var rows = domTable.rows;
for (var rowIndex = 0; rowIndex < rows.length; rowIndex++) {
var cells = rows[rowIndex].cells;
for (var cellIndex = 0; cellIndex < cells.length; cellIndex++) {
addCellInfoToVirtual(rows[rowIndex], cells[cellIndex]);
}
}
} | [
"function",
"createVirtualTable",
"(",
")",
"{",
"var",
"rows",
"=",
"domTable",
".",
"rows",
";",
"for",
"(",
"var",
"rowIndex",
"=",
"0",
";",
"rowIndex",
"<",
"rows",
".",
"length",
";",
"rowIndex",
"++",
")",
"{",
"var",
"cells",
"=",
"rows",
"[",
"rowIndex",
"]",
".",
"cells",
";",
"for",
"(",
"var",
"cellIndex",
"=",
"0",
";",
"cellIndex",
"<",
"cells",
".",
"length",
";",
"cellIndex",
"++",
")",
"{",
"addCellInfoToVirtual",
"(",
"rows",
"[",
"rowIndex",
"]",
",",
"cells",
"[",
"cellIndex",
"]",
")",
";",
"}",
"}",
"}"
] | Create virtual table of cells with all cells, including span cells. | [
"Create",
"virtual",
"table",
"of",
"cells",
"with",
"all",
"cells",
"including",
"span",
"cells",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/editing/Table.js#L153-L161 | train |
Cerealkillerway/materialNote | grunts/grunt-build.js | function (compiled) {
// 01. Embed version
var version = grunt.config('pkg.version');
compiled = compiled.replace(/@VERSION/g, version);
// 02. Embed Date
var date = (new Date()).toISOString().replace(/:\d+\.\d+Z$/, 'Z');
compiled = compiled.replace(/@DATE/g, date);
grunt.file.write(self.data.outFile, compiled);
} | javascript | function (compiled) {
// 01. Embed version
var version = grunt.config('pkg.version');
compiled = compiled.replace(/@VERSION/g, version);
// 02. Embed Date
var date = (new Date()).toISOString().replace(/:\d+\.\d+Z$/, 'Z');
compiled = compiled.replace(/@DATE/g, date);
grunt.file.write(self.data.outFile, compiled);
} | [
"function",
"(",
"compiled",
")",
"{",
"var",
"version",
"=",
"grunt",
".",
"config",
"(",
"'pkg.version'",
")",
";",
"compiled",
"=",
"compiled",
".",
"replace",
"(",
"/",
"@VERSION",
"/",
"g",
",",
"version",
")",
";",
"var",
"date",
"=",
"(",
"new",
"Date",
"(",
")",
")",
".",
"toISOString",
"(",
")",
".",
"replace",
"(",
"/",
":\\d+\\.\\d+Z$",
"/",
",",
"'Z'",
")",
";",
"compiled",
"=",
"compiled",
".",
"replace",
"(",
"/",
"@DATE",
"/",
"g",
",",
"date",
")",
";",
"grunt",
".",
"file",
".",
"write",
"(",
"self",
".",
"data",
".",
"outFile",
",",
"compiled",
")",
";",
"}"
] | Handle final output from the optimizer | [
"Handle",
"final",
"output",
"from",
"the",
"optimizer"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/grunts/grunt-build.js#L21-L31 | train |
|
Cerealkillerway/materialNote | grunts/grunt-build.js | function (name, path, contents) {
contents = contents.replace(rDefineStart, '');
if (rDefineEndWithReturn.test(contents)) {
contents = contents.replace(rDefineEndWithReturn, '');
} else {
contents = contents.replace(rDefineEnd, '');
}
return contents;
} | javascript | function (name, path, contents) {
contents = contents.replace(rDefineStart, '');
if (rDefineEndWithReturn.test(contents)) {
contents = contents.replace(rDefineEndWithReturn, '');
} else {
contents = contents.replace(rDefineEnd, '');
}
return contents;
} | [
"function",
"(",
"name",
",",
"path",
",",
"contents",
")",
"{",
"contents",
"=",
"contents",
".",
"replace",
"(",
"rDefineStart",
",",
"''",
")",
";",
"if",
"(",
"rDefineEndWithReturn",
".",
"test",
"(",
"contents",
")",
")",
"{",
"contents",
"=",
"contents",
".",
"replace",
"(",
"rDefineEndWithReturn",
",",
"''",
")",
";",
"}",
"else",
"{",
"contents",
"=",
"contents",
".",
"replace",
"(",
"rDefineEnd",
",",
"''",
")",
";",
"}",
"return",
"contents",
";",
"}"
] | Strip all definitions generated by requirejs
@param {String} name
@param {String} path
@param {String} contents The contents to be written (including their AMD wrappers) | [
"Strip",
"all",
"definitions",
"generated",
"by",
"requirejs"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/grunts/grunt-build.js#L46-L55 | train |
|
Cerealkillerway/materialNote | src/js/base/core/list.js | function (array, pred) {
for (var idx = 0, len = array.length; idx < len; idx ++) {
var item = array[idx];
if (pred(item)) {
return item;
}
}
} | javascript | function (array, pred) {
for (var idx = 0, len = array.length; idx < len; idx ++) {
var item = array[idx];
if (pred(item)) {
return item;
}
}
} | [
"function",
"(",
"array",
",",
"pred",
")",
"{",
"for",
"(",
"var",
"idx",
"=",
"0",
",",
"len",
"=",
"array",
".",
"length",
";",
"idx",
"<",
"len",
";",
"idx",
"++",
")",
"{",
"var",
"item",
"=",
"array",
"[",
"idx",
"]",
";",
"if",
"(",
"pred",
"(",
"item",
")",
")",
"{",
"return",
"item",
";",
"}",
"}",
"}"
] | returns item of array | [
"returns",
"item",
"of",
"array"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/list.js#L50-L57 | train |
|
Cerealkillerway/materialNote | src/js/base/core/list.js | function (array, fn) {
if (!array.length) { return []; }
var aTail = tail(array);
return aTail.reduce(function (memo, v) {
var aLast = last(memo);
if (fn(last(aLast), v)) {
aLast[aLast.length] = v;
} else {
memo[memo.length] = [v];
}
return memo;
}, [[head(array)]]);
} | javascript | function (array, fn) {
if (!array.length) { return []; }
var aTail = tail(array);
return aTail.reduce(function (memo, v) {
var aLast = last(memo);
if (fn(last(aLast), v)) {
aLast[aLast.length] = v;
} else {
memo[memo.length] = [v];
}
return memo;
}, [[head(array)]]);
} | [
"function",
"(",
"array",
",",
"fn",
")",
"{",
"if",
"(",
"!",
"array",
".",
"length",
")",
"{",
"return",
"[",
"]",
";",
"}",
"var",
"aTail",
"=",
"tail",
"(",
"array",
")",
";",
"return",
"aTail",
".",
"reduce",
"(",
"function",
"(",
"memo",
",",
"v",
")",
"{",
"var",
"aLast",
"=",
"last",
"(",
"memo",
")",
";",
"if",
"(",
"fn",
"(",
"last",
"(",
"aLast",
")",
",",
"v",
")",
")",
"{",
"aLast",
"[",
"aLast",
".",
"length",
"]",
"=",
"v",
";",
"}",
"else",
"{",
"memo",
"[",
"memo",
".",
"length",
"]",
"=",
"[",
"v",
"]",
";",
"}",
"return",
"memo",
";",
"}",
",",
"[",
"[",
"head",
"(",
"array",
")",
"]",
"]",
")",
";",
"}"
] | cluster elements by predicate function.
@param {Array} array - array
@param {Function} fn - predicate function for cluster rule
@param {Array[]} | [
"cluster",
"elements",
"by",
"predicate",
"function",
"."
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/src/js/base/core/list.js#L124-L136 | train |
|
Cerealkillerway/materialNote | Gruntfile.js | function (filepath) {
var data = {};
try {
data = grunt.file.readJSON(filepath);
// The concatenated file won't pass onevar
// But our modules can
delete data.onever;
} catch (e) { }
return data;
} | javascript | function (filepath) {
var data = {};
try {
data = grunt.file.readJSON(filepath);
// The concatenated file won't pass onevar
// But our modules can
delete data.onever;
} catch (e) { }
return data;
} | [
"function",
"(",
"filepath",
")",
"{",
"var",
"data",
"=",
"{",
"}",
";",
"try",
"{",
"data",
"=",
"grunt",
".",
"file",
".",
"readJSON",
"(",
"filepath",
")",
";",
"delete",
"data",
".",
"onever",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"return",
"data",
";",
"}"
] | read optional JSON from filepath
@param {String} filepath
@return {Object} | [
"read",
"optional",
"JSON",
"from",
"filepath"
] | 4912662152328df8220cc4063c612e2e9b53d665 | https://github.com/Cerealkillerway/materialNote/blob/4912662152328df8220cc4063c612e2e9b53d665/Gruntfile.js#L9-L18 | train |
|
unindented/stats-webpack-plugin | index.js | StatsPlugin | function StatsPlugin (output, options, cache) {
this.output = output
this.options = options
this.cache = cache
} | javascript | function StatsPlugin (output, options, cache) {
this.output = output
this.options = options
this.cache = cache
} | [
"function",
"StatsPlugin",
"(",
"output",
",",
"options",
",",
"cache",
")",
"{",
"this",
".",
"output",
"=",
"output",
"this",
".",
"options",
"=",
"options",
"this",
".",
"cache",
"=",
"cache",
"}"
] | Create a new StatsPlugin that causes webpack to generate a stats file as
part of the emitted assets.
@constructor
@param {String} output Path to output file.
@param {Object} options Options passed to the stats' `.toJson()`. | [
"Create",
"a",
"new",
"StatsPlugin",
"that",
"causes",
"webpack",
"to",
"generate",
"a",
"stats",
"file",
"as",
"part",
"of",
"the",
"emitted",
"assets",
"."
] | b3130e5b074056d9f114c06341a66b6ff7cc61ff | https://github.com/unindented/stats-webpack-plugin/blob/b3130e5b074056d9f114c06341a66b6ff7cc61ff/index.js#L11-L15 | train |
Pagawa/PgwSlideshow | pgwslideshow.js | function() {
var listWidth = 0;
// The plugin must be visible for a correct calculation
pgwSlideshow.plugin.show();
pgwSlideshow.plugin.find('.ps-list > ul > li').show().each(function() {
listWidth += $(this).width();
});
pgwSlideshow.plugin.find('.ps-list > ul').width(listWidth);
return true;
} | javascript | function() {
var listWidth = 0;
// The plugin must be visible for a correct calculation
pgwSlideshow.plugin.show();
pgwSlideshow.plugin.find('.ps-list > ul > li').show().each(function() {
listWidth += $(this).width();
});
pgwSlideshow.plugin.find('.ps-list > ul').width(listWidth);
return true;
} | [
"function",
"(",
")",
"{",
"var",
"listWidth",
"=",
"0",
";",
"pgwSlideshow",
".",
"plugin",
".",
"show",
"(",
")",
";",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-list > ul > li'",
")",
".",
"show",
"(",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"listWidth",
"+=",
"$",
"(",
"this",
")",
".",
"width",
"(",
")",
";",
"}",
")",
";",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-list > ul'",
")",
".",
"width",
"(",
"listWidth",
")",
";",
"return",
"true",
";",
"}"
] | Set list width | [
"Set",
"list",
"width"
] | 299c13f7ac4a1d5aff4cc9402bc476e040b3be9a | https://github.com/Pagawa/PgwSlideshow/blob/299c13f7ac4a1d5aff4cc9402bc476e040b3be9a/pgwslideshow.js#L116-L128 | train |
|
Pagawa/PgwSlideshow | pgwslideshow.js | function(element) {
var elementContainer = pgwSlideshow.plugin.find('.ps-current > ul');
elementContainer.find('li').not('.elt_' + pgwSlideshow.currentSlide).not('.elt_' + element.id).each(function(){
if (typeof $(this).stop == 'function') {
$(this).stop();
}
$(this).css('position', '').css('z-index', 1).hide();
});
// Current element
if (pgwSlideshow.currentSlide > 0) {
var currentElement = elementContainer.find('.elt_' + pgwSlideshow.currentSlide);
if (typeof currentElement.animate != 'function') {
currentElement.animate = function(css, duration, callback) {
currentElement.css(css);
if (callback) {
callback();
}
};
}
if (typeof currentElement.stop == 'function') {
currentElement.stop();
}
currentElement.css('position', 'absolute').animate({
opacity : 0,
}, pgwSlideshow.config.transitionDuration, function() {
currentElement.css('position', '').css('z-index', 1).hide();
});
}
// Update current id
pgwSlideshow.currentSlide = element.id;
// Next element
var nextElement = elementContainer.find('.elt_' + element.id);
if (typeof nextElement.animate != 'function') {
nextElement.animate = function(css, duration, callback) {
nextElement.css(css);
if (callback) {
callback();
}
};
}
if (typeof nextElement.stop == 'function') {
nextElement.stop();
}
nextElement.css('position', 'absolute').show().animate({
opacity : 1,
}, pgwSlideshow.config.transitionDuration, function() {
nextElement.css('position', '').css('z-index', 2).css('display', 'block');
finishElement(element);
});
return true;
} | javascript | function(element) {
var elementContainer = pgwSlideshow.plugin.find('.ps-current > ul');
elementContainer.find('li').not('.elt_' + pgwSlideshow.currentSlide).not('.elt_' + element.id).each(function(){
if (typeof $(this).stop == 'function') {
$(this).stop();
}
$(this).css('position', '').css('z-index', 1).hide();
});
// Current element
if (pgwSlideshow.currentSlide > 0) {
var currentElement = elementContainer.find('.elt_' + pgwSlideshow.currentSlide);
if (typeof currentElement.animate != 'function') {
currentElement.animate = function(css, duration, callback) {
currentElement.css(css);
if (callback) {
callback();
}
};
}
if (typeof currentElement.stop == 'function') {
currentElement.stop();
}
currentElement.css('position', 'absolute').animate({
opacity : 0,
}, pgwSlideshow.config.transitionDuration, function() {
currentElement.css('position', '').css('z-index', 1).hide();
});
}
// Update current id
pgwSlideshow.currentSlide = element.id;
// Next element
var nextElement = elementContainer.find('.elt_' + element.id);
if (typeof nextElement.animate != 'function') {
nextElement.animate = function(css, duration, callback) {
nextElement.css(css);
if (callback) {
callback();
}
};
}
if (typeof nextElement.stop == 'function') {
nextElement.stop();
}
nextElement.css('position', 'absolute').show().animate({
opacity : 1,
}, pgwSlideshow.config.transitionDuration, function() {
nextElement.css('position', '').css('z-index', 2).css('display', 'block');
finishElement(element);
});
return true;
} | [
"function",
"(",
"element",
")",
"{",
"var",
"elementContainer",
"=",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-current > ul'",
")",
";",
"elementContainer",
".",
"find",
"(",
"'li'",
")",
".",
"not",
"(",
"'.elt_'",
"+",
"pgwSlideshow",
".",
"currentSlide",
")",
".",
"not",
"(",
"'.elt_'",
"+",
"element",
".",
"id",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"$",
"(",
"this",
")",
".",
"stop",
"==",
"'function'",
")",
"{",
"$",
"(",
"this",
")",
".",
"stop",
"(",
")",
";",
"}",
"$",
"(",
"this",
")",
".",
"css",
"(",
"'position'",
",",
"''",
")",
".",
"css",
"(",
"'z-index'",
",",
"1",
")",
".",
"hide",
"(",
")",
";",
"}",
")",
";",
"if",
"(",
"pgwSlideshow",
".",
"currentSlide",
">",
"0",
")",
"{",
"var",
"currentElement",
"=",
"elementContainer",
".",
"find",
"(",
"'.elt_'",
"+",
"pgwSlideshow",
".",
"currentSlide",
")",
";",
"if",
"(",
"typeof",
"currentElement",
".",
"animate",
"!=",
"'function'",
")",
"{",
"currentElement",
".",
"animate",
"=",
"function",
"(",
"css",
",",
"duration",
",",
"callback",
")",
"{",
"currentElement",
".",
"css",
"(",
"css",
")",
";",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
")",
";",
"}",
"}",
";",
"}",
"if",
"(",
"typeof",
"currentElement",
".",
"stop",
"==",
"'function'",
")",
"{",
"currentElement",
".",
"stop",
"(",
")",
";",
"}",
"currentElement",
".",
"css",
"(",
"'position'",
",",
"'absolute'",
")",
".",
"animate",
"(",
"{",
"opacity",
":",
"0",
",",
"}",
",",
"pgwSlideshow",
".",
"config",
".",
"transitionDuration",
",",
"function",
"(",
")",
"{",
"currentElement",
".",
"css",
"(",
"'position'",
",",
"''",
")",
".",
"css",
"(",
"'z-index'",
",",
"1",
")",
".",
"hide",
"(",
")",
";",
"}",
")",
";",
"}",
"pgwSlideshow",
".",
"currentSlide",
"=",
"element",
".",
"id",
";",
"var",
"nextElement",
"=",
"elementContainer",
".",
"find",
"(",
"'.elt_'",
"+",
"element",
".",
"id",
")",
";",
"if",
"(",
"typeof",
"nextElement",
".",
"animate",
"!=",
"'function'",
")",
"{",
"nextElement",
".",
"animate",
"=",
"function",
"(",
"css",
",",
"duration",
",",
"callback",
")",
"{",
"nextElement",
".",
"css",
"(",
"css",
")",
";",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
")",
";",
"}",
"}",
";",
"}",
"if",
"(",
"typeof",
"nextElement",
".",
"stop",
"==",
"'function'",
")",
"{",
"nextElement",
".",
"stop",
"(",
")",
";",
"}",
"nextElement",
".",
"css",
"(",
"'position'",
",",
"'absolute'",
")",
".",
"show",
"(",
")",
".",
"animate",
"(",
"{",
"opacity",
":",
"1",
",",
"}",
",",
"pgwSlideshow",
".",
"config",
".",
"transitionDuration",
",",
"function",
"(",
")",
"{",
"nextElement",
".",
"css",
"(",
"'position'",
",",
"''",
")",
".",
"css",
"(",
"'z-index'",
",",
"2",
")",
".",
"css",
"(",
"'display'",
",",
"'block'",
")",
";",
"finishElement",
"(",
"element",
")",
";",
"}",
")",
";",
"return",
"true",
";",
"}"
] | Fade an element | [
"Fade",
"an",
"element"
] | 299c13f7ac4a1d5aff4cc9402bc476e040b3be9a | https://github.com/Pagawa/PgwSlideshow/blob/299c13f7ac4a1d5aff4cc9402bc476e040b3be9a/pgwslideshow.js#L385-L446 | train |
|
Pagawa/PgwSlideshow | pgwslideshow.js | function(element, direction) {
var elementContainer = pgwSlideshow.plugin.find('.ps-current > ul');
if (typeof direction == 'undefined') {
direction = 'left';
}
if (pgwSlideshow.currentSlide == 0) {
elementContainer.find('.elt_1').css({
position : '',
left : '',
opacity : 1,
'z-index' : 2
}).show();
pgwSlideshow.plugin.find('.ps-list > li.elt_1').css('opacity', '1');
finishElement(element);
} else {
if (pgwSlideshow.transitionInProgress) {
return false;
}
pgwSlideshow.transitionInProgress = true;
// Get direction details
var elementWidth = elementContainer.width();
if (direction == 'left') {
var elementDest = -elementWidth;
var nextOrigin = elementWidth;
} else {
var elementDest = elementWidth;
var nextOrigin = -elementWidth;
}
var currentElement = elementContainer.find('.elt_' + pgwSlideshow.currentSlide);
if (typeof currentElement.animate != 'function') {
currentElement.animate = function(css, duration, callback) {
currentElement.css(css);
if (callback) {
callback();
}
};
}
currentElement.css('position', 'absolute').animate({
left : elementDest,
}, pgwSlideshow.config.transitionDuration, function() {
currentElement.css('position', '').css('z-index', 1).css('left', '').css('opacity', 0).hide();
});
// Next element
var nextElement = elementContainer.find('.elt_' + element.id);
if (typeof nextElement.animate != 'function') {
nextElement.animate = function(css, duration, callback) {
nextElement.css(css);
if (callback) {
callback();
}
};
}
nextElement.css('position', 'absolute').css('left', nextOrigin).css('opacity', 1).show().animate({
left : 0,
}, pgwSlideshow.config.transitionDuration, function() {
nextElement.css('position', '').css('left', '').css('z-index', 2).show();
pgwSlideshow.transitionInProgress = false;
finishElement(element);
});
}
// Update current id
pgwSlideshow.currentSlide = element.id;
return true;
} | javascript | function(element, direction) {
var elementContainer = pgwSlideshow.plugin.find('.ps-current > ul');
if (typeof direction == 'undefined') {
direction = 'left';
}
if (pgwSlideshow.currentSlide == 0) {
elementContainer.find('.elt_1').css({
position : '',
left : '',
opacity : 1,
'z-index' : 2
}).show();
pgwSlideshow.plugin.find('.ps-list > li.elt_1').css('opacity', '1');
finishElement(element);
} else {
if (pgwSlideshow.transitionInProgress) {
return false;
}
pgwSlideshow.transitionInProgress = true;
// Get direction details
var elementWidth = elementContainer.width();
if (direction == 'left') {
var elementDest = -elementWidth;
var nextOrigin = elementWidth;
} else {
var elementDest = elementWidth;
var nextOrigin = -elementWidth;
}
var currentElement = elementContainer.find('.elt_' + pgwSlideshow.currentSlide);
if (typeof currentElement.animate != 'function') {
currentElement.animate = function(css, duration, callback) {
currentElement.css(css);
if (callback) {
callback();
}
};
}
currentElement.css('position', 'absolute').animate({
left : elementDest,
}, pgwSlideshow.config.transitionDuration, function() {
currentElement.css('position', '').css('z-index', 1).css('left', '').css('opacity', 0).hide();
});
// Next element
var nextElement = elementContainer.find('.elt_' + element.id);
if (typeof nextElement.animate != 'function') {
nextElement.animate = function(css, duration, callback) {
nextElement.css(css);
if (callback) {
callback();
}
};
}
nextElement.css('position', 'absolute').css('left', nextOrigin).css('opacity', 1).show().animate({
left : 0,
}, pgwSlideshow.config.transitionDuration, function() {
nextElement.css('position', '').css('left', '').css('z-index', 2).show();
pgwSlideshow.transitionInProgress = false;
finishElement(element);
});
}
// Update current id
pgwSlideshow.currentSlide = element.id;
return true;
} | [
"function",
"(",
"element",
",",
"direction",
")",
"{",
"var",
"elementContainer",
"=",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-current > ul'",
")",
";",
"if",
"(",
"typeof",
"direction",
"==",
"'undefined'",
")",
"{",
"direction",
"=",
"'left'",
";",
"}",
"if",
"(",
"pgwSlideshow",
".",
"currentSlide",
"==",
"0",
")",
"{",
"elementContainer",
".",
"find",
"(",
"'.elt_1'",
")",
".",
"css",
"(",
"{",
"position",
":",
"''",
",",
"left",
":",
"''",
",",
"opacity",
":",
"1",
",",
"'z-index'",
":",
"2",
"}",
")",
".",
"show",
"(",
")",
";",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-list > li.elt_1'",
")",
".",
"css",
"(",
"'opacity'",
",",
"'1'",
")",
";",
"finishElement",
"(",
"element",
")",
";",
"}",
"else",
"{",
"if",
"(",
"pgwSlideshow",
".",
"transitionInProgress",
")",
"{",
"return",
"false",
";",
"}",
"pgwSlideshow",
".",
"transitionInProgress",
"=",
"true",
";",
"var",
"elementWidth",
"=",
"elementContainer",
".",
"width",
"(",
")",
";",
"if",
"(",
"direction",
"==",
"'left'",
")",
"{",
"var",
"elementDest",
"=",
"-",
"elementWidth",
";",
"var",
"nextOrigin",
"=",
"elementWidth",
";",
"}",
"else",
"{",
"var",
"elementDest",
"=",
"elementWidth",
";",
"var",
"nextOrigin",
"=",
"-",
"elementWidth",
";",
"}",
"var",
"currentElement",
"=",
"elementContainer",
".",
"find",
"(",
"'.elt_'",
"+",
"pgwSlideshow",
".",
"currentSlide",
")",
";",
"if",
"(",
"typeof",
"currentElement",
".",
"animate",
"!=",
"'function'",
")",
"{",
"currentElement",
".",
"animate",
"=",
"function",
"(",
"css",
",",
"duration",
",",
"callback",
")",
"{",
"currentElement",
".",
"css",
"(",
"css",
")",
";",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
")",
";",
"}",
"}",
";",
"}",
"currentElement",
".",
"css",
"(",
"'position'",
",",
"'absolute'",
")",
".",
"animate",
"(",
"{",
"left",
":",
"elementDest",
",",
"}",
",",
"pgwSlideshow",
".",
"config",
".",
"transitionDuration",
",",
"function",
"(",
")",
"{",
"currentElement",
".",
"css",
"(",
"'position'",
",",
"''",
")",
".",
"css",
"(",
"'z-index'",
",",
"1",
")",
".",
"css",
"(",
"'left'",
",",
"''",
")",
".",
"css",
"(",
"'opacity'",
",",
"0",
")",
".",
"hide",
"(",
")",
";",
"}",
")",
";",
"var",
"nextElement",
"=",
"elementContainer",
".",
"find",
"(",
"'.elt_'",
"+",
"element",
".",
"id",
")",
";",
"if",
"(",
"typeof",
"nextElement",
".",
"animate",
"!=",
"'function'",
")",
"{",
"nextElement",
".",
"animate",
"=",
"function",
"(",
"css",
",",
"duration",
",",
"callback",
")",
"{",
"nextElement",
".",
"css",
"(",
"css",
")",
";",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
")",
";",
"}",
"}",
";",
"}",
"nextElement",
".",
"css",
"(",
"'position'",
",",
"'absolute'",
")",
".",
"css",
"(",
"'left'",
",",
"nextOrigin",
")",
".",
"css",
"(",
"'opacity'",
",",
"1",
")",
".",
"show",
"(",
")",
".",
"animate",
"(",
"{",
"left",
":",
"0",
",",
"}",
",",
"pgwSlideshow",
".",
"config",
".",
"transitionDuration",
",",
"function",
"(",
")",
"{",
"nextElement",
".",
"css",
"(",
"'position'",
",",
"''",
")",
".",
"css",
"(",
"'left'",
",",
"''",
")",
".",
"css",
"(",
"'z-index'",
",",
"2",
")",
".",
"show",
"(",
")",
";",
"pgwSlideshow",
".",
"transitionInProgress",
"=",
"false",
";",
"finishElement",
"(",
"element",
")",
";",
"}",
")",
";",
"}",
"pgwSlideshow",
".",
"currentSlide",
"=",
"element",
".",
"id",
";",
"return",
"true",
";",
"}"
] | Slide an element | [
"Slide",
"an",
"element"
] | 299c13f7ac4a1d5aff4cc9402bc476e040b3be9a | https://github.com/Pagawa/PgwSlideshow/blob/299c13f7ac4a1d5aff4cc9402bc476e040b3be9a/pgwslideshow.js#L449-L527 | train |
|
Pagawa/PgwSlideshow | pgwslideshow.js | function(elementId, apiController, direction) {
if (elementId == pgwSlideshow.currentSlide) {
return false;
}
var element = pgwSlideshow.data[elementId - 1];
if (typeof element == 'undefined') {
throw new Error('pgwSlideshow - The element ' + elementId + ' is undefined');
return false;
}
if (typeof direction == 'undefined') {
direction = 'left';
}
// Before slide
if (typeof pgwSlideshow.config.beforeSlide == 'function') {
pgwSlideshow.config.beforeSlide(elementId);
}
if (typeof pgwSlideshow.plugin.find('.ps-caption').fadeOut == 'function') {
pgwSlideshow.plugin.find('.ps-caption, .ps-prev, .ps-next').fadeOut(pgwSlideshow.config.transitionDuration / 2);
} else {
pgwSlideshow.plugin.find('.ps-caption, .ps-prev, .ps-next').hide();
}
// Choose the transition effect
if (pgwSlideshow.config.transitionEffect == 'sliding') {
slideElement(element, direction);
} else {
fadeElement(element);
}
// Reset interval to avoid a half interval after an API control
if (typeof apiController != 'undefined' && pgwSlideshow.config.autoSlide) {
activateInterval();
}
return true;
} | javascript | function(elementId, apiController, direction) {
if (elementId == pgwSlideshow.currentSlide) {
return false;
}
var element = pgwSlideshow.data[elementId - 1];
if (typeof element == 'undefined') {
throw new Error('pgwSlideshow - The element ' + elementId + ' is undefined');
return false;
}
if (typeof direction == 'undefined') {
direction = 'left';
}
// Before slide
if (typeof pgwSlideshow.config.beforeSlide == 'function') {
pgwSlideshow.config.beforeSlide(elementId);
}
if (typeof pgwSlideshow.plugin.find('.ps-caption').fadeOut == 'function') {
pgwSlideshow.plugin.find('.ps-caption, .ps-prev, .ps-next').fadeOut(pgwSlideshow.config.transitionDuration / 2);
} else {
pgwSlideshow.plugin.find('.ps-caption, .ps-prev, .ps-next').hide();
}
// Choose the transition effect
if (pgwSlideshow.config.transitionEffect == 'sliding') {
slideElement(element, direction);
} else {
fadeElement(element);
}
// Reset interval to avoid a half interval after an API control
if (typeof apiController != 'undefined' && pgwSlideshow.config.autoSlide) {
activateInterval();
}
return true;
} | [
"function",
"(",
"elementId",
",",
"apiController",
",",
"direction",
")",
"{",
"if",
"(",
"elementId",
"==",
"pgwSlideshow",
".",
"currentSlide",
")",
"{",
"return",
"false",
";",
"}",
"var",
"element",
"=",
"pgwSlideshow",
".",
"data",
"[",
"elementId",
"-",
"1",
"]",
";",
"if",
"(",
"typeof",
"element",
"==",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'pgwSlideshow - The element '",
"+",
"elementId",
"+",
"' is undefined'",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"typeof",
"direction",
"==",
"'undefined'",
")",
"{",
"direction",
"=",
"'left'",
";",
"}",
"if",
"(",
"typeof",
"pgwSlideshow",
".",
"config",
".",
"beforeSlide",
"==",
"'function'",
")",
"{",
"pgwSlideshow",
".",
"config",
".",
"beforeSlide",
"(",
"elementId",
")",
";",
"}",
"if",
"(",
"typeof",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-caption'",
")",
".",
"fadeOut",
"==",
"'function'",
")",
"{",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-caption, .ps-prev, .ps-next'",
")",
".",
"fadeOut",
"(",
"pgwSlideshow",
".",
"config",
".",
"transitionDuration",
"/",
"2",
")",
";",
"}",
"else",
"{",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-caption, .ps-prev, .ps-next'",
")",
".",
"hide",
"(",
")",
";",
"}",
"if",
"(",
"pgwSlideshow",
".",
"config",
".",
"transitionEffect",
"==",
"'sliding'",
")",
"{",
"slideElement",
"(",
"element",
",",
"direction",
")",
";",
"}",
"else",
"{",
"fadeElement",
"(",
"element",
")",
";",
"}",
"if",
"(",
"typeof",
"apiController",
"!=",
"'undefined'",
"&&",
"pgwSlideshow",
".",
"config",
".",
"autoSlide",
")",
"{",
"activateInterval",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Display current element | [
"Display",
"current",
"element"
] | 299c13f7ac4a1d5aff4cc9402bc476e040b3be9a | https://github.com/Pagawa/PgwSlideshow/blob/299c13f7ac4a1d5aff4cc9402bc476e040b3be9a/pgwslideshow.js#L530-L571 | train |
|
Pagawa/PgwSlideshow | pgwslideshow.js | function() {
var containerWidth = pgwSlideshow.plugin.find('.ps-list').width();
var listObject = pgwSlideshow.plugin.find('.ps-list > ul');
var listWidth = listObject.width();
var marginLeft = parseInt(listObject.css('margin-left'));
var marginRight = parseInt(listObject.css('margin-right'));
containerWidth -= (marginLeft + marginRight);
var visibleZoneStart = Math.abs(parseInt(listObject.css('left')));
var visibleZoneEnd = visibleZoneStart + containerWidth;
var elementZoneStart = pgwSlideshow.plugin.find('.ps-list .ps-selected').position().left;
var elementZoneEnd = elementZoneStart + pgwSlideshow.plugin.find('.ps-list .ps-selected').width();
if ((elementZoneStart < visibleZoneStart) || (elementZoneEnd > visibleZoneEnd) || (listWidth > containerWidth && visibleZoneEnd > elementZoneEnd)) {
var maxPosition = -(listWidth - containerWidth);
if (-elementZoneStart < maxPosition) {
listObject.css('left', maxPosition);
} else {
listObject.css('left', -elementZoneStart);
}
}
return true;
} | javascript | function() {
var containerWidth = pgwSlideshow.plugin.find('.ps-list').width();
var listObject = pgwSlideshow.plugin.find('.ps-list > ul');
var listWidth = listObject.width();
var marginLeft = parseInt(listObject.css('margin-left'));
var marginRight = parseInt(listObject.css('margin-right'));
containerWidth -= (marginLeft + marginRight);
var visibleZoneStart = Math.abs(parseInt(listObject.css('left')));
var visibleZoneEnd = visibleZoneStart + containerWidth;
var elementZoneStart = pgwSlideshow.plugin.find('.ps-list .ps-selected').position().left;
var elementZoneEnd = elementZoneStart + pgwSlideshow.plugin.find('.ps-list .ps-selected').width();
if ((elementZoneStart < visibleZoneStart) || (elementZoneEnd > visibleZoneEnd) || (listWidth > containerWidth && visibleZoneEnd > elementZoneEnd)) {
var maxPosition = -(listWidth - containerWidth);
if (-elementZoneStart < maxPosition) {
listObject.css('left', maxPosition);
} else {
listObject.css('left', -elementZoneStart);
}
}
return true;
} | [
"function",
"(",
")",
"{",
"var",
"containerWidth",
"=",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-list'",
")",
".",
"width",
"(",
")",
";",
"var",
"listObject",
"=",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-list > ul'",
")",
";",
"var",
"listWidth",
"=",
"listObject",
".",
"width",
"(",
")",
";",
"var",
"marginLeft",
"=",
"parseInt",
"(",
"listObject",
".",
"css",
"(",
"'margin-left'",
")",
")",
";",
"var",
"marginRight",
"=",
"parseInt",
"(",
"listObject",
".",
"css",
"(",
"'margin-right'",
")",
")",
";",
"containerWidth",
"-=",
"(",
"marginLeft",
"+",
"marginRight",
")",
";",
"var",
"visibleZoneStart",
"=",
"Math",
".",
"abs",
"(",
"parseInt",
"(",
"listObject",
".",
"css",
"(",
"'left'",
")",
")",
")",
";",
"var",
"visibleZoneEnd",
"=",
"visibleZoneStart",
"+",
"containerWidth",
";",
"var",
"elementZoneStart",
"=",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-list .ps-selected'",
")",
".",
"position",
"(",
")",
".",
"left",
";",
"var",
"elementZoneEnd",
"=",
"elementZoneStart",
"+",
"pgwSlideshow",
".",
"plugin",
".",
"find",
"(",
"'.ps-list .ps-selected'",
")",
".",
"width",
"(",
")",
";",
"if",
"(",
"(",
"elementZoneStart",
"<",
"visibleZoneStart",
")",
"||",
"(",
"elementZoneEnd",
">",
"visibleZoneEnd",
")",
"||",
"(",
"listWidth",
">",
"containerWidth",
"&&",
"visibleZoneEnd",
">",
"elementZoneEnd",
")",
")",
"{",
"var",
"maxPosition",
"=",
"-",
"(",
"listWidth",
"-",
"containerWidth",
")",
";",
"if",
"(",
"-",
"elementZoneStart",
"<",
"maxPosition",
")",
"{",
"listObject",
".",
"css",
"(",
"'left'",
",",
"maxPosition",
")",
";",
"}",
"else",
"{",
"listObject",
".",
"css",
"(",
"'left'",
",",
"-",
"elementZoneStart",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Check the visibility of the selected item | [
"Check",
"the",
"visibility",
"of",
"the",
"selected",
"item"
] | 299c13f7ac4a1d5aff4cc9402bc476e040b3be9a | https://github.com/Pagawa/PgwSlideshow/blob/299c13f7ac4a1d5aff4cc9402bc476e040b3be9a/pgwslideshow.js#L718-L743 | train |
|
nisaacson/pdf-text-extract | index.js | splitPagesPromise | function splitPagesPromise (content) {
var pages = content.split(/\f/)
if (!pages) {
var ex = {
message: 'pdf-text-extract failed',
error: 'no text returned from the pdftotext command',
filePath: this.filePath,
stack: new Error().stack
}
throw ex
}
// sometimes there can be an extract blank page on the end
var lastPage = pages[pages.length - 1]
if (!lastPage) {
pages.pop()
}
resolve(pages)
} | javascript | function splitPagesPromise (content) {
var pages = content.split(/\f/)
if (!pages) {
var ex = {
message: 'pdf-text-extract failed',
error: 'no text returned from the pdftotext command',
filePath: this.filePath,
stack: new Error().stack
}
throw ex
}
// sometimes there can be an extract blank page on the end
var lastPage = pages[pages.length - 1]
if (!lastPage) {
pages.pop()
}
resolve(pages)
} | [
"function",
"splitPagesPromise",
"(",
"content",
")",
"{",
"var",
"pages",
"=",
"content",
".",
"split",
"(",
"/",
"\\f",
"/",
")",
"if",
"(",
"!",
"pages",
")",
"{",
"var",
"ex",
"=",
"{",
"message",
":",
"'pdf-text-extract failed'",
",",
"error",
":",
"'no text returned from the pdftotext command'",
",",
"filePath",
":",
"this",
".",
"filePath",
",",
"stack",
":",
"new",
"Error",
"(",
")",
".",
"stack",
"}",
"throw",
"ex",
"}",
"var",
"lastPage",
"=",
"pages",
"[",
"pages",
".",
"length",
"-",
"1",
"]",
"if",
"(",
"!",
"lastPage",
")",
"{",
"pages",
".",
"pop",
"(",
")",
"}",
"resolve",
"(",
"pages",
")",
"}"
] | Duplicated from function splitPages of pdfTextExtract | [
"Duplicated",
"from",
"function",
"splitPages",
"of",
"pdfTextExtract"
] | d21ead42859aae859d3f20b79ebd5c801b21837d | https://github.com/nisaacson/pdf-text-extract/blob/d21ead42859aae859d3f20b79ebd5c801b21837d/index.js#L160-L177 | train |
nisaacson/pdf-text-extract | index.js | streamResultsPromise | function streamResultsPromise (command, args, options, cb) {
var output = ''
var stderr = ''
var child = spawn(command, args, options)
child.stdout.setEncoding('utf8')
child.stderr.setEncoding('utf8')
child.stdout.on('data', stdoutHandler)
child.stderr.on('data', stderrHandler)
child.on('close', closeHandler)
function stdoutHandler (data) {
output += data
}
function stderrHandler (data) {
stderr += data
}
function closeHandler (code) {
if (code !== 0) {
var ex = new Error('pdf-text-extract command failed: ' + stderr)
throw ex
}
cb(output)
}
} | javascript | function streamResultsPromise (command, args, options, cb) {
var output = ''
var stderr = ''
var child = spawn(command, args, options)
child.stdout.setEncoding('utf8')
child.stderr.setEncoding('utf8')
child.stdout.on('data', stdoutHandler)
child.stderr.on('data', stderrHandler)
child.on('close', closeHandler)
function stdoutHandler (data) {
output += data
}
function stderrHandler (data) {
stderr += data
}
function closeHandler (code) {
if (code !== 0) {
var ex = new Error('pdf-text-extract command failed: ' + stderr)
throw ex
}
cb(output)
}
} | [
"function",
"streamResultsPromise",
"(",
"command",
",",
"args",
",",
"options",
",",
"cb",
")",
"{",
"var",
"output",
"=",
"''",
"var",
"stderr",
"=",
"''",
"var",
"child",
"=",
"spawn",
"(",
"command",
",",
"args",
",",
"options",
")",
"child",
".",
"stdout",
".",
"setEncoding",
"(",
"'utf8'",
")",
"child",
".",
"stderr",
".",
"setEncoding",
"(",
"'utf8'",
")",
"child",
".",
"stdout",
".",
"on",
"(",
"'data'",
",",
"stdoutHandler",
")",
"child",
".",
"stderr",
".",
"on",
"(",
"'data'",
",",
"stderrHandler",
")",
"child",
".",
"on",
"(",
"'close'",
",",
"closeHandler",
")",
"function",
"stdoutHandler",
"(",
"data",
")",
"{",
"output",
"+=",
"data",
"}",
"function",
"stderrHandler",
"(",
"data",
")",
"{",
"stderr",
"+=",
"data",
"}",
"function",
"closeHandler",
"(",
"code",
")",
"{",
"if",
"(",
"code",
"!==",
"0",
")",
"{",
"var",
"ex",
"=",
"new",
"Error",
"(",
"'pdf-text-extract command failed: '",
"+",
"stderr",
")",
"throw",
"ex",
"}",
"cb",
"(",
"output",
")",
"}",
"}"
] | Duplicated from function splitPages of streamResults | [
"Duplicated",
"from",
"function",
"splitPages",
"of",
"streamResults"
] | d21ead42859aae859d3f20b79ebd5c801b21837d | https://github.com/nisaacson/pdf-text-extract/blob/d21ead42859aae859d3f20b79ebd5c801b21837d/index.js#L182-L207 | train |
brikteknologier/seraph-model | lib/write.js | function (graph, opts, params) {
var self = this;
var savedNodes = graph.allNodes.filter(function(node) {
return node.props[self.db.options.id] != null
&& !(node.model.uniqueness && node.model.uniqueness.returnOld);
});
if (!savedNodes.length) return '';
var statements = savedNodes.map(function(node) {
params[node.name + 'id'] = getId(self.db, node.props);
return node.name + '=node({' + node.name + 'id})';
});
return 'START ' + statements.join(',');
} | javascript | function (graph, opts, params) {
var self = this;
var savedNodes = graph.allNodes.filter(function(node) {
return node.props[self.db.options.id] != null
&& !(node.model.uniqueness && node.model.uniqueness.returnOld);
});
if (!savedNodes.length) return '';
var statements = savedNodes.map(function(node) {
params[node.name + 'id'] = getId(self.db, node.props);
return node.name + '=node({' + node.name + 'id})';
});
return 'START ' + statements.join(',');
} | [
"function",
"(",
"graph",
",",
"opts",
",",
"params",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"savedNodes",
"=",
"graph",
".",
"allNodes",
".",
"filter",
"(",
"function",
"(",
"node",
")",
"{",
"return",
"node",
".",
"props",
"[",
"self",
".",
"db",
".",
"options",
".",
"id",
"]",
"!=",
"null",
"&&",
"!",
"(",
"node",
".",
"model",
".",
"uniqueness",
"&&",
"node",
".",
"model",
".",
"uniqueness",
".",
"returnOld",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"savedNodes",
".",
"length",
")",
"return",
"''",
";",
"var",
"statements",
"=",
"savedNodes",
".",
"map",
"(",
"function",
"(",
"node",
")",
"{",
"params",
"[",
"node",
".",
"name",
"+",
"'id'",
"]",
"=",
"getId",
"(",
"self",
".",
"db",
",",
"node",
".",
"props",
")",
";",
"return",
"node",
".",
"name",
"+",
"'=node({'",
"+",
"node",
".",
"name",
"+",
"'id})'",
";",
"}",
")",
";",
"return",
"'START '",
"+",
"statements",
".",
"join",
"(",
"','",
")",
";",
"}"
] | get the START statement of a write query this will start with all the pre-existing nodes | [
"get",
"the",
"START",
"statement",
"of",
"a",
"write",
"query",
"this",
"will",
"start",
"with",
"all",
"the",
"pre",
"-",
"existing",
"nodes"
] | d53da892f47155de883106e716fdc6767833306a | https://github.com/brikteknologier/seraph-model/blob/d53da892f47155de883106e716fdc6767833306a/lib/write.js#L80-L95 | train |
|
brikteknologier/seraph-model | lib/write.js | function (graph, opts, params) {
var self = this;
var newNodes = graph.allNodes.filter(function(node) {
return node.props[self.db.options.id] == null
&& !(node.model.uniqueness && node.model.uniqueness.returnOld);
});
if (!newNodes.length) return '';
var statements = newNodes.map(function(node) {
var label = node.model.type;
return '(' + node.name + ':' + label + ')';
});
return 'CREATE ' + statements.join(',');
} | javascript | function (graph, opts, params) {
var self = this;
var newNodes = graph.allNodes.filter(function(node) {
return node.props[self.db.options.id] == null
&& !(node.model.uniqueness && node.model.uniqueness.returnOld);
});
if (!newNodes.length) return '';
var statements = newNodes.map(function(node) {
var label = node.model.type;
return '(' + node.name + ':' + label + ')';
});
return 'CREATE ' + statements.join(',');
} | [
"function",
"(",
"graph",
",",
"opts",
",",
"params",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"newNodes",
"=",
"graph",
".",
"allNodes",
".",
"filter",
"(",
"function",
"(",
"node",
")",
"{",
"return",
"node",
".",
"props",
"[",
"self",
".",
"db",
".",
"options",
".",
"id",
"]",
"==",
"null",
"&&",
"!",
"(",
"node",
".",
"model",
".",
"uniqueness",
"&&",
"node",
".",
"model",
".",
"uniqueness",
".",
"returnOld",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"newNodes",
".",
"length",
")",
"return",
"''",
";",
"var",
"statements",
"=",
"newNodes",
".",
"map",
"(",
"function",
"(",
"node",
")",
"{",
"var",
"label",
"=",
"node",
".",
"model",
".",
"type",
";",
"return",
"'('",
"+",
"node",
".",
"name",
"+",
"':'",
"+",
"label",
"+",
"')'",
";",
"}",
")",
";",
"return",
"'CREATE '",
"+",
"statements",
".",
"join",
"(",
"','",
")",
";",
"}"
] | get the CREATE statement of a write query this will create non-existant nodes | [
"get",
"the",
"CREATE",
"statement",
"of",
"a",
"write",
"query",
"this",
"will",
"create",
"non",
"-",
"existant",
"nodes"
] | d53da892f47155de883106e716fdc6767833306a | https://github.com/brikteknologier/seraph-model/blob/d53da892f47155de883106e716fdc6767833306a/lib/write.js#L139-L154 | train |
|
brikteknologier/seraph-model | lib/write.js | function (graph, opts, params) {
var self = this;
var updatedNodes = graph.allNodes;
if (opts.restrictToComp) {
updatedNodes = graph.allNodes.filter(function(node) {
return node.comp && node.comp.name == opts.restrictToComp;
});
}
function assign(statements, varName, hash) {
params[varName] = hash;
if (opts.additive) {
_.forEach(hash, function(val, key) {
statements.push(varName + '.`' + key + '`={' + varName + '}.`' + key + '`');
});
} else {
statements.push(varName + '={' + varName + '}');
}
}
return 'SET ' + updatedNodes.reduce(function(statements, node) {
// set props
var props = node.props;
if (props[self.db.options.id]) props = _.omit(props, self.db.options.id);
if (node.comp) assign(statements, '__rel_' + node.name, props._rel || {});
props = _.omit(props, '_rel');
assign(statements, node.name, props);
// set timestamps
if (!node.model.usingTimestamps) return statements;
statements.push(getSetCreatedTimestampStatement(node));
statements.push(node.name + '.' + node.model.updatedField + ' = timestamp()');
return statements;
}, []).join(',');
} | javascript | function (graph, opts, params) {
var self = this;
var updatedNodes = graph.allNodes;
if (opts.restrictToComp) {
updatedNodes = graph.allNodes.filter(function(node) {
return node.comp && node.comp.name == opts.restrictToComp;
});
}
function assign(statements, varName, hash) {
params[varName] = hash;
if (opts.additive) {
_.forEach(hash, function(val, key) {
statements.push(varName + '.`' + key + '`={' + varName + '}.`' + key + '`');
});
} else {
statements.push(varName + '={' + varName + '}');
}
}
return 'SET ' + updatedNodes.reduce(function(statements, node) {
// set props
var props = node.props;
if (props[self.db.options.id]) props = _.omit(props, self.db.options.id);
if (node.comp) assign(statements, '__rel_' + node.name, props._rel || {});
props = _.omit(props, '_rel');
assign(statements, node.name, props);
// set timestamps
if (!node.model.usingTimestamps) return statements;
statements.push(getSetCreatedTimestampStatement(node));
statements.push(node.name + '.' + node.model.updatedField + ' = timestamp()');
return statements;
}, []).join(',');
} | [
"function",
"(",
"graph",
",",
"opts",
",",
"params",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"updatedNodes",
"=",
"graph",
".",
"allNodes",
";",
"if",
"(",
"opts",
".",
"restrictToComp",
")",
"{",
"updatedNodes",
"=",
"graph",
".",
"allNodes",
".",
"filter",
"(",
"function",
"(",
"node",
")",
"{",
"return",
"node",
".",
"comp",
"&&",
"node",
".",
"comp",
".",
"name",
"==",
"opts",
".",
"restrictToComp",
";",
"}",
")",
";",
"}",
"function",
"assign",
"(",
"statements",
",",
"varName",
",",
"hash",
")",
"{",
"params",
"[",
"varName",
"]",
"=",
"hash",
";",
"if",
"(",
"opts",
".",
"additive",
")",
"{",
"_",
".",
"forEach",
"(",
"hash",
",",
"function",
"(",
"val",
",",
"key",
")",
"{",
"statements",
".",
"push",
"(",
"varName",
"+",
"'.`'",
"+",
"key",
"+",
"'`={'",
"+",
"varName",
"+",
"'}.`'",
"+",
"key",
"+",
"'`'",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"statements",
".",
"push",
"(",
"varName",
"+",
"'={'",
"+",
"varName",
"+",
"'}'",
")",
";",
"}",
"}",
"return",
"'SET '",
"+",
"updatedNodes",
".",
"reduce",
"(",
"function",
"(",
"statements",
",",
"node",
")",
"{",
"var",
"props",
"=",
"node",
".",
"props",
";",
"if",
"(",
"props",
"[",
"self",
".",
"db",
".",
"options",
".",
"id",
"]",
")",
"props",
"=",
"_",
".",
"omit",
"(",
"props",
",",
"self",
".",
"db",
".",
"options",
".",
"id",
")",
";",
"if",
"(",
"node",
".",
"comp",
")",
"assign",
"(",
"statements",
",",
"'__rel_'",
"+",
"node",
".",
"name",
",",
"props",
".",
"_rel",
"||",
"{",
"}",
")",
";",
"props",
"=",
"_",
".",
"omit",
"(",
"props",
",",
"'_rel'",
")",
";",
"assign",
"(",
"statements",
",",
"node",
".",
"name",
",",
"props",
")",
";",
"if",
"(",
"!",
"node",
".",
"model",
".",
"usingTimestamps",
")",
"return",
"statements",
";",
"statements",
".",
"push",
"(",
"getSetCreatedTimestampStatement",
"(",
"node",
")",
")",
";",
"statements",
".",
"push",
"(",
"node",
".",
"name",
"+",
"'.'",
"+",
"node",
".",
"model",
".",
"updatedField",
"+",
"' = timestamp()'",
")",
";",
"return",
"statements",
";",
"}",
",",
"[",
"]",
")",
".",
"join",
"(",
"','",
")",
";",
"}"
] | get the SET statement of a write query this will set the properties on all nodes | [
"get",
"the",
"SET",
"statement",
"of",
"a",
"write",
"query",
"this",
"will",
"set",
"the",
"properties",
"on",
"all",
"nodes"
] | d53da892f47155de883106e716fdc6767833306a | https://github.com/brikteknologier/seraph-model/blob/d53da892f47155de883106e716fdc6767833306a/lib/write.js#L157-L194 | train |
|
brikteknologier/seraph-model | lib/write.js | function (graph, opts, params) {
if (graph.children.length == 0) return '';
function getRels(node) {
var rels = [];
node.children.forEach(function(childNode) {
rels.push('(' + node.name + ')-[__rel_' + childNode.name + ':' + childNode.comp.rel + ']->(' + childNode.name + ')');
rels.push.apply(rels, getRels(childNode));
});
return rels;
}
return 'CREATE UNIQUE ' + getRels(graph).join(',');
} | javascript | function (graph, opts, params) {
if (graph.children.length == 0) return '';
function getRels(node) {
var rels = [];
node.children.forEach(function(childNode) {
rels.push('(' + node.name + ')-[__rel_' + childNode.name + ':' + childNode.comp.rel + ']->(' + childNode.name + ')');
rels.push.apply(rels, getRels(childNode));
});
return rels;
}
return 'CREATE UNIQUE ' + getRels(graph).join(',');
} | [
"function",
"(",
"graph",
",",
"opts",
",",
"params",
")",
"{",
"if",
"(",
"graph",
".",
"children",
".",
"length",
"==",
"0",
")",
"return",
"''",
";",
"function",
"getRels",
"(",
"node",
")",
"{",
"var",
"rels",
"=",
"[",
"]",
";",
"node",
".",
"children",
".",
"forEach",
"(",
"function",
"(",
"childNode",
")",
"{",
"rels",
".",
"push",
"(",
"'('",
"+",
"node",
".",
"name",
"+",
"')-[__rel_'",
"+",
"childNode",
".",
"name",
"+",
"':'",
"+",
"childNode",
".",
"comp",
".",
"rel",
"+",
"']->('",
"+",
"childNode",
".",
"name",
"+",
"')'",
")",
";",
"rels",
".",
"push",
".",
"apply",
"(",
"rels",
",",
"getRels",
"(",
"childNode",
")",
")",
";",
"}",
")",
";",
"return",
"rels",
";",
"}",
"return",
"'CREATE UNIQUE '",
"+",
"getRels",
"(",
"graph",
")",
".",
"join",
"(",
"','",
")",
";",
"}"
] | get the CREATE UNIQUE statement of a write query this will create the required relationships | [
"get",
"the",
"CREATE",
"UNIQUE",
"statement",
"of",
"a",
"write",
"query",
"this",
"will",
"create",
"the",
"required",
"relationships"
] | d53da892f47155de883106e716fdc6767833306a | https://github.com/brikteknologier/seraph-model/blob/d53da892f47155de883106e716fdc6767833306a/lib/write.js#L197-L210 | train |
|
brikteknologier/seraph-model | lib/write.js | beforeCommit | function beforeCommit(object, callback) {
var self = this;
async.waterfall([
this.triggerTransformEvent.bind(this, 'prepare', object),
this.triggerProgressionEvent.bind(this, 'validate'),
this.triggerEvent.bind(this, 'beforeSave')
], function(err, object) {
if (err) return callback(err);
// run beforeCommit on all composed objects as well.
transformComps.call(self, object, object, function(comp, object, i, cb) {
if (comp.transient) return cb();
beforeCommit.call(comp.model, object, cb);
}, callback);
});
} | javascript | function beforeCommit(object, callback) {
var self = this;
async.waterfall([
this.triggerTransformEvent.bind(this, 'prepare', object),
this.triggerProgressionEvent.bind(this, 'validate'),
this.triggerEvent.bind(this, 'beforeSave')
], function(err, object) {
if (err) return callback(err);
// run beforeCommit on all composed objects as well.
transformComps.call(self, object, object, function(comp, object, i, cb) {
if (comp.transient) return cb();
beforeCommit.call(comp.model, object, cb);
}, callback);
});
} | [
"function",
"beforeCommit",
"(",
"object",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"async",
".",
"waterfall",
"(",
"[",
"this",
".",
"triggerTransformEvent",
".",
"bind",
"(",
"this",
",",
"'prepare'",
",",
"object",
")",
",",
"this",
".",
"triggerProgressionEvent",
".",
"bind",
"(",
"this",
",",
"'validate'",
")",
",",
"this",
".",
"triggerEvent",
".",
"bind",
"(",
"this",
",",
"'beforeSave'",
")",
"]",
",",
"function",
"(",
"err",
",",
"object",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"transformComps",
".",
"call",
"(",
"self",
",",
"object",
",",
"object",
",",
"function",
"(",
"comp",
",",
"object",
",",
"i",
",",
"cb",
")",
"{",
"if",
"(",
"comp",
".",
"transient",
")",
"return",
"cb",
"(",
")",
";",
"beforeCommit",
".",
"call",
"(",
"comp",
".",
"model",
",",
"object",
",",
"cb",
")",
";",
"}",
",",
"callback",
")",
";",
"}",
")",
";",
"}"
] | prepare, validate, beforeSave | [
"prepare",
"validate",
"beforeSave"
] | d53da892f47155de883106e716fdc6767833306a | https://github.com/brikteknologier/seraph-model/blob/d53da892f47155de883106e716fdc6767833306a/lib/write.js#L241-L256 | train |
rfink/sequelize-redis-cache | lib/index.js | Cacher | function Cacher(seq, red) {
if (!(this instanceof Cacher)) {
return new Cacher(seq, red);
}
this.method = 'find';
this.options = {};
this.seconds = 0;
this.cacheHit = false;
this.cachePrefix = 'cacher';
this.sequelize = seq;
this.redis = red;
} | javascript | function Cacher(seq, red) {
if (!(this instanceof Cacher)) {
return new Cacher(seq, red);
}
this.method = 'find';
this.options = {};
this.seconds = 0;
this.cacheHit = false;
this.cachePrefix = 'cacher';
this.sequelize = seq;
this.redis = red;
} | [
"function",
"Cacher",
"(",
"seq",
",",
"red",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Cacher",
")",
")",
"{",
"return",
"new",
"Cacher",
"(",
"seq",
",",
"red",
")",
";",
"}",
"this",
".",
"method",
"=",
"'find'",
";",
"this",
".",
"options",
"=",
"{",
"}",
";",
"this",
".",
"seconds",
"=",
"0",
";",
"this",
".",
"cacheHit",
"=",
"false",
";",
"this",
".",
"cachePrefix",
"=",
"'cacher'",
";",
"this",
".",
"sequelize",
"=",
"seq",
";",
"this",
".",
"redis",
"=",
"red",
";",
"}"
] | Constructor for cacher | [
"Constructor",
"for",
"cacher"
] | 9b1af1b6f2f235b0567e41c1c2eccb553e85ce8d | https://github.com/rfink/sequelize-redis-cache/blob/9b1af1b6f2f235b0567e41c1c2eccb553e85ce8d/lib/index.js#L12-L23 | train |
rfink/sequelize-redis-cache | lib/index.js | jsonReplacer | function jsonReplacer(key, value) {
if (value && (value.DAO || value.sequelize)) {
return value.name || '';
}
return value;
} | javascript | function jsonReplacer(key, value) {
if (value && (value.DAO || value.sequelize)) {
return value.name || '';
}
return value;
} | [
"function",
"jsonReplacer",
"(",
"key",
",",
"value",
")",
"{",
"if",
"(",
"value",
"&&",
"(",
"value",
".",
"DAO",
"||",
"value",
".",
"sequelize",
")",
")",
"{",
"return",
"value",
".",
"name",
"||",
"''",
";",
"}",
"return",
"value",
";",
"}"
] | Duct tape to check if this is a sequelize DAOFactory | [
"Duct",
"tape",
"to",
"check",
"if",
"this",
"is",
"a",
"sequelize",
"DAOFactory"
] | 9b1af1b6f2f235b0567e41c1c2eccb553e85ce8d | https://github.com/rfink/sequelize-redis-cache/blob/9b1af1b6f2f235b0567e41c1c2eccb553e85ce8d/lib/index.js#L251-L256 | train |
rfink/sequelize-redis-cache | lib/index.js | addMethod | function addMethod(key) {
Cacher.prototype[key] = function() {
if (!this.md) {
return Promise.reject(new Error('Model not set'));
}
this.method = key;
return this.run.apply(this, arguments);
};
} | javascript | function addMethod(key) {
Cacher.prototype[key] = function() {
if (!this.md) {
return Promise.reject(new Error('Model not set'));
}
this.method = key;
return this.run.apply(this, arguments);
};
} | [
"function",
"addMethod",
"(",
"key",
")",
"{",
"Cacher",
".",
"prototype",
"[",
"key",
"]",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"md",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"new",
"Error",
"(",
"'Model not set'",
")",
")",
";",
"}",
"this",
".",
"method",
"=",
"key",
";",
"return",
"this",
".",
"run",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
";",
"}"
] | Add a retrieval method | [
"Add",
"a",
"retrieval",
"method"
] | 9b1af1b6f2f235b0567e41c1c2eccb553e85ce8d | https://github.com/rfink/sequelize-redis-cache/blob/9b1af1b6f2f235b0567e41c1c2eccb553e85ce8d/lib/index.js#L261-L269 | train |
B-3PO/angular-material-event-calendar | dist/angular-material-event-calendar.js | getPlace | function getPlace() {
var place = 0;
while (takenPlaces.indexOf(place) !== -1) {
place++;
}
takenPlaces.push(place);
return place;
} | javascript | function getPlace() {
var place = 0;
while (takenPlaces.indexOf(place) !== -1) {
place++;
}
takenPlaces.push(place);
return place;
} | [
"function",
"getPlace",
"(",
")",
"{",
"var",
"place",
"=",
"0",
";",
"while",
"(",
"takenPlaces",
".",
"indexOf",
"(",
"place",
")",
"!==",
"-",
"1",
")",
"{",
"place",
"++",
";",
"}",
"takenPlaces",
".",
"push",
"(",
"place",
")",
";",
"return",
"place",
";",
"}"
] | find lowest place not taken | [
"find",
"lowest",
"place",
"not",
"taken"
] | dca1bac684105a612a0e1a6020d4ac72c77b6552 | https://github.com/B-3PO/angular-material-event-calendar/blob/dca1bac684105a612a0e1a6020d4ac72c77b6552/dist/angular-material-event-calendar.js#L636-L643 | train |
B-3PO/angular-material-event-calendar | dist/angular-material-event-calendar.js | hideCreateLinkOnEventItemHover | function hideCreateLinkOnEventItemHover() {
element.on('mouseenter', function () {
element.on('mousemove', checkForEventItemRAF);
});
element.on('mouseleave', function () {
element.off('mousemove', checkForEventItemRAF);
element.removeClass('md-event-hover');
});
var lastHoverItem;
var checkForEventItemRAF = $$rAF.throttle(checkForEventItem);
function checkForEventItem(e) {
if (mdEventCalendarCtrl.isCreateDisabled() === true) { return; }
if (lastHoverItem === e.target) { return; }
lastHoverItem = e.target;
var targetIsEvent = !!e.target.getAttribute('md-event-id');
element.toggleClass('md-event-hover', targetIsEvent);
}
} | javascript | function hideCreateLinkOnEventItemHover() {
element.on('mouseenter', function () {
element.on('mousemove', checkForEventItemRAF);
});
element.on('mouseleave', function () {
element.off('mousemove', checkForEventItemRAF);
element.removeClass('md-event-hover');
});
var lastHoverItem;
var checkForEventItemRAF = $$rAF.throttle(checkForEventItem);
function checkForEventItem(e) {
if (mdEventCalendarCtrl.isCreateDisabled() === true) { return; }
if (lastHoverItem === e.target) { return; }
lastHoverItem = e.target;
var targetIsEvent = !!e.target.getAttribute('md-event-id');
element.toggleClass('md-event-hover', targetIsEvent);
}
} | [
"function",
"hideCreateLinkOnEventItemHover",
"(",
")",
"{",
"element",
".",
"on",
"(",
"'mouseenter'",
",",
"function",
"(",
")",
"{",
"element",
".",
"on",
"(",
"'mousemove'",
",",
"checkForEventItemRAF",
")",
";",
"}",
")",
";",
"element",
".",
"on",
"(",
"'mouseleave'",
",",
"function",
"(",
")",
"{",
"element",
".",
"off",
"(",
"'mousemove'",
",",
"checkForEventItemRAF",
")",
";",
"element",
".",
"removeClass",
"(",
"'md-event-hover'",
")",
";",
"}",
")",
";",
"var",
"lastHoverItem",
";",
"var",
"checkForEventItemRAF",
"=",
"$$rAF",
".",
"throttle",
"(",
"checkForEventItem",
")",
";",
"function",
"checkForEventItem",
"(",
"e",
")",
"{",
"if",
"(",
"mdEventCalendarCtrl",
".",
"isCreateDisabled",
"(",
")",
"===",
"true",
")",
"{",
"return",
";",
"}",
"if",
"(",
"lastHoverItem",
"===",
"e",
".",
"target",
")",
"{",
"return",
";",
"}",
"lastHoverItem",
"=",
"e",
".",
"target",
";",
"var",
"targetIsEvent",
"=",
"!",
"!",
"e",
".",
"target",
".",
"getAttribute",
"(",
"'md-event-id'",
")",
";",
"element",
".",
"toggleClass",
"(",
"'md-event-hover'",
",",
"targetIsEvent",
")",
";",
"}",
"}"
] | When user mouses over an existing event, add a class of md-event-hover to the month element, so that the create link is hidden from view. | [
"When",
"user",
"mouses",
"over",
"an",
"existing",
"event",
"add",
"a",
"class",
"of",
"md",
"-",
"event",
"-",
"hover",
"to",
"the",
"month",
"element",
"so",
"that",
"the",
"create",
"link",
"is",
"hidden",
"from",
"view",
"."
] | dca1bac684105a612a0e1a6020d4ac72c77b6552 | https://github.com/B-3PO/angular-material-event-calendar/blob/dca1bac684105a612a0e1a6020d4ac72c77b6552/dist/angular-material-event-calendar.js#L765-L786 | train |
pulviscriptor/agario-client | account.js | Account | function Account(name) { //TODO doc vars
this.name = name; //debug name
this.token = null; //token after requestFBToken()
this.token_expire = 0; //timestamp after requestFBToken()
this.token_provider = 1; //provider ID after requester
this.c_user = null; //cookie from www.facebook.com
this.datr = null; //cookie from www.facebook.com
this.xs = null; //cookie from www.facebook.com
this.agent = null; //connection agent
this.debug = 1;
this.server = 'wss://web-live-v3-0.agario.miniclippt.com/ws'; //TODO doc
this.ws = null;
} | javascript | function Account(name) { //TODO doc vars
this.name = name; //debug name
this.token = null; //token after requestFBToken()
this.token_expire = 0; //timestamp after requestFBToken()
this.token_provider = 1; //provider ID after requester
this.c_user = null; //cookie from www.facebook.com
this.datr = null; //cookie from www.facebook.com
this.xs = null; //cookie from www.facebook.com
this.agent = null; //connection agent
this.debug = 1;
this.server = 'wss://web-live-v3-0.agario.miniclippt.com/ws'; //TODO doc
this.ws = null;
} | [
"function",
"Account",
"(",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"token",
"=",
"null",
";",
"this",
".",
"token_expire",
"=",
"0",
";",
"this",
".",
"token_provider",
"=",
"1",
";",
"this",
".",
"c_user",
"=",
"null",
";",
"this",
".",
"datr",
"=",
"null",
";",
"this",
".",
"xs",
"=",
"null",
";",
"this",
".",
"agent",
"=",
"null",
";",
"this",
".",
"debug",
"=",
"1",
";",
"this",
".",
"server",
"=",
"'wss://web-live-v3-0.agario.miniclippt.com/ws'",
";",
"this",
".",
"ws",
"=",
"null",
";",
"}"
] | hardcoded in client | [
"hardcoded",
"in",
"client"
] | 34949a146977ca680294f84fa9a1c7254d097b19 | https://github.com/pulviscriptor/agario-client/blob/34949a146977ca680294f84fa9a1c7254d097b19/account.js#L7-L20 | train |
pulviscriptor/agario-client | agario-client.js | function(client, packet) {
var x = packet.readFloat32LE();
var y = packet.readFloat32LE();
var zoom = packet.readFloat32LE();
if(client.debug >= 4)
client.log('spectate FOV update: x=' + x + ' y=' + y + ' zoom=' + zoom);
client.emitEvent('spectateFieldUpdate', x, y, zoom);
} | javascript | function(client, packet) {
var x = packet.readFloat32LE();
var y = packet.readFloat32LE();
var zoom = packet.readFloat32LE();
if(client.debug >= 4)
client.log('spectate FOV update: x=' + x + ' y=' + y + ' zoom=' + zoom);
client.emitEvent('spectateFieldUpdate', x, y, zoom);
} | [
"function",
"(",
"client",
",",
"packet",
")",
"{",
"var",
"x",
"=",
"packet",
".",
"readFloat32LE",
"(",
")",
";",
"var",
"y",
"=",
"packet",
".",
"readFloat32LE",
"(",
")",
";",
"var",
"zoom",
"=",
"packet",
".",
"readFloat32LE",
"(",
")",
";",
"if",
"(",
"client",
".",
"debug",
">=",
"4",
")",
"client",
".",
"log",
"(",
"'spectate FOV update: x='",
"+",
"x",
"+",
"' y='",
"+",
"y",
"+",
"' zoom='",
"+",
"zoom",
")",
";",
"client",
".",
"emitEvent",
"(",
"'spectateFieldUpdate'",
",",
"x",
",",
"y",
",",
"zoom",
")",
";",
"}"
] | update spectating coordinates in "spectate" mode | [
"update",
"spectating",
"coordinates",
"in",
"spectate",
"mode"
] | 34949a146977ca680294f84fa9a1c7254d097b19 | https://github.com/pulviscriptor/agario-client/blob/34949a146977ca680294f84fa9a1c7254d097b19/agario-client.js#L328-L337 | train |
|
pulviscriptor/agario-client | agario-client.js | function (client, packet) {
var line_x = packet.readSInt16LE();
var line_y = packet.readSInt16LE();
if (client.debug >= 4)
client.log('debug line drawn from x=' + line_x + ' y=' + line_y);
client.emitEvent('debugLine', line_x, line_y);
} | javascript | function (client, packet) {
var line_x = packet.readSInt16LE();
var line_y = packet.readSInt16LE();
if (client.debug >= 4)
client.log('debug line drawn from x=' + line_x + ' y=' + line_y);
client.emitEvent('debugLine', line_x, line_y);
} | [
"function",
"(",
"client",
",",
"packet",
")",
"{",
"var",
"line_x",
"=",
"packet",
".",
"readSInt16LE",
"(",
")",
";",
"var",
"line_y",
"=",
"packet",
".",
"readSInt16LE",
"(",
")",
";",
"if",
"(",
"client",
".",
"debug",
">=",
"4",
")",
"client",
".",
"log",
"(",
"'debug line drawn from x='",
"+",
"line_x",
"+",
"' y='",
"+",
"line_y",
")",
";",
"client",
".",
"emitEvent",
"(",
"'debugLine'",
",",
"line_x",
",",
"line_y",
")",
";",
"}"
] | debug line drawn from the player to the specified point | [
"debug",
"line",
"drawn",
"from",
"the",
"player",
"to",
"the",
"specified",
"point"
] | 34949a146977ca680294f84fa9a1c7254d097b19 | https://github.com/pulviscriptor/agario-client/blob/34949a146977ca680294f84fa9a1c7254d097b19/agario-client.js#L349-L356 | train |
|
pulviscriptor/agario-client | agario-client.js | function(client, packet) {
var highlights = [];
var names = [];
var count = packet.readUInt32LE();
for(var i=0;i<count;i++) {
var highlight = packet.readUInt32LE();
var name = '';
while(1) {
var char = packet.readUInt16LE();
if(char == 0) break;
name += String.fromCharCode(char);
}
highlights.push(highlight);
names.push(name);
}
if(JSON.stringify(client.leaderHighlights) == JSON.stringify(highlights) &&
JSON.stringify(client.leaderNames) == JSON.stringify(names)) {
return;
}
var old_highlights = client.leaderHighlights;
var old_leaderNames = client.leaderNames;
client.leaderHighlights = highlights;
client.leaderNames = names;
if(client.debug >= 3)
client.log('leaders update: ' + JSON.stringify(highlights) + ',' + JSON.stringify(names));
client.emitEvent('leaderBoardUpdate', old_highlights, highlights, old_leaderNames, names);
} | javascript | function(client, packet) {
var highlights = [];
var names = [];
var count = packet.readUInt32LE();
for(var i=0;i<count;i++) {
var highlight = packet.readUInt32LE();
var name = '';
while(1) {
var char = packet.readUInt16LE();
if(char == 0) break;
name += String.fromCharCode(char);
}
highlights.push(highlight);
names.push(name);
}
if(JSON.stringify(client.leaderHighlights) == JSON.stringify(highlights) &&
JSON.stringify(client.leaderNames) == JSON.stringify(names)) {
return;
}
var old_highlights = client.leaderHighlights;
var old_leaderNames = client.leaderNames;
client.leaderHighlights = highlights;
client.leaderNames = names;
if(client.debug >= 3)
client.log('leaders update: ' + JSON.stringify(highlights) + ',' + JSON.stringify(names));
client.emitEvent('leaderBoardUpdate', old_highlights, highlights, old_leaderNames, names);
} | [
"function",
"(",
"client",
",",
"packet",
")",
"{",
"var",
"highlights",
"=",
"[",
"]",
";",
"var",
"names",
"=",
"[",
"]",
";",
"var",
"count",
"=",
"packet",
".",
"readUInt32LE",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"var",
"highlight",
"=",
"packet",
".",
"readUInt32LE",
"(",
")",
";",
"var",
"name",
"=",
"''",
";",
"while",
"(",
"1",
")",
"{",
"var",
"char",
"=",
"packet",
".",
"readUInt16LE",
"(",
")",
";",
"if",
"(",
"char",
"==",
"0",
")",
"break",
";",
"name",
"+=",
"String",
".",
"fromCharCode",
"(",
"char",
")",
";",
"}",
"highlights",
".",
"push",
"(",
"highlight",
")",
";",
"names",
".",
"push",
"(",
"name",
")",
";",
"}",
"if",
"(",
"JSON",
".",
"stringify",
"(",
"client",
".",
"leaderHighlights",
")",
"==",
"JSON",
".",
"stringify",
"(",
"highlights",
")",
"&&",
"JSON",
".",
"stringify",
"(",
"client",
".",
"leaderNames",
")",
"==",
"JSON",
".",
"stringify",
"(",
"names",
")",
")",
"{",
"return",
";",
"}",
"var",
"old_highlights",
"=",
"client",
".",
"leaderHighlights",
";",
"var",
"old_leaderNames",
"=",
"client",
".",
"leaderNames",
";",
"client",
".",
"leaderHighlights",
"=",
"highlights",
";",
"client",
".",
"leaderNames",
"=",
"names",
";",
"if",
"(",
"client",
".",
"debug",
">=",
"3",
")",
"client",
".",
"log",
"(",
"'leaders update: '",
"+",
"JSON",
".",
"stringify",
"(",
"highlights",
")",
"+",
"','",
"+",
"JSON",
".",
"stringify",
"(",
"names",
")",
")",
";",
"client",
".",
"emitEvent",
"(",
"'leaderBoardUpdate'",
",",
"old_highlights",
",",
"highlights",
",",
"old_leaderNames",
",",
"names",
")",
";",
"}"
] | leaderboard update in FFA mode | [
"leaderboard",
"update",
"in",
"FFA",
"mode"
] | 34949a146977ca680294f84fa9a1c7254d097b19 | https://github.com/pulviscriptor/agario-client/blob/34949a146977ca680294f84fa9a1c7254d097b19/agario-client.js#L381-L414 | train |
|
pulviscriptor/agario-client | agario-client.js | function(client, packet) {
var teams_count = packet.readUInt32LE();
var teams_scores = [];
for (var i=0;i<teams_count;++i) {
teams_scores.push(packet.readFloat32LE());
}
if(JSON.stringify(client.teams_scores) == JSON.stringify(teams_scores)) return;
var old_scores = client.teams_scores;
if(client.debug >= 3)
client.log('teams scores update: ' + JSON.stringify(teams_scores));
client.teams_scores = teams_scores;
client.emitEvent('teamsScoresUpdate', old_scores, teams_scores);
} | javascript | function(client, packet) {
var teams_count = packet.readUInt32LE();
var teams_scores = [];
for (var i=0;i<teams_count;++i) {
teams_scores.push(packet.readFloat32LE());
}
if(JSON.stringify(client.teams_scores) == JSON.stringify(teams_scores)) return;
var old_scores = client.teams_scores;
if(client.debug >= 3)
client.log('teams scores update: ' + JSON.stringify(teams_scores));
client.teams_scores = teams_scores;
client.emitEvent('teamsScoresUpdate', old_scores, teams_scores);
} | [
"function",
"(",
"client",
",",
"packet",
")",
"{",
"var",
"teams_count",
"=",
"packet",
".",
"readUInt32LE",
"(",
")",
";",
"var",
"teams_scores",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"teams_count",
";",
"++",
"i",
")",
"{",
"teams_scores",
".",
"push",
"(",
"packet",
".",
"readFloat32LE",
"(",
")",
")",
";",
"}",
"if",
"(",
"JSON",
".",
"stringify",
"(",
"client",
".",
"teams_scores",
")",
"==",
"JSON",
".",
"stringify",
"(",
"teams_scores",
")",
")",
"return",
";",
"var",
"old_scores",
"=",
"client",
".",
"teams_scores",
";",
"if",
"(",
"client",
".",
"debug",
">=",
"3",
")",
"client",
".",
"log",
"(",
"'teams scores update: '",
"+",
"JSON",
".",
"stringify",
"(",
"teams_scores",
")",
")",
";",
"client",
".",
"teams_scores",
"=",
"teams_scores",
";",
"client",
".",
"emitEvent",
"(",
"'teamsScoresUpdate'",
",",
"old_scores",
",",
"teams_scores",
")",
";",
"}"
] | teams scored update in teams mode | [
"teams",
"scored",
"update",
"in",
"teams",
"mode"
] | 34949a146977ca680294f84fa9a1c7254d097b19 | https://github.com/pulviscriptor/agario-client/blob/34949a146977ca680294f84fa9a1c7254d097b19/agario-client.js#L417-L434 | train |
|
pulviscriptor/agario-client | agario-client.js | function(client, packet) {
var min_x = packet.readFloat64LE();
var min_y = packet.readFloat64LE();
var max_x = packet.readFloat64LE();
var max_y = packet.readFloat64LE();
if(client.debug >= 2)
client.log('map size: ' + [min_x, min_y, max_x, max_y].join(','));
client.emitEvent('mapSizeLoad', min_x, min_y, max_x, max_y);
} | javascript | function(client, packet) {
var min_x = packet.readFloat64LE();
var min_y = packet.readFloat64LE();
var max_x = packet.readFloat64LE();
var max_y = packet.readFloat64LE();
if(client.debug >= 2)
client.log('map size: ' + [min_x, min_y, max_x, max_y].join(','));
client.emitEvent('mapSizeLoad', min_x, min_y, max_x, max_y);
} | [
"function",
"(",
"client",
",",
"packet",
")",
"{",
"var",
"min_x",
"=",
"packet",
".",
"readFloat64LE",
"(",
")",
";",
"var",
"min_y",
"=",
"packet",
".",
"readFloat64LE",
"(",
")",
";",
"var",
"max_x",
"=",
"packet",
".",
"readFloat64LE",
"(",
")",
";",
"var",
"max_y",
"=",
"packet",
".",
"readFloat64LE",
"(",
")",
";",
"if",
"(",
"client",
".",
"debug",
">=",
"2",
")",
"client",
".",
"log",
"(",
"'map size: '",
"+",
"[",
"min_x",
",",
"min_y",
",",
"max_x",
",",
"max_y",
"]",
".",
"join",
"(",
"','",
")",
")",
";",
"client",
".",
"emitEvent",
"(",
"'mapSizeLoad'",
",",
"min_x",
",",
"min_y",
",",
"max_x",
",",
"max_y",
")",
";",
"}"
] | map size load | [
"map",
"size",
"load"
] | 34949a146977ca680294f84fa9a1c7254d097b19 | https://github.com/pulviscriptor/agario-client/blob/34949a146977ca680294f84fa9a1c7254d097b19/agario-client.js#L437-L447 | train |
|
pulviscriptor/agario-client | agario-client.js | function(name) {
if(this.debug >= 3)
this.log('spawn() called, name=' + name);
if(!this.ws || this.ws.readyState !== WebSocket.OPEN) {
if(this.debug >= 1)
this.log('[warning] spawn() was called when connection was not established, packet will be dropped');
return false;
}
var buf = new Buffer(1 + 2*name.length);
buf.writeUInt8(0, 0);
for (var i=0;i<name.length;i++) {
buf.writeUInt16LE(name.charCodeAt(i), 1 + i*2);
}
this.send(buf);
//fix for unstable spawn on official servers
if(!this.spawn_attempt && this.spawn_interval) {
if(this.debug >= 4)
this.log('Starting spawn() interval');
var that = this;
this.spawn_attempt = 1;
this.spawn_interval_id = setInterval(function() {
if(that.debug >= 4)
that.log('spawn() interval tick, attempt ' + that.spawn_attempt + '/' + that.spawn_attempts);
if(that.spawn_attempt >= that.spawn_attempts) {
if(that.debug >= 1)
that.log('[warning] spawn() interval gave up! Disconnecting from server!');
that.spawn_attempt = 0;
clearInterval(that.spawn_interval_id);
that.spawn_interval_id = 0;
that.disconnect();
return;
}
that.spawn_attempt++;
that.spawn(name);
}, that.spawn_interval);
}
return true;
} | javascript | function(name) {
if(this.debug >= 3)
this.log('spawn() called, name=' + name);
if(!this.ws || this.ws.readyState !== WebSocket.OPEN) {
if(this.debug >= 1)
this.log('[warning] spawn() was called when connection was not established, packet will be dropped');
return false;
}
var buf = new Buffer(1 + 2*name.length);
buf.writeUInt8(0, 0);
for (var i=0;i<name.length;i++) {
buf.writeUInt16LE(name.charCodeAt(i), 1 + i*2);
}
this.send(buf);
//fix for unstable spawn on official servers
if(!this.spawn_attempt && this.spawn_interval) {
if(this.debug >= 4)
this.log('Starting spawn() interval');
var that = this;
this.spawn_attempt = 1;
this.spawn_interval_id = setInterval(function() {
if(that.debug >= 4)
that.log('spawn() interval tick, attempt ' + that.spawn_attempt + '/' + that.spawn_attempts);
if(that.spawn_attempt >= that.spawn_attempts) {
if(that.debug >= 1)
that.log('[warning] spawn() interval gave up! Disconnecting from server!');
that.spawn_attempt = 0;
clearInterval(that.spawn_interval_id);
that.spawn_interval_id = 0;
that.disconnect();
return;
}
that.spawn_attempt++;
that.spawn(name);
}, that.spawn_interval);
}
return true;
} | [
"function",
"(",
"name",
")",
"{",
"if",
"(",
"this",
".",
"debug",
">=",
"3",
")",
"this",
".",
"log",
"(",
"'spawn() called, name='",
"+",
"name",
")",
";",
"if",
"(",
"!",
"this",
".",
"ws",
"||",
"this",
".",
"ws",
".",
"readyState",
"!==",
"WebSocket",
".",
"OPEN",
")",
"{",
"if",
"(",
"this",
".",
"debug",
">=",
"1",
")",
"this",
".",
"log",
"(",
"'[warning] spawn() was called when connection was not established, packet will be dropped'",
")",
";",
"return",
"false",
";",
"}",
"var",
"buf",
"=",
"new",
"Buffer",
"(",
"1",
"+",
"2",
"*",
"name",
".",
"length",
")",
";",
"buf",
".",
"writeUInt8",
"(",
"0",
",",
"0",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"name",
".",
"length",
";",
"i",
"++",
")",
"{",
"buf",
".",
"writeUInt16LE",
"(",
"name",
".",
"charCodeAt",
"(",
"i",
")",
",",
"1",
"+",
"i",
"*",
"2",
")",
";",
"}",
"this",
".",
"send",
"(",
"buf",
")",
";",
"if",
"(",
"!",
"this",
".",
"spawn_attempt",
"&&",
"this",
".",
"spawn_interval",
")",
"{",
"if",
"(",
"this",
".",
"debug",
">=",
"4",
")",
"this",
".",
"log",
"(",
"'Starting spawn() interval'",
")",
";",
"var",
"that",
"=",
"this",
";",
"this",
".",
"spawn_attempt",
"=",
"1",
";",
"this",
".",
"spawn_interval_id",
"=",
"setInterval",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"that",
".",
"debug",
">=",
"4",
")",
"that",
".",
"log",
"(",
"'spawn() interval tick, attempt '",
"+",
"that",
".",
"spawn_attempt",
"+",
"'/'",
"+",
"that",
".",
"spawn_attempts",
")",
";",
"if",
"(",
"that",
".",
"spawn_attempt",
">=",
"that",
".",
"spawn_attempts",
")",
"{",
"if",
"(",
"that",
".",
"debug",
">=",
"1",
")",
"that",
".",
"log",
"(",
"'[warning] spawn() interval gave up! Disconnecting from server!'",
")",
";",
"that",
".",
"spawn_attempt",
"=",
"0",
";",
"clearInterval",
"(",
"that",
".",
"spawn_interval_id",
")",
";",
"that",
".",
"spawn_interval_id",
"=",
"0",
";",
"that",
".",
"disconnect",
"(",
")",
";",
"return",
";",
"}",
"that",
".",
"spawn_attempt",
"++",
";",
"that",
".",
"spawn",
"(",
"name",
")",
";",
"}",
",",
"that",
".",
"spawn_interval",
")",
";",
"}",
"return",
"true",
";",
"}"
] | functions that you can call to control your balls spawn ball | [
"functions",
"that",
"you",
"can",
"call",
"to",
"control",
"your",
"balls",
"spawn",
"ball"
] | 34949a146977ca680294f84fa9a1c7254d097b19 | https://github.com/pulviscriptor/agario-client/blob/34949a146977ca680294f84fa9a1c7254d097b19/agario-client.js#L538-L581 | train |
|
pulviscriptor/agario-client | agario-client.js | function() {
if(!this.ws || this.ws.readyState !== WebSocket.OPEN) {
if(this.debug >= 1)
this.log('[warning] spectate() was called when connection was not established, packet will be dropped');
return false;
}
var buf = new Buffer([1]);
this.send(buf);
return true;
} | javascript | function() {
if(!this.ws || this.ws.readyState !== WebSocket.OPEN) {
if(this.debug >= 1)
this.log('[warning] spectate() was called when connection was not established, packet will be dropped');
return false;
}
var buf = new Buffer([1]);
this.send(buf);
return true;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"ws",
"||",
"this",
".",
"ws",
".",
"readyState",
"!==",
"WebSocket",
".",
"OPEN",
")",
"{",
"if",
"(",
"this",
".",
"debug",
">=",
"1",
")",
"this",
".",
"log",
"(",
"'[warning] spectate() was called when connection was not established, packet will be dropped'",
")",
";",
"return",
"false",
";",
"}",
"var",
"buf",
"=",
"new",
"Buffer",
"(",
"[",
"1",
"]",
")",
";",
"this",
".",
"send",
"(",
"buf",
")",
";",
"return",
"true",
";",
"}"
] | activate spectate mode | [
"activate",
"spectate",
"mode"
] | 34949a146977ca680294f84fa9a1c7254d097b19 | https://github.com/pulviscriptor/agario-client/blob/34949a146977ca680294f84fa9a1c7254d097b19/agario-client.js#L584-L595 | train |
|
pulviscriptor/agario-client | packet.js | Packet | function Packet(e) {
if(e instanceof Buffer) {
this.data = e;
this.length = this.data.length;
}else if((typeof Buffer) != 'undefined' && e.data instanceof Buffer) {
this.data = e.data;
this.length = this.data.length;
}else{
this.data = new DataView(e.data);
this.length = this.data.byteLength;
}
this.offset = 0;
} | javascript | function Packet(e) {
if(e instanceof Buffer) {
this.data = e;
this.length = this.data.length;
}else if((typeof Buffer) != 'undefined' && e.data instanceof Buffer) {
this.data = e.data;
this.length = this.data.length;
}else{
this.data = new DataView(e.data);
this.length = this.data.byteLength;
}
this.offset = 0;
} | [
"function",
"Packet",
"(",
"e",
")",
"{",
"if",
"(",
"e",
"instanceof",
"Buffer",
")",
"{",
"this",
".",
"data",
"=",
"e",
";",
"this",
".",
"length",
"=",
"this",
".",
"data",
".",
"length",
";",
"}",
"else",
"if",
"(",
"(",
"typeof",
"Buffer",
")",
"!=",
"'undefined'",
"&&",
"e",
".",
"data",
"instanceof",
"Buffer",
")",
"{",
"this",
".",
"data",
"=",
"e",
".",
"data",
";",
"this",
".",
"length",
"=",
"this",
".",
"data",
".",
"length",
";",
"}",
"else",
"{",
"this",
".",
"data",
"=",
"new",
"DataView",
"(",
"e",
".",
"data",
")",
";",
"this",
".",
"length",
"=",
"this",
".",
"data",
".",
"byteLength",
";",
"}",
"this",
".",
"offset",
"=",
"0",
";",
"}"
] | this file is for internal use with packets | [
"this",
"file",
"is",
"for",
"internal",
"use",
"with",
"packets"
] | 34949a146977ca680294f84fa9a1c7254d097b19 | https://github.com/pulviscriptor/agario-client/blob/34949a146977ca680294f84fa9a1c7254d097b19/packet.js#L3-L16 | train |
awendland/angular-json-tree | dist/angular-json-tree.js | forKeys | function forKeys(obj, f) {
for (var key in obj) {
if (obj.hasOwnProperty(key) && typeof obj[key] !== 'function') {
if (f(key, obj[key])) {
break;
}
}
}
} | javascript | function forKeys(obj, f) {
for (var key in obj) {
if (obj.hasOwnProperty(key) && typeof obj[key] !== 'function') {
if (f(key, obj[key])) {
break;
}
}
}
} | [
"function",
"forKeys",
"(",
"obj",
",",
"f",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
"key",
")",
"&&",
"typeof",
"obj",
"[",
"key",
"]",
"!==",
"'function'",
")",
"{",
"if",
"(",
"f",
"(",
"key",
",",
"obj",
"[",
"key",
"]",
")",
")",
"{",
"break",
";",
"}",
"}",
"}",
"}"
] | Iterate over an objects keyset | [
"Iterate",
"over",
"an",
"objects",
"keyset"
] | 13383021005554a3770db67fe8cd733a4ed097e1 | https://github.com/awendland/angular-json-tree/blob/13383021005554a3770db67fe8cd733a4ed097e1/dist/angular-json-tree.js#L65-L73 | train |
ev3dev/ev3dev-lang | autogen/autogen-core.js | processFile | function processFile(autogenContext, commentInfo, callback) {
fs.readFile(path.resolve(__dirname, "..", autogenContext.filePath), function (readError, sourceFileContentsBuffer) {
if (readError) {
callback(autogenContext.filePath, readError);
return;
}
processNextAutogenBlock(autogenContext, sourceFileContentsBuffer.toString(), commentInfo, 0, function (result, autogenError) {
//Write results if the content was changed (don't need to re-write the same content)
if (sourceFileContentsBuffer.toString() != result)
fs.writeFile(path.resolve(__dirname, "..", autogenContext.filePath), result, {}, function (writeError) {
callback(autogenContext.filePath, writeError);
});
else
callback(autogenContext.filePath, autogenError);
});
});
} | javascript | function processFile(autogenContext, commentInfo, callback) {
fs.readFile(path.resolve(__dirname, "..", autogenContext.filePath), function (readError, sourceFileContentsBuffer) {
if (readError) {
callback(autogenContext.filePath, readError);
return;
}
processNextAutogenBlock(autogenContext, sourceFileContentsBuffer.toString(), commentInfo, 0, function (result, autogenError) {
//Write results if the content was changed (don't need to re-write the same content)
if (sourceFileContentsBuffer.toString() != result)
fs.writeFile(path.resolve(__dirname, "..", autogenContext.filePath), result, {}, function (writeError) {
callback(autogenContext.filePath, writeError);
});
else
callback(autogenContext.filePath, autogenError);
});
});
} | [
"function",
"processFile",
"(",
"autogenContext",
",",
"commentInfo",
",",
"callback",
")",
"{",
"fs",
".",
"readFile",
"(",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"\"..\"",
",",
"autogenContext",
".",
"filePath",
")",
",",
"function",
"(",
"readError",
",",
"sourceFileContentsBuffer",
")",
"{",
"if",
"(",
"readError",
")",
"{",
"callback",
"(",
"autogenContext",
".",
"filePath",
",",
"readError",
")",
";",
"return",
";",
"}",
"processNextAutogenBlock",
"(",
"autogenContext",
",",
"sourceFileContentsBuffer",
".",
"toString",
"(",
")",
",",
"commentInfo",
",",
"0",
",",
"function",
"(",
"result",
",",
"autogenError",
")",
"{",
"if",
"(",
"sourceFileContentsBuffer",
".",
"toString",
"(",
")",
"!=",
"result",
")",
"fs",
".",
"writeFile",
"(",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"\"..\"",
",",
"autogenContext",
".",
"filePath",
")",
",",
"result",
",",
"{",
"}",
",",
"function",
"(",
"writeError",
")",
"{",
"callback",
"(",
"autogenContext",
".",
"filePath",
",",
"writeError",
")",
";",
"}",
")",
";",
"else",
"callback",
"(",
"autogenContext",
".",
"filePath",
",",
"autogenError",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Processes the contents of the specified file, and writes the result back to the same location | [
"Processes",
"the",
"contents",
"of",
"the",
"specified",
"file",
"and",
"writes",
"the",
"result",
"back",
"to",
"the",
"same",
"location"
] | 0169750bf9aeefac423c38929287b4ad9ef7abd4 | https://github.com/ev3dev/ev3dev-lang/blob/0169750bf9aeefac423c38929287b4ad9ef7abd4/autogen/autogen-core.js#L16-L33 | train |
ev3dev/ev3dev-lang | autogen/autogen-core.js | processNextAutogenBlock | function processNextAutogenBlock(autogenContext, allData, commentInfo, pos, callback) {
//Update the position of the next block. If there isn't one, call the callback and break the recursion.
pos = utils.regexIndexOf(allData, commentInfo.start, pos);
if (pos == -1) {
callback(allData);
return;
}
//Extract the information from the autogen definition
var matchInfo = commentInfo.start.exec(allData.substring(pos));
//Skip over the start tag
pos += matchInfo[0].length;
//Get the data from the autogen tag
var tagContent = matchInfo[1];
var autogenTagData = utils.parseAutogenTag(tagContent);
//Make file name in to a full path
var filename = path.resolve(autogenContext.templateDir, autogenTagData.templateFileName + ".liquid");
//Find the end of the line (and the start of content)
// Handle both styles of line endings
var endOfAutogenLine = utils.regexIndexOf(allData, /[\r|\n]/, pos);
var startBlock = utils.regexIndexOf(allData, /[\n]/, endOfAutogenLine) + 1;
var endBlock = allData.indexOf(commentInfo.end, startBlock);
//Prepare and load the required data
var loadedLiquid = fs.readFileSync(filename);
//Deep-copy the spec data so that we can add context
var dataContext = utils.extend({}, autogenContext.specData);
//Populate the autogen data context with property mappings from autogen tag
for (var mappingIndex in autogenTagData.propertyMappings) {
var propertyMapping = autogenTagData.propertyMappings[mappingIndex];
var propValue = utils.getProp(dataContext, propertyMapping.sourceString);
utils.setProp(dataContext, propertyMapping.destString, propValue);
}
//Populate the autogen data context with value mappings from autogen tag
for (var mappingIndex in autogenTagData.valueMappings) {
var valueMapping = autogenTagData.valueMappings[mappingIndex];
utils.setProp(dataContext, valueMapping.destString, valueMapping.sourceString);
}
function insertTemplatedAndContinue(result) {
//Replace the old contents of the output block with the result from the liquid engine
var newData =
allData.substring(0, startBlock)
+ result
+ os.EOL
+ allData.substring(endBlock);
//Start/continue the recursion, and update the position for the next iteration
processNextAutogenBlock(autogenContext, newData, commentInfo,
startBlock
+ result.length
+ os.EOL.length
+ commentInfo.end.length, callback);
}
if (autogenContext.clearTemplatedSections)
insertTemplatedAndContinue('');
else {
//Parse and render the liquid using the spec data
autogenContext.liquidEngine
.parseAndRender(loadedLiquid, dataContext)
.then(insertTemplatedAndContinue);
}
} | javascript | function processNextAutogenBlock(autogenContext, allData, commentInfo, pos, callback) {
//Update the position of the next block. If there isn't one, call the callback and break the recursion.
pos = utils.regexIndexOf(allData, commentInfo.start, pos);
if (pos == -1) {
callback(allData);
return;
}
//Extract the information from the autogen definition
var matchInfo = commentInfo.start.exec(allData.substring(pos));
//Skip over the start tag
pos += matchInfo[0].length;
//Get the data from the autogen tag
var tagContent = matchInfo[1];
var autogenTagData = utils.parseAutogenTag(tagContent);
//Make file name in to a full path
var filename = path.resolve(autogenContext.templateDir, autogenTagData.templateFileName + ".liquid");
//Find the end of the line (and the start of content)
// Handle both styles of line endings
var endOfAutogenLine = utils.regexIndexOf(allData, /[\r|\n]/, pos);
var startBlock = utils.regexIndexOf(allData, /[\n]/, endOfAutogenLine) + 1;
var endBlock = allData.indexOf(commentInfo.end, startBlock);
//Prepare and load the required data
var loadedLiquid = fs.readFileSync(filename);
//Deep-copy the spec data so that we can add context
var dataContext = utils.extend({}, autogenContext.specData);
//Populate the autogen data context with property mappings from autogen tag
for (var mappingIndex in autogenTagData.propertyMappings) {
var propertyMapping = autogenTagData.propertyMappings[mappingIndex];
var propValue = utils.getProp(dataContext, propertyMapping.sourceString);
utils.setProp(dataContext, propertyMapping.destString, propValue);
}
//Populate the autogen data context with value mappings from autogen tag
for (var mappingIndex in autogenTagData.valueMappings) {
var valueMapping = autogenTagData.valueMappings[mappingIndex];
utils.setProp(dataContext, valueMapping.destString, valueMapping.sourceString);
}
function insertTemplatedAndContinue(result) {
//Replace the old contents of the output block with the result from the liquid engine
var newData =
allData.substring(0, startBlock)
+ result
+ os.EOL
+ allData.substring(endBlock);
//Start/continue the recursion, and update the position for the next iteration
processNextAutogenBlock(autogenContext, newData, commentInfo,
startBlock
+ result.length
+ os.EOL.length
+ commentInfo.end.length, callback);
}
if (autogenContext.clearTemplatedSections)
insertTemplatedAndContinue('');
else {
//Parse and render the liquid using the spec data
autogenContext.liquidEngine
.parseAndRender(loadedLiquid, dataContext)
.then(insertTemplatedAndContinue);
}
} | [
"function",
"processNextAutogenBlock",
"(",
"autogenContext",
",",
"allData",
",",
"commentInfo",
",",
"pos",
",",
"callback",
")",
"{",
"pos",
"=",
"utils",
".",
"regexIndexOf",
"(",
"allData",
",",
"commentInfo",
".",
"start",
",",
"pos",
")",
";",
"if",
"(",
"pos",
"==",
"-",
"1",
")",
"{",
"callback",
"(",
"allData",
")",
";",
"return",
";",
"}",
"var",
"matchInfo",
"=",
"commentInfo",
".",
"start",
".",
"exec",
"(",
"allData",
".",
"substring",
"(",
"pos",
")",
")",
";",
"pos",
"+=",
"matchInfo",
"[",
"0",
"]",
".",
"length",
";",
"var",
"tagContent",
"=",
"matchInfo",
"[",
"1",
"]",
";",
"var",
"autogenTagData",
"=",
"utils",
".",
"parseAutogenTag",
"(",
"tagContent",
")",
";",
"var",
"filename",
"=",
"path",
".",
"resolve",
"(",
"autogenContext",
".",
"templateDir",
",",
"autogenTagData",
".",
"templateFileName",
"+",
"\".liquid\"",
")",
";",
"var",
"endOfAutogenLine",
"=",
"utils",
".",
"regexIndexOf",
"(",
"allData",
",",
"/",
"[\\r|\\n]",
"/",
",",
"pos",
")",
";",
"var",
"startBlock",
"=",
"utils",
".",
"regexIndexOf",
"(",
"allData",
",",
"/",
"[\\n]",
"/",
",",
"endOfAutogenLine",
")",
"+",
"1",
";",
"var",
"endBlock",
"=",
"allData",
".",
"indexOf",
"(",
"commentInfo",
".",
"end",
",",
"startBlock",
")",
";",
"var",
"loadedLiquid",
"=",
"fs",
".",
"readFileSync",
"(",
"filename",
")",
";",
"var",
"dataContext",
"=",
"utils",
".",
"extend",
"(",
"{",
"}",
",",
"autogenContext",
".",
"specData",
")",
";",
"for",
"(",
"var",
"mappingIndex",
"in",
"autogenTagData",
".",
"propertyMappings",
")",
"{",
"var",
"propertyMapping",
"=",
"autogenTagData",
".",
"propertyMappings",
"[",
"mappingIndex",
"]",
";",
"var",
"propValue",
"=",
"utils",
".",
"getProp",
"(",
"dataContext",
",",
"propertyMapping",
".",
"sourceString",
")",
";",
"utils",
".",
"setProp",
"(",
"dataContext",
",",
"propertyMapping",
".",
"destString",
",",
"propValue",
")",
";",
"}",
"for",
"(",
"var",
"mappingIndex",
"in",
"autogenTagData",
".",
"valueMappings",
")",
"{",
"var",
"valueMapping",
"=",
"autogenTagData",
".",
"valueMappings",
"[",
"mappingIndex",
"]",
";",
"utils",
".",
"setProp",
"(",
"dataContext",
",",
"valueMapping",
".",
"destString",
",",
"valueMapping",
".",
"sourceString",
")",
";",
"}",
"function",
"insertTemplatedAndContinue",
"(",
"result",
")",
"{",
"var",
"newData",
"=",
"allData",
".",
"substring",
"(",
"0",
",",
"startBlock",
")",
"+",
"result",
"+",
"os",
".",
"EOL",
"+",
"allData",
".",
"substring",
"(",
"endBlock",
")",
";",
"processNextAutogenBlock",
"(",
"autogenContext",
",",
"newData",
",",
"commentInfo",
",",
"startBlock",
"+",
"result",
".",
"length",
"+",
"os",
".",
"EOL",
".",
"length",
"+",
"commentInfo",
".",
"end",
".",
"length",
",",
"callback",
")",
";",
"}",
"if",
"(",
"autogenContext",
".",
"clearTemplatedSections",
")",
"insertTemplatedAndContinue",
"(",
"''",
")",
";",
"else",
"{",
"autogenContext",
".",
"liquidEngine",
".",
"parseAndRender",
"(",
"loadedLiquid",
",",
"dataContext",
")",
".",
"then",
"(",
"insertTemplatedAndContinue",
")",
";",
"}",
"}"
] | Recursively updates the autogen blocks | [
"Recursively",
"updates",
"the",
"autogen",
"blocks"
] | 0169750bf9aeefac423c38929287b4ad9ef7abd4 | https://github.com/ev3dev/ev3dev-lang/blob/0169750bf9aeefac423c38929287b4ad9ef7abd4/autogen/autogen-core.js#L36-L109 | train |
ev3dev/ev3dev-lang | autogen/config.js | function (input) {
function camelCaseSingle(input) {
return String(input).toLowerCase().replace(/[-|\s](.)/g, function (match, group1) {
return group1.toUpperCase();
});
}
if(typeof input == 'string')
return camelCaseSingle(input);
else
return input.map(camelCaseSingle);
} | javascript | function (input) {
function camelCaseSingle(input) {
return String(input).toLowerCase().replace(/[-|\s](.)/g, function (match, group1) {
return group1.toUpperCase();
});
}
if(typeof input == 'string')
return camelCaseSingle(input);
else
return input.map(camelCaseSingle);
} | [
"function",
"(",
"input",
")",
"{",
"function",
"camelCaseSingle",
"(",
"input",
")",
"{",
"return",
"String",
"(",
"input",
")",
".",
"toLowerCase",
"(",
")",
".",
"replace",
"(",
"/",
"[-|\\s](.)",
"/",
"g",
",",
"function",
"(",
"match",
",",
"group1",
")",
"{",
"return",
"group1",
".",
"toUpperCase",
"(",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"typeof",
"input",
"==",
"'string'",
")",
"return",
"camelCaseSingle",
"(",
"input",
")",
";",
"else",
"return",
"input",
".",
"map",
"(",
"camelCaseSingle",
")",
";",
"}"
] | camel-cases the input string. If the parameter is an array, applies to all items. | [
"camel",
"-",
"cases",
"the",
"input",
"string",
".",
"If",
"the",
"parameter",
"is",
"an",
"array",
"applies",
"to",
"all",
"items",
"."
] | 0169750bf9aeefac423c38929287b4ad9ef7abd4 | https://github.com/ev3dev/ev3dev-lang/blob/0169750bf9aeefac423c38929287b4ad9ef7abd4/autogen/config.js#L22-L33 | train |
|
ev3dev/ev3dev-lang | autogen/config.js | function (object, property) {
return utils.getProp(object, Array.prototype.slice.call(arguments, 1).join("."));
} | javascript | function (object, property) {
return utils.getProp(object, Array.prototype.slice.call(arguments, 1).join("."));
} | [
"function",
"(",
"object",
",",
"property",
")",
"{",
"return",
"utils",
".",
"getProp",
"(",
"object",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
".",
"join",
"(",
"\".\"",
")",
")",
";",
"}"
] | gets a property from an object | [
"gets",
"a",
"property",
"from",
"an",
"object"
] | 0169750bf9aeefac423c38929287b4ad9ef7abd4 | https://github.com/ev3dev/ev3dev-lang/blob/0169750bf9aeefac423c38929287b4ad9ef7abd4/autogen/config.js#L47-L49 | train |
|
ibm-functions/composer | conductor.js | synthesize | function synthesize ({ name, composition, ast, version: composer, annotations = [] }) {
const code = `// generated by composer v${composer} and conductor v${version}\n\nconst composition = ${JSON.stringify(composition, null, 4)}\n\n// do not edit below this point\n\n` +
minify(`const main=(${main})(composition)`, { output: { max_line_len: 127 } }).code
annotations = annotations.concat([{ key: 'conductor', value: ast }, { key: 'composerVersion', value: composer }, { key: 'conductorVersion', value: version }])
return { name, action: { exec: { kind: 'nodejs:default', code }, annotations } }
} | javascript | function synthesize ({ name, composition, ast, version: composer, annotations = [] }) {
const code = `// generated by composer v${composer} and conductor v${version}\n\nconst composition = ${JSON.stringify(composition, null, 4)}\n\n// do not edit below this point\n\n` +
minify(`const main=(${main})(composition)`, { output: { max_line_len: 127 } }).code
annotations = annotations.concat([{ key: 'conductor', value: ast }, { key: 'composerVersion', value: composer }, { key: 'conductorVersion', value: version }])
return { name, action: { exec: { kind: 'nodejs:default', code }, annotations } }
} | [
"function",
"synthesize",
"(",
"{",
"name",
",",
"composition",
",",
"ast",
",",
"version",
":",
"composer",
",",
"annotations",
"=",
"[",
"]",
"}",
")",
"{",
"const",
"code",
"=",
"`",
"${",
"composer",
"}",
"${",
"version",
"}",
"\\n",
"\\n",
"${",
"JSON",
".",
"stringify",
"(",
"composition",
",",
"null",
",",
"4",
")",
"}",
"\\n",
"\\n",
"\\n",
"\\n",
"`",
"+",
"minify",
"(",
"`",
"${",
"main",
"}",
"`",
",",
"{",
"output",
":",
"{",
"max_line_len",
":",
"127",
"}",
"}",
")",
".",
"code",
"annotations",
"=",
"annotations",
".",
"concat",
"(",
"[",
"{",
"key",
":",
"'conductor'",
",",
"value",
":",
"ast",
"}",
",",
"{",
"key",
":",
"'composerVersion'",
",",
"value",
":",
"composer",
"}",
",",
"{",
"key",
":",
"'conductorVersion'",
",",
"value",
":",
"version",
"}",
"]",
")",
"return",
"{",
"name",
",",
"action",
":",
"{",
"exec",
":",
"{",
"kind",
":",
"'nodejs:default'",
",",
"code",
"}",
",",
"annotations",
"}",
"}",
"}"
] | synthesize conductor action code from composition | [
"synthesize",
"conductor",
"action",
"code",
"from",
"composition"
] | 94fe7415270a6718dddc5f535f38364589a70f4f | https://github.com/ibm-functions/composer/blob/94fe7415270a6718dddc5f535f38364589a70f4f/conductor.js#L32-L37 | train |
ibm-functions/composer | conductor.js | inspect | function inspect (p) {
if (!isObject(p.params)) p.params = { value: p.params }
if (p.params.error !== undefined) {
p.params = { error: p.params.error } // discard all fields but the error field
p.s.state = -1 // abort unless there is a handler in the stack
while (p.s.stack.length > 0 && !p.s.stack[0].marker) {
if ((p.s.state = p.s.stack.shift().catch || -1) >= 0) break
}
}
} | javascript | function inspect (p) {
if (!isObject(p.params)) p.params = { value: p.params }
if (p.params.error !== undefined) {
p.params = { error: p.params.error } // discard all fields but the error field
p.s.state = -1 // abort unless there is a handler in the stack
while (p.s.stack.length > 0 && !p.s.stack[0].marker) {
if ((p.s.state = p.s.stack.shift().catch || -1) >= 0) break
}
}
} | [
"function",
"inspect",
"(",
"p",
")",
"{",
"if",
"(",
"!",
"isObject",
"(",
"p",
".",
"params",
")",
")",
"p",
".",
"params",
"=",
"{",
"value",
":",
"p",
".",
"params",
"}",
"if",
"(",
"p",
".",
"params",
".",
"error",
"!==",
"undefined",
")",
"{",
"p",
".",
"params",
"=",
"{",
"error",
":",
"p",
".",
"params",
".",
"error",
"}",
"p",
".",
"s",
".",
"state",
"=",
"-",
"1",
"while",
"(",
"p",
".",
"s",
".",
"stack",
".",
"length",
">",
"0",
"&&",
"!",
"p",
".",
"s",
".",
"stack",
"[",
"0",
"]",
".",
"marker",
")",
"{",
"if",
"(",
"(",
"p",
".",
"s",
".",
"state",
"=",
"p",
".",
"s",
".",
"stack",
".",
"shift",
"(",
")",
".",
"catch",
"||",
"-",
"1",
")",
">=",
"0",
")",
"break",
"}",
"}",
"}"
] | wrap params if not a dictionary, branch to error handler if error | [
"wrap",
"params",
"if",
"not",
"a",
"dictionary",
"branch",
"to",
"error",
"handler",
"if",
"error"
] | 94fe7415270a6718dddc5f535f38364589a70f4f | https://github.com/ibm-functions/composer/blob/94fe7415270a6718dddc5f535f38364589a70f4f/conductor.js#L234-L243 | train |
ibm-functions/composer | conductor.js | run | function run (f, p) {
// handle let/mask pairs
const view = []
let n = 0
for (let frame of p.s.stack) {
if (frame.let === null) {
n++
} else if (frame.let !== undefined) {
if (n === 0) {
view.push(frame)
} else {
n--
}
}
}
// update value of topmost matching symbol on stack if any
function set (symbol, value) {
const element = view.find(element => element.let !== undefined && element.let[symbol] !== undefined)
if (element !== undefined) element.let[symbol] = JSON.parse(JSON.stringify(value))
}
// collapse stack for invocation
const env = view.reduceRight((acc, cur) => cur.let ? Object.assign(acc, cur.let) : acc, {})
let main = '(function(){try{const require=arguments[2];'
for (const name in env) main += `var ${name}=arguments[1]['${name}'];`
main += `return eval((function(){return(${f})})())(arguments[0])}finally{`
for (const name in env) main += `arguments[1]['${name}']=${name};`
main += '}})'
try {
return (1, eval)(main)(p.params, env, require)
} finally {
for (const name in env) set(name, env[name])
}
} | javascript | function run (f, p) {
// handle let/mask pairs
const view = []
let n = 0
for (let frame of p.s.stack) {
if (frame.let === null) {
n++
} else if (frame.let !== undefined) {
if (n === 0) {
view.push(frame)
} else {
n--
}
}
}
// update value of topmost matching symbol on stack if any
function set (symbol, value) {
const element = view.find(element => element.let !== undefined && element.let[symbol] !== undefined)
if (element !== undefined) element.let[symbol] = JSON.parse(JSON.stringify(value))
}
// collapse stack for invocation
const env = view.reduceRight((acc, cur) => cur.let ? Object.assign(acc, cur.let) : acc, {})
let main = '(function(){try{const require=arguments[2];'
for (const name in env) main += `var ${name}=arguments[1]['${name}'];`
main += `return eval((function(){return(${f})})())(arguments[0])}finally{`
for (const name in env) main += `arguments[1]['${name}']=${name};`
main += '}})'
try {
return (1, eval)(main)(p.params, env, require)
} finally {
for (const name in env) set(name, env[name])
}
} | [
"function",
"run",
"(",
"f",
",",
"p",
")",
"{",
"const",
"view",
"=",
"[",
"]",
"let",
"n",
"=",
"0",
"for",
"(",
"let",
"frame",
"of",
"p",
".",
"s",
".",
"stack",
")",
"{",
"if",
"(",
"frame",
".",
"let",
"===",
"null",
")",
"{",
"n",
"++",
"}",
"else",
"if",
"(",
"frame",
".",
"let",
"!==",
"undefined",
")",
"{",
"if",
"(",
"n",
"===",
"0",
")",
"{",
"view",
".",
"push",
"(",
"frame",
")",
"}",
"else",
"{",
"n",
"--",
"}",
"}",
"}",
"function",
"set",
"(",
"symbol",
",",
"value",
")",
"{",
"const",
"element",
"=",
"view",
".",
"find",
"(",
"element",
"=>",
"element",
".",
"let",
"!==",
"undefined",
"&&",
"element",
".",
"let",
"[",
"symbol",
"]",
"!==",
"undefined",
")",
"if",
"(",
"element",
"!==",
"undefined",
")",
"element",
".",
"let",
"[",
"symbol",
"]",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"value",
")",
")",
"}",
"const",
"env",
"=",
"view",
".",
"reduceRight",
"(",
"(",
"acc",
",",
"cur",
")",
"=>",
"cur",
".",
"let",
"?",
"Object",
".",
"assign",
"(",
"acc",
",",
"cur",
".",
"let",
")",
":",
"acc",
",",
"{",
"}",
")",
"let",
"main",
"=",
"'(function(){try{const require=arguments[2];'",
"for",
"(",
"const",
"name",
"in",
"env",
")",
"main",
"+=",
"`",
"${",
"name",
"}",
"${",
"name",
"}",
"`",
"main",
"+=",
"`",
"${",
"f",
"}",
"`",
"for",
"(",
"const",
"name",
"in",
"env",
")",
"main",
"+=",
"`",
"${",
"name",
"}",
"${",
"name",
"}",
"`",
"main",
"+=",
"'}})'",
"try",
"{",
"return",
"(",
"1",
",",
"eval",
")",
"(",
"main",
")",
"(",
"p",
".",
"params",
",",
"env",
",",
"require",
")",
"}",
"finally",
"{",
"for",
"(",
"const",
"name",
"in",
"env",
")",
"set",
"(",
"name",
",",
"env",
"[",
"name",
"]",
")",
"}",
"}"
] | run function f on current stack | [
"run",
"function",
"f",
"on",
"current",
"stack"
] | 94fe7415270a6718dddc5f535f38364589a70f4f | https://github.com/ibm-functions/composer/blob/94fe7415270a6718dddc5f535f38364589a70f4f/conductor.js#L246-L280 | train |
ibm-functions/composer | conductor.js | set | function set (symbol, value) {
const element = view.find(element => element.let !== undefined && element.let[symbol] !== undefined)
if (element !== undefined) element.let[symbol] = JSON.parse(JSON.stringify(value))
} | javascript | function set (symbol, value) {
const element = view.find(element => element.let !== undefined && element.let[symbol] !== undefined)
if (element !== undefined) element.let[symbol] = JSON.parse(JSON.stringify(value))
} | [
"function",
"set",
"(",
"symbol",
",",
"value",
")",
"{",
"const",
"element",
"=",
"view",
".",
"find",
"(",
"element",
"=>",
"element",
".",
"let",
"!==",
"undefined",
"&&",
"element",
".",
"let",
"[",
"symbol",
"]",
"!==",
"undefined",
")",
"if",
"(",
"element",
"!==",
"undefined",
")",
"element",
".",
"let",
"[",
"symbol",
"]",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"value",
")",
")",
"}"
] | update value of topmost matching symbol on stack if any | [
"update",
"value",
"of",
"topmost",
"matching",
"symbol",
"on",
"stack",
"if",
"any"
] | 94fe7415270a6718dddc5f535f38364589a70f4f | https://github.com/ibm-functions/composer/blob/94fe7415270a6718dddc5f535f38364589a70f4f/conductor.js#L263-L266 | train |
ibm-functions/composer | composer.js | visit | function visit (composition, f) {
composition = Object.assign({}, composition) // copy
const combinator = composition['.combinator']()
if (combinator.components) {
composition.components = composition.components.map(f)
}
for (let arg of combinator.args || []) {
if (arg.type === undefined && composition[arg.name] !== undefined) {
composition[arg.name] = f(composition[arg.name], arg.name)
}
}
return new Composition(composition)
} | javascript | function visit (composition, f) {
composition = Object.assign({}, composition) // copy
const combinator = composition['.combinator']()
if (combinator.components) {
composition.components = composition.components.map(f)
}
for (let arg of combinator.args || []) {
if (arg.type === undefined && composition[arg.name] !== undefined) {
composition[arg.name] = f(composition[arg.name], arg.name)
}
}
return new Composition(composition)
} | [
"function",
"visit",
"(",
"composition",
",",
"f",
")",
"{",
"composition",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"composition",
")",
"const",
"combinator",
"=",
"composition",
"[",
"'.combinator'",
"]",
"(",
")",
"if",
"(",
"combinator",
".",
"components",
")",
"{",
"composition",
".",
"components",
"=",
"composition",
".",
"components",
".",
"map",
"(",
"f",
")",
"}",
"for",
"(",
"let",
"arg",
"of",
"combinator",
".",
"args",
"||",
"[",
"]",
")",
"{",
"if",
"(",
"arg",
".",
"type",
"===",
"undefined",
"&&",
"composition",
"[",
"arg",
".",
"name",
"]",
"!==",
"undefined",
")",
"{",
"composition",
"[",
"arg",
".",
"name",
"]",
"=",
"f",
"(",
"composition",
"[",
"arg",
".",
"name",
"]",
",",
"arg",
".",
"name",
")",
"}",
"}",
"return",
"new",
"Composition",
"(",
"composition",
")",
"}"
] | apply f to all fields of type composition | [
"apply",
"f",
"to",
"all",
"fields",
"of",
"type",
"composition"
] | 94fe7415270a6718dddc5f535f38364589a70f4f | https://github.com/ibm-functions/composer/blob/94fe7415270a6718dddc5f535f38364589a70f4f/composer.js#L121-L133 | train |
ibm-functions/composer | composer.js | label | function label (composition) {
const label = path => (composition, name, array) => {
const p = path + (name !== undefined ? (array === undefined ? `.${name}` : `[${name}]`) : '')
composition = visit(composition, label(p)) // copy
composition.path = p
return composition
}
return label('')(composition)
} | javascript | function label (composition) {
const label = path => (composition, name, array) => {
const p = path + (name !== undefined ? (array === undefined ? `.${name}` : `[${name}]`) : '')
composition = visit(composition, label(p)) // copy
composition.path = p
return composition
}
return label('')(composition)
} | [
"function",
"label",
"(",
"composition",
")",
"{",
"const",
"label",
"=",
"path",
"=>",
"(",
"composition",
",",
"name",
",",
"array",
")",
"=>",
"{",
"const",
"p",
"=",
"path",
"+",
"(",
"name",
"!==",
"undefined",
"?",
"(",
"array",
"===",
"undefined",
"?",
"`",
"${",
"name",
"}",
"`",
":",
"`",
"${",
"name",
"}",
"`",
")",
":",
"''",
")",
"composition",
"=",
"visit",
"(",
"composition",
",",
"label",
"(",
"p",
")",
")",
"composition",
".",
"path",
"=",
"p",
"return",
"composition",
"}",
"return",
"label",
"(",
"''",
")",
"(",
"composition",
")",
"}"
] | recursively label combinators with the json path | [
"recursively",
"label",
"combinators",
"with",
"the",
"json",
"path"
] | 94fe7415270a6718dddc5f535f38364589a70f4f | https://github.com/ibm-functions/composer/blob/94fe7415270a6718dddc5f535f38364589a70f4f/composer.js#L136-L144 | train |
ibm-functions/composer | composer.js | declare | function declare (combinators, prefix) {
if (arguments.length > 2) throw new ComposerError('Too many arguments in "declare"')
if (!isObject(combinators)) throw new ComposerError('Invalid argument "combinators" in "declare"', combinators)
if (prefix !== undefined && typeof prefix !== 'string') throw new ComposerError('Invalid argument "prefix" in "declare"', prefix)
const composer = {}
for (let key in combinators) {
const type = prefix ? prefix + '.' + key : key
const combinator = combinators[key]
if (!isObject(combinator) || (combinator.args !== undefined && !Array.isArray(combinator.args))) {
throw new ComposerError(`Invalid "${type}" combinator specification in "declare"`, combinator)
}
for (let arg of combinator.args || []) {
if (typeof arg.name !== 'string') throw new ComposerError(`Invalid "${type}" combinator specification in "declare"`, combinator)
}
composer[key] = function () {
const composition = { type, '.combinator': () => combinator }
const skip = (combinator.args && combinator.args.length) || 0
if (!combinator.components && (arguments.length > skip)) {
throw new ComposerError(`Too many arguments in "${type}" combinator`)
}
for (let i = 0; i < skip; ++i) {
composition[combinator.args[i].name] = arguments[i]
}
if (combinator.components) {
composition.components = Array.prototype.slice.call(arguments, skip)
}
return new Composition(composition)
}
}
return composer
} | javascript | function declare (combinators, prefix) {
if (arguments.length > 2) throw new ComposerError('Too many arguments in "declare"')
if (!isObject(combinators)) throw new ComposerError('Invalid argument "combinators" in "declare"', combinators)
if (prefix !== undefined && typeof prefix !== 'string') throw new ComposerError('Invalid argument "prefix" in "declare"', prefix)
const composer = {}
for (let key in combinators) {
const type = prefix ? prefix + '.' + key : key
const combinator = combinators[key]
if (!isObject(combinator) || (combinator.args !== undefined && !Array.isArray(combinator.args))) {
throw new ComposerError(`Invalid "${type}" combinator specification in "declare"`, combinator)
}
for (let arg of combinator.args || []) {
if (typeof arg.name !== 'string') throw new ComposerError(`Invalid "${type}" combinator specification in "declare"`, combinator)
}
composer[key] = function () {
const composition = { type, '.combinator': () => combinator }
const skip = (combinator.args && combinator.args.length) || 0
if (!combinator.components && (arguments.length > skip)) {
throw new ComposerError(`Too many arguments in "${type}" combinator`)
}
for (let i = 0; i < skip; ++i) {
composition[combinator.args[i].name] = arguments[i]
}
if (combinator.components) {
composition.components = Array.prototype.slice.call(arguments, skip)
}
return new Composition(composition)
}
}
return composer
} | [
"function",
"declare",
"(",
"combinators",
",",
"prefix",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
">",
"2",
")",
"throw",
"new",
"ComposerError",
"(",
"'Too many arguments in \"declare\"'",
")",
"if",
"(",
"!",
"isObject",
"(",
"combinators",
")",
")",
"throw",
"new",
"ComposerError",
"(",
"'Invalid argument \"combinators\" in \"declare\"'",
",",
"combinators",
")",
"if",
"(",
"prefix",
"!==",
"undefined",
"&&",
"typeof",
"prefix",
"!==",
"'string'",
")",
"throw",
"new",
"ComposerError",
"(",
"'Invalid argument \"prefix\" in \"declare\"'",
",",
"prefix",
")",
"const",
"composer",
"=",
"{",
"}",
"for",
"(",
"let",
"key",
"in",
"combinators",
")",
"{",
"const",
"type",
"=",
"prefix",
"?",
"prefix",
"+",
"'.'",
"+",
"key",
":",
"key",
"const",
"combinator",
"=",
"combinators",
"[",
"key",
"]",
"if",
"(",
"!",
"isObject",
"(",
"combinator",
")",
"||",
"(",
"combinator",
".",
"args",
"!==",
"undefined",
"&&",
"!",
"Array",
".",
"isArray",
"(",
"combinator",
".",
"args",
")",
")",
")",
"{",
"throw",
"new",
"ComposerError",
"(",
"`",
"${",
"type",
"}",
"`",
",",
"combinator",
")",
"}",
"for",
"(",
"let",
"arg",
"of",
"combinator",
".",
"args",
"||",
"[",
"]",
")",
"{",
"if",
"(",
"typeof",
"arg",
".",
"name",
"!==",
"'string'",
")",
"throw",
"new",
"ComposerError",
"(",
"`",
"${",
"type",
"}",
"`",
",",
"combinator",
")",
"}",
"composer",
"[",
"key",
"]",
"=",
"function",
"(",
")",
"{",
"const",
"composition",
"=",
"{",
"type",
",",
"'.combinator'",
":",
"(",
")",
"=>",
"combinator",
"}",
"const",
"skip",
"=",
"(",
"combinator",
".",
"args",
"&&",
"combinator",
".",
"args",
".",
"length",
")",
"||",
"0",
"if",
"(",
"!",
"combinator",
".",
"components",
"&&",
"(",
"arguments",
".",
"length",
">",
"skip",
")",
")",
"{",
"throw",
"new",
"ComposerError",
"(",
"`",
"${",
"type",
"}",
"`",
")",
"}",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"skip",
";",
"++",
"i",
")",
"{",
"composition",
"[",
"combinator",
".",
"args",
"[",
"i",
"]",
".",
"name",
"]",
"=",
"arguments",
"[",
"i",
"]",
"}",
"if",
"(",
"combinator",
".",
"components",
")",
"{",
"composition",
".",
"components",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"skip",
")",
"}",
"return",
"new",
"Composition",
"(",
"composition",
")",
"}",
"}",
"return",
"composer",
"}"
] | derive combinator methods from combinator table check argument count and map argument positions to argument names delegate to Composition constructor for the rest of the validation | [
"derive",
"combinator",
"methods",
"from",
"combinator",
"table",
"check",
"argument",
"count",
"and",
"map",
"argument",
"positions",
"to",
"argument",
"names",
"delegate",
"to",
"Composition",
"constructor",
"for",
"the",
"rest",
"of",
"the",
"validation"
] | 94fe7415270a6718dddc5f535f38364589a70f4f | https://github.com/ibm-functions/composer/blob/94fe7415270a6718dddc5f535f38364589a70f4f/composer.js#L149-L179 | train |
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(e) {
for (var i=0, ii=touches.length; i<ii; ++i) {
if (touches[i].pointerId == e.pointerId) {
touches.splice(i, 1);
break;
}
}
} | javascript | function(e) {
for (var i=0, ii=touches.length; i<ii; ++i) {
if (touches[i].pointerId == e.pointerId) {
touches.splice(i, 1);
break;
}
}
} | [
"function",
"(",
"e",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ii",
"=",
"touches",
".",
"length",
";",
"i",
"<",
"ii",
";",
"++",
"i",
")",
"{",
"if",
"(",
"touches",
"[",
"i",
"]",
".",
"pointerId",
"==",
"e",
".",
"pointerId",
")",
"{",
"touches",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"break",
";",
"}",
"}",
"}"
] | Need to also listen for end events to keep the _msTouches list accurate | [
"Need",
"to",
"also",
"listen",
"for",
"end",
"events",
"to",
"keep",
"the",
"_msTouches",
"list",
"accurate"
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L6032-L6039 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(points, firstPoint, lastPoint, tolerance){
var maxDistance = 0;
var indexFarthest = 0;
for (var index = firstPoint, distance; index < lastPoint; index++) {
distance = perpendicularDistance(points[firstPoint], points[lastPoint], points[index]);
if (distance > maxDistance) {
maxDistance = distance;
indexFarthest = index;
}
}
if (maxDistance > tolerance && indexFarthest != firstPoint) {
//Add the largest point that exceeds the tolerance
pointIndexsToKeep.push(indexFarthest);
douglasPeuckerReduction(points, firstPoint, indexFarthest, tolerance);
douglasPeuckerReduction(points, indexFarthest, lastPoint, tolerance);
}
} | javascript | function(points, firstPoint, lastPoint, tolerance){
var maxDistance = 0;
var indexFarthest = 0;
for (var index = firstPoint, distance; index < lastPoint; index++) {
distance = perpendicularDistance(points[firstPoint], points[lastPoint], points[index]);
if (distance > maxDistance) {
maxDistance = distance;
indexFarthest = index;
}
}
if (maxDistance > tolerance && indexFarthest != firstPoint) {
//Add the largest point that exceeds the tolerance
pointIndexsToKeep.push(indexFarthest);
douglasPeuckerReduction(points, firstPoint, indexFarthest, tolerance);
douglasPeuckerReduction(points, indexFarthest, lastPoint, tolerance);
}
} | [
"function",
"(",
"points",
",",
"firstPoint",
",",
"lastPoint",
",",
"tolerance",
")",
"{",
"var",
"maxDistance",
"=",
"0",
";",
"var",
"indexFarthest",
"=",
"0",
";",
"for",
"(",
"var",
"index",
"=",
"firstPoint",
",",
"distance",
";",
"index",
"<",
"lastPoint",
";",
"index",
"++",
")",
"{",
"distance",
"=",
"perpendicularDistance",
"(",
"points",
"[",
"firstPoint",
"]",
",",
"points",
"[",
"lastPoint",
"]",
",",
"points",
"[",
"index",
"]",
")",
";",
"if",
"(",
"distance",
">",
"maxDistance",
")",
"{",
"maxDistance",
"=",
"distance",
";",
"indexFarthest",
"=",
"index",
";",
"}",
"}",
"if",
"(",
"maxDistance",
">",
"tolerance",
"&&",
"indexFarthest",
"!=",
"firstPoint",
")",
"{",
"pointIndexsToKeep",
".",
"push",
"(",
"indexFarthest",
")",
";",
"douglasPeuckerReduction",
"(",
"points",
",",
"firstPoint",
",",
"indexFarthest",
",",
"tolerance",
")",
";",
"douglasPeuckerReduction",
"(",
"points",
",",
"indexFarthest",
",",
"lastPoint",
",",
"tolerance",
")",
";",
"}",
"}"
] | Private function doing the Douglas-Peucker reduction | [
"Private",
"function",
"doing",
"the",
"Douglas",
"-",
"Peucker",
"reduction"
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L21840-L21858 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function() {
var tileWidth = this.extent.getWidth() / this.map.getResolution();
var tileHeight = this.extent.getHeight() / this.map.getResolution();
this.tileSize = new OpenLayers.Size(tileWidth, tileHeight);
} | javascript | function() {
var tileWidth = this.extent.getWidth() / this.map.getResolution();
var tileHeight = this.extent.getHeight() / this.map.getResolution();
this.tileSize = new OpenLayers.Size(tileWidth, tileHeight);
} | [
"function",
"(",
")",
"{",
"var",
"tileWidth",
"=",
"this",
".",
"extent",
".",
"getWidth",
"(",
")",
"/",
"this",
".",
"map",
".",
"getResolution",
"(",
")",
";",
"var",
"tileHeight",
"=",
"this",
".",
"extent",
".",
"getHeight",
"(",
")",
"/",
"this",
".",
"map",
".",
"getResolution",
"(",
")",
";",
"this",
".",
"tileSize",
"=",
"new",
"OpenLayers",
".",
"Size",
"(",
"tileWidth",
",",
"tileHeight",
")",
";",
"}"
] | Set the tile size based on the map size. | [
"Set",
"the",
"tile",
"size",
"based",
"on",
"the",
"map",
"size",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L34702-L34706 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(x, y) {
OpenLayers.Geometry.Point.prototype.move.apply(this, arguments);
this._rotationHandle && this._rotationHandle.geometry.move(x, y);
this._handle.geometry.move(x, y);
} | javascript | function(x, y) {
OpenLayers.Geometry.Point.prototype.move.apply(this, arguments);
this._rotationHandle && this._rotationHandle.geometry.move(x, y);
this._handle.geometry.move(x, y);
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"OpenLayers",
".",
"Geometry",
".",
"Point",
".",
"prototype",
".",
"move",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"_rotationHandle",
"&&",
"this",
".",
"_rotationHandle",
".",
"geometry",
".",
"move",
"(",
"x",
",",
"y",
")",
";",
"this",
".",
"_handle",
".",
"geometry",
".",
"move",
"(",
"x",
",",
"y",
")",
";",
"}"
] | Overrides for vertex move, resize and rotate - make sure that handle and rotationHandle geometries are also moved, resized and rotated. | [
"Overrides",
"for",
"vertex",
"move",
"resize",
"and",
"rotate",
"-",
"make",
"sure",
"that",
"handle",
"and",
"rotationHandle",
"geometries",
"are",
"also",
"moved",
"resized",
"and",
"rotated",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L61723-L61727 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(x, y){
var oldX = this.x, oldY = this.y;
OpenLayers.Geometry.Point.prototype.move.call(this, x, y);
if(control._moving) {
return;
}
var evt = control.dragControl.handlers.drag.evt;
var constrain = (evt && evt.shiftKey) ? 45 : 1;
var centerGeometry = control.center;
var dx1 = this.x - centerGeometry.x;
var dy1 = this.y - centerGeometry.y;
var dx0 = dx1 - x;
var dy0 = dy1 - y;
this.x = oldX;
this.y = oldY;
var a0 = Math.atan2(dy0, dx0);
var a1 = Math.atan2(dy1, dx1);
var angle = a1 - a0;
angle *= 180 / Math.PI;
control._angle = (control._angle + angle) % 360;
var diff = control.rotation % constrain;
if(Math.abs(control._angle) >= constrain || diff !== 0) {
angle = Math.round(control._angle / constrain) * constrain -
diff;
control._angle = 0;
control.box.geometry.rotate(angle, centerGeometry);
control.transformFeature({rotation: angle});
}
} | javascript | function(x, y){
var oldX = this.x, oldY = this.y;
OpenLayers.Geometry.Point.prototype.move.call(this, x, y);
if(control._moving) {
return;
}
var evt = control.dragControl.handlers.drag.evt;
var constrain = (evt && evt.shiftKey) ? 45 : 1;
var centerGeometry = control.center;
var dx1 = this.x - centerGeometry.x;
var dy1 = this.y - centerGeometry.y;
var dx0 = dx1 - x;
var dy0 = dy1 - y;
this.x = oldX;
this.y = oldY;
var a0 = Math.atan2(dy0, dx0);
var a1 = Math.atan2(dy1, dx1);
var angle = a1 - a0;
angle *= 180 / Math.PI;
control._angle = (control._angle + angle) % 360;
var diff = control.rotation % constrain;
if(Math.abs(control._angle) >= constrain || diff !== 0) {
angle = Math.round(control._angle / constrain) * constrain -
diff;
control._angle = 0;
control.box.geometry.rotate(angle, centerGeometry);
control.transformFeature({rotation: angle});
}
} | [
"function",
"(",
"x",
",",
"y",
")",
"{",
"var",
"oldX",
"=",
"this",
".",
"x",
",",
"oldY",
"=",
"this",
".",
"y",
";",
"OpenLayers",
".",
"Geometry",
".",
"Point",
".",
"prototype",
".",
"move",
".",
"call",
"(",
"this",
",",
"x",
",",
"y",
")",
";",
"if",
"(",
"control",
".",
"_moving",
")",
"{",
"return",
";",
"}",
"var",
"evt",
"=",
"control",
".",
"dragControl",
".",
"handlers",
".",
"drag",
".",
"evt",
";",
"var",
"constrain",
"=",
"(",
"evt",
"&&",
"evt",
".",
"shiftKey",
")",
"?",
"45",
":",
"1",
";",
"var",
"centerGeometry",
"=",
"control",
".",
"center",
";",
"var",
"dx1",
"=",
"this",
".",
"x",
"-",
"centerGeometry",
".",
"x",
";",
"var",
"dy1",
"=",
"this",
".",
"y",
"-",
"centerGeometry",
".",
"y",
";",
"var",
"dx0",
"=",
"dx1",
"-",
"x",
";",
"var",
"dy0",
"=",
"dy1",
"-",
"y",
";",
"this",
".",
"x",
"=",
"oldX",
";",
"this",
".",
"y",
"=",
"oldY",
";",
"var",
"a0",
"=",
"Math",
".",
"atan2",
"(",
"dy0",
",",
"dx0",
")",
";",
"var",
"a1",
"=",
"Math",
".",
"atan2",
"(",
"dy1",
",",
"dx1",
")",
";",
"var",
"angle",
"=",
"a1",
"-",
"a0",
";",
"angle",
"*=",
"180",
"/",
"Math",
".",
"PI",
";",
"control",
".",
"_angle",
"=",
"(",
"control",
".",
"_angle",
"+",
"angle",
")",
"%",
"360",
";",
"var",
"diff",
"=",
"control",
".",
"rotation",
"%",
"constrain",
";",
"if",
"(",
"Math",
".",
"abs",
"(",
"control",
".",
"_angle",
")",
">=",
"constrain",
"||",
"diff",
"!==",
"0",
")",
"{",
"angle",
"=",
"Math",
".",
"round",
"(",
"control",
".",
"_angle",
"/",
"constrain",
")",
"*",
"constrain",
"-",
"diff",
";",
"control",
".",
"_angle",
"=",
"0",
";",
"control",
".",
"box",
".",
"geometry",
".",
"rotate",
"(",
"angle",
",",
"centerGeometry",
")",
";",
"control",
".",
"transformFeature",
"(",
"{",
"rotation",
":",
"angle",
"}",
")",
";",
"}",
"}"
] | Override for rotation handle move - make sure that the box and other handles are updated, and finally transform the feature. | [
"Override",
"for",
"rotation",
"handle",
"move",
"-",
"make",
"sure",
"that",
"the",
"box",
"and",
"other",
"handles",
"are",
"updated",
"and",
"finally",
"transform",
"the",
"feature",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L61797-L61825 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(pixel) {
if(this.feature === control.feature) {
this.feature = control.box;
}
OpenLayers.Control.DragFeature.prototype.moveFeature.apply(this,
arguments);
} | javascript | function(pixel) {
if(this.feature === control.feature) {
this.feature = control.box;
}
OpenLayers.Control.DragFeature.prototype.moveFeature.apply(this,
arguments);
} | [
"function",
"(",
"pixel",
")",
"{",
"if",
"(",
"this",
".",
"feature",
"===",
"control",
".",
"feature",
")",
"{",
"this",
".",
"feature",
"=",
"control",
".",
"box",
";",
"}",
"OpenLayers",
".",
"Control",
".",
"DragFeature",
".",
"prototype",
".",
"moveFeature",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}"
] | avoid moving the feature itself - move the box instead | [
"avoid",
"moving",
"the",
"feature",
"itself",
"-",
"move",
"the",
"box",
"instead"
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L61867-L61873 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(feature, pixel) {
if(feature === control.box) {
control.transformFeature({center: control.center});
}
} | javascript | function(feature, pixel) {
if(feature === control.box) {
control.transformFeature({center: control.center});
}
} | [
"function",
"(",
"feature",
",",
"pixel",
")",
"{",
"if",
"(",
"feature",
"===",
"control",
".",
"box",
")",
"{",
"control",
".",
"transformFeature",
"(",
"{",
"center",
":",
"control",
".",
"center",
"}",
")",
";",
"}",
"}"
] | transform while dragging | [
"transform",
"while",
"dragging"
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L61875-L61879 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(feature, pixel) {
var eligible = !control.geometryTypes ||
OpenLayers.Util.indexOf(control.geometryTypes,
feature.geometry.CLASS_NAME) !== -1;
var i = OpenLayers.Util.indexOf(control.handles, feature);
i += OpenLayers.Util.indexOf(control.rotationHandles,
feature);
if(feature !== control.feature && feature !== control.box &&
i == -2 && eligible) {
control.setFeature(feature);
}
} | javascript | function(feature, pixel) {
var eligible = !control.geometryTypes ||
OpenLayers.Util.indexOf(control.geometryTypes,
feature.geometry.CLASS_NAME) !== -1;
var i = OpenLayers.Util.indexOf(control.handles, feature);
i += OpenLayers.Util.indexOf(control.rotationHandles,
feature);
if(feature !== control.feature && feature !== control.box &&
i == -2 && eligible) {
control.setFeature(feature);
}
} | [
"function",
"(",
"feature",
",",
"pixel",
")",
"{",
"var",
"eligible",
"=",
"!",
"control",
".",
"geometryTypes",
"||",
"OpenLayers",
".",
"Util",
".",
"indexOf",
"(",
"control",
".",
"geometryTypes",
",",
"feature",
".",
"geometry",
".",
"CLASS_NAME",
")",
"!==",
"-",
"1",
";",
"var",
"i",
"=",
"OpenLayers",
".",
"Util",
".",
"indexOf",
"(",
"control",
".",
"handles",
",",
"feature",
")",
";",
"i",
"+=",
"OpenLayers",
".",
"Util",
".",
"indexOf",
"(",
"control",
".",
"rotationHandles",
",",
"feature",
")",
";",
"if",
"(",
"feature",
"!==",
"control",
".",
"feature",
"&&",
"feature",
"!==",
"control",
".",
"box",
"&&",
"i",
"==",
"-",
"2",
"&&",
"eligible",
")",
"{",
"control",
".",
"setFeature",
"(",
"feature",
")",
";",
"}",
"}"
] | set a new feature | [
"set",
"a",
"new",
"feature"
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L61881-L61892 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(str) {
var coords = OpenLayers.String.trim(str).split(this.regExes.spaces);
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(coords[0], coords[1])
);
} | javascript | function(str) {
var coords = OpenLayers.String.trim(str).split(this.regExes.spaces);
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(coords[0], coords[1])
);
} | [
"function",
"(",
"str",
")",
"{",
"var",
"coords",
"=",
"OpenLayers",
".",
"String",
".",
"trim",
"(",
"str",
")",
".",
"split",
"(",
"this",
".",
"regExes",
".",
"spaces",
")",
";",
"return",
"new",
"OpenLayers",
".",
"Feature",
".",
"Vector",
"(",
"new",
"OpenLayers",
".",
"Geometry",
".",
"Point",
"(",
"coords",
"[",
"0",
"]",
",",
"coords",
"[",
"1",
"]",
")",
")",
";",
"}"
] | Return point feature given a point WKT fragment.
@param {String} str A WKT fragment representing the point
@returns {OpenLayers.Feature.Vector} A point feature
@private | [
"Return",
"point",
"feature",
"given",
"a",
"point",
"WKT",
"fragment",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L64983-L64988 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(str) {
var point;
var points = OpenLayers.String.trim(str).split(',');
var components = [];
for(var i=0, len=points.length; i<len; ++i) {
point = points[i].replace(this.regExes.trimParens, '$1');
components.push(this.parse.point.apply(this, [point]).geometry);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.MultiPoint(components)
);
} | javascript | function(str) {
var point;
var points = OpenLayers.String.trim(str).split(',');
var components = [];
for(var i=0, len=points.length; i<len; ++i) {
point = points[i].replace(this.regExes.trimParens, '$1');
components.push(this.parse.point.apply(this, [point]).geometry);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.MultiPoint(components)
);
} | [
"function",
"(",
"str",
")",
"{",
"var",
"point",
";",
"var",
"points",
"=",
"OpenLayers",
".",
"String",
".",
"trim",
"(",
"str",
")",
".",
"split",
"(",
"','",
")",
";",
"var",
"components",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"points",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"point",
"=",
"points",
"[",
"i",
"]",
".",
"replace",
"(",
"this",
".",
"regExes",
".",
"trimParens",
",",
"'$1'",
")",
";",
"components",
".",
"push",
"(",
"this",
".",
"parse",
".",
"point",
".",
"apply",
"(",
"this",
",",
"[",
"point",
"]",
")",
".",
"geometry",
")",
";",
"}",
"return",
"new",
"OpenLayers",
".",
"Feature",
".",
"Vector",
"(",
"new",
"OpenLayers",
".",
"Geometry",
".",
"MultiPoint",
"(",
"components",
")",
")",
";",
"}"
] | Return a multipoint feature given a multipoint WKT fragment.
@param {String} str A WKT fragment representing the multipoint
@returns {OpenLayers.Feature.Vector} A multipoint feature
@private | [
"Return",
"a",
"multipoint",
"feature",
"given",
"a",
"multipoint",
"WKT",
"fragment",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L64996-L65007 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(str) {
var points = OpenLayers.String.trim(str).split(',');
var components = [];
for(var i=0, len=points.length; i<len; ++i) {
components.push(this.parse.point.apply(this, [points[i]]).geometry);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString(components)
);
} | javascript | function(str) {
var points = OpenLayers.String.trim(str).split(',');
var components = [];
for(var i=0, len=points.length; i<len; ++i) {
components.push(this.parse.point.apply(this, [points[i]]).geometry);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString(components)
);
} | [
"function",
"(",
"str",
")",
"{",
"var",
"points",
"=",
"OpenLayers",
".",
"String",
".",
"trim",
"(",
"str",
")",
".",
"split",
"(",
"','",
")",
";",
"var",
"components",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"points",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"components",
".",
"push",
"(",
"this",
".",
"parse",
".",
"point",
".",
"apply",
"(",
"this",
",",
"[",
"points",
"[",
"i",
"]",
"]",
")",
".",
"geometry",
")",
";",
"}",
"return",
"new",
"OpenLayers",
".",
"Feature",
".",
"Vector",
"(",
"new",
"OpenLayers",
".",
"Geometry",
".",
"LineString",
"(",
"components",
")",
")",
";",
"}"
] | Return a linestring feature given a linestring WKT fragment.
@param {String} str A WKT fragment representing the linestring
@returns {OpenLayers.Feature.Vector} A linestring feature
@private | [
"Return",
"a",
"linestring",
"feature",
"given",
"a",
"linestring",
"WKT",
"fragment",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L65015-L65024 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(str) {
var line;
var lines = OpenLayers.String.trim(str).split(this.regExes.parenComma);
var components = [];
for(var i=0, len=lines.length; i<len; ++i) {
line = lines[i].replace(this.regExes.trimParens, '$1');
components.push(this.parse.linestring.apply(this, [line]).geometry);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.MultiLineString(components)
);
} | javascript | function(str) {
var line;
var lines = OpenLayers.String.trim(str).split(this.regExes.parenComma);
var components = [];
for(var i=0, len=lines.length; i<len; ++i) {
line = lines[i].replace(this.regExes.trimParens, '$1');
components.push(this.parse.linestring.apply(this, [line]).geometry);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.MultiLineString(components)
);
} | [
"function",
"(",
"str",
")",
"{",
"var",
"line",
";",
"var",
"lines",
"=",
"OpenLayers",
".",
"String",
".",
"trim",
"(",
"str",
")",
".",
"split",
"(",
"this",
".",
"regExes",
".",
"parenComma",
")",
";",
"var",
"components",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"lines",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"line",
"=",
"lines",
"[",
"i",
"]",
".",
"replace",
"(",
"this",
".",
"regExes",
".",
"trimParens",
",",
"'$1'",
")",
";",
"components",
".",
"push",
"(",
"this",
".",
"parse",
".",
"linestring",
".",
"apply",
"(",
"this",
",",
"[",
"line",
"]",
")",
".",
"geometry",
")",
";",
"}",
"return",
"new",
"OpenLayers",
".",
"Feature",
".",
"Vector",
"(",
"new",
"OpenLayers",
".",
"Geometry",
".",
"MultiLineString",
"(",
"components",
")",
")",
";",
"}"
] | Return a multilinestring feature given a multilinestring WKT fragment.
@param {String} str A WKT fragment representing the multilinestring
@returns {OpenLayers.Feature.Vector} A multilinestring feature
@private | [
"Return",
"a",
"multilinestring",
"feature",
"given",
"a",
"multilinestring",
"WKT",
"fragment",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L65032-L65043 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(str) {
var ring, linestring, linearring;
var rings = OpenLayers.String.trim(str).split(this.regExes.parenComma);
var components = [];
for(var i=0, len=rings.length; i<len; ++i) {
ring = rings[i].replace(this.regExes.trimParens, '$1');
linestring = this.parse.linestring.apply(this, [ring]).geometry;
linearring = new OpenLayers.Geometry.LinearRing(linestring.components);
components.push(linearring);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Polygon(components)
);
} | javascript | function(str) {
var ring, linestring, linearring;
var rings = OpenLayers.String.trim(str).split(this.regExes.parenComma);
var components = [];
for(var i=0, len=rings.length; i<len; ++i) {
ring = rings[i].replace(this.regExes.trimParens, '$1');
linestring = this.parse.linestring.apply(this, [ring]).geometry;
linearring = new OpenLayers.Geometry.LinearRing(linestring.components);
components.push(linearring);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Polygon(components)
);
} | [
"function",
"(",
"str",
")",
"{",
"var",
"ring",
",",
"linestring",
",",
"linearring",
";",
"var",
"rings",
"=",
"OpenLayers",
".",
"String",
".",
"trim",
"(",
"str",
")",
".",
"split",
"(",
"this",
".",
"regExes",
".",
"parenComma",
")",
";",
"var",
"components",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"rings",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"ring",
"=",
"rings",
"[",
"i",
"]",
".",
"replace",
"(",
"this",
".",
"regExes",
".",
"trimParens",
",",
"'$1'",
")",
";",
"linestring",
"=",
"this",
".",
"parse",
".",
"linestring",
".",
"apply",
"(",
"this",
",",
"[",
"ring",
"]",
")",
".",
"geometry",
";",
"linearring",
"=",
"new",
"OpenLayers",
".",
"Geometry",
".",
"LinearRing",
"(",
"linestring",
".",
"components",
")",
";",
"components",
".",
"push",
"(",
"linearring",
")",
";",
"}",
"return",
"new",
"OpenLayers",
".",
"Feature",
".",
"Vector",
"(",
"new",
"OpenLayers",
".",
"Geometry",
".",
"Polygon",
"(",
"components",
")",
")",
";",
"}"
] | Return a polygon feature given a polygon WKT fragment.
@param {String} str A WKT fragment representing the polygon
@returns {OpenLayers.Feature.Vector} A polygon feature
@private | [
"Return",
"a",
"polygon",
"feature",
"given",
"a",
"polygon",
"WKT",
"fragment",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L65051-L65064 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(str) {
var polygon;
var polygons = OpenLayers.String.trim(str).split(this.regExes.doubleParenComma);
var components = [];
for(var i=0, len=polygons.length; i<len; ++i) {
polygon = polygons[i].replace(this.regExes.trimParens, '$1');
components.push(this.parse.polygon.apply(this, [polygon]).geometry);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.MultiPolygon(components)
);
} | javascript | function(str) {
var polygon;
var polygons = OpenLayers.String.trim(str).split(this.regExes.doubleParenComma);
var components = [];
for(var i=0, len=polygons.length; i<len; ++i) {
polygon = polygons[i].replace(this.regExes.trimParens, '$1');
components.push(this.parse.polygon.apply(this, [polygon]).geometry);
}
return new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.MultiPolygon(components)
);
} | [
"function",
"(",
"str",
")",
"{",
"var",
"polygon",
";",
"var",
"polygons",
"=",
"OpenLayers",
".",
"String",
".",
"trim",
"(",
"str",
")",
".",
"split",
"(",
"this",
".",
"regExes",
".",
"doubleParenComma",
")",
";",
"var",
"components",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"polygons",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"polygon",
"=",
"polygons",
"[",
"i",
"]",
".",
"replace",
"(",
"this",
".",
"regExes",
".",
"trimParens",
",",
"'$1'",
")",
";",
"components",
".",
"push",
"(",
"this",
".",
"parse",
".",
"polygon",
".",
"apply",
"(",
"this",
",",
"[",
"polygon",
"]",
")",
".",
"geometry",
")",
";",
"}",
"return",
"new",
"OpenLayers",
".",
"Feature",
".",
"Vector",
"(",
"new",
"OpenLayers",
".",
"Geometry",
".",
"MultiPolygon",
"(",
"components",
")",
")",
";",
"}"
] | Return a multipolygon feature given a multipolygon WKT fragment.
@param {String} str A WKT fragment representing the multipolygon
@returns {OpenLayers.Feature.Vector} A multipolygon feature
@private | [
"Return",
"a",
"multipolygon",
"feature",
"given",
"a",
"multipolygon",
"WKT",
"fragment",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L65072-L65083 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(str) {
// separate components of the collection with |
str = str.replace(/,\s*([A-Za-z])/g, '|$1');
var wktArray = OpenLayers.String.trim(str).split('|');
var components = [];
for(var i=0, len=wktArray.length; i<len; ++i) {
components.push(OpenLayers.Format.WKT.prototype.read.apply(this,[wktArray[i]]));
}
return components;
} | javascript | function(str) {
// separate components of the collection with |
str = str.replace(/,\s*([A-Za-z])/g, '|$1');
var wktArray = OpenLayers.String.trim(str).split('|');
var components = [];
for(var i=0, len=wktArray.length; i<len; ++i) {
components.push(OpenLayers.Format.WKT.prototype.read.apply(this,[wktArray[i]]));
}
return components;
} | [
"function",
"(",
"str",
")",
"{",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
",\\s*([A-Za-z])",
"/",
"g",
",",
"'|$1'",
")",
";",
"var",
"wktArray",
"=",
"OpenLayers",
".",
"String",
".",
"trim",
"(",
"str",
")",
".",
"split",
"(",
"'|'",
")",
";",
"var",
"components",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"wktArray",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"components",
".",
"push",
"(",
"OpenLayers",
".",
"Format",
".",
"WKT",
".",
"prototype",
".",
"read",
".",
"apply",
"(",
"this",
",",
"[",
"wktArray",
"[",
"i",
"]",
"]",
")",
")",
";",
"}",
"return",
"components",
";",
"}"
] | Return an array of features given a geometrycollection WKT fragment.
@param {String} str A WKT fragment representing the geometrycollection
@returns {Array} An array of OpenLayers.Feature.Vector
@private | [
"Return",
"an",
"array",
"of",
"features",
"given",
"a",
"geometrycollection",
"WKT",
"fragment",
"."
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L65091-L65100 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(node, obj) {
var name = node.localName || node.nodeName.split(":").pop();
if (!(OpenLayers.Util.isArray(obj[name]))) {
obj[name] = [];
}
var dc_element = {};
var attrs = node.attributes;
for(var i=0, len=attrs.length; i<len; ++i) {
dc_element[attrs[i].name] = attrs[i].nodeValue;
}
dc_element.value = this.getChildValue(node);
if (dc_element.value != "") {
obj[name].push(dc_element);
}
} | javascript | function(node, obj) {
var name = node.localName || node.nodeName.split(":").pop();
if (!(OpenLayers.Util.isArray(obj[name]))) {
obj[name] = [];
}
var dc_element = {};
var attrs = node.attributes;
for(var i=0, len=attrs.length; i<len; ++i) {
dc_element[attrs[i].name] = attrs[i].nodeValue;
}
dc_element.value = this.getChildValue(node);
if (dc_element.value != "") {
obj[name].push(dc_element);
}
} | [
"function",
"(",
"node",
",",
"obj",
")",
"{",
"var",
"name",
"=",
"node",
".",
"localName",
"||",
"node",
".",
"nodeName",
".",
"split",
"(",
"\":\"",
")",
".",
"pop",
"(",
")",
";",
"if",
"(",
"!",
"(",
"OpenLayers",
".",
"Util",
".",
"isArray",
"(",
"obj",
"[",
"name",
"]",
")",
")",
")",
"{",
"obj",
"[",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"var",
"dc_element",
"=",
"{",
"}",
";",
"var",
"attrs",
"=",
"node",
".",
"attributes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"attrs",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"dc_element",
"[",
"attrs",
"[",
"i",
"]",
".",
"name",
"]",
"=",
"attrs",
"[",
"i",
"]",
".",
"nodeValue",
";",
"}",
"dc_element",
".",
"value",
"=",
"this",
".",
"getChildValue",
"(",
"node",
")",
";",
"if",
"(",
"dc_element",
".",
"value",
"!=",
"\"\"",
")",
"{",
"obj",
"[",
"name",
"]",
".",
"push",
"(",
"dc_element",
")",
";",
"}",
"}"
] | audience, contributor, coverage, creator, date, description, format, identifier, language, provenance, publisher, relation, rights, rightsHolder, source, subject, title, type, URI | [
"audience",
"contributor",
"coverage",
"creator",
"date",
"description",
"format",
"identifier",
"language",
"provenance",
"publisher",
"relation",
"rights",
"rightsHolder",
"source",
"subject",
"title",
"type",
"URI"
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L66096-L66110 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(node, obj) {
var name = node.localName || node.nodeName.split(":").pop();
if (!(OpenLayers.Util.isArray(obj[name]))) {
obj[name] = [];
}
obj[name].push(this.getChildValue(node));
} | javascript | function(node, obj) {
var name = node.localName || node.nodeName.split(":").pop();
if (!(OpenLayers.Util.isArray(obj[name]))) {
obj[name] = [];
}
obj[name].push(this.getChildValue(node));
} | [
"function",
"(",
"node",
",",
"obj",
")",
"{",
"var",
"name",
"=",
"node",
".",
"localName",
"||",
"node",
".",
"nodeName",
".",
"split",
"(",
"\":\"",
")",
".",
"pop",
"(",
")",
";",
"if",
"(",
"!",
"(",
"OpenLayers",
".",
"Util",
".",
"isArray",
"(",
"obj",
"[",
"name",
"]",
")",
")",
")",
"{",
"obj",
"[",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"obj",
"[",
"name",
"]",
".",
"push",
"(",
"this",
".",
"getChildValue",
"(",
"node",
")",
")",
";",
"}"
] | abstract, modified, spatial | [
"abstract",
"modified",
"spatial"
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L66114-L66120 | train |
|
Tamersoul/magic-wand-js | jsfiddle/OpenLayers.debug.js | function(theDiv, options) {
var topRico = theDiv.parentNode.childNodes[0];
//theDiv would be theDiv.parentNode.childNodes[1]
var bottomRico = theDiv.parentNode.childNodes[2];
theDiv.parentNode.removeChild(topRico);
theDiv.parentNode.removeChild(bottomRico);
this.round(theDiv.parentNode, options);
} | javascript | function(theDiv, options) {
var topRico = theDiv.parentNode.childNodes[0];
//theDiv would be theDiv.parentNode.childNodes[1]
var bottomRico = theDiv.parentNode.childNodes[2];
theDiv.parentNode.removeChild(topRico);
theDiv.parentNode.removeChild(bottomRico);
this.round(theDiv.parentNode, options);
} | [
"function",
"(",
"theDiv",
",",
"options",
")",
"{",
"var",
"topRico",
"=",
"theDiv",
".",
"parentNode",
".",
"childNodes",
"[",
"0",
"]",
";",
"var",
"bottomRico",
"=",
"theDiv",
".",
"parentNode",
".",
"childNodes",
"[",
"2",
"]",
";",
"theDiv",
".",
"parentNode",
".",
"removeChild",
"(",
"topRico",
")",
";",
"theDiv",
".",
"parentNode",
".",
"removeChild",
"(",
"bottomRico",
")",
";",
"this",
".",
"round",
"(",
"theDiv",
".",
"parentNode",
",",
"options",
")",
";",
"}"
] | this function takes care of redoing the rico cornering
you can't just call updateRicoCorners() again and pass it a
new options string. you have to first remove the divs that
rico puts on top and below the content div.
@param {DOM} theDiv - A child of the outer <div> that was
supplied to the `round` method.
@param {Object} options - list of options | [
"this",
"function",
"takes",
"care",
"of",
"redoing",
"the",
"rico",
"cornering"
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/jsfiddle/OpenLayers.debug.js#L78894-L78904 | train |
|
Tamersoul/magic-wand-js | js/ol-magic-wand.js | function (image, old) {
var data1 = old.data,
data2 = image.data,
w1 = old.width,
w2 = image.width,
px1 = old.globalOffset.x,
py1 = old.globalOffset.y,
px2 = image.globalOffset.x,
py2 = image.globalOffset.y,
b1 = old.bounds,
b2 = image.bounds,
px = Math.min(b1.minX + px1, b2.minX + px2), // global offset for new image (by min in bounds)
py = Math.min(b1.minY + py1, b2.minY + py2),
b = { // bounds for new image include all of the pixels [0,0,width,height] (reduce to bounds)
minX: 0,
minY: 0,
maxX: Math.max(b1.maxX + px1, b2.maxX + px2) - px,
maxY: Math.max(b1.maxY + py1, b2.maxY + py2) - py,
},
w = b.maxX + 1, // size for new image
h = b.maxY + 1,
i, j, k, k1, k2, len;
var result = new Uint8Array(w * h);
// copy all old image
len = b1.maxX - b1.minX + 1;
i = (py1 - py + b1.minY) * w + (px1 - px + b1.minX);
k1 = b1.minY * w1 + b1.minX;
k2 = b1.maxY * w1 + b1.minX + 1;
// walk through rows (Y)
for (k = k1; k < k2; k += w1) {
result.set(data1.subarray(k, k + len), i); // copy row
i += w;
}
// copy new image (only "black" pixels)
len = b2.maxX - b2.minX + 1;
i = (py2 - py + b2.minY) * w + (px2 - px + b2.minX);
k1 = b2.minY * w2 + b2.minX;
k2 = b2.maxY * w2 + b2.minX + 1;
// walk through rows (Y)
for (k = k1; k < k2; k += w2) {
// walk through cols (X)
for (j = 0; j < len; j++) {
if (data2[k + j] === 1) result[i + j] = 1;
}
i += w;
}
return {
data: result,
width: w,
height: h,
bounds: b,
globalOffset: {
x: px,
y: py,
}
};
} | javascript | function (image, old) {
var data1 = old.data,
data2 = image.data,
w1 = old.width,
w2 = image.width,
px1 = old.globalOffset.x,
py1 = old.globalOffset.y,
px2 = image.globalOffset.x,
py2 = image.globalOffset.y,
b1 = old.bounds,
b2 = image.bounds,
px = Math.min(b1.minX + px1, b2.minX + px2), // global offset for new image (by min in bounds)
py = Math.min(b1.minY + py1, b2.minY + py2),
b = { // bounds for new image include all of the pixels [0,0,width,height] (reduce to bounds)
minX: 0,
minY: 0,
maxX: Math.max(b1.maxX + px1, b2.maxX + px2) - px,
maxY: Math.max(b1.maxY + py1, b2.maxY + py2) - py,
},
w = b.maxX + 1, // size for new image
h = b.maxY + 1,
i, j, k, k1, k2, len;
var result = new Uint8Array(w * h);
// copy all old image
len = b1.maxX - b1.minX + 1;
i = (py1 - py + b1.minY) * w + (px1 - px + b1.minX);
k1 = b1.minY * w1 + b1.minX;
k2 = b1.maxY * w1 + b1.minX + 1;
// walk through rows (Y)
for (k = k1; k < k2; k += w1) {
result.set(data1.subarray(k, k + len), i); // copy row
i += w;
}
// copy new image (only "black" pixels)
len = b2.maxX - b2.minX + 1;
i = (py2 - py + b2.minY) * w + (px2 - px + b2.minX);
k1 = b2.minY * w2 + b2.minX;
k2 = b2.maxY * w2 + b2.minX + 1;
// walk through rows (Y)
for (k = k1; k < k2; k += w2) {
// walk through cols (X)
for (j = 0; j < len; j++) {
if (data2[k + j] === 1) result[i + j] = 1;
}
i += w;
}
return {
data: result,
width: w,
height: h,
bounds: b,
globalOffset: {
x: px,
y: py,
}
};
} | [
"function",
"(",
"image",
",",
"old",
")",
"{",
"var",
"data1",
"=",
"old",
".",
"data",
",",
"data2",
"=",
"image",
".",
"data",
",",
"w1",
"=",
"old",
".",
"width",
",",
"w2",
"=",
"image",
".",
"width",
",",
"px1",
"=",
"old",
".",
"globalOffset",
".",
"x",
",",
"py1",
"=",
"old",
".",
"globalOffset",
".",
"y",
",",
"px2",
"=",
"image",
".",
"globalOffset",
".",
"x",
",",
"py2",
"=",
"image",
".",
"globalOffset",
".",
"y",
",",
"b1",
"=",
"old",
".",
"bounds",
",",
"b2",
"=",
"image",
".",
"bounds",
",",
"px",
"=",
"Math",
".",
"min",
"(",
"b1",
".",
"minX",
"+",
"px1",
",",
"b2",
".",
"minX",
"+",
"px2",
")",
",",
"py",
"=",
"Math",
".",
"min",
"(",
"b1",
".",
"minY",
"+",
"py1",
",",
"b2",
".",
"minY",
"+",
"py2",
")",
",",
"b",
"=",
"{",
"minX",
":",
"0",
",",
"minY",
":",
"0",
",",
"maxX",
":",
"Math",
".",
"max",
"(",
"b1",
".",
"maxX",
"+",
"px1",
",",
"b2",
".",
"maxX",
"+",
"px2",
")",
"-",
"px",
",",
"maxY",
":",
"Math",
".",
"max",
"(",
"b1",
".",
"maxY",
"+",
"py1",
",",
"b2",
".",
"maxY",
"+",
"py2",
")",
"-",
"py",
",",
"}",
",",
"w",
"=",
"b",
".",
"maxX",
"+",
"1",
",",
"h",
"=",
"b",
".",
"maxY",
"+",
"1",
",",
"i",
",",
"j",
",",
"k",
",",
"k1",
",",
"k2",
",",
"len",
";",
"var",
"result",
"=",
"new",
"Uint8Array",
"(",
"w",
"*",
"h",
")",
";",
"len",
"=",
"b1",
".",
"maxX",
"-",
"b1",
".",
"minX",
"+",
"1",
";",
"i",
"=",
"(",
"py1",
"-",
"py",
"+",
"b1",
".",
"minY",
")",
"*",
"w",
"+",
"(",
"px1",
"-",
"px",
"+",
"b1",
".",
"minX",
")",
";",
"k1",
"=",
"b1",
".",
"minY",
"*",
"w1",
"+",
"b1",
".",
"minX",
";",
"k2",
"=",
"b1",
".",
"maxY",
"*",
"w1",
"+",
"b1",
".",
"minX",
"+",
"1",
";",
"for",
"(",
"k",
"=",
"k1",
";",
"k",
"<",
"k2",
";",
"k",
"+=",
"w1",
")",
"{",
"result",
".",
"set",
"(",
"data1",
".",
"subarray",
"(",
"k",
",",
"k",
"+",
"len",
")",
",",
"i",
")",
";",
"i",
"+=",
"w",
";",
"}",
"len",
"=",
"b2",
".",
"maxX",
"-",
"b2",
".",
"minX",
"+",
"1",
";",
"i",
"=",
"(",
"py2",
"-",
"py",
"+",
"b2",
".",
"minY",
")",
"*",
"w",
"+",
"(",
"px2",
"-",
"px",
"+",
"b2",
".",
"minX",
")",
";",
"k1",
"=",
"b2",
".",
"minY",
"*",
"w2",
"+",
"b2",
".",
"minX",
";",
"k2",
"=",
"b2",
".",
"maxY",
"*",
"w2",
"+",
"b2",
".",
"minX",
"+",
"1",
";",
"for",
"(",
"k",
"=",
"k1",
";",
"k",
"<",
"k2",
";",
"k",
"+=",
"w2",
")",
"{",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"len",
";",
"j",
"++",
")",
"{",
"if",
"(",
"data2",
"[",
"k",
"+",
"j",
"]",
"===",
"1",
")",
"result",
"[",
"i",
"+",
"j",
"]",
"=",
"1",
";",
"}",
"i",
"+=",
"w",
";",
"}",
"return",
"{",
"data",
":",
"result",
",",
"width",
":",
"w",
",",
"height",
":",
"h",
",",
"bounds",
":",
"b",
",",
"globalOffset",
":",
"{",
"x",
":",
"px",
",",
"y",
":",
"py",
",",
"}",
"}",
";",
"}"
] | return concatenation of image and old masks | [
"return",
"concatenation",
"of",
"image",
"and",
"old",
"masks"
] | 39d50ec17bfc060f2d360537a26a9420dd8970b6 | https://github.com/Tamersoul/magic-wand-js/blob/39d50ec17bfc060f2d360537a26a9420dd8970b6/js/ol-magic-wand.js#L1474-L1534 | train |
|
esosedi/regions | src/utils/setupGeometry.js | setupGeometry | function setupGeometry(regionsData, options) {
options = options || {};
var regions = regionsData.regions,
dataset = [],
postFilter =
options.postFilter ||
(regionsData.meta && regionsData.meta.postFilter
? new Function("region", regionsData.meta.postFilter)
: 0),
scheme = options.scheme || (regionsData.meta && regionsData.meta.scheme),
disputedBorders =
(regionsData.meta && regionsData.meta.disputedBorders) || {},
useSetup = options.recombine || options.lang || "en",
disputedBorder =
typeof useSetup == "string" ? disputedBorders[useSetup] : useSetup,
geometry = 0;
for (const i in disputedBorders) {
var setup = disputedBorders[i];
for (const j in setup) {
var regionSet = setup[j];
if (typeof regionSet == "string") {
setup[j] = new Function("region", regionSet);
}
}
}
for (const i in regions) {
if (regions.hasOwnProperty(i)) {
if (!postFilter || postFilter(wrapRegion(i, regionsData))) {
if (disputedBorder && disputedBorder[+i]) {
geometry = recombineRegion(regionsData, {
filter: disputedBorder[+i]
});
} else if (scheme && scheme[+i]) {
var sch = scheme[+i];
geometry = recombineRegion(regionsData, {
filter: typeof sch == "string" ? new Function("region", sch) : sch
});
} else {
geometry = getGeometry(+i, regionsData);
}
if (geometry) {
dataset[regions[i].index] = {
type: "Feature",
geometry: geometry,
properties: {
osmId: i,
level: regions[i].level,
properties: regions[i].property || {},
parents: regions[i].parents,
hintContent: regions[i].name,
name: regions[i].name,
title: regions[i].name,
wikipedia: regions[i].wikipedia,
orderIndex: regions[i].index,
square: regions[i].square
}
};
}
}
}
}
var result = [];
for (var i = 0, l = dataset.length; i < l; ++i) {
if (dataset[i]) {
result.push(dataset[i]);
}
}
return result;
} | javascript | function setupGeometry(regionsData, options) {
options = options || {};
var regions = regionsData.regions,
dataset = [],
postFilter =
options.postFilter ||
(regionsData.meta && regionsData.meta.postFilter
? new Function("region", regionsData.meta.postFilter)
: 0),
scheme = options.scheme || (regionsData.meta && regionsData.meta.scheme),
disputedBorders =
(regionsData.meta && regionsData.meta.disputedBorders) || {},
useSetup = options.recombine || options.lang || "en",
disputedBorder =
typeof useSetup == "string" ? disputedBorders[useSetup] : useSetup,
geometry = 0;
for (const i in disputedBorders) {
var setup = disputedBorders[i];
for (const j in setup) {
var regionSet = setup[j];
if (typeof regionSet == "string") {
setup[j] = new Function("region", regionSet);
}
}
}
for (const i in regions) {
if (regions.hasOwnProperty(i)) {
if (!postFilter || postFilter(wrapRegion(i, regionsData))) {
if (disputedBorder && disputedBorder[+i]) {
geometry = recombineRegion(regionsData, {
filter: disputedBorder[+i]
});
} else if (scheme && scheme[+i]) {
var sch = scheme[+i];
geometry = recombineRegion(regionsData, {
filter: typeof sch == "string" ? new Function("region", sch) : sch
});
} else {
geometry = getGeometry(+i, regionsData);
}
if (geometry) {
dataset[regions[i].index] = {
type: "Feature",
geometry: geometry,
properties: {
osmId: i,
level: regions[i].level,
properties: regions[i].property || {},
parents: regions[i].parents,
hintContent: regions[i].name,
name: regions[i].name,
title: regions[i].name,
wikipedia: regions[i].wikipedia,
orderIndex: regions[i].index,
square: regions[i].square
}
};
}
}
}
}
var result = [];
for (var i = 0, l = dataset.length; i < l; ++i) {
if (dataset[i]) {
result.push(dataset[i]);
}
}
return result;
} | [
"function",
"setupGeometry",
"(",
"regionsData",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"regions",
"=",
"regionsData",
".",
"regions",
",",
"dataset",
"=",
"[",
"]",
",",
"postFilter",
"=",
"options",
".",
"postFilter",
"||",
"(",
"regionsData",
".",
"meta",
"&&",
"regionsData",
".",
"meta",
".",
"postFilter",
"?",
"new",
"Function",
"(",
"\"region\"",
",",
"regionsData",
".",
"meta",
".",
"postFilter",
")",
":",
"0",
")",
",",
"scheme",
"=",
"options",
".",
"scheme",
"||",
"(",
"regionsData",
".",
"meta",
"&&",
"regionsData",
".",
"meta",
".",
"scheme",
")",
",",
"disputedBorders",
"=",
"(",
"regionsData",
".",
"meta",
"&&",
"regionsData",
".",
"meta",
".",
"disputedBorders",
")",
"||",
"{",
"}",
",",
"useSetup",
"=",
"options",
".",
"recombine",
"||",
"options",
".",
"lang",
"||",
"\"en\"",
",",
"disputedBorder",
"=",
"typeof",
"useSetup",
"==",
"\"string\"",
"?",
"disputedBorders",
"[",
"useSetup",
"]",
":",
"useSetup",
",",
"geometry",
"=",
"0",
";",
"for",
"(",
"const",
"i",
"in",
"disputedBorders",
")",
"{",
"var",
"setup",
"=",
"disputedBorders",
"[",
"i",
"]",
";",
"for",
"(",
"const",
"j",
"in",
"setup",
")",
"{",
"var",
"regionSet",
"=",
"setup",
"[",
"j",
"]",
";",
"if",
"(",
"typeof",
"regionSet",
"==",
"\"string\"",
")",
"{",
"setup",
"[",
"j",
"]",
"=",
"new",
"Function",
"(",
"\"region\"",
",",
"regionSet",
")",
";",
"}",
"}",
"}",
"for",
"(",
"const",
"i",
"in",
"regions",
")",
"{",
"if",
"(",
"regions",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"{",
"if",
"(",
"!",
"postFilter",
"||",
"postFilter",
"(",
"wrapRegion",
"(",
"i",
",",
"regionsData",
")",
")",
")",
"{",
"if",
"(",
"disputedBorder",
"&&",
"disputedBorder",
"[",
"+",
"i",
"]",
")",
"{",
"geometry",
"=",
"recombineRegion",
"(",
"regionsData",
",",
"{",
"filter",
":",
"disputedBorder",
"[",
"+",
"i",
"]",
"}",
")",
";",
"}",
"else",
"if",
"(",
"scheme",
"&&",
"scheme",
"[",
"+",
"i",
"]",
")",
"{",
"var",
"sch",
"=",
"scheme",
"[",
"+",
"i",
"]",
";",
"geometry",
"=",
"recombineRegion",
"(",
"regionsData",
",",
"{",
"filter",
":",
"typeof",
"sch",
"==",
"\"string\"",
"?",
"new",
"Function",
"(",
"\"region\"",
",",
"sch",
")",
":",
"sch",
"}",
")",
";",
"}",
"else",
"{",
"geometry",
"=",
"getGeometry",
"(",
"+",
"i",
",",
"regionsData",
")",
";",
"}",
"if",
"(",
"geometry",
")",
"{",
"dataset",
"[",
"regions",
"[",
"i",
"]",
".",
"index",
"]",
"=",
"{",
"type",
":",
"\"Feature\"",
",",
"geometry",
":",
"geometry",
",",
"properties",
":",
"{",
"osmId",
":",
"i",
",",
"level",
":",
"regions",
"[",
"i",
"]",
".",
"level",
",",
"properties",
":",
"regions",
"[",
"i",
"]",
".",
"property",
"||",
"{",
"}",
",",
"parents",
":",
"regions",
"[",
"i",
"]",
".",
"parents",
",",
"hintContent",
":",
"regions",
"[",
"i",
"]",
".",
"name",
",",
"name",
":",
"regions",
"[",
"i",
"]",
".",
"name",
",",
"title",
":",
"regions",
"[",
"i",
"]",
".",
"name",
",",
"wikipedia",
":",
"regions",
"[",
"i",
"]",
".",
"wikipedia",
",",
"orderIndex",
":",
"regions",
"[",
"i",
"]",
".",
"index",
",",
"square",
":",
"regions",
"[",
"i",
"]",
".",
"square",
"}",
"}",
";",
"}",
"}",
"}",
"}",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"dataset",
".",
"length",
";",
"i",
"<",
"l",
";",
"++",
"i",
")",
"{",
"if",
"(",
"dataset",
"[",
"i",
"]",
")",
"{",
"result",
".",
"push",
"(",
"dataset",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | main decode function
@param regionsData
@param options
@returns {Array} | [
"main",
"decode",
"function"
] | d23acc7c1ee687b6111750b0ea26d1aa565f87a8 | https://github.com/esosedi/regions/blob/d23acc7c1ee687b6111750b0ea26d1aa565f87a8/src/utils/setupGeometry.js#L11-L82 | train |
esosedi/regions | src/utils/decoder.js | decodeByteVector | function decodeByteVector(x, N) {
var point = 0;
for (var i = 0; i < N; ++i) {
point |= x.charCodeAt(i) << (i * 8);
}
return point;
} | javascript | function decodeByteVector(x, N) {
var point = 0;
for (var i = 0; i < N; ++i) {
point |= x.charCodeAt(i) << (i * 8);
}
return point;
} | [
"function",
"decodeByteVector",
"(",
"x",
",",
"N",
")",
"{",
"var",
"point",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"N",
";",
"++",
"i",
")",
"{",
"point",
"|=",
"x",
".",
"charCodeAt",
"(",
"i",
")",
"<<",
"(",
"i",
"*",
"8",
")",
";",
"}",
"return",
"point",
";",
"}"
] | target resolution 65k, real 4k
coordinateDecode
partof Yandex.Maps.API | [
"target",
"resolution",
"65k",
"real",
"4k",
"coordinateDecode",
"partof",
"Yandex",
".",
"Maps",
".",
"API"
] | d23acc7c1ee687b6111750b0ea26d1aa565f87a8 | https://github.com/esosedi/regions/blob/d23acc7c1ee687b6111750b0ea26d1aa565f87a8/src/utils/decoder.js#L9-L15 | train |
esosedi/regions | src/utils/region.js | wrapRegion | function wrapRegion(rid, data) {
var meta = data.regions[rid],
prop = meta.property || {};
return new RegionObject(rid, meta, prop, data);
} | javascript | function wrapRegion(rid, data) {
var meta = data.regions[rid],
prop = meta.property || {};
return new RegionObject(rid, meta, prop, data);
} | [
"function",
"wrapRegion",
"(",
"rid",
",",
"data",
")",
"{",
"var",
"meta",
"=",
"data",
".",
"regions",
"[",
"rid",
"]",
",",
"prop",
"=",
"meta",
".",
"property",
"||",
"{",
"}",
";",
"return",
"new",
"RegionObject",
"(",
"rid",
",",
"meta",
",",
"prop",
",",
"data",
")",
";",
"}"
] | wraps region for filter functions
@param rid
@param data
@returns {RegionObject} | [
"wraps",
"region",
"for",
"filter",
"functions"
] | d23acc7c1ee687b6111750b0ea26d1aa565f87a8 | https://github.com/esosedi/regions/blob/d23acc7c1ee687b6111750b0ea26d1aa565f87a8/src/utils/region.js#L90-L94 | train |
esosedi/regions | src/utils/load_native.js | load | function load(path, callback, errorCallback) {
try {
var xhr = new XMLHttpRequest();
xhr.open("GET", path, true);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 304) {
try {
var response = JSON.parse(xhr.responseText);
callback(response);
} catch (e) {
errorCallback(e);
}
} else {
errorCallback(xhr);
}
}
};
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send();
} catch (e) {
errorCallback(e);
}
} | javascript | function load(path, callback, errorCallback) {
try {
var xhr = new XMLHttpRequest();
xhr.open("GET", path, true);
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 304) {
try {
var response = JSON.parse(xhr.responseText);
callback(response);
} catch (e) {
errorCallback(e);
}
} else {
errorCallback(xhr);
}
}
};
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send();
} catch (e) {
errorCallback(e);
}
} | [
"function",
"load",
"(",
"path",
",",
"callback",
",",
"errorCallback",
")",
"{",
"try",
"{",
"var",
"xhr",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"xhr",
".",
"open",
"(",
"\"GET\"",
",",
"path",
",",
"true",
")",
";",
"xhr",
".",
"onreadystatechange",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"xhr",
".",
"readyState",
"===",
"4",
")",
"{",
"if",
"(",
"xhr",
".",
"status",
"===",
"200",
"||",
"xhr",
".",
"status",
"===",
"304",
")",
"{",
"try",
"{",
"var",
"response",
"=",
"JSON",
".",
"parse",
"(",
"xhr",
".",
"responseText",
")",
";",
"callback",
"(",
"response",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"errorCallback",
"(",
"e",
")",
";",
"}",
"}",
"else",
"{",
"errorCallback",
"(",
"xhr",
")",
";",
"}",
"}",
"}",
";",
"xhr",
".",
"setRequestHeader",
"(",
"\"Content-Type\"",
",",
"\"application/json\"",
")",
";",
"xhr",
".",
"setRequestHeader",
"(",
"\"X-Requested-With\"",
",",
"\"XMLHttpRequest\"",
")",
";",
"xhr",
".",
"send",
"(",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"errorCallback",
"(",
"e",
")",
";",
"}",
"}"
] | Vanilla Ajax data transfer
@param {String} path
@param {Function} callback
@param {Function} errorCallback | [
"Vanilla",
"Ajax",
"data",
"transfer"
] | d23acc7c1ee687b6111750b0ea26d1aa565f87a8 | https://github.com/esosedi/regions/blob/d23acc7c1ee687b6111750b0ea26d1aa565f87a8/src/utils/load_native.js#L7-L31 | train |
Siyfion/angular-typeahead | angular-typeahead.js | getDatumValue | function getDatumValue(datum) {
for (var i in datasets) {
var dataset = datasets[i];
var displayKey = dataset.displayKey || 'value';
var value = (angular.isFunction(displayKey) ? displayKey(datum) : datum[displayKey]) || '';
return value;
}
} | javascript | function getDatumValue(datum) {
for (var i in datasets) {
var dataset = datasets[i];
var displayKey = dataset.displayKey || 'value';
var value = (angular.isFunction(displayKey) ? displayKey(datum) : datum[displayKey]) || '';
return value;
}
} | [
"function",
"getDatumValue",
"(",
"datum",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"datasets",
")",
"{",
"var",
"dataset",
"=",
"datasets",
"[",
"i",
"]",
";",
"var",
"displayKey",
"=",
"dataset",
".",
"displayKey",
"||",
"'value'",
";",
"var",
"value",
"=",
"(",
"angular",
".",
"isFunction",
"(",
"displayKey",
")",
"?",
"displayKey",
"(",
"datum",
")",
":",
"datum",
"[",
"displayKey",
"]",
")",
"||",
"''",
";",
"return",
"value",
";",
"}",
"}"
] | Returns the string to be displayed given some datum | [
"Returns",
"the",
"string",
"to",
"be",
"displayed",
"given",
"some",
"datum"
] | 742a609d1898e972652b9141a9011b0347faa5fd | https://github.com/Siyfion/angular-typeahead/blob/742a609d1898e972652b9141a9011b0347faa5fd/angular-typeahead.js#L110-L117 | train |
evothings/cordova-eddystone | js/eddystone-plugin.js | parseFrameUID | function parseFrameUID(device, data, win, fail)
{
if(data[0] != 0x00) return false;
// The UID frame has 18 bytes + 2 bytes reserved for future use
// https://github.com/google/eddystone/tree/master/eddystone-uid
// Check that we got at least 18 bytes.
if(data.byteLength < 18)
{
fail("UID frame: invalid byteLength: "+data.byteLength);
return true;
}
device.txPower = evothings.util.littleEndianToInt8(data, 1);
device.nid = data.subarray(2, 12); // Namespace ID.
device.bid = data.subarray(12, 18); // Beacon ID.
win(device);
return true;
} | javascript | function parseFrameUID(device, data, win, fail)
{
if(data[0] != 0x00) return false;
// The UID frame has 18 bytes + 2 bytes reserved for future use
// https://github.com/google/eddystone/tree/master/eddystone-uid
// Check that we got at least 18 bytes.
if(data.byteLength < 18)
{
fail("UID frame: invalid byteLength: "+data.byteLength);
return true;
}
device.txPower = evothings.util.littleEndianToInt8(data, 1);
device.nid = data.subarray(2, 12); // Namespace ID.
device.bid = data.subarray(12, 18); // Beacon ID.
win(device);
return true;
} | [
"function",
"parseFrameUID",
"(",
"device",
",",
"data",
",",
"win",
",",
"fail",
")",
"{",
"if",
"(",
"data",
"[",
"0",
"]",
"!=",
"0x00",
")",
"return",
"false",
";",
"if",
"(",
"data",
".",
"byteLength",
"<",
"18",
")",
"{",
"fail",
"(",
"\"UID frame: invalid byteLength: \"",
"+",
"data",
".",
"byteLength",
")",
";",
"return",
"true",
";",
"}",
"device",
".",
"txPower",
"=",
"evothings",
".",
"util",
".",
"littleEndianToInt8",
"(",
"data",
",",
"1",
")",
";",
"device",
".",
"nid",
"=",
"data",
".",
"subarray",
"(",
"2",
",",
"12",
")",
";",
"device",
".",
"bid",
"=",
"data",
".",
"subarray",
"(",
"12",
",",
"18",
")",
";",
"win",
"(",
"device",
")",
";",
"return",
"true",
";",
"}"
] | Return true on frame type recognition, false otherwise. | [
"Return",
"true",
"on",
"frame",
"type",
"recognition",
"false",
"otherwise",
"."
] | 2a24a4e24004a2392b9f1c494c775b7d713f1bf2 | https://github.com/evothings/cordova-eddystone/blob/2a24a4e24004a2392b9f1c494c775b7d713f1bf2/js/eddystone-plugin.js#L2322-L2342 | train |
swarajban/npm-cache | cacheDependencyManagers/npmConfig.js | function () {
var shrinkWrapPath = path.resolve(process.cwd(), 'npm-shrinkwrap.json');
if (fs.existsSync(shrinkWrapPath)) {
logger.logInfo('[npm] using npm-shrinkwrap.json instead of package.json');
return shrinkWrapPath;
}
if (getNpmMajorVersion() >= 5) {
var packageLockPath = path.resolve(process.cwd(), 'package-lock.json');
if (fs.existsSync(packageLockPath)) {
logger.logInfo('[npm] using package-lock.json instead of package.json');
return packageLockPath;
}
}
var packagePath = path.resolve(process.cwd(), 'package.json');
return packagePath;
} | javascript | function () {
var shrinkWrapPath = path.resolve(process.cwd(), 'npm-shrinkwrap.json');
if (fs.existsSync(shrinkWrapPath)) {
logger.logInfo('[npm] using npm-shrinkwrap.json instead of package.json');
return shrinkWrapPath;
}
if (getNpmMajorVersion() >= 5) {
var packageLockPath = path.resolve(process.cwd(), 'package-lock.json');
if (fs.existsSync(packageLockPath)) {
logger.logInfo('[npm] using package-lock.json instead of package.json');
return packageLockPath;
}
}
var packagePath = path.resolve(process.cwd(), 'package.json');
return packagePath;
} | [
"function",
"(",
")",
"{",
"var",
"shrinkWrapPath",
"=",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"'npm-shrinkwrap.json'",
")",
";",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"shrinkWrapPath",
")",
")",
"{",
"logger",
".",
"logInfo",
"(",
"'[npm] using npm-shrinkwrap.json instead of package.json'",
")",
";",
"return",
"shrinkWrapPath",
";",
"}",
"if",
"(",
"getNpmMajorVersion",
"(",
")",
">=",
"5",
")",
"{",
"var",
"packageLockPath",
"=",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"'package-lock.json'",
")",
";",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"packageLockPath",
")",
")",
"{",
"logger",
".",
"logInfo",
"(",
"'[npm] using package-lock.json instead of package.json'",
")",
";",
"return",
"packageLockPath",
";",
"}",
"}",
"var",
"packagePath",
"=",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"'package.json'",
")",
";",
"return",
"packagePath",
";",
"}"
] | Returns path to configuration file for npm. Uses - npm-shrinkwrap.json if it exists; otherwise, - package-lock.json if it exists and npm >= 5; otherwise, - defaults to package.json | [
"Returns",
"path",
"to",
"configuration",
"file",
"for",
"npm",
".",
"Uses",
"-",
"npm",
"-",
"shrinkwrap",
".",
"json",
"if",
"it",
"exists",
";",
"otherwise",
"-",
"package",
"-",
"lock",
".",
"json",
"if",
"it",
"exists",
"and",
"npm",
">",
"=",
"5",
";",
"otherwise",
"-",
"defaults",
"to",
"package",
".",
"json"
] | de60eb445f3b7c0c62106f7cc2f98cabcfd9fd2c | https://github.com/swarajban/npm-cache/blob/de60eb445f3b7c0c62106f7cc2f98cabcfd9fd2c/cacheDependencyManagers/npmConfig.js#L21-L38 | train |
|
swarajban/npm-cache | cacheDependencyManagers/composerConfig.js | function () {
var composerLockPath = path.resolve(process.cwd(), 'composer.lock');
var composerJsonPath = path.resolve(process.cwd(), 'composer.json');
if (isUsingComposerLock === null) {
if (fs.existsSync(composerLockPath)) {
logger.logInfo('[composer] using composer.lock instead of composer.json');
isUsingComposerLock = true;
} else {
isUsingComposerLock = false;
}
}
return isUsingComposerLock ? composerLockPath : composerJsonPath;
} | javascript | function () {
var composerLockPath = path.resolve(process.cwd(), 'composer.lock');
var composerJsonPath = path.resolve(process.cwd(), 'composer.json');
if (isUsingComposerLock === null) {
if (fs.existsSync(composerLockPath)) {
logger.logInfo('[composer] using composer.lock instead of composer.json');
isUsingComposerLock = true;
} else {
isUsingComposerLock = false;
}
}
return isUsingComposerLock ? composerLockPath : composerJsonPath;
} | [
"function",
"(",
")",
"{",
"var",
"composerLockPath",
"=",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"'composer.lock'",
")",
";",
"var",
"composerJsonPath",
"=",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"'composer.json'",
")",
";",
"if",
"(",
"isUsingComposerLock",
"===",
"null",
")",
"{",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"composerLockPath",
")",
")",
"{",
"logger",
".",
"logInfo",
"(",
"'[composer] using composer.lock instead of composer.json'",
")",
";",
"isUsingComposerLock",
"=",
"true",
";",
"}",
"else",
"{",
"isUsingComposerLock",
"=",
"false",
";",
"}",
"}",
"return",
"isUsingComposerLock",
"?",
"composerLockPath",
":",
"composerJsonPath",
";",
"}"
] | Returns path to configuration file for composer. Uses composer.lock if it exists; otherwise, defaults to composer.json | [
"Returns",
"path",
"to",
"configuration",
"file",
"for",
"composer",
".",
"Uses",
"composer",
".",
"lock",
"if",
"it",
"exists",
";",
"otherwise",
"defaults",
"to",
"composer",
".",
"json"
] | de60eb445f3b7c0c62106f7cc2f98cabcfd9fd2c | https://github.com/swarajban/npm-cache/blob/de60eb445f3b7c0c62106f7cc2f98cabcfd9fd2c/cacheDependencyManagers/composerConfig.js#L13-L27 | train |
|
swarajban/npm-cache | cacheDependencyManagers/composerConfig.js | function () {
var composerInstallDirectory = 'vendor';
var exists = null;
try {
exists = fs.statSync(getComposerConfigPath());
} catch (e) {}
if (exists !== null) {
var composerConfig = JSON.parse(fs.readFileSync(getComposerConfigPath()));
if ('config' in composerConfig && 'vendor-dir' in composerConfig.config) {
composerInstallDirectory = composerConfig.config['vendor-dir'];
}
}
return composerInstallDirectory;
} | javascript | function () {
var composerInstallDirectory = 'vendor';
var exists = null;
try {
exists = fs.statSync(getComposerConfigPath());
} catch (e) {}
if (exists !== null) {
var composerConfig = JSON.parse(fs.readFileSync(getComposerConfigPath()));
if ('config' in composerConfig && 'vendor-dir' in composerConfig.config) {
composerInstallDirectory = composerConfig.config['vendor-dir'];
}
}
return composerInstallDirectory;
} | [
"function",
"(",
")",
"{",
"var",
"composerInstallDirectory",
"=",
"'vendor'",
";",
"var",
"exists",
"=",
"null",
";",
"try",
"{",
"exists",
"=",
"fs",
".",
"statSync",
"(",
"getComposerConfigPath",
"(",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"if",
"(",
"exists",
"!==",
"null",
")",
"{",
"var",
"composerConfig",
"=",
"JSON",
".",
"parse",
"(",
"fs",
".",
"readFileSync",
"(",
"getComposerConfigPath",
"(",
")",
")",
")",
";",
"if",
"(",
"'config'",
"in",
"composerConfig",
"&&",
"'vendor-dir'",
"in",
"composerConfig",
".",
"config",
")",
"{",
"composerInstallDirectory",
"=",
"composerConfig",
".",
"config",
"[",
"'vendor-dir'",
"]",
";",
"}",
"}",
"return",
"composerInstallDirectory",
";",
"}"
] | Composer.json can specify a custom vendor directory Let's get it if we can! | [
"Composer",
".",
"json",
"can",
"specify",
"a",
"custom",
"vendor",
"directory",
"Let",
"s",
"get",
"it",
"if",
"we",
"can!"
] | de60eb445f3b7c0c62106f7cc2f98cabcfd9fd2c | https://github.com/swarajban/npm-cache/blob/de60eb445f3b7c0c62106f7cc2f98cabcfd9fd2c/cacheDependencyManagers/composerConfig.js#L31-L46 | train |
|
swarajban/npm-cache | cacheDependencyManagers/composerConfig.js | function () {
var version = 'UnknownComposer';
var versionString = shell.exec('composer --version', {silent: true}).output;
// Example below:
// Composer version 1.0.0-alpha9 2014-12-07 17:15:20
var versionRegex = /Composer version (\S+)/;
var result = versionRegex.exec(versionString);
if (result !== null) {
version = result[1];
} else {
logger.logInfo('Could not find composer version from version string: ' + versionString);
}
return version;
} | javascript | function () {
var version = 'UnknownComposer';
var versionString = shell.exec('composer --version', {silent: true}).output;
// Example below:
// Composer version 1.0.0-alpha9 2014-12-07 17:15:20
var versionRegex = /Composer version (\S+)/;
var result = versionRegex.exec(versionString);
if (result !== null) {
version = result[1];
} else {
logger.logInfo('Could not find composer version from version string: ' + versionString);
}
return version;
} | [
"function",
"(",
")",
"{",
"var",
"version",
"=",
"'UnknownComposer'",
";",
"var",
"versionString",
"=",
"shell",
".",
"exec",
"(",
"'composer --version'",
",",
"{",
"silent",
":",
"true",
"}",
")",
".",
"output",
";",
"var",
"versionRegex",
"=",
"/",
"Composer version (\\S+)",
"/",
";",
"var",
"result",
"=",
"versionRegex",
".",
"exec",
"(",
"versionString",
")",
";",
"if",
"(",
"result",
"!==",
"null",
")",
"{",
"version",
"=",
"result",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"logger",
".",
"logInfo",
"(",
"'Could not find composer version from version string: '",
"+",
"versionString",
")",
";",
"}",
"return",
"version",
";",
"}"
] | Function to extract composer version number | [
"Function",
"to",
"extract",
"composer",
"version",
"number"
] | de60eb445f3b7c0c62106f7cc2f98cabcfd9fd2c | https://github.com/swarajban/npm-cache/blob/de60eb445f3b7c0c62106f7cc2f98cabcfd9fd2c/cacheDependencyManagers/composerConfig.js#L49-L62 | train |
|
oyyd/cheerio-without-node-native | lib/api/attributes.js | function(elem, name) {
if (!elem.attribs || !hasOwn.call(elem.attribs, name))
return;
delete elem.attribs[name];
} | javascript | function(elem, name) {
if (!elem.attribs || !hasOwn.call(elem.attribs, name))
return;
delete elem.attribs[name];
} | [
"function",
"(",
"elem",
",",
"name",
")",
"{",
"if",
"(",
"!",
"elem",
".",
"attribs",
"||",
"!",
"hasOwn",
".",
"call",
"(",
"elem",
".",
"attribs",
",",
"name",
")",
")",
"return",
";",
"delete",
"elem",
".",
"attribs",
"[",
"name",
"]",
";",
"}"
] | Remove an attribute | [
"Remove",
"an",
"attribute"
] | cb87b388e29b9a41baffb4801fc4744f7332a7b3 | https://github.com/oyyd/cheerio-without-node-native/blob/cb87b388e29b9a41baffb4801fc4744f7332a7b3/lib/api/attributes.js#L306-L311 | train |
|
oyyd/cheerio-without-node-native | lib/api/css.js | setCss | function setCss(el, prop, val, idx) {
if ('string' == typeof prop) {
var styles = getCss(el);
if (typeof val === 'function') {
val = val.call(el, idx, styles[prop]);
}
if (val === '') {
delete styles[prop];
} else if (val != null) {
styles[prop] = val;
}
el.attribs.style = stringify(styles);
} else if ('object' == typeof prop) {
Object.keys(prop).forEach(function(k){
setCss(el, k, prop[k]);
});
}
} | javascript | function setCss(el, prop, val, idx) {
if ('string' == typeof prop) {
var styles = getCss(el);
if (typeof val === 'function') {
val = val.call(el, idx, styles[prop]);
}
if (val === '') {
delete styles[prop];
} else if (val != null) {
styles[prop] = val;
}
el.attribs.style = stringify(styles);
} else if ('object' == typeof prop) {
Object.keys(prop).forEach(function(k){
setCss(el, k, prop[k]);
});
}
} | [
"function",
"setCss",
"(",
"el",
",",
"prop",
",",
"val",
",",
"idx",
")",
"{",
"if",
"(",
"'string'",
"==",
"typeof",
"prop",
")",
"{",
"var",
"styles",
"=",
"getCss",
"(",
"el",
")",
";",
"if",
"(",
"typeof",
"val",
"===",
"'function'",
")",
"{",
"val",
"=",
"val",
".",
"call",
"(",
"el",
",",
"idx",
",",
"styles",
"[",
"prop",
"]",
")",
";",
"}",
"if",
"(",
"val",
"===",
"''",
")",
"{",
"delete",
"styles",
"[",
"prop",
"]",
";",
"}",
"else",
"if",
"(",
"val",
"!=",
"null",
")",
"{",
"styles",
"[",
"prop",
"]",
"=",
"val",
";",
"}",
"el",
".",
"attribs",
".",
"style",
"=",
"stringify",
"(",
"styles",
")",
";",
"}",
"else",
"if",
"(",
"'object'",
"==",
"typeof",
"prop",
")",
"{",
"Object",
".",
"keys",
"(",
"prop",
")",
".",
"forEach",
"(",
"function",
"(",
"k",
")",
"{",
"setCss",
"(",
"el",
",",
"k",
",",
"prop",
"[",
"k",
"]",
")",
";",
"}",
")",
";",
"}",
"}"
] | Set styles of all elements.
@param {String|Object} prop
@param {String} val
@param {Number} idx - optional index within the selection
@return {self}
@api private | [
"Set",
"styles",
"of",
"all",
"elements",
"."
] | cb87b388e29b9a41baffb4801fc4744f7332a7b3 | https://github.com/oyyd/cheerio-without-node-native/blob/cb87b388e29b9a41baffb4801fc4744f7332a7b3/lib/api/css.js#L39-L58 | train |
oyyd/cheerio-without-node-native | lib/api/css.js | getCss | function getCss(el, prop) {
var styles = parse(el.attribs.style);
if (typeof prop === 'string') {
return styles[prop];
} else if (Array.isArray(prop)) {
return _.pick(styles, prop);
} else {
return styles;
}
} | javascript | function getCss(el, prop) {
var styles = parse(el.attribs.style);
if (typeof prop === 'string') {
return styles[prop];
} else if (Array.isArray(prop)) {
return _.pick(styles, prop);
} else {
return styles;
}
} | [
"function",
"getCss",
"(",
"el",
",",
"prop",
")",
"{",
"var",
"styles",
"=",
"parse",
"(",
"el",
".",
"attribs",
".",
"style",
")",
";",
"if",
"(",
"typeof",
"prop",
"===",
"'string'",
")",
"{",
"return",
"styles",
"[",
"prop",
"]",
";",
"}",
"else",
"if",
"(",
"Array",
".",
"isArray",
"(",
"prop",
")",
")",
"{",
"return",
"_",
".",
"pick",
"(",
"styles",
",",
"prop",
")",
";",
"}",
"else",
"{",
"return",
"styles",
";",
"}",
"}"
] | Get parsed styles of the first element.
@param {String} prop
@return {Object}
@api private | [
"Get",
"parsed",
"styles",
"of",
"the",
"first",
"element",
"."
] | cb87b388e29b9a41baffb4801fc4744f7332a7b3 | https://github.com/oyyd/cheerio-without-node-native/blob/cb87b388e29b9a41baffb4801fc4744f7332a7b3/lib/api/css.js#L68-L77 | train |
oyyd/cheerio-without-node-native | lib/api/css.js | stringify | function stringify(obj) {
return Object.keys(obj || {})
.reduce(function(str, prop){
return str += ''
+ (str ? ' ' : '')
+ prop
+ ': '
+ obj[prop]
+ ';';
}, '');
} | javascript | function stringify(obj) {
return Object.keys(obj || {})
.reduce(function(str, prop){
return str += ''
+ (str ? ' ' : '')
+ prop
+ ': '
+ obj[prop]
+ ';';
}, '');
} | [
"function",
"stringify",
"(",
"obj",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"obj",
"||",
"{",
"}",
")",
".",
"reduce",
"(",
"function",
"(",
"str",
",",
"prop",
")",
"{",
"return",
"str",
"+=",
"''",
"+",
"(",
"str",
"?",
"' '",
":",
"''",
")",
"+",
"prop",
"+",
"': '",
"+",
"obj",
"[",
"prop",
"]",
"+",
"';'",
";",
"}",
",",
"''",
")",
";",
"}"
] | Stringify `obj` to styles.
@param {Object} obj
@return {Object}
@api private | [
"Stringify",
"obj",
"to",
"styles",
"."
] | cb87b388e29b9a41baffb4801fc4744f7332a7b3 | https://github.com/oyyd/cheerio-without-node-native/blob/cb87b388e29b9a41baffb4801fc4744f7332a7b3/lib/api/css.js#L87-L97 | train |
oyyd/cheerio-without-node-native | lib/api/css.js | parse | function parse(styles) {
styles = (styles || '').trim();
if (!styles) return {};
return styles
.split(';')
.reduce(function(obj, str){
var n = str.indexOf(':');
// skip if there is no :, or if it is the first/last character
if (n < 1 || n === str.length-1) return obj;
obj[str.slice(0,n).trim()] = str.slice(n+1).trim();
return obj;
}, {});
} | javascript | function parse(styles) {
styles = (styles || '').trim();
if (!styles) return {};
return styles
.split(';')
.reduce(function(obj, str){
var n = str.indexOf(':');
// skip if there is no :, or if it is the first/last character
if (n < 1 || n === str.length-1) return obj;
obj[str.slice(0,n).trim()] = str.slice(n+1).trim();
return obj;
}, {});
} | [
"function",
"parse",
"(",
"styles",
")",
"{",
"styles",
"=",
"(",
"styles",
"||",
"''",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"!",
"styles",
")",
"return",
"{",
"}",
";",
"return",
"styles",
".",
"split",
"(",
"';'",
")",
".",
"reduce",
"(",
"function",
"(",
"obj",
",",
"str",
")",
"{",
"var",
"n",
"=",
"str",
".",
"indexOf",
"(",
"':'",
")",
";",
"if",
"(",
"n",
"<",
"1",
"||",
"n",
"===",
"str",
".",
"length",
"-",
"1",
")",
"return",
"obj",
";",
"obj",
"[",
"str",
".",
"slice",
"(",
"0",
",",
"n",
")",
".",
"trim",
"(",
")",
"]",
"=",
"str",
".",
"slice",
"(",
"n",
"+",
"1",
")",
".",
"trim",
"(",
")",
";",
"return",
"obj",
";",
"}",
",",
"{",
"}",
")",
";",
"}"
] | Parse `styles`.
@param {String} styles
@return {Object}
@api private | [
"Parse",
"styles",
"."
] | cb87b388e29b9a41baffb4801fc4744f7332a7b3 | https://github.com/oyyd/cheerio-without-node-native/blob/cb87b388e29b9a41baffb4801fc4744f7332a7b3/lib/api/css.js#L107-L121 | train |
flesler/jquery.serialScroll | snippets/SerialScroll_hide-arrows.js | function( e, elem, $pane, $items, pos ){
$prev.add($next).show();
if( pos == 0 )
$prev.hide();
else if( pos == $items.length-1 )
$next.hide();
} | javascript | function( e, elem, $pane, $items, pos ){
$prev.add($next).show();
if( pos == 0 )
$prev.hide();
else if( pos == $items.length-1 )
$next.hide();
} | [
"function",
"(",
"e",
",",
"elem",
",",
"$pane",
",",
"$items",
",",
"pos",
")",
"{",
"$prev",
".",
"add",
"(",
"$next",
")",
".",
"show",
"(",
")",
";",
"if",
"(",
"pos",
"==",
"0",
")",
"$prev",
".",
"hide",
"(",
")",
";",
"else",
"if",
"(",
"pos",
"==",
"$items",
".",
"length",
"-",
"1",
")",
"$next",
".",
"hide",
"(",
")",
";",
"}"
] | you probably don't want this | [
"you",
"probably",
"don",
"t",
"want",
"this"
] | bd2e40057a31fd58339f783bf109d3a25787b3a6 | https://github.com/flesler/jquery.serialScroll/blob/bd2e40057a31fd58339f783bf109d3a25787b3a6/snippets/SerialScroll_hide-arrows.js#L30-L36 | train |
|
marcelog/Nami | src/message/action.js | Action | function Action(name) {
Action.super_.call(this);
this.id = ActionUniqueId();
this.set('ActionID', this.id);
this.set('Action', name);
} | javascript | function Action(name) {
Action.super_.call(this);
this.id = ActionUniqueId();
this.set('ActionID', this.id);
this.set('Action', name);
} | [
"function",
"Action",
"(",
"name",
")",
"{",
"Action",
".",
"super_",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"id",
"=",
"ActionUniqueId",
"(",
")",
";",
"this",
".",
"set",
"(",
"'ActionID'",
",",
"this",
".",
"id",
")",
";",
"this",
".",
"set",
"(",
"'Action'",
",",
"name",
")",
";",
"}"
] | Base action class. Every action sent to AMI must be one of these.
@constructor
@param {String} name The name of the action, this is the actual value of the
"Action" key in the action message.
@see Message#marshall(String)
@augments Message | [
"Base",
"action",
"class",
".",
"Every",
"action",
"sent",
"to",
"AMI",
"must",
"be",
"one",
"of",
"these",
"."
] | ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1 | https://github.com/marcelog/Nami/blob/ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1/src/message/action.js#L36-L41 | train |
marcelog/Nami | src/message/action.js | Login | function Login(username, secret) {
Login.super_.call(this, 'Login');
this.set('Username', username);
this.set('Secret', secret );
} | javascript | function Login(username, secret) {
Login.super_.call(this, 'Login');
this.set('Username', username);
this.set('Secret', secret );
} | [
"function",
"Login",
"(",
"username",
",",
"secret",
")",
"{",
"Login",
".",
"super_",
".",
"call",
"(",
"this",
",",
"'Login'",
")",
";",
"this",
".",
"set",
"(",
"'Username'",
",",
"username",
")",
";",
"this",
".",
"set",
"(",
"'Secret'",
",",
"secret",
")",
";",
"}"
] | Login Action.
@constructor
@param {String} username The username. The value of the "Username" key.
@param {String} secret The password. The value of the "Secret" key.
@see Action(String)
@see See <a href="https://wiki.asterisk.org/wiki/display/AST/ManagerAction_Login">https://wiki.asterisk.org/wiki/display/AST/ManagerAction_Login</a>.
@augments Action | [
"Login",
"Action",
"."
] | ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1 | https://github.com/marcelog/Nami/blob/ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1/src/message/action.js#L59-L63 | train |
marcelog/Nami | src/message/action.js | QueueReload | function QueueReload(queue, members, rules, parameters) {
QueueReload.super_.call(this, 'QueueReload');
if (undefined !== queue) {
this.set('queue', queue);
}
if (undefined !== members) {
this.set('members', members);
}
if (undefined !== rules) {
this.set('rules', rules);
}
if (undefined !== parameters) {
this.set('parameters', parameters);
}
} | javascript | function QueueReload(queue, members, rules, parameters) {
QueueReload.super_.call(this, 'QueueReload');
if (undefined !== queue) {
this.set('queue', queue);
}
if (undefined !== members) {
this.set('members', members);
}
if (undefined !== rules) {
this.set('rules', rules);
}
if (undefined !== parameters) {
this.set('parameters', parameters);
}
} | [
"function",
"QueueReload",
"(",
"queue",
",",
"members",
",",
"rules",
",",
"parameters",
")",
"{",
"QueueReload",
".",
"super_",
".",
"call",
"(",
"this",
",",
"'QueueReload'",
")",
";",
"if",
"(",
"undefined",
"!==",
"queue",
")",
"{",
"this",
".",
"set",
"(",
"'queue'",
",",
"queue",
")",
";",
"}",
"if",
"(",
"undefined",
"!==",
"members",
")",
"{",
"this",
".",
"set",
"(",
"'members'",
",",
"members",
")",
";",
"}",
"if",
"(",
"undefined",
"!==",
"rules",
")",
"{",
"this",
".",
"set",
"(",
"'rules'",
",",
"rules",
")",
";",
"}",
"if",
"(",
"undefined",
"!==",
"parameters",
")",
"{",
"this",
".",
"set",
"(",
"'parameters'",
",",
"parameters",
")",
";",
"}",
"}"
] | QueueReload Action.
@constructor
@see Action(String)
@see See <a href="https://wiki.asterisk.org/wiki/display/AST/ManagerAction_QueueReload">https://wiki.asterisk.org/wiki/display/AST/ManagerAction_QueueReload</a>.
@property {String} Queue Optional, Queue
@property {String} Members Optional, yes/no
@property {String} Rules Optional, yes/no
@property {String} Parameters Optional, yes/no
@augments Action | [
"QueueReload",
"Action",
"."
] | ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1 | https://github.com/marcelog/Nami/blob/ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1/src/message/action.js#L818-L836 | train |
marcelog/Nami | src/message/action.js | QueueStatus | function QueueStatus(queue, member) {
QueueStatus.super_.call(this, 'QueueStatus');
if (undefined !== queue) {
this.set('Queue', queue);
}
if (undefined !== member) {
this.set('Member', member);
}
} | javascript | function QueueStatus(queue, member) {
QueueStatus.super_.call(this, 'QueueStatus');
if (undefined !== queue) {
this.set('Queue', queue);
}
if (undefined !== member) {
this.set('Member', member);
}
} | [
"function",
"QueueStatus",
"(",
"queue",
",",
"member",
")",
"{",
"QueueStatus",
".",
"super_",
".",
"call",
"(",
"this",
",",
"'QueueStatus'",
")",
";",
"if",
"(",
"undefined",
"!==",
"queue",
")",
"{",
"this",
".",
"set",
"(",
"'Queue'",
",",
"queue",
")",
";",
"}",
"if",
"(",
"undefined",
"!==",
"member",
")",
"{",
"this",
".",
"set",
"(",
"'Member'",
",",
"member",
")",
";",
"}",
"}"
] | QueueStatus Action.
@constructor
@see Action(String)
@see See <a href="https://wiki.asterisk.org/wiki/display/AST/ManagerAction_QueueStatus">https://wiki.asterisk.org/wiki/display/AST/ManagerAction_QueueStatus</a>.
@property {String} Queue Optional, Queue
@property {String} Member Optional, Member
@augments Action | [
"QueueStatus",
"Action",
"."
] | ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1 | https://github.com/marcelog/Nami/blob/ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1/src/message/action.js#L922-L930 | train |
marcelog/Nami | src/message/action.js | QueueRemove | function QueueRemove(asteriskInterface, queue) {
QueueRemove.super_.call(this, 'QueueRemove');
this.set('interface', asteriskInterface);
this.set('queue', queue);
} | javascript | function QueueRemove(asteriskInterface, queue) {
QueueRemove.super_.call(this, 'QueueRemove');
this.set('interface', asteriskInterface);
this.set('queue', queue);
} | [
"function",
"QueueRemove",
"(",
"asteriskInterface",
",",
"queue",
")",
"{",
"QueueRemove",
".",
"super_",
".",
"call",
"(",
"this",
",",
"'QueueRemove'",
")",
";",
"this",
".",
"set",
"(",
"'interface'",
",",
"asteriskInterface",
")",
";",
"this",
".",
"set",
"(",
"'queue'",
",",
"queue",
")",
";",
"}"
] | QueueRemove Action.
@constructor
@see Action(String)
@see See <a href="https://wiki.asterisk.org/wiki/display/AST/ManagerAction_QueueRemove">https://wiki.asterisk.org/wiki/display/AST/ManagerAction_QueueRemove</a>.
@property {String} Queue Queue
@property {String} Interface Interface
@augments Action | [
"QueueRemove",
"Action",
"."
] | ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1 | https://github.com/marcelog/Nami/blob/ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1/src/message/action.js#L953-L957 | train |
marcelog/Nami | src/message/action.js | QueueAdd | function QueueAdd(asteriskInterface, queue, paused, memberName, penalty) {
QueueAdd.super_.call(this, 'QueueAdd');
this.set('interface', asteriskInterface);
this.set('queue', queue);
if (undefined !== paused) {
this.set('paused', paused);
}
if (undefined !== memberName) {
this.set('membername', memberName);
}
if (undefined !== penalty) {
this.set('penalty', penalty);
}
} | javascript | function QueueAdd(asteriskInterface, queue, paused, memberName, penalty) {
QueueAdd.super_.call(this, 'QueueAdd');
this.set('interface', asteriskInterface);
this.set('queue', queue);
if (undefined !== paused) {
this.set('paused', paused);
}
if (undefined !== memberName) {
this.set('membername', memberName);
}
if (undefined !== penalty) {
this.set('penalty', penalty);
}
} | [
"function",
"QueueAdd",
"(",
"asteriskInterface",
",",
"queue",
",",
"paused",
",",
"memberName",
",",
"penalty",
")",
"{",
"QueueAdd",
".",
"super_",
".",
"call",
"(",
"this",
",",
"'QueueAdd'",
")",
";",
"this",
".",
"set",
"(",
"'interface'",
",",
"asteriskInterface",
")",
";",
"this",
".",
"set",
"(",
"'queue'",
",",
"queue",
")",
";",
"if",
"(",
"undefined",
"!==",
"paused",
")",
"{",
"this",
".",
"set",
"(",
"'paused'",
",",
"paused",
")",
";",
"}",
"if",
"(",
"undefined",
"!==",
"memberName",
")",
"{",
"this",
".",
"set",
"(",
"'membername'",
",",
"memberName",
")",
";",
"}",
"if",
"(",
"undefined",
"!==",
"penalty",
")",
"{",
"this",
".",
"set",
"(",
"'penalty'",
",",
"penalty",
")",
";",
"}",
"}"
] | QueueAdd Action.
@constructor
@see Action(String)
@see See <a href="https://wiki.asterisk.org/wiki/display/AST/ManagerAction_QueueAdd">https://wiki.asterisk.org/wiki/display/AST/ManagerAction_QueueAdd</a>.
@property {String} Queue Queue
@property {String} Interface Interface
@property {String} Paused Optional, 'true' or 'false
@property {String} MemberName Optional, Member name
@property {String} Penalty Optional, Penalty
@property {String} StateInterface Optional, State interface
@augments Action | [
"QueueAdd",
"Action",
"."
] | ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1 | https://github.com/marcelog/Nami/blob/ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1/src/message/action.js#L993-L1006 | train |
marcelog/Nami | src/message/action.js | MeetmeMute | function MeetmeMute(meetme, usernum) {
MeetmeMute.super_.call(this, 'MeetmeMute');
this.set('Meetme', meetme);
this.set('Usernum', usernum);
} | javascript | function MeetmeMute(meetme, usernum) {
MeetmeMute.super_.call(this, 'MeetmeMute');
this.set('Meetme', meetme);
this.set('Usernum', usernum);
} | [
"function",
"MeetmeMute",
"(",
"meetme",
",",
"usernum",
")",
"{",
"MeetmeMute",
".",
"super_",
".",
"call",
"(",
"this",
",",
"'MeetmeMute'",
")",
";",
"this",
".",
"set",
"(",
"'Meetme'",
",",
"meetme",
")",
";",
"this",
".",
"set",
"(",
"'Usernum'",
",",
"usernum",
")",
";",
"}"
] | MeetmeMute Action.
@constructor
@see Action(String)
@augments Action | [
"MeetmeMute",
"Action",
"."
] | ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1 | https://github.com/marcelog/Nami/blob/ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1/src/message/action.js#L1043-L1047 | train |
marcelog/Nami | src/message/action.js | MeetmeUnmute | function MeetmeUnmute(meetme, usernum) {
MeetmeUnmute.super_.call(this, 'MeetmeUnmute');
this.set('Meetme', meetme);
this.set('Usernum', usernum);
} | javascript | function MeetmeUnmute(meetme, usernum) {
MeetmeUnmute.super_.call(this, 'MeetmeUnmute');
this.set('Meetme', meetme);
this.set('Usernum', usernum);
} | [
"function",
"MeetmeUnmute",
"(",
"meetme",
",",
"usernum",
")",
"{",
"MeetmeUnmute",
".",
"super_",
".",
"call",
"(",
"this",
",",
"'MeetmeUnmute'",
")",
";",
"this",
".",
"set",
"(",
"'Meetme'",
",",
"meetme",
")",
";",
"this",
".",
"set",
"(",
"'Usernum'",
",",
"usernum",
")",
";",
"}"
] | MeetmeUnmute Action.
@constructor
@see Action(String)
@augments Action | [
"MeetmeUnmute",
"Action",
"."
] | ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1 | https://github.com/marcelog/Nami/blob/ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1/src/message/action.js#L1055-L1059 | train |
marcelog/Nami | src/message/action.js | ConfbridgeKick | function ConfbridgeKick(conference, channel) {
ConfbridgeKick.super_.call(this, 'ConfbridgeKick');
this.set('Conference', conference);
this.set('Channel', channel);
} | javascript | function ConfbridgeKick(conference, channel) {
ConfbridgeKick.super_.call(this, 'ConfbridgeKick');
this.set('Conference', conference);
this.set('Channel', channel);
} | [
"function",
"ConfbridgeKick",
"(",
"conference",
",",
"channel",
")",
"{",
"ConfbridgeKick",
".",
"super_",
".",
"call",
"(",
"this",
",",
"'ConfbridgeKick'",
")",
";",
"this",
".",
"set",
"(",
"'Conference'",
",",
"conference",
")",
";",
"this",
".",
"set",
"(",
"'Channel'",
",",
"channel",
")",
";",
"}"
] | ConfbridgeKick Action.
@constructor
@see Action(String)
@param {String} conference room. The value of the "conference" key.
@param {String} Channel. The value of the "Channel" key.
@augments Action | [
"ConfbridgeKick",
"Action",
"."
] | ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1 | https://github.com/marcelog/Nami/blob/ccf22f09e17c1ac5ae68e09af1bc77ea6cf106a1/src/message/action.js#L1091-L1095 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.