repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
joyent/kang
|
examples/webconsole/resources/js/jquery/jquery.dataTables.js
|
_fnBindAction
|
function _fnBindAction( n, oData, fn )
{
$(n)
.bind( 'click.DT', oData, function (e) {
n.blur(); // Remove focus outline for mouse users
fn(e);
} )
.bind( 'keypress.DT', oData, function (e){
if ( e.which === 13 ) {
fn(e);
} } )
.bind( 'selectstart.DT', function () {
/* Take the brutal approach to cancelling text selection */
return false;
} );
}
|
javascript
|
function _fnBindAction( n, oData, fn )
{
$(n)
.bind( 'click.DT', oData, function (e) {
n.blur(); // Remove focus outline for mouse users
fn(e);
} )
.bind( 'keypress.DT', oData, function (e){
if ( e.which === 13 ) {
fn(e);
} } )
.bind( 'selectstart.DT', function () {
/* Take the brutal approach to cancelling text selection */
return false;
} );
}
|
[
"function",
"_fnBindAction",
"(",
"n",
",",
"oData",
",",
"fn",
")",
"{",
"$",
"(",
"n",
")",
".",
"bind",
"(",
"'click.DT'",
",",
"oData",
",",
"function",
"(",
"e",
")",
"{",
"n",
".",
"blur",
"(",
")",
";",
"fn",
"(",
"e",
")",
";",
"}",
")",
".",
"bind",
"(",
"'keypress.DT'",
",",
"oData",
",",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"which",
"===",
"13",
")",
"{",
"fn",
"(",
"e",
")",
";",
"}",
"}",
")",
".",
"bind",
"(",
"'selectstart.DT'",
",",
"function",
"(",
")",
"{",
"return",
"false",
";",
"}",
")",
";",
"}"
] |
Bind an event handers to allow a click or return key to activate the callback.
This is good for accessability since a return on the keyboard will have the
same effect as a click, if the element has focus.
@param {element} n Element to bind the action to
@param {object} oData Data object to pass to the triggered function
@param {function) fn Callback function for when the event is triggered
@memberof DataTable#oApi
|
[
"Bind",
"an",
"event",
"handers",
"to",
"allow",
"a",
"click",
"or",
"return",
"key",
"to",
"activate",
"the",
"callback",
".",
"This",
"is",
"good",
"for",
"accessability",
"since",
"a",
"return",
"on",
"the",
"keyboard",
"will",
"have",
"the",
"same",
"effect",
"as",
"a",
"click",
"if",
"the",
"element",
"has",
"focus",
"."
] |
9b138f2b4fb7873b9b0f271516daf36e20c9c037
|
https://github.com/joyent/kang/blob/9b138f2b4fb7873b9b0f271516daf36e20c9c037/examples/webconsole/resources/js/jquery/jquery.dataTables.js#L4661-L4676
|
train
|
joyent/kang
|
examples/webconsole/resources/js/jquery/jquery.dataTables.js
|
_fnCallbackReg
|
function _fnCallbackReg( oSettings, sStore, fn, sName )
{
if ( fn )
{
oSettings[sStore].push( {
"fn": fn,
"sName": sName
} );
}
}
|
javascript
|
function _fnCallbackReg( oSettings, sStore, fn, sName )
{
if ( fn )
{
oSettings[sStore].push( {
"fn": fn,
"sName": sName
} );
}
}
|
[
"function",
"_fnCallbackReg",
"(",
"oSettings",
",",
"sStore",
",",
"fn",
",",
"sName",
")",
"{",
"if",
"(",
"fn",
")",
"{",
"oSettings",
"[",
"sStore",
"]",
".",
"push",
"(",
"{",
"\"fn\"",
":",
"fn",
",",
"\"sName\"",
":",
"sName",
"}",
")",
";",
"}",
"}"
] |
Register a callback function. Easily allows a callback function to be added to
an array store of callback functions that can then all be called together.
@param {object} oSettings dataTables settings object
@param {string} sStore Name of the array storeage for the callbacks in oSettings
@param {function} fn Function to be called back
@param {string) sName Identifying name for the callback (i.e. a label)
@memberof DataTable#oApi
|
[
"Register",
"a",
"callback",
"function",
".",
"Easily",
"allows",
"a",
"callback",
"function",
"to",
"be",
"added",
"to",
"an",
"array",
"store",
"of",
"callback",
"functions",
"that",
"can",
"then",
"all",
"be",
"called",
"together",
"."
] |
9b138f2b4fb7873b9b0f271516daf36e20c9c037
|
https://github.com/joyent/kang/blob/9b138f2b4fb7873b9b0f271516daf36e20c9c037/examples/webconsole/resources/js/jquery/jquery.dataTables.js#L4688-L4697
|
train
|
joyent/kang
|
examples/webconsole/resources/js/jquery/jquery.dataTables.js
|
function ()
{
if ( this.oFeatures.bServerSide ) {
if ( this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ) {
return this._iDisplayStart+this.aiDisplay.length;
} else {
return Math.min( this._iDisplayStart+this._iDisplayLength,
this._iRecordsDisplay );
}
} else {
return this._iDisplayEnd;
}
}
|
javascript
|
function ()
{
if ( this.oFeatures.bServerSide ) {
if ( this.oFeatures.bPaginate === false || this._iDisplayLength == -1 ) {
return this._iDisplayStart+this.aiDisplay.length;
} else {
return Math.min( this._iDisplayStart+this._iDisplayLength,
this._iRecordsDisplay );
}
} else {
return this._iDisplayEnd;
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"oFeatures",
".",
"bServerSide",
")",
"{",
"if",
"(",
"this",
".",
"oFeatures",
".",
"bPaginate",
"===",
"false",
"||",
"this",
".",
"_iDisplayLength",
"==",
"-",
"1",
")",
"{",
"return",
"this",
".",
"_iDisplayStart",
"+",
"this",
".",
"aiDisplay",
".",
"length",
";",
"}",
"else",
"{",
"return",
"Math",
".",
"min",
"(",
"this",
".",
"_iDisplayStart",
"+",
"this",
".",
"_iDisplayLength",
",",
"this",
".",
"_iRecordsDisplay",
")",
";",
"}",
"}",
"else",
"{",
"return",
"this",
".",
"_iDisplayEnd",
";",
"}",
"}"
] |
Set the display end point - aiDisplay index
@type function
@todo Should do away with _iDisplayEnd and calculate it on-the-fly here
|
[
"Set",
"the",
"display",
"end",
"point",
"-",
"aiDisplay",
"index"
] |
9b138f2b4fb7873b9b0f271516daf36e20c9c037
|
https://github.com/joyent/kang/blob/9b138f2b4fb7873b9b0f271516daf36e20c9c037/examples/webconsole/resources/js/jquery/jquery.dataTables.js#L11123-L11135
|
train
|
|
uber-workflow/probot-app-pr-title
|
validate-title.js
|
validateSentence
|
function validateSentence(parsed) {
const sentences = parsed.sentences();
return [
!isSingleSentence(sentences) ? 'Must be one and only one sentence.' : null,
!isNotTooShort(parsed) ? 'Must be at least two words long.' : null,
!isNotPunctuated(sentences) ? 'Must not have any end punctuation.' : null,
].filter(Boolean);
}
|
javascript
|
function validateSentence(parsed) {
const sentences = parsed.sentences();
return [
!isSingleSentence(sentences) ? 'Must be one and only one sentence.' : null,
!isNotTooShort(parsed) ? 'Must be at least two words long.' : null,
!isNotPunctuated(sentences) ? 'Must not have any end punctuation.' : null,
].filter(Boolean);
}
|
[
"function",
"validateSentence",
"(",
"parsed",
")",
"{",
"const",
"sentences",
"=",
"parsed",
".",
"sentences",
"(",
")",
";",
"return",
"[",
"!",
"isSingleSentence",
"(",
"sentences",
")",
"?",
"'Must be one and only one sentence.'",
":",
"null",
",",
"!",
"isNotTooShort",
"(",
"parsed",
")",
"?",
"'Must be at least two words long.'",
":",
"null",
",",
"!",
"isNotPunctuated",
"(",
"sentences",
")",
"?",
"'Must not have any end punctuation.'",
":",
"null",
",",
"]",
".",
"filter",
"(",
"Boolean",
")",
";",
"}"
] |
Validate text is a single sentence with no end punctuation
|
[
"Validate",
"text",
"is",
"a",
"single",
"sentence",
"with",
"no",
"end",
"punctuation"
] |
c3b29c5c9a9571e3e9a44fc5992003a2e744d69c
|
https://github.com/uber-workflow/probot-app-pr-title/blob/c3b29c5c9a9571e3e9a44fc5992003a2e744d69c/validate-title.js#L15-L22
|
train
|
uber-workflow/probot-app-pr-title
|
validate-title.js
|
validateFirstTerm
|
function validateFirstTerm(parsed) {
const term = parsed.terms().data()[0];
return [
!isValidVerb(term) ? 'First word must be imperative verb.' : null,
!isCapitalized(term) ? 'First word must be capitalized.' : null,
].filter(Boolean);
}
|
javascript
|
function validateFirstTerm(parsed) {
const term = parsed.terms().data()[0];
return [
!isValidVerb(term) ? 'First word must be imperative verb.' : null,
!isCapitalized(term) ? 'First word must be capitalized.' : null,
].filter(Boolean);
}
|
[
"function",
"validateFirstTerm",
"(",
"parsed",
")",
"{",
"const",
"term",
"=",
"parsed",
".",
"terms",
"(",
")",
".",
"data",
"(",
")",
"[",
"0",
"]",
";",
"return",
"[",
"!",
"isValidVerb",
"(",
"term",
")",
"?",
"'First word must be imperative verb.'",
":",
"null",
",",
"!",
"isCapitalized",
"(",
"term",
")",
"?",
"'First word must be capitalized.'",
":",
"null",
",",
"]",
".",
"filter",
"(",
"Boolean",
")",
";",
"}"
] |
Validate first word is a capitalized imperative mood verb
|
[
"Validate",
"first",
"word",
"is",
"a",
"capitalized",
"imperative",
"mood",
"verb"
] |
c3b29c5c9a9571e3e9a44fc5992003a2e744d69c
|
https://github.com/uber-workflow/probot-app-pr-title/blob/c3b29c5c9a9571e3e9a44fc5992003a2e744d69c/validate-title.js#L25-L31
|
train
|
stream-utils/destroy
|
index.js
|
destroy
|
function destroy (stream) {
if (stream instanceof ReadStream) {
return destroyReadStream(stream)
}
if (!(stream instanceof Stream)) {
return stream
}
if (typeof stream.destroy === 'function') {
stream.destroy()
}
return stream
}
|
javascript
|
function destroy (stream) {
if (stream instanceof ReadStream) {
return destroyReadStream(stream)
}
if (!(stream instanceof Stream)) {
return stream
}
if (typeof stream.destroy === 'function') {
stream.destroy()
}
return stream
}
|
[
"function",
"destroy",
"(",
"stream",
")",
"{",
"if",
"(",
"stream",
"instanceof",
"ReadStream",
")",
"{",
"return",
"destroyReadStream",
"(",
"stream",
")",
"}",
"if",
"(",
"!",
"(",
"stream",
"instanceof",
"Stream",
")",
")",
"{",
"return",
"stream",
"}",
"if",
"(",
"typeof",
"stream",
".",
"destroy",
"===",
"'function'",
")",
"{",
"stream",
".",
"destroy",
"(",
")",
"}",
"return",
"stream",
"}"
] |
Destroy a stream.
@param {object} stream
@public
|
[
"Destroy",
"a",
"stream",
"."
] |
d1a76c640b63ef662d19c8d6211f705eed06f32e
|
https://github.com/stream-utils/destroy/blob/d1a76c640b63ef662d19c8d6211f705eed06f32e/index.js#L31-L45
|
train
|
stream-utils/destroy
|
index.js
|
destroyReadStream
|
function destroyReadStream (stream) {
stream.destroy()
if (typeof stream.close === 'function') {
// node.js core bug work-around
stream.on('open', onOpenClose)
}
return stream
}
|
javascript
|
function destroyReadStream (stream) {
stream.destroy()
if (typeof stream.close === 'function') {
// node.js core bug work-around
stream.on('open', onOpenClose)
}
return stream
}
|
[
"function",
"destroyReadStream",
"(",
"stream",
")",
"{",
"stream",
".",
"destroy",
"(",
")",
"if",
"(",
"typeof",
"stream",
".",
"close",
"===",
"'function'",
")",
"{",
"stream",
".",
"on",
"(",
"'open'",
",",
"onOpenClose",
")",
"}",
"return",
"stream",
"}"
] |
Destroy a ReadStream.
@param {object} stream
@private
|
[
"Destroy",
"a",
"ReadStream",
"."
] |
d1a76c640b63ef662d19c8d6211f705eed06f32e
|
https://github.com/stream-utils/destroy/blob/d1a76c640b63ef662d19c8d6211f705eed06f32e/index.js#L54-L63
|
train
|
jaredhanson/passport-windowslive
|
lib/errors/liveconnectapierror.js
|
LiveConnectAPIError
|
function LiveConnectAPIError(message, code) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'LiveConnectAPIError';
this.message = message;
this.code = code;
}
|
javascript
|
function LiveConnectAPIError(message, code) {
Error.call(this);
Error.captureStackTrace(this, arguments.callee);
this.name = 'LiveConnectAPIError';
this.message = message;
this.code = code;
}
|
[
"function",
"LiveConnectAPIError",
"(",
"message",
",",
"code",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"name",
"=",
"'LiveConnectAPIError'",
";",
"this",
".",
"message",
"=",
"message",
";",
"this",
".",
"code",
"=",
"code",
";",
"}"
] |
`LiveConnectAPIError` error.
References:
- http://msdn.microsoft.com/en-us/library/live/hh243648.aspx#error
@constructor
@param {string} [message]
@param {string} [code]
@access public
|
[
"LiveConnectAPIError",
"error",
"."
] |
47cad2be5830c13d46eb9f1d334990fd8702aa1e
|
https://github.com/jaredhanson/passport-windowslive/blob/47cad2be5830c13d46eb9f1d334990fd8702aa1e/lib/errors/liveconnectapierror.js#L12-L18
|
train
|
rniemeyer/knockout-amd-helpers
|
spec/amdBindings.spec.js
|
function(observable, value, callback) {
var subscription = observable.subscribe(function() {
subscription.dispose();
setTimeout(function() {
callback();
}, 50);
});
observable(value);
}
|
javascript
|
function(observable, value, callback) {
var subscription = observable.subscribe(function() {
subscription.dispose();
setTimeout(function() {
callback();
}, 50);
});
observable(value);
}
|
[
"function",
"(",
"observable",
",",
"value",
",",
"callback",
")",
"{",
"var",
"subscription",
"=",
"observable",
".",
"subscribe",
"(",
"function",
"(",
")",
"{",
"subscription",
".",
"dispose",
"(",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"callback",
"(",
")",
";",
"}",
",",
"50",
")",
";",
"}",
")",
";",
"observable",
"(",
"value",
")",
";",
"}"
] |
helper to update an observable, wait, and check result
|
[
"helper",
"to",
"update",
"an",
"observable",
"wait",
"and",
"check",
"result"
] |
0e4884bb1c95b15be950b8f4474393ac042ecb24
|
https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/spec/amdBindings.spec.js#L38-L49
|
train
|
|
rniemeyer/knockout-amd-helpers
|
ext/curl/curl.js
|
countdown
|
function countdown (howMany, lambda, completed) {
var result;
return function () {
if (--howMany >= 0 && lambda) result = lambda.apply(undef, arguments);
// we want ==, not <=, since some callers expect call-once functionality
if (howMany == 0 && completed) completed(result);
return result;
}
}
|
javascript
|
function countdown (howMany, lambda, completed) {
var result;
return function () {
if (--howMany >= 0 && lambda) result = lambda.apply(undef, arguments);
// we want ==, not <=, since some callers expect call-once functionality
if (howMany == 0 && completed) completed(result);
return result;
}
}
|
[
"function",
"countdown",
"(",
"howMany",
",",
"lambda",
",",
"completed",
")",
"{",
"var",
"result",
";",
"return",
"function",
"(",
")",
"{",
"if",
"(",
"--",
"howMany",
">=",
"0",
"&&",
"lambda",
")",
"result",
"=",
"lambda",
".",
"apply",
"(",
"undef",
",",
"arguments",
")",
";",
"if",
"(",
"howMany",
"==",
"0",
"&&",
"completed",
")",
"completed",
"(",
"result",
")",
";",
"return",
"result",
";",
"}",
"}"
] |
Returns a function that when executed, executes a lambda function,
but only executes it the number of times stated by howMany.
When done executing, it executes the completed function. Each callback
function receives the same parameters that are supplied to the
returned function each time it executes. In other words, they
are passed through.
@private
@param howMany {Number} must be greater than zero
@param lambda {Function} executed each time
@param completed {Function} only executes once when the counter
reaches zero
@returns {Function}
|
[
"Returns",
"a",
"function",
"that",
"when",
"executed",
"executes",
"a",
"lambda",
"function",
"but",
"only",
"executes",
"it",
"the",
"number",
"of",
"times",
"stated",
"by",
"howMany",
".",
"When",
"done",
"executing",
"it",
"executes",
"the",
"completed",
"function",
".",
"Each",
"callback",
"function",
"receives",
"the",
"same",
"parameters",
"that",
"are",
"supplied",
"to",
"the",
"returned",
"function",
"each",
"time",
"it",
"executes",
".",
"In",
"other",
"words",
"they",
"are",
"passed",
"through",
"."
] |
0e4884bb1c95b15be950b8f4474393ac042ecb24
|
https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/ext/curl/curl.js#L233-L241
|
train
|
rniemeyer/knockout-amd-helpers
|
ext/curl/curl.js
|
convertPathMatcher
|
function convertPathMatcher (cfg) {
var pathMap = cfg.pathMap;
cfg.pathRx = new RegExp('^(' +
cfg.pathList.sort(function (a, b) { return pathMap[b].specificity - pathMap[a].specificity; } )
.join('|')
.replace(/\/|\./g, '\\$&') +
')(?=\\/|$)'
);
delete cfg.pathList;
}
|
javascript
|
function convertPathMatcher (cfg) {
var pathMap = cfg.pathMap;
cfg.pathRx = new RegExp('^(' +
cfg.pathList.sort(function (a, b) { return pathMap[b].specificity - pathMap[a].specificity; } )
.join('|')
.replace(/\/|\./g, '\\$&') +
')(?=\\/|$)'
);
delete cfg.pathList;
}
|
[
"function",
"convertPathMatcher",
"(",
"cfg",
")",
"{",
"var",
"pathMap",
"=",
"cfg",
".",
"pathMap",
";",
"cfg",
".",
"pathRx",
"=",
"new",
"RegExp",
"(",
"'^('",
"+",
"cfg",
".",
"pathList",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"pathMap",
"[",
"b",
"]",
".",
"specificity",
"-",
"pathMap",
"[",
"a",
"]",
".",
"specificity",
";",
"}",
")",
".",
"join",
"(",
"'|'",
")",
".",
"replace",
"(",
"/",
"\\/|\\.",
"/",
"g",
",",
"'\\\\$&'",
")",
"+",
"\\\\",
")",
";",
"')(?=\\\\/|$)'",
"}"
] |
adds the path matching regexp onto the cfg or plugin cfgs.
|
[
"adds",
"the",
"path",
"matching",
"regexp",
"onto",
"the",
"cfg",
"or",
"plugin",
"cfgs",
"."
] |
0e4884bb1c95b15be950b8f4474393ac042ecb24
|
https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/ext/curl/curl.js#L593-L602
|
train
|
rniemeyer/knockout-amd-helpers
|
ext/curl/curl.js
|
process
|
function process (ev) {
ev = ev || global.event;
// detect when it's done loading
// ev.type == 'load' is for all browsers except IE6-9
// IE6-9 need to use onreadystatechange and look for
// el.readyState in {loaded, complete} (yes, we need both)
if (ev.type == 'load' || readyStates[el.readyState]) {
delete activeScripts[def.id];
// release event listeners
el.onload = el.onreadystatechange = el.onerror = ''; // ie cries if we use undefined
success();
}
}
|
javascript
|
function process (ev) {
ev = ev || global.event;
// detect when it's done loading
// ev.type == 'load' is for all browsers except IE6-9
// IE6-9 need to use onreadystatechange and look for
// el.readyState in {loaded, complete} (yes, we need both)
if (ev.type == 'load' || readyStates[el.readyState]) {
delete activeScripts[def.id];
// release event listeners
el.onload = el.onreadystatechange = el.onerror = ''; // ie cries if we use undefined
success();
}
}
|
[
"function",
"process",
"(",
"ev",
")",
"{",
"ev",
"=",
"ev",
"||",
"global",
".",
"event",
";",
"if",
"(",
"ev",
".",
"type",
"==",
"'load'",
"||",
"readyStates",
"[",
"el",
".",
"readyState",
"]",
")",
"{",
"delete",
"activeScripts",
"[",
"def",
".",
"id",
"]",
";",
"el",
".",
"onload",
"=",
"el",
".",
"onreadystatechange",
"=",
"el",
".",
"onerror",
"=",
"''",
";",
"success",
"(",
")",
";",
"}",
"}"
] |
initial script processing
|
[
"initial",
"script",
"processing"
] |
0e4884bb1c95b15be950b8f4474393ac042ecb24
|
https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/ext/curl/curl.js#L694-L706
|
train
|
rniemeyer/knockout-amd-helpers
|
ext/curl/curl.js
|
CurlApi
|
function CurlApi (ids, callback, errback, waitFor) {
var then, ctx;
ctx = core.createContext(userCfg, undef, [].concat(ids));
this['then'] = then = function (resolved, rejected) {
when(ctx,
// return the dependencies as arguments, not an array
function (deps) {
if (resolved) resolved.apply(undef, deps);
},
// just throw if the dev didn't specify an error handler
function (ex) {
if (rejected) rejected(ex); else throw ex;
}
);
return this;
};
this['next'] = function (ids, cb, eb) {
// chain api
return new CurlApi(ids, cb, eb, ctx);
};
this['config'] = _config;
if (callback || errback) then(callback, errback);
when(waitFor, function () { core.getDeps(ctx); });
}
|
javascript
|
function CurlApi (ids, callback, errback, waitFor) {
var then, ctx;
ctx = core.createContext(userCfg, undef, [].concat(ids));
this['then'] = then = function (resolved, rejected) {
when(ctx,
// return the dependencies as arguments, not an array
function (deps) {
if (resolved) resolved.apply(undef, deps);
},
// just throw if the dev didn't specify an error handler
function (ex) {
if (rejected) rejected(ex); else throw ex;
}
);
return this;
};
this['next'] = function (ids, cb, eb) {
// chain api
return new CurlApi(ids, cb, eb, ctx);
};
this['config'] = _config;
if (callback || errback) then(callback, errback);
when(waitFor, function () { core.getDeps(ctx); });
}
|
[
"function",
"CurlApi",
"(",
"ids",
",",
"callback",
",",
"errback",
",",
"waitFor",
")",
"{",
"var",
"then",
",",
"ctx",
";",
"ctx",
"=",
"core",
".",
"createContext",
"(",
"userCfg",
",",
"undef",
",",
"[",
"]",
".",
"concat",
"(",
"ids",
")",
")",
";",
"this",
"[",
"'then'",
"]",
"=",
"then",
"=",
"function",
"(",
"resolved",
",",
"rejected",
")",
"{",
"when",
"(",
"ctx",
",",
"function",
"(",
"deps",
")",
"{",
"if",
"(",
"resolved",
")",
"resolved",
".",
"apply",
"(",
"undef",
",",
"deps",
")",
";",
"}",
",",
"function",
"(",
"ex",
")",
"{",
"if",
"(",
"rejected",
")",
"rejected",
"(",
"ex",
")",
";",
"else",
"throw",
"ex",
";",
"}",
")",
";",
"return",
"this",
";",
"}",
";",
"this",
"[",
"'next'",
"]",
"=",
"function",
"(",
"ids",
",",
"cb",
",",
"eb",
")",
"{",
"return",
"new",
"CurlApi",
"(",
"ids",
",",
"cb",
",",
"eb",
",",
"ctx",
")",
";",
"}",
";",
"this",
"[",
"'config'",
"]",
"=",
"_config",
";",
"if",
"(",
"callback",
"||",
"errback",
")",
"then",
"(",
"callback",
",",
"errback",
")",
";",
"when",
"(",
"waitFor",
",",
"function",
"(",
")",
"{",
"core",
".",
"getDeps",
"(",
"ctx",
")",
";",
"}",
")",
";",
"}"
] |
thanks to Joop Ringelberg for helping troubleshoot the API
|
[
"thanks",
"to",
"Joop",
"Ringelberg",
"for",
"helping",
"troubleshoot",
"the",
"API"
] |
0e4884bb1c95b15be950b8f4474393ac042ecb24
|
https://github.com/rniemeyer/knockout-amd-helpers/blob/0e4884bb1c95b15be950b8f4474393ac042ecb24/ext/curl/curl.js#L1153-L1176
|
train
|
cburgdorf/grunt-html-snapshot
|
phantomjs/bridge.js
|
function (arg) {
var args = Array.isArray(arg) ? arg : [].slice.call(arguments);
var channel = options.taskChannelPrefix + '.' + args[0];
args[0] = channel;
fs.write(tmpfile, JSON.stringify(args) + "\n", "a");
}
|
javascript
|
function (arg) {
var args = Array.isArray(arg) ? arg : [].slice.call(arguments);
var channel = options.taskChannelPrefix + '.' + args[0];
args[0] = channel;
fs.write(tmpfile, JSON.stringify(args) + "\n", "a");
}
|
[
"function",
"(",
"arg",
")",
"{",
"var",
"args",
"=",
"Array",
".",
"isArray",
"(",
"arg",
")",
"?",
"arg",
":",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"channel",
"=",
"options",
".",
"taskChannelPrefix",
"+",
"'.'",
"+",
"args",
"[",
"0",
"]",
";",
"args",
"[",
"0",
"]",
"=",
"channel",
";",
"fs",
".",
"write",
"(",
"tmpfile",
",",
"JSON",
".",
"stringify",
"(",
"args",
")",
"+",
"\"\\n\"",
",",
"\\n",
")",
";",
"}"
] |
Messages are sent to the parent by appending them to the tempfile. NOTE, the tempfile appears to be shared between asynchronously running grunt tasks
|
[
"Messages",
"are",
"sent",
"to",
"the",
"parent",
"by",
"appending",
"them",
"to",
"the",
"tempfile",
".",
"NOTE",
"the",
"tempfile",
"appears",
"to",
"be",
"shared",
"between",
"asynchronously",
"running",
"grunt",
"tasks"
] |
c92ba26600414af1b936cd550d394a59dbf120fc
|
https://github.com/cburgdorf/grunt-html-snapshot/blob/c92ba26600414af1b936cd550d394a59dbf120fc/phantomjs/bridge.js#L15-L20
|
train
|
|
yahoo/ycb
|
index.js
|
function(contextObj, options) {
options = options ? mergeDeep(this.options, options, true) : this.options;
var context = this._parseContext(contextObj);
var subKey = options.applySubstitutions !== false ? 'subbed': 'unsubbed';
var collector = this.masterDelta ? cloneDeep(this.masterDelta[subKey]) : {};
this._readHelper(this.tree, 0, context, collector, subKey);
if(collector.__ycb_source__) {
return omit(collector, '__ycb_source__');
}
return collector;
}
|
javascript
|
function(contextObj, options) {
options = options ? mergeDeep(this.options, options, true) : this.options;
var context = this._parseContext(contextObj);
var subKey = options.applySubstitutions !== false ? 'subbed': 'unsubbed';
var collector = this.masterDelta ? cloneDeep(this.masterDelta[subKey]) : {};
this._readHelper(this.tree, 0, context, collector, subKey);
if(collector.__ycb_source__) {
return omit(collector, '__ycb_source__');
}
return collector;
}
|
[
"function",
"(",
"contextObj",
",",
"options",
")",
"{",
"options",
"=",
"options",
"?",
"mergeDeep",
"(",
"this",
".",
"options",
",",
"options",
",",
"true",
")",
":",
"this",
".",
"options",
";",
"var",
"context",
"=",
"this",
".",
"_parseContext",
"(",
"contextObj",
")",
";",
"var",
"subKey",
"=",
"options",
".",
"applySubstitutions",
"!==",
"false",
"?",
"'subbed'",
":",
"'unsubbed'",
";",
"var",
"collector",
"=",
"this",
".",
"masterDelta",
"?",
"cloneDeep",
"(",
"this",
".",
"masterDelta",
"[",
"subKey",
"]",
")",
":",
"{",
"}",
";",
"this",
".",
"_readHelper",
"(",
"this",
".",
"tree",
",",
"0",
",",
"context",
",",
"collector",
",",
"subKey",
")",
";",
"if",
"(",
"collector",
".",
"__ycb_source__",
")",
"{",
"return",
"omit",
"(",
"collector",
",",
"'__ycb_source__'",
")",
";",
"}",
"return",
"collector",
";",
"}"
] |
Read the file.
@method read
@param contextObj {object}
@param options {object}
@return {object}
|
[
"Read",
"the",
"file",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L84-L94
|
train
|
|
yahoo/ycb
|
index.js
|
function(cur, depth, context, collector, subKey) {
if(depth === context.length) {
mergeDeep(cur[subKey], collector, false);
return;
}
var value = context[depth];
if(value.constructor !== Array) {
var keys = this.precedenceMap[value];
var n = keys.length;
for(var j=0; j<n; j++) {
if(cur[keys[j]] !== undefined) {
this._readHelper(cur[keys[j]], depth+1, context, collector, subKey);
}
}
} else {
var seen = {};
var i = value.length;
while(i--) {
keys = this.precedenceMap[value[i]];
n = keys.length;
for(j=0; j<n; j++) {
if(cur[keys[j]] !== undefined && seen[keys[j]] === undefined) {
this._readHelper(cur[keys[j]], depth+1, context, collector, subKey);
seen[keys[j]] = true;
}
}
}
}
}
|
javascript
|
function(cur, depth, context, collector, subKey) {
if(depth === context.length) {
mergeDeep(cur[subKey], collector, false);
return;
}
var value = context[depth];
if(value.constructor !== Array) {
var keys = this.precedenceMap[value];
var n = keys.length;
for(var j=0; j<n; j++) {
if(cur[keys[j]] !== undefined) {
this._readHelper(cur[keys[j]], depth+1, context, collector, subKey);
}
}
} else {
var seen = {};
var i = value.length;
while(i--) {
keys = this.precedenceMap[value[i]];
n = keys.length;
for(j=0; j<n; j++) {
if(cur[keys[j]] !== undefined && seen[keys[j]] === undefined) {
this._readHelper(cur[keys[j]], depth+1, context, collector, subKey);
seen[keys[j]] = true;
}
}
}
}
}
|
[
"function",
"(",
"cur",
",",
"depth",
",",
"context",
",",
"collector",
",",
"subKey",
")",
"{",
"if",
"(",
"depth",
"===",
"context",
".",
"length",
")",
"{",
"mergeDeep",
"(",
"cur",
"[",
"subKey",
"]",
",",
"collector",
",",
"false",
")",
";",
"return",
";",
"}",
"var",
"value",
"=",
"context",
"[",
"depth",
"]",
";",
"if",
"(",
"value",
".",
"constructor",
"!==",
"Array",
")",
"{",
"var",
"keys",
"=",
"this",
".",
"precedenceMap",
"[",
"value",
"]",
";",
"var",
"n",
"=",
"keys",
".",
"length",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"if",
"(",
"cur",
"[",
"keys",
"[",
"j",
"]",
"]",
"!==",
"undefined",
")",
"{",
"this",
".",
"_readHelper",
"(",
"cur",
"[",
"keys",
"[",
"j",
"]",
"]",
",",
"depth",
"+",
"1",
",",
"context",
",",
"collector",
",",
"subKey",
")",
";",
"}",
"}",
"}",
"else",
"{",
"var",
"seen",
"=",
"{",
"}",
";",
"var",
"i",
"=",
"value",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"keys",
"=",
"this",
".",
"precedenceMap",
"[",
"value",
"[",
"i",
"]",
"]",
";",
"n",
"=",
"keys",
".",
"length",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"if",
"(",
"cur",
"[",
"keys",
"[",
"j",
"]",
"]",
"!==",
"undefined",
"&&",
"seen",
"[",
"keys",
"[",
"j",
"]",
"]",
"===",
"undefined",
")",
"{",
"this",
".",
"_readHelper",
"(",
"cur",
"[",
"keys",
"[",
"j",
"]",
"]",
",",
"depth",
"+",
"1",
",",
"context",
",",
"collector",
",",
"subKey",
")",
";",
"seen",
"[",
"keys",
"[",
"j",
"]",
"]",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"}"
] |
Recurse through the tree merging configs that apply to the given context.
@param cur {object} the current node.
@param depth {int} current depth in tree.
@param context {array} the context in internal format.
@param collector {object} the config we merge onto.
@param subKey {string} determines if substituted or non-substituted configs are used.
@private
|
[
"Recurse",
"through",
"the",
"tree",
"merging",
"configs",
"that",
"apply",
"to",
"the",
"given",
"context",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L105-L133
|
train
|
|
yahoo/ycb
|
index.js
|
function(contextObj, options) {
var context = this._parseContext(contextObj);
var subKey = options.applySubstitutions !== false ? 'subbed': 'unsubbed';
var collector = this.masterDelta ? [this.masterDelta[subKey]] : [];
this._readNoMergeHelper(this.tree, 0, context, collector, subKey);
return cloneDeep(collector);
}
|
javascript
|
function(contextObj, options) {
var context = this._parseContext(contextObj);
var subKey = options.applySubstitutions !== false ? 'subbed': 'unsubbed';
var collector = this.masterDelta ? [this.masterDelta[subKey]] : [];
this._readNoMergeHelper(this.tree, 0, context, collector, subKey);
return cloneDeep(collector);
}
|
[
"function",
"(",
"contextObj",
",",
"options",
")",
"{",
"var",
"context",
"=",
"this",
".",
"_parseContext",
"(",
"contextObj",
")",
";",
"var",
"subKey",
"=",
"options",
".",
"applySubstitutions",
"!==",
"false",
"?",
"'subbed'",
":",
"'unsubbed'",
";",
"var",
"collector",
"=",
"this",
".",
"masterDelta",
"?",
"[",
"this",
".",
"masterDelta",
"[",
"subKey",
"]",
"]",
":",
"[",
"]",
";",
"this",
".",
"_readNoMergeHelper",
"(",
"this",
".",
"tree",
",",
"0",
",",
"context",
",",
"collector",
",",
"subKey",
")",
";",
"return",
"cloneDeep",
"(",
"collector",
")",
";",
"}"
] |
Read the configs for the given context and return them in order general to specific.
@method read
@param contextObj {object}
@param options {object}
@return {array}
|
[
"Read",
"the",
"configs",
"for",
"the",
"given",
"context",
"and",
"return",
"them",
"in",
"order",
"general",
"to",
"specific",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L142-L148
|
train
|
|
yahoo/ycb
|
index.js
|
function(cur, depth, context, collector, subKey) {
if(depth === context.length) {
collector.push(cur[subKey]);
return;
}
var value = context[depth];
if(value.constructor !== Array) {
var keys = this.precedenceMap[value];
var n = keys.length;
for(var j=0; j<n; j++) {
if(cur[keys[j]] !== undefined) {
this._readNoMergeHelper(cur[keys[j]], depth+1, context, collector, subKey);
}
}
} else {
var seen = {};
var i = value.length;
while(i--) {
keys = this.precedenceMap[value[i]];
n = keys.length;
for(j=0; j<n; j++) {
if(cur[keys[j]] !== undefined && seen[keys[j]] === undefined) {
this._readNoMergeHelper(cur[keys[j]], depth+1, context, collector, subKey);
seen[keys[j]] = true;
}
}
}
}
}
|
javascript
|
function(cur, depth, context, collector, subKey) {
if(depth === context.length) {
collector.push(cur[subKey]);
return;
}
var value = context[depth];
if(value.constructor !== Array) {
var keys = this.precedenceMap[value];
var n = keys.length;
for(var j=0; j<n; j++) {
if(cur[keys[j]] !== undefined) {
this._readNoMergeHelper(cur[keys[j]], depth+1, context, collector, subKey);
}
}
} else {
var seen = {};
var i = value.length;
while(i--) {
keys = this.precedenceMap[value[i]];
n = keys.length;
for(j=0; j<n; j++) {
if(cur[keys[j]] !== undefined && seen[keys[j]] === undefined) {
this._readNoMergeHelper(cur[keys[j]], depth+1, context, collector, subKey);
seen[keys[j]] = true;
}
}
}
}
}
|
[
"function",
"(",
"cur",
",",
"depth",
",",
"context",
",",
"collector",
",",
"subKey",
")",
"{",
"if",
"(",
"depth",
"===",
"context",
".",
"length",
")",
"{",
"collector",
".",
"push",
"(",
"cur",
"[",
"subKey",
"]",
")",
";",
"return",
";",
"}",
"var",
"value",
"=",
"context",
"[",
"depth",
"]",
";",
"if",
"(",
"value",
".",
"constructor",
"!==",
"Array",
")",
"{",
"var",
"keys",
"=",
"this",
".",
"precedenceMap",
"[",
"value",
"]",
";",
"var",
"n",
"=",
"keys",
".",
"length",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"if",
"(",
"cur",
"[",
"keys",
"[",
"j",
"]",
"]",
"!==",
"undefined",
")",
"{",
"this",
".",
"_readNoMergeHelper",
"(",
"cur",
"[",
"keys",
"[",
"j",
"]",
"]",
",",
"depth",
"+",
"1",
",",
"context",
",",
"collector",
",",
"subKey",
")",
";",
"}",
"}",
"}",
"else",
"{",
"var",
"seen",
"=",
"{",
"}",
";",
"var",
"i",
"=",
"value",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"keys",
"=",
"this",
".",
"precedenceMap",
"[",
"value",
"[",
"i",
"]",
"]",
";",
"n",
"=",
"keys",
".",
"length",
";",
"for",
"(",
"j",
"=",
"0",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"if",
"(",
"cur",
"[",
"keys",
"[",
"j",
"]",
"]",
"!==",
"undefined",
"&&",
"seen",
"[",
"keys",
"[",
"j",
"]",
"]",
"===",
"undefined",
")",
"{",
"this",
".",
"_readNoMergeHelper",
"(",
"cur",
"[",
"keys",
"[",
"j",
"]",
"]",
",",
"depth",
"+",
"1",
",",
"context",
",",
"collector",
",",
"subKey",
")",
";",
"seen",
"[",
"keys",
"[",
"j",
"]",
"]",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"}"
] |
Recurse through the tree collecting configs that apply to the given context.
@param cur {object} the current node.
@param depth {number} current depth in tree.
@param context {array} the context in internal format.
@param collector {array} the array we push configs to.
@param subKey {string} determines if substituted or non-substituted configs are used.
@private
|
[
"Recurse",
"through",
"the",
"tree",
"collecting",
"configs",
"that",
"apply",
"to",
"the",
"given",
"context",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L159-L187
|
train
|
|
yahoo/ycb
|
index.js
|
function(contextObj) {
if(contextObj === undefined) {
contextObj = {};
}
var context = new Array(this.dimensionsList.length);
for(var i=0; i<this.dimensionsList.length; i++) {
var dimension = this.dimensionsList[i];
if(contextObj.hasOwnProperty(dimension)) {
var value = contextObj[dimension];
if(value.constructor === Array) {
var newValue = [];
for(var j=0; j<value.length; j++) {
var numValue = this.valueToNumber[dimension][value[j]];
if(numValue !== undefined) {
newValue.push(numValue);
}
}
if(newValue.length) {
context[i] = newValue;
continue;
}
} else {
numValue = this.valueToNumber[dimension][value];
if(numValue !== undefined) {
context[i] = numValue;
continue;
}
}
}
context[i] = 0;
}
return context;
}
|
javascript
|
function(contextObj) {
if(contextObj === undefined) {
contextObj = {};
}
var context = new Array(this.dimensionsList.length);
for(var i=0; i<this.dimensionsList.length; i++) {
var dimension = this.dimensionsList[i];
if(contextObj.hasOwnProperty(dimension)) {
var value = contextObj[dimension];
if(value.constructor === Array) {
var newValue = [];
for(var j=0; j<value.length; j++) {
var numValue = this.valueToNumber[dimension][value[j]];
if(numValue !== undefined) {
newValue.push(numValue);
}
}
if(newValue.length) {
context[i] = newValue;
continue;
}
} else {
numValue = this.valueToNumber[dimension][value];
if(numValue !== undefined) {
context[i] = numValue;
continue;
}
}
}
context[i] = 0;
}
return context;
}
|
[
"function",
"(",
"contextObj",
")",
"{",
"if",
"(",
"contextObj",
"===",
"undefined",
")",
"{",
"contextObj",
"=",
"{",
"}",
";",
"}",
"var",
"context",
"=",
"new",
"Array",
"(",
"this",
".",
"dimensionsList",
".",
"length",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"dimensionsList",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"dimension",
"=",
"this",
".",
"dimensionsList",
"[",
"i",
"]",
";",
"if",
"(",
"contextObj",
".",
"hasOwnProperty",
"(",
"dimension",
")",
")",
"{",
"var",
"value",
"=",
"contextObj",
"[",
"dimension",
"]",
";",
"if",
"(",
"value",
".",
"constructor",
"===",
"Array",
")",
"{",
"var",
"newValue",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"value",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"numValue",
"=",
"this",
".",
"valueToNumber",
"[",
"dimension",
"]",
"[",
"value",
"[",
"j",
"]",
"]",
";",
"if",
"(",
"numValue",
"!==",
"undefined",
")",
"{",
"newValue",
".",
"push",
"(",
"numValue",
")",
";",
"}",
"}",
"if",
"(",
"newValue",
".",
"length",
")",
"{",
"context",
"[",
"i",
"]",
"=",
"newValue",
";",
"continue",
";",
"}",
"}",
"else",
"{",
"numValue",
"=",
"this",
".",
"valueToNumber",
"[",
"dimension",
"]",
"[",
"value",
"]",
";",
"if",
"(",
"numValue",
"!==",
"undefined",
")",
"{",
"context",
"[",
"i",
"]",
"=",
"numValue",
";",
"continue",
";",
"}",
"}",
"}",
"context",
"[",
"i",
"]",
"=",
"0",
";",
"}",
"return",
"context",
";",
"}"
] |
Converts a context object to equivalent array of numerical values.
@param contextObj {object}
@returns {array}
@private
|
[
"Converts",
"a",
"context",
"object",
"to",
"equivalent",
"array",
"of",
"numerical",
"values",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L196-L228
|
train
|
|
yahoo/ycb
|
index.js
|
function(context) {
var contextObj = {};
for(var i=0; i<context.length; i++) {
if(context[i] !== '0') {
contextObj[this.dimensionsList[i]] = this.numberToValue[context[i]];
}
}
return contextObj;
}
|
javascript
|
function(context) {
var contextObj = {};
for(var i=0; i<context.length; i++) {
if(context[i] !== '0') {
contextObj[this.dimensionsList[i]] = this.numberToValue[context[i]];
}
}
return contextObj;
}
|
[
"function",
"(",
"context",
")",
"{",
"var",
"contextObj",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"context",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"context",
"[",
"i",
"]",
"!==",
"'0'",
")",
"{",
"contextObj",
"[",
"this",
".",
"dimensionsList",
"[",
"i",
"]",
"]",
"=",
"this",
".",
"numberToValue",
"[",
"context",
"[",
"i",
"]",
"]",
";",
"}",
"}",
"return",
"contextObj",
";",
"}"
] |
Convert internal num array context to context object.
@param context {array}
@returns {object}
@private
|
[
"Convert",
"internal",
"num",
"array",
"context",
"to",
"context",
"object",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L236-L244
|
train
|
|
yahoo/ycb
|
index.js
|
function(config) {
for(var i=0; i<config.length; i++) {
if(config[i].dimensions) {
var dimensions = config[i].dimensions;
this.dimensions = dimensions;
var allDimensions = {};
for(var j=0; j<dimensions.length; j++) {
var name;
for(name in dimensions[j]) {
allDimensions[name] = j;
break;
}
}
return [dimensions, allDimensions];
}
}
return [[], {}];
}
|
javascript
|
function(config) {
for(var i=0; i<config.length; i++) {
if(config[i].dimensions) {
var dimensions = config[i].dimensions;
this.dimensions = dimensions;
var allDimensions = {};
for(var j=0; j<dimensions.length; j++) {
var name;
for(name in dimensions[j]) {
allDimensions[name] = j;
break;
}
}
return [dimensions, allDimensions];
}
}
return [[], {}];
}
|
[
"function",
"(",
"config",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"config",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"config",
"[",
"i",
"]",
".",
"dimensions",
")",
"{",
"var",
"dimensions",
"=",
"config",
"[",
"i",
"]",
".",
"dimensions",
";",
"this",
".",
"dimensions",
"=",
"dimensions",
";",
"var",
"allDimensions",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"dimensions",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"name",
";",
"for",
"(",
"name",
"in",
"dimensions",
"[",
"j",
"]",
")",
"{",
"allDimensions",
"[",
"name",
"]",
"=",
"j",
";",
"break",
";",
"}",
"}",
"return",
"[",
"dimensions",
",",
"allDimensions",
"]",
";",
"}",
"}",
"return",
"[",
"[",
"]",
",",
"{",
"}",
"]",
";",
"}"
] |
Extract dimensions object and dimension -> number map
@param config {object}
@returns {array}
@private
|
[
"Extract",
"dimensions",
"object",
"and",
"dimension",
"-",
">",
"number",
"map"
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L280-L297
|
train
|
|
yahoo/ycb
|
index.js
|
function(config, allDimensions, height) {
var usedDimensions = {};
var usedValues = {};
var contexts = {};
configLoop:
for(var i=0; i<config.length; i++) {
if (config[i].settings) {
var setting = config[i].settings;
if(setting.length === 0 ) {
continue;
}
if(setting[0] === 'master') {
if(this.masterDelta !== undefined) {
this.masterDelta = mergeDeep(this._buildDelta(config[i]), this.masterDelta, true);
} else {
this.masterDelta = this._buildDelta(config[i]);
}
continue;
}
var context = new Array(height);
for(var q=0; q<height; q++) {
context[q] = DEFAULT;
}
for(var j=0; j<setting.length; j++) {
var kv = setting[j].split(':');
var dim = kv[0];
var index = allDimensions[dim];
if(index === undefined) {
console.log('WARNING: invalid dimension "' + dim +
'" in settings ' + JSON.stringify(setting));
continue configLoop;
}
usedDimensions[dim] = 1;
usedValues[dim] = usedValues[dim] || {};
if(kv[1].indexOf(',') === -1) {
usedValues[dim][kv[1]] = 1;
context[index] = kv[1];
} else {
var vals = kv[1].split(',');
context[index] = vals;
for(var k=0; k<vals.length; k++) {
usedValues[dim][vals[k]] = 1;
}
}
}
contexts[i] = context;
}
}
return [usedDimensions, usedValues, contexts];
}
|
javascript
|
function(config, allDimensions, height) {
var usedDimensions = {};
var usedValues = {};
var contexts = {};
configLoop:
for(var i=0; i<config.length; i++) {
if (config[i].settings) {
var setting = config[i].settings;
if(setting.length === 0 ) {
continue;
}
if(setting[0] === 'master') {
if(this.masterDelta !== undefined) {
this.masterDelta = mergeDeep(this._buildDelta(config[i]), this.masterDelta, true);
} else {
this.masterDelta = this._buildDelta(config[i]);
}
continue;
}
var context = new Array(height);
for(var q=0; q<height; q++) {
context[q] = DEFAULT;
}
for(var j=0; j<setting.length; j++) {
var kv = setting[j].split(':');
var dim = kv[0];
var index = allDimensions[dim];
if(index === undefined) {
console.log('WARNING: invalid dimension "' + dim +
'" in settings ' + JSON.stringify(setting));
continue configLoop;
}
usedDimensions[dim] = 1;
usedValues[dim] = usedValues[dim] || {};
if(kv[1].indexOf(',') === -1) {
usedValues[dim][kv[1]] = 1;
context[index] = kv[1];
} else {
var vals = kv[1].split(',');
context[index] = vals;
for(var k=0; k<vals.length; k++) {
usedValues[dim][vals[k]] = 1;
}
}
}
contexts[i] = context;
}
}
return [usedDimensions, usedValues, contexts];
}
|
[
"function",
"(",
"config",
",",
"allDimensions",
",",
"height",
")",
"{",
"var",
"usedDimensions",
"=",
"{",
"}",
";",
"var",
"usedValues",
"=",
"{",
"}",
";",
"var",
"contexts",
"=",
"{",
"}",
";",
"configLoop",
":",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"config",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"config",
"[",
"i",
"]",
".",
"settings",
")",
"{",
"var",
"setting",
"=",
"config",
"[",
"i",
"]",
".",
"settings",
";",
"if",
"(",
"setting",
".",
"length",
"===",
"0",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"setting",
"[",
"0",
"]",
"===",
"'master'",
")",
"{",
"if",
"(",
"this",
".",
"masterDelta",
"!==",
"undefined",
")",
"{",
"this",
".",
"masterDelta",
"=",
"mergeDeep",
"(",
"this",
".",
"_buildDelta",
"(",
"config",
"[",
"i",
"]",
")",
",",
"this",
".",
"masterDelta",
",",
"true",
")",
";",
"}",
"else",
"{",
"this",
".",
"masterDelta",
"=",
"this",
".",
"_buildDelta",
"(",
"config",
"[",
"i",
"]",
")",
";",
"}",
"continue",
";",
"}",
"var",
"context",
"=",
"new",
"Array",
"(",
"height",
")",
";",
"for",
"(",
"var",
"q",
"=",
"0",
";",
"q",
"<",
"height",
";",
"q",
"++",
")",
"{",
"context",
"[",
"q",
"]",
"=",
"DEFAULT",
";",
"}",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"setting",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"kv",
"=",
"setting",
"[",
"j",
"]",
".",
"split",
"(",
"':'",
")",
";",
"var",
"dim",
"=",
"kv",
"[",
"0",
"]",
";",
"var",
"index",
"=",
"allDimensions",
"[",
"dim",
"]",
";",
"if",
"(",
"index",
"===",
"undefined",
")",
"{",
"console",
".",
"log",
"(",
"'WARNING: invalid dimension \"'",
"+",
"dim",
"+",
"'\" in settings '",
"+",
"JSON",
".",
"stringify",
"(",
"setting",
")",
")",
";",
"continue",
"configLoop",
";",
"}",
"usedDimensions",
"[",
"dim",
"]",
"=",
"1",
";",
"usedValues",
"[",
"dim",
"]",
"=",
"usedValues",
"[",
"dim",
"]",
"||",
"{",
"}",
";",
"if",
"(",
"kv",
"[",
"1",
"]",
".",
"indexOf",
"(",
"','",
")",
"===",
"-",
"1",
")",
"{",
"usedValues",
"[",
"dim",
"]",
"[",
"kv",
"[",
"1",
"]",
"]",
"=",
"1",
";",
"context",
"[",
"index",
"]",
"=",
"kv",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"var",
"vals",
"=",
"kv",
"[",
"1",
"]",
".",
"split",
"(",
"','",
")",
";",
"context",
"[",
"index",
"]",
"=",
"vals",
";",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"vals",
".",
"length",
";",
"k",
"++",
")",
"{",
"usedValues",
"[",
"dim",
"]",
"[",
"vals",
"[",
"k",
"]",
"]",
"=",
"1",
";",
"}",
"}",
"}",
"contexts",
"[",
"i",
"]",
"=",
"context",
";",
"}",
"}",
"return",
"[",
"usedDimensions",
",",
"usedValues",
",",
"contexts",
"]",
";",
"}"
] |
Evaluate settings and determine which dimensions and values are used. Check for unknown dimensions.
Set the master config if it exist.
@param config {object}
@param allDimensions {object}
@param height {number}
@returns {array}
@private
|
[
"Evaluate",
"settings",
"and",
"determine",
"which",
"dimensions",
"and",
"values",
"are",
"used",
".",
"Check",
"for",
"unknown",
"dimensions",
".",
"Set",
"the",
"master",
"config",
"if",
"it",
"exist",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L308-L358
|
train
|
|
yahoo/ycb
|
index.js
|
function(config) {
config = omit(config, 'settings');
var subbed = cloneDeep(config);
var subFlag = this._applySubstitutions(subbed, null, null);
var unsubbed = subFlag ? config : subbed;
return {subbed:subbed, unsubbed:unsubbed};
}
|
javascript
|
function(config) {
config = omit(config, 'settings');
var subbed = cloneDeep(config);
var subFlag = this._applySubstitutions(subbed, null, null);
var unsubbed = subFlag ? config : subbed;
return {subbed:subbed, unsubbed:unsubbed};
}
|
[
"function",
"(",
"config",
")",
"{",
"config",
"=",
"omit",
"(",
"config",
",",
"'settings'",
")",
";",
"var",
"subbed",
"=",
"cloneDeep",
"(",
"config",
")",
";",
"var",
"subFlag",
"=",
"this",
".",
"_applySubstitutions",
"(",
"subbed",
",",
"null",
",",
"null",
")",
";",
"var",
"unsubbed",
"=",
"subFlag",
"?",
"config",
":",
"subbed",
";",
"return",
"{",
"subbed",
":",
"subbed",
",",
"unsubbed",
":",
"unsubbed",
"}",
";",
"}"
] |
Convert config to delta.
@param config {object}
@returns {object}
@private
|
[
"Convert",
"config",
"to",
"delta",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L366-L372
|
train
|
|
yahoo/ycb
|
index.js
|
function(dimensions, usedDimensions, usedValues) {
var activeDimensions = new Array(dimensions.length);
var valueCounter = 1;
for(var i=0; i<dimensions.length; i++) {
var dimensionName;
for(dimensionName in dimensions[i]){break}
if(usedDimensions[dimensionName] === undefined) {
activeDimensions[i] = 0;
continue;
}
activeDimensions[i] = 1;
this.dimensionsList.push(dimensionName);
var labelCollector = {};
valueCounter = this._dimensionWalk(dimensions[i][dimensionName], usedValues[dimensionName],
valueCounter, [0], this.precedenceMap, labelCollector, this.numberToValue);
this.valueToNumber[dimensionName] = labelCollector;
}
return activeDimensions;
}
|
javascript
|
function(dimensions, usedDimensions, usedValues) {
var activeDimensions = new Array(dimensions.length);
var valueCounter = 1;
for(var i=0; i<dimensions.length; i++) {
var dimensionName;
for(dimensionName in dimensions[i]){break}
if(usedDimensions[dimensionName] === undefined) {
activeDimensions[i] = 0;
continue;
}
activeDimensions[i] = 1;
this.dimensionsList.push(dimensionName);
var labelCollector = {};
valueCounter = this._dimensionWalk(dimensions[i][dimensionName], usedValues[dimensionName],
valueCounter, [0], this.precedenceMap, labelCollector, this.numberToValue);
this.valueToNumber[dimensionName] = labelCollector;
}
return activeDimensions;
}
|
[
"function",
"(",
"dimensions",
",",
"usedDimensions",
",",
"usedValues",
")",
"{",
"var",
"activeDimensions",
"=",
"new",
"Array",
"(",
"dimensions",
".",
"length",
")",
";",
"var",
"valueCounter",
"=",
"1",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"dimensions",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"dimensionName",
";",
"for",
"(",
"dimensionName",
"in",
"dimensions",
"[",
"i",
"]",
")",
"{",
"break",
"}",
"if",
"(",
"usedDimensions",
"[",
"dimensionName",
"]",
"===",
"undefined",
")",
"{",
"activeDimensions",
"[",
"i",
"]",
"=",
"0",
";",
"continue",
";",
"}",
"activeDimensions",
"[",
"i",
"]",
"=",
"1",
";",
"this",
".",
"dimensionsList",
".",
"push",
"(",
"dimensionName",
")",
";",
"var",
"labelCollector",
"=",
"{",
"}",
";",
"valueCounter",
"=",
"this",
".",
"_dimensionWalk",
"(",
"dimensions",
"[",
"i",
"]",
"[",
"dimensionName",
"]",
",",
"usedValues",
"[",
"dimensionName",
"]",
",",
"valueCounter",
",",
"[",
"0",
"]",
",",
"this",
".",
"precedenceMap",
",",
"labelCollector",
",",
"this",
".",
"numberToValue",
")",
";",
"this",
".",
"valueToNumber",
"[",
"dimensionName",
"]",
"=",
"labelCollector",
";",
"}",
"return",
"activeDimensions",
";",
"}"
] |
Evaluate dimensions and omit unused dimensions.
@param dimensions {array}
@param usedDimensions {object}
@param usedValues {object}
@returns {array}
@private
|
[
"Evaluate",
"dimensions",
"and",
"omit",
"unused",
"dimensions",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L382-L400
|
train
|
|
yahoo/ycb
|
index.js
|
function(fullContext, activeDimensions, usedValues, setting) {
var height = this.dimensionsList.length;
var newContext = new Array(height);
for(var i=0; i<height; i++) {
newContext[i] = 0;
}
var activeIndex = 0;
for(i=0; i<fullContext.length; i++) {
if(activeDimensions[i]) {
var dimensionName = this.dimensionsList[activeIndex];
var contextValue = fullContext[i];
if(contextValue.constructor === Array) {
var newValue = [];
for(var k=0; k<contextValue.length; k++) {
var valueChunk = contextValue[k];
if(usedValues[dimensionName][valueChunk] === 2) {
newValue.push(this.valueToNumber[dimensionName][valueChunk]);
} else {
console.log('WARNING: invalid value "' + valueChunk + '" for dimension "' +
dimensionName + '" in settings ' + JSON.stringify(setting));
}
}
if(newValue.length === 0) {
return;
}
newContext[activeIndex] = newValue;
} else {
if(usedValues[dimensionName][contextValue] === 2) {
newContext[activeIndex] = this.valueToNumber[dimensionName][contextValue];
} else if(contextValue !== DEFAULT) {
console.log('WARNING: invalid value "' + contextValue + '" for dimension "' +
dimensionName + '" in settings ' + JSON.stringify(setting));
return;
}
}
activeIndex++;
}
}
return newContext;
}
|
javascript
|
function(fullContext, activeDimensions, usedValues, setting) {
var height = this.dimensionsList.length;
var newContext = new Array(height);
for(var i=0; i<height; i++) {
newContext[i] = 0;
}
var activeIndex = 0;
for(i=0; i<fullContext.length; i++) {
if(activeDimensions[i]) {
var dimensionName = this.dimensionsList[activeIndex];
var contextValue = fullContext[i];
if(contextValue.constructor === Array) {
var newValue = [];
for(var k=0; k<contextValue.length; k++) {
var valueChunk = contextValue[k];
if(usedValues[dimensionName][valueChunk] === 2) {
newValue.push(this.valueToNumber[dimensionName][valueChunk]);
} else {
console.log('WARNING: invalid value "' + valueChunk + '" for dimension "' +
dimensionName + '" in settings ' + JSON.stringify(setting));
}
}
if(newValue.length === 0) {
return;
}
newContext[activeIndex] = newValue;
} else {
if(usedValues[dimensionName][contextValue] === 2) {
newContext[activeIndex] = this.valueToNumber[dimensionName][contextValue];
} else if(contextValue !== DEFAULT) {
console.log('WARNING: invalid value "' + contextValue + '" for dimension "' +
dimensionName + '" in settings ' + JSON.stringify(setting));
return;
}
}
activeIndex++;
}
}
return newContext;
}
|
[
"function",
"(",
"fullContext",
",",
"activeDimensions",
",",
"usedValues",
",",
"setting",
")",
"{",
"var",
"height",
"=",
"this",
".",
"dimensionsList",
".",
"length",
";",
"var",
"newContext",
"=",
"new",
"Array",
"(",
"height",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"height",
";",
"i",
"++",
")",
"{",
"newContext",
"[",
"i",
"]",
"=",
"0",
";",
"}",
"var",
"activeIndex",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"fullContext",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"activeDimensions",
"[",
"i",
"]",
")",
"{",
"var",
"dimensionName",
"=",
"this",
".",
"dimensionsList",
"[",
"activeIndex",
"]",
";",
"var",
"contextValue",
"=",
"fullContext",
"[",
"i",
"]",
";",
"if",
"(",
"contextValue",
".",
"constructor",
"===",
"Array",
")",
"{",
"var",
"newValue",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"contextValue",
".",
"length",
";",
"k",
"++",
")",
"{",
"var",
"valueChunk",
"=",
"contextValue",
"[",
"k",
"]",
";",
"if",
"(",
"usedValues",
"[",
"dimensionName",
"]",
"[",
"valueChunk",
"]",
"===",
"2",
")",
"{",
"newValue",
".",
"push",
"(",
"this",
".",
"valueToNumber",
"[",
"dimensionName",
"]",
"[",
"valueChunk",
"]",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'WARNING: invalid value \"'",
"+",
"valueChunk",
"+",
"'\" for dimension \"'",
"+",
"dimensionName",
"+",
"'\" in settings '",
"+",
"JSON",
".",
"stringify",
"(",
"setting",
")",
")",
";",
"}",
"}",
"if",
"(",
"newValue",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"newContext",
"[",
"activeIndex",
"]",
"=",
"newValue",
";",
"}",
"else",
"{",
"if",
"(",
"usedValues",
"[",
"dimensionName",
"]",
"[",
"contextValue",
"]",
"===",
"2",
")",
"{",
"newContext",
"[",
"activeIndex",
"]",
"=",
"this",
".",
"valueToNumber",
"[",
"dimensionName",
"]",
"[",
"contextValue",
"]",
";",
"}",
"else",
"if",
"(",
"contextValue",
"!==",
"DEFAULT",
")",
"{",
"console",
".",
"log",
"(",
"'WARNING: invalid value \"'",
"+",
"contextValue",
"+",
"'\" for dimension \"'",
"+",
"dimensionName",
"+",
"'\" in settings '",
"+",
"JSON",
".",
"stringify",
"(",
"setting",
")",
")",
";",
"return",
";",
"}",
"}",
"activeIndex",
"++",
";",
"}",
"}",
"return",
"newContext",
";",
"}"
] |
Convert config context and omit invalid dimension values.
@param fullContext {array}
@param activeDimensions {array}
@param usedValues {object}
@param setting {object}
@returns {array}
@private
|
[
"Convert",
"config",
"context",
"and",
"omit",
"invalid",
"dimension",
"values",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L446-L485
|
train
|
|
yahoo/ycb
|
index.js
|
function(root, depth, context, delta) {
var i;
var currentValue = context[depth];
var isMulti = currentValue.constructor === Array;
if(depth === context.length-1) {
if(isMulti) {
for(i=0; i<currentValue.length; i++) {
var curDelta = delta;
if(root[currentValue[i]] !== undefined) {
curDelta = mergeDeep(delta, root[currentValue[i]], true);
}
root[currentValue[i]] = curDelta;
}
} else {
curDelta = delta;
if(root[currentValue] !== undefined) {
curDelta = mergeDeep(delta, root[currentValue], true);
}
root[currentValue] = curDelta;
}
return;
}
if(isMulti){
for(i=0; i<currentValue.length; i++) {
if(root[currentValue[i]] === undefined) {
root[currentValue[i]] = {};
}
this._buildTreeHelper(root[currentValue[i]], depth+1, context, delta);
}
} else {
if(root[currentValue] === undefined) {
root[currentValue] = {};
}
this._buildTreeHelper(root[currentValue], depth+1, context, delta);
}
}
|
javascript
|
function(root, depth, context, delta) {
var i;
var currentValue = context[depth];
var isMulti = currentValue.constructor === Array;
if(depth === context.length-1) {
if(isMulti) {
for(i=0; i<currentValue.length; i++) {
var curDelta = delta;
if(root[currentValue[i]] !== undefined) {
curDelta = mergeDeep(delta, root[currentValue[i]], true);
}
root[currentValue[i]] = curDelta;
}
} else {
curDelta = delta;
if(root[currentValue] !== undefined) {
curDelta = mergeDeep(delta, root[currentValue], true);
}
root[currentValue] = curDelta;
}
return;
}
if(isMulti){
for(i=0; i<currentValue.length; i++) {
if(root[currentValue[i]] === undefined) {
root[currentValue[i]] = {};
}
this._buildTreeHelper(root[currentValue[i]], depth+1, context, delta);
}
} else {
if(root[currentValue] === undefined) {
root[currentValue] = {};
}
this._buildTreeHelper(root[currentValue], depth+1, context, delta);
}
}
|
[
"function",
"(",
"root",
",",
"depth",
",",
"context",
",",
"delta",
")",
"{",
"var",
"i",
";",
"var",
"currentValue",
"=",
"context",
"[",
"depth",
"]",
";",
"var",
"isMulti",
"=",
"currentValue",
".",
"constructor",
"===",
"Array",
";",
"if",
"(",
"depth",
"===",
"context",
".",
"length",
"-",
"1",
")",
"{",
"if",
"(",
"isMulti",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"currentValue",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"curDelta",
"=",
"delta",
";",
"if",
"(",
"root",
"[",
"currentValue",
"[",
"i",
"]",
"]",
"!==",
"undefined",
")",
"{",
"curDelta",
"=",
"mergeDeep",
"(",
"delta",
",",
"root",
"[",
"currentValue",
"[",
"i",
"]",
"]",
",",
"true",
")",
";",
"}",
"root",
"[",
"currentValue",
"[",
"i",
"]",
"]",
"=",
"curDelta",
";",
"}",
"}",
"else",
"{",
"curDelta",
"=",
"delta",
";",
"if",
"(",
"root",
"[",
"currentValue",
"]",
"!==",
"undefined",
")",
"{",
"curDelta",
"=",
"mergeDeep",
"(",
"delta",
",",
"root",
"[",
"currentValue",
"]",
",",
"true",
")",
";",
"}",
"root",
"[",
"currentValue",
"]",
"=",
"curDelta",
";",
"}",
"return",
";",
"}",
"if",
"(",
"isMulti",
")",
"{",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"currentValue",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"root",
"[",
"currentValue",
"[",
"i",
"]",
"]",
"===",
"undefined",
")",
"{",
"root",
"[",
"currentValue",
"[",
"i",
"]",
"]",
"=",
"{",
"}",
";",
"}",
"this",
".",
"_buildTreeHelper",
"(",
"root",
"[",
"currentValue",
"[",
"i",
"]",
"]",
",",
"depth",
"+",
"1",
",",
"context",
",",
"delta",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"root",
"[",
"currentValue",
"]",
"===",
"undefined",
")",
"{",
"root",
"[",
"currentValue",
"]",
"=",
"{",
"}",
";",
"}",
"this",
".",
"_buildTreeHelper",
"(",
"root",
"[",
"currentValue",
"]",
",",
"depth",
"+",
"1",
",",
"context",
",",
"delta",
")",
";",
"}",
"}"
] |
Insert the given context and delta into the tree.
@param root {object}
@param depth {number}
@param context {array}
@param delta {object}
@private
|
[
"Insert",
"the",
"given",
"context",
"and",
"delta",
"into",
"the",
"tree",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L495-L530
|
train
|
|
yahoo/ycb
|
index.js
|
function (config, base, parent) {
var key,
sub,
find,
item;
base = base || config;
parent = parent || {ref: config, key: null};
var subFlag = false;
for (key in config) {
if (config.hasOwnProperty(key)) {
// If the value is an "Object" or an "Array" drill into it
if (isIterable(config[key])) {
// parent param {ref: config, key: key} is a recursion
// pointer that needed only when replacing "keys"
subFlag = this._applySubstitutions(config[key], base, {ref: config, key: key}) || subFlag;
} else {
// Test if the key is a "substitution" key
sub = SUBMATCH.exec(key);
if (sub && (sub[0] === key)) {
subFlag = true;
// Pull out the key to "find"
find = extract(base, sub[1], null);
if (isA(find, Object)) {
// Remove the "substitution" key
delete config[key];
// Add the keys founds
// This should be inline at the point where the "substitution" key was.
// Currently they will be added out of order on the end of the map.
for (item in find) {
if (find.hasOwnProperty(item)) {
if (!parent.ref[parent.key]) {
parent.ref[item] = find[item];
} else {
parent.ref[parent.key][item] = find[item];
}
}
}
} else {
config[key] = '--YCB-SUBSTITUTION-ERROR--';
}
} else if (SUBMATCH.test(config[key])) {
subFlag = true;
// Test if the value is a "substitution" value
// We have a match so lets use it
sub = SUBMATCH.exec(config[key]);
// Pull out the key to "find"
find = sub[1];
// First see if it is the whole value
if (sub[0] === config[key]) {
// Replace the whole value with the value found by the sub string
find = extract(base, find, null);
// If we have an array in an array do it "special like"
if (isA(find, Array) && isA(config, Array)) {
// This has to be done on the parent or the reference is lost
// The whole {ref: config, key: key} is needed only when replacing "keys"
parent.ref[parent.key] = config.slice(0, parseInt(key, 10))
.concat(find)
.concat(config.slice(parseInt(key, 10) + 1));
} else {
config[key] = find;
}
} else {
// If not it's just part of the whole value
config[key] = config[key]
.replace(SUBMATCHES, replacer(base));
}
}
}
}
}
return subFlag;
}
|
javascript
|
function (config, base, parent) {
var key,
sub,
find,
item;
base = base || config;
parent = parent || {ref: config, key: null};
var subFlag = false;
for (key in config) {
if (config.hasOwnProperty(key)) {
// If the value is an "Object" or an "Array" drill into it
if (isIterable(config[key])) {
// parent param {ref: config, key: key} is a recursion
// pointer that needed only when replacing "keys"
subFlag = this._applySubstitutions(config[key], base, {ref: config, key: key}) || subFlag;
} else {
// Test if the key is a "substitution" key
sub = SUBMATCH.exec(key);
if (sub && (sub[0] === key)) {
subFlag = true;
// Pull out the key to "find"
find = extract(base, sub[1], null);
if (isA(find, Object)) {
// Remove the "substitution" key
delete config[key];
// Add the keys founds
// This should be inline at the point where the "substitution" key was.
// Currently they will be added out of order on the end of the map.
for (item in find) {
if (find.hasOwnProperty(item)) {
if (!parent.ref[parent.key]) {
parent.ref[item] = find[item];
} else {
parent.ref[parent.key][item] = find[item];
}
}
}
} else {
config[key] = '--YCB-SUBSTITUTION-ERROR--';
}
} else if (SUBMATCH.test(config[key])) {
subFlag = true;
// Test if the value is a "substitution" value
// We have a match so lets use it
sub = SUBMATCH.exec(config[key]);
// Pull out the key to "find"
find = sub[1];
// First see if it is the whole value
if (sub[0] === config[key]) {
// Replace the whole value with the value found by the sub string
find = extract(base, find, null);
// If we have an array in an array do it "special like"
if (isA(find, Array) && isA(config, Array)) {
// This has to be done on the parent or the reference is lost
// The whole {ref: config, key: key} is needed only when replacing "keys"
parent.ref[parent.key] = config.slice(0, parseInt(key, 10))
.concat(find)
.concat(config.slice(parseInt(key, 10) + 1));
} else {
config[key] = find;
}
} else {
// If not it's just part of the whole value
config[key] = config[key]
.replace(SUBMATCHES, replacer(base));
}
}
}
}
}
return subFlag;
}
|
[
"function",
"(",
"config",
",",
"base",
",",
"parent",
")",
"{",
"var",
"key",
",",
"sub",
",",
"find",
",",
"item",
";",
"base",
"=",
"base",
"||",
"config",
";",
"parent",
"=",
"parent",
"||",
"{",
"ref",
":",
"config",
",",
"key",
":",
"null",
"}",
";",
"var",
"subFlag",
"=",
"false",
";",
"for",
"(",
"key",
"in",
"config",
")",
"{",
"if",
"(",
"config",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"if",
"(",
"isIterable",
"(",
"config",
"[",
"key",
"]",
")",
")",
"{",
"subFlag",
"=",
"this",
".",
"_applySubstitutions",
"(",
"config",
"[",
"key",
"]",
",",
"base",
",",
"{",
"ref",
":",
"config",
",",
"key",
":",
"key",
"}",
")",
"||",
"subFlag",
";",
"}",
"else",
"{",
"sub",
"=",
"SUBMATCH",
".",
"exec",
"(",
"key",
")",
";",
"if",
"(",
"sub",
"&&",
"(",
"sub",
"[",
"0",
"]",
"===",
"key",
")",
")",
"{",
"subFlag",
"=",
"true",
";",
"find",
"=",
"extract",
"(",
"base",
",",
"sub",
"[",
"1",
"]",
",",
"null",
")",
";",
"if",
"(",
"isA",
"(",
"find",
",",
"Object",
")",
")",
"{",
"delete",
"config",
"[",
"key",
"]",
";",
"for",
"(",
"item",
"in",
"find",
")",
"{",
"if",
"(",
"find",
".",
"hasOwnProperty",
"(",
"item",
")",
")",
"{",
"if",
"(",
"!",
"parent",
".",
"ref",
"[",
"parent",
".",
"key",
"]",
")",
"{",
"parent",
".",
"ref",
"[",
"item",
"]",
"=",
"find",
"[",
"item",
"]",
";",
"}",
"else",
"{",
"parent",
".",
"ref",
"[",
"parent",
".",
"key",
"]",
"[",
"item",
"]",
"=",
"find",
"[",
"item",
"]",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"config",
"[",
"key",
"]",
"=",
"'--YCB-SUBSTITUTION-ERROR--'",
";",
"}",
"}",
"else",
"if",
"(",
"SUBMATCH",
".",
"test",
"(",
"config",
"[",
"key",
"]",
")",
")",
"{",
"subFlag",
"=",
"true",
";",
"sub",
"=",
"SUBMATCH",
".",
"exec",
"(",
"config",
"[",
"key",
"]",
")",
";",
"find",
"=",
"sub",
"[",
"1",
"]",
";",
"if",
"(",
"sub",
"[",
"0",
"]",
"===",
"config",
"[",
"key",
"]",
")",
"{",
"find",
"=",
"extract",
"(",
"base",
",",
"find",
",",
"null",
")",
";",
"if",
"(",
"isA",
"(",
"find",
",",
"Array",
")",
"&&",
"isA",
"(",
"config",
",",
"Array",
")",
")",
"{",
"parent",
".",
"ref",
"[",
"parent",
".",
"key",
"]",
"=",
"config",
".",
"slice",
"(",
"0",
",",
"parseInt",
"(",
"key",
",",
"10",
")",
")",
".",
"concat",
"(",
"find",
")",
".",
"concat",
"(",
"config",
".",
"slice",
"(",
"parseInt",
"(",
"key",
",",
"10",
")",
"+",
"1",
")",
")",
";",
"}",
"else",
"{",
"config",
"[",
"key",
"]",
"=",
"find",
";",
"}",
"}",
"else",
"{",
"config",
"[",
"key",
"]",
"=",
"config",
"[",
"key",
"]",
".",
"replace",
"(",
"SUBMATCHES",
",",
"replacer",
"(",
"base",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"subFlag",
";",
"}"
] |
This is a first pass at hairball of a function.
@private
@method _applySubstitutions
@param config {object}
@param base {object}
@param parent {object}
@return {boolean}
|
[
"This",
"is",
"a",
"first",
"pass",
"at",
"hairball",
"of",
"a",
"function",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L542-L619
|
train
|
|
yahoo/ycb
|
index.js
|
function (callback) {
if(this.masterDelta && !callback({}, cloneDeep(this.masterDelta))) {
return undefined;
}
this._walkSettingsHelper(this.tree, 0, [], callback, [false]);
}
|
javascript
|
function (callback) {
if(this.masterDelta && !callback({}, cloneDeep(this.masterDelta))) {
return undefined;
}
this._walkSettingsHelper(this.tree, 0, [], callback, [false]);
}
|
[
"function",
"(",
"callback",
")",
"{",
"if",
"(",
"this",
".",
"masterDelta",
"&&",
"!",
"callback",
"(",
"{",
"}",
",",
"cloneDeep",
"(",
"this",
".",
"masterDelta",
")",
")",
")",
"{",
"return",
"undefined",
";",
"}",
"this",
".",
"_walkSettingsHelper",
"(",
"this",
".",
"tree",
",",
"0",
",",
"[",
"]",
",",
"callback",
",",
"[",
"false",
"]",
")",
";",
"}"
] |
Iterates over all the setting sections in the YCB file, calling the
callback for each section.
@method walkSettings
@param callback {function(settings, config)}
@param callback.settings {object} the condition under which section will be used
@param callback.config {object} the configuration in the section
@param callback.return {boolean} if the callback returns false, then walking is stopped
@return {nothing} results returned via callback
|
[
"Iterates",
"over",
"all",
"the",
"setting",
"sections",
"in",
"the",
"YCB",
"file",
"calling",
"the",
"callback",
"for",
"each",
"section",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L631-L636
|
train
|
|
yahoo/ycb
|
index.js
|
function(cur, depth, context, callback, stop) {
if(stop[0]) {
return true;
}
if(depth === this.dimensionsList.length) {
stop[0] = !callback(this._contextToObject(context), cloneDeep(cur));
return stop[0];
}
var key;
for(key in cur) {
if(this._walkSettingsHelper(cur[key], depth+1, context.concat(key), callback, stop)) {
return true;
}
}
}
|
javascript
|
function(cur, depth, context, callback, stop) {
if(stop[0]) {
return true;
}
if(depth === this.dimensionsList.length) {
stop[0] = !callback(this._contextToObject(context), cloneDeep(cur));
return stop[0];
}
var key;
for(key in cur) {
if(this._walkSettingsHelper(cur[key], depth+1, context.concat(key), callback, stop)) {
return true;
}
}
}
|
[
"function",
"(",
"cur",
",",
"depth",
",",
"context",
",",
"callback",
",",
"stop",
")",
"{",
"if",
"(",
"stop",
"[",
"0",
"]",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"depth",
"===",
"this",
".",
"dimensionsList",
".",
"length",
")",
"{",
"stop",
"[",
"0",
"]",
"=",
"!",
"callback",
"(",
"this",
".",
"_contextToObject",
"(",
"context",
")",
",",
"cloneDeep",
"(",
"cur",
")",
")",
";",
"return",
"stop",
"[",
"0",
"]",
";",
"}",
"var",
"key",
";",
"for",
"(",
"key",
"in",
"cur",
")",
"{",
"if",
"(",
"this",
".",
"_walkSettingsHelper",
"(",
"cur",
"[",
"key",
"]",
",",
"depth",
"+",
"1",
",",
"context",
".",
"concat",
"(",
"key",
")",
",",
"callback",
",",
"stop",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}"
] |
Recursive helper for walking the config tree.
@param cur {object}
@param depth {number}
@param context {array}
@param callback {function}
@param stop {array}
@private
|
[
"Recursive",
"helper",
"for",
"walking",
"the",
"config",
"tree",
"."
] |
eb64c56e10f600f0630aad301fa66b9d5e319ed5
|
https://github.com/yahoo/ycb/blob/eb64c56e10f600f0630aad301fa66b9d5e319ed5/index.js#L647-L661
|
train
|
|
epeschier/angular-numeric-directive
|
src/numeric-directive.js
|
round
|
function round(value) {
var d = Math.pow(10, decimals);
return Math.round(value * d) / d;
}
|
javascript
|
function round(value) {
var d = Math.pow(10, decimals);
return Math.round(value * d) / d;
}
|
[
"function",
"round",
"(",
"value",
")",
"{",
"var",
"d",
"=",
"Math",
".",
"pow",
"(",
"10",
",",
"decimals",
")",
";",
"return",
"Math",
".",
"round",
"(",
"value",
"*",
"d",
")",
"/",
"d",
";",
"}"
] |
Round the value to the closest decimal.
|
[
"Round",
"the",
"value",
"to",
"the",
"closest",
"decimal",
"."
] |
87ee0e0e7d531133d11410a35c453d788a4d451a
|
https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L124-L127
|
train
|
epeschier/angular-numeric-directive
|
src/numeric-directive.js
|
numberWithCommas
|
function numberWithCommas(value) {
if (formatting) {
var parts = (""+value).split(decimalSeparator);
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
return parts.join(decimalSeparator);
}
else {
// No formatting applies.
return value;
}
}
|
javascript
|
function numberWithCommas(value) {
if (formatting) {
var parts = (""+value).split(decimalSeparator);
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
return parts.join(decimalSeparator);
}
else {
// No formatting applies.
return value;
}
}
|
[
"function",
"numberWithCommas",
"(",
"value",
")",
"{",
"if",
"(",
"formatting",
")",
"{",
"var",
"parts",
"=",
"(",
"\"\"",
"+",
"value",
")",
".",
"split",
"(",
"decimalSeparator",
")",
";",
"parts",
"[",
"0",
"]",
"=",
"parts",
"[",
"0",
"]",
".",
"replace",
"(",
"/",
"\\B(?=(\\d{3})+(?!\\d))",
"/",
"g",
",",
"groupSeparator",
")",
";",
"return",
"parts",
".",
"join",
"(",
"decimalSeparator",
")",
";",
"}",
"else",
"{",
"return",
"value",
";",
"}",
"}"
] |
Format a number with the thousand group separator.
|
[
"Format",
"a",
"number",
"with",
"the",
"thousand",
"group",
"separator",
"."
] |
87ee0e0e7d531133d11410a35c453d788a4d451a
|
https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L132-L142
|
train
|
epeschier/angular-numeric-directive
|
src/numeric-directive.js
|
formatPrecision
|
function formatPrecision(value) {
if (!(value || value === 0)) {
return '';
}
var formattedValue = parseFloat(value).toFixed(decimals);
formattedValue = formattedValue.replace('.', decimalSeparator);
return numberWithCommas(formattedValue);
}
|
javascript
|
function formatPrecision(value) {
if (!(value || value === 0)) {
return '';
}
var formattedValue = parseFloat(value).toFixed(decimals);
formattedValue = formattedValue.replace('.', decimalSeparator);
return numberWithCommas(formattedValue);
}
|
[
"function",
"formatPrecision",
"(",
"value",
")",
"{",
"if",
"(",
"!",
"(",
"value",
"||",
"value",
"===",
"0",
")",
")",
"{",
"return",
"''",
";",
"}",
"var",
"formattedValue",
"=",
"parseFloat",
"(",
"value",
")",
".",
"toFixed",
"(",
"decimals",
")",
";",
"formattedValue",
"=",
"formattedValue",
".",
"replace",
"(",
"'.'",
",",
"decimalSeparator",
")",
";",
"return",
"numberWithCommas",
"(",
"formattedValue",
")",
";",
"}"
] |
Format a value with thousand group separator and correct decimal char.
|
[
"Format",
"a",
"value",
"with",
"thousand",
"group",
"separator",
"and",
"correct",
"decimal",
"char",
"."
] |
87ee0e0e7d531133d11410a35c453d788a4d451a
|
https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L147-L154
|
train
|
epeschier/angular-numeric-directive
|
src/numeric-directive.js
|
parseViewValue
|
function parseViewValue(value) {
if (angular.isUndefined(value)) {
value = '';
}
value = (""+value).replace(decimalSeparator, '.');
// Handle leading decimal point, like ".5"
if (value.indexOf('.') === 0) {
value = '0' + value;
}
// Allow "-" inputs only when min < 0
if (value.indexOf('-') === 0) {
if (min >= 0) {
value = null;
ngModelCtrl.$setViewValue(formatViewValue(lastValidValue));
ngModelCtrl.$render();
}
else if (value === '-') {
value = '';
}
}
var empty = ngModelCtrl.$isEmpty(value);
if (empty) {
lastValidValue = '';
//ngModelCtrl.$modelValue = undefined;
}
else {
if (regex.test(value) && (value.length <= maxInputLength)) {
if ((value > max) && limitMax) {
lastValidValue = max;
}
else if ((value < min) && limitMin) {
lastValidValue = min;
}
else {
lastValidValue = (value === '') ? null : parseFloat(value);
}
}
else {
// Render the last valid input in the field
ngModelCtrl.$setViewValue(formatViewValue(lastValidValue));
ngModelCtrl.$render();
}
}
return lastValidValue;
}
|
javascript
|
function parseViewValue(value) {
if (angular.isUndefined(value)) {
value = '';
}
value = (""+value).replace(decimalSeparator, '.');
// Handle leading decimal point, like ".5"
if (value.indexOf('.') === 0) {
value = '0' + value;
}
// Allow "-" inputs only when min < 0
if (value.indexOf('-') === 0) {
if (min >= 0) {
value = null;
ngModelCtrl.$setViewValue(formatViewValue(lastValidValue));
ngModelCtrl.$render();
}
else if (value === '-') {
value = '';
}
}
var empty = ngModelCtrl.$isEmpty(value);
if (empty) {
lastValidValue = '';
//ngModelCtrl.$modelValue = undefined;
}
else {
if (regex.test(value) && (value.length <= maxInputLength)) {
if ((value > max) && limitMax) {
lastValidValue = max;
}
else if ((value < min) && limitMin) {
lastValidValue = min;
}
else {
lastValidValue = (value === '') ? null : parseFloat(value);
}
}
else {
// Render the last valid input in the field
ngModelCtrl.$setViewValue(formatViewValue(lastValidValue));
ngModelCtrl.$render();
}
}
return lastValidValue;
}
|
[
"function",
"parseViewValue",
"(",
"value",
")",
"{",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"value",
")",
")",
"{",
"value",
"=",
"''",
";",
"}",
"value",
"=",
"(",
"\"\"",
"+",
"value",
")",
".",
"replace",
"(",
"decimalSeparator",
",",
"'.'",
")",
";",
"if",
"(",
"value",
".",
"indexOf",
"(",
"'.'",
")",
"===",
"0",
")",
"{",
"value",
"=",
"'0'",
"+",
"value",
";",
"}",
"if",
"(",
"value",
".",
"indexOf",
"(",
"'-'",
")",
"===",
"0",
")",
"{",
"if",
"(",
"min",
">=",
"0",
")",
"{",
"value",
"=",
"null",
";",
"ngModelCtrl",
".",
"$setViewValue",
"(",
"formatViewValue",
"(",
"lastValidValue",
")",
")",
";",
"ngModelCtrl",
".",
"$render",
"(",
")",
";",
"}",
"else",
"if",
"(",
"value",
"===",
"'-'",
")",
"{",
"value",
"=",
"''",
";",
"}",
"}",
"var",
"empty",
"=",
"ngModelCtrl",
".",
"$isEmpty",
"(",
"value",
")",
";",
"if",
"(",
"empty",
")",
"{",
"lastValidValue",
"=",
"''",
";",
"}",
"else",
"{",
"if",
"(",
"regex",
".",
"test",
"(",
"value",
")",
"&&",
"(",
"value",
".",
"length",
"<=",
"maxInputLength",
")",
")",
"{",
"if",
"(",
"(",
"value",
">",
"max",
")",
"&&",
"limitMax",
")",
"{",
"lastValidValue",
"=",
"max",
";",
"}",
"else",
"if",
"(",
"(",
"value",
"<",
"min",
")",
"&&",
"limitMin",
")",
"{",
"lastValidValue",
"=",
"min",
";",
"}",
"else",
"{",
"lastValidValue",
"=",
"(",
"value",
"===",
"''",
")",
"?",
"null",
":",
"parseFloat",
"(",
"value",
")",
";",
"}",
"}",
"else",
"{",
"ngModelCtrl",
".",
"$setViewValue",
"(",
"formatViewValue",
"(",
"lastValidValue",
")",
")",
";",
"ngModelCtrl",
".",
"$render",
"(",
")",
";",
"}",
"}",
"return",
"lastValidValue",
";",
"}"
] |
Parse the view value.
|
[
"Parse",
"the",
"view",
"value",
"."
] |
87ee0e0e7d531133d11410a35c453d788a4d451a
|
https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L163-L211
|
train
|
epeschier/angular-numeric-directive
|
src/numeric-directive.js
|
calculateMaxLength
|
function calculateMaxLength(value) {
var length = 16;
if (!angular.isUndefined(value)) {
length = Math.floor(value).toString().length;
}
if (decimals > 0) {
// Add extra length for the decimals plus one for the decimal separator.
length += decimals + 1;
}
if (min < 0) {
// Add extra length for the - sign.
length++;
}
return length;
}
|
javascript
|
function calculateMaxLength(value) {
var length = 16;
if (!angular.isUndefined(value)) {
length = Math.floor(value).toString().length;
}
if (decimals > 0) {
// Add extra length for the decimals plus one for the decimal separator.
length += decimals + 1;
}
if (min < 0) {
// Add extra length for the - sign.
length++;
}
return length;
}
|
[
"function",
"calculateMaxLength",
"(",
"value",
")",
"{",
"var",
"length",
"=",
"16",
";",
"if",
"(",
"!",
"angular",
".",
"isUndefined",
"(",
"value",
")",
")",
"{",
"length",
"=",
"Math",
".",
"floor",
"(",
"value",
")",
".",
"toString",
"(",
")",
".",
"length",
";",
"}",
"if",
"(",
"decimals",
">",
"0",
")",
"{",
"length",
"+=",
"decimals",
"+",
"1",
";",
"}",
"if",
"(",
"min",
"<",
"0",
")",
"{",
"length",
"++",
";",
"}",
"return",
"length",
";",
"}"
] |
Calculate the maximum input length in characters.
If no maximum the input will be limited to 16; the maximum ECMA script int.
|
[
"Calculate",
"the",
"maximum",
"input",
"length",
"in",
"characters",
".",
"If",
"no",
"maximum",
"the",
"input",
"will",
"be",
"limited",
"to",
"16",
";",
"the",
"maximum",
"ECMA",
"script",
"int",
"."
] |
87ee0e0e7d531133d11410a35c453d788a4d451a
|
https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L217-L231
|
train
|
epeschier/angular-numeric-directive
|
src/numeric-directive.js
|
minmaxValidator
|
function minmaxValidator(value, testValue, validityName, limit, compareFunction) {
if (!angular.isUndefined(testValue) && limit) {
if (!ngModelCtrl.$isEmpty(value) && compareFunction) {
return testValue;
} else {
return value;
}
}
else {
if (!limit) {
ngModelCtrl.$setValidity(validityName, !compareFunction);
}
return value;
}
}
|
javascript
|
function minmaxValidator(value, testValue, validityName, limit, compareFunction) {
if (!angular.isUndefined(testValue) && limit) {
if (!ngModelCtrl.$isEmpty(value) && compareFunction) {
return testValue;
} else {
return value;
}
}
else {
if (!limit) {
ngModelCtrl.$setValidity(validityName, !compareFunction);
}
return value;
}
}
|
[
"function",
"minmaxValidator",
"(",
"value",
",",
"testValue",
",",
"validityName",
",",
"limit",
",",
"compareFunction",
")",
"{",
"if",
"(",
"!",
"angular",
".",
"isUndefined",
"(",
"testValue",
")",
"&&",
"limit",
")",
"{",
"if",
"(",
"!",
"ngModelCtrl",
".",
"$isEmpty",
"(",
"value",
")",
"&&",
"compareFunction",
")",
"{",
"return",
"testValue",
";",
"}",
"else",
"{",
"return",
"value",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"limit",
")",
"{",
"ngModelCtrl",
".",
"$setValidity",
"(",
"validityName",
",",
"!",
"compareFunction",
")",
";",
"}",
"return",
"value",
";",
"}",
"}"
] |
Value validator for min and max.
|
[
"Value",
"validator",
"for",
"min",
"and",
"max",
"."
] |
87ee0e0e7d531133d11410a35c453d788a4d451a
|
https://github.com/epeschier/angular-numeric-directive/blob/87ee0e0e7d531133d11410a35c453d788a4d451a/src/numeric-directive.js#L236-L250
|
train
|
pevers/images-scraper
|
lib/picsearch-images-scraper.js
|
function(url) {
return new Promise(function (resolve) {
self.roptions.url = url;
request(self.roptions, function (err, response, body) {
if (!err && response.statusCode === 200) {
var $ = cheerio.load(body);
// no results
if (!$('.result').length) {
return resolve(result);
}
$('.result').each(function() {
var href = $(this).find('a').attr('href');
if(href.toString().indexOf("http") !== 0) {
result.push(base + href);
} else {
result.push(href);
}
});
if (num && result.length > num) {
return resolve(result.slice(0,num));
}
// search for current page and select next one
var page = $('#nextPage').attr('href');
if (page) {
resolve(nextPage(base + page));
}
else {
resolve(result);
}
} else {
resolve(result)
}
});
});
}
|
javascript
|
function(url) {
return new Promise(function (resolve) {
self.roptions.url = url;
request(self.roptions, function (err, response, body) {
if (!err && response.statusCode === 200) {
var $ = cheerio.load(body);
// no results
if (!$('.result').length) {
return resolve(result);
}
$('.result').each(function() {
var href = $(this).find('a').attr('href');
if(href.toString().indexOf("http") !== 0) {
result.push(base + href);
} else {
result.push(href);
}
});
if (num && result.length > num) {
return resolve(result.slice(0,num));
}
// search for current page and select next one
var page = $('#nextPage').attr('href');
if (page) {
resolve(nextPage(base + page));
}
else {
resolve(result);
}
} else {
resolve(result)
}
});
});
}
|
[
"function",
"(",
"url",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"self",
".",
"roptions",
".",
"url",
"=",
"url",
";",
"request",
"(",
"self",
".",
"roptions",
",",
"function",
"(",
"err",
",",
"response",
",",
"body",
")",
"{",
"if",
"(",
"!",
"err",
"&&",
"response",
".",
"statusCode",
"===",
"200",
")",
"{",
"var",
"$",
"=",
"cheerio",
".",
"load",
"(",
"body",
")",
";",
"if",
"(",
"!",
"$",
"(",
"'.result'",
")",
".",
"length",
")",
"{",
"return",
"resolve",
"(",
"result",
")",
";",
"}",
"$",
"(",
"'.result'",
")",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"href",
"=",
"$",
"(",
"this",
")",
".",
"find",
"(",
"'a'",
")",
".",
"attr",
"(",
"'href'",
")",
";",
"if",
"(",
"href",
".",
"toString",
"(",
")",
".",
"indexOf",
"(",
"\"http\"",
")",
"!==",
"0",
")",
"{",
"result",
".",
"push",
"(",
"base",
"+",
"href",
")",
";",
"}",
"else",
"{",
"result",
".",
"push",
"(",
"href",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"num",
"&&",
"result",
".",
"length",
">",
"num",
")",
"{",
"return",
"resolve",
"(",
"result",
".",
"slice",
"(",
"0",
",",
"num",
")",
")",
";",
"}",
"var",
"page",
"=",
"$",
"(",
"'#nextPage'",
")",
".",
"attr",
"(",
"'href'",
")",
";",
"if",
"(",
"page",
")",
"{",
"resolve",
"(",
"nextPage",
"(",
"base",
"+",
"page",
")",
")",
";",
"}",
"else",
"{",
"resolve",
"(",
"result",
")",
";",
"}",
"}",
"else",
"{",
"resolve",
"(",
"result",
")",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] |
max it to 2000 for default because we can go on indefinitely
|
[
"max",
"it",
"to",
"2000",
"for",
"default",
"because",
"we",
"can",
"go",
"on",
"indefinitely"
] |
5b97061c958a3ece8392dde813a16399a3b1d6c0
|
https://github.com/pevers/images-scraper/blob/5b97061c958a3ece8392dde813a16399a3b1d6c0/lib/picsearch-images-scraper.js#L32-L70
|
train
|
|
emmaguo/angular-poller
|
angular-poller.js
|
function(target, options) {
var poller = findPoller(target);
if (!poller) {
poller = new Poller(target, options);
pollers.push(poller);
poller.start();
} else {
poller.set(options);
poller.restart();
}
return poller;
}
|
javascript
|
function(target, options) {
var poller = findPoller(target);
if (!poller) {
poller = new Poller(target, options);
pollers.push(poller);
poller.start();
} else {
poller.set(options);
poller.restart();
}
return poller;
}
|
[
"function",
"(",
"target",
",",
"options",
")",
"{",
"var",
"poller",
"=",
"findPoller",
"(",
"target",
")",
";",
"if",
"(",
"!",
"poller",
")",
"{",
"poller",
"=",
"new",
"Poller",
"(",
"target",
",",
"options",
")",
";",
"pollers",
".",
"push",
"(",
"poller",
")",
";",
"poller",
".",
"start",
"(",
")",
";",
"}",
"else",
"{",
"poller",
".",
"set",
"(",
"options",
")",
";",
"poller",
".",
"restart",
"(",
")",
";",
"}",
"return",
"poller",
";",
"}"
] |
Return a singleton instance of a poller. If poller does
not exist, then register and start it. Otherwise return
it and restart it if necessary.
@param target
@param options
@returns {object}
|
[
"Return",
"a",
"singleton",
"instance",
"of",
"a",
"poller",
".",
"If",
"poller",
"does",
"not",
"exist",
"then",
"register",
"and",
"start",
"it",
".",
"Otherwise",
"return",
"it",
"and",
"restart",
"it",
"if",
"necessary",
"."
] |
c4baaeb0d130f90475cd7bdc3aa54df9294c1507
|
https://github.com/emmaguo/angular-poller/blob/c4baaeb0d130f90475cd7bdc3aa54df9294c1507/angular-poller.js#L332-L345
|
train
|
|
emmaguo/angular-poller
|
angular-poller.js
|
function() {
angular.forEach(pollers, function(p) {
p.delay = p.idleDelay;
if (angular.isDefined(p.interval)) {
p.restart();
}
});
}
|
javascript
|
function() {
angular.forEach(pollers, function(p) {
p.delay = p.idleDelay;
if (angular.isDefined(p.interval)) {
p.restart();
}
});
}
|
[
"function",
"(",
")",
"{",
"angular",
".",
"forEach",
"(",
"pollers",
",",
"function",
"(",
"p",
")",
"{",
"p",
".",
"delay",
"=",
"p",
".",
"idleDelay",
";",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"p",
".",
"interval",
")",
")",
"{",
"p",
".",
"restart",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Increase all poller interval to idleDelay, and restart the ones
that are already running.
|
[
"Increase",
"all",
"poller",
"interval",
"to",
"idleDelay",
"and",
"restart",
"the",
"ones",
"that",
"are",
"already",
"running",
"."
] |
c4baaeb0d130f90475cd7bdc3aa54df9294c1507
|
https://github.com/emmaguo/angular-poller/blob/c4baaeb0d130f90475cd7bdc3aa54df9294c1507/angular-poller.js#L386-L393
|
train
|
|
eface2face/rtcninja.js
|
lib/RTCPeerConnection.js
|
runTimerGatheringTimeout
|
function runTimerGatheringTimeout() {
if (typeof self.options.gatheringTimeout !== 'number') {
return;
}
// If setLocalDescription was already called, it may happen that
// ICE gathering is not needed, so don't run this timer.
if (self.pc.iceGatheringState === 'complete') {
return;
}
debug('setLocalDescription() | ending gathering in %d ms (gatheringTimeout option)',
self.options.gatheringTimeout);
self.timerGatheringTimeout = setTimeout(function () {
if (isClosed.call(self)) {
return;
}
debug('forced end of candidates after gatheringTimeout timeout');
// Clear gathering timers.
delete self.timerGatheringTimeout;
clearTimeout(self.timerGatheringTimeoutAfterRelay);
delete self.timerGatheringTimeoutAfterRelay;
// Ignore new candidates.
self.ignoreIceGathering = true;
if (self.onicecandidate) {
self.onicecandidate({ candidate: null }, null);
}
}, self.options.gatheringTimeout);
}
|
javascript
|
function runTimerGatheringTimeout() {
if (typeof self.options.gatheringTimeout !== 'number') {
return;
}
// If setLocalDescription was already called, it may happen that
// ICE gathering is not needed, so don't run this timer.
if (self.pc.iceGatheringState === 'complete') {
return;
}
debug('setLocalDescription() | ending gathering in %d ms (gatheringTimeout option)',
self.options.gatheringTimeout);
self.timerGatheringTimeout = setTimeout(function () {
if (isClosed.call(self)) {
return;
}
debug('forced end of candidates after gatheringTimeout timeout');
// Clear gathering timers.
delete self.timerGatheringTimeout;
clearTimeout(self.timerGatheringTimeoutAfterRelay);
delete self.timerGatheringTimeoutAfterRelay;
// Ignore new candidates.
self.ignoreIceGathering = true;
if (self.onicecandidate) {
self.onicecandidate({ candidate: null }, null);
}
}, self.options.gatheringTimeout);
}
|
[
"function",
"runTimerGatheringTimeout",
"(",
")",
"{",
"if",
"(",
"typeof",
"self",
".",
"options",
".",
"gatheringTimeout",
"!==",
"'number'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"self",
".",
"pc",
".",
"iceGatheringState",
"===",
"'complete'",
")",
"{",
"return",
";",
"}",
"debug",
"(",
"'setLocalDescription() | ending gathering in %d ms (gatheringTimeout option)'",
",",
"self",
".",
"options",
".",
"gatheringTimeout",
")",
";",
"self",
".",
"timerGatheringTimeout",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"isClosed",
".",
"call",
"(",
"self",
")",
")",
"{",
"return",
";",
"}",
"debug",
"(",
"'forced end of candidates after gatheringTimeout timeout'",
")",
";",
"delete",
"self",
".",
"timerGatheringTimeout",
";",
"clearTimeout",
"(",
"self",
".",
"timerGatheringTimeoutAfterRelay",
")",
";",
"delete",
"self",
".",
"timerGatheringTimeoutAfterRelay",
";",
"self",
".",
"ignoreIceGathering",
"=",
"true",
";",
"if",
"(",
"self",
".",
"onicecandidate",
")",
"{",
"self",
".",
"onicecandidate",
"(",
"{",
"candidate",
":",
"null",
"}",
",",
"null",
")",
";",
"}",
"}",
",",
"self",
".",
"options",
".",
"gatheringTimeout",
")",
";",
"}"
] |
Handle gatheringTimeout.
|
[
"Handle",
"gatheringTimeout",
"."
] |
9c070d0c77fd71281774cc45bd784a878cc714a5
|
https://github.com/eface2face/rtcninja.js/blob/9c070d0c77fd71281774cc45bd784a878cc714a5/lib/RTCPeerConnection.js#L173-L205
|
train
|
eface2face/rtcninja.js
|
lib/RTCPeerConnection.js
|
setConfigurationAndOptions
|
function setConfigurationAndOptions(pcConfig) {
// Clone pcConfig.
this.pcConfig = merge(true, pcConfig);
// Fix pcConfig.
Adapter.fixPeerConnectionConfig(this.pcConfig);
this.options = {
iceTransportsRelay: (this.pcConfig.iceTransports === 'relay'),
iceTransportsNone: (this.pcConfig.iceTransports === 'none'),
gatheringTimeout: this.pcConfig.gatheringTimeout,
gatheringTimeoutAfterRelay: this.pcConfig.gatheringTimeoutAfterRelay
};
// Remove custom rtcninja.RTCPeerConnection options from pcConfig.
delete this.pcConfig.gatheringTimeout;
delete this.pcConfig.gatheringTimeoutAfterRelay;
debug('setConfigurationAndOptions | processed pcConfig: %o', this.pcConfig);
}
|
javascript
|
function setConfigurationAndOptions(pcConfig) {
// Clone pcConfig.
this.pcConfig = merge(true, pcConfig);
// Fix pcConfig.
Adapter.fixPeerConnectionConfig(this.pcConfig);
this.options = {
iceTransportsRelay: (this.pcConfig.iceTransports === 'relay'),
iceTransportsNone: (this.pcConfig.iceTransports === 'none'),
gatheringTimeout: this.pcConfig.gatheringTimeout,
gatheringTimeoutAfterRelay: this.pcConfig.gatheringTimeoutAfterRelay
};
// Remove custom rtcninja.RTCPeerConnection options from pcConfig.
delete this.pcConfig.gatheringTimeout;
delete this.pcConfig.gatheringTimeoutAfterRelay;
debug('setConfigurationAndOptions | processed pcConfig: %o', this.pcConfig);
}
|
[
"function",
"setConfigurationAndOptions",
"(",
"pcConfig",
")",
"{",
"this",
".",
"pcConfig",
"=",
"merge",
"(",
"true",
",",
"pcConfig",
")",
";",
"Adapter",
".",
"fixPeerConnectionConfig",
"(",
"this",
".",
"pcConfig",
")",
";",
"this",
".",
"options",
"=",
"{",
"iceTransportsRelay",
":",
"(",
"this",
".",
"pcConfig",
".",
"iceTransports",
"===",
"'relay'",
")",
",",
"iceTransportsNone",
":",
"(",
"this",
".",
"pcConfig",
".",
"iceTransports",
"===",
"'none'",
")",
",",
"gatheringTimeout",
":",
"this",
".",
"pcConfig",
".",
"gatheringTimeout",
",",
"gatheringTimeoutAfterRelay",
":",
"this",
".",
"pcConfig",
".",
"gatheringTimeoutAfterRelay",
"}",
";",
"delete",
"this",
".",
"pcConfig",
".",
"gatheringTimeout",
";",
"delete",
"this",
".",
"pcConfig",
".",
"gatheringTimeoutAfterRelay",
";",
"debug",
"(",
"'setConfigurationAndOptions | processed pcConfig: %o'",
",",
"this",
".",
"pcConfig",
")",
";",
"}"
] |
Private Helpers.
|
[
"Private",
"Helpers",
"."
] |
9c070d0c77fd71281774cc45bd784a878cc714a5
|
https://github.com/eface2face/rtcninja.js/blob/9c070d0c77fd71281774cc45bd784a878cc714a5/lib/RTCPeerConnection.js#L415-L434
|
train
|
binarykitchen/videomail-client
|
src/wrappers/dimension.js
|
function (height, options) {
if (numberIsInteger(height) && height < 1) {
throw VideomailError.create('Passed limit-height argument cannot be less than 1!', options)
} else {
const limitedHeight = Math.min(
height,
// document.body.scrollHeight,
document.documentElement.clientHeight
)
if (limitedHeight < 1) {
throw VideomailError.create('Limited height cannot be less than 1!', options)
} else {
return limitedHeight
}
}
}
|
javascript
|
function (height, options) {
if (numberIsInteger(height) && height < 1) {
throw VideomailError.create('Passed limit-height argument cannot be less than 1!', options)
} else {
const limitedHeight = Math.min(
height,
// document.body.scrollHeight,
document.documentElement.clientHeight
)
if (limitedHeight < 1) {
throw VideomailError.create('Limited height cannot be less than 1!', options)
} else {
return limitedHeight
}
}
}
|
[
"function",
"(",
"height",
",",
"options",
")",
"{",
"if",
"(",
"numberIsInteger",
"(",
"height",
")",
"&&",
"height",
"<",
"1",
")",
"{",
"throw",
"VideomailError",
".",
"create",
"(",
"'Passed limit-height argument cannot be less than 1!'",
",",
"options",
")",
"}",
"else",
"{",
"const",
"limitedHeight",
"=",
"Math",
".",
"min",
"(",
"height",
",",
"document",
".",
"documentElement",
".",
"clientHeight",
")",
"if",
"(",
"limitedHeight",
"<",
"1",
")",
"{",
"throw",
"VideomailError",
".",
"create",
"(",
"'Limited height cannot be less than 1!'",
",",
"options",
")",
"}",
"else",
"{",
"return",
"limitedHeight",
"}",
"}",
"}"
] |
this is difficult to compute and is not entirely correct. but good enough for now to ensure some stability.
|
[
"this",
"is",
"difficult",
"to",
"compute",
"and",
"is",
"not",
"entirely",
"correct",
".",
"but",
"good",
"enough",
"for",
"now",
"to",
"ensure",
"some",
"stability",
"."
] |
8c9ac3488ae2d5e7eaa984d59414f244de4b4c4e
|
https://github.com/binarykitchen/videomail-client/blob/8c9ac3488ae2d5e7eaa984d59414f244de4b4c4e/src/wrappers/dimension.js#L68-L84
|
train
|
|
feedhenry/fh-sync-js
|
libs/generated/lawnchair.js
|
function (callback) {
var cb = this.lambda(callback)
// iterate from chain
if (this.__results) {
for (var i = 0, l = this.__results.length; i < l; i++) cb.call(this, this.__results[i], i)
}
// otherwise iterate the entire collection
else {
this.all(function(r) {
for (var i = 0, l = r.length; i < l; i++) cb.call(this, r[i], i)
})
}
return this
}
|
javascript
|
function (callback) {
var cb = this.lambda(callback)
// iterate from chain
if (this.__results) {
for (var i = 0, l = this.__results.length; i < l; i++) cb.call(this, this.__results[i], i)
}
// otherwise iterate the entire collection
else {
this.all(function(r) {
for (var i = 0, l = r.length; i < l; i++) cb.call(this, r[i], i)
})
}
return this
}
|
[
"function",
"(",
"callback",
")",
"{",
"var",
"cb",
"=",
"this",
".",
"lambda",
"(",
"callback",
")",
"if",
"(",
"this",
".",
"__results",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"this",
".",
"__results",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"cb",
".",
"call",
"(",
"this",
",",
"this",
".",
"__results",
"[",
"i",
"]",
",",
"i",
")",
"}",
"else",
"{",
"this",
".",
"all",
"(",
"function",
"(",
"r",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"r",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"cb",
".",
"call",
"(",
"this",
",",
"r",
"[",
"i",
"]",
",",
"i",
")",
"}",
")",
"}",
"return",
"this",
"}"
] |
a classic iterator
|
[
"a",
"classic",
"iterator"
] |
b8f3864485da482df57fbe64904926983ef910a9
|
https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/libs/generated/lawnchair.js#L150-L163
|
train
|
|
feedhenry/fh-sync-js
|
libs/generated/lawnchair.js
|
function(name) {
return {
// the key
key: name + '._index_',
// returns the index
all: function() {
var a = storage.getItem(this.key)
if (a) {
a = JSON.parse(a)
}
if (a === null) storage.setItem(this.key, JSON.stringify([])) // lazy init
return JSON.parse(storage.getItem(this.key))
},
// adds a key to the index
add: function (key) {
var a = this.all()
a.push(key)
storage.setItem(this.key, JSON.stringify(a))
},
// deletes a key from the index
del: function (key) {
var a = this.all(), r = []
// FIXME this is crazy inefficient but I'm in a strata meeting and half concentrating
for (var i = 0, l = a.length; i < l; i++) {
if (a[i] != key) r.push(a[i])
}
storage.setItem(this.key, JSON.stringify(r))
},
// returns index for a key
find: function (key) {
var a = this.all()
for (var i = 0, l = a.length; i < l; i++) {
if (key === a[i]) return i
}
return false
}
}
}
|
javascript
|
function(name) {
return {
// the key
key: name + '._index_',
// returns the index
all: function() {
var a = storage.getItem(this.key)
if (a) {
a = JSON.parse(a)
}
if (a === null) storage.setItem(this.key, JSON.stringify([])) // lazy init
return JSON.parse(storage.getItem(this.key))
},
// adds a key to the index
add: function (key) {
var a = this.all()
a.push(key)
storage.setItem(this.key, JSON.stringify(a))
},
// deletes a key from the index
del: function (key) {
var a = this.all(), r = []
// FIXME this is crazy inefficient but I'm in a strata meeting and half concentrating
for (var i = 0, l = a.length; i < l; i++) {
if (a[i] != key) r.push(a[i])
}
storage.setItem(this.key, JSON.stringify(r))
},
// returns index for a key
find: function (key) {
var a = this.all()
for (var i = 0, l = a.length; i < l; i++) {
if (key === a[i]) return i
}
return false
}
}
}
|
[
"function",
"(",
"name",
")",
"{",
"return",
"{",
"key",
":",
"name",
"+",
"'._index_'",
",",
"all",
":",
"function",
"(",
")",
"{",
"var",
"a",
"=",
"storage",
".",
"getItem",
"(",
"this",
".",
"key",
")",
"if",
"(",
"a",
")",
"{",
"a",
"=",
"JSON",
".",
"parse",
"(",
"a",
")",
"}",
"if",
"(",
"a",
"===",
"null",
")",
"storage",
".",
"setItem",
"(",
"this",
".",
"key",
",",
"JSON",
".",
"stringify",
"(",
"[",
"]",
")",
")",
"return",
"JSON",
".",
"parse",
"(",
"storage",
".",
"getItem",
"(",
"this",
".",
"key",
")",
")",
"}",
",",
"add",
":",
"function",
"(",
"key",
")",
"{",
"var",
"a",
"=",
"this",
".",
"all",
"(",
")",
"a",
".",
"push",
"(",
"key",
")",
"storage",
".",
"setItem",
"(",
"this",
".",
"key",
",",
"JSON",
".",
"stringify",
"(",
"a",
")",
")",
"}",
",",
"del",
":",
"function",
"(",
"key",
")",
"{",
"var",
"a",
"=",
"this",
".",
"all",
"(",
")",
",",
"r",
"=",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"a",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"a",
"[",
"i",
"]",
"!=",
"key",
")",
"r",
".",
"push",
"(",
"a",
"[",
"i",
"]",
")",
"}",
"storage",
".",
"setItem",
"(",
"this",
".",
"key",
",",
"JSON",
".",
"stringify",
"(",
"r",
")",
")",
"}",
",",
"find",
":",
"function",
"(",
"key",
")",
"{",
"var",
"a",
"=",
"this",
".",
"all",
"(",
")",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"a",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"key",
"===",
"a",
"[",
"i",
"]",
")",
"return",
"i",
"}",
"return",
"false",
"}",
"}",
"}"
] |
the indexer is an encapsulation of the helpers needed to keep an ordered index of the keys
|
[
"the",
"indexer",
"is",
"an",
"encapsulation",
"of",
"the",
"helpers",
"needed",
"to",
"keep",
"an",
"ordered",
"index",
"of",
"the",
"keys"
] |
b8f3864485da482df57fbe64904926983ef910a9
|
https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/libs/generated/lawnchair.js#L315-L352
|
train
|
|
feedhenry/fh-sync-js
|
libs/generated/lawnchair.js
|
function(obj, callback, error) {
var that = this
objs = (this.isArray(obj) ? obj : [obj]).map(function(o) {
if (!o.key) {
o.key = that.uuid()
}
return o
}),
ins = "INSERT OR REPLACE INTO " + this.record + " (value, timestamp, id) VALUES (?,?,?)",
win = function() {
if (callback) {
that.lambda(callback).call(that, that.isArray(obj) ? objs : objs[0])
}
}, error = error || function() {}, insvals = [],
ts = now()
try {
for (var i = 0, l = objs.length; i < l; i++) {
insvals[i] = [JSON.stringify(objs[i]), ts, objs[i].key];
}
} catch (e) {
fail(e)
throw e;
}
that.db.transaction(function(t) {
for (var i = 0, l = objs.length; i < l; i++)
t.executeSql(ins, insvals[i])
}, function(e, i) {
fail(e, i)
}, win)
return this
}
|
javascript
|
function(obj, callback, error) {
var that = this
objs = (this.isArray(obj) ? obj : [obj]).map(function(o) {
if (!o.key) {
o.key = that.uuid()
}
return o
}),
ins = "INSERT OR REPLACE INTO " + this.record + " (value, timestamp, id) VALUES (?,?,?)",
win = function() {
if (callback) {
that.lambda(callback).call(that, that.isArray(obj) ? objs : objs[0])
}
}, error = error || function() {}, insvals = [],
ts = now()
try {
for (var i = 0, l = objs.length; i < l; i++) {
insvals[i] = [JSON.stringify(objs[i]), ts, objs[i].key];
}
} catch (e) {
fail(e)
throw e;
}
that.db.transaction(function(t) {
for (var i = 0, l = objs.length; i < l; i++)
t.executeSql(ins, insvals[i])
}, function(e, i) {
fail(e, i)
}, win)
return this
}
|
[
"function",
"(",
"obj",
",",
"callback",
",",
"error",
")",
"{",
"var",
"that",
"=",
"this",
"objs",
"=",
"(",
"this",
".",
"isArray",
"(",
"obj",
")",
"?",
"obj",
":",
"[",
"obj",
"]",
")",
".",
"map",
"(",
"function",
"(",
"o",
")",
"{",
"if",
"(",
"!",
"o",
".",
"key",
")",
"{",
"o",
".",
"key",
"=",
"that",
".",
"uuid",
"(",
")",
"}",
"return",
"o",
"}",
")",
",",
"ins",
"=",
"\"INSERT OR REPLACE INTO \"",
"+",
"this",
".",
"record",
"+",
"\" (value, timestamp, id) VALUES (?,?,?)\"",
",",
"win",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"callback",
")",
"{",
"that",
".",
"lambda",
"(",
"callback",
")",
".",
"call",
"(",
"that",
",",
"that",
".",
"isArray",
"(",
"obj",
")",
"?",
"objs",
":",
"objs",
"[",
"0",
"]",
")",
"}",
"}",
",",
"error",
"=",
"error",
"||",
"function",
"(",
")",
"{",
"}",
",",
"insvals",
"=",
"[",
"]",
",",
"ts",
"=",
"now",
"(",
")",
"try",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"objs",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"insvals",
"[",
"i",
"]",
"=",
"[",
"JSON",
".",
"stringify",
"(",
"objs",
"[",
"i",
"]",
")",
",",
"ts",
",",
"objs",
"[",
"i",
"]",
".",
"key",
"]",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"fail",
"(",
"e",
")",
"throw",
"e",
";",
"}",
"that",
".",
"db",
".",
"transaction",
"(",
"function",
"(",
"t",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"objs",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"t",
".",
"executeSql",
"(",
"ins",
",",
"insvals",
"[",
"i",
"]",
")",
"}",
",",
"function",
"(",
"e",
",",
"i",
")",
"{",
"fail",
"(",
"e",
",",
"i",
")",
"}",
",",
"win",
")",
"return",
"this",
"}"
] |
you think thats air you're breathing now?
|
[
"you",
"think",
"thats",
"air",
"you",
"re",
"breathing",
"now?"
] |
b8f3864485da482df57fbe64904926983ef910a9
|
https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/libs/generated/lawnchair.js#L563-L596
|
train
|
|
feedhenry/fh-sync-js
|
src/sync-client.js
|
function(options) {
self.consoleLog('sync - init called');
self.config = JSON.parse(JSON.stringify(self.defaults));
for (var i in options) {
self.config[i] = options[i];
}
//prevent multiple monitors from created if init is called multiple times
if(!self.init_is_called){
self.init_is_called = true;
self.datasetMonitor();
}
defaultCloudHandler.init(self.config.cloudUrl, self.config.cloudPath);
}
|
javascript
|
function(options) {
self.consoleLog('sync - init called');
self.config = JSON.parse(JSON.stringify(self.defaults));
for (var i in options) {
self.config[i] = options[i];
}
//prevent multiple monitors from created if init is called multiple times
if(!self.init_is_called){
self.init_is_called = true;
self.datasetMonitor();
}
defaultCloudHandler.init(self.config.cloudUrl, self.config.cloudPath);
}
|
[
"function",
"(",
"options",
")",
"{",
"self",
".",
"consoleLog",
"(",
"'sync - init called'",
")",
";",
"self",
".",
"config",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"self",
".",
"defaults",
")",
")",
";",
"for",
"(",
"var",
"i",
"in",
"options",
")",
"{",
"self",
".",
"config",
"[",
"i",
"]",
"=",
"options",
"[",
"i",
"]",
";",
"}",
"if",
"(",
"!",
"self",
".",
"init_is_called",
")",
"{",
"self",
".",
"init_is_called",
"=",
"true",
";",
"self",
".",
"datasetMonitor",
"(",
")",
";",
"}",
"defaultCloudHandler",
".",
"init",
"(",
"self",
".",
"config",
".",
"cloudUrl",
",",
"self",
".",
"config",
".",
"cloudPath",
")",
";",
"}"
] |
PUBLIC FUNCTION IMPLEMENTATIONS
|
[
"PUBLIC",
"FUNCTION",
"IMPLEMENTATIONS"
] |
b8f3864485da482df57fbe64904926983ef910a9
|
https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/src/sync-client.js#L104-L118
|
train
|
|
feedhenry/fh-sync-js
|
src/sync-client.js
|
function(config, options) {
// Make sure config is initialised
if( ! config ) {
config = JSON.parse(JSON.stringify(self.defaults));
}
var datasetConfig = JSON.parse(JSON.stringify(config));
var optionsIn = JSON.parse(JSON.stringify(options));
for (var k in optionsIn) {
datasetConfig[k] = optionsIn[k];
}
return datasetConfig;
}
|
javascript
|
function(config, options) {
// Make sure config is initialised
if( ! config ) {
config = JSON.parse(JSON.stringify(self.defaults));
}
var datasetConfig = JSON.parse(JSON.stringify(config));
var optionsIn = JSON.parse(JSON.stringify(options));
for (var k in optionsIn) {
datasetConfig[k] = optionsIn[k];
}
return datasetConfig;
}
|
[
"function",
"(",
"config",
",",
"options",
")",
"{",
"if",
"(",
"!",
"config",
")",
"{",
"config",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"self",
".",
"defaults",
")",
")",
";",
"}",
"var",
"datasetConfig",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"config",
")",
")",
";",
"var",
"optionsIn",
"=",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"options",
")",
")",
";",
"for",
"(",
"var",
"k",
"in",
"optionsIn",
")",
"{",
"datasetConfig",
"[",
"k",
"]",
"=",
"optionsIn",
"[",
"k",
"]",
";",
"}",
"return",
"datasetConfig",
";",
"}"
] |
Sets options for passed in config, if !config then options will be applied to default config.
@param {Object} config - config to which options will be applied
@param {Object} options - options to be applied to the config
|
[
"Sets",
"options",
"for",
"passed",
"in",
"config",
"if",
"!config",
"then",
"options",
"will",
"be",
"applied",
"to",
"default",
"config",
"."
] |
b8f3864485da482df57fbe64904926983ef910a9
|
https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/src/sync-client.js#L200-L214
|
train
|
|
feedhenry/fh-sync-js
|
src/sync-client.js
|
function(callback) {
var online = true;
// first, check if navigator.online is available
if(typeof navigator.onLine !== "undefined"){
online = navigator.onLine;
}
// second, check if Phonegap is available and has online info
if(online){
//use phonegap to determin if the network is available
if(typeof navigator.network !== "undefined" && typeof navigator.network.connection !== "undefined"){
var networkType = navigator.network.connection.type;
if(networkType === "none" || networkType === null) {
online = false;
}
}
}
return callback(online);
}
|
javascript
|
function(callback) {
var online = true;
// first, check if navigator.online is available
if(typeof navigator.onLine !== "undefined"){
online = navigator.onLine;
}
// second, check if Phonegap is available and has online info
if(online){
//use phonegap to determin if the network is available
if(typeof navigator.network !== "undefined" && typeof navigator.network.connection !== "undefined"){
var networkType = navigator.network.connection.type;
if(networkType === "none" || networkType === null) {
online = false;
}
}
}
return callback(online);
}
|
[
"function",
"(",
"callback",
")",
"{",
"var",
"online",
"=",
"true",
";",
"if",
"(",
"typeof",
"navigator",
".",
"onLine",
"!==",
"\"undefined\"",
")",
"{",
"online",
"=",
"navigator",
".",
"onLine",
";",
"}",
"if",
"(",
"online",
")",
"{",
"if",
"(",
"typeof",
"navigator",
".",
"network",
"!==",
"\"undefined\"",
"&&",
"typeof",
"navigator",
".",
"network",
".",
"connection",
"!==",
"\"undefined\"",
")",
"{",
"var",
"networkType",
"=",
"navigator",
".",
"network",
".",
"connection",
".",
"type",
";",
"if",
"(",
"networkType",
"===",
"\"none\"",
"||",
"networkType",
"===",
"null",
")",
"{",
"online",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"callback",
"(",
"online",
")",
";",
"}"
] |
PRIVATE FUNCTIONS
Check if client is online.
Function is used to stop sync from executing requests.
|
[
"PRIVATE",
"FUNCTIONS",
"Check",
"if",
"client",
"is",
"online",
".",
"Function",
"is",
"used",
"to",
"stop",
"sync",
"from",
"executing",
"requests",
"."
] |
b8f3864485da482df57fbe64904926983ef910a9
|
https://github.com/feedhenry/fh-sync-js/blob/b8f3864485da482df57fbe64904926983ef910a9/src/sync-client.js#L342-L362
|
train
|
|
pifantastic/teamcity-service-messages
|
lib/message.js
|
function (type, args) {
this.type = type;
this.single = false;
// Message is a 'multiple attribute message'.
if (typeof args === 'object' || typeof args === 'undefined') {
this.args = args || {};
}
// Message is a 'single attribute message'.
else {
this.single = true;
this.args = args;
}
if (!this.single) {
if (this.args.flowId) {
this.arg('flowId', this.args.flowId);
}
else if (index.autoFlowId) {
this.arg('flowId', Message.flowId);
}
}
}
|
javascript
|
function (type, args) {
this.type = type;
this.single = false;
// Message is a 'multiple attribute message'.
if (typeof args === 'object' || typeof args === 'undefined') {
this.args = args || {};
}
// Message is a 'single attribute message'.
else {
this.single = true;
this.args = args;
}
if (!this.single) {
if (this.args.flowId) {
this.arg('flowId', this.args.flowId);
}
else if (index.autoFlowId) {
this.arg('flowId', Message.flowId);
}
}
}
|
[
"function",
"(",
"type",
",",
"args",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"single",
"=",
"false",
";",
"if",
"(",
"typeof",
"args",
"===",
"'object'",
"||",
"typeof",
"args",
"===",
"'undefined'",
")",
"{",
"this",
".",
"args",
"=",
"args",
"||",
"{",
"}",
";",
"}",
"else",
"{",
"this",
".",
"single",
"=",
"true",
";",
"this",
".",
"args",
"=",
"args",
";",
"}",
"if",
"(",
"!",
"this",
".",
"single",
")",
"{",
"if",
"(",
"this",
".",
"args",
".",
"flowId",
")",
"{",
"this",
".",
"arg",
"(",
"'flowId'",
",",
"this",
".",
"args",
".",
"flowId",
")",
";",
"}",
"else",
"if",
"(",
"index",
".",
"autoFlowId",
")",
"{",
"this",
".",
"arg",
"(",
"'flowId'",
",",
"Message",
".",
"flowId",
")",
";",
"}",
"}",
"}"
] |
Constructs a message formatted for consumption by TeamCity.
@param {String} type
@param {Object} args
|
[
"Constructs",
"a",
"message",
"formatted",
"for",
"consumption",
"by",
"TeamCity",
"."
] |
5e0d45fc89b3cba9912e8487de889c5442aba24f
|
https://github.com/pifantastic/teamcity-service-messages/blob/5e0d45fc89b3cba9912e8487de889c5442aba24f/lib/message.js#L23-L45
|
train
|
|
geneontology/amigo
|
javascript/web/TEBase.js
|
stage_01
|
function stage_01(gp_accs){
// Ready logging.
var logger = new bbop.logger();
logger.DEBUG = true;
function ll(str){ logger.kvetch('JSM01: ' + str); }
ll('');
ll('Stage 01 start...');
// Helpers.
var each = bbop.core.each;
var dump = bbop.core.dump;
// Prep the progress bar and hide the order selector until we're
// done.
jQuery("#progress-text").empty();
jQuery("#progress-text").append('<b>Loading...</b>');
//jQuery("#progress-bar").empty();
jQuery("#progress-widget").show();
// Next, setup the manager environment.
ll('Setting up manager.');
var server_meta = new amigo.data.server();
//var gloc = server_meta.golr_base();
var gloc = 'http://golr.berkeleybop.org/solr/';
var gconf = new bbop.golr.conf(amigo.data.golr);
var go = new bbop.golr.manager.jquery(gloc, gconf);
go.set_personality('annotation'); // always this
//go.debug(false);
// Now, cycle though all of the gps to collect info on.
ll('Gathering batch URLs for annotation data...');
var gp_user_order = {};
each(gp_accs, function(acc, index){
// Set/reset for the next query.
go.reset_query_filters(); // reset from the last iteration
//
go.add_query_filter('document_category', 'annotation', ['*']);
go.add_query_filter('bioentity', acc);
//go.add_query_filter('taxon', taxon_filter, ['*']); }
go.set('rows', 0); // we don't need any actual rows returned
go.set_facet_limit(-1); // we are only interested in facet counts
go.facets(['regulates_closure']);
go.add_to_batch();
gp_user_order[acc] = index;
});
var gp_info = {};
// Fetch the data and grab the number we want.
var accumulator_fun = function(resp){
// Who was this?
var acc = null;
var fqs = resp.parameter('fq');
//console.log(fqs);
//console.log(resp);
each(fqs, function(fq){
//console.log(fq);
//console.log(fq.substr(0, 9));
if( fq.substr(0, 9) === 'bioentity' ){
acc = fq.substr(10, fq.length-1);
ll('Looking at info for: ' + acc);
}
});
if( acc ){
//ll('Looking at info for: ' + acc);
console.log(resp);
var ffs = resp.facet_field('regulates_closure');
each(ffs, function(pair){
console.log(pair);
// Ensure existance.
if( ! gp_info[acc] ){
gp_info[acc] = {};
}
//
gp_info[acc][pair[0]] = pair[1];
});
}
};
// The final function is the data renderer.
var final_fun = function(){
ll('Starting final in stage 01...');
ll('gp_info: ' + dump(gp_info));
stage_02(gp_info, gp_accs);
ll('Completed stage 01!');
};
go.run_batch(accumulator_fun, final_fun);
}
|
javascript
|
function stage_01(gp_accs){
// Ready logging.
var logger = new bbop.logger();
logger.DEBUG = true;
function ll(str){ logger.kvetch('JSM01: ' + str); }
ll('');
ll('Stage 01 start...');
// Helpers.
var each = bbop.core.each;
var dump = bbop.core.dump;
// Prep the progress bar and hide the order selector until we're
// done.
jQuery("#progress-text").empty();
jQuery("#progress-text").append('<b>Loading...</b>');
//jQuery("#progress-bar").empty();
jQuery("#progress-widget").show();
// Next, setup the manager environment.
ll('Setting up manager.');
var server_meta = new amigo.data.server();
//var gloc = server_meta.golr_base();
var gloc = 'http://golr.berkeleybop.org/solr/';
var gconf = new bbop.golr.conf(amigo.data.golr);
var go = new bbop.golr.manager.jquery(gloc, gconf);
go.set_personality('annotation'); // always this
//go.debug(false);
// Now, cycle though all of the gps to collect info on.
ll('Gathering batch URLs for annotation data...');
var gp_user_order = {};
each(gp_accs, function(acc, index){
// Set/reset for the next query.
go.reset_query_filters(); // reset from the last iteration
//
go.add_query_filter('document_category', 'annotation', ['*']);
go.add_query_filter('bioentity', acc);
//go.add_query_filter('taxon', taxon_filter, ['*']); }
go.set('rows', 0); // we don't need any actual rows returned
go.set_facet_limit(-1); // we are only interested in facet counts
go.facets(['regulates_closure']);
go.add_to_batch();
gp_user_order[acc] = index;
});
var gp_info = {};
// Fetch the data and grab the number we want.
var accumulator_fun = function(resp){
// Who was this?
var acc = null;
var fqs = resp.parameter('fq');
//console.log(fqs);
//console.log(resp);
each(fqs, function(fq){
//console.log(fq);
//console.log(fq.substr(0, 9));
if( fq.substr(0, 9) === 'bioentity' ){
acc = fq.substr(10, fq.length-1);
ll('Looking at info for: ' + acc);
}
});
if( acc ){
//ll('Looking at info for: ' + acc);
console.log(resp);
var ffs = resp.facet_field('regulates_closure');
each(ffs, function(pair){
console.log(pair);
// Ensure existance.
if( ! gp_info[acc] ){
gp_info[acc] = {};
}
//
gp_info[acc][pair[0]] = pair[1];
});
}
};
// The final function is the data renderer.
var final_fun = function(){
ll('Starting final in stage 01...');
ll('gp_info: ' + dump(gp_info));
stage_02(gp_info, gp_accs);
ll('Completed stage 01!');
};
go.run_batch(accumulator_fun, final_fun);
}
|
[
"function",
"stage_01",
"(",
"gp_accs",
")",
"{",
"var",
"logger",
"=",
"new",
"bbop",
".",
"logger",
"(",
")",
";",
"logger",
".",
"DEBUG",
"=",
"true",
";",
"function",
"ll",
"(",
"str",
")",
"{",
"logger",
".",
"kvetch",
"(",
"'JSM01: '",
"+",
"str",
")",
";",
"}",
"ll",
"(",
"''",
")",
";",
"ll",
"(",
"'Stage 01 start...'",
")",
";",
"var",
"each",
"=",
"bbop",
".",
"core",
".",
"each",
";",
"var",
"dump",
"=",
"bbop",
".",
"core",
".",
"dump",
";",
"jQuery",
"(",
"\"#progress-text\"",
")",
".",
"empty",
"(",
")",
";",
"jQuery",
"(",
"\"#progress-text\"",
")",
".",
"append",
"(",
"'<b>Loading...</b>'",
")",
";",
"jQuery",
"(",
"\"#progress-widget\"",
")",
".",
"show",
"(",
")",
";",
"ll",
"(",
"'Setting up manager.'",
")",
";",
"var",
"server_meta",
"=",
"new",
"amigo",
".",
"data",
".",
"server",
"(",
")",
";",
"var",
"gloc",
"=",
"'http://golr.berkeleybop.org/solr/'",
";",
"var",
"gconf",
"=",
"new",
"bbop",
".",
"golr",
".",
"conf",
"(",
"amigo",
".",
"data",
".",
"golr",
")",
";",
"var",
"go",
"=",
"new",
"bbop",
".",
"golr",
".",
"manager",
".",
"jquery",
"(",
"gloc",
",",
"gconf",
")",
";",
"go",
".",
"set_personality",
"(",
"'annotation'",
")",
";",
"ll",
"(",
"'Gathering batch URLs for annotation data...'",
")",
";",
"var",
"gp_user_order",
"=",
"{",
"}",
";",
"each",
"(",
"gp_accs",
",",
"function",
"(",
"acc",
",",
"index",
")",
"{",
"go",
".",
"reset_query_filters",
"(",
")",
";",
"go",
".",
"add_query_filter",
"(",
"'document_category'",
",",
"'annotation'",
",",
"[",
"'*'",
"]",
")",
";",
"go",
".",
"add_query_filter",
"(",
"'bioentity'",
",",
"acc",
")",
";",
"go",
".",
"set",
"(",
"'rows'",
",",
"0",
")",
";",
"go",
".",
"set_facet_limit",
"(",
"-",
"1",
")",
";",
"go",
".",
"facets",
"(",
"[",
"'regulates_closure'",
"]",
")",
";",
"go",
".",
"add_to_batch",
"(",
")",
";",
"gp_user_order",
"[",
"acc",
"]",
"=",
"index",
";",
"}",
")",
";",
"var",
"gp_info",
"=",
"{",
"}",
";",
"var",
"accumulator_fun",
"=",
"function",
"(",
"resp",
")",
"{",
"var",
"acc",
"=",
"null",
";",
"var",
"fqs",
"=",
"resp",
".",
"parameter",
"(",
"'fq'",
")",
";",
"each",
"(",
"fqs",
",",
"function",
"(",
"fq",
")",
"{",
"if",
"(",
"fq",
".",
"substr",
"(",
"0",
",",
"9",
")",
"===",
"'bioentity'",
")",
"{",
"acc",
"=",
"fq",
".",
"substr",
"(",
"10",
",",
"fq",
".",
"length",
"-",
"1",
")",
";",
"ll",
"(",
"'Looking at info for: '",
"+",
"acc",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"acc",
")",
"{",
"console",
".",
"log",
"(",
"resp",
")",
";",
"var",
"ffs",
"=",
"resp",
".",
"facet_field",
"(",
"'regulates_closure'",
")",
";",
"each",
"(",
"ffs",
",",
"function",
"(",
"pair",
")",
"{",
"console",
".",
"log",
"(",
"pair",
")",
";",
"if",
"(",
"!",
"gp_info",
"[",
"acc",
"]",
")",
"{",
"gp_info",
"[",
"acc",
"]",
"=",
"{",
"}",
";",
"}",
"gp_info",
"[",
"acc",
"]",
"[",
"pair",
"[",
"0",
"]",
"]",
"=",
"pair",
"[",
"1",
"]",
";",
"}",
")",
";",
"}",
"}",
";",
"var",
"final_fun",
"=",
"function",
"(",
")",
"{",
"ll",
"(",
"'Starting final in stage 01...'",
")",
";",
"ll",
"(",
"'gp_info: '",
"+",
"dump",
"(",
"gp_info",
")",
")",
";",
"stage_02",
"(",
"gp_info",
",",
"gp_accs",
")",
";",
"ll",
"(",
"'Completed stage 01!'",
")",
";",
"}",
";",
"go",
".",
"run_batch",
"(",
"accumulator_fun",
",",
"final_fun",
")",
";",
"}"
] |
Get the information for the incoming accs, launch stage 02.
|
[
"Get",
"the",
"information",
"for",
"the",
"incoming",
"accs",
"launch",
"stage",
"02",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/TEBase.js#L51-L151
|
train
|
geneontology/amigo
|
scripts/web-bowser.js
|
_prep_download_url
|
function _prep_download_url(){
var engine = new impl_engine(golr_response);
//engine.method('GET');
//engine.use_jsonp(true);
var gman = new golr_manager(gserv, gconf, engine, 'async');
gman.set_personality('annotation');
gman.add_query_filter('document_category', 'annotation', ['*']);
// gman.set_results_count(download_count);
var field_list = [ // from GAF
'source', // c1
'bioentity_internal_id', // c2; not bioentity
'bioentity_label', // c3
'qualifier', // c4
'annotation_class', // c5
'reference', // c6
'evidence_type', // c7
'evidence_with', // c8
'aspect', // c9
'bioentity_name', // c10
'synonym', // c11
'type', // c12
'taxon', // c13
'date', // c14
'assigned_by', // c15
'annotation_extension_class', // c16
'bioentity_isoform' // c17
];
// gman.set('fl', field_list.join(','));
// //manager.set('rows', arg_hash['rows']);
// gman.set('csv.encapsulator', '');
// gman.set('csv.separator', '%09');
// gman.set('csv.header', 'false');
// gman.set('csv.mv.separator', '|');
// gman.set('start', _random_number(5));
//gman.set('start', _random_number(5));
gman.set_extra('&start=' + _random_number(4));
//console.log(gman.get_download_url(field_list, { 'rows': lines }));
return gman.get_download_url(field_list, { 'rows': lines });
}
|
javascript
|
function _prep_download_url(){
var engine = new impl_engine(golr_response);
//engine.method('GET');
//engine.use_jsonp(true);
var gman = new golr_manager(gserv, gconf, engine, 'async');
gman.set_personality('annotation');
gman.add_query_filter('document_category', 'annotation', ['*']);
// gman.set_results_count(download_count);
var field_list = [ // from GAF
'source', // c1
'bioentity_internal_id', // c2; not bioentity
'bioentity_label', // c3
'qualifier', // c4
'annotation_class', // c5
'reference', // c6
'evidence_type', // c7
'evidence_with', // c8
'aspect', // c9
'bioentity_name', // c10
'synonym', // c11
'type', // c12
'taxon', // c13
'date', // c14
'assigned_by', // c15
'annotation_extension_class', // c16
'bioentity_isoform' // c17
];
// gman.set('fl', field_list.join(','));
// //manager.set('rows', arg_hash['rows']);
// gman.set('csv.encapsulator', '');
// gman.set('csv.separator', '%09');
// gman.set('csv.header', 'false');
// gman.set('csv.mv.separator', '|');
// gman.set('start', _random_number(5));
//gman.set('start', _random_number(5));
gman.set_extra('&start=' + _random_number(4));
//console.log(gman.get_download_url(field_list, { 'rows': lines }));
return gman.get_download_url(field_list, { 'rows': lines });
}
|
[
"function",
"_prep_download_url",
"(",
")",
"{",
"var",
"engine",
"=",
"new",
"impl_engine",
"(",
"golr_response",
")",
";",
"var",
"gman",
"=",
"new",
"golr_manager",
"(",
"gserv",
",",
"gconf",
",",
"engine",
",",
"'async'",
")",
";",
"gman",
".",
"set_personality",
"(",
"'annotation'",
")",
";",
"gman",
".",
"add_query_filter",
"(",
"'document_category'",
",",
"'annotation'",
",",
"[",
"'*'",
"]",
")",
";",
"var",
"field_list",
"=",
"[",
"'source'",
",",
"'bioentity_internal_id'",
",",
"'bioentity_label'",
",",
"'qualifier'",
",",
"'annotation_class'",
",",
"'reference'",
",",
"'evidence_type'",
",",
"'evidence_with'",
",",
"'aspect'",
",",
"'bioentity_name'",
",",
"'synonym'",
",",
"'type'",
",",
"'taxon'",
",",
"'date'",
",",
"'assigned_by'",
",",
"'annotation_extension_class'",
",",
"'bioentity_isoform'",
"]",
";",
"gman",
".",
"set_extra",
"(",
"'&start='",
"+",
"_random_number",
"(",
"4",
")",
")",
";",
"return",
"gman",
".",
"get_download_url",
"(",
"field_list",
",",
"{",
"'rows'",
":",
"lines",
"}",
")",
";",
"}"
] |
Spin up download agents. The download-y bits.
|
[
"Spin",
"up",
"download",
"agents",
".",
"The",
"download",
"-",
"y",
"bits",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/scripts/web-bowser.js#L153-L195
|
train
|
geneontology/amigo
|
javascript/web/BulkSearch.js
|
function(identifiers, search_fields){
ll('run search');
search.set_targets(identifiers, search_fields);
//
search.search();
// Scroll to results.
jQuery('html, body').animate({
scrollTop: jQuery('#' + 'results-area').offset().top
}, 500);
}
|
javascript
|
function(identifiers, search_fields){
ll('run search');
search.set_targets(identifiers, search_fields);
//
search.search();
// Scroll to results.
jQuery('html, body').animate({
scrollTop: jQuery('#' + 'results-area').offset().top
}, 500);
}
|
[
"function",
"(",
"identifiers",
",",
"search_fields",
")",
"{",
"ll",
"(",
"'run search'",
")",
";",
"search",
".",
"set_targets",
"(",
"identifiers",
",",
"search_fields",
")",
";",
"search",
".",
"search",
"(",
")",
";",
"jQuery",
"(",
"'html, body'",
")",
".",
"animate",
"(",
"{",
"scrollTop",
":",
"jQuery",
"(",
"'#'",
"+",
"'results-area'",
")",
".",
"offset",
"(",
")",
".",
"top",
"}",
",",
"500",
")",
";",
"}"
] |
Now that we're setup, activate the display button, and make it so that it will only work on "good" input.
|
[
"Now",
"that",
"we",
"re",
"setup",
"activate",
"the",
"display",
"button",
"and",
"make",
"it",
"so",
"that",
"it",
"will",
"only",
"work",
"on",
"good",
"input",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/BulkSearch.js#L206-L218
|
train
|
|
Famous/famous-angular
|
dist/famous-angular.js
|
function (element) {
if(!element[0]) return false;
//short-circuit most common case
if(IS_FA.test(element[0].tagName)) return true;
//otherwise loop through attributes
var ret = false;
angular.forEach(element[0].attributes, function(attr){
ret = ret || IS_FA.test(attr);
});
return ret;
}
|
javascript
|
function (element) {
if(!element[0]) return false;
//short-circuit most common case
if(IS_FA.test(element[0].tagName)) return true;
//otherwise loop through attributes
var ret = false;
angular.forEach(element[0].attributes, function(attr){
ret = ret || IS_FA.test(attr);
});
return ret;
}
|
[
"function",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"element",
"[",
"0",
"]",
")",
"return",
"false",
";",
"if",
"(",
"IS_FA",
".",
"test",
"(",
"element",
"[",
"0",
"]",
".",
"tagName",
")",
")",
"return",
"true",
";",
"var",
"ret",
"=",
"false",
";",
"angular",
".",
"forEach",
"(",
"element",
"[",
"0",
"]",
".",
"attributes",
",",
"function",
"(",
"attr",
")",
"{",
"ret",
"=",
"ret",
"||",
"IS_FA",
".",
"test",
"(",
"attr",
")",
";",
"}",
")",
";",
"return",
"ret",
";",
"}"
] |
Check if the element selected is an fa- element
@param {Array} element - derived element
@return {boolean}
|
[
"Check",
"if",
"the",
"element",
"selected",
"is",
"an",
"fa",
"-",
"element"
] |
ce9e495509789295c8d57b7f9a3b8b464994a5b1
|
https://github.com/Famous/famous-angular/blob/ce9e495509789295c8d57b7f9a3b8b464994a5b1/dist/famous-angular.js#L219-L231
|
train
|
|
Famous/famous-angular
|
dist/famous-angular.js
|
function(a, b) {
if (typeof a === "number") {
return a - b;
}
else {
return a.map(function(x, i) { return x - b[i]; });
}
}
|
javascript
|
function(a, b) {
if (typeof a === "number") {
return a - b;
}
else {
return a.map(function(x, i) { return x - b[i]; });
}
}
|
[
"function",
"(",
"a",
",",
"b",
")",
"{",
"if",
"(",
"typeof",
"a",
"===",
"\"number\"",
")",
"{",
"return",
"a",
"-",
"b",
";",
"}",
"else",
"{",
"return",
"a",
".",
"map",
"(",
"function",
"(",
"x",
",",
"i",
")",
"{",
"return",
"x",
"-",
"b",
"[",
"i",
"]",
";",
"}",
")",
";",
"}",
"}"
] |
polymorphic subtract for scalars and vectors
|
[
"polymorphic",
"subtract",
"for",
"scalars",
"and",
"vectors"
] |
ce9e495509789295c8d57b7f9a3b8b464994a5b1
|
https://github.com/Famous/famous-angular/blob/ce9e495509789295c8d57b7f9a3b8b464994a5b1/dist/famous-angular.js#L917-L924
|
train
|
|
Famous/famous-angular
|
dist/famous-angular.js
|
function(A, b) {
// b is a scalar, A is a scalar or a vector
if (typeof A === "number") {
return A * b;
}
else {
return A.map(function(x) { return x * b; });
}
}
|
javascript
|
function(A, b) {
// b is a scalar, A is a scalar or a vector
if (typeof A === "number") {
return A * b;
}
else {
return A.map(function(x) { return x * b; });
}
}
|
[
"function",
"(",
"A",
",",
"b",
")",
"{",
"if",
"(",
"typeof",
"A",
"===",
"\"number\"",
")",
"{",
"return",
"A",
"*",
"b",
";",
"}",
"else",
"{",
"return",
"A",
".",
"map",
"(",
"function",
"(",
"x",
")",
"{",
"return",
"x",
"*",
"b",
";",
"}",
")",
";",
"}",
"}"
] |
polymorphic multiply for scalar and vectors
|
[
"polymorphic",
"multiply",
"for",
"scalar",
"and",
"vectors"
] |
ce9e495509789295c8d57b7f9a3b8b464994a5b1
|
https://github.com/Famous/famous-angular/blob/ce9e495509789295c8d57b7f9a3b8b464994a5b1/dist/famous-angular.js#L927-L935
|
train
|
|
Famous/famous-angular
|
dist/famous-angular.js
|
onTouchStart
|
function onTouchStart(event) {
var touches = event.touches && event.touches.length ? event.touches : [event];
var x = touches[0].clientX;
var y = touches[0].clientY;
touchCoordinates.push(x, y);
$timeout(function() {
// Remove the allowable region.
for (var i = 0; i < touchCoordinates.length; i += 2) {
if (touchCoordinates[i] === x && touchCoordinates[i+1] === y) {
touchCoordinates.splice(i, i + 2);
return;
}
}
}, PREVENT_DURATION, false);
}
|
javascript
|
function onTouchStart(event) {
var touches = event.touches && event.touches.length ? event.touches : [event];
var x = touches[0].clientX;
var y = touches[0].clientY;
touchCoordinates.push(x, y);
$timeout(function() {
// Remove the allowable region.
for (var i = 0; i < touchCoordinates.length; i += 2) {
if (touchCoordinates[i] === x && touchCoordinates[i+1] === y) {
touchCoordinates.splice(i, i + 2);
return;
}
}
}, PREVENT_DURATION, false);
}
|
[
"function",
"onTouchStart",
"(",
"event",
")",
"{",
"var",
"touches",
"=",
"event",
".",
"touches",
"&&",
"event",
".",
"touches",
".",
"length",
"?",
"event",
".",
"touches",
":",
"[",
"event",
"]",
";",
"var",
"x",
"=",
"touches",
"[",
"0",
"]",
".",
"clientX",
";",
"var",
"y",
"=",
"touches",
"[",
"0",
"]",
".",
"clientY",
";",
"touchCoordinates",
".",
"push",
"(",
"x",
",",
"y",
")",
";",
"$timeout",
"(",
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"touchCoordinates",
".",
"length",
";",
"i",
"+=",
"2",
")",
"{",
"if",
"(",
"touchCoordinates",
"[",
"i",
"]",
"===",
"x",
"&&",
"touchCoordinates",
"[",
"i",
"+",
"1",
"]",
"===",
"y",
")",
"{",
"touchCoordinates",
".",
"splice",
"(",
"i",
",",
"i",
"+",
"2",
")",
";",
"return",
";",
"}",
"}",
"}",
",",
"PREVENT_DURATION",
",",
"false",
")",
";",
"}"
] |
Global touchstart handler that creates an allowable region for a click event. This allowable region can be removed by preventGhostClick if we want to bust it.
|
[
"Global",
"touchstart",
"handler",
"that",
"creates",
"an",
"allowable",
"region",
"for",
"a",
"click",
"event",
".",
"This",
"allowable",
"region",
"can",
"be",
"removed",
"by",
"preventGhostClick",
"if",
"we",
"want",
"to",
"bust",
"it",
"."
] |
ce9e495509789295c8d57b7f9a3b8b464994a5b1
|
https://github.com/Famous/famous-angular/blob/ce9e495509789295c8d57b7f9a3b8b464994a5b1/dist/famous-angular.js#L3353-L3368
|
train
|
geneontology/amigo
|
javascript/web/TermDetails.js
|
_shrink_wrap
|
function _shrink_wrap(elt_id){
// Now take what we have, and wrap around some expansion code if
// it looks like it is too long.
var _trim_hash = {};
var _trimit = 100;
// Only want to compile once.
var ea_regexp = new RegExp("\<\/a\>", "i"); // detect an <a>
var br_regexp = new RegExp("\<br\ \/\>", "i"); // detect a <br />
function _trim_and_store( in_str ){
var retval = in_str;
// Let there be tests.
var list_p = br_regexp.test(retval);
var anchors_p = ea_regexp.test(retval);
// Try and break without breaking anchors, etc.
var tease = null;
if( ! anchors_p && ! list_p ){
// A normal string then...trim it!
//ll("\tT&S: easy normal text, go nuts!");
tease = new html.span(bbop.crop(retval, _trimit, '...'),
{'generate_id': true});
}else if( anchors_p && ! list_p ){
// It looks like it is a link without a break, so not
// a list. We cannot trim this safely.
//ll("\tT&S: single link so cannot work on!");
}else{
//ll("\tT&S: we have a list to deal with");
var new_str_list = retval.split(br_regexp);
if( new_str_list.length <= 3 ){
// Let's just ignore lists that are only three
// items.
//ll("\tT&S: pass thru list length <= 3");
}else{
//ll("\tT&S: contruct into 2 plus tag");
var new_str = '';
new_str = new_str + new_str_list.shift();
new_str = new_str + '<br />';
new_str = new_str + new_str_list.shift();
tease = new html.span(new_str, {'generate_id': true});
}
}
// If we have a tease (able to break down incoming string),
// assemble the rest of the packet to create the UI.
if( tease ){
// Setup the text for tease and full versions.
var bgen = function(lbl, dsc){
var b = new html.button(lbl, {
'generate_id': true,
'type': 'button',
'title': dsc || lbl,
//'class': 'btn btn-default btn-xs'
'class': 'btn btn-primary btn-xs'
});
return b;
};
var more_b = new bgen('more', 'Display the complete list');
var full = new html.span(retval, {'generate_id': true});
var less_b = new bgen('less', 'Display the truncated list');
// Store the different parts for later activation.
var tease_id = tease.get_id();
var more_b_id = more_b.get_id();
var full_id = full.get_id();
var less_b_id = less_b.get_id();
_trim_hash[tease_id] = [tease_id, more_b_id, full_id, less_b_id];
// New final string.
retval = tease.to_string() + " " +
more_b.to_string() + " " +
full.to_string() + " " +
less_b.to_string();
}
return retval;
}
var pre_html = jQuery('#' + elt_id).html();
if( pre_html && pre_html.length && (pre_html.length > _trimit * 2) ){
// Get the new value into the wild.
var new_str = _trim_and_store(pre_html);
if( new_str !== pre_html ){
jQuery('#' + elt_id).html(new_str);
// Bind the jQuery events to it.
// Add the roll-up/down events to the doc.
us.each(_trim_hash, function(val, key){
var tease_id = val[0];
var more_b_id = val[1];
var full_id = val[2];
var less_b_id = val[3];
// Initial state.
jQuery('#' + full_id ).hide();
jQuery('#' + less_b_id ).hide();
// Click actions to go back and forth.
jQuery('#' + more_b_id ).click(function(){
jQuery('#' + tease_id ).hide();
jQuery('#' + more_b_id ).hide();
jQuery('#' + full_id ).show('fast');
jQuery('#' + less_b_id ).show('fast');
});
jQuery('#' + less_b_id ).click(function(){
jQuery('#' + full_id ).hide();
jQuery('#' + less_b_id ).hide();
jQuery('#' + tease_id ).show('fast');
jQuery('#' + more_b_id ).show('fast');
});
});
}
}
}
|
javascript
|
function _shrink_wrap(elt_id){
// Now take what we have, and wrap around some expansion code if
// it looks like it is too long.
var _trim_hash = {};
var _trimit = 100;
// Only want to compile once.
var ea_regexp = new RegExp("\<\/a\>", "i"); // detect an <a>
var br_regexp = new RegExp("\<br\ \/\>", "i"); // detect a <br />
function _trim_and_store( in_str ){
var retval = in_str;
// Let there be tests.
var list_p = br_regexp.test(retval);
var anchors_p = ea_regexp.test(retval);
// Try and break without breaking anchors, etc.
var tease = null;
if( ! anchors_p && ! list_p ){
// A normal string then...trim it!
//ll("\tT&S: easy normal text, go nuts!");
tease = new html.span(bbop.crop(retval, _trimit, '...'),
{'generate_id': true});
}else if( anchors_p && ! list_p ){
// It looks like it is a link without a break, so not
// a list. We cannot trim this safely.
//ll("\tT&S: single link so cannot work on!");
}else{
//ll("\tT&S: we have a list to deal with");
var new_str_list = retval.split(br_regexp);
if( new_str_list.length <= 3 ){
// Let's just ignore lists that are only three
// items.
//ll("\tT&S: pass thru list length <= 3");
}else{
//ll("\tT&S: contruct into 2 plus tag");
var new_str = '';
new_str = new_str + new_str_list.shift();
new_str = new_str + '<br />';
new_str = new_str + new_str_list.shift();
tease = new html.span(new_str, {'generate_id': true});
}
}
// If we have a tease (able to break down incoming string),
// assemble the rest of the packet to create the UI.
if( tease ){
// Setup the text for tease and full versions.
var bgen = function(lbl, dsc){
var b = new html.button(lbl, {
'generate_id': true,
'type': 'button',
'title': dsc || lbl,
//'class': 'btn btn-default btn-xs'
'class': 'btn btn-primary btn-xs'
});
return b;
};
var more_b = new bgen('more', 'Display the complete list');
var full = new html.span(retval, {'generate_id': true});
var less_b = new bgen('less', 'Display the truncated list');
// Store the different parts for later activation.
var tease_id = tease.get_id();
var more_b_id = more_b.get_id();
var full_id = full.get_id();
var less_b_id = less_b.get_id();
_trim_hash[tease_id] = [tease_id, more_b_id, full_id, less_b_id];
// New final string.
retval = tease.to_string() + " " +
more_b.to_string() + " " +
full.to_string() + " " +
less_b.to_string();
}
return retval;
}
var pre_html = jQuery('#' + elt_id).html();
if( pre_html && pre_html.length && (pre_html.length > _trimit * 2) ){
// Get the new value into the wild.
var new_str = _trim_and_store(pre_html);
if( new_str !== pre_html ){
jQuery('#' + elt_id).html(new_str);
// Bind the jQuery events to it.
// Add the roll-up/down events to the doc.
us.each(_trim_hash, function(val, key){
var tease_id = val[0];
var more_b_id = val[1];
var full_id = val[2];
var less_b_id = val[3];
// Initial state.
jQuery('#' + full_id ).hide();
jQuery('#' + less_b_id ).hide();
// Click actions to go back and forth.
jQuery('#' + more_b_id ).click(function(){
jQuery('#' + tease_id ).hide();
jQuery('#' + more_b_id ).hide();
jQuery('#' + full_id ).show('fast');
jQuery('#' + less_b_id ).show('fast');
});
jQuery('#' + less_b_id ).click(function(){
jQuery('#' + full_id ).hide();
jQuery('#' + less_b_id ).hide();
jQuery('#' + tease_id ).show('fast');
jQuery('#' + more_b_id ).show('fast');
});
});
}
}
}
|
[
"function",
"_shrink_wrap",
"(",
"elt_id",
")",
"{",
"var",
"_trim_hash",
"=",
"{",
"}",
";",
"var",
"_trimit",
"=",
"100",
";",
"var",
"ea_regexp",
"=",
"new",
"RegExp",
"(",
"\"\\<\\/a\\>\"",
",",
"\\<",
")",
";",
"\\/",
"\\>",
"\"i\"",
"var",
"br_regexp",
"=",
"new",
"RegExp",
"(",
"\"\\<br\\ \\/\\>\"",
",",
"\\<",
")",
";",
"}"
] |
Take and element, look at it's contents, if it's above a certain threshold, shrink with "more..." button, otherwise leave alone.
|
[
"Take",
"and",
"element",
"look",
"at",
"it",
"s",
"contents",
"if",
"it",
"s",
"above",
"a",
"certain",
"threshold",
"shrink",
"with",
"more",
"...",
"button",
"otherwise",
"leave",
"alone",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/TermDetails.js#L40-L158
|
train
|
strapi/strapi-generate-users
|
files/api/user/services/user.js
|
function (user, next) {
if (!user.hasOwnProperty('password') || !user.password || this.isHashed(user.password)) {
next(null, user);
} else {
bcrypt.hash(user.password, 10, function (err, hash) {
user.password = hash;
next(err, user);
});
}
}
|
javascript
|
function (user, next) {
if (!user.hasOwnProperty('password') || !user.password || this.isHashed(user.password)) {
next(null, user);
} else {
bcrypt.hash(user.password, 10, function (err, hash) {
user.password = hash;
next(err, user);
});
}
}
|
[
"function",
"(",
"user",
",",
"next",
")",
"{",
"if",
"(",
"!",
"user",
".",
"hasOwnProperty",
"(",
"'password'",
")",
"||",
"!",
"user",
".",
"password",
"||",
"this",
".",
"isHashed",
"(",
"user",
".",
"password",
")",
")",
"{",
"next",
"(",
"null",
",",
"user",
")",
";",
"}",
"else",
"{",
"bcrypt",
".",
"hash",
"(",
"user",
".",
"password",
",",
"10",
",",
"function",
"(",
"err",
",",
"hash",
")",
"{",
"user",
".",
"password",
"=",
"hash",
";",
"next",
"(",
"err",
",",
"user",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Helper used to hash the password of a `user`.
@param {Object} user
@param {Function} next
|
[
"Helper",
"used",
"to",
"hash",
"the",
"password",
"of",
"a",
"user",
"."
] |
e7e8913165a591c26081706fedaec9dd4c801c50
|
https://github.com/strapi/strapi-generate-users/blob/e7e8913165a591c26081706fedaec9dd4c801c50/files/api/user/services/user.js#L25-L34
|
train
|
|
geneontology/amigo
|
javascript/bin/ringo-opensearch.js
|
create_request_function
|
function create_request_function(personality, doc_type,
id_field, label_field, link_type){
return function(request, query) {
// Declare a delayed response.
var response = new Deferred();
//response.wait(5000); // 5s wait for resolution
// New agent on every call.
var go = new bbop.golr.manager.ringo(server_loc, gconf);
go.set_personality(personality); // profile in gconf
go.add_query_filter('document_category', doc_type);
// Define what we do when our GOlr (async) information
// comes back within the scope of the deferred response
// variable.
function golr_callback_action(resp){
// Return caches for the values we'll collect.
var ret_terms = [];
var ret_descs = [];
var ret_links = [];
// Gather document info if available.
//var found_docs = resp.documents();
bbop.core.each(resp.documents(),
function(doc){
var id = doc[id_field];
var label = doc[label_field];
ret_terms.push(label);
ret_descs.push(id);
ret_links.push(linker.url(id, link_type));
});
// Assemble final answer into the OpenSearch JSON
// form.
var ret_body = [query];
ret_body.push(ret_terms);
ret_body.push(ret_descs);
ret_body.push(ret_links);
var ans = {
status: 200,
headers: {'Content-Type': 'application/json'},
body: [bbop.core.to_string(ret_body)]
};
response.resolve(ans);
}
// Run the agent action.
//go.set_query(query);
go.set_comfy_query(query);
go.register('search', 'do', golr_callback_action);
go.update('search');
return response.promise;
};
}
|
javascript
|
function create_request_function(personality, doc_type,
id_field, label_field, link_type){
return function(request, query) {
// Declare a delayed response.
var response = new Deferred();
//response.wait(5000); // 5s wait for resolution
// New agent on every call.
var go = new bbop.golr.manager.ringo(server_loc, gconf);
go.set_personality(personality); // profile in gconf
go.add_query_filter('document_category', doc_type);
// Define what we do when our GOlr (async) information
// comes back within the scope of the deferred response
// variable.
function golr_callback_action(resp){
// Return caches for the values we'll collect.
var ret_terms = [];
var ret_descs = [];
var ret_links = [];
// Gather document info if available.
//var found_docs = resp.documents();
bbop.core.each(resp.documents(),
function(doc){
var id = doc[id_field];
var label = doc[label_field];
ret_terms.push(label);
ret_descs.push(id);
ret_links.push(linker.url(id, link_type));
});
// Assemble final answer into the OpenSearch JSON
// form.
var ret_body = [query];
ret_body.push(ret_terms);
ret_body.push(ret_descs);
ret_body.push(ret_links);
var ans = {
status: 200,
headers: {'Content-Type': 'application/json'},
body: [bbop.core.to_string(ret_body)]
};
response.resolve(ans);
}
// Run the agent action.
//go.set_query(query);
go.set_comfy_query(query);
go.register('search', 'do', golr_callback_action);
go.update('search');
return response.promise;
};
}
|
[
"function",
"create_request_function",
"(",
"personality",
",",
"doc_type",
",",
"id_field",
",",
"label_field",
",",
"link_type",
")",
"{",
"return",
"function",
"(",
"request",
",",
"query",
")",
"{",
"var",
"response",
"=",
"new",
"Deferred",
"(",
")",
";",
"var",
"go",
"=",
"new",
"bbop",
".",
"golr",
".",
"manager",
".",
"ringo",
"(",
"server_loc",
",",
"gconf",
")",
";",
"go",
".",
"set_personality",
"(",
"personality",
")",
";",
"go",
".",
"add_query_filter",
"(",
"'document_category'",
",",
"doc_type",
")",
";",
"function",
"golr_callback_action",
"(",
"resp",
")",
"{",
"var",
"ret_terms",
"=",
"[",
"]",
";",
"var",
"ret_descs",
"=",
"[",
"]",
";",
"var",
"ret_links",
"=",
"[",
"]",
";",
"bbop",
".",
"core",
".",
"each",
"(",
"resp",
".",
"documents",
"(",
")",
",",
"function",
"(",
"doc",
")",
"{",
"var",
"id",
"=",
"doc",
"[",
"id_field",
"]",
";",
"var",
"label",
"=",
"doc",
"[",
"label_field",
"]",
";",
"ret_terms",
".",
"push",
"(",
"label",
")",
";",
"ret_descs",
".",
"push",
"(",
"id",
")",
";",
"ret_links",
".",
"push",
"(",
"linker",
".",
"url",
"(",
"id",
",",
"link_type",
")",
")",
";",
"}",
")",
";",
"var",
"ret_body",
"=",
"[",
"query",
"]",
";",
"ret_body",
".",
"push",
"(",
"ret_terms",
")",
";",
"ret_body",
".",
"push",
"(",
"ret_descs",
")",
";",
"ret_body",
".",
"push",
"(",
"ret_links",
")",
";",
"var",
"ans",
"=",
"{",
"status",
":",
"200",
",",
"headers",
":",
"{",
"'Content-Type'",
":",
"'application/json'",
"}",
",",
"body",
":",
"[",
"bbop",
".",
"core",
".",
"to_string",
"(",
"ret_body",
")",
"]",
"}",
";",
"response",
".",
"resolve",
"(",
"ans",
")",
";",
"}",
"go",
".",
"set_comfy_query",
"(",
"query",
")",
";",
"go",
".",
"register",
"(",
"'search'",
",",
"'do'",
",",
"golr_callback_action",
")",
";",
"go",
".",
"update",
"(",
"'search'",
")",
";",
"return",
"response",
".",
"promise",
";",
"}",
";",
"}"
] |
The request functions I use are very similar.
|
[
"The",
"request",
"functions",
"I",
"use",
"are",
"very",
"similar",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/bin/ringo-opensearch.js#L155-L213
|
train
|
geneontology/amigo
|
javascript/web/DrillExp.js
|
_doc_to_tree_node
|
function _doc_to_tree_node(doc, parent_id){
var retnode = {};
// ID.
var raw_id = doc['id'];
var safe_id = raw_id; // need to process?
retnode['attr'] = { "id" : safe_id };
// Label (with fallback).
var label = doc['label'];
if( ! label || label == '' ){
label = raw_id;
}else{
label = label + ' (' + raw_id + ')';
}
// Set anchor title and href.
var detlink = linker.url(raw_id, 'term');
retnode['data'] = {"title" : label,
"attr": {"href": detlink}};
// Turn to graph, get kids.
var graph = new bbop.model.graph();
graph.load_json(jQuery.parseJSON(doc['topology_graph']));
var kids = graph.get_child_nodes(doc['id']);
// Add state and kid_query.
if( ! kids || kids.length == 0 ){
// No kids...
}else{
// No kids, make sure the node is closed.
retnode['state'] = 'closed';
// Collect kid info for the query to get them later.
var qbuff = [];
bbop.core.each(kids,
function(kid){
qbuff.push('id:"' + kid.id() + '"');
});
retnode['attr']['kid_query'] = qbuff.join(' OR ');
}
// If the parent_id is defined, use that to pull the relationship
// out of the graph and get a more appropriate icon.
if( parent_id ){
// Try and dig out the rel to display.
var edges = graph.get_edges(raw_id, parent_id);
if( edges && edges.length ){
var weight = {
'is_a': 3,
'part_of': 2
};
var unknown_rel_weight = 1;
edges.sort(
function(a, b){
var aw = weight[a.predicate_id()];
if( ! aw ){ aw = unknown_rel_weight; }
var bw = weight[b.predicate_id()];
if( ! bw ){ bw = unknown_rel_weight; }
return bw - aw;
});
// Add it in a brittle way.
var prime_rel = edges[0].predicate_id();
retnode['data']['icon'] =
server_meta.image_base() + '/' + prime_rel + '.gif';
}
}
return retnode;
}
|
javascript
|
function _doc_to_tree_node(doc, parent_id){
var retnode = {};
// ID.
var raw_id = doc['id'];
var safe_id = raw_id; // need to process?
retnode['attr'] = { "id" : safe_id };
// Label (with fallback).
var label = doc['label'];
if( ! label || label == '' ){
label = raw_id;
}else{
label = label + ' (' + raw_id + ')';
}
// Set anchor title and href.
var detlink = linker.url(raw_id, 'term');
retnode['data'] = {"title" : label,
"attr": {"href": detlink}};
// Turn to graph, get kids.
var graph = new bbop.model.graph();
graph.load_json(jQuery.parseJSON(doc['topology_graph']));
var kids = graph.get_child_nodes(doc['id']);
// Add state and kid_query.
if( ! kids || kids.length == 0 ){
// No kids...
}else{
// No kids, make sure the node is closed.
retnode['state'] = 'closed';
// Collect kid info for the query to get them later.
var qbuff = [];
bbop.core.each(kids,
function(kid){
qbuff.push('id:"' + kid.id() + '"');
});
retnode['attr']['kid_query'] = qbuff.join(' OR ');
}
// If the parent_id is defined, use that to pull the relationship
// out of the graph and get a more appropriate icon.
if( parent_id ){
// Try and dig out the rel to display.
var edges = graph.get_edges(raw_id, parent_id);
if( edges && edges.length ){
var weight = {
'is_a': 3,
'part_of': 2
};
var unknown_rel_weight = 1;
edges.sort(
function(a, b){
var aw = weight[a.predicate_id()];
if( ! aw ){ aw = unknown_rel_weight; }
var bw = weight[b.predicate_id()];
if( ! bw ){ bw = unknown_rel_weight; }
return bw - aw;
});
// Add it in a brittle way.
var prime_rel = edges[0].predicate_id();
retnode['data']['icon'] =
server_meta.image_base() + '/' + prime_rel + '.gif';
}
}
return retnode;
}
|
[
"function",
"_doc_to_tree_node",
"(",
"doc",
",",
"parent_id",
")",
"{",
"var",
"retnode",
"=",
"{",
"}",
";",
"var",
"raw_id",
"=",
"doc",
"[",
"'id'",
"]",
";",
"var",
"safe_id",
"=",
"raw_id",
";",
"retnode",
"[",
"'attr'",
"]",
"=",
"{",
"\"id\"",
":",
"safe_id",
"}",
";",
"var",
"label",
"=",
"doc",
"[",
"'label'",
"]",
";",
"if",
"(",
"!",
"label",
"||",
"label",
"==",
"''",
")",
"{",
"label",
"=",
"raw_id",
";",
"}",
"else",
"{",
"label",
"=",
"label",
"+",
"' ('",
"+",
"raw_id",
"+",
"')'",
";",
"}",
"var",
"detlink",
"=",
"linker",
".",
"url",
"(",
"raw_id",
",",
"'term'",
")",
";",
"retnode",
"[",
"'data'",
"]",
"=",
"{",
"\"title\"",
":",
"label",
",",
"\"attr\"",
":",
"{",
"\"href\"",
":",
"detlink",
"}",
"}",
";",
"var",
"graph",
"=",
"new",
"bbop",
".",
"model",
".",
"graph",
"(",
")",
";",
"graph",
".",
"load_json",
"(",
"jQuery",
".",
"parseJSON",
"(",
"doc",
"[",
"'topology_graph'",
"]",
")",
")",
";",
"var",
"kids",
"=",
"graph",
".",
"get_child_nodes",
"(",
"doc",
"[",
"'id'",
"]",
")",
";",
"if",
"(",
"!",
"kids",
"||",
"kids",
".",
"length",
"==",
"0",
")",
"{",
"}",
"else",
"{",
"retnode",
"[",
"'state'",
"]",
"=",
"'closed'",
";",
"var",
"qbuff",
"=",
"[",
"]",
";",
"bbop",
".",
"core",
".",
"each",
"(",
"kids",
",",
"function",
"(",
"kid",
")",
"{",
"qbuff",
".",
"push",
"(",
"'id:\"'",
"+",
"kid",
".",
"id",
"(",
")",
"+",
"'\"'",
")",
";",
"}",
")",
";",
"retnode",
"[",
"'attr'",
"]",
"[",
"'kid_query'",
"]",
"=",
"qbuff",
".",
"join",
"(",
"' OR '",
")",
";",
"}",
"if",
"(",
"parent_id",
")",
"{",
"var",
"edges",
"=",
"graph",
".",
"get_edges",
"(",
"raw_id",
",",
"parent_id",
")",
";",
"if",
"(",
"edges",
"&&",
"edges",
".",
"length",
")",
"{",
"var",
"weight",
"=",
"{",
"'is_a'",
":",
"3",
",",
"'part_of'",
":",
"2",
"}",
";",
"var",
"unknown_rel_weight",
"=",
"1",
";",
"edges",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"aw",
"=",
"weight",
"[",
"a",
".",
"predicate_id",
"(",
")",
"]",
";",
"if",
"(",
"!",
"aw",
")",
"{",
"aw",
"=",
"unknown_rel_weight",
";",
"}",
"var",
"bw",
"=",
"weight",
"[",
"b",
".",
"predicate_id",
"(",
")",
"]",
";",
"if",
"(",
"!",
"bw",
")",
"{",
"bw",
"=",
"unknown_rel_weight",
";",
"}",
"return",
"bw",
"-",
"aw",
";",
"}",
")",
";",
"var",
"prime_rel",
"=",
"edges",
"[",
"0",
"]",
".",
"predicate_id",
"(",
")",
";",
"retnode",
"[",
"'data'",
"]",
"[",
"'icon'",
"]",
"=",
"server_meta",
".",
"image_base",
"(",
")",
"+",
"'/'",
"+",
"prime_rel",
"+",
"'.gif'",
";",
"}",
"}",
"return",
"retnode",
";",
"}"
] |
Return the jsTree node defined by this single argument doc.
|
[
"Return",
"the",
"jsTree",
"node",
"defined",
"by",
"this",
"single",
"argument",
"doc",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/DrillExp.js#L161-L233
|
train
|
geneontology/amigo
|
javascript/web/Matrix.js
|
_new_manager
|
function _new_manager(){
var engine = new jquery_engine(golr_response);
engine.method('GET');
engine.use_jsonp(true);
var manager = new golr_manager(gserv_bulk, gconf, engine, 'async');
return manager;
}
|
javascript
|
function _new_manager(){
var engine = new jquery_engine(golr_response);
engine.method('GET');
engine.use_jsonp(true);
var manager = new golr_manager(gserv_bulk, gconf, engine, 'async');
return manager;
}
|
[
"function",
"_new_manager",
"(",
")",
"{",
"var",
"engine",
"=",
"new",
"jquery_engine",
"(",
"golr_response",
")",
";",
"engine",
".",
"method",
"(",
"'GET'",
")",
";",
"engine",
".",
"use_jsonp",
"(",
"true",
")",
";",
"var",
"manager",
"=",
"new",
"golr_manager",
"(",
"gserv_bulk",
",",
"gconf",
",",
"engine",
",",
"'async'",
")",
";",
"return",
"manager",
";",
"}"
] |
default. Create fresh manager.
|
[
"default",
".",
"Create",
"fresh",
"manager",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/Matrix.js#L37-L43
|
train
|
geneontology/amigo
|
javascript/web/Matrix.js
|
_get_filters
|
function _get_filters(filter_manager){
var lstate = filter_manager.get_filter_query_string();
var lparams = bbop.url_parameters(decodeURIComponent(lstate));
var filters_as_strings = [];
us.each(lparams, function(lparam){
if( lparam[0] === 'fq' && lparam[1] ){
filters_as_strings.push(lparam[1]);
}
});
//console.log('pass filter state: ', filters_as_strings);
return filters_as_strings;
}
|
javascript
|
function _get_filters(filter_manager){
var lstate = filter_manager.get_filter_query_string();
var lparams = bbop.url_parameters(decodeURIComponent(lstate));
var filters_as_strings = [];
us.each(lparams, function(lparam){
if( lparam[0] === 'fq' && lparam[1] ){
filters_as_strings.push(lparam[1]);
}
});
//console.log('pass filter state: ', filters_as_strings);
return filters_as_strings;
}
|
[
"function",
"_get_filters",
"(",
"filter_manager",
")",
"{",
"var",
"lstate",
"=",
"filter_manager",
".",
"get_filter_query_string",
"(",
")",
";",
"var",
"lparams",
"=",
"bbop",
".",
"url_parameters",
"(",
"decodeURIComponent",
"(",
"lstate",
")",
")",
";",
"var",
"filters_as_strings",
"=",
"[",
"]",
";",
"us",
".",
"each",
"(",
"lparams",
",",
"function",
"(",
"lparam",
")",
"{",
"if",
"(",
"lparam",
"[",
"0",
"]",
"===",
"'fq'",
"&&",
"lparam",
"[",
"1",
"]",
")",
"{",
"filters_as_strings",
".",
"push",
"(",
"lparam",
"[",
"1",
"]",
")",
";",
"}",
"}",
")",
";",
"return",
"filters_as_strings",
";",
"}"
] |
Extract the filters being used in the filter manager.
|
[
"Extract",
"the",
"filters",
"being",
"used",
"in",
"the",
"filter",
"manager",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/Matrix.js#L48-L61
|
train
|
geneontology/amigo
|
javascript/web/Matrix.js
|
TermInfoStage
|
function TermInfoStage(term_accs){
// Ready logging.
var logger = new bbop.logger();
logger.DEBUG = true;
function ll(str){ logger.kvetch('JSM01: ' + str); }
ll('TermInfoStage start...');
// Prep the progress bar and hide the order selector until we're
// done.
jQuery("#progress-text").empty();
jQuery("#progress-text").append('<b>Loading...</b>');
//jQuery("#progress-bar").empty();
jQuery("#progress-widget").show();
jQuery("#order-selector").hide();
// Now, cycle though all of the terms to collect info on.
ll('Gathering batch functions for term info...');
var run_funs = [];
var term_user_order = {};
us.each(term_accs, function(r, r_i){
// Remember the incoming order.
term_user_order[r] = r_i;
// Create runner function.
run_funs.push(function(){
// Manager settings.
var go = _new_manager();
go.set_personality('ontology');
// Set the next query and go.
go.set_id(r);
return go.search();
});
});
var term_info = {};
// Fetch the data and grab the number we want.
var accumulator_fun = function(resp){
// Who was this?
var qval = resp.parameter('q');
var two_part = bbop.first_split(':', qval);
var acc = bbop.dequote(two_part[1]);
ll(' Looking at info for: ' + acc);
term_info[acc] = {
id : acc,
name: acc,
source : 'n/a',
index : term_user_order[acc]
};
// Dig out names and the like.
var doc = resp.get_doc(0);
if( doc ){
term_info[acc]['name'] = doc['annotation_class_label'];
term_info[acc]['source'] = doc['source'];
}
};
// The final function is the data renderer.
var final_fun = function(){
ll('Starting final in TermInfoStage...');
ll(' term_info: ' + bbop.dump(term_info));
TermDataStage(term_info, term_accs);
ll('Completed TermInfoStage!');
};
// Create and run coordinating manager.
var manager = _new_manager();
manager.run_promise_functions(
run_funs,
accumulator_fun,
final_fun,
function(err){
alert(err.toString());
});
}
|
javascript
|
function TermInfoStage(term_accs){
// Ready logging.
var logger = new bbop.logger();
logger.DEBUG = true;
function ll(str){ logger.kvetch('JSM01: ' + str); }
ll('TermInfoStage start...');
// Prep the progress bar and hide the order selector until we're
// done.
jQuery("#progress-text").empty();
jQuery("#progress-text").append('<b>Loading...</b>');
//jQuery("#progress-bar").empty();
jQuery("#progress-widget").show();
jQuery("#order-selector").hide();
// Now, cycle though all of the terms to collect info on.
ll('Gathering batch functions for term info...');
var run_funs = [];
var term_user_order = {};
us.each(term_accs, function(r, r_i){
// Remember the incoming order.
term_user_order[r] = r_i;
// Create runner function.
run_funs.push(function(){
// Manager settings.
var go = _new_manager();
go.set_personality('ontology');
// Set the next query and go.
go.set_id(r);
return go.search();
});
});
var term_info = {};
// Fetch the data and grab the number we want.
var accumulator_fun = function(resp){
// Who was this?
var qval = resp.parameter('q');
var two_part = bbop.first_split(':', qval);
var acc = bbop.dequote(two_part[1]);
ll(' Looking at info for: ' + acc);
term_info[acc] = {
id : acc,
name: acc,
source : 'n/a',
index : term_user_order[acc]
};
// Dig out names and the like.
var doc = resp.get_doc(0);
if( doc ){
term_info[acc]['name'] = doc['annotation_class_label'];
term_info[acc]['source'] = doc['source'];
}
};
// The final function is the data renderer.
var final_fun = function(){
ll('Starting final in TermInfoStage...');
ll(' term_info: ' + bbop.dump(term_info));
TermDataStage(term_info, term_accs);
ll('Completed TermInfoStage!');
};
// Create and run coordinating manager.
var manager = _new_manager();
manager.run_promise_functions(
run_funs,
accumulator_fun,
final_fun,
function(err){
alert(err.toString());
});
}
|
[
"function",
"TermInfoStage",
"(",
"term_accs",
")",
"{",
"var",
"logger",
"=",
"new",
"bbop",
".",
"logger",
"(",
")",
";",
"logger",
".",
"DEBUG",
"=",
"true",
";",
"function",
"ll",
"(",
"str",
")",
"{",
"logger",
".",
"kvetch",
"(",
"'JSM01: '",
"+",
"str",
")",
";",
"}",
"ll",
"(",
"'TermInfoStage start...'",
")",
";",
"jQuery",
"(",
"\"#progress-text\"",
")",
".",
"empty",
"(",
")",
";",
"jQuery",
"(",
"\"#progress-text\"",
")",
".",
"append",
"(",
"'<b>Loading...</b>'",
")",
";",
"jQuery",
"(",
"\"#progress-widget\"",
")",
".",
"show",
"(",
")",
";",
"jQuery",
"(",
"\"#order-selector\"",
")",
".",
"hide",
"(",
")",
";",
"ll",
"(",
"'Gathering batch functions for term info...'",
")",
";",
"var",
"run_funs",
"=",
"[",
"]",
";",
"var",
"term_user_order",
"=",
"{",
"}",
";",
"us",
".",
"each",
"(",
"term_accs",
",",
"function",
"(",
"r",
",",
"r_i",
")",
"{",
"term_user_order",
"[",
"r",
"]",
"=",
"r_i",
";",
"run_funs",
".",
"push",
"(",
"function",
"(",
")",
"{",
"var",
"go",
"=",
"_new_manager",
"(",
")",
";",
"go",
".",
"set_personality",
"(",
"'ontology'",
")",
";",
"go",
".",
"set_id",
"(",
"r",
")",
";",
"return",
"go",
".",
"search",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"var",
"term_info",
"=",
"{",
"}",
";",
"var",
"accumulator_fun",
"=",
"function",
"(",
"resp",
")",
"{",
"var",
"qval",
"=",
"resp",
".",
"parameter",
"(",
"'q'",
")",
";",
"var",
"two_part",
"=",
"bbop",
".",
"first_split",
"(",
"':'",
",",
"qval",
")",
";",
"var",
"acc",
"=",
"bbop",
".",
"dequote",
"(",
"two_part",
"[",
"1",
"]",
")",
";",
"ll",
"(",
"' Looking at info for: '",
"+",
"acc",
")",
";",
"term_info",
"[",
"acc",
"]",
"=",
"{",
"id",
":",
"acc",
",",
"name",
":",
"acc",
",",
"source",
":",
"'n/a'",
",",
"index",
":",
"term_user_order",
"[",
"acc",
"]",
"}",
";",
"var",
"doc",
"=",
"resp",
".",
"get_doc",
"(",
"0",
")",
";",
"if",
"(",
"doc",
")",
"{",
"term_info",
"[",
"acc",
"]",
"[",
"'name'",
"]",
"=",
"doc",
"[",
"'annotation_class_label'",
"]",
";",
"term_info",
"[",
"acc",
"]",
"[",
"'source'",
"]",
"=",
"doc",
"[",
"'source'",
"]",
";",
"}",
"}",
";",
"var",
"final_fun",
"=",
"function",
"(",
")",
"{",
"ll",
"(",
"'Starting final in TermInfoStage...'",
")",
";",
"ll",
"(",
"' term_info: '",
"+",
"bbop",
".",
"dump",
"(",
"term_info",
")",
")",
";",
"TermDataStage",
"(",
"term_info",
",",
"term_accs",
")",
";",
"ll",
"(",
"'Completed TermInfoStage!'",
")",
";",
"}",
";",
"var",
"manager",
"=",
"_new_manager",
"(",
")",
";",
"manager",
".",
"run_promise_functions",
"(",
"run_funs",
",",
"accumulator_fun",
",",
"final_fun",
",",
"function",
"(",
"err",
")",
"{",
"alert",
"(",
"err",
".",
"toString",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Get the information for the incoming terms, launch stage 02.
|
[
"Get",
"the",
"information",
"for",
"the",
"incoming",
"terms",
"launch",
"stage",
"02",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/Matrix.js#L165-L245
|
train
|
geneontology/amigo
|
javascript/lib/amigo/api.js
|
_abstract_solr_filter_template
|
function _abstract_solr_filter_template(filters){
var allbuf = new Array();
for( var filter_key in filters ){
var filter_val = filters[filter_key];
// If the value looks like an array, iterate over it and
// collect.
if( filter_val &&
filter_val != null &&
typeof filter_val == 'object' &&
filter_val.length ){
for( var i = 0; i < filter_val.length; i++ ){
var minibuffer = new Array();
var try_val = filter_val[i];
if( typeof(try_val) != 'undefined' &&
try_val != '' ){
minibuffer.push('fq=');
minibuffer.push(filter_key);
minibuffer.push(':');
minibuffer.push('"');
minibuffer.push(filter_val[i]);
minibuffer.push('"');
allbuf.push(minibuffer.join(''));
}
}
}else{
var minibuf = new Array();
if( typeof(filter_val) != 'undefined' &&
filter_val != '' ){
minibuf.push('fq=');
minibuf.push(filter_key);
minibuf.push(':');
minibuf.push('"');
minibuf.push(filter_val);
minibuf.push('"');
allbuf.push(minibuf.join(''));
}
}
}
return allbuf.join('&');
}
|
javascript
|
function _abstract_solr_filter_template(filters){
var allbuf = new Array();
for( var filter_key in filters ){
var filter_val = filters[filter_key];
// If the value looks like an array, iterate over it and
// collect.
if( filter_val &&
filter_val != null &&
typeof filter_val == 'object' &&
filter_val.length ){
for( var i = 0; i < filter_val.length; i++ ){
var minibuffer = new Array();
var try_val = filter_val[i];
if( typeof(try_val) != 'undefined' &&
try_val != '' ){
minibuffer.push('fq=');
minibuffer.push(filter_key);
minibuffer.push(':');
minibuffer.push('"');
minibuffer.push(filter_val[i]);
minibuffer.push('"');
allbuf.push(minibuffer.join(''));
}
}
}else{
var minibuf = new Array();
if( typeof(filter_val) != 'undefined' &&
filter_val != '' ){
minibuf.push('fq=');
minibuf.push(filter_key);
minibuf.push(':');
minibuf.push('"');
minibuf.push(filter_val);
minibuf.push('"');
allbuf.push(minibuf.join(''));
}
}
}
return allbuf.join('&');
}
|
[
"function",
"_abstract_solr_filter_template",
"(",
"filters",
")",
"{",
"var",
"allbuf",
"=",
"new",
"Array",
"(",
")",
";",
"for",
"(",
"var",
"filter_key",
"in",
"filters",
")",
"{",
"var",
"filter_val",
"=",
"filters",
"[",
"filter_key",
"]",
";",
"if",
"(",
"filter_val",
"&&",
"filter_val",
"!=",
"null",
"&&",
"typeof",
"filter_val",
"==",
"'object'",
"&&",
"filter_val",
".",
"length",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"filter_val",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"minibuffer",
"=",
"new",
"Array",
"(",
")",
";",
"var",
"try_val",
"=",
"filter_val",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
"(",
"try_val",
")",
"!=",
"'undefined'",
"&&",
"try_val",
"!=",
"''",
")",
"{",
"minibuffer",
".",
"push",
"(",
"'fq='",
")",
";",
"minibuffer",
".",
"push",
"(",
"filter_key",
")",
";",
"minibuffer",
".",
"push",
"(",
"':'",
")",
";",
"minibuffer",
".",
"push",
"(",
"'\"'",
")",
";",
"minibuffer",
".",
"push",
"(",
"filter_val",
"[",
"i",
"]",
")",
";",
"minibuffer",
".",
"push",
"(",
"'\"'",
")",
";",
"allbuf",
".",
"push",
"(",
"minibuffer",
".",
"join",
"(",
"''",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"var",
"minibuf",
"=",
"new",
"Array",
"(",
")",
";",
"if",
"(",
"typeof",
"(",
"filter_val",
")",
"!=",
"'undefined'",
"&&",
"filter_val",
"!=",
"''",
")",
"{",
"minibuf",
".",
"push",
"(",
"'fq='",
")",
";",
"minibuf",
".",
"push",
"(",
"filter_key",
")",
";",
"minibuf",
".",
"push",
"(",
"':'",
")",
";",
"minibuf",
".",
"push",
"(",
"'\"'",
")",
";",
"minibuf",
".",
"push",
"(",
"filter_val",
")",
";",
"minibuf",
".",
"push",
"(",
"'\"'",
")",
";",
"allbuf",
".",
"push",
"(",
"minibuf",
".",
"join",
"(",
"''",
")",
")",
";",
"}",
"}",
"}",
"return",
"allbuf",
".",
"join",
"(",
"'&'",
")",
";",
"}"
] |
Similar to the above, but creating a solr filter set.
|
[
"Similar",
"to",
"the",
"above",
"but",
"creating",
"a",
"solr",
"filter",
"set",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/api.js#L144-L187
|
train
|
geneontology/amigo
|
javascript/web/DDBrowse.js
|
_roots2json
|
function _roots2json(doc){
var root_id = doc['annotation_class'];
console.log("_roots2json: " +
doc + ', ' +
root_id + ', ' +
entity_counts[root_id]);
// Extract the intersting graphs.
var topo_graph_field = 'topology_graph_json';
var trans_graph_field = 'regulates_transitivity_graph_json';
var topo_graph = new model.graph();
topo_graph.load_base_json(JSON.parse(doc[topo_graph_field]));
var trans_graph = new model.graph();
trans_graph.load_base_json(JSON.parse(doc[trans_graph_field]));
//
var kids_p = false;
var kids = [];
us.each(topo_graph.get_child_nodes(root_id), function(kid){
kids.push({
'id': kid.id(),
'text': kid.label() || kid.id()
});
});
if( kids.length > 0 ){
kids_p = true;
}
// Using the badge template, get the spans for the IDs.
var ac_badges = new CountBadges(filter_manager);
var id_to_badge_text =
ac_badges.make_badge(root_id, entity_counts[root_id]);
var lbl_txt = doc['annotation_class_label'] || root_id;
var tmpl = {
'id': root_id,
'icon': 'glyphicon glyphicon-record',
'text': lbl_txt + id_to_badge_text,
//'icon': "string",
'state': {
'opened': false,
'disabled': false,
'selected': false
},
'children': kids_p,
'li_attr': {},
'a_attr': {}
};
return tmpl;
}
|
javascript
|
function _roots2json(doc){
var root_id = doc['annotation_class'];
console.log("_roots2json: " +
doc + ', ' +
root_id + ', ' +
entity_counts[root_id]);
// Extract the intersting graphs.
var topo_graph_field = 'topology_graph_json';
var trans_graph_field = 'regulates_transitivity_graph_json';
var topo_graph = new model.graph();
topo_graph.load_base_json(JSON.parse(doc[topo_graph_field]));
var trans_graph = new model.graph();
trans_graph.load_base_json(JSON.parse(doc[trans_graph_field]));
//
var kids_p = false;
var kids = [];
us.each(topo_graph.get_child_nodes(root_id), function(kid){
kids.push({
'id': kid.id(),
'text': kid.label() || kid.id()
});
});
if( kids.length > 0 ){
kids_p = true;
}
// Using the badge template, get the spans for the IDs.
var ac_badges = new CountBadges(filter_manager);
var id_to_badge_text =
ac_badges.make_badge(root_id, entity_counts[root_id]);
var lbl_txt = doc['annotation_class_label'] || root_id;
var tmpl = {
'id': root_id,
'icon': 'glyphicon glyphicon-record',
'text': lbl_txt + id_to_badge_text,
//'icon': "string",
'state': {
'opened': false,
'disabled': false,
'selected': false
},
'children': kids_p,
'li_attr': {},
'a_attr': {}
};
return tmpl;
}
|
[
"function",
"_roots2json",
"(",
"doc",
")",
"{",
"var",
"root_id",
"=",
"doc",
"[",
"'annotation_class'",
"]",
";",
"console",
".",
"log",
"(",
"\"_roots2json: \"",
"+",
"doc",
"+",
"', '",
"+",
"root_id",
"+",
"', '",
"+",
"entity_counts",
"[",
"root_id",
"]",
")",
";",
"var",
"topo_graph_field",
"=",
"'topology_graph_json'",
";",
"var",
"trans_graph_field",
"=",
"'regulates_transitivity_graph_json'",
";",
"var",
"topo_graph",
"=",
"new",
"model",
".",
"graph",
"(",
")",
";",
"topo_graph",
".",
"load_base_json",
"(",
"JSON",
".",
"parse",
"(",
"doc",
"[",
"topo_graph_field",
"]",
")",
")",
";",
"var",
"trans_graph",
"=",
"new",
"model",
".",
"graph",
"(",
")",
";",
"trans_graph",
".",
"load_base_json",
"(",
"JSON",
".",
"parse",
"(",
"doc",
"[",
"trans_graph_field",
"]",
")",
")",
";",
"var",
"kids_p",
"=",
"false",
";",
"var",
"kids",
"=",
"[",
"]",
";",
"us",
".",
"each",
"(",
"topo_graph",
".",
"get_child_nodes",
"(",
"root_id",
")",
",",
"function",
"(",
"kid",
")",
"{",
"kids",
".",
"push",
"(",
"{",
"'id'",
":",
"kid",
".",
"id",
"(",
")",
",",
"'text'",
":",
"kid",
".",
"label",
"(",
")",
"||",
"kid",
".",
"id",
"(",
")",
"}",
")",
";",
"}",
")",
";",
"if",
"(",
"kids",
".",
"length",
">",
"0",
")",
"{",
"kids_p",
"=",
"true",
";",
"}",
"var",
"ac_badges",
"=",
"new",
"CountBadges",
"(",
"filter_manager",
")",
";",
"var",
"id_to_badge_text",
"=",
"ac_badges",
".",
"make_badge",
"(",
"root_id",
",",
"entity_counts",
"[",
"root_id",
"]",
")",
";",
"var",
"lbl_txt",
"=",
"doc",
"[",
"'annotation_class_label'",
"]",
"||",
"root_id",
";",
"var",
"tmpl",
"=",
"{",
"'id'",
":",
"root_id",
",",
"'icon'",
":",
"'glyphicon glyphicon-record'",
",",
"'text'",
":",
"lbl_txt",
"+",
"id_to_badge_text",
",",
"'state'",
":",
"{",
"'opened'",
":",
"false",
",",
"'disabled'",
":",
"false",
",",
"'selected'",
":",
"false",
"}",
",",
"'children'",
":",
"kids_p",
",",
"'li_attr'",
":",
"{",
"}",
",",
"'a_attr'",
":",
"{",
"}",
"}",
";",
"return",
"tmpl",
";",
"}"
] |
Convert a term callback into the proper json. This method is used for the initial graph creation.
|
[
"Convert",
"a",
"term",
"callback",
"into",
"the",
"proper",
"json",
".",
"This",
"method",
"is",
"used",
"for",
"the",
"initial",
"graph",
"creation",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/DDBrowse.js#L284-L335
|
train
|
geneontology/amigo
|
javascript/web/DDBrowse.js
|
_resp2json
|
function _resp2json(doc){
console.log("_resp2json: " + doc);
var kids = []; // ret
// Extract the intersting graphs.
var topo_graph_field = 'topology_graph_json';
var trans_graph_field = 'regulates_transitivity_graph_json';
var topo_graph = new model.graph();
topo_graph.load_base_json(JSON.parse(doc[topo_graph_field]));
var trans_graph = new model.graph();
trans_graph.load_base_json(JSON.parse(doc[trans_graph_field]));
//console.log('topo: ' + doc[topo_graph_field]);
// Collect child ids.
var child_ids = [];
us.each(topo_graph.get_child_nodes(doc['id']), function(kid){
child_ids.push(kid.id());
});
// Using the badger, get the spans for the IDs.
var ac_badges = new CountBadges(filter_manager);
var ids_to_badge_text = ac_badges.get_future_badges(child_ids);
//
us.each(topo_graph.get_child_nodes(doc['id']), function(kid){
// Extract some info.
var oid = doc['id'];
var sid = kid.id();
var preds = topo_graph.get_predicates(sid, oid);
var imgsrc = bbop.resourcify(sd.image_base, preds[0], 'gif');
var lbl_txt = kid.label() || sid;
// Push template.
kids.push({
'id': sid,
'text': lbl_txt + ids_to_badge_text[sid],
'icon': imgsrc,
'state': {
'opened': false,
'disabled': false,
'selected': false
},
'children': true, // unknowable w/o lookahead
'li_attr': {},
'a_attr': {}
});
});
return kids;
}
|
javascript
|
function _resp2json(doc){
console.log("_resp2json: " + doc);
var kids = []; // ret
// Extract the intersting graphs.
var topo_graph_field = 'topology_graph_json';
var trans_graph_field = 'regulates_transitivity_graph_json';
var topo_graph = new model.graph();
topo_graph.load_base_json(JSON.parse(doc[topo_graph_field]));
var trans_graph = new model.graph();
trans_graph.load_base_json(JSON.parse(doc[trans_graph_field]));
//console.log('topo: ' + doc[topo_graph_field]);
// Collect child ids.
var child_ids = [];
us.each(topo_graph.get_child_nodes(doc['id']), function(kid){
child_ids.push(kid.id());
});
// Using the badger, get the spans for the IDs.
var ac_badges = new CountBadges(filter_manager);
var ids_to_badge_text = ac_badges.get_future_badges(child_ids);
//
us.each(topo_graph.get_child_nodes(doc['id']), function(kid){
// Extract some info.
var oid = doc['id'];
var sid = kid.id();
var preds = topo_graph.get_predicates(sid, oid);
var imgsrc = bbop.resourcify(sd.image_base, preds[0], 'gif');
var lbl_txt = kid.label() || sid;
// Push template.
kids.push({
'id': sid,
'text': lbl_txt + ids_to_badge_text[sid],
'icon': imgsrc,
'state': {
'opened': false,
'disabled': false,
'selected': false
},
'children': true, // unknowable w/o lookahead
'li_attr': {},
'a_attr': {}
});
});
return kids;
}
|
[
"function",
"_resp2json",
"(",
"doc",
")",
"{",
"console",
".",
"log",
"(",
"\"_resp2json: \"",
"+",
"doc",
")",
";",
"var",
"kids",
"=",
"[",
"]",
";",
"var",
"topo_graph_field",
"=",
"'topology_graph_json'",
";",
"var",
"trans_graph_field",
"=",
"'regulates_transitivity_graph_json'",
";",
"var",
"topo_graph",
"=",
"new",
"model",
".",
"graph",
"(",
")",
";",
"topo_graph",
".",
"load_base_json",
"(",
"JSON",
".",
"parse",
"(",
"doc",
"[",
"topo_graph_field",
"]",
")",
")",
";",
"var",
"trans_graph",
"=",
"new",
"model",
".",
"graph",
"(",
")",
";",
"trans_graph",
".",
"load_base_json",
"(",
"JSON",
".",
"parse",
"(",
"doc",
"[",
"trans_graph_field",
"]",
")",
")",
";",
"var",
"child_ids",
"=",
"[",
"]",
";",
"us",
".",
"each",
"(",
"topo_graph",
".",
"get_child_nodes",
"(",
"doc",
"[",
"'id'",
"]",
")",
",",
"function",
"(",
"kid",
")",
"{",
"child_ids",
".",
"push",
"(",
"kid",
".",
"id",
"(",
")",
")",
";",
"}",
")",
";",
"var",
"ac_badges",
"=",
"new",
"CountBadges",
"(",
"filter_manager",
")",
";",
"var",
"ids_to_badge_text",
"=",
"ac_badges",
".",
"get_future_badges",
"(",
"child_ids",
")",
";",
"us",
".",
"each",
"(",
"topo_graph",
".",
"get_child_nodes",
"(",
"doc",
"[",
"'id'",
"]",
")",
",",
"function",
"(",
"kid",
")",
"{",
"var",
"oid",
"=",
"doc",
"[",
"'id'",
"]",
";",
"var",
"sid",
"=",
"kid",
".",
"id",
"(",
")",
";",
"var",
"preds",
"=",
"topo_graph",
".",
"get_predicates",
"(",
"sid",
",",
"oid",
")",
";",
"var",
"imgsrc",
"=",
"bbop",
".",
"resourcify",
"(",
"sd",
".",
"image_base",
",",
"preds",
"[",
"0",
"]",
",",
"'gif'",
")",
";",
"var",
"lbl_txt",
"=",
"kid",
".",
"label",
"(",
")",
"||",
"sid",
";",
"kids",
".",
"push",
"(",
"{",
"'id'",
":",
"sid",
",",
"'text'",
":",
"lbl_txt",
"+",
"ids_to_badge_text",
"[",
"sid",
"]",
",",
"'icon'",
":",
"imgsrc",
",",
"'state'",
":",
"{",
"'opened'",
":",
"false",
",",
"'disabled'",
":",
"false",
",",
"'selected'",
":",
"false",
"}",
",",
"'children'",
":",
"true",
",",
"'li_attr'",
":",
"{",
"}",
",",
"'a_attr'",
":",
"{",
"}",
"}",
")",
";",
"}",
")",
";",
"return",
"kids",
";",
"}"
] |
Convert a term children's into the proper json.
|
[
"Convert",
"a",
"term",
"children",
"s",
"into",
"the",
"proper",
"json",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/DDBrowse.js#L338-L391
|
train
|
geneontology/amigo
|
javascript/web/DDBrowse.js
|
function(term_id){
return function(){
// Create manager.
var engine = new jquery_engine(golr_response);
engine.method('GET');
engine.use_jsonp(true);
var manager = new golr_manager(gserv, gconf, engine, 'async');
// Manager settings.
var personality = 'bioentity';
var confc = gconf.get_class(personality);
manager.set_personality(personality);
manager.add_query_filter('document_category',
confc.document_category());
manager.set_results_count(0); // don't need any actual rows returned
manager.set_facet_limit(0); // care not about facets
manager.add_query_filter('regulates_closure', term_id);
//manager.add_query_filter('isa_partof_closure', term_id);
return manager.search();
};
}
|
javascript
|
function(term_id){
return function(){
// Create manager.
var engine = new jquery_engine(golr_response);
engine.method('GET');
engine.use_jsonp(true);
var manager = new golr_manager(gserv, gconf, engine, 'async');
// Manager settings.
var personality = 'bioentity';
var confc = gconf.get_class(personality);
manager.set_personality(personality);
manager.add_query_filter('document_category',
confc.document_category());
manager.set_results_count(0); // don't need any actual rows returned
manager.set_facet_limit(0); // care not about facets
manager.add_query_filter('regulates_closure', term_id);
//manager.add_query_filter('isa_partof_closure', term_id);
return manager.search();
};
}
|
[
"function",
"(",
"term_id",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"engine",
"=",
"new",
"jquery_engine",
"(",
"golr_response",
")",
";",
"engine",
".",
"method",
"(",
"'GET'",
")",
";",
"engine",
".",
"use_jsonp",
"(",
"true",
")",
";",
"var",
"manager",
"=",
"new",
"golr_manager",
"(",
"gserv",
",",
"gconf",
",",
"engine",
",",
"'async'",
")",
";",
"var",
"personality",
"=",
"'bioentity'",
";",
"var",
"confc",
"=",
"gconf",
".",
"get_class",
"(",
"personality",
")",
";",
"manager",
".",
"set_personality",
"(",
"personality",
")",
";",
"manager",
".",
"add_query_filter",
"(",
"'document_category'",
",",
"confc",
".",
"document_category",
"(",
")",
")",
";",
"manager",
".",
"set_results_count",
"(",
"0",
")",
";",
"manager",
".",
"set_facet_limit",
"(",
"0",
")",
";",
"manager",
".",
"add_query_filter",
"(",
"'regulates_closure'",
",",
"term_id",
")",
";",
"return",
"manager",
".",
"search",
"(",
")",
";",
"}",
";",
"}"
] |
Create a new function that returns a promise when called.
|
[
"Create",
"a",
"new",
"function",
"that",
"returns",
"a",
"promise",
"when",
"called",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/DDBrowse.js#L507-L530
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function( map ){
var empty = true;
if( map != null ){
for(var i in map){
empty = false;
break;
}
}
return empty;
}
|
javascript
|
function( map ){
var empty = true;
if( map != null ){
for(var i in map){
empty = false;
break;
}
}
return empty;
}
|
[
"function",
"(",
"map",
")",
"{",
"var",
"empty",
"=",
"true",
";",
"if",
"(",
"map",
"!=",
"null",
")",
"{",
"for",
"(",
"var",
"i",
"in",
"map",
")",
"{",
"empty",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"empty",
";",
"}"
] |
has anything been set in the map
|
[
"has",
"anything",
"been",
"set",
"in",
"the",
"map"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L405-L416
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function( options ){
var obj = options.map;
var keys = options.keys;
var l = keys.length;
var keepChildren = options.keepChildren;
for(var i = 0; i < l; i++){
var key = keys[i];
if( $$.is.plainObject( key ) ){
$$.util.error('Tried to delete map with object key');
}
var lastKey = i === options.keys.length - 1;
if( lastKey ){
if( keepChildren ){ // then only delete child fields not in keepChildren
for( var child in obj ){
if( !keepChildren[child] ){
delete obj[child];
}
}
} else {
delete obj[key];
}
} else {
obj = obj[key];
}
}
}
|
javascript
|
function( options ){
var obj = options.map;
var keys = options.keys;
var l = keys.length;
var keepChildren = options.keepChildren;
for(var i = 0; i < l; i++){
var key = keys[i];
if( $$.is.plainObject( key ) ){
$$.util.error('Tried to delete map with object key');
}
var lastKey = i === options.keys.length - 1;
if( lastKey ){
if( keepChildren ){ // then only delete child fields not in keepChildren
for( var child in obj ){
if( !keepChildren[child] ){
delete obj[child];
}
}
} else {
delete obj[key];
}
} else {
obj = obj[key];
}
}
}
|
[
"function",
"(",
"options",
")",
"{",
"var",
"obj",
"=",
"options",
".",
"map",
";",
"var",
"keys",
"=",
"options",
".",
"keys",
";",
"var",
"l",
"=",
"keys",
".",
"length",
";",
"var",
"keepChildren",
"=",
"options",
".",
"keepChildren",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"key",
"=",
"keys",
"[",
"i",
"]",
";",
"if",
"(",
"$$",
".",
"is",
".",
"plainObject",
"(",
"key",
")",
")",
"{",
"$$",
".",
"util",
".",
"error",
"(",
"'Tried to delete map with object key'",
")",
";",
"}",
"var",
"lastKey",
"=",
"i",
"===",
"options",
".",
"keys",
".",
"length",
"-",
"1",
";",
"if",
"(",
"lastKey",
")",
"{",
"if",
"(",
"keepChildren",
")",
"{",
"for",
"(",
"var",
"child",
"in",
"obj",
")",
"{",
"if",
"(",
"!",
"keepChildren",
"[",
"child",
"]",
")",
"{",
"delete",
"obj",
"[",
"child",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"delete",
"obj",
"[",
"key",
"]",
";",
"}",
"}",
"else",
"{",
"obj",
"=",
"obj",
"[",
"key",
"]",
";",
"}",
"}",
"}"
] |
deletes the entry in the map
|
[
"deletes",
"the",
"entry",
"in",
"the",
"map"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L484-L514
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function( str ){
var first, last;
// find first non-space char
for( first = 0; first < str.length && str[first] === ' '; first++ ){}
// find last non-space char
for( last = str.length - 1; last > first && str[last] === ' '; last-- ){}
return str.substring(first, last + 1);
}
|
javascript
|
function( str ){
var first, last;
// find first non-space char
for( first = 0; first < str.length && str[first] === ' '; first++ ){}
// find last non-space char
for( last = str.length - 1; last > first && str[last] === ' '; last-- ){}
return str.substring(first, last + 1);
}
|
[
"function",
"(",
"str",
")",
"{",
"var",
"first",
",",
"last",
";",
"for",
"(",
"first",
"=",
"0",
";",
"first",
"<",
"str",
".",
"length",
"&&",
"str",
"[",
"first",
"]",
"===",
"' '",
";",
"first",
"++",
")",
"{",
"}",
"for",
"(",
"last",
"=",
"str",
".",
"length",
"-",
"1",
";",
"last",
">",
"first",
"&&",
"str",
"[",
"last",
"]",
"===",
"' '",
";",
"last",
"--",
")",
"{",
"}",
"return",
"str",
".",
"substring",
"(",
"first",
",",
"last",
"+",
"1",
")",
";",
"}"
] |
strip spaces from beginning of string and end of string
|
[
"strip",
"spaces",
"from",
"beginning",
"of",
"string",
"and",
"end",
"of",
"string"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L571-L581
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function( params ){
var defaults = {
field: 'data',
event: 'data',
triggerFnName: 'trigger',
triggerEvent: false,
immutableKeys: {} // key => true if immutable
};
params = $$.util.extend({}, defaults, params);
return function removeDataImpl( names ){
var p = params;
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
var single = selfIsArrayLike ? self[0] : self;
// .removeData('foo bar')
if( $$.is.string(names) ){ // then get the list of keys, and delete them
var keys = names.split(/\s+/);
var l = keys.length;
for( var i = 0; i < l; i++ ){ // delete each non-empty key
var key = keys[i];
if( $$.is.emptyString(key) ){ continue; }
var valid = !p.immutableKeys[ key ]; // not valid if immutable
if( valid ){
for( var i_a = 0, l_a = all.length; i_a < l_a; i_a++ ){
delete all[ i_a ]._private[ p.field ][ key ];
}
}
}
if( p.triggerEvent ){
self[ p.triggerFnName ]( p.event );
}
// .removeData()
} else if( names === undefined ){ // then delete all keys
for( var i_a = 0, l_a = all.length; i_a < l_a; i_a++ ){
var _privateFields = all[ i_a ]._private[ p.field ];
for( var key in _privateFields ){
var validKeyToDelete = !p.immutableKeys[ key ];
if( validKeyToDelete ){
delete _privateFields[ key ];
}
}
}
if( p.triggerEvent ){
self[ p.triggerFnName ]( p.event );
}
}
return self; // maintain chaining
}; // function
}
|
javascript
|
function( params ){
var defaults = {
field: 'data',
event: 'data',
triggerFnName: 'trigger',
triggerEvent: false,
immutableKeys: {} // key => true if immutable
};
params = $$.util.extend({}, defaults, params);
return function removeDataImpl( names ){
var p = params;
var self = this;
var selfIsArrayLike = self.length !== undefined;
var all = selfIsArrayLike ? self : [self]; // put in array if not array-like
var single = selfIsArrayLike ? self[0] : self;
// .removeData('foo bar')
if( $$.is.string(names) ){ // then get the list of keys, and delete them
var keys = names.split(/\s+/);
var l = keys.length;
for( var i = 0; i < l; i++ ){ // delete each non-empty key
var key = keys[i];
if( $$.is.emptyString(key) ){ continue; }
var valid = !p.immutableKeys[ key ]; // not valid if immutable
if( valid ){
for( var i_a = 0, l_a = all.length; i_a < l_a; i_a++ ){
delete all[ i_a ]._private[ p.field ][ key ];
}
}
}
if( p.triggerEvent ){
self[ p.triggerFnName ]( p.event );
}
// .removeData()
} else if( names === undefined ){ // then delete all keys
for( var i_a = 0, l_a = all.length; i_a < l_a; i_a++ ){
var _privateFields = all[ i_a ]._private[ p.field ];
for( var key in _privateFields ){
var validKeyToDelete = !p.immutableKeys[ key ];
if( validKeyToDelete ){
delete _privateFields[ key ];
}
}
}
if( p.triggerEvent ){
self[ p.triggerFnName ]( p.event );
}
}
return self; // maintain chaining
}; // function
}
|
[
"function",
"(",
"params",
")",
"{",
"var",
"defaults",
"=",
"{",
"field",
":",
"'data'",
",",
"event",
":",
"'data'",
",",
"triggerFnName",
":",
"'trigger'",
",",
"triggerEvent",
":",
"false",
",",
"immutableKeys",
":",
"{",
"}",
"}",
";",
"params",
"=",
"$$",
".",
"util",
".",
"extend",
"(",
"{",
"}",
",",
"defaults",
",",
"params",
")",
";",
"return",
"function",
"removeDataImpl",
"(",
"names",
")",
"{",
"var",
"p",
"=",
"params",
";",
"var",
"self",
"=",
"this",
";",
"var",
"selfIsArrayLike",
"=",
"self",
".",
"length",
"!==",
"undefined",
";",
"var",
"all",
"=",
"selfIsArrayLike",
"?",
"self",
":",
"[",
"self",
"]",
";",
"var",
"single",
"=",
"selfIsArrayLike",
"?",
"self",
"[",
"0",
"]",
":",
"self",
";",
"if",
"(",
"$$",
".",
"is",
".",
"string",
"(",
"names",
")",
")",
"{",
"var",
"keys",
"=",
"names",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"var",
"l",
"=",
"keys",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"var",
"key",
"=",
"keys",
"[",
"i",
"]",
";",
"if",
"(",
"$$",
".",
"is",
".",
"emptyString",
"(",
"key",
")",
")",
"{",
"continue",
";",
"}",
"var",
"valid",
"=",
"!",
"p",
".",
"immutableKeys",
"[",
"key",
"]",
";",
"if",
"(",
"valid",
")",
"{",
"for",
"(",
"var",
"i_a",
"=",
"0",
",",
"l_a",
"=",
"all",
".",
"length",
";",
"i_a",
"<",
"l_a",
";",
"i_a",
"++",
")",
"{",
"delete",
"all",
"[",
"i_a",
"]",
".",
"_private",
"[",
"p",
".",
"field",
"]",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"p",
".",
"triggerEvent",
")",
"{",
"self",
"[",
"p",
".",
"triggerFnName",
"]",
"(",
"p",
".",
"event",
")",
";",
"}",
"}",
"else",
"if",
"(",
"names",
"===",
"undefined",
")",
"{",
"for",
"(",
"var",
"i_a",
"=",
"0",
",",
"l_a",
"=",
"all",
".",
"length",
";",
"i_a",
"<",
"l_a",
";",
"i_a",
"++",
")",
"{",
"var",
"_privateFields",
"=",
"all",
"[",
"i_a",
"]",
".",
"_private",
"[",
"p",
".",
"field",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"_privateFields",
")",
"{",
"var",
"validKeyToDelete",
"=",
"!",
"p",
".",
"immutableKeys",
"[",
"key",
"]",
";",
"if",
"(",
"validKeyToDelete",
")",
"{",
"delete",
"_privateFields",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"p",
".",
"triggerEvent",
")",
"{",
"self",
"[",
"p",
".",
"triggerFnName",
"]",
"(",
"p",
".",
"event",
")",
";",
"}",
"}",
"return",
"self",
";",
"}",
";",
"}"
] |
remove data field
|
[
"remove",
"data",
"field"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L3129-L3189
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function(){
return {
classes: [],
colonSelectors: [],
data: [],
group: null,
ids: [],
meta: [],
// fake selectors
collection: null, // a collection to match against
filter: null, // filter function
// these are defined in the upward direction rather than down (e.g. child)
// because we need to go up in Selector.filter()
parent: null, // parent query obj
ancestor: null, // ancestor query obj
subject: null, // defines subject in compound query (subject query obj; points to self if subject)
// use these only when subject has been defined
child: null,
descendant: null
};
}
|
javascript
|
function(){
return {
classes: [],
colonSelectors: [],
data: [],
group: null,
ids: [],
meta: [],
// fake selectors
collection: null, // a collection to match against
filter: null, // filter function
// these are defined in the upward direction rather than down (e.g. child)
// because we need to go up in Selector.filter()
parent: null, // parent query obj
ancestor: null, // ancestor query obj
subject: null, // defines subject in compound query (subject query obj; points to self if subject)
// use these only when subject has been defined
child: null,
descendant: null
};
}
|
[
"function",
"(",
")",
"{",
"return",
"{",
"classes",
":",
"[",
"]",
",",
"colonSelectors",
":",
"[",
"]",
",",
"data",
":",
"[",
"]",
",",
"group",
":",
"null",
",",
"ids",
":",
"[",
"]",
",",
"meta",
":",
"[",
"]",
",",
"collection",
":",
"null",
",",
"filter",
":",
"null",
",",
"parent",
":",
"null",
",",
"ancestor",
":",
"null",
",",
"subject",
":",
"null",
",",
"child",
":",
"null",
",",
"descendant",
":",
"null",
"}",
";",
"}"
] |
storage for parsed queries
|
[
"storage",
"for",
"parsed",
"queries"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L3596-L3619
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function( expectation ){
var expr;
var match;
var name;
for( var j = 0; j < exprs.length; j++ ){
var e = exprs[j];
var n = e.name;
// ignore this expression if it doesn't meet the expectation function
if( $$.is.fn( expectation ) && !expectation(n, e) ){ continue }
var m = remaining.match(new RegExp( '^' + e.regex ));
if( m != null ){
match = m;
expr = e;
name = n;
var consumed = m[0];
remaining = remaining.substring( consumed.length );
break; // we've consumed one expr, so we can return now
}
}
return {
expr: expr,
match: match,
name: name
};
}
|
javascript
|
function( expectation ){
var expr;
var match;
var name;
for( var j = 0; j < exprs.length; j++ ){
var e = exprs[j];
var n = e.name;
// ignore this expression if it doesn't meet the expectation function
if( $$.is.fn( expectation ) && !expectation(n, e) ){ continue }
var m = remaining.match(new RegExp( '^' + e.regex ));
if( m != null ){
match = m;
expr = e;
name = n;
var consumed = m[0];
remaining = remaining.substring( consumed.length );
break; // we've consumed one expr, so we can return now
}
}
return {
expr: expr,
match: match,
name: name
};
}
|
[
"function",
"(",
"expectation",
")",
"{",
"var",
"expr",
";",
"var",
"match",
";",
"var",
"name",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"exprs",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"e",
"=",
"exprs",
"[",
"j",
"]",
";",
"var",
"n",
"=",
"e",
".",
"name",
";",
"if",
"(",
"$$",
".",
"is",
".",
"fn",
"(",
"expectation",
")",
"&&",
"!",
"expectation",
"(",
"n",
",",
"e",
")",
")",
"{",
"continue",
"}",
"var",
"m",
"=",
"remaining",
".",
"match",
"(",
"new",
"RegExp",
"(",
"'^'",
"+",
"e",
".",
"regex",
")",
")",
";",
"if",
"(",
"m",
"!=",
"null",
")",
"{",
"match",
"=",
"m",
";",
"expr",
"=",
"e",
";",
"name",
"=",
"n",
";",
"var",
"consumed",
"=",
"m",
"[",
"0",
"]",
";",
"remaining",
"=",
"remaining",
".",
"substring",
"(",
"consumed",
".",
"length",
")",
";",
"break",
";",
"}",
"}",
"return",
"{",
"expr",
":",
"expr",
",",
"match",
":",
"match",
",",
"name",
":",
"name",
"}",
";",
"}"
] |
of all the expressions, find the first match in the remaining text
|
[
"of",
"all",
"the",
"expressions",
"find",
"the",
"first",
"match",
"in",
"the",
"remaining",
"text"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L3813-L3844
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function( roots, fn, directed ){
directed = arguments.length === 1 && !$$.is.fn(fn) ? fn : directed;
fn = $$.is.fn(fn) ? fn : function(){};
var cy = this._private.cy;
var v = $$.is.string(roots) ? this.filter(roots) : roots;
var Q = [];
var connectedEles = [];
var connectedFrom = {};
var id2depth = {};
var V = {};
var j = 0;
var found;
var nodes = this.nodes();
var edges = this.edges();
// enqueue v
for( var i = 0; i < v.length; i++ ){
if( v[i].isNode() ){
Q.unshift( v[i] );
V[ v[i].id() ] = true;
connectedEles.push( v[i] );
id2depth[ v[i].id() ] = 0;
}
}
while( Q.length !== 0 ){
var v = Q.shift();
var depth = id2depth[ v.id() ];
var ret = fn.call(v, j++, depth);
if( ret === true ){
found = v;
break;
}
if( ret === false ){
break;
}
var vwEdges = v.connectedEdges(directed ? '[source = "' + v.id() + '"]' : undefined).intersect( edges );
for( var i = 0; i < vwEdges.length; i++ ){
var e = vwEdges[i];
var w = e.connectedNodes('[id != "' + v.id() + '"]').intersect( nodes );
if( w.length !== 0 && !V[ w.id() ] ){
w = w[0];
Q.push( w );
V[ w.id() ] = true;
id2depth[ w.id() ] = id2depth[ v.id() ] + 1;
connectedEles.push( w );
connectedEles.push( e );
}
}
}
return {
path: new $$.Collection( cy, connectedEles ),
found: new $$.Collection( cy, found )
};
}
|
javascript
|
function( roots, fn, directed ){
directed = arguments.length === 1 && !$$.is.fn(fn) ? fn : directed;
fn = $$.is.fn(fn) ? fn : function(){};
var cy = this._private.cy;
var v = $$.is.string(roots) ? this.filter(roots) : roots;
var Q = [];
var connectedEles = [];
var connectedFrom = {};
var id2depth = {};
var V = {};
var j = 0;
var found;
var nodes = this.nodes();
var edges = this.edges();
// enqueue v
for( var i = 0; i < v.length; i++ ){
if( v[i].isNode() ){
Q.unshift( v[i] );
V[ v[i].id() ] = true;
connectedEles.push( v[i] );
id2depth[ v[i].id() ] = 0;
}
}
while( Q.length !== 0 ){
var v = Q.shift();
var depth = id2depth[ v.id() ];
var ret = fn.call(v, j++, depth);
if( ret === true ){
found = v;
break;
}
if( ret === false ){
break;
}
var vwEdges = v.connectedEdges(directed ? '[source = "' + v.id() + '"]' : undefined).intersect( edges );
for( var i = 0; i < vwEdges.length; i++ ){
var e = vwEdges[i];
var w = e.connectedNodes('[id != "' + v.id() + '"]').intersect( nodes );
if( w.length !== 0 && !V[ w.id() ] ){
w = w[0];
Q.push( w );
V[ w.id() ] = true;
id2depth[ w.id() ] = id2depth[ v.id() ] + 1;
connectedEles.push( w );
connectedEles.push( e );
}
}
}
return {
path: new $$.Collection( cy, connectedEles ),
found: new $$.Collection( cy, found )
};
}
|
[
"function",
"(",
"roots",
",",
"fn",
",",
"directed",
")",
"{",
"directed",
"=",
"arguments",
".",
"length",
"===",
"1",
"&&",
"!",
"$$",
".",
"is",
".",
"fn",
"(",
"fn",
")",
"?",
"fn",
":",
"directed",
";",
"fn",
"=",
"$$",
".",
"is",
".",
"fn",
"(",
"fn",
")",
"?",
"fn",
":",
"function",
"(",
")",
"{",
"}",
";",
"var",
"cy",
"=",
"this",
".",
"_private",
".",
"cy",
";",
"var",
"v",
"=",
"$$",
".",
"is",
".",
"string",
"(",
"roots",
")",
"?",
"this",
".",
"filter",
"(",
"roots",
")",
":",
"roots",
";",
"var",
"Q",
"=",
"[",
"]",
";",
"var",
"connectedEles",
"=",
"[",
"]",
";",
"var",
"connectedFrom",
"=",
"{",
"}",
";",
"var",
"id2depth",
"=",
"{",
"}",
";",
"var",
"V",
"=",
"{",
"}",
";",
"var",
"j",
"=",
"0",
";",
"var",
"found",
";",
"var",
"nodes",
"=",
"this",
".",
"nodes",
"(",
")",
";",
"var",
"edges",
"=",
"this",
".",
"edges",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"v",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"v",
"[",
"i",
"]",
".",
"isNode",
"(",
")",
")",
"{",
"Q",
".",
"unshift",
"(",
"v",
"[",
"i",
"]",
")",
";",
"V",
"[",
"v",
"[",
"i",
"]",
".",
"id",
"(",
")",
"]",
"=",
"true",
";",
"connectedEles",
".",
"push",
"(",
"v",
"[",
"i",
"]",
")",
";",
"id2depth",
"[",
"v",
"[",
"i",
"]",
".",
"id",
"(",
")",
"]",
"=",
"0",
";",
"}",
"}",
"while",
"(",
"Q",
".",
"length",
"!==",
"0",
")",
"{",
"var",
"v",
"=",
"Q",
".",
"shift",
"(",
")",
";",
"var",
"depth",
"=",
"id2depth",
"[",
"v",
".",
"id",
"(",
")",
"]",
";",
"var",
"ret",
"=",
"fn",
".",
"call",
"(",
"v",
",",
"j",
"++",
",",
"depth",
")",
";",
"if",
"(",
"ret",
"===",
"true",
")",
"{",
"found",
"=",
"v",
";",
"break",
";",
"}",
"if",
"(",
"ret",
"===",
"false",
")",
"{",
"break",
";",
"}",
"var",
"vwEdges",
"=",
"v",
".",
"connectedEdges",
"(",
"directed",
"?",
"'[source = \"'",
"+",
"v",
".",
"id",
"(",
")",
"+",
"'\"]'",
":",
"undefined",
")",
".",
"intersect",
"(",
"edges",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"vwEdges",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"e",
"=",
"vwEdges",
"[",
"i",
"]",
";",
"var",
"w",
"=",
"e",
".",
"connectedNodes",
"(",
"'[id != \"'",
"+",
"v",
".",
"id",
"(",
")",
"+",
"'\"]'",
")",
".",
"intersect",
"(",
"nodes",
")",
";",
"if",
"(",
"w",
".",
"length",
"!==",
"0",
"&&",
"!",
"V",
"[",
"w",
".",
"id",
"(",
")",
"]",
")",
"{",
"w",
"=",
"w",
"[",
"0",
"]",
";",
"Q",
".",
"push",
"(",
"w",
")",
";",
"V",
"[",
"w",
".",
"id",
"(",
")",
"]",
"=",
"true",
";",
"id2depth",
"[",
"w",
".",
"id",
"(",
")",
"]",
"=",
"id2depth",
"[",
"v",
".",
"id",
"(",
")",
"]",
"+",
"1",
";",
"connectedEles",
".",
"push",
"(",
"w",
")",
";",
"connectedEles",
".",
"push",
"(",
"e",
")",
";",
"}",
"}",
"}",
"return",
"{",
"path",
":",
"new",
"$$",
".",
"Collection",
"(",
"cy",
",",
"connectedEles",
")",
",",
"found",
":",
"new",
"$$",
".",
"Collection",
"(",
"cy",
",",
"found",
")",
"}",
";",
"}"
] |
do a breadth first search from the nodes in the collection from pseudocode on wikipedia
|
[
"do",
"a",
"breadth",
"first",
"search",
"from",
"the",
"nodes",
"in",
"the",
"collection",
"from",
"pseudocode",
"on",
"wikipedia"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L8082-L8146
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function(){
var ele = this[0];
if( ele && ele.isNode() ){
var h = ele._private.style.height;
return h.strValue === 'auto' ? ele._private.autoHeight : h.pxValue;
}
}
|
javascript
|
function(){
var ele = this[0];
if( ele && ele.isNode() ){
var h = ele._private.style.height;
return h.strValue === 'auto' ? ele._private.autoHeight : h.pxValue;
}
}
|
[
"function",
"(",
")",
"{",
"var",
"ele",
"=",
"this",
"[",
"0",
"]",
";",
"if",
"(",
"ele",
"&&",
"ele",
".",
"isNode",
"(",
")",
")",
"{",
"var",
"h",
"=",
"ele",
".",
"_private",
".",
"style",
".",
"height",
";",
"return",
"h",
".",
"strValue",
"===",
"'auto'",
"?",
"ele",
".",
"_private",
".",
"autoHeight",
":",
"h",
".",
"pxValue",
";",
"}",
"}"
] |
convenience function to get a numerical value for the height of the node
|
[
"convenience",
"function",
"to",
"get",
"a",
"numerical",
"value",
"for",
"the",
"height",
"of",
"the",
"node"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L9077-L9084
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function( selector ){
var eles = this;
var roots = [];
for( var i = 0; i < eles.length; i++ ){
var ele = eles[i];
if( !ele.isNode() ){
continue;
}
var hasEdgesPointingIn = ele.connectedEdges('[target = "' + ele.id() + '"][source != "' + ele.id() + '"]').length > 0;
if( !hasEdgesPointingIn ){
roots.push( ele );
}
}
return new $$.Collection( this._private.cy, roots ).filter( selector );
}
|
javascript
|
function( selector ){
var eles = this;
var roots = [];
for( var i = 0; i < eles.length; i++ ){
var ele = eles[i];
if( !ele.isNode() ){
continue;
}
var hasEdgesPointingIn = ele.connectedEdges('[target = "' + ele.id() + '"][source != "' + ele.id() + '"]').length > 0;
if( !hasEdgesPointingIn ){
roots.push( ele );
}
}
return new $$.Collection( this._private.cy, roots ).filter( selector );
}
|
[
"function",
"(",
"selector",
")",
"{",
"var",
"eles",
"=",
"this",
";",
"var",
"roots",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"eles",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"ele",
"=",
"eles",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"ele",
".",
"isNode",
"(",
")",
")",
"{",
"continue",
";",
"}",
"var",
"hasEdgesPointingIn",
"=",
"ele",
".",
"connectedEdges",
"(",
"'[target = \"'",
"+",
"ele",
".",
"id",
"(",
")",
"+",
"'\"][source != \"'",
"+",
"ele",
".",
"id",
"(",
")",
"+",
"'\"]'",
")",
".",
"length",
">",
"0",
";",
"if",
"(",
"!",
"hasEdgesPointingIn",
")",
"{",
"roots",
".",
"push",
"(",
"ele",
")",
";",
"}",
"}",
"return",
"new",
"$$",
".",
"Collection",
"(",
"this",
".",
"_private",
".",
"cy",
",",
"roots",
")",
".",
"filter",
"(",
"selector",
")",
";",
"}"
] |
get the root nodes in the DAG
|
[
"get",
"the",
"root",
"nodes",
"in",
"the",
"DAG"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L10147-L10164
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function( selector ){
var eles = this;
var fNodes = [];
for( var i = 0; i < eles.length; i++ ){
var ele = eles[i];
var eleId = ele.id();
if( !ele.isNode() ){ continue; }
var edges = ele._private.edges;
for( var j = 0; j < edges.length; j++ ){
var edge = edges[j];
var srcId = edge._private.data.source;
var tgtId = edge._private.data.target;
if( srcId === eleId && tgtId !== eleId ){
fNodes.push( edge.target()[0] );
}
}
}
return new $$.Collection( this._private.cy, fNodes ).filter( selector );
}
|
javascript
|
function( selector ){
var eles = this;
var fNodes = [];
for( var i = 0; i < eles.length; i++ ){
var ele = eles[i];
var eleId = ele.id();
if( !ele.isNode() ){ continue; }
var edges = ele._private.edges;
for( var j = 0; j < edges.length; j++ ){
var edge = edges[j];
var srcId = edge._private.data.source;
var tgtId = edge._private.data.target;
if( srcId === eleId && tgtId !== eleId ){
fNodes.push( edge.target()[0] );
}
}
}
return new $$.Collection( this._private.cy, fNodes ).filter( selector );
}
|
[
"function",
"(",
"selector",
")",
"{",
"var",
"eles",
"=",
"this",
";",
"var",
"fNodes",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"eles",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"ele",
"=",
"eles",
"[",
"i",
"]",
";",
"var",
"eleId",
"=",
"ele",
".",
"id",
"(",
")",
";",
"if",
"(",
"!",
"ele",
".",
"isNode",
"(",
")",
")",
"{",
"continue",
";",
"}",
"var",
"edges",
"=",
"ele",
".",
"_private",
".",
"edges",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"edges",
".",
"length",
";",
"j",
"++",
")",
"{",
"var",
"edge",
"=",
"edges",
"[",
"j",
"]",
";",
"var",
"srcId",
"=",
"edge",
".",
"_private",
".",
"data",
".",
"source",
";",
"var",
"tgtId",
"=",
"edge",
".",
"_private",
".",
"data",
".",
"target",
";",
"if",
"(",
"srcId",
"===",
"eleId",
"&&",
"tgtId",
"!==",
"eleId",
")",
"{",
"fNodes",
".",
"push",
"(",
"edge",
".",
"target",
"(",
")",
"[",
"0",
"]",
")",
";",
"}",
"}",
"}",
"return",
"new",
"$$",
".",
"Collection",
"(",
"this",
".",
"_private",
".",
"cy",
",",
"fNodes",
")",
".",
"filter",
"(",
"selector",
")",
";",
"}"
] |
normally called children in graph theory these nodes =edges=> forward nodes
|
[
"normally",
"called",
"children",
"in",
"graph",
"theory",
"these",
"nodes",
"=",
"edges",
"=",
">",
"forward",
"nodes"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L10168-L10191
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function(node, dragElements) {
node._private.grabbed = true;
node._private.rscratch.inDragLayer = true;
dragElements.push(node);
for (var i=0;i<node._private.edges.length;i++) {
node._private.edges[i]._private.rscratch.inDragLayer = true;
}
//node.trigger(new $$.Event(e, {type: 'grab'}));
}
|
javascript
|
function(node, dragElements) {
node._private.grabbed = true;
node._private.rscratch.inDragLayer = true;
dragElements.push(node);
for (var i=0;i<node._private.edges.length;i++) {
node._private.edges[i]._private.rscratch.inDragLayer = true;
}
//node.trigger(new $$.Event(e, {type: 'grab'}));
}
|
[
"function",
"(",
"node",
",",
"dragElements",
")",
"{",
"node",
".",
"_private",
".",
"grabbed",
"=",
"true",
";",
"node",
".",
"_private",
".",
"rscratch",
".",
"inDragLayer",
"=",
"true",
";",
"dragElements",
".",
"push",
"(",
"node",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"node",
".",
"_private",
".",
"edges",
".",
"length",
";",
"i",
"++",
")",
"{",
"node",
".",
"_private",
".",
"edges",
"[",
"i",
"]",
".",
"_private",
".",
"rscratch",
".",
"inDragLayer",
"=",
"true",
";",
"}",
"}"
] |
adds the given nodes, and its edges to the drag layer
|
[
"adds",
"the",
"given",
"nodes",
"and",
"its",
"edges",
"to",
"the",
"drag",
"layer"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L14478-L14489
|
train
|
|
geneontology/amigo
|
static/js/org/cytoscape.js
|
function( eles ){
for( var i = 0; i < eles.length; i++ ){
eles[i]._private.grabbed = false;
eles[i]._private.rscratch.inDragLayer = false;
if( eles[i].active() ){ eles[i].unactivate(); }
}
}
|
javascript
|
function( eles ){
for( var i = 0; i < eles.length; i++ ){
eles[i]._private.grabbed = false;
eles[i]._private.rscratch.inDragLayer = false;
if( eles[i].active() ){ eles[i].unactivate(); }
}
}
|
[
"function",
"(",
"eles",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"eles",
".",
"length",
";",
"i",
"++",
")",
"{",
"eles",
"[",
"i",
"]",
".",
"_private",
".",
"grabbed",
"=",
"false",
";",
"eles",
"[",
"i",
"]",
".",
"_private",
".",
"rscratch",
".",
"inDragLayer",
"=",
"false",
";",
"if",
"(",
"eles",
"[",
"i",
"]",
".",
"active",
"(",
")",
")",
"{",
"eles",
"[",
"i",
"]",
".",
"unactivate",
"(",
")",
";",
"}",
"}",
"}"
] |
anything in the set of dragged eles should be released
|
[
"anything",
"in",
"the",
"set",
"of",
"dragged",
"eles",
"should",
"be",
"released"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/static/js/org/cytoscape.js#L15355-L15361
|
train
|
|
mjeanroy/rollup-plugin-license
|
src/license-plugin.js
|
validateOptions
|
function validateOptions(options) {
const notSupported = _.reject(_.keys(options), (key) => (
OPTIONS.has(key)
));
if (notSupported.length > 0) {
console.warn(`[${PLUGIN_NAME}] Options ${notSupported} are not supported, use following options: ${Array.from(OPTIONS)}`);
}
}
|
javascript
|
function validateOptions(options) {
const notSupported = _.reject(_.keys(options), (key) => (
OPTIONS.has(key)
));
if (notSupported.length > 0) {
console.warn(`[${PLUGIN_NAME}] Options ${notSupported} are not supported, use following options: ${Array.from(OPTIONS)}`);
}
}
|
[
"function",
"validateOptions",
"(",
"options",
")",
"{",
"const",
"notSupported",
"=",
"_",
".",
"reject",
"(",
"_",
".",
"keys",
"(",
"options",
")",
",",
"(",
"key",
")",
"=>",
"(",
"OPTIONS",
".",
"has",
"(",
"key",
")",
")",
")",
";",
"if",
"(",
"notSupported",
".",
"length",
">",
"0",
")",
"{",
"console",
".",
"warn",
"(",
"`",
"${",
"PLUGIN_NAME",
"}",
"${",
"notSupported",
"}",
"${",
"Array",
".",
"from",
"(",
"OPTIONS",
")",
"}",
"`",
")",
";",
"}",
"}"
] |
Print for deprecated or unknown options according to the `OPTIONS`
set defined below.
@param {Object} options The initialization option.
@return {void}
|
[
"Print",
"for",
"deprecated",
"or",
"unknown",
"options",
"according",
"to",
"the",
"OPTIONS",
"set",
"defined",
"below",
"."
] |
39eecef4bde8448b973439929f96cc50bbdb0132
|
https://github.com/mjeanroy/rollup-plugin-license/blob/39eecef4bde8448b973439929f96cc50bbdb0132/src/license-plugin.js#L62-L70
|
train
|
mjeanroy/rollup-plugin-license
|
src/license-plugin.js
|
fixSourceMapOptions
|
function fixSourceMapOptions(options) {
// Rollup <= 0.48 used `sourceMap` in camelcase, so this plugin used
// this convention at the beginning.
// Now, the `sourcemap` key should be used, but legacy version should still
// be able to use the `sourceMap` key.
const newOptions = _.omitBy(options, (value, key) => (
key === 'sourceMap'
));
// If the old `sourceMap` key is used, set it to `sourcemap` key.
if (_.hasIn(options, 'sourceMap')) {
console.warn(`[${PLUGIN_NAME}] sourceMap has been deprecated, please use sourcemap instead.`);
if (!_.hasIn(newOptions, 'sourcemap')) {
newOptions.sourcemap = options.sourceMap;
}
}
// Validate options.
validateOptions(newOptions);
return newOptions;
}
|
javascript
|
function fixSourceMapOptions(options) {
// Rollup <= 0.48 used `sourceMap` in camelcase, so this plugin used
// this convention at the beginning.
// Now, the `sourcemap` key should be used, but legacy version should still
// be able to use the `sourceMap` key.
const newOptions = _.omitBy(options, (value, key) => (
key === 'sourceMap'
));
// If the old `sourceMap` key is used, set it to `sourcemap` key.
if (_.hasIn(options, 'sourceMap')) {
console.warn(`[${PLUGIN_NAME}] sourceMap has been deprecated, please use sourcemap instead.`);
if (!_.hasIn(newOptions, 'sourcemap')) {
newOptions.sourcemap = options.sourceMap;
}
}
// Validate options.
validateOptions(newOptions);
return newOptions;
}
|
[
"function",
"fixSourceMapOptions",
"(",
"options",
")",
"{",
"const",
"newOptions",
"=",
"_",
".",
"omitBy",
"(",
"options",
",",
"(",
"value",
",",
"key",
")",
"=>",
"(",
"key",
"===",
"'sourceMap'",
")",
")",
";",
"if",
"(",
"_",
".",
"hasIn",
"(",
"options",
",",
"'sourceMap'",
")",
")",
"{",
"console",
".",
"warn",
"(",
"`",
"${",
"PLUGIN_NAME",
"}",
"`",
")",
";",
"if",
"(",
"!",
"_",
".",
"hasIn",
"(",
"newOptions",
",",
"'sourcemap'",
")",
")",
"{",
"newOptions",
".",
"sourcemap",
"=",
"options",
".",
"sourceMap",
";",
"}",
"}",
"validateOptions",
"(",
"newOptions",
")",
";",
"return",
"newOptions",
";",
"}"
] |
Fix option object, replace `sourceMap` with `sourcemap` if needed.
@param {Object} options Original option object.
@return {Object} The new fixed option object.
|
[
"Fix",
"option",
"object",
"replace",
"sourceMap",
"with",
"sourcemap",
"if",
"needed",
"."
] |
39eecef4bde8448b973439929f96cc50bbdb0132
|
https://github.com/mjeanroy/rollup-plugin-license/blob/39eecef4bde8448b973439929f96cc50bbdb0132/src/license-plugin.js#L78-L99
|
train
|
geneontology/amigo
|
gulpfile.js
|
_ping_count
|
function _ping_count(){
if( count_url && typeof(count_url) === 'string' && count_url !== '' ){
request({
url: count_url
}, function(error, response, body){
if( error || response.statusCode !== 200 ){
console.log('Unable to ping: ' + count_url);
}else{
console.log('Pinged: ' + count_url);
}
});
}else{
console.log('Will not ping home.');
}
}
|
javascript
|
function _ping_count(){
if( count_url && typeof(count_url) === 'string' && count_url !== '' ){
request({
url: count_url
}, function(error, response, body){
if( error || response.statusCode !== 200 ){
console.log('Unable to ping: ' + count_url);
}else{
console.log('Pinged: ' + count_url);
}
});
}else{
console.log('Will not ping home.');
}
}
|
[
"function",
"_ping_count",
"(",
")",
"{",
"if",
"(",
"count_url",
"&&",
"typeof",
"(",
"count_url",
")",
"===",
"'string'",
"&&",
"count_url",
"!==",
"''",
")",
"{",
"request",
"(",
"{",
"url",
":",
"count_url",
"}",
",",
"function",
"(",
"error",
",",
"response",
",",
"body",
")",
"{",
"if",
"(",
"error",
"||",
"response",
".",
"statusCode",
"!==",
"200",
")",
"{",
"console",
".",
"log",
"(",
"'Unable to ping: '",
"+",
"count_url",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'Pinged: '",
"+",
"count_url",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'Will not ping home.'",
")",
";",
"}",
"}"
] |
Ping server; used during certain commands.
|
[
"Ping",
"server",
";",
"used",
"during",
"certain",
"commands",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/gulpfile.js#L42-L58
|
train
|
geneontology/amigo
|
gulpfile.js
|
_client_compile_task
|
function _client_compile_task(file) {
var infile = amigo_js_dev_path + '/' +file;
//var outfile = amigo_js_out_path + '/' +file;
var b = browserify(infile);
return b
// not in npm, don't need in browser
.exclude('ringo/httpclient')
.bundle()
// desired output filename to vinyl-source-stream
.pipe(source(file))
.pipe(gulp.dest(amigo_js_out_path));
}
|
javascript
|
function _client_compile_task(file) {
var infile = amigo_js_dev_path + '/' +file;
//var outfile = amigo_js_out_path + '/' +file;
var b = browserify(infile);
return b
// not in npm, don't need in browser
.exclude('ringo/httpclient')
.bundle()
// desired output filename to vinyl-source-stream
.pipe(source(file))
.pipe(gulp.dest(amigo_js_out_path));
}
|
[
"function",
"_client_compile_task",
"(",
"file",
")",
"{",
"var",
"infile",
"=",
"amigo_js_dev_path",
"+",
"'/'",
"+",
"file",
";",
"var",
"b",
"=",
"browserify",
"(",
"infile",
")",
";",
"return",
"b",
".",
"exclude",
"(",
"'ringo/httpclient'",
")",
".",
"bundle",
"(",
")",
".",
"pipe",
"(",
"source",
"(",
"file",
")",
")",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"amigo_js_out_path",
")",
")",
";",
"}"
] |
See what browserify-shim is up to. process.env.BROWSERIFYSHIM_DIAGNOSTICS = 1; Browser runtime environment construction.
|
[
"See",
"what",
"browserify",
"-",
"shim",
"is",
"up",
"to",
".",
"process",
".",
"env",
".",
"BROWSERIFYSHIM_DIAGNOSTICS",
"=",
"1",
";",
"Browser",
"runtime",
"environment",
"construction",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/gulpfile.js#L300-L313
|
train
|
strapi/strapi-generate-users
|
files/api/user/services/grant.js
|
getProfile
|
function getProfile(provider, access_token, callback) {
let fields;
switch (provider) {
case 'facebook':
facebook.query().get('me?fields=name,email').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
username: body.name,
email: body.email
});
}
});
break;
case 'google':
google.query('plus').get('people/me').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
username: body.displayName,
email: body.emails[0].value
});
}
});
break;
case 'github':
github.query().get('user').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
username: body.login,
email: body.email
});
}
});
break;
case 'linkedin2':
fields = [
'public-profile-url', 'email-address'
];
linkedin.query().select('people/~:(' + fields.join() + ')?format=json').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
username: substr(body.publicProfileUrl.lastIndexOf('/') + 1),
email: body.emailAddress
});
}
});
break;
default:
callback({
message: 'Unknown provider.'
});
break;
}
}
|
javascript
|
function getProfile(provider, access_token, callback) {
let fields;
switch (provider) {
case 'facebook':
facebook.query().get('me?fields=name,email').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
username: body.name,
email: body.email
});
}
});
break;
case 'google':
google.query('plus').get('people/me').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
username: body.displayName,
email: body.emails[0].value
});
}
});
break;
case 'github':
github.query().get('user').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
username: body.login,
email: body.email
});
}
});
break;
case 'linkedin2':
fields = [
'public-profile-url', 'email-address'
];
linkedin.query().select('people/~:(' + fields.join() + ')?format=json').auth(access_token).request(function (err, res, body) {
if (err) {
callback(err);
} else {
callback(null, {
username: substr(body.publicProfileUrl.lastIndexOf('/') + 1),
email: body.emailAddress
});
}
});
break;
default:
callback({
message: 'Unknown provider.'
});
break;
}
}
|
[
"function",
"getProfile",
"(",
"provider",
",",
"access_token",
",",
"callback",
")",
"{",
"let",
"fields",
";",
"switch",
"(",
"provider",
")",
"{",
"case",
"'facebook'",
":",
"facebook",
".",
"query",
"(",
")",
".",
"get",
"(",
"'me?fields=name,email'",
")",
".",
"auth",
"(",
"access_token",
")",
".",
"request",
"(",
"function",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"{",
"username",
":",
"body",
".",
"name",
",",
"email",
":",
"body",
".",
"email",
"}",
")",
";",
"}",
"}",
")",
";",
"break",
";",
"case",
"'google'",
":",
"google",
".",
"query",
"(",
"'plus'",
")",
".",
"get",
"(",
"'people/me'",
")",
".",
"auth",
"(",
"access_token",
")",
".",
"request",
"(",
"function",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"{",
"username",
":",
"body",
".",
"displayName",
",",
"email",
":",
"body",
".",
"emails",
"[",
"0",
"]",
".",
"value",
"}",
")",
";",
"}",
"}",
")",
";",
"break",
";",
"case",
"'github'",
":",
"github",
".",
"query",
"(",
")",
".",
"get",
"(",
"'user'",
")",
".",
"auth",
"(",
"access_token",
")",
".",
"request",
"(",
"function",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"{",
"username",
":",
"body",
".",
"login",
",",
"email",
":",
"body",
".",
"email",
"}",
")",
";",
"}",
"}",
")",
";",
"break",
";",
"case",
"'linkedin2'",
":",
"fields",
"=",
"[",
"'public-profile-url'",
",",
"'email-address'",
"]",
";",
"linkedin",
".",
"query",
"(",
")",
".",
"select",
"(",
"'people/~:('",
"+",
"fields",
".",
"join",
"(",
")",
"+",
"')?format=json'",
")",
".",
"auth",
"(",
"access_token",
")",
".",
"request",
"(",
"function",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"{",
"username",
":",
"substr",
"(",
"body",
".",
"publicProfileUrl",
".",
"lastIndexOf",
"(",
"'/'",
")",
"+",
"1",
")",
",",
"email",
":",
"body",
".",
"emailAddress",
"}",
")",
";",
"}",
"}",
")",
";",
"break",
";",
"default",
":",
"callback",
"(",
"{",
"message",
":",
"'Unknown provider.'",
"}",
")",
";",
"break",
";",
"}",
"}"
] |
Helper to get profiles
@param {String} provider
@param {Function} callback
|
[
"Helper",
"to",
"get",
"profiles"
] |
e7e8913165a591c26081706fedaec9dd4c801c50
|
https://github.com/strapi/strapi-generate-users/blob/e7e8913165a591c26081706fedaec9dd4c801c50/files/api/user/services/grant.js#L99-L159
|
train
|
geneontology/amigo
|
javascript/npm/bbop-widget-set/lib/display.js
|
function(){
var retval = false;
var lc = jQuery(this).text().toLowerCase();
if( lc.indexOf(stext) >= 0 ){
retval = true;
}
return retval;
}
|
javascript
|
function(){
var retval = false;
var lc = jQuery(this).text().toLowerCase();
if( lc.indexOf(stext) >= 0 ){
retval = true;
}
return retval;
}
|
[
"function",
"(",
")",
"{",
"var",
"retval",
"=",
"false",
";",
"var",
"lc",
"=",
"jQuery",
"(",
"this",
")",
".",
"text",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"lc",
".",
"indexOf",
"(",
"stext",
")",
">=",
"0",
")",
"{",
"retval",
"=",
"true",
";",
"}",
"return",
"retval",
";",
"}"
] |
jQuery filter to match element contents against stext.
|
[
"jQuery",
"filter",
"to",
"match",
"element",
"contents",
"against",
"stext",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/npm/bbop-widget-set/lib/display.js#L383-L390
|
train
|
|
geneontology/amigo
|
javascript/lib/amigo/ui/interactive.js
|
_has_item
|
function _has_item(in_arg_key){
var retval = false;
if( typeof anchor.current_data[in_arg_key] != 'undefined' ){
retval = true;
}
return retval;
}
|
javascript
|
function _has_item(in_arg_key){
var retval = false;
if( typeof anchor.current_data[in_arg_key] != 'undefined' ){
retval = true;
}
return retval;
}
|
[
"function",
"_has_item",
"(",
"in_arg_key",
")",
"{",
"var",
"retval",
"=",
"false",
";",
"if",
"(",
"typeof",
"anchor",
".",
"current_data",
"[",
"in_arg_key",
"]",
"!=",
"'undefined'",
")",
"{",
"retval",
"=",
"true",
";",
"}",
"return",
"retval",
";",
"}"
] |
See if data item exists by key.
|
[
"See",
"if",
"data",
"item",
"exists",
"by",
"key",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L73-L79
|
train
|
geneontology/amigo
|
javascript/lib/amigo/ui/interactive.js
|
_add_item
|
function _add_item(in_arg_key, data){
var retval = false;
if( typeof anchor.current_data[in_arg_key] == 'undefined' ){
// BUG/TODO: this should be a copy.
anchor.current_data[in_arg_key] = data;
//ll("add_item: adding key (w/data): " + in_arg_key);
retval = true;
}
return retval;
}
|
javascript
|
function _add_item(in_arg_key, data){
var retval = false;
if( typeof anchor.current_data[in_arg_key] == 'undefined' ){
// BUG/TODO: this should be a copy.
anchor.current_data[in_arg_key] = data;
//ll("add_item: adding key (w/data): " + in_arg_key);
retval = true;
}
return retval;
}
|
[
"function",
"_add_item",
"(",
"in_arg_key",
",",
"data",
")",
"{",
"var",
"retval",
"=",
"false",
";",
"if",
"(",
"typeof",
"anchor",
".",
"current_data",
"[",
"in_arg_key",
"]",
"==",
"'undefined'",
")",
"{",
"anchor",
".",
"current_data",
"[",
"in_arg_key",
"]",
"=",
"data",
";",
"retval",
"=",
"true",
";",
"}",
"return",
"retval",
";",
"}"
] |
Add a new data item to the model.
|
[
"Add",
"a",
"new",
"data",
"item",
"to",
"the",
"model",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L84-L94
|
train
|
geneontology/amigo
|
javascript/lib/amigo/ui/interactive.js
|
_update_value
|
function _update_value(inkey, intype, inval){
// Update the value in question.
var rval = false;
if( typeof anchor.current_data[inkey] != 'undefined' &&
typeof anchor.current_data[inkey][intype] != 'undefined' ){
anchor.current_data[inkey][intype] = inval;
rval = true;
// ll("\tupdated: " + inkey +
// "'s " + intype +
// ' to ' + inval);
}
// Bookkeeping to keep the "no filter" option selected
// or not in all cases.
if( _get_selected_items().length == 0 ){
anchor.current_data['_nil_']['selected'] = true;
}else{
anchor.current_data['_nil_']['selected'] = false;
}
return rval;
}
|
javascript
|
function _update_value(inkey, intype, inval){
// Update the value in question.
var rval = false;
if( typeof anchor.current_data[inkey] != 'undefined' &&
typeof anchor.current_data[inkey][intype] != 'undefined' ){
anchor.current_data[inkey][intype] = inval;
rval = true;
// ll("\tupdated: " + inkey +
// "'s " + intype +
// ' to ' + inval);
}
// Bookkeeping to keep the "no filter" option selected
// or not in all cases.
if( _get_selected_items().length == 0 ){
anchor.current_data['_nil_']['selected'] = true;
}else{
anchor.current_data['_nil_']['selected'] = false;
}
return rval;
}
|
[
"function",
"_update_value",
"(",
"inkey",
",",
"intype",
",",
"inval",
")",
"{",
"var",
"rval",
"=",
"false",
";",
"if",
"(",
"typeof",
"anchor",
".",
"current_data",
"[",
"inkey",
"]",
"!=",
"'undefined'",
"&&",
"typeof",
"anchor",
".",
"current_data",
"[",
"inkey",
"]",
"[",
"intype",
"]",
"!=",
"'undefined'",
")",
"{",
"anchor",
".",
"current_data",
"[",
"inkey",
"]",
"[",
"intype",
"]",
"=",
"inval",
";",
"rval",
"=",
"true",
";",
"}",
"if",
"(",
"_get_selected_items",
"(",
")",
".",
"length",
"==",
"0",
")",
"{",
"anchor",
".",
"current_data",
"[",
"'_nil_'",
"]",
"[",
"'selected'",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"anchor",
".",
"current_data",
"[",
"'_nil_'",
"]",
"[",
"'selected'",
"]",
"=",
"false",
";",
"}",
"return",
"rval",
";",
"}"
] |
Update the underlying data structure. Can change count or selected or whatever.
|
[
"Update",
"the",
"underlying",
"data",
"structure",
".",
"Can",
"change",
"count",
"or",
"selected",
"or",
"whatever",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L100-L122
|
train
|
geneontology/amigo
|
javascript/lib/amigo/ui/interactive.js
|
_get_selected_items
|
function _get_selected_items(){
var ret_filters = [];
// Push out the filters that have selected == true.
var all_filters = _get_all_items();
for( var afi = 0; afi < all_filters.length; afi++ ){
var filter_name = all_filters[afi];
var fconf = anchor.current_data[filter_name];
if( fconf &&
typeof fconf['selected'] != 'undefined' &&
fconf['selected'] == true ){
ret_filters.push(filter_name);
}
}
return ret_filters;
}
|
javascript
|
function _get_selected_items(){
var ret_filters = [];
// Push out the filters that have selected == true.
var all_filters = _get_all_items();
for( var afi = 0; afi < all_filters.length; afi++ ){
var filter_name = all_filters[afi];
var fconf = anchor.current_data[filter_name];
if( fconf &&
typeof fconf['selected'] != 'undefined' &&
fconf['selected'] == true ){
ret_filters.push(filter_name);
}
}
return ret_filters;
}
|
[
"function",
"_get_selected_items",
"(",
")",
"{",
"var",
"ret_filters",
"=",
"[",
"]",
";",
"var",
"all_filters",
"=",
"_get_all_items",
"(",
")",
";",
"for",
"(",
"var",
"afi",
"=",
"0",
";",
"afi",
"<",
"all_filters",
".",
"length",
";",
"afi",
"++",
")",
"{",
"var",
"filter_name",
"=",
"all_filters",
"[",
"afi",
"]",
";",
"var",
"fconf",
"=",
"anchor",
".",
"current_data",
"[",
"filter_name",
"]",
";",
"if",
"(",
"fconf",
"&&",
"typeof",
"fconf",
"[",
"'selected'",
"]",
"!=",
"'undefined'",
"&&",
"fconf",
"[",
"'selected'",
"]",
"==",
"true",
")",
"{",
"ret_filters",
".",
"push",
"(",
"filter_name",
")",
";",
"}",
"}",
"return",
"ret_filters",
";",
"}"
] |
Give all selected current filters.
|
[
"Give",
"all",
"selected",
"current",
"filters",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L143-L160
|
train
|
geneontology/amigo
|
javascript/lib/amigo/ui/interactive.js
|
_render_label
|
function _render_label(){
var buf = new Array();
// Add the label.
buf.push('<label for="');
buf.push(anchor.mid);
buf.push('" class="select">');
buf.push(anchor.mlabel);
buf.push('</label>');
return buf.join('');
}
|
javascript
|
function _render_label(){
var buf = new Array();
// Add the label.
buf.push('<label for="');
buf.push(anchor.mid);
buf.push('" class="select">');
buf.push(anchor.mlabel);
buf.push('</label>');
return buf.join('');
}
|
[
"function",
"_render_label",
"(",
")",
"{",
"var",
"buf",
"=",
"new",
"Array",
"(",
")",
";",
"buf",
".",
"push",
"(",
"'<label for=\"'",
")",
";",
"buf",
".",
"push",
"(",
"anchor",
".",
"mid",
")",
";",
"buf",
".",
"push",
"(",
"'\" class=\"select\">'",
")",
";",
"buf",
".",
"push",
"(",
"anchor",
".",
"mlabel",
")",
";",
"buf",
".",
"push",
"(",
"'</label>'",
")",
";",
"return",
"buf",
".",
"join",
"(",
"''",
")",
";",
"}"
] |
Render the label to an HTML string.
|
[
"Render",
"the",
"label",
"to",
"an",
"HTML",
"string",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L207-L219
|
train
|
geneontology/amigo
|
javascript/lib/amigo/ui/interactive.js
|
_render_option
|
function _render_option(){
var buf = new Array();
// Sort the items in the mdata array.
// Also keep a lookup for a "special" entry.
// var default_on_p = false;
var mdata_keys = bbop.core.get_keys(anchor.mdata);
function _data_comp(a, b){
// Get the associated data.
var a_data = anchor.mdata[a];
var b_data = anchor.mdata[b];
// if( (a_data['special'] == true && a_data['selected'] == true) ||
// (b_data['special'] == true && b_data['selected'] == true) ){
// default_on_p = true;
// }
//
var retval = 0;
if( a_data['special'] != b_data['special'] ){
if( a_data['count'] == true ){
retval = 1;
}else{
retval = -1;
}
}else if( a_data['count'] != b_data['count'] ){
if( a_data['count'] > b_data['count'] ){
retval = -1;
}else{
retval = 1;
}
}else if( a_data['label'] != b_data['label'] ){
if( a_data['label'] > b_data['label'] ){
retval = 1;
}else{
retval = -1;
}
}
return retval;
}
mdata_keys.sort(_data_comp); // inplace sort
//
for( var mski = 0; mski < mdata_keys.length; mski++ ){
var write_data = anchor.mdata[mdata_keys[mski]];
// Write out option if:
// 1) the default is selected (so we want to see everything)
// 2) the selection is special
// 3) if the default is not selected, either the item is selected or
// 4) it has a count (and is thus interesting)
if( // default_on_p == true ||
write_data['selected'] == true ||
write_data['special'] == true ||
( write_data['count'] && write_data['count'] > 0 ) ){
buf.push('<option');
// Title.
buf.push(' title="');
buf.push(write_data['value']);
buf.push('"');
// Value.
buf.push(' value="');
buf.push(write_data['value']);
buf.push('"');
if( write_data['selected'] ){
buf.push(' selected="selected"');
}
buf.push('>');
//buf.push(bbop.core.crop(write_data['label']));
buf.push(bbop.core.crop(write_data['label'], 40, '...'));
if( write_data['count'] && write_data['count'] > 0 ){
buf.push(' (' + write_data['count'] + ')');
}
buf.push('</option>');
}
}
return buf.join('');
}
|
javascript
|
function _render_option(){
var buf = new Array();
// Sort the items in the mdata array.
// Also keep a lookup for a "special" entry.
// var default_on_p = false;
var mdata_keys = bbop.core.get_keys(anchor.mdata);
function _data_comp(a, b){
// Get the associated data.
var a_data = anchor.mdata[a];
var b_data = anchor.mdata[b];
// if( (a_data['special'] == true && a_data['selected'] == true) ||
// (b_data['special'] == true && b_data['selected'] == true) ){
// default_on_p = true;
// }
//
var retval = 0;
if( a_data['special'] != b_data['special'] ){
if( a_data['count'] == true ){
retval = 1;
}else{
retval = -1;
}
}else if( a_data['count'] != b_data['count'] ){
if( a_data['count'] > b_data['count'] ){
retval = -1;
}else{
retval = 1;
}
}else if( a_data['label'] != b_data['label'] ){
if( a_data['label'] > b_data['label'] ){
retval = 1;
}else{
retval = -1;
}
}
return retval;
}
mdata_keys.sort(_data_comp); // inplace sort
//
for( var mski = 0; mski < mdata_keys.length; mski++ ){
var write_data = anchor.mdata[mdata_keys[mski]];
// Write out option if:
// 1) the default is selected (so we want to see everything)
// 2) the selection is special
// 3) if the default is not selected, either the item is selected or
// 4) it has a count (and is thus interesting)
if( // default_on_p == true ||
write_data['selected'] == true ||
write_data['special'] == true ||
( write_data['count'] && write_data['count'] > 0 ) ){
buf.push('<option');
// Title.
buf.push(' title="');
buf.push(write_data['value']);
buf.push('"');
// Value.
buf.push(' value="');
buf.push(write_data['value']);
buf.push('"');
if( write_data['selected'] ){
buf.push(' selected="selected"');
}
buf.push('>');
//buf.push(bbop.core.crop(write_data['label']));
buf.push(bbop.core.crop(write_data['label'], 40, '...'));
if( write_data['count'] && write_data['count'] > 0 ){
buf.push(' (' + write_data['count'] + ')');
}
buf.push('</option>');
}
}
return buf.join('');
}
|
[
"function",
"_render_option",
"(",
")",
"{",
"var",
"buf",
"=",
"new",
"Array",
"(",
")",
";",
"var",
"mdata_keys",
"=",
"bbop",
".",
"core",
".",
"get_keys",
"(",
"anchor",
".",
"mdata",
")",
";",
"function",
"_data_comp",
"(",
"a",
",",
"b",
")",
"{",
"var",
"a_data",
"=",
"anchor",
".",
"mdata",
"[",
"a",
"]",
";",
"var",
"b_data",
"=",
"anchor",
".",
"mdata",
"[",
"b",
"]",
";",
"var",
"retval",
"=",
"0",
";",
"if",
"(",
"a_data",
"[",
"'special'",
"]",
"!=",
"b_data",
"[",
"'special'",
"]",
")",
"{",
"if",
"(",
"a_data",
"[",
"'count'",
"]",
"==",
"true",
")",
"{",
"retval",
"=",
"1",
";",
"}",
"else",
"{",
"retval",
"=",
"-",
"1",
";",
"}",
"}",
"else",
"if",
"(",
"a_data",
"[",
"'count'",
"]",
"!=",
"b_data",
"[",
"'count'",
"]",
")",
"{",
"if",
"(",
"a_data",
"[",
"'count'",
"]",
">",
"b_data",
"[",
"'count'",
"]",
")",
"{",
"retval",
"=",
"-",
"1",
";",
"}",
"else",
"{",
"retval",
"=",
"1",
";",
"}",
"}",
"else",
"if",
"(",
"a_data",
"[",
"'label'",
"]",
"!=",
"b_data",
"[",
"'label'",
"]",
")",
"{",
"if",
"(",
"a_data",
"[",
"'label'",
"]",
">",
"b_data",
"[",
"'label'",
"]",
")",
"{",
"retval",
"=",
"1",
";",
"}",
"else",
"{",
"retval",
"=",
"-",
"1",
";",
"}",
"}",
"return",
"retval",
";",
"}",
"mdata_keys",
".",
"sort",
"(",
"_data_comp",
")",
";",
"for",
"(",
"var",
"mski",
"=",
"0",
";",
"mski",
"<",
"mdata_keys",
".",
"length",
";",
"mski",
"++",
")",
"{",
"var",
"write_data",
"=",
"anchor",
".",
"mdata",
"[",
"mdata_keys",
"[",
"mski",
"]",
"]",
";",
"if",
"(",
"write_data",
"[",
"'selected'",
"]",
"==",
"true",
"||",
"write_data",
"[",
"'special'",
"]",
"==",
"true",
"||",
"(",
"write_data",
"[",
"'count'",
"]",
"&&",
"write_data",
"[",
"'count'",
"]",
">",
"0",
")",
")",
"{",
"buf",
".",
"push",
"(",
"'<option'",
")",
";",
"buf",
".",
"push",
"(",
"' title=\"'",
")",
";",
"buf",
".",
"push",
"(",
"write_data",
"[",
"'value'",
"]",
")",
";",
"buf",
".",
"push",
"(",
"'\"'",
")",
";",
"buf",
".",
"push",
"(",
"' value=\"'",
")",
";",
"buf",
".",
"push",
"(",
"write_data",
"[",
"'value'",
"]",
")",
";",
"buf",
".",
"push",
"(",
"'\"'",
")",
";",
"if",
"(",
"write_data",
"[",
"'selected'",
"]",
")",
"{",
"buf",
".",
"push",
"(",
"' selected=\"selected\"'",
")",
";",
"}",
"buf",
".",
"push",
"(",
"'>'",
")",
";",
"buf",
".",
"push",
"(",
"bbop",
".",
"core",
".",
"crop",
"(",
"write_data",
"[",
"'label'",
"]",
",",
"40",
",",
"'...'",
")",
")",
";",
"if",
"(",
"write_data",
"[",
"'count'",
"]",
"&&",
"write_data",
"[",
"'count'",
"]",
">",
"0",
")",
"{",
"buf",
".",
"push",
"(",
"' ('",
"+",
"write_data",
"[",
"'count'",
"]",
"+",
"')'",
")",
";",
"}",
"buf",
".",
"push",
"(",
"'</option>'",
")",
";",
"}",
"}",
"return",
"buf",
".",
"join",
"(",
"''",
")",
";",
"}"
] |
Render the options to an HTML string.
|
[
"Render",
"the",
"options",
"to",
"an",
"HTML",
"string",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L224-L309
|
train
|
geneontology/amigo
|
javascript/lib/amigo/ui/interactive.js
|
_render_select
|
function _render_select(){
var buf = new Array();
//
buf.push('<select id="');
buf.push(anchor.mid);
buf.push('" name="');
buf.push(anchor.mname);
buf.push('" multiple size="');
buf.push(anchor.msize);
buf.push('">');
buf.push(_render_option());
//
buf.push('</select>');
return buf.join('');
}
|
javascript
|
function _render_select(){
var buf = new Array();
//
buf.push('<select id="');
buf.push(anchor.mid);
buf.push('" name="');
buf.push(anchor.mname);
buf.push('" multiple size="');
buf.push(anchor.msize);
buf.push('">');
buf.push(_render_option());
//
buf.push('</select>');
return buf.join('');
}
|
[
"function",
"_render_select",
"(",
")",
"{",
"var",
"buf",
"=",
"new",
"Array",
"(",
")",
";",
"buf",
".",
"push",
"(",
"'<select id=\"'",
")",
";",
"buf",
".",
"push",
"(",
"anchor",
".",
"mid",
")",
";",
"buf",
".",
"push",
"(",
"'\" name=\"'",
")",
";",
"buf",
".",
"push",
"(",
"anchor",
".",
"mname",
")",
";",
"buf",
".",
"push",
"(",
"'\" multiple size=\"'",
")",
";",
"buf",
".",
"push",
"(",
"anchor",
".",
"msize",
")",
";",
"buf",
".",
"push",
"(",
"'\">'",
")",
";",
"buf",
".",
"push",
"(",
"_render_option",
"(",
")",
")",
";",
"buf",
".",
"push",
"(",
"'</select>'",
")",
";",
"return",
"buf",
".",
"join",
"(",
"''",
")",
";",
"}"
] |
Render the select frame to an HTML string.
|
[
"Render",
"the",
"select",
"frame",
"to",
"an",
"HTML",
"string",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/interactive.js#L314-L333
|
train
|
geneontology/amigo
|
javascript/web/GeneralSearchForwarding.js
|
forward
|
function forward(doc){
if( doc && doc['entity'] && doc['category'] ){
// Erase any val, change the placeholder (to try and
// prevent races where the user selects and then hits
// "search" before the forwarding finishes).
jQuery('#' + wired_name).val('');
jQuery('#' + wired_name).attr('placeholder', 'Forwarding to ' +
doc['entity'] + '...');
// Forward to the new doc.
if( doc['category'] === 'ontology_class' ){
window.location.href =
linker.url(doc['entity'], 'term');
}else if( doc['category'] === 'bioentity' ){
window.location.href = linker.url(doc['entity'], 'gp');
}
}
}
|
javascript
|
function forward(doc){
if( doc && doc['entity'] && doc['category'] ){
// Erase any val, change the placeholder (to try and
// prevent races where the user selects and then hits
// "search" before the forwarding finishes).
jQuery('#' + wired_name).val('');
jQuery('#' + wired_name).attr('placeholder', 'Forwarding to ' +
doc['entity'] + '...');
// Forward to the new doc.
if( doc['category'] === 'ontology_class' ){
window.location.href =
linker.url(doc['entity'], 'term');
}else if( doc['category'] === 'bioentity' ){
window.location.href = linker.url(doc['entity'], 'gp');
}
}
}
|
[
"function",
"forward",
"(",
"doc",
")",
"{",
"if",
"(",
"doc",
"&&",
"doc",
"[",
"'entity'",
"]",
"&&",
"doc",
"[",
"'category'",
"]",
")",
"{",
"jQuery",
"(",
"'#'",
"+",
"wired_name",
")",
".",
"val",
"(",
"''",
")",
";",
"jQuery",
"(",
"'#'",
"+",
"wired_name",
")",
".",
"attr",
"(",
"'placeholder'",
",",
"'Forwarding to '",
"+",
"doc",
"[",
"'entity'",
"]",
"+",
"'...'",
")",
";",
"if",
"(",
"doc",
"[",
"'category'",
"]",
"===",
"'ontology_class'",
")",
"{",
"window",
".",
"location",
".",
"href",
"=",
"linker",
".",
"url",
"(",
"doc",
"[",
"'entity'",
"]",
",",
"'term'",
")",
";",
"}",
"else",
"if",
"(",
"doc",
"[",
"'category'",
"]",
"===",
"'bioentity'",
")",
"{",
"window",
".",
"location",
".",
"href",
"=",
"linker",
".",
"url",
"(",
"doc",
"[",
"'entity'",
"]",
",",
"'gp'",
")",
";",
"}",
"}",
"}"
] |
Widget, default personality and filter.
|
[
"Widget",
"default",
"personality",
"and",
"filter",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/web/GeneralSearchForwarding.js#L56-L75
|
train
|
geneontology/amigo
|
javascript/lib/amigo/ui/widgets.js
|
_generate_element
|
function _generate_element(ctype){
var UID = id_base + bbop.core.randomness();
var div_text = '<div id="' + UID + '"></div>';
jQuery("body").append(jQuery(div_text).hide());
var elt = jQuery('#' + UID);
elt.addClass("org_bbop_amigo_ui_widget_base");
elt.addClass("org_bbop_amigo_ui_widget_for_" + ctype);
return elt;
}
|
javascript
|
function _generate_element(ctype){
var UID = id_base + bbop.core.randomness();
var div_text = '<div id="' + UID + '"></div>';
jQuery("body").append(jQuery(div_text).hide());
var elt = jQuery('#' + UID);
elt.addClass("org_bbop_amigo_ui_widget_base");
elt.addClass("org_bbop_amigo_ui_widget_for_" + ctype);
return elt;
}
|
[
"function",
"_generate_element",
"(",
"ctype",
")",
"{",
"var",
"UID",
"=",
"id_base",
"+",
"bbop",
".",
"core",
".",
"randomness",
"(",
")",
";",
"var",
"div_text",
"=",
"'<div id=\"'",
"+",
"UID",
"+",
"'\"></div>'",
";",
"jQuery",
"(",
"\"body\"",
")",
".",
"append",
"(",
"jQuery",
"(",
"div_text",
")",
".",
"hide",
"(",
")",
")",
";",
"var",
"elt",
"=",
"jQuery",
"(",
"'#'",
"+",
"UID",
")",
";",
"elt",
".",
"addClass",
"(",
"\"org_bbop_amigo_ui_widget_base\"",
")",
";",
"elt",
".",
"addClass",
"(",
"\"org_bbop_amigo_ui_widget_for_\"",
"+",
"ctype",
")",
";",
"return",
"elt",
";",
"}"
] |
Generate and destory used tags.
|
[
"Generate",
"and",
"destory",
"used",
"tags",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/javascript/lib/amigo/ui/widgets.js#L54-L66
|
train
|
geneontology/amigo
|
bin/amigo.js
|
envelope
|
function envelope(service_name){
var anchor = this;
anchor._is_a = 'bbop-service-envelope';
// Start the timer.
anchor._start_time = second_count();
// Theoretical good result frame.
anchor._envelope = {
service: 'n/a',
status: 'success',
arguments: {},
comments: [],
data: {}
};
//
if( service_name && typeof(service_name) === 'string' ){
anchor._envelope['service'] = service_name;
}
}
|
javascript
|
function envelope(service_name){
var anchor = this;
anchor._is_a = 'bbop-service-envelope';
// Start the timer.
anchor._start_time = second_count();
// Theoretical good result frame.
anchor._envelope = {
service: 'n/a',
status: 'success',
arguments: {},
comments: [],
data: {}
};
//
if( service_name && typeof(service_name) === 'string' ){
anchor._envelope['service'] = service_name;
}
}
|
[
"function",
"envelope",
"(",
"service_name",
")",
"{",
"var",
"anchor",
"=",
"this",
";",
"anchor",
".",
"_is_a",
"=",
"'bbop-service-envelope'",
";",
"anchor",
".",
"_start_time",
"=",
"second_count",
"(",
")",
";",
"anchor",
".",
"_envelope",
"=",
"{",
"service",
":",
"'n/a'",
",",
"status",
":",
"'success'",
",",
"arguments",
":",
"{",
"}",
",",
"comments",
":",
"[",
"]",
",",
"data",
":",
"{",
"}",
"}",
";",
"if",
"(",
"service_name",
"&&",
"typeof",
"(",
"service_name",
")",
"===",
"'string'",
")",
"{",
"anchor",
".",
"_envelope",
"[",
"'service'",
"]",
"=",
"service_name",
";",
"}",
"}"
] |
Envelopes are default good.
|
[
"Envelopes",
"are",
"default",
"good",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L83-L105
|
train
|
geneontology/amigo
|
bin/amigo.js
|
_response_json_fail
|
function _response_json_fail(res, envl, message){
envl.status('failure');
envl.comments(message);
return res.json(envl.structure());
}
|
javascript
|
function _response_json_fail(res, envl, message){
envl.status('failure');
envl.comments(message);
return res.json(envl.structure());
}
|
[
"function",
"_response_json_fail",
"(",
"res",
",",
"envl",
",",
"message",
")",
"{",
"envl",
".",
"status",
"(",
"'failure'",
")",
";",
"envl",
".",
"comments",
"(",
"message",
")",
";",
"return",
"res",
".",
"json",
"(",
"envl",
".",
"structure",
"(",
")",
")",
";",
"}"
] |
Failure with a JSON response.
|
[
"Failure",
"with",
"a",
"JSON",
"response",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L260-L264
|
train
|
geneontology/amigo
|
bin/amigo.js
|
_param
|
function _param(req, param, pdefault){
var ret = null;
// Try the route parameter space.
if( req && req.params && typeof(req.params[param]) !== 'undefined' ){
ret = req.params[param];
}
// Try the get space.
if( ! ret ){
if( req && req.query && req.query[param] && typeof(req.query[param]) !== 'undefined' ){
ret = req.query[param];
}
}
// Otherwise, try the body space.
if( ! ret ){
var decoded_body = req.body || {};
if( decoded_body && ! us.isEmpty(decoded_body) && decoded_body[param] ){
ret = decoded_body[param];
}
}
// Reduce to first if array.
if( us.isArray(ret) ){
if( ret.length === 0 ){
ret = pdefault;
}else{
ret = ret[0];
}
}
// Finally, default.
if( ! ret ){
ret = pdefault;
}
return ret;
}
|
javascript
|
function _param(req, param, pdefault){
var ret = null;
// Try the route parameter space.
if( req && req.params && typeof(req.params[param]) !== 'undefined' ){
ret = req.params[param];
}
// Try the get space.
if( ! ret ){
if( req && req.query && req.query[param] && typeof(req.query[param]) !== 'undefined' ){
ret = req.query[param];
}
}
// Otherwise, try the body space.
if( ! ret ){
var decoded_body = req.body || {};
if( decoded_body && ! us.isEmpty(decoded_body) && decoded_body[param] ){
ret = decoded_body[param];
}
}
// Reduce to first if array.
if( us.isArray(ret) ){
if( ret.length === 0 ){
ret = pdefault;
}else{
ret = ret[0];
}
}
// Finally, default.
if( ! ret ){
ret = pdefault;
}
return ret;
}
|
[
"function",
"_param",
"(",
"req",
",",
"param",
",",
"pdefault",
")",
"{",
"var",
"ret",
"=",
"null",
";",
"if",
"(",
"req",
"&&",
"req",
".",
"params",
"&&",
"typeof",
"(",
"req",
".",
"params",
"[",
"param",
"]",
")",
"!==",
"'undefined'",
")",
"{",
"ret",
"=",
"req",
".",
"params",
"[",
"param",
"]",
";",
"}",
"if",
"(",
"!",
"ret",
")",
"{",
"if",
"(",
"req",
"&&",
"req",
".",
"query",
"&&",
"req",
".",
"query",
"[",
"param",
"]",
"&&",
"typeof",
"(",
"req",
".",
"query",
"[",
"param",
"]",
")",
"!==",
"'undefined'",
")",
"{",
"ret",
"=",
"req",
".",
"query",
"[",
"param",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"ret",
")",
"{",
"var",
"decoded_body",
"=",
"req",
".",
"body",
"||",
"{",
"}",
";",
"if",
"(",
"decoded_body",
"&&",
"!",
"us",
".",
"isEmpty",
"(",
"decoded_body",
")",
"&&",
"decoded_body",
"[",
"param",
"]",
")",
"{",
"ret",
"=",
"decoded_body",
"[",
"param",
"]",
";",
"}",
"}",
"if",
"(",
"us",
".",
"isArray",
"(",
"ret",
")",
")",
"{",
"if",
"(",
"ret",
".",
"length",
"===",
"0",
")",
"{",
"ret",
"=",
"pdefault",
";",
"}",
"else",
"{",
"ret",
"=",
"ret",
"[",
"0",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"ret",
")",
"{",
"ret",
"=",
"pdefault",
";",
"}",
"return",
"ret",
";",
"}"
] |
Extract singular arguments; will take first if multiple.
|
[
"Extract",
"singular",
"arguments",
";",
"will",
"take",
"first",
"if",
"multiple",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L267-L308
|
train
|
geneontology/amigo
|
bin/amigo.js
|
_extract
|
function _extract(req, param){
var ret = [];
// Note: no route parameter possible with lists(?).
// Try the get space.
if( req && req.query && typeof(req.query[param]) !== 'undefined' ){
//console.log('as query');
// Input as list, remove dupes.
var paccs = req.query[param];
if( paccs && ! us.isArray(paccs) ){
paccs = [paccs];
}
ret = us.uniq(paccs);
}
// Otherwise, try the body space.
if( us.isEmpty(ret) ){
var decoded_body = req.body || {};
if( decoded_body && ! us.isEmpty(decoded_body) && decoded_body[param] ){
//console.log('as body');
// Input as list, remove dupes.
var baccs = decoded_body[param];
//console.log('decoded_body', decoded_body);
//console.log('baccs', baccs);
if( baccs && ! us.isArray(baccs) ){
baccs = [baccs];
}
ret = us.uniq(baccs);
}
}
return ret;
}
|
javascript
|
function _extract(req, param){
var ret = [];
// Note: no route parameter possible with lists(?).
// Try the get space.
if( req && req.query && typeof(req.query[param]) !== 'undefined' ){
//console.log('as query');
// Input as list, remove dupes.
var paccs = req.query[param];
if( paccs && ! us.isArray(paccs) ){
paccs = [paccs];
}
ret = us.uniq(paccs);
}
// Otherwise, try the body space.
if( us.isEmpty(ret) ){
var decoded_body = req.body || {};
if( decoded_body && ! us.isEmpty(decoded_body) && decoded_body[param] ){
//console.log('as body');
// Input as list, remove dupes.
var baccs = decoded_body[param];
//console.log('decoded_body', decoded_body);
//console.log('baccs', baccs);
if( baccs && ! us.isArray(baccs) ){
baccs = [baccs];
}
ret = us.uniq(baccs);
}
}
return ret;
}
|
[
"function",
"_extract",
"(",
"req",
",",
"param",
")",
"{",
"var",
"ret",
"=",
"[",
"]",
";",
"if",
"(",
"req",
"&&",
"req",
".",
"query",
"&&",
"typeof",
"(",
"req",
".",
"query",
"[",
"param",
"]",
")",
"!==",
"'undefined'",
")",
"{",
"var",
"paccs",
"=",
"req",
".",
"query",
"[",
"param",
"]",
";",
"if",
"(",
"paccs",
"&&",
"!",
"us",
".",
"isArray",
"(",
"paccs",
")",
")",
"{",
"paccs",
"=",
"[",
"paccs",
"]",
";",
"}",
"ret",
"=",
"us",
".",
"uniq",
"(",
"paccs",
")",
";",
"}",
"if",
"(",
"us",
".",
"isEmpty",
"(",
"ret",
")",
")",
"{",
"var",
"decoded_body",
"=",
"req",
".",
"body",
"||",
"{",
"}",
";",
"if",
"(",
"decoded_body",
"&&",
"!",
"us",
".",
"isEmpty",
"(",
"decoded_body",
")",
"&&",
"decoded_body",
"[",
"param",
"]",
")",
"{",
"var",
"baccs",
"=",
"decoded_body",
"[",
"param",
"]",
";",
"if",
"(",
"baccs",
"&&",
"!",
"us",
".",
"isArray",
"(",
"baccs",
")",
")",
"{",
"baccs",
"=",
"[",
"baccs",
"]",
";",
"}",
"ret",
"=",
"us",
".",
"uniq",
"(",
"baccs",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Extract list arguments.
|
[
"Extract",
"list",
"arguments",
"."
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L311-L348
|
train
|
geneontology/amigo
|
bin/amigo.js
|
function(cache){
// Frame to hang our results on.
var results = {
"good": [],
"bad": [],
"ugly": []
};
// Break out the two parts of the species cache.
var doc_lookup = cache['documents'];
var str_refs = cache['references'];
// Comb through the cache, carefully, and get the results
// that we can. First, for each of the entities try and
// pull out the right fields.
us.each(entities, function(entity){
var entity_hits = [];
// Check to see if we can find any document references
// for our given string.
if( str_refs && us.isArray(str_refs[entity]) ){
// For each of the matched IDs, lookup the
// document in question and try and figure out
// which field or fields matched.
var match_proxy_ids = str_refs[entity];
us.each(match_proxy_ids, function(match_proxy_id){
// Retrieve the document by proxy ID.
var doc = doc_lookup[match_proxy_id];
if( doc ){
// Look in all the possibly multi-valued
// fields in the doc for the match.
us.each(bioentity_search_fields, function(search_field){
//console.log("search_field: ", search_field);
var vals = doc[search_field];
// Array-ify the field if not already.
if( vals && ! us.isArray(vals) ){
vals = [vals];
}
us.each(vals, function(val){
// Record that we found the exact
// match we want.
if( entity === val ){
entity_hits.push({
"id": match_proxy_id,
"matched": search_field
});
}
});
});
}
});
}
// The results are good, bad, or ugly, depending on the
// number.
var rtype = null;
if( entity_hits.length === 1 ){
rtype = "good";
}else if( entity_hits.length === 0 ){
rtype = "bad";
}else{
rtype = "ugly";
}
//console.log("results: ", results);
// Push the found results into the right section.
results[rtype].push({
"input": entity,
"results": entity_hits
});
});
return results;
}
|
javascript
|
function(cache){
// Frame to hang our results on.
var results = {
"good": [],
"bad": [],
"ugly": []
};
// Break out the two parts of the species cache.
var doc_lookup = cache['documents'];
var str_refs = cache['references'];
// Comb through the cache, carefully, and get the results
// that we can. First, for each of the entities try and
// pull out the right fields.
us.each(entities, function(entity){
var entity_hits = [];
// Check to see if we can find any document references
// for our given string.
if( str_refs && us.isArray(str_refs[entity]) ){
// For each of the matched IDs, lookup the
// document in question and try and figure out
// which field or fields matched.
var match_proxy_ids = str_refs[entity];
us.each(match_proxy_ids, function(match_proxy_id){
// Retrieve the document by proxy ID.
var doc = doc_lookup[match_proxy_id];
if( doc ){
// Look in all the possibly multi-valued
// fields in the doc for the match.
us.each(bioentity_search_fields, function(search_field){
//console.log("search_field: ", search_field);
var vals = doc[search_field];
// Array-ify the field if not already.
if( vals && ! us.isArray(vals) ){
vals = [vals];
}
us.each(vals, function(val){
// Record that we found the exact
// match we want.
if( entity === val ){
entity_hits.push({
"id": match_proxy_id,
"matched": search_field
});
}
});
});
}
});
}
// The results are good, bad, or ugly, depending on the
// number.
var rtype = null;
if( entity_hits.length === 1 ){
rtype = "good";
}else if( entity_hits.length === 0 ){
rtype = "bad";
}else{
rtype = "ugly";
}
//console.log("results: ", results);
// Push the found results into the right section.
results[rtype].push({
"input": entity,
"results": entity_hits
});
});
return results;
}
|
[
"function",
"(",
"cache",
")",
"{",
"var",
"results",
"=",
"{",
"\"good\"",
":",
"[",
"]",
",",
"\"bad\"",
":",
"[",
"]",
",",
"\"ugly\"",
":",
"[",
"]",
"}",
";",
"var",
"doc_lookup",
"=",
"cache",
"[",
"'documents'",
"]",
";",
"var",
"str_refs",
"=",
"cache",
"[",
"'references'",
"]",
";",
"us",
".",
"each",
"(",
"entities",
",",
"function",
"(",
"entity",
")",
"{",
"var",
"entity_hits",
"=",
"[",
"]",
";",
"if",
"(",
"str_refs",
"&&",
"us",
".",
"isArray",
"(",
"str_refs",
"[",
"entity",
"]",
")",
")",
"{",
"var",
"match_proxy_ids",
"=",
"str_refs",
"[",
"entity",
"]",
";",
"us",
".",
"each",
"(",
"match_proxy_ids",
",",
"function",
"(",
"match_proxy_id",
")",
"{",
"var",
"doc",
"=",
"doc_lookup",
"[",
"match_proxy_id",
"]",
";",
"if",
"(",
"doc",
")",
"{",
"us",
".",
"each",
"(",
"bioentity_search_fields",
",",
"function",
"(",
"search_field",
")",
"{",
"var",
"vals",
"=",
"doc",
"[",
"search_field",
"]",
";",
"if",
"(",
"vals",
"&&",
"!",
"us",
".",
"isArray",
"(",
"vals",
")",
")",
"{",
"vals",
"=",
"[",
"vals",
"]",
";",
"}",
"us",
".",
"each",
"(",
"vals",
",",
"function",
"(",
"val",
")",
"{",
"if",
"(",
"entity",
"===",
"val",
")",
"{",
"entity_hits",
".",
"push",
"(",
"{",
"\"id\"",
":",
"match_proxy_id",
",",
"\"matched\"",
":",
"search_field",
"}",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"}",
"var",
"rtype",
"=",
"null",
";",
"if",
"(",
"entity_hits",
".",
"length",
"===",
"1",
")",
"{",
"rtype",
"=",
"\"good\"",
";",
"}",
"else",
"if",
"(",
"entity_hits",
".",
"length",
"===",
"0",
")",
"{",
"rtype",
"=",
"\"bad\"",
";",
"}",
"else",
"{",
"rtype",
"=",
"\"ugly\"",
";",
"}",
"results",
"[",
"rtype",
"]",
".",
"push",
"(",
"{",
"\"input\"",
":",
"entity",
",",
"\"results\"",
":",
"entity_hits",
"}",
")",
";",
"}",
")",
";",
"return",
"results",
";",
"}"
] |
First, let us discuss what will happen when we have a populated cache to work with, one way or another. The cache is
|
[
"First",
"let",
"us",
"discuss",
"what",
"will",
"happen",
"when",
"we",
"have",
"a",
"populated",
"cache",
"to",
"work",
"with",
"one",
"way",
"or",
"another",
".",
"The",
"cache",
"is"
] |
c12209eff40abf15ad612525633ce7c2a625dfa9
|
https://github.com/geneontology/amigo/blob/c12209eff40abf15ad612525633ce7c2a625dfa9/bin/amigo.js#L1116-L1199
|
train
|
|
gmac/sass-thematic
|
lib/thematic.js
|
function(open, close) {
this.fieldOpen = (typeof open === 'string' && open.length) ? open : '____';
this.fieldClose = (typeof close === 'string' && close.length) ? close : this.fieldOpen;
var fieldPattern = this.fieldOpen +'(.+?)'+ this.fieldClose;
this.fieldRegex = new RegExp(fieldPattern);
this.fieldRegexAll = new RegExp(fieldPattern, 'g');
}
|
javascript
|
function(open, close) {
this.fieldOpen = (typeof open === 'string' && open.length) ? open : '____';
this.fieldClose = (typeof close === 'string' && close.length) ? close : this.fieldOpen;
var fieldPattern = this.fieldOpen +'(.+?)'+ this.fieldClose;
this.fieldRegex = new RegExp(fieldPattern);
this.fieldRegexAll = new RegExp(fieldPattern, 'g');
}
|
[
"function",
"(",
"open",
",",
"close",
")",
"{",
"this",
".",
"fieldOpen",
"=",
"(",
"typeof",
"open",
"===",
"'string'",
"&&",
"open",
".",
"length",
")",
"?",
"open",
":",
"'",
"_'",
";",
"this",
".",
"fieldClose",
"=",
"(",
"typeof",
"close",
"===",
"'string'",
"&&",
"close",
".",
"length",
")",
"?",
"close",
":",
"this",
".",
"fieldOpen",
";",
"var",
"fieldPattern",
"=",
"this",
".",
"fieldOpen",
"+",
"'(.+?)'",
"+",
"this",
".",
"fieldClose",
";",
"this",
".",
"fieldRegex",
"=",
"new",
"RegExp",
"(",
"fieldPattern",
")",
";",
"this",
".",
"fieldRegexAll",
"=",
"new",
"RegExp",
"(",
"fieldPattern",
",",
"'g'",
")",
";",
"}"
] |
Configures the patterns used as template field literals.
@param {String} open token denoting start of field identifier.
@param {String} close token denoting end of field identifier.
|
[
"Configures",
"the",
"patterns",
"used",
"as",
"template",
"field",
"literals",
"."
] |
a887c15b98ec2c45452340a9bc26c5321add034a
|
https://github.com/gmac/sass-thematic/blob/a887c15b98ec2c45452340a9bc26c5321add034a/lib/thematic.js#L131-L138
|
train
|
|
gmac/sass-thematic
|
lib/thematic.js
|
function(varsData) {
if (isJSON(varsData)) {
// JSON variables
varsData = JSON.parse(varsData);
for (var key in varsData) {
if (varsData.hasOwnProperty(key)) {
this.vars[normalizeVarName(key)] = varsData[key];
}
}
}
else {
// Sass variables
var pattern = /\$([^\s:]+)\s*:\s*([^!;]+)/g;
var match = pattern.exec(varsData);
while (match) {
this.vars[ match[1] ] = match[2].trim();
match = pattern.exec(varsData);
}
}
}
|
javascript
|
function(varsData) {
if (isJSON(varsData)) {
// JSON variables
varsData = JSON.parse(varsData);
for (var key in varsData) {
if (varsData.hasOwnProperty(key)) {
this.vars[normalizeVarName(key)] = varsData[key];
}
}
}
else {
// Sass variables
var pattern = /\$([^\s:]+)\s*:\s*([^!;]+)/g;
var match = pattern.exec(varsData);
while (match) {
this.vars[ match[1] ] = match[2].trim();
match = pattern.exec(varsData);
}
}
}
|
[
"function",
"(",
"varsData",
")",
"{",
"if",
"(",
"isJSON",
"(",
"varsData",
")",
")",
"{",
"varsData",
"=",
"JSON",
".",
"parse",
"(",
"varsData",
")",
";",
"for",
"(",
"var",
"key",
"in",
"varsData",
")",
"{",
"if",
"(",
"varsData",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"this",
".",
"vars",
"[",
"normalizeVarName",
"(",
"key",
")",
"]",
"=",
"varsData",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"var",
"pattern",
"=",
"/",
"\\$([^\\s:]+)\\s*:\\s*([^!;]+)",
"/",
"g",
";",
"var",
"match",
"=",
"pattern",
".",
"exec",
"(",
"varsData",
")",
";",
"while",
"(",
"match",
")",
"{",
"this",
".",
"vars",
"[",
"match",
"[",
"1",
"]",
"]",
"=",
"match",
"[",
"2",
"]",
".",
"trim",
"(",
")",
";",
"match",
"=",
"pattern",
".",
"exec",
"(",
"varsData",
")",
";",
"}",
"}",
"}"
] |
Parses raw Sass variable definitions
into the thematic mapping of vars names to values.
|
[
"Parses",
"raw",
"Sass",
"variable",
"definitions",
"into",
"the",
"thematic",
"mapping",
"of",
"vars",
"names",
"to",
"values",
"."
] |
a887c15b98ec2c45452340a9bc26c5321add034a
|
https://github.com/gmac/sass-thematic/blob/a887c15b98ec2c45452340a9bc26c5321add034a/lib/thematic.js#L144-L165
|
train
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.