id
int32 0
58k
| 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
|
---|---|---|---|---|---|---|---|---|---|---|---|
47,400 | saggiyogesh/nodeportal | public/ckeditor/_source/core/htmlparser.js | function( html )
{
var parts,
tagName,
nextIndex = 0,
cdata; // The collected data inside a CDATA section.
while ( ( parts = this._.htmlPartsRegex.exec( html ) ) )
{
var tagIndex = parts.index;
if ( tagIndex > nextIndex )
{
var text = html.substring( nextIndex, tagIndex );
if ( cdata )
cdata.push( text );
else
this.onText( text );
}
nextIndex = this._.htmlPartsRegex.lastIndex;
/*
"parts" is an array with the following items:
0 : The entire match for opening/closing tags and comments.
1 : Group filled with the tag name for closing tags.
2 : Group filled with the comment text.
3 : Group filled with the tag name for opening tags.
4 : Group filled with the attributes part of opening tags.
*/
// Closing tag
if ( ( tagName = parts[ 1 ] ) )
{
tagName = tagName.toLowerCase();
if ( cdata && CKEDITOR.dtd.$cdata[ tagName ] )
{
// Send the CDATA data.
this.onCDATA( cdata.join('') );
cdata = null;
}
if ( !cdata )
{
this.onTagClose( tagName );
continue;
}
}
// If CDATA is enabled, just save the raw match.
if ( cdata )
{
cdata.push( parts[ 0 ] );
continue;
}
// Opening tag
if ( ( tagName = parts[ 3 ] ) )
{
tagName = tagName.toLowerCase();
// There are some tag names that can break things, so let's
// simply ignore them when parsing. (#5224)
if ( /="/.test( tagName ) )
continue;
var attribs = {},
attribMatch,
attribsPart = parts[ 4 ],
selfClosing = !!( attribsPart && attribsPart.charAt( attribsPart.length - 1 ) == '/' );
if ( attribsPart )
{
while ( ( attribMatch = attribsRegex.exec( attribsPart ) ) )
{
var attName = attribMatch[1].toLowerCase(),
attValue = attribMatch[2] || attribMatch[3] || attribMatch[4] || '';
if ( !attValue && emptyAttribs[ attName ] )
attribs[ attName ] = attName;
else
attribs[ attName ] = attValue;
}
}
this.onTagOpen( tagName, attribs, selfClosing );
// Open CDATA mode when finding the appropriate tags.
if ( !cdata && CKEDITOR.dtd.$cdata[ tagName ] )
cdata = [];
continue;
}
// Comment
if ( ( tagName = parts[ 2 ] ) )
this.onComment( tagName );
}
if ( html.length > nextIndex )
this.onText( html.substring( nextIndex, html.length ) );
} | javascript | function( html )
{
var parts,
tagName,
nextIndex = 0,
cdata; // The collected data inside a CDATA section.
while ( ( parts = this._.htmlPartsRegex.exec( html ) ) )
{
var tagIndex = parts.index;
if ( tagIndex > nextIndex )
{
var text = html.substring( nextIndex, tagIndex );
if ( cdata )
cdata.push( text );
else
this.onText( text );
}
nextIndex = this._.htmlPartsRegex.lastIndex;
/*
"parts" is an array with the following items:
0 : The entire match for opening/closing tags and comments.
1 : Group filled with the tag name for closing tags.
2 : Group filled with the comment text.
3 : Group filled with the tag name for opening tags.
4 : Group filled with the attributes part of opening tags.
*/
// Closing tag
if ( ( tagName = parts[ 1 ] ) )
{
tagName = tagName.toLowerCase();
if ( cdata && CKEDITOR.dtd.$cdata[ tagName ] )
{
// Send the CDATA data.
this.onCDATA( cdata.join('') );
cdata = null;
}
if ( !cdata )
{
this.onTagClose( tagName );
continue;
}
}
// If CDATA is enabled, just save the raw match.
if ( cdata )
{
cdata.push( parts[ 0 ] );
continue;
}
// Opening tag
if ( ( tagName = parts[ 3 ] ) )
{
tagName = tagName.toLowerCase();
// There are some tag names that can break things, so let's
// simply ignore them when parsing. (#5224)
if ( /="/.test( tagName ) )
continue;
var attribs = {},
attribMatch,
attribsPart = parts[ 4 ],
selfClosing = !!( attribsPart && attribsPart.charAt( attribsPart.length - 1 ) == '/' );
if ( attribsPart )
{
while ( ( attribMatch = attribsRegex.exec( attribsPart ) ) )
{
var attName = attribMatch[1].toLowerCase(),
attValue = attribMatch[2] || attribMatch[3] || attribMatch[4] || '';
if ( !attValue && emptyAttribs[ attName ] )
attribs[ attName ] = attName;
else
attribs[ attName ] = attValue;
}
}
this.onTagOpen( tagName, attribs, selfClosing );
// Open CDATA mode when finding the appropriate tags.
if ( !cdata && CKEDITOR.dtd.$cdata[ tagName ] )
cdata = [];
continue;
}
// Comment
if ( ( tagName = parts[ 2 ] ) )
this.onComment( tagName );
}
if ( html.length > nextIndex )
this.onText( html.substring( nextIndex, html.length ) );
} | [
"function",
"(",
"html",
")",
"{",
"var",
"parts",
",",
"tagName",
",",
"nextIndex",
"=",
"0",
",",
"cdata",
";",
"// The collected data inside a CDATA section.\r",
"while",
"(",
"(",
"parts",
"=",
"this",
".",
"_",
".",
"htmlPartsRegex",
".",
"exec",
"(",
"html",
")",
")",
")",
"{",
"var",
"tagIndex",
"=",
"parts",
".",
"index",
";",
"if",
"(",
"tagIndex",
">",
"nextIndex",
")",
"{",
"var",
"text",
"=",
"html",
".",
"substring",
"(",
"nextIndex",
",",
"tagIndex",
")",
";",
"if",
"(",
"cdata",
")",
"cdata",
".",
"push",
"(",
"text",
")",
";",
"else",
"this",
".",
"onText",
"(",
"text",
")",
";",
"}",
"nextIndex",
"=",
"this",
".",
"_",
".",
"htmlPartsRegex",
".",
"lastIndex",
";",
"/*\r\n\t\t\t\t \"parts\" is an array with the following items:\r\n\t\t\t\t\t0 : The entire match for opening/closing tags and comments.\r\n\t\t\t\t\t1 : Group filled with the tag name for closing tags.\r\n\t\t\t\t\t2 : Group filled with the comment text.\r\n\t\t\t\t\t3 : Group filled with the tag name for opening tags.\r\n\t\t\t\t\t4 : Group filled with the attributes part of opening tags.\r\n\t\t\t\t */",
"// Closing tag\r",
"if",
"(",
"(",
"tagName",
"=",
"parts",
"[",
"1",
"]",
")",
")",
"{",
"tagName",
"=",
"tagName",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"cdata",
"&&",
"CKEDITOR",
".",
"dtd",
".",
"$cdata",
"[",
"tagName",
"]",
")",
"{",
"// Send the CDATA data.\r",
"this",
".",
"onCDATA",
"(",
"cdata",
".",
"join",
"(",
"''",
")",
")",
";",
"cdata",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"cdata",
")",
"{",
"this",
".",
"onTagClose",
"(",
"tagName",
")",
";",
"continue",
";",
"}",
"}",
"// If CDATA is enabled, just save the raw match.\r",
"if",
"(",
"cdata",
")",
"{",
"cdata",
".",
"push",
"(",
"parts",
"[",
"0",
"]",
")",
";",
"continue",
";",
"}",
"// Opening tag\r",
"if",
"(",
"(",
"tagName",
"=",
"parts",
"[",
"3",
"]",
")",
")",
"{",
"tagName",
"=",
"tagName",
".",
"toLowerCase",
"(",
")",
";",
"// There are some tag names that can break things, so let's\r",
"// simply ignore them when parsing. (#5224)\r",
"if",
"(",
"/",
"=\"",
"/",
".",
"test",
"(",
"tagName",
")",
")",
"continue",
";",
"var",
"attribs",
"=",
"{",
"}",
",",
"attribMatch",
",",
"attribsPart",
"=",
"parts",
"[",
"4",
"]",
",",
"selfClosing",
"=",
"!",
"!",
"(",
"attribsPart",
"&&",
"attribsPart",
".",
"charAt",
"(",
"attribsPart",
".",
"length",
"-",
"1",
")",
"==",
"'/'",
")",
";",
"if",
"(",
"attribsPart",
")",
"{",
"while",
"(",
"(",
"attribMatch",
"=",
"attribsRegex",
".",
"exec",
"(",
"attribsPart",
")",
")",
")",
"{",
"var",
"attName",
"=",
"attribMatch",
"[",
"1",
"]",
".",
"toLowerCase",
"(",
")",
",",
"attValue",
"=",
"attribMatch",
"[",
"2",
"]",
"||",
"attribMatch",
"[",
"3",
"]",
"||",
"attribMatch",
"[",
"4",
"]",
"||",
"''",
";",
"if",
"(",
"!",
"attValue",
"&&",
"emptyAttribs",
"[",
"attName",
"]",
")",
"attribs",
"[",
"attName",
"]",
"=",
"attName",
";",
"else",
"attribs",
"[",
"attName",
"]",
"=",
"attValue",
";",
"}",
"}",
"this",
".",
"onTagOpen",
"(",
"tagName",
",",
"attribs",
",",
"selfClosing",
")",
";",
"// Open CDATA mode when finding the appropriate tags.\r",
"if",
"(",
"!",
"cdata",
"&&",
"CKEDITOR",
".",
"dtd",
".",
"$cdata",
"[",
"tagName",
"]",
")",
"cdata",
"=",
"[",
"]",
";",
"continue",
";",
"}",
"// Comment\r",
"if",
"(",
"(",
"tagName",
"=",
"parts",
"[",
"2",
"]",
")",
")",
"this",
".",
"onComment",
"(",
"tagName",
")",
";",
"}",
"if",
"(",
"html",
".",
"length",
">",
"nextIndex",
")",
"this",
".",
"onText",
"(",
"html",
".",
"substring",
"(",
"nextIndex",
",",
"html",
".",
"length",
")",
")",
";",
"}"
]
| Parses text, looking for HTML tokens, like tag openers or closers,
or comments. This function fires the onTagOpen, onTagClose, onText
and onComment function during its execution.
@param {String} html The HTML to be parsed.
@example
var parser = new CKEDITOR.htmlParser();
// The onTagOpen, onTagClose, onText and onComment should be overriden
// at this point.
parser.parse( "<!-- Example --><b>Hello</b>" ); | [
"Parses",
"text",
"looking",
"for",
"HTML",
"tokens",
"like",
"tag",
"openers",
"or",
"closers",
"or",
"comments",
".",
"This",
"function",
"fires",
"the",
"onTagOpen",
"onTagClose",
"onText",
"and",
"onComment",
"function",
"during",
"its",
"execution",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/htmlparser.js#L120-L222 |
|
47,401 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/selection/plugin.js | function()
{
var cache = this._.cache;
if ( cache.startElement !== undefined )
return cache.startElement;
var node,
sel = this.getNative();
switch ( this.getType() )
{
case CKEDITOR.SELECTION_ELEMENT :
return this.getSelectedElement();
case CKEDITOR.SELECTION_TEXT :
var range = this.getRanges()[0];
if ( range )
{
if ( !range.collapsed )
{
range.optimize();
// Decrease the range content to exclude particial
// selected node on the start which doesn't have
// visual impact. ( #3231 )
while ( 1 )
{
var startContainer = range.startContainer,
startOffset = range.startOffset;
// Limit the fix only to non-block elements.(#3950)
if ( startOffset == ( startContainer.getChildCount ?
startContainer.getChildCount() : startContainer.getLength() )
&& !startContainer.isBlockBoundary() )
range.setStartAfter( startContainer );
else break;
}
node = range.startContainer;
if ( node.type != CKEDITOR.NODE_ELEMENT )
return node.getParent();
node = node.getChild( range.startOffset );
if ( !node || node.type != CKEDITOR.NODE_ELEMENT )
node = range.startContainer;
else
{
var child = node.getFirst();
while ( child && child.type == CKEDITOR.NODE_ELEMENT )
{
node = child;
child = child.getFirst();
}
}
}
else
{
node = range.startContainer;
if ( node.type != CKEDITOR.NODE_ELEMENT )
node = node.getParent();
}
node = node.$;
}
}
return cache.startElement = ( node ? new CKEDITOR.dom.element( node ) : null );
} | javascript | function()
{
var cache = this._.cache;
if ( cache.startElement !== undefined )
return cache.startElement;
var node,
sel = this.getNative();
switch ( this.getType() )
{
case CKEDITOR.SELECTION_ELEMENT :
return this.getSelectedElement();
case CKEDITOR.SELECTION_TEXT :
var range = this.getRanges()[0];
if ( range )
{
if ( !range.collapsed )
{
range.optimize();
// Decrease the range content to exclude particial
// selected node on the start which doesn't have
// visual impact. ( #3231 )
while ( 1 )
{
var startContainer = range.startContainer,
startOffset = range.startOffset;
// Limit the fix only to non-block elements.(#3950)
if ( startOffset == ( startContainer.getChildCount ?
startContainer.getChildCount() : startContainer.getLength() )
&& !startContainer.isBlockBoundary() )
range.setStartAfter( startContainer );
else break;
}
node = range.startContainer;
if ( node.type != CKEDITOR.NODE_ELEMENT )
return node.getParent();
node = node.getChild( range.startOffset );
if ( !node || node.type != CKEDITOR.NODE_ELEMENT )
node = range.startContainer;
else
{
var child = node.getFirst();
while ( child && child.type == CKEDITOR.NODE_ELEMENT )
{
node = child;
child = child.getFirst();
}
}
}
else
{
node = range.startContainer;
if ( node.type != CKEDITOR.NODE_ELEMENT )
node = node.getParent();
}
node = node.$;
}
}
return cache.startElement = ( node ? new CKEDITOR.dom.element( node ) : null );
} | [
"function",
"(",
")",
"{",
"var",
"cache",
"=",
"this",
".",
"_",
".",
"cache",
";",
"if",
"(",
"cache",
".",
"startElement",
"!==",
"undefined",
")",
"return",
"cache",
".",
"startElement",
";",
"var",
"node",
",",
"sel",
"=",
"this",
".",
"getNative",
"(",
")",
";",
"switch",
"(",
"this",
".",
"getType",
"(",
")",
")",
"{",
"case",
"CKEDITOR",
".",
"SELECTION_ELEMENT",
":",
"return",
"this",
".",
"getSelectedElement",
"(",
")",
";",
"case",
"CKEDITOR",
".",
"SELECTION_TEXT",
":",
"var",
"range",
"=",
"this",
".",
"getRanges",
"(",
")",
"[",
"0",
"]",
";",
"if",
"(",
"range",
")",
"{",
"if",
"(",
"!",
"range",
".",
"collapsed",
")",
"{",
"range",
".",
"optimize",
"(",
")",
";",
"// Decrease the range content to exclude particial\r",
"// selected node on the start which doesn't have\r",
"// visual impact. ( #3231 )\r",
"while",
"(",
"1",
")",
"{",
"var",
"startContainer",
"=",
"range",
".",
"startContainer",
",",
"startOffset",
"=",
"range",
".",
"startOffset",
";",
"// Limit the fix only to non-block elements.(#3950)\r",
"if",
"(",
"startOffset",
"==",
"(",
"startContainer",
".",
"getChildCount",
"?",
"startContainer",
".",
"getChildCount",
"(",
")",
":",
"startContainer",
".",
"getLength",
"(",
")",
")",
"&&",
"!",
"startContainer",
".",
"isBlockBoundary",
"(",
")",
")",
"range",
".",
"setStartAfter",
"(",
"startContainer",
")",
";",
"else",
"break",
";",
"}",
"node",
"=",
"range",
".",
"startContainer",
";",
"if",
"(",
"node",
".",
"type",
"!=",
"CKEDITOR",
".",
"NODE_ELEMENT",
")",
"return",
"node",
".",
"getParent",
"(",
")",
";",
"node",
"=",
"node",
".",
"getChild",
"(",
"range",
".",
"startOffset",
")",
";",
"if",
"(",
"!",
"node",
"||",
"node",
".",
"type",
"!=",
"CKEDITOR",
".",
"NODE_ELEMENT",
")",
"node",
"=",
"range",
".",
"startContainer",
";",
"else",
"{",
"var",
"child",
"=",
"node",
".",
"getFirst",
"(",
")",
";",
"while",
"(",
"child",
"&&",
"child",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_ELEMENT",
")",
"{",
"node",
"=",
"child",
";",
"child",
"=",
"child",
".",
"getFirst",
"(",
")",
";",
"}",
"}",
"}",
"else",
"{",
"node",
"=",
"range",
".",
"startContainer",
";",
"if",
"(",
"node",
".",
"type",
"!=",
"CKEDITOR",
".",
"NODE_ELEMENT",
")",
"node",
"=",
"node",
".",
"getParent",
"(",
")",
";",
"}",
"node",
"=",
"node",
".",
"$",
";",
"}",
"}",
"return",
"cache",
".",
"startElement",
"=",
"(",
"node",
"?",
"new",
"CKEDITOR",
".",
"dom",
".",
"element",
"(",
"node",
")",
":",
"null",
")",
";",
"}"
]
| Gets the DOM element in which the selection starts.
@returns {CKEDITOR.dom.element} The element at the beginning of the
selection.
@example
var element = editor.getSelection().<strong>getStartElement()</strong>;
alert( element.getName() ); | [
"Gets",
"the",
"DOM",
"element",
"in",
"which",
"the",
"selection",
"starts",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/selection/plugin.js#L1054-L1124 |
|
47,402 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/selection/plugin.js | function()
{
var root,
retval,
range = self.getRanges()[ 0 ],
ancestor = range.getCommonAncestor( 1, 1 ),
tags = { table:1,ul:1,ol:1,dl:1 };
for ( var t in tags )
{
if ( root = ancestor.getAscendant( t, 1 ) )
break;
}
if ( root )
{
// Enlarging the start boundary.
var testRange = new CKEDITOR.dom.range( this.document );
testRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START );
testRange.setEnd( range.startContainer, range.startOffset );
var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent ),
walker = new CKEDITOR.dom.walker( testRange ),
// Check the range is at the inner boundary of the structural element.
guard = function( walker, isEnd )
{
return function( node, isWalkOut )
{
if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) )
return true;
var tag;
if ( node.type == CKEDITOR.NODE_ELEMENT )
{
tag = node.getName();
// Bypass bogus br at the end of block.
if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) )
return true;
if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty )
return true;
}
walker.halted = 1;
return false;
};
};
walker.guard = guard( walker );
if ( walker.checkBackward() && !walker.halted )
{
walker = new CKEDITOR.dom.walker( testRange );
testRange.setStart( range.endContainer, range.endOffset );
testRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END );
walker.guard = guard( walker, 1 );
if ( walker.checkForward() && !walker.halted )
retval = root.$;
}
}
if ( !retval )
throw 0;
return retval;
} | javascript | function()
{
var root,
retval,
range = self.getRanges()[ 0 ],
ancestor = range.getCommonAncestor( 1, 1 ),
tags = { table:1,ul:1,ol:1,dl:1 };
for ( var t in tags )
{
if ( root = ancestor.getAscendant( t, 1 ) )
break;
}
if ( root )
{
// Enlarging the start boundary.
var testRange = new CKEDITOR.dom.range( this.document );
testRange.setStartAt( root, CKEDITOR.POSITION_AFTER_START );
testRange.setEnd( range.startContainer, range.startOffset );
var enlargeables = CKEDITOR.tools.extend( tags, CKEDITOR.dtd.$listItem, CKEDITOR.dtd.$tableContent ),
walker = new CKEDITOR.dom.walker( testRange ),
// Check the range is at the inner boundary of the structural element.
guard = function( walker, isEnd )
{
return function( node, isWalkOut )
{
if ( node.type == CKEDITOR.NODE_TEXT && ( !CKEDITOR.tools.trim( node.getText() ) || node.getParent().data( 'cke-bookmark' ) ) )
return true;
var tag;
if ( node.type == CKEDITOR.NODE_ELEMENT )
{
tag = node.getName();
// Bypass bogus br at the end of block.
if ( tag == 'br' && isEnd && node.equals( node.getParent().getBogus() ) )
return true;
if ( isWalkOut && tag in enlargeables || tag in CKEDITOR.dtd.$removeEmpty )
return true;
}
walker.halted = 1;
return false;
};
};
walker.guard = guard( walker );
if ( walker.checkBackward() && !walker.halted )
{
walker = new CKEDITOR.dom.walker( testRange );
testRange.setStart( range.endContainer, range.endOffset );
testRange.setEndAt( root, CKEDITOR.POSITION_BEFORE_END );
walker.guard = guard( walker, 1 );
if ( walker.checkForward() && !walker.halted )
retval = root.$;
}
}
if ( !retval )
throw 0;
return retval;
} | [
"function",
"(",
")",
"{",
"var",
"root",
",",
"retval",
",",
"range",
"=",
"self",
".",
"getRanges",
"(",
")",
"[",
"0",
"]",
",",
"ancestor",
"=",
"range",
".",
"getCommonAncestor",
"(",
"1",
",",
"1",
")",
",",
"tags",
"=",
"{",
"table",
":",
"1",
",",
"ul",
":",
"1",
",",
"ol",
":",
"1",
",",
"dl",
":",
"1",
"}",
";",
"for",
"(",
"var",
"t",
"in",
"tags",
")",
"{",
"if",
"(",
"root",
"=",
"ancestor",
".",
"getAscendant",
"(",
"t",
",",
"1",
")",
")",
"break",
";",
"}",
"if",
"(",
"root",
")",
"{",
"// Enlarging the start boundary.\r",
"var",
"testRange",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"range",
"(",
"this",
".",
"document",
")",
";",
"testRange",
".",
"setStartAt",
"(",
"root",
",",
"CKEDITOR",
".",
"POSITION_AFTER_START",
")",
";",
"testRange",
".",
"setEnd",
"(",
"range",
".",
"startContainer",
",",
"range",
".",
"startOffset",
")",
";",
"var",
"enlargeables",
"=",
"CKEDITOR",
".",
"tools",
".",
"extend",
"(",
"tags",
",",
"CKEDITOR",
".",
"dtd",
".",
"$listItem",
",",
"CKEDITOR",
".",
"dtd",
".",
"$tableContent",
")",
",",
"walker",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"walker",
"(",
"testRange",
")",
",",
"// Check the range is at the inner boundary of the structural element.\r",
"guard",
"=",
"function",
"(",
"walker",
",",
"isEnd",
")",
"{",
"return",
"function",
"(",
"node",
",",
"isWalkOut",
")",
"{",
"if",
"(",
"node",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_TEXT",
"&&",
"(",
"!",
"CKEDITOR",
".",
"tools",
".",
"trim",
"(",
"node",
".",
"getText",
"(",
")",
")",
"||",
"node",
".",
"getParent",
"(",
")",
".",
"data",
"(",
"'cke-bookmark'",
")",
")",
")",
"return",
"true",
";",
"var",
"tag",
";",
"if",
"(",
"node",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_ELEMENT",
")",
"{",
"tag",
"=",
"node",
".",
"getName",
"(",
")",
";",
"// Bypass bogus br at the end of block.\r",
"if",
"(",
"tag",
"==",
"'br'",
"&&",
"isEnd",
"&&",
"node",
".",
"equals",
"(",
"node",
".",
"getParent",
"(",
")",
".",
"getBogus",
"(",
")",
")",
")",
"return",
"true",
";",
"if",
"(",
"isWalkOut",
"&&",
"tag",
"in",
"enlargeables",
"||",
"tag",
"in",
"CKEDITOR",
".",
"dtd",
".",
"$removeEmpty",
")",
"return",
"true",
";",
"}",
"walker",
".",
"halted",
"=",
"1",
";",
"return",
"false",
";",
"}",
";",
"}",
";",
"walker",
".",
"guard",
"=",
"guard",
"(",
"walker",
")",
";",
"if",
"(",
"walker",
".",
"checkBackward",
"(",
")",
"&&",
"!",
"walker",
".",
"halted",
")",
"{",
"walker",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"walker",
"(",
"testRange",
")",
";",
"testRange",
".",
"setStart",
"(",
"range",
".",
"endContainer",
",",
"range",
".",
"endOffset",
")",
";",
"testRange",
".",
"setEndAt",
"(",
"root",
",",
"CKEDITOR",
".",
"POSITION_BEFORE_END",
")",
";",
"walker",
".",
"guard",
"=",
"guard",
"(",
"walker",
",",
"1",
")",
";",
"if",
"(",
"walker",
".",
"checkForward",
"(",
")",
"&&",
"!",
"walker",
".",
"halted",
")",
"retval",
"=",
"root",
".",
"$",
";",
"}",
"}",
"if",
"(",
"!",
"retval",
")",
"throw",
"0",
";",
"return",
"retval",
";",
"}"
]
| If a table or list is fully selected. | [
"If",
"a",
"table",
"or",
"list",
"is",
"fully",
"selected",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/selection/plugin.js#L1150-L1216 |
|
47,403 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/selection/plugin.js | function()
{
var ranges = this.getRanges(),
startNode = ranges[ 0 ].startContainer,
endNode = ranges[ ranges.length - 1 ].endContainer;
return startNode.getCommonAncestor( endNode );
} | javascript | function()
{
var ranges = this.getRanges(),
startNode = ranges[ 0 ].startContainer,
endNode = ranges[ ranges.length - 1 ].endContainer;
return startNode.getCommonAncestor( endNode );
} | [
"function",
"(",
")",
"{",
"var",
"ranges",
"=",
"this",
".",
"getRanges",
"(",
")",
",",
"startNode",
"=",
"ranges",
"[",
"0",
"]",
".",
"startContainer",
",",
"endNode",
"=",
"ranges",
"[",
"ranges",
".",
"length",
"-",
"1",
"]",
".",
"endContainer",
";",
"return",
"startNode",
".",
"getCommonAncestor",
"(",
"endNode",
")",
";",
"}"
]
| Retrieves the common ancestor node of the first range and the last range.
@returns {CKEDITOR.dom.element} The common ancestor of the selection.
@example
var ancestor = editor.getSelection().<strong>getCommonAncestor()</strong>; | [
"Retrieves",
"the",
"common",
"ancestor",
"node",
"of",
"the",
"first",
"range",
"and",
"the",
"last",
"range",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/selection/plugin.js#L1577-L1583 |
|
47,404 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/entities/plugin.js | buildTable | function buildTable( entities, reverse )
{
var table = {},
regex = [];
// Entities that the browsers DOM don't transform to the final char
// automatically.
var specialTable =
{
nbsp : '\u00A0', // IE | FF
shy : '\u00AD', // IE
gt : '\u003E', // IE | FF | -- | Opera
lt : '\u003C', // IE | FF | Safari | Opera
amp : '\u0026' // ALL
};
entities = entities.replace( /\b(nbsp|shy|gt|lt|amp)(?:,|$)/g, function( match, entity )
{
var org = reverse ? '&' + entity + ';' : specialTable[ entity ],
result = reverse ? specialTable[ entity ] : '&' + entity + ';';
table[ org ] = result;
regex.push( org );
return '';
});
if ( !reverse && entities )
{
// Transforms the entities string into an array.
entities = entities.split( ',' );
// Put all entities inside a DOM element, transforming them to their
// final chars.
var div = document.createElement( 'div' ),
chars;
div.innerHTML = '&' + entities.join( ';&' ) + ';';
chars = div.innerHTML;
div = null;
// Add all chars to the table.
for ( var i = 0 ; i < chars.length ; i++ )
{
var charAt = chars.charAt( i );
table[ charAt ] = '&' + entities[ i ] + ';';
regex.push( charAt );
}
}
table.regex = regex.join( reverse ? '|' : '' );
return table;
} | javascript | function buildTable( entities, reverse )
{
var table = {},
regex = [];
// Entities that the browsers DOM don't transform to the final char
// automatically.
var specialTable =
{
nbsp : '\u00A0', // IE | FF
shy : '\u00AD', // IE
gt : '\u003E', // IE | FF | -- | Opera
lt : '\u003C', // IE | FF | Safari | Opera
amp : '\u0026' // ALL
};
entities = entities.replace( /\b(nbsp|shy|gt|lt|amp)(?:,|$)/g, function( match, entity )
{
var org = reverse ? '&' + entity + ';' : specialTable[ entity ],
result = reverse ? specialTable[ entity ] : '&' + entity + ';';
table[ org ] = result;
regex.push( org );
return '';
});
if ( !reverse && entities )
{
// Transforms the entities string into an array.
entities = entities.split( ',' );
// Put all entities inside a DOM element, transforming them to their
// final chars.
var div = document.createElement( 'div' ),
chars;
div.innerHTML = '&' + entities.join( ';&' ) + ';';
chars = div.innerHTML;
div = null;
// Add all chars to the table.
for ( var i = 0 ; i < chars.length ; i++ )
{
var charAt = chars.charAt( i );
table[ charAt ] = '&' + entities[ i ] + ';';
regex.push( charAt );
}
}
table.regex = regex.join( reverse ? '|' : '' );
return table;
} | [
"function",
"buildTable",
"(",
"entities",
",",
"reverse",
")",
"{",
"var",
"table",
"=",
"{",
"}",
",",
"regex",
"=",
"[",
"]",
";",
"// Entities that the browsers DOM don't transform to the final char\r",
"// automatically.\r",
"var",
"specialTable",
"=",
"{",
"nbsp",
":",
"'\\u00A0'",
",",
"// IE | FF\r",
"shy",
":",
"'\\u00AD'",
",",
"// IE\r",
"gt",
":",
"'\\u003E'",
",",
"// IE | FF | -- | Opera\r",
"lt",
":",
"'\\u003C'",
",",
"// IE | FF | Safari | Opera\r",
"amp",
":",
"'\\u0026'",
"// ALL\r",
"}",
";",
"entities",
"=",
"entities",
".",
"replace",
"(",
"/",
"\\b(nbsp|shy|gt|lt|amp)(?:,|$)",
"/",
"g",
",",
"function",
"(",
"match",
",",
"entity",
")",
"{",
"var",
"org",
"=",
"reverse",
"?",
"'&'",
"+",
"entity",
"+",
"';'",
":",
"specialTable",
"[",
"entity",
"]",
",",
"result",
"=",
"reverse",
"?",
"specialTable",
"[",
"entity",
"]",
":",
"'&'",
"+",
"entity",
"+",
"';'",
";",
"table",
"[",
"org",
"]",
"=",
"result",
";",
"regex",
".",
"push",
"(",
"org",
")",
";",
"return",
"''",
";",
"}",
")",
";",
"if",
"(",
"!",
"reverse",
"&&",
"entities",
")",
"{",
"// Transforms the entities string into an array.\r",
"entities",
"=",
"entities",
".",
"split",
"(",
"','",
")",
";",
"// Put all entities inside a DOM element, transforming them to their\r",
"// final chars.\r",
"var",
"div",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
",",
"chars",
";",
"div",
".",
"innerHTML",
"=",
"'&'",
"+",
"entities",
".",
"join",
"(",
"';&'",
")",
"+",
"';'",
";",
"chars",
"=",
"div",
".",
"innerHTML",
";",
"div",
"=",
"null",
";",
"// Add all chars to the table.\r",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"chars",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"charAt",
"=",
"chars",
".",
"charAt",
"(",
"i",
")",
";",
"table",
"[",
"charAt",
"]",
"=",
"'&'",
"+",
"entities",
"[",
"i",
"]",
"+",
"';'",
";",
"regex",
".",
"push",
"(",
"charAt",
")",
";",
"}",
"}",
"table",
".",
"regex",
"=",
"regex",
".",
"join",
"(",
"reverse",
"?",
"'|'",
":",
"''",
")",
";",
"return",
"table",
";",
"}"
]
| Create a mapping table between one character and its entity form from a list of entity names.
@param reverse {Boolean} Whether to create a reverse map from the entity string form to an actual character. | [
"Create",
"a",
"mapping",
"table",
"between",
"one",
"character",
"and",
"its",
"entity",
"form",
"from",
"a",
"list",
"of",
"entity",
"names",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/entities/plugin.js#L52-L103 |
47,405 | philmander/inverted | lib/inverted.js | function(config) {
this.config = config;
this.appContext = null;
this.injectAppContext = this.config.injectAppContext === true ? true : false;
//cache of loaded dependencies
this.moduleMap = {};
} | javascript | function(config) {
this.config = config;
this.appContext = null;
this.injectAppContext = this.config.injectAppContext === true ? true : false;
//cache of loaded dependencies
this.moduleMap = {};
} | [
"function",
"(",
"config",
")",
"{",
"this",
".",
"config",
"=",
"config",
";",
"this",
".",
"appContext",
"=",
"null",
";",
"this",
".",
"injectAppContext",
"=",
"this",
".",
"config",
".",
"injectAppContext",
"===",
"true",
"?",
"true",
":",
"false",
";",
"//cache of loaded dependencies",
"this",
".",
"moduleMap",
"=",
"{",
"}",
";",
"}"
]
| Create a new ProtoFactory with config
@constructor
@param {Object} config | [
"Create",
"a",
"new",
"ProtoFactory",
"with",
"config"
]
| af49a1ab2f501a19c457a8b41a40306e12103bf4 | https://github.com/philmander/inverted/blob/af49a1ab2f501a19c457a8b41a40306e12103bf4/lib/inverted.js#L282-L291 |
|
47,406 | philmander/inverted | lib/inverted.js | function(config, protoFactory, originalModule) {
this.config = config;
this.protoFactory = protoFactory;
this.originalModule = originalModule || module;
//defines if circular dependencies should throw an error or be gracefully handled
this.allowCircular = this.config.allowCircular || false;
this.modules = [];
if(define.amd && typeof requirejs !== "undefined") {
this._loader = require;
} else if(define.amd && typeof curl !== "undefined") {
this._loader = curl;
} else {
this._loader = this._commonRequire;
}
} | javascript | function(config, protoFactory, originalModule) {
this.config = config;
this.protoFactory = protoFactory;
this.originalModule = originalModule || module;
//defines if circular dependencies should throw an error or be gracefully handled
this.allowCircular = this.config.allowCircular || false;
this.modules = [];
if(define.amd && typeof requirejs !== "undefined") {
this._loader = require;
} else if(define.amd && typeof curl !== "undefined") {
this._loader = curl;
} else {
this._loader = this._commonRequire;
}
} | [
"function",
"(",
"config",
",",
"protoFactory",
",",
"originalModule",
")",
"{",
"this",
".",
"config",
"=",
"config",
";",
"this",
".",
"protoFactory",
"=",
"protoFactory",
";",
"this",
".",
"originalModule",
"=",
"originalModule",
"||",
"module",
";",
"//defines if circular dependencies should throw an error or be gracefully handled",
"this",
".",
"allowCircular",
"=",
"this",
".",
"config",
".",
"allowCircular",
"||",
"false",
";",
"this",
".",
"modules",
"=",
"[",
"]",
";",
"if",
"(",
"define",
".",
"amd",
"&&",
"typeof",
"requirejs",
"!==",
"\"undefined\"",
")",
"{",
"this",
".",
"_loader",
"=",
"require",
";",
"}",
"else",
"if",
"(",
"define",
".",
"amd",
"&&",
"typeof",
"curl",
"!==",
"\"undefined\"",
")",
"{",
"this",
".",
"_loader",
"=",
"curl",
";",
"}",
"else",
"{",
"this",
".",
"_loader",
"=",
"this",
".",
"_commonRequire",
";",
"}",
"}"
]
| Create a new AppContext with config
@constructor
@param {Object} config
@param {Object} protoFactory
@param {Object} originalModule The original node module use to load node modules on the right path | [
"Create",
"a",
"new",
"AppContext",
"with",
"config"
]
| af49a1ab2f501a19c457a8b41a40306e12103bf4 | https://github.com/philmander/inverted/blob/af49a1ab2f501a19c457a8b41a40306e12103bf4/lib/inverted.js#L695-L712 |
|
47,407 | slideme/rorschach | lib/ConnectionState.js | ConnectionState | function ConnectionState(code, stringId, connected) {
if (arguments.length === 2) {
connected = stringId;
stringId = 'NONAME';
}
if (!(this instanceof ConnectionState)) {
return new ConnectionState(code, stringId, connected);
}
this.id = stringId;
this.code = code;
this.connected = connected;
} | javascript | function ConnectionState(code, stringId, connected) {
if (arguments.length === 2) {
connected = stringId;
stringId = 'NONAME';
}
if (!(this instanceof ConnectionState)) {
return new ConnectionState(code, stringId, connected);
}
this.id = stringId;
this.code = code;
this.connected = connected;
} | [
"function",
"ConnectionState",
"(",
"code",
",",
"stringId",
",",
"connected",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"2",
")",
"{",
"connected",
"=",
"stringId",
";",
"stringId",
"=",
"'NONAME'",
";",
"}",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ConnectionState",
")",
")",
"{",
"return",
"new",
"ConnectionState",
"(",
"code",
",",
"stringId",
",",
"connected",
")",
";",
"}",
"this",
".",
"id",
"=",
"stringId",
";",
"this",
".",
"code",
"=",
"code",
";",
"this",
".",
"connected",
"=",
"connected",
";",
"}"
]
| Connection state.
@constructor
@param {Number} code
@param {String} stringId
@param {Boolean} connected | [
"Connection",
"state",
"."
]
| 899339baf31682f8a62b2960cdd26fbb58a9e3a1 | https://github.com/slideme/rorschach/blob/899339baf31682f8a62b2960cdd26fbb58a9e3a1/lib/ConnectionState.js#L12-L24 |
47,408 | saggiyogesh/nodeportal | public/ckeditor/_source/core/htmlparser/element.js | function( obj )
{
var style = this.toString();
if ( style )
{
obj instanceof CKEDITOR.dom.element ?
obj.setAttribute( 'style', style ) :
obj instanceof CKEDITOR.htmlParser.element ?
obj.attributes.style = style :
obj.style = style;
}
} | javascript | function( obj )
{
var style = this.toString();
if ( style )
{
obj instanceof CKEDITOR.dom.element ?
obj.setAttribute( 'style', style ) :
obj instanceof CKEDITOR.htmlParser.element ?
obj.attributes.style = style :
obj.style = style;
}
} | [
"function",
"(",
"obj",
")",
"{",
"var",
"style",
"=",
"this",
".",
"toString",
"(",
")",
";",
"if",
"(",
"style",
")",
"{",
"obj",
"instanceof",
"CKEDITOR",
".",
"dom",
".",
"element",
"?",
"obj",
".",
"setAttribute",
"(",
"'style'",
",",
"style",
")",
":",
"obj",
"instanceof",
"CKEDITOR",
".",
"htmlParser",
".",
"element",
"?",
"obj",
".",
"attributes",
".",
"style",
"=",
"style",
":",
"obj",
".",
"style",
"=",
"style",
";",
"}",
"}"
]
| Apply the styles onto the specified element or object.
@param {CKEDITOR.htmlParser.element|CKEDITOR.dom.element|Object} obj | [
"Apply",
"the",
"styles",
"onto",
"the",
"specified",
"element",
"or",
"object",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/htmlparser/element.js#L95-L106 |
|
47,409 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/clipboard/plugin.js | function( event )
{
if ( this.mode != 'wysiwyg' )
return;
switch ( event.data.keyCode )
{
// Paste
case CKEDITOR.CTRL + 86 : // CTRL+V
case CKEDITOR.SHIFT + 45 : // SHIFT+INS
var body = this.document.getBody();
// Simulate 'beforepaste' event for all none-IEs.
if ( !CKEDITOR.env.ie && body.fire( 'beforepaste' ) )
event.cancel();
// Simulate 'paste' event for Opera/Firefox2.
else if ( CKEDITOR.env.opera
|| CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 )
body.fire( 'paste' );
return;
// Cut
case CKEDITOR.CTRL + 88 : // CTRL+X
case CKEDITOR.SHIFT + 46 : // SHIFT+DEL
// Save Undo snapshot.
var editor = this;
this.fire( 'saveSnapshot' ); // Save before paste
setTimeout( function()
{
editor.fire( 'saveSnapshot' ); // Save after paste
}, 0 );
}
} | javascript | function( event )
{
if ( this.mode != 'wysiwyg' )
return;
switch ( event.data.keyCode )
{
// Paste
case CKEDITOR.CTRL + 86 : // CTRL+V
case CKEDITOR.SHIFT + 45 : // SHIFT+INS
var body = this.document.getBody();
// Simulate 'beforepaste' event for all none-IEs.
if ( !CKEDITOR.env.ie && body.fire( 'beforepaste' ) )
event.cancel();
// Simulate 'paste' event for Opera/Firefox2.
else if ( CKEDITOR.env.opera
|| CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 )
body.fire( 'paste' );
return;
// Cut
case CKEDITOR.CTRL + 88 : // CTRL+X
case CKEDITOR.SHIFT + 46 : // SHIFT+DEL
// Save Undo snapshot.
var editor = this;
this.fire( 'saveSnapshot' ); // Save before paste
setTimeout( function()
{
editor.fire( 'saveSnapshot' ); // Save after paste
}, 0 );
}
} | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"this",
".",
"mode",
"!=",
"'wysiwyg'",
")",
"return",
";",
"switch",
"(",
"event",
".",
"data",
".",
"keyCode",
")",
"{",
"// Paste\r",
"case",
"CKEDITOR",
".",
"CTRL",
"+",
"86",
":",
"// CTRL+V\r",
"case",
"CKEDITOR",
".",
"SHIFT",
"+",
"45",
":",
"// SHIFT+INS\r",
"var",
"body",
"=",
"this",
".",
"document",
".",
"getBody",
"(",
")",
";",
"// Simulate 'beforepaste' event for all none-IEs.\r",
"if",
"(",
"!",
"CKEDITOR",
".",
"env",
".",
"ie",
"&&",
"body",
".",
"fire",
"(",
"'beforepaste'",
")",
")",
"event",
".",
"cancel",
"(",
")",
";",
"// Simulate 'paste' event for Opera/Firefox2.\r",
"else",
"if",
"(",
"CKEDITOR",
".",
"env",
".",
"opera",
"||",
"CKEDITOR",
".",
"env",
".",
"gecko",
"&&",
"CKEDITOR",
".",
"env",
".",
"version",
"<",
"10900",
")",
"body",
".",
"fire",
"(",
"'paste'",
")",
";",
"return",
";",
"// Cut\r",
"case",
"CKEDITOR",
".",
"CTRL",
"+",
"88",
":",
"// CTRL+X\r",
"case",
"CKEDITOR",
".",
"SHIFT",
"+",
"46",
":",
"// SHIFT+DEL\r",
"// Save Undo snapshot.\r",
"var",
"editor",
"=",
"this",
";",
"this",
".",
"fire",
"(",
"'saveSnapshot'",
")",
";",
"// Save before paste\r",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"editor",
".",
"fire",
"(",
"'saveSnapshot'",
")",
";",
"// Save after paste\r",
"}",
",",
"0",
")",
";",
"}",
"}"
]
| Listens for some clipboard related keystrokes, so they get customized. | [
"Listens",
"for",
"some",
"clipboard",
"related",
"keystrokes",
"so",
"they",
"get",
"customized",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/clipboard/plugin.js#L125-L159 |
|
47,410 | hitsujiwool/node-holiday-jp | index.js | function(start, end) {
var date;
var res = [];
for (var key in holidays) {
date = beginningOfDay(new Date(key));
// given `start` and `end` Date object are both normalized to beginning of the day
if (beginningOfDay(start) <= date && date <= beginningOfDay(end)) {
res.push(holiday(date, holidays[key]));
}
}
return res;
} | javascript | function(start, end) {
var date;
var res = [];
for (var key in holidays) {
date = beginningOfDay(new Date(key));
// given `start` and `end` Date object are both normalized to beginning of the day
if (beginningOfDay(start) <= date && date <= beginningOfDay(end)) {
res.push(holiday(date, holidays[key]));
}
}
return res;
} | [
"function",
"(",
"start",
",",
"end",
")",
"{",
"var",
"date",
";",
"var",
"res",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"holidays",
")",
"{",
"date",
"=",
"beginningOfDay",
"(",
"new",
"Date",
"(",
"key",
")",
")",
";",
"// given `start` and `end` Date object are both normalized to beginning of the day",
"if",
"(",
"beginningOfDay",
"(",
"start",
")",
"<=",
"date",
"&&",
"date",
"<=",
"beginningOfDay",
"(",
"end",
")",
")",
"{",
"res",
".",
"push",
"(",
"holiday",
"(",
"date",
",",
"holidays",
"[",
"key",
"]",
")",
")",
";",
"}",
"}",
"return",
"res",
";",
"}"
]
| Find holidays between `start` and `end`.
@param {Date} start
@param {Date} end
@return {Array[Object]}
@api public | [
"Find",
"holidays",
"between",
"start",
"and",
"end",
"."
]
| d5d397ddd3a443ce0210ba05dc46a01b0668378d | https://github.com/hitsujiwool/node-holiday-jp/blob/d5d397ddd3a443ce0210ba05dc46a01b0668378d/index.js#L28-L39 |
|
47,411 | saggiyogesh/nodeportal | lib/Router.js | Route | function Route(method, route, fn) {
this.method = method;
this.route = route;
this.fn = fn;
return function (app) {
var middleware = exports.isAppSettingsRoute(route) ? utils.getSettingsMiddlewares() :
utils.getRequestMiddlewares();
if (method == "get") {
app.get(route, middleware, fn)
}
else if (method == "post") {
app.post(route, middleware, fn);
}
// var methodRoutes = app.routes[method];
// return methodRoutes[methodRoutes.length - 1];
};
} | javascript | function Route(method, route, fn) {
this.method = method;
this.route = route;
this.fn = fn;
return function (app) {
var middleware = exports.isAppSettingsRoute(route) ? utils.getSettingsMiddlewares() :
utils.getRequestMiddlewares();
if (method == "get") {
app.get(route, middleware, fn)
}
else if (method == "post") {
app.post(route, middleware, fn);
}
// var methodRoutes = app.routes[method];
// return methodRoutes[methodRoutes.length - 1];
};
} | [
"function",
"Route",
"(",
"method",
",",
"route",
",",
"fn",
")",
"{",
"this",
".",
"method",
"=",
"method",
";",
"this",
".",
"route",
"=",
"route",
";",
"this",
".",
"fn",
"=",
"fn",
";",
"return",
"function",
"(",
"app",
")",
"{",
"var",
"middleware",
"=",
"exports",
".",
"isAppSettingsRoute",
"(",
"route",
")",
"?",
"utils",
".",
"getSettingsMiddlewares",
"(",
")",
":",
"utils",
".",
"getRequestMiddlewares",
"(",
")",
";",
"if",
"(",
"method",
"==",
"\"get\"",
")",
"{",
"app",
".",
"get",
"(",
"route",
",",
"middleware",
",",
"fn",
")",
"}",
"else",
"if",
"(",
"method",
"==",
"\"post\"",
")",
"{",
"app",
".",
"post",
"(",
"route",
",",
"middleware",
",",
"fn",
")",
";",
"}",
"// var methodRoutes = app.routes[method];",
"// return methodRoutes[methodRoutes.length - 1];",
"}",
";",
"}"
]
| Returns a fn, which return the express route object
@param method
@param route
@param fn | [
"Returns",
"a",
"fn",
"which",
"return",
"the",
"express",
"route",
"object"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/Router.js#L35-L53 |
47,412 | cloud9ide/frontdoor | lib/route.js | normalizePath | function normalizePath(path, keys, params) {
for (var name in params) {
var param = params[name];
if (typeof param == "string" || param instanceof RegExp)
params[name] = {type: param};
}
path = path
.concat("/?")
.replace(/\/:([\w.\-_]+)(\*?)/g, function(match, key, wildcard) {
keys.push(key);
if (!params[key]) {
params[key] = {};
}
// url params default to type string and optional=false
var param = params[key];
param.type = param.type || "string";
param.optional = false;
if (!param.source) param.source = "url";
if (param.source !== "url")
throw new Error(
"Url parameters must have 'url' as source but found '" +
param.source +
"'"
);
if (wildcard) return "(/*)";
else return "/([^\\/]+)";
})
.replace(/([/.])/g, "\\$1")
.replace(/\*/g, "(.*)");
return new RegExp("^" + path + "$");
} | javascript | function normalizePath(path, keys, params) {
for (var name in params) {
var param = params[name];
if (typeof param == "string" || param instanceof RegExp)
params[name] = {type: param};
}
path = path
.concat("/?")
.replace(/\/:([\w.\-_]+)(\*?)/g, function(match, key, wildcard) {
keys.push(key);
if (!params[key]) {
params[key] = {};
}
// url params default to type string and optional=false
var param = params[key];
param.type = param.type || "string";
param.optional = false;
if (!param.source) param.source = "url";
if (param.source !== "url")
throw new Error(
"Url parameters must have 'url' as source but found '" +
param.source +
"'"
);
if (wildcard) return "(/*)";
else return "/([^\\/]+)";
})
.replace(/([/.])/g, "\\$1")
.replace(/\*/g, "(.*)");
return new RegExp("^" + path + "$");
} | [
"function",
"normalizePath",
"(",
"path",
",",
"keys",
",",
"params",
")",
"{",
"for",
"(",
"var",
"name",
"in",
"params",
")",
"{",
"var",
"param",
"=",
"params",
"[",
"name",
"]",
";",
"if",
"(",
"typeof",
"param",
"==",
"\"string\"",
"||",
"param",
"instanceof",
"RegExp",
")",
"params",
"[",
"name",
"]",
"=",
"{",
"type",
":",
"param",
"}",
";",
"}",
"path",
"=",
"path",
".",
"concat",
"(",
"\"/?\"",
")",
".",
"replace",
"(",
"/",
"\\/:([\\w.\\-_]+)(\\*?)",
"/",
"g",
",",
"function",
"(",
"match",
",",
"key",
",",
"wildcard",
")",
"{",
"keys",
".",
"push",
"(",
"key",
")",
";",
"if",
"(",
"!",
"params",
"[",
"key",
"]",
")",
"{",
"params",
"[",
"key",
"]",
"=",
"{",
"}",
";",
"}",
"// url params default to type string and optional=false",
"var",
"param",
"=",
"params",
"[",
"key",
"]",
";",
"param",
".",
"type",
"=",
"param",
".",
"type",
"||",
"\"string\"",
";",
"param",
".",
"optional",
"=",
"false",
";",
"if",
"(",
"!",
"param",
".",
"source",
")",
"param",
".",
"source",
"=",
"\"url\"",
";",
"if",
"(",
"param",
".",
"source",
"!==",
"\"url\"",
")",
"throw",
"new",
"Error",
"(",
"\"Url parameters must have 'url' as source but found '\"",
"+",
"param",
".",
"source",
"+",
"\"'\"",
")",
";",
"if",
"(",
"wildcard",
")",
"return",
"\"(/*)\"",
";",
"else",
"return",
"\"/([^\\\\/]+)\"",
";",
"}",
")",
".",
"replace",
"(",
"/",
"([/.])",
"/",
"g",
",",
"\"\\\\$1\"",
")",
".",
"replace",
"(",
"/",
"\\*",
"/",
"g",
",",
"\"(.*)\"",
")",
";",
"return",
"new",
"RegExp",
"(",
"\"^\"",
"+",
"path",
"+",
"\"$\"",
")",
";",
"}"
]
| Creates a rgular expression to match this route.
Url param names are stored in `keys` and the `params` are completed with
the default values for url parameters. | [
"Creates",
"a",
"rgular",
"expression",
"to",
"match",
"this",
"route",
".",
"Url",
"param",
"names",
"are",
"stored",
"in",
"keys",
"and",
"the",
"params",
"are",
"completed",
"with",
"the",
"default",
"values",
"for",
"url",
"parameters",
"."
]
| d29907494ef2259235b7f331dd7e225b5c186cd6 | https://github.com/cloud9ide/frontdoor/blob/d29907494ef2259235b7f331dd7e225b5c186cd6/lib/route.js#L54-L89 |
47,413 | dominictarr/web-bootloader | bootloader.js | function (target, cb) {
if(!target) return cb(new Error('WebBoot.prune: size to clear must be provided'))
var cleared = 0, remove = []
function clear () {
var n = remove.length
while(remove.length) store.rm(remove.shift(), function () {
if(--n) return
if(cleared < target)
cb(new Error('could not clear requested space'), cleared)
else
cb(null, cleared)
})
}
store.ls(function (err, ls) {
if(err) return cb(err)
log.unfiltered(function (err, unfiltered) {
if(err) return cb(err)
var stored = unfiltered.reverse()
ls.forEach(function (a) {
if(!unfiltered.find(function (b) {
return a.id == b.id
})) {
cleared += a.size
remove.push(a.id)
}
})
for(var i = 0; i < stored.length; i++) {
var id = stored[i].value
var item = ls.find(function (e) {
return e.id === id
})
if(item) {
cleared += item.size
remove.push(id)
if(cleared >= target) return clear()
}
}
clear()
})
})
} | javascript | function (target, cb) {
if(!target) return cb(new Error('WebBoot.prune: size to clear must be provided'))
var cleared = 0, remove = []
function clear () {
var n = remove.length
while(remove.length) store.rm(remove.shift(), function () {
if(--n) return
if(cleared < target)
cb(new Error('could not clear requested space'), cleared)
else
cb(null, cleared)
})
}
store.ls(function (err, ls) {
if(err) return cb(err)
log.unfiltered(function (err, unfiltered) {
if(err) return cb(err)
var stored = unfiltered.reverse()
ls.forEach(function (a) {
if(!unfiltered.find(function (b) {
return a.id == b.id
})) {
cleared += a.size
remove.push(a.id)
}
})
for(var i = 0; i < stored.length; i++) {
var id = stored[i].value
var item = ls.find(function (e) {
return e.id === id
})
if(item) {
cleared += item.size
remove.push(id)
if(cleared >= target) return clear()
}
}
clear()
})
})
} | [
"function",
"(",
"target",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"target",
")",
"return",
"cb",
"(",
"new",
"Error",
"(",
"'WebBoot.prune: size to clear must be provided'",
")",
")",
"var",
"cleared",
"=",
"0",
",",
"remove",
"=",
"[",
"]",
"function",
"clear",
"(",
")",
"{",
"var",
"n",
"=",
"remove",
".",
"length",
"while",
"(",
"remove",
".",
"length",
")",
"store",
".",
"rm",
"(",
"remove",
".",
"shift",
"(",
")",
",",
"function",
"(",
")",
"{",
"if",
"(",
"--",
"n",
")",
"return",
"if",
"(",
"cleared",
"<",
"target",
")",
"cb",
"(",
"new",
"Error",
"(",
"'could not clear requested space'",
")",
",",
"cleared",
")",
"else",
"cb",
"(",
"null",
",",
"cleared",
")",
"}",
")",
"}",
"store",
".",
"ls",
"(",
"function",
"(",
"err",
",",
"ls",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
"log",
".",
"unfiltered",
"(",
"function",
"(",
"err",
",",
"unfiltered",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
"var",
"stored",
"=",
"unfiltered",
".",
"reverse",
"(",
")",
"ls",
".",
"forEach",
"(",
"function",
"(",
"a",
")",
"{",
"if",
"(",
"!",
"unfiltered",
".",
"find",
"(",
"function",
"(",
"b",
")",
"{",
"return",
"a",
".",
"id",
"==",
"b",
".",
"id",
"}",
")",
")",
"{",
"cleared",
"+=",
"a",
".",
"size",
"remove",
".",
"push",
"(",
"a",
".",
"id",
")",
"}",
"}",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"stored",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"id",
"=",
"stored",
"[",
"i",
"]",
".",
"value",
"var",
"item",
"=",
"ls",
".",
"find",
"(",
"function",
"(",
"e",
")",
"{",
"return",
"e",
".",
"id",
"===",
"id",
"}",
")",
"if",
"(",
"item",
")",
"{",
"cleared",
"+=",
"item",
".",
"size",
"remove",
".",
"push",
"(",
"id",
")",
"if",
"(",
"cleared",
">=",
"target",
")",
"return",
"clear",
"(",
")",
"}",
"}",
"clear",
"(",
")",
"}",
")",
"}",
")",
"}"
]
| clear target amount of space. | [
"clear",
"target",
"amount",
"of",
"space",
"."
]
| de995bc3e41ba4db94a6de41388dfe676ed37a7e | https://github.com/dominictarr/web-bootloader/blob/de995bc3e41ba4db94a6de41388dfe676ed37a7e/bootloader.js#L108-L152 |
|
47,414 | jhermsmeier/node-speech | lib/distance/dice.js | dice | function dice( source, target ) {
var sources = dice.prepare( source )
var targets = dice.prepare( target )
var i, k, intersection = 0
var source_count = sources.length
var target_count = targets.length
var union = source_count + target_count
for( i = 0; i < source_count; i++ ) {
source = sources[i]
for( k = 0; k < target_count; k++ ) {
target = targets[k]
if( source === target ) {
intersection++
targets[k] = undefined
break
}
}
}
return 2 * intersection / union
} | javascript | function dice( source, target ) {
var sources = dice.prepare( source )
var targets = dice.prepare( target )
var i, k, intersection = 0
var source_count = sources.length
var target_count = targets.length
var union = source_count + target_count
for( i = 0; i < source_count; i++ ) {
source = sources[i]
for( k = 0; k < target_count; k++ ) {
target = targets[k]
if( source === target ) {
intersection++
targets[k] = undefined
break
}
}
}
return 2 * intersection / union
} | [
"function",
"dice",
"(",
"source",
",",
"target",
")",
"{",
"var",
"sources",
"=",
"dice",
".",
"prepare",
"(",
"source",
")",
"var",
"targets",
"=",
"dice",
".",
"prepare",
"(",
"target",
")",
"var",
"i",
",",
"k",
",",
"intersection",
"=",
"0",
"var",
"source_count",
"=",
"sources",
".",
"length",
"var",
"target_count",
"=",
"targets",
".",
"length",
"var",
"union",
"=",
"source_count",
"+",
"target_count",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"source_count",
";",
"i",
"++",
")",
"{",
"source",
"=",
"sources",
"[",
"i",
"]",
"for",
"(",
"k",
"=",
"0",
";",
"k",
"<",
"target_count",
";",
"k",
"++",
")",
"{",
"target",
"=",
"targets",
"[",
"k",
"]",
"if",
"(",
"source",
"===",
"target",
")",
"{",
"intersection",
"++",
"targets",
"[",
"k",
"]",
"=",
"undefined",
"break",
"}",
"}",
"}",
"return",
"2",
"*",
"intersection",
"/",
"union",
"}"
]
| Computes dice's coefficient.
@param {String} source
@param {String} target
@return {Number} dice coefficient | [
"Computes",
"dice",
"s",
"coefficient",
"."
]
| 984c4dd6e2fe640c01267f10e3804ef81391e73a | https://github.com/jhermsmeier/node-speech/blob/984c4dd6e2fe640c01267f10e3804ef81391e73a/lib/distance/dice.js#L9-L33 |
47,415 | reklatsmasters/unicast | lib/create-socket.js | createSocket | function createSocket(socket, options = {}) {
if (!isSocket(socket)) {
options = socket; // eslint-disable-line no-param-reassign
if (isSocket(options.socket)) {
// eslint-disable-next-line no-param-reassign, prefer-destructuring
socket = options.socket;
} else {
socket = dgram.createSocket(options); // eslint-disable-line no-param-reassign
socket.bind(options.port || 0, options.address || '0.0.0.0');
}
}
return new Socket(Object.assign({}, options, { socket }));
} | javascript | function createSocket(socket, options = {}) {
if (!isSocket(socket)) {
options = socket; // eslint-disable-line no-param-reassign
if (isSocket(options.socket)) {
// eslint-disable-next-line no-param-reassign, prefer-destructuring
socket = options.socket;
} else {
socket = dgram.createSocket(options); // eslint-disable-line no-param-reassign
socket.bind(options.port || 0, options.address || '0.0.0.0');
}
}
return new Socket(Object.assign({}, options, { socket }));
} | [
"function",
"createSocket",
"(",
"socket",
",",
"options",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"!",
"isSocket",
"(",
"socket",
")",
")",
"{",
"options",
"=",
"socket",
";",
"// eslint-disable-line no-param-reassign",
"if",
"(",
"isSocket",
"(",
"options",
".",
"socket",
")",
")",
"{",
"// eslint-disable-next-line no-param-reassign, prefer-destructuring",
"socket",
"=",
"options",
".",
"socket",
";",
"}",
"else",
"{",
"socket",
"=",
"dgram",
".",
"createSocket",
"(",
"options",
")",
";",
"// eslint-disable-line no-param-reassign",
"socket",
".",
"bind",
"(",
"options",
".",
"port",
"||",
"0",
",",
"options",
".",
"address",
"||",
"'0.0.0.0'",
")",
";",
"}",
"}",
"return",
"new",
"Socket",
"(",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
",",
"{",
"socket",
"}",
")",
")",
";",
"}"
]
| Create a new UDP unicast socket.
@param {dgram.Socket|string|object} socket
@param {object} [options]
@return {Socket} | [
"Create",
"a",
"new",
"UDP",
"unicast",
"socket",
"."
]
| fe83eb884bcd8687e50a4b5163a5af584d32444b | https://github.com/reklatsmasters/unicast/blob/fe83eb884bcd8687e50a4b5163a5af584d32444b/lib/create-socket.js#L16-L30 |
47,416 | levilindsey/physx | src/collisions/contact-calculation/src/sphere-contact-calculation.js | sphereVsAabb | function sphereVsAabb(contactPoint, contactNormal, sphere, aabb) {
findClosestPointFromAabbSurfaceToPoint(contactPoint, aabb, sphere.centerOfVolume);
findAabbNormalFromContactPoint(contactNormal, contactPoint, aabb);
vec3.negate(contactNormal, contactNormal);
} | javascript | function sphereVsAabb(contactPoint, contactNormal, sphere, aabb) {
findClosestPointFromAabbSurfaceToPoint(contactPoint, aabb, sphere.centerOfVolume);
findAabbNormalFromContactPoint(contactNormal, contactPoint, aabb);
vec3.negate(contactNormal, contactNormal);
} | [
"function",
"sphereVsAabb",
"(",
"contactPoint",
",",
"contactNormal",
",",
"sphere",
",",
"aabb",
")",
"{",
"findClosestPointFromAabbSurfaceToPoint",
"(",
"contactPoint",
",",
"aabb",
",",
"sphere",
".",
"centerOfVolume",
")",
";",
"findAabbNormalFromContactPoint",
"(",
"contactNormal",
",",
"contactPoint",
",",
"aabb",
")",
";",
"vec3",
".",
"negate",
"(",
"contactNormal",
",",
"contactNormal",
")",
";",
"}"
]
| Finds the closest point on the surface of the AABB to the sphere center.
@param {vec3} contactPoint Output param.
@param {vec3} contactNormal Output param.
@param {Sphere} sphere
@param {Aabb} aabb | [
"Finds",
"the",
"closest",
"point",
"on",
"the",
"surface",
"of",
"the",
"AABB",
"to",
"the",
"sphere",
"center",
"."
]
| 62df9f6968082ed34aa784a23f3db6c8feca6f3a | https://github.com/levilindsey/physx/blob/62df9f6968082ed34aa784a23f3db6c8feca6f3a/src/collisions/contact-calculation/src/sphere-contact-calculation.js#L48-L52 |
47,417 | imcuttle/tiny-i18n | packages/react-live/src/index.js | argsGetter | function argsGetter(args, lang) {
return args.map(arg =>
rStrip(
String(arg),
(s, a, b, c, count) => {
const data = JSON.parse(s)
return toWrappedString(translatedGetter(data[0], () => data.slice(1), lang), void 0, count)
},
level - 1
)
)
} | javascript | function argsGetter(args, lang) {
return args.map(arg =>
rStrip(
String(arg),
(s, a, b, c, count) => {
const data = JSON.parse(s)
return toWrappedString(translatedGetter(data[0], () => data.slice(1), lang), void 0, count)
},
level - 1
)
)
} | [
"function",
"argsGetter",
"(",
"args",
",",
"lang",
")",
"{",
"return",
"args",
".",
"map",
"(",
"arg",
"=>",
"rStrip",
"(",
"String",
"(",
"arg",
")",
",",
"(",
"s",
",",
"a",
",",
"b",
",",
"c",
",",
"count",
")",
"=>",
"{",
"const",
"data",
"=",
"JSON",
".",
"parse",
"(",
"s",
")",
"return",
"toWrappedString",
"(",
"translatedGetter",
"(",
"data",
"[",
"0",
"]",
",",
"(",
")",
"=>",
"data",
".",
"slice",
"(",
"1",
")",
",",
"lang",
")",
",",
"void",
"0",
",",
"count",
")",
"}",
",",
"level",
"-",
"1",
")",
")",
"}"
]
| Strips the outermost wrapper | [
"Strips",
"the",
"outermost",
"wrapper"
]
| 2b37e4a189918d9e8cd0c9cecb41940c9257e8cb | https://github.com/imcuttle/tiny-i18n/blob/2b37e4a189918d9e8cd0c9cecb41940c9257e8cb/packages/react-live/src/index.js#L91-L102 |
47,418 | mitchwinn/gulp-serve-iis-express | lib/index.js | startSites | function startSites(config){
config.siteNames.forEach(function(item){
var cmd = 'iisexpress /site:"' + item + '"';
if(config.configFile !== ""){
cmd += ' /config:"' + config.configFile + '"';
}
if (config.sysTray){
cmd += ' /systray:true';
}else{
cmd += ' /systray:false';
}
gulp.src('')
.pipe(shell([
cmd
],{
cwd: config.iisExpressPath
}))
.on('error', util.log);
});
return gulp.src('');
} | javascript | function startSites(config){
config.siteNames.forEach(function(item){
var cmd = 'iisexpress /site:"' + item + '"';
if(config.configFile !== ""){
cmd += ' /config:"' + config.configFile + '"';
}
if (config.sysTray){
cmd += ' /systray:true';
}else{
cmd += ' /systray:false';
}
gulp.src('')
.pipe(shell([
cmd
],{
cwd: config.iisExpressPath
}))
.on('error', util.log);
});
return gulp.src('');
} | [
"function",
"startSites",
"(",
"config",
")",
"{",
"config",
".",
"siteNames",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"var",
"cmd",
"=",
"'iisexpress /site:\"'",
"+",
"item",
"+",
"'\"'",
";",
"if",
"(",
"config",
".",
"configFile",
"!==",
"\"\"",
")",
"{",
"cmd",
"+=",
"' /config:\"'",
"+",
"config",
".",
"configFile",
"+",
"'\"'",
";",
"}",
"if",
"(",
"config",
".",
"sysTray",
")",
"{",
"cmd",
"+=",
"' /systray:true'",
";",
"}",
"else",
"{",
"cmd",
"+=",
"' /systray:false'",
";",
"}",
"gulp",
".",
"src",
"(",
"''",
")",
".",
"pipe",
"(",
"shell",
"(",
"[",
"cmd",
"]",
",",
"{",
"cwd",
":",
"config",
".",
"iisExpressPath",
"}",
")",
")",
".",
"on",
"(",
"'error'",
",",
"util",
".",
"log",
")",
";",
"}",
")",
";",
"return",
"gulp",
".",
"src",
"(",
"''",
")",
";",
"}"
]
| starting the sites. | [
"starting",
"the",
"sites",
"."
]
| 34e00e8c8a717e82e8b2cd69a98deec1daf41b51 | https://github.com/mitchwinn/gulp-serve-iis-express/blob/34e00e8c8a717e82e8b2cd69a98deec1daf41b51/lib/index.js#L98-L122 |
47,419 | kaelzhang/node-semver-extra | index.js | maxPrerelease | function maxPrerelease (versions, prerelease) {
return first(desc(versions), function (version) {
return isPrerelease(version, prerelease);
});
} | javascript | function maxPrerelease (versions, prerelease) {
return first(desc(versions), function (version) {
return isPrerelease(version, prerelease);
});
} | [
"function",
"maxPrerelease",
"(",
"versions",
",",
"prerelease",
")",
"{",
"return",
"first",
"(",
"desc",
"(",
"versions",
")",
",",
"function",
"(",
"version",
")",
"{",
"return",
"isPrerelease",
"(",
"version",
",",
"prerelease",
")",
";",
"}",
")",
";",
"}"
]
| Returns the max prerelease version of the maximun matched prerelease version | [
"Returns",
"the",
"max",
"prerelease",
"version",
"of",
"the",
"maximun",
"matched",
"prerelease",
"version"
]
| eb249cfe9c7d32c8141481314d37bd02d619bfd9 | https://github.com/kaelzhang/node-semver-extra/blob/eb249cfe9c7d32c8141481314d37bd02d619bfd9/index.js#L49-L53 |
47,420 | kaelzhang/node-semver-extra | index.js | first | function first (array, filter) {
var i = 0;
var length = array.length;
var item;
for (; i < length; i ++) {
item = array[i];
if (filter(item)) {
return item;
}
}
return null;
} | javascript | function first (array, filter) {
var i = 0;
var length = array.length;
var item;
for (; i < length; i ++) {
item = array[i];
if (filter(item)) {
return item;
}
}
return null;
} | [
"function",
"first",
"(",
"array",
",",
"filter",
")",
"{",
"var",
"i",
"=",
"0",
";",
"var",
"length",
"=",
"array",
".",
"length",
";",
"var",
"item",
";",
"for",
"(",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"item",
"=",
"array",
"[",
"i",
"]",
";",
"if",
"(",
"filter",
"(",
"item",
")",
")",
"{",
"return",
"item",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Returns the first matched array item | [
"Returns",
"the",
"first",
"matched",
"array",
"item"
]
| eb249cfe9c7d32c8141481314d37bd02d619bfd9 | https://github.com/kaelzhang/node-semver-extra/blob/eb249cfe9c7d32c8141481314d37bd02d619bfd9/index.js#L66-L78 |
47,421 | creationix/git-node | examples/create.js | serialEach | function serialEach(object, fn, callback) {
var keys = Object.keys(object);
next();
function next(err) {
if (err) return callback(err);
var key = keys.shift();
if (!key) return callback();
fn(key, object[key], next);
}
} | javascript | function serialEach(object, fn, callback) {
var keys = Object.keys(object);
next();
function next(err) {
if (err) return callback(err);
var key = keys.shift();
if (!key) return callback();
fn(key, object[key], next);
}
} | [
"function",
"serialEach",
"(",
"object",
",",
"fn",
",",
"callback",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"object",
")",
";",
"next",
"(",
")",
";",
"function",
"next",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"callback",
"(",
"err",
")",
";",
"var",
"key",
"=",
"keys",
".",
"shift",
"(",
")",
";",
"if",
"(",
"!",
"key",
")",
"return",
"callback",
"(",
")",
";",
"fn",
"(",
"key",
",",
"object",
"[",
"key",
"]",
",",
"next",
")",
";",
"}",
"}"
]
| Mini control-flow library | [
"Mini",
"control",
"-",
"flow",
"library"
]
| 74d927d0168ce1592303ac2f030e2ee6314ad6c6 | https://github.com/creationix/git-node/blob/74d927d0168ce1592303ac2f030e2ee6314ad6c6/examples/create.js#L51-L60 |
47,422 | saggiyogesh/nodeportal | lib/permissions/Cache.js | CacheItem | function CacheItem(permissionSchemaKey, actionsValue, permissions) {
if (!actionsValue) {
if (!utils.contains(permissionSchemaKey, TRIPLE_UNDERSCORE)) {
throw new Error("Invalid permissions schema key.")
}
else {
var key = permissionSchemaKey.split(TRIPLE_UNDERSCORE)[0];
actionsValue = cache.get(key).actionsValue;
}
}
/**
* Getter for permissionSchemaKey
* @returns {String}
*/
this.getPermissionSchemaKey = function () {
return permissionSchemaKey;
};
/**
* Returns action value.
* @param action {String} Action key
* @returns {String}
*/
this.getActionValue = function (action) {
if (!action) {
throw new Error('No arguments');
}
return actionsValue[action];
};
/**
* Returns array of action values for the role
* @param roleId {Number}
* @returns {Array}
*/
this.getRolePermissions = function (roleId) {
if (!roleId) {
throw new Error('No arguments');
}
return permissions[roleId];
};
/**
* Getter of permissions
* @returns {Object}
*/
this.getPermissions = function () {
return permissions;
};
/**
* Getter of actions values.
* @returns {Object}
*/
this.getActionsValue = function () {
return actionsValue;
};
this.permissions = permissions
this.actionsValue = actionsValue
} | javascript | function CacheItem(permissionSchemaKey, actionsValue, permissions) {
if (!actionsValue) {
if (!utils.contains(permissionSchemaKey, TRIPLE_UNDERSCORE)) {
throw new Error("Invalid permissions schema key.")
}
else {
var key = permissionSchemaKey.split(TRIPLE_UNDERSCORE)[0];
actionsValue = cache.get(key).actionsValue;
}
}
/**
* Getter for permissionSchemaKey
* @returns {String}
*/
this.getPermissionSchemaKey = function () {
return permissionSchemaKey;
};
/**
* Returns action value.
* @param action {String} Action key
* @returns {String}
*/
this.getActionValue = function (action) {
if (!action) {
throw new Error('No arguments');
}
return actionsValue[action];
};
/**
* Returns array of action values for the role
* @param roleId {Number}
* @returns {Array}
*/
this.getRolePermissions = function (roleId) {
if (!roleId) {
throw new Error('No arguments');
}
return permissions[roleId];
};
/**
* Getter of permissions
* @returns {Object}
*/
this.getPermissions = function () {
return permissions;
};
/**
* Getter of actions values.
* @returns {Object}
*/
this.getActionsValue = function () {
return actionsValue;
};
this.permissions = permissions
this.actionsValue = actionsValue
} | [
"function",
"CacheItem",
"(",
"permissionSchemaKey",
",",
"actionsValue",
",",
"permissions",
")",
"{",
"if",
"(",
"!",
"actionsValue",
")",
"{",
"if",
"(",
"!",
"utils",
".",
"contains",
"(",
"permissionSchemaKey",
",",
"TRIPLE_UNDERSCORE",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Invalid permissions schema key.\"",
")",
"}",
"else",
"{",
"var",
"key",
"=",
"permissionSchemaKey",
".",
"split",
"(",
"TRIPLE_UNDERSCORE",
")",
"[",
"0",
"]",
";",
"actionsValue",
"=",
"cache",
".",
"get",
"(",
"key",
")",
".",
"actionsValue",
";",
"}",
"}",
"/**\n * Getter for permissionSchemaKey\n * @returns {String}\n */",
"this",
".",
"getPermissionSchemaKey",
"=",
"function",
"(",
")",
"{",
"return",
"permissionSchemaKey",
";",
"}",
";",
"/**\n * Returns action value.\n * @param action {String} Action key\n * @returns {String}\n */",
"this",
".",
"getActionValue",
"=",
"function",
"(",
"action",
")",
"{",
"if",
"(",
"!",
"action",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No arguments'",
")",
";",
"}",
"return",
"actionsValue",
"[",
"action",
"]",
";",
"}",
";",
"/**\n * Returns array of action values for the role\n * @param roleId {Number}\n * @returns {Array}\n */",
"this",
".",
"getRolePermissions",
"=",
"function",
"(",
"roleId",
")",
"{",
"if",
"(",
"!",
"roleId",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No arguments'",
")",
";",
"}",
"return",
"permissions",
"[",
"roleId",
"]",
";",
"}",
";",
"/**\n * Getter of permissions\n * @returns {Object}\n */",
"this",
".",
"getPermissions",
"=",
"function",
"(",
")",
"{",
"return",
"permissions",
";",
"}",
";",
"/**\n * Getter of actions values.\n * @returns {Object}\n */",
"this",
".",
"getActionsValue",
"=",
"function",
"(",
")",
"{",
"return",
"actionsValue",
";",
"}",
";",
"this",
".",
"permissions",
"=",
"permissions",
"this",
".",
"actionsValue",
"=",
"actionsValue",
"}"
]
| Constructor to create cache item
@param permissionSchemaKey {String} unique key
@param actionsValue {Object} Object to Action key with value
@param permissions {Object} Object having array of permissions to each role.
@constructor | [
"Constructor",
"to",
"create",
"cache",
"item"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/permissions/Cache.js#L21-L82 |
47,423 | saggiyogesh/nodeportal | lib/permissions/Cache.js | storeModel | function storeModel(model, permissionSchemaKey) {
if (model && model.rolePermissions) {
var obj = {
permissionSchemaKey: permissionSchemaKey,
rolePermissions: model.rolePermissions
};
exports.store(obj);
}
} | javascript | function storeModel(model, permissionSchemaKey) {
if (model && model.rolePermissions) {
var obj = {
permissionSchemaKey: permissionSchemaKey,
rolePermissions: model.rolePermissions
};
exports.store(obj);
}
} | [
"function",
"storeModel",
"(",
"model",
",",
"permissionSchemaKey",
")",
"{",
"if",
"(",
"model",
"&&",
"model",
".",
"rolePermissions",
")",
"{",
"var",
"obj",
"=",
"{",
"permissionSchemaKey",
":",
"permissionSchemaKey",
",",
"rolePermissions",
":",
"model",
".",
"rolePermissions",
"}",
";",
"exports",
".",
"store",
"(",
"obj",
")",
";",
"}",
"}"
]
| Method storing model's role permissions to cache
@param model {Object}
@param permissionSchemaKey {String} | [
"Method",
"storing",
"model",
"s",
"role",
"permissions",
"to",
"cache"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/permissions/Cache.js#L89-L97 |
47,424 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/stylescombo/plugin.js | function()
{
if ( combo )
{
delete combo._.panel;
delete combo._.list;
combo._.committed = 0;
combo._.items = {};
combo._.state = CKEDITOR.TRISTATE_OFF;
}
styles = {};
stylesList = [];
loadStylesSet();
} | javascript | function()
{
if ( combo )
{
delete combo._.panel;
delete combo._.list;
combo._.committed = 0;
combo._.items = {};
combo._.state = CKEDITOR.TRISTATE_OFF;
}
styles = {};
stylesList = [];
loadStylesSet();
} | [
"function",
"(",
")",
"{",
"if",
"(",
"combo",
")",
"{",
"delete",
"combo",
".",
"_",
".",
"panel",
";",
"delete",
"combo",
".",
"_",
".",
"list",
";",
"combo",
".",
"_",
".",
"committed",
"=",
"0",
";",
"combo",
".",
"_",
".",
"items",
"=",
"{",
"}",
";",
"combo",
".",
"_",
".",
"state",
"=",
"CKEDITOR",
".",
"TRISTATE_OFF",
";",
"}",
"styles",
"=",
"{",
"}",
";",
"stylesList",
"=",
"[",
"]",
";",
"loadStylesSet",
"(",
")",
";",
"}"
]
| Force a reload of the data | [
"Force",
"a",
"reload",
"of",
"the",
"data"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/stylescombo/plugin.js#L187-L200 |
|
47,425 | azu/spellcheck-technical-word | lib/spellcheck-technical-word.js | spellCheckText | function spellCheckText(text) {
var src = new StructuredSource(text);
var results = [];
for (var i = 0, length = dictionaryItems.length; i < length; i++) {
var dictionary = dictionaryItems[i];
var query = new RegExp(dictionary.pattern, dictionary.flag);
var match = query.exec(text);
if (!match) {
continue;
}
var matchedString = match[0];
// s/Web/Web/iは大文字小文字無視してWebに変換したいという意味に対応する
if (dictionary.flag != null) {
var strictQuery = new RegExp(dictionary.pattern);
var isStrictMatch = strictQuery.test(match[0]);
// /Web/i でマッチするけど、 /Web/ でマッチするならそれは除外する
if (isStrictMatch) {
continue;
}
}
// s/ベンダ/ベンダー/ のようにexpectedがpatternを包含している場合のexpectedを除外
var expected = matchedString.replace(query, dictionary.expected);
if (text.slice(match.index).indexOf(expected) === 0) {
// [start, end]
continue;
}
var position = src.indexToPosition(match.index);
/**
*
* @typedef {{actual: string, expected: string, paddingLine: number, paddingColumn: number}} SpellCheckResult
*/
var result = {
actual: matchedString,
expected: expected,
paddingIndex: match.index,
paddingLine: position.line - 1,// start with 0
paddingColumn: position.column// start with 0
};
results.push(result);
}
return results.reverse();
} | javascript | function spellCheckText(text) {
var src = new StructuredSource(text);
var results = [];
for (var i = 0, length = dictionaryItems.length; i < length; i++) {
var dictionary = dictionaryItems[i];
var query = new RegExp(dictionary.pattern, dictionary.flag);
var match = query.exec(text);
if (!match) {
continue;
}
var matchedString = match[0];
// s/Web/Web/iは大文字小文字無視してWebに変換したいという意味に対応する
if (dictionary.flag != null) {
var strictQuery = new RegExp(dictionary.pattern);
var isStrictMatch = strictQuery.test(match[0]);
// /Web/i でマッチするけど、 /Web/ でマッチするならそれは除外する
if (isStrictMatch) {
continue;
}
}
// s/ベンダ/ベンダー/ のようにexpectedがpatternを包含している場合のexpectedを除外
var expected = matchedString.replace(query, dictionary.expected);
if (text.slice(match.index).indexOf(expected) === 0) {
// [start, end]
continue;
}
var position = src.indexToPosition(match.index);
/**
*
* @typedef {{actual: string, expected: string, paddingLine: number, paddingColumn: number}} SpellCheckResult
*/
var result = {
actual: matchedString,
expected: expected,
paddingIndex: match.index,
paddingLine: position.line - 1,// start with 0
paddingColumn: position.column// start with 0
};
results.push(result);
}
return results.reverse();
} | [
"function",
"spellCheckText",
"(",
"text",
")",
"{",
"var",
"src",
"=",
"new",
"StructuredSource",
"(",
"text",
")",
";",
"var",
"results",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"length",
"=",
"dictionaryItems",
".",
"length",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"var",
"dictionary",
"=",
"dictionaryItems",
"[",
"i",
"]",
";",
"var",
"query",
"=",
"new",
"RegExp",
"(",
"dictionary",
".",
"pattern",
",",
"dictionary",
".",
"flag",
")",
";",
"var",
"match",
"=",
"query",
".",
"exec",
"(",
"text",
")",
";",
"if",
"(",
"!",
"match",
")",
"{",
"continue",
";",
"}",
"var",
"matchedString",
"=",
"match",
"[",
"0",
"]",
";",
"// s/Web/Web/iは大文字小文字無視してWebに変換したいという意味に対応する",
"if",
"(",
"dictionary",
".",
"flag",
"!=",
"null",
")",
"{",
"var",
"strictQuery",
"=",
"new",
"RegExp",
"(",
"dictionary",
".",
"pattern",
")",
";",
"var",
"isStrictMatch",
"=",
"strictQuery",
".",
"test",
"(",
"match",
"[",
"0",
"]",
")",
";",
"// /Web/i でマッチするけど、 /Web/ でマッチするならそれは除外する",
"if",
"(",
"isStrictMatch",
")",
"{",
"continue",
";",
"}",
"}",
"// s/ベンダ/ベンダー/ のようにexpectedがpatternを包含している場合のexpectedを除外",
"var",
"expected",
"=",
"matchedString",
".",
"replace",
"(",
"query",
",",
"dictionary",
".",
"expected",
")",
";",
"if",
"(",
"text",
".",
"slice",
"(",
"match",
".",
"index",
")",
".",
"indexOf",
"(",
"expected",
")",
"===",
"0",
")",
"{",
"// [start, end]",
"continue",
";",
"}",
"var",
"position",
"=",
"src",
".",
"indexToPosition",
"(",
"match",
".",
"index",
")",
";",
"/**\n *\n * @typedef {{actual: string, expected: string, paddingLine: number, paddingColumn: number}} SpellCheckResult\n */",
"var",
"result",
"=",
"{",
"actual",
":",
"matchedString",
",",
"expected",
":",
"expected",
",",
"paddingIndex",
":",
"match",
".",
"index",
",",
"paddingLine",
":",
"position",
".",
"line",
"-",
"1",
",",
"// start with 0",
"paddingColumn",
":",
"position",
".",
"column",
"// start with 0",
"}",
";",
"results",
".",
"push",
"(",
"result",
")",
";",
"}",
"return",
"results",
".",
"reverse",
"(",
")",
";",
"}"
]
| spell check the text, then return array of result.
@param {string} text
@returns {SpellCheckResult[]} | [
"spell",
"check",
"the",
"text",
"then",
"return",
"array",
"of",
"result",
"."
]
| 11aad9e2f89c6cccc0e9387669ce56c83366e204 | https://github.com/azu/spellcheck-technical-word/blob/11aad9e2f89c6cccc0e9387669ce56c83366e204/lib/spellcheck-technical-word.js#L9-L54 |
47,426 | saggiyogesh/nodeportal | lib/Renderer/SettingsErrorRenderer.js | SettingsErrorRenderer | function SettingsErrorRenderer(err, req, res) {
SettingsRenderer.call(this, req, res);
Object.defineProperties(this, {
err: {
value: err || new Error()
}
});
req.attrs.isErrorPage = true;
} | javascript | function SettingsErrorRenderer(err, req, res) {
SettingsRenderer.call(this, req, res);
Object.defineProperties(this, {
err: {
value: err || new Error()
}
});
req.attrs.isErrorPage = true;
} | [
"function",
"SettingsErrorRenderer",
"(",
"err",
",",
"req",
",",
"res",
")",
"{",
"SettingsRenderer",
".",
"call",
"(",
"this",
",",
"req",
",",
"res",
")",
";",
"Object",
".",
"defineProperties",
"(",
"this",
",",
"{",
"err",
":",
"{",
"value",
":",
"err",
"||",
"new",
"Error",
"(",
")",
"}",
"}",
")",
";",
"req",
".",
"attrs",
".",
"isErrorPage",
"=",
"true",
";",
"}"
]
| Constructor to create SettingsErrorRenderer
@param err
@param req
@param res
@constructor | [
"Constructor",
"to",
"create",
"SettingsErrorRenderer"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/Renderer/SettingsErrorRenderer.js#L15-L23 |
47,427 | jchook/virtual-dom-handlebars | lib/Template.js | reset | function reset(html) {
this.html = html || this.html;
this.root = new VNode('div');
this.node = this.root; // current working node
this.path = []; // current working node parents
this.blocks = []; // recursive components
} | javascript | function reset(html) {
this.html = html || this.html;
this.root = new VNode('div');
this.node = this.root; // current working node
this.path = []; // current working node parents
this.blocks = []; // recursive components
} | [
"function",
"reset",
"(",
"html",
")",
"{",
"this",
".",
"html",
"=",
"html",
"||",
"this",
".",
"html",
";",
"this",
".",
"root",
"=",
"new",
"VNode",
"(",
"'div'",
")",
";",
"this",
".",
"node",
"=",
"this",
".",
"root",
";",
"// current working node",
"this",
".",
"path",
"=",
"[",
"]",
";",
"// current working node parents",
"this",
".",
"blocks",
"=",
"[",
"]",
";",
"// recursive components",
"}"
]
| Update the HTML | [
"Update",
"the",
"HTML"
]
| d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L87-L93 |
47,428 | jchook/virtual-dom-handlebars | lib/Template.js | push | function push() {
this.path.push(this.node);
this.node = this.node.children[this.node.children.length - 1];
} | javascript | function push() {
this.path.push(this.node);
this.node = this.node.children[this.node.children.length - 1];
} | [
"function",
"push",
"(",
")",
"{",
"this",
".",
"path",
".",
"push",
"(",
"this",
".",
"node",
")",
";",
"this",
".",
"node",
"=",
"this",
".",
"node",
".",
"children",
"[",
"this",
".",
"node",
".",
"children",
".",
"length",
"-",
"1",
"]",
";",
"}"
]
| Move cursor to the latest child of the current node | [
"Move",
"cursor",
"to",
"the",
"latest",
"child",
"of",
"the",
"current",
"node"
]
| d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L113-L116 |
47,429 | jchook/virtual-dom-handlebars | lib/Template.js | ontext | function ontext(template, text, config) {
var
blockStubPos = -1,
cursor = 0,
children = null,
nodes = []
;
config = extend({virtual: template.virtual}, config);
// Ensures that consecutive textOnly components are merged into a single VText node
function concatText(text) {
if ((nodes.length > 0) && nodes[nodes.length - 1].addText) {
nodes[nodes.length - 1].addText(text);
} else {
nodes.push(new VText(text, config));
}
}
// DRY parse
function concatInterpolatedContent(content) {
Expression.parseInterpolated(content, {
ontext: function(text) {
concatText(text);
},
onexpression: function(expr) {
if (expr.textOnly || (config.virtual === false)) {
concatText(expr);
} else {
nodes.push(expr);
}
}
});
}
// While we find more interpolated handlebars blocks
while ((blockStubPos = text.indexOf(_blockStub, cursor)) > -1) {
// Get pre-text
if (blockStubPos > cursor) {
concatInterpolatedContent(text.substr(cursor, blockStubPos - cursor));
}
// Add the block to the list of nodes
block = template.blocks.shift();
if (config.virtual === false) {
block.callback.virtual = false;
concatText(block);
} else {
nodes.push(block);
}
// Advance the cursor
cursor = blockStubPos + _blockStub.length;
}
// Get post-text (or the only text)
if (cursor < text.length) {
concatInterpolatedContent(text.substr(cursor));
}
// textOnly is for things like tagName and attribute values
return nodes;
} | javascript | function ontext(template, text, config) {
var
blockStubPos = -1,
cursor = 0,
children = null,
nodes = []
;
config = extend({virtual: template.virtual}, config);
// Ensures that consecutive textOnly components are merged into a single VText node
function concatText(text) {
if ((nodes.length > 0) && nodes[nodes.length - 1].addText) {
nodes[nodes.length - 1].addText(text);
} else {
nodes.push(new VText(text, config));
}
}
// DRY parse
function concatInterpolatedContent(content) {
Expression.parseInterpolated(content, {
ontext: function(text) {
concatText(text);
},
onexpression: function(expr) {
if (expr.textOnly || (config.virtual === false)) {
concatText(expr);
} else {
nodes.push(expr);
}
}
});
}
// While we find more interpolated handlebars blocks
while ((blockStubPos = text.indexOf(_blockStub, cursor)) > -1) {
// Get pre-text
if (blockStubPos > cursor) {
concatInterpolatedContent(text.substr(cursor, blockStubPos - cursor));
}
// Add the block to the list of nodes
block = template.blocks.shift();
if (config.virtual === false) {
block.callback.virtual = false;
concatText(block);
} else {
nodes.push(block);
}
// Advance the cursor
cursor = blockStubPos + _blockStub.length;
}
// Get post-text (or the only text)
if (cursor < text.length) {
concatInterpolatedContent(text.substr(cursor));
}
// textOnly is for things like tagName and attribute values
return nodes;
} | [
"function",
"ontext",
"(",
"template",
",",
"text",
",",
"config",
")",
"{",
"var",
"blockStubPos",
"=",
"-",
"1",
",",
"cursor",
"=",
"0",
",",
"children",
"=",
"null",
",",
"nodes",
"=",
"[",
"]",
";",
"config",
"=",
"extend",
"(",
"{",
"virtual",
":",
"template",
".",
"virtual",
"}",
",",
"config",
")",
";",
"// Ensures that consecutive textOnly components are merged into a single VText node",
"function",
"concatText",
"(",
"text",
")",
"{",
"if",
"(",
"(",
"nodes",
".",
"length",
">",
"0",
")",
"&&",
"nodes",
"[",
"nodes",
".",
"length",
"-",
"1",
"]",
".",
"addText",
")",
"{",
"nodes",
"[",
"nodes",
".",
"length",
"-",
"1",
"]",
".",
"addText",
"(",
"text",
")",
";",
"}",
"else",
"{",
"nodes",
".",
"push",
"(",
"new",
"VText",
"(",
"text",
",",
"config",
")",
")",
";",
"}",
"}",
"// DRY parse",
"function",
"concatInterpolatedContent",
"(",
"content",
")",
"{",
"Expression",
".",
"parseInterpolated",
"(",
"content",
",",
"{",
"ontext",
":",
"function",
"(",
"text",
")",
"{",
"concatText",
"(",
"text",
")",
";",
"}",
",",
"onexpression",
":",
"function",
"(",
"expr",
")",
"{",
"if",
"(",
"expr",
".",
"textOnly",
"||",
"(",
"config",
".",
"virtual",
"===",
"false",
")",
")",
"{",
"concatText",
"(",
"expr",
")",
";",
"}",
"else",
"{",
"nodes",
".",
"push",
"(",
"expr",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"// While we find more interpolated handlebars blocks",
"while",
"(",
"(",
"blockStubPos",
"=",
"text",
".",
"indexOf",
"(",
"_blockStub",
",",
"cursor",
")",
")",
">",
"-",
"1",
")",
"{",
"// Get pre-text",
"if",
"(",
"blockStubPos",
">",
"cursor",
")",
"{",
"concatInterpolatedContent",
"(",
"text",
".",
"substr",
"(",
"cursor",
",",
"blockStubPos",
"-",
"cursor",
")",
")",
";",
"}",
"// Add the block to the list of nodes",
"block",
"=",
"template",
".",
"blocks",
".",
"shift",
"(",
")",
";",
"if",
"(",
"config",
".",
"virtual",
"===",
"false",
")",
"{",
"block",
".",
"callback",
".",
"virtual",
"=",
"false",
";",
"concatText",
"(",
"block",
")",
";",
"}",
"else",
"{",
"nodes",
".",
"push",
"(",
"block",
")",
";",
"}",
"// Advance the cursor",
"cursor",
"=",
"blockStubPos",
"+",
"_blockStub",
".",
"length",
";",
"}",
"// Get post-text (or the only text)",
"if",
"(",
"cursor",
"<",
"text",
".",
"length",
")",
"{",
"concatInterpolatedContent",
"(",
"text",
".",
"substr",
"(",
"cursor",
")",
")",
";",
"}",
"// textOnly is for things like tagName and attribute values",
"return",
"nodes",
";",
"}"
]
| ontext helper for html parsing ensure that blocks are handled | [
"ontext",
"helper",
"for",
"html",
"parsing",
"ensure",
"that",
"blocks",
"are",
"handled"
]
| d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L132-L195 |
47,430 | jchook/virtual-dom-handlebars | lib/Template.js | concatText | function concatText(text) {
if ((nodes.length > 0) && nodes[nodes.length - 1].addText) {
nodes[nodes.length - 1].addText(text);
} else {
nodes.push(new VText(text, config));
}
} | javascript | function concatText(text) {
if ((nodes.length > 0) && nodes[nodes.length - 1].addText) {
nodes[nodes.length - 1].addText(text);
} else {
nodes.push(new VText(text, config));
}
} | [
"function",
"concatText",
"(",
"text",
")",
"{",
"if",
"(",
"(",
"nodes",
".",
"length",
">",
"0",
")",
"&&",
"nodes",
"[",
"nodes",
".",
"length",
"-",
"1",
"]",
".",
"addText",
")",
"{",
"nodes",
"[",
"nodes",
".",
"length",
"-",
"1",
"]",
".",
"addText",
"(",
"text",
")",
";",
"}",
"else",
"{",
"nodes",
".",
"push",
"(",
"new",
"VText",
"(",
"text",
",",
"config",
")",
")",
";",
"}",
"}"
]
| Ensures that consecutive textOnly components are merged into a single VText node | [
"Ensures",
"that",
"consecutive",
"textOnly",
"components",
"are",
"merged",
"into",
"a",
"single",
"VText",
"node"
]
| d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L143-L149 |
47,431 | jchook/virtual-dom-handlebars | lib/Template.js | attributesToJavascript | function attributesToJavascript(template, attr) {
var i, name, value, js = [];
for (i in attr) {
if (attr.hasOwnProperty(i)) {
// Translate
name = Template.HTML_ATTRIBUTES[i] ? Template.HTML_ATTRIBUTES[i] : i;
// Potentially interpolated attributes
if (typeof attr[i] === 'string') {
if (attr[i].length > 0) {
js.push(JSON.stringify(name) + ':' + (ontext(template, attr[i], {virtual: false}).pop() || new VText).toJavascript());
} else {
js.push(JSON.stringify(name) + ':""');
}
} else {
js.push(JSON.stringify(name) + ':' + JSON.stringify(attr[i]));
}
}
}
return '{' + js.join(',') + '}';
} | javascript | function attributesToJavascript(template, attr) {
var i, name, value, js = [];
for (i in attr) {
if (attr.hasOwnProperty(i)) {
// Translate
name = Template.HTML_ATTRIBUTES[i] ? Template.HTML_ATTRIBUTES[i] : i;
// Potentially interpolated attributes
if (typeof attr[i] === 'string') {
if (attr[i].length > 0) {
js.push(JSON.stringify(name) + ':' + (ontext(template, attr[i], {virtual: false}).pop() || new VText).toJavascript());
} else {
js.push(JSON.stringify(name) + ':""');
}
} else {
js.push(JSON.stringify(name) + ':' + JSON.stringify(attr[i]));
}
}
}
return '{' + js.join(',') + '}';
} | [
"function",
"attributesToJavascript",
"(",
"template",
",",
"attr",
")",
"{",
"var",
"i",
",",
"name",
",",
"value",
",",
"js",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"in",
"attr",
")",
"{",
"if",
"(",
"attr",
".",
"hasOwnProperty",
"(",
"i",
")",
")",
"{",
"// Translate",
"name",
"=",
"Template",
".",
"HTML_ATTRIBUTES",
"[",
"i",
"]",
"?",
"Template",
".",
"HTML_ATTRIBUTES",
"[",
"i",
"]",
":",
"i",
";",
"// Potentially interpolated attributes",
"if",
"(",
"typeof",
"attr",
"[",
"i",
"]",
"===",
"'string'",
")",
"{",
"if",
"(",
"attr",
"[",
"i",
"]",
".",
"length",
">",
"0",
")",
"{",
"js",
".",
"push",
"(",
"JSON",
".",
"stringify",
"(",
"name",
")",
"+",
"':'",
"+",
"(",
"ontext",
"(",
"template",
",",
"attr",
"[",
"i",
"]",
",",
"{",
"virtual",
":",
"false",
"}",
")",
".",
"pop",
"(",
")",
"||",
"new",
"VText",
")",
".",
"toJavascript",
"(",
")",
")",
";",
"}",
"else",
"{",
"js",
".",
"push",
"(",
"JSON",
".",
"stringify",
"(",
"name",
")",
"+",
"':\"\"'",
")",
";",
"}",
"}",
"else",
"{",
"js",
".",
"push",
"(",
"JSON",
".",
"stringify",
"(",
"name",
")",
"+",
"':'",
"+",
"JSON",
".",
"stringify",
"(",
"attr",
"[",
"i",
"]",
")",
")",
";",
"}",
"}",
"}",
"return",
"'{'",
"+",
"js",
".",
"join",
"(",
"','",
")",
"+",
"'}'",
";",
"}"
]
| Not particularly proud of this function.. obv it should probably be located in some kind of AttributeList class or something, but as it stands, the use of htmlparser2 requires a more 'aware' parser to do proper block parsing | [
"Not",
"particularly",
"proud",
"of",
"this",
"function",
"..",
"obv",
"it",
"should",
"probably",
"be",
"located",
"in",
"some",
"kind",
"of",
"AttributeList",
"class",
"or",
"something",
"but",
"as",
"it",
"stands",
"the",
"use",
"of",
"htmlparser2",
"requires",
"a",
"more",
"aware",
"parser",
"to",
"do",
"proper",
"block",
"parsing"
]
| d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/Template.js#L201-L223 |
47,432 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/link/dialogs/link.js | function()
{
var dialog = this.getDialog(),
popupFeatures = dialog.getContentElement( 'target', 'popupFeatures' ),
targetName = dialog.getContentElement( 'target', 'linkTargetName' ),
value = this.getValue();
if ( !popupFeatures || !targetName )
return;
popupFeatures = popupFeatures.getElement();
popupFeatures.hide();
targetName.setValue( '' );
switch ( value )
{
case 'frame' :
targetName.setLabel( editor.lang.link.targetFrameName );
targetName.getElement().show();
break;
case 'popup' :
popupFeatures.show();
targetName.setLabel( editor.lang.link.targetPopupName );
targetName.getElement().show();
break;
default :
targetName.setValue( value );
targetName.getElement().hide();
break;
}
} | javascript | function()
{
var dialog = this.getDialog(),
popupFeatures = dialog.getContentElement( 'target', 'popupFeatures' ),
targetName = dialog.getContentElement( 'target', 'linkTargetName' ),
value = this.getValue();
if ( !popupFeatures || !targetName )
return;
popupFeatures = popupFeatures.getElement();
popupFeatures.hide();
targetName.setValue( '' );
switch ( value )
{
case 'frame' :
targetName.setLabel( editor.lang.link.targetFrameName );
targetName.getElement().show();
break;
case 'popup' :
popupFeatures.show();
targetName.setLabel( editor.lang.link.targetPopupName );
targetName.getElement().show();
break;
default :
targetName.setValue( value );
targetName.getElement().hide();
break;
}
} | [
"function",
"(",
")",
"{",
"var",
"dialog",
"=",
"this",
".",
"getDialog",
"(",
")",
",",
"popupFeatures",
"=",
"dialog",
".",
"getContentElement",
"(",
"'target'",
",",
"'popupFeatures'",
")",
",",
"targetName",
"=",
"dialog",
".",
"getContentElement",
"(",
"'target'",
",",
"'linkTargetName'",
")",
",",
"value",
"=",
"this",
".",
"getValue",
"(",
")",
";",
"if",
"(",
"!",
"popupFeatures",
"||",
"!",
"targetName",
")",
"return",
";",
"popupFeatures",
"=",
"popupFeatures",
".",
"getElement",
"(",
")",
";",
"popupFeatures",
".",
"hide",
"(",
")",
";",
"targetName",
".",
"setValue",
"(",
"''",
")",
";",
"switch",
"(",
"value",
")",
"{",
"case",
"'frame'",
":",
"targetName",
".",
"setLabel",
"(",
"editor",
".",
"lang",
".",
"link",
".",
"targetFrameName",
")",
";",
"targetName",
".",
"getElement",
"(",
")",
".",
"show",
"(",
")",
";",
"break",
";",
"case",
"'popup'",
":",
"popupFeatures",
".",
"show",
"(",
")",
";",
"targetName",
".",
"setLabel",
"(",
"editor",
".",
"lang",
".",
"link",
".",
"targetPopupName",
")",
";",
"targetName",
".",
"getElement",
"(",
")",
".",
"show",
"(",
")",
";",
"break",
";",
"default",
":",
"targetName",
".",
"setValue",
"(",
"value",
")",
";",
"targetName",
".",
"getElement",
"(",
")",
".",
"hide",
"(",
")",
";",
"break",
";",
"}",
"}"
]
| Handles the event when the "Target" selection box is changed. | [
"Handles",
"the",
"event",
"when",
"the",
"Target",
"selection",
"box",
"is",
"changed",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/link/dialogs/link.js#L10-L41 |
|
47,433 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/link/dialogs/link.js | function()
{
var dialog = this.getDialog(),
partIds = [ 'urlOptions', 'anchorOptions', 'emailOptions' ],
typeValue = this.getValue(),
uploadTab = dialog.definition.getContents( 'upload' ),
uploadInitiallyHidden = uploadTab && uploadTab.hidden;
if ( typeValue == 'url' )
{
if ( editor.config.linkShowTargetTab )
dialog.showPage( 'target' );
if ( !uploadInitiallyHidden )
dialog.showPage( 'upload' );
}
else
{
dialog.hidePage( 'target' );
if ( !uploadInitiallyHidden )
dialog.hidePage( 'upload' );
}
for ( var i = 0 ; i < partIds.length ; i++ )
{
var element = dialog.getContentElement( 'info', partIds[i] );
if ( !element )
continue;
element = element.getElement().getParent().getParent();
if ( partIds[i] == typeValue + 'Options' )
element.show();
else
element.hide();
}
dialog.layout();
} | javascript | function()
{
var dialog = this.getDialog(),
partIds = [ 'urlOptions', 'anchorOptions', 'emailOptions' ],
typeValue = this.getValue(),
uploadTab = dialog.definition.getContents( 'upload' ),
uploadInitiallyHidden = uploadTab && uploadTab.hidden;
if ( typeValue == 'url' )
{
if ( editor.config.linkShowTargetTab )
dialog.showPage( 'target' );
if ( !uploadInitiallyHidden )
dialog.showPage( 'upload' );
}
else
{
dialog.hidePage( 'target' );
if ( !uploadInitiallyHidden )
dialog.hidePage( 'upload' );
}
for ( var i = 0 ; i < partIds.length ; i++ )
{
var element = dialog.getContentElement( 'info', partIds[i] );
if ( !element )
continue;
element = element.getElement().getParent().getParent();
if ( partIds[i] == typeValue + 'Options' )
element.show();
else
element.hide();
}
dialog.layout();
} | [
"function",
"(",
")",
"{",
"var",
"dialog",
"=",
"this",
".",
"getDialog",
"(",
")",
",",
"partIds",
"=",
"[",
"'urlOptions'",
",",
"'anchorOptions'",
",",
"'emailOptions'",
"]",
",",
"typeValue",
"=",
"this",
".",
"getValue",
"(",
")",
",",
"uploadTab",
"=",
"dialog",
".",
"definition",
".",
"getContents",
"(",
"'upload'",
")",
",",
"uploadInitiallyHidden",
"=",
"uploadTab",
"&&",
"uploadTab",
".",
"hidden",
";",
"if",
"(",
"typeValue",
"==",
"'url'",
")",
"{",
"if",
"(",
"editor",
".",
"config",
".",
"linkShowTargetTab",
")",
"dialog",
".",
"showPage",
"(",
"'target'",
")",
";",
"if",
"(",
"!",
"uploadInitiallyHidden",
")",
"dialog",
".",
"showPage",
"(",
"'upload'",
")",
";",
"}",
"else",
"{",
"dialog",
".",
"hidePage",
"(",
"'target'",
")",
";",
"if",
"(",
"!",
"uploadInitiallyHidden",
")",
"dialog",
".",
"hidePage",
"(",
"'upload'",
")",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"partIds",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"element",
"=",
"dialog",
".",
"getContentElement",
"(",
"'info'",
",",
"partIds",
"[",
"i",
"]",
")",
";",
"if",
"(",
"!",
"element",
")",
"continue",
";",
"element",
"=",
"element",
".",
"getElement",
"(",
")",
".",
"getParent",
"(",
")",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"partIds",
"[",
"i",
"]",
"==",
"typeValue",
"+",
"'Options'",
")",
"element",
".",
"show",
"(",
")",
";",
"else",
"element",
".",
"hide",
"(",
")",
";",
"}",
"dialog",
".",
"layout",
"(",
")",
";",
"}"
]
| Handles the event when the "Type" selection box is changed. | [
"Handles",
"the",
"event",
"when",
"the",
"Type",
"selection",
"box",
"is",
"changed",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/link/dialogs/link.js#L44-L80 |
|
47,434 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/link/dialogs/link.js | function()
{
var linkType = this.getContentElement( 'info', 'linkType' ),
urlField;
if ( linkType && linkType.getValue() == 'url' )
{
urlField = this.getContentElement( 'info', 'url' );
urlField.select();
}
} | javascript | function()
{
var linkType = this.getContentElement( 'info', 'linkType' ),
urlField;
if ( linkType && linkType.getValue() == 'url' )
{
urlField = this.getContentElement( 'info', 'url' );
urlField.select();
}
} | [
"function",
"(",
")",
"{",
"var",
"linkType",
"=",
"this",
".",
"getContentElement",
"(",
"'info'",
",",
"'linkType'",
")",
",",
"urlField",
";",
"if",
"(",
"linkType",
"&&",
"linkType",
".",
"getValue",
"(",
")",
"==",
"'url'",
")",
"{",
"urlField",
"=",
"this",
".",
"getContentElement",
"(",
"'info'",
",",
"'url'",
")",
";",
"urlField",
".",
"select",
"(",
")",
";",
"}",
"}"
]
| Inital focus on 'url' field if link is of type URL. | [
"Inital",
"focus",
"on",
"url",
"field",
"if",
"link",
"is",
"of",
"type",
"URL",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/link/dialogs/link.js#L1388-L1397 |
|
47,435 | mdreizin/webpack-config-stream | lib/failAfterStream.js | failAfterStream | function failAfterStream(options) {
if (!_.isObject(options)) {
options = {};
}
var files = [];
return through.obj(function(chunk, enc, cb) {
var stats = chunk[processStats.STATS_DATA_FIELD_NAME],
isStats = chunk[processStats.STATS_FLAG_FIELD_NAME],
filename = path.resolve(chunk.path);
if (isStats && !_.includes(files, filename)) {
var hasErrors = false,
hasWarnings = false;
if (options.errors === true) {
hasErrors = stats.hasErrors();
}
if (options.warnings === true) {
hasWarnings = stats.hasWarnings();
}
if (hasErrors || hasWarnings) {
files.push(filename);
}
}
cb(null, chunk);
}, function(cb) {
if (files.length > 0) {
var message = messageFor(files);
this.emit('error', wrapError(message, {
showProperties: false,
showStack: false
}));
}
cb();
});
} | javascript | function failAfterStream(options) {
if (!_.isObject(options)) {
options = {};
}
var files = [];
return through.obj(function(chunk, enc, cb) {
var stats = chunk[processStats.STATS_DATA_FIELD_NAME],
isStats = chunk[processStats.STATS_FLAG_FIELD_NAME],
filename = path.resolve(chunk.path);
if (isStats && !_.includes(files, filename)) {
var hasErrors = false,
hasWarnings = false;
if (options.errors === true) {
hasErrors = stats.hasErrors();
}
if (options.warnings === true) {
hasWarnings = stats.hasWarnings();
}
if (hasErrors || hasWarnings) {
files.push(filename);
}
}
cb(null, chunk);
}, function(cb) {
if (files.length > 0) {
var message = messageFor(files);
this.emit('error', wrapError(message, {
showProperties: false,
showStack: false
}));
}
cb();
});
} | [
"function",
"failAfterStream",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"var",
"files",
"=",
"[",
"]",
";",
"return",
"through",
".",
"obj",
"(",
"function",
"(",
"chunk",
",",
"enc",
",",
"cb",
")",
"{",
"var",
"stats",
"=",
"chunk",
"[",
"processStats",
".",
"STATS_DATA_FIELD_NAME",
"]",
",",
"isStats",
"=",
"chunk",
"[",
"processStats",
".",
"STATS_FLAG_FIELD_NAME",
"]",
",",
"filename",
"=",
"path",
".",
"resolve",
"(",
"chunk",
".",
"path",
")",
";",
"if",
"(",
"isStats",
"&&",
"!",
"_",
".",
"includes",
"(",
"files",
",",
"filename",
")",
")",
"{",
"var",
"hasErrors",
"=",
"false",
",",
"hasWarnings",
"=",
"false",
";",
"if",
"(",
"options",
".",
"errors",
"===",
"true",
")",
"{",
"hasErrors",
"=",
"stats",
".",
"hasErrors",
"(",
")",
";",
"}",
"if",
"(",
"options",
".",
"warnings",
"===",
"true",
")",
"{",
"hasWarnings",
"=",
"stats",
".",
"hasWarnings",
"(",
")",
";",
"}",
"if",
"(",
"hasErrors",
"||",
"hasWarnings",
")",
"{",
"files",
".",
"push",
"(",
"filename",
")",
";",
"}",
"}",
"cb",
"(",
"null",
",",
"chunk",
")",
";",
"}",
",",
"function",
"(",
"cb",
")",
"{",
"if",
"(",
"files",
".",
"length",
">",
"0",
")",
"{",
"var",
"message",
"=",
"messageFor",
"(",
"files",
")",
";",
"this",
".",
"emit",
"(",
"'error'",
",",
"wrapError",
"(",
"message",
",",
"{",
"showProperties",
":",
"false",
",",
"showStack",
":",
"false",
"}",
")",
")",
";",
"}",
"cb",
"(",
")",
";",
"}",
")",
";",
"}"
]
| Stops a task if some `stats` objects have some errors or warnings. Can be piped.
@function
@alias failAfterStream
@param {Object=} options - Options.
@param {Boolean} [options.errors=false] - Fails build if some `stats` objects have some errors.
@param {Boolean} [options.warnings=false] - Fails build if some `stats` objects have some warnings.
@returns {Stream} | [
"Stops",
"a",
"task",
"if",
"some",
"stats",
"objects",
"have",
"some",
"errors",
"or",
"warnings",
".",
"Can",
"be",
"piped",
"."
]
| f8424f97837a224bc07cc18a03ecf649d708e924 | https://github.com/mdreizin/webpack-config-stream/blob/f8424f97837a224bc07cc18a03ecf649d708e924/lib/failAfterStream.js#L40-L82 |
47,436 | campsi/campsi | lib/modules/sortCursor.js | getMongoSortArray | function getMongoSortArray (field, prefix) {
return (!field.startsWith('-'))
? [prefix + field, 1]
: [prefix + field.substr(1), -1];
} | javascript | function getMongoSortArray (field, prefix) {
return (!field.startsWith('-'))
? [prefix + field, 1]
: [prefix + field.substr(1), -1];
} | [
"function",
"getMongoSortArray",
"(",
"field",
",",
"prefix",
")",
"{",
"return",
"(",
"!",
"field",
".",
"startsWith",
"(",
"'-'",
")",
")",
"?",
"[",
"prefix",
"+",
"field",
",",
"1",
"]",
":",
"[",
"prefix",
"+",
"field",
".",
"substr",
"(",
"1",
")",
",",
"-",
"1",
"]",
";",
"}"
]
| flips sorting order if field begins with minus '-'
@param {String} field
@param {String} prefix
@returns {Array<Array>} | [
"flips",
"sorting",
"order",
"if",
"field",
"begins",
"with",
"minus",
"-"
]
| 65ff16d267ea7e60bbb9e8959e6805e009202d2c | https://github.com/campsi/campsi/blob/65ff16d267ea7e60bbb9e8959e6805e009202d2c/lib/modules/sortCursor.js#L7-L11 |
47,437 | elwayman02/ember-cli-opinionated | blueprints/ember-cli-opinionated/index.js | function () {
var packages = [
'ember-cli-autoprefixer',
'ember-cli-blanket',
'ember-cli-sass',
'ember-cpm',
'ember-feature-flags',
'ember-metrics',
'ember-moment',
'ember-responsive',
'ember-route-action-helper',
'ember-suave',
'ember-truth-helpers'
];
var updatePrompt = {
type: 'confirm',
name: 'answer',
choices: [
{ key: 'y', name: 'Yes', value: 'yes' },
{ key: 'n', name: 'No', value: 'no' }
]
};
var prompts = [
extend({ message: 'Would you like to enhance your ember-cli-opinionated setup?', packages: packages }, updatePrompt),
// extend({ message: 'Organizing Your App Into Pods', packages: ['ember-cli-sass-pods'] }, updatePrompt),
extend({ message: 'Analytics/Reports', packages: ['ember-e3'] }, updatePrompt),
extend({ message: 'Testing', packages: ['ember-cli-mirage', 'ember-sinon-qunit'] }, updatePrompt),
// extend({ message: 'Internationalization (i18n)', packages: ['ember-intl'] }, updatePrompt),
extend({ message: 'Mobile Touch', packages: ['ember-gestures'] }, updatePrompt),
extend({ message: 'Material Design', packages: ['ember-paper'] }, updatePrompt),
extend({ message: 'Animations', packages: ['liquid-fire'] }, updatePrompt)
];
return this.promptUserForOpinions(packages, prompts);
} | javascript | function () {
var packages = [
'ember-cli-autoprefixer',
'ember-cli-blanket',
'ember-cli-sass',
'ember-cpm',
'ember-feature-flags',
'ember-metrics',
'ember-moment',
'ember-responsive',
'ember-route-action-helper',
'ember-suave',
'ember-truth-helpers'
];
var updatePrompt = {
type: 'confirm',
name: 'answer',
choices: [
{ key: 'y', name: 'Yes', value: 'yes' },
{ key: 'n', name: 'No', value: 'no' }
]
};
var prompts = [
extend({ message: 'Would you like to enhance your ember-cli-opinionated setup?', packages: packages }, updatePrompt),
// extend({ message: 'Organizing Your App Into Pods', packages: ['ember-cli-sass-pods'] }, updatePrompt),
extend({ message: 'Analytics/Reports', packages: ['ember-e3'] }, updatePrompt),
extend({ message: 'Testing', packages: ['ember-cli-mirage', 'ember-sinon-qunit'] }, updatePrompt),
// extend({ message: 'Internationalization (i18n)', packages: ['ember-intl'] }, updatePrompt),
extend({ message: 'Mobile Touch', packages: ['ember-gestures'] }, updatePrompt),
extend({ message: 'Material Design', packages: ['ember-paper'] }, updatePrompt),
extend({ message: 'Animations', packages: ['liquid-fire'] }, updatePrompt)
];
return this.promptUserForOpinions(packages, prompts);
} | [
"function",
"(",
")",
"{",
"var",
"packages",
"=",
"[",
"'ember-cli-autoprefixer'",
",",
"'ember-cli-blanket'",
",",
"'ember-cli-sass'",
",",
"'ember-cpm'",
",",
"'ember-feature-flags'",
",",
"'ember-metrics'",
",",
"'ember-moment'",
",",
"'ember-responsive'",
",",
"'ember-route-action-helper'",
",",
"'ember-suave'",
",",
"'ember-truth-helpers'",
"]",
";",
"var",
"updatePrompt",
"=",
"{",
"type",
":",
"'confirm'",
",",
"name",
":",
"'answer'",
",",
"choices",
":",
"[",
"{",
"key",
":",
"'y'",
",",
"name",
":",
"'Yes'",
",",
"value",
":",
"'yes'",
"}",
",",
"{",
"key",
":",
"'n'",
",",
"name",
":",
"'No'",
",",
"value",
":",
"'no'",
"}",
"]",
"}",
";",
"var",
"prompts",
"=",
"[",
"extend",
"(",
"{",
"message",
":",
"'Would you like to enhance your ember-cli-opinionated setup?'",
",",
"packages",
":",
"packages",
"}",
",",
"updatePrompt",
")",
",",
"// extend({ message: 'Organizing Your App Into Pods', packages: ['ember-cli-sass-pods'] }, updatePrompt),",
"extend",
"(",
"{",
"message",
":",
"'Analytics/Reports'",
",",
"packages",
":",
"[",
"'ember-e3'",
"]",
"}",
",",
"updatePrompt",
")",
",",
"extend",
"(",
"{",
"message",
":",
"'Testing'",
",",
"packages",
":",
"[",
"'ember-cli-mirage'",
",",
"'ember-sinon-qunit'",
"]",
"}",
",",
"updatePrompt",
")",
",",
"// extend({ message: 'Internationalization (i18n)', packages: ['ember-intl'] }, updatePrompt),",
"extend",
"(",
"{",
"message",
":",
"'Mobile Touch'",
",",
"packages",
":",
"[",
"'ember-gestures'",
"]",
"}",
",",
"updatePrompt",
")",
",",
"extend",
"(",
"{",
"message",
":",
"'Material Design'",
",",
"packages",
":",
"[",
"'ember-paper'",
"]",
"}",
",",
"updatePrompt",
")",
",",
"extend",
"(",
"{",
"message",
":",
"'Animations'",
",",
"packages",
":",
"[",
"'liquid-fire'",
"]",
"}",
",",
"updatePrompt",
")",
"]",
";",
"return",
"this",
".",
"promptUserForOpinions",
"(",
"packages",
",",
"prompts",
")",
";",
"}"
]
| no-op since we're just adding dependencies | [
"no",
"-",
"op",
"since",
"we",
"re",
"just",
"adding",
"dependencies"
]
| ceb7d0c0fb56406c09009c372dc018e89842c32b | https://github.com/elwayman02/ember-cli-opinionated/blob/ceb7d0c0fb56406c09009c372dc018e89842c32b/blueprints/ember-cli-opinionated/index.js#L10-L46 |
|
47,438 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/elementpath.js | function( element )
{
var childNodes = element.getChildren();
for ( var i = 0, count = childNodes.count() ; i < count ; i++ )
{
var child = childNodes.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$block[ child.getName() ] )
return true;
}
return false;
} | javascript | function( element )
{
var childNodes = element.getChildren();
for ( var i = 0, count = childNodes.count() ; i < count ; i++ )
{
var child = childNodes.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$block[ child.getName() ] )
return true;
}
return false;
} | [
"function",
"(",
"element",
")",
"{",
"var",
"childNodes",
"=",
"element",
".",
"getChildren",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"count",
"=",
"childNodes",
".",
"count",
"(",
")",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"var",
"child",
"=",
"childNodes",
".",
"getItem",
"(",
"i",
")",
";",
"if",
"(",
"child",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_ELEMENT",
"&&",
"CKEDITOR",
".",
"dtd",
".",
"$block",
"[",
"child",
".",
"getName",
"(",
")",
"]",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Check if an element contains any block element. | [
"Check",
"if",
"an",
"element",
"contains",
"any",
"block",
"element",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/elementpath.js#L15-L28 |
|
47,439 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/elementpath.js | function( otherPath )
{
var thisElements = this.elements;
var otherElements = otherPath && otherPath.elements;
if ( !otherElements || thisElements.length != otherElements.length )
return false;
for ( var i = 0 ; i < thisElements.length ; i++ )
{
if ( !thisElements[ i ].equals( otherElements[ i ] ) )
return false;
}
return true;
} | javascript | function( otherPath )
{
var thisElements = this.elements;
var otherElements = otherPath && otherPath.elements;
if ( !otherElements || thisElements.length != otherElements.length )
return false;
for ( var i = 0 ; i < thisElements.length ; i++ )
{
if ( !thisElements[ i ].equals( otherElements[ i ] ) )
return false;
}
return true;
} | [
"function",
"(",
"otherPath",
")",
"{",
"var",
"thisElements",
"=",
"this",
".",
"elements",
";",
"var",
"otherElements",
"=",
"otherPath",
"&&",
"otherPath",
".",
"elements",
";",
"if",
"(",
"!",
"otherElements",
"||",
"thisElements",
".",
"length",
"!=",
"otherElements",
".",
"length",
")",
"return",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"thisElements",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"thisElements",
"[",
"i",
"]",
".",
"equals",
"(",
"otherElements",
"[",
"i",
"]",
")",
")",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Compares this element path with another one.
@param {CKEDITOR.dom.elementPath} otherPath The elementPath object to be
compared with this one.
@returns {Boolean} "true" if the paths are equal, containing the same
number of elements and the same elements in the same order. | [
"Compares",
"this",
"element",
"path",
"with",
"another",
"one",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/elementpath.js#L91-L106 |
|
47,440 | RohanDoshi2018/google_directions | index.js | validateInput | function validateInput(params, cb) {
if (typeof params !== 'object')
return new TypeError("params must be an object");
if (typeof cb !== 'function')
return new TypeError("callback must be a function");
if (params.origin === "")
return new Error("params.origin is required");
if (params.destination === "")
return new Error("params.destination is required");
if (params.key === "")
return new Error("params.key is required");
} | javascript | function validateInput(params, cb) {
if (typeof params !== 'object')
return new TypeError("params must be an object");
if (typeof cb !== 'function')
return new TypeError("callback must be a function");
if (params.origin === "")
return new Error("params.origin is required");
if (params.destination === "")
return new Error("params.destination is required");
if (params.key === "")
return new Error("params.key is required");
} | [
"function",
"validateInput",
"(",
"params",
",",
"cb",
")",
"{",
"if",
"(",
"typeof",
"params",
"!==",
"'object'",
")",
"return",
"new",
"TypeError",
"(",
"\"params must be an object\"",
")",
";",
"if",
"(",
"typeof",
"cb",
"!==",
"'function'",
")",
"return",
"new",
"TypeError",
"(",
"\"callback must be a function\"",
")",
";",
"if",
"(",
"params",
".",
"origin",
"===",
"\"\"",
")",
"return",
"new",
"Error",
"(",
"\"params.origin is required\"",
")",
";",
"if",
"(",
"params",
".",
"destination",
"===",
"\"\"",
")",
"return",
"new",
"Error",
"(",
"\"params.destination is required\"",
")",
";",
"if",
"(",
"params",
".",
"key",
"===",
"\"\"",
")",
"return",
"new",
"Error",
"(",
"\"params.key is required\"",
")",
";",
"}"
]
| validation of input | [
"validation",
"of",
"input"
]
| 9b0465604d65f26f385072adaf7fce18e1ed4037 | https://github.com/RohanDoshi2018/google_directions/blob/9b0465604d65f26f385072adaf7fce18e1ed4037/index.js#L10-L21 |
47,441 | jlewczyk/git-hooks-js-win | lib/cli.js | outputHelp | function outputHelp() {
console.log(
'\nUsage: git-hooks [options]\n\n' +
'A tool to manage project Git hooks\n\n' +
'Options:\n\n' +
Object.keys(options)
.map(function (key) {
return ' --' + key + '\t' + options[key] + '\n';
})
.join('')
);
} | javascript | function outputHelp() {
console.log(
'\nUsage: git-hooks [options]\n\n' +
'A tool to manage project Git hooks\n\n' +
'Options:\n\n' +
Object.keys(options)
.map(function (key) {
return ' --' + key + '\t' + options[key] + '\n';
})
.join('')
);
} | [
"function",
"outputHelp",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'\\nUsage: git-hooks [options]\\n\\n'",
"+",
"'A tool to manage project Git hooks\\n\\n'",
"+",
"'Options:\\n\\n'",
"+",
"Object",
".",
"keys",
"(",
"options",
")",
".",
"map",
"(",
"function",
"(",
"key",
")",
"{",
"return",
"' --'",
"+",
"key",
"+",
"'\\t'",
"+",
"options",
"[",
"key",
"]",
"+",
"'\\n'",
";",
"}",
")",
".",
"join",
"(",
"''",
")",
")",
";",
"}"
]
| Outputs the help to console. | [
"Outputs",
"the",
"help",
"to",
"console",
"."
]
| e156f88ad7aec76c9180c70656c5568ad89f9de7 | https://github.com/jlewczyk/git-hooks-js-win/blob/e156f88ad7aec76c9180c70656c5568ad89f9de7/lib/cli.js#L32-L43 |
47,442 | saggiyogesh/nodeportal | plugins/threadComments/ThreadCommentsController.js | function (err, m) {
if (m) {
model = m;
}
else {
err = new Error("Invalid linked model.");
}
n(err, m);
} | javascript | function (err, m) {
if (m) {
model = m;
}
else {
err = new Error("Invalid linked model.");
}
n(err, m);
} | [
"function",
"(",
"err",
",",
"m",
")",
"{",
"if",
"(",
"m",
")",
"{",
"model",
"=",
"m",
";",
"}",
"else",
"{",
"err",
"=",
"new",
"Error",
"(",
"\"Invalid linked model.\"",
")",
";",
"}",
"n",
"(",
"err",
",",
"m",
")",
";",
"}"
]
| find model obj | [
"find",
"model",
"obj"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/threadComments/ThreadCommentsController.js#L324-L332 |
|
47,443 | ebceu4/waves-crypto | src/libs/blake2b.js | normalizeInput | function normalizeInput(input) {
var ret;
if (input instanceof Uint8Array) {
ret = input;
}
else if (input instanceof Buffer) {
ret = new Uint8Array(input);
}
else if (typeof (input) === 'string') {
ret = new Uint8Array(Buffer.from(input, 'utf8'));
}
else {
throw new Error(ERROR_MSG_INPUT);
}
return ret;
} | javascript | function normalizeInput(input) {
var ret;
if (input instanceof Uint8Array) {
ret = input;
}
else if (input instanceof Buffer) {
ret = new Uint8Array(input);
}
else if (typeof (input) === 'string') {
ret = new Uint8Array(Buffer.from(input, 'utf8'));
}
else {
throw new Error(ERROR_MSG_INPUT);
}
return ret;
} | [
"function",
"normalizeInput",
"(",
"input",
")",
"{",
"var",
"ret",
";",
"if",
"(",
"input",
"instanceof",
"Uint8Array",
")",
"{",
"ret",
"=",
"input",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"Buffer",
")",
"{",
"ret",
"=",
"new",
"Uint8Array",
"(",
"input",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"(",
"input",
")",
"===",
"'string'",
")",
"{",
"ret",
"=",
"new",
"Uint8Array",
"(",
"Buffer",
".",
"from",
"(",
"input",
",",
"'utf8'",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"ERROR_MSG_INPUT",
")",
";",
"}",
"return",
"ret",
";",
"}"
]
| For convenience, let people hash a string, not just a Uint8Array | [
"For",
"convenience",
"let",
"people",
"hash",
"a",
"string",
"not",
"just",
"a",
"Uint8Array"
]
| 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L5-L20 |
47,444 | ebceu4/waves-crypto | src/libs/blake2b.js | B2B_GET32 | function B2B_GET32(arr, i) {
return (arr[i] ^
(arr[i + 1] << 8) ^
(arr[i + 2] << 16) ^
(arr[i + 3] << 24));
} | javascript | function B2B_GET32(arr, i) {
return (arr[i] ^
(arr[i + 1] << 8) ^
(arr[i + 2] << 16) ^
(arr[i + 3] << 24));
} | [
"function",
"B2B_GET32",
"(",
"arr",
",",
"i",
")",
"{",
"return",
"(",
"arr",
"[",
"i",
"]",
"^",
"(",
"arr",
"[",
"i",
"+",
"1",
"]",
"<<",
"8",
")",
"^",
"(",
"arr",
"[",
"i",
"+",
"2",
"]",
"<<",
"16",
")",
"^",
"(",
"arr",
"[",
"i",
"+",
"3",
"]",
"<<",
"24",
")",
")",
";",
"}"
]
| Little-endian byte access | [
"Little",
"-",
"endian",
"byte",
"access"
]
| 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L104-L109 |
47,445 | ebceu4/waves-crypto | src/libs/blake2b.js | B2B_G | function B2B_G(a, b, c, d, ix, iy) {
var x0 = m[ix];
var x1 = m[ix + 1];
var y0 = m[iy];
var y1 = m[iy + 1];
ADD64AA(v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s
ADD64AC(v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits
var xor0 = v[d] ^ v[a];
var xor1 = v[d + 1] ^ v[a + 1];
v[d] = xor1;
v[d + 1] = xor0;
ADD64AA(v, c, d);
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits
xor0 = v[b] ^ v[c];
xor1 = v[b + 1] ^ v[c + 1];
v[b] = (xor0 >>> 24) ^ (xor1 << 8);
v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);
ADD64AA(v, a, b);
ADD64AC(v, a, y0, y1);
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits
xor0 = v[d] ^ v[a];
xor1 = v[d + 1] ^ v[a + 1];
v[d] = (xor0 >>> 16) ^ (xor1 << 16);
v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);
ADD64AA(v, c, d);
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits
xor0 = v[b] ^ v[c];
xor1 = v[b + 1] ^ v[c + 1];
v[b] = (xor1 >>> 31) ^ (xor0 << 1);
v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);
} | javascript | function B2B_G(a, b, c, d, ix, iy) {
var x0 = m[ix];
var x1 = m[ix + 1];
var y0 = m[iy];
var y1 = m[iy + 1];
ADD64AA(v, a, b); // v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s
ADD64AC(v, a, x0, x1); // v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits
var xor0 = v[d] ^ v[a];
var xor1 = v[d + 1] ^ v[a + 1];
v[d] = xor1;
v[d + 1] = xor0;
ADD64AA(v, c, d);
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits
xor0 = v[b] ^ v[c];
xor1 = v[b + 1] ^ v[c + 1];
v[b] = (xor0 >>> 24) ^ (xor1 << 8);
v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);
ADD64AA(v, a, b);
ADD64AC(v, a, y0, y1);
// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits
xor0 = v[d] ^ v[a];
xor1 = v[d + 1] ^ v[a + 1];
v[d] = (xor0 >>> 16) ^ (xor1 << 16);
v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);
ADD64AA(v, c, d);
// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits
xor0 = v[b] ^ v[c];
xor1 = v[b + 1] ^ v[c + 1];
v[b] = (xor1 >>> 31) ^ (xor0 << 1);
v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);
} | [
"function",
"B2B_G",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"ix",
",",
"iy",
")",
"{",
"var",
"x0",
"=",
"m",
"[",
"ix",
"]",
";",
"var",
"x1",
"=",
"m",
"[",
"ix",
"+",
"1",
"]",
";",
"var",
"y0",
"=",
"m",
"[",
"iy",
"]",
";",
"var",
"y1",
"=",
"m",
"[",
"iy",
"+",
"1",
"]",
";",
"ADD64AA",
"(",
"v",
",",
"a",
",",
"b",
")",
";",
"// v[a,a+1] += v[b,b+1] ... in JS we must store a uint64 as two uint32s",
"ADD64AC",
"(",
"v",
",",
"a",
",",
"x0",
",",
"x1",
")",
";",
"// v[a, a+1] += x ... x0 is the low 32 bits of x, x1 is the high 32 bits",
"// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits",
"var",
"xor0",
"=",
"v",
"[",
"d",
"]",
"^",
"v",
"[",
"a",
"]",
";",
"var",
"xor1",
"=",
"v",
"[",
"d",
"+",
"1",
"]",
"^",
"v",
"[",
"a",
"+",
"1",
"]",
";",
"v",
"[",
"d",
"]",
"=",
"xor1",
";",
"v",
"[",
"d",
"+",
"1",
"]",
"=",
"xor0",
";",
"ADD64AA",
"(",
"v",
",",
"c",
",",
"d",
")",
";",
"// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits",
"xor0",
"=",
"v",
"[",
"b",
"]",
"^",
"v",
"[",
"c",
"]",
";",
"xor1",
"=",
"v",
"[",
"b",
"+",
"1",
"]",
"^",
"v",
"[",
"c",
"+",
"1",
"]",
";",
"v",
"[",
"b",
"]",
"=",
"(",
"xor0",
">>>",
"24",
")",
"^",
"(",
"xor1",
"<<",
"8",
")",
";",
"v",
"[",
"b",
"+",
"1",
"]",
"=",
"(",
"xor1",
">>>",
"24",
")",
"^",
"(",
"xor0",
"<<",
"8",
")",
";",
"ADD64AA",
"(",
"v",
",",
"a",
",",
"b",
")",
";",
"ADD64AC",
"(",
"v",
",",
"a",
",",
"y0",
",",
"y1",
")",
";",
"// v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits",
"xor0",
"=",
"v",
"[",
"d",
"]",
"^",
"v",
"[",
"a",
"]",
";",
"xor1",
"=",
"v",
"[",
"d",
"+",
"1",
"]",
"^",
"v",
"[",
"a",
"+",
"1",
"]",
";",
"v",
"[",
"d",
"]",
"=",
"(",
"xor0",
">>>",
"16",
")",
"^",
"(",
"xor1",
"<<",
"16",
")",
";",
"v",
"[",
"d",
"+",
"1",
"]",
"=",
"(",
"xor1",
">>>",
"16",
")",
"^",
"(",
"xor0",
"<<",
"16",
")",
";",
"ADD64AA",
"(",
"v",
",",
"c",
",",
"d",
")",
";",
"// v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits",
"xor0",
"=",
"v",
"[",
"b",
"]",
"^",
"v",
"[",
"c",
"]",
";",
"xor1",
"=",
"v",
"[",
"b",
"+",
"1",
"]",
"^",
"v",
"[",
"c",
"+",
"1",
"]",
";",
"v",
"[",
"b",
"]",
"=",
"(",
"xor1",
">>>",
"31",
")",
"^",
"(",
"xor0",
"<<",
"1",
")",
";",
"v",
"[",
"b",
"+",
"1",
"]",
"=",
"(",
"xor0",
">>>",
"31",
")",
"^",
"(",
"xor1",
"<<",
"1",
")",
";",
"}"
]
| G Mixing function The ROTRs are inlined for speed | [
"G",
"Mixing",
"function",
"The",
"ROTRs",
"are",
"inlined",
"for",
"speed"
]
| 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L112-L143 |
47,446 | ebceu4/waves-crypto | src/libs/blake2b.js | blake2bInit | function blake2bInit(outlen, key) {
if (outlen === 0 || outlen > 64) {
throw new Error('Illegal output length, expected 0 < length <= 64');
}
if (key && key.length > 64) {
throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64');
}
// state, 'param block'
var ctx = {
b: new Uint8Array(128),
h: new Uint32Array(16),
t: 0,
c: 0,
outlen: outlen // output length in bytes
};
// initialize hash state
for (var i = 0; i < 16; i++) {
ctx.h[i] = BLAKE2B_IV32[i];
}
var keylen = key ? key.length : 0;
ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen;
// key the hash, if applicable
if (key) {
blake2bUpdate(ctx, key);
// at the end
ctx.c = 128;
}
return ctx;
} | javascript | function blake2bInit(outlen, key) {
if (outlen === 0 || outlen > 64) {
throw new Error('Illegal output length, expected 0 < length <= 64');
}
if (key && key.length > 64) {
throw new Error('Illegal key, expected Uint8Array with 0 < length <= 64');
}
// state, 'param block'
var ctx = {
b: new Uint8Array(128),
h: new Uint32Array(16),
t: 0,
c: 0,
outlen: outlen // output length in bytes
};
// initialize hash state
for (var i = 0; i < 16; i++) {
ctx.h[i] = BLAKE2B_IV32[i];
}
var keylen = key ? key.length : 0;
ctx.h[0] ^= 0x01010000 ^ (keylen << 8) ^ outlen;
// key the hash, if applicable
if (key) {
blake2bUpdate(ctx, key);
// at the end
ctx.c = 128;
}
return ctx;
} | [
"function",
"blake2bInit",
"(",
"outlen",
",",
"key",
")",
"{",
"if",
"(",
"outlen",
"===",
"0",
"||",
"outlen",
">",
"64",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Illegal output length, expected 0 < length <= 64'",
")",
";",
"}",
"if",
"(",
"key",
"&&",
"key",
".",
"length",
">",
"64",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Illegal key, expected Uint8Array with 0 < length <= 64'",
")",
";",
"}",
"// state, 'param block'",
"var",
"ctx",
"=",
"{",
"b",
":",
"new",
"Uint8Array",
"(",
"128",
")",
",",
"h",
":",
"new",
"Uint32Array",
"(",
"16",
")",
",",
"t",
":",
"0",
",",
"c",
":",
"0",
",",
"outlen",
":",
"outlen",
"// output length in bytes",
"}",
";",
"// initialize hash state",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"16",
";",
"i",
"++",
")",
"{",
"ctx",
".",
"h",
"[",
"i",
"]",
"=",
"BLAKE2B_IV32",
"[",
"i",
"]",
";",
"}",
"var",
"keylen",
"=",
"key",
"?",
"key",
".",
"length",
":",
"0",
";",
"ctx",
".",
"h",
"[",
"0",
"]",
"^=",
"0x01010000",
"^",
"(",
"keylen",
"<<",
"8",
")",
"^",
"outlen",
";",
"// key the hash, if applicable",
"if",
"(",
"key",
")",
"{",
"blake2bUpdate",
"(",
"ctx",
",",
"key",
")",
";",
"// at the end",
"ctx",
".",
"c",
"=",
"128",
";",
"}",
"return",
"ctx",
";",
"}"
]
| Creates a BLAKE2b hashing context Requires an output length between 1 and 64 bytes Takes an optional Uint8Array key | [
"Creates",
"a",
"BLAKE2b",
"hashing",
"context",
"Requires",
"an",
"output",
"length",
"between",
"1",
"and",
"64",
"bytes",
"Takes",
"an",
"optional",
"Uint8Array",
"key"
]
| 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L219-L247 |
47,447 | ebceu4/waves-crypto | src/libs/blake2b.js | blake2bFinal | function blake2bFinal(ctx) {
ctx.t += ctx.c; // mark last block offset
while (ctx.c < 128) { // fill up with zeros
ctx.b[ctx.c++] = 0;
}
blake2bCompress(ctx, true); // final block flag = 1
// little endian convert and store
var out = new Uint8Array(ctx.outlen);
for (var i = 0; i < ctx.outlen; i++) {
out[i] = ctx.h[i >> 2] >> (8 * (i & 3));
}
return out;
} | javascript | function blake2bFinal(ctx) {
ctx.t += ctx.c; // mark last block offset
while (ctx.c < 128) { // fill up with zeros
ctx.b[ctx.c++] = 0;
}
blake2bCompress(ctx, true); // final block flag = 1
// little endian convert and store
var out = new Uint8Array(ctx.outlen);
for (var i = 0; i < ctx.outlen; i++) {
out[i] = ctx.h[i >> 2] >> (8 * (i & 3));
}
return out;
} | [
"function",
"blake2bFinal",
"(",
"ctx",
")",
"{",
"ctx",
".",
"t",
"+=",
"ctx",
".",
"c",
";",
"// mark last block offset",
"while",
"(",
"ctx",
".",
"c",
"<",
"128",
")",
"{",
"// fill up with zeros",
"ctx",
".",
"b",
"[",
"ctx",
".",
"c",
"++",
"]",
"=",
"0",
";",
"}",
"blake2bCompress",
"(",
"ctx",
",",
"true",
")",
";",
"// final block flag = 1",
"// little endian convert and store",
"var",
"out",
"=",
"new",
"Uint8Array",
"(",
"ctx",
".",
"outlen",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ctx",
".",
"outlen",
";",
"i",
"++",
")",
"{",
"out",
"[",
"i",
"]",
"=",
"ctx",
".",
"h",
"[",
"i",
">>",
"2",
"]",
">>",
"(",
"8",
"*",
"(",
"i",
"&",
"3",
")",
")",
";",
"}",
"return",
"out",
";",
"}"
]
| Completes a BLAKE2b streaming hash Returns a Uint8Array containing the message digest | [
"Completes",
"a",
"BLAKE2b",
"streaming",
"hash",
"Returns",
"a",
"Uint8Array",
"containing",
"the",
"message",
"digest"
]
| 76877f2df898505125eb55d45e00af194acd155f | https://github.com/ebceu4/waves-crypto/blob/76877f2df898505125eb55d45e00af194acd155f/src/libs/blake2b.js#L264-L276 |
47,448 | saggiyogesh/nodeportal | lib/static/ThemesWatcher.js | generateIdFromFilePath | function generateIdFromFilePath(filePath) {
var arr = filePath.split("/"), len = arr.length, last = arr[len - 1],
secondLast = arr[len - 2], thirdLast = arr[len - 3];
var isPluginFile = utils.contains(filePath, "/plugins/");
return isPluginFile ? thirdLast + "/" + last : thirdLast + "/" + secondLast + "/" + last;
} | javascript | function generateIdFromFilePath(filePath) {
var arr = filePath.split("/"), len = arr.length, last = arr[len - 1],
secondLast = arr[len - 2], thirdLast = arr[len - 3];
var isPluginFile = utils.contains(filePath, "/plugins/");
return isPluginFile ? thirdLast + "/" + last : thirdLast + "/" + secondLast + "/" + last;
} | [
"function",
"generateIdFromFilePath",
"(",
"filePath",
")",
"{",
"var",
"arr",
"=",
"filePath",
".",
"split",
"(",
"\"/\"",
")",
",",
"len",
"=",
"arr",
".",
"length",
",",
"last",
"=",
"arr",
"[",
"len",
"-",
"1",
"]",
",",
"secondLast",
"=",
"arr",
"[",
"len",
"-",
"2",
"]",
",",
"thirdLast",
"=",
"arr",
"[",
"len",
"-",
"3",
"]",
";",
"var",
"isPluginFile",
"=",
"utils",
".",
"contains",
"(",
"filePath",
",",
"\"/plugins/\"",
")",
";",
"return",
"isPluginFile",
"?",
"thirdLast",
"+",
"\"/\"",
"+",
"last",
":",
"thirdLast",
"+",
"\"/\"",
"+",
"secondLast",
"+",
"\"/\"",
"+",
"last",
";",
"}"
]
| Returns unique id depends on file location i.e. a theme file or a plugin file
@param filePath | [
"Returns",
"unique",
"id",
"depends",
"on",
"file",
"location",
"i",
".",
"e",
".",
"a",
"theme",
"file",
"or",
"a",
"plugin",
"file"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/static/ThemesWatcher.js#L13-L19 |
47,449 | saggiyogesh/nodeportal | lib/static/ThemesWatcher.js | initThemeFilesWatch | function initThemeFilesWatch(app) {
utils.tick(function () {
var viewsPath = utils.getViewsPath();
var dbAction = new DBActions.DBActions(app.set("db"), {modelName: "Theme"});
dbAction.get("getAll", null, function (err, themes) {
if (err) throw err;
themes.forEach(function (theme) {
cacheAndWatchTheme(app, theme);
});
})
});
} | javascript | function initThemeFilesWatch(app) {
utils.tick(function () {
var viewsPath = utils.getViewsPath();
var dbAction = new DBActions.DBActions(app.set("db"), {modelName: "Theme"});
dbAction.get("getAll", null, function (err, themes) {
if (err) throw err;
themes.forEach(function (theme) {
cacheAndWatchTheme(app, theme);
});
})
});
} | [
"function",
"initThemeFilesWatch",
"(",
"app",
")",
"{",
"utils",
".",
"tick",
"(",
"function",
"(",
")",
"{",
"var",
"viewsPath",
"=",
"utils",
".",
"getViewsPath",
"(",
")",
";",
"var",
"dbAction",
"=",
"new",
"DBActions",
".",
"DBActions",
"(",
"app",
".",
"set",
"(",
"\"db\"",
")",
",",
"{",
"modelName",
":",
"\"Theme\"",
"}",
")",
";",
"dbAction",
".",
"get",
"(",
"\"getAll\"",
",",
"null",
",",
"function",
"(",
"err",
",",
"themes",
")",
"{",
"if",
"(",
"err",
")",
"throw",
"err",
";",
"themes",
".",
"forEach",
"(",
"function",
"(",
"theme",
")",
"{",
"cacheAndWatchTheme",
"(",
"app",
",",
"theme",
")",
";",
"}",
")",
";",
"}",
")",
"}",
")",
";",
"}"
]
| Initiates file watcher and caching of theme's css and js files.
@param app | [
"Initiates",
"file",
"watcher",
"and",
"caching",
"of",
"theme",
"s",
"css",
"and",
"js",
"files",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/static/ThemesWatcher.js#L121-L132 |
47,450 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/tabletools/plugin.js | trimCell | function trimCell( cell )
{
var bogus = cell.getBogus();
bogus && bogus.remove();
cell.trim();
} | javascript | function trimCell( cell )
{
var bogus = cell.getBogus();
bogus && bogus.remove();
cell.trim();
} | [
"function",
"trimCell",
"(",
"cell",
")",
"{",
"var",
"bogus",
"=",
"cell",
".",
"getBogus",
"(",
")",
";",
"bogus",
"&&",
"bogus",
".",
"remove",
"(",
")",
";",
"cell",
".",
"trim",
"(",
")",
";",
"}"
]
| Remove filler at end and empty spaces around the cell content. | [
"Remove",
"filler",
"at",
"end",
"and",
"empty",
"spaces",
"around",
"the",
"cell",
"content",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/tabletools/plugin.js#L459-L464 |
47,451 | saggiyogesh/nodeportal | lib/DefaultDataHandler.js | getHandler | function getHandler(app, schema, data) {
function handleSave(err, results, next) {
if (!err) {
delete DependenciesMap[schema];
SavedSchemas.push(schema);
_l('schema saved: ' + schema);
}
next(err, results);
}
// Default handler function
var ret = function (next) {
data = _.isObject(data) ? _.values(data) : data;
DBActions.getSimpleInstance(app, schema).multipleSave(data, function (err, results) {
handleSave(err, results, next);
});
};
// Data handler provided in plugin
var ret1 = SchemaDataHandler[schema] && function (next) {
SchemaDataHandler[schema](app, data)(function (err, results) {
handleSave(err, results, next);
});
};
return ret1 || ret;
} | javascript | function getHandler(app, schema, data) {
function handleSave(err, results, next) {
if (!err) {
delete DependenciesMap[schema];
SavedSchemas.push(schema);
_l('schema saved: ' + schema);
}
next(err, results);
}
// Default handler function
var ret = function (next) {
data = _.isObject(data) ? _.values(data) : data;
DBActions.getSimpleInstance(app, schema).multipleSave(data, function (err, results) {
handleSave(err, results, next);
});
};
// Data handler provided in plugin
var ret1 = SchemaDataHandler[schema] && function (next) {
SchemaDataHandler[schema](app, data)(function (err, results) {
handleSave(err, results, next);
});
};
return ret1 || ret;
} | [
"function",
"getHandler",
"(",
"app",
",",
"schema",
",",
"data",
")",
"{",
"function",
"handleSave",
"(",
"err",
",",
"results",
",",
"next",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"delete",
"DependenciesMap",
"[",
"schema",
"]",
";",
"SavedSchemas",
".",
"push",
"(",
"schema",
")",
";",
"_l",
"(",
"'schema saved: '",
"+",
"schema",
")",
";",
"}",
"next",
"(",
"err",
",",
"results",
")",
";",
"}",
"// Default handler function",
"var",
"ret",
"=",
"function",
"(",
"next",
")",
"{",
"data",
"=",
"_",
".",
"isObject",
"(",
"data",
")",
"?",
"_",
".",
"values",
"(",
"data",
")",
":",
"data",
";",
"DBActions",
".",
"getSimpleInstance",
"(",
"app",
",",
"schema",
")",
".",
"multipleSave",
"(",
"data",
",",
"function",
"(",
"err",
",",
"results",
")",
"{",
"handleSave",
"(",
"err",
",",
"results",
",",
"next",
")",
";",
"}",
")",
";",
"}",
";",
"// Data handler provided in plugin",
"var",
"ret1",
"=",
"SchemaDataHandler",
"[",
"schema",
"]",
"&&",
"function",
"(",
"next",
")",
"{",
"SchemaDataHandler",
"[",
"schema",
"]",
"(",
"app",
",",
"data",
")",
"(",
"function",
"(",
"err",
",",
"results",
")",
"{",
"handleSave",
"(",
"err",
",",
"results",
",",
"next",
")",
";",
"}",
")",
";",
"}",
";",
"return",
"ret1",
"||",
"ret",
";",
"}"
]
| Returns data handler if provided with plugin otherwise return default handler function
@param app
@param schema {String} Schema name
@param data {Object|Array} default data
@returns {*|Function|Function} | [
"Returns",
"data",
"handler",
"if",
"provided",
"with",
"plugin",
"otherwise",
"return",
"default",
"handler",
"function"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L27-L52 |
47,452 | saggiyogesh/nodeportal | lib/DefaultDataHandler.js | function (next) {
data = _.isObject(data) ? _.values(data) : data;
DBActions.getSimpleInstance(app, schema).multipleSave(data, function (err, results) {
handleSave(err, results, next);
});
} | javascript | function (next) {
data = _.isObject(data) ? _.values(data) : data;
DBActions.getSimpleInstance(app, schema).multipleSave(data, function (err, results) {
handleSave(err, results, next);
});
} | [
"function",
"(",
"next",
")",
"{",
"data",
"=",
"_",
".",
"isObject",
"(",
"data",
")",
"?",
"_",
".",
"values",
"(",
"data",
")",
":",
"data",
";",
"DBActions",
".",
"getSimpleInstance",
"(",
"app",
",",
"schema",
")",
".",
"multipleSave",
"(",
"data",
",",
"function",
"(",
"err",
",",
"results",
")",
"{",
"handleSave",
"(",
"err",
",",
"results",
",",
"next",
")",
";",
"}",
")",
";",
"}"
]
| Default handler function | [
"Default",
"handler",
"function"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L38-L43 |
|
47,453 | saggiyogesh/nodeportal | lib/DefaultDataHandler.js | dependenciesExists | function dependenciesExists(schema) {
var deps = DependenciesMap[schema];
var f = false;
deps.forEach(function (d) {
f = SavedSchemas.indexOf(d) > -1
});
return f;
} | javascript | function dependenciesExists(schema) {
var deps = DependenciesMap[schema];
var f = false;
deps.forEach(function (d) {
f = SavedSchemas.indexOf(d) > -1
});
return f;
} | [
"function",
"dependenciesExists",
"(",
"schema",
")",
"{",
"var",
"deps",
"=",
"DependenciesMap",
"[",
"schema",
"]",
";",
"var",
"f",
"=",
"false",
";",
"deps",
".",
"forEach",
"(",
"function",
"(",
"d",
")",
"{",
"f",
"=",
"SavedSchemas",
".",
"indexOf",
"(",
"d",
")",
">",
"-",
"1",
"}",
")",
";",
"return",
"f",
";",
"}"
]
| Checks for required dependencies for the schema are saved.
@param schema {String} schema name
@returns {boolean} | [
"Checks",
"for",
"required",
"dependencies",
"for",
"the",
"schema",
"are",
"saved",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L60-L67 |
47,454 | saggiyogesh/nodeportal | lib/DefaultDataHandler.js | saveSchemas | function saveSchemas(app) {
var keys = Object.keys(DependenciesMap);
if (keys.length == 0) {
_l('Default data saved...');
event.emit(COMPLETED_EVENT);
return;
}
HandlerArray = [];
var errFlag = true;
keys.forEach(function (k) {
dependenciesExists(k) && HandlerArray.push(getHandler(app, k, PluginsData[k]));
});
async.series(HandlerArray, function (err, end) {
if (err)
throw err;
saveSchemas(app);
});
} | javascript | function saveSchemas(app) {
var keys = Object.keys(DependenciesMap);
if (keys.length == 0) {
_l('Default data saved...');
event.emit(COMPLETED_EVENT);
return;
}
HandlerArray = [];
var errFlag = true;
keys.forEach(function (k) {
dependenciesExists(k) && HandlerArray.push(getHandler(app, k, PluginsData[k]));
});
async.series(HandlerArray, function (err, end) {
if (err)
throw err;
saveSchemas(app);
});
} | [
"function",
"saveSchemas",
"(",
"app",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"DependenciesMap",
")",
";",
"if",
"(",
"keys",
".",
"length",
"==",
"0",
")",
"{",
"_l",
"(",
"'Default data saved...'",
")",
";",
"event",
".",
"emit",
"(",
"COMPLETED_EVENT",
")",
";",
"return",
";",
"}",
"HandlerArray",
"=",
"[",
"]",
";",
"var",
"errFlag",
"=",
"true",
";",
"keys",
".",
"forEach",
"(",
"function",
"(",
"k",
")",
"{",
"dependenciesExists",
"(",
"k",
")",
"&&",
"HandlerArray",
".",
"push",
"(",
"getHandler",
"(",
"app",
",",
"k",
",",
"PluginsData",
"[",
"k",
"]",
")",
")",
";",
"}",
")",
";",
"async",
".",
"series",
"(",
"HandlerArray",
",",
"function",
"(",
"err",
",",
"end",
")",
"{",
"if",
"(",
"err",
")",
"throw",
"err",
";",
"saveSchemas",
"(",
"app",
")",
";",
"}",
")",
";",
"}"
]
| Saves those schemas which depends on other collections data.
@param app | [
"Saves",
"those",
"schemas",
"which",
"depends",
"on",
"other",
"collections",
"data",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L74-L93 |
47,455 | saggiyogesh/nodeportal | lib/DefaultDataHandler.js | init | function init(app) {
var keys = Object.keys(DependenciesMap);
var allDeps = _.uniq(_.flatten(_.values(DependenciesMap)));
allDeps.forEach(function (d) {
if (!_.contains(keys, d)) {
throw new Error("Unresolved dependency: " + d)
}
});
keys.forEach(function (k) {
var dep = DependenciesMap[k];
if (_.contains(dep, k)) {
throw new Error('Circular dependency: key: ' + k);
}
if (dep.length == 0) {
HandlerArray.push(getHandler(app, k, PluginsData[k]));
}
});
async.series(HandlerArray, function (err, end) {
if (err)
throw err;
saveSchemas(app);
});
} | javascript | function init(app) {
var keys = Object.keys(DependenciesMap);
var allDeps = _.uniq(_.flatten(_.values(DependenciesMap)));
allDeps.forEach(function (d) {
if (!_.contains(keys, d)) {
throw new Error("Unresolved dependency: " + d)
}
});
keys.forEach(function (k) {
var dep = DependenciesMap[k];
if (_.contains(dep, k)) {
throw new Error('Circular dependency: key: ' + k);
}
if (dep.length == 0) {
HandlerArray.push(getHandler(app, k, PluginsData[k]));
}
});
async.series(HandlerArray, function (err, end) {
if (err)
throw err;
saveSchemas(app);
});
} | [
"function",
"init",
"(",
"app",
")",
"{",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"DependenciesMap",
")",
";",
"var",
"allDeps",
"=",
"_",
".",
"uniq",
"(",
"_",
".",
"flatten",
"(",
"_",
".",
"values",
"(",
"DependenciesMap",
")",
")",
")",
";",
"allDeps",
".",
"forEach",
"(",
"function",
"(",
"d",
")",
"{",
"if",
"(",
"!",
"_",
".",
"contains",
"(",
"keys",
",",
"d",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Unresolved dependency: \"",
"+",
"d",
")",
"}",
"}",
")",
";",
"keys",
".",
"forEach",
"(",
"function",
"(",
"k",
")",
"{",
"var",
"dep",
"=",
"DependenciesMap",
"[",
"k",
"]",
";",
"if",
"(",
"_",
".",
"contains",
"(",
"dep",
",",
"k",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Circular dependency: key: '",
"+",
"k",
")",
";",
"}",
"if",
"(",
"dep",
".",
"length",
"==",
"0",
")",
"{",
"HandlerArray",
".",
"push",
"(",
"getHandler",
"(",
"app",
",",
"k",
",",
"PluginsData",
"[",
"k",
"]",
")",
")",
";",
"}",
"}",
")",
";",
"async",
".",
"series",
"(",
"HandlerArray",
",",
"function",
"(",
"err",
",",
"end",
")",
"{",
"if",
"(",
"err",
")",
"throw",
"err",
";",
"saveSchemas",
"(",
"app",
")",
";",
"}",
")",
";",
"}"
]
| Start handling default data provided in plugins and save those collections which are not having dependencies.
@param app | [
"Start",
"handling",
"default",
"data",
"provided",
"in",
"plugins",
"and",
"save",
"those",
"collections",
"which",
"are",
"not",
"having",
"dependencies",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/lib/DefaultDataHandler.js#L99-L127 |
47,456 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( className )
{
var c = this.$.className;
if ( c )
{
var regex = new RegExp( '(?:^|\\s)' + className + '(?:\\s|$)', '' );
if ( !regex.test( c ) )
c += ' ' + className;
}
this.$.className = c || className;
} | javascript | function( className )
{
var c = this.$.className;
if ( c )
{
var regex = new RegExp( '(?:^|\\s)' + className + '(?:\\s|$)', '' );
if ( !regex.test( c ) )
c += ' ' + className;
}
this.$.className = c || className;
} | [
"function",
"(",
"className",
")",
"{",
"var",
"c",
"=",
"this",
".",
"$",
".",
"className",
";",
"if",
"(",
"c",
")",
"{",
"var",
"regex",
"=",
"new",
"RegExp",
"(",
"'(?:^|\\\\s)'",
"+",
"className",
"+",
"'(?:\\\\s|$)'",
",",
"''",
")",
";",
"if",
"(",
"!",
"regex",
".",
"test",
"(",
"c",
")",
")",
"c",
"+=",
"' '",
"+",
"className",
";",
"}",
"this",
".",
"$",
".",
"className",
"=",
"c",
"||",
"className",
";",
"}"
]
| Adds a CSS class to the element. It appends the class to the
already existing names.
@param {String} className The name of the class to be added.
@example
var element = new CKEDITOR.dom.element( 'div' );
element.addClass( 'classA' ); // <div class="classA">
element.addClass( 'classB' ); // <div class="classA classB">
element.addClass( 'classA' ); // <div class="classA classB"> | [
"Adds",
"a",
"CSS",
"class",
"to",
"the",
"element",
".",
"It",
"appends",
"the",
"class",
"to",
"the",
"already",
"existing",
"names",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L129-L139 |
|
47,457 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( className )
{
var c = this.getAttribute( 'class' );
if ( c )
{
var regex = new RegExp( '(?:^|\\s+)' + className + '(?=\\s|$)', 'i' );
if ( regex.test( c ) )
{
c = c.replace( regex, '' ).replace( /^\s+/, '' );
if ( c )
this.setAttribute( 'class', c );
else
this.removeAttribute( 'class' );
}
}
} | javascript | function( className )
{
var c = this.getAttribute( 'class' );
if ( c )
{
var regex = new RegExp( '(?:^|\\s+)' + className + '(?=\\s|$)', 'i' );
if ( regex.test( c ) )
{
c = c.replace( regex, '' ).replace( /^\s+/, '' );
if ( c )
this.setAttribute( 'class', c );
else
this.removeAttribute( 'class' );
}
}
} | [
"function",
"(",
"className",
")",
"{",
"var",
"c",
"=",
"this",
".",
"getAttribute",
"(",
"'class'",
")",
";",
"if",
"(",
"c",
")",
"{",
"var",
"regex",
"=",
"new",
"RegExp",
"(",
"'(?:^|\\\\s+)'",
"+",
"className",
"+",
"'(?=\\\\s|$)'",
",",
"'i'",
")",
";",
"if",
"(",
"regex",
".",
"test",
"(",
"c",
")",
")",
"{",
"c",
"=",
"c",
".",
"replace",
"(",
"regex",
",",
"''",
")",
".",
"replace",
"(",
"/",
"^\\s+",
"/",
",",
"''",
")",
";",
"if",
"(",
"c",
")",
"this",
".",
"setAttribute",
"(",
"'class'",
",",
"c",
")",
";",
"else",
"this",
".",
"removeAttribute",
"(",
"'class'",
")",
";",
"}",
"}",
"}"
]
| Removes a CSS class name from the elements classes. Other classes
remain untouched.
@param {String} className The name of the class to remove.
@example
var element = new CKEDITOR.dom.element( 'div' );
element.addClass( 'classA' ); // <div class="classA">
element.addClass( 'classB' ); // <div class="classA classB">
element.removeClass( 'classA' ); // <div class="classB">
element.removeClass( 'classB' ); // <div> | [
"Removes",
"a",
"CSS",
"class",
"name",
"from",
"the",
"elements",
"classes",
".",
"Other",
"classes",
"remain",
"untouched",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L152-L168 |
|
47,458 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( text )
{
CKEDITOR.dom.element.prototype.setText = ( this.$.innerText != undefined ) ?
function ( text )
{
return this.$.innerText = text;
} :
function ( text )
{
return this.$.textContent = text;
};
return this.setText( text );
} | javascript | function( text )
{
CKEDITOR.dom.element.prototype.setText = ( this.$.innerText != undefined ) ?
function ( text )
{
return this.$.innerText = text;
} :
function ( text )
{
return this.$.textContent = text;
};
return this.setText( text );
} | [
"function",
"(",
"text",
")",
"{",
"CKEDITOR",
".",
"dom",
".",
"element",
".",
"prototype",
".",
"setText",
"=",
"(",
"this",
".",
"$",
".",
"innerText",
"!=",
"undefined",
")",
"?",
"function",
"(",
"text",
")",
"{",
"return",
"this",
".",
"$",
".",
"innerText",
"=",
"text",
";",
"}",
":",
"function",
"(",
"text",
")",
"{",
"return",
"this",
".",
"$",
".",
"textContent",
"=",
"text",
";",
"}",
";",
"return",
"this",
".",
"setText",
"(",
"text",
")",
";",
"}"
]
| Sets the element contents as plain text.
@param {String} text The text to be set.
@returns {String} The inserted text.
@example
var element = new CKEDITOR.dom.element( 'div' );
element.setText( 'A > B & C < D' );
alert( element.innerHTML ); // "A &gt; B &amp; C &lt; D" | [
"Sets",
"the",
"element",
"contents",
"as",
"plain",
"text",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L391-L404 |
|
47,459 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( evaluator )
{
var first = this.$.firstChild,
retval = first && new CKEDITOR.dom.node( first );
if ( retval && evaluator && !evaluator( retval ) )
retval = retval.getNext( evaluator );
return retval;
} | javascript | function( evaluator )
{
var first = this.$.firstChild,
retval = first && new CKEDITOR.dom.node( first );
if ( retval && evaluator && !evaluator( retval ) )
retval = retval.getNext( evaluator );
return retval;
} | [
"function",
"(",
"evaluator",
")",
"{",
"var",
"first",
"=",
"this",
".",
"$",
".",
"firstChild",
",",
"retval",
"=",
"first",
"&&",
"new",
"CKEDITOR",
".",
"dom",
".",
"node",
"(",
"first",
")",
";",
"if",
"(",
"retval",
"&&",
"evaluator",
"&&",
"!",
"evaluator",
"(",
"retval",
")",
")",
"retval",
"=",
"retval",
".",
"getNext",
"(",
"evaluator",
")",
";",
"return",
"retval",
";",
"}"
]
| Gets the first child node of this element.
@param {Function} evaluator Filtering the result node.
@returns {CKEDITOR.dom.node} The first child node or null if not
available.
@example
var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b></div>' );
var first = <b>element.getFirst()</b>;
alert( first.getName() ); // "b" | [
"Gets",
"the",
"first",
"child",
"node",
"of",
"this",
"element",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L672-L680 |
|
47,460 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function()
{
var name = this.getName();
for ( var i = 0 ; i < arguments.length ; i++ )
{
if ( arguments[ i ] == name )
return true;
}
return false;
} | javascript | function()
{
var name = this.getName();
for ( var i = 0 ; i < arguments.length ; i++ )
{
if ( arguments[ i ] == name )
return true;
}
return false;
} | [
"function",
"(",
")",
"{",
"var",
"name",
"=",
"this",
".",
"getName",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arguments",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"arguments",
"[",
"i",
"]",
"==",
"name",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Checks if the element name matches one or more names.
@param {String} name[,name[,...]] One or more names to be checked.
@returns {Boolean} true if the element name matches any of the names.
@example
var element = new CKEDITOR.element( 'span' );
alert( <b>element.is( 'span' )</b> ); "true"
alert( <b>element.is( 'p', 'span' )</b> ); "true"
alert( <b>element.is( 'p' )</b> ); "false"
alert( <b>element.is( 'p', 'div' )</b> ); "false" | [
"Checks",
"if",
"the",
"element",
"name",
"matches",
"one",
"or",
"more",
"names",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L711-L720 |
|
47,461 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function()
{
var isVisible = ( this.$.offsetHeight || this.$.offsetWidth ) && this.getComputedStyle( 'visibility' ) != 'hidden',
elementWindow,
elementWindowFrame;
// Webkit and Opera report non-zero offsetHeight despite that
// element is inside an invisible iframe. (#4542)
if ( isVisible && ( CKEDITOR.env.webkit || CKEDITOR.env.opera ) )
{
elementWindow = this.getWindow();
if ( !elementWindow.equals( CKEDITOR.document.getWindow() )
&& ( elementWindowFrame = elementWindow.$.frameElement ) )
{
isVisible = new CKEDITOR.dom.element( elementWindowFrame ).isVisible();
}
}
return !!isVisible;
} | javascript | function()
{
var isVisible = ( this.$.offsetHeight || this.$.offsetWidth ) && this.getComputedStyle( 'visibility' ) != 'hidden',
elementWindow,
elementWindowFrame;
// Webkit and Opera report non-zero offsetHeight despite that
// element is inside an invisible iframe. (#4542)
if ( isVisible && ( CKEDITOR.env.webkit || CKEDITOR.env.opera ) )
{
elementWindow = this.getWindow();
if ( !elementWindow.equals( CKEDITOR.document.getWindow() )
&& ( elementWindowFrame = elementWindow.$.frameElement ) )
{
isVisible = new CKEDITOR.dom.element( elementWindowFrame ).isVisible();
}
}
return !!isVisible;
} | [
"function",
"(",
")",
"{",
"var",
"isVisible",
"=",
"(",
"this",
".",
"$",
".",
"offsetHeight",
"||",
"this",
".",
"$",
".",
"offsetWidth",
")",
"&&",
"this",
".",
"getComputedStyle",
"(",
"'visibility'",
")",
"!=",
"'hidden'",
",",
"elementWindow",
",",
"elementWindowFrame",
";",
"// Webkit and Opera report non-zero offsetHeight despite that\r",
"// element is inside an invisible iframe. (#4542)\r",
"if",
"(",
"isVisible",
"&&",
"(",
"CKEDITOR",
".",
"env",
".",
"webkit",
"||",
"CKEDITOR",
".",
"env",
".",
"opera",
")",
")",
"{",
"elementWindow",
"=",
"this",
".",
"getWindow",
"(",
")",
";",
"if",
"(",
"!",
"elementWindow",
".",
"equals",
"(",
"CKEDITOR",
".",
"document",
".",
"getWindow",
"(",
")",
")",
"&&",
"(",
"elementWindowFrame",
"=",
"elementWindow",
".",
"$",
".",
"frameElement",
")",
")",
"{",
"isVisible",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"element",
"(",
"elementWindowFrame",
")",
".",
"isVisible",
"(",
")",
";",
"}",
"}",
"return",
"!",
"!",
"isVisible",
";",
"}"
]
| Checks if this element is visible. May not work if the element is
child of an element with visibility set to "hidden", but works well
on the great majority of cases.
@return {Boolean} True if the element is visible. | [
"Checks",
"if",
"this",
"element",
"is",
"visible",
".",
"May",
"not",
"work",
"if",
"the",
"element",
"is",
"child",
"of",
"an",
"element",
"with",
"visibility",
"set",
"to",
"hidden",
"but",
"works",
"well",
"on",
"the",
"great",
"majority",
"of",
"cases",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L793-L813 |
|
47,462 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function()
{
if ( !CKEDITOR.dtd.$removeEmpty[ this.getName() ] )
return false;
var children = this.getChildren();
for ( var i = 0, count = children.count(); i < count; i++ )
{
var child = children.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && child.data( 'cke-bookmark' ) )
continue;
if ( child.type == CKEDITOR.NODE_ELEMENT && !child.isEmptyInlineRemoveable()
|| child.type == CKEDITOR.NODE_TEXT && CKEDITOR.tools.trim( child.getText() ) )
{
return false;
}
}
return true;
} | javascript | function()
{
if ( !CKEDITOR.dtd.$removeEmpty[ this.getName() ] )
return false;
var children = this.getChildren();
for ( var i = 0, count = children.count(); i < count; i++ )
{
var child = children.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && child.data( 'cke-bookmark' ) )
continue;
if ( child.type == CKEDITOR.NODE_ELEMENT && !child.isEmptyInlineRemoveable()
|| child.type == CKEDITOR.NODE_TEXT && CKEDITOR.tools.trim( child.getText() ) )
{
return false;
}
}
return true;
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"CKEDITOR",
".",
"dtd",
".",
"$removeEmpty",
"[",
"this",
".",
"getName",
"(",
")",
"]",
")",
"return",
"false",
";",
"var",
"children",
"=",
"this",
".",
"getChildren",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"count",
"=",
"children",
".",
"count",
"(",
")",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"var",
"child",
"=",
"children",
".",
"getItem",
"(",
"i",
")",
";",
"if",
"(",
"child",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_ELEMENT",
"&&",
"child",
".",
"data",
"(",
"'cke-bookmark'",
")",
")",
"continue",
";",
"if",
"(",
"child",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_ELEMENT",
"&&",
"!",
"child",
".",
"isEmptyInlineRemoveable",
"(",
")",
"||",
"child",
".",
"type",
"==",
"CKEDITOR",
".",
"NODE_TEXT",
"&&",
"CKEDITOR",
".",
"tools",
".",
"trim",
"(",
"child",
".",
"getText",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
]
| Whether it's an empty inline elements which has no visual impact when removed. | [
"Whether",
"it",
"s",
"an",
"empty",
"inline",
"elements",
"which",
"has",
"no",
"visual",
"impact",
"when",
"removed",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L818-L838 |
|
47,463 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( opacity )
{
if ( CKEDITOR.env.ie )
{
opacity = Math.round( opacity * 100 );
this.setStyle( 'filter', opacity >= 100 ? '' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')' );
}
else
this.setStyle( 'opacity', opacity );
} | javascript | function( opacity )
{
if ( CKEDITOR.env.ie )
{
opacity = Math.round( opacity * 100 );
this.setStyle( 'filter', opacity >= 100 ? '' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')' );
}
else
this.setStyle( 'opacity', opacity );
} | [
"function",
"(",
"opacity",
")",
"{",
"if",
"(",
"CKEDITOR",
".",
"env",
".",
"ie",
")",
"{",
"opacity",
"=",
"Math",
".",
"round",
"(",
"opacity",
"*",
"100",
")",
";",
"this",
".",
"setStyle",
"(",
"'filter'",
",",
"opacity",
">=",
"100",
"?",
"''",
":",
"'progid:DXImageTransform.Microsoft.Alpha(opacity='",
"+",
"opacity",
"+",
"')'",
")",
";",
"}",
"else",
"this",
".",
"setStyle",
"(",
"'opacity'",
",",
"opacity",
")",
";",
"}"
]
| Sets the opacity of an element.
@param {Number} opacity A number within the range [0.0, 1.0].
@example
var element = CKEDITOR.dom.element.getById( 'myElement' );
<b>element.setOpacity( 0.75 )</b>; | [
"Sets",
"the",
"opacity",
"of",
"an",
"element",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L1227-L1236 |
|
47,464 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function()
{
var $ = this.$;
try
{
// In IE, with custom document.domain, it may happen that
// the iframe is not yet available, resulting in "Access
// Denied" for the following property access.
$.contentWindow.document;
}
catch ( e )
{
// Trick to solve this issue, forcing the iframe to get ready
// by simply setting its "src" property.
$.src = $.src;
// In IE6 though, the above is not enough, so we must pause the
// execution for a while, giving it time to think.
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 7 )
{
window.showModalDialog(
'javascript:document.write("' +
'<script>' +
'window.setTimeout(' +
'function(){window.close();}' +
',50);' +
'</script>")' );
}
}
return $ && new CKEDITOR.dom.document( $.contentWindow.document );
} | javascript | function()
{
var $ = this.$;
try
{
// In IE, with custom document.domain, it may happen that
// the iframe is not yet available, resulting in "Access
// Denied" for the following property access.
$.contentWindow.document;
}
catch ( e )
{
// Trick to solve this issue, forcing the iframe to get ready
// by simply setting its "src" property.
$.src = $.src;
// In IE6 though, the above is not enough, so we must pause the
// execution for a while, giving it time to think.
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 7 )
{
window.showModalDialog(
'javascript:document.write("' +
'<script>' +
'window.setTimeout(' +
'function(){window.close();}' +
',50);' +
'</script>")' );
}
}
return $ && new CKEDITOR.dom.document( $.contentWindow.document );
} | [
"function",
"(",
")",
"{",
"var",
"$",
"=",
"this",
".",
"$",
";",
"try",
"{",
"// In IE, with custom document.domain, it may happen that\r",
"// the iframe is not yet available, resulting in \"Access\r",
"// Denied\" for the following property access.\r",
"$",
".",
"contentWindow",
".",
"document",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"// Trick to solve this issue, forcing the iframe to get ready\r",
"// by simply setting its \"src\" property.\r",
"$",
".",
"src",
"=",
"$",
".",
"src",
";",
"// In IE6 though, the above is not enough, so we must pause the\r",
"// execution for a while, giving it time to think.\r",
"if",
"(",
"CKEDITOR",
".",
"env",
".",
"ie",
"&&",
"CKEDITOR",
".",
"env",
".",
"version",
"<",
"7",
")",
"{",
"window",
".",
"showModalDialog",
"(",
"'javascript:document.write(\"'",
"+",
"'<script>'",
"+",
"'window.setTimeout('",
"+",
"'function(){window.close();}'",
"+",
"',50);'",
"+",
"'</script>\")'",
")",
";",
"}",
"}",
"return",
"$",
"&&",
"new",
"CKEDITOR",
".",
"dom",
".",
"document",
"(",
"$",
".",
"contentWindow",
".",
"document",
")",
";",
"}"
]
| Returns the inner document of this IFRAME element.
@returns {CKEDITOR.dom.document} The inner document. | [
"Returns",
"the",
"inner",
"document",
"of",
"this",
"IFRAME",
"element",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L1461-L1493 |
|
47,465 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( dest, skipAttributes )
{
var attributes = this.$.attributes;
skipAttributes = skipAttributes || {};
for ( var n = 0 ; n < attributes.length ; n++ )
{
var attribute = attributes[n];
// Lowercase attribute name hard rule is broken for
// some attribute on IE, e.g. CHECKED.
var attrName = attribute.nodeName.toLowerCase(),
attrValue;
// We can set the type only once, so do it with the proper value, not copying it.
if ( attrName in skipAttributes )
continue;
if ( attrName == 'checked' && ( attrValue = this.getAttribute( attrName ) ) )
dest.setAttribute( attrName, attrValue );
// IE BUG: value attribute is never specified even if it exists.
else if ( attribute.specified ||
( CKEDITOR.env.ie && attribute.nodeValue && attrName == 'value' ) )
{
attrValue = this.getAttribute( attrName );
if ( attrValue === null )
attrValue = attribute.nodeValue;
dest.setAttribute( attrName, attrValue );
}
}
// The style:
if ( this.$.style.cssText !== '' )
dest.$.style.cssText = this.$.style.cssText;
} | javascript | function( dest, skipAttributes )
{
var attributes = this.$.attributes;
skipAttributes = skipAttributes || {};
for ( var n = 0 ; n < attributes.length ; n++ )
{
var attribute = attributes[n];
// Lowercase attribute name hard rule is broken for
// some attribute on IE, e.g. CHECKED.
var attrName = attribute.nodeName.toLowerCase(),
attrValue;
// We can set the type only once, so do it with the proper value, not copying it.
if ( attrName in skipAttributes )
continue;
if ( attrName == 'checked' && ( attrValue = this.getAttribute( attrName ) ) )
dest.setAttribute( attrName, attrValue );
// IE BUG: value attribute is never specified even if it exists.
else if ( attribute.specified ||
( CKEDITOR.env.ie && attribute.nodeValue && attrName == 'value' ) )
{
attrValue = this.getAttribute( attrName );
if ( attrValue === null )
attrValue = attribute.nodeValue;
dest.setAttribute( attrName, attrValue );
}
}
// The style:
if ( this.$.style.cssText !== '' )
dest.$.style.cssText = this.$.style.cssText;
} | [
"function",
"(",
"dest",
",",
"skipAttributes",
")",
"{",
"var",
"attributes",
"=",
"this",
".",
"$",
".",
"attributes",
";",
"skipAttributes",
"=",
"skipAttributes",
"||",
"{",
"}",
";",
"for",
"(",
"var",
"n",
"=",
"0",
";",
"n",
"<",
"attributes",
".",
"length",
";",
"n",
"++",
")",
"{",
"var",
"attribute",
"=",
"attributes",
"[",
"n",
"]",
";",
"// Lowercase attribute name hard rule is broken for\r",
"// some attribute on IE, e.g. CHECKED.\r",
"var",
"attrName",
"=",
"attribute",
".",
"nodeName",
".",
"toLowerCase",
"(",
")",
",",
"attrValue",
";",
"// We can set the type only once, so do it with the proper value, not copying it.\r",
"if",
"(",
"attrName",
"in",
"skipAttributes",
")",
"continue",
";",
"if",
"(",
"attrName",
"==",
"'checked'",
"&&",
"(",
"attrValue",
"=",
"this",
".",
"getAttribute",
"(",
"attrName",
")",
")",
")",
"dest",
".",
"setAttribute",
"(",
"attrName",
",",
"attrValue",
")",
";",
"// IE BUG: value attribute is never specified even if it exists.\r",
"else",
"if",
"(",
"attribute",
".",
"specified",
"||",
"(",
"CKEDITOR",
".",
"env",
".",
"ie",
"&&",
"attribute",
".",
"nodeValue",
"&&",
"attrName",
"==",
"'value'",
")",
")",
"{",
"attrValue",
"=",
"this",
".",
"getAttribute",
"(",
"attrName",
")",
";",
"if",
"(",
"attrValue",
"===",
"null",
")",
"attrValue",
"=",
"attribute",
".",
"nodeValue",
";",
"dest",
".",
"setAttribute",
"(",
"attrName",
",",
"attrValue",
")",
";",
"}",
"}",
"// The style:\r",
"if",
"(",
"this",
".",
"$",
".",
"style",
".",
"cssText",
"!==",
"''",
")",
"dest",
".",
"$",
".",
"style",
".",
"cssText",
"=",
"this",
".",
"$",
".",
"style",
".",
"cssText",
";",
"}"
]
| Copy all the attributes from one node to the other, kinda like a clone
skipAttributes is an object with the attributes that must NOT be copied.
@param {CKEDITOR.dom.element} dest The destination element.
@param {Object} skipAttributes A dictionary of attributes to skip.
@example | [
"Copy",
"all",
"the",
"attributes",
"from",
"one",
"node",
"to",
"the",
"other",
"kinda",
"like",
"a",
"clone",
"skipAttributes",
"is",
"an",
"object",
"with",
"the",
"attributes",
"that",
"must",
"NOT",
"be",
"copied",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L1502-L1537 |
|
47,466 | saggiyogesh/nodeportal | public/ckeditor/_source/core/dom/element.js | function( newTag )
{
// If it's already correct exit here.
if ( this.getName() == newTag )
return;
var doc = this.getDocument();
// Create the new node.
var newNode = new CKEDITOR.dom.element( newTag, doc );
// Copy all attributes.
this.copyAttributes( newNode );
// Move children to the new node.
this.moveChildren( newNode );
// Replace the node.
this.getParent() && this.$.parentNode.replaceChild( newNode.$, this.$ );
newNode.$[ 'data-cke-expando' ] = this.$[ 'data-cke-expando' ];
this.$ = newNode.$;
} | javascript | function( newTag )
{
// If it's already correct exit here.
if ( this.getName() == newTag )
return;
var doc = this.getDocument();
// Create the new node.
var newNode = new CKEDITOR.dom.element( newTag, doc );
// Copy all attributes.
this.copyAttributes( newNode );
// Move children to the new node.
this.moveChildren( newNode );
// Replace the node.
this.getParent() && this.$.parentNode.replaceChild( newNode.$, this.$ );
newNode.$[ 'data-cke-expando' ] = this.$[ 'data-cke-expando' ];
this.$ = newNode.$;
} | [
"function",
"(",
"newTag",
")",
"{",
"// If it's already correct exit here.\r",
"if",
"(",
"this",
".",
"getName",
"(",
")",
"==",
"newTag",
")",
"return",
";",
"var",
"doc",
"=",
"this",
".",
"getDocument",
"(",
")",
";",
"// Create the new node.\r",
"var",
"newNode",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"element",
"(",
"newTag",
",",
"doc",
")",
";",
"// Copy all attributes.\r",
"this",
".",
"copyAttributes",
"(",
"newNode",
")",
";",
"// Move children to the new node.\r",
"this",
".",
"moveChildren",
"(",
"newNode",
")",
";",
"// Replace the node.\r",
"this",
".",
"getParent",
"(",
")",
"&&",
"this",
".",
"$",
".",
"parentNode",
".",
"replaceChild",
"(",
"newNode",
".",
"$",
",",
"this",
".",
"$",
")",
";",
"newNode",
".",
"$",
"[",
"'data-cke-expando'",
"]",
"=",
"this",
".",
"$",
"[",
"'data-cke-expando'",
"]",
";",
"this",
".",
"$",
"=",
"newNode",
".",
"$",
";",
"}"
]
| Changes the tag name of the current element.
@param {String} newTag The new tag for the element. | [
"Changes",
"the",
"tag",
"name",
"of",
"the",
"current",
"element",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/dom/element.js#L1543-L1564 |
|
47,467 | fvsch/gulp-task-maker | example/tasks/minjs/index.js | minjs | function minjs(config, tools) {
return tools.simpleStream(config, [
config.concat && concat(config.concat),
config.minify && uglify(config.uglifyjs)
])
} | javascript | function minjs(config, tools) {
return tools.simpleStream(config, [
config.concat && concat(config.concat),
config.minify && uglify(config.uglifyjs)
])
} | [
"function",
"minjs",
"(",
"config",
",",
"tools",
")",
"{",
"return",
"tools",
".",
"simpleStream",
"(",
"config",
",",
"[",
"config",
".",
"concat",
"&&",
"concat",
"(",
"config",
".",
"concat",
")",
",",
"config",
".",
"minify",
"&&",
"uglify",
"(",
"config",
".",
"uglifyjs",
")",
"]",
")",
"}"
]
| Make a simple JS build, optionally concatenated and minified
@param {object} config - task configuration
@param {object} tools - gtm utility functions
@return {object} | [
"Make",
"a",
"simple",
"JS",
"build",
"optionally",
"concatenated",
"and",
"minified"
]
| 20ab4245f2d75174786ad140793e9438c025d546 | https://github.com/fvsch/gulp-task-maker/blob/20ab4245f2d75174786ad140793e9438c025d546/example/tasks/minjs/index.js#L10-L15 |
47,468 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/docprops/dialogs/docprops.js | resetStyle | function resetStyle( element, prop, resetVal )
{
element.removeStyle( prop );
if ( element.getComputedStyle( prop ) != resetVal )
element.setStyle( prop, resetVal );
} | javascript | function resetStyle( element, prop, resetVal )
{
element.removeStyle( prop );
if ( element.getComputedStyle( prop ) != resetVal )
element.setStyle( prop, resetVal );
} | [
"function",
"resetStyle",
"(",
"element",
",",
"prop",
",",
"resetVal",
")",
"{",
"element",
".",
"removeStyle",
"(",
"prop",
")",
";",
"if",
"(",
"element",
".",
"getComputedStyle",
"(",
"prop",
")",
"!=",
"resetVal",
")",
"element",
".",
"setStyle",
"(",
"prop",
",",
"resetVal",
")",
";",
"}"
]
| We cannot just remove the style from the element, as it might be affected from non-inline stylesheets. To get the proper result, we should manually set the inline style to its default value. | [
"We",
"cannot",
"just",
"remove",
"the",
"style",
"from",
"the",
"element",
"as",
"it",
"might",
"be",
"affected",
"from",
"non",
"-",
"inline",
"stylesheets",
".",
"To",
"get",
"the",
"proper",
"result",
"we",
"should",
"manually",
"set",
"the",
"inline",
"style",
"to",
"its",
"default",
"value",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/docprops/dialogs/docprops.js#L132-L137 |
47,469 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/docprops/dialogs/docprops.js | function( id, label, fieldProps )
{
return {
type : 'hbox',
padding : 0,
widths : [ '60%', '40%' ],
children : [
CKEDITOR.tools.extend( {
type : 'text',
id : id,
label : lang[ label ]
}, fieldProps || {}, 1 ),
{
type : 'button',
id : id + 'Choose',
label : lang.chooseColor,
className : 'colorChooser',
onClick : function()
{
var self = this;
getDialogValue( 'colordialog', function( colorDialog )
{
var dialog = self.getDialog();
dialog.getContentElement( dialog._.currentTabId, id ).setValue( colorDialog.getContentElement( 'picker', 'selectedColor' ).getValue() );
});
}
}
]
};
} | javascript | function( id, label, fieldProps )
{
return {
type : 'hbox',
padding : 0,
widths : [ '60%', '40%' ],
children : [
CKEDITOR.tools.extend( {
type : 'text',
id : id,
label : lang[ label ]
}, fieldProps || {}, 1 ),
{
type : 'button',
id : id + 'Choose',
label : lang.chooseColor,
className : 'colorChooser',
onClick : function()
{
var self = this;
getDialogValue( 'colordialog', function( colorDialog )
{
var dialog = self.getDialog();
dialog.getContentElement( dialog._.currentTabId, id ).setValue( colorDialog.getContentElement( 'picker', 'selectedColor' ).getValue() );
});
}
}
]
};
} | [
"function",
"(",
"id",
",",
"label",
",",
"fieldProps",
")",
"{",
"return",
"{",
"type",
":",
"'hbox'",
",",
"padding",
":",
"0",
",",
"widths",
":",
"[",
"'60%'",
",",
"'40%'",
"]",
",",
"children",
":",
"[",
"CKEDITOR",
".",
"tools",
".",
"extend",
"(",
"{",
"type",
":",
"'text'",
",",
"id",
":",
"id",
",",
"label",
":",
"lang",
"[",
"label",
"]",
"}",
",",
"fieldProps",
"||",
"{",
"}",
",",
"1",
")",
",",
"{",
"type",
":",
"'button'",
",",
"id",
":",
"id",
"+",
"'Choose'",
",",
"label",
":",
"lang",
".",
"chooseColor",
",",
"className",
":",
"'colorChooser'",
",",
"onClick",
":",
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"getDialogValue",
"(",
"'colordialog'",
",",
"function",
"(",
"colorDialog",
")",
"{",
"var",
"dialog",
"=",
"self",
".",
"getDialog",
"(",
")",
";",
"dialog",
".",
"getContentElement",
"(",
"dialog",
".",
"_",
".",
"currentTabId",
",",
"id",
")",
".",
"setValue",
"(",
"colorDialog",
".",
"getContentElement",
"(",
"'picker'",
",",
"'selectedColor'",
")",
".",
"getValue",
"(",
")",
")",
";",
"}",
")",
";",
"}",
"}",
"]",
"}",
";",
"}"
]
| Utilty to shorten the creation of color fields in the dialog. | [
"Utilty",
"to",
"shorten",
"the",
"creation",
"of",
"color",
"fields",
"in",
"the",
"dialog",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/docprops/dialogs/docprops.js#L140-L169 |
|
47,470 | cblanquera/acquire | acquire.js | function(paths, callback, results, cached) {
results = results || [];
if(!paths.length) {
callback.apply(null, results);
return results;
}
var path = paths.shift();
//what do we do if it's not a string ?
if(typeof path !== 'string') {
results.push(null);
//um skip it?
loadArray(paths, callback, results, cached);
return;
}
acquire.loadPath(path, function(result) {
results.push(result);
loadArray(paths, callback, results, cached);
}, cached);
} | javascript | function(paths, callback, results, cached) {
results = results || [];
if(!paths.length) {
callback.apply(null, results);
return results;
}
var path = paths.shift();
//what do we do if it's not a string ?
if(typeof path !== 'string') {
results.push(null);
//um skip it?
loadArray(paths, callback, results, cached);
return;
}
acquire.loadPath(path, function(result) {
results.push(result);
loadArray(paths, callback, results, cached);
}, cached);
} | [
"function",
"(",
"paths",
",",
"callback",
",",
"results",
",",
"cached",
")",
"{",
"results",
"=",
"results",
"||",
"[",
"]",
";",
"if",
"(",
"!",
"paths",
".",
"length",
")",
"{",
"callback",
".",
"apply",
"(",
"null",
",",
"results",
")",
";",
"return",
"results",
";",
"}",
"var",
"path",
"=",
"paths",
".",
"shift",
"(",
")",
";",
"//what do we do if it's not a string ?",
"if",
"(",
"typeof",
"path",
"!==",
"'string'",
")",
"{",
"results",
".",
"push",
"(",
"null",
")",
";",
"//um skip it?",
"loadArray",
"(",
"paths",
",",
"callback",
",",
"results",
",",
"cached",
")",
";",
"return",
";",
"}",
"acquire",
".",
"loadPath",
"(",
"path",
",",
"function",
"(",
"result",
")",
"{",
"results",
".",
"push",
"(",
"result",
")",
";",
"loadArray",
"(",
"paths",
",",
"callback",
",",
"results",
",",
"cached",
")",
";",
"}",
",",
"cached",
")",
";",
"}"
]
| Loads files by the list
@param array
@param function
@param array current results
@param bool whether to use cache
@return void | [
"Loads",
"files",
"by",
"the",
"list"
]
| 2675484be1bf352b8ecbec37bb8eec6fed8b8b0d | https://github.com/cblanquera/acquire/blob/2675484be1bf352b8ecbec37bb8eec6fed8b8b0d/acquire.js#L377-L399 |
|
47,471 | cblanquera/acquire | acquire.js | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just add it
return queue[source].push(callback);
}
//otherwise there is not a queue
//so let's create one
queue[source] = [callback];
var script = document.createElement('script');
var head = document.getElementsByTagName('head')[0];
script.async = 1;
head.appendChild(script);
script.onload = script.onreadystatechange = function( _, isAbort ) {
if(isAbort || !script.readyState || /loaded|complete/.test(script.readyState) ) {
script.onload = script.onreadystatechange = null;
script = undefined;
if(!isAbort) {
queue[source].forEach(function(callback) {
callback();
});
delete queue[source];
}
}
};
script.src = source;
} | javascript | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just add it
return queue[source].push(callback);
}
//otherwise there is not a queue
//so let's create one
queue[source] = [callback];
var script = document.createElement('script');
var head = document.getElementsByTagName('head')[0];
script.async = 1;
head.appendChild(script);
script.onload = script.onreadystatechange = function( _, isAbort ) {
if(isAbort || !script.readyState || /loaded|complete/.test(script.readyState) ) {
script.onload = script.onreadystatechange = null;
script = undefined;
if(!isAbort) {
queue[source].forEach(function(callback) {
callback();
});
delete queue[source];
}
}
};
script.src = source;
} | [
"function",
"(",
"source",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"noop",
";",
"//if there's a queue",
"if",
"(",
"queue",
"[",
"source",
"]",
"instanceof",
"Array",
")",
"{",
"//just add it",
"return",
"queue",
"[",
"source",
"]",
".",
"push",
"(",
"callback",
")",
";",
"}",
"//otherwise there is not a queue",
"//so let's create one",
"queue",
"[",
"source",
"]",
"=",
"[",
"callback",
"]",
";",
"var",
"script",
"=",
"document",
".",
"createElement",
"(",
"'script'",
")",
";",
"var",
"head",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'head'",
")",
"[",
"0",
"]",
";",
"script",
".",
"async",
"=",
"1",
";",
"head",
".",
"appendChild",
"(",
"script",
")",
";",
"script",
".",
"onload",
"=",
"script",
".",
"onreadystatechange",
"=",
"function",
"(",
"_",
",",
"isAbort",
")",
"{",
"if",
"(",
"isAbort",
"||",
"!",
"script",
".",
"readyState",
"||",
"/",
"loaded|complete",
"/",
".",
"test",
"(",
"script",
".",
"readyState",
")",
")",
"{",
"script",
".",
"onload",
"=",
"script",
".",
"onreadystatechange",
"=",
"null",
";",
"script",
"=",
"undefined",
";",
"if",
"(",
"!",
"isAbort",
")",
"{",
"queue",
"[",
"source",
"]",
".",
"forEach",
"(",
"function",
"(",
"callback",
")",
"{",
"callback",
"(",
")",
";",
"}",
")",
";",
"delete",
"queue",
"[",
"source",
"]",
";",
"}",
"}",
"}",
";",
"script",
".",
"src",
"=",
"source",
";",
"}"
]
| Gets a script remotely, runs it
and caches it.
@param string
@param function
@return void | [
"Gets",
"a",
"script",
"remotely",
"runs",
"it",
"and",
"caches",
"it",
"."
]
| 2675484be1bf352b8ecbec37bb8eec6fed8b8b0d | https://github.com/cblanquera/acquire/blob/2675484be1bf352b8ecbec37bb8eec6fed8b8b0d/acquire.js#L409-L445 |
|
47,472 | cblanquera/acquire | acquire.js | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just call the callback
return callback();
}
//otherwise there is not a queue
//so let's create one
queue[source] = [];
var style = document.createElement('link');
var head = document.getElementsByTagName('head')[0];
style.type = 'text/css';
style.rel = 'stylesheet';
style.href = source;
head.appendChild(style);
callback();
} | javascript | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just call the callback
return callback();
}
//otherwise there is not a queue
//so let's create one
queue[source] = [];
var style = document.createElement('link');
var head = document.getElementsByTagName('head')[0];
style.type = 'text/css';
style.rel = 'stylesheet';
style.href = source;
head.appendChild(style);
callback();
} | [
"function",
"(",
"source",
",",
"callback",
")",
"{",
"callback",
"=",
"callback",
"||",
"noop",
";",
"//if there's a queue",
"if",
"(",
"queue",
"[",
"source",
"]",
"instanceof",
"Array",
")",
"{",
"//just call the callback",
"return",
"callback",
"(",
")",
";",
"}",
"//otherwise there is not a queue",
"//so let's create one",
"queue",
"[",
"source",
"]",
"=",
"[",
"]",
";",
"var",
"style",
"=",
"document",
".",
"createElement",
"(",
"'link'",
")",
";",
"var",
"head",
"=",
"document",
".",
"getElementsByTagName",
"(",
"'head'",
")",
"[",
"0",
"]",
";",
"style",
".",
"type",
"=",
"'text/css'",
";",
"style",
".",
"rel",
"=",
"'stylesheet'",
";",
"style",
".",
"href",
"=",
"source",
";",
"head",
".",
"appendChild",
"(",
"style",
")",
";",
"callback",
"(",
")",
";",
"}"
]
| Gets a style remotely
and caches it.
@param string
@param function
@return void | [
"Gets",
"a",
"style",
"remotely",
"and",
"caches",
"it",
"."
]
| 2675484be1bf352b8ecbec37bb8eec6fed8b8b0d | https://github.com/cblanquera/acquire/blob/2675484be1bf352b8ecbec37bb8eec6fed8b8b0d/acquire.js#L455-L477 |
|
47,473 | cblanquera/acquire | acquire.js | function(url, success, fail) {
success = success || noop;
fail = fail || noop;
//if there's a queue
if (queue[url] instanceof Array) {
//just add it
return queue[url].push({
success: success,
fail: fail
});
}
//otherwise there is not a queue
//so let's create one
queue[url] = [{
success: success,
fail: fail
}];
var xhr;
if(typeof XMLHttpRequest !== 'undefined') {
xhr = new XMLHttpRequest();
} else {
var versions = [
'MSXML2.XmlHttp.5.0',
'MSXML2.XmlHttp.4.0',
'MSXML2.XmlHttp.3.0',
'MSXML2.XmlHttp.2.0',
'Microsoft.XmlHttp'];
for(var i = 0; i < versions.length; i++) {
try {
xhr = new ActiveXObject(versions[i]);
break;
}
catch(e){}
}
}
if(!xhr) {
//fail the queue
queue[url].forEach(function(callback) {
callback.fail(null);
});
delete queue[url];
return;
}
var process = function() {
if(xhr.readyState < 4) {
return;
}
if(xhr.status >= 404 && xhr.status < 600) {
//fail the queue
queue[url].forEach(function(callback) {
callback.fail(xhr);
});
delete queue[url];
return;
}
if(xhr.status !== 200) {
return;
}
// all is well
if(xhr.readyState === 4) {
var response = xhr.responseText;
try {
response = JSON.parse(response);
} catch(e) {}
//fail the queue
queue[url].forEach(function(callback) {
callback.success(response, xhr);
});
delete queue[url];
}
};
xhr.onreadystatechange = process;
xhr.open('GET', url, true);
xhr.send('');
} | javascript | function(url, success, fail) {
success = success || noop;
fail = fail || noop;
//if there's a queue
if (queue[url] instanceof Array) {
//just add it
return queue[url].push({
success: success,
fail: fail
});
}
//otherwise there is not a queue
//so let's create one
queue[url] = [{
success: success,
fail: fail
}];
var xhr;
if(typeof XMLHttpRequest !== 'undefined') {
xhr = new XMLHttpRequest();
} else {
var versions = [
'MSXML2.XmlHttp.5.0',
'MSXML2.XmlHttp.4.0',
'MSXML2.XmlHttp.3.0',
'MSXML2.XmlHttp.2.0',
'Microsoft.XmlHttp'];
for(var i = 0; i < versions.length; i++) {
try {
xhr = new ActiveXObject(versions[i]);
break;
}
catch(e){}
}
}
if(!xhr) {
//fail the queue
queue[url].forEach(function(callback) {
callback.fail(null);
});
delete queue[url];
return;
}
var process = function() {
if(xhr.readyState < 4) {
return;
}
if(xhr.status >= 404 && xhr.status < 600) {
//fail the queue
queue[url].forEach(function(callback) {
callback.fail(xhr);
});
delete queue[url];
return;
}
if(xhr.status !== 200) {
return;
}
// all is well
if(xhr.readyState === 4) {
var response = xhr.responseText;
try {
response = JSON.parse(response);
} catch(e) {}
//fail the queue
queue[url].forEach(function(callback) {
callback.success(response, xhr);
});
delete queue[url];
}
};
xhr.onreadystatechange = process;
xhr.open('GET', url, true);
xhr.send('');
} | [
"function",
"(",
"url",
",",
"success",
",",
"fail",
")",
"{",
"success",
"=",
"success",
"||",
"noop",
";",
"fail",
"=",
"fail",
"||",
"noop",
";",
"//if there's a queue",
"if",
"(",
"queue",
"[",
"url",
"]",
"instanceof",
"Array",
")",
"{",
"//just add it",
"return",
"queue",
"[",
"url",
"]",
".",
"push",
"(",
"{",
"success",
":",
"success",
",",
"fail",
":",
"fail",
"}",
")",
";",
"}",
"//otherwise there is not a queue",
"//so let's create one",
"queue",
"[",
"url",
"]",
"=",
"[",
"{",
"success",
":",
"success",
",",
"fail",
":",
"fail",
"}",
"]",
";",
"var",
"xhr",
";",
"if",
"(",
"typeof",
"XMLHttpRequest",
"!==",
"'undefined'",
")",
"{",
"xhr",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"}",
"else",
"{",
"var",
"versions",
"=",
"[",
"'MSXML2.XmlHttp.5.0'",
",",
"'MSXML2.XmlHttp.4.0'",
",",
"'MSXML2.XmlHttp.3.0'",
",",
"'MSXML2.XmlHttp.2.0'",
",",
"'Microsoft.XmlHttp'",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"versions",
".",
"length",
";",
"i",
"++",
")",
"{",
"try",
"{",
"xhr",
"=",
"new",
"ActiveXObject",
"(",
"versions",
"[",
"i",
"]",
")",
";",
"break",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"}",
"}",
"if",
"(",
"!",
"xhr",
")",
"{",
"//fail the queue",
"queue",
"[",
"url",
"]",
".",
"forEach",
"(",
"function",
"(",
"callback",
")",
"{",
"callback",
".",
"fail",
"(",
"null",
")",
";",
"}",
")",
";",
"delete",
"queue",
"[",
"url",
"]",
";",
"return",
";",
"}",
"var",
"process",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"xhr",
".",
"readyState",
"<",
"4",
")",
"{",
"return",
";",
"}",
"if",
"(",
"xhr",
".",
"status",
">=",
"404",
"&&",
"xhr",
".",
"status",
"<",
"600",
")",
"{",
"//fail the queue",
"queue",
"[",
"url",
"]",
".",
"forEach",
"(",
"function",
"(",
"callback",
")",
"{",
"callback",
".",
"fail",
"(",
"xhr",
")",
";",
"}",
")",
";",
"delete",
"queue",
"[",
"url",
"]",
";",
"return",
";",
"}",
"if",
"(",
"xhr",
".",
"status",
"!==",
"200",
")",
"{",
"return",
";",
"}",
"// all is well",
"if",
"(",
"xhr",
".",
"readyState",
"===",
"4",
")",
"{",
"var",
"response",
"=",
"xhr",
".",
"responseText",
";",
"try",
"{",
"response",
"=",
"JSON",
".",
"parse",
"(",
"response",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"}",
"//fail the queue",
"queue",
"[",
"url",
"]",
".",
"forEach",
"(",
"function",
"(",
"callback",
")",
"{",
"callback",
".",
"success",
"(",
"response",
",",
"xhr",
")",
";",
"}",
")",
";",
"delete",
"queue",
"[",
"url",
"]",
";",
"}",
"}",
";",
"xhr",
".",
"onreadystatechange",
"=",
"process",
";",
"xhr",
".",
"open",
"(",
"'GET'",
",",
"url",
",",
"true",
")",
";",
"xhr",
".",
"send",
"(",
"''",
")",
";",
"}"
]
| Gets a file remotely
and caches it.
@param string
@param function success callback
@param function fail callback
@return void | [
"Gets",
"a",
"file",
"remotely",
"and",
"caches",
"it",
"."
]
| 2675484be1bf352b8ecbec37bb8eec6fed8b8b0d | https://github.com/cblanquera/acquire/blob/2675484be1bf352b8ecbec37bb8eec6fed8b8b0d/acquire.js#L488-L578 |
|
47,474 | esha/Eventi | dist/eventi.js | function(type, event, handler) {
_.parsers.forEach(function(parser) {
type = type.replace(parser[0], function() {
var args = _.slice(arguments, 1);
args.unshift(event, handler);
return parser[1].apply(event, args) || '';
});
});
return type ? event.type = type : type;
} | javascript | function(type, event, handler) {
_.parsers.forEach(function(parser) {
type = type.replace(parser[0], function() {
var args = _.slice(arguments, 1);
args.unshift(event, handler);
return parser[1].apply(event, args) || '';
});
});
return type ? event.type = type : type;
} | [
"function",
"(",
"type",
",",
"event",
",",
"handler",
")",
"{",
"_",
".",
"parsers",
".",
"forEach",
"(",
"function",
"(",
"parser",
")",
"{",
"type",
"=",
"type",
".",
"replace",
"(",
"parser",
"[",
"0",
"]",
",",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"_",
".",
"slice",
"(",
"arguments",
",",
"1",
")",
";",
"args",
".",
"unshift",
"(",
"event",
",",
"handler",
")",
";",
"return",
"parser",
"[",
"1",
"]",
".",
"apply",
"(",
"event",
",",
"args",
")",
"||",
"''",
";",
"}",
")",
";",
"}",
")",
";",
"return",
"type",
"?",
"event",
".",
"type",
"=",
"type",
":",
"type",
";",
"}"
]
| only an extension hook | [
"only",
"an",
"extension",
"hook"
]
| 2a5cf530ee7f69c6a53426d38b129b6d0e2c45dd | https://github.com/esha/Eventi/blob/2a5cf530ee7f69c6a53426d38b129b6d0e2c45dd/dist/eventi.js#L74-L83 |
|
47,475 | Testlio/lambda-foundation | lib/error/index.js | report | function report(error, additionalTags, extra) {
let sentTags = tags ? [].concat(tags) : [];
if (additionalTags) {
sentTags = sentTags.concat(additionalTags);
}
return Promise.resolve(sentTags).then(function(t) {
// Need this wrapping so that our internal implementation can safely throw errors
return new Promise(function(resolve) {
const sentError = error.nativeError ? error.nativeError : error;
Raygun.send(sentError, _.merge(extra || {}, error.extra), function(res) {
// No response === stubbed Raygun
if (res) {
if (res.statusCode !== 202) {
console.log('Failed to report error to Raygun', res); //eslint-disable-line no-console
} else {
console.log('Reported error to Raygun', error); //eslint-disable-line no-console
}
}
// Resolve with the error, so that our caller can finish deal
// with it further
resolve(error);
}, error.request, t);
});
}).catch(function(err) {
// Return the same error that we were supposed to report
// and simply log out the error that actually occurred during reporting
console.error(err); //eslint-disable-line no-console
return error;
});
} | javascript | function report(error, additionalTags, extra) {
let sentTags = tags ? [].concat(tags) : [];
if (additionalTags) {
sentTags = sentTags.concat(additionalTags);
}
return Promise.resolve(sentTags).then(function(t) {
// Need this wrapping so that our internal implementation can safely throw errors
return new Promise(function(resolve) {
const sentError = error.nativeError ? error.nativeError : error;
Raygun.send(sentError, _.merge(extra || {}, error.extra), function(res) {
// No response === stubbed Raygun
if (res) {
if (res.statusCode !== 202) {
console.log('Failed to report error to Raygun', res); //eslint-disable-line no-console
} else {
console.log('Reported error to Raygun', error); //eslint-disable-line no-console
}
}
// Resolve with the error, so that our caller can finish deal
// with it further
resolve(error);
}, error.request, t);
});
}).catch(function(err) {
// Return the same error that we were supposed to report
// and simply log out the error that actually occurred during reporting
console.error(err); //eslint-disable-line no-console
return error;
});
} | [
"function",
"report",
"(",
"error",
",",
"additionalTags",
",",
"extra",
")",
"{",
"let",
"sentTags",
"=",
"tags",
"?",
"[",
"]",
".",
"concat",
"(",
"tags",
")",
":",
"[",
"]",
";",
"if",
"(",
"additionalTags",
")",
"{",
"sentTags",
"=",
"sentTags",
".",
"concat",
"(",
"additionalTags",
")",
";",
"}",
"return",
"Promise",
".",
"resolve",
"(",
"sentTags",
")",
".",
"then",
"(",
"function",
"(",
"t",
")",
"{",
"// Need this wrapping so that our internal implementation can safely throw errors",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
")",
"{",
"const",
"sentError",
"=",
"error",
".",
"nativeError",
"?",
"error",
".",
"nativeError",
":",
"error",
";",
"Raygun",
".",
"send",
"(",
"sentError",
",",
"_",
".",
"merge",
"(",
"extra",
"||",
"{",
"}",
",",
"error",
".",
"extra",
")",
",",
"function",
"(",
"res",
")",
"{",
"// No response === stubbed Raygun",
"if",
"(",
"res",
")",
"{",
"if",
"(",
"res",
".",
"statusCode",
"!==",
"202",
")",
"{",
"console",
".",
"log",
"(",
"'Failed to report error to Raygun'",
",",
"res",
")",
";",
"//eslint-disable-line no-console",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"'Reported error to Raygun'",
",",
"error",
")",
";",
"//eslint-disable-line no-console",
"}",
"}",
"// Resolve with the error, so that our caller can finish deal",
"// with it further",
"resolve",
"(",
"error",
")",
";",
"}",
",",
"error",
".",
"request",
",",
"t",
")",
";",
"}",
")",
";",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"// Return the same error that we were supposed to report",
"// and simply log out the error that actually occurred during reporting",
"console",
".",
"error",
"(",
"err",
")",
";",
"//eslint-disable-line no-console",
"return",
"error",
";",
"}",
")",
";",
"}"
]
| Report an error, with optional additional tags
@param error - error to report
@param additionalTags - optional additional tags to report, along with the
default set of tags set on the module
@param extra - optional extra metadata to include in the error report
@returns promise which resolves into the passed in error | [
"Report",
"an",
"error",
"with",
"optional",
"additional",
"tags"
]
| d6db22ab7974b9279f17466f36f77af4d53fde01 | https://github.com/Testlio/lambda-foundation/blob/d6db22ab7974b9279f17466f36f77af4d53fde01/lib/error/index.js#L25-L58 |
47,476 | Testlio/lambda-foundation | lib/error/index.js | LambdaError | function LambdaError(code, message, extra, request) {
Error.captureStackTrace(this, this.constructor);
this.name = 'LambdaError';
this.message = `${code}: ${message}`;
this.code = code;
this.extra = extra;
this.request = request;
// Also capture a native error internally, which
// we can send to Raygun later
this.nativeError = new Error(this.message);
Error.captureStackTrace(this.nativeError, this.constructor);
} | javascript | function LambdaError(code, message, extra, request) {
Error.captureStackTrace(this, this.constructor);
this.name = 'LambdaError';
this.message = `${code}: ${message}`;
this.code = code;
this.extra = extra;
this.request = request;
// Also capture a native error internally, which
// we can send to Raygun later
this.nativeError = new Error(this.message);
Error.captureStackTrace(this.nativeError, this.constructor);
} | [
"function",
"LambdaError",
"(",
"code",
",",
"message",
",",
"extra",
",",
"request",
")",
"{",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"this",
".",
"constructor",
")",
";",
"this",
".",
"name",
"=",
"'LambdaError'",
";",
"this",
".",
"message",
"=",
"`",
"${",
"code",
"}",
"${",
"message",
"}",
"`",
";",
"this",
".",
"code",
"=",
"code",
";",
"this",
".",
"extra",
"=",
"extra",
";",
"this",
".",
"request",
"=",
"request",
";",
"// Also capture a native error internally, which",
"// we can send to Raygun later",
"this",
".",
"nativeError",
"=",
"new",
"Error",
"(",
"this",
".",
"message",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
".",
"nativeError",
",",
"this",
".",
"constructor",
")",
";",
"}"
]
| Create a new error object
@param code - code for the error (for example HTTP response code)
@param message - error message
@param extra - additional metadata sent when reporting the error
@param request - optional request information sent when reporting
@returns error object | [
"Create",
"a",
"new",
"error",
"object"
]
| d6db22ab7974b9279f17466f36f77af4d53fde01 | https://github.com/Testlio/lambda-foundation/blob/d6db22ab7974b9279f17466f36f77af4d53fde01/lib/error/index.js#L81-L93 |
47,477 | rhythmagency/rhythm.framework | lib/jquery/jquery.dataAttributeFramework.js | function ($element, event, fn) {
var handler = {
$element: $element,
event: event,
fn: fn
};
existingHandlers.push(handler);
return $element.on(event, fn);
} | javascript | function ($element, event, fn) {
var handler = {
$element: $element,
event: event,
fn: fn
};
existingHandlers.push(handler);
return $element.on(event, fn);
} | [
"function",
"(",
"$element",
",",
"event",
",",
"fn",
")",
"{",
"var",
"handler",
"=",
"{",
"$element",
":",
"$element",
",",
"event",
":",
"event",
",",
"fn",
":",
"fn",
"}",
";",
"existingHandlers",
".",
"push",
"(",
"handler",
")",
";",
"return",
"$element",
".",
"on",
"(",
"event",
",",
"fn",
")",
";",
"}"
]
| Attaches events, keeping track of handlers. | [
"Attaches",
"events",
"keeping",
"track",
"of",
"handlers",
"."
]
| 056671a8596f1d9c23f8cbe780659af0abc8041f | https://github.com/rhythmagency/rhythm.framework/blob/056671a8596f1d9c23f8cbe780659af0abc8041f/lib/jquery/jquery.dataAttributeFramework.js#L19-L27 |
|
47,478 | jchook/virtual-dom-handlebars | lib/VNode.js | VNode | function VNode(tagName, attributes, children) {
this.simple = true;
this.tagName = tagName; // non-virtual VText
this.attributes = attributes; // javascript
this.children = new VTree(children);
} | javascript | function VNode(tagName, attributes, children) {
this.simple = true;
this.tagName = tagName; // non-virtual VText
this.attributes = attributes; // javascript
this.children = new VTree(children);
} | [
"function",
"VNode",
"(",
"tagName",
",",
"attributes",
",",
"children",
")",
"{",
"this",
".",
"simple",
"=",
"true",
";",
"this",
".",
"tagName",
"=",
"tagName",
";",
"// non-virtual VText",
"this",
".",
"attributes",
"=",
"attributes",
";",
"// javascript",
"this",
".",
"children",
"=",
"new",
"VTree",
"(",
"children",
")",
";",
"}"
]
| Node that can have children | [
"Node",
"that",
"can",
"have",
"children"
]
| d1c2015449bad8489572114fe3d8facef2cce367 | https://github.com/jchook/virtual-dom-handlebars/blob/d1c2015449bad8489572114fe3d8facef2cce367/lib/VNode.js#L8-L13 |
47,479 | shlomiassaf/resty-stone | lib/RestListMetadata.js | groupFieldsByType | function groupFieldsByType(list){
var fields = {};
_.each(list.fields, function(v,k) {
if (! fields.hasOwnProperty(v.type)) fields[v.type] = [];
fields[v.type].push(v);
});
return fields;
} | javascript | function groupFieldsByType(list){
var fields = {};
_.each(list.fields, function(v,k) {
if (! fields.hasOwnProperty(v.type)) fields[v.type] = [];
fields[v.type].push(v);
});
return fields;
} | [
"function",
"groupFieldsByType",
"(",
"list",
")",
"{",
"var",
"fields",
"=",
"{",
"}",
";",
"_",
".",
"each",
"(",
"list",
".",
"fields",
",",
"function",
"(",
"v",
",",
"k",
")",
"{",
"if",
"(",
"!",
"fields",
".",
"hasOwnProperty",
"(",
"v",
".",
"type",
")",
")",
"fields",
"[",
"v",
".",
"type",
"]",
"=",
"[",
"]",
";",
"fields",
"[",
"v",
".",
"type",
"]",
".",
"push",
"(",
"v",
")",
";",
"}",
")",
";",
"return",
"fields",
";",
"}"
]
| Groups all fields in a list by type.
@param list
@returns {{}} An object map of type/fields. | [
"Groups",
"all",
"fields",
"in",
"a",
"list",
"by",
"type",
"."
]
| 9ab093272ea7b68c6fe0aba45384206571896295 | https://github.com/shlomiassaf/resty-stone/blob/9ab093272ea7b68c6fe0aba45384206571896295/lib/RestListMetadata.js#L76-L83 |
47,480 | saggiyogesh/nodeportal | plugins/manageResource/client/js/manageResource.js | getBytesWithUnit | function getBytesWithUnit(bytes) {
if (isNaN(bytes)) {
return;
}
var units = [ ' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB' ];
var amountOf2s = Math.floor(Math.log(+bytes) / Math.log(2));
if (amountOf2s < 1) {
amountOf2s = 0;
}
var i = Math.floor(amountOf2s / 10);
bytes = +bytes / Math.pow(2, 10 * i);
if (bytes.toString().length > bytes.toFixed(2).toString().length) {
bytes = bytes.toFixed(2);
}
return bytes + units[i];
} | javascript | function getBytesWithUnit(bytes) {
if (isNaN(bytes)) {
return;
}
var units = [ ' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB' ];
var amountOf2s = Math.floor(Math.log(+bytes) / Math.log(2));
if (amountOf2s < 1) {
amountOf2s = 0;
}
var i = Math.floor(amountOf2s / 10);
bytes = +bytes / Math.pow(2, 10 * i);
if (bytes.toString().length > bytes.toFixed(2).toString().length) {
bytes = bytes.toFixed(2);
}
return bytes + units[i];
} | [
"function",
"getBytesWithUnit",
"(",
"bytes",
")",
"{",
"if",
"(",
"isNaN",
"(",
"bytes",
")",
")",
"{",
"return",
";",
"}",
"var",
"units",
"=",
"[",
"' bytes'",
",",
"' KB'",
",",
"' MB'",
",",
"' GB'",
",",
"' TB'",
",",
"' PB'",
",",
"' EB'",
",",
"' ZB'",
",",
"' YB'",
"]",
";",
"var",
"amountOf2s",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"log",
"(",
"+",
"bytes",
")",
"/",
"Math",
".",
"log",
"(",
"2",
")",
")",
";",
"if",
"(",
"amountOf2s",
"<",
"1",
")",
"{",
"amountOf2s",
"=",
"0",
";",
"}",
"var",
"i",
"=",
"Math",
".",
"floor",
"(",
"amountOf2s",
"/",
"10",
")",
";",
"bytes",
"=",
"+",
"bytes",
"/",
"Math",
".",
"pow",
"(",
"2",
",",
"10",
"*",
"i",
")",
";",
"if",
"(",
"bytes",
".",
"toString",
"(",
")",
".",
"length",
">",
"bytes",
".",
"toFixed",
"(",
"2",
")",
".",
"toString",
"(",
")",
".",
"length",
")",
"{",
"bytes",
"=",
"bytes",
".",
"toFixed",
"(",
"2",
")",
";",
"}",
"return",
"bytes",
"+",
"units",
"[",
"i",
"]",
";",
"}"
]
| code with the help of google | [
"code",
"with",
"the",
"help",
"of",
"google"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/manageResource/client/js/manageResource.js#L32-L49 |
47,481 | saggiyogesh/nodeportal | plugins/manageResource/client/js/manageResource.js | renderActionButtons | function renderActionButtons() {
$('.manage-resource-container .action-button').each(function (i, action) {
action = $(action);
var type = action.parent().hasClass(FOLDER_TYPE) ? FOLDER_TYPE : "";
var id = action.attr("id"),
dataId = action.parent('.resource-item').attr("id");
var actions = [
{
text: type ? "View" : "Download",
onClick: function (e) {
if (type) {
renderItemsByFolderId(dataId);
} else {
download(dataId);
}
},
permissionAction: "VIEW"
},
{
text: "Permission", data: {id: dataId},
onClick: function (e) {
openPermissions(dataId);
},
permissionAction: "PERMISSION"
},
{
text: "Rename", data: {id: dataId},
onClick: function (e) {
rename(dataId, true);
},
permissionAction: "UPDATE"
},
{
text: "Delete",
onClick: function (e) {
remove(dataId, type);
},
permissionAction: "DELETE"
}
];
var opts = {
handlerId: id,
buttonSize: "mini",
actions: actions
};
var permissionConf = {
modelId: dataId,
modelName: modelName,
permissionSchemaKey: permissionSchemaKey
};
new Rocket.ActionButton(opts, permissionConf)
});
} | javascript | function renderActionButtons() {
$('.manage-resource-container .action-button').each(function (i, action) {
action = $(action);
var type = action.parent().hasClass(FOLDER_TYPE) ? FOLDER_TYPE : "";
var id = action.attr("id"),
dataId = action.parent('.resource-item').attr("id");
var actions = [
{
text: type ? "View" : "Download",
onClick: function (e) {
if (type) {
renderItemsByFolderId(dataId);
} else {
download(dataId);
}
},
permissionAction: "VIEW"
},
{
text: "Permission", data: {id: dataId},
onClick: function (e) {
openPermissions(dataId);
},
permissionAction: "PERMISSION"
},
{
text: "Rename", data: {id: dataId},
onClick: function (e) {
rename(dataId, true);
},
permissionAction: "UPDATE"
},
{
text: "Delete",
onClick: function (e) {
remove(dataId, type);
},
permissionAction: "DELETE"
}
];
var opts = {
handlerId: id,
buttonSize: "mini",
actions: actions
};
var permissionConf = {
modelId: dataId,
modelName: modelName,
permissionSchemaKey: permissionSchemaKey
};
new Rocket.ActionButton(opts, permissionConf)
});
} | [
"function",
"renderActionButtons",
"(",
")",
"{",
"$",
"(",
"'.manage-resource-container .action-button'",
")",
".",
"each",
"(",
"function",
"(",
"i",
",",
"action",
")",
"{",
"action",
"=",
"$",
"(",
"action",
")",
";",
"var",
"type",
"=",
"action",
".",
"parent",
"(",
")",
".",
"hasClass",
"(",
"FOLDER_TYPE",
")",
"?",
"FOLDER_TYPE",
":",
"\"\"",
";",
"var",
"id",
"=",
"action",
".",
"attr",
"(",
"\"id\"",
")",
",",
"dataId",
"=",
"action",
".",
"parent",
"(",
"'.resource-item'",
")",
".",
"attr",
"(",
"\"id\"",
")",
";",
"var",
"actions",
"=",
"[",
"{",
"text",
":",
"type",
"?",
"\"View\"",
":",
"\"Download\"",
",",
"onClick",
":",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"type",
")",
"{",
"renderItemsByFolderId",
"(",
"dataId",
")",
";",
"}",
"else",
"{",
"download",
"(",
"dataId",
")",
";",
"}",
"}",
",",
"permissionAction",
":",
"\"VIEW\"",
"}",
",",
"{",
"text",
":",
"\"Permission\"",
",",
"data",
":",
"{",
"id",
":",
"dataId",
"}",
",",
"onClick",
":",
"function",
"(",
"e",
")",
"{",
"openPermissions",
"(",
"dataId",
")",
";",
"}",
",",
"permissionAction",
":",
"\"PERMISSION\"",
"}",
",",
"{",
"text",
":",
"\"Rename\"",
",",
"data",
":",
"{",
"id",
":",
"dataId",
"}",
",",
"onClick",
":",
"function",
"(",
"e",
")",
"{",
"rename",
"(",
"dataId",
",",
"true",
")",
";",
"}",
",",
"permissionAction",
":",
"\"UPDATE\"",
"}",
",",
"{",
"text",
":",
"\"Delete\"",
",",
"onClick",
":",
"function",
"(",
"e",
")",
"{",
"remove",
"(",
"dataId",
",",
"type",
")",
";",
"}",
",",
"permissionAction",
":",
"\"DELETE\"",
"}",
"]",
";",
"var",
"opts",
"=",
"{",
"handlerId",
":",
"id",
",",
"buttonSize",
":",
"\"mini\"",
",",
"actions",
":",
"actions",
"}",
";",
"var",
"permissionConf",
"=",
"{",
"modelId",
":",
"dataId",
",",
"modelName",
":",
"modelName",
",",
"permissionSchemaKey",
":",
"permissionSchemaKey",
"}",
";",
"new",
"Rocket",
".",
"ActionButton",
"(",
"opts",
",",
"permissionConf",
")",
"}",
")",
";",
"}"
]
| render action button | [
"render",
"action",
"button"
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/plugins/manageResource/client/js/manageResource.js#L263-L319 |
47,482 | mdreizin/webpack-config-stream | lib/ignoreStream.js | ignoreStream | function ignoreStream(strategy) {
if (!(strategy instanceof IgnoreStrategy)) {
strategy = DefaultIgnoreStrategy.INSTANCE;
}
return through.obj(function(chunk, enc, cb) {
strategy.execute(this, chunk).then(function(isIgnored) {
if (!isIgnored) {
cb(null, chunk);
} else {
cb(null);
}
});
});
} | javascript | function ignoreStream(strategy) {
if (!(strategy instanceof IgnoreStrategy)) {
strategy = DefaultIgnoreStrategy.INSTANCE;
}
return through.obj(function(chunk, enc, cb) {
strategy.execute(this, chunk).then(function(isIgnored) {
if (!isIgnored) {
cb(null, chunk);
} else {
cb(null);
}
});
});
} | [
"function",
"ignoreStream",
"(",
"strategy",
")",
"{",
"if",
"(",
"!",
"(",
"strategy",
"instanceof",
"IgnoreStrategy",
")",
")",
"{",
"strategy",
"=",
"DefaultIgnoreStrategy",
".",
"INSTANCE",
";",
"}",
"return",
"through",
".",
"obj",
"(",
"function",
"(",
"chunk",
",",
"enc",
",",
"cb",
")",
"{",
"strategy",
".",
"execute",
"(",
"this",
",",
"chunk",
")",
".",
"then",
"(",
"function",
"(",
"isIgnored",
")",
"{",
"if",
"(",
"!",
"isIgnored",
")",
"{",
"cb",
"(",
"null",
",",
"chunk",
")",
";",
"}",
"else",
"{",
"cb",
"(",
"null",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
]
| Prevents writing of `webpack.config.js`. Can be piped.
@function
@alias ignoreStream
@param {IgnoreStrategy=} strategy
@returns {Stream} | [
"Prevents",
"writing",
"of",
"webpack",
".",
"config",
".",
"js",
".",
"Can",
"be",
"piped",
"."
]
| f8424f97837a224bc07cc18a03ecf649d708e924 | https://github.com/mdreizin/webpack-config-stream/blob/f8424f97837a224bc07cc18a03ecf649d708e924/lib/ignoreStream.js#L14-L28 |
47,483 | saggiyogesh/nodeportal | public/ckeditor/_source/core/tools.js | function( text )
{
var standard = function( text )
{
var span = new CKEDITOR.dom.element( 'span' );
span.setText( text );
return span.getHtml();
};
var fix1 = ( standard( '\n' ).toLowerCase() == '<br>' ) ?
function( text )
{
// #3874 IE and Safari encode line-break into <br>
return standard( text ).replace( /<br>/gi, '\n' );
} :
standard;
var fix2 = ( standard( '>' ) == '>' ) ?
function( text )
{
// WebKit does't encode the ">" character, which makes sense, but
// it's different than other browsers.
return fix1( text ).replace( />/g, '>' );
} :
fix1;
var fix3 = ( standard( ' ' ) == ' ' ) ?
function( text )
{
// #3785 IE8 changes spaces (>= 2) to
return fix2( text ).replace( / /g, ' ' );
} :
fix2;
this.htmlEncode = fix3;
return this.htmlEncode( text );
} | javascript | function( text )
{
var standard = function( text )
{
var span = new CKEDITOR.dom.element( 'span' );
span.setText( text );
return span.getHtml();
};
var fix1 = ( standard( '\n' ).toLowerCase() == '<br>' ) ?
function( text )
{
// #3874 IE and Safari encode line-break into <br>
return standard( text ).replace( /<br>/gi, '\n' );
} :
standard;
var fix2 = ( standard( '>' ) == '>' ) ?
function( text )
{
// WebKit does't encode the ">" character, which makes sense, but
// it's different than other browsers.
return fix1( text ).replace( />/g, '>' );
} :
fix1;
var fix3 = ( standard( ' ' ) == ' ' ) ?
function( text )
{
// #3785 IE8 changes spaces (>= 2) to
return fix2( text ).replace( / /g, ' ' );
} :
fix2;
this.htmlEncode = fix3;
return this.htmlEncode( text );
} | [
"function",
"(",
"text",
")",
"{",
"var",
"standard",
"=",
"function",
"(",
"text",
")",
"{",
"var",
"span",
"=",
"new",
"CKEDITOR",
".",
"dom",
".",
"element",
"(",
"'span'",
")",
";",
"span",
".",
"setText",
"(",
"text",
")",
";",
"return",
"span",
".",
"getHtml",
"(",
")",
";",
"}",
";",
"var",
"fix1",
"=",
"(",
"standard",
"(",
"'\\n'",
")",
".",
"toLowerCase",
"(",
")",
"==",
"'<br>'",
")",
"?",
"function",
"(",
"text",
")",
"{",
"// #3874 IE and Safari encode line-break into <br>\r",
"return",
"standard",
"(",
"text",
")",
".",
"replace",
"(",
"/",
"<br>",
"/",
"gi",
",",
"'\\n'",
")",
";",
"}",
":",
"standard",
";",
"var",
"fix2",
"=",
"(",
"standard",
"(",
"'>'",
")",
"==",
"'>'",
")",
"?",
"function",
"(",
"text",
")",
"{",
"// WebKit does't encode the \">\" character, which makes sense, but\r",
"// it's different than other browsers.\r",
"return",
"fix1",
"(",
"text",
")",
".",
"replace",
"(",
"/",
">",
"/",
"g",
",",
"'>'",
")",
";",
"}",
":",
"fix1",
";",
"var",
"fix3",
"=",
"(",
"standard",
"(",
"' '",
")",
"==",
"' '",
")",
"?",
"function",
"(",
"text",
")",
"{",
"// #3785 IE8 changes spaces (>= 2) to \r",
"return",
"fix2",
"(",
"text",
")",
".",
"replace",
"(",
"/",
" ",
"/",
"g",
",",
"' '",
")",
";",
"}",
":",
"fix2",
";",
"this",
".",
"htmlEncode",
"=",
"fix3",
";",
"return",
"this",
".",
"htmlEncode",
"(",
"text",
")",
";",
"}"
]
| Replace special HTML characters in a string with their relative HTML
entity values.
@param {String} text The string to be encoded.
@returns {String} The encode string.
@example
alert( CKEDITOR.tools.htmlEncode( 'A > B & C < D' ) ); // "A &gt; B &amp; C &lt; D" | [
"Replace",
"special",
"HTML",
"characters",
"in",
"a",
"string",
"with",
"their",
"relative",
"HTML",
"entity",
"values",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/tools.js#L296-L333 |
|
47,484 | saggiyogesh/nodeportal | public/ckeditor/_source/core/tools.js | function( func, milliseconds, scope, args, ownerWindow )
{
if ( !ownerWindow )
ownerWindow = window;
if ( !scope )
scope = ownerWindow;
return ownerWindow.setTimeout(
function()
{
if ( args )
func.apply( scope, [].concat( args ) ) ;
else
func.apply( scope ) ;
},
milliseconds || 0 );
} | javascript | function( func, milliseconds, scope, args, ownerWindow )
{
if ( !ownerWindow )
ownerWindow = window;
if ( !scope )
scope = ownerWindow;
return ownerWindow.setTimeout(
function()
{
if ( args )
func.apply( scope, [].concat( args ) ) ;
else
func.apply( scope ) ;
},
milliseconds || 0 );
} | [
"function",
"(",
"func",
",",
"milliseconds",
",",
"scope",
",",
"args",
",",
"ownerWindow",
")",
"{",
"if",
"(",
"!",
"ownerWindow",
")",
"ownerWindow",
"=",
"window",
";",
"if",
"(",
"!",
"scope",
")",
"scope",
"=",
"ownerWindow",
";",
"return",
"ownerWindow",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"args",
")",
"func",
".",
"apply",
"(",
"scope",
",",
"[",
"]",
".",
"concat",
"(",
"args",
")",
")",
";",
"else",
"func",
".",
"apply",
"(",
"scope",
")",
";",
"}",
",",
"milliseconds",
"||",
"0",
")",
";",
"}"
]
| Executes a function after specified delay.
@param {Function} func The function to be executed.
@param {Number} [milliseconds] The amount of time (millisecods) to wait
to fire the function execution. Defaults to zero.
@param {Object} [scope] The object to hold the function execution scope
(the "this" object). By default the "window" object.
@param {Object|Array} [args] A single object, or an array of objects, to
pass as arguments to the function.
@param {Object} [ownerWindow] The window that will be used to set the
timeout. By default the current "window".
@returns {Object} A value that can be used to cancel the function execution.
@example
CKEDITOR.tools.<b>setTimeout(
function()
{
alert( 'Executed after 2 seconds' );
},
2000 )</b>; | [
"Executes",
"a",
"function",
"after",
"specified",
"delay",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/tools.js#L430-L447 |
|
47,485 | saggiyogesh/nodeportal | public/ckeditor/_source/core/tools.js | function( ref )
{
var fn = functions[ ref ];
return fn && fn.apply( window, Array.prototype.slice.call( arguments, 1 ) );
} | javascript | function( ref )
{
var fn = functions[ ref ];
return fn && fn.apply( window, Array.prototype.slice.call( arguments, 1 ) );
} | [
"function",
"(",
"ref",
")",
"{",
"var",
"fn",
"=",
"functions",
"[",
"ref",
"]",
";",
"return",
"fn",
"&&",
"fn",
".",
"apply",
"(",
"window",
",",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"1",
")",
")",
";",
"}"
]
| Executes a function based on the reference created with
CKEDITOR.tools.addFunction.
@param {Number} ref The function reference created with
CKEDITOR.tools.addFunction.
@param {[Any,[Any,...]} params Any number of parameters to be passed
to the executed function.
@returns {Any} The return value of the function.
@example
var ref = CKEDITOR.tools.addFunction(
function()
{
alert( 'Hello!');
});
<b>CKEDITOR.tools.callFunction( ref )</b>; // Hello! | [
"Executes",
"a",
"function",
"based",
"on",
"the",
"reference",
"created",
"with",
"CKEDITOR",
".",
"tools",
".",
"addFunction",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/core/tools.js#L671-L675 |
|
47,486 | dailymotion/react-collider | lib/server.js | returnResponse | function returnResponse(res, Handler, data, perfInstance) {
var content = React.renderToString(React.createElement(Handler, { data: data })),
html = '<!DOCTYPE html>' + content;
options.log && log(options.log, 'perf', perfInstance());
res.end(html);
} | javascript | function returnResponse(res, Handler, data, perfInstance) {
var content = React.renderToString(React.createElement(Handler, { data: data })),
html = '<!DOCTYPE html>' + content;
options.log && log(options.log, 'perf', perfInstance());
res.end(html);
} | [
"function",
"returnResponse",
"(",
"res",
",",
"Handler",
",",
"data",
",",
"perfInstance",
")",
"{",
"var",
"content",
"=",
"React",
".",
"renderToString",
"(",
"React",
".",
"createElement",
"(",
"Handler",
",",
"{",
"data",
":",
"data",
"}",
")",
")",
",",
"html",
"=",
"'<!DOCTYPE html>'",
"+",
"content",
";",
"options",
".",
"log",
"&&",
"log",
"(",
"options",
".",
"log",
",",
"'perf'",
",",
"perfInstance",
"(",
")",
")",
";",
"res",
".",
"end",
"(",
"html",
")",
";",
"}"
]
| Server side rendering | [
"Server",
"side",
"rendering"
]
| 00cea5d25928d4a3ff0c68b6535edbc231d2b0a1 | https://github.com/dailymotion/react-collider/blob/00cea5d25928d4a3ff0c68b6535edbc231d2b0a1/lib/server.js#L40-L45 |
47,487 | francois2metz/node-spore | lib/client.js | function(url, callback) {
var parsedUrl = urlparse(url, true);
var method = this._normalizeSpecMethod(this.spec, {
base_url: parsedUrl.protocol +'//' + parsedUrl.hostname,
headers: {},
method: 'GET',
path: parsedUrl.pathname + parsedUrl.search
});
var request = this._createRequest(method, {}, null);
this._callRequestMiddlewares(this.middlewares.slice(0), method, request, [], callback);
} | javascript | function(url, callback) {
var parsedUrl = urlparse(url, true);
var method = this._normalizeSpecMethod(this.spec, {
base_url: parsedUrl.protocol +'//' + parsedUrl.hostname,
headers: {},
method: 'GET',
path: parsedUrl.pathname + parsedUrl.search
});
var request = this._createRequest(method, {}, null);
this._callRequestMiddlewares(this.middlewares.slice(0), method, request, [], callback);
} | [
"function",
"(",
"url",
",",
"callback",
")",
"{",
"var",
"parsedUrl",
"=",
"urlparse",
"(",
"url",
",",
"true",
")",
";",
"var",
"method",
"=",
"this",
".",
"_normalizeSpecMethod",
"(",
"this",
".",
"spec",
",",
"{",
"base_url",
":",
"parsedUrl",
".",
"protocol",
"+",
"'//'",
"+",
"parsedUrl",
".",
"hostname",
",",
"headers",
":",
"{",
"}",
",",
"method",
":",
"'GET'",
",",
"path",
":",
"parsedUrl",
".",
"pathname",
"+",
"parsedUrl",
".",
"search",
"}",
")",
";",
"var",
"request",
"=",
"this",
".",
"_createRequest",
"(",
"method",
",",
"{",
"}",
",",
"null",
")",
";",
"this",
".",
"_callRequestMiddlewares",
"(",
"this",
".",
"middlewares",
".",
"slice",
"(",
"0",
")",
",",
"method",
",",
"request",
",",
"[",
"]",
",",
"callback",
")",
";",
"}"
]
| Direct get request | [
"Direct",
"get",
"request"
]
| a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L38-L48 |
|
47,488 | francois2metz/node-spore | lib/client.js | function(middleware) {
this.middlewares = this.middlewares.filter(function(element) {
if (element.fun === middleware)
return false;
return true;
});
} | javascript | function(middleware) {
this.middlewares = this.middlewares.filter(function(element) {
if (element.fun === middleware)
return false;
return true;
});
} | [
"function",
"(",
"middleware",
")",
"{",
"this",
".",
"middlewares",
"=",
"this",
".",
"middlewares",
".",
"filter",
"(",
"function",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"fun",
"===",
"middleware",
")",
"return",
"false",
";",
"return",
"true",
";",
"}",
")",
";",
"}"
]
| Disable middleware at runtime | [
"Disable",
"middleware",
"at",
"runtime"
]
| a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L64-L70 |
|
47,489 | francois2metz/node-spore | lib/client.js | function(methodName, args) {
var method = this.spec.methods[methodName];
if (method.deprecated === true)
console.warn('Method '+ methodName + ' is deprecated.')
var callback = args.pop(); // callback is always at the end
var middleware = args[0];
var params = null;
var payload = null;
var index = 0;
if (typeof middleware != 'function') {
params = args[0];
middleware = null;
} else {
params = args[1];
index = 1;
}
if (args.length > 1) {
payload = args[index + 1];
} else {
if (method.required_params.length == 0
&& method.optional_params.length == 0) {
payload = args[index];
params = null;
}
}
if (this._isValidCall(method, callback, params, payload)) {
var request = this._createRequest(method, params, payload);
var middlewares = this.middlewares.slice(0);
if (middleware !== null) middlewares.push({cond: function() { return true; }, fun: middleware});
this._callRequestMiddlewares(middlewares, method, request, [], callback);
}
} | javascript | function(methodName, args) {
var method = this.spec.methods[methodName];
if (method.deprecated === true)
console.warn('Method '+ methodName + ' is deprecated.')
var callback = args.pop(); // callback is always at the end
var middleware = args[0];
var params = null;
var payload = null;
var index = 0;
if (typeof middleware != 'function') {
params = args[0];
middleware = null;
} else {
params = args[1];
index = 1;
}
if (args.length > 1) {
payload = args[index + 1];
} else {
if (method.required_params.length == 0
&& method.optional_params.length == 0) {
payload = args[index];
params = null;
}
}
if (this._isValidCall(method, callback, params, payload)) {
var request = this._createRequest(method, params, payload);
var middlewares = this.middlewares.slice(0);
if (middleware !== null) middlewares.push({cond: function() { return true; }, fun: middleware});
this._callRequestMiddlewares(middlewares, method, request, [], callback);
}
} | [
"function",
"(",
"methodName",
",",
"args",
")",
"{",
"var",
"method",
"=",
"this",
".",
"spec",
".",
"methods",
"[",
"methodName",
"]",
";",
"if",
"(",
"method",
".",
"deprecated",
"===",
"true",
")",
"console",
".",
"warn",
"(",
"'Method '",
"+",
"methodName",
"+",
"' is deprecated.'",
")",
"var",
"callback",
"=",
"args",
".",
"pop",
"(",
")",
";",
"// callback is always at the end",
"var",
"middleware",
"=",
"args",
"[",
"0",
"]",
";",
"var",
"params",
"=",
"null",
";",
"var",
"payload",
"=",
"null",
";",
"var",
"index",
"=",
"0",
";",
"if",
"(",
"typeof",
"middleware",
"!=",
"'function'",
")",
"{",
"params",
"=",
"args",
"[",
"0",
"]",
";",
"middleware",
"=",
"null",
";",
"}",
"else",
"{",
"params",
"=",
"args",
"[",
"1",
"]",
";",
"index",
"=",
"1",
";",
"}",
"if",
"(",
"args",
".",
"length",
">",
"1",
")",
"{",
"payload",
"=",
"args",
"[",
"index",
"+",
"1",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"method",
".",
"required_params",
".",
"length",
"==",
"0",
"&&",
"method",
".",
"optional_params",
".",
"length",
"==",
"0",
")",
"{",
"payload",
"=",
"args",
"[",
"index",
"]",
";",
"params",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"this",
".",
"_isValidCall",
"(",
"method",
",",
"callback",
",",
"params",
",",
"payload",
")",
")",
"{",
"var",
"request",
"=",
"this",
".",
"_createRequest",
"(",
"method",
",",
"params",
",",
"payload",
")",
";",
"var",
"middlewares",
"=",
"this",
".",
"middlewares",
".",
"slice",
"(",
"0",
")",
";",
"if",
"(",
"middleware",
"!==",
"null",
")",
"middlewares",
".",
"push",
"(",
"{",
"cond",
":",
"function",
"(",
")",
"{",
"return",
"true",
";",
"}",
",",
"fun",
":",
"middleware",
"}",
")",
";",
"this",
".",
"_callRequestMiddlewares",
"(",
"middlewares",
",",
"method",
",",
"request",
",",
"[",
"]",
",",
"callback",
")",
";",
"}",
"}"
]
| args is an array with some possibilities
middleware, params, payload, callback
middleware, payload, callback
middleware, params, callback
middleware, callback
params, payload, callback
payload, callback
params, callback
callback | [
"args",
"is",
"an",
"array",
"with",
"some",
"possibilities",
"middleware",
"params",
"payload",
"callback",
"middleware",
"payload",
"callback",
"middleware",
"params",
"callback",
"middleware",
"callback",
"params",
"payload",
"callback",
"payload",
"callback",
"params",
"callback",
"callback"
]
| a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L96-L127 |
|
47,490 | francois2metz/node-spore | lib/client.js | function(request, callback, response_middlewares) {
var that = this;
request.finalize(function(err, res) {
if (err) callback(err, null);
else that._callResponseMiddlewares(response_middlewares, res, callback);
});
} | javascript | function(request, callback, response_middlewares) {
var that = this;
request.finalize(function(err, res) {
if (err) callback(err, null);
else that._callResponseMiddlewares(response_middlewares, res, callback);
});
} | [
"function",
"(",
"request",
",",
"callback",
",",
"response_middlewares",
")",
"{",
"var",
"that",
"=",
"this",
";",
"request",
".",
"finalize",
"(",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"callback",
"(",
"err",
",",
"null",
")",
";",
"else",
"that",
".",
"_callResponseMiddlewares",
"(",
"response_middlewares",
",",
"res",
",",
"callback",
")",
";",
"}",
")",
";",
"}"
]
| Make http request | [
"Make",
"http",
"request"
]
| a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L192-L198 |
|
47,491 | francois2metz/node-spore | lib/client.js | function(methodDef, callback, params, payload) {
// check required params
for (var index in methodDef.required_params) {
var requiredParamName = methodDef.required_params[index];
if (!params.hasOwnProperty(requiredParamName)) {
callback(requiredParamName +' param is required');
return false;
}
}
// check unattended params
if (methodDef.unattended_params === false) {
for (var param in params) {
if (methodDef.optional_params.indexOf(param) == -1
&& methodDef.required_params.indexOf(param) == -1) {
callback('unattended param '+ param);
return false;
}
}
}
// TODO: optional_payload is also on spore specification
if (!payload && methodDef.required_payload === true) {
callback("payload is required");
return false;
}
return true;
} | javascript | function(methodDef, callback, params, payload) {
// check required params
for (var index in methodDef.required_params) {
var requiredParamName = methodDef.required_params[index];
if (!params.hasOwnProperty(requiredParamName)) {
callback(requiredParamName +' param is required');
return false;
}
}
// check unattended params
if (methodDef.unattended_params === false) {
for (var param in params) {
if (methodDef.optional_params.indexOf(param) == -1
&& methodDef.required_params.indexOf(param) == -1) {
callback('unattended param '+ param);
return false;
}
}
}
// TODO: optional_payload is also on spore specification
if (!payload && methodDef.required_payload === true) {
callback("payload is required");
return false;
}
return true;
} | [
"function",
"(",
"methodDef",
",",
"callback",
",",
"params",
",",
"payload",
")",
"{",
"// check required params",
"for",
"(",
"var",
"index",
"in",
"methodDef",
".",
"required_params",
")",
"{",
"var",
"requiredParamName",
"=",
"methodDef",
".",
"required_params",
"[",
"index",
"]",
";",
"if",
"(",
"!",
"params",
".",
"hasOwnProperty",
"(",
"requiredParamName",
")",
")",
"{",
"callback",
"(",
"requiredParamName",
"+",
"' param is required'",
")",
";",
"return",
"false",
";",
"}",
"}",
"// check unattended params",
"if",
"(",
"methodDef",
".",
"unattended_params",
"===",
"false",
")",
"{",
"for",
"(",
"var",
"param",
"in",
"params",
")",
"{",
"if",
"(",
"methodDef",
".",
"optional_params",
".",
"indexOf",
"(",
"param",
")",
"==",
"-",
"1",
"&&",
"methodDef",
".",
"required_params",
".",
"indexOf",
"(",
"param",
")",
"==",
"-",
"1",
")",
"{",
"callback",
"(",
"'unattended param '",
"+",
"param",
")",
";",
"return",
"false",
";",
"}",
"}",
"}",
"// TODO: optional_payload is also on spore specification",
"if",
"(",
"!",
"payload",
"&&",
"methodDef",
".",
"required_payload",
"===",
"true",
")",
"{",
"callback",
"(",
"\"payload is required\"",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Check params and payload | [
"Check",
"params",
"and",
"payload"
]
| a74df36300852d8bab70c83506e4a3301137b6a0 | https://github.com/francois2metz/node-spore/blob/a74df36300852d8bab70c83506e4a3301137b6a0/lib/client.js#L235-L260 |
|
47,492 | nijikokun/http-responses | index.js | GenericRestError | function GenericRestError (type, status) {
return function Handler (code, message, header) {
return new RestError(type, status, code, message, header)
}
} | javascript | function GenericRestError (type, status) {
return function Handler (code, message, header) {
return new RestError(type, status, code, message, header)
}
} | [
"function",
"GenericRestError",
"(",
"type",
",",
"status",
")",
"{",
"return",
"function",
"Handler",
"(",
"code",
",",
"message",
",",
"header",
")",
"{",
"return",
"new",
"RestError",
"(",
"type",
",",
"status",
",",
"code",
",",
"message",
",",
"header",
")",
"}",
"}"
]
| Setup pre-defined status code for RestError method
@param {Number} status HTTP Status Code
@private | [
"Setup",
"pre",
"-",
"defined",
"status",
"code",
"for",
"RestError",
"method"
]
| f33f01c69ba720773adaba6d1b596f2b973f5189 | https://github.com/nijikokun/http-responses/blob/f33f01c69ba720773adaba6d1b596f2b973f5189/index.js#L174-L178 |
47,493 | jeffsu/js2 | src/core/js2-lexer.js | function(stuff) {
var len = this.str.length;
if (typeof stuff == 'number') {
this.str = this.str.substr(stuff);
} else if (typeof stuff == 'string') {
this.str = this.str.substr(stuff.length);
} else if (stuff instanceof RegExp) {
var m = this.str.match(stuff);
if (m) {
this.str = this.str.substr(m[0].length);
}
}
return len > this.str.length;
} | javascript | function(stuff) {
var len = this.str.length;
if (typeof stuff == 'number') {
this.str = this.str.substr(stuff);
} else if (typeof stuff == 'string') {
this.str = this.str.substr(stuff.length);
} else if (stuff instanceof RegExp) {
var m = this.str.match(stuff);
if (m) {
this.str = this.str.substr(m[0].length);
}
}
return len > this.str.length;
} | [
"function",
"(",
"stuff",
")",
"{",
"var",
"len",
"=",
"this",
".",
"str",
".",
"length",
";",
"if",
"(",
"typeof",
"stuff",
"==",
"'number'",
")",
"{",
"this",
".",
"str",
"=",
"this",
".",
"str",
".",
"substr",
"(",
"stuff",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"stuff",
"==",
"'string'",
")",
"{",
"this",
".",
"str",
"=",
"this",
".",
"str",
".",
"substr",
"(",
"stuff",
".",
"length",
")",
";",
"}",
"else",
"if",
"(",
"stuff",
"instanceof",
"RegExp",
")",
"{",
"var",
"m",
"=",
"this",
".",
"str",
".",
"match",
"(",
"stuff",
")",
";",
"if",
"(",
"m",
")",
"{",
"this",
".",
"str",
"=",
"this",
".",
"str",
".",
"substr",
"(",
"m",
"[",
"0",
"]",
".",
"length",
")",
";",
"}",
"}",
"return",
"len",
">",
"this",
".",
"str",
".",
"length",
";",
"}"
]
| stuff can be string, integer, or regex will return true if it actually made the string smaller | [
"stuff",
"can",
"be",
"string",
"integer",
"or",
"regex",
"will",
"return",
"true",
"if",
"it",
"actually",
"made",
"the",
"string",
"smaller"
]
| 5651e6d8ceaea1239aa162462ab9eab80c640707 | https://github.com/jeffsu/js2/blob/5651e6d8ceaea1239aa162462ab9eab80c640707/src/core/js2-lexer.js#L350-L363 |
|
47,494 | wombleton/angular-gettext-extract-loader | index.js | mergeReferences | function mergeReferences (oldRefs, newRefs) {
const _newRefs = _(newRefs);
return _(oldRefs)
.reject(function (oldRef) {
return _newRefs.any(function (newRef) {
return matches(oldRef, newRef);
});
})
.concat(newRefs)
.uniq()
.sort()
.value();
} | javascript | function mergeReferences (oldRefs, newRefs) {
const _newRefs = _(newRefs);
return _(oldRefs)
.reject(function (oldRef) {
return _newRefs.any(function (newRef) {
return matches(oldRef, newRef);
});
})
.concat(newRefs)
.uniq()
.sort()
.value();
} | [
"function",
"mergeReferences",
"(",
"oldRefs",
",",
"newRefs",
")",
"{",
"const",
"_newRefs",
"=",
"_",
"(",
"newRefs",
")",
";",
"return",
"_",
"(",
"oldRefs",
")",
".",
"reject",
"(",
"function",
"(",
"oldRef",
")",
"{",
"return",
"_newRefs",
".",
"any",
"(",
"function",
"(",
"newRef",
")",
"{",
"return",
"matches",
"(",
"oldRef",
",",
"newRef",
")",
";",
"}",
")",
";",
"}",
")",
".",
"concat",
"(",
"newRefs",
")",
".",
"uniq",
"(",
")",
".",
"sort",
"(",
")",
".",
"value",
"(",
")",
";",
"}"
]
| Merge new references with old references; ignore old references from the same file. | [
"Merge",
"new",
"references",
"with",
"old",
"references",
";",
"ignore",
"old",
"references",
"from",
"the",
"same",
"file",
"."
]
| 8b977383b4f34a74e967d99267b70c83aa53cffd | https://github.com/wombleton/angular-gettext-extract-loader/blob/8b977383b4f34a74e967d99267b70c83aa53cffd/index.js#L15-L28 |
47,495 | bevacqua/measly | sample/sample.js | preventAll | function preventAll () {
function shield (req) {
req.prevent();
}
measly.on('create', shield);
text(preventButton, 'Shield On..');
preventButton.classList.add('cm-prevent-on');
setTimeout(function () {
measly.off('create', shield);
text(preventButton, 'Prevent for 5s');
preventButton.classList.remove('cm-prevent-on');
}, 5000);
} | javascript | function preventAll () {
function shield (req) {
req.prevent();
}
measly.on('create', shield);
text(preventButton, 'Shield On..');
preventButton.classList.add('cm-prevent-on');
setTimeout(function () {
measly.off('create', shield);
text(preventButton, 'Prevent for 5s');
preventButton.classList.remove('cm-prevent-on');
}, 5000);
} | [
"function",
"preventAll",
"(",
")",
"{",
"function",
"shield",
"(",
"req",
")",
"{",
"req",
".",
"prevent",
"(",
")",
";",
"}",
"measly",
".",
"on",
"(",
"'create'",
",",
"shield",
")",
";",
"text",
"(",
"preventButton",
",",
"'Shield On..'",
")",
";",
"preventButton",
".",
"classList",
".",
"add",
"(",
"'cm-prevent-on'",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"measly",
".",
"off",
"(",
"'create'",
",",
"shield",
")",
";",
"text",
"(",
"preventButton",
",",
"'Prevent for 5s'",
")",
";",
"preventButton",
".",
"classList",
".",
"remove",
"(",
"'cm-prevent-on'",
")",
";",
"}",
",",
"5000",
")",
";",
"}"
]
| prevents all requests fired by measly for 5 seconds. | [
"prevents",
"all",
"requests",
"fired",
"by",
"measly",
"for",
"5",
"seconds",
"."
]
| bc94d8207c61f7140da8a2a4879e3ca15e1a4b38 | https://github.com/bevacqua/measly/blob/bc94d8207c61f7140da8a2a4879e3ca15e1a4b38/sample/sample.js#L117-L130 |
47,496 | jeffsu/js2 | flavors/ringo-full.js | mainFunction | function mainFunction (arg) {
if (typeof arg == 'string') {
return JS2.Parser.parse(arg).toString();
} else if (arg instanceof Array) {
return new JS2.Array(arg);
} else {
return new JS2.Array();
}
} | javascript | function mainFunction (arg) {
if (typeof arg == 'string') {
return JS2.Parser.parse(arg).toString();
} else if (arg instanceof Array) {
return new JS2.Array(arg);
} else {
return new JS2.Array();
}
} | [
"function",
"mainFunction",
"(",
"arg",
")",
"{",
"if",
"(",
"typeof",
"arg",
"==",
"'string'",
")",
"{",
"return",
"JS2",
".",
"Parser",
".",
"parse",
"(",
"arg",
")",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"arg",
"instanceof",
"Array",
")",
"{",
"return",
"new",
"JS2",
".",
"Array",
"(",
"arg",
")",
";",
"}",
"else",
"{",
"return",
"new",
"JS2",
".",
"Array",
"(",
")",
";",
"}",
"}"
]
| temporarily set root to JS2 global var for this scope | [
"temporarily",
"set",
"root",
"to",
"JS2",
"global",
"var",
"for",
"this",
"scope"
]
| 5651e6d8ceaea1239aa162462ab9eab80c640707 | https://github.com/jeffsu/js2/blob/5651e6d8ceaea1239aa162462ab9eab80c640707/flavors/ringo-full.js#L4-L12 |
47,497 | UsabilityDynamics/node-wordpress-client | examples/get-single.js | havePosts | function havePosts( error, post ) {
this.debug( 'haveSingle' );
console.log( require( 'util' ).inspect( post, { showHidden: false, colors: true, depth: 4 } ) );
} | javascript | function havePosts( error, post ) {
this.debug( 'haveSingle' );
console.log( require( 'util' ).inspect( post, { showHidden: false, colors: true, depth: 4 } ) );
} | [
"function",
"havePosts",
"(",
"error",
",",
"post",
")",
"{",
"this",
".",
"debug",
"(",
"'haveSingle'",
")",
";",
"console",
".",
"log",
"(",
"require",
"(",
"'util'",
")",
".",
"inspect",
"(",
"post",
",",
"{",
"showHidden",
":",
"false",
",",
"colors",
":",
"true",
",",
"depth",
":",
"4",
"}",
")",
")",
";",
"}"
]
| Post Query Callback
@param error
@param post | [
"Post",
"Query",
"Callback"
]
| 2b47a7c5cadd3d8f2cfd255f997f36af14a5d843 | https://github.com/UsabilityDynamics/node-wordpress-client/blob/2b47a7c5cadd3d8f2cfd255f997f36af14a5d843/examples/get-single.js#L14-L17 |
47,498 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/wysiwygarea/plugin.js | function( data )
{
if ( iframe )
iframe.remove();
var src =
'document.open();' +
// The document domain must be set any time we
// call document.open().
( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +
'document.close();';
// With IE, the custom domain has to be taken care at first,
// for other browers, the 'src' attribute should be left empty to
// trigger iframe's 'load' event.
src =
CKEDITOR.env.air ?
'javascript:void(0)' :
CKEDITOR.env.ie ?
'javascript:void(function(){' + encodeURIComponent( src ) + '}())'
:
'';
iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' +
' style="width:100%;height:100%"' +
' frameBorder="0"' +
' title="' + frameLabel + '"' +
' src="' + src + '"' +
' tabIndex="' + ( CKEDITOR.env.webkit? -1 : editor.tabIndex ) + '"' +
' allowTransparency="true"' +
'></iframe>' );
// Running inside of Firefox chrome the load event doesn't bubble like in a normal page (#5689)
if ( document.location.protocol == 'chrome:' )
CKEDITOR.event.useCapture = true;
// With FF, it's better to load the data on iframe.load. (#3894,#4058)
iframe.on( 'load', function( ev )
{
frameLoaded = 1;
ev.removeListener();
var doc = iframe.getFrameDocument();
doc.write( data );
CKEDITOR.env.air && contentDomReady( doc.getWindow().$ );
});
// Reset adjustment back to default (#5689)
if ( document.location.protocol == 'chrome:' )
CKEDITOR.event.useCapture = false;
mainElement.append( iframe );
} | javascript | function( data )
{
if ( iframe )
iframe.remove();
var src =
'document.open();' +
// The document domain must be set any time we
// call document.open().
( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +
'document.close();';
// With IE, the custom domain has to be taken care at first,
// for other browers, the 'src' attribute should be left empty to
// trigger iframe's 'load' event.
src =
CKEDITOR.env.air ?
'javascript:void(0)' :
CKEDITOR.env.ie ?
'javascript:void(function(){' + encodeURIComponent( src ) + '}())'
:
'';
iframe = CKEDITOR.dom.element.createFromHtml( '<iframe' +
' style="width:100%;height:100%"' +
' frameBorder="0"' +
' title="' + frameLabel + '"' +
' src="' + src + '"' +
' tabIndex="' + ( CKEDITOR.env.webkit? -1 : editor.tabIndex ) + '"' +
' allowTransparency="true"' +
'></iframe>' );
// Running inside of Firefox chrome the load event doesn't bubble like in a normal page (#5689)
if ( document.location.protocol == 'chrome:' )
CKEDITOR.event.useCapture = true;
// With FF, it's better to load the data on iframe.load. (#3894,#4058)
iframe.on( 'load', function( ev )
{
frameLoaded = 1;
ev.removeListener();
var doc = iframe.getFrameDocument();
doc.write( data );
CKEDITOR.env.air && contentDomReady( doc.getWindow().$ );
});
// Reset adjustment back to default (#5689)
if ( document.location.protocol == 'chrome:' )
CKEDITOR.event.useCapture = false;
mainElement.append( iframe );
} | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"iframe",
")",
"iframe",
".",
"remove",
"(",
")",
";",
"var",
"src",
"=",
"'document.open();'",
"+",
"// The document domain must be set any time we\r",
"// call document.open().\r",
"(",
"isCustomDomain",
"?",
"(",
"'document.domain=\"'",
"+",
"document",
".",
"domain",
"+",
"'\";'",
")",
":",
"''",
")",
"+",
"'document.close();'",
";",
"// With IE, the custom domain has to be taken care at first,\r",
"// for other browers, the 'src' attribute should be left empty to\r",
"// trigger iframe's 'load' event.\r",
"src",
"=",
"CKEDITOR",
".",
"env",
".",
"air",
"?",
"'javascript:void(0)'",
":",
"CKEDITOR",
".",
"env",
".",
"ie",
"?",
"'javascript:void(function(){'",
"+",
"encodeURIComponent",
"(",
"src",
")",
"+",
"'}())'",
":",
"''",
";",
"iframe",
"=",
"CKEDITOR",
".",
"dom",
".",
"element",
".",
"createFromHtml",
"(",
"'<iframe'",
"+",
"' style=\"width:100%;height:100%\"'",
"+",
"' frameBorder=\"0\"'",
"+",
"' title=\"'",
"+",
"frameLabel",
"+",
"'\"'",
"+",
"' src=\"'",
"+",
"src",
"+",
"'\"'",
"+",
"' tabIndex=\"'",
"+",
"(",
"CKEDITOR",
".",
"env",
".",
"webkit",
"?",
"-",
"1",
":",
"editor",
".",
"tabIndex",
")",
"+",
"'\"'",
"+",
"' allowTransparency=\"true\"'",
"+",
"'></iframe>'",
")",
";",
"// Running inside of Firefox chrome the load event doesn't bubble like in a normal page (#5689)\r",
"if",
"(",
"document",
".",
"location",
".",
"protocol",
"==",
"'chrome:'",
")",
"CKEDITOR",
".",
"event",
".",
"useCapture",
"=",
"true",
";",
"// With FF, it's better to load the data on iframe.load. (#3894,#4058)\r",
"iframe",
".",
"on",
"(",
"'load'",
",",
"function",
"(",
"ev",
")",
"{",
"frameLoaded",
"=",
"1",
";",
"ev",
".",
"removeListener",
"(",
")",
";",
"var",
"doc",
"=",
"iframe",
".",
"getFrameDocument",
"(",
")",
";",
"doc",
".",
"write",
"(",
"data",
")",
";",
"CKEDITOR",
".",
"env",
".",
"air",
"&&",
"contentDomReady",
"(",
"doc",
".",
"getWindow",
"(",
")",
".",
"$",
")",
";",
"}",
")",
";",
"// Reset adjustment back to default (#5689)\r",
"if",
"(",
"document",
".",
"location",
".",
"protocol",
"==",
"'chrome:'",
")",
"CKEDITOR",
".",
"event",
".",
"useCapture",
"=",
"false",
";",
"mainElement",
".",
"append",
"(",
"iframe",
")",
";",
"}"
]
| Creates the iframe that holds the editable document. | [
"Creates",
"the",
"iframe",
"that",
"holds",
"the",
"editable",
"document",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/wysiwygarea/plugin.js#L494-L549 |
|
47,499 | saggiyogesh/nodeportal | public/ckeditor/_source/plugins/wysiwygarea/plugin.js | blinkCursor | function blinkCursor( retry )
{
if ( editor.readOnly )
return;
CKEDITOR.tools.tryThese(
function()
{
editor.document.$.designMode = 'on';
setTimeout( function()
{
editor.document.$.designMode = 'off';
if ( CKEDITOR.currentInstance == editor )
editor.document.getBody().focus();
}, 50 );
},
function()
{
// The above call is known to fail when parent DOM
// tree layout changes may break design mode. (#5782)
// Refresh the 'contentEditable' is a cue to this.
editor.document.$.designMode = 'off';
var body = editor.document.getBody();
body.setAttribute( 'contentEditable', false );
body.setAttribute( 'contentEditable', true );
// Try it again once..
!retry && blinkCursor( 1 );
});
} | javascript | function blinkCursor( retry )
{
if ( editor.readOnly )
return;
CKEDITOR.tools.tryThese(
function()
{
editor.document.$.designMode = 'on';
setTimeout( function()
{
editor.document.$.designMode = 'off';
if ( CKEDITOR.currentInstance == editor )
editor.document.getBody().focus();
}, 50 );
},
function()
{
// The above call is known to fail when parent DOM
// tree layout changes may break design mode. (#5782)
// Refresh the 'contentEditable' is a cue to this.
editor.document.$.designMode = 'off';
var body = editor.document.getBody();
body.setAttribute( 'contentEditable', false );
body.setAttribute( 'contentEditable', true );
// Try it again once..
!retry && blinkCursor( 1 );
});
} | [
"function",
"blinkCursor",
"(",
"retry",
")",
"{",
"if",
"(",
"editor",
".",
"readOnly",
")",
"return",
";",
"CKEDITOR",
".",
"tools",
".",
"tryThese",
"(",
"function",
"(",
")",
"{",
"editor",
".",
"document",
".",
"$",
".",
"designMode",
"=",
"'on'",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"editor",
".",
"document",
".",
"$",
".",
"designMode",
"=",
"'off'",
";",
"if",
"(",
"CKEDITOR",
".",
"currentInstance",
"==",
"editor",
")",
"editor",
".",
"document",
".",
"getBody",
"(",
")",
".",
"focus",
"(",
")",
";",
"}",
",",
"50",
")",
";",
"}",
",",
"function",
"(",
")",
"{",
"// The above call is known to fail when parent DOM\r",
"// tree layout changes may break design mode. (#5782)\r",
"// Refresh the 'contentEditable' is a cue to this.\r",
"editor",
".",
"document",
".",
"$",
".",
"designMode",
"=",
"'off'",
";",
"var",
"body",
"=",
"editor",
".",
"document",
".",
"getBody",
"(",
")",
";",
"body",
".",
"setAttribute",
"(",
"'contentEditable'",
",",
"false",
")",
";",
"body",
".",
"setAttribute",
"(",
"'contentEditable'",
",",
"true",
")",
";",
"// Try it again once..\r",
"!",
"retry",
"&&",
"blinkCursor",
"(",
"1",
")",
";",
"}",
")",
";",
"}"
]
| Switch on design mode for a short while and close it after then. | [
"Switch",
"on",
"design",
"mode",
"for",
"a",
"short",
"while",
"and",
"close",
"it",
"after",
"then",
"."
]
| cfd5b340f259d3a57c20892a1e2c95b133fe99ee | https://github.com/saggiyogesh/nodeportal/blob/cfd5b340f259d3a57c20892a1e2c95b133fe99ee/public/ckeditor/_source/plugins/wysiwygarea/plugin.js#L1171-L1199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.