repo stringclasses 192 values | path stringlengths 4 115 | func_name stringlengths 0 45 | original_string stringlengths 74 24k | language stringclasses 1 value | code stringlengths 74 24k | code_tokens listlengths 23 4.2k | docstring stringlengths 2 23.7k | docstring_tokens listlengths 1 810 | sha stringclasses 192 values | url stringlengths 90 200 | partition stringclasses 1 value | summary stringlengths 6 313 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eslint/eslint | lib/rules/no-eval.js | report | function report(node) {
const parent = node.parent;
const locationNode = node.type === "MemberExpression"
? node.property
: node;
const reportNode = parent.type === "CallExpression" && parent.callee === node
? parent
: node;
context.report({
node: reportNode,
loc: locationNode.loc.start,
messageId: "unexpected"
});
} | javascript | function report(node) {
const parent = node.parent;
const locationNode = node.type === "MemberExpression"
? node.property
: node;
const reportNode = parent.type === "CallExpression" && parent.callee === node
? parent
: node;
context.report({
node: reportNode,
loc: locationNode.loc.start,
messageId: "unexpected"
});
} | [
"function",
"report",
"(",
"node",
")",
"{",
"const",
"parent",
"=",
"node",
".",
"parent",
";",
"const",
"locationNode",
"=",
"node",
".",
"type",
"===",
"\"MemberExpression\"",
"?",
"node",
".",
"property",
":",
"node",
";",
"const",
"reportNode",
"=",
... | Reports a given node.
`node` is `Identifier` or `MemberExpression`.
The parent of `node` might be `CallExpression`.
The location of the report is always `eval` `Identifier` (or possibly
`Literal`). The type of the report is `CallExpression` if the parent is
`CallExpression`. Otherwise, it's the given node type.
@param {ASTNode} node - A node to report.
@returns {void} | [
"Reports",
"a",
"given",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-eval.js#L155-L170 | train | Reports an unexpected node. | [
30522,
3853,
3189,
1006,
13045,
1007,
1063,
9530,
3367,
6687,
1027,
13045,
1012,
6687,
1025,
9530,
3367,
3295,
3630,
3207,
1027,
13045,
1012,
2828,
1027,
1027,
1027,
1000,
2266,
10288,
20110,
3258,
1000,
1029,
13045,
1012,
3200,
1024,
13045... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/AutoUpdate/main.js | handleDownloadFailure | function handleDownloadFailure(message) {
console.log("AutoUpdate : Download of latest installer failed in Attempt " +
(MAX_DOWNLOAD_ATTEMPTS - downloadAttemptsRemaining) + ".\n Reason : " + message);
if (downloadAttemptsRemaining) {
// Retry the downloading
attemptToDownload();
} else {
// Download could not completed, all attempts exhausted
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
var descriptionMessage = "",
analyticsDescriptionMessage = "";
if (message === _nodeErrorMessages.DOWNLOAD_ERROR) {
descriptionMessage = Strings.DOWNLOAD_ERROR;
analyticsDescriptionMessage = "Error occurred while downloading.";
} else if (message === _nodeErrorMessages.NETWORK_SLOW_OR_DISCONNECTED) {
descriptionMessage = Strings.NETWORK_SLOW_OR_DISCONNECTED;
analyticsDescriptionMessage = "Network is Disconnected or too slow.";
}
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
analyticsDescriptionMessage
);
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.DOWNLOAD_FAILED,
description: descriptionMessage
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
} | javascript | function handleDownloadFailure(message) {
console.log("AutoUpdate : Download of latest installer failed in Attempt " +
(MAX_DOWNLOAD_ATTEMPTS - downloadAttemptsRemaining) + ".\n Reason : " + message);
if (downloadAttemptsRemaining) {
// Retry the downloading
attemptToDownload();
} else {
// Download could not completed, all attempts exhausted
enableCheckForUpdateEntry(true);
UpdateStatus.cleanUpdateStatus();
var descriptionMessage = "",
analyticsDescriptionMessage = "";
if (message === _nodeErrorMessages.DOWNLOAD_ERROR) {
descriptionMessage = Strings.DOWNLOAD_ERROR;
analyticsDescriptionMessage = "Error occurred while downloading.";
} else if (message === _nodeErrorMessages.NETWORK_SLOW_OR_DISCONNECTED) {
descriptionMessage = Strings.NETWORK_SLOW_OR_DISCONNECTED;
analyticsDescriptionMessage = "Network is Disconnected or too slow.";
}
HealthLogger.sendAnalyticsData(
autoUpdateEventNames.AUTOUPDATE_DOWNLOAD_FAILED,
"autoUpdate",
"download",
"fail",
analyticsDescriptionMessage
);
UpdateInfoBar.showUpdateBar({
type: "error",
title: Strings.DOWNLOAD_FAILED,
description: descriptionMessage
});
setUpdateStateInJSON("autoUpdateInProgress", false);
}
} | [
"function",
"handleDownloadFailure",
"(",
"message",
")",
"{",
"console",
".",
"log",
"(",
"\"AutoUpdate : Download of latest installer failed in Attempt \"",
"+",
"(",
"MAX_DOWNLOAD_ATTEMPTS",
"-",
"downloadAttemptsRemaining",
")",
"+",
"\".\\n Reason : \"",
"+",
"message",
... | Handles the download failure callback from Node
@param {string} message - reason of download failure | [
"Handles",
"the",
"download",
"failure",
"callback",
"from",
"Node"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/main.js#L1024-L1063 | train | Handle download failure | [
30522,
3853,
8971,
12384,
11066,
7011,
4014,
5397,
1006,
4471,
1007,
1063,
10122,
1012,
8833,
1006,
1000,
8285,
6279,
13701,
1024,
8816,
1997,
6745,
16500,
2121,
3478,
1999,
3535,
1000,
1009,
1006,
4098,
1035,
8816,
1035,
4740,
1011,
8816,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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(inst, date) {
var yearSplit, currentYear,
minDate = this._getMinMaxDate(inst, "min"),
maxDate = this._getMinMaxDate(inst, "max"),
minYear = null,
maxYear = null,
years = this._get(inst, "yearRange");
if (years){
yearSplit = years.split(":");
currentYear = new Date().getFullYear();
minYear = parseInt(yearSplit[0], 10);
maxYear = parseInt(yearSplit[1], 10);
if ( yearSplit[0].match(/[+\-].*/) ) {
minYear += currentYear;
}
if ( yearSplit[1].match(/[+\-].*/) ) {
maxYear += currentYear;
}
}
return ((!minDate || date.getTime() >= minDate.getTime()) &&
(!maxDate || date.getTime() <= maxDate.getTime()) &&
(!minYear || date.getFullYear() >= minYear) &&
(!maxYear || date.getFullYear() <= maxYear));
} | javascript | function(inst, date) {
var yearSplit, currentYear,
minDate = this._getMinMaxDate(inst, "min"),
maxDate = this._getMinMaxDate(inst, "max"),
minYear = null,
maxYear = null,
years = this._get(inst, "yearRange");
if (years){
yearSplit = years.split(":");
currentYear = new Date().getFullYear();
minYear = parseInt(yearSplit[0], 10);
maxYear = parseInt(yearSplit[1], 10);
if ( yearSplit[0].match(/[+\-].*/) ) {
minYear += currentYear;
}
if ( yearSplit[1].match(/[+\-].*/) ) {
maxYear += currentYear;
}
}
return ((!minDate || date.getTime() >= minDate.getTime()) &&
(!maxDate || date.getTime() <= maxDate.getTime()) &&
(!minYear || date.getFullYear() >= minYear) &&
(!maxYear || date.getFullYear() <= maxYear));
} | [
"function",
"(",
"inst",
",",
"date",
")",
"{",
"var",
"yearSplit",
",",
"currentYear",
",",
"minDate",
"=",
"this",
".",
"_getMinMaxDate",
"(",
"inst",
",",
"\"min\"",
")",
",",
"maxDate",
"=",
"this",
".",
"_getMinMaxDate",
"(",
"inst",
",",
"\"max\"",... | /* Is the given date in the accepted range? | [
"/",
"*",
"Is",
"the",
"given",
"date",
"in",
"the",
"accepted",
"range?"
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L9518-L9542 | train | Determines whether a date is within the range of the calendar. | [
30522,
3853,
1006,
16021,
2102,
1010,
3058,
1007,
1063,
13075,
2086,
24759,
4183,
1010,
2783,
29100,
1010,
2568,
3686,
1027,
2023,
1012,
1035,
2131,
10020,
17848,
13701,
1006,
16021,
2102,
1010,
1000,
8117,
1000,
1007,
1010,
4098,
13701,
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... | |
LLK/scratch-blocks | blocks_vertical/looks.js | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "COSTUME",
"options": [
['costume1', 'COSTUME1'],
['costume2', 'COSTUME2']
]
}
],
"colour": Blockly.Colours.looks.secondary,
"colourSecondary": Blockly.Colours.looks.secondary,
"colourTertiary": Blockly.Colours.looks.tertiary,
"extensions": ["output_string"]
});
} | javascript | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "COSTUME",
"options": [
['costume1', 'COSTUME1'],
['costume2', 'COSTUME2']
]
}
],
"colour": Blockly.Colours.looks.secondary,
"colourSecondary": Blockly.Colours.looks.secondary,
"colourTertiary": Blockly.Colours.looks.tertiary,
"extensions": ["output_string"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"\"%1\"",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_dropdown\"",
",",
"\"name\"",
":",
"\"COSTUME\"",
",",
"\"options\"",
":",
"[",
"[",
"'costume1'",
",",
... | Costumes drop-down menu.
@this Blockly.Block | [
"Costumes",
"drop",
"-",
"down",
"menu",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/looks.js#L354-L372 | train | Block for
. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1046,
3385,
5498,
2102,
1006,
1063,
1000,
4471,
2692,
1000,
1024,
1000,
1003,
1015,
1000,
1010,
1000,
12098,
5620,
2692,
1000,
1024,
1031,
1063,
1000,
2828,
1000,
1024,
1000,
2492,
1035,
4530,
76... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/max-lines-per-function.js | isIIFE | function isIIFE(node) {
return node.type === "FunctionExpression" && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node;
} | javascript | function isIIFE(node) {
return node.type === "FunctionExpression" && node.parent && node.parent.type === "CallExpression" && node.parent.callee === node;
} | [
"function",
"isIIFE",
"(",
"node",
")",
"{",
"return",
"node",
".",
"type",
"===",
"\"FunctionExpression\"",
"&&",
"node",
".",
"parent",
"&&",
"node",
".",
"parent",
".",
"type",
"===",
"\"CallExpression\"",
"&&",
"node",
".",
"parent",
".",
"callee",
"==... | Identifies is a node is a FunctionExpression which is part of an IIFE
@param {ASTNode} node Node to test
@returns {boolean} True if it's an IIFE | [
"Identifies",
"is",
"a",
"node",
"is",
"a",
"FunctionExpression",
"which",
"is",
"part",
"of",
"an",
"IIFE"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/max-lines-per-function.js#L137-L139 | train | Checks whether a node is an IIFE. | [
30522,
3853,
2003,
6137,
7959,
1006,
13045,
1007,
1063,
2709,
13045,
1012,
2828,
1027,
1027,
1027,
1000,
3853,
10288,
20110,
3258,
1000,
1004,
1004,
13045,
1012,
6687,
1004,
1004,
13045,
1012,
6687,
1012,
2828,
1027,
1027,
1027,
1000,
2655,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/tabs/js/tabsController.js | select | function select (index, canSkipClick) {
if (!locked) ctrl.focusIndex = ctrl.selectedIndex = index;
// skip the click event if noSelectClick is enabled
if (canSkipClick && ctrl.noSelectClick) return;
// nextTick is required to prevent errors in user-defined click events
$mdUtil.nextTick(function () {
ctrl.tabs[ index ].element.triggerHandler('click');
}, false);
} | javascript | function select (index, canSkipClick) {
if (!locked) ctrl.focusIndex = ctrl.selectedIndex = index;
// skip the click event if noSelectClick is enabled
if (canSkipClick && ctrl.noSelectClick) return;
// nextTick is required to prevent errors in user-defined click events
$mdUtil.nextTick(function () {
ctrl.tabs[ index ].element.triggerHandler('click');
}, false);
} | [
"function",
"select",
"(",
"index",
",",
"canSkipClick",
")",
"{",
"if",
"(",
"!",
"locked",
")",
"ctrl",
".",
"focusIndex",
"=",
"ctrl",
".",
"selectedIndex",
"=",
"index",
";",
"// skip the click event if noSelectClick is enabled",
"if",
"(",
"canSkipClick",
"... | Update the selected index. Triggers a click event on the original `md-tab` element in order
to fire user-added click events if canSkipClick or `md-no-select-click` are false.
@param index
@param canSkipClick Optionally allow not firing the click event if `md-no-select-click` is also true. | [
"Update",
"the",
"selected",
"index",
".",
"Triggers",
"a",
"click",
"event",
"on",
"the",
"original",
"md",
"-",
"tab",
"element",
"in",
"order",
"to",
"fire",
"user",
"-",
"added",
"click",
"events",
"if",
"canSkipClick",
"or",
"md",
"-",
"no",
"-",
... | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/tabs/js/tabsController.js#L339-L347 | train | Select a tab | [
30522,
3853,
7276,
1006,
5950,
1010,
18484,
3211,
15042,
25230,
1007,
1063,
2065,
1006,
999,
5299,
1007,
14931,
12190,
1012,
3579,
22254,
10288,
1027,
14931,
12190,
1012,
3479,
22254,
10288,
1027,
5950,
1025,
1013,
1013,
13558,
1996,
11562,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | docs/app/js/codepen.js | escapeJsonQuotes | function escapeJsonQuotes(json) {
return JSON.stringify(json)
.replace(/'/g, "&apos;")
.replace(/"/g, "&quot;")
/**
* Codepen was unescaping < (<) and > (>) which caused, on some demos,
* an unclosed elements (like <md-select>).
* Used different unicode lookalike characters so it won't be considered as an element
*/
.replace(/&lt;/g, "˂") // http://graphemica.com/%CB%82
.replace(/&gt;/g, "˃"); // http://graphemica.com/%CB%83
} | javascript | function escapeJsonQuotes(json) {
return JSON.stringify(json)
.replace(/'/g, "&apos;")
.replace(/"/g, "&quot;")
/**
* Codepen was unescaping < (<) and > (>) which caused, on some demos,
* an unclosed elements (like <md-select>).
* Used different unicode lookalike characters so it won't be considered as an element
*/
.replace(/&lt;/g, "˂") // http://graphemica.com/%CB%82
.replace(/&gt;/g, "˃"); // http://graphemica.com/%CB%83
} | [
"function",
"escapeJsonQuotes",
"(",
"json",
")",
"{",
"return",
"JSON",
".",
"stringify",
"(",
"json",
")",
".",
"replace",
"(",
"/",
"'",
"/",
"g",
",",
"\"&apos;\"",
")",
".",
"replace",
"(",
"/",
"\"",
"/",
"g",
",",
"\"&quot;\"",
")",
"/... | Recommended by Codepen to escape quotes. See http://blog.codepen.io/documentation/api/prefill | [
"Recommended",
"by",
"Codepen",
"to",
"escape",
"quotes",
".",
"See",
"http",
":",
"//",
"blog",
".",
"codepen",
".",
"io",
"/",
"documentation",
"/",
"api",
"/",
"prefill"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/codepen.js#L45-L56 | train | Escape the JSON quotes | [
30522,
3853,
4019,
22578,
2239,
28940,
12184,
2015,
1006,
1046,
3385,
1007,
1063,
2709,
1046,
3385,
1012,
5164,
8757,
1006,
1046,
3385,
1007,
1012,
5672,
1006,
1013,
1005,
1013,
1043,
1010,
1000,
1004,
23713,
1025,
9706,
2891,
1025,
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... |
mochajs/mocha | lib/runnable.js | done | function done(err) {
var ms = self.timeout();
if (self.timedOut) {
return;
}
if (finished) {
return multiple(err);
}
self.clearTimeout();
self.duration = new Date() - start;
finished = true;
if (!err && self.duration > ms && self._enableTimeouts) {
err = self._timeoutError(ms);
}
fn(err);
} | javascript | function done(err) {
var ms = self.timeout();
if (self.timedOut) {
return;
}
if (finished) {
return multiple(err);
}
self.clearTimeout();
self.duration = new Date() - start;
finished = true;
if (!err && self.duration > ms && self._enableTimeouts) {
err = self._timeoutError(ms);
}
fn(err);
} | [
"function",
"done",
"(",
"err",
")",
"{",
"var",
"ms",
"=",
"self",
".",
"timeout",
"(",
")",
";",
"if",
"(",
"self",
".",
"timedOut",
")",
"{",
"return",
";",
"}",
"if",
"(",
"finished",
")",
"{",
"return",
"multiple",
"(",
"err",
")",
";",
"}... | finished | [
"finished"
] | 9b00fedb610241e33f7592c40164e42a38a793cf | https://github.com/mochajs/mocha/blob/9b00fedb610241e33f7592c40164e42a38a793cf/lib/runnable.js#L318-L335 | train | Called when all tasks have been completed | [
30522,
3853,
2589,
1006,
9413,
2099,
1007,
1063,
13075,
5796,
1027,
2969,
1012,
2051,
5833,
1006,
1007,
1025,
2065,
1006,
2969,
1012,
22313,
5833,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
2736,
1007,
1063,
2709,
3674,
1006,
9413,
2099,
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... |
eslint/eslint | lib/util/report-translator.js | assertValidNodeInfo | function assertValidNodeInfo(descriptor) {
if (descriptor.node) {
assert(typeof descriptor.node === "object", "Node must be an object");
} else {
assert(descriptor.loc, "Node must be provided when reporting error if location is not provided");
}
} | javascript | function assertValidNodeInfo(descriptor) {
if (descriptor.node) {
assert(typeof descriptor.node === "object", "Node must be an object");
} else {
assert(descriptor.loc, "Node must be provided when reporting error if location is not provided");
}
} | [
"function",
"assertValidNodeInfo",
"(",
"descriptor",
")",
"{",
"if",
"(",
"descriptor",
".",
"node",
")",
"{",
"assert",
"(",
"typeof",
"descriptor",
".",
"node",
"===",
"\"object\"",
",",
"\"Node must be an object\"",
")",
";",
"}",
"else",
"{",
"assert",
... | Asserts that either a loc or a node was provided, and the node is valid if it was provided.
@param {MessageDescriptor} descriptor A descriptor to validate
@returns {void}
@throws AssertionError if neither a node nor a loc was provided, or if the node is not an object | [
"Asserts",
"that",
"either",
"a",
"loc",
"or",
"a",
"node",
"was",
"provided",
"and",
"the",
"node",
"is",
"valid",
"if",
"it",
"was",
"provided",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/report-translator.js#L92-L98 | train | Assert that the node is valid | [
30522,
3853,
20865,
10175,
3593,
3630,
3207,
2378,
14876,
1006,
4078,
23235,
2953,
1007,
1063,
2065,
1006,
4078,
23235,
2953,
1012,
13045,
1007,
1063,
20865,
1006,
2828,
11253,
4078,
23235,
2953,
1012,
13045,
1027,
1027,
1027,
1000,
4874,
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.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (vModel, sArrayName, sQualifiedName, bAsPath) {
var aArray,
vResult = bAsPath ? undefined : null,
oSchema,
iSeparatorPos,
sNamespace,
sName;
sQualifiedName = sQualifiedName || "";
iSeparatorPos = sQualifiedName.lastIndexOf(".");
sNamespace = sQualifiedName.slice(0, iSeparatorPos);
sName = sQualifiedName.slice(iSeparatorPos + 1);
oSchema = Utils.getSchema(vModel, sNamespace);
if (oSchema) {
aArray = oSchema[sArrayName];
if (aArray) {
aArray.forEach(function (oThing) {
if (oThing.name === sName) {
vResult = bAsPath ? oThing.$path : oThing;
return false; // break
}
});
}
}
return vResult;
} | javascript | function (vModel, sArrayName, sQualifiedName, bAsPath) {
var aArray,
vResult = bAsPath ? undefined : null,
oSchema,
iSeparatorPos,
sNamespace,
sName;
sQualifiedName = sQualifiedName || "";
iSeparatorPos = sQualifiedName.lastIndexOf(".");
sNamespace = sQualifiedName.slice(0, iSeparatorPos);
sName = sQualifiedName.slice(iSeparatorPos + 1);
oSchema = Utils.getSchema(vModel, sNamespace);
if (oSchema) {
aArray = oSchema[sArrayName];
if (aArray) {
aArray.forEach(function (oThing) {
if (oThing.name === sName) {
vResult = bAsPath ? oThing.$path : oThing;
return false; // break
}
});
}
}
return vResult;
} | [
"function",
"(",
"vModel",
",",
"sArrayName",
",",
"sQualifiedName",
",",
"bAsPath",
")",
"{",
"var",
"aArray",
",",
"vResult",
"=",
"bAsPath",
"?",
"undefined",
":",
"null",
",",
"oSchema",
",",
"iSeparatorPos",
",",
"sNamespace",
",",
"sName",
";",
"sQua... | Returns the thing with the given qualified name from the given model's array (within a
schema) of given name.
@param {sap.ui.model.Model|object[]} vModel
either a model or an array of schemas
@param {string} sArrayName
name of array within schema which will be searched
@param {string} sQualifiedName
a qualified name, e.g. "ACME.Foo"
@param {boolean} [bAsPath=false]
determines whether the thing itself is returned or just its path
@returns {object|string}
(the path to) the thing with the given qualified name; <code>undefined</code> (for a
path) or <code>null</code> (for an object) if no such thing is found | [
"Returns",
"the",
"thing",
"with",
"the",
"given",
"qualified",
"name",
"from",
"the",
"given",
"model",
"s",
"array",
"(",
"within",
"a",
"schema",
")",
"of",
"given",
"name",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L686-L712 | train | Returns the path of the object in the schema | [
30522,
3853,
1006,
1058,
5302,
9247,
1010,
18906,
9447,
18442,
1010,
5490,
8787,
7810,
18442,
1010,
19021,
15069,
1007,
1063,
13075,
9779,
11335,
2100,
1010,
27830,
2229,
11314,
1027,
19021,
15069,
1029,
6151,
28344,
1024,
19701,
1010,
9808,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | src/ol/pointer/MouseSource.js | mouseover | function mouseover(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.enterOver(e, inEvent);
}
} | javascript | function mouseover(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = prepareEvent(inEvent, this.dispatcher);
this.dispatcher.enterOver(e, inEvent);
}
} | [
"function",
"mouseover",
"(",
"inEvent",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isEventSimulatedFromTouch_",
"(",
"inEvent",
")",
")",
"{",
"const",
"e",
"=",
"prepareEvent",
"(",
"inEvent",
",",
"this",
".",
"dispatcher",
")",
";",
"this",
".",
"dispat... | Handler for `mouseover`.
@this {MouseSource}
@param {MouseEvent} inEvent The in event. | [
"Handler",
"for",
"mouseover",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MouseSource.js#L113-L118 | train | mouseover event handler | [
30522,
3853,
8000,
7840,
1006,
1999,
18697,
3372,
1007,
1063,
2065,
1006,
999,
2023,
1012,
2003,
18697,
7666,
5714,
8898,
19699,
5358,
24826,
2818,
1035,
1006,
1999,
18697,
3372,
1007,
1007,
1063,
9530,
3367,
1041,
1027,
7374,
18697,
3372,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
airyland/vux | src/components/video/zy.media.js | _css | function _css(el, property) {
return parseInt(el.style[property] || window.getComputedStyle(el, null).getPropertyValue(property))
} | javascript | function _css(el, property) {
return parseInt(el.style[property] || window.getComputedStyle(el, null).getPropertyValue(property))
} | [
"function",
"_css",
"(",
"el",
",",
"property",
")",
"{",
"return",
"parseInt",
"(",
"el",
".",
"style",
"[",
"property",
"]",
"||",
"window",
".",
"getComputedStyle",
"(",
"el",
",",
"null",
")",
".",
"getPropertyValue",
"(",
"property",
")",
")",
"}"... | Get style | [
"Get",
"style"
] | 484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6 | https://github.com/airyland/vux/blob/484fc3c18bdca99b0c08efbb678c0ee0f5ceedd6/src/components/video/zy.media.js#L110-L112 | train | Get the value of a CSS property | [
30522,
3853,
1035,
20116,
2015,
1006,
3449,
1010,
3200,
1007,
1063,
2709,
11968,
30524,
19701,
1007,
1012,
2131,
21572,
4842,
3723,
10175,
5657,
1006,
3200,
1007,
1007,
1065,
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,
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/utils/ExtensionUtils.js | getModuleUrl | function getModuleUrl(module, path) {
var url = encodeURI(getModulePath(module, path));
// On Windows, $.get() fails if the url is a full pathname. To work around this,
// prepend "file:///". On the Mac, $.get() works fine if the url is a full pathname,
// but *doesn't* work if it is prepended with "file://". Go figure.
// However, the prefix "file://localhost" does work.
if (brackets.platform === "win" && url.indexOf(":") !== -1) {
url = "file:///" + url;
}
return url;
} | javascript | function getModuleUrl(module, path) {
var url = encodeURI(getModulePath(module, path));
// On Windows, $.get() fails if the url is a full pathname. To work around this,
// prepend "file:///". On the Mac, $.get() works fine if the url is a full pathname,
// but *doesn't* work if it is prepended with "file://". Go figure.
// However, the prefix "file://localhost" does work.
if (brackets.platform === "win" && url.indexOf(":") !== -1) {
url = "file:///" + url;
}
return url;
} | [
"function",
"getModuleUrl",
"(",
"module",
",",
"path",
")",
"{",
"var",
"url",
"=",
"encodeURI",
"(",
"getModulePath",
"(",
"module",
",",
"path",
")",
")",
";",
"// On Windows, $.get() fails if the url is a full pathname. To work around this,",
"// prepend \"file:///\".... | Returns a URL to an extension module.
@param {!module} module Module provided by RequireJS
@param {?string} path Relative path from the extension folder to a file
@return {!string} The URL to the module's folder | [
"Returns",
"a",
"URL",
"to",
"an",
"extension",
"module",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/utils/ExtensionUtils.js#L153-L165 | train | Get the url of a module | [
30522,
3853,
2131,
5302,
8566,
2571,
3126,
2140,
1006,
11336,
1010,
4130,
1007,
1063,
13075,
24471,
2140,
1027,
4372,
16044,
9496,
1006,
2131,
5302,
8566,
2571,
15069,
1006,
11336,
1010,
4130,
1007,
1007,
1025,
1013,
1013,
2006,
3645,
1010,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
LLK/scratch-blocks | blocks_vertical/looks.js | function() {
this.jsonInit({
"message0": Blockly.Msg.LOOKS_GOFORWARDBACKWARDLAYERS,
"args0": [
{
"type": "field_dropdown",
"name": "FORWARD_BACKWARD",
"options": [
[Blockly.Msg.LOOKS_GOFORWARDBACKWARDLAYERS_FORWARD, 'forward'],
[Blockly.Msg.LOOKS_GOFORWARDBACKWARDLAYERS_BACKWARD, 'backward']
]
},
{
"type": "input_value",
"name": "NUM"
}
],
"category": Blockly.Categories.looks,
"extensions": ["colours_looks", "shape_statement"]
});
} | javascript | function() {
this.jsonInit({
"message0": Blockly.Msg.LOOKS_GOFORWARDBACKWARDLAYERS,
"args0": [
{
"type": "field_dropdown",
"name": "FORWARD_BACKWARD",
"options": [
[Blockly.Msg.LOOKS_GOFORWARDBACKWARDLAYERS_FORWARD, 'forward'],
[Blockly.Msg.LOOKS_GOFORWARDBACKWARDLAYERS_BACKWARD, 'backward']
]
},
{
"type": "input_value",
"name": "NUM"
}
],
"category": Blockly.Categories.looks,
"extensions": ["colours_looks", "shape_statement"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"Blockly",
".",
"Msg",
".",
"LOOKS_GOFORWARDBACKWARDLAYERS",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_dropdown\"",
",",
"\"name\"",
":",
"\"FORWARD_BACKWARD\"",
... | "Go forward/backward [Number] Layers" Block.
@this Blockly.Block | [
"Go",
"forward",
"/",
"backward",
"[",
"Number",
"]",
"Layers",
"Block",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/looks.js#L484-L504 | train | Block for the next forward backward. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1046,
3385,
5498,
2102,
1006,
1063,
1000,
4471,
2692,
1000,
1024,
3796,
2135,
1012,
5796,
2290,
1012,
3504,
1035,
2175,
29278,
7652,
5963,
7652,
24314,
2015,
1010,
1000,
12098,
5620,
2692,
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/protractor | lib/clientsidescripts.js | function(callback) {
if (window.angular) {
var hooks = getNg1Hooks(rootSelector);
if (!hooks){
callback(); // not an angular1 app
}
else{
if (hooks.$$testability) {
hooks.$$testability.whenStable(callback);
} else if (hooks.$injector) {
hooks.$injector.get('$browser')
.notifyWhenNoOutstandingRequests(callback);
} else if (!rootSelector) {
throw new Error(
'Could not automatically find injector on page: "' +
window.location.toString() + '". Consider using config.rootEl');
} else {
throw new Error(
'root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
}
}
}
else {callback();} // not an angular1 app
} | javascript | function(callback) {
if (window.angular) {
var hooks = getNg1Hooks(rootSelector);
if (!hooks){
callback(); // not an angular1 app
}
else{
if (hooks.$$testability) {
hooks.$$testability.whenStable(callback);
} else if (hooks.$injector) {
hooks.$injector.get('$browser')
.notifyWhenNoOutstandingRequests(callback);
} else if (!rootSelector) {
throw new Error(
'Could not automatically find injector on page: "' +
window.location.toString() + '". Consider using config.rootEl');
} else {
throw new Error(
'root element (' + rootSelector + ') has no injector.' +
' this may mean it is not inside ng-app.');
}
}
}
else {callback();} // not an angular1 app
} | [
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"window",
".",
"angular",
")",
"{",
"var",
"hooks",
"=",
"getNg1Hooks",
"(",
"rootSelector",
")",
";",
"if",
"(",
"!",
"hooks",
")",
"{",
"callback",
"(",
")",
";",
"// not an angular1 app",
"}",
"else"... | Wait for angular1 testability first and run waitForAngular2 as a callback | [
"Wait",
"for",
"angular1",
"testability",
"first",
"and",
"run",
"waitForAngular2",
"as",
"a",
"callback"
] | 4f74a4ec753c97adfe955fe468a39286a0a55837 | https://github.com/angular/protractor/blob/4f74a4ec753c97adfe955fe468a39286a0a55837/lib/clientsidescripts.js#L143-L168 | train | get the injector | [
30522,
3853,
1006,
2655,
5963,
1007,
1063,
2065,
1006,
3332,
1012,
16108,
1007,
1063,
13075,
18008,
1027,
2131,
3070,
2487,
6806,
6559,
2015,
1006,
6147,
12260,
16761,
1007,
1025,
2065,
1006,
999,
18008,
1007,
1063,
2655,
5963,
1006,
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... | |
LLK/scratch-blocks | blocks_vertical/data.js | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_numberdropdown",
"name": "INDEX",
"value": "1",
"min": 1,
"precision": 1,
"options": [
["1", "1"],
[Blockly.Msg.DATA_INDEX_LAST, "last"],
[Blockly.Msg.DATA_INDEX_RANDOM, "random"]
]
}
],
"category": Blockly.Categories.data,
"extensions": ["colours_textfield", "output_string"]
});
} | javascript | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_numberdropdown",
"name": "INDEX",
"value": "1",
"min": 1,
"precision": 1,
"options": [
["1", "1"],
[Blockly.Msg.DATA_INDEX_LAST, "last"],
[Blockly.Msg.DATA_INDEX_RANDOM, "random"]
]
}
],
"category": Blockly.Categories.data,
"extensions": ["colours_textfield", "output_string"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"\"%1\"",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_numberdropdown\"",
",",
"\"name\"",
":",
"\"INDEX\"",
",",
"\"value\"",
":",
"\"1\"",
",",
"\"min\"",
":... | List index menu, with random option.
@this Blockly.Block | [
"List",
"index",
"menu",
"with",
"random",
"option",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/data.js#L208-L228 | train | Block for
. | [
30522,
3853,
1006,
1007,
1063,
2023,
1012,
1046,
3385,
5498,
2102,
1006,
1063,
1000,
4471,
2692,
1000,
1024,
1000,
1003,
1015,
1000,
1010,
1000,
12098,
5620,
2692,
1000,
1024,
1031,
1063,
1000,
2828,
1000,
1024,
1000,
2492,
1035,
2193,
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... | |
Freeboard/freeboard | js/freeboard.thirdparty.js | function( element ) {
// if the element is already wrapped, return it
if ( element.parent().is( ".ui-effects-wrapper" )) {
return element.parent();
}
// wrap the element
var props = {
width: element.outerWidth(true),
height: element.outerHeight(true),
"float": element.css( "float" )
},
wrapper = $( "<div></div>" )
.addClass( "ui-effects-wrapper" )
.css({
fontSize: "100%",
background: "transparent",
border: "none",
margin: 0,
padding: 0
}),
// Store the size in case width/height are defined in % - Fixes #5245
size = {
width: element.width(),
height: element.height()
},
active = document.activeElement;
// support: Firefox
// Firefox incorrectly exposes anonymous content
// https://bugzilla.mozilla.org/show_bug.cgi?id=561664
try {
active.id;
} catch( e ) {
active = document.body;
}
element.wrap( wrapper );
// Fixes #7595 - Elements lose focus when wrapped.
if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
$( active ).focus();
}
wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
// transfer positioning properties to the wrapper
if ( element.css( "position" ) === "static" ) {
wrapper.css({ position: "relative" });
element.css({ position: "relative" });
} else {
$.extend( props, {
position: element.css( "position" ),
zIndex: element.css( "z-index" )
});
$.each([ "top", "left", "bottom", "right" ], function(i, pos) {
props[ pos ] = element.css( pos );
if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
props[ pos ] = "auto";
}
});
element.css({
position: "relative",
top: 0,
left: 0,
right: "auto",
bottom: "auto"
});
}
element.css(size);
return wrapper.css( props ).show();
} | javascript | function( element ) {
// if the element is already wrapped, return it
if ( element.parent().is( ".ui-effects-wrapper" )) {
return element.parent();
}
// wrap the element
var props = {
width: element.outerWidth(true),
height: element.outerHeight(true),
"float": element.css( "float" )
},
wrapper = $( "<div></div>" )
.addClass( "ui-effects-wrapper" )
.css({
fontSize: "100%",
background: "transparent",
border: "none",
margin: 0,
padding: 0
}),
// Store the size in case width/height are defined in % - Fixes #5245
size = {
width: element.width(),
height: element.height()
},
active = document.activeElement;
// support: Firefox
// Firefox incorrectly exposes anonymous content
// https://bugzilla.mozilla.org/show_bug.cgi?id=561664
try {
active.id;
} catch( e ) {
active = document.body;
}
element.wrap( wrapper );
// Fixes #7595 - Elements lose focus when wrapped.
if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
$( active ).focus();
}
wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
// transfer positioning properties to the wrapper
if ( element.css( "position" ) === "static" ) {
wrapper.css({ position: "relative" });
element.css({ position: "relative" });
} else {
$.extend( props, {
position: element.css( "position" ),
zIndex: element.css( "z-index" )
});
$.each([ "top", "left", "bottom", "right" ], function(i, pos) {
props[ pos ] = element.css( pos );
if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
props[ pos ] = "auto";
}
});
element.css({
position: "relative",
top: 0,
left: 0,
right: "auto",
bottom: "auto"
});
}
element.css(size);
return wrapper.css( props ).show();
} | [
"function",
"(",
"element",
")",
"{",
"// if the element is already wrapped, return it",
"if",
"(",
"element",
".",
"parent",
"(",
")",
".",
"is",
"(",
"\".ui-effects-wrapper\"",
")",
")",
"{",
"return",
"element",
".",
"parent",
"(",
")",
";",
"}",
"// wrap t... | Wraps the element around a wrapper that copies position properties | [
"Wraps",
"the",
"element",
"around",
"a",
"wrapper",
"that",
"copies",
"position",
"properties"
] | 38789f6e8bd3d04f7d3b2c3427e509d00f2610fc | https://github.com/Freeboard/freeboard/blob/38789f6e8bd3d04f7d3b2c3427e509d00f2610fc/js/freeboard.thirdparty.js#L5734-L5807 | train | wrap an element | [
30522,
3853,
1006,
5783,
1007,
1063,
1013,
1013,
2065,
1996,
5783,
2003,
2525,
5058,
1010,
2709,
2009,
2065,
1006,
5783,
1012,
6687,
1006,
1007,
1012,
2003,
1006,
1000,
1012,
21318,
1011,
3896,
1011,
10236,
4842,
1000,
1007,
1007,
1063,
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... | |
PrismJS/prism | scripts/utopia.js | function(url, callback, doc) {
doc = doc || document;
return _.element.create({
tag: 'script',
properties: {
src: url,
async: true,
onload: callback
},
inside: doc.documentElement
});
} | javascript | function(url, callback, doc) {
doc = doc || document;
return _.element.create({
tag: 'script',
properties: {
src: url,
async: true,
onload: callback
},
inside: doc.documentElement
});
} | [
"function",
"(",
"url",
",",
"callback",
",",
"doc",
")",
"{",
"doc",
"=",
"doc",
"||",
"document",
";",
"return",
"_",
".",
"element",
".",
"create",
"(",
"{",
"tag",
":",
"'script'",
",",
"properties",
":",
"{",
"src",
":",
"url",
",",
"async",
... | Lazy loads an external script | [
"Lazy",
"loads",
"an",
"external",
"script"
] | acceb3b56f0e8362a7ef274dbd85b17611df2ec4 | https://github.com/PrismJS/prism/blob/acceb3b56f0e8362a7ef274dbd85b17611df2ec4/scripts/utopia.js#L403-L415 | train | Load a script | [
30522,
3853,
1006,
24471,
2140,
1010,
2655,
5963,
1010,
9986,
1007,
1063,
9986,
1027,
9986,
1064,
1064,
6254,
1025,
2709,
1035,
1012,
5783,
1012,
3443,
1006,
1063,
6415,
1024,
1005,
5896,
1005,
1010,
5144,
1024,
1063,
5034,
2278,
1024,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/utils/tracked-controls.js | isControllerPresentWebVR | function isControllerPresentWebVR (component, idPrefix, queryObject) {
var gamepads;
var sceneEl = component.el.sceneEl;
var trackedControlsSystem;
var filterControllerIndex = queryObject.index || 0;
if (!idPrefix) { return false; }
trackedControlsSystem = sceneEl && sceneEl.systems['tracked-controls-webvr'];
if (!trackedControlsSystem) { return false; }
gamepads = trackedControlsSystem.controllers;
if (!gamepads.length) { return false; }
return !!findMatchingControllerWebVR(gamepads, null, idPrefix, queryObject.hand,
filterControllerIndex);
} | javascript | function isControllerPresentWebVR (component, idPrefix, queryObject) {
var gamepads;
var sceneEl = component.el.sceneEl;
var trackedControlsSystem;
var filterControllerIndex = queryObject.index || 0;
if (!idPrefix) { return false; }
trackedControlsSystem = sceneEl && sceneEl.systems['tracked-controls-webvr'];
if (!trackedControlsSystem) { return false; }
gamepads = trackedControlsSystem.controllers;
if (!gamepads.length) { return false; }
return !!findMatchingControllerWebVR(gamepads, null, idPrefix, queryObject.hand,
filterControllerIndex);
} | [
"function",
"isControllerPresentWebVR",
"(",
"component",
",",
"idPrefix",
",",
"queryObject",
")",
"{",
"var",
"gamepads",
";",
"var",
"sceneEl",
"=",
"component",
".",
"el",
".",
"sceneEl",
";",
"var",
"trackedControlsSystem",
";",
"var",
"filterControllerIndex"... | Enumerate controller (that have pose) and check if they match parameters for WebVR
@param {object} component - Tracked controls component.
@param {object} idPrefix - Prefix to match in gamepad id if any.
@param {object} queryObject - Map of values to match. | [
"Enumerate",
"controller",
"(",
"that",
"have",
"pose",
")",
"and",
"check",
"if",
"they",
"match",
"parameters",
"for",
"WebVR"
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/utils/tracked-controls.js#L55-L71 | train | Returns true if the specified controller is present in the WebVR. | [
30522,
3853,
2003,
8663,
13181,
10820,
28994,
4765,
8545,
2497,
19716,
1006,
6922,
1010,
8909,
28139,
8873,
2595,
1010,
23032,
16429,
20614,
1007,
1063,
13075,
2208,
15455,
2015,
1025,
13075,
3496,
2884,
1027,
6922,
1012,
3449,
1012,
3496,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.m/src/sap/m/IconTabBarDragAndDropUtil.js | function (context, sDropLayout) {
var oIconTabHeader = context._iconTabHeader ? context._iconTabHeader : context;
var sIconTabHeaderId = oIconTabHeader.getId();
//Adding Drag&Drop configuration to the dragDropConfig aggregation if needed
context.addDragDropConfig(new DragInfo({
sourceAggregation: "items",
groupName: DRAG_DROP_GROUP_NAME + sIconTabHeaderId
}));
context.addDragDropConfig(new DropInfo({
targetAggregation: "items",
dropPosition: "Between",
dropLayout: sDropLayout,
drop: context._handleDragAndDrop.bind(context),
groupName: DRAG_DROP_GROUP_NAME + sIconTabHeaderId
}));
} | javascript | function (context, sDropLayout) {
var oIconTabHeader = context._iconTabHeader ? context._iconTabHeader : context;
var sIconTabHeaderId = oIconTabHeader.getId();
//Adding Drag&Drop configuration to the dragDropConfig aggregation if needed
context.addDragDropConfig(new DragInfo({
sourceAggregation: "items",
groupName: DRAG_DROP_GROUP_NAME + sIconTabHeaderId
}));
context.addDragDropConfig(new DropInfo({
targetAggregation: "items",
dropPosition: "Between",
dropLayout: sDropLayout,
drop: context._handleDragAndDrop.bind(context),
groupName: DRAG_DROP_GROUP_NAME + sIconTabHeaderId
}));
} | [
"function",
"(",
"context",
",",
"sDropLayout",
")",
"{",
"var",
"oIconTabHeader",
"=",
"context",
".",
"_iconTabHeader",
"?",
"context",
".",
"_iconTabHeader",
":",
"context",
";",
"var",
"sIconTabHeaderId",
"=",
"oIconTabHeader",
".",
"getId",
"(",
")",
";",... | Adding aggregations for drag and drop.
@param {object} context from which context function is called (sap.m.IconTabHeader or sap.m.IconTabSelectList)
@param {string} sDropLayout Depending on the control we are dragging in, it could be Vertical or Horizontal | [
"Adding",
"aggregations",
"for",
"drag",
"and",
"drop",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/IconTabBarDragAndDropUtil.js#L239-L254 | train | Adds the drag & drop configuration to the context | [
30522,
3853,
1006,
6123,
1010,
17371,
18981,
8485,
5833,
1007,
1063,
13075,
1051,
28524,
2696,
23706,
13775,
2121,
1027,
6123,
1012,
1035,
12696,
2696,
23706,
13775,
2121,
1029,
6123,
1012,
1035,
12696,
2696,
23706,
13775,
2121,
1024,
6123,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | function(time, index, ticks, format) {
var me = this;
var adapter = me._adapter;
var options = me.options;
var formats = options.time.displayFormats;
var minorFormat = formats[me._unit];
var majorUnit = me._majorUnit;
var majorFormat = formats[majorUnit];
var majorTime = +adapter.startOf(time, majorUnit);
var majorTickOpts = options.ticks.major;
var major = majorTickOpts.enabled && majorUnit && majorFormat && time === majorTime;
var label = adapter.format(time, format ? format : major ? majorFormat : minorFormat);
var tickOpts = major ? majorTickOpts : options.ticks.minor;
var formatter = valueOrDefault$c(tickOpts.callback, tickOpts.userCallback);
return formatter ? formatter(label, index, ticks) : label;
} | javascript | function(time, index, ticks, format) {
var me = this;
var adapter = me._adapter;
var options = me.options;
var formats = options.time.displayFormats;
var minorFormat = formats[me._unit];
var majorUnit = me._majorUnit;
var majorFormat = formats[majorUnit];
var majorTime = +adapter.startOf(time, majorUnit);
var majorTickOpts = options.ticks.major;
var major = majorTickOpts.enabled && majorUnit && majorFormat && time === majorTime;
var label = adapter.format(time, format ? format : major ? majorFormat : minorFormat);
var tickOpts = major ? majorTickOpts : options.ticks.minor;
var formatter = valueOrDefault$c(tickOpts.callback, tickOpts.userCallback);
return formatter ? formatter(label, index, ticks) : label;
} | [
"function",
"(",
"time",
",",
"index",
",",
"ticks",
",",
"format",
")",
"{",
"var",
"me",
"=",
"this",
";",
"var",
"adapter",
"=",
"me",
".",
"_adapter",
";",
"var",
"options",
"=",
"me",
".",
"options",
";",
"var",
"formats",
"=",
"options",
".",... | Function to format an individual tick mark
@private | [
"Function",
"to",
"format",
"an",
"individual",
"tick",
"mark"
] | ddfaceb4a8e65a41f163e2fdc4eab49384b810a1 | https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/ddfaceb4a8e65a41f163e2fdc4eab49384b810a1/vendor/chart.js/Chart.js#L13197-L13213 | train | Returns a string that can be used to format the ticks. | [
30522,
3853,
1006,
2051,
1010,
5950,
30524,
2023,
1025,
13075,
15581,
2121,
1027,
2033,
1012,
1035,
15581,
2121,
1025,
13075,
7047,
1027,
2033,
1012,
7047,
1025,
13075,
11630,
1027,
7047,
1012,
2051,
1012,
4653,
14192,
11149,
1025,
13075,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/atoms/dom.js | getOverflowParent | function getOverflowParent(e) {
var position = bot.dom.getEffectiveStyle(e, 'position');
if (position == 'fixed') {
treatAsFixedPosition = true;
// Fixed-position element may only overflow the viewport.
return e == htmlElem ? null : htmlElem;
} else {
var parent = bot.dom.getParentElement(e);
while (parent && !canBeOverflowed(parent)) {
parent = bot.dom.getParentElement(parent);
}
return parent;
}
function canBeOverflowed(container) {
// The HTML element can always be overflowed.
if (container == htmlElem) {
return true;
}
// An element cannot overflow an element with an inline or contents display style.
var containerDisplay = /** @type {string} */ (
bot.dom.getEffectiveStyle(container, 'display'));
if (goog.string.startsWith(containerDisplay, 'inline') ||
(containerDisplay == 'contents')) {
return false;
}
// An absolute-positioned element cannot overflow a static-positioned one.
if (position == 'absolute' &&
bot.dom.getEffectiveStyle(container, 'position') == 'static') {
return false;
}
return true;
}
} | javascript | function getOverflowParent(e) {
var position = bot.dom.getEffectiveStyle(e, 'position');
if (position == 'fixed') {
treatAsFixedPosition = true;
// Fixed-position element may only overflow the viewport.
return e == htmlElem ? null : htmlElem;
} else {
var parent = bot.dom.getParentElement(e);
while (parent && !canBeOverflowed(parent)) {
parent = bot.dom.getParentElement(parent);
}
return parent;
}
function canBeOverflowed(container) {
// The HTML element can always be overflowed.
if (container == htmlElem) {
return true;
}
// An element cannot overflow an element with an inline or contents display style.
var containerDisplay = /** @type {string} */ (
bot.dom.getEffectiveStyle(container, 'display'));
if (goog.string.startsWith(containerDisplay, 'inline') ||
(containerDisplay == 'contents')) {
return false;
}
// An absolute-positioned element cannot overflow a static-positioned one.
if (position == 'absolute' &&
bot.dom.getEffectiveStyle(container, 'position') == 'static') {
return false;
}
return true;
}
} | [
"function",
"getOverflowParent",
"(",
"e",
")",
"{",
"var",
"position",
"=",
"bot",
".",
"dom",
".",
"getEffectiveStyle",
"(",
"e",
",",
"'position'",
")",
";",
"if",
"(",
"position",
"==",
"'fixed'",
")",
"{",
"treatAsFixedPosition",
"=",
"true",
";",
"... | Return the closest ancestor that the given element may overflow. | [
"Return",
"the",
"closest",
"ancestor",
"that",
"the",
"given",
"element",
"may",
"overflow",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/atoms/dom.js#L655-L688 | train | Returns the parent element of the element that can overflow the viewport. | [
30522,
3853,
2131,
7840,
12314,
19362,
4765,
1006,
1041,
1007,
1063,
13075,
2597,
1027,
28516,
1012,
14383,
1012,
2131,
12879,
25969,
24653,
27983,
1006,
1041,
1010,
1005,
2597,
1005,
1007,
1025,
2065,
1006,
2597,
1027,
1027,
1005,
4964,
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/core/XMLTemplateProcessor.js | parseNode | function parseNode(xmlNode, bRoot, bIgnoreTopLevelTextNodes) {
if ( xmlNode.nodeType === 1 /* ELEMENT_NODE */ ) {
var sLocalName = localName(xmlNode);
if (xmlNode.namespaceURI === "http://www.w3.org/1999/xhtml" || xmlNode.namespaceURI === "http://www.w3.org/2000/svg") {
// write opening tag
aResult.push("<" + sLocalName + " ");
// write attributes
var bHasId = false;
for (var i = 0; i < xmlNode.attributes.length; i++) {
var attr = xmlNode.attributes[i];
var value = attr.value;
if (attr.name === "id") {
bHasId = true;
value = getId(oView, xmlNode);
}
aResult.push(attr.name + "=\"" + encodeXML(value) + "\" ");
}
if ( bRoot === true ) {
aResult.push("data-sap-ui-preserve" + "=\"" + oView.getId() + "\" ");
if (!bHasId) {
aResult.push("id" + "=\"" + oView.getId() + "\" ");
}
}
aResult.push(">");
// write children
var oContent = xmlNode;
if (window.HTMLTemplateElement && xmlNode instanceof HTMLTemplateElement && xmlNode.content instanceof DocumentFragment) {
// <template> support (HTMLTemplateElement has no childNodes, but a content node which contains the childNodes)
oContent = xmlNode.content;
}
parseChildren(oContent);
aResult.push("</" + sLocalName + ">");
} else if (sLocalName === "FragmentDefinition" && xmlNode.namespaceURI === "sap.ui.core") {
// a Fragment element - which is not turned into a control itself. Only its content is parsed.
parseChildren(xmlNode, false, true);
// TODO: check if this branch is required or can be handled by the below one
} else {
// assumption: an ELEMENT_NODE with non-XHTML namespace is an SAPUI5 control and the namespace equals the library name
pResultChain = pResultChain.then(function() {
// Chaining the Promises as we need to make sure the order in which the XML DOM nodes are processed is fixed (depth-first, pre-order).
// The order of processing (and Promise resolution) is mandatory for keeping the order of the UI5 Controls' aggregation fixed and compatible.
return createControlOrExtension(xmlNode).then(function(aChildControls) {
for (var i = 0; i < aChildControls.length; i++) {
var oChild = aChildControls[i];
if (oView.getMetadata().hasAggregation("content")) {
oView.addAggregation("content", oChild);
// can oView really have an association called "content"?
} else if (oView.getMetadata().hasAssociation(("content"))) {
oView.addAssociation("content", oChild);
}
}
return aChildControls;
});
});
aResult.push(pResultChain);
}
} else if (xmlNode.nodeType === 3 /* TEXT_NODE */ && !bIgnoreTopLevelTextNodes) {
var text = xmlNode.textContent || xmlNode.text,
parentName = localName(xmlNode.parentNode);
if (text) {
if (parentName != "style") {
text = encodeXML(text);
}
aResult.push(text);
}
}
} | javascript | function parseNode(xmlNode, bRoot, bIgnoreTopLevelTextNodes) {
if ( xmlNode.nodeType === 1 /* ELEMENT_NODE */ ) {
var sLocalName = localName(xmlNode);
if (xmlNode.namespaceURI === "http://www.w3.org/1999/xhtml" || xmlNode.namespaceURI === "http://www.w3.org/2000/svg") {
// write opening tag
aResult.push("<" + sLocalName + " ");
// write attributes
var bHasId = false;
for (var i = 0; i < xmlNode.attributes.length; i++) {
var attr = xmlNode.attributes[i];
var value = attr.value;
if (attr.name === "id") {
bHasId = true;
value = getId(oView, xmlNode);
}
aResult.push(attr.name + "=\"" + encodeXML(value) + "\" ");
}
if ( bRoot === true ) {
aResult.push("data-sap-ui-preserve" + "=\"" + oView.getId() + "\" ");
if (!bHasId) {
aResult.push("id" + "=\"" + oView.getId() + "\" ");
}
}
aResult.push(">");
// write children
var oContent = xmlNode;
if (window.HTMLTemplateElement && xmlNode instanceof HTMLTemplateElement && xmlNode.content instanceof DocumentFragment) {
// <template> support (HTMLTemplateElement has no childNodes, but a content node which contains the childNodes)
oContent = xmlNode.content;
}
parseChildren(oContent);
aResult.push("</" + sLocalName + ">");
} else if (sLocalName === "FragmentDefinition" && xmlNode.namespaceURI === "sap.ui.core") {
// a Fragment element - which is not turned into a control itself. Only its content is parsed.
parseChildren(xmlNode, false, true);
// TODO: check if this branch is required or can be handled by the below one
} else {
// assumption: an ELEMENT_NODE with non-XHTML namespace is an SAPUI5 control and the namespace equals the library name
pResultChain = pResultChain.then(function() {
// Chaining the Promises as we need to make sure the order in which the XML DOM nodes are processed is fixed (depth-first, pre-order).
// The order of processing (and Promise resolution) is mandatory for keeping the order of the UI5 Controls' aggregation fixed and compatible.
return createControlOrExtension(xmlNode).then(function(aChildControls) {
for (var i = 0; i < aChildControls.length; i++) {
var oChild = aChildControls[i];
if (oView.getMetadata().hasAggregation("content")) {
oView.addAggregation("content", oChild);
// can oView really have an association called "content"?
} else if (oView.getMetadata().hasAssociation(("content"))) {
oView.addAssociation("content", oChild);
}
}
return aChildControls;
});
});
aResult.push(pResultChain);
}
} else if (xmlNode.nodeType === 3 /* TEXT_NODE */ && !bIgnoreTopLevelTextNodes) {
var text = xmlNode.textContent || xmlNode.text,
parentName = localName(xmlNode.parentNode);
if (text) {
if (parentName != "style") {
text = encodeXML(text);
}
aResult.push(text);
}
}
} | [
"function",
"parseNode",
"(",
"xmlNode",
",",
"bRoot",
",",
"bIgnoreTopLevelTextNodes",
")",
"{",
"if",
"(",
"xmlNode",
".",
"nodeType",
"===",
"1",
"/* ELEMENT_NODE */",
")",
"{",
"var",
"sLocalName",
"=",
"localName",
"(",
"xmlNode",
")",
";",
"if",
"(",
... | Parses an XML node that might represent a UI5 control or simple XHTML.
XHTML will be added to the aResult array as a sequence of strings,
UI5 controls will be instantiated and added as controls
@param {Element} xmlNode the XML node to parse
@param {boolean} bRoot whether this node is the root node
@param {boolean} bIgnoreTopLevelTextNodes
@returns {Promise} resolving with the content of the parsed node, which is a tree structure containing DOM Strings & UI5 Controls | [
"Parses",
"an",
"XML",
"node",
"that",
"might",
"represent",
"a",
"UI5",
"control",
"or",
"simple",
"XHTML",
".",
"XHTML",
"will",
"be",
"added",
"to",
"the",
"aResult",
"array",
"as",
"a",
"sequence",
"of",
"strings",
"UI5",
"controls",
"will",
"be",
"i... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/XMLTemplateProcessor.js#L366-L444 | train | Parses the given XML node. | [
30522,
3853,
11968,
5054,
10244,
1006,
20950,
3630,
3207,
1010,
22953,
4140,
1010,
2502,
12131,
18903,
10814,
15985,
18209,
3630,
6155,
1007,
1063,
2065,
1006,
20950,
3630,
3207,
1012,
13045,
13874,
1027,
1027,
1027,
1015,
1013,
1008,
5783,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
TryGhost/Ghost | core/server/models/post.js | defaults | function defaults() {
return {
uuid: uuid.v4(),
status: 'draft',
featured: false,
page: false,
visibility: 'public'
};
} | javascript | function defaults() {
return {
uuid: uuid.v4(),
status: 'draft',
featured: false,
page: false,
visibility: 'public'
};
} | [
"function",
"defaults",
"(",
")",
"{",
"return",
"{",
"uuid",
":",
"uuid",
".",
"v4",
"(",
")",
",",
"status",
":",
"'draft'",
",",
"featured",
":",
"false",
",",
"page",
":",
"false",
",",
"visibility",
":",
"'public'",
"}",
";",
"}"
] | @NOTE
We define the defaults on the schema (db) and model level.
Why?
- when you insert a resource, Knex does only return the id of the created resource
- see https://knexjs.org/#Builder-insert
- that means `defaultTo` is a pure database configuration (!)
- Bookshelf just returns the model values which you have asked Bookshelf to insert
- it can't return the `defaultTo` value from the schema/db level
- but the db defaults defined in the schema are saved in the database correctly
- `models.Post.add` always does to operations:
1. add
2. fetch (this ensures we fetch the whole resource from the database)
- that means we have to apply the defaults on the model layer to ensure a complete field set
1. any connected logic in our model hooks e.g. beforeSave
2. model events e.g. "post.published" are using the inserted resource, not the fetched resource | [
"@NOTE"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/models/post.js#L42-L50 | train | defaults are not used | [
30522,
3853,
12398,
2015,
1006,
1007,
1063,
2709,
1063,
1057,
21272,
1024,
1057,
21272,
1012,
1058,
2549,
1006,
1007,
1010,
3570,
1024,
1005,
4433,
1005,
1010,
2956,
1024,
6270,
1010,
3931,
1024,
6270,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
apache/incubator-echarts | src/model/Series.js | function (dataIndex, multipleSeries, dataType, renderMode) {
var series = this;
renderMode = renderMode || 'html';
var newLine = renderMode === 'html' ? '<br/>' : '\n';
var isRichText = renderMode === 'richText';
var markers = {};
var markerId = 0;
function formatArrayValue(value) {
// ??? TODO refactor these logic.
// check: category-no-encode-has-axis-data in dataset.html
var vertially = zrUtil.reduce(value, function (vertially, val, idx) {
var dimItem = data.getDimensionInfo(idx);
return vertially |= dimItem && dimItem.tooltip !== false && dimItem.displayName != null;
}, 0);
var result = [];
tooltipDims.length
? zrUtil.each(tooltipDims, function (dim) {
setEachItem(retrieveRawValue(data, dataIndex, dim), dim);
})
// By default, all dims is used on tooltip.
: zrUtil.each(value, setEachItem);
function setEachItem(val, dim) {
var dimInfo = data.getDimensionInfo(dim);
// If `dimInfo.tooltip` is not set, show tooltip.
if (!dimInfo || dimInfo.otherDims.tooltip === false) {
return;
}
var dimType = dimInfo.type;
var markName = 'sub' + series.seriesIndex + 'at' + markerId;
var dimHead = getTooltipMarker({
color: color,
type: 'subItem',
renderMode: renderMode,
markerId: markName
});
var dimHeadStr = typeof dimHead === 'string' ? dimHead : dimHead.content;
var valStr = (vertially
? dimHeadStr + encodeHTML(dimInfo.displayName || '-') + ': '
: ''
)
// FIXME should not format time for raw data?
+ encodeHTML(dimType === 'ordinal'
? val + ''
: dimType === 'time'
? (multipleSeries ? '' : formatTime('yyyy/MM/dd hh:mm:ss', val))
: addCommas(val)
);
valStr && result.push(valStr);
if (isRichText) {
markers[markName] = color;
++markerId;
}
}
var newLine = vertially ? (isRichText ? '\n' : '<br/>') : '';
var content = newLine + result.join(newLine || ', ');
return {
renderMode: renderMode,
content: content,
style: markers
};
}
function formatSingleValue(val) {
// return encodeHTML(addCommas(val));
return {
renderMode: renderMode,
content: encodeHTML(addCommas(val)),
style: markers
};
}
var data = this.getData();
var tooltipDims = data.mapDimension('defaultedTooltip', true);
var tooltipDimLen = tooltipDims.length;
var value = this.getRawValue(dataIndex);
var isValueArr = zrUtil.isArray(value);
var color = data.getItemVisual(dataIndex, 'color');
if (zrUtil.isObject(color) && color.colorStops) {
color = (color.colorStops[0] || {}).color;
}
color = color || 'transparent';
// Complicated rule for pretty tooltip.
var formattedValue = (tooltipDimLen > 1 || (isValueArr && !tooltipDimLen))
? formatArrayValue(value)
: tooltipDimLen
? formatSingleValue(retrieveRawValue(data, dataIndex, tooltipDims[0]))
: formatSingleValue(isValueArr ? value[0] : value);
var content = formattedValue.content;
var markName = series.seriesIndex + 'at' + markerId;
var colorEl = getTooltipMarker({
color: color,
type: 'item',
renderMode: renderMode,
markerId: markName
});
markers[markName] = color;
++markerId;
var name = data.getName(dataIndex);
var seriesName = this.name;
if (!modelUtil.isNameSpecified(this)) {
seriesName = '';
}
seriesName = seriesName
? encodeHTML(seriesName) + (!multipleSeries ? newLine : ': ')
: '';
var colorStr = typeof colorEl === 'string' ? colorEl : colorEl.content;
var html = !multipleSeries
? seriesName + colorStr
+ (name
? encodeHTML(name) + ': ' + content
: content
)
: colorStr + seriesName + content;
return {
html: html,
markers: markers
};
} | javascript | function (dataIndex, multipleSeries, dataType, renderMode) {
var series = this;
renderMode = renderMode || 'html';
var newLine = renderMode === 'html' ? '<br/>' : '\n';
var isRichText = renderMode === 'richText';
var markers = {};
var markerId = 0;
function formatArrayValue(value) {
// ??? TODO refactor these logic.
// check: category-no-encode-has-axis-data in dataset.html
var vertially = zrUtil.reduce(value, function (vertially, val, idx) {
var dimItem = data.getDimensionInfo(idx);
return vertially |= dimItem && dimItem.tooltip !== false && dimItem.displayName != null;
}, 0);
var result = [];
tooltipDims.length
? zrUtil.each(tooltipDims, function (dim) {
setEachItem(retrieveRawValue(data, dataIndex, dim), dim);
})
// By default, all dims is used on tooltip.
: zrUtil.each(value, setEachItem);
function setEachItem(val, dim) {
var dimInfo = data.getDimensionInfo(dim);
// If `dimInfo.tooltip` is not set, show tooltip.
if (!dimInfo || dimInfo.otherDims.tooltip === false) {
return;
}
var dimType = dimInfo.type;
var markName = 'sub' + series.seriesIndex + 'at' + markerId;
var dimHead = getTooltipMarker({
color: color,
type: 'subItem',
renderMode: renderMode,
markerId: markName
});
var dimHeadStr = typeof dimHead === 'string' ? dimHead : dimHead.content;
var valStr = (vertially
? dimHeadStr + encodeHTML(dimInfo.displayName || '-') + ': '
: ''
)
// FIXME should not format time for raw data?
+ encodeHTML(dimType === 'ordinal'
? val + ''
: dimType === 'time'
? (multipleSeries ? '' : formatTime('yyyy/MM/dd hh:mm:ss', val))
: addCommas(val)
);
valStr && result.push(valStr);
if (isRichText) {
markers[markName] = color;
++markerId;
}
}
var newLine = vertially ? (isRichText ? '\n' : '<br/>') : '';
var content = newLine + result.join(newLine || ', ');
return {
renderMode: renderMode,
content: content,
style: markers
};
}
function formatSingleValue(val) {
// return encodeHTML(addCommas(val));
return {
renderMode: renderMode,
content: encodeHTML(addCommas(val)),
style: markers
};
}
var data = this.getData();
var tooltipDims = data.mapDimension('defaultedTooltip', true);
var tooltipDimLen = tooltipDims.length;
var value = this.getRawValue(dataIndex);
var isValueArr = zrUtil.isArray(value);
var color = data.getItemVisual(dataIndex, 'color');
if (zrUtil.isObject(color) && color.colorStops) {
color = (color.colorStops[0] || {}).color;
}
color = color || 'transparent';
// Complicated rule for pretty tooltip.
var formattedValue = (tooltipDimLen > 1 || (isValueArr && !tooltipDimLen))
? formatArrayValue(value)
: tooltipDimLen
? formatSingleValue(retrieveRawValue(data, dataIndex, tooltipDims[0]))
: formatSingleValue(isValueArr ? value[0] : value);
var content = formattedValue.content;
var markName = series.seriesIndex + 'at' + markerId;
var colorEl = getTooltipMarker({
color: color,
type: 'item',
renderMode: renderMode,
markerId: markName
});
markers[markName] = color;
++markerId;
var name = data.getName(dataIndex);
var seriesName = this.name;
if (!modelUtil.isNameSpecified(this)) {
seriesName = '';
}
seriesName = seriesName
? encodeHTML(seriesName) + (!multipleSeries ? newLine : ': ')
: '';
var colorStr = typeof colorEl === 'string' ? colorEl : colorEl.content;
var html = !multipleSeries
? seriesName + colorStr
+ (name
? encodeHTML(name) + ': ' + content
: content
)
: colorStr + seriesName + content;
return {
html: html,
markers: markers
};
} | [
"function",
"(",
"dataIndex",
",",
"multipleSeries",
",",
"dataType",
",",
"renderMode",
")",
"{",
"var",
"series",
"=",
"this",
";",
"renderMode",
"=",
"renderMode",
"||",
"'html'",
";",
"var",
"newLine",
"=",
"renderMode",
"===",
"'html'",
"?",
"'<br/>'",
... | FIXME
Default tooltip formatter
@param {number} dataIndex
@param {boolean} [multipleSeries=false]
@param {number} [dataType]
@param {string} [renderMode='html'] valid values: 'html' and 'richText'.
'html' is used for rendering tooltip in extra DOM form, and the result
string is used as DOM HTML content.
'richText' is used for rendering tooltip in rich text form, for those where
DOM operation is not supported.
@return {Object} formatted tooltip with `html` and `markers` | [
"FIXME",
"Default",
"tooltip",
"formatter"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/model/Series.js#L313-L445 | train | Returns an array of data items | [
30522,
3853,
1006,
2951,
22254,
10288,
1010,
3674,
8043,
3111,
1010,
2951,
13874,
1010,
17552,
5302,
3207,
1007,
1063,
13075,
2186,
1027,
2023,
1025,
17552,
5302,
3207,
1027,
17552,
5302,
3207,
1064,
1064,
1005,
16129,
1005,
1025,
13075,
20... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/localization.js | _reportNode | function _reportNode(node) {
if (node.id) {
return "id: " + node.id;
} else if (node.label) {
return "label: " + node.label;
} else if (node.value) {
return "value: " + node.value;
} else if (node.hasAttributes()) {
var attrs = "node attributes: ";
for (var i = node.attributes.length - 1; i >= 0; i--) {
attrs += node.attributes[i].name + "->" + node.attributes[i].value + ";";
}
return attrs;
} else {
return "anonymous node";
}
} | javascript | function _reportNode(node) {
if (node.id) {
return "id: " + node.id;
} else if (node.label) {
return "label: " + node.label;
} else if (node.value) {
return "value: " + node.value;
} else if (node.hasAttributes()) {
var attrs = "node attributes: ";
for (var i = node.attributes.length - 1; i >= 0; i--) {
attrs += node.attributes[i].name + "->" + node.attributes[i].value + ";";
}
return attrs;
} else {
return "anonymous node";
}
} | [
"function",
"_reportNode",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"id",
")",
"{",
"return",
"\"id: \"",
"+",
"node",
".",
"id",
";",
"}",
"else",
"if",
"(",
"node",
".",
"label",
")",
"{",
"return",
"\"label: \"",
"+",
"node",
".",
"label",... | Tries to return a useful string identificator of the given node
@param {node} node
@returns Identificator of the node
@type {String} | [
"Tries",
"to",
"return",
"a",
"useful",
"string",
"identificator",
"of",
"the",
"given",
"node"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/localization.js#L283-L299 | train | report node | [
30522,
3853,
1035,
3189,
3630,
3207,
1006,
13045,
1007,
1063,
2065,
1006,
13045,
1012,
8909,
1007,
1063,
2709,
1000,
8909,
1024,
1000,
1009,
13045,
1012,
8909,
1025,
1065,
2842,
2065,
1006,
13045,
1012,
3830,
1007,
1063,
2709,
1000,
3830,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/TableAccExtension.js | function($Cell) {
var oTable = this.getTable(),
sTableId = oTable.getId(),
bIsInGroupingRow = TableUtils.Grouping.isInGroupingRow($Cell),
bIsInSumRow = TableUtils.Grouping.isInSumRow($Cell),
iRow = $Cell.attr("data-sap-ui-rowindex"),
oRow = oTable.getRows()[iRow],
bHidden = ExtensionHelper.isHiddenCell($Cell),
aDefaultLabels = ExtensionHelper.getAriaAttributesFor(this, TableAccExtension.ELEMENTTYPES.ROWACTION)["aria-labelledby"] || [],
aLabels = [sTableId + "-rownumberofrows", sTableId + "-colnumberofcols"].concat(aDefaultLabels),
aDescriptions = [];
if (bIsInGroupingRow) {
aLabels.push(sTableId + "-ariarowgrouplabel");
aLabels.push(sTableId + "-rows-row" + iRow + "-groupHeader");
aLabels.push(sTableId + (oRow._bIsExpanded ? "-rowcollapsetext" : "-rowexpandtext"));
}
if (bIsInSumRow) {
var iLevel = $Cell.data("sap-ui-level");
if (iLevel == 0) {
aLabels.push(sTableId + "-ariagrandtotallabel");
} else if (iLevel > 0) {
aLabels.push(sTableId + "-ariagrouptotallabel");
aLabels.push(sTableId + "-rows-row" + iRow + "-groupHeader");
}
}
if (!bIsInSumRow && !bIsInGroupingRow && $Cell.attr("aria-selected") == "true") {
aLabels.push(sTableId + "-ariarowselected");
}
if (TableUtils.hasRowHighlights(oTable) && !bIsInGroupingRow && !bIsInSumRow) {
aLabels.push(oRow.getId() + "-highlighttext");
}
var sText = "";
if (!bHidden) {
var oRowAction = oRow.getRowAction();
if (oRowAction) {
var oInfo = oRowAction.getAccessibilityInfo();
if (oInfo) {
aLabels.push(sTableId + "-cellacc");
sText = oInfo.description;
if (TableUtils.getInteractiveElements($Cell) !== null) {
aDescriptions.push(sTableId + "-toggleedit");
}
}
}
}
ExtensionHelper.performCellModifications(this, $Cell, aDefaultLabels, [], aLabels, aDescriptions, sText);
} | javascript | function($Cell) {
var oTable = this.getTable(),
sTableId = oTable.getId(),
bIsInGroupingRow = TableUtils.Grouping.isInGroupingRow($Cell),
bIsInSumRow = TableUtils.Grouping.isInSumRow($Cell),
iRow = $Cell.attr("data-sap-ui-rowindex"),
oRow = oTable.getRows()[iRow],
bHidden = ExtensionHelper.isHiddenCell($Cell),
aDefaultLabels = ExtensionHelper.getAriaAttributesFor(this, TableAccExtension.ELEMENTTYPES.ROWACTION)["aria-labelledby"] || [],
aLabels = [sTableId + "-rownumberofrows", sTableId + "-colnumberofcols"].concat(aDefaultLabels),
aDescriptions = [];
if (bIsInGroupingRow) {
aLabels.push(sTableId + "-ariarowgrouplabel");
aLabels.push(sTableId + "-rows-row" + iRow + "-groupHeader");
aLabels.push(sTableId + (oRow._bIsExpanded ? "-rowcollapsetext" : "-rowexpandtext"));
}
if (bIsInSumRow) {
var iLevel = $Cell.data("sap-ui-level");
if (iLevel == 0) {
aLabels.push(sTableId + "-ariagrandtotallabel");
} else if (iLevel > 0) {
aLabels.push(sTableId + "-ariagrouptotallabel");
aLabels.push(sTableId + "-rows-row" + iRow + "-groupHeader");
}
}
if (!bIsInSumRow && !bIsInGroupingRow && $Cell.attr("aria-selected") == "true") {
aLabels.push(sTableId + "-ariarowselected");
}
if (TableUtils.hasRowHighlights(oTable) && !bIsInGroupingRow && !bIsInSumRow) {
aLabels.push(oRow.getId() + "-highlighttext");
}
var sText = "";
if (!bHidden) {
var oRowAction = oRow.getRowAction();
if (oRowAction) {
var oInfo = oRowAction.getAccessibilityInfo();
if (oInfo) {
aLabels.push(sTableId + "-cellacc");
sText = oInfo.description;
if (TableUtils.getInteractiveElements($Cell) !== null) {
aDescriptions.push(sTableId + "-toggleedit");
}
}
}
}
ExtensionHelper.performCellModifications(this, $Cell, aDefaultLabels, [], aLabels, aDescriptions, sText);
} | [
"function",
"(",
"$Cell",
")",
"{",
"var",
"oTable",
"=",
"this",
".",
"getTable",
"(",
")",
",",
"sTableId",
"=",
"oTable",
".",
"getId",
"(",
")",
",",
"bIsInGroupingRow",
"=",
"TableUtils",
".",
"Grouping",
".",
"isInGroupingRow",
"(",
"$Cell",
")",
... | /*
Modifies the labels and descriptions of a row action cell.
@see ExtensionHelper.performCellModifications | [
"/",
"*",
"Modifies",
"the",
"labels",
"and",
"descriptions",
"of",
"a",
"row",
"action",
"cell",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableAccExtension.js#L534-L586 | train | Adds a label to the end of the list of labels | [
30522,
3853,
1006,
1002,
3526,
1007,
1063,
13075,
27178,
3085,
1027,
2023,
1012,
2131,
10880,
1006,
1007,
1010,
6540,
3593,
1027,
27178,
3085,
1012,
2131,
3593,
1006,
1007,
1010,
20377,
2075,
22107,
2075,
10524,
1027,
2795,
21823,
4877,
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... | |
adobe/brackets | src/editor/MultiRangeInlineEditor.js | finalizeSection | function finalizeSection() {
if (lastSectionDoc) {
self._$headers[lastSectionDoc.file.fullPath].append(" (" + numItemsInSection + ")");
if (self._collapsedFiles[lastSectionDoc.file.fullPath]) {
self._toggleSection(lastSectionDoc.file.fullPath, true);
}
}
} | javascript | function finalizeSection() {
if (lastSectionDoc) {
self._$headers[lastSectionDoc.file.fullPath].append(" (" + numItemsInSection + ")");
if (self._collapsedFiles[lastSectionDoc.file.fullPath]) {
self._toggleSection(lastSectionDoc.file.fullPath, true);
}
}
} | [
"function",
"finalizeSection",
"(",
")",
"{",
"if",
"(",
"lastSectionDoc",
")",
"{",
"self",
".",
"_$headers",
"[",
"lastSectionDoc",
".",
"file",
".",
"fullPath",
"]",
".",
"append",
"(",
"\" (\"",
"+",
"numItemsInSection",
"+",
"\")\"",
")",
";",
"if",
... | After seeing all results for a given file, update its header with total # of results | [
"After",
"seeing",
"all",
"results",
"for",
"a",
"given",
"file",
"update",
"its",
"header",
"with",
"total",
"#",
"of",
"results"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/MultiRangeInlineEditor.js#L247-L254 | train | Finalizes the section | [
30522,
3853,
2345,
10057,
18491,
1006,
1007,
1063,
2065,
1006,
16180,
18491,
3527,
2278,
1007,
1063,
2969,
1012,
1035,
1002,
20346,
2015,
1031,
16180,
18491,
3527,
2278,
1012,
5371,
1012,
2440,
15069,
1033,
1012,
10439,
10497,
1006,
1000,
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/parse/parsePagesList.js | parseFilePage | function parseFilePage(book, filePath) {
var fs = book.getContentFS();
return fs.statFile(filePath)
.then(
function(file) {
var page = Page.createForFile(file);
return parsePage(book, page);
},
function(err) {
// file doesn't exist
return null;
}
)
.fail(function(err) {
var logger = book.getLogger();
logger.error.ln('error while parsing page "' + filePath + '":');
throw err;
});
} | javascript | function parseFilePage(book, filePath) {
var fs = book.getContentFS();
return fs.statFile(filePath)
.then(
function(file) {
var page = Page.createForFile(file);
return parsePage(book, page);
},
function(err) {
// file doesn't exist
return null;
}
)
.fail(function(err) {
var logger = book.getLogger();
logger.error.ln('error while parsing page "' + filePath + '":');
throw err;
});
} | [
"function",
"parseFilePage",
"(",
"book",
",",
"filePath",
")",
"{",
"var",
"fs",
"=",
"book",
".",
"getContentFS",
"(",
")",
";",
"return",
"fs",
".",
"statFile",
"(",
"filePath",
")",
".",
"then",
"(",
"function",
"(",
"file",
")",
"{",
"var",
"pag... | Parse a page from a path
@param {Book} book
@param {String} filePath
@return {Page?} | [
"Parse",
"a",
"page",
"from",
"a",
"path"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parsePagesList.js#L16-L35 | train | Parse a page from a file | [
30522,
3853,
11968,
20106,
9463,
13704,
1006,
2338,
1010,
5371,
15069,
1007,
1063,
13075,
1042,
2015,
1027,
2338,
1012,
2131,
8663,
6528,
24475,
2015,
1006,
1007,
1025,
2709,
1042,
2015,
1012,
28093,
8873,
2571,
1006,
5371,
15069,
1007,
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... |
openlayers/openlayers | examples/webpack/example-builder.js | createWordIndex | function createWordIndex(exampleData) {
const index = {};
const keys = ['shortdesc', 'title', 'tags'];
exampleData.forEach((data, i) => {
keys.forEach(key => {
let text = data[key];
if (Array.isArray(text)) {
text = text.join(' ');
}
const words = text ? text.split(/\W+/) : [];
words.forEach(word => {
if (word) {
word = word.toLowerCase();
let counts = index[word];
if (counts) {
if (index in counts) {
counts[i] += 1;
} else {
counts[i] = 1;
}
} else {
counts = {};
counts[i] = 1;
index[word] = counts;
}
}
});
});
});
return index;
} | javascript | function createWordIndex(exampleData) {
const index = {};
const keys = ['shortdesc', 'title', 'tags'];
exampleData.forEach((data, i) => {
keys.forEach(key => {
let text = data[key];
if (Array.isArray(text)) {
text = text.join(' ');
}
const words = text ? text.split(/\W+/) : [];
words.forEach(word => {
if (word) {
word = word.toLowerCase();
let counts = index[word];
if (counts) {
if (index in counts) {
counts[i] += 1;
} else {
counts[i] = 1;
}
} else {
counts = {};
counts[i] = 1;
index[word] = counts;
}
}
});
});
});
return index;
} | [
"function",
"createWordIndex",
"(",
"exampleData",
")",
"{",
"const",
"index",
"=",
"{",
"}",
";",
"const",
"keys",
"=",
"[",
"'shortdesc'",
",",
"'title'",
",",
"'tags'",
"]",
";",
"exampleData",
".",
"forEach",
"(",
"(",
"data",
",",
"i",
")",
"=>",
... | Create an inverted index of keywords from examples. Property names are
lowercased words. Property values are objects mapping example index to word
count.
@param {Array<Object>} exampleData Array of example data objects.
@return {Object} Word index. | [
"Create",
"an",
"inverted",
"index",
"of",
"keywords",
"from",
"examples",
".",
"Property",
"names",
"are",
"lowercased",
"words",
".",
"Property",
"values",
"are",
"objects",
"mapping",
"example",
"index",
"to",
"word",
"count",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/webpack/example-builder.js#L33-L63 | train | Create word index | [
30522,
3853,
3443,
18351,
22254,
10288,
1006,
2742,
2850,
2696,
1007,
1063,
9530,
3367,
5950,
1027,
1063,
1065,
1025,
9530,
3367,
6309,
1027,
1031,
1005,
2460,
6155,
2278,
1005,
1010,
1005,
2516,
1005,
1010,
1005,
22073,
1005,
1033,
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... |
eslint/eslint | lib/code-path-analysis/debug-helpers.js | function(codePath) {
let text =
"\n" +
"digraph {\n" +
"node[shape=box,style=\"rounded,filled\",fillcolor=white];\n" +
"initial[label=\"\",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
if (codePath.returnedSegments.length > 0) {
text += "final[label=\"\",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
}
if (codePath.thrownSegments.length > 0) {
text += "thrown[label=\"✘\",shape=circle,width=0.3,height=0.3,fixedsize];\n";
}
const traceMap = Object.create(null);
const arrows = this.makeDotArrows(codePath, traceMap);
for (const id in traceMap) { // eslint-disable-line guard-for-in
const segment = traceMap[id];
text += `${id}[`;
if (segment.reachable) {
text += "label=\"";
} else {
text += "style=\"rounded,dashed,filled\",fillcolor=\"#FF9800\",label=\"<<unreachable>>\\n";
}
if (segment.internal.nodes.length > 0 || segment.internal.exitNodes.length > 0) {
text += [].concat(
segment.internal.nodes.map(node => {
switch (node.type) {
case "Identifier": return `${node.type} (${node.name})`;
case "Literal": return `${node.type} (${node.value})`;
default: return node.type;
}
}),
segment.internal.exitNodes.map(node => {
switch (node.type) {
case "Identifier": return `${node.type}:exit (${node.name})`;
case "Literal": return `${node.type}:exit (${node.value})`;
default: return `${node.type}:exit`;
}
})
).join("\\n");
} else {
text += "????";
}
text += "\"];\n";
}
text += `${arrows}\n`;
text += "}";
debug("DOT", text);
} | javascript | function(codePath) {
let text =
"\n" +
"digraph {\n" +
"node[shape=box,style=\"rounded,filled\",fillcolor=white];\n" +
"initial[label=\"\",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
if (codePath.returnedSegments.length > 0) {
text += "final[label=\"\",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
}
if (codePath.thrownSegments.length > 0) {
text += "thrown[label=\"✘\",shape=circle,width=0.3,height=0.3,fixedsize];\n";
}
const traceMap = Object.create(null);
const arrows = this.makeDotArrows(codePath, traceMap);
for (const id in traceMap) { // eslint-disable-line guard-for-in
const segment = traceMap[id];
text += `${id}[`;
if (segment.reachable) {
text += "label=\"";
} else {
text += "style=\"rounded,dashed,filled\",fillcolor=\"#FF9800\",label=\"<<unreachable>>\\n";
}
if (segment.internal.nodes.length > 0 || segment.internal.exitNodes.length > 0) {
text += [].concat(
segment.internal.nodes.map(node => {
switch (node.type) {
case "Identifier": return `${node.type} (${node.name})`;
case "Literal": return `${node.type} (${node.value})`;
default: return node.type;
}
}),
segment.internal.exitNodes.map(node => {
switch (node.type) {
case "Identifier": return `${node.type}:exit (${node.name})`;
case "Literal": return `${node.type}:exit (${node.value})`;
default: return `${node.type}:exit`;
}
})
).join("\\n");
} else {
text += "????";
}
text += "\"];\n";
}
text += `${arrows}\n`;
text += "}";
debug("DOT", text);
} | [
"function",
"(",
"codePath",
")",
"{",
"let",
"text",
"=",
"\"\\n\"",
"+",
"\"digraph {\\n\"",
"+",
"\"node[shape=box,style=\\\"rounded,filled\\\",fillcolor=white];\\n\"",
"+",
"\"initial[label=\\\"\\\",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25];\\n\"",
";",
"i... | /* istanbul ignore next | [
"/",
"*",
"istanbul",
"ignore",
"next"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/code-path-analysis/debug-helpers.js#L82-L137 | train | Generate a text file for a code path. | [
30522,
3853,
1006,
3642,
15069,
1007,
1063,
2292,
3793,
1027,
1000,
1032,
1050,
1000,
1009,
1000,
10667,
24342,
1063,
1032,
1050,
1000,
1009,
1000,
13045,
1031,
4338,
1027,
3482,
1010,
2806,
1027,
1032,
1000,
8352,
1010,
3561,
1032,
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... | |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/downloads.js | getLocalFileFromNativePathOrUrl | function getLocalFileFromNativePathOrUrl(aPathOrUrl) {
if (aPathOrUrl.substring(0,7) == "file://") {
// if this is a URL, get the file from that
let ioSvc = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
// XXX it's possible that using a null char-set here is bad
const fileUrl = ioSvc.newURI(aPathOrUrl, null, null)
.QueryInterface(Ci.nsIFileURL);
return fileUrl.file.clone().QueryInterface(Ci.nsILocalFile);
} else {
// if it's a pathname, create the nsILocalFile directly
var f = new nsLocalFile(aPathOrUrl);
return f;
}
} | javascript | function getLocalFileFromNativePathOrUrl(aPathOrUrl) {
if (aPathOrUrl.substring(0,7) == "file://") {
// if this is a URL, get the file from that
let ioSvc = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
// XXX it's possible that using a null char-set here is bad
const fileUrl = ioSvc.newURI(aPathOrUrl, null, null)
.QueryInterface(Ci.nsIFileURL);
return fileUrl.file.clone().QueryInterface(Ci.nsILocalFile);
} else {
// if it's a pathname, create the nsILocalFile directly
var f = new nsLocalFile(aPathOrUrl);
return f;
}
} | [
"function",
"getLocalFileFromNativePathOrUrl",
"(",
"aPathOrUrl",
")",
"{",
"if",
"(",
"aPathOrUrl",
".",
"substring",
"(",
"0",
",",
"7",
")",
"==",
"\"file://\"",
")",
"{",
"// if this is a URL, get the file from that",
"let",
"ioSvc",
"=",
"Cc",
"[",
"\"@mozill... | Get a local file from a native path or URL
@param {string} aPathOrUrl
Native path or URL of the file
@see http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/downloads/content/downloads.js#1309 | [
"Get",
"a",
"local",
"file",
"from",
"a",
"native",
"path",
"or",
"URL"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/downloads.js#L386-L401 | train | Get the local file from a native path or a URL | [
30522,
3853,
2131,
4135,
9289,
8873,
2571,
19699,
5358,
19833,
3512,
15069,
2953,
3126,
2140,
1006,
9706,
8988,
2953,
3126,
2140,
1007,
1063,
2065,
1006,
9706,
8988,
2953,
3126,
2140,
1012,
4942,
3367,
4892,
1006,
1014,
1010,
1021,
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.ui.core/src/sap/ui/core/support/Support.js | _storeXMLModifications | function _storeXMLModifications() {
if (bHasLocalStorage) {
localStorage.setItem("sap-ui-support.aSupportXMLModifications/" + document.location.href, JSON.stringify(aSupportXMLModifications));
}
} | javascript | function _storeXMLModifications() {
if (bHasLocalStorage) {
localStorage.setItem("sap-ui-support.aSupportXMLModifications/" + document.location.href, JSON.stringify(aSupportXMLModifications));
}
} | [
"function",
"_storeXMLModifications",
"(",
")",
"{",
"if",
"(",
"bHasLocalStorage",
")",
"{",
"localStorage",
".",
"setItem",
"(",
"\"sap-ui-support.aSupportXMLModifications/\"",
"+",
"document",
".",
"location",
".",
"href",
",",
"JSON",
".",
"stringify",
"(",
"a... | store xml modification to local storage | [
"store",
"xml",
"modification",
"to",
"local",
"storage"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/support/Support.js#L652-L656 | train | Stores the XML modifications to the local storage. | [
30522,
3853,
1035,
3573,
2595,
19968,
5302,
4305,
10803,
2015,
1006,
1007,
1063,
2065,
1006,
1038,
14949,
4135,
9289,
23809,
4270,
1007,
1063,
10575,
4263,
4270,
1012,
2275,
4221,
2213,
1006,
1000,
20066,
1011,
21318,
1011,
2490,
1012,
2004... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
dimsemenov/PhotoSwipe | src/js/gestures.js | function(touch0, touch1) {
return Math.abs(touch0.x - touch1.x) < DOUBLE_TAP_RADIUS && Math.abs(touch0.y - touch1.y) < DOUBLE_TAP_RADIUS;
} | javascript | function(touch0, touch1) {
return Math.abs(touch0.x - touch1.x) < DOUBLE_TAP_RADIUS && Math.abs(touch0.y - touch1.y) < DOUBLE_TAP_RADIUS;
} | [
"function",
"(",
"touch0",
",",
"touch1",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"touch0",
".",
"x",
"-",
"touch1",
".",
"x",
")",
"<",
"DOUBLE_TAP_RADIUS",
"&&",
"Math",
".",
"abs",
"(",
"touch0",
".",
"y",
"-",
"touch1",
".",
"y",
")",
"<... | amount of pixels to drag to determine direction of swipe | [
"amount",
"of",
"pixels",
"to",
"drag",
"to",
"determine",
"direction",
"of",
"swipe"
] | 80607e12542a1a54ecefa837649e862b35dffd25 | https://github.com/dimsemenov/PhotoSwipe/blob/80607e12542a1a54ecefa837649e862b35dffd25/src/js/gestures.js#L56-L58 | train | Check if two touches are on the same screen | [
30522,
3853,
1006,
3543,
2692,
1010,
3543,
2487,
1007,
1063,
2709,
8785,
1012,
14689,
1006,
3543,
2692,
1012,
1060,
1011,
3543,
2487,
1012,
1060,
1007,
1026,
3313,
1035,
11112,
1035,
12177,
1004,
1004,
8785,
1012,
14689,
1006,
3543,
2692,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/multiline-comment-style.js | convertToStarredBlock | function convertToStarredBlock(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const starredLines = commentLinesList.map(line => `${initialOffset} *${line}`);
return `\n${starredLines.join("\n")}\n${initialOffset} `;
} | javascript | function convertToStarredBlock(firstComment, commentLinesList) {
const initialOffset = sourceCode.text.slice(firstComment.range[0] - firstComment.loc.start.column, firstComment.range[0]);
const starredLines = commentLinesList.map(line => `${initialOffset} *${line}`);
return `\n${starredLines.join("\n")}\n${initialOffset} `;
} | [
"function",
"convertToStarredBlock",
"(",
"firstComment",
",",
"commentLinesList",
")",
"{",
"const",
"initialOffset",
"=",
"sourceCode",
".",
"text",
".",
"slice",
"(",
"firstComment",
".",
"range",
"[",
"0",
"]",
"-",
"firstComment",
".",
"loc",
".",
"start"... | Converts a comment into starred-block form
@param {Token} firstComment The first comment of the group being converted
@param {string[]} commentLinesList A list of lines to appear in the new starred-block comment
@returns {string} A representation of the comment value in starred-block form, excluding start and end markers | [
"Converts",
"a",
"comment",
"into",
"starred",
"-",
"block",
"form"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/multiline-comment-style.js#L64-L69 | train | Converts a comment to a starred block | [
30522,
3853,
10463,
13122,
7559,
5596,
23467,
1006,
2034,
9006,
3672,
1010,
7615,
12735,
9863,
1007,
1063,
9530,
3367,
3988,
27475,
3388,
1027,
3120,
16044,
1012,
3793,
1012,
14704,
1006,
2034,
9006,
3672,
1012,
2846,
1031,
1014,
1033,
1011... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | examples/3d/js/camera.js | function() {
var hand = game.player.hand;
var steps = game.player.steps;
var scaleFactor = this.scale * 6;
// Calculate the position of each hand relative to the steps taken.
var xScale = Math.cos(steps * 2);
var yScale = Math.sin(steps * 4);
var bobX = xScale * scaleFactor;
var bobY = yScale * scaleFactor;
var x = (canvas.width - (hand.width * this.scale) + scaleFactor) + bobX;
var y = (canvas.height - (hand.height * this.scale) + scaleFactor) + bobY;
var w = hand.width * this.scale;
var h = hand.height * this.scale;
ctx.drawImage(hand.image, x, y, w, h);
} | javascript | function() {
var hand = game.player.hand;
var steps = game.player.steps;
var scaleFactor = this.scale * 6;
// Calculate the position of each hand relative to the steps taken.
var xScale = Math.cos(steps * 2);
var yScale = Math.sin(steps * 4);
var bobX = xScale * scaleFactor;
var bobY = yScale * scaleFactor;
var x = (canvas.width - (hand.width * this.scale) + scaleFactor) + bobX;
var y = (canvas.height - (hand.height * this.scale) + scaleFactor) + bobY;
var w = hand.width * this.scale;
var h = hand.height * this.scale;
ctx.drawImage(hand.image, x, y, w, h);
} | [
"function",
"(",
")",
"{",
"var",
"hand",
"=",
"game",
".",
"player",
".",
"hand",
";",
"var",
"steps",
"=",
"game",
".",
"player",
".",
"steps",
";",
"var",
"scaleFactor",
"=",
"this",
".",
"scale",
"*",
"6",
";",
"// Calculate the position of each hand... | Draw the hand holding the gun and implement a "bobbing" to simulate walking. | [
"Draw",
"the",
"hand",
"holding",
"the",
"gun",
"and",
"implement",
"a",
"bobbing",
"to",
"simulate",
"walking",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/3d/js/camera.js#L118-L134 | train | Draw the hand | [
30522,
3853,
1006,
1007,
1063,
13075,
2192,
1027,
2208,
1012,
2447,
1012,
2192,
1025,
13075,
4084,
1027,
2208,
1012,
2447,
1012,
4084,
1025,
13075,
4094,
7011,
16761,
1027,
2023,
1012,
4094,
1008,
1020,
1025,
1013,
1013,
18422,
1996,
2597,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/menu/js/menuServiceProvider.js | focusMenuItem | function focusMenuItem(e, menuEl, opts, direction) {
var currentItem = $mdUtil.getClosest(e.target, 'MD-MENU-ITEM');
var items = $mdUtil.nodesToArray(menuEl[0].children);
var currentIndex = items.indexOf(currentItem);
// Traverse through our elements in the specified direction (+/-1) and try to
// focus them until we find one that accepts focus
var didFocus;
for (var i = currentIndex + direction; i >= 0 && i < items.length; i = i + direction) {
var focusTarget = items[i].querySelector('.md-button');
didFocus = attemptFocus(focusTarget);
if (didFocus) {
break;
}
}
return didFocus;
} | javascript | function focusMenuItem(e, menuEl, opts, direction) {
var currentItem = $mdUtil.getClosest(e.target, 'MD-MENU-ITEM');
var items = $mdUtil.nodesToArray(menuEl[0].children);
var currentIndex = items.indexOf(currentItem);
// Traverse through our elements in the specified direction (+/-1) and try to
// focus them until we find one that accepts focus
var didFocus;
for (var i = currentIndex + direction; i >= 0 && i < items.length; i = i + direction) {
var focusTarget = items[i].querySelector('.md-button');
didFocus = attemptFocus(focusTarget);
if (didFocus) {
break;
}
}
return didFocus;
} | [
"function",
"focusMenuItem",
"(",
"e",
",",
"menuEl",
",",
"opts",
",",
"direction",
")",
"{",
"var",
"currentItem",
"=",
"$mdUtil",
".",
"getClosest",
"(",
"e",
".",
"target",
",",
"'MD-MENU-ITEM'",
")",
";",
"var",
"items",
"=",
"$mdUtil",
".",
"nodesT... | Takes a keypress event and focuses the next/previous menu
item from the emitting element
@param {event} e - The origin keypress event
@param {angular.element} menuEl - The menu element
@param {object} opts - The interim element options for the mdMenu
@param {number} direction - The direction to move in (+1 = next, -1 = prev) | [
"Takes",
"a",
"keypress",
"event",
"and",
"focuses",
"the",
"next",
"/",
"previous",
"menu",
"item",
"from",
"the",
"emitting",
"element"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/menu/js/menuServiceProvider.js#L392-L409 | train | Focuses the specified menu item | [
30522,
3853,
3579,
3549,
14663,
6633,
1006,
1041,
1010,
12183,
2884,
1010,
23569,
2015,
1010,
3257,
1007,
1063,
13075,
2783,
4221,
2213,
1027,
1002,
9108,
21823,
2140,
1012,
2131,
20464,
27465,
2102,
1006,
1041,
1012,
4539,
1010,
1005,
9108... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/InPlaceEdit.js | updateControls | function updateControls(oInPlaceEdit){
var oContent = oInPlaceEdit.getContent();
if (!oContent) {
return;
}
var oTooltip = oContent.getTooltip();
switch (oContent.getMetadata().getName()) { // do not check with instanceof because then all classes must be loaded
case "sap.ui.commons.TextField":
case "sap.ui.commons.ComboBox":
case "sap.ui.commons.DropdownBox":
// use TextView for display
if (!oInPlaceEdit._oTextView) {
oInPlaceEdit._oTextView = new TextView(oInPlaceEdit.getId() + "--TV",{
wrapping: false});
oInPlaceEdit._oTextView.setParent(oInPlaceEdit);
// Make sure the delegate is not there twice
oInPlaceEdit._oTextView.removeDelegate(contentDelegate);
oInPlaceEdit._oTextView.addDelegate(contentDelegate, oInPlaceEdit);
oInPlaceEdit._oTextView.getTooltip = function(){
return this.getParent().getTooltip();
};
}
oInPlaceEdit._oTextView.setText(oContent.getValue());
oInPlaceEdit._oTextView.setEnabled(oContent.getEnabled());
oInPlaceEdit._oTextView.setTextDirection(oContent.getTextDirection());
oInPlaceEdit._oTextView.setVisible(oContent.getVisible());
oInPlaceEdit._oTextView.setWidth("100%"); // width is set on the outer DIV
oInPlaceEdit._oTextView.setTextAlign(oContent.getTextAlign());
oInPlaceEdit._oTextView.setDesign(oInPlaceEdit.getDesign());
oInPlaceEdit._oTextView.setHelpId(oContent.getHelpId());
oInPlaceEdit._oTextView.setAccessibleRole(oContent.getAccessibleRole());
if (oInPlaceEdit._oTextView._oTooltip && oInPlaceEdit._oTextView._oTooltip != oTooltip) {
oInPlaceEdit._oTextView.removeDelegate(oInPlaceEdit._oTextView._oTooltip);
oInPlaceEdit._oTextView._oTooltip = undefined;
}
if (oTooltip instanceof sap.ui.core.TooltipBase) {
if (!oInPlaceEdit._oTextView._oTooltip || oInPlaceEdit._oTextView._oTooltip != oTooltip) {
oInPlaceEdit._oTextView.addDelegate(oTooltip);
oInPlaceEdit._oTextView._oTooltip = oTooltip;
}
}
oInPlaceEdit._oDisplayControl = oInPlaceEdit._oTextView;
// use oContent for edit
oInPlaceEdit._oEditControl = oContent;
oInPlaceEdit._bUseEditButton = false;
break;
case "sap.ui.commons.Link":
// use Link for display
oInPlaceEdit._oDisplayControl = oContent;
// Make sure the delegate is not there twice
oInPlaceEdit._oDisplayControl.removeDelegate(contentDelegate);
oInPlaceEdit._oDisplayControl.addDelegate(contentDelegate, oInPlaceEdit);
// use TextField for edit
if (oInPlaceEdit._oTextField) {
oInPlaceEdit._oTextField.setValue(oContent.getText());
oInPlaceEdit._oTextField.setWidth("100%");
oInPlaceEdit._oEditControl = oInPlaceEdit._oTextField;
if (oInPlaceEdit._oTextField._oTooltip && oInPlaceEdit._oTextField._oTooltip != oTooltip) {
oInPlaceEdit._oTextField.removeDelegate(oInPlaceEdit._oTextField._oTooltip);
oInPlaceEdit._oTextField._oTooltip = undefined;
}
if (oTooltip instanceof sap.ui.core.TooltipBase) {
if (!oInPlaceEdit._oTextField._oTooltip || oInPlaceEdit._oTextField._oTooltip != oTooltip) {
oInPlaceEdit._oTextField.addDelegate(oTooltip);
oInPlaceEdit._oTextField._oTooltip = oTooltip;
}
}
}
// for link an edit button is needed to allow the link click
createEditButton(oInPlaceEdit);
oInPlaceEdit._bUseEditButton = true;
break;
default:
throw new Error("Control not supported for InPlaceEdit");
}
} | javascript | function updateControls(oInPlaceEdit){
var oContent = oInPlaceEdit.getContent();
if (!oContent) {
return;
}
var oTooltip = oContent.getTooltip();
switch (oContent.getMetadata().getName()) { // do not check with instanceof because then all classes must be loaded
case "sap.ui.commons.TextField":
case "sap.ui.commons.ComboBox":
case "sap.ui.commons.DropdownBox":
// use TextView for display
if (!oInPlaceEdit._oTextView) {
oInPlaceEdit._oTextView = new TextView(oInPlaceEdit.getId() + "--TV",{
wrapping: false});
oInPlaceEdit._oTextView.setParent(oInPlaceEdit);
// Make sure the delegate is not there twice
oInPlaceEdit._oTextView.removeDelegate(contentDelegate);
oInPlaceEdit._oTextView.addDelegate(contentDelegate, oInPlaceEdit);
oInPlaceEdit._oTextView.getTooltip = function(){
return this.getParent().getTooltip();
};
}
oInPlaceEdit._oTextView.setText(oContent.getValue());
oInPlaceEdit._oTextView.setEnabled(oContent.getEnabled());
oInPlaceEdit._oTextView.setTextDirection(oContent.getTextDirection());
oInPlaceEdit._oTextView.setVisible(oContent.getVisible());
oInPlaceEdit._oTextView.setWidth("100%"); // width is set on the outer DIV
oInPlaceEdit._oTextView.setTextAlign(oContent.getTextAlign());
oInPlaceEdit._oTextView.setDesign(oInPlaceEdit.getDesign());
oInPlaceEdit._oTextView.setHelpId(oContent.getHelpId());
oInPlaceEdit._oTextView.setAccessibleRole(oContent.getAccessibleRole());
if (oInPlaceEdit._oTextView._oTooltip && oInPlaceEdit._oTextView._oTooltip != oTooltip) {
oInPlaceEdit._oTextView.removeDelegate(oInPlaceEdit._oTextView._oTooltip);
oInPlaceEdit._oTextView._oTooltip = undefined;
}
if (oTooltip instanceof sap.ui.core.TooltipBase) {
if (!oInPlaceEdit._oTextView._oTooltip || oInPlaceEdit._oTextView._oTooltip != oTooltip) {
oInPlaceEdit._oTextView.addDelegate(oTooltip);
oInPlaceEdit._oTextView._oTooltip = oTooltip;
}
}
oInPlaceEdit._oDisplayControl = oInPlaceEdit._oTextView;
// use oContent for edit
oInPlaceEdit._oEditControl = oContent;
oInPlaceEdit._bUseEditButton = false;
break;
case "sap.ui.commons.Link":
// use Link for display
oInPlaceEdit._oDisplayControl = oContent;
// Make sure the delegate is not there twice
oInPlaceEdit._oDisplayControl.removeDelegate(contentDelegate);
oInPlaceEdit._oDisplayControl.addDelegate(contentDelegate, oInPlaceEdit);
// use TextField for edit
if (oInPlaceEdit._oTextField) {
oInPlaceEdit._oTextField.setValue(oContent.getText());
oInPlaceEdit._oTextField.setWidth("100%");
oInPlaceEdit._oEditControl = oInPlaceEdit._oTextField;
if (oInPlaceEdit._oTextField._oTooltip && oInPlaceEdit._oTextField._oTooltip != oTooltip) {
oInPlaceEdit._oTextField.removeDelegate(oInPlaceEdit._oTextField._oTooltip);
oInPlaceEdit._oTextField._oTooltip = undefined;
}
if (oTooltip instanceof sap.ui.core.TooltipBase) {
if (!oInPlaceEdit._oTextField._oTooltip || oInPlaceEdit._oTextField._oTooltip != oTooltip) {
oInPlaceEdit._oTextField.addDelegate(oTooltip);
oInPlaceEdit._oTextField._oTooltip = oTooltip;
}
}
}
// for link an edit button is needed to allow the link click
createEditButton(oInPlaceEdit);
oInPlaceEdit._bUseEditButton = true;
break;
default:
throw new Error("Control not supported for InPlaceEdit");
}
} | [
"function",
"updateControls",
"(",
"oInPlaceEdit",
")",
"{",
"var",
"oContent",
"=",
"oInPlaceEdit",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"!",
"oContent",
")",
"{",
"return",
";",
"}",
"var",
"oTooltip",
"=",
"oContent",
".",
"getTooltip",
"(",
"... | Private functions | [
"Private",
"functions"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/InPlaceEdit.js#L674-L763 | train | Updates the controls | [
30522,
3853,
10651,
8663,
13181,
4877,
1006,
1051,
2378,
24759,
10732,
2098,
4183,
1007,
1063,
13075,
1051,
8663,
6528,
2102,
1027,
1051,
2378,
24759,
10732,
2098,
4183,
1012,
2131,
8663,
6528,
2102,
1006,
1007,
1025,
2065,
1006,
999,
1051,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
dimsemenov/PhotoSwipe | src/js/gestures.js | function(e) {
// Allow dragging only via left mouse button.
// As this handler is not added in IE8 - we ignore e.which
//
// http://www.quirksmode.org/js/events_properties.html
// https://developer.mozilla.org/en-US/docs/Web/API/event.button
if(e.type === 'mousedown' && e.button > 0 ) {
return;
}
if(_initialZoomRunning) {
e.preventDefault();
return;
}
if(_oldAndroidTouchEndTimeout && e.type === 'mousedown') {
return;
}
if(_preventDefaultEventBehaviour(e, true)) {
e.preventDefault();
}
_shout('pointerDown');
if(_pointerEventEnabled) {
var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id');
if(pointerIndex < 0) {
pointerIndex = _currPointers.length;
}
_currPointers[pointerIndex] = {x:e.pageX, y:e.pageY, id: e.pointerId};
}
var startPointsList = _getTouchPoints(e),
numPoints = startPointsList.length;
_currentPoints = null;
_stopAllAnimations();
// init drag
if(!_isDragging || numPoints === 1) {
_isDragging = _isFirstMove = true;
framework.bind(window, _upMoveEvents, self);
_isZoomingIn =
_wasOverInitialZoom =
_opacityChanged =
_verticalDragInitiated =
_mainScrollShifted =
_moved =
_isMultitouch =
_zoomStarted = false;
_direction = null;
_shout('firstTouchStart', startPointsList);
_equalizePoints(_startPanOffset, _panOffset);
_currPanDist.x = _currPanDist.y = 0;
_equalizePoints(_currPoint, startPointsList[0]);
_equalizePoints(_startPoint, _currPoint);
//_equalizePoints(_startMainScrollPos, _mainScrollPos);
_startMainScrollPos.x = _slideSize.x * _currPositionIndex;
_posPoints = [{
x: _currPoint.x,
y: _currPoint.y
}];
_gestureCheckSpeedTime = _gestureStartTime = _getCurrentTime();
//_mainScrollAnimationEnd(true);
_calculatePanBounds( _currZoomLevel, true );
// Start rendering
_stopDragUpdateLoop();
_dragUpdateLoop();
}
// init zoom
if(!_isZooming && numPoints > 1 && !_mainScrollAnimating && !_mainScrollShifted) {
_startZoomLevel = _currZoomLevel;
_zoomStarted = false; // true if zoom changed at least once
_isZooming = _isMultitouch = true;
_currPanDist.y = _currPanDist.x = 0;
_equalizePoints(_startPanOffset, _panOffset);
_equalizePoints(p, startPointsList[0]);
_equalizePoints(p2, startPointsList[1]);
_findCenterOfPoints(p, p2, _currCenterPoint);
_midZoomPoint.x = Math.abs(_currCenterPoint.x) - _panOffset.x;
_midZoomPoint.y = Math.abs(_currCenterPoint.y) - _panOffset.y;
_currPointsDistance = _startPointsDistance = _calculatePointsDistance(p, p2);
}
} | javascript | function(e) {
// Allow dragging only via left mouse button.
// As this handler is not added in IE8 - we ignore e.which
//
// http://www.quirksmode.org/js/events_properties.html
// https://developer.mozilla.org/en-US/docs/Web/API/event.button
if(e.type === 'mousedown' && e.button > 0 ) {
return;
}
if(_initialZoomRunning) {
e.preventDefault();
return;
}
if(_oldAndroidTouchEndTimeout && e.type === 'mousedown') {
return;
}
if(_preventDefaultEventBehaviour(e, true)) {
e.preventDefault();
}
_shout('pointerDown');
if(_pointerEventEnabled) {
var pointerIndex = framework.arraySearch(_currPointers, e.pointerId, 'id');
if(pointerIndex < 0) {
pointerIndex = _currPointers.length;
}
_currPointers[pointerIndex] = {x:e.pageX, y:e.pageY, id: e.pointerId};
}
var startPointsList = _getTouchPoints(e),
numPoints = startPointsList.length;
_currentPoints = null;
_stopAllAnimations();
// init drag
if(!_isDragging || numPoints === 1) {
_isDragging = _isFirstMove = true;
framework.bind(window, _upMoveEvents, self);
_isZoomingIn =
_wasOverInitialZoom =
_opacityChanged =
_verticalDragInitiated =
_mainScrollShifted =
_moved =
_isMultitouch =
_zoomStarted = false;
_direction = null;
_shout('firstTouchStart', startPointsList);
_equalizePoints(_startPanOffset, _panOffset);
_currPanDist.x = _currPanDist.y = 0;
_equalizePoints(_currPoint, startPointsList[0]);
_equalizePoints(_startPoint, _currPoint);
//_equalizePoints(_startMainScrollPos, _mainScrollPos);
_startMainScrollPos.x = _slideSize.x * _currPositionIndex;
_posPoints = [{
x: _currPoint.x,
y: _currPoint.y
}];
_gestureCheckSpeedTime = _gestureStartTime = _getCurrentTime();
//_mainScrollAnimationEnd(true);
_calculatePanBounds( _currZoomLevel, true );
// Start rendering
_stopDragUpdateLoop();
_dragUpdateLoop();
}
// init zoom
if(!_isZooming && numPoints > 1 && !_mainScrollAnimating && !_mainScrollShifted) {
_startZoomLevel = _currZoomLevel;
_zoomStarted = false; // true if zoom changed at least once
_isZooming = _isMultitouch = true;
_currPanDist.y = _currPanDist.x = 0;
_equalizePoints(_startPanOffset, _panOffset);
_equalizePoints(p, startPointsList[0]);
_equalizePoints(p2, startPointsList[1]);
_findCenterOfPoints(p, p2, _currCenterPoint);
_midZoomPoint.x = Math.abs(_currCenterPoint.x) - _panOffset.x;
_midZoomPoint.y = Math.abs(_currCenterPoint.y) - _panOffset.y;
_currPointsDistance = _startPointsDistance = _calculatePointsDistance(p, p2);
}
} | [
"function",
"(",
"e",
")",
"{",
"// Allow dragging only via left mouse button.",
"// As this handler is not added in IE8 - we ignore e.which",
"// ",
"// http://www.quirksmode.org/js/events_properties.html",
"// https://developer.mozilla.org/en-US/docs/Web/API/event.button",
"if",
"(",
"e",
... | amount of pixels to drag to determine direction of swipe | [
"amount",
"of",
"pixels",
"to",
"drag",
"to",
"determine",
"direction",
"of",
"swipe"
] | 80607e12542a1a54ecefa837649e862b35dffd25 | https://github.com/dimsemenov/PhotoSwipe/blob/80607e12542a1a54ecefa837649e862b35dffd25/src/js/gestures.js#L295-L407 | train | The mouse move event handler | [
30522,
3853,
1006,
1041,
1007,
1063,
1013,
1013,
3499,
11920,
2069,
3081,
2187,
8000,
6462,
1012,
1013,
1013,
2004,
2023,
28213,
2003,
2025,
2794,
1999,
29464,
2620,
1011,
2057,
8568,
1041,
1012,
2029,
1013,
1013,
1013,
1013,
8299,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
KaTeX/KaTeX | dockers/screenshotter/screenshotter.js | execFile | function execFile(cmd, args, opts) {
return new Promise(function(resolve, reject) {
childProcess.execFile(cmd, args, opts, function(err, stdout, stderr) {
if (err) {
console.error("Error executing " + cmd + " " + args.join(" "));
console.error(stdout + stderr);
err.stdout = stdout;
err.stderr = stderr;
reject(err);
} else {
resolve(stdout);
}
});
});
} | javascript | function execFile(cmd, args, opts) {
return new Promise(function(resolve, reject) {
childProcess.execFile(cmd, args, opts, function(err, stdout, stderr) {
if (err) {
console.error("Error executing " + cmd + " " + args.join(" "));
console.error(stdout + stderr);
err.stdout = stdout;
err.stderr = stderr;
reject(err);
} else {
resolve(stdout);
}
});
});
} | [
"function",
"execFile",
"(",
"cmd",
",",
"args",
",",
"opts",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"childProcess",
".",
"execFile",
"(",
"cmd",
",",
"args",
",",
"opts",
",",
"function",
"(",
... | Execute a given command, and return a promise to its output. | [
"Execute",
"a",
"given",
"command",
"and",
"return",
"a",
"promise",
"to",
"its",
"output",
"."
] | 17bfb247b88070267f3e5c7b21fe4a360fdf49d9 | https://github.com/KaTeX/KaTeX/blob/17bfb247b88070267f3e5c7b21fe4a360fdf49d9/dockers/screenshotter/screenshotter.js#L561-L575 | train | Exec a command | [
30522,
3853,
4654,
8586,
8873,
2571,
1006,
4642,
2094,
1010,
12098,
5620,
1010,
23569,
2015,
1007,
1063,
2709,
2047,
4872,
1006,
3853,
1006,
10663,
1010,
15454,
1007,
1063,
2775,
21572,
9623,
2015,
1012,
4654,
8586,
8873,
2571,
1006,
4642,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/downloads.js | downloadManager_getElement | function downloadManager_getElement(spec) {
var elem = null;
switch(spec.type) {
/**
* subtype: subtype of property to match
* value: value of property to match
*/
case "download":
// Use a temporary lookup to get the download item
var download = new elementslib.Lookup(this._controller.window.document,
'/id("downloadManager")/id("downloadView")/' +
'{"' + spec.subtype + '":"' + spec.value + '"}');
this._controller.waitForElement(download, gTimeout);
// Use its download id to construct the real lookup expression
elem = new elementslib.Lookup(this._controller.window.document,
'/id("downloadManager")/id("downloadView")/' +
'id("' + download.getNode().getAttribute('id') + '")');
break;
/**
* subtype: Identifier of the specified download button (cancel, pause, resume, retry)
* value: Entry (download) of the download list
*/
case "download_button":
// XXX: Bug 555347 - There are outstanding events to process
this._controller.sleep(0);
elem = new elementslib.Lookup(this._controller.window.document, spec.value.expression +
'/anon({"flex":"1"})/[1]/[1]/{"cmd":"cmd_' + spec.subtype + '"}');
break;
default:
throw new Error(arguments.callee.name + ": Unknown element type - " + spec.type);
}
return elem;
} | javascript | function downloadManager_getElement(spec) {
var elem = null;
switch(spec.type) {
/**
* subtype: subtype of property to match
* value: value of property to match
*/
case "download":
// Use a temporary lookup to get the download item
var download = new elementslib.Lookup(this._controller.window.document,
'/id("downloadManager")/id("downloadView")/' +
'{"' + spec.subtype + '":"' + spec.value + '"}');
this._controller.waitForElement(download, gTimeout);
// Use its download id to construct the real lookup expression
elem = new elementslib.Lookup(this._controller.window.document,
'/id("downloadManager")/id("downloadView")/' +
'id("' + download.getNode().getAttribute('id') + '")');
break;
/**
* subtype: Identifier of the specified download button (cancel, pause, resume, retry)
* value: Entry (download) of the download list
*/
case "download_button":
// XXX: Bug 555347 - There are outstanding events to process
this._controller.sleep(0);
elem = new elementslib.Lookup(this._controller.window.document, spec.value.expression +
'/anon({"flex":"1"})/[1]/[1]/{"cmd":"cmd_' + spec.subtype + '"}');
break;
default:
throw new Error(arguments.callee.name + ": Unknown element type - " + spec.type);
}
return elem;
} | [
"function",
"downloadManager_getElement",
"(",
"spec",
")",
"{",
"var",
"elem",
"=",
"null",
";",
"switch",
"(",
"spec",
".",
"type",
")",
"{",
"/**\n * subtype: subtype of property to match\n * value: value of property to match\n */",
"case",
"\"download\""... | 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/downloads.js#L255-L292 | train | Returns the element that matches the specified specification | [
30522,
3853,
8816,
24805,
4590,
1035,
2131,
12260,
3672,
1006,
28699,
1007,
1063,
13075,
3449,
6633,
1027,
19701,
1025,
6942,
1006,
28699,
1012,
2828,
1007,
1063,
1013,
1008,
1008,
1008,
4942,
13874,
1024,
4942,
13874,
1997,
3200,
2000,
267... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/keyword-spacing.js | checkSpacingForTryStatement | function checkSpacingForTryStatement(node) {
checkSpacingAroundFirstToken(node);
checkSpacingAroundFirstToken(node.handler);
checkSpacingAroundTokenBefore(node.finalizer);
} | javascript | function checkSpacingForTryStatement(node) {
checkSpacingAroundFirstToken(node);
checkSpacingAroundFirstToken(node.handler);
checkSpacingAroundTokenBefore(node.finalizer);
} | [
"function",
"checkSpacingForTryStatement",
"(",
"node",
")",
"{",
"checkSpacingAroundFirstToken",
"(",
"node",
")",
";",
"checkSpacingAroundFirstToken",
"(",
"node",
".",
"handler",
")",
";",
"checkSpacingAroundTokenBefore",
"(",
"node",
".",
"finalizer",
")",
";",
... | Reports `try`, `catch`, and `finally` keywords of a given node if usage
of spacing around those keywords is invalid.
@param {ASTNode} node - A node to report.
@returns {void} | [
"Reports",
"try",
"catch",
"and",
"finally",
"keywords",
"of",
"a",
"given",
"node",
"if",
"usage",
"of",
"spacing",
"around",
"those",
"keywords",
"is",
"invalid",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/keyword-spacing.js#L397-L401 | train | Check spacing around the first token of a try statement. | [
30522,
3853,
14148,
19498,
2075,
13028,
24769,
12259,
3672,
1006,
13045,
1007,
1063,
14148,
19498,
28234,
22494,
4859,
8873,
12096,
18715,
2368,
1006,
13045,
1007,
1025,
14148,
19498,
28234,
22494,
4859,
8873,
12096,
18715,
2368,
1006,
13045,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
juliangarnier/anime | lib/anime.js | rgbToRgba | function rgbToRgba(rgbValue) {
var rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(rgbValue);
return rgb ? ("rgba(" + (rgb[1]) + ",1)") : rgbValue;
} | javascript | function rgbToRgba(rgbValue) {
var rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(rgbValue);
return rgb ? ("rgba(" + (rgb[1]) + ",1)") : rgbValue;
} | [
"function",
"rgbToRgba",
"(",
"rgbValue",
")",
"{",
"var",
"rgb",
"=",
"/",
"rgb\\((\\d+,\\s*[\\d]+,\\s*[\\d]+)\\)",
"/",
"g",
".",
"exec",
"(",
"rgbValue",
")",
";",
"return",
"rgb",
"?",
"(",
"\"rgba(\"",
"+",
"(",
"rgb",
"[",
"1",
"]",
")",
"+",
"\"... | Colors | [
"Colors"
] | 875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a | https://github.com/juliangarnier/anime/blob/875a3d6745d4bff2e4c6ffe0e2d24aac3bf8a45a/lib/anime.js#L373-L376 | train | Converts a rgb value to a rgba value | [
30522,
3853,
1054,
18259,
4263,
18259,
30524,
1032,
1055,
1008,
1031,
1032,
1040,
1033,
1009,
1010,
1032,
1055,
1008,
1031,
1032,
1040,
1033,
1009,
1007,
1032,
1007,
1013,
1043,
1012,
4654,
8586,
1006,
1054,
18259,
10175,
5657,
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... |
jantimon/html-webpack-plugin | lib/compiler.js | hasOutDatedTemplateCache | function hasOutDatedTemplateCache (mainCompilation) {
const childCompiler = getChildCompiler(mainCompilation.compiler);
/**
* @type {WeakMap<HtmlWebpackChildCompiler, boolean>|undefined}
*/
let hasOutdatedChildCompilerDependenciesMap = hasOutdatedCompilationDependenciesMap.get(mainCompilation);
// Create map for childCompiler if none exist
if (!hasOutdatedChildCompilerDependenciesMap) {
hasOutdatedChildCompilerDependenciesMap = new WeakMap();
hasOutdatedCompilationDependenciesMap.set(mainCompilation, hasOutdatedChildCompilerDependenciesMap);
}
// Try to get the `checkChildCompilerCache` result from cache
let isOutdated = hasOutdatedChildCompilerDependenciesMap.get(childCompiler);
if (isOutdated !== undefined) {
return isOutdated;
}
// If `checkChildCompilerCache` has never been called for the given
// `mainCompilation` and `childCompiler` combination call it:
isOutdated = isChildCompilerCacheOutdated(mainCompilation, childCompiler);
hasOutdatedChildCompilerDependenciesMap.set(childCompiler, isOutdated);
return isOutdated;
} | javascript | function hasOutDatedTemplateCache (mainCompilation) {
const childCompiler = getChildCompiler(mainCompilation.compiler);
/**
* @type {WeakMap<HtmlWebpackChildCompiler, boolean>|undefined}
*/
let hasOutdatedChildCompilerDependenciesMap = hasOutdatedCompilationDependenciesMap.get(mainCompilation);
// Create map for childCompiler if none exist
if (!hasOutdatedChildCompilerDependenciesMap) {
hasOutdatedChildCompilerDependenciesMap = new WeakMap();
hasOutdatedCompilationDependenciesMap.set(mainCompilation, hasOutdatedChildCompilerDependenciesMap);
}
// Try to get the `checkChildCompilerCache` result from cache
let isOutdated = hasOutdatedChildCompilerDependenciesMap.get(childCompiler);
if (isOutdated !== undefined) {
return isOutdated;
}
// If `checkChildCompilerCache` has never been called for the given
// `mainCompilation` and `childCompiler` combination call it:
isOutdated = isChildCompilerCacheOutdated(mainCompilation, childCompiler);
hasOutdatedChildCompilerDependenciesMap.set(childCompiler, isOutdated);
return isOutdated;
} | [
"function",
"hasOutDatedTemplateCache",
"(",
"mainCompilation",
")",
"{",
"const",
"childCompiler",
"=",
"getChildCompiler",
"(",
"mainCompilation",
".",
"compiler",
")",
";",
"/**\n * @type {WeakMap<HtmlWebpackChildCompiler, boolean>|undefined}\n */",
"let",
"hasOutdatedChil... | Returns `true` if the file dependencies of the current childCompiler
for the given mainCompilation are outdated.
Uses the `hasOutdatedCompilationDependenciesMap` cache if possible.
@param {WebpackCompilation} mainCompilation
@returns {boolean} | [
"Returns",
"true",
"if",
"the",
"file",
"dependencies",
"of",
"the",
"current",
"childCompiler",
"for",
"the",
"given",
"mainCompilation",
"are",
"outdated",
"."
] | 38db64ae8805de37d038e0ee0f6dfa2a26e2163a | https://github.com/jantimon/html-webpack-plugin/blob/38db64ae8805de37d038e0ee0f6dfa2a26e2163a/lib/compiler.js#L303-L324 | train | Returns true if the given mainCompilation has been marked as outdated. | [
30522,
3853,
2038,
5833,
13701,
11927,
6633,
15725,
3540,
5403,
1006,
2364,
9006,
8197,
13490,
30524,
1027,
2131,
19339,
9006,
22090,
2099,
1006,
2364,
9006,
8197,
13490,
1012,
21624,
1007,
1025,
1013,
1008,
1008,
1008,
1030,
2828,
1063,
54... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.numeric.extensions.js | function (chrs, buffer, pos, strict, opts) {
if (chrs == "") return false;
if (!strict && pos <= 1 && buffer[0] === '0' && new RegExp("[\\d-]").test(chrs) && buffer.join('').length == 1) { //handle first char
buffer[0] = "";
return { "pos": 0 };
}
var cbuf = strict ? buffer.slice(0, pos) : buffer.slice();
cbuf.splice(pos, 0, chrs);
var bufferStr = cbuf.join('');
//strip groupseparator
var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
bufferStr = bufferStr.replace(new RegExp(escapedGroupSeparator, "g"), '');
var isValid = opts.regex.number(opts).test(bufferStr);
if (!isValid) {
//let's help the regex a bit
bufferStr += "0";
isValid = opts.regex.number(opts).test(bufferStr);
if (!isValid) {
//make a valid group
var lastGroupSeparator = bufferStr.lastIndexOf(opts.groupSeparator);
for (var i = bufferStr.length - lastGroupSeparator; i <= 3; i++) {
bufferStr += "0";
}
isValid = opts.regex.number(opts).test(bufferStr);
if (!isValid && !strict) {
if (chrs == opts.radixPoint) {
isValid = opts.regex.number(opts).test("0" + bufferStr + "0");
if (isValid) {
buffer[pos] = "0";
pos++;
return { "pos": pos };
}
}
}
}
}
if (isValid != false && !strict && chrs != opts.radixPoint) {
var newPos = opts.postFormat(buffer, pos, false, opts);
return { "pos": newPos };
}
return isValid;
} | javascript | function (chrs, buffer, pos, strict, opts) {
if (chrs == "") return false;
if (!strict && pos <= 1 && buffer[0] === '0' && new RegExp("[\\d-]").test(chrs) && buffer.join('').length == 1) { //handle first char
buffer[0] = "";
return { "pos": 0 };
}
var cbuf = strict ? buffer.slice(0, pos) : buffer.slice();
cbuf.splice(pos, 0, chrs);
var bufferStr = cbuf.join('');
//strip groupseparator
var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
bufferStr = bufferStr.replace(new RegExp(escapedGroupSeparator, "g"), '');
var isValid = opts.regex.number(opts).test(bufferStr);
if (!isValid) {
//let's help the regex a bit
bufferStr += "0";
isValid = opts.regex.number(opts).test(bufferStr);
if (!isValid) {
//make a valid group
var lastGroupSeparator = bufferStr.lastIndexOf(opts.groupSeparator);
for (var i = bufferStr.length - lastGroupSeparator; i <= 3; i++) {
bufferStr += "0";
}
isValid = opts.regex.number(opts).test(bufferStr);
if (!isValid && !strict) {
if (chrs == opts.radixPoint) {
isValid = opts.regex.number(opts).test("0" + bufferStr + "0");
if (isValid) {
buffer[pos] = "0";
pos++;
return { "pos": pos };
}
}
}
}
}
if (isValid != false && !strict && chrs != opts.radixPoint) {
var newPos = opts.postFormat(buffer, pos, false, opts);
return { "pos": newPos };
}
return isValid;
} | [
"function",
"(",
"chrs",
",",
"buffer",
",",
"pos",
",",
"strict",
",",
"opts",
")",
"{",
"if",
"(",
"chrs",
"==",
"\"\"",
")",
"return",
"false",
";",
"if",
"(",
"!",
"strict",
"&&",
"pos",
"<=",
"1",
"&&",
"buffer",
"[",
"0",
"]",
"===",
"'0'... | real number | [
"real",
"number"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/input-mask/jquery.inputmask.numeric.extensions.js#L110-L158 | train | check if a character is valid | [
30522,
3853,
1006,
10381,
2869,
1010,
17698,
1010,
13433,
2015,
1010,
9384,
1010,
23569,
2015,
1007,
1063,
2065,
1006,
10381,
2869,
1027,
1027,
1000,
1000,
1007,
2709,
6270,
1025,
2065,
1006,
999,
9384,
1004,
1004,
13433,
2015,
1026,
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... | |
lovell/sharp | lib/output.js | tile | function tile (tile) {
if (is.object(tile)) {
// Size of square tiles, in pixels
if (is.defined(tile.size)) {
if (is.integer(tile.size) && is.inRange(tile.size, 1, 8192)) {
this.options.tileSize = tile.size;
} else {
throw new Error('Invalid tile size (1 to 8192) ' + tile.size);
}
}
// Overlap of tiles, in pixels
if (is.defined(tile.overlap)) {
if (is.integer(tile.overlap) && is.inRange(tile.overlap, 0, 8192)) {
if (tile.overlap > this.options.tileSize) {
throw new Error('Tile overlap ' + tile.overlap + ' cannot be larger than tile size ' + this.options.tileSize);
}
this.options.tileOverlap = tile.overlap;
} else {
throw new Error('Invalid tile overlap (0 to 8192) ' + tile.overlap);
}
}
// Container
if (is.defined(tile.container)) {
if (is.string(tile.container) && is.inArray(tile.container, ['fs', 'zip'])) {
this.options.tileContainer = tile.container;
} else {
throw new Error('Invalid tile container ' + tile.container);
}
}
// Layout
if (is.defined(tile.layout)) {
if (is.string(tile.layout) && is.inArray(tile.layout, ['dz', 'google', 'zoomify'])) {
this.options.tileLayout = tile.layout;
} else {
throw new Error('Invalid tile layout ' + tile.layout);
}
}
// Angle of rotation,
if (is.defined(tile.angle)) {
if (is.integer(tile.angle) && !(tile.angle % 90)) {
this.options.tileAngle = tile.angle;
} else {
throw new Error('Unsupported angle: angle must be a positive/negative multiple of 90 ' + tile.angle);
}
}
// Depth of tiles
if (is.defined(tile.depth)) {
if (is.string(tile.depth) && is.inArray(tile.depth, ['onepixel', 'onetile', 'one'])) {
this.options.tileDepth = tile.depth;
} else {
throw new Error("Invalid tile depth '" + tile.depth + "', should be one of 'onepixel', 'onetile' or 'one'");
}
}
}
// Format
if (is.inArray(this.options.formatOut, ['jpeg', 'png', 'webp'])) {
this.options.tileFormat = this.options.formatOut;
} else if (this.options.formatOut !== 'input') {
throw new Error('Invalid tile format ' + this.options.formatOut);
}
return this._updateFormatOut('dz');
} | javascript | function tile (tile) {
if (is.object(tile)) {
// Size of square tiles, in pixels
if (is.defined(tile.size)) {
if (is.integer(tile.size) && is.inRange(tile.size, 1, 8192)) {
this.options.tileSize = tile.size;
} else {
throw new Error('Invalid tile size (1 to 8192) ' + tile.size);
}
}
// Overlap of tiles, in pixels
if (is.defined(tile.overlap)) {
if (is.integer(tile.overlap) && is.inRange(tile.overlap, 0, 8192)) {
if (tile.overlap > this.options.tileSize) {
throw new Error('Tile overlap ' + tile.overlap + ' cannot be larger than tile size ' + this.options.tileSize);
}
this.options.tileOverlap = tile.overlap;
} else {
throw new Error('Invalid tile overlap (0 to 8192) ' + tile.overlap);
}
}
// Container
if (is.defined(tile.container)) {
if (is.string(tile.container) && is.inArray(tile.container, ['fs', 'zip'])) {
this.options.tileContainer = tile.container;
} else {
throw new Error('Invalid tile container ' + tile.container);
}
}
// Layout
if (is.defined(tile.layout)) {
if (is.string(tile.layout) && is.inArray(tile.layout, ['dz', 'google', 'zoomify'])) {
this.options.tileLayout = tile.layout;
} else {
throw new Error('Invalid tile layout ' + tile.layout);
}
}
// Angle of rotation,
if (is.defined(tile.angle)) {
if (is.integer(tile.angle) && !(tile.angle % 90)) {
this.options.tileAngle = tile.angle;
} else {
throw new Error('Unsupported angle: angle must be a positive/negative multiple of 90 ' + tile.angle);
}
}
// Depth of tiles
if (is.defined(tile.depth)) {
if (is.string(tile.depth) && is.inArray(tile.depth, ['onepixel', 'onetile', 'one'])) {
this.options.tileDepth = tile.depth;
} else {
throw new Error("Invalid tile depth '" + tile.depth + "', should be one of 'onepixel', 'onetile' or 'one'");
}
}
}
// Format
if (is.inArray(this.options.formatOut, ['jpeg', 'png', 'webp'])) {
this.options.tileFormat = this.options.formatOut;
} else if (this.options.formatOut !== 'input') {
throw new Error('Invalid tile format ' + this.options.formatOut);
}
return this._updateFormatOut('dz');
} | [
"function",
"tile",
"(",
"tile",
")",
"{",
"if",
"(",
"is",
".",
"object",
"(",
"tile",
")",
")",
"{",
"// Size of square tiles, in pixels",
"if",
"(",
"is",
".",
"defined",
"(",
"tile",
".",
"size",
")",
")",
"{",
"if",
"(",
"is",
".",
"integer",
... | Use tile-based deep zoom (image pyramid) output.
Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions.
Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format.
Warning: multiple sharp instances concurrently producing tile output can expose a possible race condition in some versions of libgsf.
@example
sharp('input.tiff')
.png()
.tile({
size: 512
})
.toFile('output.dz', function(err, info) {
// output.dzi is the Deep Zoom XML definition
// output_files contains 512x512 tiles grouped by zoom level
});
@param {Object} [tile]
@param {Number} [tile.size=256] tile size in pixels, a value between 1 and 8192.
@param {Number} [tile.overlap=0] tile overlap in pixels, a value between 0 and 8192.
@param {Number} [tile.angle=0] tile angle of rotation, must be a multiple of 90.
@param {String} [tile.depth] how deep to make the pyramid, possible values are `onepixel`, `onetile` or `one`, default based on layout.
@param {String} [tile.container='fs'] tile container, with value `fs` (filesystem) or `zip` (compressed file).
@param {String} [tile.layout='dz'] filesystem layout, possible values are `dz`, `zoomify` or `google`.
@returns {Sharp}
@throws {Error} Invalid parameters | [
"Use",
"tile",
"-",
"based",
"deep",
"zoom",
"(",
"image",
"pyramid",
")",
"output",
".",
"Set",
"the",
"format",
"and",
"options",
"for",
"tile",
"images",
"via",
"the",
"toFormat",
"jpeg",
"png",
"or",
"webp",
"functions",
".",
"Use",
"a",
".",
"zip"... | 05d76eeadfe54713606a615185b2da047923406b | https://github.com/lovell/sharp/blob/05d76eeadfe54713606a615185b2da047923406b/lib/output.js#L500-L564 | train | Sets the options for a single tile | [
30522,
3853,
14090,
1006,
14090,
1007,
1063,
2065,
1006,
2003,
1012,
4874,
1006,
14090,
1007,
1007,
1063,
1013,
1013,
2946,
1997,
2675,
13262,
1010,
1999,
27725,
2065,
1006,
2003,
1012,
4225,
1006,
14090,
1012,
2946,
1007,
1007,
1063,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/less.js | function (env, op, other) {
var rgb = [];
var alpha = this.alpha * (1 - other.alpha) + other.alpha;
for (var c = 0; c < 3; c++) {
rgb[c] = tree.operate(env, op, this.rgb[c], other.rgb[c]);
}
return new(tree.Color)(rgb, alpha);
} | javascript | function (env, op, other) {
var rgb = [];
var alpha = this.alpha * (1 - other.alpha) + other.alpha;
for (var c = 0; c < 3; c++) {
rgb[c] = tree.operate(env, op, this.rgb[c], other.rgb[c]);
}
return new(tree.Color)(rgb, alpha);
} | [
"function",
"(",
"env",
",",
"op",
",",
"other",
")",
"{",
"var",
"rgb",
"=",
"[",
"]",
";",
"var",
"alpha",
"=",
"this",
".",
"alpha",
"*",
"(",
"1",
"-",
"other",
".",
"alpha",
")",
"+",
"other",
".",
"alpha",
";",
"for",
"(",
"var",
"c",
... | Operations have to be done per-channel, if not, channels will spill onto each other. Once we have our result, in the form of an integer triplet, we create a new Color node to hold the result. | [
"Operations",
"have",
"to",
"be",
"done",
"per",
"-",
"channel",
"if",
"not",
"channels",
"will",
"spill",
"onto",
"each",
"other",
".",
"Once",
"we",
"have",
"our",
"result",
"in",
"the",
"form",
"of",
"an",
"integer",
"triplet",
"we",
"create",
"a",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/less.js#L3238-L3245 | train | Returns the result of the operation | [
30522,
3853,
1006,
4372,
2615,
1010,
6728,
1010,
2060,
1007,
1063,
13075,
1054,
18259,
1027,
1031,
1033,
1025,
13075,
6541,
1027,
2023,
1012,
6541,
1008,
1006,
1015,
1011,
2060,
1012,
6541,
1007,
1009,
2060,
1012,
6541,
1025,
2005,
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... | |
openlayers/openlayers | src/ol/format/TopoJSON.js | readFeatureFromGeometry | function readFeatureFromGeometry(object, arcs, scale, translate, property, name, opt_options) {
let geometry;
const type = object.type;
const geometryReader = GEOMETRY_READERS[type];
if ((type === 'Point') || (type === 'MultiPoint')) {
geometry = geometryReader(object, scale, translate);
} else {
geometry = geometryReader(object, arcs);
}
const feature = new Feature();
feature.setGeometry(transformGeometryWithOptions(geometry, false, opt_options));
if (object.id !== undefined) {
feature.setId(object.id);
}
let properties = object.properties;
if (property) {
if (!properties) {
properties = {};
}
properties[property] = name;
}
if (properties) {
feature.setProperties(properties, true);
}
return feature;
} | javascript | function readFeatureFromGeometry(object, arcs, scale, translate, property, name, opt_options) {
let geometry;
const type = object.type;
const geometryReader = GEOMETRY_READERS[type];
if ((type === 'Point') || (type === 'MultiPoint')) {
geometry = geometryReader(object, scale, translate);
} else {
geometry = geometryReader(object, arcs);
}
const feature = new Feature();
feature.setGeometry(transformGeometryWithOptions(geometry, false, opt_options));
if (object.id !== undefined) {
feature.setId(object.id);
}
let properties = object.properties;
if (property) {
if (!properties) {
properties = {};
}
properties[property] = name;
}
if (properties) {
feature.setProperties(properties, true);
}
return feature;
} | [
"function",
"readFeatureFromGeometry",
"(",
"object",
",",
"arcs",
",",
"scale",
",",
"translate",
",",
"property",
",",
"name",
",",
"opt_options",
")",
"{",
"let",
"geometry",
";",
"const",
"type",
"=",
"object",
".",
"type",
";",
"const",
"geometryReader"... | Create a feature from a TopoJSON geometry object.
@param {TopoJSONGeometry} object TopoJSON geometry object.
@param {Array<Array<import("../coordinate.js").Coordinate>>} arcs Array of arcs.
@param {Array<number>} scale Scale for each dimension.
@param {Array<number>} translate Translation for each dimension.
@param {string|undefined} property Property to set the `GeometryCollection`'s parent
object to.
@param {string} name Name of the `Topology`'s child object.
@param {import("./Feature.js").ReadOptions=} opt_options Read options.
@return {Feature} Feature. | [
"Create",
"a",
"feature",
"from",
"a",
"TopoJSON",
"geometry",
"object",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/TopoJSON.js#L331-L356 | train | Reads a feature from an object geometry | [
30522,
3853,
3191,
7959,
4017,
5397,
19699,
5358,
3351,
8462,
11129,
1006,
4874,
1010,
29137,
1010,
4094,
1010,
17637,
1010,
3200,
1010,
2171,
1010,
23569,
1035,
7047,
1007,
1063,
2292,
10988,
1025,
9530,
3367,
2828,
1027,
4874,
1012,
2828,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/TableUtils.js | function(oTable, row) {
if (isNaN(row)) {
var $Ref = jQuery(row);
row = parseInt($Ref.add($Ref.parent()).filter("[data-sap-ui-rowindex]").attr("data-sap-ui-rowindex"));
}
var iFixed = oTable.getFixedRowCount() || 0;
return row == iFixed;
} | javascript | function(oTable, row) {
if (isNaN(row)) {
var $Ref = jQuery(row);
row = parseInt($Ref.add($Ref.parent()).filter("[data-sap-ui-rowindex]").attr("data-sap-ui-rowindex"));
}
var iFixed = oTable.getFixedRowCount() || 0;
return row == iFixed;
} | [
"function",
"(",
"oTable",
",",
"row",
")",
"{",
"if",
"(",
"isNaN",
"(",
"row",
")",
")",
"{",
"var",
"$Ref",
"=",
"jQuery",
"(",
"row",
")",
";",
"row",
"=",
"parseInt",
"(",
"$Ref",
".",
"add",
"(",
"$Ref",
".",
"parent",
"(",
")",
")",
".... | Checks whether the cell of the given DOM reference is in the first row (from DOM point of view) of the scrollable area.
@param {sap.ui.table.Table} oTable Instance of the table.
@param {jQuery | HTMLElement | int} row Cell DOM reference or row index.
@returns {boolean} Whether the row is the first scrollable row of the table based on the data. | [
"Checks",
"whether",
"the",
"cell",
"of",
"the",
"given",
"DOM",
"reference",
"is",
"in",
"the",
"first",
"row",
"(",
"from",
"DOM",
"point",
"of",
"view",
")",
"of",
"the",
"scrollable",
"area",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/TableUtils.js#L993-L1000 | train | Returns true if the given row is a row of the table | [
30522,
3853,
1006,
27178,
3085,
1010,
5216,
1007,
1063,
2065,
1006,
3475,
2319,
1006,
5216,
1007,
1007,
1063,
13075,
1002,
25416,
1027,
1046,
4226,
2854,
1006,
5216,
1007,
1025,
5216,
1027,
30524,
1007,
1007,
1025,
1065,
13075,
2065,
7646,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/software-update.js | softwareUpdate_openDialog | function softwareUpdate_openDialog(browserController) {
// XXX: After Firefox 4 has been released and we do not have to test any
// beta release anymore uncomment out the following code
// With version >= 4.0b7pre the update dialog is reachable from within the
// about window now.
var appVersion = utils.appInfo.version;
if (this._vc.compare(appVersion, "4.0b7pre") >= 0) {
// XXX: We can't open the about window, otherwise a parallel download of
// the update will let us fallback to a complete one all the time
// Open the about window and check the update button
//var aboutItem = new elementslib.Elem(browserController.menus.helpMenu.aboutName);
//browserController.click(aboutItem);
//
//utils.handleWindow("type", "Browser:About", function(controller) {
// // XXX: Bug 599290 - Check for updates has been completely relocated
// // into the about window. We can't check the in-about ui yet.
// var updateButton = new elementslib.ID(controller.window.document,
// "checkForUpdatesButton");
// //controller.click(updateButton);
// controller.waitForElement(updateButton, gTimeout);
//});
// For now just call the old ui until we have support for the about window.
var updatePrompt = Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(Ci.nsIUpdatePrompt);
updatePrompt.checkForUpdates();
} else {
// For builds <4.0b7pre
updateItem = new elementslib.Elem(browserController.menus.helpMenu.checkForUpdates);
browserController.click(updateItem);
}
this.waitForDialogOpen(browserController);
} | javascript | function softwareUpdate_openDialog(browserController) {
// XXX: After Firefox 4 has been released and we do not have to test any
// beta release anymore uncomment out the following code
// With version >= 4.0b7pre the update dialog is reachable from within the
// about window now.
var appVersion = utils.appInfo.version;
if (this._vc.compare(appVersion, "4.0b7pre") >= 0) {
// XXX: We can't open the about window, otherwise a parallel download of
// the update will let us fallback to a complete one all the time
// Open the about window and check the update button
//var aboutItem = new elementslib.Elem(browserController.menus.helpMenu.aboutName);
//browserController.click(aboutItem);
//
//utils.handleWindow("type", "Browser:About", function(controller) {
// // XXX: Bug 599290 - Check for updates has been completely relocated
// // into the about window. We can't check the in-about ui yet.
// var updateButton = new elementslib.ID(controller.window.document,
// "checkForUpdatesButton");
// //controller.click(updateButton);
// controller.waitForElement(updateButton, gTimeout);
//});
// For now just call the old ui until we have support for the about window.
var updatePrompt = Cc["@mozilla.org/updates/update-prompt;1"].
createInstance(Ci.nsIUpdatePrompt);
updatePrompt.checkForUpdates();
} else {
// For builds <4.0b7pre
updateItem = new elementslib.Elem(browserController.menus.helpMenu.checkForUpdates);
browserController.click(updateItem);
}
this.waitForDialogOpen(browserController);
} | [
"function",
"softwareUpdate_openDialog",
"(",
"browserController",
")",
"{",
"// XXX: After Firefox 4 has been released and we do not have to test any",
"// beta release anymore uncomment out the following code",
"// With version >= 4.0b7pre the update dialog is reachable from within the",
"// abo... | Open software update dialog
@param {MozMillController} browserController
Mozmill controller of the browser window | [
"Open",
"software",
"update",
"dialog"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/software-update.js#L404-L440 | train | Open the software update dialog | [
30522,
3853,
4007,
6279,
13701,
1035,
2330,
27184,
8649,
1006,
16602,
8663,
13181,
10820,
1007,
1063,
1013,
1013,
22038,
2595,
1024,
2044,
2543,
14876,
2595,
1018,
2038,
2042,
2207,
1998,
2057,
2079,
2025,
2031,
2000,
3231,
2151,
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... |
adobe/brackets | src/document/DocumentManager.js | getOpenDocumentForPath | function getOpenDocumentForPath(fullPath) {
var id;
// Need to walk all open documents and check for matching path. We can't
// use getFileForPath(fullPath).id since the file it returns won't match
// an Untitled document's InMemoryFile.
for (id in _openDocuments) {
if (_openDocuments.hasOwnProperty(id)) {
if (_openDocuments[id].file.fullPath === fullPath) {
return _openDocuments[id];
}
}
}
return null;
} | javascript | function getOpenDocumentForPath(fullPath) {
var id;
// Need to walk all open documents and check for matching path. We can't
// use getFileForPath(fullPath).id since the file it returns won't match
// an Untitled document's InMemoryFile.
for (id in _openDocuments) {
if (_openDocuments.hasOwnProperty(id)) {
if (_openDocuments[id].file.fullPath === fullPath) {
return _openDocuments[id];
}
}
}
return null;
} | [
"function",
"getOpenDocumentForPath",
"(",
"fullPath",
")",
"{",
"var",
"id",
";",
"// Need to walk all open documents and check for matching path. We can't",
"// use getFileForPath(fullPath).id since the file it returns won't match",
"// an Untitled document's InMemoryFile.",
"for",
"(",
... | Returns the existing open Document for the given file, or null if the file is not open ('open'
means referenced by the UI somewhere). If you will hang onto the Document, you must addRef()
it; see {@link #getDocumentForPath} for details.
@param {!string} fullPath
@return {?Document} | [
"Returns",
"the",
"existing",
"open",
"Document",
"for",
"the",
"given",
"file",
"or",
"null",
"if",
"the",
"file",
"is",
"not",
"open",
"(",
"open",
"means",
"referenced",
"by",
"the",
"UI",
"somewhere",
")",
".",
"If",
"you",
"will",
"hang",
"onto",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/document/DocumentManager.js#L120-L134 | train | Get the document for a given path | [
30522,
3853,
2131,
26915,
3527,
24894,
4765,
29278,
15069,
1006,
2440,
15069,
1007,
1063,
13075,
8909,
1025,
1013,
1013,
2342,
2000,
3328,
2035,
2330,
5491,
1998,
4638,
2005,
9844,
4130,
1012,
2057,
2064,
1005,
1056,
1013,
1013,
2224,
2131,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/templating/listShortcuts.js | listShortcuts | function listShortcuts(blocks, filePath) {
var parser = parsers.getForFile(filePath);
if (!parser) {
return Immutable.List();
}
return blocks
.map(function(block) {
return block.getShortcuts();
})
.filter(function(shortcuts) {
return (
shortcuts &&
shortcuts.acceptParser(parser.getName())
);
});
} | javascript | function listShortcuts(blocks, filePath) {
var parser = parsers.getForFile(filePath);
if (!parser) {
return Immutable.List();
}
return blocks
.map(function(block) {
return block.getShortcuts();
})
.filter(function(shortcuts) {
return (
shortcuts &&
shortcuts.acceptParser(parser.getName())
);
});
} | [
"function",
"listShortcuts",
"(",
"blocks",
",",
"filePath",
")",
"{",
"var",
"parser",
"=",
"parsers",
".",
"getForFile",
"(",
"filePath",
")",
";",
"if",
"(",
"!",
"parser",
")",
"{",
"return",
"Immutable",
".",
"List",
"(",
")",
";",
"}",
"return",
... | Return a list of all shortcuts that can apply
to a file for a TemplatEngine
@param {List<TemplateBlock>} engine
@param {String} filePath
@return {List<TemplateShortcut>} | [
"Return",
"a",
"list",
"of",
"all",
"shortcuts",
"that",
"can",
"apply",
"to",
"a",
"file",
"for",
"a",
"TemplatEngine"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/templating/listShortcuts.js#L12-L29 | train | List all the shortcuts for a file | [
30522,
3853,
7201,
27794,
12690,
2015,
1006,
5991,
1010,
5371,
15069,
1007,
1063,
13075,
11968,
8043,
1027,
11968,
8043,
2015,
1012,
2131,
29278,
8873,
2571,
1006,
5371,
15069,
1007,
1025,
2065,
1006,
999,
11968,
8043,
1007,
1063,
2709,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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_comments_xml | function parse_comments_xml(data, opts) {
/* 18.7.6 CT_Comments */
if(data.match(/<(?:\w+:)?comments *\/>/)) return [];
var authors = [];
var commentList = [];
var authtag = data.match(/<(?:\w+:)?authors>([\s\S]*)<\/(?:\w+:)?authors>/);
if(authtag && authtag[1]) authtag[1].split(/<\/\w*:?author>/).forEach(function(x) {
if(x === "" || x.trim() === "") return;
var a = x.match(/<(?:\w+:)?author[^>]*>(.*)/);
if(a) authors.push(a[1]);
});
var cmnttag = data.match(/<(?:\w+:)?commentList>([\s\S]*)<\/(?:\w+:)?commentList>/);
if(cmnttag && cmnttag[1]) cmnttag[1].split(/<\/\w*:?comment>/).forEach(function(x) {
if(x === "" || x.trim() === "") return;
var cm = x.match(/<(?:\w+:)?comment[^>]*>/);
if(!cm) return;
var y = parsexmltag(cm[0]);
var comment = ({ author: y.authorId && authors[y.authorId] || "sheetjsghost", ref: y.ref, guid: y.guid });
var cell = decode_cell(y.ref);
if(opts.sheetRows && opts.sheetRows <= cell.r) return;
var textMatch = x.match(/<(?:\w+:)?text>([\s\S]*)<\/(?:\w+:)?text>/);
var rt = !!textMatch && !!textMatch[1] && parse_si(textMatch[1]) || {r:"",t:"",h:""};
comment.r = rt.r;
if(rt.r == "<t></t>") rt.t = rt.h = "";
comment.t = rt.t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");
if(opts.cellHTML) comment.h = rt.h;
commentList.push(comment);
});
return commentList;
} | javascript | function parse_comments_xml(data, opts) {
/* 18.7.6 CT_Comments */
if(data.match(/<(?:\w+:)?comments *\/>/)) return [];
var authors = [];
var commentList = [];
var authtag = data.match(/<(?:\w+:)?authors>([\s\S]*)<\/(?:\w+:)?authors>/);
if(authtag && authtag[1]) authtag[1].split(/<\/\w*:?author>/).forEach(function(x) {
if(x === "" || x.trim() === "") return;
var a = x.match(/<(?:\w+:)?author[^>]*>(.*)/);
if(a) authors.push(a[1]);
});
var cmnttag = data.match(/<(?:\w+:)?commentList>([\s\S]*)<\/(?:\w+:)?commentList>/);
if(cmnttag && cmnttag[1]) cmnttag[1].split(/<\/\w*:?comment>/).forEach(function(x) {
if(x === "" || x.trim() === "") return;
var cm = x.match(/<(?:\w+:)?comment[^>]*>/);
if(!cm) return;
var y = parsexmltag(cm[0]);
var comment = ({ author: y.authorId && authors[y.authorId] || "sheetjsghost", ref: y.ref, guid: y.guid });
var cell = decode_cell(y.ref);
if(opts.sheetRows && opts.sheetRows <= cell.r) return;
var textMatch = x.match(/<(?:\w+:)?text>([\s\S]*)<\/(?:\w+:)?text>/);
var rt = !!textMatch && !!textMatch[1] && parse_si(textMatch[1]) || {r:"",t:"",h:""};
comment.r = rt.r;
if(rt.r == "<t></t>") rt.t = rt.h = "";
comment.t = rt.t.replace(/\r\n/g,"\n").replace(/\r/g,"\n");
if(opts.cellHTML) comment.h = rt.h;
commentList.push(comment);
});
return commentList;
} | [
"function",
"parse_comments_xml",
"(",
"data",
",",
"opts",
")",
"{",
"/* 18.7.6 CT_Comments */",
"if",
"(",
"data",
".",
"match",
"(",
"/",
"<(?:\\w+:)?comments *\\/>",
"/",
")",
")",
"return",
"[",
"]",
";",
"var",
"authors",
"=",
"[",
"]",
";",
"var",
... | /* 18.7 Comments | [
"/",
"*",
"18",
".",
"7",
"Comments"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L9990-L10019 | train | Parse comments from XML | [
30522,
3853,
11968,
3366,
1035,
7928,
1035,
20950,
1006,
2951,
1010,
23569,
2015,
1007,
1063,
1013,
1008,
2324,
1012,
1021,
1012,
1020,
14931,
1035,
7928,
1008,
1013,
2065,
1006,
2951,
1012,
2674,
1006,
1013,
1026,
1006,
1029,
1024,
1032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/camera.js | function (oldData) {
var data = this.data;
var camera = this.camera;
// Update properties.
camera.aspect = data.aspect || (window.innerWidth / window.innerHeight);
camera.far = data.far;
camera.fov = data.fov;
camera.near = data.near;
camera.zoom = data.zoom;
camera.updateProjectionMatrix();
this.updateActiveCamera(oldData);
this.updateSpectatorCamera(oldData);
} | javascript | function (oldData) {
var data = this.data;
var camera = this.camera;
// Update properties.
camera.aspect = data.aspect || (window.innerWidth / window.innerHeight);
camera.far = data.far;
camera.fov = data.fov;
camera.near = data.near;
camera.zoom = data.zoom;
camera.updateProjectionMatrix();
this.updateActiveCamera(oldData);
this.updateSpectatorCamera(oldData);
} | [
"function",
"(",
"oldData",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"camera",
"=",
"this",
".",
"camera",
";",
"// Update properties.",
"camera",
".",
"aspect",
"=",
"data",
".",
"aspect",
"||",
"(",
"window",
".",
"innerWidth",
... | Update three.js camera. | [
"Update",
"three",
".",
"js",
"camera",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/camera.js#L34-L48 | train | Update camera properties | [
30522,
3853,
1006,
2214,
2850,
2696,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
4950,
1027,
2023,
1012,
4950,
1025,
1013,
1013,
10651,
5144,
1012,
4950,
1012,
7814,
1027,
2951,
1012,
7814,
1064,
1064,
1006,
3332,
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... | |
jhipster/generator-jhipster | generators/aws-containers/aws-client.js | createS3Bucket | function createS3Bucket(bucketName, region = DEFAULT_REGION) {
const createBuckerParams = {
Bucket: bucketName
};
return spinner(
new Promise((resolve, reject) =>
s3
.headBucket({
Bucket: bucketName
})
.promise()
.catch(error => {
if (error.code !== 'NotFound') {
reject(
new Error(
`The S3 Bucket ${chalk.bold(bucketName)} in region ${chalk.bold(
region
)} already exists and you don't have access to it. Error code: ${chalk.bold(error.code)}`
)
);
}
})
.then(() =>
s3
.createBucket(createBuckerParams)
.promise()
.then(resolve)
.catch(error =>
reject(
new Error(
`There was an error during the creation of the S3 Bucket ${chalk.bold(
bucketName
)} in region ${chalk.bold(region)}`
)
)
)
)
)
);
} | javascript | function createS3Bucket(bucketName, region = DEFAULT_REGION) {
const createBuckerParams = {
Bucket: bucketName
};
return spinner(
new Promise((resolve, reject) =>
s3
.headBucket({
Bucket: bucketName
})
.promise()
.catch(error => {
if (error.code !== 'NotFound') {
reject(
new Error(
`The S3 Bucket ${chalk.bold(bucketName)} in region ${chalk.bold(
region
)} already exists and you don't have access to it. Error code: ${chalk.bold(error.code)}`
)
);
}
})
.then(() =>
s3
.createBucket(createBuckerParams)
.promise()
.then(resolve)
.catch(error =>
reject(
new Error(
`There was an error during the creation of the S3 Bucket ${chalk.bold(
bucketName
)} in region ${chalk.bold(region)}`
)
)
)
)
)
);
} | [
"function",
"createS3Bucket",
"(",
"bucketName",
",",
"region",
"=",
"DEFAULT_REGION",
")",
"{",
"const",
"createBuckerParams",
"=",
"{",
"Bucket",
":",
"bucketName",
"}",
";",
"return",
"spinner",
"(",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
"... | Create a S3 Bucket in said region with said bucketBaseName.
the bucketBaseName will be used to create a
@param bucketName the name of the bucket to create.
@param region the region to create the bucket in.
@returns {Promise} | [
"Create",
"a",
"S3",
"Bucket",
"in",
"said",
"region",
"with",
"said",
"bucketBaseName",
".",
"the",
"bucketBaseName",
"will",
"be",
"used",
"to",
"create",
"a"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/aws-containers/aws-client.js#L264-L303 | train | Creates an S3 Bucket | [
30522,
3853,
9005,
2509,
24204,
3388,
1006,
13610,
18442,
1010,
2555,
1027,
12398,
1035,
2555,
1007,
1063,
9530,
3367,
3443,
24204,
2121,
28689,
5244,
1027,
1063,
13610,
1024,
13610,
18442,
1065,
1025,
2709,
6714,
3678,
1006,
2047,
4872,
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... |
babel/babel | packages/babel-helper-module-transforms/src/index.js | buildNamespaceReexport | function buildNamespaceReexport(metadata, namespace, loose) {
return (loose
? template.statement`
Object.keys(NAMESPACE).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
VERIFY_NAME_LIST;
EXPORTS[key] = NAMESPACE[key];
});
`
: template.statement`
Object.keys(NAMESPACE).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
VERIFY_NAME_LIST;
Object.defineProperty(EXPORTS, key, {
enumerable: true,
get: function() {
return NAMESPACE[key];
},
});
});
`)({
NAMESPACE: namespace,
EXPORTS: metadata.exportName,
VERIFY_NAME_LIST: metadata.exportNameListName
? template`
if (Object.prototype.hasOwnProperty.call(EXPORTS_LIST, key)) return;
`({ EXPORTS_LIST: metadata.exportNameListName })
: null,
});
} | javascript | function buildNamespaceReexport(metadata, namespace, loose) {
return (loose
? template.statement`
Object.keys(NAMESPACE).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
VERIFY_NAME_LIST;
EXPORTS[key] = NAMESPACE[key];
});
`
: template.statement`
Object.keys(NAMESPACE).forEach(function(key) {
if (key === "default" || key === "__esModule") return;
VERIFY_NAME_LIST;
Object.defineProperty(EXPORTS, key, {
enumerable: true,
get: function() {
return NAMESPACE[key];
},
});
});
`)({
NAMESPACE: namespace,
EXPORTS: metadata.exportName,
VERIFY_NAME_LIST: metadata.exportNameListName
? template`
if (Object.prototype.hasOwnProperty.call(EXPORTS_LIST, key)) return;
`({ EXPORTS_LIST: metadata.exportNameListName })
: null,
});
} | [
"function",
"buildNamespaceReexport",
"(",
"metadata",
",",
"namespace",
",",
"loose",
")",
"{",
"return",
"(",
"loose",
"?",
"template",
".",
"statement",
"`",
"`",
":",
"template",
".",
"statement",
"`",
"`",
")",
"(",
"{",
"NAMESPACE",
":",
"namespace",... | Create a re-export initialization loop for a specific imported namespace. | [
"Create",
"a",
"re",
"-",
"export",
"initialization",
"loop",
"for",
"a",
"specific",
"imported",
"namespace",
"."
] | 1969e6b6aa7d90be3fbb3aca98ea96849656a55a | https://github.com/babel/babel/blob/1969e6b6aa7d90be3fbb3aca98ea96849656a55a/packages/babel-helper-module-transforms/src/index.js#L231-L262 | train | Build a reexport statement for a namespace | [
30522,
3853,
3857,
18442,
23058,
9910,
2595,
6442,
1006,
27425,
1010,
3415,
15327,
1010,
6065,
1007,
1063,
2709,
1006,
6065,
1029,
23561,
1012,
4861,
1036,
4874,
1012,
6309,
1006,
3415,
15327,
1007,
1012,
18921,
6776,
1006,
3853,
1006,
3145... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
jiahaog/nativefier | src/helpers/convertToIcns.js | convertToIcns | function convertToIcns(pngSrc, icnsDest, callback) {
if (!isOSX()) {
callback('OSX is required to convert .png to .icns icon', pngSrc);
return;
}
shell.exec(
`"${PNG_TO_ICNS_BIN_PATH}" "${pngSrc}" "${icnsDest}"`,
{ silent: true },
(exitCode, stdOut, stdError) => {
if (stdOut.includes('icon.iconset:error') || exitCode) {
if (exitCode) {
callback(
{
stdOut,
stdError,
},
pngSrc,
);
return;
}
callback(stdOut, pngSrc);
return;
}
callback(null, icnsDest);
},
);
} | javascript | function convertToIcns(pngSrc, icnsDest, callback) {
if (!isOSX()) {
callback('OSX is required to convert .png to .icns icon', pngSrc);
return;
}
shell.exec(
`"${PNG_TO_ICNS_BIN_PATH}" "${pngSrc}" "${icnsDest}"`,
{ silent: true },
(exitCode, stdOut, stdError) => {
if (stdOut.includes('icon.iconset:error') || exitCode) {
if (exitCode) {
callback(
{
stdOut,
stdError,
},
pngSrc,
);
return;
}
callback(stdOut, pngSrc);
return;
}
callback(null, icnsDest);
},
);
} | [
"function",
"convertToIcns",
"(",
"pngSrc",
",",
"icnsDest",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"isOSX",
"(",
")",
")",
"{",
"callback",
"(",
"'OSX is required to convert .png to .icns icon'",
",",
"pngSrc",
")",
";",
"return",
";",
"}",
"shell",
"."... | @callback pngToIcnsCallback
@param error
@param {string} icnsDest If error, will return the original png src
@param {string} pngSrc
@param {string} icnsDest
@param {pngToIcnsCallback} callback | [
"@callback",
"pngToIcnsCallback",
"@param",
"error",
"@param",
"{",
"string",
"}",
"icnsDest",
"If",
"error",
"will",
"return",
"the",
"original",
"png",
"src"
] | b959956a38ce51a9dd95d42308f0a6c66489b624 | https://github.com/jiahaog/nativefier/blob/b959956a38ce51a9dd95d42308f0a6c66489b624/src/helpers/convertToIcns.js#L23-L52 | train | Convert. png to. icns | [
30522,
3853,
10463,
3406,
2594,
3619,
1006,
1052,
3070,
21338,
2278,
1010,
24582,
3619,
6155,
2102,
1010,
2655,
5963,
1007,
1063,
2065,
1006,
999,
11163,
2015,
2595,
1006,
1007,
1007,
1063,
2655,
5963,
1006,
1005,
9808,
2595,
2003,
3223,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
mdn/browser-compat-data | scripts/render.js | writeTable | function writeTable(browserPlatformType) {
let compatNotes = collectCompatNotes();
let output = writeTableHead(browserPlatformType);
output += '<tbody>';
for (let row of features) {
let feature = Object.keys(row).map((k) => row[k])[0];
let desc = '';
if (feature.description) {
let label = Object.keys(row)[0];
// Basic support or unnested features need no prefixing
if (label.indexOf('.') === -1) {
desc += feature.description;
// otherwise add a prefix so that we know where this belongs to (e.g. "parse: ISO 8601 format")
} else {
desc += `<code>${label.slice(0, label.lastIndexOf('.'))}</code>: ${feature.description}`;
}
} else {
desc += `<code>${Object.keys(row)[0]}</code>`;
}
if (feature.mdn_url) {
desc = `<a href="${feature.mdn_url}">${desc}</a>`;
}
output += `<tr><td>${desc}</td>`;
output += `${writeSupportCells(feature.support, compatNotes, browserPlatformType)}</tr>`;
}
output += '</tbody></table></div>';
return output;
} | javascript | function writeTable(browserPlatformType) {
let compatNotes = collectCompatNotes();
let output = writeTableHead(browserPlatformType);
output += '<tbody>';
for (let row of features) {
let feature = Object.keys(row).map((k) => row[k])[0];
let desc = '';
if (feature.description) {
let label = Object.keys(row)[0];
// Basic support or unnested features need no prefixing
if (label.indexOf('.') === -1) {
desc += feature.description;
// otherwise add a prefix so that we know where this belongs to (e.g. "parse: ISO 8601 format")
} else {
desc += `<code>${label.slice(0, label.lastIndexOf('.'))}</code>: ${feature.description}`;
}
} else {
desc += `<code>${Object.keys(row)[0]}</code>`;
}
if (feature.mdn_url) {
desc = `<a href="${feature.mdn_url}">${desc}</a>`;
}
output += `<tr><td>${desc}</td>`;
output += `${writeSupportCells(feature.support, compatNotes, browserPlatformType)}</tr>`;
}
output += '</tbody></table></div>';
return output;
} | [
"function",
"writeTable",
"(",
"browserPlatformType",
")",
"{",
"let",
"compatNotes",
"=",
"collectCompatNotes",
"(",
")",
";",
"let",
"output",
"=",
"writeTableHead",
"(",
"browserPlatformType",
")",
";",
"output",
"+=",
"'<tbody>'",
";",
"for",
"(",
"let",
"... | /*
Write compat table | [
"/",
"*",
"Write",
"compat",
"table"
] | 6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b | https://github.com/mdn/browser-compat-data/blob/6ca59b232e8fe080f441c7cb625d2bfd1a6fbe2b/scripts/render.js#L357-L384 | train | Writes a table of features | [
30522,
3853,
4339,
10880,
1006,
16602,
24759,
4017,
14192,
13874,
1007,
1063,
2292,
4012,
4502,
2102,
20564,
1027,
8145,
9006,
4502,
2102,
20564,
1006,
1007,
1025,
2292,
6434,
1027,
4339,
10880,
4974,
1006,
16602,
24759,
4017,
14192,
13874,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/jsunit/app/jsUnitCore.js | jsUnitFixTop | function jsUnitFixTop() {
var tempTop = top;
if (!tempTop) {
tempTop = window;
while (tempTop.parent) {
tempTop = tempTop.parent;
if (tempTop.top && tempTop.top.jsUnitTestSuite) {
tempTop = tempTop.top;
break;
}
}
}
try {
window.top = tempTop;
} catch (e) {
}
} | javascript | function jsUnitFixTop() {
var tempTop = top;
if (!tempTop) {
tempTop = window;
while (tempTop.parent) {
tempTop = tempTop.parent;
if (tempTop.top && tempTop.top.jsUnitTestSuite) {
tempTop = tempTop.top;
break;
}
}
}
try {
window.top = tempTop;
} catch (e) {
}
} | [
"function",
"jsUnitFixTop",
"(",
")",
"{",
"var",
"tempTop",
"=",
"top",
";",
"if",
"(",
"!",
"tempTop",
")",
"{",
"tempTop",
"=",
"window",
";",
"while",
"(",
"tempTop",
".",
"parent",
")",
"{",
"tempTop",
"=",
"tempTop",
".",
"parent",
";",
"if",
... | hack for NS62 bug | [
"hack",
"for",
"NS62",
"bug"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/jsunit/app/jsUnitCore.js#L6-L22 | train | jsUnitFixTop - Fixes top of window | [
30522,
3853,
1046,
19729,
4183,
8873,
18413,
7361,
1006,
1007,
1063,
13075,
8915,
27718,
7361,
1027,
2327,
1025,
2065,
1006,
999,
8915,
27718,
7361,
1007,
1063,
8915,
27718,
7361,
1027,
3332,
1025,
2096,
1006,
8915,
27718,
7361,
1012,
6687,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/zyngascroll.js | function() {
return Math.abs(self.__decelerationVelocityX) >= minVelocityToKeepDecelerating || Math.abs(self.__decelerationVelocityY) >= minVelocityToKeepDecelerating;
} | javascript | function() {
return Math.abs(self.__decelerationVelocityX) >= minVelocityToKeepDecelerating || Math.abs(self.__decelerationVelocityY) >= minVelocityToKeepDecelerating;
} | [
"function",
"(",
")",
"{",
"return",
"Math",
".",
"abs",
"(",
"self",
".",
"__decelerationVelocityX",
")",
">=",
"minVelocityToKeepDecelerating",
"||",
"Math",
".",
"abs",
"(",
"self",
".",
"__decelerationVelocityY",
")",
">=",
"minVelocityToKeepDecelerating",
";"... | Detect whether it's still worth to continue animating steps If we are already slow enough to not being user perceivable anymore, we stop the whole process here. | [
"Detect",
"whether",
"it",
"s",
"still",
"worth",
"to",
"continue",
"animating",
"steps",
"If",
"we",
"are",
"already",
"slow",
"enough",
"to",
"not",
"being",
"user",
"perceivable",
"anymore",
"we",
"stop",
"the",
"whole",
"process",
"here",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/zyngascroll.js#L1437-L1439 | train | Returns true if the deceleration is within the minVelocityToKeepDecelerating range | [
30522,
3853,
1006,
1007,
1063,
2709,
8785,
1012,
14689,
1006,
2969,
1012,
1035,
1035,
11703,
12260,
8156,
15985,
10085,
3012,
2595,
1007,
1028,
1027,
8117,
15985,
10085,
3012,
18715,
4402,
17299,
26005,
3917,
5844,
1064,
1064,
8785,
1012,
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.table/src/sap/ui/table/rules/TableHelper.support.js | function(oIssueManager, sText, sSeverity, sControlId) {
oIssueManager.addIssue({
severity: sSeverity || Severity.Medium,
details: sText,
context: {id: sControlId || "WEBPAGE"}
});
} | javascript | function(oIssueManager, sText, sSeverity, sControlId) {
oIssueManager.addIssue({
severity: sSeverity || Severity.Medium,
details: sText,
context: {id: sControlId || "WEBPAGE"}
});
} | [
"function",
"(",
"oIssueManager",
",",
"sText",
",",
"sSeverity",
",",
"sControlId",
")",
"{",
"oIssueManager",
".",
"addIssue",
"(",
"{",
"severity",
":",
"sSeverity",
"||",
"Severity",
".",
"Medium",
",",
"details",
":",
"sText",
",",
"context",
":",
"{"... | Adds an issue with the given text, severity and context to the given issue manager.
@param {sap.ui.support.IssueManager} oIssueManager The issue manager
@param {string} sText The text of the issue.
@param {sap.ui.support.Severity} [sSeverity] The severity of the issue, if nothing is given Warning is used.
@param {string} [sControlId] The id of the control the issue is related to. If nothing is given the "global" context is used. | [
"Adds",
"an",
"issue",
"with",
"the",
"given",
"text",
"severity",
"and",
"context",
"to",
"the",
"given",
"issue",
"manager",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.table/src/sap/ui/table/rules/TableHelper.support.js#L93-L99 | train | Adds an issue to the issue manager. | [
30522,
3853,
1006,
1051,
14643,
5657,
24805,
4590,
1010,
26261,
18413,
1010,
7020,
22507,
3012,
1010,
8040,
12162,
13153,
3593,
1007,
1063,
1051,
14643,
5657,
24805,
4590,
1012,
5587,
14643,
5657,
1006,
1063,
18976,
1024,
7020,
22507,
3012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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() {
var self = this || Howler;
// Create a global ID counter.
self._counter = 1000;
// Pool of unlocked HTML5 Audio objects.
self._html5AudioPool = [];
self.html5PoolSize = 10;
// Internal properties.
self._codecs = {};
self._howls = [];
self._muted = false;
self._volume = 1;
self._canPlayEvent = 'canplaythrough';
self._navigator = (typeof window !== 'undefined' && window.navigator) ? window.navigator : null;
// Public properties.
self.masterGain = null;
self.noAudio = false;
self.usingWebAudio = true;
self.autoSuspend = true;
self.ctx = null;
// Set to false to disable the auto audio unlocker.
self.autoUnlock = true;
// Setup the various state values for global tracking.
self._setup();
return self;
} | javascript | function() {
var self = this || Howler;
// Create a global ID counter.
self._counter = 1000;
// Pool of unlocked HTML5 Audio objects.
self._html5AudioPool = [];
self.html5PoolSize = 10;
// Internal properties.
self._codecs = {};
self._howls = [];
self._muted = false;
self._volume = 1;
self._canPlayEvent = 'canplaythrough';
self._navigator = (typeof window !== 'undefined' && window.navigator) ? window.navigator : null;
// Public properties.
self.masterGain = null;
self.noAudio = false;
self.usingWebAudio = true;
self.autoSuspend = true;
self.ctx = null;
// Set to false to disable the auto audio unlocker.
self.autoUnlock = true;
// Setup the various state values for global tracking.
self._setup();
return self;
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
"||",
"Howler",
";",
"// Create a global ID counter.",
"self",
".",
"_counter",
"=",
"1000",
";",
"// Pool of unlocked HTML5 Audio objects.",
"self",
".",
"_html5AudioPool",
"=",
"[",
"]",
";",
"self",
".",
... | Initialize the global Howler object.
@return {Howler} | [
"Initialize",
"the",
"global",
"Howler",
"object",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/dist/howler.js#L30-L62 | train | The howler class. | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1064,
1064,
22912,
2121,
1025,
1013,
1013,
3443,
1037,
3795,
8909,
4675,
1012,
2969,
1012,
1035,
4675,
1027,
6694,
1025,
1013,
1013,
4770,
1997,
14058,
16129,
2629,
5746,
5200,
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 | bits/88_write.js | write_zip_type | function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
var o = opts||{};
var z = write_zip(wb, o);
var oopts = {};
if(o.compression) oopts.compression = 'DEFLATE';
if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
else switch(o.type) {
case "base64": oopts.type = "base64"; break;
case "binary": oopts.type = "string"; break;
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
case "buffer":
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
default: throw new Error("Unrecognized type " + o.type);
}
var out = z.generate(oopts);
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out;
} | javascript | function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
var o = opts||{};
var z = write_zip(wb, o);
var oopts = {};
if(o.compression) oopts.compression = 'DEFLATE';
if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
else switch(o.type) {
case "base64": oopts.type = "base64"; break;
case "binary": oopts.type = "string"; break;
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
case "buffer":
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
default: throw new Error("Unrecognized type " + o.type);
}
var out = z.generate(oopts);
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out;
} | [
"function",
"write_zip_type",
"(",
"wb",
"/*:Workbook*/",
",",
"opts",
"/*:?WriteOpts*/",
")",
"/*:any*/",
"{",
"var",
"o",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"z",
"=",
"write_zip",
"(",
"wb",
",",
"o",
")",
";",
"var",
"oopts",
"=",
"{",
"}",
... | /*global encrypt_agile /*:: declare var encrypt_agile:any; | [
"/",
"*",
"global",
"encrypt_agile",
"/",
"*",
"::",
"declare",
"var",
"encrypt_agile",
":",
"any",
";"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/88_write.js#L14-L32 | train | Write the type of the zip file | [
30522,
3853,
4339,
1035,
14101,
1035,
2828,
1006,
25610,
1013,
1008,
1024,
2147,
8654,
1008,
1013,
1010,
23569,
2015,
1013,
1008,
1024,
1029,
4339,
7361,
3215,
1008,
1013,
1007,
1013,
1008,
1024,
2151,
1008,
1013,
1063,
13075,
1051,
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... |
aframevr/aframe | src/components/text.js | function () {
var data = this.data;
var el = this.el;
var fontSrc;
var geometry = this.geometry;
var self = this;
if (!data.font) { warn('No font specified. Using the default font.'); }
// Make invisible during font swap.
this.mesh.visible = false;
// Look up font URL to use, and perform cached load.
fontSrc = this.lookupFont(data.font || DEFAULT_FONT) || data.font;
cache.get(fontSrc, function doLoadFont () {
return loadFont(fontSrc, data.yOffset);
}).then(function setFont (font) {
var fontImgSrc;
if (font.pages.length !== 1) {
throw new Error('Currently only single-page bitmap fonts are supported.');
}
if (!fontWidthFactors[fontSrc]) {
font.widthFactor = fontWidthFactors[font] = computeFontWidthFactor(font);
}
// Update geometry given font metrics.
self.updateGeometry(geometry, font);
// Set font and update layout.
self.currentFont = font;
self.updateLayout();
// Look up font image URL to use, and perform cached load.
fontImgSrc = self.getFontImageSrc();
cache.get(fontImgSrc, function () {
return loadTexture(fontImgSrc);
}).then(function (image) {
// Make mesh visible and apply font image as texture.
var texture = self.texture;
texture.image = image;
texture.needsUpdate = true;
textures[data.font] = texture;
self.texture = texture;
self.mesh.visible = true;
el.emit('textfontset', {font: data.font, fontObj: font});
}).catch(function (err) {
error(err.message);
error(err.stack);
});
}).catch(function (err) {
error(err.message);
error(err.stack);
});
} | javascript | function () {
var data = this.data;
var el = this.el;
var fontSrc;
var geometry = this.geometry;
var self = this;
if (!data.font) { warn('No font specified. Using the default font.'); }
// Make invisible during font swap.
this.mesh.visible = false;
// Look up font URL to use, and perform cached load.
fontSrc = this.lookupFont(data.font || DEFAULT_FONT) || data.font;
cache.get(fontSrc, function doLoadFont () {
return loadFont(fontSrc, data.yOffset);
}).then(function setFont (font) {
var fontImgSrc;
if (font.pages.length !== 1) {
throw new Error('Currently only single-page bitmap fonts are supported.');
}
if (!fontWidthFactors[fontSrc]) {
font.widthFactor = fontWidthFactors[font] = computeFontWidthFactor(font);
}
// Update geometry given font metrics.
self.updateGeometry(geometry, font);
// Set font and update layout.
self.currentFont = font;
self.updateLayout();
// Look up font image URL to use, and perform cached load.
fontImgSrc = self.getFontImageSrc();
cache.get(fontImgSrc, function () {
return loadTexture(fontImgSrc);
}).then(function (image) {
// Make mesh visible and apply font image as texture.
var texture = self.texture;
texture.image = image;
texture.needsUpdate = true;
textures[data.font] = texture;
self.texture = texture;
self.mesh.visible = true;
el.emit('textfontset', {font: data.font, fontObj: font});
}).catch(function (err) {
error(err.message);
error(err.stack);
});
}).catch(function (err) {
error(err.message);
error(err.stack);
});
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"fontSrc",
";",
"var",
"geometry",
"=",
"this",
".",
"geometry",
";",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"da... | Load font for geometry, load font image for material, and apply. | [
"Load",
"font",
"for",
"geometry",
"load",
"font",
"image",
"for",
"material",
"and",
"apply",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/text.js#L194-L249 | train | Update the geometry and layout | [
30522,
3853,
1006,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
3449,
1027,
2023,
1012,
30524,
15489,
9675,
1012,
2478,
1996,
12398,
15489,
1012,
1005,
1007,
1025,
1065,
1013,
1013,
2191,
8841,
2076,
15489,
19948,
1012,
202... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/blanket.js | parseConditionalExpression | function parseConditionalExpression() {
var expr, previousAllowIn, consequent, alternate, startToken;
startToken = lookahead;
expr = parseBinaryExpression();
if (match('?')) {
lex();
previousAllowIn = state.allowIn;
state.allowIn = true;
consequent = parseAssignmentExpression();
state.allowIn = previousAllowIn;
expect(':');
alternate = parseAssignmentExpression();
expr = delegate.createConditionalExpression(expr, consequent, alternate);
delegate.markEnd(expr, startToken);
}
return expr;
} | javascript | function parseConditionalExpression() {
var expr, previousAllowIn, consequent, alternate, startToken;
startToken = lookahead;
expr = parseBinaryExpression();
if (match('?')) {
lex();
previousAllowIn = state.allowIn;
state.allowIn = true;
consequent = parseAssignmentExpression();
state.allowIn = previousAllowIn;
expect(':');
alternate = parseAssignmentExpression();
expr = delegate.createConditionalExpression(expr, consequent, alternate);
delegate.markEnd(expr, startToken);
}
return expr;
} | [
"function",
"parseConditionalExpression",
"(",
")",
"{",
"var",
"expr",
",",
"previousAllowIn",
",",
"consequent",
",",
"alternate",
",",
"startToken",
";",
"startToken",
"=",
"lookahead",
";",
"expr",
"=",
"parseBinaryExpression",
"(",
")",
";",
"if",
"(",
"m... | 11.12 Conditional Operator | [
"11",
".",
"12",
"Conditional",
"Operator"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L2532-L2553 | train | ECMA - 262 12. 2 Conditional Operator | [
30522,
3853,
11968,
3366,
8663,
27064,
10288,
20110,
3258,
1006,
1007,
1063,
13075,
4654,
18098,
1010,
3025,
8095,
5004,
2378,
1010,
9530,
3366,
15417,
1010,
6585,
1010,
2707,
18715,
2368,
1025,
2707,
18715,
2368,
1027,
2298,
4430,
13775,
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... |
elastic/elasticsearch-js | api/api/indices.rollover.js | buildIndicesRollover | function buildIndicesRollover (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [indices.rollover](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html) request
*
* @param {string} alias - The name of the alias to rollover
* @param {string} new_index - The name of the rollover index
* @param {boolean} include_type_name - Whether a type should be included in the body of the mappings.
* @param {time} timeout - Explicit operation timeout
* @param {boolean} dry_run - If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false
* @param {time} master_timeout - Specify timeout for connection to master
* @param {string} wait_for_active_shards - Set the number of active shards to wait for on the newly created rollover index before the operation returns.
* @param {object} body - The conditions that needs to be met for executing rollover
*/
const acceptedQuerystring = [
'include_type_name',
'timeout',
'dry_run',
'master_timeout',
'wait_for_active_shards',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
includeTypeName: 'include_type_name',
dryRun: 'dry_run',
masterTimeout: 'master_timeout',
waitForActiveShards: 'wait_for_active_shards',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function indicesRollover (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['alias'] == null) {
const err = new ConfigurationError('Missing required parameter: alias')
return handleError(err, callback)
}
// check required url components
if ((params['new_index'] != null || params['newIndex'] != null) && (params['alias'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: alias')
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, alias, newIndex, new_index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((alias) != null && (new_index || newIndex) != null) {
path = '/' + encodeURIComponent(alias) + '/' + '_rollover' + '/' + encodeURIComponent(new_index || newIndex)
} else {
path = '/' + encodeURIComponent(alias) + '/' + '_rollover'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | javascript | function buildIndicesRollover (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
/**
* Perform a [indices.rollover](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html) request
*
* @param {string} alias - The name of the alias to rollover
* @param {string} new_index - The name of the rollover index
* @param {boolean} include_type_name - Whether a type should be included in the body of the mappings.
* @param {time} timeout - Explicit operation timeout
* @param {boolean} dry_run - If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false
* @param {time} master_timeout - Specify timeout for connection to master
* @param {string} wait_for_active_shards - Set the number of active shards to wait for on the newly created rollover index before the operation returns.
* @param {object} body - The conditions that needs to be met for executing rollover
*/
const acceptedQuerystring = [
'include_type_name',
'timeout',
'dry_run',
'master_timeout',
'wait_for_active_shards',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
includeTypeName: 'include_type_name',
dryRun: 'dry_run',
masterTimeout: 'master_timeout',
waitForActiveShards: 'wait_for_active_shards',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
return function indicesRollover (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['alias'] == null) {
const err = new ConfigurationError('Missing required parameter: alias')
return handleError(err, callback)
}
// check required url components
if ((params['new_index'] != null || params['newIndex'] != null) && (params['alias'] == null)) {
const err = new ConfigurationError('Missing required parameter of the url: alias')
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, alias, newIndex, new_index, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
if (method == null) {
method = 'POST'
}
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((alias) != null && (new_index || newIndex) != null) {
path = '/' + encodeURIComponent(alias) + '/' + '_rollover' + '/' + encodeURIComponent(new_index || newIndex)
} else {
path = '/' + encodeURIComponent(alias) + '/' + '_rollover'
}
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
} | [
"function",
"buildIndicesRollover",
"(",
"opts",
")",
"{",
"// eslint-disable-next-line no-unused-vars",
"const",
"{",
"makeRequest",
",",
"ConfigurationError",
",",
"handleError",
",",
"snakeCaseKeys",
"}",
"=",
"opts",
"/**\n * Perform a [indices.rollover](http://www.elasti... | /* 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/indices.rollover.js#L25-L125 | train | Build an index rollover function. | [
30522,
3853,
3857,
22254,
23522,
28402,
7840,
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,
212... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | lib/jsdoc/transform-apijson-for-sdk.js | function (description, since) {
var result = description || "";
result += '<br>For more information, see ' + this.handleExternalUrl(this.ANNOTATIONS_LINK, "OData v4 Annotations");
if (since) {
result += '<br><br><i>Since: ' + since + '.</i>';
}
result = this._preProcessLinksInTextBlock(result);
return result;
} | javascript | function (description, since) {
var result = description || "";
result += '<br>For more information, see ' + this.handleExternalUrl(this.ANNOTATIONS_LINK, "OData v4 Annotations");
if (since) {
result += '<br><br><i>Since: ' + since + '.</i>';
}
result = this._preProcessLinksInTextBlock(result);
return result;
} | [
"function",
"(",
"description",
",",
"since",
")",
"{",
"var",
"result",
"=",
"description",
"||",
"\"\"",
";",
"result",
"+=",
"'<br>For more information, see '",
"+",
"this",
".",
"handleExternalUrl",
"(",
"this",
".",
"ANNOTATIONS_LINK",
",",
"\"OData v4 Annota... | Formats the description of annotations
@param description - the description of the annotation
@param since - the since version information of the annotation
@returns string - the formatted description | [
"Formats",
"the",
"description",
"of",
"annotations"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/transform-apijson-for-sdk.js#L1006-L1017 | train | Returns a description of the annotation | [
30522,
3853,
1006,
6412,
1010,
2144,
1007,
1063,
13075,
2765,
1027,
6412,
1064,
1064,
1000,
1000,
1025,
2765,
1009,
1027,
1005,
1026,
7987,
1028,
2005,
2062,
2592,
1010,
2156,
1005,
1009,
2023,
1012,
5047,
10288,
16451,
2389,
3126,
2140,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/util/ast-utils.js | getOpeningParenOfParams | function getOpeningParenOfParams(node, sourceCode) {
return node.id
? sourceCode.getTokenAfter(node.id, isOpeningParenToken)
: sourceCode.getFirstToken(node, isOpeningParenToken);
} | javascript | function getOpeningParenOfParams(node, sourceCode) {
return node.id
? sourceCode.getTokenAfter(node.id, isOpeningParenToken)
: sourceCode.getFirstToken(node, isOpeningParenToken);
} | [
"function",
"getOpeningParenOfParams",
"(",
"node",
",",
"sourceCode",
")",
"{",
"return",
"node",
".",
"id",
"?",
"sourceCode",
".",
"getTokenAfter",
"(",
"node",
".",
"id",
",",
"isOpeningParenToken",
")",
":",
"sourceCode",
".",
"getFirstToken",
"(",
"node"... | Gets the `(` token of the given function node.
@param {ASTNode} node - The function node to get.
@param {SourceCode} sourceCode - The source code object to get tokens.
@returns {Token} `(` token. | [
"Gets",
"the",
"(",
"token",
"of",
"the",
"given",
"function",
"node",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/ast-utils.js#L390-L394 | train | Gets the opening parenthesis of a function call. | [
30522,
3853,
2131,
26915,
2075,
19362,
16515,
22540,
5400,
5244,
1006,
13045,
1010,
3120,
16044,
1007,
1063,
2709,
13045,
1012,
8909,
1029,
3120,
16044,
1012,
2131,
18715,
8189,
6199,
2121,
1006,
13045,
1012,
8909,
1010,
11163,
11837,
2075,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/hello-mui/js/mui.picker.all.js | function(callback) {
var self = this;
self.callback = callback;
self.mask.show();
document.body.classList.add($.className('poppicker-active-for-page'));
self.panel.classList.add($.className('active'));
//处理物理返回键
self.__back = $.back;
$.back = function() {
self.hide();
};
} | javascript | function(callback) {
var self = this;
self.callback = callback;
self.mask.show();
document.body.classList.add($.className('poppicker-active-for-page'));
self.panel.classList.add($.className('active'));
//处理物理返回键
self.__back = $.back;
$.back = function() {
self.hide();
};
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"callback",
"=",
"callback",
";",
"self",
".",
"mask",
".",
"show",
"(",
")",
";",
"document",
".",
"body",
".",
"classList",
".",
"add",
"(",
"$",
".",
"className... | 显示 | [
"显示"
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/hello-mui/js/mui.picker.all.js#L511-L522 | train | show the pop - picker | [
30522,
3853,
1006,
2655,
5963,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2969,
1012,
2655,
5963,
1027,
2655,
5963,
1025,
2969,
1012,
7308,
1012,
2265,
1006,
1007,
1025,
6254,
1012,
2303,
1012,
2465,
9863,
1012,
5587,
1006,
1002,
1012,
24... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/core/services/interaction/interaction.js | MdInteractionService | function MdInteractionService($timeout, $mdUtil, $rootScope) {
this.$timeout = $timeout;
this.$mdUtil = $mdUtil;
this.$rootScope = $rootScope;
// IE browsers can also trigger pointer events, which also leads to an interaction.
this.pointerEvent = 'MSPointerEvent' in window ? 'MSPointerDown' : 'PointerEvent' in window ? 'pointerdown' : null;
this.bodyElement = angular.element(document.body);
this.isBuffering = false;
this.bufferTimeout = null;
this.lastInteractionType = null;
this.lastInteractionTime = null;
this.inputHandler = this.onInputEvent.bind(this);
this.bufferedInputHandler = this.onBufferInputEvent.bind(this);
// Type Mappings for the different events
// There will be three three interaction types
// `keyboard`, `mouse` and `touch`
// type `pointer` will be evaluated in `pointerMap` for IE Browser events
this.inputEventMap = {
'keydown': 'keyboard',
'mousedown': 'mouse',
'mouseenter': 'mouse',
'touchstart': 'touch',
'pointerdown': 'pointer',
'MSPointerDown': 'pointer'
};
// IE PointerDown events will be validated in `touch` or `mouse`
// Index numbers referenced here: https://msdn.microsoft.com/library/windows/apps/hh466130.aspx
this.iePointerMap = {
2: 'touch',
3: 'touch',
4: 'mouse'
};
this.initializeEvents();
this.$rootScope.$on('$destroy', this.deregister.bind(this));
} | javascript | function MdInteractionService($timeout, $mdUtil, $rootScope) {
this.$timeout = $timeout;
this.$mdUtil = $mdUtil;
this.$rootScope = $rootScope;
// IE browsers can also trigger pointer events, which also leads to an interaction.
this.pointerEvent = 'MSPointerEvent' in window ? 'MSPointerDown' : 'PointerEvent' in window ? 'pointerdown' : null;
this.bodyElement = angular.element(document.body);
this.isBuffering = false;
this.bufferTimeout = null;
this.lastInteractionType = null;
this.lastInteractionTime = null;
this.inputHandler = this.onInputEvent.bind(this);
this.bufferedInputHandler = this.onBufferInputEvent.bind(this);
// Type Mappings for the different events
// There will be three three interaction types
// `keyboard`, `mouse` and `touch`
// type `pointer` will be evaluated in `pointerMap` for IE Browser events
this.inputEventMap = {
'keydown': 'keyboard',
'mousedown': 'mouse',
'mouseenter': 'mouse',
'touchstart': 'touch',
'pointerdown': 'pointer',
'MSPointerDown': 'pointer'
};
// IE PointerDown events will be validated in `touch` or `mouse`
// Index numbers referenced here: https://msdn.microsoft.com/library/windows/apps/hh466130.aspx
this.iePointerMap = {
2: 'touch',
3: 'touch',
4: 'mouse'
};
this.initializeEvents();
this.$rootScope.$on('$destroy', this.deregister.bind(this));
} | [
"function",
"MdInteractionService",
"(",
"$timeout",
",",
"$mdUtil",
",",
"$rootScope",
")",
"{",
"this",
".",
"$timeout",
"=",
"$timeout",
";",
"this",
".",
"$mdUtil",
"=",
"$mdUtil",
";",
"this",
".",
"$rootScope",
"=",
"$rootScope",
";",
"// IE browsers can... | @ngdoc service
@name $mdInteraction
@module material.core.interaction
@description
Service which keeps track of the last interaction type and validates them for several browsers.
The service hooks into the document's body and listens for touch, mouse and keyboard events.
The most recent interaction type can be retrieved by calling the `getLastInteractionType` method.
Here is an example markup for using the interaction service.
<hljs lang="js">
var lastType = $mdInteraction.getLastInteractionType();
if (lastType === 'keyboard') {
// We only restore the focus for keyboard users.
restoreFocus();
}
</hljs> | [
"@ngdoc",
"service",
"@name",
"$mdInteraction",
"@module",
"material",
".",
"core",
".",
"interaction"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/interaction/interaction.js#L36-L74 | train | The MdInteractionService class | [
30522,
3853,
9108,
18447,
6906,
22014,
2121,
7903,
2063,
1006,
1002,
2051,
5833,
1010,
1002,
9108,
21823,
2140,
1010,
1002,
6147,
16186,
1007,
1063,
2023,
1012,
1002,
2051,
5833,
1027,
1002,
2051,
5833,
1025,
2023,
1012,
1002,
9108,
21823,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/editor/EditorCommandHandlers.js | lineComment | function lineComment(editor) {
editor = editor || EditorManager.getFocusedEditor();
if (!editor) {
return;
}
editor.setSelections(editor.document.doMultipleEdits(_getLineCommentEdits(editor, editor.getSelections(), "line")));
} | javascript | function lineComment(editor) {
editor = editor || EditorManager.getFocusedEditor();
if (!editor) {
return;
}
editor.setSelections(editor.document.doMultipleEdits(_getLineCommentEdits(editor, editor.getSelections(), "line")));
} | [
"function",
"lineComment",
"(",
"editor",
")",
"{",
"editor",
"=",
"editor",
"||",
"EditorManager",
".",
"getFocusedEditor",
"(",
")",
";",
"if",
"(",
"!",
"editor",
")",
"{",
"return",
";",
"}",
"editor",
".",
"setSelections",
"(",
"editor",
".",
"docum... | Invokes a language-specific line-comment/uncomment handler
@param {?Editor} editor If unspecified, applies to the currently focused editor | [
"Invokes",
"a",
"language",
"-",
"specific",
"line",
"-",
"comment",
"/",
"uncomment",
"handler"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/editor/EditorCommandHandlers.js#L681-L688 | train | Line comment editor | [
30522,
3853,
2240,
9006,
3672,
1006,
3559,
1007,
1063,
3559,
1027,
3559,
1064,
1064,
3559,
24805,
4590,
1012,
2131,
14876,
7874,
19082,
15660,
1006,
1007,
1025,
2065,
1006,
999,
3559,
1007,
1063,
2709,
1025,
1065,
3559,
1012,
4520,
12260,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/runtime/flash/image.js | function( blob ) {
var owner = this.owner;
owner.info() && this.flashExec( 'Image', 'info', owner.info() );
owner.meta() && this.flashExec( 'Image', 'meta', owner.meta() );
this.flashExec( 'Image', 'loadFromBlob', blob.uid );
} | javascript | function( blob ) {
var owner = this.owner;
owner.info() && this.flashExec( 'Image', 'info', owner.info() );
owner.meta() && this.flashExec( 'Image', 'meta', owner.meta() );
this.flashExec( 'Image', 'loadFromBlob', blob.uid );
} | [
"function",
"(",
"blob",
")",
"{",
"var",
"owner",
"=",
"this",
".",
"owner",
";",
"owner",
".",
"info",
"(",
")",
"&&",
"this",
".",
"flashExec",
"(",
"'Image'",
",",
"'info'",
",",
"owner",
".",
"info",
"(",
")",
")",
";",
"owner",
".",
"meta",... | this.flashExec( 'Image', 'init', options ); owner.on( 'load', function() { debugger; }); }, | [
"this",
".",
"flashExec",
"(",
"Image",
"init",
"options",
")",
";",
"owner",
".",
"on",
"(",
"load",
"function",
"()",
"{",
"debugger",
";",
"}",
")",
";",
"}"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/src/runtime/flash/image.js#L18-L25 | train | Load image from blob | [
30522,
3853,
1006,
1038,
4135,
2497,
1007,
1063,
13075,
3954,
1027,
2023,
1012,
3954,
1025,
3954,
1012,
18558,
1006,
1007,
1004,
1004,
2023,
1012,
5956,
10288,
8586,
1006,
1005,
3746,
1005,
1010,
1005,
18558,
1005,
1010,
3954,
1012,
18558,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/dom-utils.js | nodeCollector_queryAnonymousNodes | function nodeCollector_queryAnonymousNodes(aAttribute, aValue) {
var node = this._document.getAnonymousElementByAttribute(this._root,
aAttribute,
aValue);
this.nodes = node ? [node] : [ ];
return this;
} | javascript | function nodeCollector_queryAnonymousNodes(aAttribute, aValue) {
var node = this._document.getAnonymousElementByAttribute(this._root,
aAttribute,
aValue);
this.nodes = node ? [node] : [ ];
return this;
} | [
"function",
"nodeCollector_queryAnonymousNodes",
"(",
"aAttribute",
",",
"aValue",
")",
"{",
"var",
"node",
"=",
"this",
".",
"_document",
".",
"getAnonymousElementByAttribute",
"(",
"this",
".",
"_root",
",",
"aAttribute",
",",
"aValue",
")",
";",
"this",
".",
... | Find anonymouse nodes with the specified attribute and value
@param {string} aAttribute
DOM attribute of the wanted node
@param {string} aValue
Value of the DOM attribute
@returns The class instance
@type {object} | [
"Find",
"anonymouse",
"nodes",
"with",
"the",
"specified",
"attribute",
"and",
"value"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/dom-utils.js#L632-L639 | train | Query anonymous nodes | [
30522,
3853,
13045,
26895,
22471,
2953,
1035,
23032,
6761,
4890,
27711,
3630,
6155,
1006,
9779,
4779,
3089,
8569,
2618,
1010,
10927,
7630,
2063,
1007,
1063,
13075,
13045,
1027,
2023,
1012,
1035,
6254,
1012,
2131,
6761,
4890,
27711,
12260,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | aio/tools/examples/run-example-e2e.js | logSpecs | function logSpecs(e2eSpecPaths) {
Object.keys(e2eSpecPaths).forEach(type => {
const paths = e2eSpecPaths[type];
console.log(` ${type.toUpperCase()}:`);
console.log(paths.map(p => ` ${p}`).join('\n'));
});
} | javascript | function logSpecs(e2eSpecPaths) {
Object.keys(e2eSpecPaths).forEach(type => {
const paths = e2eSpecPaths[type];
console.log(` ${type.toUpperCase()}:`);
console.log(paths.map(p => ` ${p}`).join('\n'));
});
} | [
"function",
"logSpecs",
"(",
"e2eSpecPaths",
")",
"{",
"Object",
".",
"keys",
"(",
"e2eSpecPaths",
")",
".",
"forEach",
"(",
"type",
"=>",
"{",
"const",
"paths",
"=",
"e2eSpecPaths",
"[",
"type",
"]",
";",
"console",
".",
"log",
"(",
"`",
"${",
"type",... | Log the specs (for debugging purposes). `e2eSpecPaths` is of type: `{[type: string]: string[]}` (where `type` is `systemjs`, `cli, etc.) | [
"Log",
"the",
"specs",
"(",
"for",
"debugging",
"purposes",
")",
".",
"e2eSpecPaths",
"is",
"of",
"type",
":",
"{",
"[",
"type",
":",
"string",
"]",
":",
"string",
"[]",
"}",
"(",
"where",
"type",
"is",
"systemjs",
"cli",
"etc",
".",
")"
] | c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c | https://github.com/angular/angular/blob/c016e2c4ecf7529f08fae4ca0f5c8b0170c6b51c/aio/tools/examples/run-example-e2e.js#L389-L396 | train | Logs the spec files | [
30522,
3853,
15664,
5051,
6169,
1006,
1041,
2475,
2229,
5051,
21906,
8988,
2015,
1007,
1063,
4874,
1012,
6309,
1006,
1041,
2475,
2229,
5051,
21906,
8988,
2015,
1007,
1012,
18921,
6776,
1006,
2828,
1027,
1028,
1063,
9530,
3367,
10425,
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... |
angular/material | src/core/util/util.js | function(element) {
var node = element[0] || element;
document.addEventListener('click', function focusOnClick(ev) {
if (ev.target === node && ev.$focus) {
node.focus();
ev.stopImmediatePropagation();
ev.preventDefault();
node.removeEventListener('click', focusOnClick);
}
}, true);
var newEvent = document.createEvent('MouseEvents');
newEvent.initMouseEvent('click', false, true, window, {}, 0, 0, 0, 0,
false, false, false, false, 0, null);
newEvent.$material = true;
newEvent.$focus = true;
node.dispatchEvent(newEvent);
} | javascript | function(element) {
var node = element[0] || element;
document.addEventListener('click', function focusOnClick(ev) {
if (ev.target === node && ev.$focus) {
node.focus();
ev.stopImmediatePropagation();
ev.preventDefault();
node.removeEventListener('click', focusOnClick);
}
}, true);
var newEvent = document.createEvent('MouseEvents');
newEvent.initMouseEvent('click', false, true, window, {}, 0, 0, 0, 0,
false, false, false, false, 0, null);
newEvent.$material = true;
newEvent.$focus = true;
node.dispatchEvent(newEvent);
} | [
"function",
"(",
"element",
")",
"{",
"var",
"node",
"=",
"element",
"[",
"0",
"]",
"||",
"element",
";",
"document",
".",
"addEventListener",
"(",
"'click'",
",",
"function",
"focusOnClick",
"(",
"ev",
")",
"{",
"if",
"(",
"ev",
".",
"target",
"===",
... | Mobile safari only allows you to set focus in click event listeners... | [
"Mobile",
"safari",
"only",
"allows",
"you",
"to",
"set",
"focus",
"in",
"click",
"event",
"listeners",
"..."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L349-L367 | train | This function is called by the focusOnClick function of the element | [
30522,
3853,
1006,
5783,
1007,
1063,
13075,
13045,
1027,
5783,
1031,
1014,
1033,
1064,
1064,
5783,
1025,
6254,
1012,
5587,
18697,
3372,
9863,
24454,
1006,
1005,
11562,
1005,
1010,
3853,
3579,
2239,
20464,
6799,
1006,
23408,
1007,
1063,
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... | |
aframevr/aframe | src/systems/material.js | loadImageTexture | function loadImageTexture (src, data) {
return new Promise(doLoadImageTexture);
function doLoadImageTexture (resolve, reject) {
var isEl = typeof src !== 'string';
function resolveTexture (texture) {
setTextureProperties(texture, data);
texture.needsUpdate = true;
resolve(texture);
}
// Create texture from an element.
if (isEl) {
resolveTexture(new THREE.Texture(src));
return;
}
// Request and load texture from src string. THREE will create underlying element.
// Use THREE.TextureLoader (src, onLoad, onProgress, onError) to load texture.
TextureLoader.load(
src,
resolveTexture,
function () { /* no-op */ },
function (xhr) {
error('`$s` could not be fetched (Error code: %s; Response: %s)', xhr.status,
xhr.statusText);
}
);
}
} | javascript | function loadImageTexture (src, data) {
return new Promise(doLoadImageTexture);
function doLoadImageTexture (resolve, reject) {
var isEl = typeof src !== 'string';
function resolveTexture (texture) {
setTextureProperties(texture, data);
texture.needsUpdate = true;
resolve(texture);
}
// Create texture from an element.
if (isEl) {
resolveTexture(new THREE.Texture(src));
return;
}
// Request and load texture from src string. THREE will create underlying element.
// Use THREE.TextureLoader (src, onLoad, onProgress, onError) to load texture.
TextureLoader.load(
src,
resolveTexture,
function () { /* no-op */ },
function (xhr) {
error('`$s` could not be fetched (Error code: %s; Response: %s)', xhr.status,
xhr.statusText);
}
);
}
} | [
"function",
"loadImageTexture",
"(",
"src",
",",
"data",
")",
"{",
"return",
"new",
"Promise",
"(",
"doLoadImageTexture",
")",
";",
"function",
"doLoadImageTexture",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"isEl",
"=",
"typeof",
"src",
"!==",
"'strin... | Load image texture.
@private
@param {string|object} src - An <img> element or url to an image file.
@param {object} data - Data to set texture properties like `repeat`.
@returns {Promise} Resolves once texture is loaded. | [
"Load",
"image",
"texture",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/material.js#L288-L318 | train | Load image texture from string | [
30522,
3853,
7170,
9581,
18150,
10288,
11244,
1006,
5034,
2278,
1010,
2951,
1007,
1063,
2709,
2047,
4872,
1006,
2079,
11066,
9581,
18150,
10288,
11244,
1007,
1025,
3853,
2079,
11066,
9581,
18150,
10288,
11244,
1006,
10663,
1010,
15454,
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... |
eslint/eslint | lib/rules/key-spacing.js | continuesPropertyGroup | function continuesPropertyGroup(lastMember, candidate) {
const groupEndLine = lastMember.loc.start.line,
candidateStartLine = candidate.loc.start.line;
if (candidateStartLine - groupEndLine <= 1) {
return true;
}
/*
* Check that the first comment is adjacent to the end of the group, the
* last comment is adjacent to the candidate property, and that successive
* comments are adjacent to each other.
*/
const leadingComments = sourceCode.getCommentsBefore(candidate);
if (
leadingComments.length &&
leadingComments[0].loc.start.line - groupEndLine <= 1 &&
candidateStartLine - last(leadingComments).loc.end.line <= 1
) {
for (let i = 1; i < leadingComments.length; i++) {
if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) {
return false;
}
}
return true;
}
return false;
} | javascript | function continuesPropertyGroup(lastMember, candidate) {
const groupEndLine = lastMember.loc.start.line,
candidateStartLine = candidate.loc.start.line;
if (candidateStartLine - groupEndLine <= 1) {
return true;
}
/*
* Check that the first comment is adjacent to the end of the group, the
* last comment is adjacent to the candidate property, and that successive
* comments are adjacent to each other.
*/
const leadingComments = sourceCode.getCommentsBefore(candidate);
if (
leadingComments.length &&
leadingComments[0].loc.start.line - groupEndLine <= 1 &&
candidateStartLine - last(leadingComments).loc.end.line <= 1
) {
for (let i = 1; i < leadingComments.length; i++) {
if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) {
return false;
}
}
return true;
}
return false;
} | [
"function",
"continuesPropertyGroup",
"(",
"lastMember",
",",
"candidate",
")",
"{",
"const",
"groupEndLine",
"=",
"lastMember",
".",
"loc",
".",
"start",
".",
"line",
",",
"candidateStartLine",
"=",
"candidate",
".",
"loc",
".",
"start",
".",
"line",
";",
"... | Checks whether a property is a member of the property group it follows.
@param {ASTNode} lastMember The last Property known to be in the group.
@param {ASTNode} candidate The next Property that might be in the group.
@returns {boolean} True if the candidate property is part of the group. | [
"Checks",
"whether",
"a",
"property",
"is",
"a",
"member",
"of",
"the",
"property",
"group",
"it",
"follows",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/key-spacing.js#L328-L357 | train | Check if the candidate property is adjacent to the last member of the group | [
30522,
3853,
4247,
21572,
4842,
3723,
17058,
1006,
2197,
4168,
21784,
1010,
4018,
1007,
1063,
9530,
3367,
2177,
10497,
4179,
1027,
2197,
4168,
21784,
1012,
8840,
2278,
1012,
2707,
1012,
2240,
1010,
5347,
7559,
19646,
3170,
1027,
4018,
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... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function(error) {
Strophe.error("Websocket error " + error);
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established was disconnected.");
this._disconnect();
} | javascript | function(error) {
Strophe.error("Websocket error " + error);
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL, "The WebSocket connection could not be established was disconnected.");
this._disconnect();
} | [
"function",
"(",
"error",
")",
"{",
"Strophe",
".",
"error",
"(",
"\"Websocket error \"",
"+",
"error",
")",
";",
"this",
".",
"_conn",
".",
"_changeConnectStatus",
"(",
"Strophe",
".",
"Status",
".",
"CONNFAIL",
",",
"\"The WebSocket connection could not be estab... | PrivateFunction: _onError
_Private_ function to handle websockets errors.
Parameters:
(Object) error - The websocket error. | [
"PrivateFunction",
":",
"_onError",
"_Private_",
"function",
"to",
"handle",
"websockets",
"errors",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L5086-L5090 | train | The WebSocket error handler | [
30522,
3853,
1006,
7561,
1007,
1063,
2358,
18981,
5369,
1012,
7561,
1006,
1000,
4773,
6499,
19869,
2102,
7561,
1000,
1009,
7561,
1007,
1025,
2023,
1012,
1035,
9530,
2078,
1012,
1035,
2689,
8663,
2638,
16649,
29336,
2271,
1006,
2358,
18981,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/caja-html-sanitizer.js | parseText | function parseText(parts, tag, h, param, continuationMarker, state) {
var end = parts.length;
if (!endTagRe.hasOwnProperty(tag.name)) {
endTagRe[tag.name] = new RegExp('^' + tag.name + '(?:[\\s\\/]|$)', 'i');
}
var re = endTagRe[tag.name];
var first = tag.next;
var p = tag.next + 1;
for (; p < end; p++) {
if (parts[p - 1] === '<\/' && re.test(parts[p])) { break; }
}
if (p < end) { p -= 1; }
var buf = parts.slice(first, p).join('');
if (tag.eflags & html4.eflags.CDATA) {
if (h.cdata) {
h.cdata(buf, param, continuationMarker,
continuationMaker(h, parts, p, state, param));
}
} else if (tag.eflags & html4.eflags.RCDATA) {
if (h.rcdata) {
h.rcdata(normalizeRCData(buf), param, continuationMarker,
continuationMaker(h, parts, p, state, param));
}
} else {
throw new Error('bug');
}
return p;
} | javascript | function parseText(parts, tag, h, param, continuationMarker, state) {
var end = parts.length;
if (!endTagRe.hasOwnProperty(tag.name)) {
endTagRe[tag.name] = new RegExp('^' + tag.name + '(?:[\\s\\/]|$)', 'i');
}
var re = endTagRe[tag.name];
var first = tag.next;
var p = tag.next + 1;
for (; p < end; p++) {
if (parts[p - 1] === '<\/' && re.test(parts[p])) { break; }
}
if (p < end) { p -= 1; }
var buf = parts.slice(first, p).join('');
if (tag.eflags & html4.eflags.CDATA) {
if (h.cdata) {
h.cdata(buf, param, continuationMarker,
continuationMaker(h, parts, p, state, param));
}
} else if (tag.eflags & html4.eflags.RCDATA) {
if (h.rcdata) {
h.rcdata(normalizeRCData(buf), param, continuationMarker,
continuationMaker(h, parts, p, state, param));
}
} else {
throw new Error('bug');
}
return p;
} | [
"function",
"parseText",
"(",
"parts",
",",
"tag",
",",
"h",
",",
"param",
",",
"continuationMarker",
",",
"state",
")",
"{",
"var",
"end",
"=",
"parts",
".",
"length",
";",
"if",
"(",
"!",
"endTagRe",
".",
"hasOwnProperty",
"(",
"tag",
".",
"name",
... | Tags like <script> and <textarea> are flagged as CDATA or RCDATA, which means everything is text until we see the correct closing tag. | [
"Tags",
"like",
"<script",
">",
"and",
"<textarea",
">",
"are",
"flagged",
"as",
"CDATA",
"or",
"RCDATA",
"which",
"means",
"everything",
"is",
"text",
"until",
"we",
"see",
"the",
"correct",
"closing",
"tag",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/caja-html-sanitizer.js#L3206-L3233 | train | Parse text from tag | [
30522,
3853,
11968,
13462,
10288,
2102,
1006,
3033,
1010,
6415,
1010,
1044,
1010,
11498,
2213,
1010,
13633,
10665,
2121,
1010,
2110,
1007,
1063,
13075,
2203,
1027,
3033,
1012,
3091,
1025,
2065,
1006,
999,
2203,
15900,
2890,
1012,
2038,
1238... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/panel/panel.spec.js | openPanel | function openPanel(preset, opt_config) {
// TODO(ErinCoughlan): Investigate why panelRef.open() doesn't return
// panelRef.
var openPromise;
if (panelRef) {
openPromise = panelRef.open();
} else {
openPromise = $mdPanel.open(preset, opt_config);
}
openPromise.then(function(createdPanelRef) {
panelRef = createdPanelRef;
return panelRef;
});
flushPanel();
} | javascript | function openPanel(preset, opt_config) {
// TODO(ErinCoughlan): Investigate why panelRef.open() doesn't return
// panelRef.
var openPromise;
if (panelRef) {
openPromise = panelRef.open();
} else {
openPromise = $mdPanel.open(preset, opt_config);
}
openPromise.then(function(createdPanelRef) {
panelRef = createdPanelRef;
return panelRef;
});
flushPanel();
} | [
"function",
"openPanel",
"(",
"preset",
",",
"opt_config",
")",
"{",
"// TODO(ErinCoughlan): Investigate why panelRef.open() doesn't return",
"// panelRef.",
"var",
"openPromise",
";",
"if",
"(",
"panelRef",
")",
"{",
"openPromise",
"=",
"panelRef",
".",
"open",
"(",
... | Opens the panel. If a config value is passed, creates a new panelRef
using $mdPanel.open(config); Otherwise, called open on the panelRef,
assuming one has already been created.
@param {!Object=} opt_config | [
"Opens",
"the",
"panel",
".",
"If",
"a",
"config",
"value",
"is",
"passed",
"creates",
"a",
"new",
"panelRef",
"using",
"$mdPanel",
".",
"open",
"(",
"config",
")",
";",
"Otherwise",
"called",
"open",
"on",
"the",
"panelRef",
"assuming",
"one",
"has",
"a... | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/panel/panel.spec.js#L3423-L3440 | train | Open a panel | [
30522,
3853,
2330,
9739,
2884,
1006,
3653,
13462,
1010,
23569,
1035,
9530,
8873,
2290,
1007,
1063,
1013,
1013,
28681,
2080,
1006,
11781,
3597,
8953,
5802,
1007,
1024,
8556,
2339,
5997,
2890,
2546,
1012,
2330,
1006,
1007,
2987,
1005,
1056,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Control.js | fnRemoveBusyIndicator | function fnRemoveBusyIndicator(bForceRemoval) {
// removing all block layers is done upon rerendering and destroy of the control
if (bForceRemoval) {
fnRemoveAllBlockLayers.call(this);
return;
}
var $this = this.$(this._sBusySection);
$this.removeClass('sapUiLocalBusy');
//Unset the actual DOM Element´s 'aria-busy'
$this.removeAttr('aria-busy');
if (this._sBlockSection === this._sBusySection) {
if (!this.getBlocked() && !this.getBusy()) {
// Remove shared block state & busy block state reference
fnRemoveAllBlockLayers.call(this);
} else if (this.getBlocked()) {
// Hide animation in shared block layer
BlockLayerUtils.toggleAnimationStyle(this._oBlockState || this._oBusyBlockState, false);
this._oBlockState = this._oBusyBlockState;
} else if (this._oBusyBlockState) {
BlockLayerUtils.unblock(this._oBusyBlockState);
delete this._oBusyBlockState;
}
} else if (this._oBusyBlockState) {
// standalone busy block state
BlockLayerUtils.unblock(this._oBusyBlockState);
delete this._oBusyBlockState;
}
} | javascript | function fnRemoveBusyIndicator(bForceRemoval) {
// removing all block layers is done upon rerendering and destroy of the control
if (bForceRemoval) {
fnRemoveAllBlockLayers.call(this);
return;
}
var $this = this.$(this._sBusySection);
$this.removeClass('sapUiLocalBusy');
//Unset the actual DOM Element´s 'aria-busy'
$this.removeAttr('aria-busy');
if (this._sBlockSection === this._sBusySection) {
if (!this.getBlocked() && !this.getBusy()) {
// Remove shared block state & busy block state reference
fnRemoveAllBlockLayers.call(this);
} else if (this.getBlocked()) {
// Hide animation in shared block layer
BlockLayerUtils.toggleAnimationStyle(this._oBlockState || this._oBusyBlockState, false);
this._oBlockState = this._oBusyBlockState;
} else if (this._oBusyBlockState) {
BlockLayerUtils.unblock(this._oBusyBlockState);
delete this._oBusyBlockState;
}
} else if (this._oBusyBlockState) {
// standalone busy block state
BlockLayerUtils.unblock(this._oBusyBlockState);
delete this._oBusyBlockState;
}
} | [
"function",
"fnRemoveBusyIndicator",
"(",
"bForceRemoval",
")",
"{",
"// removing all block layers is done upon rerendering and destroy of the control",
"if",
"(",
"bForceRemoval",
")",
"{",
"fnRemoveAllBlockLayers",
".",
"call",
"(",
"this",
")",
";",
"return",
";",
"}",
... | Remove busy indicator from DOM
@param {boolean} bForceRemoval Forces the removal of all Block layers
@private | [
"Remove",
"busy",
"indicator",
"from",
"DOM"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Control.js#L796-L831 | train | Removes the busy indicator from the DOM | [
30522,
3853,
1042,
16118,
6633,
21818,
8286,
25811,
14808,
8844,
1006,
28939,
2953,
17119,
6633,
7103,
2140,
1007,
1063,
1013,
1013,
9268,
2035,
3796,
9014,
2003,
2589,
2588,
2128,
7389,
4063,
2075,
1998,
6033,
1997,
1996,
2491,
2065,
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... |
aws/aws-sdk-js | lib/services/sts.js | credentialsFrom | function credentialsFrom(data, credentials) {
if (!data) return null;
if (!credentials) credentials = new AWS.TemporaryCredentials();
credentials.expired = false;
credentials.accessKeyId = data.Credentials.AccessKeyId;
credentials.secretAccessKey = data.Credentials.SecretAccessKey;
credentials.sessionToken = data.Credentials.SessionToken;
credentials.expireTime = data.Credentials.Expiration;
return credentials;
} | javascript | function credentialsFrom(data, credentials) {
if (!data) return null;
if (!credentials) credentials = new AWS.TemporaryCredentials();
credentials.expired = false;
credentials.accessKeyId = data.Credentials.AccessKeyId;
credentials.secretAccessKey = data.Credentials.SecretAccessKey;
credentials.sessionToken = data.Credentials.SessionToken;
credentials.expireTime = data.Credentials.Expiration;
return credentials;
} | [
"function",
"credentialsFrom",
"(",
"data",
",",
"credentials",
")",
"{",
"if",
"(",
"!",
"data",
")",
"return",
"null",
";",
"if",
"(",
"!",
"credentials",
")",
"credentials",
"=",
"new",
"AWS",
".",
"TemporaryCredentials",
"(",
")",
";",
"credentials",
... | @overload credentialsFrom(data, credentials = null)
Creates a credentials object from STS response data containing
credentials information. Useful for quickly setting AWS credentials.
@note This is a low-level utility function. If you want to load temporary
credentials into your process for subsequent requests to AWS resources,
you should use {AWS.TemporaryCredentials} instead.
@param data [map] data retrieved from a call to {getFederatedToken},
{getSessionToken}, {assumeRole}, or {assumeRoleWithWebIdentity}.
@param credentials [AWS.Credentials] an optional credentials object to
fill instead of creating a new object. Useful when modifying an
existing credentials object from a refresh call.
@return [AWS.TemporaryCredentials] the set of temporary credentials
loaded from a raw STS operation response.
@example Using credentialsFrom to load global AWS credentials
var sts = new AWS.STS();
sts.getSessionToken(function (err, data) {
if (err) console.log("Error getting credentials");
else {
AWS.config.credentials = sts.credentialsFrom(data);
}
});
@see AWS.TemporaryCredentials | [
"@overload",
"credentialsFrom",
"(",
"data",
"credentials",
"=",
"null",
")",
"Creates",
"a",
"credentials",
"object",
"from",
"STS",
"response",
"data",
"containing",
"credentials",
"information",
".",
"Useful",
"for",
"quickly",
"setting",
"AWS",
"credentials",
... | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/services/sts.js#L29-L38 | train | Creates temporary credentials from credentials object | [
30522,
3853,
22496,
19699,
5358,
1006,
2951,
1010,
22496,
1007,
1063,
2065,
1006,
999,
2951,
1007,
2709,
19701,
1025,
2065,
1006,
999,
22496,
1007,
22496,
1027,
2047,
22091,
2015,
1012,
5741,
16748,
16454,
26340,
1006,
1007,
1025,
22496,
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... |
zloirock/core-js | packages/core-js/internals/collection-weak.js | get | function get(key) {
var state = getInternalState(this);
if (isObject(key)) {
var data = getWeakData(key);
if (data === true) return uncaughtFrozenStore(state).get(key);
return data ? data[state.id] : undefined;
}
} | javascript | function get(key) {
var state = getInternalState(this);
if (isObject(key)) {
var data = getWeakData(key);
if (data === true) return uncaughtFrozenStore(state).get(key);
return data ? data[state.id] : undefined;
}
} | [
"function",
"get",
"(",
"key",
")",
"{",
"var",
"state",
"=",
"getInternalState",
"(",
"this",
")",
";",
"if",
"(",
"isObject",
"(",
"key",
")",
")",
"{",
"var",
"data",
"=",
"getWeakData",
"(",
"key",
")",
";",
"if",
"(",
"data",
"===",
"true",
... | 23.3.3.3 WeakMap.prototype.get(key) | [
"23",
".",
"3",
".",
"3",
".",
"3",
"WeakMap",
".",
"prototype",
".",
"get",
"(",
"key",
")"
] | fe7c8511a6d27d03a9b8e075b3351416aae95c58 | https://github.com/zloirock/core-js/blob/fe7c8511a6d27d03a9b8e075b3351416aae95c58/packages/core-js/internals/collection-weak.js#L99-L106 | train | Get the value of a key. | [
30522,
3853,
2131,
1006,
3145,
1007,
1063,
13075,
2110,
1027,
2131,
18447,
11795,
9777,
12259,
1006,
2023,
1007,
1025,
2065,
1006,
11163,
2497,
20614,
1006,
3145,
1007,
1007,
1063,
13075,
2951,
1027,
2131,
8545,
4817,
2850,
2696,
1006,
3145... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/blanket.js | parseDoWhileStatement | function parseDoWhileStatement() {
var body, test, oldInIteration;
expectKeyword('do');
oldInIteration = state.inIteration;
state.inIteration = true;
body = parseStatement();
state.inIteration = oldInIteration;
expectKeyword('while');
expect('(');
test = parseExpression();
expect(')');
if (match(';')) {
lex();
}
return delegate.createDoWhileStatement(body, test);
} | javascript | function parseDoWhileStatement() {
var body, test, oldInIteration;
expectKeyword('do');
oldInIteration = state.inIteration;
state.inIteration = true;
body = parseStatement();
state.inIteration = oldInIteration;
expectKeyword('while');
expect('(');
test = parseExpression();
expect(')');
if (match(';')) {
lex();
}
return delegate.createDoWhileStatement(body, test);
} | [
"function",
"parseDoWhileStatement",
"(",
")",
"{",
"var",
"body",
",",
"test",
",",
"oldInIteration",
";",
"expectKeyword",
"(",
"'do'",
")",
";",
"oldInIteration",
"=",
"state",
".",
"inIteration",
";",
"state",
".",
"inIteration",
"=",
"true",
";",
"body"... | 12.6 Iteration Statements | [
"12",
".",
"6",
"Iteration",
"Statements"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/blanket.js#L2764-L2789 | train | ECMA - 262 12. 2 WhileStatement | [
30522,
3853,
11968,
6924,
5004,
19466,
4355,
3686,
3672,
1006,
1007,
1063,
13075,
2303,
1010,
3231,
1010,
2214,
5498,
14621,
3508,
1025,
5987,
14839,
18351,
1006,
1005,
2079,
1005,
1007,
1025,
2214,
5498,
14621,
3508,
1027,
2110,
30524,
119... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/vscode | build/lib/i18n.js | updateResource | function updateResource(project, slug, xlfFile, apiHostname, credentials) {
return new Promise((resolve, reject) => {
const data = JSON.stringify({ content: xlfFile.contents.toString() });
const options = {
hostname: apiHostname,
path: `/api/2/project/${project}/resource/${slug}/content`,
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data)
},
auth: credentials,
method: 'PUT'
};
let request = https.request(options, (res) => {
if (res.statusCode === 200) {
res.setEncoding('utf8');
let responseBuffer = '';
res.on('data', function (chunk) {
responseBuffer += chunk;
});
res.on('end', () => {
const response = JSON.parse(responseBuffer);
log(`Resource ${project}/${slug} successfully updated on Transifex. Strings added: ${response.strings_added}, updated: ${response.strings_added}, deleted: ${response.strings_added}`);
resolve();
});
}
else {
reject(`Something went wrong in the request updating ${slug} in ${project}. ${res.statusCode}`);
}
});
request.on('error', (err) => {
reject(`Failed to update ${project}/${slug} on Transifex: ${err}`);
});
request.write(data);
request.end();
});
} | javascript | function updateResource(project, slug, xlfFile, apiHostname, credentials) {
return new Promise((resolve, reject) => {
const data = JSON.stringify({ content: xlfFile.contents.toString() });
const options = {
hostname: apiHostname,
path: `/api/2/project/${project}/resource/${slug}/content`,
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data)
},
auth: credentials,
method: 'PUT'
};
let request = https.request(options, (res) => {
if (res.statusCode === 200) {
res.setEncoding('utf8');
let responseBuffer = '';
res.on('data', function (chunk) {
responseBuffer += chunk;
});
res.on('end', () => {
const response = JSON.parse(responseBuffer);
log(`Resource ${project}/${slug} successfully updated on Transifex. Strings added: ${response.strings_added}, updated: ${response.strings_added}, deleted: ${response.strings_added}`);
resolve();
});
}
else {
reject(`Something went wrong in the request updating ${slug} in ${project}. ${res.statusCode}`);
}
});
request.on('error', (err) => {
reject(`Failed to update ${project}/${slug} on Transifex: ${err}`);
});
request.write(data);
request.end();
});
} | [
"function",
"updateResource",
"(",
"project",
",",
"slug",
",",
"xlfFile",
",",
"apiHostname",
",",
"credentials",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"data",
"=",
"JSON",
".",
"stringify",
"... | The following link provides information about how Transifex handles updates of a resource file:
https://dev.befoolish.co/tx-docs/public/projects/updating-content#what-happens-when-you-update-files | [
"The",
"following",
"link",
"provides",
"information",
"about",
"how",
"Transifex",
"handles",
"updates",
"of",
"a",
"resource",
"file",
":",
"https",
":",
"//",
"dev",
".",
"befoolish",
".",
"co",
"/",
"tx",
"-",
"docs",
"/",
"public",
"/",
"projects",
... | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/build/lib/i18n.js#L861-L897 | train | Updates a resource on Transifex | [
30522,
3853,
10651,
6072,
8162,
3401,
1006,
2622,
1010,
23667,
1010,
28712,
26989,
2571,
1010,
17928,
15006,
2102,
18442,
1010,
22496,
1007,
1063,
2709,
2047,
4872,
1006,
1006,
10663,
1010,
15454,
1007,
1027,
1028,
1063,
9530,
3367,
2951,
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... |
Dogfalo/materialize | extras/noUiSlider/nouislider.js | baseSize | function baseSize ( ) {
var rect = scope_Base.getBoundingClientRect(), alt = 'offset' + ['Width', 'Height'][options.ort];
return options.ort === 0 ? (rect.width||scope_Base[alt]) : (rect.height||scope_Base[alt]);
} | javascript | function baseSize ( ) {
var rect = scope_Base.getBoundingClientRect(), alt = 'offset' + ['Width', 'Height'][options.ort];
return options.ort === 0 ? (rect.width||scope_Base[alt]) : (rect.height||scope_Base[alt]);
} | [
"function",
"baseSize",
"(",
")",
"{",
"var",
"rect",
"=",
"scope_Base",
".",
"getBoundingClientRect",
"(",
")",
",",
"alt",
"=",
"'offset'",
"+",
"[",
"'Width'",
",",
"'Height'",
"]",
"[",
"options",
".",
"ort",
"]",
";",
"return",
"options",
".",
"or... | Shorthand for base dimensions. | [
"Shorthand",
"for",
"base",
"dimensions",
"."
] | 1122efadad8f1433d404696f7613e3cc13fb83a4 | https://github.com/Dogfalo/materialize/blob/1122efadad8f1433d404696f7613e3cc13fb83a4/extras/noUiSlider/nouislider.js#L1252-L1255 | train | Get base size | [
30522,
3853,
7888,
4697,
1006,
1007,
1063,
13075,
28667,
2102,
1027,
9531,
1035,
2918,
1012,
2131,
15494,
2075,
20464,
11638,
2890,
6593,
1006,
1007,
1010,
12456,
1027,
1005,
16396,
1005,
1009,
1031,
1005,
9381,
1005,
1010,
1005,
4578,
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... |
GitbookIO/gitbook | lib/parse/parseReadme.js | parseReadme | function parseReadme(book) {
var logger = book.getLogger();
return parseStructureFile(book, 'readme')
.spread(function(file, result) {
if (!file) {
throw new error.FileNotFoundError({ filename: 'README' });
}
logger.debug.ln('readme found at', file.getPath());
var readme = Readme.create(file, result);
return book.set('readme', readme);
});
} | javascript | function parseReadme(book) {
var logger = book.getLogger();
return parseStructureFile(book, 'readme')
.spread(function(file, result) {
if (!file) {
throw new error.FileNotFoundError({ filename: 'README' });
}
logger.debug.ln('readme found at', file.getPath());
var readme = Readme.create(file, result);
return book.set('readme', readme);
});
} | [
"function",
"parseReadme",
"(",
"book",
")",
"{",
"var",
"logger",
"=",
"book",
".",
"getLogger",
"(",
")",
";",
"return",
"parseStructureFile",
"(",
"book",
",",
"'readme'",
")",
".",
"spread",
"(",
"function",
"(",
"file",
",",
"result",
")",
"{",
"i... | Parse readme from book
@param {Book} book
@return {Promise<Book>} | [
"Parse",
"readme",
"from",
"book"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parseReadme.js#L12-L26 | train | Parse the readme from a book | [
30522,
3853,
11968,
8043,
13775,
4168,
1006,
2338,
1007,
1063,
13075,
8833,
4590,
1027,
2338,
1012,
2131,
21197,
4590,
1006,
1007,
1025,
2709,
11968,
8583,
18300,
5397,
8873,
2571,
1006,
2338,
1010,
1005,
3191,
4168,
1005,
1007,
1012,
3659,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | examples/3d/js/controls.js | function(event) {
this.states.left = false;
this.states.right = false;
this.states.front = false;
this.states.back = false;
event.preventDefault();
event.stopPropagation();
} | javascript | function(event) {
this.states.left = false;
this.states.right = false;
this.states.front = false;
this.states.back = false;
event.preventDefault();
event.stopPropagation();
} | [
"function",
"(",
"event",
")",
"{",
"this",
".",
"states",
".",
"left",
"=",
"false",
";",
"this",
".",
"states",
".",
"right",
"=",
"false",
";",
"this",
".",
"states",
".",
"front",
"=",
"false",
";",
"this",
".",
"states",
".",
"back",
"=",
"f... | Fired to reset all key statuses based on no fingers being on the screen.
@param {Object} event DOM event data including the position touched. | [
"Fired",
"to",
"reset",
"all",
"key",
"statuses",
"based",
"on",
"no",
"fingers",
"being",
"on",
"the",
"screen",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/3d/js/controls.js#L77-L85 | train | Stop the event | [
30522,
3853,
1006,
2724,
1007,
1063,
2023,
1012,
2163,
1012,
2187,
1027,
6270,
1025,
2023,
1012,
2163,
1012,
2157,
1027,
6270,
1025,
2023,
1012,
2163,
1012,
2392,
1027,
6270,
1025,
2023,
1012,
2163,
1012,
2067,
1027,
6270,
1025,
2724,
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/model/odata/_AnnotationHelperBasics.js | function (oPathValue, vProperty, vExpectedType) {
var oTarget = jQuery.extend({}, oPathValue);
Basics.expectType(oPathValue, typeof vProperty === "number" ? "array" : "object");
oTarget.path = oPathValue.path + "/" + vProperty;
oTarget.value = oPathValue.value[vProperty];
if (vExpectedType === true) {
oTarget.asExpression = true;
} else if (vExpectedType) {
Basics.expectType(oTarget, vExpectedType);
}
return oTarget;
} | javascript | function (oPathValue, vProperty, vExpectedType) {
var oTarget = jQuery.extend({}, oPathValue);
Basics.expectType(oPathValue, typeof vProperty === "number" ? "array" : "object");
oTarget.path = oPathValue.path + "/" + vProperty;
oTarget.value = oPathValue.value[vProperty];
if (vExpectedType === true) {
oTarget.asExpression = true;
} else if (vExpectedType) {
Basics.expectType(oTarget, vExpectedType);
}
return oTarget;
} | [
"function",
"(",
"oPathValue",
",",
"vProperty",
",",
"vExpectedType",
")",
"{",
"var",
"oTarget",
"=",
"jQuery",
".",
"extend",
"(",
"{",
"}",
",",
"oPathValue",
")",
";",
"Basics",
".",
"expectType",
"(",
"oPathValue",
",",
"typeof",
"vProperty",
"===",
... | Descends the path/value pair to the given property or array index. Logs an error and
throws an error if the result is not of the expected type.
@param {object} oPathValue
a path/value pair which may contain additional arbitrary properties
@param {string} oPathValue.path
the meta model path to start at
@param {object|any[]} oPathValue.value
the value at this path
@param {string|number} vProperty
the property name or array index
@param {boolean|string} [vExpectedType]
the expected type (tested w/ typeof) or the special value "array" for an array;
if <code>undefined</code> the result is not checked; <code>true</code> means that no
check happens, but the result carries the <code>asExpression : true</code> flag.
@returns {object}
the path/value pair after descending with all original additional properties
@throws {SyntaxError}
if the result is not of the expected type | [
"Descends",
"the",
"path",
"/",
"value",
"pair",
"to",
"the",
"given",
"property",
"or",
"array",
"index",
".",
"Logs",
"an",
"error",
"and",
"throws",
"an",
"error",
"if",
"the",
"result",
"is",
"not",
"of",
"the",
"expected",
"type",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_AnnotationHelperBasics.js#L68-L80 | train | Returns the target object for the given property | [
30522,
3853,
1006,
6728,
8988,
10175,
5657,
1010,
21210,
18981,
15010,
1010,
2310,
2595,
5051,
10985,
13874,
1007,
1063,
13075,
27178,
2906,
18150,
1027,
1046,
4226,
2854,
1012,
7949,
1006,
1063,
1065,
1010,
6728,
8988,
10175,
5657,
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... | |
sass/node-sass | lib/extensions.js | getVersionInfo | function getVersionInfo(binding) {
return [
['node-sass', pkg.version, '(Wrapper)', '[JavaScript]'].join('\t'),
['libsass ', binding.libsassVersion(), '(Sass Compiler)', '[C/C++]'].join('\t'),
].join(eol);
} | javascript | function getVersionInfo(binding) {
return [
['node-sass', pkg.version, '(Wrapper)', '[JavaScript]'].join('\t'),
['libsass ', binding.libsassVersion(), '(Sass Compiler)', '[C/C++]'].join('\t'),
].join(eol);
} | [
"function",
"getVersionInfo",
"(",
"binding",
")",
"{",
"return",
"[",
"[",
"'node-sass'",
",",
"pkg",
".",
"version",
",",
"'(Wrapper)'",
",",
"'[JavaScript]'",
"]",
".",
"join",
"(",
"'\\t'",
")",
",",
"[",
"'libsass '",
",",
"binding",
".",
"libsassVer... | Get Sass version information
@api public | [
"Get",
"Sass",
"version",
"information"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L412-L417 | train | Get the version info of the compiler | [
30522,
3853,
2131,
27774,
2378,
14876,
1006,
8031,
1007,
1063,
2709,
1031,
1031,
1005,
13045,
1011,
21871,
2015,
1005,
1010,
1052,
2243,
2290,
1012,
2544,
1010,
1005,
1006,
10236,
4842,
1007,
1005,
1010,
1005,
1031,
9262,
22483,
1033,
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... |
adobe/brackets | src/view/MainViewManager.js | addListToWorkingSet | function addListToWorkingSet(paneId, fileList) {
var uniqueFileList,
pane = _getPane(paneId);
uniqueFileList = pane.addListToViewList(fileList);
uniqueFileList.forEach(function (file) {
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
_mruList.push(_makeMRUListEntry(file, pane.id));
});
exports.trigger("workingSetAddList", uniqueFileList, pane.id);
// find all of the files that could be added but were not
var unsolvedList = fileList.filter(function (item) {
// if the file open in another pane, then add it to the list of unsolvedList
return (pane.findInViewList(item.fullPath) === -1 && _getPaneIdForPath(item.fullPath));
});
// Use the pane id of the first one in the list for pane id and recurse
// if we add more panes, then this will recurse until all items in the list are satisified
if (unsolvedList.length) {
addListToWorkingSet(_getPaneIdForPath(unsolvedList[0].fullPath), unsolvedList);
}
} | javascript | function addListToWorkingSet(paneId, fileList) {
var uniqueFileList,
pane = _getPane(paneId);
uniqueFileList = pane.addListToViewList(fileList);
uniqueFileList.forEach(function (file) {
if (_findFileInMRUList(pane.id, file) !== -1) {
console.log(file.fullPath + " duplicated in mru list");
}
_mruList.push(_makeMRUListEntry(file, pane.id));
});
exports.trigger("workingSetAddList", uniqueFileList, pane.id);
// find all of the files that could be added but were not
var unsolvedList = fileList.filter(function (item) {
// if the file open in another pane, then add it to the list of unsolvedList
return (pane.findInViewList(item.fullPath) === -1 && _getPaneIdForPath(item.fullPath));
});
// Use the pane id of the first one in the list for pane id and recurse
// if we add more panes, then this will recurse until all items in the list are satisified
if (unsolvedList.length) {
addListToWorkingSet(_getPaneIdForPath(unsolvedList[0].fullPath), unsolvedList);
}
} | [
"function",
"addListToWorkingSet",
"(",
"paneId",
",",
"fileList",
")",
"{",
"var",
"uniqueFileList",
",",
"pane",
"=",
"_getPane",
"(",
"paneId",
")",
";",
"uniqueFileList",
"=",
"pane",
".",
"addListToViewList",
"(",
"fileList",
")",
";",
"uniqueFileList",
"... | Adds the given file list to the end of the workingset.
@param {!string} paneId - The id of the pane in which to add the file object to or ACTIVE_PANE
@param {!Array.<File>} fileList - Array of files to add to the pane | [
"Adds",
"the",
"given",
"file",
"list",
"to",
"the",
"end",
"of",
"the",
"workingset",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/view/MainViewManager.js#L746-L772 | train | Add a list of files to the working set | [
30522,
3853,
5587,
9863,
18790,
2953,
6834,
13462,
1006,
6090,
7416,
2094,
1010,
5371,
9863,
1007,
1063,
13075,
4310,
8873,
2571,
9863,
1010,
6090,
2063,
1027,
1035,
2131,
9739,
2063,
1006,
6090,
7416,
2094,
1007,
1025,
4310,
8873,
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... |
nhn/tui.editor | src/js/extensions/table/tableRenderer.js | _createTheadOrTbodyHtml | function _createTheadOrTbodyHtml(trs, wrapperNodeName) {
let html = '';
if (trs.length) {
html = trs.map(tr => {
const tdHtml = tr.map(_createCellHtml).join('');
return `<tr>${tdHtml}</tr>`;
}).join('');
html = `<${wrapperNodeName}>${html}</${wrapperNodeName}>`;
}
return html;
} | javascript | function _createTheadOrTbodyHtml(trs, wrapperNodeName) {
let html = '';
if (trs.length) {
html = trs.map(tr => {
const tdHtml = tr.map(_createCellHtml).join('');
return `<tr>${tdHtml}</tr>`;
}).join('');
html = `<${wrapperNodeName}>${html}</${wrapperNodeName}>`;
}
return html;
} | [
"function",
"_createTheadOrTbodyHtml",
"(",
"trs",
",",
"wrapperNodeName",
")",
"{",
"let",
"html",
"=",
"''",
";",
"if",
"(",
"trs",
".",
"length",
")",
"{",
"html",
"=",
"trs",
".",
"map",
"(",
"tr",
"=>",
"{",
"const",
"tdHtml",
"=",
"tr",
".",
... | Create html for thead or tbody.
@param {Array.<Array.<object>>} trs - tr list
@param {string} wrapperNodeName - wrapper node name like THEAD, TBODY
@returns {string}
@private | [
"Create",
"html",
"for",
"thead",
"or",
"tbody",
"."
] | e75ab08c2a7ab07d1143e318f7cde135c5e3002e | https://github.com/nhn/tui.editor/blob/e75ab08c2a7ab07d1143e318f7cde135c5e3002e/src/js/extensions/table/tableRenderer.js#L30-L43 | train | Create html for the table head or tbody | [
30522,
3853,
1035,
3443,
10760,
26467,
2102,
23684,
11039,
19968,
1006,
19817,
2015,
1010,
10236,
4842,
3630,
4181,
14074,
1007,
1063,
2292,
16129,
1027,
1005,
1005,
1025,
2065,
1006,
19817,
2015,
1012,
3091,
1007,
1063,
16129,
1027,
19817,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
dimsemenov/PhotoSwipe | src/js/gestures.js | function(gestureType, _releaseAnimData) {
var itemChanged;
if(!_mainScrollAnimating) {
_currZoomedItemIndex = _currentItemIndex;
}
var itemsDiff;
if(gestureType === 'swipe') {
var totalShiftDist = _currPoint.x - _startPoint.x,
isFastLastFlick = _releaseAnimData.lastFlickDist.x < 10;
// if container is shifted for more than MIN_SWIPE_DISTANCE,
// and last flick gesture was in right direction
if(totalShiftDist > MIN_SWIPE_DISTANCE &&
(isFastLastFlick || _releaseAnimData.lastFlickOffset.x > 20) ) {
// go to prev item
itemsDiff = -1;
} else if(totalShiftDist < -MIN_SWIPE_DISTANCE &&
(isFastLastFlick || _releaseAnimData.lastFlickOffset.x < -20) ) {
// go to next item
itemsDiff = 1;
}
}
var nextCircle;
if(itemsDiff) {
_currentItemIndex += itemsDiff;
if(_currentItemIndex < 0) {
_currentItemIndex = _options.loop ? _getNumItems()-1 : 0;
nextCircle = true;
} else if(_currentItemIndex >= _getNumItems()) {
_currentItemIndex = _options.loop ? 0 : _getNumItems()-1;
nextCircle = true;
}
if(!nextCircle || _options.loop) {
_indexDiff += itemsDiff;
_currPositionIndex -= itemsDiff;
itemChanged = true;
}
}
var animateToX = _slideSize.x * _currPositionIndex;
var animateToDist = Math.abs( animateToX - _mainScrollPos.x );
var finishAnimDuration;
if(!itemChanged && animateToX > _mainScrollPos.x !== _releaseAnimData.lastFlickSpeed.x > 0) {
// "return to current" duration, e.g. when dragging from slide 0 to -1
finishAnimDuration = 333;
} else {
finishAnimDuration = Math.abs(_releaseAnimData.lastFlickSpeed.x) > 0 ?
animateToDist / Math.abs(_releaseAnimData.lastFlickSpeed.x) :
333;
finishAnimDuration = Math.min(finishAnimDuration, 400);
finishAnimDuration = Math.max(finishAnimDuration, 250);
}
if(_currZoomedItemIndex === _currentItemIndex) {
itemChanged = false;
}
_mainScrollAnimating = true;
_shout('mainScrollAnimStart');
_animateProp('mainScroll', _mainScrollPos.x, animateToX, finishAnimDuration, framework.easing.cubic.out,
_moveMainScroll,
function() {
_stopAllAnimations();
_mainScrollAnimating = false;
_currZoomedItemIndex = -1;
if(itemChanged || _currZoomedItemIndex !== _currentItemIndex) {
self.updateCurrItem();
}
_shout('mainScrollAnimComplete');
}
);
if(itemChanged) {
self.updateCurrItem(true);
}
return itemChanged;
} | javascript | function(gestureType, _releaseAnimData) {
var itemChanged;
if(!_mainScrollAnimating) {
_currZoomedItemIndex = _currentItemIndex;
}
var itemsDiff;
if(gestureType === 'swipe') {
var totalShiftDist = _currPoint.x - _startPoint.x,
isFastLastFlick = _releaseAnimData.lastFlickDist.x < 10;
// if container is shifted for more than MIN_SWIPE_DISTANCE,
// and last flick gesture was in right direction
if(totalShiftDist > MIN_SWIPE_DISTANCE &&
(isFastLastFlick || _releaseAnimData.lastFlickOffset.x > 20) ) {
// go to prev item
itemsDiff = -1;
} else if(totalShiftDist < -MIN_SWIPE_DISTANCE &&
(isFastLastFlick || _releaseAnimData.lastFlickOffset.x < -20) ) {
// go to next item
itemsDiff = 1;
}
}
var nextCircle;
if(itemsDiff) {
_currentItemIndex += itemsDiff;
if(_currentItemIndex < 0) {
_currentItemIndex = _options.loop ? _getNumItems()-1 : 0;
nextCircle = true;
} else if(_currentItemIndex >= _getNumItems()) {
_currentItemIndex = _options.loop ? 0 : _getNumItems()-1;
nextCircle = true;
}
if(!nextCircle || _options.loop) {
_indexDiff += itemsDiff;
_currPositionIndex -= itemsDiff;
itemChanged = true;
}
}
var animateToX = _slideSize.x * _currPositionIndex;
var animateToDist = Math.abs( animateToX - _mainScrollPos.x );
var finishAnimDuration;
if(!itemChanged && animateToX > _mainScrollPos.x !== _releaseAnimData.lastFlickSpeed.x > 0) {
// "return to current" duration, e.g. when dragging from slide 0 to -1
finishAnimDuration = 333;
} else {
finishAnimDuration = Math.abs(_releaseAnimData.lastFlickSpeed.x) > 0 ?
animateToDist / Math.abs(_releaseAnimData.lastFlickSpeed.x) :
333;
finishAnimDuration = Math.min(finishAnimDuration, 400);
finishAnimDuration = Math.max(finishAnimDuration, 250);
}
if(_currZoomedItemIndex === _currentItemIndex) {
itemChanged = false;
}
_mainScrollAnimating = true;
_shout('mainScrollAnimStart');
_animateProp('mainScroll', _mainScrollPos.x, animateToX, finishAnimDuration, framework.easing.cubic.out,
_moveMainScroll,
function() {
_stopAllAnimations();
_mainScrollAnimating = false;
_currZoomedItemIndex = -1;
if(itemChanged || _currZoomedItemIndex !== _currentItemIndex) {
self.updateCurrItem();
}
_shout('mainScrollAnimComplete');
}
);
if(itemChanged) {
self.updateCurrItem(true);
}
return itemChanged;
} | [
"function",
"(",
"gestureType",
",",
"_releaseAnimData",
")",
"{",
"var",
"itemChanged",
";",
"if",
"(",
"!",
"_mainScrollAnimating",
")",
"{",
"_currZoomedItemIndex",
"=",
"_currentItemIndex",
";",
"}",
"var",
"itemsDiff",
";",
"if",
"(",
"gestureType",
"===",
... | amount of pixels to drag to determine direction of swipe | [
"amount",
"of",
"pixels",
"to",
"drag",
"to",
"determine",
"direction",
"of",
"swipe"
] | 80607e12542a1a54ecefa837649e862b35dffd25 | https://github.com/dimsemenov/PhotoSwipe/blob/80607e12542a1a54ecefa837649e862b35dffd25/src/js/gestures.js#L950-L1046 | train | Animate the current item based on the current position | [
30522,
3853,
1006,
9218,
13874,
1010,
1035,
2713,
7088,
26876,
6790,
1007,
1063,
13075,
8875,
22305,
2098,
1025,
2065,
1006,
999,
1035,
2364,
11020,
28402,
7088,
18900,
2075,
1007,
1063,
1035,
12731,
12171,
23221,
7583,
4221,
23356,
10288,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/QUnitUtils.js | getKeyCodeStringFromNumber | function getKeyCodeStringFromNumber(iKeyCode) {
for (var sKey in KeyCodes) {
if (KeyCodes.hasOwnProperty(sKey)) {
if (KeyCodes[sKey] === iKeyCode) {
return sKey;
}
}
}
} | javascript | function getKeyCodeStringFromNumber(iKeyCode) {
for (var sKey in KeyCodes) {
if (KeyCodes.hasOwnProperty(sKey)) {
if (KeyCodes[sKey] === iKeyCode) {
return sKey;
}
}
}
} | [
"function",
"getKeyCodeStringFromNumber",
"(",
"iKeyCode",
")",
"{",
"for",
"(",
"var",
"sKey",
"in",
"KeyCodes",
")",
"{",
"if",
"(",
"KeyCodes",
".",
"hasOwnProperty",
"(",
"sKey",
")",
")",
"{",
"if",
"(",
"KeyCodes",
"[",
"sKey",
"]",
"===",
"iKeyCod... | Retrieves keycode string from number
@param iKeyCode
@returns {string} | [
"Retrieves",
"keycode",
"string",
"from",
"number"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/QUnitUtils.js#L411-L419 | train | Get the key code string from a number | [
30522,
3853,
2131,
14839,
23237,
18886,
3070,
19699,
5358,
19172,
5677,
1006,
25209,
2100,
16044,
1007,
1063,
2005,
1006,
13075,
15315,
3240,
1999,
3145,
23237,
1007,
1063,
2065,
1006,
3145,
23237,
1012,
2038,
12384,
21572,
4842,
3723,
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... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function ()
{
var node = null;
if (this.xhr.responseXML && this.xhr.responseXML.documentElement) {
node = this.xhr.responseXML.documentElement;
if (node.tagName == "parsererror") {
Strophe.error("invalid response received");
Strophe.error("responseText: " + this.xhr.responseText);
Strophe.error("responseXML: " +
Strophe.serialize(this.xhr.responseXML));
throw "parsererror";
}
} else if (this.xhr.responseText) {
Strophe.error("invalid response received");
Strophe.error("responseText: " + this.xhr.responseText);
Strophe.error("responseXML: " +
Strophe.serialize(this.xhr.responseXML));
}
return node;
} | javascript | function ()
{
var node = null;
if (this.xhr.responseXML && this.xhr.responseXML.documentElement) {
node = this.xhr.responseXML.documentElement;
if (node.tagName == "parsererror") {
Strophe.error("invalid response received");
Strophe.error("responseText: " + this.xhr.responseText);
Strophe.error("responseXML: " +
Strophe.serialize(this.xhr.responseXML));
throw "parsererror";
}
} else if (this.xhr.responseText) {
Strophe.error("invalid response received");
Strophe.error("responseText: " + this.xhr.responseText);
Strophe.error("responseXML: " +
Strophe.serialize(this.xhr.responseXML));
}
return node;
} | [
"function",
"(",
")",
"{",
"var",
"node",
"=",
"null",
";",
"if",
"(",
"this",
".",
"xhr",
".",
"responseXML",
"&&",
"this",
".",
"xhr",
".",
"responseXML",
".",
"documentElement",
")",
"{",
"node",
"=",
"this",
".",
"xhr",
".",
"responseXML",
".",
... | PrivateFunction: getResponse
Get a response from the underlying XMLHttpRequest.
This function attempts to get a response from the request and checks
for errors.
Throws:
"parsererror" - A parser error occured.
Returns:
The DOM element tree of the response. | [
"PrivateFunction",
":",
"getResponse",
"Get",
"a",
"response",
"from",
"the",
"underlying",
"XMLHttpRequest",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L3927-L3947 | train | Returns the node of the last term in the SEASIA SE | [
30522,
3853,
1006,
1007,
1063,
13075,
13045,
1027,
19701,
1025,
2065,
1006,
2023,
1012,
1060,
8093,
1012,
3433,
2595,
19968,
1004,
1004,
2023,
1012,
1060,
8093,
1012,
3433,
2595,
19968,
1012,
6254,
12260,
3672,
1007,
1063,
13045,
1027,
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... | |
eslint/eslint | lib/rules/prefer-numeric-literals.js | isParseInt | function isParseInt(calleeNode) {
switch (calleeNode.type) {
case "Identifier":
return calleeNode.name === "parseInt";
case "MemberExpression":
return calleeNode.object.type === "Identifier" &&
calleeNode.object.name === "Number" &&
calleeNode.property.type === "Identifier" &&
calleeNode.property.name === "parseInt";
// no default
}
return false;
} | javascript | function isParseInt(calleeNode) {
switch (calleeNode.type) {
case "Identifier":
return calleeNode.name === "parseInt";
case "MemberExpression":
return calleeNode.object.type === "Identifier" &&
calleeNode.object.name === "Number" &&
calleeNode.property.type === "Identifier" &&
calleeNode.property.name === "parseInt";
// no default
}
return false;
} | [
"function",
"isParseInt",
"(",
"calleeNode",
")",
"{",
"switch",
"(",
"calleeNode",
".",
"type",
")",
"{",
"case",
"\"Identifier\"",
":",
"return",
"calleeNode",
".",
"name",
"===",
"\"parseInt\"",
";",
"case",
"\"MemberExpression\"",
":",
"return",
"calleeNode"... | ------------------------------------------------------------------------------ Helpers ------------------------------------------------------------------------------
Checks to see if a CallExpression's callee node is `parseInt` or
`Number.parseInt`.
@param {ASTNode} calleeNode The callee node to evaluate.
@returns {boolean} True if the callee is `parseInt` or `Number.parseInt`,
false otherwise. | [
"------------------------------------------------------------------------------",
"Helpers",
"------------------------------------------------------------------------------",
"Checks",
"to",
"see",
"if",
"a",
"CallExpression",
"s",
"callee",
"node",
"is",
"parseInt",
"or",
"Number",
... | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/prefer-numeric-literals.js#L19-L33 | train | Determines if a node is an integer | [
30522,
3853,
2003,
19362,
20240,
3372,
1006,
2655,
12129,
10244,
1007,
1063,
6942,
1006,
2655,
12129,
10244,
1012,
2828,
1007,
1063,
2553,
1000,
8909,
4765,
18095,
1000,
1024,
2709,
2655,
12129,
10244,
1012,
2171,
1027,
1027,
1027,
1000,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | lib/jsdoc/ui5/template/publish.js | createInheritanceTree | function createInheritanceTree() {
function makeDoclet(longname, lines) {
lines.push("@name " + longname);
var newDoclet = new doclet.Doclet("/**\n * " + lines.join("\n * ") + "\n */", {});
newDoclet.__ui5 = {};
__longnames[longname] = newDoclet;
__db.insert(newDoclet);
return newDoclet;
}
info("create inheritance tree (" + __db().count() + " symbols)");
var oTypes = __db(function() { return supportsInheritance(this); });
var aRootTypes = [];
var oObject = lookup("Object");
if ( !oObject ) {
oObject = makeDoclet("Object", [
"@class",
"@synthetic",
"@public"
]);
aRootTypes.push(oObject);
}
function getOrCreateClass(sClass, sExtendingClass) {
var oClass = lookup(sClass);
if ( !oClass ) {
warning("create missing class " + sClass + " (extended by " + sExtendingClass + ")");
var sBaseClass = 'Object';
if ( externalSymbols[sClass] ) {
sBaseClass = externalSymbols[sClass].extends || sBaseClass;
}
var oBaseClass = getOrCreateClass(sBaseClass, sClass);
oClass = makeDoclet(sClass, [
"@extends " + sBaseClass,
"@class",
"@synthetic",
"@public"
]);
oClass.__ui5.base = oBaseClass;
oBaseClass.__ui5.derived = oBaseClass.__ui5.derived || [];
oBaseClass.__ui5.derived.push(oClass);
}
return oClass;
}
// link them according to the inheritance infos
oTypes.each(function(oClass) {
if ( oClass.longname === 'Object') {
return;
}
var sBaseClass = "Object";
if ( oClass.augments && oClass.augments.length > 0 ) {
if ( oClass.augments.length > 1 ) {
warning("multiple inheritance detected in " + oClass.longname);
}
sBaseClass = oClass.augments[0];
} else {
aRootTypes.push(oClass);
}
var oBaseClass = getOrCreateClass(sBaseClass, oClass.longname);
oClass.__ui5.base = oBaseClass;
oBaseClass.__ui5.derived = oBaseClass.__ui5.derived || [];
oBaseClass.__ui5.derived.push(oClass);
if ( oClass.implements ) {
for (var j = 0; j < oClass.implements.length; j++) {
var oInterface = lookup(oClass.implements[j]);
if ( !oInterface ) {
warning("create missing interface " + oClass.implements[j]);
oInterface = makeDoclet(oClass.implements[j], [
"@extends Object",
"@interface",
"@synthetic",
"@public"
]);
oInterface.__ui5.base = oObject;
oObject.__ui5.derived = oObject.__ui5.derived || [];
oObject.__ui5.derived.push(oInterface);
}
oInterface.__ui5.implementations = oInterface.__ui5.implementations || [];
oInterface.__ui5.implementations.push(oClass);
}
}
});
function setStereotype(oSymbol, sStereotype) {
if ( !oSymbol ) {
return;
}
oSymbol.__ui5.stereotype = sStereotype;
var derived = oSymbol.__ui5.derived;
if ( derived ) {
for (var i = 0; i < derived.length; i++ ) {
if ( !derived[i].__ui5.stereotype ) {
setStereotype(derived[i], sStereotype);
}
}
}
}
setStereotype(lookup("sap.ui.core.Component"), "component");
setStereotype(lookup("sap.ui.core.Control"), "control");
setStereotype(lookup("sap.ui.core.Element"), "element");
setStereotype(lookup("sap.ui.base.Object"), "object");
// check for cyclic inheritance (not supported)
// Note: the check needs to run bottom up, not top down as a typical cyclic dependency never will end at the root node
oTypes.each(function(oStartClass) {
var visited = {};
function visit(oClass) {
if ( visited[oClass.longname] ) {
throw new Error("cyclic inheritance detected: " + JSON.stringify(Object.keys(visited)));
}
if ( oClass.__ui5.base ) {
visited[oClass.longname] = true;
visit(oClass.__ui5.base);
delete visited[oClass.longname];
}
}
visit(oStartClass);
});
// collect root nodes (and ignore pure packages)
return aRootTypes;
/*
return __db(function() {
return R_KINDS.test(this.kind) && this.__ui5 && this.__ui5.base == null;
}).get();
*/
} | javascript | function createInheritanceTree() {
function makeDoclet(longname, lines) {
lines.push("@name " + longname);
var newDoclet = new doclet.Doclet("/**\n * " + lines.join("\n * ") + "\n */", {});
newDoclet.__ui5 = {};
__longnames[longname] = newDoclet;
__db.insert(newDoclet);
return newDoclet;
}
info("create inheritance tree (" + __db().count() + " symbols)");
var oTypes = __db(function() { return supportsInheritance(this); });
var aRootTypes = [];
var oObject = lookup("Object");
if ( !oObject ) {
oObject = makeDoclet("Object", [
"@class",
"@synthetic",
"@public"
]);
aRootTypes.push(oObject);
}
function getOrCreateClass(sClass, sExtendingClass) {
var oClass = lookup(sClass);
if ( !oClass ) {
warning("create missing class " + sClass + " (extended by " + sExtendingClass + ")");
var sBaseClass = 'Object';
if ( externalSymbols[sClass] ) {
sBaseClass = externalSymbols[sClass].extends || sBaseClass;
}
var oBaseClass = getOrCreateClass(sBaseClass, sClass);
oClass = makeDoclet(sClass, [
"@extends " + sBaseClass,
"@class",
"@synthetic",
"@public"
]);
oClass.__ui5.base = oBaseClass;
oBaseClass.__ui5.derived = oBaseClass.__ui5.derived || [];
oBaseClass.__ui5.derived.push(oClass);
}
return oClass;
}
// link them according to the inheritance infos
oTypes.each(function(oClass) {
if ( oClass.longname === 'Object') {
return;
}
var sBaseClass = "Object";
if ( oClass.augments && oClass.augments.length > 0 ) {
if ( oClass.augments.length > 1 ) {
warning("multiple inheritance detected in " + oClass.longname);
}
sBaseClass = oClass.augments[0];
} else {
aRootTypes.push(oClass);
}
var oBaseClass = getOrCreateClass(sBaseClass, oClass.longname);
oClass.__ui5.base = oBaseClass;
oBaseClass.__ui5.derived = oBaseClass.__ui5.derived || [];
oBaseClass.__ui5.derived.push(oClass);
if ( oClass.implements ) {
for (var j = 0; j < oClass.implements.length; j++) {
var oInterface = lookup(oClass.implements[j]);
if ( !oInterface ) {
warning("create missing interface " + oClass.implements[j]);
oInterface = makeDoclet(oClass.implements[j], [
"@extends Object",
"@interface",
"@synthetic",
"@public"
]);
oInterface.__ui5.base = oObject;
oObject.__ui5.derived = oObject.__ui5.derived || [];
oObject.__ui5.derived.push(oInterface);
}
oInterface.__ui5.implementations = oInterface.__ui5.implementations || [];
oInterface.__ui5.implementations.push(oClass);
}
}
});
function setStereotype(oSymbol, sStereotype) {
if ( !oSymbol ) {
return;
}
oSymbol.__ui5.stereotype = sStereotype;
var derived = oSymbol.__ui5.derived;
if ( derived ) {
for (var i = 0; i < derived.length; i++ ) {
if ( !derived[i].__ui5.stereotype ) {
setStereotype(derived[i], sStereotype);
}
}
}
}
setStereotype(lookup("sap.ui.core.Component"), "component");
setStereotype(lookup("sap.ui.core.Control"), "control");
setStereotype(lookup("sap.ui.core.Element"), "element");
setStereotype(lookup("sap.ui.base.Object"), "object");
// check for cyclic inheritance (not supported)
// Note: the check needs to run bottom up, not top down as a typical cyclic dependency never will end at the root node
oTypes.each(function(oStartClass) {
var visited = {};
function visit(oClass) {
if ( visited[oClass.longname] ) {
throw new Error("cyclic inheritance detected: " + JSON.stringify(Object.keys(visited)));
}
if ( oClass.__ui5.base ) {
visited[oClass.longname] = true;
visit(oClass.__ui5.base);
delete visited[oClass.longname];
}
}
visit(oStartClass);
});
// collect root nodes (and ignore pure packages)
return aRootTypes;
/*
return __db(function() {
return R_KINDS.test(this.kind) && this.__ui5 && this.__ui5.base == null;
}).get();
*/
} | [
"function",
"createInheritanceTree",
"(",
")",
"{",
"function",
"makeDoclet",
"(",
"longname",
",",
"lines",
")",
"{",
"lines",
".",
"push",
"(",
"\"@name \"",
"+",
"longname",
")",
";",
"var",
"newDoclet",
"=",
"new",
"doclet",
".",
"Doclet",
"(",
"\"/**\... | ---- inheritance hierarchy ---------------------------------------------------------------------------- /*
Calculates the inheritance hierarchy for all class/interface/namespace symbols.
Each node in the tree has the content
Node : {
longname : {string} // name of the node (usually equals symbol.longname)
symbol : {Symbol} // backlink to the original symbol
base : {Node} // parent node or undefined for root nodes
derived : {Node[]} // subclasses/-types
} | [
"----",
"inheritance",
"hierarchy",
"----------------------------------------------------------------------------",
"/",
"*",
"Calculates",
"the",
"inheritance",
"hierarchy",
"for",
"all",
"class",
"/",
"interface",
"/",
"namespace",
"symbols",
".",
"Each",
"node",
"in",
... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/ui5/template/publish.js#L715-L850 | train | Creates a tree of inheritance symbols. | [
30522,
3853,
3443,
2378,
5886,
25451,
3401,
13334,
1006,
1007,
1063,
3853,
2191,
3527,
14321,
2102,
1006,
2146,
18442,
1010,
3210,
1007,
1063,
3210,
1012,
5245,
1006,
1000,
1030,
2171,
1000,
1009,
2146,
18442,
1007,
1025,
13075,
2047,
3527,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/CodeFolding/foldhelpers/foldgutter.js | getFoldOnLine | function getFoldOnLine(cm, line) {
var pos = CodeMirror.Pos(line, 0);
var folds = cm.findMarksAt(pos) || [];
folds = folds.filter(isFold);
return folds.length ? folds[0] : undefined;
} | javascript | function getFoldOnLine(cm, line) {
var pos = CodeMirror.Pos(line, 0);
var folds = cm.findMarksAt(pos) || [];
folds = folds.filter(isFold);
return folds.length ? folds[0] : undefined;
} | [
"function",
"getFoldOnLine",
"(",
"cm",
",",
"line",
")",
"{",
"var",
"pos",
"=",
"CodeMirror",
".",
"Pos",
"(",
"line",
",",
"0",
")",
";",
"var",
"folds",
"=",
"cm",
".",
"findMarksAt",
"(",
"pos",
")",
"||",
"[",
"]",
";",
"folds",
"=",
"folds... | Helper function to return the fold text marker on a line in an editor
@param {CodeMirror} cm The CodeMirror instance for the active editor
@param {Number} line The line number representing the position of the fold marker
@returns {TextMarker} A CodeMirror TextMarker object | [
"Helper",
"function",
"to",
"return",
"the",
"fold",
"text",
"marker",
"on",
"a",
"line",
"in",
"an",
"editor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/CodeFolding/foldhelpers/foldgutter.js#L149-L154 | train | Get the first fold on the line | [
30522,
3853,
2131,
10371,
2239,
4179,
1006,
4642,
1010,
2240,
1007,
1063,
13075,
13433,
2015,
1027,
3642,
14503,
29165,
1012,
13433,
2015,
1006,
2240,
1010,
1014,
1007,
1025,
13075,
15439,
1027,
4642,
1012,
2424,
27373,
4017,
1006,
13433,
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... |
Tonejs/Tone.js | Tone/signal/TickSignal.js | _wrapScheduleMethods | function _wrapScheduleMethods(method){
return function(value, time){
time = this.toSeconds(time);
method.apply(this, arguments);
var event = this._events.get(time);
var previousEvent = this._events.previousEvent(event);
var ticksUntilTime = this._getTicksUntilEvent(previousEvent, time);
event.ticks = Math.max(ticksUntilTime, 0);
return this;
};
} | javascript | function _wrapScheduleMethods(method){
return function(value, time){
time = this.toSeconds(time);
method.apply(this, arguments);
var event = this._events.get(time);
var previousEvent = this._events.previousEvent(event);
var ticksUntilTime = this._getTicksUntilEvent(previousEvent, time);
event.ticks = Math.max(ticksUntilTime, 0);
return this;
};
} | [
"function",
"_wrapScheduleMethods",
"(",
"method",
")",
"{",
"return",
"function",
"(",
"value",
",",
"time",
")",
"{",
"time",
"=",
"this",
".",
"toSeconds",
"(",
"time",
")",
";",
"method",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var"... | Wraps Tone.Signal methods so that they also
record the ticks.
@param {Function} method
@return {Function}
@private | [
"Wraps",
"Tone",
".",
"Signal",
"methods",
"so",
"that",
"they",
"also",
"record",
"the",
"ticks",
"."
] | bb67e9c83d5553dfaa3c10babc147600aa14c147 | https://github.com/Tonejs/Tone.js/blob/bb67e9c83d5553dfaa3c10babc147600aa14c147/Tone/signal/TickSignal.js#L46-L56 | train | Wrap the given method to add a time to the last scheduled event | [
30522,
3853,
1035,
19735,
7690,
9307,
11368,
6806,
5104,
1006,
4118,
1007,
1063,
2709,
3853,
1006,
3643,
1010,
2051,
1007,
1063,
2051,
1027,
2023,
1012,
2000,
3366,
8663,
5104,
1006,
2051,
1007,
1025,
4118,
1012,
6611,
1006,
2023,
1010,
9... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/selenium-core/scripts/selenium-browserbot.js | function(topLevelApplicationWindow) {
this.topWindow = topLevelApplicationWindow;
this.topFrame = this.topWindow;
this.baseUrl=window.location.href;
// the buttonWindow is the Selenium window
// it contains the Run/Pause buttons... this should *not* be the AUT window
this.buttonWindow = window;
this.currentWindow = this.topWindow;
this.currentWindowName = null;
this.allowNativeXpath = true;
this.xpathEvaluator = new XPathEvaluator('ajaxslt'); // change to "javascript-xpath" for the newer, faster engine
// We need to know this in advance, in case the frame closes unexpectedly
this.isSubFrameSelected = false;
this.altKeyDown = false;
this.controlKeyDown = false;
this.shiftKeyDown = false;
this.metaKeyDown = false;
this.modalDialogTest = null;
this.recordedAlerts = new Array();
this.recordedConfirmations = new Array();
this.recordedPrompts = new Array();
this.openedWindows = {};
this.nextConfirmResult = true;
this.nextPromptResult = '';
this.newPageLoaded = false;
this.pageLoadError = null;
this.ignoreResponseCode = false;
this.xhr = null;
this.abortXhr = false;
this.isXhrSent = false;
this.isXhrDone = false;
this.xhrOpenLocation = null;
this.xhrResponseCode = null;
this.xhrStatusText = null;
this.shouldHighlightLocatedElement = false;
this.uniqueId = "seleniumMarker" + new Date().getTime();
this.pollingForLoad = new Object();
this.permDeniedCount = new Object();
this.windowPollers = new Array();
// DGF for backwards compatibility
this.browserbot = this;
var self = this;
objectExtend(this, PageBot.prototype);
this._registerAllLocatorFunctions();
this.recordPageLoad = function(elementOrWindow) {
LOG.debug("Page load detected");
try {
if (elementOrWindow.location && elementOrWindow.location.href) {
LOG.debug("Page load location=" + elementOrWindow.location.href);
} else if (elementOrWindow.contentWindow && elementOrWindow.contentWindow.location && elementOrWindow.contentWindow.location.href) {
LOG.debug("Page load location=" + elementOrWindow.contentWindow.location.href);
} else {
LOG.debug("Page load location unknown, current window location=" + self.getCurrentWindow(true).location);
}
} catch (e) {
LOG.error("Caught an exception attempting to log location; this should get noticed soon!");
LOG.exception(e);
self.pageLoadError = e;
return;
}
self.newPageLoaded = true;
};
this.isNewPageLoaded = function() {
var e;
if (this.pageLoadError) {
LOG.error("isNewPageLoaded found an old pageLoadError: " + this.pageLoadError);
if (this.pageLoadError.stack) {
LOG.warn("Stack is: " + this.pageLoadError.stack);
}
e = this.pageLoadError;
this.pageLoadError = null;
throw e;
}
if (self.ignoreResponseCode) {
return self.newPageLoaded;
} else {
if (self.isXhrSent && self.isXhrDone) {
if (!((self.xhrResponseCode >= 200 && self.xhrResponseCode <= 399) || self.xhrResponseCode == 0)) {
// TODO: for IE status like: 12002, 12007, ... provide corresponding statusText messages also.
LOG.error("XHR failed with message " + self.xhrStatusText);
e = "XHR ERROR: URL = " + self.xhrOpenLocation + " Response_Code = " + self.xhrResponseCode + " Error_Message = " + self.xhrStatusText;
self.abortXhr = false;
self.isXhrSent = false;
self.isXhrDone = false;
self.xhrResponseCode = null;
self.xhrStatusText = null;
throw new SeleniumError(e);
}
}
return self.newPageLoaded && (self.isXhrSent ? (self.abortXhr || self.isXhrDone) : true);
}
};
this.setAllowNativeXPath = function(allow) {
this.xpathEvaluator.setAllowNativeXPath(allow);
};
this.setIgnoreAttributesWithoutValue = function(ignore) {
this.xpathEvaluator.setIgnoreAttributesWithoutValue(ignore);
};
this.setXPathEngine = function(engineName) {
this.xpathEvaluator.setCurrentEngine(engineName);
};
this.getXPathEngine = function() {
return this.xpathEvaluator.getCurrentEngine();
};
} | javascript | function(topLevelApplicationWindow) {
this.topWindow = topLevelApplicationWindow;
this.topFrame = this.topWindow;
this.baseUrl=window.location.href;
// the buttonWindow is the Selenium window
// it contains the Run/Pause buttons... this should *not* be the AUT window
this.buttonWindow = window;
this.currentWindow = this.topWindow;
this.currentWindowName = null;
this.allowNativeXpath = true;
this.xpathEvaluator = new XPathEvaluator('ajaxslt'); // change to "javascript-xpath" for the newer, faster engine
// We need to know this in advance, in case the frame closes unexpectedly
this.isSubFrameSelected = false;
this.altKeyDown = false;
this.controlKeyDown = false;
this.shiftKeyDown = false;
this.metaKeyDown = false;
this.modalDialogTest = null;
this.recordedAlerts = new Array();
this.recordedConfirmations = new Array();
this.recordedPrompts = new Array();
this.openedWindows = {};
this.nextConfirmResult = true;
this.nextPromptResult = '';
this.newPageLoaded = false;
this.pageLoadError = null;
this.ignoreResponseCode = false;
this.xhr = null;
this.abortXhr = false;
this.isXhrSent = false;
this.isXhrDone = false;
this.xhrOpenLocation = null;
this.xhrResponseCode = null;
this.xhrStatusText = null;
this.shouldHighlightLocatedElement = false;
this.uniqueId = "seleniumMarker" + new Date().getTime();
this.pollingForLoad = new Object();
this.permDeniedCount = new Object();
this.windowPollers = new Array();
// DGF for backwards compatibility
this.browserbot = this;
var self = this;
objectExtend(this, PageBot.prototype);
this._registerAllLocatorFunctions();
this.recordPageLoad = function(elementOrWindow) {
LOG.debug("Page load detected");
try {
if (elementOrWindow.location && elementOrWindow.location.href) {
LOG.debug("Page load location=" + elementOrWindow.location.href);
} else if (elementOrWindow.contentWindow && elementOrWindow.contentWindow.location && elementOrWindow.contentWindow.location.href) {
LOG.debug("Page load location=" + elementOrWindow.contentWindow.location.href);
} else {
LOG.debug("Page load location unknown, current window location=" + self.getCurrentWindow(true).location);
}
} catch (e) {
LOG.error("Caught an exception attempting to log location; this should get noticed soon!");
LOG.exception(e);
self.pageLoadError = e;
return;
}
self.newPageLoaded = true;
};
this.isNewPageLoaded = function() {
var e;
if (this.pageLoadError) {
LOG.error("isNewPageLoaded found an old pageLoadError: " + this.pageLoadError);
if (this.pageLoadError.stack) {
LOG.warn("Stack is: " + this.pageLoadError.stack);
}
e = this.pageLoadError;
this.pageLoadError = null;
throw e;
}
if (self.ignoreResponseCode) {
return self.newPageLoaded;
} else {
if (self.isXhrSent && self.isXhrDone) {
if (!((self.xhrResponseCode >= 200 && self.xhrResponseCode <= 399) || self.xhrResponseCode == 0)) {
// TODO: for IE status like: 12002, 12007, ... provide corresponding statusText messages also.
LOG.error("XHR failed with message " + self.xhrStatusText);
e = "XHR ERROR: URL = " + self.xhrOpenLocation + " Response_Code = " + self.xhrResponseCode + " Error_Message = " + self.xhrStatusText;
self.abortXhr = false;
self.isXhrSent = false;
self.isXhrDone = false;
self.xhrResponseCode = null;
self.xhrStatusText = null;
throw new SeleniumError(e);
}
}
return self.newPageLoaded && (self.isXhrSent ? (self.abortXhr || self.isXhrDone) : true);
}
};
this.setAllowNativeXPath = function(allow) {
this.xpathEvaluator.setAllowNativeXPath(allow);
};
this.setIgnoreAttributesWithoutValue = function(ignore) {
this.xpathEvaluator.setIgnoreAttributesWithoutValue(ignore);
};
this.setXPathEngine = function(engineName) {
this.xpathEvaluator.setCurrentEngine(engineName);
};
this.getXPathEngine = function() {
return this.xpathEvaluator.getCurrentEngine();
};
} | [
"function",
"(",
"topLevelApplicationWindow",
")",
"{",
"this",
".",
"topWindow",
"=",
"topLevelApplicationWindow",
";",
"this",
".",
"topFrame",
"=",
"this",
".",
"topWindow",
";",
"this",
".",
"baseUrl",
"=",
"window",
".",
"location",
".",
"href",
";",
"/... | The window to which the commands will be sent. For example, to click on a popup window, first select that window, and then do a normal click command. | [
"The",
"window",
"to",
"which",
"the",
"commands",
"will",
"be",
"sent",
".",
"For",
"example",
"to",
"click",
"on",
"a",
"popup",
"window",
"first",
"select",
"that",
"window",
"and",
"then",
"do",
"a",
"normal",
"click",
"command",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/selenium-browserbot.js#L29-L150 | train | The page bot class | [
30522,
3853,
1006,
2327,
20414,
10581,
9397,
19341,
3508,
11101,
5004,
1007,
1063,
2023,
1012,
2327,
11101,
5004,
1027,
2327,
20414,
10581,
9397,
19341,
3508,
11101,
5004,
1025,
2023,
1012,
2327,
15643,
1027,
2023,
1012,
2327,
11101,
5004,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.