repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/cache/LRUPersistentCache.js | updateItemUsage | function updateItemUsage(self, oItem) {
if (self._metadata.__byKey__[oItem.oData.key] != null) { // ItemData already exists, we need to remove the old position index
var oldIndex = self._metadata.__byKey__[oItem.oData.key];
delete self._metadata.__byIndex__[oldIndex];
Log.debug("Cache Manager LRUPersistentCache: set/internalset - item already exists, so its indexes are updated");
}
self._metadata.__byIndex__[oItem.oData.lu] = oItem.oData.key;
self._metadata.__byKey__[oItem.oData.key] = oItem.oData.lu;
seekMetadataLRU(self);
} | javascript | function updateItemUsage(self, oItem) {
if (self._metadata.__byKey__[oItem.oData.key] != null) { // ItemData already exists, we need to remove the old position index
var oldIndex = self._metadata.__byKey__[oItem.oData.key];
delete self._metadata.__byIndex__[oldIndex];
Log.debug("Cache Manager LRUPersistentCache: set/internalset - item already exists, so its indexes are updated");
}
self._metadata.__byIndex__[oItem.oData.lu] = oItem.oData.key;
self._metadata.__byKey__[oItem.oData.key] = oItem.oData.lu;
seekMetadataLRU(self);
} | [
"function",
"updateItemUsage",
"(",
"self",
",",
"oItem",
")",
"{",
"if",
"(",
"self",
".",
"_metadata",
".",
"__byKey__",
"[",
"oItem",
".",
"oData",
".",
"key",
"]",
"!=",
"null",
")",
"{",
"// ItemData already exists, we need to remove the old position index",
... | Set/updates item's usage by setting LRU indexes and moves the LRU pointer if needed.
@param {sap.ui.core.cache.LRUPersistenceCache} self the <code>this</code> instance
@param {Item} oItem the item to update indexes for | [
"Set",
"/",
"updates",
"item",
"s",
"usage",
"by",
"setting",
"LRU",
"indexes",
"and",
"moves",
"the",
"LRU",
"pointer",
"if",
"needed",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/cache/LRUPersistentCache.js#L592-L602 | train | Updates the usage of an item | [
30522,
3853,
10651,
4221,
7606,
4270,
1006,
2969,
1010,
1051,
4221,
2213,
1007,
1063,
2065,
1006,
2969,
1012,
1035,
27425,
1012,
1035,
1035,
2011,
14839,
1035,
1035,
1031,
1051,
4221,
2213,
1012,
1051,
2850,
2696,
1012,
3145,
1033,
999,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/InlineColorEditor/ColorEditor.js | _getNewOffset | function _getNewOffset(pos, zeroPos, maxOffset) {
var offset = pos - zeroPos;
offset = Math.min(maxOffset, Math.max(0, offset));
return offset;
} | javascript | function _getNewOffset(pos, zeroPos, maxOffset) {
var offset = pos - zeroPos;
offset = Math.min(maxOffset, Math.max(0, offset));
return offset;
} | [
"function",
"_getNewOffset",
"(",
"pos",
",",
"zeroPos",
",",
"maxOffset",
")",
"{",
"var",
"offset",
"=",
"pos",
"-",
"zeroPos",
";",
"offset",
"=",
"Math",
".",
"min",
"(",
"maxOffset",
",",
"Math",
".",
"max",
"(",
"0",
",",
"offset",
")",
")",
... | Converts a mouse coordinate to be relative to zeroPos, and clips to [0, maxOffset] | [
"Converts",
"a",
"mouse",
"coordinate",
"to",
"be",
"relative",
"to",
"zeroPos",
"and",
"clips",
"to",
"[",
"0",
"maxOffset",
"]"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineColorEditor/ColorEditor.js#L545-L549 | train | Get new offset from pos | [
30522,
3853,
1035,
2131,
2638,
12155,
21807,
3388,
1006,
13433,
2015,
1010,
5717,
6873,
2015,
1010,
4098,
27475,
3388,
1007,
1063,
13075,
16396,
1027,
13433,
2015,
1011,
5717,
6873,
2015,
1025,
16396,
1027,
8785,
1012,
8117,
1006,
4098,
274... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsAnalyzer.js | _checkForDuplicateLabels | function _checkForDuplicateLabels(oInvisibleElement, aODataProperties) {
return aODataProperties.some(function(oDataProperty) {
return oDataProperty.fieldLabel === oInvisibleElement.fieldLabel;
});
} | javascript | function _checkForDuplicateLabels(oInvisibleElement, aODataProperties) {
return aODataProperties.some(function(oDataProperty) {
return oDataProperty.fieldLabel === oInvisibleElement.fieldLabel;
});
} | [
"function",
"_checkForDuplicateLabels",
"(",
"oInvisibleElement",
",",
"aODataProperties",
")",
"{",
"return",
"aODataProperties",
".",
"some",
"(",
"function",
"(",
"oDataProperty",
")",
"{",
"return",
"oDataProperty",
".",
"fieldLabel",
"===",
"oInvisibleElement",
"... | check for duplicate labels to later add the referenced complexTypeName if available | [
"check",
"for",
"duplicate",
"labels",
"to",
"later",
"add",
"the",
"referenced",
"complexTypeName",
"if",
"available"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsAnalyzer.js#L301-L305 | train | Check if the field label is already in the data | [
30522,
3853,
1035,
4638,
3877,
6279,
19341,
9834,
16336,
4877,
1006,
1051,
2378,
11365,
7028,
12260,
3672,
1010,
20118,
2850,
2696,
21572,
4842,
7368,
1007,
1063,
2709,
20118,
2850,
2696,
21572,
4842,
7368,
1012,
2070,
1006,
3853,
1006,
105... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/docker-prompts.js | askForApplicationType | function askForApplicationType() {
if (this.regenerate) return;
const done = this.async();
const prompts = [
{
type: 'list',
name: 'deploymentApplicationType',
message: 'Which *type* of application would you like to deploy?',
choices: [
{
value: 'monolith',
name: 'Monolithic application'
},
{
value: 'microservice',
name: 'Microservice application'
}
],
default: 'monolith'
}
];
this.prompt(prompts).then(props => {
this.deploymentApplicationType = props.deploymentApplicationType;
done();
});
} | javascript | function askForApplicationType() {
if (this.regenerate) return;
const done = this.async();
const prompts = [
{
type: 'list',
name: 'deploymentApplicationType',
message: 'Which *type* of application would you like to deploy?',
choices: [
{
value: 'monolith',
name: 'Monolithic application'
},
{
value: 'microservice',
name: 'Microservice application'
}
],
default: 'monolith'
}
];
this.prompt(prompts).then(props => {
this.deploymentApplicationType = props.deploymentApplicationType;
done();
});
} | [
"function",
"askForApplicationType",
"(",
")",
"{",
"if",
"(",
"this",
".",
"regenerate",
")",
"return",
";",
"const",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"const",
"prompts",
"=",
"[",
"{",
"type",
":",
"'list'",
",",
"name",
":",
"'dep... | Ask For Application Type | [
"Ask",
"For",
"Application",
"Type"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/docker-prompts.js#L42-L70 | train | Ask For Application Type | [
30522,
3853,
3198,
29278,
29098,
19341,
3508,
13874,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
19723,
24454,
3686,
1007,
2709,
1025,
9530,
3367,
2589,
1027,
2023,
1012,
2004,
6038,
2278,
1006,
1007,
1025,
9530,
3367,
25732,
2015,
1027,
1031... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fex-team/webuploader | _draft/music/webuploader.js | Queue | function Queue() {
/**
* 统计文件数。
* * `numOfQueue` 队列中的文件数。
* * `numOfSuccess` 上传成功的文件数
* * `numOfCancel` 被移除的文件数
* * `numOfProgress` 正在上传中的文件数
* * `numOfUploadFailed` 上传错误的文件数。
* * `numOfInvalid` 无效的文件数。
* @property {Object} stats
*/
this.stats = {
numOfQueue: 0,
numOfSuccess: 0,
numOfCancel: 0,
numOfProgress: 0,
numOfUploadFailed: 0,
numOfInvalid: 0
};
// 上传队列,仅包括等待上传的文件
this._queue = [];
// 存储所有文件
this._map = {};
} | javascript | function Queue() {
/**
* 统计文件数。
* * `numOfQueue` 队列中的文件数。
* * `numOfSuccess` 上传成功的文件数
* * `numOfCancel` 被移除的文件数
* * `numOfProgress` 正在上传中的文件数
* * `numOfUploadFailed` 上传错误的文件数。
* * `numOfInvalid` 无效的文件数。
* @property {Object} stats
*/
this.stats = {
numOfQueue: 0,
numOfSuccess: 0,
numOfCancel: 0,
numOfProgress: 0,
numOfUploadFailed: 0,
numOfInvalid: 0
};
// 上传队列,仅包括等待上传的文件
this._queue = [];
// 存储所有文件
this._map = {};
} | [
"function",
"Queue",
"(",
")",
"{",
"/**\n * 统计文件数。\n * * `numOfQueue` 队列中的文件数。\n * * `numOfSuccess` 上传成功的文件数\n * * `numOfCancel` 被移除的文件数\n * * `numOfProgress` 正在上传中的文件数\n * * `numOfUploadFailed` 上传错误的文件数。\n * * `numOfInva... | 文件队列, 用来存储各个状态中的文件。
@class Queue
@extends Mediator | [
"文件队列",
"用来存储各个状态中的文件。"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/_draft/music/webuploader.js#L2042-L2068 | train | Queue constructor. | [
30522,
3853,
24240,
1006,
1007,
1063,
1013,
1008,
1008,
1008,
100,
100,
1861,
100,
100,
1636,
1008,
1008,
1036,
16371,
5302,
2546,
4226,
5657,
1036,
100,
100,
1746,
1916,
1861,
100,
100,
1636,
1008,
1008,
1036,
16371,
5302,
10343,
14194,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.table/src/sap/ui/table/TableSyncExtension.js | function(iIndex, bSelected) {
var oTable = this.getTable();
var oRow = oTable.getRows()[iIndex];
if (oRow && bSelected != null) {
TableUtils.toggleRowSelection(oTable, oRow.getIndex(), bSelected);
}
} | javascript | function(iIndex, bSelected) {
var oTable = this.getTable();
var oRow = oTable.getRows()[iIndex];
if (oRow && bSelected != null) {
TableUtils.toggleRowSelection(oTable, oRow.getIndex(), bSelected);
}
} | [
"function",
"(",
"iIndex",
",",
"bSelected",
")",
"{",
"var",
"oTable",
"=",
"this",
".",
"getTable",
"(",
")",
";",
"var",
"oRow",
"=",
"oTable",
".",
"getRows",
"(",
")",
"[",
"iIndex",
"]",
";",
"if",
"(",
"oRow",
"&&",
"bSelected",
"!=",
"null"... | Sets the selection state of a row.
@param {int} iIndex The index of the row in the aggregation.
@param {boolean} bSelected Whether the row should be selected. | [
"Sets",
"the",
"selection",
"state",
"of",
"a",
"row",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableSyncExtension.js#L20-L27 | train | Sets the selection state of a row. | [
30522,
3853,
1006,
2462,
13629,
2595,
1010,
18667,
12260,
10985,
1007,
1063,
13075,
27178,
3085,
1027,
2023,
1012,
2131,
10880,
1006,
1007,
1025,
13075,
20298,
2860,
1027,
27178,
3085,
1012,
2131,
10524,
2015,
1006,
1007,
1031,
2462,
13629,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
transloadit/uppy | packages/@uppy/companion/src/server/controllers/s3.js | completeMultipartUpload | function completeMultipartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const { uploadId } = req.params
const { key } = req.query
const { parts } = req.body
if (typeof key !== 'string') {
return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' })
}
if (!Array.isArray(parts) || !parts.every(isValidPart)) {
return res.status(400).json({ error: 's3: `parts` must be an array of {ETag, PartNumber} objects.' })
}
client.completeMultipartUpload({
Bucket: config.bucket,
Key: key,
UploadId: uploadId,
MultipartUpload: {
Parts: parts
}
}, (err, data) => {
if (err) {
next(err)
return
}
res.json({
location: data.Location
})
})
} | javascript | function completeMultipartUpload (req, res, next) {
// @ts-ignore The `uppy` property is added by middleware before reaching here.
const client = req.uppy.s3Client
const { uploadId } = req.params
const { key } = req.query
const { parts } = req.body
if (typeof key !== 'string') {
return res.status(400).json({ error: 's3: the object key must be passed as a query parameter. For example: "?key=abc.jpg"' })
}
if (!Array.isArray(parts) || !parts.every(isValidPart)) {
return res.status(400).json({ error: 's3: `parts` must be an array of {ETag, PartNumber} objects.' })
}
client.completeMultipartUpload({
Bucket: config.bucket,
Key: key,
UploadId: uploadId,
MultipartUpload: {
Parts: parts
}
}, (err, data) => {
if (err) {
next(err)
return
}
res.json({
location: data.Location
})
})
} | [
"function",
"completeMultipartUpload",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"// @ts-ignore The `uppy` property is added by middleware before reaching here.",
"const",
"client",
"=",
"req",
".",
"uppy",
".",
"s3Client",
"const",
"{",
"uploadId",
"}",
"=",
"re... | Complete a multipart upload, combining all the parts into a single object in the S3 bucket.
Expected URL parameters:
- uploadId - The uploadId returned from `createMultipartUpload`.
Expected query parameters:
- key - The object key in the S3 bucket.
Expected JSON body:
- parts - An array of parts, see the `getUploadedParts` response JSON.
Response JSON:
- location - The full URL to the object in the S3 bucket. | [
"Complete",
"a",
"multipart",
"upload",
"combining",
"all",
"the",
"parts",
"into",
"a",
"single",
"object",
"in",
"the",
"S3",
"bucket",
"."
] | 7ae18bf992d544a64da998f033258ec09a3de275 | https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/companion/src/server/controllers/s3.js#L239-L269 | train | Complete a multipart upload | [
30522,
3853,
3143,
12274,
7096,
11514,
8445,
6279,
11066,
1006,
2128,
4160,
1010,
24501,
1010,
2279,
1007,
1063,
1013,
1013,
1030,
24529,
1011,
8568,
1996,
1036,
2039,
7685,
1036,
3200,
2003,
2794,
2011,
2690,
8059,
2077,
4285,
2182,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | blobify | function blobify(data) {
if(typeof data === "string") return s2ab(data);
if(Array.isArray(data)) return a2u(data);
return data;
} | javascript | function blobify(data) {
if(typeof data === "string") return s2ab(data);
if(Array.isArray(data)) return a2u(data);
return data;
} | [
"function",
"blobify",
"(",
"data",
")",
"{",
"if",
"(",
"typeof",
"data",
"===",
"\"string\"",
")",
"return",
"s2ab",
"(",
"data",
")",
";",
"if",
"(",
"Array",
".",
"isArray",
"(",
"data",
")",
")",
"return",
"a2u",
"(",
"data",
")",
";",
"return... | /* normalize data for blob ctor | [
"/",
"*",
"normalize",
"data",
"for",
"blob",
"ctor"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L2582-L2586 | train | Convert a blob to a string array or array | [
30522,
3853,
1038,
4135,
5638,
12031,
1006,
2951,
1007,
1063,
2065,
1006,
2828,
11253,
2951,
1027,
1027,
1027,
1000,
5164,
1000,
1007,
2709,
1055,
2475,
7875,
1006,
2951,
1007,
1025,
2065,
1006,
9140,
1012,
18061,
11335,
2100,
1006,
2951,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/Utils.js | function (oComponent, sParameterName, aValues) {
var oParsedHash = Utils.getParsedURLHash(sParameterName);
if (oParsedHash.params) {
hasher.changed.active = false; //disable changed signal
var mTechnicalParameters = Utils.getTechnicalParametersForComponent(oComponent);
// if mTechnicalParameters are not available we write a warning and continue updating the hash
if (!mTechnicalParameters) {
this.log.warning("Component instance not provided, so technical parameters in component data and browser history remain unchanged");
}
if (aValues.length === 0) {
delete oParsedHash.params[sParameterName];
mTechnicalParameters && delete mTechnicalParameters[sParameterName]; // Case when ControlVariantsAPI.clearVariantParameterInURL is called with a parameter
} else {
oParsedHash.params[sParameterName] = aValues;
mTechnicalParameters && (mTechnicalParameters[sParameterName] = aValues); // Technical parameters need to be in sync with the URL hash
}
hasher.replaceHash(Utils.getUshellContainer().getService("URLParsing").constructShellHash(oParsedHash)); // Set hash without dispatching changed signal nor writing history
hasher.changed.active = true; // Re-enable signal
}
} | javascript | function (oComponent, sParameterName, aValues) {
var oParsedHash = Utils.getParsedURLHash(sParameterName);
if (oParsedHash.params) {
hasher.changed.active = false; //disable changed signal
var mTechnicalParameters = Utils.getTechnicalParametersForComponent(oComponent);
// if mTechnicalParameters are not available we write a warning and continue updating the hash
if (!mTechnicalParameters) {
this.log.warning("Component instance not provided, so technical parameters in component data and browser history remain unchanged");
}
if (aValues.length === 0) {
delete oParsedHash.params[sParameterName];
mTechnicalParameters && delete mTechnicalParameters[sParameterName]; // Case when ControlVariantsAPI.clearVariantParameterInURL is called with a parameter
} else {
oParsedHash.params[sParameterName] = aValues;
mTechnicalParameters && (mTechnicalParameters[sParameterName] = aValues); // Technical parameters need to be in sync with the URL hash
}
hasher.replaceHash(Utils.getUshellContainer().getService("URLParsing").constructShellHash(oParsedHash)); // Set hash without dispatching changed signal nor writing history
hasher.changed.active = true; // Re-enable signal
}
} | [
"function",
"(",
"oComponent",
",",
"sParameterName",
",",
"aValues",
")",
"{",
"var",
"oParsedHash",
"=",
"Utils",
".",
"getParsedURLHash",
"(",
"sParameterName",
")",
";",
"if",
"(",
"oParsedHash",
".",
"params",
")",
"{",
"hasher",
".",
"changed",
".",
... | Sets the values for url hash and technical parameters for the component data.
Deactivates hash based navigation while performing the operations, which is then re-activated upon completion.
If the passed doesn't exist in the url hash or technical parameters, then a new object is added respectively.
@param {object} oComponent Component instance used to get the technical parameters
@param {string} sParameterName Name of the parameter (e.g. "sap-ui-fl-control-variant-id")
@param {string[]} aValues Array of values for the technical parameter | [
"Sets",
"the",
"values",
"for",
"url",
"hash",
"and",
"technical",
"parameters",
"for",
"the",
"component",
"data",
".",
"Deactivates",
"hash",
"based",
"navigation",
"while",
"performing",
"the",
"operations",
"which",
"is",
"then",
"re",
"-",
"activated",
"u... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/Utils.js#L910-L931 | train | Updates the technical parameters of the given component with the given values. | [
30522,
3853,
1006,
1051,
9006,
29513,
3372,
1010,
12403,
6444,
15141,
18442,
1010,
10927,
7630,
2229,
1007,
1063,
13075,
6728,
11650,
2098,
14949,
2232,
1027,
21183,
12146,
1012,
2131,
19362,
6924,
3126,
2140,
14949,
2232,
1006,
12403,
6444,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensibility/Package.js | validate | function validate(path, options) {
return _extensionManagerCall(function (extensionManager) {
var d = new $.Deferred();
// make sure proxy is attached to options before calling validate
// so npm can use it in the domain
options = options || {};
options.proxy = PreferencesManager.get("proxy");
extensionManager.validate(path, options)
.done(function (result) {
d.resolve({
errors: result.errors,
metadata: result.metadata
});
})
.fail(function (error) {
d.reject(error);
});
return d.promise();
});
} | javascript | function validate(path, options) {
return _extensionManagerCall(function (extensionManager) {
var d = new $.Deferred();
// make sure proxy is attached to options before calling validate
// so npm can use it in the domain
options = options || {};
options.proxy = PreferencesManager.get("proxy");
extensionManager.validate(path, options)
.done(function (result) {
d.resolve({
errors: result.errors,
metadata: result.metadata
});
})
.fail(function (error) {
d.reject(error);
});
return d.promise();
});
} | [
"function",
"validate",
"(",
"path",
",",
"options",
")",
"{",
"return",
"_extensionManagerCall",
"(",
"function",
"(",
"extensionManager",
")",
"{",
"var",
"d",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"// make sure proxy is attached to options before cal... | TODO: can this go away now that we never call it directly?
Validates the package at the given path. The actual validation is
handled by the Node server.
The promise is resolved with an object:
{ errors: Array.<{string}>, metadata: { name:string, version:string, ... } }
metadata is pulled straight from package.json and will be undefined
if there are errors or null if the extension did not include package.json.
@param {string} Absolute path to the package zip file
@param {{requirePackageJSON: ?boolean}} validation options
@return {$.Promise} A promise that is resolved with information about the package | [
"TODO",
":",
"can",
"this",
"go",
"away",
"now",
"that",
"we",
"never",
"call",
"it",
"directly?"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/Package.js#L110-L132 | train | Validate the file | [
30522,
3853,
9398,
3686,
1006,
4130,
1010,
7047,
1007,
1063,
2709,
1035,
5331,
24805,
4590,
9289,
2140,
1006,
3853,
1006,
5331,
24805,
4590,
1007,
1063,
13075,
1040,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
1013,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
pagekit/vue-resource | dist/vue-resource.esm.js | nodeClient | function nodeClient (request) {
var client = require('got');
return new PromiseObj(function (resolve) {
var url = request.getUrl();
var body = request.getBody();
var method = request.method;
var headers = {}, handler;
request.headers.forEach(function (value, name) {
headers[name] = value;
});
client(url, {body: body, method: method, headers: headers}).then(handler = function (resp) {
var response = request.respondWith(resp.body, {
status: resp.statusCode,
statusText: trim(resp.statusMessage)
});
each(resp.headers, function (value, name) {
response.headers.set(name, value);
});
resolve(response);
}, function (error$$1) { return handler(error$$1.response); });
});
} | javascript | function nodeClient (request) {
var client = require('got');
return new PromiseObj(function (resolve) {
var url = request.getUrl();
var body = request.getBody();
var method = request.method;
var headers = {}, handler;
request.headers.forEach(function (value, name) {
headers[name] = value;
});
client(url, {body: body, method: method, headers: headers}).then(handler = function (resp) {
var response = request.respondWith(resp.body, {
status: resp.statusCode,
statusText: trim(resp.statusMessage)
});
each(resp.headers, function (value, name) {
response.headers.set(name, value);
});
resolve(response);
}, function (error$$1) { return handler(error$$1.response); });
});
} | [
"function",
"nodeClient",
"(",
"request",
")",
"{",
"var",
"client",
"=",
"require",
"(",
"'got'",
")",
";",
"return",
"new",
"PromiseObj",
"(",
"function",
"(",
"resolve",
")",
"{",
"var",
"url",
"=",
"request",
".",
"getUrl",
"(",
")",
";",
"var",
... | Http client (Node). | [
"Http",
"client",
"(",
"Node",
")",
"."
] | fe268fa1d6053ede5f34aef9a11e1a424a70446c | https://github.com/pagekit/vue-resource/blob/fe268fa1d6053ede5f34aef9a11e1a424a70446c/dist/vue-resource.esm.js#L1090-L1120 | train | nodeClient - node - client | [
30522,
3853,
13045,
20464,
11638,
1006,
5227,
1007,
1063,
13075,
7396,
1027,
5478,
1006,
1005,
2288,
1005,
1007,
1025,
2709,
2047,
4872,
16429,
3501,
1006,
3853,
1006,
10663,
1007,
1063,
13075,
24471,
2140,
1027,
5227,
1012,
2131,
3126,
214... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/core/utils/get-selector.js | getBaseSelector | function getBaseSelector(elm) {
if (typeof isXHTML === 'undefined') {
isXHTML = axe.utils.isXHTML(document);
}
return escapeSelector(isXHTML ? elm.localName : elm.nodeName.toLowerCase());
} | javascript | function getBaseSelector(elm) {
if (typeof isXHTML === 'undefined') {
isXHTML = axe.utils.isXHTML(document);
}
return escapeSelector(isXHTML ? elm.localName : elm.nodeName.toLowerCase());
} | [
"function",
"getBaseSelector",
"(",
"elm",
")",
"{",
"if",
"(",
"typeof",
"isXHTML",
"===",
"'undefined'",
")",
"{",
"isXHTML",
"=",
"axe",
".",
"utils",
".",
"isXHTML",
"(",
"document",
")",
";",
"}",
"return",
"escapeSelector",
"(",
"isXHTML",
"?",
"el... | Return the base CSS selector for a given element
@param {HTMLElement} elm The element to get the selector for
@return {String|Array<String>} Base CSS selector for the node | [
"Return",
"the",
"base",
"CSS",
"selector",
"for",
"a",
"given",
"element"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/get-selector.js#L222-L227 | train | Returns the base selector for the given element | [
30522,
3853,
2131,
15058,
11246,
22471,
2953,
1006,
17709,
1007,
1063,
2065,
1006,
2828,
11253,
2003,
2595,
11039,
19968,
1027,
1027,
1027,
1005,
6151,
28344,
1005,
1007,
1063,
2003,
2595,
11039,
19968,
1027,
12946,
1012,
21183,
12146,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.uxap/src/sap/uxap/component/Component.js | function () {
if (this._oView) {
this._oView.destroy();
this._oView = null;
}
if (this._oModel) {
this._oModel.destroy();
this._oModel = null;
}
if (UIComponent.prototype.destroy) {
UIComponent.prototype.destroy.call(this);
}
} | javascript | function () {
if (this._oView) {
this._oView.destroy();
this._oView = null;
}
if (this._oModel) {
this._oModel.destroy();
this._oModel = null;
}
if (UIComponent.prototype.destroy) {
UIComponent.prototype.destroy.call(this);
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"_oView",
")",
"{",
"this",
".",
"_oView",
".",
"destroy",
"(",
")",
";",
"this",
".",
"_oView",
"=",
"null",
";",
"}",
"if",
"(",
"this",
".",
"_oModel",
")",
"{",
"this",
".",
"_oModel",
".",... | destroy the view and model before exiting | [
"destroy",
"the",
"view",
"and",
"model",
"before",
"exiting"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.uxap/src/sap/uxap/component/Component.js#L106-L120 | train | Destroys the view model and UI elements | [
30522,
3853,
1006,
1007,
30524,
2023,
1012,
1035,
1051,
8584,
1027,
19701,
1025,
1065,
2065,
1006,
2023,
1012,
1035,
18168,
10244,
2140,
1007,
1063,
2023,
1012,
1035,
18168,
10244,
2140,
1012,
6033,
1006,
1007,
1025,
2023,
1012,
1035,
18168... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
elastic/elasticsearch-js | api/api/search_template.js | buildSearchTemplate | function buildSearchTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [search_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request
*
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @param {list} routing - A comma-separated list of specific routing values
* @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search
* @param {enum} search_type - Search operation type
* @param {boolean} explain - Specify whether to return detailed information about score computation as part of a hit
* @param {boolean} profile - Specify whether to profile the query execution
* @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response
* @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response
* @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
* @param {object} body - The search definition template and its params
*/
const acceptedQuerystring = [
'ignore_unavailable',
'ignore_throttled',
'allow_no_indices',
'expand_wildcards',
'preference',
'routing',
'scroll',
'search_type',
'explain',
'profile',
'typed_keys',
'rest_total_hits_as_int',
'ccs_minimize_roundtrips',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
ignoreUnavailable: 'ignore_unavailable',
ignoreThrottled: 'ignore_throttled',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
searchType: 'search_type',
typedKeys: 'typed_keys',
restTotalHitsAsInt: 'rest_total_hits_as_int',
ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function searchTemplate (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// check required url components
if (params['type'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = body == null ? 'GET' : 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + '/' + 'template'
} else if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template'
} else {
path = '/' + '_search' + '/' + 'template'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | javascript | function buildSearchTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [search_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request
*
* @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types
* @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed)
* @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled
* @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
* @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both.
* @param {string} preference - Specify the node or shard the operation should be performed on (default: random)
* @param {list} routing - A comma-separated list of specific routing values
* @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search
* @param {enum} search_type - Search operation type
* @param {boolean} explain - Specify whether to return detailed information about score computation as part of a hit
* @param {boolean} profile - Specify whether to profile the query execution
* @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response
* @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response
* @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution
* @param {object} body - The search definition template and its params
*/
const acceptedQuerystring = [
'ignore_unavailable',
'ignore_throttled',
'allow_no_indices',
'expand_wildcards',
'preference',
'routing',
'scroll',
'search_type',
'explain',
'profile',
'typed_keys',
'rest_total_hits_as_int',
'ccs_minimize_roundtrips',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
ignoreUnavailable: 'ignore_unavailable',
ignoreThrottled: 'ignore_throttled',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',
searchType: 'search_type',
typedKeys: 'typed_keys',
restTotalHitsAsInt: 'rest_total_hits_as_int',
ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function searchTemplate (params, options, callback) {
options = options || {}
if (typeof options === 'function') {
callback = options
options = {}
}
if (typeof params === 'function' || params == null) {
callback = params
params = {}
options = {}
}
// check required parameters
if (params['body'] == null) {
const err = new ConfigurationError('Missing required parameter: body')
return handleError(err, callback)
}
// check required url components
if (params['type'] != null && (params['index'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: index')
return handleError(err, callback)
}
// validate headers object
if (options.headers != null && typeof options.headers !== 'object') {
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
return handleError(err, callback)
}
var warnings = []
var { method, body, index, type, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = body == null ? 'GET' : 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((index) != null && (type) != null) {
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + '/' + 'template'
} else if ((index) != null) {
path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template'
} else {
path = '/' + '_search' + '/' + 'template'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | [
"function",
"buildSearchTemplate",
"(",
"opts",
")",
"{",
"// eslint-disable-next-line no-unused-vars",
"const",
"{",
"makeRequest",
",",
"ConfigurationError",
",",
"handleError",
",",
"snakeCaseKeys",
"}",
"=",
"opts",
"/**\n * Perform a [search_template](http://www.elastic.... | /* eslint camelcase: 0 /* eslint no-unused-vars: 0 | [
"/",
"*",
"eslint",
"camelcase",
":",
"0",
"/",
"*",
"eslint",
"no",
"-",
"unused",
"-",
"vars",
":",
"0"
] | 4fc4699a4d4474d7887bc7757e0269218a859294 | https://github.com/elastic/elasticsearch-js/blob/4fc4699a4d4474d7887bc7757e0269218a859294/api/api/search_template.js#L25-L147 | train | Build a search template | [
30522,
3853,
16473,
14644,
10143,
6633,
15725,
1006,
23569,
2015,
1007,
1063,
1013,
1013,
9686,
4115,
2102,
1011,
4487,
19150,
1011,
2279,
1011,
2240,
2053,
1011,
15171,
1011,
13075,
2015,
9530,
3367,
1063,
9338,
2063,
15500,
1010,
9563,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/LocaleData.js | getData | function getData(oLocale) {
var sLanguage = oLocale.getLanguage() || "",
sScript = oLocale.getScript() || "",
sRegion = oLocale.getRegion() || "",
mData;
/*
* Merge a CLDR delta file and a CLDR fallback file.
*
* Note: the contract of this method reg. null values differs from both,
* jQuery.extend as well as jQuery.sap.extend.
*/
function merge(obj, fallbackObj) {
var name, value, fallbackValue;
if ( !fallbackObj ) {
return;
}
for ( name in fallbackObj ) {
if ( fallbackObj.hasOwnProperty(name) ) {
value = obj[ name ];
fallbackValue = fallbackObj[ name ];
if ( value === undefined ) {
// 'undefined': value doesn't exist in delta, so take it from the fallback object
// Note: undefined is not a valid value in JSON, so we can't misunderstand an existing undefined
obj[name] = fallbackValue;
} else if ( value === null ) {
// 'null' is used by the delta tooling as a marker that a value must not be taken form the fallback
delete obj[name];
} else if ( typeof value === 'object' && typeof fallbackValue === 'object' ) {
// both values are objects, merge them recursively
merge(value, fallbackValue);
}
}
}
}
function getOrLoad(sId) {
if ( !mLocaleDatas[sId] && (!M_SUPPORTED_LOCALES || M_SUPPORTED_LOCALES[sId] === true) ) {
var data = mLocaleDatas[sId] = LoaderExtensions.loadResource("sap/ui/core/cldr/" + sId + ".json", {
dataType: "json",
failOnError : false
});
// check if the data is a minified delta file.
// If so, load the corresponding fallback data as well, merge it and remove the fallback marker
if ( data && data.__fallbackLocale ) {
merge(data, getOrLoad(data.__fallbackLocale));
delete data.__fallbackLocale;
}
// if load fails, null is returned
// -> caller will process the fallback chain, in the end a result is identified and stored in mDatas under the originally requested ID
}
return mLocaleDatas[sId];
}
// normalize language and handle special cases
sLanguage = (sLanguage && M_ISO639_OLD_TO_NEW[sLanguage]) || sLanguage;
// Special case 1: in an SAP context, the inclusive language code "no" always means Norwegian Bokmal ("nb")
if ( sLanguage === "no" ) {
sLanguage = "nb";
}
// Special case 2: for Chinese, derive a default region from the script (this behavior is inherited from Java)
if ( sLanguage === "zh" && !sRegion ) {
if ( sScript === "Hans" ) {
sRegion = "CN";
} else if ( sScript === "Hant" ) {
sRegion = "TW";
}
}
var sId = sLanguage + "_" + sRegion; // the originally requested locale; this is the key under which the result (even a fallback one) will be stored in the end
// first try: load CLDR data for specific language / region combination
if ( sLanguage && sRegion ) {
mData = getOrLoad(sId);
}
// second try: load data for language only
if ( !mData && sLanguage ) {
mData = getOrLoad(sLanguage);
}
// last try: use fallback data
mLocaleDatas[sId] = mData || M_DEFAULT_DATA;
return mLocaleDatas[sId];
} | javascript | function getData(oLocale) {
var sLanguage = oLocale.getLanguage() || "",
sScript = oLocale.getScript() || "",
sRegion = oLocale.getRegion() || "",
mData;
/*
* Merge a CLDR delta file and a CLDR fallback file.
*
* Note: the contract of this method reg. null values differs from both,
* jQuery.extend as well as jQuery.sap.extend.
*/
function merge(obj, fallbackObj) {
var name, value, fallbackValue;
if ( !fallbackObj ) {
return;
}
for ( name in fallbackObj ) {
if ( fallbackObj.hasOwnProperty(name) ) {
value = obj[ name ];
fallbackValue = fallbackObj[ name ];
if ( value === undefined ) {
// 'undefined': value doesn't exist in delta, so take it from the fallback object
// Note: undefined is not a valid value in JSON, so we can't misunderstand an existing undefined
obj[name] = fallbackValue;
} else if ( value === null ) {
// 'null' is used by the delta tooling as a marker that a value must not be taken form the fallback
delete obj[name];
} else if ( typeof value === 'object' && typeof fallbackValue === 'object' ) {
// both values are objects, merge them recursively
merge(value, fallbackValue);
}
}
}
}
function getOrLoad(sId) {
if ( !mLocaleDatas[sId] && (!M_SUPPORTED_LOCALES || M_SUPPORTED_LOCALES[sId] === true) ) {
var data = mLocaleDatas[sId] = LoaderExtensions.loadResource("sap/ui/core/cldr/" + sId + ".json", {
dataType: "json",
failOnError : false
});
// check if the data is a minified delta file.
// If so, load the corresponding fallback data as well, merge it and remove the fallback marker
if ( data && data.__fallbackLocale ) {
merge(data, getOrLoad(data.__fallbackLocale));
delete data.__fallbackLocale;
}
// if load fails, null is returned
// -> caller will process the fallback chain, in the end a result is identified and stored in mDatas under the originally requested ID
}
return mLocaleDatas[sId];
}
// normalize language and handle special cases
sLanguage = (sLanguage && M_ISO639_OLD_TO_NEW[sLanguage]) || sLanguage;
// Special case 1: in an SAP context, the inclusive language code "no" always means Norwegian Bokmal ("nb")
if ( sLanguage === "no" ) {
sLanguage = "nb";
}
// Special case 2: for Chinese, derive a default region from the script (this behavior is inherited from Java)
if ( sLanguage === "zh" && !sRegion ) {
if ( sScript === "Hans" ) {
sRegion = "CN";
} else if ( sScript === "Hant" ) {
sRegion = "TW";
}
}
var sId = sLanguage + "_" + sRegion; // the originally requested locale; this is the key under which the result (even a fallback one) will be stored in the end
// first try: load CLDR data for specific language / region combination
if ( sLanguage && sRegion ) {
mData = getOrLoad(sId);
}
// second try: load data for language only
if ( !mData && sLanguage ) {
mData = getOrLoad(sLanguage);
}
// last try: use fallback data
mLocaleDatas[sId] = mData || M_DEFAULT_DATA;
return mLocaleDatas[sId];
} | [
"function",
"getData",
"(",
"oLocale",
")",
"{",
"var",
"sLanguage",
"=",
"oLocale",
".",
"getLanguage",
"(",
")",
"||",
"\"\"",
",",
"sScript",
"=",
"oLocale",
".",
"getScript",
"(",
")",
"||",
"\"\"",
",",
"sRegion",
"=",
"oLocale",
".",
"getRegion",
... | Load LocaleData data from the CLDR generated files. | [
"Load",
"LocaleData",
"data",
"from",
"the",
"CLDR",
"generated",
"files",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/LocaleData.js#L3200-L3293 | train | Get the data for a locale | [
30522,
3853,
2131,
2850,
2696,
1006,
19330,
24755,
2571,
1007,
1063,
13075,
21435,
6692,
3351,
1027,
19330,
24755,
2571,
1012,
2131,
25023,
6692,
3351,
1006,
1007,
1064,
1064,
1000,
1000,
1010,
7020,
30524,
3258,
1027,
19330,
24755,
2571,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/main.js | _togglePref | function _togglePref(key, value) {
var val,
oldPref = !!prefs.get(key);
if (value === undefined) {
val = !oldPref;
} else {
val = !!value;
}
// update menu
if (val !== oldPref) {
prefs.set(key, val);
}
return val;
} | javascript | function _togglePref(key, value) {
var val,
oldPref = !!prefs.get(key);
if (value === undefined) {
val = !oldPref;
} else {
val = !!value;
}
// update menu
if (val !== oldPref) {
prefs.set(key, val);
}
return val;
} | [
"function",
"_togglePref",
"(",
"key",
",",
"value",
")",
"{",
"var",
"val",
",",
"oldPref",
"=",
"!",
"!",
"prefs",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"value",
"===",
"undefined",
")",
"{",
"val",
"=",
"!",
"oldPref",
";",
"}",
"else",... | Toggles or sets the preference * | [
"Toggles",
"or",
"sets",
"the",
"preference",
"*"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/main.js#L108-L124 | train | Toggles the preference of a key | [
30522,
3853,
1035,
2000,
24679,
28139,
2546,
1006,
3145,
1010,
3643,
1007,
1063,
13075,
11748,
1010,
2214,
28139,
2546,
1027,
999,
999,
3653,
10343,
1012,
2131,
1006,
3145,
1007,
1025,
2065,
1006,
3643,
1027,
1027,
1027,
6151,
28344,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fex-team/webuploader | _draft/music/webuploader.js | Image | function Image( opts ) {
this.options = $.extend({}, Image.options, opts );
RuntimeClient.call( this, 'Image' );
this.on( 'load', function() {
this._info = this.exec('info');
this._meta = this.exec('meta');
});
} | javascript | function Image( opts ) {
this.options = $.extend({}, Image.options, opts );
RuntimeClient.call( this, 'Image' );
this.on( 'load', function() {
this._info = this.exec('info');
this._meta = this.exec('meta');
});
} | [
"function",
"Image",
"(",
"opts",
")",
"{",
"this",
".",
"options",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"Image",
".",
"options",
",",
"opts",
")",
";",
"RuntimeClient",
".",
"call",
"(",
"this",
",",
"'Image'",
")",
";",
"this",
".",
"on... | 构造器。 | [
"构造器。"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/_draft/music/webuploader.js#L1811-L1819 | train | Image constructor. | [
30522,
3853,
3746,
1006,
23569,
2015,
1007,
1063,
2023,
1012,
7047,
1027,
1002,
1012,
7949,
1006,
1063,
1065,
1010,
3746,
1012,
7047,
1010,
23569,
2015,
1007,
1025,
2448,
7292,
20464,
11638,
1012,
2655,
1006,
2023,
1010,
1005,
3746,
1005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/core/a-assets.js | setCrossOrigin | function setCrossOrigin (mediaEl) {
var newMediaEl;
var src;
// Already has crossorigin set.
if (mediaEl.hasAttribute('crossorigin')) { return mediaEl; }
src = mediaEl.getAttribute('src');
if (src !== null) {
// Does not have protocol.
if (src.indexOf('://') === -1) { return mediaEl; }
// Determine if cross origin is actually needed.
if (extractDomain(src) === window.location.host) { return mediaEl; }
}
warn('Cross-origin element (e.g., <img>) was requested without `crossorigin` set. ' +
'A-Frame will re-request the asset with `crossorigin` attribute set. ' +
'Please set `crossorigin` on the element (e.g., <img crossorigin="anonymous">)', src);
mediaEl.crossOrigin = 'anonymous';
newMediaEl = mediaEl.cloneNode(true);
return newMediaEl;
} | javascript | function setCrossOrigin (mediaEl) {
var newMediaEl;
var src;
// Already has crossorigin set.
if (mediaEl.hasAttribute('crossorigin')) { return mediaEl; }
src = mediaEl.getAttribute('src');
if (src !== null) {
// Does not have protocol.
if (src.indexOf('://') === -1) { return mediaEl; }
// Determine if cross origin is actually needed.
if (extractDomain(src) === window.location.host) { return mediaEl; }
}
warn('Cross-origin element (e.g., <img>) was requested without `crossorigin` set. ' +
'A-Frame will re-request the asset with `crossorigin` attribute set. ' +
'Please set `crossorigin` on the element (e.g., <img crossorigin="anonymous">)', src);
mediaEl.crossOrigin = 'anonymous';
newMediaEl = mediaEl.cloneNode(true);
return newMediaEl;
} | [
"function",
"setCrossOrigin",
"(",
"mediaEl",
")",
"{",
"var",
"newMediaEl",
";",
"var",
"src",
";",
"// Already has crossorigin set.",
"if",
"(",
"mediaEl",
".",
"hasAttribute",
"(",
"'crossorigin'",
")",
")",
"{",
"return",
"mediaEl",
";",
"}",
"src",
"=",
... | Automatically set `crossorigin` if not defined on the media element.
If it is not defined, we must create and re-append a new media element <img> and
have the browser re-request it with `crossorigin` set.
@param {Element} Media element (e.g., <img>, <audio>, <video>).
@returns {Element} Media element to be used to listen to for loaded events. | [
"Automatically",
"set",
"crossorigin",
"if",
"not",
"defined",
"on",
"the",
"media",
"element",
".",
"If",
"it",
"is",
"not",
"defined",
"we",
"must",
"create",
"and",
"re",
"-",
"append",
"a",
"new",
"media",
"element",
"<img",
">",
"and",
"have",
"the"... | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/a-assets.js#L205-L228 | train | Sets cross - origin attribute on the media element. | [
30522,
3853,
2275,
16458,
10050,
11528,
1006,
2865,
2884,
1007,
1063,
13075,
2047,
16969,
2884,
1025,
13075,
5034,
2278,
1025,
1013,
1013,
2525,
2038,
2892,
10050,
11528,
2275,
1012,
2065,
1006,
2865,
2884,
1012,
2038,
19321,
3089,
8569,
26... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | read_wb_ID | function read_wb_ID(d, opts) {
var o = opts || {}, OLD_WTF = !!o.WTF; o.WTF = true;
try {
var out = SYLK.to_workbook(d, o);
o.WTF = OLD_WTF;
return out;
} catch(e) {
o.WTF = OLD_WTF;
if(!e.message.match(/SYLK bad record ID/) && OLD_WTF) throw e;
return PRN.to_workbook(d, opts);
}
} | javascript | function read_wb_ID(d, opts) {
var o = opts || {}, OLD_WTF = !!o.WTF; o.WTF = true;
try {
var out = SYLK.to_workbook(d, o);
o.WTF = OLD_WTF;
return out;
} catch(e) {
o.WTF = OLD_WTF;
if(!e.message.match(/SYLK bad record ID/) && OLD_WTF) throw e;
return PRN.to_workbook(d, opts);
}
} | [
"function",
"read_wb_ID",
"(",
"d",
",",
"opts",
")",
"{",
"var",
"o",
"=",
"opts",
"||",
"{",
"}",
",",
"OLD_WTF",
"=",
"!",
"!",
"o",
".",
"WTF",
";",
"o",
".",
"WTF",
"=",
"true",
";",
"try",
"{",
"var",
"out",
"=",
"SYLK",
".",
"to_workbo... | /* Excel defaults to SYLK but warns if data is not valid | [
"/",
"*",
"Excel",
"defaults",
"to",
"SYLK",
"but",
"warns",
"if",
"data",
"is",
"not",
"valid"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L7505-L7516 | train | read_wb_ID - read the WBID from the file | [
30522,
3853,
3191,
1035,
25610,
1035,
8909,
1006,
1040,
1010,
30524,
1010,
2214,
1035,
1059,
24475,
1027,
999,
999,
1051,
1012,
1059,
24475,
1025,
1051,
1012,
1059,
24475,
1027,
2995,
1025,
3046,
1063,
13075,
2041,
1027,
25353,
13687,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | realloc | function realloc(b, sz) {
var L = b.length, M = 2*L > sz ? 2*L : sz + 5, i = 0;
if(L >= sz) return b;
if(has_buf) {
var o = new_unsafe_buf(M);
// $FlowIgnore
if(b.copy) b.copy(o);
else for(; i < b.length; ++i) o[i] = b[i];
return o;
} else if(use_typed_arrays) {
var a = new Uint8Array(M);
if(a.set) a.set(b);
else for(; i < b.length; ++i) a[i] = b[i];
return a;
}
b.length = M;
return b;
} | javascript | function realloc(b, sz) {
var L = b.length, M = 2*L > sz ? 2*L : sz + 5, i = 0;
if(L >= sz) return b;
if(has_buf) {
var o = new_unsafe_buf(M);
// $FlowIgnore
if(b.copy) b.copy(o);
else for(; i < b.length; ++i) o[i] = b[i];
return o;
} else if(use_typed_arrays) {
var a = new Uint8Array(M);
if(a.set) a.set(b);
else for(; i < b.length; ++i) a[i] = b[i];
return a;
}
b.length = M;
return b;
} | [
"function",
"realloc",
"(",
"b",
",",
"sz",
")",
"{",
"var",
"L",
"=",
"b",
".",
"length",
",",
"M",
"=",
"2",
"*",
"L",
">",
"sz",
"?",
"2",
"*",
"L",
":",
"sz",
"+",
"5",
",",
"i",
"=",
"0",
";",
"if",
"(",
"L",
">=",
"sz",
")",
"re... | /* until ArrayBuffer#realloc is a thing, fake a realloc | [
"/",
"*",
"until",
"ArrayBuffer#realloc",
"is",
"a",
"thing",
"fake",
"a",
"realloc"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L2019-L2036 | train | realloc - allocates a buffer of size sz | [
30522,
3853,
2613,
4135,
2278,
1006,
1038,
1010,
1055,
2480,
1007,
1063,
13075,
1048,
1027,
1038,
1012,
3091,
1010,
1049,
1027,
1016,
1008,
1048,
1028,
1055,
2480,
1029,
1016,
1008,
1048,
1024,
1055,
2480,
1009,
1019,
1010,
1045,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.demokit/src/sap/ui/demokit/explored/view/entity.controller.js | function () {
this.router = UIComponent.getRouterFor(this);
this.router.attachRoutePatternMatched(this.onRouteMatched, this);
this._component = Component.getOwnerComponentFor(this.getView());
// click handler for @link tags in JSdoc fragments
this.getView().attachBrowserEvent("click", this.onJSDocLinkClick, this);
this.getView().addEventDelegate({
onBeforeFirstShow: jQuery.proxy(this._applyViewConfigurations, this)
});
} | javascript | function () {
this.router = UIComponent.getRouterFor(this);
this.router.attachRoutePatternMatched(this.onRouteMatched, this);
this._component = Component.getOwnerComponentFor(this.getView());
// click handler for @link tags in JSdoc fragments
this.getView().attachBrowserEvent("click", this.onJSDocLinkClick, this);
this.getView().addEventDelegate({
onBeforeFirstShow: jQuery.proxy(this._applyViewConfigurations, this)
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"router",
"=",
"UIComponent",
".",
"getRouterFor",
"(",
"this",
")",
";",
"this",
".",
"router",
".",
"attachRoutePatternMatched",
"(",
"this",
".",
"onRouteMatched",
",",
"this",
")",
";",
"this",
".",
"_component",... | ====== event handling ==================================================================== | [
"======",
"event",
"handling",
"===================================================================="
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.demokit/src/sap/ui/demokit/explored/view/entity.controller.js#L32-L42 | train | Attaches event listeners to the view | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
2799,
2099,
1027,
21318,
9006,
29513,
3372,
1012,
2131,
22494,
3334,
29278,
1006,
2023,
1007,
1025,
2023,
1012,
2799,
2099,
1012,
22476,
22494,
2618,
4502,
12079,
2078,
18900,
7690,
1006,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.ux3/src/sap/ui/ux3/NotificationBarRenderer.js | function(oRm, oMessageNotifier, oNotiBar) {
if (oMessageNotifier.hasItems()) {
var aMessages = oMessageNotifier.getMessages();
var lastItem = aMessages[aMessages.length - 1];
var oMA = oMessageNotifier._oMessageArea;
// this ensures that this message is selectable from the bar
oMA._message = lastItem;
var sId = oNotiBar.getId() + "-inplaceMessage-" + oMA._message.getId();
oRm.write("<li");
oRm.writeAttribute("id", sId);
oRm.addClass("sapUiInPlaceMessage");
oRm.writeClasses();
if (oNotiBar._gapMessageArea) {
var sMargin = oNotiBar._gapMessageArea + "px";
oRm.addStyle("margin-left", sMargin);
oRm.writeStyles();
}
oRm.write(">");
// oRm.renderControl(oMA);
if (lastItem.getText() != "") {
oRm.write("<div");
oRm.writeControlData(oMA);
// enable inplace message for item navigation
oRm.writeAttribute("tabindex", "-1");
oRm.addClass("sapUiNotifierMessageText");
oRm.addClass("sapUiInPlaceMessage");
// if the latest message is read-only don't provide a visual selectable link
if (oMessageNotifier._bEnableMessageSelect && !oMA._message.getReadOnly()) {
// if there is an event handler show the inplace message
// clickable
oRm.addClass("sapUiInPlaceMessageSelectable");
}
oRm.writeClasses();
oRm.write(">");
oRm.writeEscaped(lastItem.getText());
oRm.write("</div>"); // Text
}
if (lastItem.getTimestamp() != "") {
oRm.write("<div");
oRm.addClass("sapUiNotifierMessageTimestamp");
oRm.addClass("sapUiInPlaceMessage");
oRm.writeClasses();
oRm.write(">");
oRm.writeEscaped(lastItem.getTimestamp());
oRm.write("</div>"); // Timestamp
}
oRm.write("</li>");
}
} | javascript | function(oRm, oMessageNotifier, oNotiBar) {
if (oMessageNotifier.hasItems()) {
var aMessages = oMessageNotifier.getMessages();
var lastItem = aMessages[aMessages.length - 1];
var oMA = oMessageNotifier._oMessageArea;
// this ensures that this message is selectable from the bar
oMA._message = lastItem;
var sId = oNotiBar.getId() + "-inplaceMessage-" + oMA._message.getId();
oRm.write("<li");
oRm.writeAttribute("id", sId);
oRm.addClass("sapUiInPlaceMessage");
oRm.writeClasses();
if (oNotiBar._gapMessageArea) {
var sMargin = oNotiBar._gapMessageArea + "px";
oRm.addStyle("margin-left", sMargin);
oRm.writeStyles();
}
oRm.write(">");
// oRm.renderControl(oMA);
if (lastItem.getText() != "") {
oRm.write("<div");
oRm.writeControlData(oMA);
// enable inplace message for item navigation
oRm.writeAttribute("tabindex", "-1");
oRm.addClass("sapUiNotifierMessageText");
oRm.addClass("sapUiInPlaceMessage");
// if the latest message is read-only don't provide a visual selectable link
if (oMessageNotifier._bEnableMessageSelect && !oMA._message.getReadOnly()) {
// if there is an event handler show the inplace message
// clickable
oRm.addClass("sapUiInPlaceMessageSelectable");
}
oRm.writeClasses();
oRm.write(">");
oRm.writeEscaped(lastItem.getText());
oRm.write("</div>"); // Text
}
if (lastItem.getTimestamp() != "") {
oRm.write("<div");
oRm.addClass("sapUiNotifierMessageTimestamp");
oRm.addClass("sapUiInPlaceMessage");
oRm.writeClasses();
oRm.write(">");
oRm.writeEscaped(lastItem.getTimestamp());
oRm.write("</div>"); // Timestamp
}
oRm.write("</li>");
}
} | [
"function",
"(",
"oRm",
",",
"oMessageNotifier",
",",
"oNotiBar",
")",
"{",
"if",
"(",
"oMessageNotifier",
".",
"hasItems",
"(",
")",
")",
"{",
"var",
"aMessages",
"=",
"oMessageNotifier",
".",
"getMessages",
"(",
")",
";",
"var",
"lastItem",
"=",
"aMessag... | Renders the message area next to a message notifier | [
"Renders",
"the",
"message",
"area",
"next",
"to",
"a",
"message",
"notifier"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.ux3/src/sap/ui/ux3/NotificationBarRenderer.js#L466-L520 | train | Renders the message area | [
30522,
3853,
1006,
2030,
2213,
1010,
18168,
7971,
4270,
17048,
18095,
1010,
21058,
3775,
8237,
1007,
1063,
2065,
1006,
18168,
7971,
4270,
17048,
18095,
1012,
2038,
4221,
5244,
1006,
1007,
1007,
1063,
13075,
19900,
3736,
8449,
1027,
18168,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
openlayers/openlayers | examples/wms-custom-proj.js | CHtoWGSlng | function CHtoWGSlng(y, x) {
// Converts militar to civil and to unit = 1000km
// Axiliary values (% Bern)
const y_aux = (y - 600000) / 1000000;
const x_aux = (x - 200000) / 1000000;
// Process long
let lng = 2.6779094 +
4.728982 * y_aux +
0.791484 * y_aux * x_aux +
0.1306 * y_aux * Math.pow(x_aux, 2) -
0.0436 * Math.pow(y_aux, 3);
// Unit 10000" to 1 " and converts seconds to degrees (dec)
lng = lng * 100 / 36;
return lng;
} | javascript | function CHtoWGSlng(y, x) {
// Converts militar to civil and to unit = 1000km
// Axiliary values (% Bern)
const y_aux = (y - 600000) / 1000000;
const x_aux = (x - 200000) / 1000000;
// Process long
let lng = 2.6779094 +
4.728982 * y_aux +
0.791484 * y_aux * x_aux +
0.1306 * y_aux * Math.pow(x_aux, 2) -
0.0436 * Math.pow(y_aux, 3);
// Unit 10000" to 1 " and converts seconds to degrees (dec)
lng = lng * 100 / 36;
return lng;
} | [
"function",
"CHtoWGSlng",
"(",
"y",
",",
"x",
")",
"{",
"// Converts militar to civil and to unit = 1000km",
"// Axiliary values (% Bern)",
"const",
"y_aux",
"=",
"(",
"y",
"-",
"600000",
")",
"/",
"1000000",
";",
"const",
"x_aux",
"=",
"(",
"x",
"-",
"200000",... | Convert CH y/x to WGS long | [
"Convert",
"CH",
"y",
"/",
"x",
"to",
"WGS",
"long"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/wms-custom-proj.js#L170-L189 | train | Convert CH to WGS lng | [
30522,
3853,
10381,
18790,
5620,
19666,
2290,
1006,
1061,
1010,
1060,
1007,
1063,
1013,
1013,
19884,
23689,
6590,
2099,
2000,
2942,
1998,
2000,
3131,
1027,
6694,
22287,
1013,
1013,
22260,
27861,
2854,
5300,
1006,
1003,
16595,
1007,
9530,
33... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/lines-around-comment.js | isParentNodeType | function isParentNodeType(parent, nodeType) {
return parent.type === nodeType ||
(parent.body && parent.body.type === nodeType) ||
(parent.consequent && parent.consequent.type === nodeType);
} | javascript | function isParentNodeType(parent, nodeType) {
return parent.type === nodeType ||
(parent.body && parent.body.type === nodeType) ||
(parent.consequent && parent.consequent.type === nodeType);
} | [
"function",
"isParentNodeType",
"(",
"parent",
",",
"nodeType",
")",
"{",
"return",
"parent",
".",
"type",
"===",
"nodeType",
"||",
"(",
"parent",
".",
"body",
"&&",
"parent",
".",
"body",
".",
"type",
"===",
"nodeType",
")",
"||",
"(",
"parent",
".",
... | Returns whether or not comments are inside a node type or not.
@param {ASTNode} parent The Comment parent node.
@param {string} nodeType The parent type to check against.
@returns {boolean} True if the comment is inside nodeType. | [
"Returns",
"whether",
"or",
"not",
"comments",
"are",
"inside",
"a",
"node",
"type",
"or",
"not",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/lines-around-comment.js#L181-L185 | train | Check if parent node type is the same as nodeType | [
30522,
3853,
2003,
19362,
4765,
3630,
3207,
13874,
1006,
6687,
1010,
13045,
13874,
1007,
1063,
2709,
6687,
1012,
2828,
1027,
1027,
1027,
13045,
13874,
1064,
1064,
1006,
6687,
1012,
2303,
1004,
1004,
6687,
1012,
2303,
1012,
2828,
1027,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(method, restoreScrollPosition) {
var body = this.doc.body,
oldScrollTop = restoreScrollPosition && body.scrollTop,
oldScrollLeft = restoreScrollPosition && body.scrollLeft,
className = "_wysihtml5-temp-placeholder",
placeholderHtml = '<span class="' + className + '">' + wysihtml5.INVISIBLE_SPACE + '</span>',
range = this.getRange(true),
caretPlaceholder,
newCaretPlaceholder,
nextSibling, prevSibling,
node, node2, range2,
newRange;
// Nothing selected, execute and say goodbye
if (!range) {
method(body, body);
return;
}
if (!range.collapsed) {
range2 = range.cloneRange();
node2 = range2.createContextualFragment(placeholderHtml);
range2.collapse(false);
range2.insertNode(node2);
range2.detach();
}
node = range.createContextualFragment(placeholderHtml);
range.insertNode(node);
if (node2) {
caretPlaceholder = this.contain.querySelectorAll("." + className);
range.setStartBefore(caretPlaceholder[0]);
range.setEndAfter(caretPlaceholder[caretPlaceholder.length -1]);
}
this.setSelection(range);
// Make sure that a potential error doesn't cause our placeholder element to be left as a placeholder
try {
method(range.startContainer, range.endContainer);
} catch(e) {
setTimeout(function() { throw e; }, 0);
}
caretPlaceholder = this.contain.querySelectorAll("." + className);
if (caretPlaceholder && caretPlaceholder.length) {
newRange = rangy.createRange(this.doc);
nextSibling = caretPlaceholder[0].nextSibling;
if (caretPlaceholder.length > 1) {
prevSibling = caretPlaceholder[caretPlaceholder.length -1].previousSibling;
}
if (prevSibling && nextSibling) {
newRange.setStartBefore(nextSibling);
newRange.setEndAfter(prevSibling);
} else {
newCaretPlaceholder = this.doc.createTextNode(wysihtml5.INVISIBLE_SPACE);
dom.insert(newCaretPlaceholder).after(caretPlaceholder[0]);
newRange.setStartBefore(newCaretPlaceholder);
newRange.setEndAfter(newCaretPlaceholder);
}
this.setSelection(newRange);
for (var i = caretPlaceholder.length; i--;) {
caretPlaceholder[i].parentNode.removeChild(caretPlaceholder[i]);
}
} else {
// fallback for when all hell breaks loose
this.contain.focus();
}
if (restoreScrollPosition) {
body.scrollTop = oldScrollTop;
body.scrollLeft = oldScrollLeft;
}
// Remove it again, just to make sure that the placeholder is definitely out of the dom tree
try {
caretPlaceholder.parentNode.removeChild(caretPlaceholder);
} catch(e2) {}
} | javascript | function(method, restoreScrollPosition) {
var body = this.doc.body,
oldScrollTop = restoreScrollPosition && body.scrollTop,
oldScrollLeft = restoreScrollPosition && body.scrollLeft,
className = "_wysihtml5-temp-placeholder",
placeholderHtml = '<span class="' + className + '">' + wysihtml5.INVISIBLE_SPACE + '</span>',
range = this.getRange(true),
caretPlaceholder,
newCaretPlaceholder,
nextSibling, prevSibling,
node, node2, range2,
newRange;
// Nothing selected, execute and say goodbye
if (!range) {
method(body, body);
return;
}
if (!range.collapsed) {
range2 = range.cloneRange();
node2 = range2.createContextualFragment(placeholderHtml);
range2.collapse(false);
range2.insertNode(node2);
range2.detach();
}
node = range.createContextualFragment(placeholderHtml);
range.insertNode(node);
if (node2) {
caretPlaceholder = this.contain.querySelectorAll("." + className);
range.setStartBefore(caretPlaceholder[0]);
range.setEndAfter(caretPlaceholder[caretPlaceholder.length -1]);
}
this.setSelection(range);
// Make sure that a potential error doesn't cause our placeholder element to be left as a placeholder
try {
method(range.startContainer, range.endContainer);
} catch(e) {
setTimeout(function() { throw e; }, 0);
}
caretPlaceholder = this.contain.querySelectorAll("." + className);
if (caretPlaceholder && caretPlaceholder.length) {
newRange = rangy.createRange(this.doc);
nextSibling = caretPlaceholder[0].nextSibling;
if (caretPlaceholder.length > 1) {
prevSibling = caretPlaceholder[caretPlaceholder.length -1].previousSibling;
}
if (prevSibling && nextSibling) {
newRange.setStartBefore(nextSibling);
newRange.setEndAfter(prevSibling);
} else {
newCaretPlaceholder = this.doc.createTextNode(wysihtml5.INVISIBLE_SPACE);
dom.insert(newCaretPlaceholder).after(caretPlaceholder[0]);
newRange.setStartBefore(newCaretPlaceholder);
newRange.setEndAfter(newCaretPlaceholder);
}
this.setSelection(newRange);
for (var i = caretPlaceholder.length; i--;) {
caretPlaceholder[i].parentNode.removeChild(caretPlaceholder[i]);
}
} else {
// fallback for when all hell breaks loose
this.contain.focus();
}
if (restoreScrollPosition) {
body.scrollTop = oldScrollTop;
body.scrollLeft = oldScrollLeft;
}
// Remove it again, just to make sure that the placeholder is definitely out of the dom tree
try {
caretPlaceholder.parentNode.removeChild(caretPlaceholder);
} catch(e2) {}
} | [
"function",
"(",
"method",
",",
"restoreScrollPosition",
")",
"{",
"var",
"body",
"=",
"this",
".",
"doc",
".",
"body",
",",
"oldScrollTop",
"=",
"restoreScrollPosition",
"&&",
"body",
".",
"scrollTop",
",",
"oldScrollLeft",
"=",
"restoreScrollPosition",
"&&",
... | TODO: has problems in chrome 12. investigate block level and uneditable area inbetween | [
"TODO",
":",
"has",
"problems",
"in",
"chrome",
"12",
".",
"investigate",
"block",
"level",
"and",
"uneditable",
"area",
"inbetween"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L9068-L9146 | train | Executes a method on the selection. | [
30522,
3853,
1006,
4118,
1010,
9239,
11020,
28402,
26994,
1007,
1063,
13075,
2303,
1027,
2023,
1012,
9986,
1012,
2303,
1010,
19457,
26775,
14511,
14399,
1027,
9239,
11020,
28402,
26994,
1004,
1004,
2303,
1012,
17186,
14399,
1010,
19457,
26775... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | javascript/node/selenium-webdriver/lib/promise.js | filter | async function filter(array, fn, self = undefined) {
const v = await Promise.resolve(array);
if (!Array.isArray(v)) {
throw TypeError('not an array');
}
const arr = /** @type {!Array} */(v);
const n = arr.length;
const values = [];
let valuesLength = 0;
for (let i = 0; i < n; i++) {
if (i in arr) {
let value = arr[i];
let include = await fn.call(self, value, i, arr);
if (include) {
values[valuesLength++] = value;
}
}
}
return values;
} | javascript | async function filter(array, fn, self = undefined) {
const v = await Promise.resolve(array);
if (!Array.isArray(v)) {
throw TypeError('not an array');
}
const arr = /** @type {!Array} */(v);
const n = arr.length;
const values = [];
let valuesLength = 0;
for (let i = 0; i < n; i++) {
if (i in arr) {
let value = arr[i];
let include = await fn.call(self, value, i, arr);
if (include) {
values[valuesLength++] = value;
}
}
}
return values;
} | [
"async",
"function",
"filter",
"(",
"array",
",",
"fn",
",",
"self",
"=",
"undefined",
")",
"{",
"const",
"v",
"=",
"await",
"Promise",
".",
"resolve",
"(",
"array",
")",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"v",
")",
")",
"{",
"thr... | Calls a function for each element in an array, and if the function returns
true adds the element to a new array.
If the return value of the filter function is a promise, this function
will wait for it to be fulfilled before determining whether to insert the
element into the new array.
If the filter function throws or returns a rejected promise, the promise
returned by this function will be rejected with the same reason. Only the
first failure will be reported; all subsequent errors will be silently
ignored.
@param {!(Array<TYPE>|IThenable<!Array<TYPE>>)} array The array to iterate
over, or a promise that will resolve to said array.
@param {function(this: SELF, TYPE, number, !Array<TYPE>): (
boolean|IThenable<boolean>)} fn The function
to call for each element in the array.
@param {SELF=} self The object to be used as the value of 'this' within `fn`.
@template TYPE, SELF | [
"Calls",
"a",
"function",
"for",
"each",
"element",
"in",
"an",
"array",
"and",
"if",
"the",
"function",
"returns",
"true",
"adds",
"the",
"element",
"to",
"a",
"new",
"array",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/node/selenium-webdriver/lib/promise.js#L193-L214 | train | filter function for array | [
30522,
2004,
6038,
2278,
3853,
11307,
1006,
9140,
1010,
1042,
2078,
1010,
2969,
1027,
6151,
28344,
1007,
1063,
9530,
3367,
1058,
1027,
26751,
4872,
1012,
10663,
30524,
1008,
1030,
2828,
1063,
999,
9140,
1065,
1008,
1013,
1006,
1058,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.f/src/sap/f/shellBar/ResponsiveHandler.js | function (oContext) {
oControl = oContext;
// Get and calculate padding's
this._iREMSize = parseInt(jQuery("body").css("font-size"));
this._iChildControlMargin = parseInt(Parameters.get("_sap_f_ShellBar_ChildMargin"));
this._iDoubleChildControlMargin = this._iChildControlMargin * 2;
this._iCoPilotWidth = parseInt(Parameters.get("_sap_f_ShellBar_CoPilotWidth")) + this._iDoubleChildControlMargin;
this._iHalfCoPilotWidth = this._iCoPilotWidth / 2;
// Delegate used to attach on ShellBar lifecycle events
this._oDelegate = {
onAfterRendering: this.onAfterRendering,
onBeforeRendering: this.onBeforeRendering
};
// Attach Event Delegates
oControl.addDelegate(this._oDelegate, false, this);
// Init resize handler method
this._fnResize = this._resize;
// Attach events
oControl._oOverflowToolbar.attachEvent("_controlWidthChanged", this._handleResize, this);
} | javascript | function (oContext) {
oControl = oContext;
// Get and calculate padding's
this._iREMSize = parseInt(jQuery("body").css("font-size"));
this._iChildControlMargin = parseInt(Parameters.get("_sap_f_ShellBar_ChildMargin"));
this._iDoubleChildControlMargin = this._iChildControlMargin * 2;
this._iCoPilotWidth = parseInt(Parameters.get("_sap_f_ShellBar_CoPilotWidth")) + this._iDoubleChildControlMargin;
this._iHalfCoPilotWidth = this._iCoPilotWidth / 2;
// Delegate used to attach on ShellBar lifecycle events
this._oDelegate = {
onAfterRendering: this.onAfterRendering,
onBeforeRendering: this.onBeforeRendering
};
// Attach Event Delegates
oControl.addDelegate(this._oDelegate, false, this);
// Init resize handler method
this._fnResize = this._resize;
// Attach events
oControl._oOverflowToolbar.attachEvent("_controlWidthChanged", this._handleResize, this);
} | [
"function",
"(",
"oContext",
")",
"{",
"oControl",
"=",
"oContext",
";",
"// Get and calculate padding's",
"this",
".",
"_iREMSize",
"=",
"parseInt",
"(",
"jQuery",
"(",
"\"body\"",
")",
".",
"css",
"(",
"\"font-size\"",
")",
")",
";",
"this",
".",
"_iChildC... | Class taking care of the control responsive behaviour.
@alias sap/f/shellBar/ResponsiveHandler
@since 1.63
@private
@property {object} oContext the context of the ShellBar control instance | [
"Class",
"taking",
"care",
"of",
"the",
"control",
"responsive",
"behaviour",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.f/src/sap/f/shellBar/ResponsiveHandler.js#L29-L53 | train | Initializes the ShellBar | [
30522,
3853,
1006,
1051,
8663,
18209,
1007,
1063,
1051,
8663,
13181,
2140,
1027,
1051,
8663,
18209,
1025,
1013,
1013,
2131,
1998,
18422,
11687,
4667,
1005,
1055,
2023,
1012,
1035,
20868,
6633,
5332,
4371,
1027,
11968,
20240,
3372,
1006,
104... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dequelabs/axe-core | lib/core/utils/dq-element.js | truncate | function truncate(str, maxLength) {
maxLength = maxLength || 300;
if (str.length > maxLength) {
var index = str.indexOf('>');
str = str.substring(0, index + 1);
}
return str;
} | javascript | function truncate(str, maxLength) {
maxLength = maxLength || 300;
if (str.length > maxLength) {
var index = str.indexOf('>');
str = str.substring(0, index + 1);
}
return str;
} | [
"function",
"truncate",
"(",
"str",
",",
"maxLength",
")",
"{",
"maxLength",
"=",
"maxLength",
"||",
"300",
";",
"if",
"(",
"str",
".",
"length",
">",
"maxLength",
")",
"{",
"var",
"index",
"=",
"str",
".",
"indexOf",
"(",
"'>'",
")",
";",
"str",
"... | /*exported DqElement | [
"/",
"*",
"exported",
"DqElement"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/dq-element.js#L3-L12 | train | Truncate a string to a specified length | [
30522,
3853,
19817,
4609,
16280,
1006,
2358,
2099,
1010,
4098,
7770,
13512,
2232,
1007,
1063,
4098,
7770,
13512,
2232,
1027,
4098,
7770,
13512,
2232,
1064,
1064,
3998,
1025,
2065,
1006,
2358,
2099,
1012,
3091,
1028,
4098,
7770,
13512,
2232,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/FileTreeViewModel.js | _filePathToObjectPath | function _filePathToObjectPath(treeData, path) {
if (path === null) {
return null;
} else if (path === "") {
return [];
}
var parts = path.split("/"),
part = parts.shift(),
result = [],
node;
// Step through the parts of the path and the treeData object simultaneously
while (part) {
// We hit the end of the tree without finding our object, so return null
if (!treeData) {
return null;
}
node = treeData.get(part);
// The name represented by `part` isn't in the tree, so return null.
if (node === undefined) {
return null;
}
// We've verified this part, so store it.
result.push(part);
// Pull the next part of the path
part = parts.shift();
// If we haven't passed the end of the path string, then the object we've got in hand
// *should* be a directory. Confirm that and add `children` to the path to move down
// to the next directory level.
if (part) {
treeData = node.get("children");
if (treeData) {
result.push("children");
}
}
}
return result;
} | javascript | function _filePathToObjectPath(treeData, path) {
if (path === null) {
return null;
} else if (path === "") {
return [];
}
var parts = path.split("/"),
part = parts.shift(),
result = [],
node;
// Step through the parts of the path and the treeData object simultaneously
while (part) {
// We hit the end of the tree without finding our object, so return null
if (!treeData) {
return null;
}
node = treeData.get(part);
// The name represented by `part` isn't in the tree, so return null.
if (node === undefined) {
return null;
}
// We've verified this part, so store it.
result.push(part);
// Pull the next part of the path
part = parts.shift();
// If we haven't passed the end of the path string, then the object we've got in hand
// *should* be a directory. Confirm that and add `children` to the path to move down
// to the next directory level.
if (part) {
treeData = node.get("children");
if (treeData) {
result.push("children");
}
}
}
return result;
} | [
"function",
"_filePathToObjectPath",
"(",
"treeData",
",",
"path",
")",
"{",
"if",
"(",
"path",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"if",
"(",
"path",
"===",
"\"\"",
")",
"{",
"return",
"[",
"]",
";",
"}",
"var",
"parts",
"... | @private
Converts a project-relative file path into an object path array suitable for
`Immutable.Map.getIn` and `Immutable.Map.updateIn`.
The root path is "".
@param {Immutable.Map} treeData
@param {string} path project relative path to the file or directory. Can include trailing slash.
@return {Array.<string>|null} Returns null if the path can't be found in the tree, otherwise an array of strings representing the path through the object. | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileTreeViewModel.js#L172-L216 | train | Get the object of the given path | [
30522,
3853,
1035,
5371,
15069,
3406,
16429,
20614,
15069,
1006,
3392,
2850,
2696,
1010,
4130,
1007,
1063,
2065,
1006,
4130,
1027,
1027,
1027,
19701,
1007,
1063,
2709,
19701,
1025,
1065,
2842,
2065,
1006,
4130,
1027,
1027,
1027,
1000,
1000,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/angular | tools/gulp-tasks/cldr/extract.js | getCurrencySettings | function getCurrencySettings(locale, localeData) {
const currencyInfo = localeData.main(`numbers/currencies`);
let currentCurrency = '';
// find the currency currently used in this country
const currencies =
localeData.get(`supplemental/currencyData/region/${localeData.attributes.territory}`) ||
localeData.get(`supplemental/currencyData/region/${localeData.attributes.language.toUpperCase()}`);
if (currencies) {
currencies.some(currency => {
const keys = Object.keys(currency);
return keys.some(key => {
if (currency[key]._from && !currency[key]._to) {
return currentCurrency = key;
}
});
});
if (!currentCurrency) {
throw new Error(`Unable to find currency for locale "${locale}"`);
}
}
let currencySettings = [undefined, undefined];
if (currentCurrency) {
currencySettings = [currencyInfo[currentCurrency].symbol, currencyInfo[currentCurrency].displayName];
}
return currencySettings;
} | javascript | function getCurrencySettings(locale, localeData) {
const currencyInfo = localeData.main(`numbers/currencies`);
let currentCurrency = '';
// find the currency currently used in this country
const currencies =
localeData.get(`supplemental/currencyData/region/${localeData.attributes.territory}`) ||
localeData.get(`supplemental/currencyData/region/${localeData.attributes.language.toUpperCase()}`);
if (currencies) {
currencies.some(currency => {
const keys = Object.keys(currency);
return keys.some(key => {
if (currency[key]._from && !currency[key]._to) {
return currentCurrency = key;
}
});
});
if (!currentCurrency) {
throw new Error(`Unable to find currency for locale "${locale}"`);
}
}
let currencySettings = [undefined, undefined];
if (currentCurrency) {
currencySettings = [currencyInfo[currentCurrency].symbol, currencyInfo[currentCurrency].displayName];
}
return currencySettings;
} | [
"function",
"getCurrencySettings",
"(",
"locale",
",",
"localeData",
")",
"{",
"const",
"currencyInfo",
"=",
"localeData",
".",
"main",
"(",
"`",
"`",
")",
";",
"let",
"currentCurrency",
"=",
"''",
";",
"// find the currency currently used in this country",
"const",... | Returns the currency symbol and name for a locale
@returns [ symbol, name ] | [
"Returns",
"the",
"currency",
"symbol",
"and",
"name",
"for",
"a",
"locale"
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/tools/gulp-tasks/cldr/extract.js#L465-L496 | train | Get currency settings for a locale | [
30522,
3853,
2131,
10841,
14343,
9407,
21678,
8613,
1006,
2334,
2063,
1010,
2334,
11960,
2696,
1007,
1063,
9530,
3367,
9598,
2378,
14876,
1027,
2334,
11960,
2696,
1012,
2364,
1006,
1036,
3616,
1013,
12731,
14343,
14767,
1036,
1007,
1025,
22... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/LiveDevMultiBrowser.js | _onDocumentSaved | function _onDocumentSaved(event, doc) {
if (!isActive() || !_server) {
return;
}
var absolutePath = doc.file.fullPath,
liveDocument = absolutePath && _server.get(absolutePath),
liveEditingEnabled = liveDocument && liveDocument.isLiveEditingEnabled && liveDocument.isLiveEditingEnabled();
// Skip reload if the saved document has live editing enabled
if (liveEditingEnabled) {
return;
}
// reload the page if the given document is a JS file related
// to the current live document.
if (_liveDocument.isRelated(absolutePath)) {
if (doc.getLanguage().getId() === "javascript") {
_setStatus(STATUS_RELOADING);
_protocol.reload();
}
}
} | javascript | function _onDocumentSaved(event, doc) {
if (!isActive() || !_server) {
return;
}
var absolutePath = doc.file.fullPath,
liveDocument = absolutePath && _server.get(absolutePath),
liveEditingEnabled = liveDocument && liveDocument.isLiveEditingEnabled && liveDocument.isLiveEditingEnabled();
// Skip reload if the saved document has live editing enabled
if (liveEditingEnabled) {
return;
}
// reload the page if the given document is a JS file related
// to the current live document.
if (_liveDocument.isRelated(absolutePath)) {
if (doc.getLanguage().getId() === "javascript") {
_setStatus(STATUS_RELOADING);
_protocol.reload();
}
}
} | [
"function",
"_onDocumentSaved",
"(",
"event",
",",
"doc",
")",
"{",
"if",
"(",
"!",
"isActive",
"(",
")",
"||",
"!",
"_server",
")",
"{",
"return",
";",
"}",
"var",
"absolutePath",
"=",
"doc",
".",
"file",
".",
"fullPath",
",",
"liveDocument",
"=",
"... | For files that don't support as-you-type live editing, but are loaded by live HTML documents
(e.g. JS files), we want to reload the full document when they're saved.
@param {$.Event} event
@param {Document} doc | [
"For",
"files",
"that",
"don",
"t",
"support",
"as",
"-",
"you",
"-",
"type",
"live",
"editing",
"but",
"are",
"loaded",
"by",
"live",
"HTML",
"documents",
"(",
"e",
".",
"g",
".",
"JS",
"files",
")",
"we",
"want",
"to",
"reload",
"the",
"full",
"d... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevMultiBrowser.js#L725-L747 | train | The event handler for the document saved event | [
30522,
3853,
1035,
2006,
3527,
24894,
11187,
10696,
2094,
1006,
2724,
1010,
9986,
1007,
1063,
2065,
1006,
999,
18061,
15277,
1006,
1007,
1064,
1064,
999,
1035,
8241,
1007,
1063,
2709,
1025,
1065,
13075,
7619,
15069,
1027,
9986,
1012,
5371,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
react-spring/react-spring | src/renderprops/animated/AnimatedValue.js | findAnimatedStyles | function findAnimatedStyles(node, styles) {
if (typeof node.update === 'function') styles.add(node)
else node.getChildren().forEach(child => findAnimatedStyles(child, styles))
} | javascript | function findAnimatedStyles(node, styles) {
if (typeof node.update === 'function') styles.add(node)
else node.getChildren().forEach(child => findAnimatedStyles(child, styles))
} | [
"function",
"findAnimatedStyles",
"(",
"node",
",",
"styles",
")",
"{",
"if",
"(",
"typeof",
"node",
".",
"update",
"===",
"'function'",
")",
"styles",
".",
"add",
"(",
"node",
")",
"else",
"node",
".",
"getChildren",
"(",
")",
".",
"forEach",
"(",
"ch... | Animated works by building a directed acyclic graph of dependencies
transparently when you render your Animated components.
new Animated.Value(0)
.interpolate() .interpolate() new Animated.Value(1)
opacity translateY scale
style transform
View#234 style
View#123
A) Top Down phase
When an Animated.Value is updated, we recursively go down through this
graph in order to find leaf nodes: the views that we flag as needing
an update.
B) Bottom Up phase
When a view is flagged as needing an update, we recursively go back up
in order to build the new value that it needs. The reason why we need
this two-phases process is to deal with composite props such as
transform which can receive values from multiple parents. | [
"Animated",
"works",
"by",
"building",
"a",
"directed",
"acyclic",
"graph",
"of",
"dependencies",
"transparently",
"when",
"you",
"render",
"your",
"Animated",
"components",
"."
] | 807a1bb14822c97212fe54082ea5a675de499020 | https://github.com/react-spring/react-spring/blob/807a1bb14822c97212fe54082ea5a675de499020/src/renderprops/animated/AnimatedValue.js#L27-L30 | train | Recursively find animated styles for a node | [
30522,
3853,
2424,
7088,
8585,
5104,
27983,
2015,
1006,
13045,
1010,
6782,
1007,
1063,
2065,
1006,
2828,
11253,
13045,
1012,
10651,
1027,
1027,
1027,
1005,
3853,
1005,
1007,
6782,
1012,
5587,
1006,
13045,
1007,
2842,
13045,
1012,
2131,
1933... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/checks/navigation/region.js | findRegionlessElms | function findRegionlessElms(virtualNode) {
const node = virtualNode.actualNode;
// End recursion if the element is a landmark, skiplink, or hidden content
if (
isRegion(virtualNode) ||
(dom.isSkipLink(virtualNode.actualNode) &&
dom.getElementByReference(virtualNode.actualNode, 'href')) ||
!dom.isVisible(node, true)
) {
return [];
// Return the node is a content element
} else if (dom.hasContent(node, /* noRecursion: */ true)) {
return [node];
// Recursively look at all child elements
} else {
return virtualNode.children
.filter(({ actualNode }) => actualNode.nodeType === 1)
.map(findRegionlessElms)
.reduce((a, b) => a.concat(b), []); // flatten the results
}
} | javascript | function findRegionlessElms(virtualNode) {
const node = virtualNode.actualNode;
// End recursion if the element is a landmark, skiplink, or hidden content
if (
isRegion(virtualNode) ||
(dom.isSkipLink(virtualNode.actualNode) &&
dom.getElementByReference(virtualNode.actualNode, 'href')) ||
!dom.isVisible(node, true)
) {
return [];
// Return the node is a content element
} else if (dom.hasContent(node, /* noRecursion: */ true)) {
return [node];
// Recursively look at all child elements
} else {
return virtualNode.children
.filter(({ actualNode }) => actualNode.nodeType === 1)
.map(findRegionlessElms)
.reduce((a, b) => a.concat(b), []); // flatten the results
}
} | [
"function",
"findRegionlessElms",
"(",
"virtualNode",
")",
"{",
"const",
"node",
"=",
"virtualNode",
".",
"actualNode",
";",
"// End recursion if the element is a landmark, skiplink, or hidden content",
"if",
"(",
"isRegion",
"(",
"virtualNode",
")",
"||",
"(",
"dom",
"... | Find all visible elements not wrapped inside a landmark or skiplink | [
"Find",
"all",
"visible",
"elements",
"not",
"wrapped",
"inside",
"a",
"landmark",
"or",
"skiplink"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/checks/navigation/region.js#L41-L63 | train | Find all regionless elements | [
30522,
3853,
2424,
23784,
3238,
2884,
5244,
1006,
7484,
3630,
3207,
1007,
1063,
9530,
3367,
13045,
1027,
7484,
3630,
3207,
1012,
5025,
3630,
3207,
1025,
1013,
1013,
2203,
28667,
9236,
3258,
2065,
1996,
5783,
2003,
1037,
8637,
1010,
13558,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
uber/deck.gl | modules/core/src/utils/get.js | getGetter | function getGetter(container) {
// Check if container has a special get method
const prototype = Object.getPrototypeOf(container);
return prototype.get ? getMethodGetter : squareBracketGetter;
} | javascript | function getGetter(container) {
// Check if container has a special get method
const prototype = Object.getPrototypeOf(container);
return prototype.get ? getMethodGetter : squareBracketGetter;
} | [
"function",
"getGetter",
"(",
"container",
")",
"{",
"// Check if container has a special get method",
"const",
"prototype",
"=",
"Object",
".",
"getPrototypeOf",
"(",
"container",
")",
";",
"return",
"prototype",
".",
"get",
"?",
"getMethodGetter",
":",
"squareBracke... | Looks for a `get` function on the prototype TODO - follow prototype chain? @private @return {Function} - get function: (container, key) => value | [
"Looks",
"for",
"a",
"get",
"function",
"on",
"the",
"prototype",
"TODO",
"-",
"follow",
"prototype",
"chain?"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/core/src/utils/get.js#L68-L72 | train | Get getter for a container | [
30522,
3853,
2131,
18150,
3334,
1006,
11661,
1007,
1063,
1013,
1013,
4638,
2065,
11661,
2038,
1037,
2569,
2131,
4118,
9530,
3367,
8773,
1027,
4874,
1012,
2131,
21572,
3406,
13874,
11253,
1006,
11661,
1007,
1025,
2709,
8773,
1012,
2131,
1029... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/input-mask/jquery.inputmask.date.extensions.js | function (chrs, buffer, pos, strict, opts) {
if (opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
var dayMonthValue = buffer.join('').substr(0, 6);
if (dayMonthValue != opts.leapday)
return true;
else {
var year = parseInt(chrs, 10);//detect leap year
if (year % 4 === 0)
if (year % 100 === 0)
if (year % 400 === 0)
return true;
else return false;
else return true;
else return false;
}
} else return false;
} | javascript | function (chrs, buffer, pos, strict, opts) {
if (opts.isInYearRange(chrs, opts.yearrange.minyear, opts.yearrange.maxyear)) {
var dayMonthValue = buffer.join('').substr(0, 6);
if (dayMonthValue != opts.leapday)
return true;
else {
var year = parseInt(chrs, 10);//detect leap year
if (year % 4 === 0)
if (year % 100 === 0)
if (year % 400 === 0)
return true;
else return false;
else return true;
else return false;
}
} else return false;
} | [
"function",
"(",
"chrs",
",",
"buffer",
",",
"pos",
",",
"strict",
",",
"opts",
")",
"{",
"if",
"(",
"opts",
".",
"isInYearRange",
"(",
"chrs",
",",
"opts",
".",
"yearrange",
".",
"minyear",
",",
"opts",
".",
"yearrange",
".",
"maxyear",
")",
")",
... | year | [
"year"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/input-mask/jquery.inputmask.date.extensions.js#L150-L166 | train | check if the chrs is a leap year | [
30522,
3853,
1006,
10381,
2869,
1010,
17698,
1010,
13433,
2015,
1010,
9384,
1010,
23569,
2015,
1007,
1063,
2065,
1006,
23569,
2015,
1012,
2003,
24300,
14644,
24388,
2063,
1006,
10381,
2869,
1010,
23569,
2015,
1012,
2095,
24388,
2063,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/type/Decimal.js | getText | function getText(sKey, aParams) {
return sap.ui.getCore().getLibraryResourceBundle().getText(sKey, aParams);
} | javascript | function getText(sKey, aParams) {
return sap.ui.getCore().getLibraryResourceBundle().getText(sKey, aParams);
} | [
"function",
"getText",
"(",
"sKey",
",",
"aParams",
")",
"{",
"return",
"sap",
".",
"ui",
".",
"getCore",
"(",
")",
".",
"getLibraryResourceBundle",
"(",
")",
".",
"getText",
"(",
"sKey",
",",
"aParams",
")",
";",
"}"
] | Fetches a text from the message bundle and formats it using the parameters.
@param {string} sKey
the message key
@param {any[]} aParams
the message parameters
@returns {string}
the message | [
"Fetches",
"a",
"text",
"from",
"the",
"message",
"bundle",
"and",
"formats",
"it",
"using",
"the",
"parameters",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/type/Decimal.js#L68-L70 | train | Returns the text of the given key. | [
30522,
3853,
2131,
18209,
1006,
15315,
3240,
1010,
9706,
5400,
5244,
1007,
1063,
2709,
20066,
1012,
21318,
1012,
2131,
17345,
1006,
1007,
1012,
2131,
29521,
19848,
16363,
6499,
3126,
3401,
27265,
2571,
1006,
1007,
1012,
2131,
18209,
1006,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/MasterTreeBaseController.js | function (oEvent) {
// Update filter value
this._sFilter = oEvent.getParameter("newValue").trim();
if (this._filterTimeout) {
clearTimeout(this._filterTimeout);
}
this._filterTimeout = setTimeout(function () {
if (this.buildAndApplyFilters()) {
this._expandAllNodes();
} else {
this._collapseAllNodes();
if (this.oSelectedItem) {
this._expandTreeToNode(this.oSelectedItem.sTopicId, this.oSelectedItem.oModel);
}
}
this._filterTimeout = null;
}.bind(this), 250);
} | javascript | function (oEvent) {
// Update filter value
this._sFilter = oEvent.getParameter("newValue").trim();
if (this._filterTimeout) {
clearTimeout(this._filterTimeout);
}
this._filterTimeout = setTimeout(function () {
if (this.buildAndApplyFilters()) {
this._expandAllNodes();
} else {
this._collapseAllNodes();
if (this.oSelectedItem) {
this._expandTreeToNode(this.oSelectedItem.sTopicId, this.oSelectedItem.oModel);
}
}
this._filterTimeout = null;
}.bind(this), 250);
} | [
"function",
"(",
"oEvent",
")",
"{",
"// Update filter value",
"this",
".",
"_sFilter",
"=",
"oEvent",
".",
"getParameter",
"(",
"\"newValue\"",
")",
".",
"trim",
"(",
")",
";",
"if",
"(",
"this",
".",
"_filterTimeout",
")",
"{",
"clearTimeout",
"(",
"this... | Handler for the SearchField
@param oEvent | [
"Handler",
"for",
"the",
"SearchField"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/MasterTreeBaseController.js#L95-L117 | train | Updates the filter value | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
1013,
1013,
10651,
11307,
3643,
2023,
1012,
1035,
16420,
4014,
3334,
1027,
1051,
18697,
3372,
1012,
2131,
28689,
22828,
1006,
1000,
2047,
10175,
5657,
1000,
1007,
1012,
12241,
1006,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nodejs/node-gyp | lib/configure.js | checkCommand | function checkCommand (command, errorCallback) {
var exec = command
var args = this.argsExecutable
var shell = false
if (this.win) {
// Arguments have to be manually quoted
exec = `"${exec}"`
args = args.map(a => `"${a}"`)
shell = true
}
this.log.verbose(`- executing "${command}" to get executable path`)
this.run(exec, args, shell, function (err, execPath) {
// Possible outcomes:
// - Error: not in PATH, not executable or execution fails
// - Gibberish: the next command to check version will fail
// - Absolute path to executable
if (err) {
this.addLog(`- "${command}" is not in PATH or produced an error`)
return errorCallback(err)
}
this.addLog(`- executable path is "${execPath}"`)
this.checkExecPath(execPath, errorCallback)
}.bind(this))
} | javascript | function checkCommand (command, errorCallback) {
var exec = command
var args = this.argsExecutable
var shell = false
if (this.win) {
// Arguments have to be manually quoted
exec = `"${exec}"`
args = args.map(a => `"${a}"`)
shell = true
}
this.log.verbose(`- executing "${command}" to get executable path`)
this.run(exec, args, shell, function (err, execPath) {
// Possible outcomes:
// - Error: not in PATH, not executable or execution fails
// - Gibberish: the next command to check version will fail
// - Absolute path to executable
if (err) {
this.addLog(`- "${command}" is not in PATH or produced an error`)
return errorCallback(err)
}
this.addLog(`- executable path is "${execPath}"`)
this.checkExecPath(execPath, errorCallback)
}.bind(this))
} | [
"function",
"checkCommand",
"(",
"command",
",",
"errorCallback",
")",
"{",
"var",
"exec",
"=",
"command",
"var",
"args",
"=",
"this",
".",
"argsExecutable",
"var",
"shell",
"=",
"false",
"if",
"(",
"this",
".",
"win",
")",
"{",
"// Arguments have to be manu... | Check if command is a valid Python to use. Will exit the Python finder on success. If on Windows, run in a CMD shell to support BAT/CMD launchers. | [
"Check",
"if",
"command",
"is",
"a",
"valid",
"Python",
"to",
"use",
".",
"Will",
"exit",
"the",
"Python",
"finder",
"on",
"success",
".",
"If",
"on",
"Windows",
"run",
"in",
"a",
"CMD",
"shell",
"to",
"support",
"BAT",
"/",
"CMD",
"launchers",
"."
] | 721eb691cf15556cc2700eda0558d5bad5f84232 | https://github.com/nodejs/node-gyp/blob/721eb691cf15556cc2700eda0558d5bad5f84232/lib/configure.js#L490-L514 | train | Check the executable path of the command | [
30522,
3853,
4638,
9006,
2386,
2094,
1006,
3094,
1010,
7561,
9289,
20850,
8684,
1007,
1063,
13075,
4654,
8586,
1027,
3094,
13075,
12098,
5620,
1027,
2023,
1012,
12098,
5620,
10288,
8586,
23056,
13075,
5806,
1027,
6270,
2065,
1006,
2023,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/signals.js | function (listener, listenerContext, priority) {
validateListener(listener, 'addOnce');
return this._registerListener(listener, true, listenerContext, priority);
} | javascript | function (listener, listenerContext, priority) {
validateListener(listener, 'addOnce');
return this._registerListener(listener, true, listenerContext, priority);
} | [
"function",
"(",
"listener",
",",
"listenerContext",
",",
"priority",
")",
"{",
"validateListener",
"(",
"listener",
",",
"'addOnce'",
")",
";",
"return",
"this",
".",
"_registerListener",
"(",
"listener",
",",
"true",
",",
"listenerContext",
",",
"priority",
... | Add listener to the signal that should be removed after first execution (will be executed only once).
@param {Function} listener Signal handler function.
@param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
@param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
@return {SignalBinding} An Object representing the binding between the Signal and listener. | [
"Add",
"listener",
"to",
"the",
"signal",
"that",
"should",
"be",
"removed",
"after",
"first",
"execution",
"(",
"will",
"be",
"executed",
"only",
"once",
")",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/signals.js#L308-L311 | train | Add a listener to the event queue. | [
30522,
3853,
1006,
19373,
1010,
19373,
8663,
18209,
1010,
9470,
1007,
1063,
9398,
3686,
9863,
24454,
1006,
19373,
1010,
1005,
5587,
2239,
3401,
1005,
1007,
1025,
2709,
2023,
1012,
1035,
4236,
9863,
24454,
1006,
19373,
1010,
2995,
1010,
1937... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SheetJS/js-xlsx | bits/27_csfutils.js | encode_range | function encode_range(cs/*:CellAddrSpec|Range*/,ce/*:?CellAddrSpec*/)/*:string*/ {
if(typeof ce === 'undefined' || typeof ce === 'number') {
/*:: if(!(cs instanceof Range)) throw "unreachable"; */
return encode_range(cs.s, cs.e);
}
/*:: if((cs instanceof Range)) throw "unreachable"; */
if(typeof cs !== 'string') cs = encode_cell((cs/*:any*/));
if(typeof ce !== 'string') ce = encode_cell((ce/*:any*/));
/*:: if(typeof cs !== 'string') throw "unreachable"; */
/*:: if(typeof ce !== 'string') throw "unreachable"; */
return cs == ce ? cs : cs + ":" + ce;
} | javascript | function encode_range(cs/*:CellAddrSpec|Range*/,ce/*:?CellAddrSpec*/)/*:string*/ {
if(typeof ce === 'undefined' || typeof ce === 'number') {
/*:: if(!(cs instanceof Range)) throw "unreachable"; */
return encode_range(cs.s, cs.e);
}
/*:: if((cs instanceof Range)) throw "unreachable"; */
if(typeof cs !== 'string') cs = encode_cell((cs/*:any*/));
if(typeof ce !== 'string') ce = encode_cell((ce/*:any*/));
/*:: if(typeof cs !== 'string') throw "unreachable"; */
/*:: if(typeof ce !== 'string') throw "unreachable"; */
return cs == ce ? cs : cs + ":" + ce;
} | [
"function",
"encode_range",
"(",
"cs",
"/*:CellAddrSpec|Range*/",
",",
"ce",
"/*:?CellAddrSpec*/",
")",
"/*:string*/",
"{",
"if",
"(",
"typeof",
"ce",
"===",
"'undefined'",
"||",
"typeof",
"ce",
"===",
"'number'",
")",
"{",
"/*:: if(!(cs instanceof Range)) throw \"unr... | /*# if only one arg, it is assumed to be a Range. If 2 args, both are cell addresses | [
"/",
"*",
"#",
"if",
"only",
"one",
"arg",
"it",
"is",
"assumed",
"to",
"be",
"a",
"Range",
".",
"If",
"2",
"args",
"both",
"are",
"cell",
"addresses"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/27_csfutils.js#L16-L27 | train | Encode a range of cells | [
30522,
3853,
4372,
16044,
1035,
2846,
1006,
20116,
1013,
1008,
1024,
3526,
4215,
13626,
13102,
8586,
1064,
2846,
1008,
1013,
1010,
8292,
1013,
1008,
1024,
1029,
3526,
4215,
13626,
13102,
8586,
1008,
1013,
1007,
1013,
1008,
1024,
5164,
1008,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
google/code-prettify | tasks/lib/lang-aliases.js | runLanguageHandler | function runLanguageHandler(src) {
// execute source code in an isolated sandbox with a mock PR object
var sandbox = createSandbox();
vm.runInNewContext(fs.readFileSync(src), sandbox, {
filename: src
});
// language name
var lang = path.basename(src, path.extname(src)).replace(/^lang-/, '');
// collect and filter extensions
var exts = sandbox.extensions.map(function (ext) {
// case-insensitive names
return ext.toLowerCase();
}).filter(function (ext) {
// skip self, and internal names like foo-bar-baz or lang.foo
return ext !== lang && !/\W/.test(ext);
});
exts = exts.filter(function (ext, pos) {
// remove duplicates
return exts.indexOf(ext) === pos;
});
return exts;
} | javascript | function runLanguageHandler(src) {
// execute source code in an isolated sandbox with a mock PR object
var sandbox = createSandbox();
vm.runInNewContext(fs.readFileSync(src), sandbox, {
filename: src
});
// language name
var lang = path.basename(src, path.extname(src)).replace(/^lang-/, '');
// collect and filter extensions
var exts = sandbox.extensions.map(function (ext) {
// case-insensitive names
return ext.toLowerCase();
}).filter(function (ext) {
// skip self, and internal names like foo-bar-baz or lang.foo
return ext !== lang && !/\W/.test(ext);
});
exts = exts.filter(function (ext, pos) {
// remove duplicates
return exts.indexOf(ext) === pos;
});
return exts;
} | [
"function",
"runLanguageHandler",
"(",
"src",
")",
"{",
"// execute source code in an isolated sandbox with a mock PR object",
"var",
"sandbox",
"=",
"createSandbox",
"(",
")",
";",
"vm",
".",
"runInNewContext",
"(",
"fs",
".",
"readFileSync",
"(",
"src",
")",
",",
... | Runs a language handler file under VM to collect extensions.
Given a lang-*.js file, runs the language handler in a fake context where
PR.registerLangHandler collects handler names without doing anything else.
This is later used to makes copies of the JS extension under all its
registered language names lang-<EXT>.js
@param {string} src path to lang-xxx.js language handler
@return {Array<string>} registered file extensions | [
"Runs",
"a",
"language",
"handler",
"file",
"under",
"VM",
"to",
"collect",
"extensions",
"."
] | e14ed1c3c40f78fca2a11af4cb0fa251f6f997fc | https://github.com/google/code-prettify/blob/e14ed1c3c40f78fca2a11af4cb0fa251f6f997fc/tasks/lib/lang-aliases.js#L67-L90 | train | Runs the language handler in a sandbox | [
30522,
3853,
2448,
25023,
6692,
3351,
11774,
3917,
1006,
5034,
2278,
1007,
1063,
1013,
1013,
15389,
3120,
3642,
1999,
2019,
7275,
5472,
8758,
2007,
1037,
12934,
10975,
4874,
13075,
5472,
8758,
1027,
9005,
5685,
8758,
1006,
1007,
1025,
1058,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/util/BindingsExtractor.js | getBindingsFromTemplateProperties | function getBindingsFromTemplateProperties(oElement) {
var aPropertiesKeys = Object.keys(oElement.getMetadata().getAllProperties());
return aPropertiesKeys
.filter(function (sPropertyName) {
return sPropertyName in oElement.mBindingInfos;
})
.reduce(function (aBindings, sPropertyName) {
return aBindings.concat(
flattenBindingsFromTemplate(
oElement.mBindingInfos[sPropertyName]
)
);
}, []);
} | javascript | function getBindingsFromTemplateProperties(oElement) {
var aPropertiesKeys = Object.keys(oElement.getMetadata().getAllProperties());
return aPropertiesKeys
.filter(function (sPropertyName) {
return sPropertyName in oElement.mBindingInfos;
})
.reduce(function (aBindings, sPropertyName) {
return aBindings.concat(
flattenBindingsFromTemplate(
oElement.mBindingInfos[sPropertyName]
)
);
}, []);
} | [
"function",
"getBindingsFromTemplateProperties",
"(",
"oElement",
")",
"{",
"var",
"aPropertiesKeys",
"=",
"Object",
".",
"keys",
"(",
"oElement",
".",
"getMetadata",
"(",
")",
".",
"getAllProperties",
"(",
")",
")",
";",
"return",
"aPropertiesKeys",
".",
"filte... | Retrieving all bindings from all available properties for a specified element of template
@param {sap.ui.core.Control} oElement - element to get bindings from
@return {Array} - returns found bindings
@private | [
"Retrieving",
"all",
"bindings",
"from",
"all",
"available",
"properties",
"for",
"a",
"specified",
"element",
"of",
"template"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/util/BindingsExtractor.js#L219-L233 | train | Get all bindings from template properties | [
30522,
3853,
2131,
8428,
4667,
22747,
21716,
18532,
15725,
21572,
4842,
7368,
1006,
1051,
12260,
3672,
1007,
1063,
13075,
19804,
25918,
7368,
14839,
2015,
1027,
4874,
1012,
6309,
1006,
1051,
12260,
3672,
1012,
2131,
11368,
8447,
2696,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | function(element)
{
try
{
if (element != null)
{
mxEvent.removeAllListeners(element);
var children = element.childNodes;
if (children != null)
{
var childCount = children.length;
for (var i = 0; i < childCount; i += 1)
{
mxEvent.release(children[i]);
}
}
}
}
catch (e)
{
// ignores errors as this is typically called in cleanup code
}
} | javascript | function(element)
{
try
{
if (element != null)
{
mxEvent.removeAllListeners(element);
var children = element.childNodes;
if (children != null)
{
var childCount = children.length;
for (var i = 0; i < childCount; i += 1)
{
mxEvent.release(children[i]);
}
}
}
}
catch (e)
{
// ignores errors as this is typically called in cleanup code
}
} | [
"function",
"(",
"element",
")",
"{",
"try",
"{",
"if",
"(",
"element",
"!=",
"null",
")",
"{",
"mxEvent",
".",
"removeAllListeners",
"(",
"element",
")",
";",
"var",
"children",
"=",
"element",
".",
"childNodes",
";",
"if",
"(",
"children",
"!=",
"nul... | Function: release
Removes the known listeners from the given DOM node and its descendants.
Parameters:
element - DOM node to remove the listeners from. | [
"Function",
":",
"release"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L9683-L9708 | train | Removes all listeners from an element | [
30522,
3853,
1006,
5783,
1007,
1063,
3046,
1063,
2065,
1006,
5783,
999,
1027,
19701,
1007,
1063,
25630,
18697,
3372,
1012,
6366,
8095,
9863,
24454,
2015,
1006,
5783,
1007,
1025,
13075,
2336,
1027,
5783,
1012,
2775,
3630,
6155,
1025,
2065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nhn/tui.editor | src/js/extensions/table/tableDataHandler.js | _addMergedCell | function _addMergedCell(base, cellData, startRowIndex, startCellIndex) {
const {
colspan,
rowspan,
nodeName
} = cellData;
const colMerged = colspan > 1;
const rowMerged = rowspan > 1;
if (!colMerged && !rowMerged) {
return;
}
const limitRowIndex = startRowIndex + rowspan;
const limitCellIndex = startCellIndex + colspan;
util.range(startRowIndex, limitRowIndex).forEach(rowIndex => {
base[rowIndex] = base[rowIndex] || [];
util.range(startCellIndex, limitCellIndex).forEach(cellIndex => {
const mergedData = {
nodeName
};
if (rowIndex === startRowIndex && cellIndex === startCellIndex) {
return;
}
if (colMerged) {
mergedData.colMergeWith = startCellIndex;
}
if (rowMerged) {
mergedData.rowMergeWith = startRowIndex;
}
base[rowIndex][cellIndex] = mergedData;
});
});
} | javascript | function _addMergedCell(base, cellData, startRowIndex, startCellIndex) {
const {
colspan,
rowspan,
nodeName
} = cellData;
const colMerged = colspan > 1;
const rowMerged = rowspan > 1;
if (!colMerged && !rowMerged) {
return;
}
const limitRowIndex = startRowIndex + rowspan;
const limitCellIndex = startCellIndex + colspan;
util.range(startRowIndex, limitRowIndex).forEach(rowIndex => {
base[rowIndex] = base[rowIndex] || [];
util.range(startCellIndex, limitCellIndex).forEach(cellIndex => {
const mergedData = {
nodeName
};
if (rowIndex === startRowIndex && cellIndex === startCellIndex) {
return;
}
if (colMerged) {
mergedData.colMergeWith = startCellIndex;
}
if (rowMerged) {
mergedData.rowMergeWith = startRowIndex;
}
base[rowIndex][cellIndex] = mergedData;
});
});
} | [
"function",
"_addMergedCell",
"(",
"base",
",",
"cellData",
",",
"startRowIndex",
",",
"startCellIndex",
")",
"{",
"const",
"{",
"colspan",
",",
"rowspan",
",",
"nodeName",
"}",
"=",
"cellData",
";",
"const",
"colMerged",
"=",
"colspan",
">",
"1",
";",
"co... | Add merged cell.
@param {object} base - base table data
@param {object} cellData - cell data
@param {number} startRowIndex - start row index
@param {number} startCellIndex - start cell index
@private | [
"Add",
"merged",
"cell",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/tableDataHandler.js#L58-L97 | train | Add merged cell to base | [
30522,
3853,
1035,
5587,
5017,
5999,
29109,
2140,
1006,
2918,
1010,
3526,
2850,
2696,
1010,
2707,
10524,
22254,
10288,
1010,
2707,
29109,
27164,
10288,
1007,
1063,
9530,
3367,
1063,
8902,
13102,
2319,
1010,
10281,
9739,
1010,
13045,
18442,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
nhn/tui.editor | src/js/wysiwygCommands/tableAddRow.js | getSelectedRowsLength | function getSelectedRowsLength(wwe) {
const selectionMgr = wwe.componentManager.getManager('tableSelection');
const $selectedCells = selectionMgr.getSelectedCells();
let length = 1;
if ($selectedCells.length > 1) {
const first = $selectedCells.first().get(0);
const last = $selectedCells.last().get(0);
const range = selectionMgr.getSelectionRangeFromTable(first, last);
length = range.to.row - range.from.row + 1;
}
return length;
} | javascript | function getSelectedRowsLength(wwe) {
const selectionMgr = wwe.componentManager.getManager('tableSelection');
const $selectedCells = selectionMgr.getSelectedCells();
let length = 1;
if ($selectedCells.length > 1) {
const first = $selectedCells.first().get(0);
const last = $selectedCells.last().get(0);
const range = selectionMgr.getSelectionRangeFromTable(first, last);
length = range.to.row - range.from.row + 1;
}
return length;
} | [
"function",
"getSelectedRowsLength",
"(",
"wwe",
")",
"{",
"const",
"selectionMgr",
"=",
"wwe",
".",
"componentManager",
".",
"getManager",
"(",
"'tableSelection'",
")",
";",
"const",
"$selectedCells",
"=",
"selectionMgr",
".",
"getSelectedCells",
"(",
")",
";",
... | get number of selected rows
@param {WysiwygEditor} wwe - wysiwygEditor instance
@returns {number} - number of selected rows
@ignore | [
"get",
"number",
"of",
"selected",
"rows"
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/wysiwygCommands/tableAddRow.js#L59-L72 | train | Returns the number of selected rows | [
30522,
3853,
4152,
12260,
10985,
10524,
25016,
3070,
2705,
1006,
11700,
1007,
1063,
9530,
3367,
4989,
24798,
2099,
1027,
11700,
1012,
6922,
24805,
4590,
1012,
2131,
24805,
4590,
1006,
1005,
7251,
12260,
7542,
1005,
1007,
1025,
9530,
3367,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/output/website/prepareI18n.js | prepareI18n | function prepareI18n(output) {
var state = output.getState();
var i18n = state.getI18n();
var searchPaths = listSearchPaths(output);
searchPaths
.reverse()
.forEach(function(searchPath) {
var i18nRoot = path.resolve(searchPath, '_i18n');
if (!fs.existsSync(i18nRoot)) return;
i18n.load(i18nRoot);
});
return Promise(output);
} | javascript | function prepareI18n(output) {
var state = output.getState();
var i18n = state.getI18n();
var searchPaths = listSearchPaths(output);
searchPaths
.reverse()
.forEach(function(searchPath) {
var i18nRoot = path.resolve(searchPath, '_i18n');
if (!fs.existsSync(i18nRoot)) return;
i18n.load(i18nRoot);
});
return Promise(output);
} | [
"function",
"prepareI18n",
"(",
"output",
")",
"{",
"var",
"state",
"=",
"output",
".",
"getState",
"(",
")",
";",
"var",
"i18n",
"=",
"state",
".",
"getI18n",
"(",
")",
";",
"var",
"searchPaths",
"=",
"listSearchPaths",
"(",
"output",
")",
";",
"searc... | Prepare i18n, load translations from plugins and book
@param {Output}
@return {Promise<Output>} | [
"Prepare",
"i18n",
"load",
"translations",
"from",
"plugins",
"and",
"book"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/website/prepareI18n.js#L13-L28 | train | prepareI18n - prepare the i18n | [
30522,
3853,
7374,
2072,
15136,
2078,
1006,
6434,
1007,
1063,
13075,
2110,
1027,
6434,
1012,
4152,
12259,
1006,
1007,
1025,
13075,
1045,
15136,
2078,
1027,
2110,
1012,
2131,
2072,
15136,
2078,
1006,
1007,
1025,
13075,
3945,
15069,
2015,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/timepicker/bootstrap-timepicker.js | function(element, options) {
this.widget = '';
this.$element = $(element);
this.defaultTime = options.defaultTime;
this.disableFocus = options.disableFocus;
this.disableMousewheel = options.disableMousewheel;
this.isOpen = options.isOpen;
this.minuteStep = options.minuteStep;
this.modalBackdrop = options.modalBackdrop;
this.orientation = options.orientation;
this.secondStep = options.secondStep;
this.snapToStep = options.snapToStep;
this.showInputs = options.showInputs;
this.showMeridian = options.showMeridian;
this.showSeconds = options.showSeconds;
this.template = options.template;
this.appendWidgetTo = options.appendWidgetTo;
this.showWidgetOnAddonClick = options.showWidgetOnAddonClick;
this.icons = options.icons;
this.maxHours = options.maxHours;
this.explicitMode = options.explicitMode; // If true 123 = 1:23, 12345 = 1:23:45, else invalid.
this.handleDocumentClick = function (e) {
var self = e.data.scope;
// This condition was inspired by bootstrap-datepicker.
// The element the timepicker is invoked on is the input but it has a sibling for addon/button.
if (!(self.$element.parent().find(e.target).length ||
self.$widget.is(e.target) ||
self.$widget.find(e.target).length)) {
self.hideWidget();
}
};
this._init();
} | javascript | function(element, options) {
this.widget = '';
this.$element = $(element);
this.defaultTime = options.defaultTime;
this.disableFocus = options.disableFocus;
this.disableMousewheel = options.disableMousewheel;
this.isOpen = options.isOpen;
this.minuteStep = options.minuteStep;
this.modalBackdrop = options.modalBackdrop;
this.orientation = options.orientation;
this.secondStep = options.secondStep;
this.snapToStep = options.snapToStep;
this.showInputs = options.showInputs;
this.showMeridian = options.showMeridian;
this.showSeconds = options.showSeconds;
this.template = options.template;
this.appendWidgetTo = options.appendWidgetTo;
this.showWidgetOnAddonClick = options.showWidgetOnAddonClick;
this.icons = options.icons;
this.maxHours = options.maxHours;
this.explicitMode = options.explicitMode; // If true 123 = 1:23, 12345 = 1:23:45, else invalid.
this.handleDocumentClick = function (e) {
var self = e.data.scope;
// This condition was inspired by bootstrap-datepicker.
// The element the timepicker is invoked on is the input but it has a sibling for addon/button.
if (!(self.$element.parent().find(e.target).length ||
self.$widget.is(e.target) ||
self.$widget.find(e.target).length)) {
self.hideWidget();
}
};
this._init();
} | [
"function",
"(",
"element",
",",
"options",
")",
"{",
"this",
".",
"widget",
"=",
"''",
";",
"this",
".",
"$element",
"=",
"$",
"(",
"element",
")",
";",
"this",
".",
"defaultTime",
"=",
"options",
".",
"defaultTime",
";",
"this",
".",
"disableFocus",
... | TIMEPICKER PUBLIC CLASS DEFINITION | [
"TIMEPICKER",
"PUBLIC",
"CLASS",
"DEFINITION"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/timepicker/bootstrap-timepicker.js#L15-L49 | train | Constructor for timepicker | [
30522,
30524,
12398,
7292,
1027,
7047,
1012,
12398,
7292,
1025,
2023,
1012,
4487,
19150,
14876,
7874,
1027,
7047,
1012,
4487,
19150,
14876,
7874,
1025,
2023,
1012,
4487,
19150,
27711,
7974,
21030,
2140,
1027,
7047,
1012,
4487,
19150,
27711,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
google/closure-library | closure/goog/html/cssspecificity.js | calculateSpecificity | function calculateSpecificity(selector) {
var specificity = [0, 0, 0, 0];
// Cannot use RegExp literals for all regular expressions, IE does not accept
// the syntax.
// Matches a backslash followed by six hexadecimal digits followed by an
// optional single whitespace character.
var escapeHexadecimalRegex = new RegExp('\\\\[0-9A-Fa-f]{6}\\s?', 'g');
// Matches a backslash followed by fewer than six hexadecimal digits
// followed by a mandatory single whitespace character.
var escapeHexadecimalRegex2 = new RegExp('\\\\[0-9A-Fa-f]{1,5}\\s', 'g');
// Matches a backslash followed by any character
var escapeSpecialCharacter = /\\./g;
selector = replaceWithPlainText(selector, escapeHexadecimalRegex);
selector = replaceWithPlainText(selector, escapeHexadecimalRegex2);
selector = replaceWithPlainText(selector, escapeSpecialCharacter);
// Remove the negation pseudo-class (:not) but leave its argument because
// specificity is calculated on its argument.
var pseudoClassWithNotRegex = new RegExp(':not\\(([^\\)]*)\\)', 'g');
selector = selector.replace(pseudoClassWithNotRegex, ' $1 ');
// Remove anything after a left brace in case a user has pasted in a rule,
// not just a selector.
var rulesRegex = new RegExp('{[^]*', 'gm');
selector = selector.replace(rulesRegex, '');
// The following regular expressions assume that selectors matching the
// preceding regular expressions have been removed.
// SPECIFICITY 2: Counts attribute selectors.
var attributeRegex = new RegExp('(\\[[^\\]]+\\])', 'g');
selector = replaceWithEmptyText(selector, specificity, attributeRegex, 2);
// SPECIFICITY 1: Counts ID selectors.
var idRegex = new RegExp('(#[^\\#\\s\\+>~\\.\\[:]+)', 'g');
selector = replaceWithEmptyText(selector, specificity, idRegex, 1);
// SPECIFICITY 2: Counts class selectors.
var classRegex = new RegExp('(\\.[^\\s\\+>~\\.\\[:]+)', 'g');
selector = replaceWithEmptyText(selector, specificity, classRegex, 2);
// SPECIFICITY 3: Counts pseudo-element selectors.
var pseudoElementRegex =
/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi;
selector = replaceWithEmptyText(selector, specificity, pseudoElementRegex, 3);
// SPECIFICITY 2: Counts pseudo-class selectors.
// A regex for pseudo classes with brackets. For example:
// :nth-child()
// :nth-last-child()
// :nth-of-type()
// :nth-last-type()
// :lang()
var pseudoClassWithBracketsRegex = /(:[\w-]+\([^\)]*\))/gi;
selector = replaceWithEmptyText(
selector, specificity, pseudoClassWithBracketsRegex, 2);
// A regex for other pseudo classes, which don't have brackets.
var pseudoClassRegex = /(:[^\s\+>~\.\[:]+)/g;
selector = replaceWithEmptyText(selector, specificity, pseudoClassRegex, 2);
// Remove universal selector and separator characters.
selector = selector.replace(/[\*\s\+>~]/g, ' ');
// Remove any stray dots or hashes which aren't attached to words.
// These may be present if the user is live-editing this selector.
selector = selector.replace(/[#\.]/g, ' ');
// SPECIFICITY 3: The only things left should be element selectors.
var elementRegex = /([^\s\+>~\.\[:]+)/g;
selector = replaceWithEmptyText(selector, specificity, elementRegex, 3);
return specificity;
} | javascript | function calculateSpecificity(selector) {
var specificity = [0, 0, 0, 0];
// Cannot use RegExp literals for all regular expressions, IE does not accept
// the syntax.
// Matches a backslash followed by six hexadecimal digits followed by an
// optional single whitespace character.
var escapeHexadecimalRegex = new RegExp('\\\\[0-9A-Fa-f]{6}\\s?', 'g');
// Matches a backslash followed by fewer than six hexadecimal digits
// followed by a mandatory single whitespace character.
var escapeHexadecimalRegex2 = new RegExp('\\\\[0-9A-Fa-f]{1,5}\\s', 'g');
// Matches a backslash followed by any character
var escapeSpecialCharacter = /\\./g;
selector = replaceWithPlainText(selector, escapeHexadecimalRegex);
selector = replaceWithPlainText(selector, escapeHexadecimalRegex2);
selector = replaceWithPlainText(selector, escapeSpecialCharacter);
// Remove the negation pseudo-class (:not) but leave its argument because
// specificity is calculated on its argument.
var pseudoClassWithNotRegex = new RegExp(':not\\(([^\\)]*)\\)', 'g');
selector = selector.replace(pseudoClassWithNotRegex, ' $1 ');
// Remove anything after a left brace in case a user has pasted in a rule,
// not just a selector.
var rulesRegex = new RegExp('{[^]*', 'gm');
selector = selector.replace(rulesRegex, '');
// The following regular expressions assume that selectors matching the
// preceding regular expressions have been removed.
// SPECIFICITY 2: Counts attribute selectors.
var attributeRegex = new RegExp('(\\[[^\\]]+\\])', 'g');
selector = replaceWithEmptyText(selector, specificity, attributeRegex, 2);
// SPECIFICITY 1: Counts ID selectors.
var idRegex = new RegExp('(#[^\\#\\s\\+>~\\.\\[:]+)', 'g');
selector = replaceWithEmptyText(selector, specificity, idRegex, 1);
// SPECIFICITY 2: Counts class selectors.
var classRegex = new RegExp('(\\.[^\\s\\+>~\\.\\[:]+)', 'g');
selector = replaceWithEmptyText(selector, specificity, classRegex, 2);
// SPECIFICITY 3: Counts pseudo-element selectors.
var pseudoElementRegex =
/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi;
selector = replaceWithEmptyText(selector, specificity, pseudoElementRegex, 3);
// SPECIFICITY 2: Counts pseudo-class selectors.
// A regex for pseudo classes with brackets. For example:
// :nth-child()
// :nth-last-child()
// :nth-of-type()
// :nth-last-type()
// :lang()
var pseudoClassWithBracketsRegex = /(:[\w-]+\([^\)]*\))/gi;
selector = replaceWithEmptyText(
selector, specificity, pseudoClassWithBracketsRegex, 2);
// A regex for other pseudo classes, which don't have brackets.
var pseudoClassRegex = /(:[^\s\+>~\.\[:]+)/g;
selector = replaceWithEmptyText(selector, specificity, pseudoClassRegex, 2);
// Remove universal selector and separator characters.
selector = selector.replace(/[\*\s\+>~]/g, ' ');
// Remove any stray dots or hashes which aren't attached to words.
// These may be present if the user is live-editing this selector.
selector = selector.replace(/[#\.]/g, ' ');
// SPECIFICITY 3: The only things left should be element selectors.
var elementRegex = /([^\s\+>~\.\[:]+)/g;
selector = replaceWithEmptyText(selector, specificity, elementRegex, 3);
return specificity;
} | [
"function",
"calculateSpecificity",
"(",
"selector",
")",
"{",
"var",
"specificity",
"=",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
"]",
";",
"// Cannot use RegExp literals for all regular expressions, IE does not accept",
"// the syntax.",
"// Matches a backslash followed by... | Calculates the specificity of CSS selectors
@see http://www.w3.org/TR/css3-selectors/#specificity
@see https://github.com/keeganstreet/specificity
@see https://specificity.keegan.st/
@param {string} selector
@return {!Array<number>} The CSS specificity. | [
"Calculates",
"the",
"specificity",
"of",
"CSS",
"selectors"
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/html/cssspecificity.js#L98-L172 | train | Calculates the specificity of a selector. | [
30522,
3853,
18422,
13102,
8586,
18513,
3012,
1006,
27000,
1007,
1063,
13075,
3563,
3012,
1027,
1031,
1014,
1010,
1014,
1010,
1014,
1010,
1014,
1033,
1025,
1013,
1013,
3685,
2224,
19723,
10288,
2361,
18204,
2015,
2005,
2035,
3180,
11423,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js | function(url, response, method, status, headers) {
var aHeaders = headers || [];
aHeaders.push({
"name": "Content-Type",
"value": "application/json;charset=utf-8"
});
this.addResponse(url, response, method, status, aHeaders);
} | javascript | function(url, response, method, status, headers) {
var aHeaders = headers || [];
aHeaders.push({
"name": "Content-Type",
"value": "application/json;charset=utf-8"
});
this.addResponse(url, response, method, status, aHeaders);
} | [
"function",
"(",
"url",
",",
"response",
",",
"method",
",",
"status",
",",
"headers",
")",
"{",
"var",
"aHeaders",
"=",
"headers",
"||",
"[",
"]",
";",
"aHeaders",
".",
"push",
"(",
"{",
"\"name\"",
":",
"\"Content-Type\"",
",",
"\"value\"",
":",
"\"a... | Adds a JSON encoded response for a request with the provided URL.
@param {string} url The requested URL.
@param {string|function} response The returned response as string or callback.
@param {string} [method] The HTTP method (e.g. GET, POST), default is GET.
@param {int} [status] The desired status, default is 200.
@param {array} [headers] The response Headers, the Content-Type for JSON is already set for this method. | [
"Adds",
"a",
"JSON",
"encoded",
"response",
"for",
"a",
"request",
"with",
"the",
"provided",
"URL",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/RequestRecorder.js#L788-L795 | train | Add a response to the response queue | [
30522,
3853,
1006,
24471,
2140,
1010,
3433,
1010,
4118,
1010,
3570,
1010,
20346,
2015,
1007,
1063,
13075,
3805,
2545,
1027,
20346,
2015,
1064,
1064,
1031,
1033,
1025,
3805,
2545,
1012,
5245,
1006,
1063,
1000,
2171,
1000,
1024,
1000,
4180,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/components/dialog/dialog.js | MdDialogProvider | function MdDialogProvider($$interimElementProvider) {
// Elements to capture and redirect focus when the user presses tab at the dialog boundary.
var topFocusTrap, bottomFocusTrap;
return $$interimElementProvider('$mdDialog')
.setDefaults({
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose',
'targetEvent', 'closeTo', 'openFrom', 'parent', 'fullscreen', 'multiple'],
options: dialogDefaultOptions
})
.addPreset('alert', {
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'theme',
'css'],
options: advancedDialogOptions
})
.addPreset('confirm', {
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'cancel',
'theme', 'css'],
options: advancedDialogOptions
})
.addPreset('prompt', {
methods: ['title', 'htmlContent', 'textContent', 'initialValue', 'content', 'placeholder', 'ariaLabel',
'ok', 'cancel', 'theme', 'css', 'required'],
options: advancedDialogOptions
});
/* @ngInject */
function advancedDialogOptions() {
return {
template: [
'<md-dialog md-theme="{{ dialog.theme || dialog.defaultTheme }}" aria-label="{{ dialog.ariaLabel }}" ng-class="dialog.css">',
' <md-dialog-content class="md-dialog-content" role="document" tabIndex="-1">',
' <h2 class="md-title">{{ dialog.title }}</h2>',
' <div ng-if="::dialog.mdHtmlContent" class="md-dialog-content-body" ',
' ng-bind-html="::dialog.mdHtmlContent"></div>',
' <div ng-if="::!dialog.mdHtmlContent" class="md-dialog-content-body">',
' <p>{{::dialog.mdTextContent}}</p>',
' </div>',
' <md-input-container md-no-float ng-if="::dialog.$type == \'prompt\'" class="md-prompt-input-container">',
' <input ng-keypress="dialog.keypress($event)" md-autofocus ng-model="dialog.result" ' +
' placeholder="{{::dialog.placeholder}}" ng-required="dialog.required">',
' </md-input-container>',
' </md-dialog-content>',
' <md-dialog-actions>',
' <md-button ng-if="dialog.$type === \'confirm\' || dialog.$type === \'prompt\'"' +
' ng-click="dialog.abort()" class="md-primary md-cancel-button">',
' {{ dialog.cancel }}',
' </md-button>',
' <md-button ng-click="dialog.hide()" class="md-primary md-confirm-button" md-autofocus="dialog.$type===\'alert\'"' +
' ng-disabled="dialog.required && !dialog.result">',
' {{ dialog.ok }}',
' </md-button>',
' </md-dialog-actions>',
'</md-dialog>'
].join('').replace(/\s\s+/g, ''),
controller: MdDialogController,
controllerAs: 'dialog',
bindToController: true,
};
}
/**
* Controller for the md-dialog interim elements
* @ngInject
*/
function MdDialogController($mdDialog, $mdConstant) {
// For compatibility with AngularJS 1.6+, we should always use the $onInit hook in
// interimElements. The $mdCompiler simulates the $onInit hook for all versions.
this.$onInit = function() {
var isPrompt = this.$type == 'prompt';
if (isPrompt && this.initialValue) {
this.result = this.initialValue;
}
this.hide = function() {
$mdDialog.hide(isPrompt ? this.result : true);
};
this.abort = function() {
$mdDialog.cancel();
};
this.keypress = function($event) {
var invalidPrompt = isPrompt && this.required && !angular.isDefined(this.result);
if ($event.keyCode === $mdConstant.KEY_CODE.ENTER && !invalidPrompt) {
$mdDialog.hide(this.result);
}
};
};
}
/* @ngInject */
function dialogDefaultOptions($mdDialog, $mdAria, $mdUtil, $mdConstant, $animate, $document, $window, $rootElement,
$log, $injector, $mdTheming, $interpolate, $mdInteraction) {
return {
hasBackdrop: true,
isolateScope: true,
onCompiling: beforeCompile,
onShow: onShow,
onShowing: beforeShow,
onRemove: onRemove,
clickOutsideToClose: false,
escapeToClose: true,
targetEvent: null,
closeTo: null,
openFrom: null,
focusOnOpen: true,
disableParentScroll: true,
autoWrap: true,
fullscreen: false,
transformTemplate: function(template, options) {
// Make the dialog container focusable, because otherwise the focus will be always redirected to
// an element outside of the container, and the focus trap won't work probably..
// Also the tabindex is needed for the `escapeToClose` functionality, because
// the keyDown event can't be triggered when the focus is outside of the container.
var startSymbol = $interpolate.startSymbol();
var endSymbol = $interpolate.endSymbol();
var theme = startSymbol + (options.themeWatch ? '' : '::') + 'theme' + endSymbol;
var themeAttr = (options.hasTheme) ? 'md-theme="'+theme+'"': '';
return '<div class="md-dialog-container" tabindex="-1" ' + themeAttr + '>' + validatedTemplate(template) + '</div>';
/**
* The specified template should contain a <md-dialog> wrapper element....
*/
function validatedTemplate(template) {
if (options.autoWrap && !/<\/md-dialog>/g.test(template)) {
return '<md-dialog>' + (template || '') + '</md-dialog>';
} else {
return template || '';
}
}
}
};
function beforeCompile(options) {
// Automatically apply the theme, if the user didn't specify a theme explicitly.
// Those option changes need to be done, before the compilation has started, because otherwise
// the option changes will be not available in the $mdCompilers locales.
options.defaultTheme = $mdTheming.defaultTheme();
detectTheming(options);
}
function beforeShow(scope, element, options, controller) {
if (controller) {
var mdHtmlContent = controller.htmlContent || options.htmlContent || '';
var mdTextContent = controller.textContent || options.textContent ||
controller.content || options.content || '';
if (mdHtmlContent && !$injector.has('$sanitize')) {
throw Error('The ngSanitize module must be loaded in order to use htmlContent.');
}
if (mdHtmlContent && mdTextContent) {
throw Error('md-dialog cannot have both `htmlContent` and `textContent`');
}
// Only assign the content if nothing throws, otherwise it'll still be compiled.
controller.mdHtmlContent = mdHtmlContent;
controller.mdTextContent = mdTextContent;
}
}
/** Show method for dialogs */
function onShow(scope, element, options, controller) {
angular.element($document[0].body).addClass('md-dialog-is-showing');
var dialogElement = element.find('md-dialog');
// Once a dialog has `ng-cloak` applied on his template the dialog animation will not work properly.
// This is a very common problem, so we have to notify the developer about this.
if (dialogElement.hasClass('ng-cloak')) {
var message = '$mdDialog: using `<md-dialog ng-cloak>` will affect the dialog opening animations.';
$log.warn(message, element[0]);
}
captureParentAndFromToElements(options);
configureAria(dialogElement, options);
showBackdrop(scope, element, options);
activateListeners(element, options);
return dialogPopIn(element, options)
.then(function() {
lockScreenReader(element, options);
warnDeprecatedActions();
focusOnOpen();
});
/**
* Check to see if they used the deprecated .md-actions class and log a warning
*/
function warnDeprecatedActions() {
if (element[0].querySelector('.md-actions')) {
$log.warn('Using a class of md-actions is deprecated, please use <md-dialog-actions>.');
}
}
/**
* For alerts, focus on content... otherwise focus on
* the close button (or equivalent)
*/
function focusOnOpen() {
if (options.focusOnOpen) {
var target = $mdUtil.findFocusTarget(element) || findCloseButton() || dialogElement;
target.focus();
}
/**
* If no element with class dialog-close, try to find the last
* button child in md-actions and assume it is a close button.
*
* If we find no actions at all, log a warning to the console.
*/
function findCloseButton() {
return element[0].querySelector('.dialog-close, md-dialog-actions button:last-child');
}
}
}
/**
* Remove function for all dialogs
*/
function onRemove(scope, element, options) {
options.deactivateListeners();
options.unlockScreenReader();
options.hideBackdrop(options.$destroy);
// Remove the focus traps that we added earlier for keeping focus within the dialog.
if (topFocusTrap && topFocusTrap.parentNode) {
topFocusTrap.parentNode.removeChild(topFocusTrap);
}
if (bottomFocusTrap && bottomFocusTrap.parentNode) {
bottomFocusTrap.parentNode.removeChild(bottomFocusTrap);
}
// For navigation $destroy events, do a quick, non-animated removal,
// but for normal closes (from clicks, etc) animate the removal
return options.$destroy ? detachAndClean() : animateRemoval().then(detachAndClean);
/**
* For normal closes, animate the removal.
* For forced closes (like $destroy events), skip the animations
*/
function animateRemoval() {
return dialogPopOut(element, options);
}
/**
* Detach the element
*/
function detachAndClean() {
angular.element($document[0].body).removeClass('md-dialog-is-showing');
// Reverse the container stretch if using a content element.
if (options.contentElement) {
options.reverseContainerStretch();
}
// Exposed cleanup function from the $mdCompiler.
options.cleanupElement();
// Restores the focus to the origin element if the last interaction upon opening was a keyboard.
if (!options.$destroy && options.originInteraction === 'keyboard') {
options.origin.focus();
}
}
}
function detectTheming(options) {
// Once the user specifies a targetEvent, we will automatically try to find the correct
// nested theme.
var targetEl;
if (options.targetEvent && options.targetEvent.target) {
targetEl = angular.element(options.targetEvent.target);
}
var themeCtrl = targetEl && targetEl.controller('mdTheme');
options.hasTheme = (!!themeCtrl);
if (!options.hasTheme) {
return;
}
options.themeWatch = themeCtrl.$shouldWatch;
var theme = options.theme || themeCtrl.$mdTheme;
if (theme) {
options.scope.theme = theme;
}
var unwatch = themeCtrl.registerChanges(function (newTheme) {
options.scope.theme = newTheme;
if (!options.themeWatch) {
unwatch();
}
});
}
/**
* Capture originator/trigger/from/to element information (if available)
* and the parent container for the dialog; defaults to the $rootElement
* unless overridden in the options.parent
*/
function captureParentAndFromToElements(options) {
options.origin = angular.extend({
element: null,
bounds: null,
focus: angular.noop
}, options.origin || {});
options.parent = getDomElement(options.parent, $rootElement);
options.closeTo = getBoundingClientRect(getDomElement(options.closeTo));
options.openFrom = getBoundingClientRect(getDomElement(options.openFrom));
if (options.targetEvent) {
options.origin = getBoundingClientRect(options.targetEvent.target, options.origin);
options.originInteraction = $mdInteraction.getLastInteractionType();
}
/**
* Identify the bounding RECT for the target element
*
*/
function getBoundingClientRect (element, orig) {
var source = angular.element((element || {}));
if (source && source.length) {
// Compute and save the target element's bounding rect, so that if the
// element is hidden when the dialog closes, we can shrink the dialog
// back to the same position it expanded from.
//
// Checking if the source is a rect object or a DOM element
var bounds = {top:0,left:0,height:0,width:0};
var hasFn = angular.isFunction(source[0].getBoundingClientRect);
return angular.extend(orig || {}, {
element : hasFn ? source : undefined,
bounds : hasFn ? source[0].getBoundingClientRect() : angular.extend({}, bounds, source[0]),
focus : angular.bind(source, source.focus),
});
}
}
/**
* If the specifier is a simple string selector, then query for
* the DOM element.
*/
function getDomElement(element, defaultElement) {
if (angular.isString(element)) {
element = $document[0].querySelector(element);
}
// If we have a reference to a raw dom element, always wrap it in jqLite
return angular.element(element || defaultElement);
}
}
/**
* Listen for escape keys and outside clicks to auto close
*/
function activateListeners(element, options) {
var window = angular.element($window);
var onWindowResize = $mdUtil.debounce(function() {
stretchDialogContainerToViewport(element, options);
}, 60);
var removeListeners = [];
var smartClose = function() {
// Only 'confirm' dialogs have a cancel button... escape/clickOutside will
// cancel or fallback to hide.
var closeFn = (options.$type == 'alert') ? $mdDialog.hide : $mdDialog.cancel;
$mdUtil.nextTick(closeFn, true);
};
if (options.escapeToClose) {
var parentTarget = options.parent;
var keyHandlerFn = function(ev) {
if (ev.keyCode === $mdConstant.KEY_CODE.ESCAPE) {
ev.stopImmediatePropagation();
ev.preventDefault();
smartClose();
}
};
// Add keydown listeners
element.on('keydown', keyHandlerFn);
parentTarget.on('keydown', keyHandlerFn);
// Queue remove listeners function
removeListeners.push(function() {
element.off('keydown', keyHandlerFn);
parentTarget.off('keydown', keyHandlerFn);
});
}
// Register listener to update dialog on window resize
window.on('resize', onWindowResize);
removeListeners.push(function() {
window.off('resize', onWindowResize);
});
if (options.clickOutsideToClose) {
var target = element;
var sourceElem;
// Keep track of the element on which the mouse originally went down
// so that we can only close the backdrop when the 'click' started on it.
// A simple 'click' handler does not work,
// it sets the target object as the element the mouse went down on.
var mousedownHandler = function(ev) {
sourceElem = ev.target;
};
// We check if our original element and the target is the backdrop
// because if the original was the backdrop and the target was inside the dialog
// we don't want to dialog to close.
var mouseupHandler = function(ev) {
if (sourceElem === target[0] && ev.target === target[0]) {
ev.stopPropagation();
ev.preventDefault();
smartClose();
}
};
// Add listeners
target.on('mousedown', mousedownHandler);
target.on('mouseup', mouseupHandler);
// Queue remove listeners function
removeListeners.push(function() {
target.off('mousedown', mousedownHandler);
target.off('mouseup', mouseupHandler);
});
}
// Attach specific `remove` listener handler
options.deactivateListeners = function() {
removeListeners.forEach(function(removeFn) {
removeFn();
});
options.deactivateListeners = null;
};
}
/**
* Show modal backdrop element...
*/
function showBackdrop(scope, element, options) {
if (options.disableParentScroll) {
// !! DO this before creating the backdrop; since disableScrollAround()
// configures the scroll offset; which is used by mdBackDrop postLink()
options.restoreScroll = $mdUtil.disableScrollAround(element, options.parent);
}
if (options.hasBackdrop) {
options.backdrop = $mdUtil.createBackdrop(scope, "md-dialog-backdrop md-opaque");
$animate.enter(options.backdrop, options.parent);
}
/**
* Hide modal backdrop element...
*/
options.hideBackdrop = function hideBackdrop($destroy) {
if (options.backdrop) {
if ($destroy) options.backdrop.remove();
else $animate.leave(options.backdrop);
}
if (options.disableParentScroll) {
options.restoreScroll && options.restoreScroll();
delete options.restoreScroll;
}
options.hideBackdrop = null;
};
}
/**
* Inject ARIA-specific attributes appropriate for Dialogs
*/
function configureAria(element, options) {
var role = (options.$type === 'alert') ? 'alertdialog' : 'dialog';
var dialogContent = element.find('md-dialog-content');
var existingDialogId = element.attr('id');
var dialogContentId = 'dialogContent_' + (existingDialogId || $mdUtil.nextUid());
element.attr({
'role': role,
'tabIndex': '-1'
});
if (dialogContent.length === 0) {
dialogContent = element;
// If the dialog element already had an ID, don't clobber it.
if (existingDialogId) {
dialogContentId = existingDialogId;
}
}
dialogContent.attr('id', dialogContentId);
element.attr('aria-describedby', dialogContentId);
if (options.ariaLabel) {
$mdAria.expect(element, 'aria-label', options.ariaLabel);
}
else {
$mdAria.expectAsync(element, 'aria-label', function() {
// If dialog title is specified, set aria-label with it
// See https://github.com/angular/material/issues/10582
if (options.title) {
return options.title;
} else {
var words = dialogContent.text().split(/\s+/);
if (words.length > 3) words = words.slice(0, 3).concat('...');
return words.join(' ');
}
});
}
// Set up elements before and after the dialog content to capture focus and
// redirect back into the dialog.
topFocusTrap = document.createElement('div');
topFocusTrap.classList.add('md-dialog-focus-trap');
topFocusTrap.tabIndex = 0;
bottomFocusTrap = topFocusTrap.cloneNode(false);
// When focus is about to move out of the dialog, we want to intercept it and redirect it
// back to the dialog element.
var focusHandler = function() {
element.focus();
};
topFocusTrap.addEventListener('focus', focusHandler);
bottomFocusTrap.addEventListener('focus', focusHandler);
// The top focus trap inserted immeidately before the md-dialog element (as a sibling).
// The bottom focus trap is inserted at the very end of the md-dialog element (as a child).
element[0].parentNode.insertBefore(topFocusTrap, element[0]);
element.after(bottomFocusTrap);
}
/**
* Prevents screen reader interaction behind modal window
* on swipe interfaces
*/
function lockScreenReader(element, options) {
var isHidden = true;
// get raw DOM node
walkDOM(element[0]);
options.unlockScreenReader = function () {
isHidden = false;
walkDOM(element[0]);
options.unlockScreenReader = null;
};
/**
* Get all of an element's parent elements up the DOM tree
* @return {Array} The parent elements
*/
function getParents(element) {
var parents = [];
while (element.parentNode) {
if (element === document.body) {
return parents;
}
var children = element.parentNode.children;
for (var i = 0; i < children.length; i++) {
// skip over child if it is an ascendant of the dialog
// a script or style tag, or a live region.
if (element !== children[i] &&
!isNodeOneOf(children[i], ['SCRIPT', 'STYLE']) &&
!children[i].hasAttribute('aria-live')) {
parents.push(children[i]);
}
}
element = element.parentNode;
}
return parents;
}
/**
* Walk DOM to apply or remove aria-hidden on sibling nodes
* and parent sibling nodes
*/
function walkDOM(element) {
var elements = getParents(element);
for (var i = 0; i < elements.length; i++) {
elements[i].setAttribute('aria-hidden', isHidden);
}
}
}
/**
* Ensure the dialog container fill-stretches to the viewport
*/
function stretchDialogContainerToViewport(container, options) {
var isFixed = $window.getComputedStyle($document[0].body).position == 'fixed';
var backdrop = options.backdrop ? $window.getComputedStyle(options.backdrop[0]) : null;
var height = backdrop ? Math.min($document[0].body.clientHeight, Math.ceil(Math.abs(parseInt(backdrop.height, 10)))) : 0;
var previousStyles = {
top: container.css('top'),
height: container.css('height')
};
// If the body is fixed, determine the distance to the viewport in relative from the parent.
var parentTop = Math.abs(options.parent[0].getBoundingClientRect().top);
container.css({
top: (isFixed ? parentTop : 0) + 'px',
height: height ? height + 'px' : '100%'
});
return function() {
// Reverts the modified styles back to the previous values.
// This is needed for contentElements, which should have the same styles after close
// as before.
container.css(previousStyles);
};
}
/**
* Dialog open and pop-in animation
*/
function dialogPopIn(container, options) {
// Add the `md-dialog-container` to the DOM
options.parent.append(container);
options.reverseContainerStretch = stretchDialogContainerToViewport(container, options);
var dialogEl = container.find('md-dialog');
var animator = $mdUtil.dom.animator;
var buildTranslateToOrigin = animator.calculateZoomToOrigin;
var translateOptions = {transitionInClass: 'md-transition-in', transitionOutClass: 'md-transition-out'};
var from = animator.toTransformCss(buildTranslateToOrigin(dialogEl, options.openFrom || options.origin));
var to = animator.toTransformCss(""); // defaults to center display (or parent or $rootElement)
dialogEl.toggleClass('md-dialog-fullscreen', !!options.fullscreen);
return animator
.translate3d(dialogEl, from, to, translateOptions)
.then(function(animateReversal) {
// Build a reversal translate function synced to this translation...
options.reverseAnimate = function() {
delete options.reverseAnimate;
if (options.closeTo) {
// Using the opposite classes to create a close animation to the closeTo element
translateOptions = {transitionInClass: 'md-transition-out', transitionOutClass: 'md-transition-in'};
from = to;
to = animator.toTransformCss(buildTranslateToOrigin(dialogEl, options.closeTo));
return animator
.translate3d(dialogEl, from, to,translateOptions);
}
return animateReversal(
to = animator.toTransformCss(
// in case the origin element has moved or is hidden,
// let's recalculate the translateCSS
buildTranslateToOrigin(dialogEl, options.origin)
)
);
};
// Function to revert the generated animation styles on the dialog element.
// Useful when using a contentElement instead of a template.
options.clearAnimate = function() {
delete options.clearAnimate;
// Remove the transition classes, added from $animateCSS, since those can't be removed
// by reversely running the animator.
dialogEl.removeClass([
translateOptions.transitionOutClass,
translateOptions.transitionInClass
].join(' '));
// Run the animation reversely to remove the previous added animation styles.
return animator.translate3d(dialogEl, to, animator.toTransformCss(''), {});
};
return true;
});
}
/**
* Dialog close and pop-out animation
*/
function dialogPopOut(container, options) {
return options.reverseAnimate().then(function() {
if (options.contentElement) {
// When we use a contentElement, we want the element to be the same as before.
// That means, that we have to clear all the animation properties, like transform.
options.clearAnimate();
}
});
}
/**
* Utility function to filter out raw DOM nodes
*/
function isNodeOneOf(elem, nodeTypeArray) {
if (nodeTypeArray.indexOf(elem.nodeName) !== -1) {
return true;
}
}
}
} | javascript | function MdDialogProvider($$interimElementProvider) {
// Elements to capture and redirect focus when the user presses tab at the dialog boundary.
var topFocusTrap, bottomFocusTrap;
return $$interimElementProvider('$mdDialog')
.setDefaults({
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose',
'targetEvent', 'closeTo', 'openFrom', 'parent', 'fullscreen', 'multiple'],
options: dialogDefaultOptions
})
.addPreset('alert', {
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'theme',
'css'],
options: advancedDialogOptions
})
.addPreset('confirm', {
methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'cancel',
'theme', 'css'],
options: advancedDialogOptions
})
.addPreset('prompt', {
methods: ['title', 'htmlContent', 'textContent', 'initialValue', 'content', 'placeholder', 'ariaLabel',
'ok', 'cancel', 'theme', 'css', 'required'],
options: advancedDialogOptions
});
/* @ngInject */
function advancedDialogOptions() {
return {
template: [
'<md-dialog md-theme="{{ dialog.theme || dialog.defaultTheme }}" aria-label="{{ dialog.ariaLabel }}" ng-class="dialog.css">',
' <md-dialog-content class="md-dialog-content" role="document" tabIndex="-1">',
' <h2 class="md-title">{{ dialog.title }}</h2>',
' <div ng-if="::dialog.mdHtmlContent" class="md-dialog-content-body" ',
' ng-bind-html="::dialog.mdHtmlContent"></div>',
' <div ng-if="::!dialog.mdHtmlContent" class="md-dialog-content-body">',
' <p>{{::dialog.mdTextContent}}</p>',
' </div>',
' <md-input-container md-no-float ng-if="::dialog.$type == \'prompt\'" class="md-prompt-input-container">',
' <input ng-keypress="dialog.keypress($event)" md-autofocus ng-model="dialog.result" ' +
' placeholder="{{::dialog.placeholder}}" ng-required="dialog.required">',
' </md-input-container>',
' </md-dialog-content>',
' <md-dialog-actions>',
' <md-button ng-if="dialog.$type === \'confirm\' || dialog.$type === \'prompt\'"' +
' ng-click="dialog.abort()" class="md-primary md-cancel-button">',
' {{ dialog.cancel }}',
' </md-button>',
' <md-button ng-click="dialog.hide()" class="md-primary md-confirm-button" md-autofocus="dialog.$type===\'alert\'"' +
' ng-disabled="dialog.required && !dialog.result">',
' {{ dialog.ok }}',
' </md-button>',
' </md-dialog-actions>',
'</md-dialog>'
].join('').replace(/\s\s+/g, ''),
controller: MdDialogController,
controllerAs: 'dialog',
bindToController: true,
};
}
/**
* Controller for the md-dialog interim elements
* @ngInject
*/
function MdDialogController($mdDialog, $mdConstant) {
// For compatibility with AngularJS 1.6+, we should always use the $onInit hook in
// interimElements. The $mdCompiler simulates the $onInit hook for all versions.
this.$onInit = function() {
var isPrompt = this.$type == 'prompt';
if (isPrompt && this.initialValue) {
this.result = this.initialValue;
}
this.hide = function() {
$mdDialog.hide(isPrompt ? this.result : true);
};
this.abort = function() {
$mdDialog.cancel();
};
this.keypress = function($event) {
var invalidPrompt = isPrompt && this.required && !angular.isDefined(this.result);
if ($event.keyCode === $mdConstant.KEY_CODE.ENTER && !invalidPrompt) {
$mdDialog.hide(this.result);
}
};
};
}
/* @ngInject */
function dialogDefaultOptions($mdDialog, $mdAria, $mdUtil, $mdConstant, $animate, $document, $window, $rootElement,
$log, $injector, $mdTheming, $interpolate, $mdInteraction) {
return {
hasBackdrop: true,
isolateScope: true,
onCompiling: beforeCompile,
onShow: onShow,
onShowing: beforeShow,
onRemove: onRemove,
clickOutsideToClose: false,
escapeToClose: true,
targetEvent: null,
closeTo: null,
openFrom: null,
focusOnOpen: true,
disableParentScroll: true,
autoWrap: true,
fullscreen: false,
transformTemplate: function(template, options) {
// Make the dialog container focusable, because otherwise the focus will be always redirected to
// an element outside of the container, and the focus trap won't work probably..
// Also the tabindex is needed for the `escapeToClose` functionality, because
// the keyDown event can't be triggered when the focus is outside of the container.
var startSymbol = $interpolate.startSymbol();
var endSymbol = $interpolate.endSymbol();
var theme = startSymbol + (options.themeWatch ? '' : '::') + 'theme' + endSymbol;
var themeAttr = (options.hasTheme) ? 'md-theme="'+theme+'"': '';
return '<div class="md-dialog-container" tabindex="-1" ' + themeAttr + '>' + validatedTemplate(template) + '</div>';
/**
* The specified template should contain a <md-dialog> wrapper element....
*/
function validatedTemplate(template) {
if (options.autoWrap && !/<\/md-dialog>/g.test(template)) {
return '<md-dialog>' + (template || '') + '</md-dialog>';
} else {
return template || '';
}
}
}
};
function beforeCompile(options) {
// Automatically apply the theme, if the user didn't specify a theme explicitly.
// Those option changes need to be done, before the compilation has started, because otherwise
// the option changes will be not available in the $mdCompilers locales.
options.defaultTheme = $mdTheming.defaultTheme();
detectTheming(options);
}
function beforeShow(scope, element, options, controller) {
if (controller) {
var mdHtmlContent = controller.htmlContent || options.htmlContent || '';
var mdTextContent = controller.textContent || options.textContent ||
controller.content || options.content || '';
if (mdHtmlContent && !$injector.has('$sanitize')) {
throw Error('The ngSanitize module must be loaded in order to use htmlContent.');
}
if (mdHtmlContent && mdTextContent) {
throw Error('md-dialog cannot have both `htmlContent` and `textContent`');
}
// Only assign the content if nothing throws, otherwise it'll still be compiled.
controller.mdHtmlContent = mdHtmlContent;
controller.mdTextContent = mdTextContent;
}
}
/** Show method for dialogs */
function onShow(scope, element, options, controller) {
angular.element($document[0].body).addClass('md-dialog-is-showing');
var dialogElement = element.find('md-dialog');
// Once a dialog has `ng-cloak` applied on his template the dialog animation will not work properly.
// This is a very common problem, so we have to notify the developer about this.
if (dialogElement.hasClass('ng-cloak')) {
var message = '$mdDialog: using `<md-dialog ng-cloak>` will affect the dialog opening animations.';
$log.warn(message, element[0]);
}
captureParentAndFromToElements(options);
configureAria(dialogElement, options);
showBackdrop(scope, element, options);
activateListeners(element, options);
return dialogPopIn(element, options)
.then(function() {
lockScreenReader(element, options);
warnDeprecatedActions();
focusOnOpen();
});
/**
* Check to see if they used the deprecated .md-actions class and log a warning
*/
function warnDeprecatedActions() {
if (element[0].querySelector('.md-actions')) {
$log.warn('Using a class of md-actions is deprecated, please use <md-dialog-actions>.');
}
}
/**
* For alerts, focus on content... otherwise focus on
* the close button (or equivalent)
*/
function focusOnOpen() {
if (options.focusOnOpen) {
var target = $mdUtil.findFocusTarget(element) || findCloseButton() || dialogElement;
target.focus();
}
/**
* If no element with class dialog-close, try to find the last
* button child in md-actions and assume it is a close button.
*
* If we find no actions at all, log a warning to the console.
*/
function findCloseButton() {
return element[0].querySelector('.dialog-close, md-dialog-actions button:last-child');
}
}
}
/**
* Remove function for all dialogs
*/
function onRemove(scope, element, options) {
options.deactivateListeners();
options.unlockScreenReader();
options.hideBackdrop(options.$destroy);
// Remove the focus traps that we added earlier for keeping focus within the dialog.
if (topFocusTrap && topFocusTrap.parentNode) {
topFocusTrap.parentNode.removeChild(topFocusTrap);
}
if (bottomFocusTrap && bottomFocusTrap.parentNode) {
bottomFocusTrap.parentNode.removeChild(bottomFocusTrap);
}
// For navigation $destroy events, do a quick, non-animated removal,
// but for normal closes (from clicks, etc) animate the removal
return options.$destroy ? detachAndClean() : animateRemoval().then(detachAndClean);
/**
* For normal closes, animate the removal.
* For forced closes (like $destroy events), skip the animations
*/
function animateRemoval() {
return dialogPopOut(element, options);
}
/**
* Detach the element
*/
function detachAndClean() {
angular.element($document[0].body).removeClass('md-dialog-is-showing');
// Reverse the container stretch if using a content element.
if (options.contentElement) {
options.reverseContainerStretch();
}
// Exposed cleanup function from the $mdCompiler.
options.cleanupElement();
// Restores the focus to the origin element if the last interaction upon opening was a keyboard.
if (!options.$destroy && options.originInteraction === 'keyboard') {
options.origin.focus();
}
}
}
function detectTheming(options) {
// Once the user specifies a targetEvent, we will automatically try to find the correct
// nested theme.
var targetEl;
if (options.targetEvent && options.targetEvent.target) {
targetEl = angular.element(options.targetEvent.target);
}
var themeCtrl = targetEl && targetEl.controller('mdTheme');
options.hasTheme = (!!themeCtrl);
if (!options.hasTheme) {
return;
}
options.themeWatch = themeCtrl.$shouldWatch;
var theme = options.theme || themeCtrl.$mdTheme;
if (theme) {
options.scope.theme = theme;
}
var unwatch = themeCtrl.registerChanges(function (newTheme) {
options.scope.theme = newTheme;
if (!options.themeWatch) {
unwatch();
}
});
}
/**
* Capture originator/trigger/from/to element information (if available)
* and the parent container for the dialog; defaults to the $rootElement
* unless overridden in the options.parent
*/
function captureParentAndFromToElements(options) {
options.origin = angular.extend({
element: null,
bounds: null,
focus: angular.noop
}, options.origin || {});
options.parent = getDomElement(options.parent, $rootElement);
options.closeTo = getBoundingClientRect(getDomElement(options.closeTo));
options.openFrom = getBoundingClientRect(getDomElement(options.openFrom));
if (options.targetEvent) {
options.origin = getBoundingClientRect(options.targetEvent.target, options.origin);
options.originInteraction = $mdInteraction.getLastInteractionType();
}
/**
* Identify the bounding RECT for the target element
*
*/
function getBoundingClientRect (element, orig) {
var source = angular.element((element || {}));
if (source && source.length) {
// Compute and save the target element's bounding rect, so that if the
// element is hidden when the dialog closes, we can shrink the dialog
// back to the same position it expanded from.
//
// Checking if the source is a rect object or a DOM element
var bounds = {top:0,left:0,height:0,width:0};
var hasFn = angular.isFunction(source[0].getBoundingClientRect);
return angular.extend(orig || {}, {
element : hasFn ? source : undefined,
bounds : hasFn ? source[0].getBoundingClientRect() : angular.extend({}, bounds, source[0]),
focus : angular.bind(source, source.focus),
});
}
}
/**
* If the specifier is a simple string selector, then query for
* the DOM element.
*/
function getDomElement(element, defaultElement) {
if (angular.isString(element)) {
element = $document[0].querySelector(element);
}
// If we have a reference to a raw dom element, always wrap it in jqLite
return angular.element(element || defaultElement);
}
}
/**
* Listen for escape keys and outside clicks to auto close
*/
function activateListeners(element, options) {
var window = angular.element($window);
var onWindowResize = $mdUtil.debounce(function() {
stretchDialogContainerToViewport(element, options);
}, 60);
var removeListeners = [];
var smartClose = function() {
// Only 'confirm' dialogs have a cancel button... escape/clickOutside will
// cancel or fallback to hide.
var closeFn = (options.$type == 'alert') ? $mdDialog.hide : $mdDialog.cancel;
$mdUtil.nextTick(closeFn, true);
};
if (options.escapeToClose) {
var parentTarget = options.parent;
var keyHandlerFn = function(ev) {
if (ev.keyCode === $mdConstant.KEY_CODE.ESCAPE) {
ev.stopImmediatePropagation();
ev.preventDefault();
smartClose();
}
};
// Add keydown listeners
element.on('keydown', keyHandlerFn);
parentTarget.on('keydown', keyHandlerFn);
// Queue remove listeners function
removeListeners.push(function() {
element.off('keydown', keyHandlerFn);
parentTarget.off('keydown', keyHandlerFn);
});
}
// Register listener to update dialog on window resize
window.on('resize', onWindowResize);
removeListeners.push(function() {
window.off('resize', onWindowResize);
});
if (options.clickOutsideToClose) {
var target = element;
var sourceElem;
// Keep track of the element on which the mouse originally went down
// so that we can only close the backdrop when the 'click' started on it.
// A simple 'click' handler does not work,
// it sets the target object as the element the mouse went down on.
var mousedownHandler = function(ev) {
sourceElem = ev.target;
};
// We check if our original element and the target is the backdrop
// because if the original was the backdrop and the target was inside the dialog
// we don't want to dialog to close.
var mouseupHandler = function(ev) {
if (sourceElem === target[0] && ev.target === target[0]) {
ev.stopPropagation();
ev.preventDefault();
smartClose();
}
};
// Add listeners
target.on('mousedown', mousedownHandler);
target.on('mouseup', mouseupHandler);
// Queue remove listeners function
removeListeners.push(function() {
target.off('mousedown', mousedownHandler);
target.off('mouseup', mouseupHandler);
});
}
// Attach specific `remove` listener handler
options.deactivateListeners = function() {
removeListeners.forEach(function(removeFn) {
removeFn();
});
options.deactivateListeners = null;
};
}
/**
* Show modal backdrop element...
*/
function showBackdrop(scope, element, options) {
if (options.disableParentScroll) {
// !! DO this before creating the backdrop; since disableScrollAround()
// configures the scroll offset; which is used by mdBackDrop postLink()
options.restoreScroll = $mdUtil.disableScrollAround(element, options.parent);
}
if (options.hasBackdrop) {
options.backdrop = $mdUtil.createBackdrop(scope, "md-dialog-backdrop md-opaque");
$animate.enter(options.backdrop, options.parent);
}
/**
* Hide modal backdrop element...
*/
options.hideBackdrop = function hideBackdrop($destroy) {
if (options.backdrop) {
if ($destroy) options.backdrop.remove();
else $animate.leave(options.backdrop);
}
if (options.disableParentScroll) {
options.restoreScroll && options.restoreScroll();
delete options.restoreScroll;
}
options.hideBackdrop = null;
};
}
/**
* Inject ARIA-specific attributes appropriate for Dialogs
*/
function configureAria(element, options) {
var role = (options.$type === 'alert') ? 'alertdialog' : 'dialog';
var dialogContent = element.find('md-dialog-content');
var existingDialogId = element.attr('id');
var dialogContentId = 'dialogContent_' + (existingDialogId || $mdUtil.nextUid());
element.attr({
'role': role,
'tabIndex': '-1'
});
if (dialogContent.length === 0) {
dialogContent = element;
// If the dialog element already had an ID, don't clobber it.
if (existingDialogId) {
dialogContentId = existingDialogId;
}
}
dialogContent.attr('id', dialogContentId);
element.attr('aria-describedby', dialogContentId);
if (options.ariaLabel) {
$mdAria.expect(element, 'aria-label', options.ariaLabel);
}
else {
$mdAria.expectAsync(element, 'aria-label', function() {
// If dialog title is specified, set aria-label with it
// See https://github.com/angular/material/issues/10582
if (options.title) {
return options.title;
} else {
var words = dialogContent.text().split(/\s+/);
if (words.length > 3) words = words.slice(0, 3).concat('...');
return words.join(' ');
}
});
}
// Set up elements before and after the dialog content to capture focus and
// redirect back into the dialog.
topFocusTrap = document.createElement('div');
topFocusTrap.classList.add('md-dialog-focus-trap');
topFocusTrap.tabIndex = 0;
bottomFocusTrap = topFocusTrap.cloneNode(false);
// When focus is about to move out of the dialog, we want to intercept it and redirect it
// back to the dialog element.
var focusHandler = function() {
element.focus();
};
topFocusTrap.addEventListener('focus', focusHandler);
bottomFocusTrap.addEventListener('focus', focusHandler);
// The top focus trap inserted immeidately before the md-dialog element (as a sibling).
// The bottom focus trap is inserted at the very end of the md-dialog element (as a child).
element[0].parentNode.insertBefore(topFocusTrap, element[0]);
element.after(bottomFocusTrap);
}
/**
* Prevents screen reader interaction behind modal window
* on swipe interfaces
*/
function lockScreenReader(element, options) {
var isHidden = true;
// get raw DOM node
walkDOM(element[0]);
options.unlockScreenReader = function () {
isHidden = false;
walkDOM(element[0]);
options.unlockScreenReader = null;
};
/**
* Get all of an element's parent elements up the DOM tree
* @return {Array} The parent elements
*/
function getParents(element) {
var parents = [];
while (element.parentNode) {
if (element === document.body) {
return parents;
}
var children = element.parentNode.children;
for (var i = 0; i < children.length; i++) {
// skip over child if it is an ascendant of the dialog
// a script or style tag, or a live region.
if (element !== children[i] &&
!isNodeOneOf(children[i], ['SCRIPT', 'STYLE']) &&
!children[i].hasAttribute('aria-live')) {
parents.push(children[i]);
}
}
element = element.parentNode;
}
return parents;
}
/**
* Walk DOM to apply or remove aria-hidden on sibling nodes
* and parent sibling nodes
*/
function walkDOM(element) {
var elements = getParents(element);
for (var i = 0; i < elements.length; i++) {
elements[i].setAttribute('aria-hidden', isHidden);
}
}
}
/**
* Ensure the dialog container fill-stretches to the viewport
*/
function stretchDialogContainerToViewport(container, options) {
var isFixed = $window.getComputedStyle($document[0].body).position == 'fixed';
var backdrop = options.backdrop ? $window.getComputedStyle(options.backdrop[0]) : null;
var height = backdrop ? Math.min($document[0].body.clientHeight, Math.ceil(Math.abs(parseInt(backdrop.height, 10)))) : 0;
var previousStyles = {
top: container.css('top'),
height: container.css('height')
};
// If the body is fixed, determine the distance to the viewport in relative from the parent.
var parentTop = Math.abs(options.parent[0].getBoundingClientRect().top);
container.css({
top: (isFixed ? parentTop : 0) + 'px',
height: height ? height + 'px' : '100%'
});
return function() {
// Reverts the modified styles back to the previous values.
// This is needed for contentElements, which should have the same styles after close
// as before.
container.css(previousStyles);
};
}
/**
* Dialog open and pop-in animation
*/
function dialogPopIn(container, options) {
// Add the `md-dialog-container` to the DOM
options.parent.append(container);
options.reverseContainerStretch = stretchDialogContainerToViewport(container, options);
var dialogEl = container.find('md-dialog');
var animator = $mdUtil.dom.animator;
var buildTranslateToOrigin = animator.calculateZoomToOrigin;
var translateOptions = {transitionInClass: 'md-transition-in', transitionOutClass: 'md-transition-out'};
var from = animator.toTransformCss(buildTranslateToOrigin(dialogEl, options.openFrom || options.origin));
var to = animator.toTransformCss(""); // defaults to center display (or parent or $rootElement)
dialogEl.toggleClass('md-dialog-fullscreen', !!options.fullscreen);
return animator
.translate3d(dialogEl, from, to, translateOptions)
.then(function(animateReversal) {
// Build a reversal translate function synced to this translation...
options.reverseAnimate = function() {
delete options.reverseAnimate;
if (options.closeTo) {
// Using the opposite classes to create a close animation to the closeTo element
translateOptions = {transitionInClass: 'md-transition-out', transitionOutClass: 'md-transition-in'};
from = to;
to = animator.toTransformCss(buildTranslateToOrigin(dialogEl, options.closeTo));
return animator
.translate3d(dialogEl, from, to,translateOptions);
}
return animateReversal(
to = animator.toTransformCss(
// in case the origin element has moved or is hidden,
// let's recalculate the translateCSS
buildTranslateToOrigin(dialogEl, options.origin)
)
);
};
// Function to revert the generated animation styles on the dialog element.
// Useful when using a contentElement instead of a template.
options.clearAnimate = function() {
delete options.clearAnimate;
// Remove the transition classes, added from $animateCSS, since those can't be removed
// by reversely running the animator.
dialogEl.removeClass([
translateOptions.transitionOutClass,
translateOptions.transitionInClass
].join(' '));
// Run the animation reversely to remove the previous added animation styles.
return animator.translate3d(dialogEl, to, animator.toTransformCss(''), {});
};
return true;
});
}
/**
* Dialog close and pop-out animation
*/
function dialogPopOut(container, options) {
return options.reverseAnimate().then(function() {
if (options.contentElement) {
// When we use a contentElement, we want the element to be the same as before.
// That means, that we have to clear all the animation properties, like transform.
options.clearAnimate();
}
});
}
/**
* Utility function to filter out raw DOM nodes
*/
function isNodeOneOf(elem, nodeTypeArray) {
if (nodeTypeArray.indexOf(elem.nodeName) !== -1) {
return true;
}
}
}
} | [
"function",
"MdDialogProvider",
"(",
"$$interimElementProvider",
")",
"{",
"// Elements to capture and redirect focus when the user presses tab at the dialog boundary.",
"var",
"topFocusTrap",
",",
"bottomFocusTrap",
";",
"return",
"$$interimElementProvider",
"(",
"'$mdDialog'",
")",... | @ngdoc method
@name $mdDialog#hide
@description
Hide an existing dialog and resolve the promise returned from `$mdDialog.show()`.
@param {*=} response An argument for the resolved promise.
@returns {promise} A promise that is resolved when the dialog has been closed.
@ngdoc method
@name $mdDialog#cancel
@description
Hide an existing dialog and reject the promise returned from `$mdDialog.show()`.
@param {*=} response An argument for the rejected promise.
@returns {promise} A promise that is resolved when the dialog has been closed. | [
"@ngdoc",
"method",
"@name",
"$mdDialog#hide"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/dialog/dialog.js#L582-L1309 | train | A provider that provides the options for the advanced dialog. | [
30522,
3853,
9108,
27184,
8649,
21572,
17258,
2121,
1006,
1002,
1002,
9455,
12260,
3672,
21572,
17258,
2121,
1007,
1063,
1013,
1013,
3787,
2000,
5425,
1998,
2417,
7442,
6593,
3579,
2043,
1996,
5310,
14616,
21628,
2012,
1996,
13764,
8649,
61... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GeekyAnts/vue-native-core | dist/vue.runtime.common.js | checkDuration | function checkDuration (val, name, vnode) {
if (typeof val !== 'number') {
warn(
"<transition> explicit " + name + " duration is not a valid number - " +
"got " + (JSON.stringify(val)) + ".",
vnode.context
);
} else if (isNaN(val)) {
warn(
"<transition> explicit " + name + " duration is NaN - " +
'the duration expression might be incorrect.',
vnode.context
);
}
} | javascript | function checkDuration (val, name, vnode) {
if (typeof val !== 'number') {
warn(
"<transition> explicit " + name + " duration is not a valid number - " +
"got " + (JSON.stringify(val)) + ".",
vnode.context
);
} else if (isNaN(val)) {
warn(
"<transition> explicit " + name + " duration is NaN - " +
'the duration expression might be incorrect.',
vnode.context
);
}
} | [
"function",
"checkDuration",
"(",
"val",
",",
"name",
",",
"vnode",
")",
"{",
"if",
"(",
"typeof",
"val",
"!==",
"'number'",
")",
"{",
"warn",
"(",
"\"<transition> explicit \"",
"+",
"name",
"+",
"\" duration is not a valid number - \"",
"+",
"\"got \"",
"+",
... | only used in dev mode | [
"only",
"used",
"in",
"dev",
"mode"
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/dist/vue.runtime.common.js#L5977-L5991 | train | Check if the duration expression is valid | [
30522,
3853,
4638,
24979,
3370,
1006,
11748,
1010,
2171,
1010,
1058,
3630,
3207,
1007,
1063,
2065,
1006,
2828,
11253,
11748,
999,
1027,
1027,
1005,
2193,
1005,
1007,
1063,
11582,
1006,
1000,
1026,
6653,
1028,
13216,
1000,
1009,
2171,
1009,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
goldfire/howler.js | dist/howler.js | function(node) {
var checkIE = /MSIE |Trident\//.test(Howler._navigator && Howler._navigator.userAgent);
if (!checkIE) {
node.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA';
}
} | javascript | function(node) {
var checkIE = /MSIE |Trident\//.test(Howler._navigator && Howler._navigator.userAgent);
if (!checkIE) {
node.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA';
}
} | [
"function",
"(",
"node",
")",
"{",
"var",
"checkIE",
"=",
"/",
"MSIE |Trident\\/",
"/",
".",
"test",
"(",
"Howler",
".",
"_navigator",
"&&",
"Howler",
".",
"_navigator",
".",
"userAgent",
")",
";",
"if",
"(",
"!",
"checkIE",
")",
"{",
"node",
".",
"s... | Set the source to a 0-second silence to stop any downloading (except in IE).
@param {Object} node Audio node to clear. | [
"Set",
"the",
"source",
"to",
"a",
"0",
"-",
"second",
"silence",
"to",
"stop",
"any",
"downloading",
"(",
"except",
"in",
"IE",
")",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L2140-L2145 | train | This function is called by the main function to create the audio file for a node | [
30522,
3853,
1006,
13045,
1007,
1063,
13075,
4638,
2666,
1027,
1013,
5796,
2666,
1064,
26515,
1032,
1013,
1013,
1012,
3231,
1006,
22912,
2121,
1012,
1035,
20532,
1004,
1004,
22912,
2121,
1012,
1035,
20532,
1012,
5310,
4270,
3372,
1007,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
feathericons/feather | src/replace.js | replace | function replace(attrs = {}) {
if (typeof document === 'undefined') {
throw new Error('`feather.replace()` only works in a browser environment.');
}
const elementsToReplace = document.querySelectorAll('[data-feather]');
Array.from(elementsToReplace).forEach(element =>
replaceElement(element, attrs),
);
} | javascript | function replace(attrs = {}) {
if (typeof document === 'undefined') {
throw new Error('`feather.replace()` only works in a browser environment.');
}
const elementsToReplace = document.querySelectorAll('[data-feather]');
Array.from(elementsToReplace).forEach(element =>
replaceElement(element, attrs),
);
} | [
"function",
"replace",
"(",
"attrs",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"typeof",
"document",
"===",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'`feather.replace()` only works in a browser environment.'",
")",
";",
"}",
"const",
"elementsToReplace",
... | Replace all HTML elements that have a `data-feather` attribute with SVG markup
corresponding to the element's `data-feather` attribute value.
@param {Object} attrs | [
"Replace",
"all",
"HTML",
"elements",
"that",
"have",
"a",
"data",
"-",
"feather",
"attribute",
"with",
"SVG",
"markup",
"corresponding",
"to",
"the",
"element",
"s",
"data",
"-",
"feather",
"attribute",
"value",
"."
] | 8f658193d25e943b196a2367319b5d9e85ee9f9f | https://github.com/feathericons/feather/blob/8f658193d25e943b196a2367319b5d9e85ee9f9f/src/replace.js#L11-L21 | train | Replace all feather elements with the specified attributes. | [
30522,
3853,
5672,
1006,
2012,
16344,
2015,
1027,
1063,
1065,
1007,
1063,
2065,
1006,
2828,
11253,
6254,
1027,
1027,
1027,
1005,
6151,
28344,
1005,
1007,
1063,
5466,
2047,
7561,
1006,
1005,
1036,
15550,
1012,
5672,
1006,
1007,
1036,
2069,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/curly.js | getElseKeyword | function getElseKeyword(node) {
return node.alternate && sourceCode.getFirstTokenBetween(node.consequent, node.alternate, isElseKeywordToken);
} | javascript | function getElseKeyword(node) {
return node.alternate && sourceCode.getFirstTokenBetween(node.consequent, node.alternate, isElseKeywordToken);
} | [
"function",
"getElseKeyword",
"(",
"node",
")",
"{",
"return",
"node",
".",
"alternate",
"&&",
"sourceCode",
".",
"getFirstTokenBetween",
"(",
"node",
".",
"consequent",
",",
"node",
".",
"alternate",
",",
"isElseKeywordToken",
")",
";",
"}"
] | Gets the `else` keyword token of a given `IfStatement` node.
@param {ASTNode} node - A `IfStatement` node to get.
@returns {Token} The `else` keyword token. | [
"Gets",
"the",
"else",
"keyword",
"token",
"of",
"a",
"given",
"IfStatement",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/curly.js#L121-L123 | train | Returns the first token of the else keyword of a IfStatement node. | [
30522,
3853,
2131,
9050,
23941,
2100,
18351,
1006,
13045,
1007,
1063,
2709,
13045,
1012,
6585,
1004,
1004,
3120,
16044,
1012,
2131,
8873,
12096,
18715,
2368,
20915,
28394,
2078,
1006,
13045,
1012,
9530,
3366,
15417,
1010,
13045,
1012,
6585,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/support/ToolsAPI.js | function (control) {
var result = [];
var inheritedMetadata = control.getMetadata().getParent();
while (inheritedMetadata instanceof ElementMetadata) {
result.push(this._copyInheritedProperties(control, inheritedMetadata));
inheritedMetadata = inheritedMetadata.getParent();
}
return result;
} | javascript | function (control) {
var result = [];
var inheritedMetadata = control.getMetadata().getParent();
while (inheritedMetadata instanceof ElementMetadata) {
result.push(this._copyInheritedProperties(control, inheritedMetadata));
inheritedMetadata = inheritedMetadata.getParent();
}
return result;
} | [
"function",
"(",
"control",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"inheritedMetadata",
"=",
"control",
".",
"getMetadata",
"(",
")",
".",
"getParent",
"(",
")",
";",
"while",
"(",
"inheritedMetadata",
"instanceof",
"ElementMetadata",
")",
"... | Creates an array with the control properties that are inherited.
@param {Object} control - UI5 control.
@returns {Array}
@private | [
"Creates",
"an",
"array",
"with",
"the",
"control",
"properties",
"that",
"are",
"inherited",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/ToolsAPI.js#L247-L257 | train | Returns an array of all inherited properties of the given control. | [
30522,
3853,
1006,
2491,
1007,
1063,
13075,
2765,
1027,
1031,
1033,
1025,
13075,
7900,
11368,
8447,
2696,
1027,
2491,
1012,
2131,
11368,
8447,
2696,
1006,
1007,
1012,
2131,
19362,
4765,
1006,
1007,
1025,
2096,
1006,
7900,
11368,
8447,
2696,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/NavigationAndHistory/main.js | _handleActiveEditorChange | function _handleActiveEditorChange(event, current, previous) {
if (current) { // Handle only full editors
if (_mrofList.length === 0) {
_initRecentFilesList();
}
var file = current.document.file;
var paneId = current._paneId;
_addToMROFList(file, paneId, current.getCursorPos(true, "first"));
}
if (previous) { // Capture the last know cursor position
_updateCursorPosition(previous.document.file.fullPath, previous._paneId, previous.getCursorPos(true, "first"));
}
} | javascript | function _handleActiveEditorChange(event, current, previous) {
if (current) { // Handle only full editors
if (_mrofList.length === 0) {
_initRecentFilesList();
}
var file = current.document.file;
var paneId = current._paneId;
_addToMROFList(file, paneId, current.getCursorPos(true, "first"));
}
if (previous) { // Capture the last know cursor position
_updateCursorPosition(previous.document.file.fullPath, previous._paneId, previous.getCursorPos(true, "first"));
}
} | [
"function",
"_handleActiveEditorChange",
"(",
"event",
",",
"current",
",",
"previous",
")",
"{",
"if",
"(",
"current",
")",
"{",
"// Handle only full editors",
"if",
"(",
"_mrofList",
".",
"length",
"===",
"0",
")",
"{",
"_initRecentFilesList",
"(",
")",
";",... | Handle Active Editor change to update mrof information | [
"Handle",
"Active",
"Editor",
"change",
"to",
"update",
"mrof",
"information"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/NavigationAndHistory/main.js#L782-L796 | train | Handle active editor change | [
30522,
3853,
1035,
5047,
19620,
2098,
15660,
22305,
2063,
1006,
2724,
1010,
2783,
1010,
3025,
1007,
1063,
2065,
1006,
2783,
1007,
1063,
1013,
1013,
5047,
2069,
2440,
10195,
2065,
1006,
1035,
2720,
11253,
9863,
1012,
3091,
1027,
1027,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (node)
{
if (typeof node !== "string") { return node; }
return node.replace(/^\s+|\s+$/g, '')
.replace(/\\/g, "\\5c")
.replace(/ /g, "\\20")
.replace(/\"/g, "\\22")
.replace(/\&/g, "\\26")
.replace(/\'/g, "\\27")
.replace(/\//g, "\\2f")
.replace(/:/g, "\\3a")
.replace(/</g, "\\3c")
.replace(/>/g, "\\3e")
.replace(/@/g, "\\40");
} | javascript | function (node)
{
if (typeof node !== "string") { return node; }
return node.replace(/^\s+|\s+$/g, '')
.replace(/\\/g, "\\5c")
.replace(/ /g, "\\20")
.replace(/\"/g, "\\22")
.replace(/\&/g, "\\26")
.replace(/\'/g, "\\27")
.replace(/\//g, "\\2f")
.replace(/:/g, "\\3a")
.replace(/</g, "\\3c")
.replace(/>/g, "\\3e")
.replace(/@/g, "\\40");
} | [
"function",
"(",
"node",
")",
"{",
"if",
"(",
"typeof",
"node",
"!==",
"\"string\"",
")",
"{",
"return",
"node",
";",
"}",
"return",
"node",
".",
"replace",
"(",
"/",
"^\\s+|\\s+$",
"/",
"g",
",",
"''",
")",
".",
"replace",
"(",
"/",
"\\\\",
"/",
... | Function: escapeNode
Escape the node part (also called local part) of a JID.
Parameters:
(String) node - A node (or local part).
Returns:
An escaped node (or local part). | [
"Function",
":",
"escapeNode",
"Escape",
"the",
"node",
"part",
"(",
"also",
"called",
"local",
"part",
")",
"of",
"a",
"JID",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L1256-L1270 | train | Returns a string that contains the tag name | [
30522,
3853,
1006,
13045,
1007,
1063,
2065,
1006,
2828,
11253,
13045,
999,
1027,
1027,
1000,
5164,
1000,
1007,
1063,
2709,
13045,
1025,
1065,
2709,
13045,
1012,
5672,
1006,
1013,
1034,
1032,
1055,
1009,
1064,
1032,
1055,
1009,
1002,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | function(evt, preventDefault, stopPropagation)
{
preventDefault = (preventDefault != null) ? preventDefault : true;
stopPropagation = (stopPropagation != null) ? stopPropagation : true;
if (preventDefault)
{
if (evt.preventDefault)
{
if (stopPropagation)
{
evt.stopPropagation();
}
evt.preventDefault();
}
else if (stopPropagation)
{
evt.cancelBubble = true;
}
}
// Opera
evt.isConsumed = true;
// Other browsers
if (!evt.preventDefault)
{
evt.returnValue = false;
}
} | javascript | function(evt, preventDefault, stopPropagation)
{
preventDefault = (preventDefault != null) ? preventDefault : true;
stopPropagation = (stopPropagation != null) ? stopPropagation : true;
if (preventDefault)
{
if (evt.preventDefault)
{
if (stopPropagation)
{
evt.stopPropagation();
}
evt.preventDefault();
}
else if (stopPropagation)
{
evt.cancelBubble = true;
}
}
// Opera
evt.isConsumed = true;
// Other browsers
if (!evt.preventDefault)
{
evt.returnValue = false;
}
} | [
"function",
"(",
"evt",
",",
"preventDefault",
",",
"stopPropagation",
")",
"{",
"preventDefault",
"=",
"(",
"preventDefault",
"!=",
"null",
")",
"?",
"preventDefault",
":",
"true",
";",
"stopPropagation",
"=",
"(",
"stopPropagation",
"!=",
"null",
")",
"?",
... | Function: consume
Consumes the given event.
Parameters:
evt - Native event to be consumed.
preventDefault - Optional boolean to prevent the default for the event.
Default is true.
stopPropagation - Option boolean to stop event propagation. Default is
true. | [
"Function",
":",
"consume"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L10033-L10063 | train | Prevent default behavior and stop propagation | [
30522,
3853,
1006,
23408,
2102,
1010,
4652,
3207,
7011,
11314,
1010,
2644,
21572,
4502,
12540,
1007,
1063,
4652,
3207,
7011,
11314,
1027,
1006,
4652,
3207,
7011,
11314,
999,
1027,
19701,
1007,
1029,
4652,
3207,
7011,
11314,
1024,
2995,
1025... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/base/i18n/ResourceBundle.js | nextFallbackLocale | function nextFallbackLocale(sLocale) {
// there is no fallback for the 'raw' locale or for null/undefined
if ( !sLocale ) {
return null;
}
// special (legacy) handling for zh_HK: try zh_TW (for Traditional Chinese) first before falling back to 'zh'
if ( sLocale === "zh_HK" ) {
return "zh_TW";
}
// if there are multiple segments (separated by underscores), remove the last one
var p = sLocale.lastIndexOf('_');
if ( p >= 0 ) {
return sLocale.slice(0,p);
}
// invariant: only a single segment, must be a language
// for any language but 'en', fallback to 'en' first before falling back to the 'raw' language (empty string)
return sLocale !== 'en' ? 'en' : '';
} | javascript | function nextFallbackLocale(sLocale) {
// there is no fallback for the 'raw' locale or for null/undefined
if ( !sLocale ) {
return null;
}
// special (legacy) handling for zh_HK: try zh_TW (for Traditional Chinese) first before falling back to 'zh'
if ( sLocale === "zh_HK" ) {
return "zh_TW";
}
// if there are multiple segments (separated by underscores), remove the last one
var p = sLocale.lastIndexOf('_');
if ( p >= 0 ) {
return sLocale.slice(0,p);
}
// invariant: only a single segment, must be a language
// for any language but 'en', fallback to 'en' first before falling back to the 'raw' language (empty string)
return sLocale !== 'en' ? 'en' : '';
} | [
"function",
"nextFallbackLocale",
"(",
"sLocale",
")",
"{",
"// there is no fallback for the 'raw' locale or for null/undefined",
"if",
"(",
"!",
"sLocale",
")",
"{",
"return",
"null",
";",
"}",
"// special (legacy) handling for zh_HK: try zh_TW (for Traditional Chinese) first befo... | Calculate the next fallback locale for the given locale.
Note: always keep this in sync with the fallback mechanism in Java, ABAP (MIME & BSP)
resource handler (Java: Peter M., MIME: Sebastian A., BSP: Silke A.)
@param {string} sLocale Locale string in Java format (underscores) or null
@returns {string|null} Next fallback Locale or null if there is no more fallback
@private | [
"Calculate",
"the",
"next",
"fallback",
"locale",
"for",
"the",
"given",
"locale",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/base/i18n/ResourceBundle.js#L129-L150 | train | Returns the next fallback locale for the given locale. | [
30522,
3853,
2279,
13976,
5963,
4135,
9289,
2063,
1006,
22889,
24755,
2571,
1007,
1063,
1013,
1013,
2045,
2003,
2053,
2991,
5963,
2005,
1996,
1005,
6315,
1005,
2334,
2063,
2030,
2005,
19701,
1013,
6151,
28344,
2065,
1006,
999,
22889,
24755,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
uber/deck.gl | modules/json/src/parsers/convert-json.js | convertJSONMapProps | function convertJSONMapProps(jsonProps, configuration) {
if (jsonProps.map || jsonProps.mapStyle) {
jsonProps.map = Object.assign({}, DEFAULT_MAP_PROPS, jsonProps.map);
}
if (!jsonProps.map) {
return;
}
if ('mapStyle' in jsonProps) {
jsonProps.map.style = jsonProps.mapStyle;
jsonProps.map.mapStyle = jsonProps.mapStyle;
delete jsonProps.mapStyle;
}
// TODO - better map handling
if ('viewState' in jsonProps) {
jsonProps.map.viewState = jsonProps.viewState;
}
} | javascript | function convertJSONMapProps(jsonProps, configuration) {
if (jsonProps.map || jsonProps.mapStyle) {
jsonProps.map = Object.assign({}, DEFAULT_MAP_PROPS, jsonProps.map);
}
if (!jsonProps.map) {
return;
}
if ('mapStyle' in jsonProps) {
jsonProps.map.style = jsonProps.mapStyle;
jsonProps.map.mapStyle = jsonProps.mapStyle;
delete jsonProps.mapStyle;
}
// TODO - better map handling
if ('viewState' in jsonProps) {
jsonProps.map.viewState = jsonProps.viewState;
}
} | [
"function",
"convertJSONMapProps",
"(",
"jsonProps",
",",
"configuration",
")",
"{",
"if",
"(",
"jsonProps",
".",
"map",
"||",
"jsonProps",
".",
"mapStyle",
")",
"{",
"jsonProps",
".",
"map",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"DEFAULT_MAP_P... | Normalizes map/mapStyle etc props to a `map: {style}` object-valued prop | [
"Normalizes",
"map",
"/",
"mapStyle",
"etc",
"props",
"to",
"a",
"map",
":",
"{",
"style",
"}",
"object",
"-",
"valued",
"prop"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/json/src/parsers/convert-json.js#L48-L67 | train | Convert the map properties from the json - style to the correct map style | [
30522,
3853,
10463,
22578,
2239,
2863,
9397,
18981,
2015,
1006,
1046,
3385,
21572,
4523,
1010,
9563,
1007,
1063,
2065,
1006,
1046,
3385,
21572,
4523,
1012,
4949,
1064,
1064,
1046,
3385,
21572,
4523,
1012,
7341,
27983,
1007,
1063,
1046,
3385... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/indent-legacy.js | checkIndentInFunctionBlock | function checkIndentInFunctionBlock(node) {
/*
* Search first caller in chain.
* Ex.:
*
* Models <- Identifier
* .User
* .find()
* .exec(function() {
* // function body
* });
*
* Looks for 'Models'
*/
const calleeNode = node.parent; // FunctionExpression
let indent;
if (calleeNode.parent &&
(calleeNode.parent.type === "Property" ||
calleeNode.parent.type === "ArrayExpression")) {
// If function is part of array or object, comma can be put at left
indent = getNodeIndent(calleeNode, false).goodChar;
} else {
// If function is standalone, simple calculate indent
indent = getNodeIndent(calleeNode).goodChar;
}
if (calleeNode.parent.type === "CallExpression") {
const calleeParent = calleeNode.parent;
if (calleeNode.type !== "FunctionExpression" && calleeNode.type !== "ArrowFunctionExpression") {
if (calleeParent && calleeParent.loc.start.line < node.loc.start.line) {
indent = getNodeIndent(calleeParent).goodChar;
}
} else {
if (isArgBeforeCalleeNodeMultiline(calleeNode) &&
calleeParent.callee.loc.start.line === calleeParent.callee.loc.end.line &&
!isNodeFirstInLine(calleeNode)) {
indent = getNodeIndent(calleeParent).goodChar;
}
}
}
/*
* function body indent should be indent + indent size, unless this
* is a FunctionDeclaration, FunctionExpression, or outer IIFE and the corresponding options are enabled.
*/
let functionOffset = indentSize;
if (options.outerIIFEBody !== null && isOuterIIFE(calleeNode)) {
functionOffset = options.outerIIFEBody * indentSize;
} else if (calleeNode.type === "FunctionExpression") {
functionOffset = options.FunctionExpression.body * indentSize;
} else if (calleeNode.type === "FunctionDeclaration") {
functionOffset = options.FunctionDeclaration.body * indentSize;
}
indent += functionOffset;
// check if the node is inside a variable
const parentVarNode = getVariableDeclaratorNode(node);
if (parentVarNode && isNodeInVarOnTop(node, parentVarNode)) {
indent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
}
if (node.body.length > 0) {
checkNodesIndent(node.body, indent);
}
checkLastNodeLineIndent(node, indent - functionOffset);
} | javascript | function checkIndentInFunctionBlock(node) {
/*
* Search first caller in chain.
* Ex.:
*
* Models <- Identifier
* .User
* .find()
* .exec(function() {
* // function body
* });
*
* Looks for 'Models'
*/
const calleeNode = node.parent; // FunctionExpression
let indent;
if (calleeNode.parent &&
(calleeNode.parent.type === "Property" ||
calleeNode.parent.type === "ArrayExpression")) {
// If function is part of array or object, comma can be put at left
indent = getNodeIndent(calleeNode, false).goodChar;
} else {
// If function is standalone, simple calculate indent
indent = getNodeIndent(calleeNode).goodChar;
}
if (calleeNode.parent.type === "CallExpression") {
const calleeParent = calleeNode.parent;
if (calleeNode.type !== "FunctionExpression" && calleeNode.type !== "ArrowFunctionExpression") {
if (calleeParent && calleeParent.loc.start.line < node.loc.start.line) {
indent = getNodeIndent(calleeParent).goodChar;
}
} else {
if (isArgBeforeCalleeNodeMultiline(calleeNode) &&
calleeParent.callee.loc.start.line === calleeParent.callee.loc.end.line &&
!isNodeFirstInLine(calleeNode)) {
indent = getNodeIndent(calleeParent).goodChar;
}
}
}
/*
* function body indent should be indent + indent size, unless this
* is a FunctionDeclaration, FunctionExpression, or outer IIFE and the corresponding options are enabled.
*/
let functionOffset = indentSize;
if (options.outerIIFEBody !== null && isOuterIIFE(calleeNode)) {
functionOffset = options.outerIIFEBody * indentSize;
} else if (calleeNode.type === "FunctionExpression") {
functionOffset = options.FunctionExpression.body * indentSize;
} else if (calleeNode.type === "FunctionDeclaration") {
functionOffset = options.FunctionDeclaration.body * indentSize;
}
indent += functionOffset;
// check if the node is inside a variable
const parentVarNode = getVariableDeclaratorNode(node);
if (parentVarNode && isNodeInVarOnTop(node, parentVarNode)) {
indent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind];
}
if (node.body.length > 0) {
checkNodesIndent(node.body, indent);
}
checkLastNodeLineIndent(node, indent - functionOffset);
} | [
"function",
"checkIndentInFunctionBlock",
"(",
"node",
")",
"{",
"/*\n * Search first caller in chain.\n * Ex.:\n *\n * Models <- Identifier\n * .User\n * .find()\n * .exec(function() {\n * // functio... | Check indent for function block content
@param {ASTNode} node A BlockStatement node that is inside of a function.
@returns {void} | [
"Check",
"indent",
"for",
"function",
"block",
"content"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/indent-legacy.js#L610-L683 | train | Check indent in function block | [
30522,
3853,
4638,
22254,
4765,
2378,
11263,
27989,
23467,
1006,
13045,
1007,
1063,
1013,
1008,
1008,
3945,
2034,
20587,
1999,
4677,
1012,
1008,
4654,
1012,
1024,
1008,
1008,
4275,
1026,
1011,
8909,
4765,
18095,
1008,
1012,
5310,
1008,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/document/DocumentManager.js | _proxyDeprecatedEvent | function _proxyDeprecatedEvent(eventName) {
DeprecationWarning.deprecateEvent(exports,
MainViewManager,
eventName,
eventName,
"DocumentManager." + eventName,
"MainViewManager." + eventName);
} | javascript | function _proxyDeprecatedEvent(eventName) {
DeprecationWarning.deprecateEvent(exports,
MainViewManager,
eventName,
eventName,
"DocumentManager." + eventName,
"MainViewManager." + eventName);
} | [
"function",
"_proxyDeprecatedEvent",
"(",
"eventName",
")",
"{",
"DeprecationWarning",
".",
"deprecateEvent",
"(",
"exports",
",",
"MainViewManager",
",",
"eventName",
",",
"eventName",
",",
"\"DocumentManager.\"",
"+",
"eventName",
",",
"\"MainViewManager.\"",
"+",
"... | Listens for the given event on MainViewManager, and triggers a copy of the event on DocumentManager whenever it occurs | [
"Listens",
"for",
"the",
"given",
"event",
"on",
"MainViewManager",
"and",
"triggers",
"a",
"copy",
"of",
"the",
"event",
"on",
"DocumentManager",
"whenever",
"it",
"occurs"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L651-L658 | train | Proxy a deprecated event to the main view manager | [
30522,
3853,
1035,
24540,
3207,
28139,
12921,
18697,
3372,
1006,
2724,
18442,
1007,
1063,
2139,
28139,
10719,
9028,
5582,
1012,
2139,
28139,
16280,
18697,
3372,
1006,
14338,
1010,
2364,
8584,
24805,
4590,
1010,
2724,
18442,
1010,
2724,
18442,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
fex-team/webuploader | src/widgets/upload.js | function(file) {
var me = this;
// 移出invalid的文件
$.each( me.request( 'get-files', Status.INVALID ), function() {
me.request( 'remove-file', this );
});
// 如果指定了开始某个文件,则只开始指定的文件。
if ( file ) {
file = file.id ? file : me.request( 'get-file', file );
if (file.getStatus() === Status.INTERRUPT) {
file.setStatus( Status.QUEUED );
$.each( me.pool, function( _, v ) {
// 之前暂停过。
if (v.file !== file) {
return;
}
v.transport && v.transport.send();
file.setStatus( Status.PROGRESS );
});
} else if (file.getStatus() !== Status.PROGRESS) {
file.setStatus( Status.QUEUED );
}
} else {
$.each( me.request( 'get-files', [ Status.INITED ] ), function() {
this.setStatus( Status.QUEUED );
});
}
if ( me.runing ) {
me.owner.trigger('startUpload', file);// 开始上传或暂停恢复的,trigger event
return Base.nextTick( me.__tick );
}
me.runing = true;
var files = [];
// 如果有暂停的,则续传
file || $.each( me.pool, function( _, v ) {
var file = v.file;
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);
if (v.waiting) {
return;
}
// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
}
});
$.each(files, function() {
this.setStatus( Status.PROGRESS );
});
file || $.each( me.request( 'get-files',
Status.INTERRUPT ), function() {
this.setStatus( Status.PROGRESS );
});
me._trigged = false;
Base.nextTick( me.__tick );
me.owner.trigger('startUpload');
} | javascript | function(file) {
var me = this;
// 移出invalid的文件
$.each( me.request( 'get-files', Status.INVALID ), function() {
me.request( 'remove-file', this );
});
// 如果指定了开始某个文件,则只开始指定的文件。
if ( file ) {
file = file.id ? file : me.request( 'get-file', file );
if (file.getStatus() === Status.INTERRUPT) {
file.setStatus( Status.QUEUED );
$.each( me.pool, function( _, v ) {
// 之前暂停过。
if (v.file !== file) {
return;
}
v.transport && v.transport.send();
file.setStatus( Status.PROGRESS );
});
} else if (file.getStatus() !== Status.PROGRESS) {
file.setStatus( Status.QUEUED );
}
} else {
$.each( me.request( 'get-files', [ Status.INITED ] ), function() {
this.setStatus( Status.QUEUED );
});
}
if ( me.runing ) {
me.owner.trigger('startUpload', file);// 开始上传或暂停恢复的,trigger event
return Base.nextTick( me.__tick );
}
me.runing = true;
var files = [];
// 如果有暂停的,则续传
file || $.each( me.pool, function( _, v ) {
var file = v.file;
if ( file.getStatus() === Status.INTERRUPT ) {
me._trigged = false;
files.push(file);
if (v.waiting) {
return;
}
// 文件 prepare 完后,如果暂停了,这个时候只会把文件插入 pool, 而不会创建 tranport,
v.transport ? v.transport.send() : me._doSend(v);
}
});
$.each(files, function() {
this.setStatus( Status.PROGRESS );
});
file || $.each( me.request( 'get-files',
Status.INTERRUPT ), function() {
this.setStatus( Status.PROGRESS );
});
me._trigged = false;
Base.nextTick( me.__tick );
me.owner.trigger('startUpload');
} | [
"function",
"(",
"file",
")",
"{",
"var",
"me",
"=",
"this",
";",
"// 移出invalid的文件",
"$",
".",
"each",
"(",
"me",
".",
"request",
"(",
"'get-files'",
",",
"Status",
".",
"INVALID",
")",
",",
"function",
"(",
")",
"{",
"me",
".",
"request",
"(",
"'r... | @event startUpload
@description 当开始上传流程时触发。
@for Uploader
开始上传。此方法可以从初始状态调用开始上传流程,也可以从暂停状态调用,继续上传流程。
可以指定开始某一个文件。
@grammar upload() => undefined
@grammar upload( file | fileId) => undefined
@method upload
@for Uploader | [
"@event",
"startUpload",
"@description",
"当开始上传流程时触发。",
"@for",
"Uploader",
"开始上传。此方法可以从初始状态调用开始上传流程,也可以从暂停状态调用,继续上传流程。"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/src/widgets/upload.js#L220-L293 | train | upload file | [
30522,
3853,
1006,
5371,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
1013,
1013,
100,
1774,
19528,
1916,
1861,
100,
1002,
1012,
2169,
1006,
2033,
1012,
5227,
1006,
1005,
2131,
1011,
6764,
1005,
1010,
3570,
1012,
19528,
1007,
1010,
3853,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/qunit/utils/MemoryLeakCheck.js | function(assert, mActual, mExpected, sMessage) {
var aUnexpectedElements = [];
for (var sId in mActual) {
if (!mExpected[sId]) {
aUnexpectedElements.push(mActual[sId]);
}
}
// enrich with helpful info to more easily identify the leaked control
for (var i = 0; i < aUnexpectedElements.length; i++) {
if (typeof aUnexpectedElements[i].getText === "function") {
aUnexpectedElements[i] += " (text: '" + aUnexpectedElements[i].getText() + "')";
}
}
sMessage = sMessage + (aUnexpectedElements.length > 0 ? ". LEFTOVERS: " + aUnexpectedElements.join(", ") : "");
assert.equal(aUnexpectedElements.length, 0, sMessage);
} | javascript | function(assert, mActual, mExpected, sMessage) {
var aUnexpectedElements = [];
for (var sId in mActual) {
if (!mExpected[sId]) {
aUnexpectedElements.push(mActual[sId]);
}
}
// enrich with helpful info to more easily identify the leaked control
for (var i = 0; i < aUnexpectedElements.length; i++) {
if (typeof aUnexpectedElements[i].getText === "function") {
aUnexpectedElements[i] += " (text: '" + aUnexpectedElements[i].getText() + "')";
}
}
sMessage = sMessage + (aUnexpectedElements.length > 0 ? ". LEFTOVERS: " + aUnexpectedElements.join(", ") : "");
assert.equal(aUnexpectedElements.length, 0, sMessage);
} | [
"function",
"(",
"assert",
",",
"mActual",
",",
"mExpected",
",",
"sMessage",
")",
"{",
"var",
"aUnexpectedElements",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"sId",
"in",
"mActual",
")",
"{",
"if",
"(",
"!",
"mExpected",
"[",
"sId",
"]",
")",
"{",
"... | asserts that both given maps have the same entries | [
"asserts",
"that",
"both",
"given",
"maps",
"have",
"the",
"same",
"entries"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/utils/MemoryLeakCheck.js#L156-L174 | train | Assert that the given objects are not equal | [
30522,
3853,
1006,
20865,
1010,
6097,
26302,
2140,
1010,
2033,
2595,
5051,
10985,
1010,
15488,
7971,
4270,
1007,
1063,
13075,
8740,
2638,
2595,
5051,
10985,
12260,
8163,
1027,
1031,
1033,
1025,
2005,
1006,
13075,
15765,
1999,
6097,
26302,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
uber/deck.gl | modules/core/src/lifecycle/create-props.js | createPropsPrototype | function createPropsPrototype(props, parentProps, propTypes, componentClass) {
const defaultProps = Object.create(null);
Object.assign(defaultProps, parentProps, props);
// Avoid freezing `id` prop
const id = getComponentName(componentClass);
delete props.id;
// Add getters/setters for async prop properties
Object.defineProperties(defaultProps, {
// `id` is treated specially because layer might need to override it
id: {
configurable: false,
writable: true,
value: id
}
});
// Add getters/setters for async prop properties
addAsyncPropsToPropPrototype(defaultProps, propTypes);
return defaultProps;
} | javascript | function createPropsPrototype(props, parentProps, propTypes, componentClass) {
const defaultProps = Object.create(null);
Object.assign(defaultProps, parentProps, props);
// Avoid freezing `id` prop
const id = getComponentName(componentClass);
delete props.id;
// Add getters/setters for async prop properties
Object.defineProperties(defaultProps, {
// `id` is treated specially because layer might need to override it
id: {
configurable: false,
writable: true,
value: id
}
});
// Add getters/setters for async prop properties
addAsyncPropsToPropPrototype(defaultProps, propTypes);
return defaultProps;
} | [
"function",
"createPropsPrototype",
"(",
"props",
",",
"parentProps",
",",
"propTypes",
",",
"componentClass",
")",
"{",
"const",
"defaultProps",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"Object",
".",
"assign",
"(",
"defaultProps",
",",
"parentPro... | Builds a pre-merged default props object that component props can inherit from | [
"Builds",
"a",
"pre",
"-",
"merged",
"default",
"props",
"object",
"that",
"component",
"props",
"can",
"inherit",
"from"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/core/src/lifecycle/create-props.js#L139-L162 | train | Create a prototype for the given props object. | [
30522,
3853,
3443,
21572,
4523,
21572,
3406,
13874,
1006,
24387,
1010,
6687,
21572,
4523,
1010,
17678,
13874,
2015,
1010,
6922,
26266,
1007,
1063,
9530,
3367,
12398,
21572,
4523,
1027,
4874,
1012,
3443,
1006,
19701,
1007,
1025,
4874,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/object-shorthand.js | enterFunction | function enterFunction() {
lexicalScopeStack.unshift(new Set());
context.getScope().variables.filter(variable => variable.name === "arguments").forEach(variable => {
variable.references.map(ref => ref.identifier).forEach(identifier => argumentsIdentifiers.add(identifier));
});
} | javascript | function enterFunction() {
lexicalScopeStack.unshift(new Set());
context.getScope().variables.filter(variable => variable.name === "arguments").forEach(variable => {
variable.references.map(ref => ref.identifier).forEach(identifier => argumentsIdentifiers.add(identifier));
});
} | [
"function",
"enterFunction",
"(",
")",
"{",
"lexicalScopeStack",
".",
"unshift",
"(",
"new",
"Set",
"(",
")",
")",
";",
"context",
".",
"getScope",
"(",
")",
".",
"variables",
".",
"filter",
"(",
"variable",
"=>",
"variable",
".",
"name",
"===",
"\"argum... | Enters a function. This creates a new lexical identifier scope, so a new Set of arrow functions is pushed onto the stack.
Also, this marks all `arguments` identifiers so that they can be detected later.
@returns {void} | [
"Enters",
"a",
"function",
".",
"This",
"creates",
"a",
"new",
"lexical",
"identifier",
"scope",
"so",
"a",
"new",
"Set",
"of",
"arrow",
"functions",
"is",
"pushed",
"onto",
"the",
"stack",
".",
"Also",
"this",
"marks",
"all",
"arguments",
"identifiers",
"... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/object-shorthand.js#L321-L326 | train | Enter function. | [
30522,
3853,
4607,
11263,
27989,
1006,
1007,
1063,
16105,
9289,
26127,
9153,
3600,
1012,
4895,
6182,
6199,
1006,
2047,
2275,
1006,
1007,
1007,
1025,
6123,
1012,
4152,
16186,
1006,
1007,
1012,
10857,
1012,
11307,
1006,
8023,
1027,
1028,
8023... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-implicit-coercion.js | report | function report(node, recommendation, shouldFix) {
context.report({
node,
message: "use `{{recommendation}}` instead.",
data: {
recommendation
},
fix(fixer) {
if (!shouldFix) {
return null;
}
const tokenBefore = sourceCode.getTokenBefore(node);
if (
tokenBefore &&
tokenBefore.range[1] === node.range[0] &&
!astUtils.canTokensBeAdjacent(tokenBefore, recommendation)
) {
return fixer.replaceText(node, ` ${recommendation}`);
}
return fixer.replaceText(node, recommendation);
}
});
} | javascript | function report(node, recommendation, shouldFix) {
context.report({
node,
message: "use `{{recommendation}}` instead.",
data: {
recommendation
},
fix(fixer) {
if (!shouldFix) {
return null;
}
const tokenBefore = sourceCode.getTokenBefore(node);
if (
tokenBefore &&
tokenBefore.range[1] === node.range[0] &&
!astUtils.canTokensBeAdjacent(tokenBefore, recommendation)
) {
return fixer.replaceText(node, ` ${recommendation}`);
}
return fixer.replaceText(node, recommendation);
}
});
} | [
"function",
"report",
"(",
"node",
",",
"recommendation",
",",
"shouldFix",
")",
"{",
"context",
".",
"report",
"(",
"{",
"node",
",",
"message",
":",
"\"use `{{recommendation}}` instead.\"",
",",
"data",
":",
"{",
"recommendation",
"}",
",",
"fix",
"(",
"fi... | Reports an error and autofixes the node
@param {ASTNode} node - An ast node to report the error on.
@param {string} recommendation - The recommended code for the issue
@param {bool} shouldFix - Whether this report should fix the node
@returns {void} | [
"Reports",
"an",
"error",
"and",
"autofixes",
"the",
"node"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-implicit-coercion.js#L204-L228 | train | Reports a node with a given recommendation. | [
30522,
3853,
3189,
1006,
13045,
1010,
12832,
1010,
2323,
8873,
2595,
1007,
1063,
6123,
1012,
3189,
1006,
1063,
13045,
1010,
4471,
1024,
1000,
2224,
1036,
1063,
1063,
12832,
1065,
1065,
1036,
2612,
1012,
1000,
1010,
2951,
1024,
1063,
12832,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/QuickOpenHTML/main.js | FileLocation | function FileLocation(fullPath, line, chFrom, chTo, id) {
this.fullPath = fullPath;
this.line = line;
this.chFrom = chFrom;
this.chTo = chTo;
this.id = id;
} | javascript | function FileLocation(fullPath, line, chFrom, chTo, id) {
this.fullPath = fullPath;
this.line = line;
this.chFrom = chFrom;
this.chTo = chTo;
this.id = id;
} | [
"function",
"FileLocation",
"(",
"fullPath",
",",
"line",
",",
"chFrom",
",",
"chTo",
",",
"id",
")",
"{",
"this",
".",
"fullPath",
"=",
"fullPath",
";",
"this",
".",
"line",
"=",
"line",
";",
"this",
".",
"chFrom",
"=",
"chFrom",
";",
"this",
".",
... | FileLocation class
@constructor
@param {string} fullPath
@param {number} line
@param {number} chFrom column start position
@param {number} chTo column end position
@param {string} id | [
"FileLocation",
"class"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/QuickOpenHTML/main.js#L45-L51 | train | FileLocation constructor. | [
30522,
3853,
5371,
4135,
10719,
1006,
2440,
15069,
1010,
2240,
1010,
10381,
19699,
5358,
1010,
10381,
3406,
1010,
8909,
1007,
1063,
2023,
1012,
2440,
15069,
1027,
2440,
15069,
1025,
2023,
1012,
2240,
1027,
2240,
1025,
2023,
1012,
10381,
196... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
airbnb/enzyme | packages/enzyme/src/selectors.js | matchAdjacentSiblings | function matchAdjacentSiblings(nodes, predicate, root) {
return nodes.reduce((matches, node) => {
const parent = findParentNode(root, node);
// If there's no parent, there's no siblings
if (!parent) {
return matches;
}
const parentChildren = childrenOfNode(parent);
const nodeIndex = parentChildren.indexOf(node);
const adjacentSibling = parentChildren[nodeIndex + 1];
// No sibling
if (!adjacentSibling) {
return matches;
}
if (predicate(adjacentSibling)) {
matches.push(adjacentSibling);
}
return matches;
}, []);
} | javascript | function matchAdjacentSiblings(nodes, predicate, root) {
return nodes.reduce((matches, node) => {
const parent = findParentNode(root, node);
// If there's no parent, there's no siblings
if (!parent) {
return matches;
}
const parentChildren = childrenOfNode(parent);
const nodeIndex = parentChildren.indexOf(node);
const adjacentSibling = parentChildren[nodeIndex + 1];
// No sibling
if (!adjacentSibling) {
return matches;
}
if (predicate(adjacentSibling)) {
matches.push(adjacentSibling);
}
return matches;
}, []);
} | [
"function",
"matchAdjacentSiblings",
"(",
"nodes",
",",
"predicate",
",",
"root",
")",
"{",
"return",
"nodes",
".",
"reduce",
"(",
"(",
"matches",
",",
"node",
")",
"=>",
"{",
"const",
"parent",
"=",
"findParentNode",
"(",
"root",
",",
"node",
")",
";",
... | Matches only nodes which are adjacent siblings (direct next sibling)
against a predicate, returning those that match.
@param {Array<Node>} nodes
@param {Function} predicate
@param {Node} root | [
"Matches",
"only",
"nodes",
"which",
"are",
"adjacent",
"siblings",
"(",
"direct",
"next",
"sibling",
")",
"against",
"a",
"predicate",
"returning",
"those",
"that",
"match",
"."
] | cd430eae95eba151f17e970ee77c18f09476de0e | https://github.com/airbnb/enzyme/blob/cd430eae95eba151f17e970ee77c18f09476de0e/packages/enzyme/src/selectors.js#L301-L320 | train | Match adjacent siblings of nodes | [
30522,
3853,
2674,
4215,
3900,
13013,
5332,
9709,
2015,
1006,
14164,
1010,
3653,
16467,
1010,
7117,
1007,
1063,
2709,
14164,
1012,
5547,
1006,
1006,
3503,
1010,
13045,
1007,
1027,
1028,
1063,
9530,
3367,
6687,
1027,
2424,
19362,
4765,
3630,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/preferences/PreferencesBase.js | PreferencesSystem | function PreferencesSystem(contextBuilder) {
this.contextBuilder = contextBuilder;
this._knownPrefs = {};
this._scopes = {
"default": new Scope(new MemoryStorage())
};
this._scopes["default"].load();
this._defaults = {
scopeOrder: ["default"],
_shadowScopeOrder: [{
id: "default",
scope: this._scopes["default"],
promise: (new $.Deferred()).resolve().promise()
}]
};
this._pendingScopes = {};
this._saveInProgress = false;
this._nextSaveDeferred = null;
// The objects that define the different kinds of path-based Scope handlers.
// Examples could include the handler for .brackets.json files or an .editorconfig
// handler.
this._pathScopeDefinitions = {};
// Names of the files that contain path scopes
this._pathScopeFilenames = [];
// Keeps track of cached path scope objects.
this._pathScopes = {};
// Keeps track of change events that need to be sent when change events are resumed
this._changeEventQueue = null;
var notifyPrefChange = function (id) {
var pref = this._knownPrefs[id];
if (pref) {
pref.trigger(PREFERENCE_CHANGE);
}
}.bind(this);
// When we signal a general change message on this manager, we also signal a change
// on the individual preference object.
this.on(PREFERENCE_CHANGE, function (e, data) {
data.ids.forEach(notifyPrefChange);
}.bind(this));
} | javascript | function PreferencesSystem(contextBuilder) {
this.contextBuilder = contextBuilder;
this._knownPrefs = {};
this._scopes = {
"default": new Scope(new MemoryStorage())
};
this._scopes["default"].load();
this._defaults = {
scopeOrder: ["default"],
_shadowScopeOrder: [{
id: "default",
scope: this._scopes["default"],
promise: (new $.Deferred()).resolve().promise()
}]
};
this._pendingScopes = {};
this._saveInProgress = false;
this._nextSaveDeferred = null;
// The objects that define the different kinds of path-based Scope handlers.
// Examples could include the handler for .brackets.json files or an .editorconfig
// handler.
this._pathScopeDefinitions = {};
// Names of the files that contain path scopes
this._pathScopeFilenames = [];
// Keeps track of cached path scope objects.
this._pathScopes = {};
// Keeps track of change events that need to be sent when change events are resumed
this._changeEventQueue = null;
var notifyPrefChange = function (id) {
var pref = this._knownPrefs[id];
if (pref) {
pref.trigger(PREFERENCE_CHANGE);
}
}.bind(this);
// When we signal a general change message on this manager, we also signal a change
// on the individual preference object.
this.on(PREFERENCE_CHANGE, function (e, data) {
data.ids.forEach(notifyPrefChange);
}.bind(this));
} | [
"function",
"PreferencesSystem",
"(",
"contextBuilder",
")",
"{",
"this",
".",
"contextBuilder",
"=",
"contextBuilder",
";",
"this",
".",
"_knownPrefs",
"=",
"{",
"}",
";",
"this",
".",
"_scopes",
"=",
"{",
"\"default\"",
":",
"new",
"Scope",
"(",
"new",
"... | PreferencesSystem ties everything together to provide a simple interface for
managing the whole prefs system.
It keeps track of multiple Scope levels and also manages path-based Scopes.
It also provides the ability to register preferences, which gives a fine-grained
means for listening for changes and will ultimately allow for automatic UI generation.
The contextBuilder is used to construct get/set contexts based on the needs of individual
context systems. It can be passed in at construction time or set later.
@constructor
@param {function=} contextNormalizer function that is passed the context used for get or set to adjust for specific PreferencesSystem behavior | [
"PreferencesSystem",
"ties",
"everything",
"together",
"to",
"provide",
"a",
"simple",
"interface",
"for",
"managing",
"the",
"whole",
"prefs",
"system",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L1240-L1290 | train | Constructs a new PreferencesSystem instance. | [
30522,
3853,
18394,
6508,
13473,
2213,
1006,
6123,
8569,
23891,
2099,
1007,
1063,
2023,
1012,
6123,
8569,
23891,
2099,
1027,
6123,
8569,
23891,
2099,
1025,
2023,
1012,
1035,
2124,
28139,
10343,
1027,
1063,
1065,
1025,
2023,
1012,
1035,
9531... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/WorkingSetSort.js | setAutomatic | function setAutomatic(enable) {
_automaticSort = enable;
PreferencesManager.setViewState("automaticSort", _automaticSort);
CommandManager.get(Commands.CMD_WORKING_SORT_TOGGLE_AUTO).setChecked(_automaticSort);
_currentSort.setChecked(_automaticSort);
if (_automaticSort) {
_currentSort.sort();
} else {
_removeListeners();
}
} | javascript | function setAutomatic(enable) {
_automaticSort = enable;
PreferencesManager.setViewState("automaticSort", _automaticSort);
CommandManager.get(Commands.CMD_WORKING_SORT_TOGGLE_AUTO).setChecked(_automaticSort);
_currentSort.setChecked(_automaticSort);
if (_automaticSort) {
_currentSort.sort();
} else {
_removeListeners();
}
} | [
"function",
"setAutomatic",
"(",
"enable",
")",
"{",
"_automaticSort",
"=",
"enable",
";",
"PreferencesManager",
".",
"setViewState",
"(",
"\"automaticSort\"",
",",
"_automaticSort",
")",
";",
"CommandManager",
".",
"get",
"(",
"Commands",
".",
"CMD_WORKING_SORT_TOG... | Enables/Disables Automatic Sort depending on the value.
@param {boolean} enable True to enable, false to disable. | [
"Enables",
"/",
"Disables",
"Automatic",
"Sort",
"depending",
"on",
"the",
"value",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetSort.js#L153-L164 | train | Set automatic sort | [
30522,
3853,
2275,
4887,
20389,
12070,
1006,
9585,
1007,
1063,
1035,
6882,
21748,
2102,
1027,
9585,
1025,
18394,
24805,
4590,
1012,
2275,
8584,
9153,
2618,
1006,
1000,
6882,
21748,
2102,
1000,
1010,
1035,
6882,
21748,
2102,
1007,
1025,
3094... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/preferences/PreferencesBase.js | function (data, id, value, context, layerID) {
if (!layerID) {
layerID = this.getPreferenceLocation(data, id, context);
}
if (!layerID) {
return false;
}
var section = data[layerID];
if (!section) {
data[layerID] = section = {};
}
if (!_.isEqual(section[id], value)) {
if (value === undefined) {
delete section[id];
} else {
section[id] = _.cloneDeep(value);
}
return true;
}
return false;
} | javascript | function (data, id, value, context, layerID) {
if (!layerID) {
layerID = this.getPreferenceLocation(data, id, context);
}
if (!layerID) {
return false;
}
var section = data[layerID];
if (!section) {
data[layerID] = section = {};
}
if (!_.isEqual(section[id], value)) {
if (value === undefined) {
delete section[id];
} else {
section[id] = _.cloneDeep(value);
}
return true;
}
return false;
} | [
"function",
"(",
"data",
",",
"id",
",",
"value",
",",
"context",
",",
"layerID",
")",
"{",
"if",
"(",
"!",
"layerID",
")",
"{",
"layerID",
"=",
"this",
".",
"getPreferenceLocation",
"(",
"data",
",",
"id",
",",
"context",
")",
";",
"}",
"if",
"(",... | Sets the preference value in the given data structure for the layerID provided. If no
layerID is provided, then the current layer is used. If a layerID is provided and it
does not exist, it will be created.
This function returns whether or not a value was set.
@param {Object} data the preference data from the Scope
@param {string} id preference ID to look up
@param {Object} value new value to assign to the preference
@param {Object} context Object with filename that will be compared to the globs
@param {string=} layerID Optional: glob pattern for a specific section to set the value in
@return {boolean} true if the value was set | [
"Sets",
"the",
"preference",
"value",
"in",
"the",
"given",
"data",
"structure",
"for",
"the",
"layerID",
"provided",
".",
"If",
"no",
"layerID",
"is",
"provided",
"then",
"the",
"current",
"layer",
"is",
"used",
".",
"If",
"a",
"layerID",
"is",
"provided"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L928-L950 | train | Set preference value | [
30522,
3853,
1006,
2951,
1010,
8909,
1010,
3643,
1010,
6123,
1010,
6741,
3593,
1007,
1063,
2065,
1006,
999,
6741,
3593,
1007,
1063,
6741,
3593,
1027,
2023,
1012,
2131,
28139,
25523,
4135,
10719,
1006,
2951,
1010,
8909,
1010,
6123,
1007,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | mxGraphHierarchyEdge | function mxGraphHierarchyEdge(edges)
{
mxGraphAbstractHierarchyCell.apply(this, arguments);
this.edges = edges;
this.ids = [];
for (var i = 0; i < edges.length; i++)
{
this.ids.push(mxObjectIdentity.get(edges[i]));
}
} | javascript | function mxGraphHierarchyEdge(edges)
{
mxGraphAbstractHierarchyCell.apply(this, arguments);
this.edges = edges;
this.ids = [];
for (var i = 0; i < edges.length; i++)
{
this.ids.push(mxObjectIdentity.get(edges[i]));
}
} | [
"function",
"mxGraphHierarchyEdge",
"(",
"edges",
")",
"{",
"mxGraphAbstractHierarchyCell",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"edges",
"=",
"edges",
";",
"this",
".",
"ids",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxGraphHierarchyEdge
An abstraction of a hierarchical edge for the hierarchy layout
Constructor: mxGraphHierarchyEdge
Constructs a hierarchy edge
Arguments:
edges - a list of real graph edges this abstraction represents | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxGraphHierarchyEdge"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L33179-L33189 | train | A hierarchy edge is a cell that contains a single node. | [
30522,
3853,
25630,
14413,
4048,
6906,
29389,
24225,
1006,
7926,
1007,
1063,
25630,
14413,
7875,
20528,
6593,
4048,
6906,
29389,
29109,
2140,
1012,
6611,
1006,
2023,
1010,
9918,
1007,
1025,
2023,
1012,
7926,
1027,
7926,
1025,
2023,
1012,
89... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GoogleChrome/workbox | packages/workbox-cli/src/app.js | runBuildCommand | async function runBuildCommand({command, config, watch}) {
try {
const {size, count, warnings} = await workboxBuild[command](config);
for (const warning of warnings) {
logger.warn(warning);
}
logger.log(`The service worker was written to ${config.swDest}\n` +
`${count} files will be precached, totalling ${prettyBytes(size)}.`);
if (watch) {
logger.log(`\nWatching for changes...`);
}
} catch (error) {
// See https://github.com/hapijs/joi/blob/v11.3.4/API.md#errors
if (typeof error.annotate === 'function') {
throw new Error(
`${errors['config-validation-failed']}\n${error.annotate()}`);
}
logger.error(errors['workbox-build-runtime-error']);
throw error;
}
} | javascript | async function runBuildCommand({command, config, watch}) {
try {
const {size, count, warnings} = await workboxBuild[command](config);
for (const warning of warnings) {
logger.warn(warning);
}
logger.log(`The service worker was written to ${config.swDest}\n` +
`${count} files will be precached, totalling ${prettyBytes(size)}.`);
if (watch) {
logger.log(`\nWatching for changes...`);
}
} catch (error) {
// See https://github.com/hapijs/joi/blob/v11.3.4/API.md#errors
if (typeof error.annotate === 'function') {
throw new Error(
`${errors['config-validation-failed']}\n${error.annotate()}`);
}
logger.error(errors['workbox-build-runtime-error']);
throw error;
}
} | [
"async",
"function",
"runBuildCommand",
"(",
"{",
"command",
",",
"config",
",",
"watch",
"}",
")",
"{",
"try",
"{",
"const",
"{",
"size",
",",
"count",
",",
"warnings",
"}",
"=",
"await",
"workboxBuild",
"[",
"command",
"]",
"(",
"config",
")",
";",
... | Runs the specified build command with the provided configuration.
@param {Object} options | [
"Runs",
"the",
"specified",
"build",
"command",
"with",
"the",
"provided",
"configuration",
"."
] | 8379c51b6deaf52faed5879206fe84579cae41f0 | https://github.com/GoogleChrome/workbox/blob/8379c51b6deaf52faed5879206fe84579cae41f0/packages/workbox-cli/src/app.js#L27-L50 | train | Run the given command on the cluster | [
30522,
2004,
6038,
2278,
3853,
2448,
8569,
4014,
16409,
5358,
2386,
2094,
1006,
1063,
3094,
1010,
9530,
8873,
2290,
1010,
3422,
1065,
1007,
1063,
3046,
1063,
9530,
3367,
1063,
2946,
1010,
4175,
1010,
16234,
1065,
1027,
26751,
2147,
8758,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/publisher/configuration.js | fromConfigFile | function fromConfigFile(config) {
var sharedFileConfig;
try {
var configFile = AWS.util.iniLoader.loadFrom({
isConfig: true,
filename: process.env[AWS.util.sharedConfigFileEnv]
});
var sharedFileConfig = configFile[
process.env.AWS_PROFILE || AWS.util.defaultProfile
];
} catch (err) {
return false;
}
if (!sharedFileConfig) return config;
config.port = config.port || sharedFileConfig.csm_port;
config.enabled = config.enabled || sharedFileConfig.csm_enabled;
config.clientId = config.clientId || sharedFileConfig.csm_client_id;
return config.port && config.enabled && config.clientId;
} | javascript | function fromConfigFile(config) {
var sharedFileConfig;
try {
var configFile = AWS.util.iniLoader.loadFrom({
isConfig: true,
filename: process.env[AWS.util.sharedConfigFileEnv]
});
var sharedFileConfig = configFile[
process.env.AWS_PROFILE || AWS.util.defaultProfile
];
} catch (err) {
return false;
}
if (!sharedFileConfig) return config;
config.port = config.port || sharedFileConfig.csm_port;
config.enabled = config.enabled || sharedFileConfig.csm_enabled;
config.clientId = config.clientId || sharedFileConfig.csm_client_id;
return config.port && config.enabled && config.clientId;
} | [
"function",
"fromConfigFile",
"(",
"config",
")",
"{",
"var",
"sharedFileConfig",
";",
"try",
"{",
"var",
"configFile",
"=",
"AWS",
".",
"util",
".",
"iniLoader",
".",
"loadFrom",
"(",
"{",
"isConfig",
":",
"true",
",",
"filename",
":",
"process",
".",
"... | Resolve cofigurations from shared config file with specified role name
@param {object} client side monitoring config object needs to be resolved
@returns {boolean} whether resolving configurations is done
@api private | [
"Resolve",
"cofigurations",
"from",
"shared",
"config",
"file",
"with",
"specified",
"role",
"name"
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/publisher/configuration.js#L40-L58 | train | Get the config from the shared config file | [
30522,
3853,
2013,
8663,
8873,
25708,
9463,
1006,
9530,
8873,
2290,
1007,
1063,
13075,
4207,
8873,
2571,
8663,
8873,
2290,
1025,
30524,
4372,
2615,
1031,
22091,
2015,
1012,
21183,
4014,
1012,
4207,
8663,
8873,
25708,
9463,
2368,
2615,
1033,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/events/jquery/EventSimulation.js | function(oEvent, oConfig) {
if (oEvent.isMarked("handledByTouchToMouse")) {
return;
}
oEvent.setMarked("handledByTouchToMouse");
if (!bFingerIsMoved) {
var oTouch = oEvent.originalEvent.touches[0];
bFingerIsMoved = (Math.abs(oTouch.pageX - iStartX) > iMoveThreshold ||
Math.abs(oTouch.pageY - iStartY) > iMoveThreshold);
}
if (bBlackberryDevice) {
//Blackberry sends many touchmoves -> create a simulated mousemove every 50ms
if (iLastTouchMoveTime && oEvent.timeStamp - iLastTouchMoveTime < 50) {
return;
}
iLastTouchMoveTime = oEvent.timeStamp;
}
var oNewEvent = fnCreateNewEvent(oEvent, oConfig, oEvent.touches[0]);
setTimeout(function() {
oNewEvent.setMark("handledByUIArea", false);
oConfig.eventHandle.handler.call(oConfig.domRef, oNewEvent);
}, 0);
} | javascript | function(oEvent, oConfig) {
if (oEvent.isMarked("handledByTouchToMouse")) {
return;
}
oEvent.setMarked("handledByTouchToMouse");
if (!bFingerIsMoved) {
var oTouch = oEvent.originalEvent.touches[0];
bFingerIsMoved = (Math.abs(oTouch.pageX - iStartX) > iMoveThreshold ||
Math.abs(oTouch.pageY - iStartY) > iMoveThreshold);
}
if (bBlackberryDevice) {
//Blackberry sends many touchmoves -> create a simulated mousemove every 50ms
if (iLastTouchMoveTime && oEvent.timeStamp - iLastTouchMoveTime < 50) {
return;
}
iLastTouchMoveTime = oEvent.timeStamp;
}
var oNewEvent = fnCreateNewEvent(oEvent, oConfig, oEvent.touches[0]);
setTimeout(function() {
oNewEvent.setMark("handledByUIArea", false);
oConfig.eventHandle.handler.call(oConfig.domRef, oNewEvent);
}, 0);
} | [
"function",
"(",
"oEvent",
",",
"oConfig",
")",
"{",
"if",
"(",
"oEvent",
".",
"isMarked",
"(",
"\"handledByTouchToMouse\"",
")",
")",
"{",
"return",
";",
"}",
"oEvent",
".",
"setMarked",
"(",
"\"handledByTouchToMouse\"",
")",
";",
"if",
"(",
"!",
"bFinger... | This function simulates the corresponding mouse event by listening to touch event (touchmove).
The simulated event will be dispatch through UI5 event delegation which means that the on"EventName" function is called
on control's prototype.
@param {jQuery.Event} oEvent The original event object
@param {object} oConfig Additional configuration passed from createSimulatedEvent function | [
"This",
"function",
"simulates",
"the",
"corresponding",
"mouse",
"event",
"by",
"listening",
"to",
"touch",
"event",
"(",
"touchmove",
")",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/events/jquery/EventSimulation.js#L261-L287 | train | This function is called when a touch event is handled by the mouse | [
30522,
3853,
1006,
1051,
18697,
3372,
1010,
1051,
8663,
8873,
2290,
1007,
1063,
2065,
1006,
1051,
18697,
3372,
1012,
2003,
10665,
2098,
1006,
1000,
8971,
3762,
24826,
10143,
19506,
8557,
1000,
1007,
1007,
1063,
2709,
1025,
1065,
1051,
18697... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Freeboard/freeboard | js/freeboard.thirdparty.js | function(key) {
var style = this.css( key ),
val = [];
$.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
if ( style.indexOf( unit ) > 0 ) {
val = [ parseFloat( style ), unit ];
}
});
return val;
} | javascript | function(key) {
var style = this.css( key ),
val = [];
$.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
if ( style.indexOf( unit ) > 0 ) {
val = [ parseFloat( style ), unit ];
}
});
return val;
} | [
"function",
"(",
"key",
")",
"{",
"var",
"style",
"=",
"this",
".",
"css",
"(",
"key",
")",
",",
"val",
"=",
"[",
"]",
";",
"$",
".",
"each",
"(",
"[",
"\"em\"",
",",
"\"px\"",
",",
"\"%\"",
",",
"\"pt\"",
"]",
",",
"function",
"(",
"i",
",",... | helper functions | [
"helper",
"functions"
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L5999-L6009 | train | get the value of a CSS property | [
30522,
3853,
1006,
3145,
1007,
1063,
13075,
2806,
1027,
2023,
1012,
20116,
2015,
1006,
3145,
1007,
1010,
11748,
1027,
1031,
1033,
1025,
1002,
1012,
2169,
1006,
1031,
1000,
7861,
1000,
1010,
1000,
1052,
2595,
1000,
1010,
1000,
1003,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
Microsoft/BotFramework-WebChat | packages/embed/src/setups/loadAsset.js | loadScript | function loadScript(src, integrity) {
return new Promise((resolve, reject) => {
document.head.appendChild(createElement(
'script',
{
async: true,
crossOrigin: 'anonymous',
integrity,
onError: reject,
onLoad: resolve,
src
}
));
});
} | javascript | function loadScript(src, integrity) {
return new Promise((resolve, reject) => {
document.head.appendChild(createElement(
'script',
{
async: true,
crossOrigin: 'anonymous',
integrity,
onError: reject,
onLoad: resolve,
src
}
));
});
} | [
"function",
"loadScript",
"(",
"src",
",",
"integrity",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"document",
".",
"head",
".",
"appendChild",
"(",
"createElement",
"(",
"'script'",
",",
"{",
"async",
":",
... | We enable Subresource Integrity to protect our assets on CDN. https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity curl https://cdn.botframework.com/botframework-webchat/4.3.0/webchat.js | openssl dgst -sha384 -binary | openssl base64 -A | [
"We",
"enable",
"Subresource",
"Integrity",
"to",
"protect",
"our",
"assets",
"on",
"CDN",
".",
"https",
":",
"//",
"developer",
".",
"mozilla",
".",
"org",
"/",
"en",
"-",
"US",
"/",
"docs",
"/",
"Web",
"/",
"Security",
"/",
"Subresource_Integrity",
"cu... | 8bc934d3d07d1ca901d52b5e3a9481fddcdbd91e | https://github.com/Microsoft/BotFramework-WebChat/blob/8bc934d3d07d1ca901d52b5e3a9481fddcdbd91e/packages/embed/src/setups/loadAsset.js#L7-L21 | train | Load a script | [
30522,
3853,
15665,
23235,
1006,
5034,
2278,
1010,
11109,
1007,
1063,
2709,
2047,
4872,
1006,
1006,
10663,
1010,
15454,
1007,
1027,
1028,
1063,
6254,
1012,
2132,
1012,
10439,
10497,
19339,
1006,
3443,
12260,
3672,
1006,
1005,
5896,
1005,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
PrismJS/prism | components/prism-asciidoc.js | copyFromAsciiDoc | function copyFromAsciiDoc(keys) {
keys = keys.split(' ');
var o = {};
for (var i = 0, l = keys.length; i < l; i++) {
o[keys[i]] = asciidoc[keys[i]];
}
return o;
} | javascript | function copyFromAsciiDoc(keys) {
keys = keys.split(' ');
var o = {};
for (var i = 0, l = keys.length; i < l; i++) {
o[keys[i]] = asciidoc[keys[i]];
}
return o;
} | [
"function",
"copyFromAsciiDoc",
"(",
"keys",
")",
"{",
"keys",
"=",
"keys",
".",
"split",
"(",
"' '",
")",
";",
"var",
"o",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"keys",
".",
"length",
";",
"i",
"<",
"l",
";",
... | Allow some nesting. There is no recursion though, so cloning should not be needed. | [
"Allow",
"some",
"nesting",
".",
"There",
"is",
"no",
"recursion",
"though",
"so",
"cloning",
"should",
"not",
"be",
"needed",
"."
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/components/prism-asciidoc.js#L203-L211 | train | Copy the contents of an ASCII document to an object | [
30522,
3853,
6100,
19699,
9626,
11020,
6137,
3527,
2278,
1006,
6309,
1007,
1063,
6309,
1027,
6309,
1012,
3975,
1006,
1005,
1005,
1007,
1025,
13075,
1051,
1027,
1063,
1065,
1025,
2005,
1006,
13075,
1045,
1027,
1014,
1010,
1048,
1027,
6309,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_Theme | function parse_Theme(blob, length, opts) {
var end = blob.l + length;
var dwThemeVersion = blob.read_shift(4);
if(dwThemeVersion === 124226) return;
if(!opts.cellStyles || !jszip) { blob.l = end; return; }
var data = blob.slice(blob.l);
blob.l = end;
var zip; try { zip = new jszip(data); } catch(e) { return; }
var themeXML = getzipstr(zip, "theme/theme/theme1.xml", true);
if(!themeXML) return;
return parse_theme_xml(themeXML, opts);
} | javascript | function parse_Theme(blob, length, opts) {
var end = blob.l + length;
var dwThemeVersion = blob.read_shift(4);
if(dwThemeVersion === 124226) return;
if(!opts.cellStyles || !jszip) { blob.l = end; return; }
var data = blob.slice(blob.l);
blob.l = end;
var zip; try { zip = new jszip(data); } catch(e) { return; }
var themeXML = getzipstr(zip, "theme/theme/theme1.xml", true);
if(!themeXML) return;
return parse_theme_xml(themeXML, opts);
} | [
"function",
"parse_Theme",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"end",
"=",
"blob",
".",
"l",
"+",
"length",
";",
"var",
"dwThemeVersion",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
";",
"if",
"(",
"dwThemeVersion",
"===",
"1... | /* [MS-XLS] 2.4.326 TODO: payload is a zip file | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"4",
".",
"326",
"TODO",
":",
"payload",
"is",
"a",
"zip",
"file"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L9681-L9692 | train | Parse a theme | [
30522,
3853,
11968,
3366,
30524,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1018,
1007,
1025,
2065,
1006,
1040,
26677,
29122,
22507,
10992,
1027,
1027,
1027,
13412,
19317,
2575,
1007,
2709,
1025,
2065,
1006,
999,
23569,
2015,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
exceljs/exceljs | lib/xlsx/xform/static-xform.js | build | function build(xmlStream, model) {
xmlStream.openNode(model.tag, model.$);
if (model.c) {
model.c.forEach(function(child) {
build(xmlStream, child);
});
}
if (model.t) {
xmlStream.writeText(model.t);
}
xmlStream.closeNode();
} | javascript | function build(xmlStream, model) {
xmlStream.openNode(model.tag, model.$);
if (model.c) {
model.c.forEach(function(child) {
build(xmlStream, child);
});
}
if (model.t) {
xmlStream.writeText(model.t);
}
xmlStream.closeNode();
} | [
"function",
"build",
"(",
"xmlStream",
",",
"model",
")",
"{",
"xmlStream",
".",
"openNode",
"(",
"model",
".",
"tag",
",",
"model",
".",
"$",
")",
";",
"if",
"(",
"model",
".",
"c",
")",
"{",
"model",
".",
"c",
".",
"forEach",
"(",
"function",
"... | var model = { tag: 'name', $: {attr: 'value'}, c: [ { tag: 'child' } ], t: 'some text' }; | [
"var",
"model",
"=",
"{",
"tag",
":",
"name",
"$",
":",
"{",
"attr",
":",
"value",
"}",
"c",
":",
"[",
"{",
"tag",
":",
"child",
"}",
"]",
"t",
":",
"some",
"text",
"}",
";"
] | c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2 | https://github.com/exceljs/exceljs/blob/c6ee7a14d5e0e5a07bf0e475aa4dd7b9a1e907f2/lib/xlsx/xform/static-xform.js#L16-L27 | train | Build XML from model | [
30522,
3853,
3857,
1006,
20950,
30524,
1012,
1039,
1012,
18921,
6776,
1006,
3853,
1006,
2775,
1007,
1063,
3857,
1006,
20950,
21422,
1010,
2775,
1007,
1025,
1065,
1007,
1025,
1065,
2065,
1006,
2944,
1012,
1056,
1007,
1063,
20950,
21422,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controls/TitleLink.js | function (oRm, oTitle) {
var oAssoTitle = oTitle._getTitle(),
sLevel = (oAssoTitle ? oAssoTitle.getLevel() : oTitle.getLevel()) || coreLibrary.TitleLevel.Auto,
bAutoLevel = sLevel == TitleLevel.Auto,
sTag = bAutoLevel ? "div" : sLevel;
oRm.write("<", sTag);
oRm.writeControlData(oTitle);
oRm.addClass("sapUiDocTitleLink");
oRm.addClass("sapMTitle");
oRm.addClass("sapMTitleStyle" + (oTitle.getTitleStyle() || coreLibrary.TitleLevel.Auto));
oRm.addClass("sapUiSelectable");
// adding wrap functionality begin
if (oTitle.getWrap()) {
oRm.addClass("wrap");
} else {
oRm.addClass("sapMTitleNoWrap");
}
// adding wrap functionality end
var sWidth = oTitle.getWidth();
if (!sWidth) {
oRm.addClass("sapMTitleMaxWidth");
} else {
oRm.addStyle("width", sWidth);
}
var sTextAlign = oTitle.getTextAlign();
if (sTextAlign && sTextAlign != TextAlign.Initial) {
oRm.addClass("sapMTitleAlign" + sTextAlign);
}
if (oTitle.getParent() instanceof Toolbar) {
oRm.addClass("sapMTitleTB");
}
var sTooltip = oAssoTitle ? oAssoTitle.getTooltip_AsString() : oTitle.getTooltip_AsString();
if (sTooltip) {
oRm.writeAttributeEscaped("title", sTooltip);
}
if (bAutoLevel) {
oRm.writeAttribute("role", "heading");
}
oRm.writeClasses();
oRm.writeStyles();
oRm.write(">");
// adding link functionality begin
oRm.write("<a");
oRm.addClass("sapMLnk");
if (oTitle.getText()) {
oRm.writeAttribute("tabIndex", "0");
} else {
oRm.writeAttribute("tabIndex", "-1");
}
oRm.writeAttributeEscaped("href", oTitle.getHref());
if (oTitle.getTarget()) {
oRm.writeAttributeEscaped("target", oTitle.getTarget());
}
oRm.writeClasses();
oRm.write(">");
// adding link functionality end
oRm.write("<span");
oRm.writeAttribute("id", oTitle.getId() + "-inner");
oRm.write(">");
oRm.writeEscaped(oAssoTitle ? oAssoTitle.getText() : oTitle.getText());
oRm.write("</span></a></", sTag, ">");
} | javascript | function (oRm, oTitle) {
var oAssoTitle = oTitle._getTitle(),
sLevel = (oAssoTitle ? oAssoTitle.getLevel() : oTitle.getLevel()) || coreLibrary.TitleLevel.Auto,
bAutoLevel = sLevel == TitleLevel.Auto,
sTag = bAutoLevel ? "div" : sLevel;
oRm.write("<", sTag);
oRm.writeControlData(oTitle);
oRm.addClass("sapUiDocTitleLink");
oRm.addClass("sapMTitle");
oRm.addClass("sapMTitleStyle" + (oTitle.getTitleStyle() || coreLibrary.TitleLevel.Auto));
oRm.addClass("sapUiSelectable");
// adding wrap functionality begin
if (oTitle.getWrap()) {
oRm.addClass("wrap");
} else {
oRm.addClass("sapMTitleNoWrap");
}
// adding wrap functionality end
var sWidth = oTitle.getWidth();
if (!sWidth) {
oRm.addClass("sapMTitleMaxWidth");
} else {
oRm.addStyle("width", sWidth);
}
var sTextAlign = oTitle.getTextAlign();
if (sTextAlign && sTextAlign != TextAlign.Initial) {
oRm.addClass("sapMTitleAlign" + sTextAlign);
}
if (oTitle.getParent() instanceof Toolbar) {
oRm.addClass("sapMTitleTB");
}
var sTooltip = oAssoTitle ? oAssoTitle.getTooltip_AsString() : oTitle.getTooltip_AsString();
if (sTooltip) {
oRm.writeAttributeEscaped("title", sTooltip);
}
if (bAutoLevel) {
oRm.writeAttribute("role", "heading");
}
oRm.writeClasses();
oRm.writeStyles();
oRm.write(">");
// adding link functionality begin
oRm.write("<a");
oRm.addClass("sapMLnk");
if (oTitle.getText()) {
oRm.writeAttribute("tabIndex", "0");
} else {
oRm.writeAttribute("tabIndex", "-1");
}
oRm.writeAttributeEscaped("href", oTitle.getHref());
if (oTitle.getTarget()) {
oRm.writeAttributeEscaped("target", oTitle.getTarget());
}
oRm.writeClasses();
oRm.write(">");
// adding link functionality end
oRm.write("<span");
oRm.writeAttribute("id", oTitle.getId() + "-inner");
oRm.write(">");
oRm.writeEscaped(oAssoTitle ? oAssoTitle.getText() : oTitle.getText());
oRm.write("</span></a></", sTag, ">");
} | [
"function",
"(",
"oRm",
",",
"oTitle",
")",
"{",
"var",
"oAssoTitle",
"=",
"oTitle",
".",
"_getTitle",
"(",
")",
",",
"sLevel",
"=",
"(",
"oAssoTitle",
"?",
"oAssoTitle",
".",
"getLevel",
"(",
")",
":",
"oTitle",
".",
"getLevel",
"(",
")",
")",
"||",... | Renders the HTML for the given control, using the provided {@link sap.ui.core.RenderManager}.
@param {sap.ui.core.RenderManager} oRm the RenderManager that can be used for writing to the Render-Output-Buffer
@param {sap.ui.core.Control} oTitle an object representation of the control that should be rendered | [
"Renders",
"the",
"HTML",
"for",
"the",
"given",
"control",
"using",
"the",
"provided",
"{"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controls/TitleLink.js#L135-L207 | train | Renders the title tag | [
30522,
3853,
1006,
2030,
2213,
1010,
27178,
4183,
2571,
1007,
1063,
13075,
1051,
12054,
4140,
4183,
2571,
1027,
27178,
4183,
2571,
1012,
1035,
2131,
3775,
9286,
1006,
1007,
1010,
22889,
18697,
2140,
1027,
1006,
1051,
12054,
4140,
4183,
2571... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/prefs.js | aboutSessionRestore_getElement | function aboutSessionRestore_getElement(spec) {
var elem = null;
switch(spec.type) {
case "button":
elem = new elementslib.Lookup(this._controller.window.document, PREF_DIALOG_BUTTONS +
'/{"dlgtype":"' + spec.subtype + '"}');
break;
case "deck":
elem = new elementslib.Lookup(this._controller.window.document, PREF_DIALOG_DECK);
break;
case "deck_pane":
var deck = this.getElement({type: "deck"}).getNode();
// XXX: Bug 390724 - selectedPane is broken. So iterate through all elements
var panel = deck.boxObject.firstChild;
for (var ii = 0; ii < deck.selectedIndex; ii++)
panel = panel.nextSibling;
elem = new elementslib.Elem(panel);
break;
case "selector":
elem = new elementslib.Lookup(this._controller.window.document, PREF_DIALOG_SELECTOR);
break;
case "selector_button":
elem = new elementslib.Lookup(this._controller.window.document, PREF_DIALOG_SELECTOR +
'/{"pane":"' + spec.value + '"}');
break;
default:
throw new Error(arguments.callee.name + ": Unknown element type - " + spec.type);
}
return elem;
} | javascript | function aboutSessionRestore_getElement(spec) {
var elem = null;
switch(spec.type) {
case "button":
elem = new elementslib.Lookup(this._controller.window.document, PREF_DIALOG_BUTTONS +
'/{"dlgtype":"' + spec.subtype + '"}');
break;
case "deck":
elem = new elementslib.Lookup(this._controller.window.document, PREF_DIALOG_DECK);
break;
case "deck_pane":
var deck = this.getElement({type: "deck"}).getNode();
// XXX: Bug 390724 - selectedPane is broken. So iterate through all elements
var panel = deck.boxObject.firstChild;
for (var ii = 0; ii < deck.selectedIndex; ii++)
panel = panel.nextSibling;
elem = new elementslib.Elem(panel);
break;
case "selector":
elem = new elementslib.Lookup(this._controller.window.document, PREF_DIALOG_SELECTOR);
break;
case "selector_button":
elem = new elementslib.Lookup(this._controller.window.document, PREF_DIALOG_SELECTOR +
'/{"pane":"' + spec.value + '"}');
break;
default:
throw new Error(arguments.callee.name + ": Unknown element type - " + spec.type);
}
return elem;
} | [
"function",
"aboutSessionRestore_getElement",
"(",
"spec",
")",
"{",
"var",
"elem",
"=",
"null",
";",
"switch",
"(",
"spec",
".",
"type",
")",
"{",
"case",
"\"button\"",
":",
"elem",
"=",
"new",
"elementslib",
".",
"Lookup",
"(",
"this",
".",
"_controller"... | Retrieve an UI element based on the given spec
@param {object} spec
Information of the UI element which should be retrieved
type: General type information
subtype: Specific element or property
value: Value of the element or property
@returns Element which has been created
@type {ElemBase} | [
"Retrieve",
"an",
"UI",
"element",
"based",
"on",
"the",
"given",
"spec"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/prefs.js#L163-L196 | train | Get the element that is used to restore the session | [
30522,
3853,
2055,
8583,
10992,
28533,
5686,
1035,
2131,
12260,
3672,
1006,
28699,
1007,
1063,
13075,
3449,
6633,
1027,
19701,
1025,
6942,
1006,
28699,
1012,
2828,
1007,
1063,
2553,
1000,
6462,
1000,
1024,
3449,
6633,
1027,
2047,
3787,
2952... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/Storage.js | function (RuleSerializer, constants) {
"use strict";
/**
* Encodes rules written by the user.
* @private
* @function
* @name Encode
* @param {string} sData Stringified object containing rule properties.
* @returns {string} base-64 encoded string.
*/
function encode(sData) {
return window.btoa(unescape(encodeURIComponent(sData)));
}
/**
* Decodes the already encoded data by the user.
* @private
* @function
* @name Decode
* @param {string} sData Stringified base-64 object containing rule properties.
* @returns {string} Stringified object containing rule properties.
*/
function decode(sData) {
return decodeURIComponent(escape(window.atob(sData)));
}
return {
/**
* Returns all previously created temporary rules.
* @private
* @name sap.ui.support.Storage.getRules
* @method
* @returns {object[]} An array containing all the temporary rules.
*/
getRules: function () {
var tempRules = [],
rawLSData;
try {
rawLSData = localStorage.getItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY);
if (!rawLSData) {
return null;
}
tempRules = JSON.parse(decode(rawLSData));
tempRules = tempRules.map(function (tempRule) {
return RuleSerializer.deserialize(tempRule, true);
});
} catch (oError) {
// Swallow "Access Denied" exceptions in cross-origin scenarios.
}
return tempRules;
},
/**
* Saves the temporary rules into the LocalStorage persistence layer.
* @private
* @name sap.ui.support.Storage.setRules
* @method
* @param {object[]} rules The temporary rules from the shared model.
*/
setRules: function (rules) {
var stringifyRules = encode(JSON.stringify(rules));
localStorage.setItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY, stringifyRules);
},
/**
* Retrieves the selected rules which are stored in the LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.getSelectedRules
* @returns {object[]} All selected rules that are stored in the LocalStorage persistence layer.
*/
getSelectedRules: function () {
var rawLSData = localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY);
if (!rawLSData) {
return null;
}
return JSON.parse(rawLSData);
},
/**
* Stores which rules are selected to be run by the analyzer on the next check.
* @private
* @method
* @name sap.ui.support.Storage.setSelectedRules
* @param {object[]} aSelectedRules The data for the libraries and their rules.
*/
setSelectedRules: function (aSelectedRules) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY, JSON.stringify(aSelectedRules));
},
/**
* Sets the context for the execution scope in the LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.setSelectedContext
* @param {object} selectedContext Object containing the <code>analyzeContext</code> and <code>subtreeExecutionContextId</code>.
*/
setSelectedContext: function(selectedContext) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_KEY, JSON.stringify(selectedContext));
},
/**
* Retrieves the selected context from the LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.getSelectedContext
* @returns {string} Parsed value of the <code>selectedContext</code> key in the LocalStorage persistence layer.
*/
getSelectedContext: function() {
return JSON.parse(localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_KEY));
},
/**
* Sets the scope components that are selected.
* @private
* @method
* @name sap.ui.support.Storage.setSelectedScopeComponents
* @param {object} contextComponent Component that's stored in the LocalStorage.
*/
setSelectedScopeComponents: function(contextComponent) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_COMPONENT_KEY, JSON.stringify(contextComponent));
},
/**
* Gets the scope components that are selected.
* @private
* @method
* @name sap.ui.support.Storage.getSelectedScopeComponents
* @returns {string} componentContext The selected components within a given scope.
*/
getSelectedScopeComponents: function() {
var componentContext = localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_COMPONENT_KEY);
return JSON.parse(componentContext);
},
/**
* Overwrites the temporary rules into the local storage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.removeSelectedRules
* @param {object[]} aSelectedRules The temporary rules from the shared model.
*/
removeSelectedRules: function(aSelectedRules) {
this.setRules(aSelectedRules);
},
/**
* Sets the visible column setting selection.
* @method
* @name sap.ui.support.Storage.setVisibleColumns
* @param {string[]} aVisibleColumns visible columns ids
*/
setVisibleColumns: function(aVisibleColumns) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTED_VISIBLE_COLUMN_KEY, JSON.stringify(aVisibleColumns));
},
/**
* Gets the visible column setting selection.
* @method
* @name sap.ui.support.Storage.getVisibleColumns
* @returns {string[]} ids of visible columns.
*/
getVisibleColumns: function() {
return JSON.parse(localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_VISIBLE_COLUMN_KEY));
},
/**
* Retrieves the list of selection presets
* @private
* @method
* @name sap.ui.support.Storage.getSelectionPresets
* @returns {Object[]} The list of selection presets
*/
getSelectionPresets: function() {
return JSON.parse(localStorage.getItem(constants.LOCAL_STORAGE_SELECTION_PRESETS_KEY));
},
/**
* Retrieves the list of custom presets
* @private
* @method
* @name sap.ui.support.Storage.getCustomPresets
* @returns {Object[]} The list of custom presets
*/
getCustomPresets: function() {
return JSON.parse(localStorage.getItem(constants.LOCAL_STORAGE_CUSTOM_PRESETS_KEY));
},
/**
* Sets the list of selection presets
* @private
* @method
* @name sap.ui.support.Storage.setSelectionPresets
* @param {Object[]} selectionPresets The list of selection presets
*/
setSelectionPresets: function(selectionPresets) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTION_PRESETS_KEY, JSON.stringify(selectionPresets));
},
/**
* Sets the list of custom presets
* @private
* @method
* @name sap.ui.support.Storage.setCustomPresets
* @param {Object[]} customPresets The list of custom presets
*/
setCustomPresets: function(customPresets) {
localStorage.setItem(constants.LOCAL_STORAGE_CUSTOM_PRESETS_KEY, JSON.stringify(customPresets));
},
/**
* Removes all data from LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.removeAllData
*/
removeAllData: function() {
localStorage.removeItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_COMPONENT_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_VISIBLE_COLUMN_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTION_PRESETS_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_CUSTOM_PRESETS_KEY);
},
/**
* Creates a cookie with encoded information in the LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.createPersistenceCookie
* @param {string} sCookieName Name of the cookie.
* @param {boolean} sCookieValue Contents of the cookie.
* @returns {void}
*/
createPersistenceCookie: function(sCookieName, sCookieValue) {
document.cookie = sCookieName + "=" + sCookieValue;
},
/**
* Retrieves the persistence options of the user in the LocalStorage layer.
* @private
* @method
* @name sap.ui.support.Storage.readPersistenceCookie
* @alias readPersistenceCookie
* @param {string} sCookieName Name of the cookie.
* @returns {string} sOutput The persistence options of the user.
*/
readPersistenceCookie: function(sCookieName) {
var name = sCookieName + "=",
decodedCookie = decodeURIComponent(document.cookie),
ca = decodedCookie.split(';'),
sOutput = "";
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
sOutput = c.substring(name.length, c.length);
return sOutput;
}
}
return sOutput;
},
/**
* Removes the cookie with persistence information in the LocalStorage.
* @private
* @method
* @name sap.ui.support.Storage.deletePersistenceCookie
* @param {string} sCookieName Name of the cookie
* @returns {void}
*/
deletePersistenceCookie: function(sCookieName) {
document.cookie = sCookieName + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
};
} | javascript | function (RuleSerializer, constants) {
"use strict";
/**
* Encodes rules written by the user.
* @private
* @function
* @name Encode
* @param {string} sData Stringified object containing rule properties.
* @returns {string} base-64 encoded string.
*/
function encode(sData) {
return window.btoa(unescape(encodeURIComponent(sData)));
}
/**
* Decodes the already encoded data by the user.
* @private
* @function
* @name Decode
* @param {string} sData Stringified base-64 object containing rule properties.
* @returns {string} Stringified object containing rule properties.
*/
function decode(sData) {
return decodeURIComponent(escape(window.atob(sData)));
}
return {
/**
* Returns all previously created temporary rules.
* @private
* @name sap.ui.support.Storage.getRules
* @method
* @returns {object[]} An array containing all the temporary rules.
*/
getRules: function () {
var tempRules = [],
rawLSData;
try {
rawLSData = localStorage.getItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY);
if (!rawLSData) {
return null;
}
tempRules = JSON.parse(decode(rawLSData));
tempRules = tempRules.map(function (tempRule) {
return RuleSerializer.deserialize(tempRule, true);
});
} catch (oError) {
// Swallow "Access Denied" exceptions in cross-origin scenarios.
}
return tempRules;
},
/**
* Saves the temporary rules into the LocalStorage persistence layer.
* @private
* @name sap.ui.support.Storage.setRules
* @method
* @param {object[]} rules The temporary rules from the shared model.
*/
setRules: function (rules) {
var stringifyRules = encode(JSON.stringify(rules));
localStorage.setItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY, stringifyRules);
},
/**
* Retrieves the selected rules which are stored in the LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.getSelectedRules
* @returns {object[]} All selected rules that are stored in the LocalStorage persistence layer.
*/
getSelectedRules: function () {
var rawLSData = localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY);
if (!rawLSData) {
return null;
}
return JSON.parse(rawLSData);
},
/**
* Stores which rules are selected to be run by the analyzer on the next check.
* @private
* @method
* @name sap.ui.support.Storage.setSelectedRules
* @param {object[]} aSelectedRules The data for the libraries and their rules.
*/
setSelectedRules: function (aSelectedRules) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY, JSON.stringify(aSelectedRules));
},
/**
* Sets the context for the execution scope in the LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.setSelectedContext
* @param {object} selectedContext Object containing the <code>analyzeContext</code> and <code>subtreeExecutionContextId</code>.
*/
setSelectedContext: function(selectedContext) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_KEY, JSON.stringify(selectedContext));
},
/**
* Retrieves the selected context from the LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.getSelectedContext
* @returns {string} Parsed value of the <code>selectedContext</code> key in the LocalStorage persistence layer.
*/
getSelectedContext: function() {
return JSON.parse(localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_KEY));
},
/**
* Sets the scope components that are selected.
* @private
* @method
* @name sap.ui.support.Storage.setSelectedScopeComponents
* @param {object} contextComponent Component that's stored in the LocalStorage.
*/
setSelectedScopeComponents: function(contextComponent) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_COMPONENT_KEY, JSON.stringify(contextComponent));
},
/**
* Gets the scope components that are selected.
* @private
* @method
* @name sap.ui.support.Storage.getSelectedScopeComponents
* @returns {string} componentContext The selected components within a given scope.
*/
getSelectedScopeComponents: function() {
var componentContext = localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_COMPONENT_KEY);
return JSON.parse(componentContext);
},
/**
* Overwrites the temporary rules into the local storage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.removeSelectedRules
* @param {object[]} aSelectedRules The temporary rules from the shared model.
*/
removeSelectedRules: function(aSelectedRules) {
this.setRules(aSelectedRules);
},
/**
* Sets the visible column setting selection.
* @method
* @name sap.ui.support.Storage.setVisibleColumns
* @param {string[]} aVisibleColumns visible columns ids
*/
setVisibleColumns: function(aVisibleColumns) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTED_VISIBLE_COLUMN_KEY, JSON.stringify(aVisibleColumns));
},
/**
* Gets the visible column setting selection.
* @method
* @name sap.ui.support.Storage.getVisibleColumns
* @returns {string[]} ids of visible columns.
*/
getVisibleColumns: function() {
return JSON.parse(localStorage.getItem(constants.LOCAL_STORAGE_SELECTED_VISIBLE_COLUMN_KEY));
},
/**
* Retrieves the list of selection presets
* @private
* @method
* @name sap.ui.support.Storage.getSelectionPresets
* @returns {Object[]} The list of selection presets
*/
getSelectionPresets: function() {
return JSON.parse(localStorage.getItem(constants.LOCAL_STORAGE_SELECTION_PRESETS_KEY));
},
/**
* Retrieves the list of custom presets
* @private
* @method
* @name sap.ui.support.Storage.getCustomPresets
* @returns {Object[]} The list of custom presets
*/
getCustomPresets: function() {
return JSON.parse(localStorage.getItem(constants.LOCAL_STORAGE_CUSTOM_PRESETS_KEY));
},
/**
* Sets the list of selection presets
* @private
* @method
* @name sap.ui.support.Storage.setSelectionPresets
* @param {Object[]} selectionPresets The list of selection presets
*/
setSelectionPresets: function(selectionPresets) {
localStorage.setItem(constants.LOCAL_STORAGE_SELECTION_PRESETS_KEY, JSON.stringify(selectionPresets));
},
/**
* Sets the list of custom presets
* @private
* @method
* @name sap.ui.support.Storage.setCustomPresets
* @param {Object[]} customPresets The list of custom presets
*/
setCustomPresets: function(customPresets) {
localStorage.setItem(constants.LOCAL_STORAGE_CUSTOM_PRESETS_KEY, JSON.stringify(customPresets));
},
/**
* Removes all data from LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.removeAllData
*/
removeAllData: function() {
localStorage.removeItem(constants.LOCAL_STORAGE_TEMP_RULES_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_RULES_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_CONTEXT_COMPONENT_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTED_VISIBLE_COLUMN_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_SELECTION_PRESETS_KEY);
localStorage.removeItem(constants.LOCAL_STORAGE_CUSTOM_PRESETS_KEY);
},
/**
* Creates a cookie with encoded information in the LocalStorage persistence layer.
* @private
* @method
* @name sap.ui.support.Storage.createPersistenceCookie
* @param {string} sCookieName Name of the cookie.
* @param {boolean} sCookieValue Contents of the cookie.
* @returns {void}
*/
createPersistenceCookie: function(sCookieName, sCookieValue) {
document.cookie = sCookieName + "=" + sCookieValue;
},
/**
* Retrieves the persistence options of the user in the LocalStorage layer.
* @private
* @method
* @name sap.ui.support.Storage.readPersistenceCookie
* @alias readPersistenceCookie
* @param {string} sCookieName Name of the cookie.
* @returns {string} sOutput The persistence options of the user.
*/
readPersistenceCookie: function(sCookieName) {
var name = sCookieName + "=",
decodedCookie = decodeURIComponent(document.cookie),
ca = decodedCookie.split(';'),
sOutput = "";
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
sOutput = c.substring(name.length, c.length);
return sOutput;
}
}
return sOutput;
},
/**
* Removes the cookie with persistence information in the LocalStorage.
* @private
* @method
* @name sap.ui.support.Storage.deletePersistenceCookie
* @param {string} sCookieName Name of the cookie
* @returns {void}
*/
deletePersistenceCookie: function(sCookieName) {
document.cookie = sCookieName + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
};
} | [
"function",
"(",
"RuleSerializer",
",",
"constants",
")",
"{",
"\"use strict\"",
";",
"/**\n\t * Encodes rules written by the user.\n\t * @private\n\t * @function\n\t * @name Encode\n\t * @param {string} sData Stringified object containing rule properties.\n\t * @returns {string} base-64 encoded s... | @class
The Storage is used to store and recieve data in/from the LocalStorage in the browser.
<h3>Overview</h3>
The Storage class is used to persist user settings.
<h3>Usage</h3>
This class must be used with {@link sap.ui.support.RuleSerializer} and {@link sap.ui.support.Constants} in order to store user data in the LocalStorage.
@name sap.ui.support.Storage
@alias sap.ui.support.Storage
@author SAP SE.
@version ${version}
@private
@param {object} RuleSerializer Instance of the {@link sap.ui.support.RuleSerializer}
@param {object} constants Constants written in the {@link sap.ui.support.Constants}
@returns {object} Methods that enable the user to work with the LocalStorage.
@ui5-metamodel This control/element also will be described in the UI5 (legacy) designtime metamodel | [
"@class",
"The",
"Storage",
"is",
"used",
"to",
"store",
"and",
"recieve",
"data",
"in",
"/",
"from",
"the",
"LocalStorage",
"in",
"the",
"browser",
".",
"<h3",
">",
"Overview<",
"/",
"h3",
">",
"The",
"Storage",
"class",
"is",
"used",
"to",
"persist",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/Storage.js#L33-L324 | train | The internal function used to serialize temporary rules into the LocalStorage persistence layer. | [
30522,
3853,
1006,
3513,
11610,
28863,
1010,
5377,
2015,
1007,
1063,
1000,
2224,
9384,
1000,
1025,
1013,
1008,
1008,
1008,
4372,
23237,
3513,
2517,
2011,
1996,
5310,
1012,
1008,
1030,
2797,
1008,
1030,
3853,
1008,
1030,
2171,
4372,
16044,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | grunt/config/aliases.js | function() {
var version = grunt.config(['package', 'version']);
config.libraries.forEach(function(library) {
if (library.bower === false) {
return;
}
var bowerFilename = 'tmp/packaged-' + library.name + '/bower.json';
grunt.log.subhead(library.name);
var bower = grunt.file.readJSON(bowerFilename);
var oldVersion = bower.version;
// update version
bower.version = version;
grunt.log.writeln('version: ' + oldVersion + ' => ' + version);
// check for dependency infos
if (bower.dependencies) {
Object.keys(bower.dependencies).forEach(function(dependency) {
var oldDependencyVersion = bower.dependencies[dependency];
var oldDependencyVersionParts = oldDependencyVersion.split('#', 1);
var newDependencyVersion = oldDependencyVersionParts[0] + '#' + version;
bower.dependencies[dependency] = newDependencyVersion;
grunt.log.writeln('dependencies.' + dependency + ': ' + oldDependencyVersion + ' => ' + newDependencyVersion);
});
}
grunt.file.write(bowerFilename, JSON.stringify(bower, null, 2));
});
} | javascript | function() {
var version = grunt.config(['package', 'version']);
config.libraries.forEach(function(library) {
if (library.bower === false) {
return;
}
var bowerFilename = 'tmp/packaged-' + library.name + '/bower.json';
grunt.log.subhead(library.name);
var bower = grunt.file.readJSON(bowerFilename);
var oldVersion = bower.version;
// update version
bower.version = version;
grunt.log.writeln('version: ' + oldVersion + ' => ' + version);
// check for dependency infos
if (bower.dependencies) {
Object.keys(bower.dependencies).forEach(function(dependency) {
var oldDependencyVersion = bower.dependencies[dependency];
var oldDependencyVersionParts = oldDependencyVersion.split('#', 1);
var newDependencyVersion = oldDependencyVersionParts[0] + '#' + version;
bower.dependencies[dependency] = newDependencyVersion;
grunt.log.writeln('dependencies.' + dependency + ': ' + oldDependencyVersion + ' => ' + newDependencyVersion);
});
}
grunt.file.write(bowerFilename, JSON.stringify(bower, null, 2));
});
} | [
"function",
"(",
")",
"{",
"var",
"version",
"=",
"grunt",
".",
"config",
"(",
"[",
"'package'",
",",
"'version'",
"]",
")",
";",
"config",
".",
"libraries",
".",
"forEach",
"(",
"function",
"(",
"library",
")",
"{",
"if",
"(",
"library",
".",
"bower... | updates version infos (incl. dependency versions) of bower.json files | [
"updates",
"version",
"infos",
"(",
"incl",
".",
"dependency",
"versions",
")",
"of",
"bower",
".",
"json",
"files"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/grunt/config/aliases.js#L222-L263 | train | update version of all libraries | [
30522,
3853,
1006,
1007,
1063,
13075,
2544,
1027,
20696,
1012,
9530,
8873,
2290,
1006,
1031,
1005,
7427,
1005,
1010,
1005,
2544,
1005,
1033,
1007,
1025,
9530,
8873,
2290,
1012,
8860,
1012,
18921,
6776,
1006,
3853,
1006,
3075,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/components/material.js | function (oldData) {
var data = this.data;
if (!this.shader || data.shader !== oldData.shader) {
this.updateShader(data.shader);
}
this.shader.update(this.data);
this.updateMaterial(oldData);
} | javascript | function (oldData) {
var data = this.data;
if (!this.shader || data.shader !== oldData.shader) {
this.updateShader(data.shader);
}
this.shader.update(this.data);
this.updateMaterial(oldData);
} | [
"function",
"(",
"oldData",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"if",
"(",
"!",
"this",
".",
"shader",
"||",
"data",
".",
"shader",
"!==",
"oldData",
".",
"shader",
")",
"{",
"this",
".",
"updateShader",
"(",
"data",
".",
"shade... | Update or create material.
@param {object|null} oldData | [
"Update",
"or",
"create",
"material",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/material.js#L46-L53 | train | update the shader and material | [
30522,
3853,
1006,
2214,
2850,
2696,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
2065,
1006,
999,
2023,
1012,
8703,
2099,
1064,
1064,
2951,
1012,
8703,
2099,
999,
1027,
1027,
2214,
2850,
2696,
1012,
8703,
2099,
1007,
1063,
2023... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js | function (sServiceUrl, oModelInterface, mHeaders, mQueryParams, sODataVersion) {
var oRequestor = new Requestor(sServiceUrl, mHeaders, mQueryParams, oModelInterface);
if (sODataVersion === "2.0") {
asV2Requestor(oRequestor);
}
return oRequestor;
} | javascript | function (sServiceUrl, oModelInterface, mHeaders, mQueryParams, sODataVersion) {
var oRequestor = new Requestor(sServiceUrl, mHeaders, mQueryParams, oModelInterface);
if (sODataVersion === "2.0") {
asV2Requestor(oRequestor);
}
return oRequestor;
} | [
"function",
"(",
"sServiceUrl",
",",
"oModelInterface",
",",
"mHeaders",
",",
"mQueryParams",
",",
"sODataVersion",
")",
"{",
"var",
"oRequestor",
"=",
"new",
"Requestor",
"(",
"sServiceUrl",
",",
"mHeaders",
",",
"mQueryParams",
",",
"oModelInterface",
")",
";"... | Creates a new <code>_Requestor</code> instance for the given service URL and default
headers.
@param {string} sServiceUrl
URL of the service document to request the CSRF token from; also used to resolve
relative resource paths (see {@link #request})
@param {object} oModelInterface
An interface allowing to call back to the owning model
@param {function} oModelInterface.fetchEntityContainer
A promise which is resolved with the $metadata "JSON" object as soon as the entity
container is fully available, or rejected with an error.
@param {function} oModelInterface.fetchMetadata
A function that returns a SyncPromise which resolves with the metadata instance for a
given meta path
@param {function} oModelInterface.getGroupProperty
A function called with parameters <code>sGroupId</code> and <code>sPropertyName</code>
returning the property value in question. Only 'submit' is supported for <code>
sPropertyName</code>. Supported property values are: 'API', 'Auto' and 'Direct'.
@param {function (string)} [oModelInterface.onCreateGroup]
A callback function that is called with the group name as parameter when the first
request is added to a group
@param {function} oModelInterface.lockGroup
A function to create or modify a lock for a group
@param {function} oModelInterface.reportBoundMessages
A function to report bound OData messages
@param {function (object[])} oModelInterface.reportUnboundMessages
A function to report unbound OData messages contained in the <code>sap-messages</code>
response header
@param {object} [mHeaders={}]
Map of default headers; may be overridden with request-specific headers; certain
OData V4 headers are predefined, but may be overridden by the default or
request-specific headers:
<pre>{
"Accept" : "application/json;odata.metadata=minimal;IEEE754Compatible=true",
"OData-MaxVersion" : "4.0",
"OData-Version" : "4.0"
}</pre>
The map of the default headers must not contain "X-CSRF-Token" header. The created
<code>_Requestor</code> always sets the "Content-Type" header value to
"application/json;charset=UTF-8;IEEE754Compatible=true" for OData V4 or
"application/json;charset=UTF-8" for OData V2.
@param {object} [mQueryParams={}]
A map of query parameters as described in
{@link sap.ui.model.odata.v4.lib._Helper.buildQuery}; used only to request the CSRF
token
@param {string} [sODataVersion="4.0"]
The version of the OData service. Supported values are "2.0" and "4.0".
@returns {object}
A new <code>_Requestor</code> instance | [
"Creates",
"a",
"new",
"<code",
">",
"_Requestor<",
"/",
"code",
">",
"instance",
"for",
"the",
"given",
"service",
"URL",
"and",
"default",
"headers",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Requestor.js#L1536-L1544 | train | Creates a new Requestor instance. | [
30522,
3853,
1006,
7020,
2121,
7903,
11236,
2140,
1010,
18168,
10244,
4115,
3334,
12172,
1010,
1049,
4974,
2545,
1010,
1049,
4226,
2854,
28689,
5244,
1010,
14904,
2696,
27774,
1007,
1063,
13075,
10848,
15500,
2953,
1027,
2047,
5227,
2953,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
BlackrockDigital/startbootstrap-sb-admin-2 | vendor/chart.js/Chart.js | getConstraintDimension | function getConstraintDimension(domNode, maxStyle, percentageProperty) {
var view = document.defaultView;
var parentNode = helpers$1._getParentNode(domNode);
var constrainedNode = view.getComputedStyle(domNode)[maxStyle];
var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle];
var hasCNode = isConstrainedValue(constrainedNode);
var hasCContainer = isConstrainedValue(constrainedContainer);
var infinity = Number.POSITIVE_INFINITY;
if (hasCNode || hasCContainer) {
return Math.min(
hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity,
hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity);
}
return 'none';
} | javascript | function getConstraintDimension(domNode, maxStyle, percentageProperty) {
var view = document.defaultView;
var parentNode = helpers$1._getParentNode(domNode);
var constrainedNode = view.getComputedStyle(domNode)[maxStyle];
var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle];
var hasCNode = isConstrainedValue(constrainedNode);
var hasCContainer = isConstrainedValue(constrainedContainer);
var infinity = Number.POSITIVE_INFINITY;
if (hasCNode || hasCContainer) {
return Math.min(
hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity,
hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity);
}
return 'none';
} | [
"function",
"getConstraintDimension",
"(",
"domNode",
",",
"maxStyle",
",",
"percentageProperty",
")",
"{",
"var",
"view",
"=",
"document",
".",
"defaultView",
";",
"var",
"parentNode",
"=",
"helpers$1",
".",
"_getParentNode",
"(",
"domNode",
")",
";",
"var",
... | Returns the max width or height of the given DOM node in a cross-browser compatible fashion
@param {HTMLElement} domNode - the node to check the constraint on
@param {string} maxStyle - the style that defines the maximum for the direction we are using ('max-width' / 'max-height')
@param {string} percentageProperty - property of parent to use when calculating width as a percentage
@see {@link https://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser} | [
"Returns",
"the",
"max",
"width",
"or",
"height",
"of",
"the",
"given",
"DOM",
"node",
"in",
"a",
"cross",
"-",
"browser",
"compatible",
"fashion"
] | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L9758-L9774 | train | Returns the max dimension of a constraint. | [
30522,
3853,
2131,
8663,
20528,
18447,
22172,
6132,
3258,
1006,
14383,
3630,
3207,
1010,
4098,
21756,
2571,
1010,
7017,
21572,
4842,
3723,
1007,
1063,
13075,
3193,
1027,
6254,
1012,
12398,
8584,
1025,
13075,
6687,
3630,
3207,
1027,
2393,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_LabelSst | function parse_LabelSst(blob) {
var cell = parse_XLSCell(blob);
cell.isst = blob.read_shift(4);
return cell;
} | javascript | function parse_LabelSst(blob) {
var cell = parse_XLSCell(blob);
cell.isst = blob.read_shift(4);
return cell;
} | [
"function",
"parse_LabelSst",
"(",
"blob",
")",
"{",
"var",
"cell",
"=",
"parse_XLSCell",
"(",
"blob",
")",
";",
"cell",
".",
"isst",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
";",
"return",
"cell",
";",
"}"
] | /* [MS-XLS] 2.4.149 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"4",
".",
"149"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L5967-L5971 | train | Parse LabelSst | [
30522,
3853,
11968,
3366,
1035,
10873,
3367,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
3526,
1027,
11968,
3366,
1035,
28712,
11020,
5349,
1006,
1038,
4135,
2497,
1007,
1025,
3526,
1012,
26354,
2102,
1027,
1038,
4135,
2497,
1012,
3191,
1035... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_FileMoniker | function parse_FileMoniker(blob) {
blob.l += 2; //var cAnti = blob.read_shift(2);
var ansiPath = blob.read_shift(0, 'lpstr-ansi');
blob.l += 2; //var endServer = blob.read_shift(2);
if(blob.read_shift(2) != 0xDEAD) throw new Error("Bad FileMoniker");
var sz = blob.read_shift(4);
if(sz === 0) return ansiPath.replace(/\\/g,"/");
var bytes = blob.read_shift(4);
if(blob.read_shift(2) != 3) throw new Error("Bad FileMoniker");
var unicodePath = blob.read_shift(bytes>>1, 'utf16le').replace(chr0,"");
return unicodePath;
} | javascript | function parse_FileMoniker(blob) {
blob.l += 2; //var cAnti = blob.read_shift(2);
var ansiPath = blob.read_shift(0, 'lpstr-ansi');
blob.l += 2; //var endServer = blob.read_shift(2);
if(blob.read_shift(2) != 0xDEAD) throw new Error("Bad FileMoniker");
var sz = blob.read_shift(4);
if(sz === 0) return ansiPath.replace(/\\/g,"/");
var bytes = blob.read_shift(4);
if(blob.read_shift(2) != 3) throw new Error("Bad FileMoniker");
var unicodePath = blob.read_shift(bytes>>1, 'utf16le').replace(chr0,"");
return unicodePath;
} | [
"function",
"parse_FileMoniker",
"(",
"blob",
")",
"{",
"blob",
".",
"l",
"+=",
"2",
";",
"//var cAnti = blob.read_shift(2);",
"var",
"ansiPath",
"=",
"blob",
".",
"read_shift",
"(",
"0",
",",
"'lpstr-ansi'",
")",
";",
"blob",
".",
"l",
"+=",
"2",
";",
"... | /* [MS-OSHARED] 2.3.7.8 FileMoniker TODO: all fields | [
"/",
"*",
"[",
"MS",
"-",
"OSHARED",
"]",
"2",
".",
"3",
".",
"7",
".",
"8",
"FileMoniker",
"TODO",
":",
"all",
"fields"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L5475-L5486 | train | Parse FileMoniker | [
30522,
3853,
11968,
3366,
1035,
5371,
8202,
17339,
2099,
1006,
1038,
4135,
2497,
1007,
1063,
1038,
4135,
2497,
1012,
1048,
1009,
1027,
1016,
1025,
1013,
1013,
13075,
2064,
3775,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
1016,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/Toolbar.js | removeOverflowContentAndPopup | function removeOverflowContentAndPopup() {
if (this.bPopupInitialized) {
this._oOverflowPopup.destroy();
this._oOverflowPopup = null;
this.popup.detachOpened(this.handlePopupOpened, this);
this.popup.detachClosed(this.handlePopupClosed, this);
this.popup.destroy();
this.popup = null;
this.bPopupInitialized = false;
}
} | javascript | function removeOverflowContentAndPopup() {
if (this.bPopupInitialized) {
this._oOverflowPopup.destroy();
this._oOverflowPopup = null;
this.popup.detachOpened(this.handlePopupOpened, this);
this.popup.detachClosed(this.handlePopupClosed, this);
this.popup.destroy();
this.popup = null;
this.bPopupInitialized = false;
}
} | [
"function",
"removeOverflowContentAndPopup",
"(",
")",
"{",
"if",
"(",
"this",
".",
"bPopupInitialized",
")",
"{",
"this",
".",
"_oOverflowPopup",
".",
"destroy",
"(",
")",
";",
"this",
".",
"_oOverflowPopup",
"=",
"null",
";",
"this",
".",
"popup",
".",
"... | Destroy/Remove overflow menu content that is inside the popup and the popup itself
@private | [
"Destroy",
"/",
"Remove",
"overflow",
"menu",
"content",
"that",
"is",
"inside",
"the",
"popup",
"and",
"the",
"popup",
"itself"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/Toolbar.js#L1047-L1057 | train | Removes the overflow content and the popup | [
30522,
3853,
6366,
7840,
12314,
8663,
6528,
5794,
18927,
7361,
6279,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
30524,
26915,
2098,
1010,
2023,
1007,
1025,
2023,
1012,
3769,
6279,
1012,
20010,
6776,
20464,
24768,
1006,
2023,
1012,
5047,
1634... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ksky521/nodeppt | packages/nodeppt/lib/ask.js | render | function render(content, data) {
if (content && /{{([^{}]+)}}/g.test(content)) {
Object.keys(data).forEach(key => {
if (data[key] && typeof data[key] === 'string') {
content = content.split(new RegExp(`{{\\s*${key}\\s*}}`, 'g')).join(data[key]);
}
});
return content;
}
return content;
} | javascript | function render(content, data) {
if (content && /{{([^{}]+)}}/g.test(content)) {
Object.keys(data).forEach(key => {
if (data[key] && typeof data[key] === 'string') {
content = content.split(new RegExp(`{{\\s*${key}\\s*}}`, 'g')).join(data[key]);
}
});
return content;
}
return content;
} | [
"function",
"render",
"(",
"content",
",",
"data",
")",
"{",
"if",
"(",
"content",
"&&",
"/",
"{{([^{}]+)}}",
"/",
"g",
".",
"test",
"(",
"content",
")",
")",
"{",
"Object",
".",
"keys",
"(",
"data",
")",
".",
"forEach",
"(",
"key",
"=>",
"{",
"i... | 将 default 使用 templateData 渲染一下,比如作者之类的 | [
"将",
"default",
"使用",
"templateData",
"渲染一下,比如作者之类的"
] | ca77e29ef818c08b0522b31e3925b073cf159b9c | https://github.com/ksky521/nodeppt/blob/ca77e29ef818c08b0522b31e3925b073cf159b9c/packages/nodeppt/lib/ask.js#L26-L37 | train | render content with data | [
30522,
3853,
17552,
1006,
4180,
1010,
2951,
1007,
1063,
2065,
1006,
4180,
1004,
1004,
1013,
1063,
1063,
1006,
1031,
1034,
1063,
1065,
1033,
1009,
1007,
1065,
1065,
1013,
1043,
1012,
3231,
1006,
4180,
1007,
1007,
1063,
4874,
1012,
6309,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js | function (vValue) {
var sJSON;
if (typeof vValue !== "function") {
try {
sJSON = Basics.toJSON(vValue);
// undefined --> undefined
// null, NaN, Infinity --> "null"
// all are correctly handled by String
if (sJSON !== undefined && sJSON !== "null") {
return sJSON;
}
} catch (e) {
// "converting circular structure to JSON"
}
}
return String(vValue);
} | javascript | function (vValue) {
var sJSON;
if (typeof vValue !== "function") {
try {
sJSON = Basics.toJSON(vValue);
// undefined --> undefined
// null, NaN, Infinity --> "null"
// all are correctly handled by String
if (sJSON !== undefined && sJSON !== "null") {
return sJSON;
}
} catch (e) {
// "converting circular structure to JSON"
}
}
return String(vValue);
} | [
"function",
"(",
"vValue",
")",
"{",
"var",
"sJSON",
";",
"if",
"(",
"typeof",
"vValue",
"!==",
"\"function\"",
")",
"{",
"try",
"{",
"sJSON",
"=",
"Basics",
".",
"toJSON",
"(",
"vValue",
")",
";",
"// undefined --> undefined",
"// null, NaN, Infinity --> \"nu... | Stringifies the value for usage in an error message. Special handling for functions and
object trees with circular references.
@param {any} vValue the value
@returns {string} the stringified value | [
"Stringifies",
"the",
"value",
"for",
"usage",
"in",
"an",
"error",
"message",
".",
"Special",
"handling",
"for",
"functions",
"and",
"object",
"trees",
"with",
"circular",
"references",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js#L401-L418 | train | Converts a value to JSON | [
30522,
3853,
1006,
1058,
10175,
5657,
1007,
1063,
13075,
1055,
22578,
2239,
1025,
2065,
1006,
2828,
11253,
1058,
10175,
5657,
999,
1027,
1027,
1000,
3853,
1000,
1007,
1063,
3046,
1063,
1055,
22578,
2239,
1027,
24078,
1012,
2000,
22578,
2239... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.demokit/src/sap/ui/demokit/util/jsanalyzer/Doclet.js | Doclet | function Doclet(comment) {
this.comment = comment = unwrap(comment);
this.tags = [];
var m;
var lastContent = 0;
var lastTag = "description";
while ((m = rtag.exec(comment)) != null) {
this._addTag(lastTag, comment.slice(lastContent, m.index));
lastTag = m[2];
lastContent = rtag.lastIndex;
}
this._addTag(lastTag, comment.slice(lastContent));
} | javascript | function Doclet(comment) {
this.comment = comment = unwrap(comment);
this.tags = [];
var m;
var lastContent = 0;
var lastTag = "description";
while ((m = rtag.exec(comment)) != null) {
this._addTag(lastTag, comment.slice(lastContent, m.index));
lastTag = m[2];
lastContent = rtag.lastIndex;
}
this._addTag(lastTag, comment.slice(lastContent));
} | [
"function",
"Doclet",
"(",
"comment",
")",
"{",
"this",
".",
"comment",
"=",
"comment",
"=",
"unwrap",
"(",
"comment",
")",
";",
"this",
".",
"tags",
"=",
"[",
"]",
";",
"var",
"m",
";",
"var",
"lastContent",
"=",
"0",
";",
"var",
"lastTag",
"=",
... | Creates a Doclet from the given comment string
@param {string} comment Comment string.
@constructor
@private | [
"Creates",
"a",
"Doclet",
"from",
"the",
"given",
"comment",
"string"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.demokit/src/sap/ui/demokit/util/jsanalyzer/Doclet.js#L42-L56 | train | Doclet constructor. | [
30522,
3853,
9986,
7485,
1006,
7615,
1007,
1063,
2023,
1012,
7615,
1027,
7615,
1027,
4895,
13088,
9331,
1006,
7615,
1007,
1025,
2023,
1012,
22073,
1027,
1031,
1033,
1025,
13075,
1049,
1025,
13075,
2197,
8663,
6528,
2102,
1027,
1014,
1025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/FileFilters.js | _handleEditFilter | function _handleEditFilter(e) {
var filterSets = PreferencesManager.get("fileFilters") || [],
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
// Close the dropdown first before opening the edit filter dialog
// so that it will restore focus to the DOM element that has focus
// prior to opening it.
_picker.closeDropdown();
editFilter(filterSets[filterIndex], filterIndex);
} | javascript | function _handleEditFilter(e) {
var filterSets = PreferencesManager.get("fileFilters") || [],
filterIndex = $(e.target).parent().data("index") - FIRST_FILTER_INDEX;
// Don't let the click bubble upward.
e.stopPropagation();
// Close the dropdown first before opening the edit filter dialog
// so that it will restore focus to the DOM element that has focus
// prior to opening it.
_picker.closeDropdown();
editFilter(filterSets[filterIndex], filterIndex);
} | [
"function",
"_handleEditFilter",
"(",
"e",
")",
"{",
"var",
"filterSets",
"=",
"PreferencesManager",
".",
"get",
"(",
"\"fileFilters\"",
")",
"||",
"[",
"]",
",",
"filterIndex",
"=",
"$",
"(",
"e",
".",
"target",
")",
".",
"parent",
"(",
")",
".",
"dat... | Close filter dropdwon list and launch edit filter dialog.
@param {!Event} e Mouse events | [
"Close",
"filter",
"dropdwon",
"list",
"and",
"launch",
"edit",
"filter",
"dialog",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/FileFilters.js#L466-L479 | train | Handles the edit filter click event. | [
30522,
3853,
1035,
5047,
2098,
4183,
8873,
21928,
1006,
1041,
1007,
1063,
13075,
17736,
8454,
1027,
18394,
24805,
4590,
1012,
2131,
1006,
1000,
5371,
8873,
21928,
2015,
1000,
1007,
1064,
1064,
1031,
1033,
1010,
11307,
22254,
10288,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ColorlibHQ/AdminLTE | plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js | function(node) {
var range = rangy.createRange(this.doc);
range.setStartAfter(node);
range.setEndAfter(node);
return this.setSelection(range);
} | javascript | function(node) {
var range = rangy.createRange(this.doc);
range.setStartAfter(node);
range.setEndAfter(node);
return this.setSelection(range);
} | [
"function",
"(",
"node",
")",
"{",
"var",
"range",
"=",
"rangy",
".",
"createRange",
"(",
"this",
".",
"doc",
")",
";",
"range",
".",
"setStartAfter",
"(",
"node",
")",
";",
"range",
".",
"setEndAfter",
"(",
"node",
")",
";",
"return",
"this",
".",
... | Set the caret after the given node
@param {Object} node The element or text node where to position the caret in front of
@example
selection.setBefore(myElement); | [
"Set",
"the",
"caret",
"after",
"the",
"given",
"node"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.js#L8810-L8816 | train | Set selection to the node after the node | [
30522,
3853,
1006,
13045,
1007,
1063,
13075,
2846,
1027,
8369,
2100,
1012,
3443,
24388,
2063,
1006,
2023,
1012,
9986,
1007,
1025,
2846,
1012,
4520,
7559,
2696,
6199,
2121,
1006,
13045,
1007,
1025,
2846,
1012,
2275,
10497,
10354,
3334,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
codemirror/CodeMirror | src/model/history.js | getOldSpans | function getOldSpans(doc, change) {
let found = change["spans_" + doc.id]
if (!found) return null
let nw = []
for (let i = 0; i < change.text.length; ++i)
nw.push(removeClearedSpans(found[i]))
return nw
} | javascript | function getOldSpans(doc, change) {
let found = change["spans_" + doc.id]
if (!found) return null
let nw = []
for (let i = 0; i < change.text.length; ++i)
nw.push(removeClearedSpans(found[i]))
return nw
} | [
"function",
"getOldSpans",
"(",
"doc",
",",
"change",
")",
"{",
"let",
"found",
"=",
"change",
"[",
"\"spans_\"",
"+",
"doc",
".",
"id",
"]",
"if",
"(",
"!",
"found",
")",
"return",
"null",
"let",
"nw",
"=",
"[",
"]",
"for",
"(",
"let",
"i",
"=",... | Retrieve and filter the old marked spans stored in a change event. | [
"Retrieve",
"and",
"filter",
"the",
"old",
"marked",
"spans",
"stored",
"in",
"a",
"change",
"event",
"."
] | dab6f676107c10ba8d16c654a42f66cae3f27db1 | https://github.com/codemirror/CodeMirror/blob/dab6f676107c10ba8d16c654a42f66cae3f27db1/src/model/history.js#L169-L176 | train | Get old spans from a change | [
30522,
3853,
2131,
11614,
13102,
6962,
1006,
9986,
1010,
2689,
1007,
1063,
2292,
2179,
1027,
2689,
1031,
1000,
14798,
1035,
1000,
1009,
9986,
1012,
8909,
1033,
2065,
1006,
999,
2179,
1007,
2709,
19701,
2292,
22064,
1027,
1031,
1033,
2005,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/Manifest.js | function(sUri, sRelativeTo) {
var oUri = this._resolveUri(new URI(sUri), sRelativeTo);
return oUri && oUri.toString();
} | javascript | function(sUri, sRelativeTo) {
var oUri = this._resolveUri(new URI(sUri), sRelativeTo);
return oUri && oUri.toString();
} | [
"function",
"(",
"sUri",
",",
"sRelativeTo",
")",
"{",
"var",
"oUri",
"=",
"this",
".",
"_resolveUri",
"(",
"new",
"URI",
"(",
"sUri",
")",
",",
"sRelativeTo",
")",
";",
"return",
"oUri",
"&&",
"oUri",
".",
"toString",
"(",
")",
";",
"}"
] | Resolves the given URI relative to the Component by default
or optional relative to the manifest when passing 'manifest'
as second parameter.
@param {string} sUri URI to resolve as string
@param {string} [sRelativeTo='component'] defines to which base URI the given URI will be resolved to; one of ‘component' (default) or 'manifest'
@return {string} resolved URI as string
@public
@since 1.60.1 | [
"Resolves",
"the",
"given",
"URI",
"relative",
"to",
"the",
"Component",
"by",
"default",
"or",
"optional",
"relative",
"to",
"the",
"manifest",
"when",
"passing",
"manifest",
"as",
"second",
"parameter",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Manifest.js#L599-L602 | train | Resolves the given URI and returns the absolute URI | [
30522,
3853,
1006,
7505,
2072,
1010,
5034,
10581,
6024,
3406,
1007,
1063,
13075,
2256,
2072,
1027,
2023,
1012,
1035,
10663,
9496,
1006,
2047,
24471,
2072,
1006,
7505,
2072,
1007,
1010,
5034,
10581,
6024,
3406,
1007,
1025,
2709,
2256,
2072,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jhipster/generator-jhipster | generators/aws-containers/prompts.js | askScaling | function askScaling() {
if (this.abort) return null;
const done = this.async();
const chainPromises = index => {
if (index === this.appConfigs.length) {
done();
return null;
}
const config = this.appConfigs[index];
const awsConfig = this.aws.apps.find(a => a.baseName === config.baseName) || { baseName: config.baseName };
return promptScaling.call(this, config, awsConfig).then(scaling => {
awsConfig.scaling = scaling;
awsConfig.fargate = { ...awsConfig.fargate, ...SCALING_TO_CONFIG[scaling].fargate };
awsConfig.database = { ...awsConfig.database, ...SCALING_TO_CONFIG[scaling].database };
_.remove(this.aws.apps, a => _.isEqual(a, awsConfig));
this.aws.apps.push(awsConfig);
return chainPromises(index + 1);
});
};
return chainPromises(0);
} | javascript | function askScaling() {
if (this.abort) return null;
const done = this.async();
const chainPromises = index => {
if (index === this.appConfigs.length) {
done();
return null;
}
const config = this.appConfigs[index];
const awsConfig = this.aws.apps.find(a => a.baseName === config.baseName) || { baseName: config.baseName };
return promptScaling.call(this, config, awsConfig).then(scaling => {
awsConfig.scaling = scaling;
awsConfig.fargate = { ...awsConfig.fargate, ...SCALING_TO_CONFIG[scaling].fargate };
awsConfig.database = { ...awsConfig.database, ...SCALING_TO_CONFIG[scaling].database };
_.remove(this.aws.apps, a => _.isEqual(a, awsConfig));
this.aws.apps.push(awsConfig);
return chainPromises(index + 1);
});
};
return chainPromises(0);
} | [
"function",
"askScaling",
"(",
")",
"{",
"if",
"(",
"this",
".",
"abort",
")",
"return",
"null",
";",
"const",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"const",
"chainPromises",
"=",
"index",
"=>",
"{",
"if",
"(",
"index",
"===",
"this",
"... | Ask about scaling | [
"Ask",
"about",
"scaling"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/aws-containers/prompts.js#L291-L313 | train | Ask scaling for a new application | [
30522,
3853,
5176,
9289,
2075,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
11113,
11589,
1007,
2709,
19701,
1025,
9530,
3367,
2589,
1027,
2023,
1012,
2004,
6038,
2278,
1006,
1007,
1025,
9530,
3367,
4677,
21572,
28732,
2015,
1027,
5950,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/utils.js | handleWindow | function handleWindow(type, text, callback, dontClose) {
// Set the window opener function to use depending on the type
var func_ptr = null;
switch (type) {
case "type":
func_ptr = mozmill.utils.getWindowByType;
break;
case "title":
func_ptr = mozmill.utils.getWindowByTitle;
break;
default:
throw new Error(arguments.callee.name + ": Unknown opener type - " + type);
}
var window = null;
var controller = null;
try {
// Wait until the window has been opened
mozmill.utils.waitFor(function () {
window = func_ptr(text);
return window != null;
}, "Window has been found.");
// XXX: We still have to find a reliable way to wait until the new window
// content has been finished loading. Let's wait for now.
controller = new mozmill.controller.MozMillController(window);
controller.sleep(200);
if (callback) {
callback(controller);
}
// Check if we have to close the window
dontClose = dontClose || false;
if (dontClose == false & window != null) {
controller.window.close();
mozmill.utils.waitFor(function () {
return func_ptr(text) != window;
}, "Window has been closed.");
window = null;
controller = null;
}
return controller;
} catch (ex) {
if (window)
window.close();
throw ex;
}
} | javascript | function handleWindow(type, text, callback, dontClose) {
// Set the window opener function to use depending on the type
var func_ptr = null;
switch (type) {
case "type":
func_ptr = mozmill.utils.getWindowByType;
break;
case "title":
func_ptr = mozmill.utils.getWindowByTitle;
break;
default:
throw new Error(arguments.callee.name + ": Unknown opener type - " + type);
}
var window = null;
var controller = null;
try {
// Wait until the window has been opened
mozmill.utils.waitFor(function () {
window = func_ptr(text);
return window != null;
}, "Window has been found.");
// XXX: We still have to find a reliable way to wait until the new window
// content has been finished loading. Let's wait for now.
controller = new mozmill.controller.MozMillController(window);
controller.sleep(200);
if (callback) {
callback(controller);
}
// Check if we have to close the window
dontClose = dontClose || false;
if (dontClose == false & window != null) {
controller.window.close();
mozmill.utils.waitFor(function () {
return func_ptr(text) != window;
}, "Window has been closed.");
window = null;
controller = null;
}
return controller;
} catch (ex) {
if (window)
window.close();
throw ex;
}
} | [
"function",
"handleWindow",
"(",
"type",
",",
"text",
",",
"callback",
",",
"dontClose",
")",
"{",
"// Set the window opener function to use depending on the type",
"var",
"func_ptr",
"=",
"null",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"\"type\"",
":",
"fun... | Function to handle non-modal windows
@param {string} type
Specifies how to check for the new window (possible values: type or title)
@param {string} text
The window type of title string to search for
@param {function} callback (optional)
Callback function to call for window specific tests
@param {boolean} dontClose (optional)
Doens't close the window after the return from the callback handler
@returns The MozMillController of the window (if the window hasn't been closed) | [
"Function",
"to",
"handle",
"non",
"-",
"modal",
"windows"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/utils.js#L373-L425 | train | Handles a window opener | [
30522,
30524,
2828,
13075,
4569,
2278,
1035,
13866,
2099,
1027,
19701,
1025,
6942,
1006,
2828,
1007,
1063,
2553,
1000,
2828,
1000,
1024,
4569,
2278,
1035,
13866,
2099,
1027,
9587,
2480,
19912,
1012,
21183,
12146,
1012,
2131,
11101,
5004,
37... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.