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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
angular/material | docs/app/js/codepen.js | Codepen | function Codepen($demoAngularScripts, $document, codepenDataAdapter) {
// The following URL used to be HTTP and not HTTPS to allow us to do localhost testing
// It's no longer working, for more info:
// https://blog.codepen.io/2017/03/31/codepen-going-https/
var CODEPEN_API = 'https://codepen.io/pen/define/';
return {
editOnCodepen: editOnCodepen
};
// Creates a codepen from the given demo model by posting to Codepen's API
// using a hidden form. The hidden form is necessary to avoid a CORS issue.
// See http://blog.codepen.io/documentation/api/prefill
function editOnCodepen(demo) {
var externalScripts = $demoAngularScripts.all();
externalScripts.push('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.js');
var data = codepenDataAdapter.translate(demo, externalScripts);
var form = buildForm(data);
$document.find('body').append(form);
form[0].submit();
form.remove();
}
// Builds a hidden form with data necessary to create a codepen.
function buildForm(data) {
var form = angular.element(
'<form style="display: none;" method="post" target="_blank" action="' +
CODEPEN_API +
'"></form>'
);
var input = '<input type="hidden" name="data" value="' + escapeJsonQuotes(data) + '" />';
form.append(input);
return form;
}
// Recommended by Codepen to escape quotes.
// See http://blog.codepen.io/documentation/api/prefill
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 Codepen($demoAngularScripts, $document, codepenDataAdapter) {
// The following URL used to be HTTP and not HTTPS to allow us to do localhost testing
// It's no longer working, for more info:
// https://blog.codepen.io/2017/03/31/codepen-going-https/
var CODEPEN_API = 'https://codepen.io/pen/define/';
return {
editOnCodepen: editOnCodepen
};
// Creates a codepen from the given demo model by posting to Codepen's API
// using a hidden form. The hidden form is necessary to avoid a CORS issue.
// See http://blog.codepen.io/documentation/api/prefill
function editOnCodepen(demo) {
var externalScripts = $demoAngularScripts.all();
externalScripts.push('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.js');
var data = codepenDataAdapter.translate(demo, externalScripts);
var form = buildForm(data);
$document.find('body').append(form);
form[0].submit();
form.remove();
}
// Builds a hidden form with data necessary to create a codepen.
function buildForm(data) {
var form = angular.element(
'<form style="display: none;" method="post" target="_blank" action="' +
CODEPEN_API +
'"></form>'
);
var input = '<input type="hidden" name="data" value="' + escapeJsonQuotes(data) + '" />';
form.append(input);
return form;
}
// Recommended by Codepen to escape quotes.
// See http://blog.codepen.io/documentation/api/prefill
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",
"Codepen",
"(",
"$demoAngularScripts",
",",
"$document",
",",
"codepenDataAdapter",
")",
"{",
"// The following URL used to be HTTP and not HTTPS to allow us to do localhost testing",
"// It's no longer working, for more info:",
"// https://blog.codepen.io/2017/03/31/codepen-goin... | Provides a service to open a code example in codepen. | [
"Provides",
"a",
"service",
"to",
"open",
"a",
"code",
"example",
"in",
"codepen",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/docs/app/js/codepen.js#L7-L57 | train | Codepen is a demo model that is used to generate a code phrase. | [
30522,
3853,
3642,
11837,
1006,
1002,
9703,
5654,
7934,
22483,
2015,
1010,
1002,
6254,
1010,
3642,
11837,
2850,
2696,
8447,
13876,
2121,
1007,
1063,
1013,
1013,
1996,
2206,
24471,
2140,
2109,
2000,
2022,
8299,
1998,
2025,
16770,
2000,
3499,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/Component.js | processOptions | function processOptions(vObj, bIgnoreLazy) {
assert(
(typeof vObj === 'string' && vObj) ||
(typeof vObj === 'object' && typeof vObj.name === 'string' && vObj.name),
"reference either must be a non-empty string or an object with a non-empty 'name' and an optional 'url' property");
if ( typeof vObj === 'object' ) {
if ( vObj.url ) {
registerModulePath(vObj.name, vObj.url);
}
return (vObj.lazy && bIgnoreLazy !== true) ? undefined : vObj.name; // expl. check for true to allow usage in Array.prototype.map below
}
return vObj;
} | javascript | function processOptions(vObj, bIgnoreLazy) {
assert(
(typeof vObj === 'string' && vObj) ||
(typeof vObj === 'object' && typeof vObj.name === 'string' && vObj.name),
"reference either must be a non-empty string or an object with a non-empty 'name' and an optional 'url' property");
if ( typeof vObj === 'object' ) {
if ( vObj.url ) {
registerModulePath(vObj.name, vObj.url);
}
return (vObj.lazy && bIgnoreLazy !== true) ? undefined : vObj.name; // expl. check for true to allow usage in Array.prototype.map below
}
return vObj;
} | [
"function",
"processOptions",
"(",
"vObj",
",",
"bIgnoreLazy",
")",
"{",
"assert",
"(",
"(",
"typeof",
"vObj",
"===",
"'string'",
"&&",
"vObj",
")",
"||",
"(",
"typeof",
"vObj",
"===",
"'object'",
"&&",
"typeof",
"vObj",
".",
"name",
"===",
"'string'",
"... | /*
Process .url and .lazy options.
For preloadBundles, lazy will be ignored | [
"/",
"*",
"Process",
".",
"url",
"and",
".",
"lazy",
"options",
".",
"For",
"preloadBundles",
"lazy",
"will",
"be",
"ignored"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/Component.js#L2540-L2555 | train | Process options | [
30522,
3853,
2832,
7361,
9285,
1006,
29536,
2497,
3501,
1010,
2502,
12131,
10581,
9096,
1007,
1063,
20865,
1006,
1006,
2828,
11253,
29536,
2497,
3501,
1027,
1027,
1027,
1005,
5164,
1005,
1004,
1004,
29536,
2497,
3501,
1007,
1064,
1064,
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... |
TryGhost/Ghost | core/server/services/url/utils.js | getAdminUrl | function getAdminUrl() {
var adminUrl = config.get('admin:url'),
subDir = getSubdir();
if (!adminUrl) {
return;
}
if (!adminUrl.match(/\/$/)) {
adminUrl += '/';
}
adminUrl = urlJoin(adminUrl, subDir, '/');
adminUrl = deduplicateSubDir(adminUrl);
return adminUrl;
} | javascript | function getAdminUrl() {
var adminUrl = config.get('admin:url'),
subDir = getSubdir();
if (!adminUrl) {
return;
}
if (!adminUrl.match(/\/$/)) {
adminUrl += '/';
}
adminUrl = urlJoin(adminUrl, subDir, '/');
adminUrl = deduplicateSubDir(adminUrl);
return adminUrl;
} | [
"function",
"getAdminUrl",
"(",
")",
"{",
"var",
"adminUrl",
"=",
"config",
".",
"get",
"(",
"'admin:url'",
")",
",",
"subDir",
"=",
"getSubdir",
"(",
")",
";",
"if",
"(",
"!",
"adminUrl",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"adminUrl",
"... | admin:url is optional | [
"admin",
":",
"url",
"is",
"optional"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/services/url/utils.js#L149-L164 | train | Get admin url | [
30522,
3853,
2131,
4215,
10020,
3126,
2140,
1006,
1007,
1063,
13075,
4748,
10020,
3126,
2140,
1027,
9530,
8873,
2290,
1012,
2131,
1006,
1005,
4748,
10020,
1024,
24471,
2140,
1005,
1007,
1010,
4942,
4305,
2099,
1027,
4152,
12083,
4305,
2099,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/ProjectManager.js | _displayCreationError | function _displayCreationError(e, errorInfo) {
window.setTimeout(function () {
var error = errorInfo.type,
isFolder = errorInfo.isFolder,
name = errorInfo.name;
if (error === FileSystemError.ALREADY_EXISTS) {
_showErrorDialog(ERR_TYPE_CREATE_EXISTS, isFolder, null, name);
} else if (error === ProjectModel.ERROR_INVALID_FILENAME) {
_showErrorDialog(ERR_TYPE_INVALID_FILENAME, isFolder, ProjectModel._invalidChars);
} else {
var errString = error === FileSystemError.NOT_WRITABLE ?
Strings.NO_MODIFICATION_ALLOWED_ERR :
StringUtils.format(Strings.GENERIC_ERROR, error);
_showErrorDialog(ERR_TYPE_CREATE, isFolder, errString, name).getPromise();
}
}, 10);
} | javascript | function _displayCreationError(e, errorInfo) {
window.setTimeout(function () {
var error = errorInfo.type,
isFolder = errorInfo.isFolder,
name = errorInfo.name;
if (error === FileSystemError.ALREADY_EXISTS) {
_showErrorDialog(ERR_TYPE_CREATE_EXISTS, isFolder, null, name);
} else if (error === ProjectModel.ERROR_INVALID_FILENAME) {
_showErrorDialog(ERR_TYPE_INVALID_FILENAME, isFolder, ProjectModel._invalidChars);
} else {
var errString = error === FileSystemError.NOT_WRITABLE ?
Strings.NO_MODIFICATION_ALLOWED_ERR :
StringUtils.format(Strings.GENERIC_ERROR, error);
_showErrorDialog(ERR_TYPE_CREATE, isFolder, errString, name).getPromise();
}
}, 10);
} | [
"function",
"_displayCreationError",
"(",
"e",
",",
"errorInfo",
")",
"{",
"window",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"error",
"=",
"errorInfo",
".",
"type",
",",
"isFolder",
"=",
"errorInfo",
".",
"isFolder",
",",
"name",
"=",
"... | @private
Event handler which displays an error based on a problem creating a file.
@param {$.Event} e jQuery event object
@param {{type:any,isFolder:boolean}} errorInfo Information passed in the error events | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/ProjectManager.js#L175-L193 | train | Display creation error | [
30522,
3853,
1035,
4653,
16748,
3370,
2121,
29165,
1006,
1041,
1010,
7561,
2378,
14876,
1007,
1063,
3332,
1012,
2275,
7292,
5833,
1006,
3853,
1006,
1007,
1063,
13075,
7561,
1027,
7561,
2378,
14876,
1012,
2828,
1010,
2003,
10371,
2121,
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... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js | _receive | function _receive(clientId, msgStr) {
var msg = JSON.parse(msgStr),
event = msg.method || "event",
deferred;
if (msg.id) {
deferred = _responseDeferreds[msg.id];
if (deferred) {
delete _responseDeferreds[msg.id];
if (msg.error) {
deferred.reject(msg);
} else {
deferred.resolve(msg);
}
}
} else if (msg.tagId) {
var editor = EditorManager.getActiveEditor(),
position = HTMLInstrumentation.getPositionFromTagId(editor, parseInt(msg.tagId, 10));
if (position) {
editor.setCursorPos(position.line, position.ch, true);
}
} else {
// enrich received message with clientId
msg.clientId = clientId;
exports.trigger(event, msg);
}
} | javascript | function _receive(clientId, msgStr) {
var msg = JSON.parse(msgStr),
event = msg.method || "event",
deferred;
if (msg.id) {
deferred = _responseDeferreds[msg.id];
if (deferred) {
delete _responseDeferreds[msg.id];
if (msg.error) {
deferred.reject(msg);
} else {
deferred.resolve(msg);
}
}
} else if (msg.tagId) {
var editor = EditorManager.getActiveEditor(),
position = HTMLInstrumentation.getPositionFromTagId(editor, parseInt(msg.tagId, 10));
if (position) {
editor.setCursorPos(position.line, position.ch, true);
}
} else {
// enrich received message with clientId
msg.clientId = clientId;
exports.trigger(event, msg);
}
} | [
"function",
"_receive",
"(",
"clientId",
",",
"msgStr",
")",
"{",
"var",
"msg",
"=",
"JSON",
".",
"parse",
"(",
"msgStr",
")",
",",
"event",
"=",
"msg",
".",
"method",
"||",
"\"event\"",
",",
"deferred",
";",
"if",
"(",
"msg",
".",
"id",
")",
"{",
... | @private
Handles a message received from the remote protocol handler via the transport.
If the message has an `id` field, it's assumed to be a response to a previous
request, and will be passed along to the original promise returned by `_send()`.
Otherwise, it's treated as an event and dispatched.
TODO: we should probably have a way of returning the results from all clients, not just the first?
@param {number} clientId ID of the client that sent the message
@param {string} msg The message that was sent, in JSON string format | [
"@private",
"Handles",
"a",
"message",
"received",
"from",
"the",
"remote",
"protocol",
"handler",
"via",
"the",
"transport",
".",
"If",
"the",
"message",
"has",
"an",
"id",
"field",
"it",
"s",
"assumed",
"to",
"be",
"a",
"response",
"to",
"a",
"previous",... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js#L101-L126 | train | receive a message from the client | [
30522,
3853,
1035,
4374,
1006,
7396,
3593,
1010,
5796,
5620,
16344,
1007,
1063,
13075,
5796,
2290,
1027,
1046,
3385,
1012,
11968,
3366,
1006,
5796,
5620,
16344,
1007,
1010,
2724,
1027,
5796,
2290,
1012,
4118,
1064,
1064,
1000,
2724,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/dom/jquery/hasTabIndex.js | function(oElem) {
var iTabIndex = jQuery.prop(oElem, "tabIndex");
// compensate for 'specialties' in the implementation of jQuery.prop:
// - it returns undefined for text, comment and attribute nodes
// - when calculating an implicit tabindex for focusable/clickable elements, it ignores the 'disabled' attribute
return iTabIndex != null && iTabIndex >= 0 &&
( !jQuery.attr(oElem, "disabled") || jQuery.attr(oElem, "tabindex") );
} | javascript | function(oElem) {
var iTabIndex = jQuery.prop(oElem, "tabIndex");
// compensate for 'specialties' in the implementation of jQuery.prop:
// - it returns undefined for text, comment and attribute nodes
// - when calculating an implicit tabindex for focusable/clickable elements, it ignores the 'disabled' attribute
return iTabIndex != null && iTabIndex >= 0 &&
( !jQuery.attr(oElem, "disabled") || jQuery.attr(oElem, "tabindex") );
} | [
"function",
"(",
"oElem",
")",
"{",
"var",
"iTabIndex",
"=",
"jQuery",
".",
"prop",
"(",
"oElem",
",",
"\"tabIndex\"",
")",
";",
"// compensate for 'specialties' in the implementation of jQuery.prop:",
"// - it returns undefined for text, comment and attribute nodes",
"// - whe... | This module provides the {@link jQuery#hasTabIndex} API.
@namespace
@name module:sap/ui/dom/jquery/hasTabIndex
@public
@since 1.58
Returns <code>true</code> if the first element has a set tabindex.
@return {boolean} If the first element has a set tabindex
@public
@name jQuery#hasTabIndex
@author SAP SE
@since 0.9.0
@function
@requires module:sap/ui/dom/jquery/hasTabIndex | [
"This",
"module",
"provides",
"the",
"{",
"@link",
"jQuery#hasTabIndex",
"}",
"API",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/dom/jquery/hasTabIndex.js#L27-L37 | train | Returns true if the element has a tabindex attribute | [
30522,
3853,
1006,
1051,
12260,
2213,
1007,
1063,
13075,
2009,
28518,
13629,
2595,
1027,
1046,
4226,
2854,
1012,
17678,
1006,
1051,
12260,
2213,
1010,
1000,
21628,
22254,
10288,
1000,
1007,
1025,
1013,
1013,
19079,
2005,
1005,
2569,
7368,
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... | |
electron/electron | script/bump-version.js | updateInfoPlist | async function updateInfoPlist (version) {
const filePath = path.resolve(__dirname, '..', 'atom', 'browser', 'resources', 'mac', 'Info.plist')
const file = plist.parse(await readFile(filePath, { encoding: 'utf8' }))
file.CFBundleVersion = version
file.CFBundleShortVersionString = version
await writeFile(filePath, plist.build(file))
} | javascript | async function updateInfoPlist (version) {
const filePath = path.resolve(__dirname, '..', 'atom', 'browser', 'resources', 'mac', 'Info.plist')
const file = plist.parse(await readFile(filePath, { encoding: 'utf8' }))
file.CFBundleVersion = version
file.CFBundleShortVersionString = version
await writeFile(filePath, plist.build(file))
} | [
"async",
"function",
"updateInfoPlist",
"(",
"version",
")",
"{",
"const",
"filePath",
"=",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'..'",
",",
"'atom'",
",",
"'browser'",
",",
"'resources'",
",",
"'mac'",
",",
"'Info.plist'",
")",
"const",
"file",
... | update CFBundle version information and overwrite pre-existing file TODO(codebytere): provide these version fields at GN build time | [
"update",
"CFBundle",
"version",
"information",
"and",
"overwrite",
"pre",
"-",
"existing",
"file",
"TODO",
"(",
"codebytere",
")",
":",
"provide",
"these",
"version",
"fields",
"at",
"GN",
"build",
"time"
] | 6e29611788277729647acf465f10db1ea6f15788 | https://github.com/electron/electron/blob/6e29611788277729647acf465f10db1ea6f15788/script/bump-version.js#L124-L132 | train | Update info. plist with new version | [
30522,
2004,
6038,
2278,
3853,
10651,
2378,
14876,
24759,
2923,
1006,
2544,
1007,
1063,
9530,
3367,
5371,
15069,
1027,
4130,
1012,
10663,
1006,
1035,
1035,
16101,
18442,
1010,
1005,
1012,
1012,
1005,
1010,
1005,
13787,
1005,
1010,
1005,
166... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/MenuBar.js | function(oThis, oEvent, sDir){
oEvent.stopPropagation();
oEvent.preventDefault();
if (!oThis.sCurrentFocusedItemRefId) {
return;
}
var sFollowingFocusItemId = null;
if (oThis.sLastVisibleItemId && ((oThis.sCurrentFocusedItemRefId == oThis.sLastVisibleItemId && sDir == "next") || sDir == "last")) {
sFollowingFocusItemId = oThis.getId() + "-ovrflw";
} else if (oThis.sLastVisibleItemId && oThis.sCurrentFocusedItemRefId == oThis.getId() + "-ovrflw" && sDir == "prev") {
sFollowingFocusItemId = oThis.sLastVisibleItemId;
} else {
var sFoo = sDir + "All";
var bIsJumpToEnd = false;
if (sDir == "first") {
sFoo = "prevAll";
bIsJumpToEnd = true;
} else if (sDir == "last") {
sFoo = "nextAll";
bIsJumpToEnd = true;
}
var jCurrentFocusItem = jQuery(document.getElementById(oThis.sCurrentFocusedItemRefId));
var jFollowingItems = jCurrentFocusItem[sFoo](":visible");
sFollowingFocusItemId = jQuery(jFollowingItems.get(bIsJumpToEnd ? jFollowingItems.length - 1 : 0)).attr("id");
}
if (sFollowingFocusItemId) {
oThis.sCurrentFocusedItemRefId = sFollowingFocusItemId;
document.getElementById(sFollowingFocusItemId).focus();
}
} | javascript | function(oThis, oEvent, sDir){
oEvent.stopPropagation();
oEvent.preventDefault();
if (!oThis.sCurrentFocusedItemRefId) {
return;
}
var sFollowingFocusItemId = null;
if (oThis.sLastVisibleItemId && ((oThis.sCurrentFocusedItemRefId == oThis.sLastVisibleItemId && sDir == "next") || sDir == "last")) {
sFollowingFocusItemId = oThis.getId() + "-ovrflw";
} else if (oThis.sLastVisibleItemId && oThis.sCurrentFocusedItemRefId == oThis.getId() + "-ovrflw" && sDir == "prev") {
sFollowingFocusItemId = oThis.sLastVisibleItemId;
} else {
var sFoo = sDir + "All";
var bIsJumpToEnd = false;
if (sDir == "first") {
sFoo = "prevAll";
bIsJumpToEnd = true;
} else if (sDir == "last") {
sFoo = "nextAll";
bIsJumpToEnd = true;
}
var jCurrentFocusItem = jQuery(document.getElementById(oThis.sCurrentFocusedItemRefId));
var jFollowingItems = jCurrentFocusItem[sFoo](":visible");
sFollowingFocusItemId = jQuery(jFollowingItems.get(bIsJumpToEnd ? jFollowingItems.length - 1 : 0)).attr("id");
}
if (sFollowingFocusItemId) {
oThis.sCurrentFocusedItemRefId = sFollowingFocusItemId;
document.getElementById(sFollowingFocusItemId).focus();
}
} | [
"function",
"(",
"oThis",
",",
"oEvent",
",",
"sDir",
")",
"{",
"oEvent",
".",
"stopPropagation",
"(",
")",
";",
"oEvent",
".",
"preventDefault",
"(",
")",
";",
"if",
"(",
"!",
"oThis",
".",
"sCurrentFocusedItemRefId",
")",
"{",
"return",
";",
"}",
"va... | Focus the next (depending on the given direction) step | [
"Focus",
"the",
"next",
"(",
"depending",
"on",
"the",
"given",
"direction",
")",
"step"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/MenuBar.js#L551-L584 | train | This function is called when the user clicks on an item in the list. It is also called by the focusHandler when the item is clicked. | [
30522,
3853,
1006,
27178,
24158,
1010,
1051,
18697,
3372,
1010,
17371,
4313,
1007,
1063,
1051,
18697,
3372,
1012,
2644,
21572,
4502,
12540,
1006,
1007,
1025,
1051,
18697,
3372,
1012,
4652,
3207,
7011,
11314,
1006,
1007,
1025,
2065,
1006,
99... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/type/Date.js | getModelFormatter | function getModelFormatter() {
if (!oModelFormatter) {
oModelFormatter = DateFormat.getDateInstance({
pattern : 'yyyy-MM-dd',
strictParsing : true,
UTC : true
});
}
return oModelFormatter;
} | javascript | function getModelFormatter() {
if (!oModelFormatter) {
oModelFormatter = DateFormat.getDateInstance({
pattern : 'yyyy-MM-dd',
strictParsing : true,
UTC : true
});
}
return oModelFormatter;
} | [
"function",
"getModelFormatter",
"(",
")",
"{",
"if",
"(",
"!",
"oModelFormatter",
")",
"{",
"oModelFormatter",
"=",
"DateFormat",
".",
"getDateInstance",
"(",
"{",
"pattern",
":",
"'yyyy-MM-dd'",
",",
"strictParsing",
":",
"true",
",",
"UTC",
":",
"true",
"... | Returns a formatter that formats the date into YYYY-MM-DD. Creates it lazily.
@returns {sap.ui.core.format.DateFormat}
the formatter | [
"Returns",
"a",
"formatter",
"that",
"formats",
"the",
"date",
"into",
"YYYY",
"-",
"MM",
"-",
"DD",
".",
"Creates",
"it",
"lazily",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/type/Date.js#L58-L67 | train | Returns the formatter for the model. | [
30522,
3853,
2131,
5302,
9247,
14192,
20097,
1006,
1007,
1063,
2065,
1006,
999,
18168,
10244,
10270,
2953,
18900,
3334,
1007,
1063,
18168,
10244,
10270,
2953,
18900,
3334,
1027,
3058,
14192,
4017,
1012,
2131,
13701,
7076,
26897,
1006,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/file/FileUtils.js | readAsText | function readAsText(file) {
var result = new $.Deferred();
// Measure performance
var perfTimerName = PerfUtils.markStart("readAsText:\t" + file.fullPath);
result.always(function () {
PerfUtils.addMeasurement(perfTimerName);
});
// Read file
file.read(function (err, data, encoding, stat) {
if (!err) {
result.resolve(data, stat.mtime);
} else {
result.reject(err);
}
});
return result.promise();
} | javascript | function readAsText(file) {
var result = new $.Deferred();
// Measure performance
var perfTimerName = PerfUtils.markStart("readAsText:\t" + file.fullPath);
result.always(function () {
PerfUtils.addMeasurement(perfTimerName);
});
// Read file
file.read(function (err, data, encoding, stat) {
if (!err) {
result.resolve(data, stat.mtime);
} else {
result.reject(err);
}
});
return result.promise();
} | [
"function",
"readAsText",
"(",
"file",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"// Measure performance",
"var",
"perfTimerName",
"=",
"PerfUtils",
".",
"markStart",
"(",
"\"readAsText:\\t\"",
"+",
"file",
".",
"fullPath",
... | Asynchronously reads a file as UTF-8 encoded text.
@param {!File} file File to read
@return {$.Promise} a jQuery promise that will be resolved with the
file's text content plus its timestamp, or rejected with a FileSystemError string
constant if the file can not be read. | [
"Asynchronously",
"reads",
"a",
"file",
"as",
"UTF",
"-",
"8",
"encoded",
"text",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/file/FileUtils.js#L70-L89 | train | Reads a file as text | [
30522,
3853,
3191,
14083,
10288,
2102,
1006,
5371,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
1013,
1013,
5468,
2836,
13075,
2566,
6199,
14428,
12789,
4168,
1027,
2566,
11263,
3775,
4877,
1012,
60... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/Agents/DOMAgent.js | _onFinishedLoadingDOM | function _onFinishedLoadingDOM() {
var request = new XMLHttpRequest();
request.open("GET", exports.url);
request.onload = function onLoad() {
if ((request.status >= 200 && request.status < 300) ||
request.status === 304 || request.status === 0) {
_mapDocumentToSource(request.response);
_load.resolve();
} else {
var msg = "Received status " + request.status + " from XMLHttpRequest while attempting to load source file at " + exports.url;
_load.reject(msg, { message: msg });
}
};
request.onerror = function onError() {
var msg = "Could not load source file at " + exports.url;
_load.reject(msg, { message: msg });
};
request.send(null);
} | javascript | function _onFinishedLoadingDOM() {
var request = new XMLHttpRequest();
request.open("GET", exports.url);
request.onload = function onLoad() {
if ((request.status >= 200 && request.status < 300) ||
request.status === 304 || request.status === 0) {
_mapDocumentToSource(request.response);
_load.resolve();
} else {
var msg = "Received status " + request.status + " from XMLHttpRequest while attempting to load source file at " + exports.url;
_load.reject(msg, { message: msg });
}
};
request.onerror = function onError() {
var msg = "Could not load source file at " + exports.url;
_load.reject(msg, { message: msg });
};
request.send(null);
} | [
"function",
"_onFinishedLoadingDOM",
"(",
")",
"{",
"var",
"request",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"request",
".",
"open",
"(",
"\"GET\"",
",",
"exports",
".",
"url",
")",
";",
"request",
".",
"onload",
"=",
"function",
"onLoad",
"(",
")"... | Load the source document and match it with the DOM tree | [
"Load",
"the",
"source",
"document",
"and",
"match",
"it",
"with",
"the",
"DOM",
"tree"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/Agents/DOMAgent.js#L163-L181 | train | Load the source file from the server | [
30522,
3853,
1035,
2006,
16294,
13295,
18570,
9527,
1006,
1007,
1063,
13075,
5227,
1027,
2047,
20950,
11039,
25856,
2890,
15500,
1006,
1007,
1025,
5227,
1012,
2330,
1006,
1000,
2131,
1000,
1010,
14338,
1012,
24471,
2140,
1007,
1025,
5227,
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... |
apache/incubator-echarts | src/coord/View.js | function (data, noRoam, out) {
var transform = noRoam ? this._rawTransform : this.transform;
out = out || [];
return transform
? v2ApplyTransform(out, data, transform)
: vector.copy(out, data);
} | javascript | function (data, noRoam, out) {
var transform = noRoam ? this._rawTransform : this.transform;
out = out || [];
return transform
? v2ApplyTransform(out, data, transform)
: vector.copy(out, data);
} | [
"function",
"(",
"data",
",",
"noRoam",
",",
"out",
")",
"{",
"var",
"transform",
"=",
"noRoam",
"?",
"this",
".",
"_rawTransform",
":",
"this",
".",
"transform",
";",
"out",
"=",
"out",
"||",
"[",
"]",
";",
"return",
"transform",
"?",
"v2ApplyTransfor... | Convert a single (lon, lat) data item to (x, y) point.
@param {Array.<number>} data
@param {boolean} noRoam
@param {Array.<number>} [out]
@return {Array.<number>} | [
"Convert",
"a",
"single",
"(",
"lon",
"lat",
")",
"data",
"item",
"to",
"(",
"x",
"y",
")",
"point",
"."
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/View.js#L256-L262 | train | Returns a vector of the alternatives of the given data | [
30522,
3853,
1006,
2951,
1010,
4496,
10441,
2213,
1010,
2041,
1007,
1063,
13075,
10938,
1027,
4496,
10441,
2213,
1029,
2023,
1012,
1035,
6315,
6494,
3619,
14192,
1024,
2023,
1012,
10938,
1025,
2041,
1027,
2041,
1064,
1064,
1031,
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... | |
adobe/brackets | src/search/QuickOpen.js | QuickNavigateDialog | function QuickNavigateDialog() {
this.$searchField = undefined; // defined when showDialog() is called
// ModalBar event handlers & callbacks
this._handleCloseBar = this._handleCloseBar.bind(this);
// QuickSearchField callbacks
this._handleItemSelect = this._handleItemSelect.bind(this);
this._handleItemHighlight = this._handleItemHighlight.bind(this);
this._filterCallback = this._filterCallback.bind(this);
this._resultsFormatterCallback = this._resultsFormatterCallback.bind(this);
// StringMatchers that cache in-progress query data.
this._filenameMatcher = new StringMatch.StringMatcher({
segmentedSearch: true
});
this._matchers = {};
} | javascript | function QuickNavigateDialog() {
this.$searchField = undefined; // defined when showDialog() is called
// ModalBar event handlers & callbacks
this._handleCloseBar = this._handleCloseBar.bind(this);
// QuickSearchField callbacks
this._handleItemSelect = this._handleItemSelect.bind(this);
this._handleItemHighlight = this._handleItemHighlight.bind(this);
this._filterCallback = this._filterCallback.bind(this);
this._resultsFormatterCallback = this._resultsFormatterCallback.bind(this);
// StringMatchers that cache in-progress query data.
this._filenameMatcher = new StringMatch.StringMatcher({
segmentedSearch: true
});
this._matchers = {};
} | [
"function",
"QuickNavigateDialog",
"(",
")",
"{",
"this",
".",
"$searchField",
"=",
"undefined",
";",
"// defined when showDialog() is called",
"// ModalBar event handlers & callbacks",
"this",
".",
"_handleCloseBar",
"=",
"this",
".",
"_handleCloseBar",
".",
"bind",
"(",... | QuickNavigateDialog class
@constructor | [
"QuickNavigateDialog",
"class"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/QuickOpen.js#L199-L216 | train | QuickNavigateDialog constructor. | [
30522,
3853,
4248,
2532,
5737,
11644,
4818,
8649,
1006,
1007,
1063,
2023,
1012,
1002,
3945,
3790,
1027,
6151,
28344,
1025,
1013,
1013,
4225,
2043,
2265,
27184,
8649,
1006,
1007,
2003,
2170,
1013,
1013,
16913,
2389,
8237,
2724,
28213,
2015,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/plugin.js | location | function location(doclet) {
var filename = (doclet.meta && doclet.meta.filename) || "unknown";
return " #" + ui5data(doclet).id + "@" + filename + (doclet.meta.lineno != null ? ":" + doclet.meta.lineno : "") + (doclet.synthetic ? "(synthetic)" : "");
} | javascript | function location(doclet) {
var filename = (doclet.meta && doclet.meta.filename) || "unknown";
return " #" + ui5data(doclet).id + "@" + filename + (doclet.meta.lineno != null ? ":" + doclet.meta.lineno : "") + (doclet.synthetic ? "(synthetic)" : "");
} | [
"function",
"location",
"(",
"doclet",
")",
"{",
"var",
"filename",
"=",
"(",
"doclet",
".",
"meta",
"&&",
"doclet",
".",
"meta",
".",
"filename",
")",
"||",
"\"unknown\"",
";",
"return",
"\" #\"",
"+",
"ui5data",
"(",
"doclet",
")",
".",
"id",
"+",
... | Creates a human readable location info for a given doclet.
@param {Doclet} doclet Doclet to get a location info for
@returns {string} A human readable location info | [
"Creates",
"a",
"human",
"readable",
"location",
"info",
"for",
"a",
"given",
"doclet",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/ui5/plugin.js#L1759-L1762 | train | Return the location of the file. | [
30522,
3853,
3295,
1006,
9986,
7485,
1007,
1063,
13075,
5371,
18442,
1027,
30524,
1025,
2709,
1000,
1001,
1000,
1009,
21318,
2629,
2850,
2696,
1006,
9986,
7485,
1007,
1012,
8909,
1009,
1000,
1030,
1000,
1009,
5371,
18442,
1009,
1006,
9986,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-ex-assign.js | checkVariable | function checkVariable(variable) {
astUtils.getModifyingReferences(variable.references).forEach(reference => {
context.report({ node: reference.identifier, messageId: "unexpected" });
});
} | javascript | function checkVariable(variable) {
astUtils.getModifyingReferences(variable.references).forEach(reference => {
context.report({ node: reference.identifier, messageId: "unexpected" });
});
} | [
"function",
"checkVariable",
"(",
"variable",
")",
"{",
"astUtils",
".",
"getModifyingReferences",
"(",
"variable",
".",
"references",
")",
".",
"forEach",
"(",
"reference",
"=>",
"{",
"context",
".",
"report",
"(",
"{",
"node",
":",
"reference",
".",
"ident... | Finds and reports references that are non initializer and writable.
@param {Variable} variable - A variable to check.
@returns {void} | [
"Finds",
"and",
"reports",
"references",
"that",
"are",
"non",
"initializer",
"and",
"writable",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-ex-assign.js#L39-L43 | train | Check variable references | [
30522,
3853,
4638,
10755,
19210,
1006,
8023,
1007,
1063,
2004,
8525,
3775,
4877,
1012,
2131,
5302,
4305,
14116,
2890,
25523,
2015,
1006,
8023,
1012,
7604,
1007,
1012,
18921,
6776,
1006,
4431,
1027,
1028,
1063,
6123,
1012,
3189,
1006,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | function() {
var doc = this._doc;
// Remove all style tags in head
this._removeNodes(doc.getElementsByTagName("style"));
if (doc.body) {
this._replaceBrs(doc.body);
}
this._replaceNodeTags(doc.getElementsByTagName("font"), "SPAN");
} | javascript | function() {
var doc = this._doc;
// Remove all style tags in head
this._removeNodes(doc.getElementsByTagName("style"));
if (doc.body) {
this._replaceBrs(doc.body);
}
this._replaceNodeTags(doc.getElementsByTagName("font"), "SPAN");
} | [
"function",
"(",
")",
"{",
"var",
"doc",
"=",
"this",
".",
"_doc",
";",
"// Remove all style tags in head",
"this",
".",
"_removeNodes",
"(",
"doc",
".",
"getElementsByTagName",
"(",
"\"style\"",
")",
")",
";",
"if",
"(",
"doc",
".",
"body",
")",
"{",
"t... | Prepare the HTML document for readability to scrape it.
This includes things like stripping javascript, CSS, and handling terrible markup.
@return void | [
"Prepare",
"the",
"HTML",
"document",
"for",
"readability",
"to",
"scrape",
"it",
".",
"This",
"includes",
"things",
"like",
"stripping",
"javascript",
"CSS",
"and",
"handling",
"terrible",
"markup",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L431-L442 | train | Remove all style tags in head and body | [
30522,
3853,
1006,
1007,
1063,
13075,
9986,
1027,
2023,
1012,
1035,
9986,
1025,
1013,
1013,
6366,
2035,
2806,
22073,
1999,
2132,
2023,
1012,
1035,
6366,
3630,
6155,
1006,
9986,
1012,
2131,
12260,
8163,
3762,
15900,
18442,
1006,
1000,
2806,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js | function (oRouteMatch) {
var that = this;
var mRouteArguments = oRouteMatch.getParameter("arguments");
var oModelData = {};
oModelData.layer = mRouteArguments.layer;
oModelData.namespace = decodeURIComponent(mRouteArguments.namespace);
oModelData.fileName = mRouteArguments.fileName;
oModelData.fileType = mRouteArguments.fileType;
// correct namespace
if (oModelData.namespace[oModelData.namespace.length - 1] !== "/") {
oModelData.namespace += "/";
}
var sContentSuffix = oModelData.namespace + oModelData.fileName + "." + oModelData.fileType;
var oPage = that.getView().getContent()[0];
oPage.setBusy(true);
return LRepConnector.getContent(oModelData.layer, sContentSuffix, null, null, true).then(
that._onContentReceived.bind(that, oModelData, oPage, sContentSuffix),
function () {
oPage.setBusy(false);
}
);
} | javascript | function (oRouteMatch) {
var that = this;
var mRouteArguments = oRouteMatch.getParameter("arguments");
var oModelData = {};
oModelData.layer = mRouteArguments.layer;
oModelData.namespace = decodeURIComponent(mRouteArguments.namespace);
oModelData.fileName = mRouteArguments.fileName;
oModelData.fileType = mRouteArguments.fileType;
// correct namespace
if (oModelData.namespace[oModelData.namespace.length - 1] !== "/") {
oModelData.namespace += "/";
}
var sContentSuffix = oModelData.namespace + oModelData.fileName + "." + oModelData.fileType;
var oPage = that.getView().getContent()[0];
oPage.setBusy(true);
return LRepConnector.getContent(oModelData.layer, sContentSuffix, null, null, true).then(
that._onContentReceived.bind(that, oModelData, oPage, sContentSuffix),
function () {
oPage.setBusy(false);
}
);
} | [
"function",
"(",
"oRouteMatch",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"mRouteArguments",
"=",
"oRouteMatch",
".",
"getParameter",
"(",
"\"arguments\"",
")",
";",
"var",
"oModelData",
"=",
"{",
"}",
";",
"oModelData",
".",
"layer",
"=",
"mRouteA... | Handler if a route was matched;
Obtains information about layer, namespace, filename, and file type from the route's arguments, and then requests content from Layered Repository.
@param {Object} oRouteMatch - route object which is specified in the router and matched via regexp
@returns {Promise} - <code>LRepConnector</code> "getContent" promise
@private | [
"Handler",
"if",
"a",
"route",
"was",
"matched",
";",
"Obtains",
"information",
"about",
"layer",
"namespace",
"filename",
"and",
"file",
"type",
"from",
"the",
"route",
"s",
"arguments",
"and",
"then",
"requests",
"content",
"from",
"Layered",
"Repository",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/ContentDetailsEdit.controller.js#L62-L87 | train | This function is called when a route matches the content of a page | [
30522,
3853,
1006,
20298,
10421,
18900,
2818,
1007,
1063,
13075,
2008,
1027,
2023,
1025,
13075,
2720,
5833,
14644,
22850,
11187,
1027,
20298,
10421,
18900,
2818,
1012,
2131,
28689,
22828,
1006,
1000,
9918,
1000,
1007,
1025,
13075,
18168,
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... | |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function ()
{
var i, thand, since, newList;
// add timed handlers scheduled for addition
// NOTE: we add before remove in the case a timed handler is
// added and then deleted before the next _onIdle() call.
while (this.addTimeds.length > 0) {
this.timedHandlers.push(this.addTimeds.pop());
}
// remove timed handlers that have been scheduled for deletion
while (this.removeTimeds.length > 0) {
thand = this.removeTimeds.pop();
i = this.timedHandlers.indexOf(thand);
if (i >= 0) {
this.timedHandlers.splice(i, 1);
}
}
// call ready timed handlers
var now = new Date().getTime();
newList = [];
for (i = 0; i < this.timedHandlers.length; i++) {
thand = this.timedHandlers[i];
if (this.authenticated || !thand.user) {
since = thand.lastCalled + thand.period;
if (since - now <= 0) {
if (thand.run()) {
newList.push(thand);
}
} else {
newList.push(thand);
}
}
}
this.timedHandlers = newList;
clearTimeout(this._idleTimeout);
this._proto._onIdle();
// reactivate the timer only if connected
if (this.connected) {
this._idleTimeout = setTimeout(this._onIdle.bind(this), 100);
}
} | javascript | function ()
{
var i, thand, since, newList;
// add timed handlers scheduled for addition
// NOTE: we add before remove in the case a timed handler is
// added and then deleted before the next _onIdle() call.
while (this.addTimeds.length > 0) {
this.timedHandlers.push(this.addTimeds.pop());
}
// remove timed handlers that have been scheduled for deletion
while (this.removeTimeds.length > 0) {
thand = this.removeTimeds.pop();
i = this.timedHandlers.indexOf(thand);
if (i >= 0) {
this.timedHandlers.splice(i, 1);
}
}
// call ready timed handlers
var now = new Date().getTime();
newList = [];
for (i = 0; i < this.timedHandlers.length; i++) {
thand = this.timedHandlers[i];
if (this.authenticated || !thand.user) {
since = thand.lastCalled + thand.period;
if (since - now <= 0) {
if (thand.run()) {
newList.push(thand);
}
} else {
newList.push(thand);
}
}
}
this.timedHandlers = newList;
clearTimeout(this._idleTimeout);
this._proto._onIdle();
// reactivate the timer only if connected
if (this.connected) {
this._idleTimeout = setTimeout(this._onIdle.bind(this), 100);
}
} | [
"function",
"(",
")",
"{",
"var",
"i",
",",
"thand",
",",
"since",
",",
"newList",
";",
"// add timed handlers scheduled for addition\r",
"// NOTE: we add before remove in the case a timed handler is\r",
"// added and then deleted before the next _onIdle() call.\r",
"while",
"(",
... | PrivateFunction: _onIdle
_Private_ handler to process events during idle cycle.
This handler is called every 100ms to fire timed handlers that
are ready and keep poll requests going. | [
"PrivateFunction",
":",
"_onIdle",
"_Private_",
"handler",
"to",
"process",
"events",
"during",
"idle",
"cycle",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L3440-L3486 | train | Called by the TTY service to update the related information of the related information. | [
30522,
3853,
1006,
1007,
1063,
13075,
1045,
1010,
2084,
2094,
1010,
2144,
1010,
2047,
9863,
1025,
1013,
1013,
5587,
22313,
28213,
2015,
5115,
2005,
2804,
1013,
1013,
3602,
1024,
2057,
5587,
2077,
6366,
1999,
1996,
2553,
1037,
22313,
28213,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
google/closure-library | closure/goog/html/sanitizer/noclobber.js | getElementStyleSheet | function getElementStyleSheet(element) {
assertHTMLElement(element);
return genericPropertyGet(
Methods.SHEET_GETTER, element, 'sheet', function(sheet) {
return sheet instanceof CSSStyleSheet;
});
} | javascript | function getElementStyleSheet(element) {
assertHTMLElement(element);
return genericPropertyGet(
Methods.SHEET_GETTER, element, 'sheet', function(sheet) {
return sheet instanceof CSSStyleSheet;
});
} | [
"function",
"getElementStyleSheet",
"(",
"element",
")",
"{",
"assertHTMLElement",
"(",
"element",
")",
";",
"return",
"genericPropertyGet",
"(",
"Methods",
".",
"SHEET_GETTER",
",",
"element",
",",
"'sheet'",
",",
"function",
"(",
"sheet",
")",
"{",
"return",
... | Returns an element's style without falling prey to things like
<form><input name="style"></form>.
@param {!Element} element
@return {!CSSStyleSheet} | [
"Returns",
"an",
"element",
"s",
"style",
"without",
"falling",
"prey",
"to",
"things",
"like",
"<form",
">",
"<input",
"name",
"=",
"style",
">",
"<",
"/",
"form",
">",
"."
] | 97390e9ca4483cebb9628e06026139fbb3023d65 | https://github.com/google/closure-library/blob/97390e9ca4483cebb9628e06026139fbb3023d65/closure/goog/html/sanitizer/noclobber.js#L296-L302 | train | Returns the style sheet of an HTMLElement | [
30522,
3853,
2131,
12260,
8163,
27983,
4095,
15558,
1006,
5783,
1007,
1063,
20865,
11039,
19968,
12260,
3672,
1006,
5783,
1007,
1025,
2709,
12391,
21572,
4842,
3723,
18150,
1006,
4725,
1012,
7123,
1035,
2131,
3334,
1010,
5783,
1010,
1005,
7... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/util/report-translator.js | createProblem | function createProblem(options) {
const problem = {
ruleId: options.ruleId,
severity: options.severity,
message: options.message,
line: options.loc.start.line,
column: options.loc.start.column + 1,
nodeType: options.node && options.node.type || null
};
/*
* If this isn’t in the conditional, some of the tests fail
* because `messageId` is present in the problem object
*/
if (options.messageId) {
problem.messageId = options.messageId;
}
if (options.loc.end) {
problem.endLine = options.loc.end.line;
problem.endColumn = options.loc.end.column + 1;
}
if (options.fix) {
problem.fix = options.fix;
}
return problem;
} | javascript | function createProblem(options) {
const problem = {
ruleId: options.ruleId,
severity: options.severity,
message: options.message,
line: options.loc.start.line,
column: options.loc.start.column + 1,
nodeType: options.node && options.node.type || null
};
/*
* If this isn’t in the conditional, some of the tests fail
* because `messageId` is present in the problem object
*/
if (options.messageId) {
problem.messageId = options.messageId;
}
if (options.loc.end) {
problem.endLine = options.loc.end.line;
problem.endColumn = options.loc.end.column + 1;
}
if (options.fix) {
problem.fix = options.fix;
}
return problem;
} | [
"function",
"createProblem",
"(",
"options",
")",
"{",
"const",
"problem",
"=",
"{",
"ruleId",
":",
"options",
".",
"ruleId",
",",
"severity",
":",
"options",
".",
"severity",
",",
"message",
":",
"options",
".",
"message",
",",
"line",
":",
"options",
"... | Creates information about the report from a descriptor
@param {Object} options Information about the problem
@param {string} options.ruleId Rule ID
@param {(0|1|2)} options.severity Rule severity
@param {(ASTNode|null)} options.node Node
@param {string} options.message Error message
@param {string} [options.messageId] The error message ID.
@param {{start: SourceLocation, end: (SourceLocation|null)}} options.loc Start and end location
@param {{text: string, range: (number[]|null)}} options.fix The fix object
@returns {function(...args): ReportInfo} Function that returns information about the report | [
"Creates",
"information",
"about",
"the",
"report",
"from",
"a",
"descriptor"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/util/report-translator.js#L197-L225 | train | Creates a problem object from the options | [
30522,
3853,
3443,
21572,
3468,
2213,
1006,
7047,
1007,
1063,
9530,
3367,
3291,
1027,
1063,
3627,
3593,
1024,
7047,
1012,
3627,
3593,
1010,
18976,
1024,
7047,
1012,
18976,
1010,
4471,
1024,
7047,
1012,
4471,
1010,
2240,
1024,
7047,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.m/src/sap/m/FormattedText.js | sanitizeHTML | function sanitizeHTML(sText) {
return sanitizeHTML0(sText, {
tagPolicy: fnPolicy.bind(this),
uriRewriter: function (sUrl) {
// by default we use the URL whitelist to check the URLs
if (URLWhitelist.validate(sUrl)) {
return sUrl;
}
}
});
} | javascript | function sanitizeHTML(sText) {
return sanitizeHTML0(sText, {
tagPolicy: fnPolicy.bind(this),
uriRewriter: function (sUrl) {
// by default we use the URL whitelist to check the URLs
if (URLWhitelist.validate(sUrl)) {
return sUrl;
}
}
});
} | [
"function",
"sanitizeHTML",
"(",
"sText",
")",
"{",
"return",
"sanitizeHTML0",
"(",
"sText",
",",
"{",
"tagPolicy",
":",
"fnPolicy",
".",
"bind",
"(",
"this",
")",
",",
"uriRewriter",
":",
"function",
"(",
"sUrl",
")",
"{",
"// by default we use the URL whitel... | Sanitizes HTML tags and attributes according to a given policy.
@param {string} sText The HTML to sanitize
@return {string} The sanitized HTML
@private | [
"Sanitizes",
"HTML",
"tags",
"and",
"attributes",
"according",
"to",
"a",
"given",
"policy",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/FormattedText.js#L269-L279 | train | Sanitize HTML to be valid HTML | [
30522,
3853,
2624,
25090,
4371,
11039,
19968,
1006,
26261,
18413,
1007,
1063,
2709,
2624,
25090,
4371,
11039,
19968,
2692,
1006,
26261,
18413,
1010,
1063,
6415,
18155,
2594,
2100,
1024,
1042,
16275,
23518,
2100,
1012,
14187,
1006,
2023,
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... |
blueimp/jQuery-File-Upload | js/jquery.fileupload-ui.js | function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload');
if (data.context && data.dataType &&
data.dataType.substr(0, 6) === 'iframe') {
// Iframe Transport does not support progress events.
// In lack of an indeterminate progress bar, we set
// the progress to 100%, showing the full animated bar:
data.context
.find('.progress').addClass(
!$.support.transition && 'progress-animated'
)
.attr('aria-valuenow', 100)
.children().first().css(
'width',
'100%'
);
}
return that._trigger('sent', e, data);
} | javascript | function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
var that = $(this).data('blueimp-fileupload') ||
$(this).data('fileupload');
if (data.context && data.dataType &&
data.dataType.substr(0, 6) === 'iframe') {
// Iframe Transport does not support progress events.
// In lack of an indeterminate progress bar, we set
// the progress to 100%, showing the full animated bar:
data.context
.find('.progress').addClass(
!$.support.transition && 'progress-animated'
)
.attr('aria-valuenow', 100)
.children().first().css(
'width',
'100%'
);
}
return that._trigger('sent', e, data);
} | [
"function",
"(",
"e",
",",
"data",
")",
"{",
"if",
"(",
"e",
".",
"isDefaultPrevented",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"that",
"=",
"$",
"(",
"this",
")",
".",
"data",
"(",
"'blueimp-fileupload'",
")",
"||",
"$",
"(",
"th... | Callback for the start of each file upload request: | [
"Callback",
"for",
"the",
"start",
"of",
"each",
"file",
"upload",
"request",
":"
] | 4586771d65482dc9678c7e48d245a1501bf96ff5 | https://github.com/blueimp/jQuery-File-Upload/blob/4586771d65482dc9678c7e48d245a1501bf96ff5/js/jquery.fileupload-ui.js#L143-L165 | train | Called when a file upload is sent | [
30522,
3853,
1006,
1041,
1010,
2951,
1007,
1063,
2065,
1006,
1041,
1012,
2003,
3207,
7011,
11314,
28139,
15338,
2098,
1006,
1007,
1007,
1063,
2709,
6270,
1025,
1065,
13075,
2008,
1027,
1002,
1006,
2023,
1007,
1012,
2951,
1006,
1005,
2630,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | getObjectFallback | function getObjectFallback(oClassObject) {
// some modules might not return a class definition, so we fallback to the global
// this is against the AMD definition, but is required for backward compatibility
if (!oClassObject) {
Log.error("Control '" + sClassName + "' did not return a class definition from sap.ui.define.", "", "XMLTemplateProcessor");
oClassObject = ObjectPath.get(sClassName);
}
if (!oClassObject) {
Log.error("Can't find object class '" + sClassName + "' for XML-view", "", "XMLTemplateProcessor");
}
return oClassObject;
} | javascript | function getObjectFallback(oClassObject) {
// some modules might not return a class definition, so we fallback to the global
// this is against the AMD definition, but is required for backward compatibility
if (!oClassObject) {
Log.error("Control '" + sClassName + "' did not return a class definition from sap.ui.define.", "", "XMLTemplateProcessor");
oClassObject = ObjectPath.get(sClassName);
}
if (!oClassObject) {
Log.error("Can't find object class '" + sClassName + "' for XML-view", "", "XMLTemplateProcessor");
}
return oClassObject;
} | [
"function",
"getObjectFallback",
"(",
"oClassObject",
")",
"{",
"// some modules might not return a class definition, so we fallback to the global",
"// this is against the AMD definition, but is required for backward compatibility",
"if",
"(",
"!",
"oClassObject",
")",
"{",
"Log",
"."... | ensure that control and library are loaded | [
"ensure",
"that",
"control",
"and",
"library",
"are",
"loaded"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/XMLTemplateProcessor.js#L481-L492 | train | This function is called by the control constructor to get the object class from the global object path | [
30522,
3853,
2131,
16429,
20614,
13976,
5963,
1006,
1051,
26266,
16429,
20614,
1007,
1063,
1013,
1013,
2070,
14184,
2453,
2025,
2709,
1037,
2465,
6210,
1010,
2061,
2057,
2991,
5963,
2000,
1996,
3795,
1013,
1013,
2023,
2003,
2114,
1996,
2572... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/FileSyncManager.js | presentConflicts | function presentConflicts(title) {
var allConflicts = editConflicts.concat(deleteConflicts);
function presentConflict(docInfo, i) {
var result = new $.Deferred(),
promise = result.promise(),
doc = docInfo.doc,
fileTime = docInfo.fileTime;
// If window has been re-focused, skip all remaining conflicts so the sync can bail & restart
if (_restartPending) {
result.resolve();
return promise;
}
var toClose;
var dialogId;
var message;
var buttons;
// Prompt UI varies depending on whether the file on disk was modified vs. deleted
if (i < editConflicts.length) {
toClose = false;
dialogId = DefaultDialogs.DIALOG_ID_EXT_CHANGED;
message = StringUtils.format(
Strings.EXT_MODIFIED_MESSAGE,
StringUtils.breakableUrl(
ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
)
);
buttons = [
{
className: Dialogs.DIALOG_BTN_CLASS_LEFT,
id: Dialogs.DIALOG_BTN_DONTSAVE,
text: Strings.RELOAD_FROM_DISK
},
{
className: Dialogs.DIALOG_BTN_CLASS_PRIMARY,
id: Dialogs.DIALOG_BTN_CANCEL,
text: Strings.KEEP_CHANGES_IN_EDITOR
}
];
} else {
toClose = true;
dialogId = DefaultDialogs.DIALOG_ID_EXT_DELETED;
message = StringUtils.format(
Strings.EXT_DELETED_MESSAGE,
StringUtils.breakableUrl(
ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
)
);
buttons = [
{
className: Dialogs.DIALOG_BTN_CLASS_LEFT,
id: Dialogs.DIALOG_BTN_DONTSAVE,
text: Strings.CLOSE_DONT_SAVE
},
{
className: Dialogs.DIALOG_BTN_CLASS_PRIMARY,
id: Dialogs.DIALOG_BTN_CANCEL,
text: Strings.KEEP_CHANGES_IN_EDITOR
}
];
}
Dialogs.showModalDialog(dialogId, title, message, buttons)
.done(function (id) {
if (id === Dialogs.DIALOG_BTN_DONTSAVE) {
if (toClose) {
// Discard - close all editors
DocumentManager.notifyFileDeleted(doc.file);
result.resolve();
} else {
// Discard - load changes from disk
reloadDoc(doc)
.done(function () {
result.resolve();
})
.fail(function (error) {
// Unable to load changed version from disk - show error UI
showReloadError(error, doc)
.done(function () {
// After user dismisses, move on to next conflict prompt
result.reject();
});
});
}
} else {
// Cancel - if user doesn't manually save or close, remember that they
// chose to keep the changes in the editor and don't prompt again unless the
// file changes again
// OR programmatically canceled due to _resetPending - we'll skip all
// remaining files in the conflicts list (see above)
// If this wasn't programmatically cancelled, remember that the user
// has accepted conflicting changes as of this file version.
if (!_restartPending) {
doc.keepChangesTime = fileTime;
}
result.resolve();
}
});
return promise;
}
// Begin walking through the conflicts, one at a time
return Async.doSequentially(allConflicts, presentConflict, false);
} | javascript | function presentConflicts(title) {
var allConflicts = editConflicts.concat(deleteConflicts);
function presentConflict(docInfo, i) {
var result = new $.Deferred(),
promise = result.promise(),
doc = docInfo.doc,
fileTime = docInfo.fileTime;
// If window has been re-focused, skip all remaining conflicts so the sync can bail & restart
if (_restartPending) {
result.resolve();
return promise;
}
var toClose;
var dialogId;
var message;
var buttons;
// Prompt UI varies depending on whether the file on disk was modified vs. deleted
if (i < editConflicts.length) {
toClose = false;
dialogId = DefaultDialogs.DIALOG_ID_EXT_CHANGED;
message = StringUtils.format(
Strings.EXT_MODIFIED_MESSAGE,
StringUtils.breakableUrl(
ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
)
);
buttons = [
{
className: Dialogs.DIALOG_BTN_CLASS_LEFT,
id: Dialogs.DIALOG_BTN_DONTSAVE,
text: Strings.RELOAD_FROM_DISK
},
{
className: Dialogs.DIALOG_BTN_CLASS_PRIMARY,
id: Dialogs.DIALOG_BTN_CANCEL,
text: Strings.KEEP_CHANGES_IN_EDITOR
}
];
} else {
toClose = true;
dialogId = DefaultDialogs.DIALOG_ID_EXT_DELETED;
message = StringUtils.format(
Strings.EXT_DELETED_MESSAGE,
StringUtils.breakableUrl(
ProjectManager.makeProjectRelativeIfPossible(doc.file.fullPath)
)
);
buttons = [
{
className: Dialogs.DIALOG_BTN_CLASS_LEFT,
id: Dialogs.DIALOG_BTN_DONTSAVE,
text: Strings.CLOSE_DONT_SAVE
},
{
className: Dialogs.DIALOG_BTN_CLASS_PRIMARY,
id: Dialogs.DIALOG_BTN_CANCEL,
text: Strings.KEEP_CHANGES_IN_EDITOR
}
];
}
Dialogs.showModalDialog(dialogId, title, message, buttons)
.done(function (id) {
if (id === Dialogs.DIALOG_BTN_DONTSAVE) {
if (toClose) {
// Discard - close all editors
DocumentManager.notifyFileDeleted(doc.file);
result.resolve();
} else {
// Discard - load changes from disk
reloadDoc(doc)
.done(function () {
result.resolve();
})
.fail(function (error) {
// Unable to load changed version from disk - show error UI
showReloadError(error, doc)
.done(function () {
// After user dismisses, move on to next conflict prompt
result.reject();
});
});
}
} else {
// Cancel - if user doesn't manually save or close, remember that they
// chose to keep the changes in the editor and don't prompt again unless the
// file changes again
// OR programmatically canceled due to _resetPending - we'll skip all
// remaining files in the conflicts list (see above)
// If this wasn't programmatically cancelled, remember that the user
// has accepted conflicting changes as of this file version.
if (!_restartPending) {
doc.keepChangesTime = fileTime;
}
result.resolve();
}
});
return promise;
}
// Begin walking through the conflicts, one at a time
return Async.doSequentially(allConflicts, presentConflict, false);
} | [
"function",
"presentConflicts",
"(",
"title",
")",
"{",
"var",
"allConflicts",
"=",
"editConflicts",
".",
"concat",
"(",
"deleteConflicts",
")",
";",
"function",
"presentConflict",
"(",
"docInfo",
",",
"i",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
... | Walks through all the documents in "editConflicts" & "deleteConflicts" and prompts the user
about each one. Processing is sequential: if the user chooses to reload a document, the next
prompt is not shown until after the reload has completed.
@param {string} title Title of the dialog.
@return {$.Promise} Resolved/rejected after all documents have been prompted and (if
applicable) reloaded (and any resulting error UI has been dismissed). Rejected if any
one reload failed. | [
"Walks",
"through",
"all",
"the",
"documents",
"in",
"editConflicts",
"&",
"deleteConflicts",
"and",
"prompts",
"the",
"user",
"about",
"each",
"one",
".",
"Processing",
"is",
"sequential",
":",
"if",
"the",
"user",
"chooses",
"to",
"reload",
"a",
"document",
... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileSyncManager.js#L280-L392 | train | Check if any conflicts are present in the editor | [
30522,
3853,
2556,
8663,
29301,
2015,
1006,
2516,
1007,
1063,
13075,
2035,
8663,
29301,
2015,
1027,
10086,
8663,
29301,
2015,
1012,
9530,
11266,
1006,
3972,
12870,
8663,
29301,
2015,
1007,
1025,
3853,
2556,
8663,
29301,
1006,
9986,
2378,
14... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
markdown-it/markdown-it | lib/common/utils.js | assign | function assign(obj /*from1, from2, from3, ...*/) {
var sources = Array.prototype.slice.call(arguments, 1);
sources.forEach(function (source) {
if (!source) { return; }
if (typeof source !== 'object') {
throw new TypeError(source + 'must be object');
}
Object.keys(source).forEach(function (key) {
obj[key] = source[key];
});
});
return obj;
} | javascript | function assign(obj /*from1, from2, from3, ...*/) {
var sources = Array.prototype.slice.call(arguments, 1);
sources.forEach(function (source) {
if (!source) { return; }
if (typeof source !== 'object') {
throw new TypeError(source + 'must be object');
}
Object.keys(source).forEach(function (key) {
obj[key] = source[key];
});
});
return obj;
} | [
"function",
"assign",
"(",
"obj",
"/*from1, from2, from3, ...*/",
")",
"{",
"var",
"sources",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
";",
"sources",
".",
"forEach",
"(",
"function",
"(",
"source",
")",
... | Merge objects | [
"Merge",
"objects"
] | ba6830ba13fb92953a91fb90318964ccd15b82c4 | https://github.com/markdown-it/markdown-it/blob/ba6830ba13fb92953a91fb90318964ccd15b82c4/lib/common/utils.js#L18-L34 | train | Assign all the specified objects to obj. | [
30522,
3853,
23911,
1006,
27885,
3501,
1013,
1008,
2013,
2487,
1010,
2013,
30524,
18921,
6776,
1006,
3853,
1006,
3120,
1007,
1063,
2065,
1006,
999,
3120,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
2828,
11253,
3120,
999,
1027,
1027,
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... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | dispatch | function dispatch(methodName, inDocument, xpath, contextNode, namespaceResolver) {
xpath = preprocess(xpath);
if (! contextNode) {
contextNode = inDocument;
}
var result = getEngineFor(inDocument)
.setIgnoreAttributesWithoutValue(ignoreAttributesWithoutValue)
[methodName](xpath, contextNode, namespaceResolver);
return result;
} | javascript | function dispatch(methodName, inDocument, xpath, contextNode, namespaceResolver) {
xpath = preprocess(xpath);
if (! contextNode) {
contextNode = inDocument;
}
var result = getEngineFor(inDocument)
.setIgnoreAttributesWithoutValue(ignoreAttributesWithoutValue)
[methodName](xpath, contextNode, namespaceResolver);
return result;
} | [
"function",
"dispatch",
"(",
"methodName",
",",
"inDocument",
",",
"xpath",
",",
"contextNode",
",",
"namespaceResolver",
")",
"{",
"xpath",
"=",
"preprocess",
"(",
"xpath",
")",
";",
"if",
"(",
"!",
"contextNode",
")",
"{",
"contextNode",
"=",
"inDocument",... | Dispatches an XPath evaluation method on the relevant engine for the
given document, and returns the result | [
"Dispatches",
"an",
"XPath",
"evaluation",
"method",
"on",
"the",
"relevant",
"engine",
"for",
"the",
"given",
"document",
"and",
"returns",
"the",
"result"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L2001-L2013 | train | Dispatches a method to the engine for the given xpath. | [
30522,
3853,
18365,
1006,
4118,
18442,
1010,
11424,
24894,
4765,
1010,
26726,
8988,
1010,
6123,
3630,
3207,
1010,
3415,
15327,
6072,
4747,
6299,
1007,
1063,
26726,
8988,
1027,
17463,
3217,
9623,
2015,
1006,
26726,
8988,
1007,
1025,
2065,
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... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (req)
{
Strophe.debug("removing request");
var i;
for (i = this._requests.length - 1; i >= 0; i--) {
if (req == this._requests[i]) {
this._requests.splice(i, 1);
}
}
// IE6 fails on setting to null, so set to empty function
req.xhr.onreadystatechange = function () {};
this._throttledRequestHandler();
} | javascript | function (req)
{
Strophe.debug("removing request");
var i;
for (i = this._requests.length - 1; i >= 0; i--) {
if (req == this._requests[i]) {
this._requests.splice(i, 1);
}
}
// IE6 fails on setting to null, so set to empty function
req.xhr.onreadystatechange = function () {};
this._throttledRequestHandler();
} | [
"function",
"(",
"req",
")",
"{",
"Strophe",
".",
"debug",
"(",
"\"removing request\"",
")",
";",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"this",
".",
"_requests",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"if",
"("... | PrivateFunction: _removeRequest
_Private_ function to remove a request from the queue.
Parameters:
(Strophe.Request) req - The request to remove. | [
"PrivateFunction",
":",
"_removeRequest",
"_Private_",
"function",
"to",
"remove",
"a",
"request",
"from",
"the",
"queue",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L4576-L4591 | train | Remove a request from the list of requests | [
30522,
3853,
1006,
2128,
4160,
1007,
1063,
2358,
18981,
5369,
1012,
2139,
8569,
2290,
1006,
1000,
9268,
5227,
1000,
1007,
1025,
13075,
1045,
1025,
2005,
1006,
1045,
1027,
2023,
1012,
1035,
11186,
1012,
3091,
1011,
1015,
1025,
1045,
1028,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/one-var.js | getCurrentScope | function getCurrentScope(statementType) {
let currentScope;
if (statementType === "var") {
currentScope = functionStack[functionStack.length - 1];
} else if (statementType === "let") {
currentScope = blockStack[blockStack.length - 1].let;
} else if (statementType === "const") {
currentScope = blockStack[blockStack.length - 1].const;
}
return currentScope;
} | javascript | function getCurrentScope(statementType) {
let currentScope;
if (statementType === "var") {
currentScope = functionStack[functionStack.length - 1];
} else if (statementType === "let") {
currentScope = blockStack[blockStack.length - 1].let;
} else if (statementType === "const") {
currentScope = blockStack[blockStack.length - 1].const;
}
return currentScope;
} | [
"function",
"getCurrentScope",
"(",
"statementType",
")",
"{",
"let",
"currentScope",
";",
"if",
"(",
"statementType",
"===",
"\"var\"",
")",
"{",
"currentScope",
"=",
"functionStack",
"[",
"functionStack",
".",
"length",
"-",
"1",
"]",
";",
"}",
"else",
"if... | Determines the current scope (function or block)
@param {string} statementType node.kind, one of: "var", "let", or "const"
@returns {Object} The scope associated with statementType | [
"Determines",
"the",
"current",
"scope",
"(",
"function",
"or",
"block",
")"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/one-var.js#L186-L197 | train | Get the current scope of the statement | [
30522,
3853,
2131,
10841,
14343,
7666,
16186,
1006,
4861,
13874,
1007,
1063,
2292,
14731,
16186,
1025,
2065,
1006,
4861,
13874,
1027,
1027,
1027,
1000,
13075,
1000,
1007,
1063,
14731,
16186,
1027,
4972,
2696,
3600,
1031,
4972,
2696,
3600,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/language/JSONUtils.js | _getParentKeyName | function _getParentKeyName(ctx) {
var parentKeyName, braceParity = 1, hasColon;
// Move the context back to find the parent key.
while (TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctx)) {
if (ctx.token.type === null) {
if (ctx.token.string === "}") {
braceParity++;
} else if (ctx.token.string === "{") {
braceParity--;
}
}
if (braceParity === 0) {
while (TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctx)) {
if (ctx.token.type === null && ctx.token.string === ":") {
hasColon = true;
} else if (ctx.token.type === "string property") {
parentKeyName = stripQuotes(ctx.token.string);
break;
}
}
break;
}
}
if (parentKeyName && hasColon) {
return parentKeyName;
}
return null;
} | javascript | function _getParentKeyName(ctx) {
var parentKeyName, braceParity = 1, hasColon;
// Move the context back to find the parent key.
while (TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctx)) {
if (ctx.token.type === null) {
if (ctx.token.string === "}") {
braceParity++;
} else if (ctx.token.string === "{") {
braceParity--;
}
}
if (braceParity === 0) {
while (TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctx)) {
if (ctx.token.type === null && ctx.token.string === ":") {
hasColon = true;
} else if (ctx.token.type === "string property") {
parentKeyName = stripQuotes(ctx.token.string);
break;
}
}
break;
}
}
if (parentKeyName && hasColon) {
return parentKeyName;
}
return null;
} | [
"function",
"_getParentKeyName",
"(",
"ctx",
")",
"{",
"var",
"parentKeyName",
",",
"braceParity",
"=",
"1",
",",
"hasColon",
";",
"// Move the context back to find the parent key.",
"while",
"(",
"TokenUtils",
".",
"moveSkippingWhitespace",
"(",
"TokenUtils",
".",
"m... | @private
Returns the name of parent object
@param {!{editor:!CodeMirror, pos:!{ch:number, line:number}, token:Object}} ctx
@return {String} | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/JSONUtils.js#L95-L125 | train | Get the parent key name from the context | [
30522,
3853,
1035,
2131,
19362,
4765,
14839,
18442,
1006,
14931,
2595,
1007,
1063,
13075,
6687,
14839,
18442,
1010,
17180,
19362,
3012,
1027,
1015,
1010,
2038,
25778,
2239,
1025,
1013,
1013,
2693,
1996,
6123,
2067,
2000,
2424,
1996,
6687,
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... |
jgraph/mxgraph | javascript/mxClient.js | function(node, attr, value)
{
if (node.nodeType == mxConstants.NODETYPE_ELEMENT)
{
var tmp = node.getAttribute(attr);
if (tmp != null && tmp == value)
{
return node;
}
}
node = node.firstChild;
while (node != null)
{
var result = mxUtils.findNode(node, attr, value);
if (result != null)
{
return result;
}
node = node.nextSibling;
}
return null;
} | javascript | function(node, attr, value)
{
if (node.nodeType == mxConstants.NODETYPE_ELEMENT)
{
var tmp = node.getAttribute(attr);
if (tmp != null && tmp == value)
{
return node;
}
}
node = node.firstChild;
while (node != null)
{
var result = mxUtils.findNode(node, attr, value);
if (result != null)
{
return result;
}
node = node.nextSibling;
}
return null;
} | [
"function",
"(",
"node",
",",
"attr",
",",
"value",
")",
"{",
"if",
"(",
"node",
".",
"nodeType",
"==",
"mxConstants",
".",
"NODETYPE_ELEMENT",
")",
"{",
"var",
"tmp",
"=",
"node",
".",
"getAttribute",
"(",
"attr",
")",
";",
"if",
"(",
"tmp",
"!=",
... | Function: findNode
Returns the first node where attr equals value.
This implementation does not use XPath. | [
"Function",
":",
"findNode"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L2397-L2424 | train | Returns the nearest ancestor of node with the specified attribute | [
30522,
3853,
1006,
13045,
1010,
2012,
16344,
1010,
3643,
1007,
1063,
2065,
1006,
13045,
1012,
13045,
13874,
1027,
1027,
25630,
8663,
12693,
3215,
1012,
13045,
13874,
1035,
5783,
1007,
1063,
13075,
1056,
8737,
1027,
13045,
1012,
2131,
19321,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jgraph/mxgraph | javascript/mxClient.js | mxCellEditor | function mxCellEditor(graph)
{
this.graph = graph;
// Stops editing after zoom changes
this.zoomHandler = mxUtils.bind(this, function()
{
if (this.graph.isEditing())
{
this.resize();
}
});
this.graph.view.addListener(mxEvent.SCALE, this.zoomHandler);
this.graph.view.addListener(mxEvent.SCALE_AND_TRANSLATE, this.zoomHandler);
// Adds handling of deleted cells while editing
this.changeHandler = mxUtils.bind(this, function(sender)
{
if (this.editingCell != null && this.graph.getView().getState(this.editingCell) == null)
{
this.stopEditing(true);
}
});
this.graph.getModel().addListener(mxEvent.CHANGE, this.changeHandler);
} | javascript | function mxCellEditor(graph)
{
this.graph = graph;
// Stops editing after zoom changes
this.zoomHandler = mxUtils.bind(this, function()
{
if (this.graph.isEditing())
{
this.resize();
}
});
this.graph.view.addListener(mxEvent.SCALE, this.zoomHandler);
this.graph.view.addListener(mxEvent.SCALE_AND_TRANSLATE, this.zoomHandler);
// Adds handling of deleted cells while editing
this.changeHandler = mxUtils.bind(this, function(sender)
{
if (this.editingCell != null && this.graph.getView().getState(this.editingCell) == null)
{
this.stopEditing(true);
}
});
this.graph.getModel().addListener(mxEvent.CHANGE, this.changeHandler);
} | [
"function",
"mxCellEditor",
"(",
"graph",
")",
"{",
"this",
".",
"graph",
"=",
"graph",
";",
"// Stops editing after zoom changes",
"this",
".",
"zoomHandler",
"=",
"mxUtils",
".",
"bind",
"(",
"this",
",",
"function",
"(",
")",
"{",
"if",
"(",
"this",
"."... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxCellEditor
In-place editor for the graph. To control this editor, use
<mxGraph.invokesStopCellEditing>, <mxGraph.enterStopsCellEditing> and
<mxGraph.escapeEnabled>. If <mxGraph.enterStopsCellEditing> is true then
ctrl-enter or shift-enter can be used to create a linefeed. The F2 and
escape keys can always be used to stop editing.
To customize the location of the textbox in the graph, override
<getEditorBounds> as follows:
(code)
graph.cellEditor.getEditorBounds = function(state)
{
var result = mxCellEditor.prototype.getEditorBounds.apply(this, arguments);
if (this.graph.getModel().isEdge(state.cell))
{
result.x = state.getCenterX() - result.width / 2;
result.y = state.getCenterY() - result.height / 2;
}
return result;
};
(end)
Note that this hook is only called if <autoSize> is false. If <autoSize> is true,
then <mxShape.getLabelBounds> is used to compute the current bounds of the textbox.
The textarea uses the mxCellEditor CSS class. You can modify this class in
your custom CSS. Note: You should modify the CSS after loading the client
in the page.
Example:
To only allow numeric input in the in-place editor, use the following code.
(code)
var text = graph.cellEditor.textarea;
mxEvent.addListener(text, 'keydown', function (evt)
{
if (!(evt.keyCode >= 48 && evt.keyCode <= 57) &&
!(evt.keyCode >= 96 && evt.keyCode <= 105))
{
mxEvent.consume(evt);
}
});
(end)
Placeholder:
To implement a placeholder for cells without a label, use the
<emptyLabelText> variable.
Resize in Chrome:
Resize of the textarea is disabled by default. If you want to enable
this feature extend <init> and set this.textarea.style.resize = ''.
To start editing on a key press event, the container of the graph
should have focus or a focusable parent should be used to add the
key press handler as follows.
(code)
mxEvent.addListener(graph.container, 'keypress', mxUtils.bind(this, function(evt)
{
if (!graph.isEditing() && !graph.isSelectionEmpty() && evt.which !== 0 &&
!mxEvent.isAltDown(evt) && !mxEvent.isControlDown(evt) && !mxEvent.isMetaDown(evt))
{
graph.startEditing();
if (mxClient.IS_FF)
{
graph.cellEditor.textarea.value = String.fromCharCode(evt.which);
}
}
}));
(end)
To allow focus for a DIV, and hence to receive key press events, some browsers
require it to have a valid tabindex attribute. In this case the following
code may be used to keep the container focused.
(code)
var graphFireMouseEvent = graph.fireMouseEvent;
graph.fireMouseEvent = function(evtName, me, sender)
{
if (evtName == mxEvent.MOUSE_DOWN)
{
this.container.focus();
}
graphFireMouseEvent.apply(this, arguments);
};
(end)
Constructor: mxCellEditor
Constructs a new in-place editor for the specified graph.
Parameters:
graph - Reference to the enclosing <mxGraph>. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxCellEditor"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L46758-L46784 | train | This is the main entry point for the cell editor | [
30522,
3853,
25630,
29109,
3709,
15660,
1006,
10629,
1007,
1063,
2023,
1012,
10629,
1027,
10629,
1025,
1013,
1013,
6762,
9260,
2044,
24095,
3431,
2023,
1012,
24095,
11774,
3917,
1027,
25630,
21823,
4877,
1012,
14187,
1006,
2023,
1010,
3853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
ecomfe/zrender | src/core/BoundingRect.js | function (b) {
var a = this;
var sx = b.width / a.width;
var sy = b.height / a.height;
var m = matrix.create();
// 矩阵右乘
matrix.translate(m, m, [-a.x, -a.y]);
matrix.scale(m, m, [sx, sy]);
matrix.translate(m, m, [b.x, b.y]);
return m;
} | javascript | function (b) {
var a = this;
var sx = b.width / a.width;
var sy = b.height / a.height;
var m = matrix.create();
// 矩阵右乘
matrix.translate(m, m, [-a.x, -a.y]);
matrix.scale(m, m, [sx, sy]);
matrix.translate(m, m, [b.x, b.y]);
return m;
} | [
"function",
"(",
"b",
")",
"{",
"var",
"a",
"=",
"this",
";",
"var",
"sx",
"=",
"b",
".",
"width",
"/",
"a",
".",
"width",
";",
"var",
"sy",
"=",
"b",
".",
"height",
"/",
"a",
".",
"height",
";",
"var",
"m",
"=",
"matrix",
".",
"create",
"(... | Calculate matrix of transforming from self to target rect
@param {module:zrender/core/BoundingRect} b
@return {Array.<number>} | [
"Calculate",
"matrix",
"of",
"transforming",
"from",
"self",
"to",
"target",
"rect"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/core/BoundingRect.js#L107-L120 | train | returns a matrix of the same size as b | [
30522,
3853,
1006,
1038,
1007,
1063,
13075,
1037,
1027,
2023,
1025,
13075,
1055,
2595,
1027,
1038,
1012,
9381,
1013,
1037,
1012,
9381,
1025,
13075,
25353,
1027,
1038,
1012,
4578,
1013,
1037,
1012,
4578,
1025,
13075,
1049,
1027,
8185,
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... | |
GeekyAnts/vue-native-core | dist/vue.react.js | mergeAssets | function mergeAssets (parentVal, childVal) {
var res = Object.create(parentVal || null);
return childVal
? extend$1(res, childVal)
: res
} | javascript | function mergeAssets (parentVal, childVal) {
var res = Object.create(parentVal || null);
return childVal
? extend$1(res, childVal)
: res
} | [
"function",
"mergeAssets",
"(",
"parentVal",
",",
"childVal",
")",
"{",
"var",
"res",
"=",
"Object",
".",
"create",
"(",
"parentVal",
"||",
"null",
")",
";",
"return",
"childVal",
"?",
"extend$1",
"(",
"res",
",",
"childVal",
")",
":",
"res",
"}"
] | Assets
When a vm is present (instance creation), we need to do
a three-way merge between constructor options, instance
options and parent options. | [
"Assets"
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/dist/vue.react.js#L1107-L1112 | train | Merge assets from parent to child | [
30522,
3853,
13590,
27241,
3215,
1006,
6687,
10175,
1010,
2775,
10175,
1007,
1063,
13075,
24501,
1027,
4874,
1012,
3443,
1006,
6687,
10175,
1064,
1064,
19701,
1007,
1025,
2709,
2775,
10175,
1029,
7949,
1002,
1015,
1006,
24501,
1010,
2775,
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.m/src/sap/m/Suggest.js | ontap | function ontap(oEvent) {
var item = oEvent.srcControl;
var value;
if (item instanceof SuggestionItem ) {
value = item.getSuggestionText();
picker.close();
window.setTimeout(function() {
oInput.setValue(value);
oInput.fireSearch({
query: value,
suggestionItem: item,
refreshButtonPressed: false,
clearButtonPressed: false
});
}, 0);
}
} | javascript | function ontap(oEvent) {
var item = oEvent.srcControl;
var value;
if (item instanceof SuggestionItem ) {
value = item.getSuggestionText();
picker.close();
window.setTimeout(function() {
oInput.setValue(value);
oInput.fireSearch({
query: value,
suggestionItem: item,
refreshButtonPressed: false,
clearButtonPressed: false
});
}, 0);
}
} | [
"function",
"ontap",
"(",
"oEvent",
")",
"{",
"var",
"item",
"=",
"oEvent",
".",
"srcControl",
";",
"var",
"value",
";",
"if",
"(",
"item",
"instanceof",
"SuggestionItem",
")",
"{",
"value",
"=",
"item",
".",
"getSuggestionText",
"(",
")",
";",
"picker",... | /* =========================================================== /* events processing /* =========================================================== Process tap over a list item in a picker | [
"/",
"*",
"===========================================================",
"/",
"*",
"events",
"processing",
"/",
"*",
"===========================================================",
"Process",
"tap",
"over",
"a",
"list",
"item",
"in",
"a",
"picker"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.m/src/sap/m/Suggest.js#L48-L64 | train | The event handler for the search button | [
30522,
3853,
2006,
2696,
2361,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
8875,
1027,
1051,
18697,
3372,
1012,
5034,
21408,
3372,
13153,
1025,
13075,
3643,
1025,
2065,
1006,
8875,
6013,
11253,
10293,
4221,
2213,
1007,
1063,
3643,
1027,
887... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/search/node/FindInFilesDomain.js | getNumMatches | function getNumMatches(fileList, queryExpr) {
var i,
matches = 0;
for (i = 0; i < fileList.length; i++) {
var temp = countNumMatches(getFileContentsForFile(fileList[i]), queryExpr);
if (temp) {
numFiles++;
matches += temp;
}
if (matches > MAX_TOTAL_RESULTS) {
exceedsMaximum = true;
break;
}
}
return matches;
} | javascript | function getNumMatches(fileList, queryExpr) {
var i,
matches = 0;
for (i = 0; i < fileList.length; i++) {
var temp = countNumMatches(getFileContentsForFile(fileList[i]), queryExpr);
if (temp) {
numFiles++;
matches += temp;
}
if (matches > MAX_TOTAL_RESULTS) {
exceedsMaximum = true;
break;
}
}
return matches;
} | [
"function",
"getNumMatches",
"(",
"fileList",
",",
"queryExpr",
")",
"{",
"var",
"i",
",",
"matches",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"fileList",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"temp",
"=",
"countNumMatches... | Get the total number of matches from all the files in fileList
@param {array} fileList file path array
@param {Object} queryExpr
@return {Number} total number of matches | [
"Get",
"the",
"total",
"number",
"of",
"matches",
"from",
"all",
"the",
"files",
"in",
"fileList"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/search/node/FindInFilesDomain.js#L402-L417 | train | get num matches | [
30522,
3853,
2131,
19172,
18900,
8376,
1006,
5371,
9863,
1010,
23032,
10288,
18098,
1007,
1063,
13075,
1045,
1010,
3503,
1027,
1014,
1025,
2005,
1006,
1045,
1027,
1014,
1025,
1045,
1026,
5371,
9863,
1012,
3091,
1025,
1045,
1009,
1009,
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... |
angular/material | src/core/util/util.js | scanChildren | function scanChildren(element) {
var found;
if (element) {
for (var i = 0, len = element.length; i < len; i++) {
var target = element[i];
if (!found) {
for (var j = 0, numChild = target.childNodes.length; j < numChild; j++) {
found = found || scanTree([target.childNodes[j]]);
}
}
}
}
return found;
} | javascript | function scanChildren(element) {
var found;
if (element) {
for (var i = 0, len = element.length; i < len; i++) {
var target = element[i];
if (!found) {
for (var j = 0, numChild = target.childNodes.length; j < numChild; j++) {
found = found || scanTree([target.childNodes[j]]);
}
}
}
}
return found;
} | [
"function",
"scanChildren",
"(",
"element",
")",
"{",
"var",
"found",
";",
"if",
"(",
"element",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"element",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"targ... | Scan children of specified node | [
"Scan",
"children",
"of",
"specified",
"node"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/util/util.js#L629-L642 | train | Scan children of an element | [
30522,
3853,
13594,
19339,
7389,
1006,
5783,
1007,
1063,
13075,
2179,
1025,
2065,
1006,
5783,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1014,
1010,
18798,
1027,
5783,
1012,
3091,
1025,
1045,
1026,
18798,
1025,
1045,
1009,
1009,
1007,
1063,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ecomfe/zrender | src/Layer.js | function (clearAll, clearColor) {
var dom = this.dom;
var ctx = this.ctx;
var width = dom.width;
var height = dom.height;
var clearColor = clearColor || this.clearColor;
var haveMotionBLur = this.motionBlur && !clearAll;
var lastFrameAlpha = this.lastFrameAlpha;
var dpr = this.dpr;
if (haveMotionBLur) {
if (!this.domBack) {
this.createBackBuffer();
}
this.ctxBack.globalCompositeOperation = 'copy';
this.ctxBack.drawImage(
dom, 0, 0,
width / dpr,
height / dpr
);
}
ctx.clearRect(0, 0, width, height);
if (clearColor && clearColor !== 'transparent') {
var clearColorGradientOrPattern;
// Gradient
if (clearColor.colorStops) {
// Cache canvas gradient
clearColorGradientOrPattern = clearColor.__canvasGradient || Style.getGradient(ctx, clearColor, {
x: 0,
y: 0,
width: width,
height: height
});
clearColor.__canvasGradient = clearColorGradientOrPattern;
}
// Pattern
else if (clearColor.image) {
clearColorGradientOrPattern = Pattern.prototype.getCanvasPattern.call(clearColor, ctx);
}
ctx.save();
ctx.fillStyle = clearColorGradientOrPattern || clearColor;
ctx.fillRect(0, 0, width, height);
ctx.restore();
}
if (haveMotionBLur) {
var domBack = this.domBack;
ctx.save();
ctx.globalAlpha = lastFrameAlpha;
ctx.drawImage(domBack, 0, 0, width, height);
ctx.restore();
}
} | javascript | function (clearAll, clearColor) {
var dom = this.dom;
var ctx = this.ctx;
var width = dom.width;
var height = dom.height;
var clearColor = clearColor || this.clearColor;
var haveMotionBLur = this.motionBlur && !clearAll;
var lastFrameAlpha = this.lastFrameAlpha;
var dpr = this.dpr;
if (haveMotionBLur) {
if (!this.domBack) {
this.createBackBuffer();
}
this.ctxBack.globalCompositeOperation = 'copy';
this.ctxBack.drawImage(
dom, 0, 0,
width / dpr,
height / dpr
);
}
ctx.clearRect(0, 0, width, height);
if (clearColor && clearColor !== 'transparent') {
var clearColorGradientOrPattern;
// Gradient
if (clearColor.colorStops) {
// Cache canvas gradient
clearColorGradientOrPattern = clearColor.__canvasGradient || Style.getGradient(ctx, clearColor, {
x: 0,
y: 0,
width: width,
height: height
});
clearColor.__canvasGradient = clearColorGradientOrPattern;
}
// Pattern
else if (clearColor.image) {
clearColorGradientOrPattern = Pattern.prototype.getCanvasPattern.call(clearColor, ctx);
}
ctx.save();
ctx.fillStyle = clearColorGradientOrPattern || clearColor;
ctx.fillRect(0, 0, width, height);
ctx.restore();
}
if (haveMotionBLur) {
var domBack = this.domBack;
ctx.save();
ctx.globalAlpha = lastFrameAlpha;
ctx.drawImage(domBack, 0, 0, width, height);
ctx.restore();
}
} | [
"function",
"(",
"clearAll",
",",
"clearColor",
")",
"{",
"var",
"dom",
"=",
"this",
".",
"dom",
";",
"var",
"ctx",
"=",
"this",
".",
"ctx",
";",
"var",
"width",
"=",
"dom",
".",
"width",
";",
"var",
"height",
"=",
"dom",
".",
"height",
";",
"var... | 清空该层画布
@param {boolean} [clearAll]=false Clear all with out motion blur
@param {Color} [clearColor] | [
"清空该层画布"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/Layer.js#L181-L238 | train | Clear the image | [
30522,
3853,
1006,
3154,
8095,
1010,
3154,
18717,
1007,
1063,
13075,
14383,
1027,
2023,
1012,
14383,
1025,
13075,
14931,
2595,
1027,
2023,
1012,
14931,
2595,
1025,
13075,
9381,
1027,
14383,
1012,
9381,
1025,
13075,
4578,
1027,
14383,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/preferences/PreferencesManager.js | _includeProjectScope | function _includeProjectScope(filename) {
filename = filename || currentFilename;
if (!filename || !projectDirectory) {
return false;
}
return FileUtils.getRelativeFilename(projectDirectory, filename) !== undefined;
} | javascript | function _includeProjectScope(filename) {
filename = filename || currentFilename;
if (!filename || !projectDirectory) {
return false;
}
return FileUtils.getRelativeFilename(projectDirectory, filename) !== undefined;
} | [
"function",
"_includeProjectScope",
"(",
"filename",
")",
"{",
"filename",
"=",
"filename",
"||",
"currentFilename",
";",
"if",
"(",
"!",
"filename",
"||",
"!",
"projectDirectory",
")",
"{",
"return",
"false",
";",
"}",
"return",
"FileUtils",
".",
"getRelative... | @private
Determines whether the project Scope should be included based on whether
the currently edited file is within the project.
@param {string=} filename Full path to edited file
@return {boolean} true if the project Scope should be included. | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesManager.js#L58-L64 | train | Returns true if the current filename is a relative path to the project directory | [
30522,
3853,
1035,
2421,
21572,
20614,
26127,
1006,
5371,
18442,
1007,
1063,
5371,
18442,
1027,
5371,
18442,
1064,
1064,
2783,
8873,
20844,
4168,
1025,
2065,
1006,
999,
5371,
18442,
1064,
1064,
999,
2622,
4305,
2890,
16761,
2100,
1007,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Microsoft/vscode | build/lib/optimize.js | uglifyWithCopyrights | function uglifyWithCopyrights() {
const preserveComments = (f) => {
return (_node, comment) => {
const text = comment.value;
const type = comment.type;
if (/@minifier_do_not_preserve/.test(text)) {
return false;
}
const isOurCopyright = IS_OUR_COPYRIGHT_REGEXP.test(text);
if (isOurCopyright) {
if (f.__hasOurCopyright) {
return false;
}
f.__hasOurCopyright = true;
return true;
}
if ('comment2' === type) {
// check for /*!. Note that text doesn't contain leading /*
return (text.length > 0 && text[0] === '!') || /@preserve|license|@cc_on|copyright/i.test(text);
}
else if ('comment1' === type) {
return /license|copyright/i.test(text);
}
return false;
};
};
const minify = composer(uglifyes);
const input = es.through();
const output = input
.pipe(flatmap((stream, f) => {
return stream.pipe(minify({
output: {
comments: preserveComments(f),
max_line_len: 1024
}
}));
}));
return es.duplex(input, output);
} | javascript | function uglifyWithCopyrights() {
const preserveComments = (f) => {
return (_node, comment) => {
const text = comment.value;
const type = comment.type;
if (/@minifier_do_not_preserve/.test(text)) {
return false;
}
const isOurCopyright = IS_OUR_COPYRIGHT_REGEXP.test(text);
if (isOurCopyright) {
if (f.__hasOurCopyright) {
return false;
}
f.__hasOurCopyright = true;
return true;
}
if ('comment2' === type) {
// check for /*!. Note that text doesn't contain leading /*
return (text.length > 0 && text[0] === '!') || /@preserve|license|@cc_on|copyright/i.test(text);
}
else if ('comment1' === type) {
return /license|copyright/i.test(text);
}
return false;
};
};
const minify = composer(uglifyes);
const input = es.through();
const output = input
.pipe(flatmap((stream, f) => {
return stream.pipe(minify({
output: {
comments: preserveComments(f),
max_line_len: 1024
}
}));
}));
return es.duplex(input, output);
} | [
"function",
"uglifyWithCopyrights",
"(",
")",
"{",
"const",
"preserveComments",
"=",
"(",
"f",
")",
"=>",
"{",
"return",
"(",
"_node",
",",
"comment",
")",
"=>",
"{",
"const",
"text",
"=",
"comment",
".",
"value",
";",
"const",
"type",
"=",
"comment",
... | Wrap around uglify and allow the preserveComments function
to have a file "context" to include our copyright only once per file. | [
"Wrap",
"around",
"uglify",
"and",
"allow",
"the",
"preserveComments",
"function",
"to",
"have",
"a",
"file",
"context",
"to",
"include",
"our",
"copyright",
"only",
"once",
"per",
"file",
"."
] | 693a13cd32c5be798051edc0cb43e1e39fc456d9 | https://github.com/Microsoft/vscode/blob/693a13cd32c5be798051edc0cb43e1e39fc456d9/build/lib/optimize.js#L169-L207 | train | Uglify with copyright comments | [
30522,
3853,
1057,
25394,
12031,
24415,
3597,
7685,
15950,
2015,
1006,
1007,
1063,
9530,
3367,
7969,
9006,
8163,
1027,
1006,
1042,
1007,
1027,
1028,
1063,
2709,
1006,
1035,
13045,
1010,
7615,
1007,
1027,
1028,
1063,
9530,
3367,
3793,
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... |
adobe/brackets | src/JSUtils/ScopeManager.js | getOffset | function getOffset(session, fileInfo, offset) {
var newOffset;
if (offset) {
newOffset = {line: offset.line, ch: offset.ch};
} else {
newOffset = session.getCursor();
}
if (fileInfo.type === MessageIds.TERN_FILE_INFO_TYPE_PART) {
newOffset.line = Math.max(0, newOffset.line - fileInfo.offsetLines);
}
return newOffset;
} | javascript | function getOffset(session, fileInfo, offset) {
var newOffset;
if (offset) {
newOffset = {line: offset.line, ch: offset.ch};
} else {
newOffset = session.getCursor();
}
if (fileInfo.type === MessageIds.TERN_FILE_INFO_TYPE_PART) {
newOffset.line = Math.max(0, newOffset.line - fileInfo.offsetLines);
}
return newOffset;
} | [
"function",
"getOffset",
"(",
"session",
",",
"fileInfo",
",",
"offset",
")",
"{",
"var",
"newOffset",
";",
"if",
"(",
"offset",
")",
"{",
"newOffset",
"=",
"{",
"line",
":",
"offset",
".",
"line",
",",
"ch",
":",
"offset",
".",
"ch",
"}",
";",
"}"... | Get the current offset. The offset is adjusted for "part" updates.
@param {!Session} session - the current session
@param {{type: string, name: string, offsetLines: number, text: string}} fileInfo
- type of update, name of file, and the text of the update.
For "full" updates, the whole text of the file is present. For "part" updates,
the changed portion of the text. For "empty" updates, the file has not been modified
and the text is empty.
@param {{line: number, ch: number}=} offset - the default offset (optional). Will
use the cursor if not provided.
@return {{line: number, ch: number}} | [
"Get",
"the",
"current",
"offset",
".",
"The",
"offset",
"is",
"adjusted",
"for",
"part",
"updates",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/JSUtils/ScopeManager.js#L636-L650 | train | Get offset of file | [
30522,
3853,
2131,
27475,
3388,
1006,
5219,
1010,
5371,
2378,
14876,
1010,
16396,
1007,
1063,
13075,
2047,
27475,
3388,
1025,
2065,
1006,
16396,
1007,
1063,
2047,
27475,
3388,
1027,
1063,
2240,
1024,
16396,
1012,
2240,
1010,
10381,
1024,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
tensorflow/tfjs-models | speech-commands/demo/index.js | createWordDivs | function createWordDivs(transferWords) {
// Clear collectButtonsDiv first.
while (collectButtonsDiv.firstChild) {
collectButtonsDiv.removeChild(collectButtonsDiv.firstChild);
}
datasetViz = new DatasetViz(transferRecognizer,
collectButtonsDiv,
MIN_EXAMPLES_PER_CLASS,
startTransferLearnButton,
downloadAsFileButton,
transferDurationMultiplier);
const wordDivs = {};
for (const word of transferWords) {
const wordDiv = document.createElement('div');
wordDiv.classList.add('word-div');
wordDivs[word] = wordDiv;
wordDiv.setAttribute('word', word);
const button = document.createElement('button');
button.setAttribute('isFixed', 'true');
button.style['display'] = 'inline-block';
button.style['vertical-align'] = 'middle';
const displayWord = word === BACKGROUND_NOISE_TAG ? 'noise' : word;
button.textContent = `${displayWord} (0)`;
wordDiv.appendChild(button);
wordDiv.className = 'transfer-word';
collectButtonsDiv.appendChild(wordDiv);
collectWordButtons[word] = button;
let durationInput;
if (word === BACKGROUND_NOISE_TAG) {
// Create noise duration input.
durationInput = document.createElement('input');
durationInput.setAttribute('isFixed', 'true');
durationInput.value = '10';
durationInput.style['width'] = '100px';
wordDiv.appendChild(durationInput);
// Create time-unit span for noise duration.
const timeUnitSpan = document.createElement('span');
timeUnitSpan.setAttribute('isFixed', 'true');
timeUnitSpan.classList.add('settings');
timeUnitSpan.style['vertical-align'] = 'middle';
timeUnitSpan.textContent = 'seconds';
wordDiv.appendChild(timeUnitSpan);
}
button.addEventListener('click', async () => {
disableAllCollectWordButtons();
removeNonFixedChildrenFromWordDiv(wordDiv);
const collectExampleOptions = {};
let durationSec;
let intervalJob;
let progressBar;
if (word === BACKGROUND_NOISE_TAG) {
// If the word type is background noise, display a progress bar during
// sound collection and do not show an incrementally updating
// spectrogram.
// _background_noise_ examples are special, in that user can specify
// the length of the recording (in seconds).
collectExampleOptions.durationSec =
Number.parseFloat(durationInput.value);
durationSec = collectExampleOptions.durationSec;
const barAndJob = createProgressBarAndIntervalJob(wordDiv, durationSec);
progressBar = barAndJob.progressBar;
intervalJob = barAndJob.intervalJob;
} else {
// If this is not a background-noise word type and if the duration
// multiplier is >1 (> ~1 s recoding), show an incrementally
// updating spectrogram in real time.
collectExampleOptions.durationMultiplier = transferDurationMultiplier;
let tempSpectrogramData;
const tempCanvas = document.createElement('canvas');
tempCanvas.style['margin-left'] = '132px';
tempCanvas.height = 50;
wordDiv.appendChild(tempCanvas);
collectExampleOptions.snippetDurationSec = 0.1;
collectExampleOptions.onSnippet = async (spectrogram) => {
if (tempSpectrogramData == null) {
tempSpectrogramData = spectrogram.data;
} else {
tempSpectrogramData = SpeechCommands.utils.concatenateFloat32Arrays(
[tempSpectrogramData, spectrogram.data]);
}
plotSpectrogram(
tempCanvas, tempSpectrogramData, spectrogram.frameSize,
spectrogram.frameSize, {pixelsPerFrame: 2});
}
}
collectExampleOptions.includeRawAudio =
includeTimeDomainWaveformCheckbox.checked;
const spectrogram = await transferRecognizer.collectExample(
word, collectExampleOptions);
if (intervalJob != null) {
clearInterval(intervalJob);
}
if (progressBar != null) {
wordDiv.removeChild(progressBar);
}
const examples = transferRecognizer.getExamples(word)
const example = examples[examples.length - 1];
await datasetViz.drawExample(
wordDiv, word, spectrogram, example.example.rawAudio, example.uid);
enableAllCollectWordButtons();
});
}
return wordDivs;
} | javascript | function createWordDivs(transferWords) {
// Clear collectButtonsDiv first.
while (collectButtonsDiv.firstChild) {
collectButtonsDiv.removeChild(collectButtonsDiv.firstChild);
}
datasetViz = new DatasetViz(transferRecognizer,
collectButtonsDiv,
MIN_EXAMPLES_PER_CLASS,
startTransferLearnButton,
downloadAsFileButton,
transferDurationMultiplier);
const wordDivs = {};
for (const word of transferWords) {
const wordDiv = document.createElement('div');
wordDiv.classList.add('word-div');
wordDivs[word] = wordDiv;
wordDiv.setAttribute('word', word);
const button = document.createElement('button');
button.setAttribute('isFixed', 'true');
button.style['display'] = 'inline-block';
button.style['vertical-align'] = 'middle';
const displayWord = word === BACKGROUND_NOISE_TAG ? 'noise' : word;
button.textContent = `${displayWord} (0)`;
wordDiv.appendChild(button);
wordDiv.className = 'transfer-word';
collectButtonsDiv.appendChild(wordDiv);
collectWordButtons[word] = button;
let durationInput;
if (word === BACKGROUND_NOISE_TAG) {
// Create noise duration input.
durationInput = document.createElement('input');
durationInput.setAttribute('isFixed', 'true');
durationInput.value = '10';
durationInput.style['width'] = '100px';
wordDiv.appendChild(durationInput);
// Create time-unit span for noise duration.
const timeUnitSpan = document.createElement('span');
timeUnitSpan.setAttribute('isFixed', 'true');
timeUnitSpan.classList.add('settings');
timeUnitSpan.style['vertical-align'] = 'middle';
timeUnitSpan.textContent = 'seconds';
wordDiv.appendChild(timeUnitSpan);
}
button.addEventListener('click', async () => {
disableAllCollectWordButtons();
removeNonFixedChildrenFromWordDiv(wordDiv);
const collectExampleOptions = {};
let durationSec;
let intervalJob;
let progressBar;
if (word === BACKGROUND_NOISE_TAG) {
// If the word type is background noise, display a progress bar during
// sound collection and do not show an incrementally updating
// spectrogram.
// _background_noise_ examples are special, in that user can specify
// the length of the recording (in seconds).
collectExampleOptions.durationSec =
Number.parseFloat(durationInput.value);
durationSec = collectExampleOptions.durationSec;
const barAndJob = createProgressBarAndIntervalJob(wordDiv, durationSec);
progressBar = barAndJob.progressBar;
intervalJob = barAndJob.intervalJob;
} else {
// If this is not a background-noise word type and if the duration
// multiplier is >1 (> ~1 s recoding), show an incrementally
// updating spectrogram in real time.
collectExampleOptions.durationMultiplier = transferDurationMultiplier;
let tempSpectrogramData;
const tempCanvas = document.createElement('canvas');
tempCanvas.style['margin-left'] = '132px';
tempCanvas.height = 50;
wordDiv.appendChild(tempCanvas);
collectExampleOptions.snippetDurationSec = 0.1;
collectExampleOptions.onSnippet = async (spectrogram) => {
if (tempSpectrogramData == null) {
tempSpectrogramData = spectrogram.data;
} else {
tempSpectrogramData = SpeechCommands.utils.concatenateFloat32Arrays(
[tempSpectrogramData, spectrogram.data]);
}
plotSpectrogram(
tempCanvas, tempSpectrogramData, spectrogram.frameSize,
spectrogram.frameSize, {pixelsPerFrame: 2});
}
}
collectExampleOptions.includeRawAudio =
includeTimeDomainWaveformCheckbox.checked;
const spectrogram = await transferRecognizer.collectExample(
word, collectExampleOptions);
if (intervalJob != null) {
clearInterval(intervalJob);
}
if (progressBar != null) {
wordDiv.removeChild(progressBar);
}
const examples = transferRecognizer.getExamples(word)
const example = examples[examples.length - 1];
await datasetViz.drawExample(
wordDiv, word, spectrogram, example.example.rawAudio, example.uid);
enableAllCollectWordButtons();
});
}
return wordDivs;
} | [
"function",
"createWordDivs",
"(",
"transferWords",
")",
"{",
"// Clear collectButtonsDiv first.",
"while",
"(",
"collectButtonsDiv",
".",
"firstChild",
")",
"{",
"collectButtonsDiv",
".",
"removeChild",
"(",
"collectButtonsDiv",
".",
"firstChild",
")",
";",
"}",
"dat... | Create div elements for transfer words.
@param {string[]} transferWords The array of transfer words.
@returns {Object} An object mapping word to th div element created for it. | [
"Create",
"div",
"elements",
"for",
"transfer",
"words",
"."
] | af194797c90cc5bcac1060d3cd41b0258a34c7dc | https://github.com/tensorflow/tfjs-models/blob/af194797c90cc5bcac1060d3cd41b0258a34c7dc/speech-commands/demo/index.js#L188-L303 | train | Creates a div for each word. | [
30522,
3853,
3443,
18351,
4305,
15088,
1006,
4651,
22104,
1007,
1063,
1013,
1013,
3154,
8145,
8569,
15474,
16150,
12848,
2034,
1012,
2096,
1006,
8145,
8569,
15474,
16150,
12848,
1012,
2034,
19339,
1007,
1063,
8145,
8569,
15474,
16150,
12848,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
wangfupeng1988/wangEditor | src/js/menus/link/index.js | function () {
if (!this._active) {
return
}
const editor = this.editor
const $selectionELem = editor.selection.getSelectionContainerElem()
if (!$selectionELem) {
return
}
const selectionText = editor.selection.getSelectionText()
editor.cmd.do('insertHTML', '<span>' + selectionText + '</span>')
} | javascript | function () {
if (!this._active) {
return
}
const editor = this.editor
const $selectionELem = editor.selection.getSelectionContainerElem()
if (!$selectionELem) {
return
}
const selectionText = editor.selection.getSelectionText()
editor.cmd.do('insertHTML', '<span>' + selectionText + '</span>')
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_active",
")",
"{",
"return",
"}",
"const",
"editor",
"=",
"this",
".",
"editor",
"const",
"$selectionELem",
"=",
"editor",
".",
"selection",
".",
"getSelectionContainerElem",
"(",
")",
"if",
"(",
... | 删除当前链接 | [
"删除当前链接"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/menus/link/index.js#L121-L132 | train | Return the current language | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
999,
2023,
1012,
1035,
3161,
1007,
1063,
2709,
1065,
9530,
3367,
3559,
1027,
2023,
1012,
3559,
9530,
3367,
1002,
4989,
12260,
2213,
1027,
3559,
30524,
18209,
1006,
1007,
3559,
1012,
4642,
2094,
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 | lib/jsdoc/ui5/plugin.js | preprocessComment | function preprocessComment(e) {
var src = e.comment;
// add a default visibility
if ( !/@private|@public|@protected|@sap-restricted|@ui5-restricted/.test(src) ) {
src = unwrap(src);
src = src + "\n@private";
src = wrap(src);
// console.log("added default visibility to '" + src + "'");
}
if ( /@class/.test(src) && /@static/.test(src) ) {
warning("combination of @class and @static is no longer supported with jsdoc3, converting it to @namespace and @classdesc: (line " + e.lineno + ")");
src = unwrap(src);
src = src.replace(/@class/, "@classdesc").replace(/@static/, "@namespace");
src = wrap(src);
//console.log(src);
}
return src;
} | javascript | function preprocessComment(e) {
var src = e.comment;
// add a default visibility
if ( !/@private|@public|@protected|@sap-restricted|@ui5-restricted/.test(src) ) {
src = unwrap(src);
src = src + "\n@private";
src = wrap(src);
// console.log("added default visibility to '" + src + "'");
}
if ( /@class/.test(src) && /@static/.test(src) ) {
warning("combination of @class and @static is no longer supported with jsdoc3, converting it to @namespace and @classdesc: (line " + e.lineno + ")");
src = unwrap(src);
src = src.replace(/@class/, "@classdesc").replace(/@static/, "@namespace");
src = wrap(src);
//console.log(src);
}
return src;
} | [
"function",
"preprocessComment",
"(",
"e",
")",
"{",
"var",
"src",
"=",
"e",
".",
"comment",
";",
"// add a default visibility",
"if",
"(",
"!",
"/",
"@private|@public|@protected|@sap-restricted|@ui5-restricted",
"/",
".",
"test",
"(",
"src",
")",
")",
"{",
"src... | Pre-processes a JSDoc comment string to ensure some UI5 standards.
@param {event} e Event for the new comment
@returns {event} Returns the modified event | [
"Pre",
"-",
"processes",
"a",
"JSDoc",
"comment",
"string",
"to",
"ensure",
"some",
"UI5",
"standards",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/ui5/plugin.js#L1910-L1932 | train | Preprocess a comment | [
30522,
3853,
17463,
3217,
9623,
9363,
20058,
3372,
1006,
1041,
1007,
1063,
13075,
5034,
2278,
1027,
1041,
1012,
7615,
1025,
1013,
1013,
5587,
1037,
12398,
16476,
2065,
1006,
999,
1013,
1030,
2797,
1064,
1030,
2270,
1064,
1030,
5123,
1064,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/output/helper/fileToURL.js | fileToURL | function fileToURL(output, filePath) {
var options = output.getOptions();
var directoryIndex = options.get('directoryIndex');
filePath = fileToOutput(output, filePath);
if (directoryIndex && path.basename(filePath) == 'index.html') {
filePath = path.dirname(filePath) + '/';
}
return LocationUtils.normalize(filePath);
} | javascript | function fileToURL(output, filePath) {
var options = output.getOptions();
var directoryIndex = options.get('directoryIndex');
filePath = fileToOutput(output, filePath);
if (directoryIndex && path.basename(filePath) == 'index.html') {
filePath = path.dirname(filePath) + '/';
}
return LocationUtils.normalize(filePath);
} | [
"function",
"fileToURL",
"(",
"output",
",",
"filePath",
")",
"{",
"var",
"options",
"=",
"output",
".",
"getOptions",
"(",
")",
";",
"var",
"directoryIndex",
"=",
"options",
".",
"get",
"(",
"'directoryIndex'",
")",
";",
"filePath",
"=",
"fileToOutput",
"... | Convert a filePath (absolute) to an url (without hostname).
It returns an absolute path.
"README.md" -> "/"
"test/hello.md" -> "test/hello.html"
"test/README.md" -> "test/"
@param {Output} output
@param {String} filePath
@return {String} | [
"Convert",
"a",
"filePath",
"(",
"absolute",
")",
"to",
"an",
"url",
"(",
"without",
"hostname",
")",
".",
"It",
"returns",
"an",
"absolute",
"path",
"."
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/helper/fileToURL.js#L18-L29 | train | Get the URL of the file | [
30522,
3853,
5371,
21163,
2140,
1006,
6434,
1010,
5371,
15069,
1007,
1063,
13075,
7047,
1027,
6434,
1012,
2131,
7361,
9285,
1006,
1007,
1025,
13075,
14176,
22254,
10288,
1027,
7047,
1012,
2131,
1006,
1005,
14176,
22254,
10288,
1005,
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... |
SAP/openui5 | src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js | getObjectValues | function getObjectValues(oObject) {
var aKeys = Object.keys(oObject),
aValues = [];
aKeys.forEach(function(sKey) {
aValues.push(oObject[sKey]);
});
return aValues;
} | javascript | function getObjectValues(oObject) {
var aKeys = Object.keys(oObject),
aValues = [];
aKeys.forEach(function(sKey) {
aValues.push(oObject[sKey]);
});
return aValues;
} | [
"function",
"getObjectValues",
"(",
"oObject",
")",
"{",
"var",
"aKeys",
"=",
"Object",
".",
"keys",
"(",
"oObject",
")",
",",
"aValues",
"=",
"[",
"]",
";",
"aKeys",
".",
"forEach",
"(",
"function",
"(",
"sKey",
")",
"{",
"aValues",
".",
"push",
"("... | Polyfill for Object.values
as original Object.values is N/A on IE
@param oObject
@returns {Array} | [
"Polyfill",
"for",
"Object",
".",
"values"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.documentation/src/sap/ui/documentation/sdk/controller/util/IndexWorker.js#L467-L476 | train | Get the values of an object | [
30522,
3853,
2131,
16429,
20614,
10175,
15808,
1006,
1051,
16429,
20614,
1007,
1063,
13075,
17712,
3240,
2015,
1027,
4874,
1012,
6309,
1006,
1051,
16429,
20614,
1007,
1010,
10927,
7630,
2229,
1027,
1031,
1033,
1025,
17712,
3240,
2015,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function(aUI5Filter, oReferencedProperties) {
for ( var i = -1, oUI5Filter; (oUI5Filter = aUI5Filter[++i]) !== undefined;) {
if (oUI5Filter.aFilters != undefined) {
this.getPropertiesReferencedByUI5FilterArray(oUI5Filter.aFilters, oReferencedProperties);
} else {
if (oReferencedProperties[oUI5Filter.sPath] == undefined) {
oReferencedProperties[oUI5Filter.sPath] = [];
}
oReferencedProperties[oUI5Filter.sPath].push(oUI5Filter);
}
}
} | javascript | function(aUI5Filter, oReferencedProperties) {
for ( var i = -1, oUI5Filter; (oUI5Filter = aUI5Filter[++i]) !== undefined;) {
if (oUI5Filter.aFilters != undefined) {
this.getPropertiesReferencedByUI5FilterArray(oUI5Filter.aFilters, oReferencedProperties);
} else {
if (oReferencedProperties[oUI5Filter.sPath] == undefined) {
oReferencedProperties[oUI5Filter.sPath] = [];
}
oReferencedProperties[oUI5Filter.sPath].push(oUI5Filter);
}
}
} | [
"function",
"(",
"aUI5Filter",
",",
"oReferencedProperties",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"-",
"1",
",",
"oUI5Filter",
";",
"(",
"oUI5Filter",
"=",
"aUI5Filter",
"[",
"++",
"i",
"]",
")",
"!==",
"undefined",
";",
")",
"{",
"if",
"(",
"oUI5F... | /*
@private | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L3289-L3300 | train | Recursively finds all properties referenced by the given UI5 filter. | [
30522,
3853,
1006,
8740,
2072,
2629,
8873,
21928,
1010,
10848,
25523,
18927,
18981,
8743,
3111,
1007,
1063,
2005,
1006,
13075,
1045,
1027,
1011,
1015,
1010,
15068,
2072,
2629,
8873,
21928,
1025,
1006,
15068,
2072,
2629,
8873,
21928,
1027,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/utils/promise.js | serie | function serie(arr, iter, base) {
return reduce(arr, function(before, item, key) {
return Q(iter(item, key))
.then(function(r) {
before.push(r);
return before;
});
}, []);
} | javascript | function serie(arr, iter, base) {
return reduce(arr, function(before, item, key) {
return Q(iter(item, key))
.then(function(r) {
before.push(r);
return before;
});
}, []);
} | [
"function",
"serie",
"(",
"arr",
",",
"iter",
",",
"base",
")",
"{",
"return",
"reduce",
"(",
"arr",
",",
"function",
"(",
"before",
",",
"item",
",",
"key",
")",
"{",
"return",
"Q",
"(",
"iter",
"(",
"item",
",",
"key",
")",
")",
".",
"then",
... | Transform an array
@param {Array|List} arr
@param {Function(value, element, index)}
@return {Promise} | [
"Transform",
"an",
"array"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/promise.js#L47-L55 | train | returns a promise that resolves to an array of the result | [
30522,
3853,
8668,
1006,
12098,
2099,
1010,
2009,
2121,
1010,
2918,
1007,
1063,
2709,
5547,
1006,
12098,
2099,
1010,
3853,
1006,
2077,
1010,
8875,
1010,
3145,
1007,
1063,
2709,
1053,
1006,
2009,
2121,
1006,
8875,
1010,
3145,
1007,
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... |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/utils/DataUtils.js | function (oGroup) {
var sTitle = "{i18n>systemData}";
if (oGroup.key === "custom") {
sTitle = "{i18n>externalReferences}";
}
return new GroupHeaderListItem({
title: sTitle,
upperCase: false
});
} | javascript | function (oGroup) {
var sTitle = "{i18n>systemData}";
if (oGroup.key === "custom") {
sTitle = "{i18n>externalReferences}";
}
return new GroupHeaderListItem({
title: sTitle,
upperCase: false
});
} | [
"function",
"(",
"oGroup",
")",
"{",
"var",
"sTitle",
"=",
"\"{i18n>systemData}\"",
";",
"if",
"(",
"oGroup",
".",
"key",
"===",
"\"custom\"",
")",
"{",
"sTitle",
"=",
"\"{i18n>externalReferences}\"",
";",
"}",
"return",
"new",
"GroupHeaderListItem",
"(",
"{",... | Factory for creating list group header objects for the metadata list.
@param {Object} oGroup - group data passed from the lists model binding
@returns {sap.m.GroupHeaderListItem}
@public | [
"Factory",
"for",
"creating",
"list",
"group",
"header",
"objects",
"for",
"the",
"metadata",
"list",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/utils/DataUtils.js#L60-L71 | train | Creates a list of GroupHeaderItems for the given group. | [
30522,
3853,
1006,
13958,
22107,
1007,
1063,
13075,
2358,
4183,
2571,
1027,
1000,
1063,
1045,
15136,
2078,
1028,
2291,
2850,
2696,
1065,
1000,
1025,
2065,
1006,
13958,
22107,
1012,
3145,
1027,
1027,
1027,
1000,
7661,
1000,
1007,
1063,
2358,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/xpath/xpath.js | function(ctx) {
assert(this.args.length >= 1);
var c = this.args[0].evaluate(ctx).numberValue();
var ret = [];
for (var i = 0; i < c; ++i) {
ret.push(ctx.node);
}
return new NodeSetValue(ret);
} | javascript | function(ctx) {
assert(this.args.length >= 1);
var c = this.args[0].evaluate(ctx).numberValue();
var ret = [];
for (var i = 0; i < c; ++i) {
ret.push(ctx.node);
}
return new NodeSetValue(ret);
} | [
"function",
"(",
"ctx",
")",
"{",
"assert",
"(",
"this",
".",
"args",
".",
"length",
">=",
"1",
")",
";",
"var",
"c",
"=",
"this",
".",
"args",
"[",
"0",
"]",
".",
"evaluate",
"(",
"ctx",
")",
".",
"numberValue",
"(",
")",
";",
"var",
"ret",
... | ext-cardinal() evaluates its single argument as a number, and returns the current node that many times. It can be used in the select attribute to iterate over an integer range. | [
"ext",
"-",
"cardinal",
"()",
"evaluates",
"its",
"single",
"argument",
"as",
"a",
"number",
"and",
"returns",
"the",
"current",
"node",
"that",
"many",
"times",
".",
"It",
"can",
"be",
"used",
"in",
"the",
"select",
"attribute",
"to",
"iterate",
"over",
... | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/xpath/xpath.js#L1382-L1390 | train | Returns a node set with the specified number of nodes | [
30522,
3853,
1006,
14931,
2595,
1007,
1063,
20865,
1006,
2023,
1012,
12098,
5620,
1012,
3091,
1028,
1027,
1015,
1007,
1025,
13075,
1039,
1027,
2023,
1012,
12098,
5620,
1031,
1014,
1033,
1012,
16157,
1006,
14931,
2595,
1007,
1012,
2193,
1017... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 dir = game.player.dir;
var sky = game.map.skybox;
var ambient = game.map.light;
var width = sky.width * (this.height / sky.height) * 2;
var left = (dir / circle) * -width;
ctx.save();
ctx.drawImage(sky.image, left, 0, width, this.height);
if (left < width - this.width) {
ctx.drawImage(sky.image, left + width, 0, width, this.height);
}
if (ambient > 0) {
ctx.fillStyle = '#fff';
ctx.globalAlpha = ambient * 0.1;
ctx.fillRect(0, this.height * 0.5, this.width, this.height * 0.5);
}
ctx.restore();
} | javascript | function() {
var dir = game.player.dir;
var sky = game.map.skybox;
var ambient = game.map.light;
var width = sky.width * (this.height / sky.height) * 2;
var left = (dir / circle) * -width;
ctx.save();
ctx.drawImage(sky.image, left, 0, width, this.height);
if (left < width - this.width) {
ctx.drawImage(sky.image, left + width, 0, width, this.height);
}
if (ambient > 0) {
ctx.fillStyle = '#fff';
ctx.globalAlpha = ambient * 0.1;
ctx.fillRect(0, this.height * 0.5, this.width, this.height * 0.5);
}
ctx.restore();
} | [
"function",
"(",
")",
"{",
"var",
"dir",
"=",
"game",
".",
"player",
".",
"dir",
";",
"var",
"sky",
"=",
"game",
".",
"map",
".",
"skybox",
";",
"var",
"ambient",
"=",
"game",
".",
"map",
".",
"light",
";",
"var",
"width",
"=",
"sky",
".",
"wid... | Draw the skybox based on the player's direction. | [
"Draw",
"the",
"skybox",
"based",
"on",
"the",
"player",
"s",
"direction",
"."
] | 030db918dd8ce640afd57e172418472497e8f113 | https://github.com/goldfire/howler.js/blob/030db918dd8ce640afd57e172418472497e8f113/examples/3d/js/camera.js#L31-L49 | train | draw the skybox | [
30522,
3853,
1006,
1007,
1063,
13075,
16101,
1027,
2208,
1012,
2447,
1012,
16101,
1025,
13075,
3712,
1027,
2208,
1012,
4949,
1012,
3712,
8758,
1025,
13075,
17093,
1027,
2208,
1012,
4949,
1012,
2422,
1025,
13075,
9381,
1027,
3712,
1012,
9381... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/resize.js | extract | function extract (options) {
const suffix = this.options.width === -1 && this.options.height === -1 ? 'Pre' : 'Post';
['left', 'top', 'width', 'height'].forEach(function (name) {
const value = options[name];
if (is.integer(value) && value >= 0) {
this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;
} else {
throw new Error('Non-integer value for ' + name + ' of ' + value);
}
}, this);
// Ensure existing rotation occurs before pre-resize extraction
if (suffix === 'Pre' && ((this.options.angle % 360) !== 0 || this.options.useExifOrientation === true)) {
this.options.rotateBeforePreExtract = true;
}
return this;
} | javascript | function extract (options) {
const suffix = this.options.width === -1 && this.options.height === -1 ? 'Pre' : 'Post';
['left', 'top', 'width', 'height'].forEach(function (name) {
const value = options[name];
if (is.integer(value) && value >= 0) {
this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;
} else {
throw new Error('Non-integer value for ' + name + ' of ' + value);
}
}, this);
// Ensure existing rotation occurs before pre-resize extraction
if (suffix === 'Pre' && ((this.options.angle % 360) !== 0 || this.options.useExifOrientation === true)) {
this.options.rotateBeforePreExtract = true;
}
return this;
} | [
"function",
"extract",
"(",
"options",
")",
"{",
"const",
"suffix",
"=",
"this",
".",
"options",
".",
"width",
"===",
"-",
"1",
"&&",
"this",
".",
"options",
".",
"height",
"===",
"-",
"1",
"?",
"'Pre'",
":",
"'Post'",
";",
"[",
"'left'",
",",
"'to... | Extract a region of the image.
- Use `extract` before `resize` for pre-resize extraction.
- Use `extract` after `resize` for post-resize extraction.
- Use `extract` before and after for both.
@example
sharp(input)
.extract({ left: left, top: top, width: width, height: height })
.toFile(output, function(err) {
// Extract a region of the input image, saving in the same format.
});
@example
sharp(input)
.extract({ left: leftOffsetPre, top: topOffsetPre, width: widthPre, height: heightPre })
.resize(width, height)
.extract({ left: leftOffsetPost, top: topOffsetPost, width: widthPost, height: heightPost })
.toFile(output, function(err) {
// Extract a region, resize, then extract from the resized image
});
@param {Object} options - describes the region to extract using integral pixel values
@param {Number} options.left - zero-indexed offset from left edge
@param {Number} options.top - zero-indexed offset from top edge
@param {Number} options.width - width of region to extract
@param {Number} options.height - height of region to extract
@returns {Sharp}
@throws {Error} Invalid parameters | [
"Extract",
"a",
"region",
"of",
"the",
"image",
"."
] | 05d76eeadfe54713606a615185b2da047923406b | https://github.com/lovell/sharp/blob/05d76eeadfe54713606a615185b2da047923406b/lib/resize.js#L345-L360 | train | Extract image from the specified options | [
30522,
3853,
14817,
1006,
7047,
1007,
1063,
9530,
3367,
16809,
1027,
2023,
1012,
7047,
1012,
9381,
1027,
1027,
1027,
1011,
1015,
1004,
1004,
2023,
1012,
7047,
1012,
4578,
1027,
1027,
1027,
1011,
1015,
1029,
1005,
3653,
1005,
1024,
1005,
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... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/JSDOMParser.js | function (str) {
var index = this.html.indexOf(str, this.currentChar) + str.length;
if (index === -1)
this.currentChar = this.html.length;
this.currentChar = index;
} | javascript | function (str) {
var index = this.html.indexOf(str, this.currentChar) + str.length;
if (index === -1)
this.currentChar = this.html.length;
this.currentChar = index;
} | [
"function",
"(",
"str",
")",
"{",
"var",
"index",
"=",
"this",
".",
"html",
".",
"indexOf",
"(",
"str",
",",
"this",
".",
"currentChar",
")",
"+",
"str",
".",
"length",
";",
"if",
"(",
"index",
"===",
"-",
"1",
")",
"this",
".",
"currentChar",
"=... | Searches the input until a string is found and discards all input up to
and including the matched string. | [
"Searches",
"the",
"input",
"until",
"a",
"string",
"is",
"found",
"and",
"discards",
"all",
"input",
"up",
"to",
"and",
"including",
"the",
"matched",
"string",
"."
] | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/JSDOMParser.js#L1008-L1013 | train | Find the next index of str | [
30522,
3853,
1006,
2358,
2099,
1007,
1063,
13075,
5950,
1027,
2023,
1012,
16129,
1012,
5950,
11253,
1006,
2358,
2099,
1010,
2023,
1012,
2783,
7507,
2099,
1007,
1009,
2358,
2099,
1012,
3091,
1025,
2065,
1006,
5950,
1027,
1027,
1027,
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... | |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/layout/AbsoluteLayout.js | function(oThis, sProp, oValue, sChangeType) {
var bHasDomRef = !!oThis.getDomRef();
oThis.setProperty(sProp, oValue, bHasDomRef);
if (bHasDomRef) {
oThis.contentChanged(null, sChangeType);
}
return oThis;
} | javascript | function(oThis, sProp, oValue, sChangeType) {
var bHasDomRef = !!oThis.getDomRef();
oThis.setProperty(sProp, oValue, bHasDomRef);
if (bHasDomRef) {
oThis.contentChanged(null, sChangeType);
}
return oThis;
} | [
"function",
"(",
"oThis",
",",
"sProp",
",",
"oValue",
",",
"sChangeType",
")",
"{",
"var",
"bHasDomRef",
"=",
"!",
"!",
"oThis",
".",
"getDomRef",
"(",
")",
";",
"oThis",
".",
"setProperty",
"(",
"sProp",
",",
"oValue",
",",
"bHasDomRef",
")",
";",
... | Sets the value of the given property and triggers Dom change if
possible.
@private | [
"Sets",
"the",
"value",
"of",
"the",
"given",
"property",
"and",
"triggers",
"Dom",
"change",
"if",
"possible",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/layout/AbsoluteLayout.js#L590-L597 | train | Sets the value of a property on the DOM element | [
30522,
3853,
1006,
27178,
24158,
1010,
11867,
18981,
1010,
9242,
5657,
1010,
8040,
18003,
27405,
5051,
1007,
1063,
13075,
1038,
14949,
9527,
2890,
2546,
1027,
999,
999,
27178,
24158,
1012,
2131,
9527,
2890,
2546,
1006,
1007,
1025,
27178,
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... | |
ColorlibHQ/AdminLTE | plugins/input-mask/jquery.inputmask.date.extensions.js | function (chrs, buffer, pos, strict, opts) {
var frontValue = buffer.join('').substr(0, 3);
if (frontValue.indexOf(opts.placeholder[0]) != -1) frontValue = "01" + opts.separator;
var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
if (!strict && !isValid) {
if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0));
if (isValid) {
buffer[pos - 1] = "0";
return { "pos": pos, "c": chrs.charAt(0) };
}
}
}
return isValid;
} | javascript | function (chrs, buffer, pos, strict, opts) {
var frontValue = buffer.join('').substr(0, 3);
if (frontValue.indexOf(opts.placeholder[0]) != -1) frontValue = "01" + opts.separator;
var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
if (!strict && !isValid) {
if (chrs.charAt(1) == opts.separator || "-./".indexOf(chrs.charAt(1)) != -1) {
isValid = opts.regex.val2(opts.separator).test(frontValue + "0" + chrs.charAt(0));
if (isValid) {
buffer[pos - 1] = "0";
return { "pos": pos, "c": chrs.charAt(0) };
}
}
}
return isValid;
} | [
"function",
"(",
"chrs",
",",
"buffer",
",",
"pos",
",",
"strict",
",",
"opts",
")",
"{",
"var",
"frontValue",
"=",
"buffer",
".",
"join",
"(",
"''",
")",
".",
"substr",
"(",
"0",
",",
"3",
")",
";",
"if",
"(",
"frontValue",
".",
"indexOf",
"(",
... | val2 ~ day or month | [
"val2",
"~",
"day",
"or",
"month"
] | 19113c3cbc19a7afe0cfd3158d647064d2d30661 | https://github.com/ColorlibHQ/AdminLTE/blob/19113c3cbc19a7afe0cfd3158d647064d2d30661/plugins/input-mask/jquery.inputmask.date.extensions.js#L116-L130 | train | check if the character is valid | [
30522,
3853,
1006,
10381,
2869,
1010,
17698,
1010,
13433,
2015,
1010,
9384,
1010,
23569,
2015,
1007,
1063,
13075,
2392,
10175,
5657,
1027,
17698,
1012,
3693,
1006,
1005,
1005,
1007,
1012,
4942,
3367,
2099,
1006,
1014,
1010,
1017,
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... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js | function(aLibrariesToTest, aExcludedLibraries, bIncludeDistLayer, QUnit) {
var mLibraries = aLibrariesToTest ?
getRequestedLibraries(aLibrariesToTest)
:
getAllLibraries(aExcludedLibraries, bIncludeDistLayer);
QUnit.test("Should load at least one library and some controls", function(assert) {
assert.expect(2);
var bLibFound = false;
for (var sLibName in mLibraries) {
if (mLibraries[sLibName]) {
if (!bLibFound) {
assert.ok(mLibraries[sLibName], "Should have loaded at least one library");
bLibFound = true;
}
var iControls = mLibraries[sLibName].controls ? mLibraries[sLibName].controls.length : 0;
if (iControls > 0) {
assert.ok(iControls > 0, "Should find at least 10 controls in a library");
break;
}
}
}
});
return mLibraries;
} | javascript | function(aLibrariesToTest, aExcludedLibraries, bIncludeDistLayer, QUnit) {
var mLibraries = aLibrariesToTest ?
getRequestedLibraries(aLibrariesToTest)
:
getAllLibraries(aExcludedLibraries, bIncludeDistLayer);
QUnit.test("Should load at least one library and some controls", function(assert) {
assert.expect(2);
var bLibFound = false;
for (var sLibName in mLibraries) {
if (mLibraries[sLibName]) {
if (!bLibFound) {
assert.ok(mLibraries[sLibName], "Should have loaded at least one library");
bLibFound = true;
}
var iControls = mLibraries[sLibName].controls ? mLibraries[sLibName].controls.length : 0;
if (iControls > 0) {
assert.ok(iControls > 0, "Should find at least 10 controls in a library");
break;
}
}
}
});
return mLibraries;
} | [
"function",
"(",
"aLibrariesToTest",
",",
"aExcludedLibraries",
",",
"bIncludeDistLayer",
",",
"QUnit",
")",
"{",
"var",
"mLibraries",
"=",
"aLibrariesToTest",
"?",
"getRequestedLibraries",
"(",
"aLibrariesToTest",
")",
":",
"getAllLibraries",
"(",
"aExcludedLibraries",... | Returns a map of libraries - either exactly those requested in aLibrariesToTest, if defined, or all discoverable libraries
under the given conditions. | [
"Returns",
"a",
"map",
"of",
"libraries",
"-",
"either",
"exactly",
"those",
"requested",
"in",
"aLibrariesToTest",
"if",
"defined",
"or",
"all",
"discoverable",
"libraries",
"under",
"the",
"given",
"conditions",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/qunit/utils/ControlIterator.js#L321-L348 | train | Tests that all libraries are loaded and that there are at least 10 controls in a library | [
30522,
3853,
1006,
4862,
10024,
5134,
3406,
22199,
1010,
29347,
2595,
20464,
13936,
29521,
19848,
3111,
1010,
8026,
20464,
13936,
2923,
24314,
1010,
24209,
3490,
2102,
1007,
1063,
13075,
19875,
12322,
19848,
3111,
1027,
4862,
10024,
5134,
340... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
wangfupeng1988/wangEditor | src/js/editor/index.js | Editor | function Editor(toolbarSelector, textSelector) {
if (toolbarSelector == null) {
// 没有传入任何参数,报错
throw new Error('错误:初始化编辑器时候未传入任何参数,请查阅文档')
}
// id,用以区分单个页面不同的编辑器对象
this.id = 'wangEditor-' + editorId++
this.toolbarSelector = toolbarSelector
this.textSelector = textSelector
// 自定义配置
this.customConfig = {}
} | javascript | function Editor(toolbarSelector, textSelector) {
if (toolbarSelector == null) {
// 没有传入任何参数,报错
throw new Error('错误:初始化编辑器时候未传入任何参数,请查阅文档')
}
// id,用以区分单个页面不同的编辑器对象
this.id = 'wangEditor-' + editorId++
this.toolbarSelector = toolbarSelector
this.textSelector = textSelector
// 自定义配置
this.customConfig = {}
} | [
"function",
"Editor",
"(",
"toolbarSelector",
",",
"textSelector",
")",
"{",
"if",
"(",
"toolbarSelector",
"==",
"null",
")",
"{",
"// 没有传入任何参数,报错",
"throw",
"new",
"Error",
"(",
"'错误:初始化编辑器时候未传入任何参数,请查阅文档')",
"",
"}",
"// id,用以区分单个页面不同的编辑器对象",
"this",
".",
"id",
... | 构造函数 | [
"构造函数"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/editor/index.js#L19-L32 | train | Editor constructor. | [
30522,
3853,
3559,
1006,
6994,
8237,
11246,
22471,
2953,
1010,
6981,
12260,
16761,
1007,
1063,
2065,
1006,
6994,
8237,
11246,
22471,
2953,
1027,
1027,
19701,
1007,
1063,
1013,
1013,
100,
1873,
100,
100,
100,
100,
100,
100,
1989,
100,
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... |
LLK/scratch-blocks | blocks_vertical/motion.js | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "TOWARDS",
"options": [
[Blockly.Msg.MOTION_POINTTOWARDS_POINTER, '_mouse_'],
[Blockly.Msg.MOTION_POINTTOWARDS_RANDOM, '_random_']
]
}
],
"colour": Blockly.Colours.motion.secondary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"extensions": ["output_string"]
});
} | javascript | function() {
this.jsonInit({
"message0": "%1",
"args0": [
{
"type": "field_dropdown",
"name": "TOWARDS",
"options": [
[Blockly.Msg.MOTION_POINTTOWARDS_POINTER, '_mouse_'],
[Blockly.Msg.MOTION_POINTTOWARDS_RANDOM, '_random_']
]
}
],
"colour": Blockly.Colours.motion.secondary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"extensions": ["output_string"]
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"jsonInit",
"(",
"{",
"\"message0\"",
":",
"\"%1\"",
",",
"\"args0\"",
":",
"[",
"{",
"\"type\"",
":",
"\"field_dropdown\"",
",",
"\"name\"",
":",
"\"TOWARDS\"",
",",
"\"options\"",
":",
"[",
"[",
"Blockly",
".",
"... | Point towards drop-down menu.
@this Blockly.Block | [
"Point",
"towards",
"drop",
"-",
"down",
"menu",
"."
] | 455b2a854435c0a67da1da92320ddc3ec3e2b799 | https://github.com/LLK/scratch-blocks/blob/455b2a854435c0a67da1da92320ddc3ec3e2b799/blocks_vertical/motion.js#L128-L146 | 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... | |
websockets/ws | lib/buffer-util.js | toArrayBuffer | function toArrayBuffer(buf) {
if (buf.byteLength === buf.buffer.byteLength) {
return buf.buffer;
}
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
} | javascript | function toArrayBuffer(buf) {
if (buf.byteLength === buf.buffer.byteLength) {
return buf.buffer;
}
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
} | [
"function",
"toArrayBuffer",
"(",
"buf",
")",
"{",
"if",
"(",
"buf",
".",
"byteLength",
"===",
"buf",
".",
"buffer",
".",
"byteLength",
")",
"{",
"return",
"buf",
".",
"buffer",
";",
"}",
"return",
"buf",
".",
"buffer",
".",
"slice",
"(",
"buf",
".",... | Converts a buffer to an `ArrayBuffer`.
@param {Buffer} buf The buffer to convert
@return {ArrayBuffer} Converted buffer
@public | [
"Converts",
"a",
"buffer",
"to",
"an",
"ArrayBuffer",
"."
] | 995c527c87d0d4833d8093c18dcfa2e4a41d9582 | https://github.com/websockets/ws/blob/995c527c87d0d4833d8093c18dcfa2e4a41d9582/lib/buffer-util.js#L67-L73 | train | Converts a buffer to an array of bytes | [
30522,
3853,
2000,
2906,
9447,
8569,
12494,
1006,
20934,
2546,
1007,
1063,
2065,
1006,
20934,
2546,
1012,
24880,
7770,
13512,
2232,
1027,
1027,
1027,
20934,
2546,
1012,
17698,
1012,
24880,
7770,
13512,
2232,
1007,
1063,
2709,
20934,
2546,
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... |
SheetJS/js-xlsx | xlsx.js | fuzzynum | function fuzzynum(s) {
var v = Number(s);
if(!isNaN(v)) return v;
var wt = 1;
var ss = s.replace(/([\d]),([\d])/g,"$1$2").replace(/[$]/g,"").replace(/[%]/g, function() { wt *= 100; return "";});
if(!isNaN(v = Number(ss))) return v / wt;
ss = ss.replace(/[(](.*)[)]/,function($$, $1) { wt = -wt; return $1;});
if(!isNaN(v = Number(ss))) return v / wt;
return v;
} | javascript | function fuzzynum(s) {
var v = Number(s);
if(!isNaN(v)) return v;
var wt = 1;
var ss = s.replace(/([\d]),([\d])/g,"$1$2").replace(/[$]/g,"").replace(/[%]/g, function() { wt *= 100; return "";});
if(!isNaN(v = Number(ss))) return v / wt;
ss = ss.replace(/[(](.*)[)]/,function($$, $1) { wt = -wt; return $1;});
if(!isNaN(v = Number(ss))) return v / wt;
return v;
} | [
"function",
"fuzzynum",
"(",
"s",
")",
"{",
"var",
"v",
"=",
"Number",
"(",
"s",
")",
";",
"if",
"(",
"!",
"isNaN",
"(",
"v",
")",
")",
"return",
"v",
";",
"var",
"wt",
"=",
"1",
";",
"var",
"ss",
"=",
"s",
".",
"replace",
"(",
"/",
"([\\d]... | /* TODO: stress test | [
"/",
"*",
"TODO",
":",
"stress",
"test"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L2748-L2757 | train | Fuzzynum function | [
30522,
3853,
18001,
19172,
1006,
1055,
1007,
1063,
13075,
1058,
1027,
2193,
1006,
1055,
1007,
1025,
2065,
1006,
999,
3475,
2319,
1006,
1058,
1007,
1007,
2709,
1058,
1025,
13075,
1059,
2102,
1027,
1015,
1025,
13075,
7020,
1027,
1055,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/WorkingSetView.js | useIconProviders | function useIconProviders(data, $element) {
_iconProviders.forEach(function (provider) {
var icon = provider(data);
if (icon) {
$element.prepend($(icon));
}
});
} | javascript | function useIconProviders(data, $element) {
_iconProviders.forEach(function (provider) {
var icon = provider(data);
if (icon) {
$element.prepend($(icon));
}
});
} | [
"function",
"useIconProviders",
"(",
"data",
",",
"$element",
")",
"{",
"_iconProviders",
".",
"forEach",
"(",
"function",
"(",
"provider",
")",
"{",
"var",
"icon",
"=",
"provider",
"(",
"data",
")",
";",
"if",
"(",
"icon",
")",
"{",
"$element",
".",
"... | /*
To be used by other modules/default-extensions which needs to borrow working set entry icons
@param {!object} data - contains file info {fullPath, name, isFile}
@param {!jQuery} $element - jquery fn wrap for the list item | [
"/",
"*",
"To",
"be",
"used",
"by",
"other",
"modules",
"/",
"default",
"-",
"extensions",
"which",
"needs",
"to",
"borrow",
"working",
"set",
"entry",
"icons"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/WorkingSetView.js#L1480-L1487 | train | Use icon providers | [
30522,
3853,
2224,
28524,
21572,
17258,
2545,
1006,
2951,
1010,
1002,
5783,
1007,
1063,
1035,
12696,
21572,
17258,
2545,
1012,
18921,
6776,
1006,
3853,
1006,
10802,
1007,
1063,
13075,
12696,
1027,
10802,
1006,
2951,
1007,
1025,
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... |
fex-team/webuploader | dist/webuploader.withoutimage.js | function( name, callback, context ) {
var me = this;
if ( !callback ) {
return me;
}
eachEvent( name, callback, function( name, callback ) {
var once = function() {
me.off( name, once );
return callback.apply( context || me, arguments );
};
once._cb = callback;
me.on( name, once, context );
});
return me;
} | javascript | function( name, callback, context ) {
var me = this;
if ( !callback ) {
return me;
}
eachEvent( name, callback, function( name, callback ) {
var once = function() {
me.off( name, once );
return callback.apply( context || me, arguments );
};
once._cb = callback;
me.on( name, once, context );
});
return me;
} | [
"function",
"(",
"name",
",",
"callback",
",",
"context",
")",
"{",
"var",
"me",
"=",
"this",
";",
"if",
"(",
"!",
"callback",
")",
"{",
"return",
"me",
";",
"}",
"eachEvent",
"(",
"name",
",",
"callback",
",",
"function",
"(",
"name",
",",
"callba... | 绑定事件,且当handler执行完后,自动解除绑定。
@method once
@grammar once( name, callback[, context] ) => self
@param {String} name 事件名
@param {Function} callback 事件处理器
@param {Object} [context] 事件处理器的上下文。
@return {self} 返回自身,方便链式
@chainable | [
"绑定事件,且当handler执行完后,自动解除绑定。"
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/dist/webuploader.withoutimage.js#L614-L632 | train | add event listener | [
30522,
3853,
1006,
2171,
1010,
2655,
5963,
1010,
6123,
1007,
1063,
13075,
2033,
1027,
2023,
1025,
2065,
1006,
999,
2655,
5963,
1007,
1063,
2709,
2033,
1025,
1065,
2169,
18697,
3372,
1006,
2171,
1010,
2655,
5963,
1010,
3853,
1006,
2171,
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... | |
SeleniumHQ/selenium | javascript/jsunit/app/xbDebug.js | xbDebugApplyFunction | function xbDebugApplyFunction(funcname, funcref, thisref, argumentsref)
{
var rv;
if (!funcref)
{
alert('xbDebugApplyFunction: funcref is null');
}
if (typeof(funcref.apply) != 'undefined')
return funcref.apply(thisref, argumentsref);
var applyexpr = 'thisref.xbDebug_orig_' + funcname + '(';
var i;
for (i = 0; i < argumentsref.length; i++)
{
applyexpr += 'argumentsref[' + i + '],';
}
if (argumentsref.length > 0)
{
applyexpr = applyexpr.substring(0, applyexpr.length - 1);
}
applyexpr += ')';
return eval(applyexpr);
} | javascript | function xbDebugApplyFunction(funcname, funcref, thisref, argumentsref)
{
var rv;
if (!funcref)
{
alert('xbDebugApplyFunction: funcref is null');
}
if (typeof(funcref.apply) != 'undefined')
return funcref.apply(thisref, argumentsref);
var applyexpr = 'thisref.xbDebug_orig_' + funcname + '(';
var i;
for (i = 0; i < argumentsref.length; i++)
{
applyexpr += 'argumentsref[' + i + '],';
}
if (argumentsref.length > 0)
{
applyexpr = applyexpr.substring(0, applyexpr.length - 1);
}
applyexpr += ')';
return eval(applyexpr);
} | [
"function",
"xbDebugApplyFunction",
"(",
"funcname",
",",
"funcref",
",",
"thisref",
",",
"argumentsref",
")",
"{",
"var",
"rv",
";",
"if",
"(",
"!",
"funcref",
")",
"{",
"alert",
"(",
"'xbDebugApplyFunction: funcref is null'",
")",
";",
"}",
"if",
"(",
"typ... | emulate functionref.apply for IE mac and IE win < 5.5 | [
"emulate",
"functionref",
".",
"apply",
"for",
"IE",
"mac",
"and",
"IE",
"win",
"<",
"5",
".",
"5"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/jsunit/app/xbDebug.js#L118-L146 | train | This function is called by xbDebugApplyFunction to apply a function to a specific object | [
30522,
3853,
1060,
2497,
3207,
8569,
3654,
9397,
2135,
11263,
27989,
1006,
4569,
2278,
18442,
1010,
4569,
16748,
2546,
1010,
2023,
2890,
2546,
1010,
9918,
2890,
2546,
1007,
1063,
13075,
27634,
1025,
2065,
1006,
999,
4569,
16748,
2546,
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... |
angular/material | src/components/gridList/grid-list.js | GridLayoutFactory | function GridLayoutFactory($mdUtil) {
var defaultAnimator = GridTileAnimator;
/**
* Set the reflow animator callback
*/
GridLayout.animateWith = function(customAnimator) {
defaultAnimator = !angular.isFunction(customAnimator) ? GridTileAnimator : customAnimator;
};
return GridLayout;
/**
* Publish layout function
*/
function GridLayout(colCount, tileSpans) {
var self, layoutInfo, gridStyles, layoutTime, mapTime, reflowTime;
layoutTime = $mdUtil.time(function() {
layoutInfo = calculateGridFor(colCount, tileSpans);
});
return self = {
/**
* An array of objects describing each tile's position in the grid.
*/
layoutInfo: function() {
return layoutInfo;
},
/**
* Maps grid positioning to an element and a set of styles using the
* provided updateFn.
*/
map: function(updateFn) {
mapTime = $mdUtil.time(function() {
var info = self.layoutInfo();
gridStyles = updateFn(info.positioning, info.rowCount);
});
return self;
},
/**
* Default animator simply sets the element.css( <styles> ). An alternate
* animator can be provided as an argument. The function has the following
* signature:
*
* function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>)
*/
reflow: function(animatorFn) {
reflowTime = $mdUtil.time(function() {
var animator = animatorFn || defaultAnimator;
animator(gridStyles.grid, gridStyles.tiles);
});
return self;
},
/**
* Timing for the most recent layout run.
*/
performance: function() {
return {
tileCount: tileSpans.length,
layoutTime: layoutTime,
mapTime: mapTime,
reflowTime: reflowTime,
totalTime: layoutTime + mapTime + reflowTime
};
}
};
}
/**
* Default Gridlist animator simple sets the css for each element;
* NOTE: any transitions effects must be manually set in the CSS.
* e.g.
*
* md-grid-tile {
* transition: all 700ms ease-out 50ms;
* }
*
*/
function GridTileAnimator(grid, tiles) {
grid.element.css(grid.style);
tiles.forEach(function(t) {
t.element.css(t.style);
});
}
/**
* Calculates the positions of tiles.
*
* The algorithm works as follows:
* An Array<Number> with length colCount (spaceTracker) keeps track of
* available tiling positions, where elements of value 0 represents an
* empty position. Space for a tile is reserved by finding a sequence of
* 0s with length <= than the tile's colspan. When such a space has been
* found, the occupied tile positions are incremented by the tile's
* rowspan value, as these positions have become unavailable for that
* many rows.
*
* If the end of a row has been reached without finding space for the
* tile, spaceTracker's elements are each decremented by 1 to a minimum
* of 0. Rows are searched in this fashion until space is found.
*/
function calculateGridFor(colCount, tileSpans) {
var curCol = 0,
curRow = 0,
spaceTracker = newSpaceTracker();
return {
positioning: tileSpans.map(function(spans, i) {
return {
spans: spans,
position: reserveSpace(spans, i)
};
}),
rowCount: curRow + Math.max.apply(Math, spaceTracker)
};
function reserveSpace(spans, i) {
if (spans.col > colCount) {
throw 'md-grid-list: Tile at position ' + i + ' has a colspan ' +
'(' + spans.col + ') that exceeds the column count ' +
'(' + colCount + ')';
}
var start = 0,
end = 0;
// TODO(shyndman): This loop isn't strictly necessary if you can
// determine the minimum number of rows before a space opens up. To do
// this, recognize that you've iterated across an entire row looking for
// space, and if so fast-forward by the minimum rowSpan count. Repeat
// until the required space opens up.
while (end - start < spans.col) {
if (curCol >= colCount) {
nextRow();
continue;
}
start = spaceTracker.indexOf(0, curCol);
if (start === -1 || (end = findEnd(start + 1)) === -1) {
start = end = 0;
nextRow();
continue;
}
curCol = end + 1;
}
adjustRow(start, spans.col, spans.row);
curCol = start + spans.col;
return {
col: start,
row: curRow
};
}
function nextRow() {
curCol = 0;
curRow++;
adjustRow(0, colCount, -1); // Decrement row spans by one
}
function adjustRow(from, cols, by) {
for (var i = from; i < from + cols; i++) {
spaceTracker[i] = Math.max(spaceTracker[i] + by, 0);
}
}
function findEnd(start) {
var i;
for (i = start; i < spaceTracker.length; i++) {
if (spaceTracker[i] !== 0) {
return i;
}
}
if (i === spaceTracker.length) {
return i;
}
}
function newSpaceTracker() {
var tracker = [];
for (var i = 0; i < colCount; i++) {
tracker.push(0);
}
return tracker;
}
}
} | javascript | function GridLayoutFactory($mdUtil) {
var defaultAnimator = GridTileAnimator;
/**
* Set the reflow animator callback
*/
GridLayout.animateWith = function(customAnimator) {
defaultAnimator = !angular.isFunction(customAnimator) ? GridTileAnimator : customAnimator;
};
return GridLayout;
/**
* Publish layout function
*/
function GridLayout(colCount, tileSpans) {
var self, layoutInfo, gridStyles, layoutTime, mapTime, reflowTime;
layoutTime = $mdUtil.time(function() {
layoutInfo = calculateGridFor(colCount, tileSpans);
});
return self = {
/**
* An array of objects describing each tile's position in the grid.
*/
layoutInfo: function() {
return layoutInfo;
},
/**
* Maps grid positioning to an element and a set of styles using the
* provided updateFn.
*/
map: function(updateFn) {
mapTime = $mdUtil.time(function() {
var info = self.layoutInfo();
gridStyles = updateFn(info.positioning, info.rowCount);
});
return self;
},
/**
* Default animator simply sets the element.css( <styles> ). An alternate
* animator can be provided as an argument. The function has the following
* signature:
*
* function({grid: {element: JQLite, style: Object}, tiles: Array<{element: JQLite, style: Object}>)
*/
reflow: function(animatorFn) {
reflowTime = $mdUtil.time(function() {
var animator = animatorFn || defaultAnimator;
animator(gridStyles.grid, gridStyles.tiles);
});
return self;
},
/**
* Timing for the most recent layout run.
*/
performance: function() {
return {
tileCount: tileSpans.length,
layoutTime: layoutTime,
mapTime: mapTime,
reflowTime: reflowTime,
totalTime: layoutTime + mapTime + reflowTime
};
}
};
}
/**
* Default Gridlist animator simple sets the css for each element;
* NOTE: any transitions effects must be manually set in the CSS.
* e.g.
*
* md-grid-tile {
* transition: all 700ms ease-out 50ms;
* }
*
*/
function GridTileAnimator(grid, tiles) {
grid.element.css(grid.style);
tiles.forEach(function(t) {
t.element.css(t.style);
});
}
/**
* Calculates the positions of tiles.
*
* The algorithm works as follows:
* An Array<Number> with length colCount (spaceTracker) keeps track of
* available tiling positions, where elements of value 0 represents an
* empty position. Space for a tile is reserved by finding a sequence of
* 0s with length <= than the tile's colspan. When such a space has been
* found, the occupied tile positions are incremented by the tile's
* rowspan value, as these positions have become unavailable for that
* many rows.
*
* If the end of a row has been reached without finding space for the
* tile, spaceTracker's elements are each decremented by 1 to a minimum
* of 0. Rows are searched in this fashion until space is found.
*/
function calculateGridFor(colCount, tileSpans) {
var curCol = 0,
curRow = 0,
spaceTracker = newSpaceTracker();
return {
positioning: tileSpans.map(function(spans, i) {
return {
spans: spans,
position: reserveSpace(spans, i)
};
}),
rowCount: curRow + Math.max.apply(Math, spaceTracker)
};
function reserveSpace(spans, i) {
if (spans.col > colCount) {
throw 'md-grid-list: Tile at position ' + i + ' has a colspan ' +
'(' + spans.col + ') that exceeds the column count ' +
'(' + colCount + ')';
}
var start = 0,
end = 0;
// TODO(shyndman): This loop isn't strictly necessary if you can
// determine the minimum number of rows before a space opens up. To do
// this, recognize that you've iterated across an entire row looking for
// space, and if so fast-forward by the minimum rowSpan count. Repeat
// until the required space opens up.
while (end - start < spans.col) {
if (curCol >= colCount) {
nextRow();
continue;
}
start = spaceTracker.indexOf(0, curCol);
if (start === -1 || (end = findEnd(start + 1)) === -1) {
start = end = 0;
nextRow();
continue;
}
curCol = end + 1;
}
adjustRow(start, spans.col, spans.row);
curCol = start + spans.col;
return {
col: start,
row: curRow
};
}
function nextRow() {
curCol = 0;
curRow++;
adjustRow(0, colCount, -1); // Decrement row spans by one
}
function adjustRow(from, cols, by) {
for (var i = from; i < from + cols; i++) {
spaceTracker[i] = Math.max(spaceTracker[i] + by, 0);
}
}
function findEnd(start) {
var i;
for (i = start; i < spaceTracker.length; i++) {
if (spaceTracker[i] !== 0) {
return i;
}
}
if (i === spaceTracker.length) {
return i;
}
}
function newSpaceTracker() {
var tracker = [];
for (var i = 0; i < colCount; i++) {
tracker.push(0);
}
return tracker;
}
}
} | [
"function",
"GridLayoutFactory",
"(",
"$mdUtil",
")",
"{",
"var",
"defaultAnimator",
"=",
"GridTileAnimator",
";",
"/**\n * Set the reflow animator callback\n */",
"GridLayout",
".",
"animateWith",
"=",
"function",
"(",
"customAnimator",
")",
"{",
"defaultAnimator",
"... | /* @ngInject | [
"/",
"*"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/gridList/grid-list.js#L466-L660 | train | Creates a new GridLayout instance. | [
30522,
3853,
8370,
8485,
5833,
21450,
1006,
1002,
9108,
21823,
2140,
1007,
1063,
13075,
12398,
7088,
18900,
2953,
1027,
8370,
15286,
7088,
18900,
2953,
1025,
1013,
1008,
1008,
1008,
2275,
1996,
25416,
8261,
25132,
2655,
5963,
1008,
1013,
83... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-unexpected-multiline.js | checkForBreakAfter | function checkForBreakAfter(node, messageId) {
const openParen = sourceCode.getTokenAfter(node, astUtils.isNotClosingParenToken);
const nodeExpressionEnd = sourceCode.getTokenBefore(openParen);
if (openParen.loc.start.line !== nodeExpressionEnd.loc.end.line) {
context.report({ node, loc: openParen.loc.start, messageId, data: { char: openParen.value } });
}
} | javascript | function checkForBreakAfter(node, messageId) {
const openParen = sourceCode.getTokenAfter(node, astUtils.isNotClosingParenToken);
const nodeExpressionEnd = sourceCode.getTokenBefore(openParen);
if (openParen.loc.start.line !== nodeExpressionEnd.loc.end.line) {
context.report({ node, loc: openParen.loc.start, messageId, data: { char: openParen.value } });
}
} | [
"function",
"checkForBreakAfter",
"(",
"node",
",",
"messageId",
")",
"{",
"const",
"openParen",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"node",
",",
"astUtils",
".",
"isNotClosingParenToken",
")",
";",
"const",
"nodeExpressionEnd",
"=",
"sourceCode",
".",
... | Check to see if there is a newline between the node and the following open bracket
line's expression
@param {ASTNode} node The node to check.
@param {string} messageId The error messageId to use.
@returns {void}
@private | [
"Check",
"to",
"see",
"if",
"there",
"is",
"a",
"newline",
"between",
"the",
"node",
"and",
"the",
"following",
"open",
"bracket",
"line",
"s",
"expression"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-unexpected-multiline.js#L51-L58 | train | Check if a break is after a break | [
30522,
3853,
4638,
29278,
23890,
10354,
3334,
1006,
13045,
1010,
4471,
3593,
1007,
1063,
9530,
3367,
2330,
19362,
2368,
1027,
3120,
16044,
1012,
2131,
18715,
8189,
6199,
2121,
1006,
13045,
1010,
2004,
8525,
3775,
4877,
1012,
3475,
4140,
204... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/utils.js | classify | function classify(string) {
string = string.replace(/[\W_](\w)/g, match => ` ${match[1].toUpperCase()}`).replace(/\s/g, '');
return string.charAt(0).toUpperCase() + string.slice(1);
} | javascript | function classify(string) {
string = string.replace(/[\W_](\w)/g, match => ` ${match[1].toUpperCase()}`).replace(/\s/g, '');
return string.charAt(0).toUpperCase() + string.slice(1);
} | [
"function",
"classify",
"(",
"string",
")",
"{",
"string",
"=",
"string",
".",
"replace",
"(",
"/",
"[\\W_](\\w)",
"/",
"g",
",",
"match",
"=>",
"`",
"${",
"match",
"[",
"1",
"]",
".",
"toUpperCase",
"(",
")",
"}",
"`",
")",
".",
"replace",
"(",
... | Convenient function to convert string into valid java class name
Note: _.classify uses _.titleize which lowercase the string,
so if the user chooses a proper ClassName it will not rename properly
@param string string to 'class'-ify
@returns {string} 'class'-ified string | [
"Convenient",
"function",
"to",
"convert",
"string",
"into",
"valid",
"java",
"class",
"name",
"Note",
":",
"_",
".",
"classify",
"uses",
"_",
".",
"titleize",
"which",
"lowercase",
"the",
"string",
"so",
"if",
"the",
"user",
"chooses",
"a",
"proper",
"Cla... | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/utils.js#L140-L143 | train | Classify a string | [
30522,
3853,
26268,
1006,
5164,
1007,
1063,
5164,
1027,
5164,
1012,
5672,
1006,
1013,
1031,
1032,
1059,
1035,
1033,
1006,
1032,
1059,
1007,
1013,
1043,
1010,
2674,
1027,
1028,
1036,
1002,
1063,
2674,
1031,
1015,
1033,
1012,
2000,
29547,
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... |
GeekyAnts/vue-native-core | packages/vue-native-scripts/src/scripts/compiler.js | parseTemplate | function parseTemplate(code) {
const obj = compiler.nativeCompiler(code);
return {
import: obj.importCode,
render: `const ${constants.TEMPLATE_RENDER} = ${obj.renderCode}`
};
} | javascript | function parseTemplate(code) {
const obj = compiler.nativeCompiler(code);
return {
import: obj.importCode,
render: `const ${constants.TEMPLATE_RENDER} = ${obj.renderCode}`
};
} | [
"function",
"parseTemplate",
"(",
"code",
")",
"{",
"const",
"obj",
"=",
"compiler",
".",
"nativeCompiler",
"(",
"code",
")",
";",
"return",
"{",
"import",
":",
"obj",
".",
"importCode",
",",
"render",
":",
"`",
"${",
"constants",
".",
"TEMPLATE_RENDER",
... | function remove(name) { fs.unlink(name.replace(FILTER, '.js'), function(err) { if (err) { throw err; } }); } | [
"function",
"remove",
"(",
"name",
")",
"{",
"fs",
".",
"unlink",
"(",
"name",
".",
"replace",
"(",
"FILTER",
".",
"js",
")",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"throw",
"err",
";",
"}",
"}",
")",
";",
"}"
] | a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e | https://github.com/GeekyAnts/vue-native-core/blob/a7b4c9e35fe3f01d7576086f41e5e9ec6975b72e/packages/vue-native-scripts/src/scripts/compiler.js#L254-L260 | train | Parse a template | [
30522,
3853,
11968,
13462,
6633,
15725,
1006,
3642,
1007,
1063,
9530,
3367,
27885,
3501,
1027,
21624,
1012,
3128,
9006,
22090,
2099,
1006,
3642,
1007,
1025,
2709,
1063,
12324,
1024,
27885,
3501,
1012,
12324,
16044,
1010,
17552,
1024,
1036,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
vuejs/vuepress | packages/@vuepress/core/lib/node/build/index.js | compile | function compile (config) {
return new Promise((resolve, reject) => {
webpack(config, (err, stats) => {
if (err) {
return reject(err)
}
if (stats.hasErrors()) {
stats.toJson().errors.forEach(err => {
console.error(err)
})
reject(new Error(`Failed to compile with errors.`))
return
}
if (env.isDebug && stats.hasWarnings()) {
stats.toJson().warnings.forEach(warning => {
console.warn(warning)
})
}
resolve(stats.toJson({ modules: false }))
})
})
} | javascript | function compile (config) {
return new Promise((resolve, reject) => {
webpack(config, (err, stats) => {
if (err) {
return reject(err)
}
if (stats.hasErrors()) {
stats.toJson().errors.forEach(err => {
console.error(err)
})
reject(new Error(`Failed to compile with errors.`))
return
}
if (env.isDebug && stats.hasWarnings()) {
stats.toJson().warnings.forEach(warning => {
console.warn(warning)
})
}
resolve(stats.toJson({ modules: false }))
})
})
} | [
"function",
"compile",
"(",
"config",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"webpack",
"(",
"config",
",",
"(",
"err",
",",
"stats",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"reject",... | Compile a webpack application and return stats json.
@param {Object} config
@returns {Promise<Object>} | [
"Compile",
"a",
"webpack",
"application",
"and",
"return",
"stats",
"json",
"."
] | 15784acc0cf2e87de3c147895b2c3977b0195d78 | https://github.com/vuejs/vuepress/blob/15784acc0cf2e87de3c147895b2c3977b0195d78/packages/@vuepress/core/lib/node/build/index.js#L176-L197 | train | Compile the webpack module | [
30522,
3853,
4012,
22090,
1006,
9530,
8873,
2290,
1007,
1063,
2709,
2047,
4872,
1006,
1006,
10663,
1010,
15454,
1007,
1027,
1028,
1063,
4773,
23947,
1006,
9530,
8873,
2290,
1010,
1006,
9413,
2099,
1010,
26319,
1007,
1027,
1028,
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... |
firebase/firebaseui-web | javascript/widgets/handler/phonesigninfinish.js | function(error) {
if (error['name'] && error['name'] == 'cancel') {
// Close dialog.
component.dismissDialog();
return;
}
// Get error message.
var errorMessage =
firebaseui.auth.widget.handler.common.getErrorMessage(error);
// Some errors are recoverable while others require resending the code.
switch (error['code']) {
case 'auth/credential-already-in-use':
// Do nothing when anonymous user is getting upgraded.
// Developer should handle this in signInFailure callback.
component.dismissDialog();
break;
case 'auth/code-expired':
// Expired code requires sending another request.
// Render previous phone sign in start page and display error in
// the info bar.
var container = component.getContainer();
// Close dialog.
component.dismissDialog();
component.dispose();
firebaseui.auth.widget.handler.handle(
firebaseui.auth.widget.HandlerName.PHONE_SIGN_IN_START, app,
container, phoneNumberValue, errorMessage);
break;
case 'auth/missing-verification-code':
case 'auth/invalid-verification-code':
// Close dialog.
component.dismissDialog();
// As these errors are related to the code provided, it is better
// to display inline.
showInvalidCode(errorMessage);
break;
default:
// Close dialog.
component.dismissDialog();
// Stay on the same page for all other errors and display error in
// info bar.
component.showInfoBar(errorMessage);
break;
}
} | javascript | function(error) {
if (error['name'] && error['name'] == 'cancel') {
// Close dialog.
component.dismissDialog();
return;
}
// Get error message.
var errorMessage =
firebaseui.auth.widget.handler.common.getErrorMessage(error);
// Some errors are recoverable while others require resending the code.
switch (error['code']) {
case 'auth/credential-already-in-use':
// Do nothing when anonymous user is getting upgraded.
// Developer should handle this in signInFailure callback.
component.dismissDialog();
break;
case 'auth/code-expired':
// Expired code requires sending another request.
// Render previous phone sign in start page and display error in
// the info bar.
var container = component.getContainer();
// Close dialog.
component.dismissDialog();
component.dispose();
firebaseui.auth.widget.handler.handle(
firebaseui.auth.widget.HandlerName.PHONE_SIGN_IN_START, app,
container, phoneNumberValue, errorMessage);
break;
case 'auth/missing-verification-code':
case 'auth/invalid-verification-code':
// Close dialog.
component.dismissDialog();
// As these errors are related to the code provided, it is better
// to display inline.
showInvalidCode(errorMessage);
break;
default:
// Close dialog.
component.dismissDialog();
// Stay on the same page for all other errors and display error in
// info bar.
component.showInfoBar(errorMessage);
break;
}
} | [
"function",
"(",
"error",
")",
"{",
"if",
"(",
"error",
"[",
"'name'",
"]",
"&&",
"error",
"[",
"'name'",
"]",
"==",
"'cancel'",
")",
"{",
"// Close dialog.",
"component",
".",
"dismissDialog",
"(",
")",
";",
"return",
";",
"}",
"// Get error message.",
... | On code verification failure. | [
"On",
"code",
"verification",
"failure",
"."
] | c10aa51e38aeb38dc63baa22b48cd6690c2be087 | https://github.com/firebase/firebaseui-web/blob/c10aa51e38aeb38dc63baa22b48cd6690c2be087/javascript/widgets/handler/phonesigninfinish.js#L173-L217 | train | Handle phone sign in failure. | [
30522,
3853,
1006,
7561,
1007,
1063,
2065,
1006,
7561,
1031,
1005,
2171,
1005,
1033,
1004,
1004,
7561,
1031,
1005,
2171,
1005,
1033,
1027,
1027,
1005,
17542,
1005,
1007,
1063,
1013,
1013,
2485,
13764,
8649,
1012,
6922,
1012,
19776,
27184,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
nodejs/node-gyp | lib/build.js | findMsbuild | function findMsbuild () {
log.verbose('could not find "msbuild.exe" in PATH - finding location in registry')
var notfoundErr = 'Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?'
var cmd = 'reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s'
if (process.arch !== 'ia32')
cmd += ' /reg:32'
exec(cmd, function (err, stdout) {
if (err) {
return callback(new Error(err.message + '\n' + notfoundErr))
}
var reVers = /ToolsVersions\\([^\\]+)$/i
, rePath = /\r\n[ \t]+MSBuildToolsPath[ \t]+REG_SZ[ \t]+([^\r]+)/i
, msbuilds = []
, r
, msbuildPath
stdout.split('\r\n\r\n').forEach(function(l) {
if (!l) return
l = l.trim()
if (r = reVers.exec(l.substring(0, l.indexOf('\r\n')))) {
var ver = parseFloat(r[1], 10)
if (ver >= 3.5) {
if (r = rePath.exec(l)) {
msbuilds.push({
version: ver,
path: r[1]
})
}
}
}
})
msbuilds.sort(function (x, y) {
return (x.version < y.version ? -1 : 1)
})
;(function verifyMsbuild () {
if (!msbuilds.length) return callback(new Error(notfoundErr))
msbuildPath = path.resolve(msbuilds.pop().path, 'msbuild.exe')
fs.stat(msbuildPath, function (err) {
if (err) {
if (err.code == 'ENOENT') {
if (msbuilds.length) {
return verifyMsbuild()
} else {
callback(new Error(notfoundErr))
}
} else {
callback(err)
}
return
}
command = msbuildPath
doBuild()
})
})()
})
} | javascript | function findMsbuild () {
log.verbose('could not find "msbuild.exe" in PATH - finding location in registry')
var notfoundErr = 'Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?'
var cmd = 'reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s'
if (process.arch !== 'ia32')
cmd += ' /reg:32'
exec(cmd, function (err, stdout) {
if (err) {
return callback(new Error(err.message + '\n' + notfoundErr))
}
var reVers = /ToolsVersions\\([^\\]+)$/i
, rePath = /\r\n[ \t]+MSBuildToolsPath[ \t]+REG_SZ[ \t]+([^\r]+)/i
, msbuilds = []
, r
, msbuildPath
stdout.split('\r\n\r\n').forEach(function(l) {
if (!l) return
l = l.trim()
if (r = reVers.exec(l.substring(0, l.indexOf('\r\n')))) {
var ver = parseFloat(r[1], 10)
if (ver >= 3.5) {
if (r = rePath.exec(l)) {
msbuilds.push({
version: ver,
path: r[1]
})
}
}
}
})
msbuilds.sort(function (x, y) {
return (x.version < y.version ? -1 : 1)
})
;(function verifyMsbuild () {
if (!msbuilds.length) return callback(new Error(notfoundErr))
msbuildPath = path.resolve(msbuilds.pop().path, 'msbuild.exe')
fs.stat(msbuildPath, function (err) {
if (err) {
if (err.code == 'ENOENT') {
if (msbuilds.length) {
return verifyMsbuild()
} else {
callback(new Error(notfoundErr))
}
} else {
callback(err)
}
return
}
command = msbuildPath
doBuild()
})
})()
})
} | [
"function",
"findMsbuild",
"(",
")",
"{",
"log",
".",
"verbose",
"(",
"'could not find \"msbuild.exe\" in PATH - finding location in registry'",
")",
"var",
"notfoundErr",
"=",
"'Can\\'t find \"msbuild.exe\". Do you have Microsoft Visual Studio C++ 2008+ installed?'",
"var",
"cmd",
... | Search for the location of "msbuild.exe" file on Windows. | [
"Search",
"for",
"the",
"location",
"of",
"msbuild",
".",
"exe",
"file",
"on",
"Windows",
"."
] | 721eb691cf15556cc2700eda0558d5bad5f84232 | https://github.com/nodejs/node-gyp/blob/721eb691cf15556cc2700eda0558d5bad5f84232/lib/build.js#L126-L180 | train | find msbuild. exe | [
30522,
3853,
2424,
5244,
8569,
4014,
2094,
1006,
1007,
1063,
8833,
1012,
12034,
9232,
1006,
1005,
2071,
2025,
2424,
1000,
5796,
8569,
4014,
2094,
1012,
4654,
2063,
1000,
1999,
4130,
1011,
4531,
3295,
1999,
15584,
1005,
1007,
13075,
2025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | getHumanEnvironment | function getHumanEnvironment(env) {
var binding = env.replace(/_binding\.node$/, ''),
parts = binding.split('-'),
platform = getHumanPlatform(parts[0]),
arch = getHumanArchitecture(parts[1]),
runtime = getHumanNodeVersion(parts[2]);
if (parts.length !== 3) {
return 'Unknown environment (' + binding + ')';
}
if (!platform) {
platform = 'Unsupported platform (' + parts[0] + ')';
}
if (!arch) {
arch = 'Unsupported architecture (' + parts[1] + ')';
}
if (!runtime) {
runtime = 'Unsupported runtime (' + parts[2] + ')';
}
return [
platform, arch, 'with', runtime,
].join(' ');
} | javascript | function getHumanEnvironment(env) {
var binding = env.replace(/_binding\.node$/, ''),
parts = binding.split('-'),
platform = getHumanPlatform(parts[0]),
arch = getHumanArchitecture(parts[1]),
runtime = getHumanNodeVersion(parts[2]);
if (parts.length !== 3) {
return 'Unknown environment (' + binding + ')';
}
if (!platform) {
platform = 'Unsupported platform (' + parts[0] + ')';
}
if (!arch) {
arch = 'Unsupported architecture (' + parts[1] + ')';
}
if (!runtime) {
runtime = 'Unsupported runtime (' + parts[2] + ')';
}
return [
platform, arch, 'with', runtime,
].join(' ');
} | [
"function",
"getHumanEnvironment",
"(",
"env",
")",
"{",
"var",
"binding",
"=",
"env",
".",
"replace",
"(",
"/",
"_binding\\.node$",
"/",
",",
"''",
")",
",",
"parts",
"=",
"binding",
".",
"split",
"(",
"'-'",
")",
",",
"platform",
"=",
"getHumanPlatform... | Get a human readable description of where node-sass is running to support
user error reporting when something goes wrong
@param {string} env - The name of the native bindings that is to be parsed
@return {string} A description of what os, architecture, and Node version
that is being run
@api public | [
"Get",
"a",
"human",
"readable",
"description",
"of",
"where",
"node",
"-",
"sass",
"is",
"running",
"to",
"support",
"user",
"error",
"reporting",
"when",
"something",
"goes",
"wrong"
] | 0c1a49eefa37544d16041c5fe5b2e3d9168004b7 | https://github.com/sass/node-sass/blob/0c1a49eefa37544d16041c5fe5b2e3d9168004b7/lib/extensions.js#L95-L121 | train | Get a human readable environment | [
30522,
3853,
2131,
28600,
7231,
2078,
21663,
2239,
3672,
1006,
4372,
2615,
1007,
1063,
13075,
8031,
1027,
4372,
2615,
1012,
5672,
1006,
1013,
1035,
8031,
1032,
1012,
13045,
1002,
1013,
1010,
1005,
1005,
1007,
1010,
3033,
1027,
8031,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/project/FileSyncManager.js | syncOpenDocuments | function syncOpenDocuments(title) {
title = title || Strings.EXT_MODIFIED_TITLE;
// We can become "re-entrant" if the user leaves & then returns to Brackets before we're
// done -- easy if a prompt dialog is left open. Since the user may have left Brackets to
// revert some of the disk changes, etc. we want to cancel the current sync and immediately
// begin a new one. We let the orig sync run until the user-visible dialog phase, then
// bail; if we're already there we programmatically close the dialog to bail right away.
if (_alreadyChecking) {
_restartPending = true;
// Close dialog if it was open. This will 'unblock' presentConflict(), which bails back
// to us immediately upon seeing _restartPending. We then restart the sync - see below
Dialogs.cancelModalDialogIfOpen(DefaultDialogs.DIALOG_ID_EXT_CHANGED);
Dialogs.cancelModalDialogIfOpen(DefaultDialogs.DIALOG_ID_EXT_DELETED);
return;
}
_alreadyChecking = true;
// Syncing proceeds in four phases:
// 1) Check all open files for external modifications
// 2) Check any other working set entries (that are not open) for deletion, and remove
// from working set if deleted
// 3) Refresh all Documents that are clean (if file changed on disk)
// 4) Close all Documents that are clean (if file deleted on disk)
// 5) Prompt about any Documents that are dirty (if file changed/deleted on disk)
// Each phase fully completes (asynchronously) before the next one begins.
// 1) Check for external modifications
var allDocs = DocumentManager.getAllOpenDocuments();
findExternalChanges(allDocs)
.done(function () {
// 2) Check un-open working set entries for deletion (& "close" if needed)
syncUnopenWorkingSet()
.always(function () {
// If we were unable to check any un-open files for deletion, silently ignore
// (after logging to console). This doesn't have any bearing on syncing truly
// open Documents (which we've already successfully checked).
// 3) Reload clean docs as needed
reloadChangedDocs()
.always(function () {
// 4) Close clean docs as needed
// This phase completes synchronously
closeDeletedDocs();
// 5) Prompt for dirty editors (conflicts)
presentConflicts(title)
.always(function () {
if (_restartPending) {
// Restart the sync if needed
_restartPending = false;
_alreadyChecking = false;
syncOpenDocuments();
} else {
// We're really done!
_alreadyChecking = false;
// If we showed a dialog, restore focus to editor
if (editConflicts.length > 0 || deleteConflicts.length > 0) {
MainViewManager.focusActivePane();
}
// (Any errors that ocurred during presentConflicts() have already
// shown UI & been dismissed, so there's no fail() handler here)
}
});
});
// Note: if any auto-reloads failed, we silently ignore (after logging to console)
// and we still continue onto phase 4 and try to process those files anyway.
// (We'll retry the auto-reloads next time window is activated... and evenually
// we'll also be double checking before each Save).
});
}).fail(function () {
// Unable to fetch timestamps for some reason - silently ignore (after logging to console)
// (We'll retry next time window is activated... and evenually we'll also be double
// checking before each Save).
// We can't go on without knowing which files are dirty, so bail now
_alreadyChecking = false;
});
} | javascript | function syncOpenDocuments(title) {
title = title || Strings.EXT_MODIFIED_TITLE;
// We can become "re-entrant" if the user leaves & then returns to Brackets before we're
// done -- easy if a prompt dialog is left open. Since the user may have left Brackets to
// revert some of the disk changes, etc. we want to cancel the current sync and immediately
// begin a new one. We let the orig sync run until the user-visible dialog phase, then
// bail; if we're already there we programmatically close the dialog to bail right away.
if (_alreadyChecking) {
_restartPending = true;
// Close dialog if it was open. This will 'unblock' presentConflict(), which bails back
// to us immediately upon seeing _restartPending. We then restart the sync - see below
Dialogs.cancelModalDialogIfOpen(DefaultDialogs.DIALOG_ID_EXT_CHANGED);
Dialogs.cancelModalDialogIfOpen(DefaultDialogs.DIALOG_ID_EXT_DELETED);
return;
}
_alreadyChecking = true;
// Syncing proceeds in four phases:
// 1) Check all open files for external modifications
// 2) Check any other working set entries (that are not open) for deletion, and remove
// from working set if deleted
// 3) Refresh all Documents that are clean (if file changed on disk)
// 4) Close all Documents that are clean (if file deleted on disk)
// 5) Prompt about any Documents that are dirty (if file changed/deleted on disk)
// Each phase fully completes (asynchronously) before the next one begins.
// 1) Check for external modifications
var allDocs = DocumentManager.getAllOpenDocuments();
findExternalChanges(allDocs)
.done(function () {
// 2) Check un-open working set entries for deletion (& "close" if needed)
syncUnopenWorkingSet()
.always(function () {
// If we were unable to check any un-open files for deletion, silently ignore
// (after logging to console). This doesn't have any bearing on syncing truly
// open Documents (which we've already successfully checked).
// 3) Reload clean docs as needed
reloadChangedDocs()
.always(function () {
// 4) Close clean docs as needed
// This phase completes synchronously
closeDeletedDocs();
// 5) Prompt for dirty editors (conflicts)
presentConflicts(title)
.always(function () {
if (_restartPending) {
// Restart the sync if needed
_restartPending = false;
_alreadyChecking = false;
syncOpenDocuments();
} else {
// We're really done!
_alreadyChecking = false;
// If we showed a dialog, restore focus to editor
if (editConflicts.length > 0 || deleteConflicts.length > 0) {
MainViewManager.focusActivePane();
}
// (Any errors that ocurred during presentConflicts() have already
// shown UI & been dismissed, so there's no fail() handler here)
}
});
});
// Note: if any auto-reloads failed, we silently ignore (after logging to console)
// and we still continue onto phase 4 and try to process those files anyway.
// (We'll retry the auto-reloads next time window is activated... and evenually
// we'll also be double checking before each Save).
});
}).fail(function () {
// Unable to fetch timestamps for some reason - silently ignore (after logging to console)
// (We'll retry next time window is activated... and evenually we'll also be double
// checking before each Save).
// We can't go on without knowing which files are dirty, so bail now
_alreadyChecking = false;
});
} | [
"function",
"syncOpenDocuments",
"(",
"title",
")",
"{",
"title",
"=",
"title",
"||",
"Strings",
".",
"EXT_MODIFIED_TITLE",
";",
"// We can become \"re-entrant\" if the user leaves & then returns to Brackets before we're",
"// done -- easy if a prompt dialog is left open. Since the use... | Check to see whether any open files have been modified by an external app since the last time
Brackets synced up with the copy on disk (either by loading or saving the file). For clean
files, we silently upate the editor automatically. For files with unsaved changes, we prompt
the user.
@param {string} title Title to use for document. Default is "External Changes". | [
"Check",
"to",
"see",
"whether",
"any",
"open",
"files",
"have",
"been",
"modified",
"by",
"an",
"external",
"app",
"since",
"the",
"last",
"time",
"Brackets",
"synced",
"up",
"with",
"the",
"copy",
"on",
"disk",
"(",
"either",
"by",
"loading",
"or",
"sa... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/project/FileSyncManager.js#L404-L492 | train | Syncs all open files for modifications | [
30522,
3853,
26351,
26915,
3527,
24894,
11187,
1006,
2516,
1007,
1063,
2516,
1027,
2516,
1064,
1064,
7817,
1012,
4654,
2102,
1035,
6310,
1035,
2516,
1025,
1013,
1013,
2057,
2064,
2468,
1000,
2128,
1011,
4372,
6494,
3372,
1000,
2065,
1996,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... |
ecomfe/zrender | src/tool/path.js | createPathProxyFromString | function createPathProxyFromString(data) {
if (!data) {
return new PathProxy();
}
// var data = data.replace(/-/g, ' -')
// .replace(/ /g, ' ')
// .replace(/ /g, ',')
// .replace(/,,/g, ',');
// var n;
// create pipes so that we can split the data
// for (n = 0; n < cc.length; n++) {
// cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
// }
// data = data.replace(/-/g, ',-');
// create array
// var arr = cs.split('|');
// init context point
var cpx = 0;
var cpy = 0;
var subpathX = cpx;
var subpathY = cpy;
var prevCmd;
var path = new PathProxy();
var CMD = PathProxy.CMD;
// commandReg.lastIndex = 0;
// var cmdResult;
// while ((cmdResult = commandReg.exec(data)) != null) {
// var cmdStr = cmdResult[1];
// var cmdContent = cmdResult[2];
var cmdList = data.match(commandReg);
for (var l = 0; l < cmdList.length; l++) {
var cmdText = cmdList[l];
var cmdStr = cmdText.charAt(0);
var cmd;
// String#split is faster a little bit than String#replace or RegExp#exec.
// var p = cmdContent.split(valueSplitReg);
// var pLen = 0;
// for (var i = 0; i < p.length; i++) {
// // '' and other invalid str => NaN
// var val = parseFloat(p[i]);
// !isNaN(val) && (p[pLen++] = val);
// }
var p = cmdText.match(numberReg) || [];
var pLen = p.length;
for (var i = 0; i < pLen; i++) {
p[i] = parseFloat(p[i]);
}
var off = 0;
while (off < pLen) {
var ctlPtx;
var ctlPty;
var rx;
var ry;
var psi;
var fa;
var fs;
var x1 = cpx;
var y1 = cpy;
// convert l, H, h, V, and v to L
switch (cmdStr) {
case 'l':
cpx += p[off++];
cpy += p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'L':
cpx = p[off++];
cpy = p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'm':
cpx += p[off++];
cpy += p[off++];
cmd = CMD.M;
path.addData(cmd, cpx, cpy);
subpathX = cpx;
subpathY = cpy;
cmdStr = 'l';
break;
case 'M':
cpx = p[off++];
cpy = p[off++];
cmd = CMD.M;
path.addData(cmd, cpx, cpy);
subpathX = cpx;
subpathY = cpy;
cmdStr = 'L';
break;
case 'h':
cpx += p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'H':
cpx = p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'v':
cpy += p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'V':
cpy = p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'C':
cmd = CMD.C;
path.addData(
cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]
);
cpx = p[off - 2];
cpy = p[off - 1];
break;
case 'c':
cmd = CMD.C;
path.addData(
cmd,
p[off++] + cpx, p[off++] + cpy,
p[off++] + cpx, p[off++] + cpy,
p[off++] + cpx, p[off++] + cpy
);
cpx += p[off - 2];
cpy += p[off - 1];
break;
case 'S':
ctlPtx = cpx;
ctlPty = cpy;
var len = path.len();
var pathData = path.data;
if (prevCmd === CMD.C) {
ctlPtx += cpx - pathData[len - 4];
ctlPty += cpy - pathData[len - 3];
}
cmd = CMD.C;
x1 = p[off++];
y1 = p[off++];
cpx = p[off++];
cpy = p[off++];
path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
break;
case 's':
ctlPtx = cpx;
ctlPty = cpy;
var len = path.len();
var pathData = path.data;
if (prevCmd === CMD.C) {
ctlPtx += cpx - pathData[len - 4];
ctlPty += cpy - pathData[len - 3];
}
cmd = CMD.C;
x1 = cpx + p[off++];
y1 = cpy + p[off++];
cpx += p[off++];
cpy += p[off++];
path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
break;
case 'Q':
x1 = p[off++];
y1 = p[off++];
cpx = p[off++];
cpy = p[off++];
cmd = CMD.Q;
path.addData(cmd, x1, y1, cpx, cpy);
break;
case 'q':
x1 = p[off++] + cpx;
y1 = p[off++] + cpy;
cpx += p[off++];
cpy += p[off++];
cmd = CMD.Q;
path.addData(cmd, x1, y1, cpx, cpy);
break;
case 'T':
ctlPtx = cpx;
ctlPty = cpy;
var len = path.len();
var pathData = path.data;
if (prevCmd === CMD.Q) {
ctlPtx += cpx - pathData[len - 4];
ctlPty += cpy - pathData[len - 3];
}
cpx = p[off++];
cpy = p[off++];
cmd = CMD.Q;
path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
break;
case 't':
ctlPtx = cpx;
ctlPty = cpy;
var len = path.len();
var pathData = path.data;
if (prevCmd === CMD.Q) {
ctlPtx += cpx - pathData[len - 4];
ctlPty += cpy - pathData[len - 3];
}
cpx += p[off++];
cpy += p[off++];
cmd = CMD.Q;
path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
break;
case 'A':
rx = p[off++];
ry = p[off++];
psi = p[off++];
fa = p[off++];
fs = p[off++];
x1 = cpx, y1 = cpy;
cpx = p[off++];
cpy = p[off++];
cmd = CMD.A;
processArc(
x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
);
break;
case 'a':
rx = p[off++];
ry = p[off++];
psi = p[off++];
fa = p[off++];
fs = p[off++];
x1 = cpx, y1 = cpy;
cpx += p[off++];
cpy += p[off++];
cmd = CMD.A;
processArc(
x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
);
break;
}
}
if (cmdStr === 'z' || cmdStr === 'Z') {
cmd = CMD.Z;
path.addData(cmd);
// z may be in the middle of the path.
cpx = subpathX;
cpy = subpathY;
}
prevCmd = cmd;
}
path.toStatic();
return path;
} | javascript | function createPathProxyFromString(data) {
if (!data) {
return new PathProxy();
}
// var data = data.replace(/-/g, ' -')
// .replace(/ /g, ' ')
// .replace(/ /g, ',')
// .replace(/,,/g, ',');
// var n;
// create pipes so that we can split the data
// for (n = 0; n < cc.length; n++) {
// cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
// }
// data = data.replace(/-/g, ',-');
// create array
// var arr = cs.split('|');
// init context point
var cpx = 0;
var cpy = 0;
var subpathX = cpx;
var subpathY = cpy;
var prevCmd;
var path = new PathProxy();
var CMD = PathProxy.CMD;
// commandReg.lastIndex = 0;
// var cmdResult;
// while ((cmdResult = commandReg.exec(data)) != null) {
// var cmdStr = cmdResult[1];
// var cmdContent = cmdResult[2];
var cmdList = data.match(commandReg);
for (var l = 0; l < cmdList.length; l++) {
var cmdText = cmdList[l];
var cmdStr = cmdText.charAt(0);
var cmd;
// String#split is faster a little bit than String#replace or RegExp#exec.
// var p = cmdContent.split(valueSplitReg);
// var pLen = 0;
// for (var i = 0; i < p.length; i++) {
// // '' and other invalid str => NaN
// var val = parseFloat(p[i]);
// !isNaN(val) && (p[pLen++] = val);
// }
var p = cmdText.match(numberReg) || [];
var pLen = p.length;
for (var i = 0; i < pLen; i++) {
p[i] = parseFloat(p[i]);
}
var off = 0;
while (off < pLen) {
var ctlPtx;
var ctlPty;
var rx;
var ry;
var psi;
var fa;
var fs;
var x1 = cpx;
var y1 = cpy;
// convert l, H, h, V, and v to L
switch (cmdStr) {
case 'l':
cpx += p[off++];
cpy += p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'L':
cpx = p[off++];
cpy = p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'm':
cpx += p[off++];
cpy += p[off++];
cmd = CMD.M;
path.addData(cmd, cpx, cpy);
subpathX = cpx;
subpathY = cpy;
cmdStr = 'l';
break;
case 'M':
cpx = p[off++];
cpy = p[off++];
cmd = CMD.M;
path.addData(cmd, cpx, cpy);
subpathX = cpx;
subpathY = cpy;
cmdStr = 'L';
break;
case 'h':
cpx += p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'H':
cpx = p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'v':
cpy += p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'V':
cpy = p[off++];
cmd = CMD.L;
path.addData(cmd, cpx, cpy);
break;
case 'C':
cmd = CMD.C;
path.addData(
cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]
);
cpx = p[off - 2];
cpy = p[off - 1];
break;
case 'c':
cmd = CMD.C;
path.addData(
cmd,
p[off++] + cpx, p[off++] + cpy,
p[off++] + cpx, p[off++] + cpy,
p[off++] + cpx, p[off++] + cpy
);
cpx += p[off - 2];
cpy += p[off - 1];
break;
case 'S':
ctlPtx = cpx;
ctlPty = cpy;
var len = path.len();
var pathData = path.data;
if (prevCmd === CMD.C) {
ctlPtx += cpx - pathData[len - 4];
ctlPty += cpy - pathData[len - 3];
}
cmd = CMD.C;
x1 = p[off++];
y1 = p[off++];
cpx = p[off++];
cpy = p[off++];
path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
break;
case 's':
ctlPtx = cpx;
ctlPty = cpy;
var len = path.len();
var pathData = path.data;
if (prevCmd === CMD.C) {
ctlPtx += cpx - pathData[len - 4];
ctlPty += cpy - pathData[len - 3];
}
cmd = CMD.C;
x1 = cpx + p[off++];
y1 = cpy + p[off++];
cpx += p[off++];
cpy += p[off++];
path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
break;
case 'Q':
x1 = p[off++];
y1 = p[off++];
cpx = p[off++];
cpy = p[off++];
cmd = CMD.Q;
path.addData(cmd, x1, y1, cpx, cpy);
break;
case 'q':
x1 = p[off++] + cpx;
y1 = p[off++] + cpy;
cpx += p[off++];
cpy += p[off++];
cmd = CMD.Q;
path.addData(cmd, x1, y1, cpx, cpy);
break;
case 'T':
ctlPtx = cpx;
ctlPty = cpy;
var len = path.len();
var pathData = path.data;
if (prevCmd === CMD.Q) {
ctlPtx += cpx - pathData[len - 4];
ctlPty += cpy - pathData[len - 3];
}
cpx = p[off++];
cpy = p[off++];
cmd = CMD.Q;
path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
break;
case 't':
ctlPtx = cpx;
ctlPty = cpy;
var len = path.len();
var pathData = path.data;
if (prevCmd === CMD.Q) {
ctlPtx += cpx - pathData[len - 4];
ctlPty += cpy - pathData[len - 3];
}
cpx += p[off++];
cpy += p[off++];
cmd = CMD.Q;
path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
break;
case 'A':
rx = p[off++];
ry = p[off++];
psi = p[off++];
fa = p[off++];
fs = p[off++];
x1 = cpx, y1 = cpy;
cpx = p[off++];
cpy = p[off++];
cmd = CMD.A;
processArc(
x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
);
break;
case 'a':
rx = p[off++];
ry = p[off++];
psi = p[off++];
fa = p[off++];
fs = p[off++];
x1 = cpx, y1 = cpy;
cpx += p[off++];
cpy += p[off++];
cmd = CMD.A;
processArc(
x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
);
break;
}
}
if (cmdStr === 'z' || cmdStr === 'Z') {
cmd = CMD.Z;
path.addData(cmd);
// z may be in the middle of the path.
cpx = subpathX;
cpy = subpathY;
}
prevCmd = cmd;
}
path.toStatic();
return path;
} | [
"function",
"createPathProxyFromString",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"return",
"new",
"PathProxy",
"(",
")",
";",
"}",
"// var data = data.replace(/-/g, ' -')",
"// .replace(/ /g, ' ')",
"// .replace(/ /g, ',')",
"// .replace(/,,/... | var valueSplitReg = /[\s,]+/; | [
"var",
"valueSplitReg",
"=",
"/",
"[",
"\\",
"s",
"]",
"+",
"/",
";"
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/tool/path.js#L90-L356 | train | Create PathProxy from string | [
30522,
3853,
3443,
15069,
21572,
18037,
19699,
30524,
1043,
1010,
1005,
1005,
1007,
1013,
1013,
1012,
5672,
1006,
1013,
1013,
1043,
1010,
1005,
1010,
1005,
1007,
1013,
1013,
1012,
5672,
1006,
1013,
1010,
1010,
1013,
1043,
1010,
1005,
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... |
jaredpalmer/razzle | packages/razzle/scripts/build.js | compile | function compile(config, cb) {
let compiler;
try {
compiler = webpack(config);
} catch (e) {
printErrors('Failed to compile.', [e]);
process.exit(1);
}
compiler.run((err, stats) => {
cb(err, stats);
});
} | javascript | function compile(config, cb) {
let compiler;
try {
compiler = webpack(config);
} catch (e) {
printErrors('Failed to compile.', [e]);
process.exit(1);
}
compiler.run((err, stats) => {
cb(err, stats);
});
} | [
"function",
"compile",
"(",
"config",
",",
"cb",
")",
"{",
"let",
"compiler",
";",
"try",
"{",
"compiler",
"=",
"webpack",
"(",
"config",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"printErrors",
"(",
"'Failed to compile.'",
",",
"[",
"e",
"]",
")",... | Wrap webpack compile in a try catch. | [
"Wrap",
"webpack",
"compile",
"in",
"a",
"try",
"catch",
"."
] | 6f12cb8a84a1ef1b8491c36958a8797f97407312 | https://github.com/jaredpalmer/razzle/blob/6f12cb8a84a1ef1b8491c36958a8797f97407312/packages/razzle/scripts/build.js#L177-L188 | train | Compile the webpack module. | [
30522,
3853,
4012,
22090,
1006,
9530,
8873,
2290,
1010,
17324,
1007,
1063,
2292,
21624,
1025,
3046,
1063,
21624,
1027,
4773,
23947,
1006,
9530,
8873,
2290,
1007,
1025,
1065,
4608,
1006,
1041,
1007,
1063,
15041,
29165,
2015,
1006,
1005,
3478... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-extra-parens.js | isNewExpressionWithParens | function isNewExpressionWithParens(newExpression) {
const lastToken = sourceCode.getLastToken(newExpression);
const penultimateToken = sourceCode.getTokenBefore(lastToken);
return newExpression.arguments.length > 0 || astUtils.isOpeningParenToken(penultimateToken) && astUtils.isClosingParenToken(lastToken);
} | javascript | function isNewExpressionWithParens(newExpression) {
const lastToken = sourceCode.getLastToken(newExpression);
const penultimateToken = sourceCode.getTokenBefore(lastToken);
return newExpression.arguments.length > 0 || astUtils.isOpeningParenToken(penultimateToken) && astUtils.isClosingParenToken(lastToken);
} | [
"function",
"isNewExpressionWithParens",
"(",
"newExpression",
")",
"{",
"const",
"lastToken",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"newExpression",
")",
";",
"const",
"penultimateToken",
"=",
"sourceCode",
".",
"getTokenBefore",
"(",
"lastToken",
")",
";",
... | Determines if a constructor function is newed-up with parens
@param {ASTNode} newExpression - The NewExpression node to be checked.
@returns {boolean} True if the constructor is called with parens.
@private | [
"Determines",
"if",
"a",
"constructor",
"function",
"is",
"newed",
"-",
"up",
"with",
"parens"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-parens.js#L190-L195 | train | Check if newExpression has parentheses | [
30522,
3853,
3475,
7974,
10288,
20110,
3258,
24415,
19362,
6132,
1006,
2047,
10288,
20110,
3258,
1007,
1063,
9530,
3367,
2197,
18715,
2368,
1027,
3120,
16044,
1012,
2131,
8523,
9284,
7520,
1006,
2047,
10288,
20110,
3258,
1007,
1025,
9530,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/base/Log.js | log | function log(iLevel, sMessage, sDetails, sComponent, fnSupportInfo) {
if (!fnSupportInfo && !sComponent && typeof sDetails === "function") {
fnSupportInfo = sDetails;
sDetails = "";
}
if (!fnSupportInfo && typeof sComponent === "function") {
fnSupportInfo = sComponent;
sComponent = "";
}
sComponent = sComponent || sDefaultComponent;
if (iLevel <= level(sComponent) ) {
var fNow = now(),
oNow = new Date(fNow),
iMicroSeconds = Math.floor((fNow - Math.floor(fNow)) * 1000),
oLogEntry = {
time : pad0(oNow.getHours(),2) + ":" + pad0(oNow.getMinutes(),2) + ":" + pad0(oNow.getSeconds(),2) + "." + pad0(oNow.getMilliseconds(),3) + pad0(iMicroSeconds,3),
date : pad0(oNow.getFullYear(),4) + "-" + pad0(oNow.getMonth() + 1,2) + "-" + pad0(oNow.getDate(),2),
timestamp: fNow,
level : iLevel,
message : String(sMessage || ""),
details : String(sDetails || ""),
component: String(sComponent || "")
};
if (bLogSupportInfo && typeof fnSupportInfo === "function") {
oLogEntry.supportInfo = fnSupportInfo();
}
aLog.push( oLogEntry );
if (oListener) {
oListener.onLogEntry(oLogEntry);
}
/*
* Console Log, also tries to log to the console, if available.
*
* Unfortunately, the support for console is quite different between the UI5 browsers. The most important differences are:
* - in IE (checked until IE9), the console object does not exist in a window, until the developer tools are opened for that window.
* After opening the dev tools, the console remains available even when the tools are closed again. Only using a new window (or tab)
* restores the old state without console.
* When the console is available, it provides most standard methods, but not debug and trace
* - in FF3.6 the console is not available, until FireBug is opened. It disappears again, when fire bug is closed.
* But when the settings for a web site are stored (convenience), the console remains open
* When the console is available, it supports all relevant methods
* - in FF9.0, the console is always available, but method assert is only available when firebug is open
* - in Webkit browsers, the console object is always available and has all required methods
* - Exception: in the iOS Simulator, console.info() does not exist
*/
/*eslint-disable no-console */
if (console) { // in IE and FF, console might not exist; in FF it might even disappear
var isDetailsError = sDetails instanceof Error,
logText = oLogEntry.date + " " + oLogEntry.time + " " + oLogEntry.message + " - " + oLogEntry.details + " " + oLogEntry.component;
switch (iLevel) {
case Log.Level.FATAL:
case Log.Level.ERROR: isDetailsError ? console.error(logText, "\n", sDetails) : console.error(logText); break;
case Log.Level.WARNING: isDetailsError ? console.warn(logText, "\n", sDetails) : console.warn(logText); break;
case Log.Level.INFO:
if (console.info) { // info not available in iOS simulator
isDetailsError ? console.info(logText, "\n", sDetails) : console.info(logText);
} else {
isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText);
}
break;
case Log.Level.DEBUG:
if (console.debug) { // debug not available in IE, fallback to log
isDetailsError ? console.debug(logText, "\n", sDetails) : console.debug(logText);
} else {
isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText);
}
break;
case Log.Level.TRACE:
if (console.trace) { // trace not available in IE, fallback to log (no trace)
isDetailsError ? console.trace(logText, "\n", sDetails) : console.trace(logText);
} else {
isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText);
}
break;
}
if (console.info && oLogEntry.supportInfo) {
console.info(oLogEntry.supportInfo);
}
}
/*eslint-enable no-console */
return oLogEntry;
}
} | javascript | function log(iLevel, sMessage, sDetails, sComponent, fnSupportInfo) {
if (!fnSupportInfo && !sComponent && typeof sDetails === "function") {
fnSupportInfo = sDetails;
sDetails = "";
}
if (!fnSupportInfo && typeof sComponent === "function") {
fnSupportInfo = sComponent;
sComponent = "";
}
sComponent = sComponent || sDefaultComponent;
if (iLevel <= level(sComponent) ) {
var fNow = now(),
oNow = new Date(fNow),
iMicroSeconds = Math.floor((fNow - Math.floor(fNow)) * 1000),
oLogEntry = {
time : pad0(oNow.getHours(),2) + ":" + pad0(oNow.getMinutes(),2) + ":" + pad0(oNow.getSeconds(),2) + "." + pad0(oNow.getMilliseconds(),3) + pad0(iMicroSeconds,3),
date : pad0(oNow.getFullYear(),4) + "-" + pad0(oNow.getMonth() + 1,2) + "-" + pad0(oNow.getDate(),2),
timestamp: fNow,
level : iLevel,
message : String(sMessage || ""),
details : String(sDetails || ""),
component: String(sComponent || "")
};
if (bLogSupportInfo && typeof fnSupportInfo === "function") {
oLogEntry.supportInfo = fnSupportInfo();
}
aLog.push( oLogEntry );
if (oListener) {
oListener.onLogEntry(oLogEntry);
}
/*
* Console Log, also tries to log to the console, if available.
*
* Unfortunately, the support for console is quite different between the UI5 browsers. The most important differences are:
* - in IE (checked until IE9), the console object does not exist in a window, until the developer tools are opened for that window.
* After opening the dev tools, the console remains available even when the tools are closed again. Only using a new window (or tab)
* restores the old state without console.
* When the console is available, it provides most standard methods, but not debug and trace
* - in FF3.6 the console is not available, until FireBug is opened. It disappears again, when fire bug is closed.
* But when the settings for a web site are stored (convenience), the console remains open
* When the console is available, it supports all relevant methods
* - in FF9.0, the console is always available, but method assert is only available when firebug is open
* - in Webkit browsers, the console object is always available and has all required methods
* - Exception: in the iOS Simulator, console.info() does not exist
*/
/*eslint-disable no-console */
if (console) { // in IE and FF, console might not exist; in FF it might even disappear
var isDetailsError = sDetails instanceof Error,
logText = oLogEntry.date + " " + oLogEntry.time + " " + oLogEntry.message + " - " + oLogEntry.details + " " + oLogEntry.component;
switch (iLevel) {
case Log.Level.FATAL:
case Log.Level.ERROR: isDetailsError ? console.error(logText, "\n", sDetails) : console.error(logText); break;
case Log.Level.WARNING: isDetailsError ? console.warn(logText, "\n", sDetails) : console.warn(logText); break;
case Log.Level.INFO:
if (console.info) { // info not available in iOS simulator
isDetailsError ? console.info(logText, "\n", sDetails) : console.info(logText);
} else {
isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText);
}
break;
case Log.Level.DEBUG:
if (console.debug) { // debug not available in IE, fallback to log
isDetailsError ? console.debug(logText, "\n", sDetails) : console.debug(logText);
} else {
isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText);
}
break;
case Log.Level.TRACE:
if (console.trace) { // trace not available in IE, fallback to log (no trace)
isDetailsError ? console.trace(logText, "\n", sDetails) : console.trace(logText);
} else {
isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText);
}
break;
}
if (console.info && oLogEntry.supportInfo) {
console.info(oLogEntry.supportInfo);
}
}
/*eslint-enable no-console */
return oLogEntry;
}
} | [
"function",
"log",
"(",
"iLevel",
",",
"sMessage",
",",
"sDetails",
",",
"sComponent",
",",
"fnSupportInfo",
")",
"{",
"if",
"(",
"!",
"fnSupportInfo",
"&&",
"!",
"sComponent",
"&&",
"typeof",
"sDetails",
"===",
"\"function\"",
")",
"{",
"fnSupportInfo",
"="... | Creates a new log entry depending on its level and component.
If the given level is higher than the max level for the given component
(or higher than the global level, if no component is given),
then no entry is created and <code>undefined</code> is returned.
If an <code>Error</code> is passed via <code>sDetails</code> the stack
of the <code>Error</code> will be logged as a separate parameter in
the proper <code>console</code> function for the matching log level.
@param {module:sap/base/Log.Level} iLevel One of the log levels FATAL, ERROR, WARNING, INFO, DEBUG, TRACE
@param {string} sMessage The message to be logged
@param {string|Error} [sDetails] The optional details for the message; could be an Error which will be logged with the stack to easily find the root cause of the Error
@param {string} [sComponent] The log component under which the message should be logged
@param {function} [fnSupportInfo] Callback that returns an additional support object to be logged in support mode.
This function is only called if support info mode is turned on with <code>logSupportInfo(true)</code>.
To avoid negative effects regarding execution times and memory consumption, the returned object should be a simple
immutable JSON object with mostly static and stable content.
@returns {object} The log entry as an object or <code>undefined</code> if no entry was created
@private | [
"Creates",
"a",
"new",
"log",
"entry",
"depending",
"on",
"its",
"level",
"and",
"component",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/base/Log.js#L359-L443 | train | Logs to the console. | [
30522,
3853,
8833,
1006,
17869,
15985,
1010,
15488,
7971,
4270,
1010,
17371,
12928,
12146,
1010,
8040,
25377,
5643,
3372,
1010,
1042,
3619,
6279,
6442,
2378,
14876,
1007,
1063,
2065,
1006,
999,
1042,
3619,
6279,
6442,
2378,
14876,
1004,
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... |
adobe/brackets | src/extensibility/ExtensionManager.js | removeUpdate | function removeUpdate(id) {
var installationResult = _idsToUpdate[id];
if (!installationResult) {
return;
}
if (installationResult.localPath && !installationResult.keepFile) {
FileSystem.getFileForPath(installationResult.localPath).unlink();
}
delete _idsToUpdate[id];
exports.trigger("statusChange", id);
} | javascript | function removeUpdate(id) {
var installationResult = _idsToUpdate[id];
if (!installationResult) {
return;
}
if (installationResult.localPath && !installationResult.keepFile) {
FileSystem.getFileForPath(installationResult.localPath).unlink();
}
delete _idsToUpdate[id];
exports.trigger("statusChange", id);
} | [
"function",
"removeUpdate",
"(",
"id",
")",
"{",
"var",
"installationResult",
"=",
"_idsToUpdate",
"[",
"id",
"]",
";",
"if",
"(",
"!",
"installationResult",
")",
"{",
"return",
";",
"}",
"if",
"(",
"installationResult",
".",
"localPath",
"&&",
"!",
"insta... | Removes the mark for an extension to be updated on restart. Also deletes the
downloaded package file.
@param {string} id The id of the extension for which the update is being removed | [
"Removes",
"the",
"mark",
"for",
"an",
"extension",
"to",
"be",
"updated",
"on",
"restart",
".",
"Also",
"deletes",
"the",
"downloaded",
"package",
"file",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensibility/ExtensionManager.js#L605-L615 | train | Remove an update from the cache | [
30522,
3853,
6366,
6279,
13701,
1006,
8909,
1007,
1063,
13075,
8272,
6072,
11314,
1027,
1035,
8909,
16033,
6279,
13701,
1031,
8909,
1033,
1025,
2065,
1006,
999,
8272,
6072,
11314,
1007,
1063,
2709,
1025,
1065,
2065,
1006,
8272,
6072,
11314,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/camera.js | function (cameraEl) {
var cameraData;
var sceneEl = this.el.sceneEl;
this.numUserCamerasChecked++;
// Already found one.
if (this.initialCameraFound) { return; }
// Check if camera is appropriate for being the initial camera.
cameraData = cameraEl.getAttribute('camera');
if (!cameraData.active || cameraData.spectator) {
// No user cameras eligible, create default camera.
if (this.numUserCamerasChecked === this.numUserCameras) {
this.createDefaultCamera();
}
return;
}
this.initialCameraFound = true;
sceneEl.camera = cameraEl.getObject3D('camera');
sceneEl.emit('cameraready', {cameraEl: cameraEl});
} | javascript | function (cameraEl) {
var cameraData;
var sceneEl = this.el.sceneEl;
this.numUserCamerasChecked++;
// Already found one.
if (this.initialCameraFound) { return; }
// Check if camera is appropriate for being the initial camera.
cameraData = cameraEl.getAttribute('camera');
if (!cameraData.active || cameraData.spectator) {
// No user cameras eligible, create default camera.
if (this.numUserCamerasChecked === this.numUserCameras) {
this.createDefaultCamera();
}
return;
}
this.initialCameraFound = true;
sceneEl.camera = cameraEl.getObject3D('camera');
sceneEl.emit('cameraready', {cameraEl: cameraEl});
} | [
"function",
"(",
"cameraEl",
")",
"{",
"var",
"cameraData",
";",
"var",
"sceneEl",
"=",
"this",
".",
"el",
".",
"sceneEl",
";",
"this",
".",
"numUserCamerasChecked",
"++",
";",
"// Already found one.",
"if",
"(",
"this",
".",
"initialCameraFound",
")",
"{",
... | Check if a user-defined camera entity is appropriate to be initial camera.
(active + non-spectator).
Keep track of the number of cameras we checked and whether we found one. | [
"Check",
"if",
"a",
"user",
"-",
"defined",
"camera",
"entity",
"is",
"appropriate",
"to",
"be",
"initial",
"camera",
".",
"(",
"active",
"+",
"non",
"-",
"spectator",
")",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/systems/camera.js#L78-L99 | train | Find the camera element that is appropriate for the user. | [
30522,
3853,
1006,
4950,
2884,
1007,
1063,
13075,
4950,
2850,
2696,
1025,
13075,
3496,
2884,
1027,
2023,
1012,
3449,
1012,
3496,
2884,
1025,
2023,
1012,
16371,
7606,
2121,
28727,
24140,
5403,
18141,
1009,
1009,
1025,
1013,
1013,
2525,
2179,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js | function () {
var oRouter = UIComponent.getRouterFor(this);
if (!this.sNamespace || this.sNamespace === "/") {
oRouter.navTo("Layers");
} else {
var sSplittedNamespace = this.sNamespace.split("/");
sSplittedNamespace.splice(-2, 1);
var sTargetNamespace = sSplittedNamespace.join("/");
oRouter.navTo("LayerContentMaster", {"layer": this.sLayer, "namespace": encodeURIComponent(sTargetNamespace)}, true);
}
} | javascript | function () {
var oRouter = UIComponent.getRouterFor(this);
if (!this.sNamespace || this.sNamespace === "/") {
oRouter.navTo("Layers");
} else {
var sSplittedNamespace = this.sNamespace.split("/");
sSplittedNamespace.splice(-2, 1);
var sTargetNamespace = sSplittedNamespace.join("/");
oRouter.navTo("LayerContentMaster", {"layer": this.sLayer, "namespace": encodeURIComponent(sTargetNamespace)}, true);
}
} | [
"function",
"(",
")",
"{",
"var",
"oRouter",
"=",
"UIComponent",
".",
"getRouterFor",
"(",
"this",
")",
";",
"if",
"(",
"!",
"this",
".",
"sNamespace",
"||",
"this",
".",
"sNamespace",
"===",
"\"/\"",
")",
"{",
"oRouter",
".",
"navTo",
"(",
"\"Layers\"... | Handles the back navigation in the master list;
Calculates the parent namespace, then navigates to the target.
@public | [
"Handles",
"the",
"back",
"navigation",
"in",
"the",
"master",
"list",
";",
"Calculates",
"the",
"parent",
"namespace",
"then",
"navigates",
"to",
"the",
"target",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.fl/src/sap/ui/fl/support/apps/contentbrowser/controller/LayerContentMaster.controller.js#L153-L163 | train | Navigates to the Layer s content master | [
30522,
3853,
1006,
1007,
1063,
13075,
20298,
19901,
1027,
21318,
9006,
29513,
3372,
1012,
2131,
22494,
3334,
29278,
1006,
2023,
1007,
1025,
2065,
1006,
999,
2023,
1012,
1055,
18442,
23058,
1064,
1064,
2023,
1012,
1055,
18442,
23058,
1027,
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/core/History.js | function(sValue) {
var aHistory = this._initHistory();
// ensure it is not contained twice -> remove
for (var i = 0; i < aHistory.length; i++) {
if (aHistory[i] === sValue) {
aHistory.splice(i,1);
break;
}
}
// and put it to the 'very top'
aHistory.unshift(sValue);
// but do not store more than specified
if (aHistory.length > this._iMaxHistory) {
aHistory.splice(this._iMaxHistory);
}
this._oStorage.put(this._sHistoryId, aHistory);
} | javascript | function(sValue) {
var aHistory = this._initHistory();
// ensure it is not contained twice -> remove
for (var i = 0; i < aHistory.length; i++) {
if (aHistory[i] === sValue) {
aHistory.splice(i,1);
break;
}
}
// and put it to the 'very top'
aHistory.unshift(sValue);
// but do not store more than specified
if (aHistory.length > this._iMaxHistory) {
aHistory.splice(this._iMaxHistory);
}
this._oStorage.put(this._sHistoryId, aHistory);
} | [
"function",
"(",
"sValue",
")",
"{",
"var",
"aHistory",
"=",
"this",
".",
"_initHistory",
"(",
")",
";",
"// ensure it is not contained twice -> remove",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"aHistory",
".",
"length",
";",
"i",
"++",
")",
"{"... | Adds the given value to the history.
@private | [
"Adds",
"the",
"given",
"value",
"to",
"the",
"history",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/History.js#L107-L124 | train | Adds the specified value to the history | [
30522,
3853,
1006,
17917,
2389,
5657,
1007,
1063,
13075,
6289,
20483,
2854,
1027,
2023,
1012,
1035,
1999,
8939,
20483,
2854,
1006,
1007,
1025,
1013,
1013,
5676,
2009,
2003,
2025,
4838,
3807,
1011,
1028,
6366,
2005,
1006,
13075,
1045,
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... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function(oUI5MultiFilter) {
var aUI5MultiFilter = [];
var sOptionString = "";
var sLogicalMultiOperator = oUI5MultiFilter.bAnd == true ? " and " : " or ";
for (var i = -1, oUI5Filter; (oUI5Filter = oUI5MultiFilter.aFilters[++i]) !== undefined;) {
if (oUI5Filter.aFilters != undefined) { // defer processing to the end
aUI5MultiFilter.push(oUI5Filter);
continue;
}
sOptionString += (sOptionString == "" ? "" : sLogicalMultiOperator) + "(" + this.renderUI5Filter(oUI5Filter) + ")";
}
// process multi filters if any
if (aUI5MultiFilter.length > 0) {
for (var j = -1, oMultiFilter; (oMultiFilter = aUI5MultiFilter[++j]) !== undefined;) {
sOptionString += (sOptionString == "" ? "" : sLogicalMultiOperator) + "(" + this.renderUI5MultiFilter(oMultiFilter) + ")";
}
}
return sOptionString;
} | javascript | function(oUI5MultiFilter) {
var aUI5MultiFilter = [];
var sOptionString = "";
var sLogicalMultiOperator = oUI5MultiFilter.bAnd == true ? " and " : " or ";
for (var i = -1, oUI5Filter; (oUI5Filter = oUI5MultiFilter.aFilters[++i]) !== undefined;) {
if (oUI5Filter.aFilters != undefined) { // defer processing to the end
aUI5MultiFilter.push(oUI5Filter);
continue;
}
sOptionString += (sOptionString == "" ? "" : sLogicalMultiOperator) + "(" + this.renderUI5Filter(oUI5Filter) + ")";
}
// process multi filters if any
if (aUI5MultiFilter.length > 0) {
for (var j = -1, oMultiFilter; (oMultiFilter = aUI5MultiFilter[++j]) !== undefined;) {
sOptionString += (sOptionString == "" ? "" : sLogicalMultiOperator) + "(" + this.renderUI5MultiFilter(oMultiFilter) + ")";
}
}
return sOptionString;
} | [
"function",
"(",
"oUI5MultiFilter",
")",
"{",
"var",
"aUI5MultiFilter",
"=",
"[",
"]",
";",
"var",
"sOptionString",
"=",
"\"\"",
";",
"var",
"sLogicalMultiOperator",
"=",
"oUI5MultiFilter",
".",
"bAnd",
"==",
"true",
"?",
"\" and \"",
":",
"\" or \"",
";",
"... | /*
@private | [
"/",
"*"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L3381-L3402 | train | Render the UI5 multi filter | [
30522,
3853,
1006,
15068,
2072,
2629,
12274,
7096,
10128,
4014,
3334,
1007,
1063,
13075,
8740,
2072,
2629,
12274,
7096,
10128,
4014,
3334,
1027,
1031,
1033,
1025,
13075,
2061,
16790,
3367,
4892,
1027,
1000,
1000,
1025,
13075,
22889,
20734,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataContextBinding.js | adjustTarget | function adjustTarget(oMessage) {
if (oMessage.target) {
var aSegments = oMessage.target.split("/");
if (aSegments.shift() === sBindingParameter) {
oMessage.target = aSegments.join("/");
return;
}
}
delete oMessage.target;
} | javascript | function adjustTarget(oMessage) {
if (oMessage.target) {
var aSegments = oMessage.target.split("/");
if (aSegments.shift() === sBindingParameter) {
oMessage.target = aSegments.join("/");
return;
}
}
delete oMessage.target;
} | [
"function",
"adjustTarget",
"(",
"oMessage",
")",
"{",
"if",
"(",
"oMessage",
".",
"target",
")",
"{",
"var",
"aSegments",
"=",
"oMessage",
".",
"target",
".",
"split",
"(",
"\"/\"",
")",
";",
"if",
"(",
"aSegments",
".",
"shift",
"(",
")",
"===",
"s... | Adjusts the target: Makes it relative to the binding parameter; deletes targets pointing to other parameters because this is not supported | [
"Adjusts",
"the",
"target",
":",
"Makes",
"it",
"relative",
"to",
"the",
"binding",
"parameter",
";",
"deletes",
"targets",
"pointing",
"to",
"other",
"parameters",
"because",
"this",
"is",
"not",
"supported"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataContextBinding.js#L289-L299 | train | Adjusts the target of the message if the binding parameter is not present | [
30522,
3853,
14171,
7559,
18150,
1006,
18168,
7971,
4270,
1007,
1063,
2065,
1006,
18168,
7971,
4270,
1012,
4539,
1007,
1063,
13075,
2004,
13910,
8163,
1027,
18168,
7971,
4270,
1012,
4539,
1012,
3975,
1006,
1000,
1013,
1000,
1007,
1025,
2065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_MetadataRequestor.js | function (sUrl, bAnnotations, bPrefetch) {
var oPromise;
function convertXMLMetadata(oJSON) {
var Converter = sODataVersion === "4.0" || bAnnotations
? _V4MetadataConverter
: _V2MetadataConverter,
oData = oJSON.$XML;
delete oJSON.$XML; // be nice to the garbage collector
return jQuery.extend(new Converter().convertXMLMetadata(oData, sUrl),
oJSON);
}
if (sUrl in mUrl2Promise) {
if (bPrefetch) {
throw new Error("Must not prefetch twice: " + sUrl);
}
oPromise = mUrl2Promise[sUrl].then(convertXMLMetadata);
delete mUrl2Promise[sUrl];
} else {
oPromise = new Promise(function (fnResolve, fnReject) {
jQuery.ajax(bAnnotations ? sUrl : sUrl + sQueryStr, {
method : "GET",
headers : mHeaders
}).then(function (oData, sTextStatus, jqXHR) {
var sDate = jqXHR.getResponseHeader("Date"),
sETag = jqXHR.getResponseHeader("ETag"),
oJSON = {$XML : oData},
sLastModified = jqXHR.getResponseHeader("Last-Modified");
if (sDate) {
oJSON.$Date = sDate;
}
if (sETag) {
oJSON.$ETag = sETag;
}
if (sLastModified) {
oJSON.$LastModified = sLastModified;
}
fnResolve(oJSON);
}, function (jqXHR, sTextStatus, sErrorMessage) {
var oError = _Helper.createError(jqXHR, "Could not load metadata");
Log.error("GET " + sUrl, oError.message,
"sap.ui.model.odata.v4.lib._MetadataRequestor");
fnReject(oError);
});
});
if (bPrefetch) {
mUrl2Promise[sUrl] = oPromise;
} else {
oPromise = oPromise.then(convertXMLMetadata);
}
}
return oPromise;
} | javascript | function (sUrl, bAnnotations, bPrefetch) {
var oPromise;
function convertXMLMetadata(oJSON) {
var Converter = sODataVersion === "4.0" || bAnnotations
? _V4MetadataConverter
: _V2MetadataConverter,
oData = oJSON.$XML;
delete oJSON.$XML; // be nice to the garbage collector
return jQuery.extend(new Converter().convertXMLMetadata(oData, sUrl),
oJSON);
}
if (sUrl in mUrl2Promise) {
if (bPrefetch) {
throw new Error("Must not prefetch twice: " + sUrl);
}
oPromise = mUrl2Promise[sUrl].then(convertXMLMetadata);
delete mUrl2Promise[sUrl];
} else {
oPromise = new Promise(function (fnResolve, fnReject) {
jQuery.ajax(bAnnotations ? sUrl : sUrl + sQueryStr, {
method : "GET",
headers : mHeaders
}).then(function (oData, sTextStatus, jqXHR) {
var sDate = jqXHR.getResponseHeader("Date"),
sETag = jqXHR.getResponseHeader("ETag"),
oJSON = {$XML : oData},
sLastModified = jqXHR.getResponseHeader("Last-Modified");
if (sDate) {
oJSON.$Date = sDate;
}
if (sETag) {
oJSON.$ETag = sETag;
}
if (sLastModified) {
oJSON.$LastModified = sLastModified;
}
fnResolve(oJSON);
}, function (jqXHR, sTextStatus, sErrorMessage) {
var oError = _Helper.createError(jqXHR, "Could not load metadata");
Log.error("GET " + sUrl, oError.message,
"sap.ui.model.odata.v4.lib._MetadataRequestor");
fnReject(oError);
});
});
if (bPrefetch) {
mUrl2Promise[sUrl] = oPromise;
} else {
oPromise = oPromise.then(convertXMLMetadata);
}
}
return oPromise;
} | [
"function",
"(",
"sUrl",
",",
"bAnnotations",
",",
"bPrefetch",
")",
"{",
"var",
"oPromise",
";",
"function",
"convertXMLMetadata",
"(",
"oJSON",
")",
"{",
"var",
"Converter",
"=",
"sODataVersion",
"===",
"\"4.0\"",
"||",
"bAnnotations",
"?",
"_V4MetadataConvert... | Reads a metadata document from the given URL.
@param {string} sUrl
The URL of a metadata document, it must not contain a query string or a
fragment part
@param {boolean} [bAnnotations=false]
<code>true</code> if an additional annotation file is read, otherwise it is
expected to be a metadata document in the correct OData version
@param {boolean} [bPrefetch=false]
Whether to just read the metadata document, but not yet convert it from XML to
JSON. For any given URL, this is useful in an optional early call that precedes
a normal call without this flag.
@returns {Promise}
A promise fulfilled with the metadata as a JSON object, enriched with a
<code>$Date</code>, <code>$ETag</code> or <code>$LastModified</code> property
that contains the value of the response header "Date", "ETag" or
"Last-Modified" respectively; these additional properties are missing if there
is no such header. In case of <code>bPrefetch</code>, the JSON object is
empty except for <code>$XML</code> (which contains the unconverted metadata as
XML) and the additional properties described before.
@throws {Error}
If <code>bPrefetch</code> is set in two consecutive calls for the same URL | [
"Reads",
"a",
"metadata",
"document",
"from",
"the",
"given",
"URL",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_MetadataRequestor.js#L56-L112 | train | Get metadata from the server | [
30522,
3853,
1006,
7505,
2140,
1010,
7221,
17048,
10708,
1010,
17531,
2890,
7959,
10649,
1007,
1063,
13075,
6728,
21716,
5562,
1025,
3853,
10463,
2595,
19968,
11368,
8447,
2696,
1006,
1051,
22578,
2239,
1007,
1063,
13075,
10463,
2121,
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... | |
SAP/openui5 | lib/jsdoc/create-api-index.js | cleanTree | function cleanTree (oSymbol) {
delete oSymbol.treeName;
delete oSymbol.parent;
if (oSymbol.children) {
oSymbol.children.forEach(o => cleanTree(o));
}
} | javascript | function cleanTree (oSymbol) {
delete oSymbol.treeName;
delete oSymbol.parent;
if (oSymbol.children) {
oSymbol.children.forEach(o => cleanTree(o));
}
} | [
"function",
"cleanTree",
"(",
"oSymbol",
")",
"{",
"delete",
"oSymbol",
".",
"treeName",
";",
"delete",
"oSymbol",
".",
"parent",
";",
"if",
"(",
"oSymbol",
".",
"children",
")",
"{",
"oSymbol",
".",
"children",
".",
"forEach",
"(",
"o",
"=>",
"cleanTree... | Clean tree - keep file size down | [
"Clean",
"tree",
"-",
"keep",
"file",
"size",
"down"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/lib/jsdoc/create-api-index.js#L329-L335 | train | clean up the tree | [
30522,
3853,
4550,
13334,
1006,
9808,
24335,
14956,
1007,
1063,
3972,
12870,
9808,
24335,
14956,
1012,
3392,
18442,
1025,
3972,
12870,
9808,
24335,
14956,
1012,
6687,
1025,
2065,
1006,
9808,
24335,
14956,
1012,
2336,
1007,
1063,
9808,
24335,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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 | build/tasks/build.js | convert | function convert( name, _path, contents ) {
var rDefine = /(define\s*\(\s*('|").*?\2\s*,\s*\[)([\s\S]*?)\]/ig,
rDeps = /('|")(.*?)\1/g,
root = _path.substr( 0, _path.length - name.length - 3 ),
dir = path.dirname( _path ),
m, m2, deps, dep, _path2;
contents = contents.replace( rDefine, function( m, m1, m2, m3 ) {
return m1 + m3.replace( rDeps, function( m, m1, m2 ) {
m2 = path.join( dir, m2 );
m2 = path.relative( root, m2 );
m2 = m2.replace(/\\/g, '/');
return m1 + m2 + m1;
}) + ']';
});
return contents;
} | javascript | function convert( name, _path, contents ) {
var rDefine = /(define\s*\(\s*('|").*?\2\s*,\s*\[)([\s\S]*?)\]/ig,
rDeps = /('|")(.*?)\1/g,
root = _path.substr( 0, _path.length - name.length - 3 ),
dir = path.dirname( _path ),
m, m2, deps, dep, _path2;
contents = contents.replace( rDefine, function( m, m1, m2, m3 ) {
return m1 + m3.replace( rDeps, function( m, m1, m2 ) {
m2 = path.join( dir, m2 );
m2 = path.relative( root, m2 );
m2 = m2.replace(/\\/g, '/');
return m1 + m2 + m1;
}) + ']';
});
return contents;
} | [
"function",
"convert",
"(",
"name",
",",
"_path",
",",
"contents",
")",
"{",
"var",
"rDefine",
"=",
"/",
"(define\\s*\\(\\s*('|\").*?\\2\\s*,\\s*\\[)([\\s\\S]*?)\\]",
"/",
"ig",
",",
"rDeps",
"=",
"/",
"('|\")(.*?)\\1",
"/",
"g",
",",
"root",
"=",
"_path",
"."... | convert relative path to absolute path. | [
"convert",
"relative",
"path",
"to",
"absolute",
"path",
"."
] | 7094e4476c5af3b06993d91dde2d223200b9feb7 | https://github.com/fex-team/webuploader/blob/7094e4476c5af3b06993d91dde2d223200b9feb7/build/tasks/build.js#L12-L30 | train | Convert a file to a xsd | [
30522,
3853,
10463,
1006,
2171,
1010,
1035,
4130,
1010,
8417,
1007,
1063,
13075,
16428,
12879,
3170,
1027,
1013,
1006,
9375,
1032,
1055,
1008,
1032,
1006,
1032,
1055,
1008,
1006,
1005,
1064,
1000,
1007,
1012,
1008,
1029,
1032,
1016,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Batch.js | getBoundaryRegExp | function getBoundaryRegExp(sContentType) {
var sBatchBoundary = getHeaderParameterValue(sContentType, "boundary"),
iMultiPartTypeIndex = sContentType.trim().indexOf("multipart/mixed");
if (iMultiPartTypeIndex !== 0 || !sBatchBoundary) {
throw new Error('Invalid $batch response header "Content-Type": ' + sContentType);
}
// escape RegExp-related characters
sBatchBoundary = escapeRegExp(sBatchBoundary);
return new RegExp('--' + sBatchBoundary + '(?:[ \t]*\r\n|--)');
} | javascript | function getBoundaryRegExp(sContentType) {
var sBatchBoundary = getHeaderParameterValue(sContentType, "boundary"),
iMultiPartTypeIndex = sContentType.trim().indexOf("multipart/mixed");
if (iMultiPartTypeIndex !== 0 || !sBatchBoundary) {
throw new Error('Invalid $batch response header "Content-Type": ' + sContentType);
}
// escape RegExp-related characters
sBatchBoundary = escapeRegExp(sBatchBoundary);
return new RegExp('--' + sBatchBoundary + '(?:[ \t]*\r\n|--)');
} | [
"function",
"getBoundaryRegExp",
"(",
"sContentType",
")",
"{",
"var",
"sBatchBoundary",
"=",
"getHeaderParameterValue",
"(",
"sContentType",
",",
"\"boundary\"",
")",
",",
"iMultiPartTypeIndex",
"=",
"sContentType",
".",
"trim",
"(",
")",
".",
"indexOf",
"(",
"\"... | Create regular expression based on boundary parameter of the given "multipart/mixed"
Content-Type header value.
@param {string} sContentType
Value of the "multipart/mixed" Content-Type header value
@returns {object} Regular expression which will be used to parse the $batch request body
@throws {Error} If the specified Content-Type header value does not represent
"multipart/mixed" MIME type with "boundary" parameter. | [
"Create",
"regular",
"expression",
"based",
"on",
"boundary",
"parameter",
"of",
"the",
"given",
"multipart",
"/",
"mixed",
"Content",
"-",
"Type",
"header",
"value",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Batch.js#L27-L38 | train | Returns a regular expression that matches the boundary of a batch response. | [
30522,
3853,
2131,
15494,
5649,
2890,
3351,
2595,
2361,
1006,
8040,
28040,
3372,
13874,
1007,
1063,
13075,
24829,
4017,
2818,
15494,
5649,
1027,
2131,
4974,
2121,
28689,
22828,
10175,
5657,
1006,
8040,
28040,
3372,
13874,
1010,
1000,
6192,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/language/JSUtils.js | _shouldGetFromCache | function _shouldGetFromCache(fileInfo) {
var result = new $.Deferred(),
isChanged = _changedDocumentTracker.isPathChanged(fileInfo.fullPath);
if (isChanged && fileInfo.JSUtils) {
// See if it's dirty and in the working set first
var doc = DocumentManager.getOpenDocumentForPath(fileInfo.fullPath);
if (doc && doc.isDirty) {
result.resolve(false);
} else {
// If a cache exists, check the timestamp on disk
var file = FileSystem.getFileForPath(fileInfo.fullPath);
file.stat(function (err, stat) {
if (!err) {
result.resolve(fileInfo.JSUtils.timestamp.getTime() === stat.mtime.getTime());
} else {
result.reject(err);
}
});
}
} else {
// Use the cache if the file did not change and the cache exists
result.resolve(!isChanged && fileInfo.JSUtils);
}
return result.promise();
} | javascript | function _shouldGetFromCache(fileInfo) {
var result = new $.Deferred(),
isChanged = _changedDocumentTracker.isPathChanged(fileInfo.fullPath);
if (isChanged && fileInfo.JSUtils) {
// See if it's dirty and in the working set first
var doc = DocumentManager.getOpenDocumentForPath(fileInfo.fullPath);
if (doc && doc.isDirty) {
result.resolve(false);
} else {
// If a cache exists, check the timestamp on disk
var file = FileSystem.getFileForPath(fileInfo.fullPath);
file.stat(function (err, stat) {
if (!err) {
result.resolve(fileInfo.JSUtils.timestamp.getTime() === stat.mtime.getTime());
} else {
result.reject(err);
}
});
}
} else {
// Use the cache if the file did not change and the cache exists
result.resolve(!isChanged && fileInfo.JSUtils);
}
return result.promise();
} | [
"function",
"_shouldGetFromCache",
"(",
"fileInfo",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
",",
"isChanged",
"=",
"_changedDocumentTracker",
".",
"isPathChanged",
"(",
"fileInfo",
".",
"fullPath",
")",
";",
"if",
"(",
"isChang... | Determines if the document function cache is up to date.
@param {FileInfo} fileInfo
@return {$.Promise} A promise resolved with true with true when a function cache is available for the document. Resolves
with false when there is no cache or the cache is stale. | [
"Determines",
"if",
"the",
"document",
"function",
"cache",
"is",
"up",
"to",
"date",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/JSUtils.js#L302-L330 | train | Check if the file is in the cache | [
30522,
3853,
1035,
2323,
18150,
19699,
5358,
3540,
5403,
1006,
5371,
2378,
14876,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
2003,
22305,
2098,
1027,
1035,
2904,
3527,
24894,
4765,
6494,
9102,
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/core/util/DraftEnabledMockServer.js | function(oEntry) {
var oResponse;
var fnGrep = function(aContains, aContained) {
return aContains.filter(function(x) {
return aContained.indexOf(x) < 0;
})[0];
};
// navigate to draft nodes and activate nodes
for (var i = 0; i < this._oDraftMetadata.draftNodes.length; i++) {
for (var navprop in this._mEntitySets[this._oDraftMetadata.draftRootName].navprops) {
if (this._mEntitySets[this._oDraftMetadata.draftRootName].navprops[navprop].to.entitySet === this._oDraftMetadata.draftNodes[i]) {
oResponse = jQuery.sap.sjax({
url: oEntry[navprop].__deferred.uri,
dataType: "json"
});
if (oResponse.success && oResponse.data && oResponse.data.d && oResponse.data.d.results) {
var oNode;
for (var j = 0; j < oResponse.data.d.results.length; j++) {
oNode = oResponse.data.d.results[j];
oNode.IsActiveEntity = true;
oNode.HasActiveEntity = false;
oNode.HasDraftEntity = false;
oNode[this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
var aSemanticDraftNodeKeys = this._calcSemanticKeys(this._oDraftMetadata.draftNodes[i], this._mEntitySets);
var sDraftKey = fnGrep(this._mEntitySets[this._oDraftMetadata.draftNodes[i]].keys, aSemanticDraftNodeKeys);
oNode[sDraftKey] = this._oConstants.EMPTY_GUID;
jQuery.sap.sjax({
url: oNode.__metadata.uri,
type: "PATCH",
data: JSON.stringify(oNode)
});
}
}
}
}
}
oEntry.IsActiveEntity = true;
oEntry.HasActiveEntity = false;
oEntry.HasDraftEntity = false;
oEntry[this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
jQuery.sap.sjax({
url: oEntry.__metadata.uri,
type: "PATCH",
data: JSON.stringify(oEntry)
});
return oEntry;
} | javascript | function(oEntry) {
var oResponse;
var fnGrep = function(aContains, aContained) {
return aContains.filter(function(x) {
return aContained.indexOf(x) < 0;
})[0];
};
// navigate to draft nodes and activate nodes
for (var i = 0; i < this._oDraftMetadata.draftNodes.length; i++) {
for (var navprop in this._mEntitySets[this._oDraftMetadata.draftRootName].navprops) {
if (this._mEntitySets[this._oDraftMetadata.draftRootName].navprops[navprop].to.entitySet === this._oDraftMetadata.draftNodes[i]) {
oResponse = jQuery.sap.sjax({
url: oEntry[navprop].__deferred.uri,
dataType: "json"
});
if (oResponse.success && oResponse.data && oResponse.data.d && oResponse.data.d.results) {
var oNode;
for (var j = 0; j < oResponse.data.d.results.length; j++) {
oNode = oResponse.data.d.results[j];
oNode.IsActiveEntity = true;
oNode.HasActiveEntity = false;
oNode.HasDraftEntity = false;
oNode[this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
var aSemanticDraftNodeKeys = this._calcSemanticKeys(this._oDraftMetadata.draftNodes[i], this._mEntitySets);
var sDraftKey = fnGrep(this._mEntitySets[this._oDraftMetadata.draftNodes[i]].keys, aSemanticDraftNodeKeys);
oNode[sDraftKey] = this._oConstants.EMPTY_GUID;
jQuery.sap.sjax({
url: oNode.__metadata.uri,
type: "PATCH",
data: JSON.stringify(oNode)
});
}
}
}
}
}
oEntry.IsActiveEntity = true;
oEntry.HasActiveEntity = false;
oEntry.HasDraftEntity = false;
oEntry[this._oDraftMetadata.draftRootKey] = this._oConstants.EMPTY_GUID;
jQuery.sap.sjax({
url: oEntry.__metadata.uri,
type: "PATCH",
data: JSON.stringify(oEntry)
});
return oEntry;
} | [
"function",
"(",
"oEntry",
")",
"{",
"var",
"oResponse",
";",
"var",
"fnGrep",
"=",
"function",
"(",
"aContains",
",",
"aContained",
")",
"{",
"return",
"aContains",
".",
"filter",
"(",
"function",
"(",
"x",
")",
"{",
"return",
"aContained",
".",
"indexO... | Activates a draft document
@param {object} oEntry the draft document | [
"Activates",
"a",
"draft",
"document"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/DraftEnabledMockServer.js#L343-L389 | train | This function is called when the draft entity is added to the list of nodes | [
30522,
3853,
1006,
1051,
4765,
2854,
1007,
1063,
13075,
10848,
13102,
5644,
2063,
1025,
13075,
1042,
3070,
2890,
2361,
1027,
3853,
1006,
9353,
12162,
28247,
1010,
30524,
2709,
9353,
12162,
18175,
2094,
1012,
5950,
11253,
1006,
1060,
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... | |
GitbookIO/gitbook | lib/plugins/listDepsForBook.js | listDepsForBook | function listDepsForBook(book) {
var config = book.getConfig();
var plugins = config.getPluginDependencies();
return listDependencies(plugins);
} | javascript | function listDepsForBook(book) {
var config = book.getConfig();
var plugins = config.getPluginDependencies();
return listDependencies(plugins);
} | [
"function",
"listDepsForBook",
"(",
"book",
")",
"{",
"var",
"config",
"=",
"book",
".",
"getConfig",
"(",
")",
";",
"var",
"plugins",
"=",
"config",
".",
"getPluginDependencies",
"(",
")",
";",
"return",
"listDependencies",
"(",
"plugins",
")",
";",
"}"
] | List all plugin requirements for a book.
It can be different from the final list of plugins,
since plugins can have their own dependencies
@param {Book}
@return {List<PluginDependency>} | [
"List",
"all",
"plugin",
"requirements",
"for",
"a",
"book",
".",
"It",
"can",
"be",
"different",
"from",
"the",
"final",
"list",
"of",
"plugins",
"since",
"plugins",
"can",
"have",
"their",
"own",
"dependencies"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/listDepsForBook.js#L11-L16 | train | List all dependencies for a book | [
30522,
3853,
2862,
3207,
4523,
29278,
8654,
1006,
2338,
1007,
1063,
13075,
9530,
8873,
2290,
1027,
2338,
1012,
2131,
8663,
8873,
2290,
1006,
1007,
1025,
13075,
13354,
7076,
1027,
9530,
8873,
2290,
1012,
2131,
24759,
15916,
22254,
13699,
104... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/preferences/PreferencesBase.js | function (data, id, context) {
var glob = this.getPreferenceLocation(data, id, context);
if (!glob) {
return;
}
return data[glob][id];
} | javascript | function (data, id, context) {
var glob = this.getPreferenceLocation(data, id, context);
if (!glob) {
return;
}
return data[glob][id];
} | [
"function",
"(",
"data",
",",
"id",
",",
"context",
")",
"{",
"var",
"glob",
"=",
"this",
".",
"getPreferenceLocation",
"(",
"data",
",",
"id",
",",
"context",
")",
";",
"if",
"(",
"!",
"glob",
")",
"{",
"return",
";",
"}",
"return",
"data",
"[",
... | Retrieve the current value based on the filename in the context
object, comparing globs relative to the prefFilePath that this
PathLayer was set up with.
@param {Object} data the preference data from the Scope
@param {string} id preference ID to look up
@param {Object} context Object with filename that will be compared to the globs | [
"Retrieve",
"the",
"current",
"value",
"based",
"on",
"the",
"filename",
"in",
"the",
"context",
"object",
"comparing",
"globs",
"relative",
"to",
"the",
"prefFilePath",
"that",
"this",
"PathLayer",
"was",
"set",
"up",
"with",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L882-L890 | train | get the preference from the cache | [
30522,
3853,
1006,
2951,
1010,
8909,
1010,
6123,
1007,
1063,
13075,
1043,
4135,
2497,
1027,
2023,
1012,
2131,
28139,
25523,
4135,
10719,
1006,
2951,
1010,
8909,
1010,
6123,
1007,
1025,
2065,
1006,
999,
1043,
4135,
2497,
1007,
1063,
2709,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
postcss/autoprefixer | lib/hacks/grid-utils.js | warnTemplateSelectorNotFound | function warnTemplateSelectorNotFound (decl, result) {
let rule = decl.parent
let root = decl.root()
let duplicatesFound = false
// slice selector array. Remove the last part (for comparison)
let slicedSelectorArr = list
.space(rule.selector)
.filter(str => str !== '>')
.slice(0, -1)
// we need to compare only if selector is complex.
// e.g '.grid-cell' is simple, but '.parent > .grid-cell' is complex
if (slicedSelectorArr.length > 0) {
let gridTemplateFound = false
let foundAreaSelector = null
root.walkDecls(/grid-template(-areas)?$/, d => {
let parent = d.parent
let templateSelectors = parent.selectors
let { areas } = parseTemplate({ decl: d, gap: getGridGap(d) })
let hasArea = areas[decl.value]
// find the the matching selectors
for (let tplSelector of templateSelectors) {
if (gridTemplateFound) {
break
}
let tplSelectorArr = list
.space(tplSelector)
.filter(str => str !== '>')
gridTemplateFound = tplSelectorArr.every(
(item, idx) => item === slicedSelectorArr[idx]
)
}
if (gridTemplateFound || !hasArea) {
return true
}
if (!foundAreaSelector) {
foundAreaSelector = parent.selector
}
// if we found the duplicate area with different selector
if (foundAreaSelector && foundAreaSelector !== parent.selector) {
duplicatesFound = true
}
return undefined
})
// warn user if we didn't find template
if (!gridTemplateFound && duplicatesFound) {
decl.warn(
result,
`Autoprefixer cannot find a grid-template ` +
`containing the duplicate grid-area "${ decl.value }" ` +
`with full selector matching: ${ slicedSelectorArr.join(' ') }`
)
}
}
} | javascript | function warnTemplateSelectorNotFound (decl, result) {
let rule = decl.parent
let root = decl.root()
let duplicatesFound = false
// slice selector array. Remove the last part (for comparison)
let slicedSelectorArr = list
.space(rule.selector)
.filter(str => str !== '>')
.slice(0, -1)
// we need to compare only if selector is complex.
// e.g '.grid-cell' is simple, but '.parent > .grid-cell' is complex
if (slicedSelectorArr.length > 0) {
let gridTemplateFound = false
let foundAreaSelector = null
root.walkDecls(/grid-template(-areas)?$/, d => {
let parent = d.parent
let templateSelectors = parent.selectors
let { areas } = parseTemplate({ decl: d, gap: getGridGap(d) })
let hasArea = areas[decl.value]
// find the the matching selectors
for (let tplSelector of templateSelectors) {
if (gridTemplateFound) {
break
}
let tplSelectorArr = list
.space(tplSelector)
.filter(str => str !== '>')
gridTemplateFound = tplSelectorArr.every(
(item, idx) => item === slicedSelectorArr[idx]
)
}
if (gridTemplateFound || !hasArea) {
return true
}
if (!foundAreaSelector) {
foundAreaSelector = parent.selector
}
// if we found the duplicate area with different selector
if (foundAreaSelector && foundAreaSelector !== parent.selector) {
duplicatesFound = true
}
return undefined
})
// warn user if we didn't find template
if (!gridTemplateFound && duplicatesFound) {
decl.warn(
result,
`Autoprefixer cannot find a grid-template ` +
`containing the duplicate grid-area "${ decl.value }" ` +
`with full selector matching: ${ slicedSelectorArr.join(' ') }`
)
}
}
} | [
"function",
"warnTemplateSelectorNotFound",
"(",
"decl",
",",
"result",
")",
"{",
"let",
"rule",
"=",
"decl",
".",
"parent",
"let",
"root",
"=",
"decl",
".",
"root",
"(",
")",
"let",
"duplicatesFound",
"=",
"false",
"// slice selector array. Remove the last part (... | compare selectors with grid-area rule and grid-template rule
show warning if grid-template selector is not found
(this function used for grid-area rule)
@param {Declaration} decl
@param {Result} result
@return {void} | [
"compare",
"selectors",
"with",
"grid",
"-",
"area",
"rule",
"and",
"grid",
"-",
"template",
"rule",
"show",
"warning",
"if",
"grid",
"-",
"template",
"selector",
"is",
"not",
"found",
"(",
"this",
"function",
"used",
"for",
"grid",
"-",
"area",
"rule",
... | 24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32 | https://github.com/postcss/autoprefixer/blob/24b28b6dbdc34a5e5800986e76f48cbaf9bbbc32/lib/hacks/grid-utils.js#L675-L739 | train | Warn user if no grid - template selector is found | [
30522,
3853,
11582,
18532,
15725,
11246,
22471,
26295,
24475,
28819,
1006,
11703,
2140,
1010,
2765,
1007,
1063,
2292,
3627,
1027,
11703,
2140,
1012,
6687,
2292,
7117,
1027,
11703,
2140,
1012,
7117,
1006,
1007,
2292,
24473,
22747,
28819,
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... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/date/Buddhist.js | toBuddhist | function toBuddhist(oGregorian) {
var iEraStartYear = UniversalDate.getEraStartDate(CalendarType.Buddhist, 0).year,
iYear = oGregorian.year - iEraStartYear + 1;
// Before 1941 new year started on 1st of April
if (oGregorian.year < 1941 && oGregorian.month < 3) {
iYear -= 1;
}
if (oGregorian.year === null) {
iYear = undefined;
}
return {
year: iYear,
month: oGregorian.month,
day: oGregorian.day
};
} | javascript | function toBuddhist(oGregorian) {
var iEraStartYear = UniversalDate.getEraStartDate(CalendarType.Buddhist, 0).year,
iYear = oGregorian.year - iEraStartYear + 1;
// Before 1941 new year started on 1st of April
if (oGregorian.year < 1941 && oGregorian.month < 3) {
iYear -= 1;
}
if (oGregorian.year === null) {
iYear = undefined;
}
return {
year: iYear,
month: oGregorian.month,
day: oGregorian.day
};
} | [
"function",
"toBuddhist",
"(",
"oGregorian",
")",
"{",
"var",
"iEraStartYear",
"=",
"UniversalDate",
".",
"getEraStartDate",
"(",
"CalendarType",
".",
"Buddhist",
",",
"0",
")",
".",
"year",
",",
"iYear",
"=",
"oGregorian",
".",
"year",
"-",
"iEraStartYear",
... | Find the matching Buddhist date for the given gregorian date
@param {object} oGregorian
@return {object} | [
"Find",
"the",
"matching",
"Buddhist",
"date",
"for",
"the",
"given",
"gregorian",
"date"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/date/Buddhist.js#L48-L63 | train | Converts a gregorian date to Buddhist. | [
30522,
3853,
2000,
8569,
14141,
24158,
2102,
1006,
13958,
2890,
20255,
2937,
1007,
1063,
13075,
29464,
8180,
7559,
3723,
14644,
1027,
5415,
13701,
1012,
2131,
24140,
7559,
2102,
13701,
1006,
8094,
13874,
1012,
7992,
1010,
1014,
1007,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js | function (aColumnsIds, bVisibilityValue) {
var aColumns = this.treeTable.getColumns();
aColumns.forEach(function(oColumn) {
oColumn.setVisible(!bVisibilityValue);
aColumnsIds.forEach(function(sRuleId) {
if (oColumn.sId.includes(sRuleId)) {
oColumn.setVisible(bVisibilityValue);
}
});
});
} | javascript | function (aColumnsIds, bVisibilityValue) {
var aColumns = this.treeTable.getColumns();
aColumns.forEach(function(oColumn) {
oColumn.setVisible(!bVisibilityValue);
aColumnsIds.forEach(function(sRuleId) {
if (oColumn.sId.includes(sRuleId)) {
oColumn.setVisible(bVisibilityValue);
}
});
});
} | [
"function",
"(",
"aColumnsIds",
",",
"bVisibilityValue",
")",
"{",
"var",
"aColumns",
"=",
"this",
".",
"treeTable",
".",
"getColumns",
"(",
")",
";",
"aColumns",
".",
"forEach",
"(",
"function",
"(",
"oColumn",
")",
"{",
"oColumn",
".",
"setVisible",
"(",... | Sets visibility to columns.
@param {Array} aColumnsIds Ids of columns
@param {boolean} bVisibilityValue | [
"Sets",
"visibility",
"to",
"columns",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js#L996-L1007 | train | Sets visibility of the columns | [
30522,
3853,
1006,
9353,
4747,
2819,
3619,
9821,
1010,
1038,
11365,
13464,
10175,
5657,
1007,
1063,
13075,
9353,
4747,
2819,
3619,
1027,
30524,
1006,
3853,
1006,
1051,
25778,
2819,
2078,
1007,
1063,
1051,
25778,
2819,
2078,
1012,
2275,
1136... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/closure/goog/i18n/dateintervalformat.js | function(
dateTimePattern, fallbackPattern, dateTimeSymbols) {
/**
* Date time pattern used to format the dates.
* @private {string}
*/
this.dateTimePattern_ = dateTimePattern;
/**
* Date time formatter used to format the dates.
* @private {!DateTimeFormat}
*/
this.dateTimeFormatter_ =
new DateTimeFormat(dateTimePattern, dateTimeSymbols);
/**
* Fallback interval pattern.
* @private {string}
*/
this.fallbackPattern_ = fallbackPattern;
} | javascript | function(
dateTimePattern, fallbackPattern, dateTimeSymbols) {
/**
* Date time pattern used to format the dates.
* @private {string}
*/
this.dateTimePattern_ = dateTimePattern;
/**
* Date time formatter used to format the dates.
* @private {!DateTimeFormat}
*/
this.dateTimeFormatter_ =
new DateTimeFormat(dateTimePattern, dateTimeSymbols);
/**
* Fallback interval pattern.
* @private {string}
*/
this.fallbackPattern_ = fallbackPattern;
} | [
"function",
"(",
"dateTimePattern",
",",
"fallbackPattern",
",",
"dateTimeSymbols",
")",
"{",
"/**\n * Date time pattern used to format the dates.\n * @private {string}\n */",
"this",
".",
"dateTimePattern_",
"=",
"dateTimePattern",
";",
"/**\n * Date time formatter used to f... | Constructs a DateTimeFormatter_ object which implements the Formatter_
interface.
Internal object to construct and store a goog.i18n.DateTimeFormat for the
a datetime pattern and formats dates using the fallback interval pattern
(e.g. '{0} – {1}').
@param {string} dateTimePattern Datetime pattern used to format the dates.
@param {string} fallbackPattern Fallback interval pattern to be used with the
datetime pattern.
@param {!DateTimeSymbolsType} dateTimeSymbols Symbols to use with
the datetime format.
@constructor
@implements {Formatter_}
@private | [
"Constructs",
"a",
"DateTimeFormatter_",
"object",
"which",
"implements",
"the",
"Formatter_",
"interface",
"."
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/closure/goog/i18n/dateintervalformat.js#L608-L628 | train | A date time interval pattern. | [
30522,
3853,
1006,
3058,
7292,
4502,
12079,
2078,
1010,
2991,
5963,
4502,
12079,
2078,
1010,
3058,
7292,
6508,
13344,
4877,
1007,
1063,
1013,
1008,
1008,
1008,
3058,
2051,
5418,
2109,
2000,
4289,
1996,
5246,
1012,
1008,
1030,
2797,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.rta/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsAnalyzer.js | function(oElement, mActions){
var oModel = oElement.getModel();
var mRevealData = mActions.reveal;
var mAddODataProperty = mActions.addODataProperty;
var mCustom = mActions.custom;
var oDefaultAggregation = oElement.getMetadata().getAggregation();
var sAggregationName = oDefaultAggregation ? oDefaultAggregation.name : mActions.aggregation;
return Promise.resolve()
.then(function () {
return _getODataPropertiesOfModel(oElement, sAggregationName);
})
.then(function(mData) {
var aODataProperties = mData.property;
var aODataNavigationProperties = mData.navigationProperty.map(function (mNavigation) {
return mNavigation.name;
});
var aODataNavigationEntityNames = mData.navigationEntityNames;
aODataProperties = _checkForComplexDuplicates(aODataProperties);
var aAllElementData = [];
var aInvisibleElements = mRevealData.elements || [];
aInvisibleElements.forEach(function(mInvisibleElement) {
var oInvisibleElement = mInvisibleElement.element;
var mAction = mInvisibleElement.action;
var bIncludeElement = true;
var mBindingPathCollection = {};
oInvisibleElement.fieldLabel = ElementUtil.getLabelForElement(oInvisibleElement, mAction.getLabel);
// BCP: 1880498671
if (mAddODataProperty) {
if (_getBindingPath(oElement, sAggregationName) === _getBindingPath(oInvisibleElement, sAggregationName)) {
//TODO fix with stashed type support
mBindingPathCollection = BindingsExtractor.collectBindingPaths(oInvisibleElement, oModel);
oInvisibleElement.duplicateComplexName = _checkForDuplicateLabels(oInvisibleElement, aODataProperties);
//Add information from the oDataProperty to the InvisibleProperty if available;
//if oData is available and the element is not present in it, do not include it
//Example use case: custom field which was hidden and then removed from system
//should not be available for adding after the removal
if (aODataProperties.length > 0){
bIncludeElement = _checkAndEnhanceODataProperty(
oInvisibleElement,
aODataProperties,
aODataNavigationProperties,
aODataNavigationEntityNames,
mBindingPathCollection);
}
} else if (BindingsExtractor.getBindings(oInvisibleElement, oModel).length > 0) {
bIncludeElement = false;
}
}
if (mCustom && bIncludeElement) {
mCustom.items.forEach(function(oCustomItem) {
_assignCustomItemIds(oElement.getParent().getId(), oCustomItem);
if (oCustomItem.itemId === oInvisibleElement.getId()) {
_enhanceInvisibleElement(oInvisibleElement, oCustomItem);
}
});
}
if (bIncludeElement) {
aAllElementData.push({
element : oInvisibleElement,
action : mAction,
bindingPathCollection: mBindingPathCollection
});
}
});
return aAllElementData;
})
.then(function(aAllElementData) {
return aAllElementData.map(_elementToAdditionalElementInfo);
});
} | javascript | function(oElement, mActions){
var oModel = oElement.getModel();
var mRevealData = mActions.reveal;
var mAddODataProperty = mActions.addODataProperty;
var mCustom = mActions.custom;
var oDefaultAggregation = oElement.getMetadata().getAggregation();
var sAggregationName = oDefaultAggregation ? oDefaultAggregation.name : mActions.aggregation;
return Promise.resolve()
.then(function () {
return _getODataPropertiesOfModel(oElement, sAggregationName);
})
.then(function(mData) {
var aODataProperties = mData.property;
var aODataNavigationProperties = mData.navigationProperty.map(function (mNavigation) {
return mNavigation.name;
});
var aODataNavigationEntityNames = mData.navigationEntityNames;
aODataProperties = _checkForComplexDuplicates(aODataProperties);
var aAllElementData = [];
var aInvisibleElements = mRevealData.elements || [];
aInvisibleElements.forEach(function(mInvisibleElement) {
var oInvisibleElement = mInvisibleElement.element;
var mAction = mInvisibleElement.action;
var bIncludeElement = true;
var mBindingPathCollection = {};
oInvisibleElement.fieldLabel = ElementUtil.getLabelForElement(oInvisibleElement, mAction.getLabel);
// BCP: 1880498671
if (mAddODataProperty) {
if (_getBindingPath(oElement, sAggregationName) === _getBindingPath(oInvisibleElement, sAggregationName)) {
//TODO fix with stashed type support
mBindingPathCollection = BindingsExtractor.collectBindingPaths(oInvisibleElement, oModel);
oInvisibleElement.duplicateComplexName = _checkForDuplicateLabels(oInvisibleElement, aODataProperties);
//Add information from the oDataProperty to the InvisibleProperty if available;
//if oData is available and the element is not present in it, do not include it
//Example use case: custom field which was hidden and then removed from system
//should not be available for adding after the removal
if (aODataProperties.length > 0){
bIncludeElement = _checkAndEnhanceODataProperty(
oInvisibleElement,
aODataProperties,
aODataNavigationProperties,
aODataNavigationEntityNames,
mBindingPathCollection);
}
} else if (BindingsExtractor.getBindings(oInvisibleElement, oModel).length > 0) {
bIncludeElement = false;
}
}
if (mCustom && bIncludeElement) {
mCustom.items.forEach(function(oCustomItem) {
_assignCustomItemIds(oElement.getParent().getId(), oCustomItem);
if (oCustomItem.itemId === oInvisibleElement.getId()) {
_enhanceInvisibleElement(oInvisibleElement, oCustomItem);
}
});
}
if (bIncludeElement) {
aAllElementData.push({
element : oInvisibleElement,
action : mAction,
bindingPathCollection: mBindingPathCollection
});
}
});
return aAllElementData;
})
.then(function(aAllElementData) {
return aAllElementData.map(_elementToAdditionalElementInfo);
});
} | [
"function",
"(",
"oElement",
",",
"mActions",
")",
"{",
"var",
"oModel",
"=",
"oElement",
".",
"getModel",
"(",
")",
";",
"var",
"mRevealData",
"=",
"mActions",
".",
"reveal",
";",
"var",
"mAddODataProperty",
"=",
"mActions",
".",
"addODataProperty",
";",
... | Filters available invisible elements whether they could be shown or not
@param {sap.ui.core.Control} oElement - Container Element where to start search for a invisible
@param {Object} mActions - Container with actions
@return {Promise} - returns a Promise which resolves with a list of hidden controls are available to display | [
"Filters",
"available",
"invisible",
"elements",
"whether",
"they",
"could",
"be",
"shown",
"or",
"not"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.rta/src/sap/ui/rta/plugin/additionalElements/AdditionalElementsAnalyzer.js#L432-L509 | train | Returns an array of elements that are invisible by the user. | [
30522,
3853,
1006,
1051,
12260,
3672,
1010,
6097,
9285,
1007,
1063,
13075,
18168,
10244,
2140,
1027,
1051,
12260,
3672,
1012,
2131,
5302,
9247,
1006,
1007,
1025,
13075,
2720,
18697,
19058,
6790,
1027,
6097,
9285,
1012,
7487,
1025,
13075,
55... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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/s3/managed_upload.js | function(callback) {
var self = this;
self.failed = false;
self.callback = callback || function(err) { if (err) throw err; };
var runFill = true;
if (self.sliceFn) {
self.fillQueue = self.fillBuffer;
} else if (AWS.util.isNode()) {
var Stream = AWS.util.stream.Stream;
if (self.body instanceof Stream) {
runFill = false;
self.fillQueue = self.fillStream;
self.partBuffers = [];
self.body.
on('error', function(err) { self.cleanup(err); }).
on('readable', function() { self.fillQueue(); }).
on('end', function() {
self.isDoneChunking = true;
self.numParts = self.totalPartNumbers;
self.fillQueue.call(self);
if (self.isDoneChunking && self.totalPartNumbers >= 1 && self.doneParts === self.numParts) {
self.finishMultiPart();
}
});
}
}
if (runFill) self.fillQueue.call(self);
} | javascript | function(callback) {
var self = this;
self.failed = false;
self.callback = callback || function(err) { if (err) throw err; };
var runFill = true;
if (self.sliceFn) {
self.fillQueue = self.fillBuffer;
} else if (AWS.util.isNode()) {
var Stream = AWS.util.stream.Stream;
if (self.body instanceof Stream) {
runFill = false;
self.fillQueue = self.fillStream;
self.partBuffers = [];
self.body.
on('error', function(err) { self.cleanup(err); }).
on('readable', function() { self.fillQueue(); }).
on('end', function() {
self.isDoneChunking = true;
self.numParts = self.totalPartNumbers;
self.fillQueue.call(self);
if (self.isDoneChunking && self.totalPartNumbers >= 1 && self.doneParts === self.numParts) {
self.finishMultiPart();
}
});
}
}
if (runFill) self.fillQueue.call(self);
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"self",
".",
"failed",
"=",
"false",
";",
"self",
".",
"callback",
"=",
"callback",
"||",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"throw",
"err",
";",
"}",
"... | Initiates the managed upload for the payload.
@callback callback function(err, data)
@param err [Error] an error or null if no error occurred.
@param data [map] The response data from the successful upload:
* `Location` (String) the URL of the uploaded object
* `ETag` (String) the ETag of the uploaded object
* `Bucket` (String) the bucket to which the object was uploaded
* `Key` (String) the key to which the object was uploaded
@example Sending a managed upload object
var params = {Bucket: 'bucket', Key: 'key', Body: stream};
var upload = new AWS.S3.ManagedUpload({params: params});
upload.send(function(err, data) {
console.log(err, data);
}); | [
"Initiates",
"the",
"managed",
"upload",
"for",
"the",
"payload",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/s3/managed_upload.js#L170-L200 | train | This method is called by the next iteration of the iteration. | [
30522,
3853,
1006,
2655,
5963,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2969,
1012,
3478,
1027,
6270,
1025,
2969,
1012,
2655,
5963,
1027,
2655,
5963,
1064,
1064,
3853,
1006,
9413,
2099,
1007,
1063,
2065,
1006,
9413,
2099,
1007,
5466,
94... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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... | |
thomaspark/bootswatch | docs/3/bower_components/html5shiv/dist/html5shiv-printshiv.js | shivPrint | function shivPrint(ownerDocument) {
var shivedSheet,
wrappers,
data = getExpandoData(ownerDocument),
namespaces = ownerDocument.namespaces,
ownerWindow = ownerDocument.parentWindow;
if (!supportsShivableSheets || ownerDocument.printShived) {
return ownerDocument;
}
if (typeof namespaces[shivNamespace] == 'undefined') {
namespaces.add(shivNamespace);
}
function removeSheet() {
clearTimeout(data._removeSheetTimer);
if (shivedSheet) {
shivedSheet.removeNode(true);
}
shivedSheet= null;
}
ownerWindow.attachEvent('onbeforeprint', function() {
removeSheet();
var imports,
length,
sheet,
collection = ownerDocument.styleSheets,
cssText = [],
index = collection.length,
sheets = Array(index);
// convert styleSheets collection to an array
while (index--) {
sheets[index] = collection[index];
}
// concat all style sheet CSS text
while ((sheet = sheets.pop())) {
// IE does not enforce a same origin policy for external style sheets...
// but has trouble with some dynamically created stylesheets
if (!sheet.disabled && reMedia.test(sheet.media)) {
try {
imports = sheet.imports;
length = imports.length;
} catch(er){
length = 0;
}
for (index = 0; index < length; index++) {
sheets.push(imports[index]);
}
try {
cssText.push(sheet.cssText);
} catch(er){}
}
}
// wrap all HTML5 elements with printable elements and add the shived style sheet
cssText = shivCssText(cssText.reverse().join(''));
wrappers = addWrappers(ownerDocument);
shivedSheet = addStyleSheet(ownerDocument, cssText);
});
ownerWindow.attachEvent('onafterprint', function() {
// remove wrappers, leaving the original elements, and remove the shived style sheet
removeWrappers(wrappers);
clearTimeout(data._removeSheetTimer);
data._removeSheetTimer = setTimeout(removeSheet, 500);
});
ownerDocument.printShived = true;
return ownerDocument;
} | javascript | function shivPrint(ownerDocument) {
var shivedSheet,
wrappers,
data = getExpandoData(ownerDocument),
namespaces = ownerDocument.namespaces,
ownerWindow = ownerDocument.parentWindow;
if (!supportsShivableSheets || ownerDocument.printShived) {
return ownerDocument;
}
if (typeof namespaces[shivNamespace] == 'undefined') {
namespaces.add(shivNamespace);
}
function removeSheet() {
clearTimeout(data._removeSheetTimer);
if (shivedSheet) {
shivedSheet.removeNode(true);
}
shivedSheet= null;
}
ownerWindow.attachEvent('onbeforeprint', function() {
removeSheet();
var imports,
length,
sheet,
collection = ownerDocument.styleSheets,
cssText = [],
index = collection.length,
sheets = Array(index);
// convert styleSheets collection to an array
while (index--) {
sheets[index] = collection[index];
}
// concat all style sheet CSS text
while ((sheet = sheets.pop())) {
// IE does not enforce a same origin policy for external style sheets...
// but has trouble with some dynamically created stylesheets
if (!sheet.disabled && reMedia.test(sheet.media)) {
try {
imports = sheet.imports;
length = imports.length;
} catch(er){
length = 0;
}
for (index = 0; index < length; index++) {
sheets.push(imports[index]);
}
try {
cssText.push(sheet.cssText);
} catch(er){}
}
}
// wrap all HTML5 elements with printable elements and add the shived style sheet
cssText = shivCssText(cssText.reverse().join(''));
wrappers = addWrappers(ownerDocument);
shivedSheet = addStyleSheet(ownerDocument, cssText);
});
ownerWindow.attachEvent('onafterprint', function() {
// remove wrappers, leaving the original elements, and remove the shived style sheet
removeWrappers(wrappers);
clearTimeout(data._removeSheetTimer);
data._removeSheetTimer = setTimeout(removeSheet, 500);
});
ownerDocument.printShived = true;
return ownerDocument;
} | [
"function",
"shivPrint",
"(",
"ownerDocument",
")",
"{",
"var",
"shivedSheet",
",",
"wrappers",
",",
"data",
"=",
"getExpandoData",
"(",
"ownerDocument",
")",
",",
"namespaces",
"=",
"ownerDocument",
".",
"namespaces",
",",
"ownerWindow",
"=",
"ownerDocument",
"... | /*--------------------------------------------------------------------------
Shivs the given document for print.
@memberOf html5
@param {Document} ownerDocument The document to shiv.
@returns {Document} The shived document. | [
"/",
"*",
"--------------------------------------------------------------------------",
"Shivs",
"the",
"given",
"document",
"for",
"print",
"."
] | a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd | https://github.com/thomaspark/bootswatch/blob/a913e4992dad8f7bf38df2e1d3f4cc6bfe5f26dd/docs/3/bower_components/html5shiv/dist/html5shiv-printshiv.js#L432-L509 | train | Print the style sheets of the given ownerDocument. | [
30522,
3853,
11895,
2615,
16550,
1006,
3954,
3527,
24894,
4765,
1007,
1063,
13075,
11895,
7178,
4095,
15558,
1010,
10236,
7347,
1010,
2951,
1027,
2131,
10288,
9739,
3527,
2850,
2696,
1006,
3954,
3527,
24894,
4765,
1007,
1010,
3415,
15327,
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... |
aframevr/aframe | src/core/scene/a-scene.js | enterVRSuccess | function enterVRSuccess () {
self.addState('vr-mode');
self.emit('enter-vr', {target: self});
// Lock to landscape orientation on mobile.
if (self.isMobile && screen.orientation && screen.orientation.lock) {
screen.orientation.lock('landscape');
}
self.addFullScreenStyles();
// On mobile, the polyfill handles fullscreen.
// TODO: 07/16 Chromium builds break when `requestFullscreen`ing on a canvas
// that we are also `requestPresent`ing. Until then, don't fullscreen if headset
// connected.
if (!self.isMobile && !self.checkHeadsetConnected()) {
requestFullscreen(self.canvas);
}
self.renderer.setAnimationLoop(self.render);
self.resize();
} | javascript | function enterVRSuccess () {
self.addState('vr-mode');
self.emit('enter-vr', {target: self});
// Lock to landscape orientation on mobile.
if (self.isMobile && screen.orientation && screen.orientation.lock) {
screen.orientation.lock('landscape');
}
self.addFullScreenStyles();
// On mobile, the polyfill handles fullscreen.
// TODO: 07/16 Chromium builds break when `requestFullscreen`ing on a canvas
// that we are also `requestPresent`ing. Until then, don't fullscreen if headset
// connected.
if (!self.isMobile && !self.checkHeadsetConnected()) {
requestFullscreen(self.canvas);
}
self.renderer.setAnimationLoop(self.render);
self.resize();
} | [
"function",
"enterVRSuccess",
"(",
")",
"{",
"self",
".",
"addState",
"(",
"'vr-mode'",
")",
";",
"self",
".",
"emit",
"(",
"'enter-vr'",
",",
"{",
"target",
":",
"self",
"}",
")",
";",
"// Lock to landscape orientation on mobile.",
"if",
"(",
"self",
".",
... | Callback that happens on enter VR success or enter fullscreen (any API). | [
"Callback",
"that",
"happens",
"on",
"enter",
"VR",
"success",
"or",
"enter",
"fullscreen",
"(",
"any",
"API",
")",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/scene/a-scene.js#L311-L330 | train | Enter the VR mode | [
30522,
3853,
4607,
19716,
6342,
9468,
7971,
1006,
1007,
1063,
2969,
1012,
9909,
12259,
1006,
1005,
27830,
1011,
5549,
1005,
1007,
1025,
2969,
1012,
12495,
2102,
1006,
1005,
4607,
1011,
27830,
1005,
1010,
1063,
4539,
1024,
2969,
1065,
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/base/i18n/ResourceBundle.js | nextFallbackLocale | function nextFallbackLocale(sLocale) {
// there is no fallback for the 'raw' locale or for null/undefined
if ( !sLocale ) {
return null;
}
// special (legacy) handling for zh_HK: try zh_TW (for Traditional Chinese) first before falling back to 'zh'
if ( sLocale === "zh_HK" ) {
return "zh_TW";
}
// if there are multiple segments (separated by underscores), remove the last one
var p = sLocale.lastIndexOf('_');
if ( p >= 0 ) {
return sLocale.slice(0,p);
}
// invariant: only a single segment, must be a language
// for any language but 'en', fallback to 'en' first before falling back to the 'raw' language (empty string)
return sLocale !== 'en' ? 'en' : '';
} | javascript | function nextFallbackLocale(sLocale) {
// there is no fallback for the 'raw' locale or for null/undefined
if ( !sLocale ) {
return null;
}
// special (legacy) handling for zh_HK: try zh_TW (for Traditional Chinese) first before falling back to 'zh'
if ( sLocale === "zh_HK" ) {
return "zh_TW";
}
// if there are multiple segments (separated by underscores), remove the last one
var p = sLocale.lastIndexOf('_');
if ( p >= 0 ) {
return sLocale.slice(0,p);
}
// invariant: only a single segment, must be a language
// for any language but 'en', fallback to 'en' first before falling back to the 'raw' language (empty string)
return sLocale !== 'en' ? 'en' : '';
} | [
"function",
"nextFallbackLocale",
"(",
"sLocale",
")",
"{",
"// there is no fallback for the 'raw' locale or for null/undefined",
"if",
"(",
"!",
"sLocale",
")",
"{",
"return",
"null",
";",
"}",
"// special (legacy) handling for zh_HK: try zh_TW (for Traditional Chinese) first befo... | Calculate the next fallback locale for the given locale.
Note: always keep this in sync with the fallback mechanism in Java, ABAP (MIME & BSP)
resource handler (Java: Peter M., MIME: Sebastian A., BSP: Silke A.)
@param {string} sLocale Locale string in Java format (underscores) or null
@returns {string|null} Next fallback Locale or null if there is no more fallback
@private | [
"Calculate",
"the",
"next",
"fallback",
"locale",
"for",
"the",
"given",
"locale",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/base/i18n/ResourceBundle.js#L129-L150 | train | Returns the next fallback locale for the given locale. | [
30522,
3853,
2279,
13976,
5963,
4135,
9289,
2063,
1006,
22889,
24755,
2571,
1007,
1063,
1013,
1013,
2045,
2003,
2053,
2991,
5963,
2005,
1996,
1005,
6315,
1005,
2334,
2063,
2030,
2005,
19701,
1013,
6151,
28344,
2065,
1006,
999,
22889,
24755,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.demokit/src/sap/ui/demokit/explored/view/base.controller.js | function (bSwitch) {
jQuery.sap.require("sap.ui.core.routing.HashChanger");
var HashChanger = sap.ui.require("sap/ui/core/routing/HashChanger");
var oHashChanger = new HashChanger();
var sHash = oHashChanger.getHash();
var oUri = window.location;
// TODO: remove this fix when microsoft fix this under IE11 on Win 10
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" +
window.location.hostname +
(window.location.port ? ':' + window.location.port : '');
}
if (bSwitch) {
// add the parameter
window.location = oUri.origin + oUri.pathname + "?sap-ui-rtl=true#" + sHash;
} else {
// or remove it
window.location = oUri.origin + oUri.pathname + "#/" + sHash;
}
} | javascript | function (bSwitch) {
jQuery.sap.require("sap.ui.core.routing.HashChanger");
var HashChanger = sap.ui.require("sap/ui/core/routing/HashChanger");
var oHashChanger = new HashChanger();
var sHash = oHashChanger.getHash();
var oUri = window.location;
// TODO: remove this fix when microsoft fix this under IE11 on Win 10
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" +
window.location.hostname +
(window.location.port ? ':' + window.location.port : '');
}
if (bSwitch) {
// add the parameter
window.location = oUri.origin + oUri.pathname + "?sap-ui-rtl=true#" + sHash;
} else {
// or remove it
window.location = oUri.origin + oUri.pathname + "#/" + sHash;
}
} | [
"function",
"(",
"bSwitch",
")",
"{",
"jQuery",
".",
"sap",
".",
"require",
"(",
"\"sap.ui.core.routing.HashChanger\"",
")",
";",
"var",
"HashChanger",
"=",
"sap",
".",
"ui",
".",
"require",
"(",
"\"sap/ui/core/routing/HashChanger\"",
")",
";",
"var",
"oHashChan... | trigger reload w/o URL-Parameter; | [
"trigger",
"reload",
"w",
"/",
"o",
"URL",
"-",
"Parameter",
";"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.demokit/src/sap/ui/demokit/explored/view/base.controller.js#L121-L144 | train | Sets the hash to the hash of the window | [
30522,
3853,
1006,
18667,
9148,
10649,
1007,
1063,
1046,
4226,
2854,
1012,
20066,
1012,
5478,
1006,
1000,
20066,
1012,
21318,
1012,
4563,
1012,
16972,
1012,
23325,
22305,
2121,
1000,
1007,
1025,
13075,
23325,
22305,
2121,
1027,
20066,
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... | |
aframevr/aframe | src/core/schema.js | parseProperty | function parseProperty (value, propDefinition) {
// Use default value if value is falsy.
if (value === undefined || value === null || value === '') {
value = propDefinition.default;
if (Array.isArray(value)) { value = value.slice(); }
}
// Invoke property type parser.
return propDefinition.parse(value, propDefinition.default);
} | javascript | function parseProperty (value, propDefinition) {
// Use default value if value is falsy.
if (value === undefined || value === null || value === '') {
value = propDefinition.default;
if (Array.isArray(value)) { value = value.slice(); }
}
// Invoke property type parser.
return propDefinition.parse(value, propDefinition.default);
} | [
"function",
"parseProperty",
"(",
"value",
",",
"propDefinition",
")",
"{",
"// Use default value if value is falsy.",
"if",
"(",
"value",
"===",
"undefined",
"||",
"value",
"===",
"null",
"||",
"value",
"===",
"''",
")",
"{",
"value",
"=",
"propDefinition",
"."... | Deserialize a single property. | [
"Deserialize",
"a",
"single",
"property",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/schema.js#L155-L163 | train | Parse property value | [
30522,
3853,
11968,
3366,
21572,
4842,
3723,
1006,
3643,
1010,
17678,
3207,
16294,
22753,
1007,
1063,
1013,
1013,
2224,
12398,
3643,
2065,
3643,
2003,
6904,
4877,
2100,
1012,
2065,
1006,
3643,
1027,
1027,
1027,
6151,
28344,
1064,
1064,
3643... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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.