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
|
---|---|---|---|---|---|---|---|---|---|---|---|
39,200 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( buttonSet, wrapper )
{
var buttonDef;
for ( var i=0, iLen=buttonSet.length ; i<iLen ; i++ )
{
if ( typeof buttonSet[i] == "string" )
{
if ( typeof TableTools.BUTTONS[ buttonSet[i] ] == 'undefined' )
{
alert( "TableTools: Warning - unknown button type: "+buttonSet[i] );
continue;
}
buttonDef = $.extend( {}, TableTools.BUTTONS[ buttonSet[i] ], true );
}
else
{
if ( typeof TableTools.BUTTONS[ buttonSet[i].sExtends ] == 'undefined' )
{
alert( "TableTools: Warning - unknown button type: "+buttonSet[i].sExtends );
continue;
}
var o = $.extend( {}, TableTools.BUTTONS[ buttonSet[i].sExtends ], true );
buttonDef = $.extend( o, buttonSet[i], true );
}
var button = this._fnCreateButton(
buttonDef,
$(wrapper).hasClass(this.classes.collection.container)
);
if ( button ) {
wrapper.appendChild( button );
}
}
}
|
javascript
|
function ( buttonSet, wrapper )
{
var buttonDef;
for ( var i=0, iLen=buttonSet.length ; i<iLen ; i++ )
{
if ( typeof buttonSet[i] == "string" )
{
if ( typeof TableTools.BUTTONS[ buttonSet[i] ] == 'undefined' )
{
alert( "TableTools: Warning - unknown button type: "+buttonSet[i] );
continue;
}
buttonDef = $.extend( {}, TableTools.BUTTONS[ buttonSet[i] ], true );
}
else
{
if ( typeof TableTools.BUTTONS[ buttonSet[i].sExtends ] == 'undefined' )
{
alert( "TableTools: Warning - unknown button type: "+buttonSet[i].sExtends );
continue;
}
var o = $.extend( {}, TableTools.BUTTONS[ buttonSet[i].sExtends ], true );
buttonDef = $.extend( o, buttonSet[i], true );
}
var button = this._fnCreateButton(
buttonDef,
$(wrapper).hasClass(this.classes.collection.container)
);
if ( button ) {
wrapper.appendChild( button );
}
}
}
|
[
"function",
"(",
"buttonSet",
",",
"wrapper",
")",
"{",
"var",
"buttonDef",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"buttonSet",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"typeof",
"buttonSet",
"[",
"i",
"]",
"==",
"\"string\"",
")",
"{",
"if",
"(",
"typeof",
"TableTools",
".",
"BUTTONS",
"[",
"buttonSet",
"[",
"i",
"]",
"]",
"==",
"'undefined'",
")",
"{",
"alert",
"(",
"\"TableTools: Warning - unknown button type: \"",
"+",
"buttonSet",
"[",
"i",
"]",
")",
";",
"continue",
";",
"}",
"buttonDef",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"TableTools",
".",
"BUTTONS",
"[",
"buttonSet",
"[",
"i",
"]",
"]",
",",
"true",
")",
";",
"}",
"else",
"{",
"if",
"(",
"typeof",
"TableTools",
".",
"BUTTONS",
"[",
"buttonSet",
"[",
"i",
"]",
".",
"sExtends",
"]",
"==",
"'undefined'",
")",
"{",
"alert",
"(",
"\"TableTools: Warning - unknown button type: \"",
"+",
"buttonSet",
"[",
"i",
"]",
".",
"sExtends",
")",
";",
"continue",
";",
"}",
"var",
"o",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"TableTools",
".",
"BUTTONS",
"[",
"buttonSet",
"[",
"i",
"]",
".",
"sExtends",
"]",
",",
"true",
")",
";",
"buttonDef",
"=",
"$",
".",
"extend",
"(",
"o",
",",
"buttonSet",
"[",
"i",
"]",
",",
"true",
")",
";",
"}",
"var",
"button",
"=",
"this",
".",
"_fnCreateButton",
"(",
"buttonDef",
",",
"$",
"(",
"wrapper",
")",
".",
"hasClass",
"(",
"this",
".",
"classes",
".",
"collection",
".",
"container",
")",
")",
";",
"if",
"(",
"button",
")",
"{",
"wrapper",
".",
"appendChild",
"(",
"button",
")",
";",
"}",
"}",
"}"
] |
Take the user input arrays and expand them to be fully defined, and then add them to a given
DOM element
@method _fnButtonDefinations
@param {array} buttonSet Set of user defined buttons
@param {node} wrapper Node to add the created buttons to
@returns void
@private
|
[
"Take",
"the",
"user",
"input",
"arrays",
"and",
"expand",
"them",
"to",
"be",
"fully",
"defined",
"and",
"then",
"add",
"them",
"to",
"a",
"given",
"DOM",
"element"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1234-L1269
|
|
39,201 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( oConfig, bCollectionButton )
{
var nButton = this._fnButtonBase( oConfig, bCollectionButton );
if ( oConfig.sAction.match(/flash/) )
{
if ( ! this._fnHasFlash() ) {
return false;
}
this._fnFlashConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "text" )
{
this._fnTextConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "div" )
{
this._fnTextConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "collection" )
{
this._fnTextConfig( nButton, oConfig );
this._fnCollectionConfig( nButton, oConfig );
}
if ( this.s.dt.iTabIndex !== -1 ) {
$(nButton)
.attr( 'tabindex', this.s.dt.iTabIndex )
.attr( 'aria-controls', this.s.dt.sTableId )
.on( 'keyup.DTTT', function (e) {
// Trigger the click event on return key when focused.
// Note that for Flash buttons this has no effect since we
// can't programmatically trigger the Flash export
if ( e.keyCode === 13 ) {
e.stopPropagation();
$(this).trigger( 'click' );
}
} )
.on( 'mousedown.DTTT', function (e) {
// On mousedown we want to stop the focus occurring on the
// button, focus is used only for the keyboard navigation.
// But using preventDefault for the flash buttons stops the
// flash action. However, it is not the button that gets
// focused but the flash element for flash buttons, so this
// works
if ( ! oConfig.sAction.match(/flash/) ) {
e.preventDefault();
}
} );
}
return nButton;
}
|
javascript
|
function ( oConfig, bCollectionButton )
{
var nButton = this._fnButtonBase( oConfig, bCollectionButton );
if ( oConfig.sAction.match(/flash/) )
{
if ( ! this._fnHasFlash() ) {
return false;
}
this._fnFlashConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "text" )
{
this._fnTextConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "div" )
{
this._fnTextConfig( nButton, oConfig );
}
else if ( oConfig.sAction == "collection" )
{
this._fnTextConfig( nButton, oConfig );
this._fnCollectionConfig( nButton, oConfig );
}
if ( this.s.dt.iTabIndex !== -1 ) {
$(nButton)
.attr( 'tabindex', this.s.dt.iTabIndex )
.attr( 'aria-controls', this.s.dt.sTableId )
.on( 'keyup.DTTT', function (e) {
// Trigger the click event on return key when focused.
// Note that for Flash buttons this has no effect since we
// can't programmatically trigger the Flash export
if ( e.keyCode === 13 ) {
e.stopPropagation();
$(this).trigger( 'click' );
}
} )
.on( 'mousedown.DTTT', function (e) {
// On mousedown we want to stop the focus occurring on the
// button, focus is used only for the keyboard navigation.
// But using preventDefault for the flash buttons stops the
// flash action. However, it is not the button that gets
// focused but the flash element for flash buttons, so this
// works
if ( ! oConfig.sAction.match(/flash/) ) {
e.preventDefault();
}
} );
}
return nButton;
}
|
[
"function",
"(",
"oConfig",
",",
"bCollectionButton",
")",
"{",
"var",
"nButton",
"=",
"this",
".",
"_fnButtonBase",
"(",
"oConfig",
",",
"bCollectionButton",
")",
";",
"if",
"(",
"oConfig",
".",
"sAction",
".",
"match",
"(",
"/",
"flash",
"/",
")",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_fnHasFlash",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"this",
".",
"_fnFlashConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
"else",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"text\"",
")",
"{",
"this",
".",
"_fnTextConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
"else",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"div\"",
")",
"{",
"this",
".",
"_fnTextConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
"else",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"collection\"",
")",
"{",
"this",
".",
"_fnTextConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"this",
".",
"_fnCollectionConfig",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
"if",
"(",
"this",
".",
"s",
".",
"dt",
".",
"iTabIndex",
"!==",
"-",
"1",
")",
"{",
"$",
"(",
"nButton",
")",
".",
"attr",
"(",
"'tabindex'",
",",
"this",
".",
"s",
".",
"dt",
".",
"iTabIndex",
")",
".",
"attr",
"(",
"'aria-controls'",
",",
"this",
".",
"s",
".",
"dt",
".",
"sTableId",
")",
".",
"on",
"(",
"'keyup.DTTT'",
",",
"function",
"(",
"e",
")",
"{",
"// Trigger the click event on return key when focused.",
"// Note that for Flash buttons this has no effect since we",
"// can't programmatically trigger the Flash export",
"if",
"(",
"e",
".",
"keyCode",
"===",
"13",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"$",
"(",
"this",
")",
".",
"trigger",
"(",
"'click'",
")",
";",
"}",
"}",
")",
".",
"on",
"(",
"'mousedown.DTTT'",
",",
"function",
"(",
"e",
")",
"{",
"// On mousedown we want to stop the focus occurring on the",
"// button, focus is used only for the keyboard navigation.",
"// But using preventDefault for the flash buttons stops the",
"// flash action. However, it is not the button that gets",
"// focused but the flash element for flash buttons, so this",
"// works",
"if",
"(",
"!",
"oConfig",
".",
"sAction",
".",
"match",
"(",
"/",
"flash",
"/",
")",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"return",
"nButton",
";",
"}"
] |
Create and configure a TableTools button
@method _fnCreateButton
@param {Object} oConfig Button configuration object
@returns {Node} Button element
@private
|
[
"Create",
"and",
"configure",
"a",
"TableTools",
"button"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1279-L1333
|
|
39,202 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( o, bCollectionButton )
{
var sTag, sLiner, sClass;
if ( bCollectionButton )
{
sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.collection.button;
sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.collection.liner;
sClass = this.classes.collection.buttons.normal;
}
else
{
sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.button;
sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.liner;
sClass = this.classes.buttons.normal;
}
var
nButton = document.createElement( sTag ),
nSpan = document.createElement( sLiner ),
masterS = this._fnGetMasterSettings();
nButton.className = sClass+" "+o.sButtonClass;
nButton.setAttribute('id', "ToolTables_"+this.s.dt.sInstance+"_"+masterS.buttonCounter );
nButton.appendChild( nSpan );
nSpan.innerHTML = o.sButtonText;
masterS.buttonCounter++;
return nButton;
}
|
javascript
|
function ( o, bCollectionButton )
{
var sTag, sLiner, sClass;
if ( bCollectionButton )
{
sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.collection.button;
sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.collection.liner;
sClass = this.classes.collection.buttons.normal;
}
else
{
sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.button;
sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.liner;
sClass = this.classes.buttons.normal;
}
var
nButton = document.createElement( sTag ),
nSpan = document.createElement( sLiner ),
masterS = this._fnGetMasterSettings();
nButton.className = sClass+" "+o.sButtonClass;
nButton.setAttribute('id', "ToolTables_"+this.s.dt.sInstance+"_"+masterS.buttonCounter );
nButton.appendChild( nSpan );
nSpan.innerHTML = o.sButtonText;
masterS.buttonCounter++;
return nButton;
}
|
[
"function",
"(",
"o",
",",
"bCollectionButton",
")",
"{",
"var",
"sTag",
",",
"sLiner",
",",
"sClass",
";",
"if",
"(",
"bCollectionButton",
")",
"{",
"sTag",
"=",
"o",
".",
"sTag",
"&&",
"o",
".",
"sTag",
"!==",
"\"default\"",
"?",
"o",
".",
"sTag",
":",
"this",
".",
"s",
".",
"tags",
".",
"collection",
".",
"button",
";",
"sLiner",
"=",
"o",
".",
"sLinerTag",
"&&",
"o",
".",
"sLinerTag",
"!==",
"\"default\"",
"?",
"o",
".",
"sLiner",
":",
"this",
".",
"s",
".",
"tags",
".",
"collection",
".",
"liner",
";",
"sClass",
"=",
"this",
".",
"classes",
".",
"collection",
".",
"buttons",
".",
"normal",
";",
"}",
"else",
"{",
"sTag",
"=",
"o",
".",
"sTag",
"&&",
"o",
".",
"sTag",
"!==",
"\"default\"",
"?",
"o",
".",
"sTag",
":",
"this",
".",
"s",
".",
"tags",
".",
"button",
";",
"sLiner",
"=",
"o",
".",
"sLinerTag",
"&&",
"o",
".",
"sLinerTag",
"!==",
"\"default\"",
"?",
"o",
".",
"sLiner",
":",
"this",
".",
"s",
".",
"tags",
".",
"liner",
";",
"sClass",
"=",
"this",
".",
"classes",
".",
"buttons",
".",
"normal",
";",
"}",
"var",
"nButton",
"=",
"document",
".",
"createElement",
"(",
"sTag",
")",
",",
"nSpan",
"=",
"document",
".",
"createElement",
"(",
"sLiner",
")",
",",
"masterS",
"=",
"this",
".",
"_fnGetMasterSettings",
"(",
")",
";",
"nButton",
".",
"className",
"=",
"sClass",
"+",
"\" \"",
"+",
"o",
".",
"sButtonClass",
";",
"nButton",
".",
"setAttribute",
"(",
"'id'",
",",
"\"ToolTables_\"",
"+",
"this",
".",
"s",
".",
"dt",
".",
"sInstance",
"+",
"\"_\"",
"+",
"masterS",
".",
"buttonCounter",
")",
";",
"nButton",
".",
"appendChild",
"(",
"nSpan",
")",
";",
"nSpan",
".",
"innerHTML",
"=",
"o",
".",
"sButtonText",
";",
"masterS",
".",
"buttonCounter",
"++",
";",
"return",
"nButton",
";",
"}"
] |
Create the DOM needed for the button and apply some base properties. All buttons start here
@method _fnButtonBase
@param {o} oConfig Button configuration object
@returns {Node} DIV element for the button
@private
|
[
"Create",
"the",
"DOM",
"needed",
"for",
"the",
"button",
"and",
"apply",
"some",
"base",
"properties",
".",
"All",
"buttons",
"start",
"here"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1343-L1373
|
|
39,203 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( nButton, oConfig )
{
var
that = this,
oPos = $(nButton).offset(),
nHidden = oConfig._collection,
iDivX = oPos.left,
iDivY = oPos.top + $(nButton).outerHeight(),
iWinHeight = $(window).height(), iDocHeight = $(document).height(),
iWinWidth = $(window).width(), iDocWidth = $(document).width();
nHidden.style.position = "absolute";
nHidden.style.left = iDivX+"px";
nHidden.style.top = iDivY+"px";
nHidden.style.display = "block";
$(nHidden).css('opacity',0);
var nBackground = document.createElement('div');
nBackground.style.position = "absolute";
nBackground.style.left = "0px";
nBackground.style.top = "0px";
nBackground.style.height = ((iWinHeight>iDocHeight)? iWinHeight : iDocHeight) +"px";
nBackground.style.width = ((iWinWidth>iDocWidth)? iWinWidth : iDocWidth) +"px";
nBackground.className = this.classes.collection.background;
$(nBackground).css('opacity',0);
document.body.appendChild( nBackground );
document.body.appendChild( nHidden );
/* Visual corrections to try and keep the collection visible */
var iDivWidth = $(nHidden).outerWidth();
var iDivHeight = $(nHidden).outerHeight();
if ( iDivX + iDivWidth > iDocWidth )
{
nHidden.style.left = (iDocWidth-iDivWidth)+"px";
}
if ( iDivY + iDivHeight > iDocHeight )
{
nHidden.style.top = (iDivY-iDivHeight-$(nButton).outerHeight())+"px";
}
this.dom.collection.collection = nHidden;
this.dom.collection.background = nBackground;
/* This results in a very small delay for the end user but it allows the animation to be
* much smoother. If you don't want the animation, then the setTimeout can be removed
*/
setTimeout( function () {
$(nHidden).animate({"opacity": 1}, 500);
$(nBackground).animate({"opacity": 0.25}, 500);
}, 10 );
/* Resize the buttons to the Flash contents fit */
this.fnResizeButtons();
/* Event handler to remove the collection display */
$(nBackground).click( function () {
that._fnCollectionHide.call( that, null, null );
} );
}
|
javascript
|
function ( nButton, oConfig )
{
var
that = this,
oPos = $(nButton).offset(),
nHidden = oConfig._collection,
iDivX = oPos.left,
iDivY = oPos.top + $(nButton).outerHeight(),
iWinHeight = $(window).height(), iDocHeight = $(document).height(),
iWinWidth = $(window).width(), iDocWidth = $(document).width();
nHidden.style.position = "absolute";
nHidden.style.left = iDivX+"px";
nHidden.style.top = iDivY+"px";
nHidden.style.display = "block";
$(nHidden).css('opacity',0);
var nBackground = document.createElement('div');
nBackground.style.position = "absolute";
nBackground.style.left = "0px";
nBackground.style.top = "0px";
nBackground.style.height = ((iWinHeight>iDocHeight)? iWinHeight : iDocHeight) +"px";
nBackground.style.width = ((iWinWidth>iDocWidth)? iWinWidth : iDocWidth) +"px";
nBackground.className = this.classes.collection.background;
$(nBackground).css('opacity',0);
document.body.appendChild( nBackground );
document.body.appendChild( nHidden );
/* Visual corrections to try and keep the collection visible */
var iDivWidth = $(nHidden).outerWidth();
var iDivHeight = $(nHidden).outerHeight();
if ( iDivX + iDivWidth > iDocWidth )
{
nHidden.style.left = (iDocWidth-iDivWidth)+"px";
}
if ( iDivY + iDivHeight > iDocHeight )
{
nHidden.style.top = (iDivY-iDivHeight-$(nButton).outerHeight())+"px";
}
this.dom.collection.collection = nHidden;
this.dom.collection.background = nBackground;
/* This results in a very small delay for the end user but it allows the animation to be
* much smoother. If you don't want the animation, then the setTimeout can be removed
*/
setTimeout( function () {
$(nHidden).animate({"opacity": 1}, 500);
$(nBackground).animate({"opacity": 0.25}, 500);
}, 10 );
/* Resize the buttons to the Flash contents fit */
this.fnResizeButtons();
/* Event handler to remove the collection display */
$(nBackground).click( function () {
that._fnCollectionHide.call( that, null, null );
} );
}
|
[
"function",
"(",
"nButton",
",",
"oConfig",
")",
"{",
"var",
"that",
"=",
"this",
",",
"oPos",
"=",
"$",
"(",
"nButton",
")",
".",
"offset",
"(",
")",
",",
"nHidden",
"=",
"oConfig",
".",
"_collection",
",",
"iDivX",
"=",
"oPos",
".",
"left",
",",
"iDivY",
"=",
"oPos",
".",
"top",
"+",
"$",
"(",
"nButton",
")",
".",
"outerHeight",
"(",
")",
",",
"iWinHeight",
"=",
"$",
"(",
"window",
")",
".",
"height",
"(",
")",
",",
"iDocHeight",
"=",
"$",
"(",
"document",
")",
".",
"height",
"(",
")",
",",
"iWinWidth",
"=",
"$",
"(",
"window",
")",
".",
"width",
"(",
")",
",",
"iDocWidth",
"=",
"$",
"(",
"document",
")",
".",
"width",
"(",
")",
";",
"nHidden",
".",
"style",
".",
"position",
"=",
"\"absolute\"",
";",
"nHidden",
".",
"style",
".",
"left",
"=",
"iDivX",
"+",
"\"px\"",
";",
"nHidden",
".",
"style",
".",
"top",
"=",
"iDivY",
"+",
"\"px\"",
";",
"nHidden",
".",
"style",
".",
"display",
"=",
"\"block\"",
";",
"$",
"(",
"nHidden",
")",
".",
"css",
"(",
"'opacity'",
",",
"0",
")",
";",
"var",
"nBackground",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"nBackground",
".",
"style",
".",
"position",
"=",
"\"absolute\"",
";",
"nBackground",
".",
"style",
".",
"left",
"=",
"\"0px\"",
";",
"nBackground",
".",
"style",
".",
"top",
"=",
"\"0px\"",
";",
"nBackground",
".",
"style",
".",
"height",
"=",
"(",
"(",
"iWinHeight",
">",
"iDocHeight",
")",
"?",
"iWinHeight",
":",
"iDocHeight",
")",
"+",
"\"px\"",
";",
"nBackground",
".",
"style",
".",
"width",
"=",
"(",
"(",
"iWinWidth",
">",
"iDocWidth",
")",
"?",
"iWinWidth",
":",
"iDocWidth",
")",
"+",
"\"px\"",
";",
"nBackground",
".",
"className",
"=",
"this",
".",
"classes",
".",
"collection",
".",
"background",
";",
"$",
"(",
"nBackground",
")",
".",
"css",
"(",
"'opacity'",
",",
"0",
")",
";",
"document",
".",
"body",
".",
"appendChild",
"(",
"nBackground",
")",
";",
"document",
".",
"body",
".",
"appendChild",
"(",
"nHidden",
")",
";",
"/* Visual corrections to try and keep the collection visible */",
"var",
"iDivWidth",
"=",
"$",
"(",
"nHidden",
")",
".",
"outerWidth",
"(",
")",
";",
"var",
"iDivHeight",
"=",
"$",
"(",
"nHidden",
")",
".",
"outerHeight",
"(",
")",
";",
"if",
"(",
"iDivX",
"+",
"iDivWidth",
">",
"iDocWidth",
")",
"{",
"nHidden",
".",
"style",
".",
"left",
"=",
"(",
"iDocWidth",
"-",
"iDivWidth",
")",
"+",
"\"px\"",
";",
"}",
"if",
"(",
"iDivY",
"+",
"iDivHeight",
">",
"iDocHeight",
")",
"{",
"nHidden",
".",
"style",
".",
"top",
"=",
"(",
"iDivY",
"-",
"iDivHeight",
"-",
"$",
"(",
"nButton",
")",
".",
"outerHeight",
"(",
")",
")",
"+",
"\"px\"",
";",
"}",
"this",
".",
"dom",
".",
"collection",
".",
"collection",
"=",
"nHidden",
";",
"this",
".",
"dom",
".",
"collection",
".",
"background",
"=",
"nBackground",
";",
"/* This results in a very small delay for the end user but it allows the animation to be\n\t\t * much smoother. If you don't want the animation, then the setTimeout can be removed\n\t\t */",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"$",
"(",
"nHidden",
")",
".",
"animate",
"(",
"{",
"\"opacity\"",
":",
"1",
"}",
",",
"500",
")",
";",
"$",
"(",
"nBackground",
")",
".",
"animate",
"(",
"{",
"\"opacity\"",
":",
"0.25",
"}",
",",
"500",
")",
";",
"}",
",",
"10",
")",
";",
"/* Resize the buttons to the Flash contents fit */",
"this",
".",
"fnResizeButtons",
"(",
")",
";",
"/* Event handler to remove the collection display */",
"$",
"(",
"nBackground",
")",
".",
"click",
"(",
"function",
"(",
")",
"{",
"that",
".",
"_fnCollectionHide",
".",
"call",
"(",
"that",
",",
"null",
",",
"null",
")",
";",
"}",
")",
";",
"}"
] |
Show a button collection
@param {Node} nButton Button to use for the collection
@param {Object} oConfig Button configuration object
@returns void
@private
|
[
"Show",
"a",
"button",
"collection"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1436-L1497
|
|
39,204 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( nButton, oConfig )
{
if ( oConfig !== null && oConfig.sExtends == 'collection' )
{
return;
}
if ( this.dom.collection.collection !== null )
{
$(this.dom.collection.collection).animate({"opacity": 0}, 500, function (e) {
this.style.display = "none";
} );
$(this.dom.collection.background).animate({"opacity": 0}, 500, function (e) {
this.parentNode.removeChild( this );
} );
this.dom.collection.collection = null;
this.dom.collection.background = null;
}
}
|
javascript
|
function ( nButton, oConfig )
{
if ( oConfig !== null && oConfig.sExtends == 'collection' )
{
return;
}
if ( this.dom.collection.collection !== null )
{
$(this.dom.collection.collection).animate({"opacity": 0}, 500, function (e) {
this.style.display = "none";
} );
$(this.dom.collection.background).animate({"opacity": 0}, 500, function (e) {
this.parentNode.removeChild( this );
} );
this.dom.collection.collection = null;
this.dom.collection.background = null;
}
}
|
[
"function",
"(",
"nButton",
",",
"oConfig",
")",
"{",
"if",
"(",
"oConfig",
"!==",
"null",
"&&",
"oConfig",
".",
"sExtends",
"==",
"'collection'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"this",
".",
"dom",
".",
"collection",
".",
"collection",
"!==",
"null",
")",
"{",
"$",
"(",
"this",
".",
"dom",
".",
"collection",
".",
"collection",
")",
".",
"animate",
"(",
"{",
"\"opacity\"",
":",
"0",
"}",
",",
"500",
",",
"function",
"(",
"e",
")",
"{",
"this",
".",
"style",
".",
"display",
"=",
"\"none\"",
";",
"}",
")",
";",
"$",
"(",
"this",
".",
"dom",
".",
"collection",
".",
"background",
")",
".",
"animate",
"(",
"{",
"\"opacity\"",
":",
"0",
"}",
",",
"500",
",",
"function",
"(",
"e",
")",
"{",
"this",
".",
"parentNode",
".",
"removeChild",
"(",
"this",
")",
";",
"}",
")",
";",
"this",
".",
"dom",
".",
"collection",
".",
"collection",
"=",
"null",
";",
"this",
".",
"dom",
".",
"collection",
".",
"background",
"=",
"null",
";",
"}",
"}"
] |
Hide a button collection
@param {Node} nButton Button to use for the collection
@param {Object} oConfig Button configuration object
@returns void
@private
|
[
"Hide",
"a",
"button",
"collection"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1507-L1527
|
|
39,205 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( src )
{
var out = [], pos, i, iLen;
if ( src.nodeName )
{
// Single node
pos = this.s.dt.oInstance.fnGetPosition( src );
out.push( this.s.dt.aoData[pos] );
}
else if ( typeof src.length !== 'undefined' )
{
// jQuery object or an array of nodes, or aoData points
for ( i=0, iLen=src.length ; i<iLen ; i++ )
{
if ( src[i].nodeName )
{
pos = this.s.dt.oInstance.fnGetPosition( src[i] );
out.push( this.s.dt.aoData[pos] );
}
else if ( typeof src[i] === 'number' )
{
out.push( this.s.dt.aoData[ src[i] ] );
}
else
{
out.push( src[i] );
}
}
return out;
}
else if ( typeof src === 'number' )
{
out.push(this.s.dt.aoData[src]);
}
else
{
// A single aoData point
out.push( src );
}
return out;
}
|
javascript
|
function ( src )
{
var out = [], pos, i, iLen;
if ( src.nodeName )
{
// Single node
pos = this.s.dt.oInstance.fnGetPosition( src );
out.push( this.s.dt.aoData[pos] );
}
else if ( typeof src.length !== 'undefined' )
{
// jQuery object or an array of nodes, or aoData points
for ( i=0, iLen=src.length ; i<iLen ; i++ )
{
if ( src[i].nodeName )
{
pos = this.s.dt.oInstance.fnGetPosition( src[i] );
out.push( this.s.dt.aoData[pos] );
}
else if ( typeof src[i] === 'number' )
{
out.push( this.s.dt.aoData[ src[i] ] );
}
else
{
out.push( src[i] );
}
}
return out;
}
else if ( typeof src === 'number' )
{
out.push(this.s.dt.aoData[src]);
}
else
{
// A single aoData point
out.push( src );
}
return out;
}
|
[
"function",
"(",
"src",
")",
"{",
"var",
"out",
"=",
"[",
"]",
",",
"pos",
",",
"i",
",",
"iLen",
";",
"if",
"(",
"src",
".",
"nodeName",
")",
"{",
"// Single node",
"pos",
"=",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnGetPosition",
"(",
"src",
")",
";",
"out",
".",
"push",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
"[",
"pos",
"]",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"src",
".",
"length",
"!==",
"'undefined'",
")",
"{",
"// jQuery object or an array of nodes, or aoData points",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"src",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"src",
"[",
"i",
"]",
".",
"nodeName",
")",
"{",
"pos",
"=",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnGetPosition",
"(",
"src",
"[",
"i",
"]",
")",
";",
"out",
".",
"push",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
"[",
"pos",
"]",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"src",
"[",
"i",
"]",
"===",
"'number'",
")",
"{",
"out",
".",
"push",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
"[",
"src",
"[",
"i",
"]",
"]",
")",
";",
"}",
"else",
"{",
"out",
".",
"push",
"(",
"src",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"out",
";",
"}",
"else",
"if",
"(",
"typeof",
"src",
"===",
"'number'",
")",
"{",
"out",
".",
"push",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoData",
"[",
"src",
"]",
")",
";",
"}",
"else",
"{",
"// A single aoData point",
"out",
".",
"push",
"(",
"src",
")",
";",
"}",
"return",
"out",
";",
"}"
] |
Take a data source for row selection and convert it into aoData points for the DT
@param {*} src Can be a single DOM TR node, an array of TR nodes (including a
a jQuery object), a single aoData point from DataTables, an array of aoData
points or an array of aoData indexes
@returns {array} An array of aoData points
|
[
"Take",
"a",
"data",
"source",
"for",
"row",
"selection",
"and",
"convert",
"it",
"into",
"aoData",
"points",
"for",
"the",
"DT"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1780-L1823
|
|
39,206 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( nButton, oConfig )
{
var that = this;
var flash = new ZeroClipboard_TableTools.Client();
if ( oConfig.fnInit !== null )
{
oConfig.fnInit.call( this, nButton, oConfig );
}
flash.setHandCursor( true );
if ( oConfig.sAction == "flash_save" )
{
flash.setAction( 'save' );
flash.setCharSet( (oConfig.sCharSet=="utf16le") ? 'UTF16LE' : 'UTF8' );
flash.setBomInc( oConfig.bBomInc );
flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
}
else if ( oConfig.sAction == "flash_pdf" )
{
flash.setAction( 'pdf' );
flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
}
else
{
flash.setAction( 'copy' );
}
flash.addEventListener('mouseOver', function(client) {
if ( oConfig.fnMouseover !== null )
{
oConfig.fnMouseover.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('mouseOut', function(client) {
if ( oConfig.fnMouseout !== null )
{
oConfig.fnMouseout.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('mouseDown', function(client) {
if ( oConfig.fnClick !== null )
{
oConfig.fnClick.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('complete', function (client, text) {
if ( oConfig.fnComplete !== null )
{
oConfig.fnComplete.call( that, nButton, oConfig, flash, text );
}
that._fnCollectionHide( nButton, oConfig );
} );
if ( oConfig.fnSelect !== null )
{
TableTools._fnEventListen( this, 'select', function (n) {
oConfig.fnSelect.call( that, nButton, oConfig, n );
} );
}
this._fnFlashGlue( flash, nButton, oConfig.sToolTip );
}
|
javascript
|
function ( nButton, oConfig )
{
var that = this;
var flash = new ZeroClipboard_TableTools.Client();
if ( oConfig.fnInit !== null )
{
oConfig.fnInit.call( this, nButton, oConfig );
}
flash.setHandCursor( true );
if ( oConfig.sAction == "flash_save" )
{
flash.setAction( 'save' );
flash.setCharSet( (oConfig.sCharSet=="utf16le") ? 'UTF16LE' : 'UTF8' );
flash.setBomInc( oConfig.bBomInc );
flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
}
else if ( oConfig.sAction == "flash_pdf" )
{
flash.setAction( 'pdf' );
flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
}
else
{
flash.setAction( 'copy' );
}
flash.addEventListener('mouseOver', function(client) {
if ( oConfig.fnMouseover !== null )
{
oConfig.fnMouseover.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('mouseOut', function(client) {
if ( oConfig.fnMouseout !== null )
{
oConfig.fnMouseout.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('mouseDown', function(client) {
if ( oConfig.fnClick !== null )
{
oConfig.fnClick.call( that, nButton, oConfig, flash );
}
} );
flash.addEventListener('complete', function (client, text) {
if ( oConfig.fnComplete !== null )
{
oConfig.fnComplete.call( that, nButton, oConfig, flash, text );
}
that._fnCollectionHide( nButton, oConfig );
} );
if ( oConfig.fnSelect !== null )
{
TableTools._fnEventListen( this, 'select', function (n) {
oConfig.fnSelect.call( that, nButton, oConfig, n );
} );
}
this._fnFlashGlue( flash, nButton, oConfig.sToolTip );
}
|
[
"function",
"(",
"nButton",
",",
"oConfig",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"flash",
"=",
"new",
"ZeroClipboard_TableTools",
".",
"Client",
"(",
")",
";",
"if",
"(",
"oConfig",
".",
"fnInit",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnInit",
".",
"call",
"(",
"this",
",",
"nButton",
",",
"oConfig",
")",
";",
"}",
"flash",
".",
"setHandCursor",
"(",
"true",
")",
";",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"flash_save\"",
")",
"{",
"flash",
".",
"setAction",
"(",
"'save'",
")",
";",
"flash",
".",
"setCharSet",
"(",
"(",
"oConfig",
".",
"sCharSet",
"==",
"\"utf16le\"",
")",
"?",
"'UTF16LE'",
":",
"'UTF8'",
")",
";",
"flash",
".",
"setBomInc",
"(",
"oConfig",
".",
"bBomInc",
")",
";",
"flash",
".",
"setFileName",
"(",
"oConfig",
".",
"sFileName",
".",
"replace",
"(",
"'*'",
",",
"this",
".",
"fnGetTitle",
"(",
"oConfig",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"oConfig",
".",
"sAction",
"==",
"\"flash_pdf\"",
")",
"{",
"flash",
".",
"setAction",
"(",
"'pdf'",
")",
";",
"flash",
".",
"setFileName",
"(",
"oConfig",
".",
"sFileName",
".",
"replace",
"(",
"'*'",
",",
"this",
".",
"fnGetTitle",
"(",
"oConfig",
")",
")",
")",
";",
"}",
"else",
"{",
"flash",
".",
"setAction",
"(",
"'copy'",
")",
";",
"}",
"flash",
".",
"addEventListener",
"(",
"'mouseOver'",
",",
"function",
"(",
"client",
")",
"{",
"if",
"(",
"oConfig",
".",
"fnMouseover",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnMouseover",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"flash",
")",
";",
"}",
"}",
")",
";",
"flash",
".",
"addEventListener",
"(",
"'mouseOut'",
",",
"function",
"(",
"client",
")",
"{",
"if",
"(",
"oConfig",
".",
"fnMouseout",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnMouseout",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"flash",
")",
";",
"}",
"}",
")",
";",
"flash",
".",
"addEventListener",
"(",
"'mouseDown'",
",",
"function",
"(",
"client",
")",
"{",
"if",
"(",
"oConfig",
".",
"fnClick",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnClick",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"flash",
")",
";",
"}",
"}",
")",
";",
"flash",
".",
"addEventListener",
"(",
"'complete'",
",",
"function",
"(",
"client",
",",
"text",
")",
"{",
"if",
"(",
"oConfig",
".",
"fnComplete",
"!==",
"null",
")",
"{",
"oConfig",
".",
"fnComplete",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"flash",
",",
"text",
")",
";",
"}",
"that",
".",
"_fnCollectionHide",
"(",
"nButton",
",",
"oConfig",
")",
";",
"}",
")",
";",
"if",
"(",
"oConfig",
".",
"fnSelect",
"!==",
"null",
")",
"{",
"TableTools",
".",
"_fnEventListen",
"(",
"this",
",",
"'select'",
",",
"function",
"(",
"n",
")",
"{",
"oConfig",
".",
"fnSelect",
".",
"call",
"(",
"that",
",",
"nButton",
",",
"oConfig",
",",
"n",
")",
";",
"}",
")",
";",
"}",
"this",
".",
"_fnFlashGlue",
"(",
"flash",
",",
"nButton",
",",
"oConfig",
".",
"sToolTip",
")",
";",
"}"
] |
Configure a flash based button for interaction events
@method _fnFlashConfig
@param {Node} nButton Button element which is being considered
@param {o} oConfig Button configuration object
@returns void
@private
|
[
"Configure",
"a",
"flash",
"based",
"button",
"for",
"interaction",
"events"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L1931-L1997
|
|
39,207 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( clip, sData )
{
var asData = this._fnChunkData( sData, 8192 );
clip.clearText();
for ( var i=0, iLen=asData.length ; i<iLen ; i++ )
{
clip.appendText( asData[i] );
}
}
|
javascript
|
function ( clip, sData )
{
var asData = this._fnChunkData( sData, 8192 );
clip.clearText();
for ( var i=0, iLen=asData.length ; i<iLen ; i++ )
{
clip.appendText( asData[i] );
}
}
|
[
"function",
"(",
"clip",
",",
"sData",
")",
"{",
"var",
"asData",
"=",
"this",
".",
"_fnChunkData",
"(",
"sData",
",",
"8192",
")",
";",
"clip",
".",
"clearText",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"asData",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"clip",
".",
"appendText",
"(",
"asData",
"[",
"i",
"]",
")",
";",
"}",
"}"
] |
Set the text for the flash clip to deal with
This function is required for large information sets. There is a limit on the
amount of data that can be transferred between Javascript and Flash in a single call, so
we use this method to build up the text in Flash by sending over chunks. It is estimated
that the data limit is around 64k, although it is undocumented, and appears to be different
between different flash versions. We chunk at 8KiB.
@method _fnFlashSetText
@param {Object} clip the ZeroClipboard object
@param {String} sData the data to be set
@returns void
@private
|
[
"Set",
"the",
"text",
"for",
"the",
"flash",
"clip",
"to",
"deal",
"with"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2042-L2051
|
|
39,208 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( sData, sBoundary, regex )
{
if ( sBoundary === "" )
{
return sData;
}
else
{
return sBoundary + sData.replace(regex, sBoundary+sBoundary) + sBoundary;
}
}
|
javascript
|
function ( sData, sBoundary, regex )
{
if ( sBoundary === "" )
{
return sData;
}
else
{
return sBoundary + sData.replace(regex, sBoundary+sBoundary) + sBoundary;
}
}
|
[
"function",
"(",
"sData",
",",
"sBoundary",
",",
"regex",
")",
"{",
"if",
"(",
"sBoundary",
"===",
"\"\"",
")",
"{",
"return",
"sData",
";",
"}",
"else",
"{",
"return",
"sBoundary",
"+",
"sData",
".",
"replace",
"(",
"regex",
",",
"sBoundary",
"+",
"sBoundary",
")",
"+",
"sBoundary",
";",
"}",
"}"
] |
Wrap data up with a boundary string
@method _fnBoundData
@param {String} sData data to bound
@param {String} sBoundary bounding char(s)
@param {RegExp} regex search for the bounding chars - constructed outside for efficiency
in the loop
@returns {String} bound data
@private
|
[
"Wrap",
"data",
"up",
"with",
"a",
"boundary",
"string"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2316-L2326
|
|
39,209 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( sData, iSize )
{
var asReturn = [];
var iStrlen = sData.length;
for ( var i=0 ; i<iStrlen ; i+=iSize )
{
if ( i+iSize < iStrlen )
{
asReturn.push( sData.substring( i, i+iSize ) );
}
else
{
asReturn.push( sData.substring( i, iStrlen ) );
}
}
return asReturn;
}
|
javascript
|
function ( sData, iSize )
{
var asReturn = [];
var iStrlen = sData.length;
for ( var i=0 ; i<iStrlen ; i+=iSize )
{
if ( i+iSize < iStrlen )
{
asReturn.push( sData.substring( i, i+iSize ) );
}
else
{
asReturn.push( sData.substring( i, iStrlen ) );
}
}
return asReturn;
}
|
[
"function",
"(",
"sData",
",",
"iSize",
")",
"{",
"var",
"asReturn",
"=",
"[",
"]",
";",
"var",
"iStrlen",
"=",
"sData",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"iStrlen",
";",
"i",
"+=",
"iSize",
")",
"{",
"if",
"(",
"i",
"+",
"iSize",
"<",
"iStrlen",
")",
"{",
"asReturn",
".",
"push",
"(",
"sData",
".",
"substring",
"(",
"i",
",",
"i",
"+",
"iSize",
")",
")",
";",
"}",
"else",
"{",
"asReturn",
".",
"push",
"(",
"sData",
".",
"substring",
"(",
"i",
",",
"iStrlen",
")",
")",
";",
"}",
"}",
"return",
"asReturn",
";",
"}"
] |
Break a string up into an array of smaller strings
@method _fnChunkData
@param {String} sData data to be broken up
@param {Int} iSize chunk size
@returns {Array} String array of broken up text
@private
|
[
"Break",
"a",
"string",
"up",
"into",
"an",
"array",
"of",
"smaller",
"strings"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2337-L2355
|
|
39,210 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( sData )
{
if ( sData.indexOf('&') === -1 )
{
return sData;
}
var n = document.createElement('div');
return sData.replace( /&([^\s]*?);/g, function( match, match2 ) {
if ( match.substr(1, 1) === '#' )
{
return String.fromCharCode( Number(match2.substr(1)) );
}
else
{
n.innerHTML = match;
return n.childNodes[0].nodeValue;
}
} );
}
|
javascript
|
function ( sData )
{
if ( sData.indexOf('&') === -1 )
{
return sData;
}
var n = document.createElement('div');
return sData.replace( /&([^\s]*?);/g, function( match, match2 ) {
if ( match.substr(1, 1) === '#' )
{
return String.fromCharCode( Number(match2.substr(1)) );
}
else
{
n.innerHTML = match;
return n.childNodes[0].nodeValue;
}
} );
}
|
[
"function",
"(",
"sData",
")",
"{",
"if",
"(",
"sData",
".",
"indexOf",
"(",
"'&'",
")",
"===",
"-",
"1",
")",
"{",
"return",
"sData",
";",
"}",
"var",
"n",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"return",
"sData",
".",
"replace",
"(",
"/",
"&([^\\s]*?);",
"/",
"g",
",",
"function",
"(",
"match",
",",
"match2",
")",
"{",
"if",
"(",
"match",
".",
"substr",
"(",
"1",
",",
"1",
")",
"===",
"'#'",
")",
"{",
"return",
"String",
".",
"fromCharCode",
"(",
"Number",
"(",
"match2",
".",
"substr",
"(",
"1",
")",
")",
")",
";",
"}",
"else",
"{",
"n",
".",
"innerHTML",
"=",
"match",
";",
"return",
"n",
".",
"childNodes",
"[",
"0",
"]",
".",
"nodeValue",
";",
"}",
"}",
")",
";",
"}"
] |
Decode HTML entities
@method _fnHtmlDecode
@param {String} sData encoded string
@returns {String} decoded string
@private
|
[
"Decode",
"HTML",
"entities"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2365-L2385
|
|
39,211 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( e )
{
var that = this;
var oSetDT = this.s.dt;
var oSetPrint = this.s.print;
var oDomPrint = this.dom.print;
/* Show all hidden nodes */
this._fnPrintShowNodes();
/* Restore DataTables' scrolling */
if ( oSetDT.oScroll.sX !== "" || oSetDT.oScroll.sY !== "" )
{
$(this.s.dt.nTable).unbind('draw.DTTT_Print');
this._fnPrintScrollEnd();
}
/* Restore the scroll */
window.scrollTo( 0, oSetPrint.saveScroll );
/* Drop the print message */
$('div.'+this.classes.print.message).remove();
/* Styling class */
$(document.body).removeClass( 'DTTT_Print' );
/* Restore the table length */
oSetDT._iDisplayStart = oSetPrint.saveStart;
oSetDT._iDisplayLength = oSetPrint.saveLength;
if ( oSetDT.oApi._fnCalculateEnd ) {
oSetDT.oApi._fnCalculateEnd( oSetDT );
}
oSetDT.oApi._fnDraw( oSetDT );
$(document).unbind( "keydown.DTTT" );
}
|
javascript
|
function ( e )
{
var that = this;
var oSetDT = this.s.dt;
var oSetPrint = this.s.print;
var oDomPrint = this.dom.print;
/* Show all hidden nodes */
this._fnPrintShowNodes();
/* Restore DataTables' scrolling */
if ( oSetDT.oScroll.sX !== "" || oSetDT.oScroll.sY !== "" )
{
$(this.s.dt.nTable).unbind('draw.DTTT_Print');
this._fnPrintScrollEnd();
}
/* Restore the scroll */
window.scrollTo( 0, oSetPrint.saveScroll );
/* Drop the print message */
$('div.'+this.classes.print.message).remove();
/* Styling class */
$(document.body).removeClass( 'DTTT_Print' );
/* Restore the table length */
oSetDT._iDisplayStart = oSetPrint.saveStart;
oSetDT._iDisplayLength = oSetPrint.saveLength;
if ( oSetDT.oApi._fnCalculateEnd ) {
oSetDT.oApi._fnCalculateEnd( oSetDT );
}
oSetDT.oApi._fnDraw( oSetDT );
$(document).unbind( "keydown.DTTT" );
}
|
[
"function",
"(",
"e",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"oSetDT",
"=",
"this",
".",
"s",
".",
"dt",
";",
"var",
"oSetPrint",
"=",
"this",
".",
"s",
".",
"print",
";",
"var",
"oDomPrint",
"=",
"this",
".",
"dom",
".",
"print",
";",
"/* Show all hidden nodes */",
"this",
".",
"_fnPrintShowNodes",
"(",
")",
";",
"/* Restore DataTables' scrolling */",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sX",
"!==",
"\"\"",
"||",
"oSetDT",
".",
"oScroll",
".",
"sY",
"!==",
"\"\"",
")",
"{",
"$",
"(",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
")",
".",
"unbind",
"(",
"'draw.DTTT_Print'",
")",
";",
"this",
".",
"_fnPrintScrollEnd",
"(",
")",
";",
"}",
"/* Restore the scroll */",
"window",
".",
"scrollTo",
"(",
"0",
",",
"oSetPrint",
".",
"saveScroll",
")",
";",
"/* Drop the print message */",
"$",
"(",
"'div.'",
"+",
"this",
".",
"classes",
".",
"print",
".",
"message",
")",
".",
"remove",
"(",
")",
";",
"/* Styling class */",
"$",
"(",
"document",
".",
"body",
")",
".",
"removeClass",
"(",
"'DTTT_Print'",
")",
";",
"/* Restore the table length */",
"oSetDT",
".",
"_iDisplayStart",
"=",
"oSetPrint",
".",
"saveStart",
";",
"oSetDT",
".",
"_iDisplayLength",
"=",
"oSetPrint",
".",
"saveLength",
";",
"if",
"(",
"oSetDT",
".",
"oApi",
".",
"_fnCalculateEnd",
")",
"{",
"oSetDT",
".",
"oApi",
".",
"_fnCalculateEnd",
"(",
"oSetDT",
")",
";",
"}",
"oSetDT",
".",
"oApi",
".",
"_fnDraw",
"(",
"oSetDT",
")",
";",
"$",
"(",
"document",
")",
".",
"unbind",
"(",
"\"keydown.DTTT\"",
")",
";",
"}"
] |
Printing is finished, resume normal display
@method _fnPrintEnd
@param {Event} e Event object
@returns void
@private
|
[
"Printing",
"is",
"finished",
"resume",
"normal",
"display"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2495-L2531
|
|
39,212 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ()
{
var
oSetDT = this.s.dt,
nScrollHeadInner = oSetDT.nScrollHead.getElementsByTagName('div')[0],
nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0],
nScrollBody = oSetDT.nTable.parentNode,
nTheadSize, nTfootSize;
/* Copy the header in the thead in the body table, this way we show one single table when
* in print view. Note that this section of code is more or less verbatim from DT 1.7.0
*/
nTheadSize = oSetDT.nTable.getElementsByTagName('thead');
if ( nTheadSize.length > 0 )
{
oSetDT.nTable.removeChild( nTheadSize[0] );
}
if ( oSetDT.nTFoot !== null )
{
nTfootSize = oSetDT.nTable.getElementsByTagName('tfoot');
if ( nTfootSize.length > 0 )
{
oSetDT.nTable.removeChild( nTfootSize[0] );
}
}
nTheadSize = oSetDT.nTHead.cloneNode(true);
oSetDT.nTable.insertBefore( nTheadSize, oSetDT.nTable.childNodes[0] );
if ( oSetDT.nTFoot !== null )
{
nTfootSize = oSetDT.nTFoot.cloneNode(true);
oSetDT.nTable.insertBefore( nTfootSize, oSetDT.nTable.childNodes[1] );
}
/* Now adjust the table's viewport so we can actually see it */
if ( oSetDT.oScroll.sX !== "" )
{
oSetDT.nTable.style.width = $(oSetDT.nTable).outerWidth()+"px";
nScrollBody.style.width = $(oSetDT.nTable).outerWidth()+"px";
nScrollBody.style.overflow = "visible";
}
if ( oSetDT.oScroll.sY !== "" )
{
nScrollBody.style.height = $(oSetDT.nTable).outerHeight()+"px";
nScrollBody.style.overflow = "visible";
}
}
|
javascript
|
function ()
{
var
oSetDT = this.s.dt,
nScrollHeadInner = oSetDT.nScrollHead.getElementsByTagName('div')[0],
nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0],
nScrollBody = oSetDT.nTable.parentNode,
nTheadSize, nTfootSize;
/* Copy the header in the thead in the body table, this way we show one single table when
* in print view. Note that this section of code is more or less verbatim from DT 1.7.0
*/
nTheadSize = oSetDT.nTable.getElementsByTagName('thead');
if ( nTheadSize.length > 0 )
{
oSetDT.nTable.removeChild( nTheadSize[0] );
}
if ( oSetDT.nTFoot !== null )
{
nTfootSize = oSetDT.nTable.getElementsByTagName('tfoot');
if ( nTfootSize.length > 0 )
{
oSetDT.nTable.removeChild( nTfootSize[0] );
}
}
nTheadSize = oSetDT.nTHead.cloneNode(true);
oSetDT.nTable.insertBefore( nTheadSize, oSetDT.nTable.childNodes[0] );
if ( oSetDT.nTFoot !== null )
{
nTfootSize = oSetDT.nTFoot.cloneNode(true);
oSetDT.nTable.insertBefore( nTfootSize, oSetDT.nTable.childNodes[1] );
}
/* Now adjust the table's viewport so we can actually see it */
if ( oSetDT.oScroll.sX !== "" )
{
oSetDT.nTable.style.width = $(oSetDT.nTable).outerWidth()+"px";
nScrollBody.style.width = $(oSetDT.nTable).outerWidth()+"px";
nScrollBody.style.overflow = "visible";
}
if ( oSetDT.oScroll.sY !== "" )
{
nScrollBody.style.height = $(oSetDT.nTable).outerHeight()+"px";
nScrollBody.style.overflow = "visible";
}
}
|
[
"function",
"(",
")",
"{",
"var",
"oSetDT",
"=",
"this",
".",
"s",
".",
"dt",
",",
"nScrollHeadInner",
"=",
"oSetDT",
".",
"nScrollHead",
".",
"getElementsByTagName",
"(",
"'div'",
")",
"[",
"0",
"]",
",",
"nScrollHeadTable",
"=",
"nScrollHeadInner",
".",
"getElementsByTagName",
"(",
"'table'",
")",
"[",
"0",
"]",
",",
"nScrollBody",
"=",
"oSetDT",
".",
"nTable",
".",
"parentNode",
",",
"nTheadSize",
",",
"nTfootSize",
";",
"/* Copy the header in the thead in the body table, this way we show one single table when\n\t\t * in print view. Note that this section of code is more or less verbatim from DT 1.7.0\n\t\t */",
"nTheadSize",
"=",
"oSetDT",
".",
"nTable",
".",
"getElementsByTagName",
"(",
"'thead'",
")",
";",
"if",
"(",
"nTheadSize",
".",
"length",
">",
"0",
")",
"{",
"oSetDT",
".",
"nTable",
".",
"removeChild",
"(",
"nTheadSize",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"oSetDT",
".",
"nTFoot",
"!==",
"null",
")",
"{",
"nTfootSize",
"=",
"oSetDT",
".",
"nTable",
".",
"getElementsByTagName",
"(",
"'tfoot'",
")",
";",
"if",
"(",
"nTfootSize",
".",
"length",
">",
"0",
")",
"{",
"oSetDT",
".",
"nTable",
".",
"removeChild",
"(",
"nTfootSize",
"[",
"0",
"]",
")",
";",
"}",
"}",
"nTheadSize",
"=",
"oSetDT",
".",
"nTHead",
".",
"cloneNode",
"(",
"true",
")",
";",
"oSetDT",
".",
"nTable",
".",
"insertBefore",
"(",
"nTheadSize",
",",
"oSetDT",
".",
"nTable",
".",
"childNodes",
"[",
"0",
"]",
")",
";",
"if",
"(",
"oSetDT",
".",
"nTFoot",
"!==",
"null",
")",
"{",
"nTfootSize",
"=",
"oSetDT",
".",
"nTFoot",
".",
"cloneNode",
"(",
"true",
")",
";",
"oSetDT",
".",
"nTable",
".",
"insertBefore",
"(",
"nTfootSize",
",",
"oSetDT",
".",
"nTable",
".",
"childNodes",
"[",
"1",
"]",
")",
";",
"}",
"/* Now adjust the table's viewport so we can actually see it */",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sX",
"!==",
"\"\"",
")",
"{",
"oSetDT",
".",
"nTable",
".",
"style",
".",
"width",
"=",
"$",
"(",
"oSetDT",
".",
"nTable",
")",
".",
"outerWidth",
"(",
")",
"+",
"\"px\"",
";",
"nScrollBody",
".",
"style",
".",
"width",
"=",
"$",
"(",
"oSetDT",
".",
"nTable",
")",
".",
"outerWidth",
"(",
")",
"+",
"\"px\"",
";",
"nScrollBody",
".",
"style",
".",
"overflow",
"=",
"\"visible\"",
";",
"}",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sY",
"!==",
"\"\"",
")",
"{",
"nScrollBody",
".",
"style",
".",
"height",
"=",
"$",
"(",
"oSetDT",
".",
"nTable",
")",
".",
"outerHeight",
"(",
")",
"+",
"\"px\"",
";",
"nScrollBody",
".",
"style",
".",
"overflow",
"=",
"\"visible\"",
";",
"}",
"}"
] |
Take account of scrolling in DataTables by showing the full table
@returns void
@private
|
[
"Take",
"account",
"of",
"scrolling",
"in",
"DataTables",
"by",
"showing",
"the",
"full",
"table"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2539-L2588
|
|
39,213 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ()
{
var
oSetDT = this.s.dt,
nScrollBody = oSetDT.nTable.parentNode;
if ( oSetDT.oScroll.sX !== "" )
{
nScrollBody.style.width = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sX );
nScrollBody.style.overflow = "auto";
}
if ( oSetDT.oScroll.sY !== "" )
{
nScrollBody.style.height = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sY );
nScrollBody.style.overflow = "auto";
}
}
|
javascript
|
function ()
{
var
oSetDT = this.s.dt,
nScrollBody = oSetDT.nTable.parentNode;
if ( oSetDT.oScroll.sX !== "" )
{
nScrollBody.style.width = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sX );
nScrollBody.style.overflow = "auto";
}
if ( oSetDT.oScroll.sY !== "" )
{
nScrollBody.style.height = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sY );
nScrollBody.style.overflow = "auto";
}
}
|
[
"function",
"(",
")",
"{",
"var",
"oSetDT",
"=",
"this",
".",
"s",
".",
"dt",
",",
"nScrollBody",
"=",
"oSetDT",
".",
"nTable",
".",
"parentNode",
";",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sX",
"!==",
"\"\"",
")",
"{",
"nScrollBody",
".",
"style",
".",
"width",
"=",
"oSetDT",
".",
"oApi",
".",
"_fnStringToCss",
"(",
"oSetDT",
".",
"oScroll",
".",
"sX",
")",
";",
"nScrollBody",
".",
"style",
".",
"overflow",
"=",
"\"auto\"",
";",
"}",
"if",
"(",
"oSetDT",
".",
"oScroll",
".",
"sY",
"!==",
"\"\"",
")",
"{",
"nScrollBody",
".",
"style",
".",
"height",
"=",
"oSetDT",
".",
"oApi",
".",
"_fnStringToCss",
"(",
"oSetDT",
".",
"oScroll",
".",
"sY",
")",
";",
"nScrollBody",
".",
"style",
".",
"overflow",
"=",
"\"auto\"",
";",
"}",
"}"
] |
Take account of scrolling in DataTables by showing the full table. Note that the redraw of
the DataTable that we do will actually deal with the majority of the hard work here
@returns void
@private
|
[
"Take",
"account",
"of",
"scrolling",
"in",
"DataTables",
"by",
"showing",
"the",
"full",
"table",
".",
"Note",
"that",
"the",
"redraw",
"of",
"the",
"DataTable",
"that",
"we",
"do",
"will",
"actually",
"deal",
"with",
"the",
"majority",
"of",
"the",
"hard",
"work",
"here"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2597-L2614
|
|
39,214 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( )
{
var anHidden = this.dom.print.hidden;
for ( var i=0, iLen=anHidden.length ; i<iLen ; i++ )
{
anHidden[i].node.style.display = anHidden[i].display;
}
anHidden.splice( 0, anHidden.length );
}
|
javascript
|
function ( )
{
var anHidden = this.dom.print.hidden;
for ( var i=0, iLen=anHidden.length ; i<iLen ; i++ )
{
anHidden[i].node.style.display = anHidden[i].display;
}
anHidden.splice( 0, anHidden.length );
}
|
[
"function",
"(",
")",
"{",
"var",
"anHidden",
"=",
"this",
".",
"dom",
".",
"print",
".",
"hidden",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"anHidden",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"anHidden",
"[",
"i",
"]",
".",
"node",
".",
"style",
".",
"display",
"=",
"anHidden",
"[",
"i",
"]",
".",
"display",
";",
"}",
"anHidden",
".",
"splice",
"(",
"0",
",",
"anHidden",
".",
"length",
")",
";",
"}"
] |
Resume the display of all TableTools hidden nodes
@method _fnPrintShowNodes
@returns void
@private
|
[
"Resume",
"the",
"display",
"of",
"all",
"TableTools",
"hidden",
"nodes"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2623-L2632
|
|
39,215 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js
|
function ( nNode )
{
var anHidden = this.dom.print.hidden;
var nParent = nNode.parentNode;
var nChildren = nParent.childNodes;
for ( var i=0, iLen=nChildren.length ; i<iLen ; i++ )
{
if ( nChildren[i] != nNode && nChildren[i].nodeType == 1 )
{
/* If our node is shown (don't want to show nodes which were previously hidden) */
var sDisplay = $(nChildren[i]).css("display");
if ( sDisplay != "none" )
{
/* Cache the node and it's previous state so we can restore it */
anHidden.push( {
"node": nChildren[i],
"display": sDisplay
} );
nChildren[i].style.display = "none";
}
}
}
if ( nParent.nodeName.toUpperCase() != "BODY" )
{
this._fnPrintHideNodes( nParent );
}
}
|
javascript
|
function ( nNode )
{
var anHidden = this.dom.print.hidden;
var nParent = nNode.parentNode;
var nChildren = nParent.childNodes;
for ( var i=0, iLen=nChildren.length ; i<iLen ; i++ )
{
if ( nChildren[i] != nNode && nChildren[i].nodeType == 1 )
{
/* If our node is shown (don't want to show nodes which were previously hidden) */
var sDisplay = $(nChildren[i]).css("display");
if ( sDisplay != "none" )
{
/* Cache the node and it's previous state so we can restore it */
anHidden.push( {
"node": nChildren[i],
"display": sDisplay
} );
nChildren[i].style.display = "none";
}
}
}
if ( nParent.nodeName.toUpperCase() != "BODY" )
{
this._fnPrintHideNodes( nParent );
}
}
|
[
"function",
"(",
"nNode",
")",
"{",
"var",
"anHidden",
"=",
"this",
".",
"dom",
".",
"print",
".",
"hidden",
";",
"var",
"nParent",
"=",
"nNode",
".",
"parentNode",
";",
"var",
"nChildren",
"=",
"nParent",
".",
"childNodes",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"nChildren",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"nChildren",
"[",
"i",
"]",
"!=",
"nNode",
"&&",
"nChildren",
"[",
"i",
"]",
".",
"nodeType",
"==",
"1",
")",
"{",
"/* If our node is shown (don't want to show nodes which were previously hidden) */",
"var",
"sDisplay",
"=",
"$",
"(",
"nChildren",
"[",
"i",
"]",
")",
".",
"css",
"(",
"\"display\"",
")",
";",
"if",
"(",
"sDisplay",
"!=",
"\"none\"",
")",
"{",
"/* Cache the node and it's previous state so we can restore it */",
"anHidden",
".",
"push",
"(",
"{",
"\"node\"",
":",
"nChildren",
"[",
"i",
"]",
",",
"\"display\"",
":",
"sDisplay",
"}",
")",
";",
"nChildren",
"[",
"i",
"]",
".",
"style",
".",
"display",
"=",
"\"none\"",
";",
"}",
"}",
"}",
"if",
"(",
"nParent",
".",
"nodeName",
".",
"toUpperCase",
"(",
")",
"!=",
"\"BODY\"",
")",
"{",
"this",
".",
"_fnPrintHideNodes",
"(",
"nParent",
")",
";",
"}",
"}"
] |
Hide nodes which are not needed in order to display the table. Note that this function is
recursive
@method _fnPrintHideNodes
@param {Node} nNode Element which should be showing in a 'print' display
@returns void
@private
|
[
"Hide",
"nodes",
"which",
"are",
"not",
"needed",
"in",
"order",
"to",
"display",
"the",
"table",
".",
"Note",
"that",
"this",
"function",
"is",
"recursive"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.js#L2643-L2671
|
|
39,216 |
lemonde/knex-schema
|
lib/populate.js
|
populate
|
function populate(schemas) {
var resolver = new Resolver(schemas);
// Reduce force sequential execution.
return Promise.reduce(resolver.resolve(), populateSchema.bind(this), []);
}
|
javascript
|
function populate(schemas) {
var resolver = new Resolver(schemas);
// Reduce force sequential execution.
return Promise.reduce(resolver.resolve(), populateSchema.bind(this), []);
}
|
[
"function",
"populate",
"(",
"schemas",
")",
"{",
"var",
"resolver",
"=",
"new",
"Resolver",
"(",
"schemas",
")",
";",
"// Reduce force sequential execution.",
"return",
"Promise",
".",
"reduce",
"(",
"resolver",
".",
"resolve",
"(",
")",
",",
"populateSchema",
".",
"bind",
"(",
"this",
")",
",",
"[",
"]",
")",
";",
"}"
] |
Populate schemas tables with schemas data.
@param {[Schemas]} schemas
@return {Promise}
|
[
"Populate",
"schemas",
"tables",
"with",
"schemas",
"data",
"."
] |
3e0f6cde374d240552eb08e50e123a513fda44ae
|
https://github.com/lemonde/knex-schema/blob/3e0f6cde374d240552eb08e50e123a513fda44ae/lib/populate.js#L19-L23
|
39,217 |
lemonde/knex-schema
|
lib/populate.js
|
populateSchema
|
function populateSchema(result, schema) {
var knex = this.knex;
return knex.schema.hasTable(schema.tableName)
.then(function (exists) {
if (! exists || ! schema.populate) return result;
return schema.populate(knex)
.then(function () {
return result.concat([schema]);
});
});
}
|
javascript
|
function populateSchema(result, schema) {
var knex = this.knex;
return knex.schema.hasTable(schema.tableName)
.then(function (exists) {
if (! exists || ! schema.populate) return result;
return schema.populate(knex)
.then(function () {
return result.concat([schema]);
});
});
}
|
[
"function",
"populateSchema",
"(",
"result",
",",
"schema",
")",
"{",
"var",
"knex",
"=",
"this",
".",
"knex",
";",
"return",
"knex",
".",
"schema",
".",
"hasTable",
"(",
"schema",
".",
"tableName",
")",
".",
"then",
"(",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"!",
"exists",
"||",
"!",
"schema",
".",
"populate",
")",
"return",
"result",
";",
"return",
"schema",
".",
"populate",
"(",
"knex",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"result",
".",
"concat",
"(",
"[",
"schema",
"]",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Populate schema table with schema data.
@param {[Schema]} result - reduce accumulator
@param {Schema} schema
@return {Promise}
|
[
"Populate",
"schema",
"table",
"with",
"schema",
"data",
"."
] |
3e0f6cde374d240552eb08e50e123a513fda44ae
|
https://github.com/lemonde/knex-schema/blob/3e0f6cde374d240552eb08e50e123a513fda44ae/lib/populate.js#L33-L43
|
39,218 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js
|
function ()
{
var oGrid = this.dom.grid;
var iWidth = $(oGrid.wrapper).width();
var iBodyHeight = $(this.s.dt.nTable.parentNode).outerHeight();
var iFullHeight = $(this.s.dt.nTable.parentNode.parentNode).outerHeight();
var oOverflow = this._fnDTOverflow();
var
iLeftWidth = this.s.iLeftWidth,
iRightWidth = this.s.iRightWidth,
iRight;
var scrollbarAdjust = function ( node, width ) {
if ( ! oOverflow.bar ) {
// If there is no scrollbar (Macs) we need to hide the auto scrollbar
node.style.width = (width+20)+"px";
node.style.paddingRight = "20px";
node.style.boxSizing = "border-box";
}
else {
// Otherwise just overflow by the scrollbar
node.style.width = (width+oOverflow.bar)+"px";
}
};
// When x scrolling - don't paint the fixed columns over the x scrollbar
if ( oOverflow.x )
{
iBodyHeight -= oOverflow.bar;
}
oGrid.wrapper.style.height = iFullHeight+"px";
if ( this.s.iLeftColumns > 0 )
{
oGrid.left.wrapper.style.width = iLeftWidth+"px";
oGrid.left.wrapper.style.height = "1px";
oGrid.left.body.style.height = iBodyHeight+"px";
if ( oGrid.left.foot ) {
oGrid.left.foot.style.top = (oOverflow.x ? oOverflow.bar : 0)+"px"; // shift footer for scrollbar
}
scrollbarAdjust( oGrid.left.liner, iLeftWidth );
oGrid.left.liner.style.height = iBodyHeight+"px";
}
if ( this.s.iRightColumns > 0 )
{
iRight = iWidth - iRightWidth;
if ( oOverflow.y )
{
iRight -= oOverflow.bar;
}
oGrid.right.wrapper.style.width = iRightWidth+"px";
oGrid.right.wrapper.style.left = iRight+"px";
oGrid.right.wrapper.style.height = "1px";
oGrid.right.body.style.height = iBodyHeight+"px";
if ( oGrid.right.foot ) {
oGrid.right.foot.style.top = (oOverflow.x ? oOverflow.bar : 0)+"px";
}
scrollbarAdjust( oGrid.right.liner, iRightWidth );
oGrid.right.liner.style.height = iBodyHeight+"px";
oGrid.right.headBlock.style.display = oOverflow.y ? 'block' : 'none';
oGrid.right.footBlock.style.display = oOverflow.y ? 'block' : 'none';
}
}
|
javascript
|
function ()
{
var oGrid = this.dom.grid;
var iWidth = $(oGrid.wrapper).width();
var iBodyHeight = $(this.s.dt.nTable.parentNode).outerHeight();
var iFullHeight = $(this.s.dt.nTable.parentNode.parentNode).outerHeight();
var oOverflow = this._fnDTOverflow();
var
iLeftWidth = this.s.iLeftWidth,
iRightWidth = this.s.iRightWidth,
iRight;
var scrollbarAdjust = function ( node, width ) {
if ( ! oOverflow.bar ) {
// If there is no scrollbar (Macs) we need to hide the auto scrollbar
node.style.width = (width+20)+"px";
node.style.paddingRight = "20px";
node.style.boxSizing = "border-box";
}
else {
// Otherwise just overflow by the scrollbar
node.style.width = (width+oOverflow.bar)+"px";
}
};
// When x scrolling - don't paint the fixed columns over the x scrollbar
if ( oOverflow.x )
{
iBodyHeight -= oOverflow.bar;
}
oGrid.wrapper.style.height = iFullHeight+"px";
if ( this.s.iLeftColumns > 0 )
{
oGrid.left.wrapper.style.width = iLeftWidth+"px";
oGrid.left.wrapper.style.height = "1px";
oGrid.left.body.style.height = iBodyHeight+"px";
if ( oGrid.left.foot ) {
oGrid.left.foot.style.top = (oOverflow.x ? oOverflow.bar : 0)+"px"; // shift footer for scrollbar
}
scrollbarAdjust( oGrid.left.liner, iLeftWidth );
oGrid.left.liner.style.height = iBodyHeight+"px";
}
if ( this.s.iRightColumns > 0 )
{
iRight = iWidth - iRightWidth;
if ( oOverflow.y )
{
iRight -= oOverflow.bar;
}
oGrid.right.wrapper.style.width = iRightWidth+"px";
oGrid.right.wrapper.style.left = iRight+"px";
oGrid.right.wrapper.style.height = "1px";
oGrid.right.body.style.height = iBodyHeight+"px";
if ( oGrid.right.foot ) {
oGrid.right.foot.style.top = (oOverflow.x ? oOverflow.bar : 0)+"px";
}
scrollbarAdjust( oGrid.right.liner, iRightWidth );
oGrid.right.liner.style.height = iBodyHeight+"px";
oGrid.right.headBlock.style.display = oOverflow.y ? 'block' : 'none';
oGrid.right.footBlock.style.display = oOverflow.y ? 'block' : 'none';
}
}
|
[
"function",
"(",
")",
"{",
"var",
"oGrid",
"=",
"this",
".",
"dom",
".",
"grid",
";",
"var",
"iWidth",
"=",
"$",
"(",
"oGrid",
".",
"wrapper",
")",
".",
"width",
"(",
")",
";",
"var",
"iBodyHeight",
"=",
"$",
"(",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
".",
"parentNode",
")",
".",
"outerHeight",
"(",
")",
";",
"var",
"iFullHeight",
"=",
"$",
"(",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
".",
"parentNode",
".",
"parentNode",
")",
".",
"outerHeight",
"(",
")",
";",
"var",
"oOverflow",
"=",
"this",
".",
"_fnDTOverflow",
"(",
")",
";",
"var",
"iLeftWidth",
"=",
"this",
".",
"s",
".",
"iLeftWidth",
",",
"iRightWidth",
"=",
"this",
".",
"s",
".",
"iRightWidth",
",",
"iRight",
";",
"var",
"scrollbarAdjust",
"=",
"function",
"(",
"node",
",",
"width",
")",
"{",
"if",
"(",
"!",
"oOverflow",
".",
"bar",
")",
"{",
"// If there is no scrollbar (Macs) we need to hide the auto scrollbar",
"node",
".",
"style",
".",
"width",
"=",
"(",
"width",
"+",
"20",
")",
"+",
"\"px\"",
";",
"node",
".",
"style",
".",
"paddingRight",
"=",
"\"20px\"",
";",
"node",
".",
"style",
".",
"boxSizing",
"=",
"\"border-box\"",
";",
"}",
"else",
"{",
"// Otherwise just overflow by the scrollbar",
"node",
".",
"style",
".",
"width",
"=",
"(",
"width",
"+",
"oOverflow",
".",
"bar",
")",
"+",
"\"px\"",
";",
"}",
"}",
";",
"// When x scrolling - don't paint the fixed columns over the x scrollbar",
"if",
"(",
"oOverflow",
".",
"x",
")",
"{",
"iBodyHeight",
"-=",
"oOverflow",
".",
"bar",
";",
"}",
"oGrid",
".",
"wrapper",
".",
"style",
".",
"height",
"=",
"iFullHeight",
"+",
"\"px\"",
";",
"if",
"(",
"this",
".",
"s",
".",
"iLeftColumns",
">",
"0",
")",
"{",
"oGrid",
".",
"left",
".",
"wrapper",
".",
"style",
".",
"width",
"=",
"iLeftWidth",
"+",
"\"px\"",
";",
"oGrid",
".",
"left",
".",
"wrapper",
".",
"style",
".",
"height",
"=",
"\"1px\"",
";",
"oGrid",
".",
"left",
".",
"body",
".",
"style",
".",
"height",
"=",
"iBodyHeight",
"+",
"\"px\"",
";",
"if",
"(",
"oGrid",
".",
"left",
".",
"foot",
")",
"{",
"oGrid",
".",
"left",
".",
"foot",
".",
"style",
".",
"top",
"=",
"(",
"oOverflow",
".",
"x",
"?",
"oOverflow",
".",
"bar",
":",
"0",
")",
"+",
"\"px\"",
";",
"// shift footer for scrollbar",
"}",
"scrollbarAdjust",
"(",
"oGrid",
".",
"left",
".",
"liner",
",",
"iLeftWidth",
")",
";",
"oGrid",
".",
"left",
".",
"liner",
".",
"style",
".",
"height",
"=",
"iBodyHeight",
"+",
"\"px\"",
";",
"}",
"if",
"(",
"this",
".",
"s",
".",
"iRightColumns",
">",
"0",
")",
"{",
"iRight",
"=",
"iWidth",
"-",
"iRightWidth",
";",
"if",
"(",
"oOverflow",
".",
"y",
")",
"{",
"iRight",
"-=",
"oOverflow",
".",
"bar",
";",
"}",
"oGrid",
".",
"right",
".",
"wrapper",
".",
"style",
".",
"width",
"=",
"iRightWidth",
"+",
"\"px\"",
";",
"oGrid",
".",
"right",
".",
"wrapper",
".",
"style",
".",
"left",
"=",
"iRight",
"+",
"\"px\"",
";",
"oGrid",
".",
"right",
".",
"wrapper",
".",
"style",
".",
"height",
"=",
"\"1px\"",
";",
"oGrid",
".",
"right",
".",
"body",
".",
"style",
".",
"height",
"=",
"iBodyHeight",
"+",
"\"px\"",
";",
"if",
"(",
"oGrid",
".",
"right",
".",
"foot",
")",
"{",
"oGrid",
".",
"right",
".",
"foot",
".",
"style",
".",
"top",
"=",
"(",
"oOverflow",
".",
"x",
"?",
"oOverflow",
".",
"bar",
":",
"0",
")",
"+",
"\"px\"",
";",
"}",
"scrollbarAdjust",
"(",
"oGrid",
".",
"right",
".",
"liner",
",",
"iRightWidth",
")",
";",
"oGrid",
".",
"right",
".",
"liner",
".",
"style",
".",
"height",
"=",
"iBodyHeight",
"+",
"\"px\"",
";",
"oGrid",
".",
"right",
".",
"headBlock",
".",
"style",
".",
"display",
"=",
"oOverflow",
".",
"y",
"?",
"'block'",
":",
"'none'",
";",
"oGrid",
".",
"right",
".",
"footBlock",
".",
"style",
".",
"display",
"=",
"oOverflow",
".",
"y",
"?",
"'block'",
":",
"'none'",
";",
"}",
"}"
] |
Style and position the grid used for the FixedColumns layout
@returns {void}
@private
|
[
"Style",
"and",
"position",
"the",
"grid",
"used",
"for",
"the",
"FixedColumns",
"layout"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js#L740-L807
|
|
39,219 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js
|
function ()
{
var nTable = this.s.dt.nTable;
var nTableScrollBody = nTable.parentNode;
var out = {
"x": false,
"y": false,
"bar": this.s.dt.oScroll.iBarWidth
};
if ( nTable.offsetWidth > nTableScrollBody.clientWidth )
{
out.x = true;
}
if ( nTable.offsetHeight > nTableScrollBody.clientHeight )
{
out.y = true;
}
return out;
}
|
javascript
|
function ()
{
var nTable = this.s.dt.nTable;
var nTableScrollBody = nTable.parentNode;
var out = {
"x": false,
"y": false,
"bar": this.s.dt.oScroll.iBarWidth
};
if ( nTable.offsetWidth > nTableScrollBody.clientWidth )
{
out.x = true;
}
if ( nTable.offsetHeight > nTableScrollBody.clientHeight )
{
out.y = true;
}
return out;
}
|
[
"function",
"(",
")",
"{",
"var",
"nTable",
"=",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
";",
"var",
"nTableScrollBody",
"=",
"nTable",
".",
"parentNode",
";",
"var",
"out",
"=",
"{",
"\"x\"",
":",
"false",
",",
"\"y\"",
":",
"false",
",",
"\"bar\"",
":",
"this",
".",
"s",
".",
"dt",
".",
"oScroll",
".",
"iBarWidth",
"}",
";",
"if",
"(",
"nTable",
".",
"offsetWidth",
">",
"nTableScrollBody",
".",
"clientWidth",
")",
"{",
"out",
".",
"x",
"=",
"true",
";",
"}",
"if",
"(",
"nTable",
".",
"offsetHeight",
">",
"nTableScrollBody",
".",
"clientHeight",
")",
"{",
"out",
".",
"y",
"=",
"true",
";",
"}",
"return",
"out",
";",
"}"
] |
Get information about the DataTable's scrolling state - specifically if the table is scrolling
on either the x or y axis, and also the scrollbar width.
@returns {object} Information about the DataTables scrolling state with the properties:
'x', 'y' and 'bar'
@private
|
[
"Get",
"information",
"about",
"the",
"DataTable",
"s",
"scrolling",
"state",
"-",
"specifically",
"if",
"the",
"table",
"is",
"scrolling",
"on",
"either",
"the",
"x",
"or",
"y",
"axis",
"and",
"also",
"the",
"scrollbar",
"width",
"."
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js#L817-L838
|
|
39,220 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js
|
function ( bAll )
{
this._fnGridLayout();
this._fnCloneLeft( bAll );
this._fnCloneRight( bAll );
/* Draw callback function */
if ( this.s.fnDrawCallback !== null )
{
this.s.fnDrawCallback.call( this, this.dom.clone.left, this.dom.clone.right );
}
/* Event triggering */
$(this).trigger( 'draw.dtfc', {
"leftClone": this.dom.clone.left,
"rightClone": this.dom.clone.right
} );
}
|
javascript
|
function ( bAll )
{
this._fnGridLayout();
this._fnCloneLeft( bAll );
this._fnCloneRight( bAll );
/* Draw callback function */
if ( this.s.fnDrawCallback !== null )
{
this.s.fnDrawCallback.call( this, this.dom.clone.left, this.dom.clone.right );
}
/* Event triggering */
$(this).trigger( 'draw.dtfc', {
"leftClone": this.dom.clone.left,
"rightClone": this.dom.clone.right
} );
}
|
[
"function",
"(",
"bAll",
")",
"{",
"this",
".",
"_fnGridLayout",
"(",
")",
";",
"this",
".",
"_fnCloneLeft",
"(",
"bAll",
")",
";",
"this",
".",
"_fnCloneRight",
"(",
"bAll",
")",
";",
"/* Draw callback function */",
"if",
"(",
"this",
".",
"s",
".",
"fnDrawCallback",
"!==",
"null",
")",
"{",
"this",
".",
"s",
".",
"fnDrawCallback",
".",
"call",
"(",
"this",
",",
"this",
".",
"dom",
".",
"clone",
".",
"left",
",",
"this",
".",
"dom",
".",
"clone",
".",
"right",
")",
";",
"}",
"/* Event triggering */",
"$",
"(",
"this",
")",
".",
"trigger",
"(",
"'draw.dtfc'",
",",
"{",
"\"leftClone\"",
":",
"this",
".",
"dom",
".",
"clone",
".",
"left",
",",
"\"rightClone\"",
":",
"this",
".",
"dom",
".",
"clone",
".",
"right",
"}",
")",
";",
"}"
] |
Clone and position the fixed columns
@returns {void}
@param {Boolean} bAll Indicate if the header and footer should be updated as well (true)
@private
|
[
"Clone",
"and",
"position",
"the",
"fixed",
"columns"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js#L847-L864
|
|
39,221 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js
|
function ( bAll )
{
if ( this.s.iRightColumns <= 0 ) {
return;
}
var that = this,
i, jq,
aiColumns = [];
for ( i=this.s.iTableColumns-this.s.iRightColumns ; i<this.s.iTableColumns ; i++ ) {
if ( this.s.dt.aoColumns[i].bVisible ) {
aiColumns.push( i );
}
}
this._fnClone( this.dom.clone.right, this.dom.grid.right, aiColumns, bAll );
}
|
javascript
|
function ( bAll )
{
if ( this.s.iRightColumns <= 0 ) {
return;
}
var that = this,
i, jq,
aiColumns = [];
for ( i=this.s.iTableColumns-this.s.iRightColumns ; i<this.s.iTableColumns ; i++ ) {
if ( this.s.dt.aoColumns[i].bVisible ) {
aiColumns.push( i );
}
}
this._fnClone( this.dom.clone.right, this.dom.grid.right, aiColumns, bAll );
}
|
[
"function",
"(",
"bAll",
")",
"{",
"if",
"(",
"this",
".",
"s",
".",
"iRightColumns",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"var",
"that",
"=",
"this",
",",
"i",
",",
"jq",
",",
"aiColumns",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"this",
".",
"s",
".",
"iTableColumns",
"-",
"this",
".",
"s",
".",
"iRightColumns",
";",
"i",
"<",
"this",
".",
"s",
".",
"iTableColumns",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
"[",
"i",
"]",
".",
"bVisible",
")",
"{",
"aiColumns",
".",
"push",
"(",
"i",
")",
";",
"}",
"}",
"this",
".",
"_fnClone",
"(",
"this",
".",
"dom",
".",
"clone",
".",
"right",
",",
"this",
".",
"dom",
".",
"grid",
".",
"right",
",",
"aiColumns",
",",
"bAll",
")",
";",
"}"
] |
Clone the right columns
@returns {void}
@param {Boolean} bAll Indicate if the header and footer should be updated as well (true)
@private
|
[
"Clone",
"the",
"right",
"columns"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js#L873-L890
|
|
39,222 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js
|
function ( bAll )
{
if ( this.s.iLeftColumns <= 0 ) {
return;
}
var that = this,
i, jq,
aiColumns = [];
for ( i=0 ; i<this.s.iLeftColumns ; i++ ) {
if ( this.s.dt.aoColumns[i].bVisible ) {
aiColumns.push( i );
}
}
this._fnClone( this.dom.clone.left, this.dom.grid.left, aiColumns, bAll );
}
|
javascript
|
function ( bAll )
{
if ( this.s.iLeftColumns <= 0 ) {
return;
}
var that = this,
i, jq,
aiColumns = [];
for ( i=0 ; i<this.s.iLeftColumns ; i++ ) {
if ( this.s.dt.aoColumns[i].bVisible ) {
aiColumns.push( i );
}
}
this._fnClone( this.dom.clone.left, this.dom.grid.left, aiColumns, bAll );
}
|
[
"function",
"(",
"bAll",
")",
"{",
"if",
"(",
"this",
".",
"s",
".",
"iLeftColumns",
"<=",
"0",
")",
"{",
"return",
";",
"}",
"var",
"that",
"=",
"this",
",",
"i",
",",
"jq",
",",
"aiColumns",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"s",
".",
"iLeftColumns",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
"[",
"i",
"]",
".",
"bVisible",
")",
"{",
"aiColumns",
".",
"push",
"(",
"i",
")",
";",
"}",
"}",
"this",
".",
"_fnClone",
"(",
"this",
".",
"dom",
".",
"clone",
".",
"left",
",",
"this",
".",
"dom",
".",
"grid",
".",
"left",
",",
"aiColumns",
",",
"bAll",
")",
";",
"}"
] |
Clone the left columns
@returns {void}
@param {Boolean} bAll Indicate if the header and footer should be updated as well (true)
@private
|
[
"Clone",
"the",
"left",
"columns"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js#L899-L916
|
|
39,223 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js
|
function ( aoOriginal, aiColumns )
{
var aReturn = [];
var aClones = [];
var aCloned = [];
for ( var i=0, iLen=aoOriginal.length ; i<iLen ; i++ )
{
var aRow = [];
aRow.nTr = $(aoOriginal[i].nTr).clone(true, true)[0];
for ( var j=0, jLen=this.s.iTableColumns ; j<jLen ; j++ )
{
if ( $.inArray( j, aiColumns ) === -1 )
{
continue;
}
var iCloned = $.inArray( aoOriginal[i][j].cell, aCloned );
if ( iCloned === -1 )
{
var nClone = $(aoOriginal[i][j].cell).clone(true, true)[0];
aClones.push( nClone );
aCloned.push( aoOriginal[i][j].cell );
aRow.push( {
"cell": nClone,
"unique": aoOriginal[i][j].unique
} );
}
else
{
aRow.push( {
"cell": aClones[ iCloned ],
"unique": aoOriginal[i][j].unique
} );
}
}
aReturn.push( aRow );
}
return aReturn;
}
|
javascript
|
function ( aoOriginal, aiColumns )
{
var aReturn = [];
var aClones = [];
var aCloned = [];
for ( var i=0, iLen=aoOriginal.length ; i<iLen ; i++ )
{
var aRow = [];
aRow.nTr = $(aoOriginal[i].nTr).clone(true, true)[0];
for ( var j=0, jLen=this.s.iTableColumns ; j<jLen ; j++ )
{
if ( $.inArray( j, aiColumns ) === -1 )
{
continue;
}
var iCloned = $.inArray( aoOriginal[i][j].cell, aCloned );
if ( iCloned === -1 )
{
var nClone = $(aoOriginal[i][j].cell).clone(true, true)[0];
aClones.push( nClone );
aCloned.push( aoOriginal[i][j].cell );
aRow.push( {
"cell": nClone,
"unique": aoOriginal[i][j].unique
} );
}
else
{
aRow.push( {
"cell": aClones[ iCloned ],
"unique": aoOriginal[i][j].unique
} );
}
}
aReturn.push( aRow );
}
return aReturn;
}
|
[
"function",
"(",
"aoOriginal",
",",
"aiColumns",
")",
"{",
"var",
"aReturn",
"=",
"[",
"]",
";",
"var",
"aClones",
"=",
"[",
"]",
";",
"var",
"aCloned",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"aoOriginal",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"var",
"aRow",
"=",
"[",
"]",
";",
"aRow",
".",
"nTr",
"=",
"$",
"(",
"aoOriginal",
"[",
"i",
"]",
".",
"nTr",
")",
".",
"clone",
"(",
"true",
",",
"true",
")",
"[",
"0",
"]",
";",
"for",
"(",
"var",
"j",
"=",
"0",
",",
"jLen",
"=",
"this",
".",
"s",
".",
"iTableColumns",
";",
"j",
"<",
"jLen",
";",
"j",
"++",
")",
"{",
"if",
"(",
"$",
".",
"inArray",
"(",
"j",
",",
"aiColumns",
")",
"===",
"-",
"1",
")",
"{",
"continue",
";",
"}",
"var",
"iCloned",
"=",
"$",
".",
"inArray",
"(",
"aoOriginal",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"cell",
",",
"aCloned",
")",
";",
"if",
"(",
"iCloned",
"===",
"-",
"1",
")",
"{",
"var",
"nClone",
"=",
"$",
"(",
"aoOriginal",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"cell",
")",
".",
"clone",
"(",
"true",
",",
"true",
")",
"[",
"0",
"]",
";",
"aClones",
".",
"push",
"(",
"nClone",
")",
";",
"aCloned",
".",
"push",
"(",
"aoOriginal",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"cell",
")",
";",
"aRow",
".",
"push",
"(",
"{",
"\"cell\"",
":",
"nClone",
",",
"\"unique\"",
":",
"aoOriginal",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"unique",
"}",
")",
";",
"}",
"else",
"{",
"aRow",
".",
"push",
"(",
"{",
"\"cell\"",
":",
"aClones",
"[",
"iCloned",
"]",
",",
"\"unique\"",
":",
"aoOriginal",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"unique",
"}",
")",
";",
"}",
"}",
"aReturn",
".",
"push",
"(",
"aRow",
")",
";",
"}",
"return",
"aReturn",
";",
"}"
] |
Make a copy of the layout object for a header or footer element from DataTables. Note that
this method will clone the nodes in the layout object.
@returns {Array} Copy of the layout array
@param {Object} aoOriginal Layout array from DataTables (aoHeader or aoFooter)
@param {Object} aiColumns Columns to copy
@private
|
[
"Make",
"a",
"copy",
"of",
"the",
"layout",
"object",
"for",
"a",
"header",
"or",
"footer",
"element",
"from",
"DataTables",
".",
"Note",
"that",
"this",
"method",
"will",
"clone",
"the",
"nodes",
"in",
"the",
"layout",
"object",
"."
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js#L927-L970
|
|
39,224 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js
|
function ( nodeName, original, clone )
{
if ( this.s.sHeightMatch == 'none' && nodeName !== 'thead' && nodeName !== 'tfoot' )
{
return;
}
var that = this,
i, iLen, iHeight, iHeight2, iHeightOriginal, iHeightClone,
rootOriginal = original.getElementsByTagName(nodeName)[0],
rootClone = clone.getElementsByTagName(nodeName)[0],
jqBoxHack = $('>'+nodeName+'>tr:eq(0)', original).children(':first'),
iBoxHack = jqBoxHack.outerHeight() - jqBoxHack.height(),
anOriginal = this._fnGetTrNodes( rootOriginal ),
anClone = this._fnGetTrNodes( rootClone ),
heights = [];
for ( i=0, iLen=anClone.length ; i<iLen ; i++ )
{
iHeightOriginal = anOriginal[i].offsetHeight;
iHeightClone = anClone[i].offsetHeight;
iHeight = iHeightClone > iHeightOriginal ? iHeightClone : iHeightOriginal;
if ( this.s.sHeightMatch == 'semiauto' )
{
anOriginal[i]._DTTC_iHeight = iHeight;
}
heights.push( iHeight );
}
for ( i=0, iLen=anClone.length ; i<iLen ; i++ )
{
anClone[i].style.height = heights[i]+"px";
anOriginal[i].style.height = heights[i]+"px";
}
}
|
javascript
|
function ( nodeName, original, clone )
{
if ( this.s.sHeightMatch == 'none' && nodeName !== 'thead' && nodeName !== 'tfoot' )
{
return;
}
var that = this,
i, iLen, iHeight, iHeight2, iHeightOriginal, iHeightClone,
rootOriginal = original.getElementsByTagName(nodeName)[0],
rootClone = clone.getElementsByTagName(nodeName)[0],
jqBoxHack = $('>'+nodeName+'>tr:eq(0)', original).children(':first'),
iBoxHack = jqBoxHack.outerHeight() - jqBoxHack.height(),
anOriginal = this._fnGetTrNodes( rootOriginal ),
anClone = this._fnGetTrNodes( rootClone ),
heights = [];
for ( i=0, iLen=anClone.length ; i<iLen ; i++ )
{
iHeightOriginal = anOriginal[i].offsetHeight;
iHeightClone = anClone[i].offsetHeight;
iHeight = iHeightClone > iHeightOriginal ? iHeightClone : iHeightOriginal;
if ( this.s.sHeightMatch == 'semiauto' )
{
anOriginal[i]._DTTC_iHeight = iHeight;
}
heights.push( iHeight );
}
for ( i=0, iLen=anClone.length ; i<iLen ; i++ )
{
anClone[i].style.height = heights[i]+"px";
anOriginal[i].style.height = heights[i]+"px";
}
}
|
[
"function",
"(",
"nodeName",
",",
"original",
",",
"clone",
")",
"{",
"if",
"(",
"this",
".",
"s",
".",
"sHeightMatch",
"==",
"'none'",
"&&",
"nodeName",
"!==",
"'thead'",
"&&",
"nodeName",
"!==",
"'tfoot'",
")",
"{",
"return",
";",
"}",
"var",
"that",
"=",
"this",
",",
"i",
",",
"iLen",
",",
"iHeight",
",",
"iHeight2",
",",
"iHeightOriginal",
",",
"iHeightClone",
",",
"rootOriginal",
"=",
"original",
".",
"getElementsByTagName",
"(",
"nodeName",
")",
"[",
"0",
"]",
",",
"rootClone",
"=",
"clone",
".",
"getElementsByTagName",
"(",
"nodeName",
")",
"[",
"0",
"]",
",",
"jqBoxHack",
"=",
"$",
"(",
"'>'",
"+",
"nodeName",
"+",
"'>tr:eq(0)'",
",",
"original",
")",
".",
"children",
"(",
"':first'",
")",
",",
"iBoxHack",
"=",
"jqBoxHack",
".",
"outerHeight",
"(",
")",
"-",
"jqBoxHack",
".",
"height",
"(",
")",
",",
"anOriginal",
"=",
"this",
".",
"_fnGetTrNodes",
"(",
"rootOriginal",
")",
",",
"anClone",
"=",
"this",
".",
"_fnGetTrNodes",
"(",
"rootClone",
")",
",",
"heights",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"anClone",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"iHeightOriginal",
"=",
"anOriginal",
"[",
"i",
"]",
".",
"offsetHeight",
";",
"iHeightClone",
"=",
"anClone",
"[",
"i",
"]",
".",
"offsetHeight",
";",
"iHeight",
"=",
"iHeightClone",
">",
"iHeightOriginal",
"?",
"iHeightClone",
":",
"iHeightOriginal",
";",
"if",
"(",
"this",
".",
"s",
".",
"sHeightMatch",
"==",
"'semiauto'",
")",
"{",
"anOriginal",
"[",
"i",
"]",
".",
"_DTTC_iHeight",
"=",
"iHeight",
";",
"}",
"heights",
".",
"push",
"(",
"iHeight",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"anClone",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"anClone",
"[",
"i",
"]",
".",
"style",
".",
"height",
"=",
"heights",
"[",
"i",
"]",
"+",
"\"px\"",
";",
"anOriginal",
"[",
"i",
"]",
".",
"style",
".",
"height",
"=",
"heights",
"[",
"i",
"]",
"+",
"\"px\"",
";",
"}",
"}"
] |
Equalise the heights of the rows in a given table node in a cross browser way
@returns {void}
@param {String} nodeName Node type - thead, tbody or tfoot
@param {Node} original Original node to take the heights from
@param {Node} clone Copy the heights to
@private
|
[
"Equalise",
"the",
"heights",
"of",
"the",
"rows",
"in",
"a",
"given",
"table",
"node",
"in",
"a",
"cross",
"browser",
"way"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/FixedColumns/js/dataTables.fixedColumns.js#L1246-L1282
|
|
39,225 |
tmcw-up-for-adoption/color-ops
|
index.js
|
function(r, g, b, a) {
var rgb = [r, g, b].map(function (c) { return number(c); });
a = number(a);
if (rgb.some(isNaN) || isNaN(a)) return null;
rgb.push(a);
return rgb;
}
|
javascript
|
function(r, g, b, a) {
var rgb = [r, g, b].map(function (c) { return number(c); });
a = number(a);
if (rgb.some(isNaN) || isNaN(a)) return null;
rgb.push(a);
return rgb;
}
|
[
"function",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
")",
"{",
"var",
"rgb",
"=",
"[",
"r",
",",
"g",
",",
"b",
"]",
".",
"map",
"(",
"function",
"(",
"c",
")",
"{",
"return",
"number",
"(",
"c",
")",
";",
"}",
")",
";",
"a",
"=",
"number",
"(",
"a",
")",
";",
"if",
"(",
"rgb",
".",
"some",
"(",
"isNaN",
")",
"||",
"isNaN",
"(",
"a",
")",
")",
"return",
"null",
";",
"rgb",
".",
"push",
"(",
"a",
")",
";",
"return",
"rgb",
";",
"}"
] |
Given an rgba color as number-like objects, return that array
with numbers if possible, and null otherwise
@param {number} r red
@param {number} g green
@param {number} b blue
@param {number} a alpha
@returns {Array} rgba array
|
[
"Given",
"an",
"rgba",
"color",
"as",
"number",
"-",
"like",
"objects",
"return",
"that",
"array",
"with",
"numbers",
"if",
"possible",
"and",
"null",
"otherwise"
] |
eaa5b1ec2f679ac0ce850dc193621ff17fbf26da
|
https://github.com/tmcw-up-for-adoption/color-ops/blob/eaa5b1ec2f679ac0ce850dc193621ff17fbf26da/index.js#L52-L58
|
|
39,226 |
tmcw-up-for-adoption/color-ops
|
index.js
|
function(h, s, l, a) {
h = (number(h) % 360) / 360;
s = number(s); l = number(l); a = number(a);
if ([h, s, l, a].some(isNaN)) return null;
var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s,
m1 = l * 2 - m2;
return this.rgba(hue(h + 1 / 3) * 255,
hue(h) * 255,
hue(h - 1 / 3) * 255,
a);
function hue(h) {
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
else if (h * 2 < 1) return m2;
else if (h * 3 < 2) return m1 + (m2 - m1) * (2 / 3 - h) * 6;
else return m1;
}
}
|
javascript
|
function(h, s, l, a) {
h = (number(h) % 360) / 360;
s = number(s); l = number(l); a = number(a);
if ([h, s, l, a].some(isNaN)) return null;
var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s,
m1 = l * 2 - m2;
return this.rgba(hue(h + 1 / 3) * 255,
hue(h) * 255,
hue(h - 1 / 3) * 255,
a);
function hue(h) {
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
else if (h * 2 < 1) return m2;
else if (h * 3 < 2) return m1 + (m2 - m1) * (2 / 3 - h) * 6;
else return m1;
}
}
|
[
"function",
"(",
"h",
",",
"s",
",",
"l",
",",
"a",
")",
"{",
"h",
"=",
"(",
"number",
"(",
"h",
")",
"%",
"360",
")",
"/",
"360",
";",
"s",
"=",
"number",
"(",
"s",
")",
";",
"l",
"=",
"number",
"(",
"l",
")",
";",
"a",
"=",
"number",
"(",
"a",
")",
";",
"if",
"(",
"[",
"h",
",",
"s",
",",
"l",
",",
"a",
"]",
".",
"some",
"(",
"isNaN",
")",
")",
"return",
"null",
";",
"var",
"m2",
"=",
"l",
"<=",
"0.5",
"?",
"l",
"*",
"(",
"s",
"+",
"1",
")",
":",
"l",
"+",
"s",
"-",
"l",
"*",
"s",
",",
"m1",
"=",
"l",
"*",
"2",
"-",
"m2",
";",
"return",
"this",
".",
"rgba",
"(",
"hue",
"(",
"h",
"+",
"1",
"/",
"3",
")",
"*",
"255",
",",
"hue",
"(",
"h",
")",
"*",
"255",
",",
"hue",
"(",
"h",
"-",
"1",
"/",
"3",
")",
"*",
"255",
",",
"a",
")",
";",
"function",
"hue",
"(",
"h",
")",
"{",
"h",
"=",
"h",
"<",
"0",
"?",
"h",
"+",
"1",
":",
"(",
"h",
">",
"1",
"?",
"h",
"-",
"1",
":",
"h",
")",
";",
"if",
"(",
"h",
"*",
"6",
"<",
"1",
")",
"return",
"m1",
"+",
"(",
"m2",
"-",
"m1",
")",
"*",
"h",
"*",
"6",
";",
"else",
"if",
"(",
"h",
"*",
"2",
"<",
"1",
")",
"return",
"m2",
";",
"else",
"if",
"(",
"h",
"*",
"3",
"<",
"2",
")",
"return",
"m1",
"+",
"(",
"m2",
"-",
"m1",
")",
"*",
"(",
"2",
"/",
"3",
"-",
"h",
")",
"*",
"6",
";",
"else",
"return",
"m1",
";",
"}",
"}"
] |
Given an HSL color as components, return an RGBA array
@param {number} h hue
@param {number} s saturation
@param {number} l luminosity
@param {number} a alpha
@returns {Array} rgba color
|
[
"Given",
"an",
"HSL",
"color",
"as",
"components",
"return",
"an",
"RGBA",
"array"
] |
eaa5b1ec2f679ac0ce850dc193621ff17fbf26da
|
https://github.com/tmcw-up-for-adoption/color-ops/blob/eaa5b1ec2f679ac0ce850dc193621ff17fbf26da/index.js#L79-L99
|
|
39,227 |
tmcw-up-for-adoption/color-ops
|
index.js
|
function(color, amount) {
var hsl = this.toHSL(color);
hsl.s += amount / 100;
hsl.s = clamp(hsl.s);
return hsla(hsl);
}
|
javascript
|
function(color, amount) {
var hsl = this.toHSL(color);
hsl.s += amount / 100;
hsl.s = clamp(hsl.s);
return hsla(hsl);
}
|
[
"function",
"(",
"color",
",",
"amount",
")",
"{",
"var",
"hsl",
"=",
"this",
".",
"toHSL",
"(",
"color",
")",
";",
"hsl",
".",
"s",
"+=",
"amount",
"/",
"100",
";",
"hsl",
".",
"s",
"=",
"clamp",
"(",
"hsl",
".",
"s",
")",
";",
"return",
"hsla",
"(",
"hsl",
")",
";",
"}"
] |
Saturate or desaturate a color by a given amount
@param {Color} color
@param {Number} amount
@returns {Color} color
|
[
"Saturate",
"or",
"desaturate",
"a",
"color",
"by",
"a",
"given",
"amount"
] |
eaa5b1ec2f679ac0ce850dc193621ff17fbf26da
|
https://github.com/tmcw-up-for-adoption/color-ops/blob/eaa5b1ec2f679ac0ce850dc193621ff17fbf26da/index.js#L145-L151
|
|
39,228 |
tmcw-up-for-adoption/color-ops
|
index.js
|
function(color, amount) {
var hsl = this.toHSL(color);
hsl.l += amount / 100;
hsl.l = clamp(hsl.l);
return hsla(hsl);
}
|
javascript
|
function(color, amount) {
var hsl = this.toHSL(color);
hsl.l += amount / 100;
hsl.l = clamp(hsl.l);
return hsla(hsl);
}
|
[
"function",
"(",
"color",
",",
"amount",
")",
"{",
"var",
"hsl",
"=",
"this",
".",
"toHSL",
"(",
"color",
")",
";",
"hsl",
".",
"l",
"+=",
"amount",
"/",
"100",
";",
"hsl",
".",
"l",
"=",
"clamp",
"(",
"hsl",
".",
"l",
")",
";",
"return",
"hsla",
"(",
"hsl",
")",
";",
"}"
] |
Lighten or darken a color by a given amount
@param {Color} color
@param {Number} amount
@returns {Color} color
|
[
"Lighten",
"or",
"darken",
"a",
"color",
"by",
"a",
"given",
"amount"
] |
eaa5b1ec2f679ac0ce850dc193621ff17fbf26da
|
https://github.com/tmcw-up-for-adoption/color-ops/blob/eaa5b1ec2f679ac0ce850dc193621ff17fbf26da/index.js#L159-L165
|
|
39,229 |
tmcw-up-for-adoption/color-ops
|
index.js
|
function(color1, color2, amount) {
var p = amount / 100.0;
var w = p * 2 - 1;
var hsl1 = this.toHSL(color1);
var hsl2 = this.toHSL(color2);
var a = hsl1.a - hsl2.a;
var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
var w2 = 1 - w1;
var rgb = [
color1[0] * w1 + color2[0] * w2,
color1[1] * w1 + color2[1] * w2,
color1[2] * w1 + color2[2] * w2
];
var alpha = color1[3] * p + color2[3] * (1 - p);
rgb[3] = alpha;
return rgb;
}
|
javascript
|
function(color1, color2, amount) {
var p = amount / 100.0;
var w = p * 2 - 1;
var hsl1 = this.toHSL(color1);
var hsl2 = this.toHSL(color2);
var a = hsl1.a - hsl2.a;
var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
var w2 = 1 - w1;
var rgb = [
color1[0] * w1 + color2[0] * w2,
color1[1] * w1 + color2[1] * w2,
color1[2] * w1 + color2[2] * w2
];
var alpha = color1[3] * p + color2[3] * (1 - p);
rgb[3] = alpha;
return rgb;
}
|
[
"function",
"(",
"color1",
",",
"color2",
",",
"amount",
")",
"{",
"var",
"p",
"=",
"amount",
"/",
"100.0",
";",
"var",
"w",
"=",
"p",
"*",
"2",
"-",
"1",
";",
"var",
"hsl1",
"=",
"this",
".",
"toHSL",
"(",
"color1",
")",
";",
"var",
"hsl2",
"=",
"this",
".",
"toHSL",
"(",
"color2",
")",
";",
"var",
"a",
"=",
"hsl1",
".",
"a",
"-",
"hsl2",
".",
"a",
";",
"var",
"w1",
"=",
"(",
"(",
"(",
"w",
"*",
"a",
"==",
"-",
"1",
")",
"?",
"w",
":",
"(",
"w",
"+",
"a",
")",
"/",
"(",
"1",
"+",
"w",
"*",
"a",
")",
")",
"+",
"1",
")",
"/",
"2.0",
";",
"var",
"w2",
"=",
"1",
"-",
"w1",
";",
"var",
"rgb",
"=",
"[",
"color1",
"[",
"0",
"]",
"*",
"w1",
"+",
"color2",
"[",
"0",
"]",
"*",
"w2",
",",
"color1",
"[",
"1",
"]",
"*",
"w1",
"+",
"color2",
"[",
"1",
"]",
"*",
"w2",
",",
"color1",
"[",
"2",
"]",
"*",
"w1",
"+",
"color2",
"[",
"2",
"]",
"*",
"w2",
"]",
";",
"var",
"alpha",
"=",
"color1",
"[",
"3",
"]",
"*",
"p",
"+",
"color2",
"[",
"3",
"]",
"*",
"(",
"1",
"-",
"p",
")",
";",
"rgb",
"[",
"3",
"]",
"=",
"alpha",
";",
"return",
"rgb",
";",
"}"
] |
Mix two colors.
@param {Color} color1
@param {Color} color2
@param {Number} degrees
@returns {Color} output
|
[
"Mix",
"two",
"colors",
"."
] |
eaa5b1ec2f679ac0ce850dc193621ff17fbf26da
|
https://github.com/tmcw-up-for-adoption/color-ops/blob/eaa5b1ec2f679ac0ce850dc193621ff17fbf26da/index.js#L200-L219
|
|
39,230 |
chrisJohn404/ljswitchboard-ljm_device_curator
|
lib/device_value_checker.js
|
reportResult
|
function reportResult(devRes, scriptRes, method) {
debug('in performRetry', devRes, scriptRes, method);
var returnData = {
'numAttempts': context.currentAttempt,
'maxAttempts': context.maxAttempts,
// 'startTime': new Date(),
// 'finishTime': new Date(),
'scriptRes': scriptRes,
'evalStr': context.evalStr,
'delay': context.delay,
'register': context.register,
};
var devResKeys = Object.keys(devRes);
devResKeys.forEach(function(key) {
returnData[key] = devRes[key];
});
valChecker.defered[method](returnData);
}
|
javascript
|
function reportResult(devRes, scriptRes, method) {
debug('in performRetry', devRes, scriptRes, method);
var returnData = {
'numAttempts': context.currentAttempt,
'maxAttempts': context.maxAttempts,
// 'startTime': new Date(),
// 'finishTime': new Date(),
'scriptRes': scriptRes,
'evalStr': context.evalStr,
'delay': context.delay,
'register': context.register,
};
var devResKeys = Object.keys(devRes);
devResKeys.forEach(function(key) {
returnData[key] = devRes[key];
});
valChecker.defered[method](returnData);
}
|
[
"function",
"reportResult",
"(",
"devRes",
",",
"scriptRes",
",",
"method",
")",
"{",
"debug",
"(",
"'in performRetry'",
",",
"devRes",
",",
"scriptRes",
",",
"method",
")",
";",
"var",
"returnData",
"=",
"{",
"'numAttempts'",
":",
"context",
".",
"currentAttempt",
",",
"'maxAttempts'",
":",
"context",
".",
"maxAttempts",
",",
"// 'startTime': new Date(),",
"// 'finishTime': new Date(),",
"'scriptRes'",
":",
"scriptRes",
",",
"'evalStr'",
":",
"context",
".",
"evalStr",
",",
"'delay'",
":",
"context",
".",
"delay",
",",
"'register'",
":",
"context",
".",
"register",
",",
"}",
";",
"var",
"devResKeys",
"=",
"Object",
".",
"keys",
"(",
"devRes",
")",
";",
"devResKeys",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"returnData",
"[",
"key",
"]",
"=",
"devRes",
"[",
"key",
"]",
";",
"}",
")",
";",
"valChecker",
".",
"defered",
"[",
"method",
"]",
"(",
"returnData",
")",
";",
"}"
] |
This function reports data when the value-checking has completed.
|
[
"This",
"function",
"reports",
"data",
"when",
"the",
"value",
"-",
"checking",
"has",
"completed",
"."
] |
36cb25645dfa0a68e906d5ec43e5514391947257
|
https://github.com/chrisJohn404/ljswitchboard-ljm_device_curator/blob/36cb25645dfa0a68e906d5ec43e5514391947257/lib/device_value_checker.js#L39-L56
|
39,231 |
chrisJohn404/ljswitchboard-ljm_device_curator
|
lib/device_value_checker.js
|
performRetry
|
function performRetry(devRes, scriptRes) {
var currentAttempt = context.currentAttempt;
var maxAttempts = context.maxAttempts;
var delay = context.delay;
debug('in performRetry', currentAttempt, maxAttempts, delay);
if(currentAttempt < maxAttempts) {
context.currentAttempt += 1;
setTimeout(checkDeviceValue, delay);
} else {
if(context.rejectOnError) {
reportResult(devRes, scriptRes, 'reject');
} else {
reportResult(devRes, scriptRes, 'resolve');
}
}
}
|
javascript
|
function performRetry(devRes, scriptRes) {
var currentAttempt = context.currentAttempt;
var maxAttempts = context.maxAttempts;
var delay = context.delay;
debug('in performRetry', currentAttempt, maxAttempts, delay);
if(currentAttempt < maxAttempts) {
context.currentAttempt += 1;
setTimeout(checkDeviceValue, delay);
} else {
if(context.rejectOnError) {
reportResult(devRes, scriptRes, 'reject');
} else {
reportResult(devRes, scriptRes, 'resolve');
}
}
}
|
[
"function",
"performRetry",
"(",
"devRes",
",",
"scriptRes",
")",
"{",
"var",
"currentAttempt",
"=",
"context",
".",
"currentAttempt",
";",
"var",
"maxAttempts",
"=",
"context",
".",
"maxAttempts",
";",
"var",
"delay",
"=",
"context",
".",
"delay",
";",
"debug",
"(",
"'in performRetry'",
",",
"currentAttempt",
",",
"maxAttempts",
",",
"delay",
")",
";",
"if",
"(",
"currentAttempt",
"<",
"maxAttempts",
")",
"{",
"context",
".",
"currentAttempt",
"+=",
"1",
";",
"setTimeout",
"(",
"checkDeviceValue",
",",
"delay",
")",
";",
"}",
"else",
"{",
"if",
"(",
"context",
".",
"rejectOnError",
")",
"{",
"reportResult",
"(",
"devRes",
",",
"scriptRes",
",",
"'reject'",
")",
";",
"}",
"else",
"{",
"reportResult",
"(",
"devRes",
",",
"scriptRes",
",",
"'resolve'",
")",
";",
"}",
"}",
"}"
] |
This function performs the re-try logic. It re-attempts a read or reports the results.
|
[
"This",
"function",
"performs",
"the",
"re",
"-",
"try",
"logic",
".",
"It",
"re",
"-",
"attempts",
"a",
"read",
"or",
"reports",
"the",
"results",
"."
] |
36cb25645dfa0a68e906d5ec43e5514391947257
|
https://github.com/chrisJohn404/ljswitchboard-ljm_device_curator/blob/36cb25645dfa0a68e906d5ec43e5514391947257/lib/device_value_checker.js#L61-L76
|
39,232 |
theetrain/gulp-resource-hints
|
lib/helpers.js
|
urlMatch
|
function urlMatch (asset, pattern) {
var multi = pattern.split(',')
var re
if (multi.length > 1) {
for (var i = 0, len = multi.length; i < len; i++) {
re = new RegExp(multi[i].replace(/([.?+^$[\]\\(){}|/-])/g, '\\$1').replace(/\*/g, '.*'))
if (re.test(asset)) {
return true
}
}
return false
}
re = new RegExp(pattern.replace(/([.?+^$[\]\\(){}|/-])/g, '\\$1').replace(/\*/g, '.*'))
return re.test(asset)
}
|
javascript
|
function urlMatch (asset, pattern) {
var multi = pattern.split(',')
var re
if (multi.length > 1) {
for (var i = 0, len = multi.length; i < len; i++) {
re = new RegExp(multi[i].replace(/([.?+^$[\]\\(){}|/-])/g, '\\$1').replace(/\*/g, '.*'))
if (re.test(asset)) {
return true
}
}
return false
}
re = new RegExp(pattern.replace(/([.?+^$[\]\\(){}|/-])/g, '\\$1').replace(/\*/g, '.*'))
return re.test(asset)
}
|
[
"function",
"urlMatch",
"(",
"asset",
",",
"pattern",
")",
"{",
"var",
"multi",
"=",
"pattern",
".",
"split",
"(",
"','",
")",
"var",
"re",
"if",
"(",
"multi",
".",
"length",
">",
"1",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"multi",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"re",
"=",
"new",
"RegExp",
"(",
"multi",
"[",
"i",
"]",
".",
"replace",
"(",
"/",
"([.?+^$[\\]\\\\(){}|/-])",
"/",
"g",
",",
"'\\\\$1'",
")",
".",
"replace",
"(",
"/",
"\\*",
"/",
"g",
",",
"'.*'",
")",
")",
"if",
"(",
"re",
".",
"test",
"(",
"asset",
")",
")",
"{",
"return",
"true",
"}",
"}",
"return",
"false",
"}",
"re",
"=",
"new",
"RegExp",
"(",
"pattern",
".",
"replace",
"(",
"/",
"([.?+^$[\\]\\\\(){}|/-])",
"/",
"g",
",",
"'\\\\$1'",
")",
".",
"replace",
"(",
"/",
"\\*",
"/",
"g",
",",
"'.*'",
")",
")",
"return",
"re",
".",
"test",
"(",
"asset",
")",
"}"
] |
Determines if url matches glob pattern
|
[
"Determines",
"if",
"url",
"matches",
"glob",
"pattern"
] |
12a01e42b35ed07ddef80bddf07e21a69f2138f4
|
https://github.com/theetrain/gulp-resource-hints/blob/12a01e42b35ed07ddef80bddf07e21a69f2138f4/lib/helpers.js#L27-L43
|
39,233 |
theetrain/gulp-resource-hints
|
lib/helpers.js
|
isDuplicate
|
function isDuplicate (assetToCheck, isHost) {
if (parsedAssets.length <= 0) {
return false
}
return ~parsedAssets.findIndex(function (asset) {
if (isHost) {
// We don't want to preconnect twice, eh?
return asset.split('//')[1] === assetToCheck.split('//')[1]
}
return asset === assetToCheck
})
}
|
javascript
|
function isDuplicate (assetToCheck, isHost) {
if (parsedAssets.length <= 0) {
return false
}
return ~parsedAssets.findIndex(function (asset) {
if (isHost) {
// We don't want to preconnect twice, eh?
return asset.split('//')[1] === assetToCheck.split('//')[1]
}
return asset === assetToCheck
})
}
|
[
"function",
"isDuplicate",
"(",
"assetToCheck",
",",
"isHost",
")",
"{",
"if",
"(",
"parsedAssets",
".",
"length",
"<=",
"0",
")",
"{",
"return",
"false",
"}",
"return",
"~",
"parsedAssets",
".",
"findIndex",
"(",
"function",
"(",
"asset",
")",
"{",
"if",
"(",
"isHost",
")",
"{",
"// We don't want to preconnect twice, eh?",
"return",
"asset",
".",
"split",
"(",
"'//'",
")",
"[",
"1",
"]",
"===",
"assetToCheck",
".",
"split",
"(",
"'//'",
")",
"[",
"1",
"]",
"}",
"return",
"asset",
"===",
"assetToCheck",
"}",
")",
"}"
] |
Checking duplicates is necessary for dns-prefetch and prefetch
resource hints since the same web page could have multiple assets
from the same external host, but we only want to dns-prefetch an
external host once.
Check for duplicates in parsedAssets helper array
@param {string} assetToCheck
@param {boolean} isHost
|
[
"Checking",
"duplicates",
"is",
"necessary",
"for",
"dns",
"-",
"prefetch",
"and",
"prefetch",
"resource",
"hints",
"since",
"the",
"same",
"web",
"page",
"could",
"have",
"multiple",
"assets",
"from",
"the",
"same",
"external",
"host",
"but",
"we",
"only",
"want",
"to",
"dns",
"-",
"prefetch",
"an",
"external",
"host",
"once",
".",
"Check",
"for",
"duplicates",
"in",
"parsedAssets",
"helper",
"array"
] |
12a01e42b35ed07ddef80bddf07e21a69f2138f4
|
https://github.com/theetrain/gulp-resource-hints/blob/12a01e42b35ed07ddef80bddf07e21a69f2138f4/lib/helpers.js#L73-L84
|
39,234 |
theetrain/gulp-resource-hints
|
lib/helpers.js
|
logger
|
function logger (message, warn) {
if (appOptions.silent) {
return
}
if (warn) {
console.warn(message)
return
}
console.log(message)
}
|
javascript
|
function logger (message, warn) {
if (appOptions.silent) {
return
}
if (warn) {
console.warn(message)
return
}
console.log(message)
}
|
[
"function",
"logger",
"(",
"message",
",",
"warn",
")",
"{",
"if",
"(",
"appOptions",
".",
"silent",
")",
"{",
"return",
"}",
"if",
"(",
"warn",
")",
"{",
"console",
".",
"warn",
"(",
"message",
")",
"return",
"}",
"console",
".",
"log",
"(",
"message",
")",
"}"
] |
Log to the console unless user opts out
@param {string} message
@param {boolean} warn
|
[
"Log",
"to",
"the",
"console",
"unless",
"user",
"opts",
"out"
] |
12a01e42b35ed07ddef80bddf07e21a69f2138f4
|
https://github.com/theetrain/gulp-resource-hints/blob/12a01e42b35ed07ddef80bddf07e21a69f2138f4/lib/helpers.js#L100-L110
|
39,235 |
theetrain/gulp-resource-hints
|
lib/helpers.js
|
hasInsertionPoint
|
function hasInsertionPoint (file) {
var token = appOptions.pageToken
if (token !== '' && String(file.contents).indexOf(token) > -1) {
insertionPoint = 'token'
return true
} else if (token !== '' && token !== defaults.pageToken) {
logger('Token not found in ' + file.relative)
}
var soup = new Soup(String(file.contents))
// Append after metas
soup.setInnerHTML('head > meta:last-of-type', function (oldHTML) {
if (oldHTML !== null) {
insertionPoint = 'meta'
return oldHTML
}
})
if (insertionPoint) {
return true
}
// Else, prepend before links
soup.setInnerHTML('head > link:first-of-type', function (oldHTML) {
if (oldHTML !== null) {
insertionPoint = 'link'
return oldHTML
}
})
if (insertionPoint) {
return true
}
// Else, append to head
soup.setInnerHTML('head', function (oldHTML) {
if (oldHTML !== null) {
insertionPoint = 'head'
return oldHTML
}
})
return insertionPoint
}
|
javascript
|
function hasInsertionPoint (file) {
var token = appOptions.pageToken
if (token !== '' && String(file.contents).indexOf(token) > -1) {
insertionPoint = 'token'
return true
} else if (token !== '' && token !== defaults.pageToken) {
logger('Token not found in ' + file.relative)
}
var soup = new Soup(String(file.contents))
// Append after metas
soup.setInnerHTML('head > meta:last-of-type', function (oldHTML) {
if (oldHTML !== null) {
insertionPoint = 'meta'
return oldHTML
}
})
if (insertionPoint) {
return true
}
// Else, prepend before links
soup.setInnerHTML('head > link:first-of-type', function (oldHTML) {
if (oldHTML !== null) {
insertionPoint = 'link'
return oldHTML
}
})
if (insertionPoint) {
return true
}
// Else, append to head
soup.setInnerHTML('head', function (oldHTML) {
if (oldHTML !== null) {
insertionPoint = 'head'
return oldHTML
}
})
return insertionPoint
}
|
[
"function",
"hasInsertionPoint",
"(",
"file",
")",
"{",
"var",
"token",
"=",
"appOptions",
".",
"pageToken",
"if",
"(",
"token",
"!==",
"''",
"&&",
"String",
"(",
"file",
".",
"contents",
")",
".",
"indexOf",
"(",
"token",
")",
">",
"-",
"1",
")",
"{",
"insertionPoint",
"=",
"'token'",
"return",
"true",
"}",
"else",
"if",
"(",
"token",
"!==",
"''",
"&&",
"token",
"!==",
"defaults",
".",
"pageToken",
")",
"{",
"logger",
"(",
"'Token not found in '",
"+",
"file",
".",
"relative",
")",
"}",
"var",
"soup",
"=",
"new",
"Soup",
"(",
"String",
"(",
"file",
".",
"contents",
")",
")",
"// Append after metas",
"soup",
".",
"setInnerHTML",
"(",
"'head > meta:last-of-type'",
",",
"function",
"(",
"oldHTML",
")",
"{",
"if",
"(",
"oldHTML",
"!==",
"null",
")",
"{",
"insertionPoint",
"=",
"'meta'",
"return",
"oldHTML",
"}",
"}",
")",
"if",
"(",
"insertionPoint",
")",
"{",
"return",
"true",
"}",
"// Else, prepend before links",
"soup",
".",
"setInnerHTML",
"(",
"'head > link:first-of-type'",
",",
"function",
"(",
"oldHTML",
")",
"{",
"if",
"(",
"oldHTML",
"!==",
"null",
")",
"{",
"insertionPoint",
"=",
"'link'",
"return",
"oldHTML",
"}",
"}",
")",
"if",
"(",
"insertionPoint",
")",
"{",
"return",
"true",
"}",
"// Else, append to head",
"soup",
".",
"setInnerHTML",
"(",
"'head'",
",",
"function",
"(",
"oldHTML",
")",
"{",
"if",
"(",
"oldHTML",
"!==",
"null",
")",
"{",
"insertionPoint",
"=",
"'head'",
"return",
"oldHTML",
"}",
"}",
")",
"return",
"insertionPoint",
"}"
] |
Determine if file has a valid area to inject resource hints
@param {stream} file
|
[
"Determine",
"if",
"file",
"has",
"a",
"valid",
"area",
"to",
"inject",
"resource",
"hints"
] |
12a01e42b35ed07ddef80bddf07e21a69f2138f4
|
https://github.com/theetrain/gulp-resource-hints/blob/12a01e42b35ed07ddef80bddf07e21a69f2138f4/lib/helpers.js#L117-L162
|
39,236 |
theetrain/gulp-resource-hints
|
lib/helpers.js
|
buildResourceHint
|
function buildResourceHint (hint, asset, glob) {
var as = ''
if (hint === 'dns-prefetch' || hint === 'preconnect') {
if (!urlMatch(asset, glob)) {
return ''
}
asset = urlParse(asset)
if (isDuplicate(asset, true)) {
return ''
}
} else {
if (!minimatch(asset, glob) || isDuplicate(asset)) {
return ''
}
if (globMatch(asset, fonts)) {
as += ' as="font"'
} else if (isCSS(asset)) {
as += ' as="style"'
}
}
parsedAssets.push(asset)
return `<link rel="${hint}" href="${asset}"${as} />`
}
|
javascript
|
function buildResourceHint (hint, asset, glob) {
var as = ''
if (hint === 'dns-prefetch' || hint === 'preconnect') {
if (!urlMatch(asset, glob)) {
return ''
}
asset = urlParse(asset)
if (isDuplicate(asset, true)) {
return ''
}
} else {
if (!minimatch(asset, glob) || isDuplicate(asset)) {
return ''
}
if (globMatch(asset, fonts)) {
as += ' as="font"'
} else if (isCSS(asset)) {
as += ' as="style"'
}
}
parsedAssets.push(asset)
return `<link rel="${hint}" href="${asset}"${as} />`
}
|
[
"function",
"buildResourceHint",
"(",
"hint",
",",
"asset",
",",
"glob",
")",
"{",
"var",
"as",
"=",
"''",
"if",
"(",
"hint",
"===",
"'dns-prefetch'",
"||",
"hint",
"===",
"'preconnect'",
")",
"{",
"if",
"(",
"!",
"urlMatch",
"(",
"asset",
",",
"glob",
")",
")",
"{",
"return",
"''",
"}",
"asset",
"=",
"urlParse",
"(",
"asset",
")",
"if",
"(",
"isDuplicate",
"(",
"asset",
",",
"true",
")",
")",
"{",
"return",
"''",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"minimatch",
"(",
"asset",
",",
"glob",
")",
"||",
"isDuplicate",
"(",
"asset",
")",
")",
"{",
"return",
"''",
"}",
"if",
"(",
"globMatch",
"(",
"asset",
",",
"fonts",
")",
")",
"{",
"as",
"+=",
"' as=\"font\"'",
"}",
"else",
"if",
"(",
"isCSS",
"(",
"asset",
")",
")",
"{",
"as",
"+=",
"' as=\"style\"'",
"}",
"}",
"parsedAssets",
".",
"push",
"(",
"asset",
")",
"return",
"`",
"${",
"hint",
"}",
"${",
"asset",
"}",
"${",
"as",
"}",
"`",
"}"
] |
Validate asset is desireable by user
Build resource hint if so
@param {string} hint
@param {string} asset
@param {string} glob
@return {string}
|
[
"Validate",
"asset",
"is",
"desireable",
"by",
"user",
"Build",
"resource",
"hint",
"if",
"so"
] |
12a01e42b35ed07ddef80bddf07e21a69f2138f4
|
https://github.com/theetrain/gulp-resource-hints/blob/12a01e42b35ed07ddef80bddf07e21a69f2138f4/lib/helpers.js#L173-L198
|
39,237 |
theetrain/gulp-resource-hints
|
lib/helpers.js
|
options
|
function options (userOpts) {
if (appLoaded && typeof userOpts === 'undefined') {
return appOptions
}
userOpts = typeof userOpts === 'object' ? userOpts : {}
appOptions = Object.assign({}, defaults, userOpts)
appOptions.paths = Object.assign({}, defaults.paths, userOpts.paths)
appLoaded = true
return appOptions
}
|
javascript
|
function options (userOpts) {
if (appLoaded && typeof userOpts === 'undefined') {
return appOptions
}
userOpts = typeof userOpts === 'object' ? userOpts : {}
appOptions = Object.assign({}, defaults, userOpts)
appOptions.paths = Object.assign({}, defaults.paths, userOpts.paths)
appLoaded = true
return appOptions
}
|
[
"function",
"options",
"(",
"userOpts",
")",
"{",
"if",
"(",
"appLoaded",
"&&",
"typeof",
"userOpts",
"===",
"'undefined'",
")",
"{",
"return",
"appOptions",
"}",
"userOpts",
"=",
"typeof",
"userOpts",
"===",
"'object'",
"?",
"userOpts",
":",
"{",
"}",
"appOptions",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaults",
",",
"userOpts",
")",
"appOptions",
".",
"paths",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"defaults",
".",
"paths",
",",
"userOpts",
".",
"paths",
")",
"appLoaded",
"=",
"true",
"return",
"appOptions",
"}"
] |
Merge user options with defaults
@param {object} userOpts
@return {object}
|
[
"Merge",
"user",
"options",
"with",
"defaults"
] |
12a01e42b35ed07ddef80bddf07e21a69f2138f4
|
https://github.com/theetrain/gulp-resource-hints/blob/12a01e42b35ed07ddef80bddf07e21a69f2138f4/lib/helpers.js#L206-L216
|
39,238 |
theetrain/gulp-resource-hints
|
lib/helpers.js
|
writeDataToFile
|
function writeDataToFile (file, data, token) {
// insertionPoint was set in hasInsertionPoint(), so we can assume it is safe to write to file
var selectors = [
'head > meta:last-of-type',
'head > link:first-of-type',
'head'
]
var selectorIndex = 0
switch (insertionPoint) {
case 'meta':
selectorIndex = 0
break
case 'link':
selectorIndex = 1
break
case 'head':
selectorIndex = 2
break
case 'token':
let html = String(file.contents).replace(token, data)
return new Buffer(html)
default:
return ''
}
var soup = new Soup(String(file.contents))
// Inject Resource Hints
soup.setInnerHTML(selectors[selectorIndex], function (oldHTML) {
if (insertionPoint === 'link') {
return data + oldHTML
}
return oldHTML + data
})
return soup.toString()
}
|
javascript
|
function writeDataToFile (file, data, token) {
// insertionPoint was set in hasInsertionPoint(), so we can assume it is safe to write to file
var selectors = [
'head > meta:last-of-type',
'head > link:first-of-type',
'head'
]
var selectorIndex = 0
switch (insertionPoint) {
case 'meta':
selectorIndex = 0
break
case 'link':
selectorIndex = 1
break
case 'head':
selectorIndex = 2
break
case 'token':
let html = String(file.contents).replace(token, data)
return new Buffer(html)
default:
return ''
}
var soup = new Soup(String(file.contents))
// Inject Resource Hints
soup.setInnerHTML(selectors[selectorIndex], function (oldHTML) {
if (insertionPoint === 'link') {
return data + oldHTML
}
return oldHTML + data
})
return soup.toString()
}
|
[
"function",
"writeDataToFile",
"(",
"file",
",",
"data",
",",
"token",
")",
"{",
"// insertionPoint was set in hasInsertionPoint(), so we can assume it is safe to write to file",
"var",
"selectors",
"=",
"[",
"'head > meta:last-of-type'",
",",
"'head > link:first-of-type'",
",",
"'head'",
"]",
"var",
"selectorIndex",
"=",
"0",
"switch",
"(",
"insertionPoint",
")",
"{",
"case",
"'meta'",
":",
"selectorIndex",
"=",
"0",
"break",
"case",
"'link'",
":",
"selectorIndex",
"=",
"1",
"break",
"case",
"'head'",
":",
"selectorIndex",
"=",
"2",
"break",
"case",
"'token'",
":",
"let",
"html",
"=",
"String",
"(",
"file",
".",
"contents",
")",
".",
"replace",
"(",
"token",
",",
"data",
")",
"return",
"new",
"Buffer",
"(",
"html",
")",
"default",
":",
"return",
"''",
"}",
"var",
"soup",
"=",
"new",
"Soup",
"(",
"String",
"(",
"file",
".",
"contents",
")",
")",
"// Inject Resource Hints",
"soup",
".",
"setInnerHTML",
"(",
"selectors",
"[",
"selectorIndex",
"]",
",",
"function",
"(",
"oldHTML",
")",
"{",
"if",
"(",
"insertionPoint",
"===",
"'link'",
")",
"{",
"return",
"data",
"+",
"oldHTML",
"}",
"return",
"oldHTML",
"+",
"data",
"}",
")",
"return",
"soup",
".",
"toString",
"(",
")",
"}"
] |
Write resource hints to file
@param {stream} file
@param {string} data
@param {string} token
@return {string}
|
[
"Write",
"resource",
"hints",
"to",
"file"
] |
12a01e42b35ed07ddef80bddf07e21a69f2138f4
|
https://github.com/theetrain/gulp-resource-hints/blob/12a01e42b35ed07ddef80bddf07e21a69f2138f4/lib/helpers.js#L226-L263
|
39,239 |
sbyrnes/classify.js
|
classify.js
|
function()
{
this.numTrainingExamples = 0;
this.groupFrequencyCount = new Object();
this.numWords = 0;
this.wordFrequencyCount = new Object();
this.groupWordTotal = new Object();
this.groupWordFrequencyCount = new Object();
}
|
javascript
|
function()
{
this.numTrainingExamples = 0;
this.groupFrequencyCount = new Object();
this.numWords = 0;
this.wordFrequencyCount = new Object();
this.groupWordTotal = new Object();
this.groupWordFrequencyCount = new Object();
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"numTrainingExamples",
"=",
"0",
";",
"this",
".",
"groupFrequencyCount",
"=",
"new",
"Object",
"(",
")",
";",
"this",
".",
"numWords",
"=",
"0",
";",
"this",
".",
"wordFrequencyCount",
"=",
"new",
"Object",
"(",
")",
";",
"this",
".",
"groupWordTotal",
"=",
"new",
"Object",
"(",
")",
";",
"this",
".",
"groupWordFrequencyCount",
"=",
"new",
"Object",
"(",
")",
";",
"}"
] |
Storage for the input parameters for the model
|
[
"Storage",
"for",
"the",
"input",
"parameters",
"for",
"the",
"model"
] |
0cf5ab334ae0f5353484cd33b0815e87766af2e4
|
https://github.com/sbyrnes/classify.js/blob/0cf5ab334ae0f5353484cd33b0815e87766af2e4/classify.js#L14-L23
|
|
39,240 |
sbyrnes/classify.js
|
classify.js
|
incrementOrCreateGroup
|
function incrementOrCreateGroup(object, group, value)
{
if(!object[group]) object[group] = new Object();
var myGroup = object[group];
if(myGroup[value]) myGroup[value] += 1;
else myGroup[value] = 1;
}
|
javascript
|
function incrementOrCreateGroup(object, group, value)
{
if(!object[group]) object[group] = new Object();
var myGroup = object[group];
if(myGroup[value]) myGroup[value] += 1;
else myGroup[value] = 1;
}
|
[
"function",
"incrementOrCreateGroup",
"(",
"object",
",",
"group",
",",
"value",
")",
"{",
"if",
"(",
"!",
"object",
"[",
"group",
"]",
")",
"object",
"[",
"group",
"]",
"=",
"new",
"Object",
"(",
")",
";",
"var",
"myGroup",
"=",
"object",
"[",
"group",
"]",
";",
"if",
"(",
"myGroup",
"[",
"value",
"]",
")",
"myGroup",
"[",
"value",
"]",
"+=",
"1",
";",
"else",
"myGroup",
"[",
"value",
"]",
"=",
"1",
";",
"}"
] |
Looks for a field with the given group and value in the object and if found increments it. Otherwise, creates it with a value of 1.
|
[
"Looks",
"for",
"a",
"field",
"with",
"the",
"given",
"group",
"and",
"value",
"in",
"the",
"object",
"and",
"if",
"found",
"increments",
"it",
".",
"Otherwise",
"creates",
"it",
"with",
"a",
"value",
"of",
"1",
"."
] |
0cf5ab334ae0f5353484cd33b0815e87766af2e4
|
https://github.com/sbyrnes/classify.js/blob/0cf5ab334ae0f5353484cd33b0815e87766af2e4/classify.js#L205-L213
|
39,241 |
base/base-helpers
|
index.js
|
isValid
|
function isValid(app) {
if (isValidApp(app, 'base-helpers', ['app', 'views', 'collection'])) {
debug('initializing <%s>, from <%s>', __filename, module.parent.id);
return true;
}
return false;
}
|
javascript
|
function isValid(app) {
if (isValidApp(app, 'base-helpers', ['app', 'views', 'collection'])) {
debug('initializing <%s>, from <%s>', __filename, module.parent.id);
return true;
}
return false;
}
|
[
"function",
"isValid",
"(",
"app",
")",
"{",
"if",
"(",
"isValidApp",
"(",
"app",
",",
"'base-helpers'",
",",
"[",
"'app'",
",",
"'views'",
",",
"'collection'",
"]",
")",
")",
"{",
"debug",
"(",
"'initializing <%s>, from <%s>'",
",",
"__filename",
",",
"module",
".",
"parent",
".",
"id",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Return false if `app` is not a valid instance of `Base`, or
the `base-helpers` plugin is alread registered.
|
[
"Return",
"false",
"if",
"app",
"is",
"not",
"a",
"valid",
"instance",
"of",
"Base",
"or",
"the",
"base",
"-",
"helpers",
"plugin",
"is",
"alread",
"registered",
"."
] |
eaf080ca6ffb164bac9c48ae1d30fb5f331400a7
|
https://github.com/base/base-helpers/blob/eaf080ca6ffb164bac9c48ae1d30fb5f331400a7/index.js#L231-L237
|
39,242 |
janus-toendering/options-parser
|
src/helper.js
|
repeat
|
function repeat(ch, count)
{
var s = '';
for(var i = 0; i < count; i++)
s += ch;
return s;
}
|
javascript
|
function repeat(ch, count)
{
var s = '';
for(var i = 0; i < count; i++)
s += ch;
return s;
}
|
[
"function",
"repeat",
"(",
"ch",
",",
"count",
")",
"{",
"var",
"s",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"s",
"+=",
"ch",
";",
"return",
"s",
";",
"}"
] |
Create new string with ch repeated count times
@param {String} ch character to repeat (should have length = 1)
@param {Number} count number of repetitions of ch
@return {String}
|
[
"Create",
"new",
"string",
"with",
"ch",
"repeated",
"count",
"times"
] |
f1e39aac203f26e7e4e67fadba63c8dce1c7d70e
|
https://github.com/janus-toendering/options-parser/blob/f1e39aac203f26e7e4e67fadba63c8dce1c7d70e/src/helper.js#L20-L26
|
39,243 |
janus-toendering/options-parser
|
src/helper.js
|
fitWidth
|
function fitWidth(s, len)
{
s = s.trim();
if(s.length <= len) return [s];
var result = [];
while(s.length > len)
{
var i = len
for(; s[i] != ' ' && i >= 0; i--)
/* empty loop */ ;
if(i == -1)
{
for(i = len + 1; s[i] != ' ' && i < s.length; i++)
/* empty loop */ ;
if(i == s.length)
{
result.push(s);
return result;
}
}
result.push(s.substr(0, i));
s = s.substr(i).trimLeft();
}
result.push(s);
return result;
}
|
javascript
|
function fitWidth(s, len)
{
s = s.trim();
if(s.length <= len) return [s];
var result = [];
while(s.length > len)
{
var i = len
for(; s[i] != ' ' && i >= 0; i--)
/* empty loop */ ;
if(i == -1)
{
for(i = len + 1; s[i] != ' ' && i < s.length; i++)
/* empty loop */ ;
if(i == s.length)
{
result.push(s);
return result;
}
}
result.push(s.substr(0, i));
s = s.substr(i).trimLeft();
}
result.push(s);
return result;
}
|
[
"function",
"fitWidth",
"(",
"s",
",",
"len",
")",
"{",
"s",
"=",
"s",
".",
"trim",
"(",
")",
";",
"if",
"(",
"s",
".",
"length",
"<=",
"len",
")",
"return",
"[",
"s",
"]",
";",
"var",
"result",
"=",
"[",
"]",
";",
"while",
"(",
"s",
".",
"length",
">",
"len",
")",
"{",
"var",
"i",
"=",
"len",
"for",
"(",
";",
"s",
"[",
"i",
"]",
"!=",
"' '",
"&&",
"i",
">=",
"0",
";",
"i",
"--",
")",
"/* empty loop */",
";",
"if",
"(",
"i",
"==",
"-",
"1",
")",
"{",
"for",
"(",
"i",
"=",
"len",
"+",
"1",
";",
"s",
"[",
"i",
"]",
"!=",
"' '",
"&&",
"i",
"<",
"s",
".",
"length",
";",
"i",
"++",
")",
"/* empty loop */",
";",
"if",
"(",
"i",
"==",
"s",
".",
"length",
")",
"{",
"result",
".",
"push",
"(",
"s",
")",
";",
"return",
"result",
";",
"}",
"}",
"result",
".",
"push",
"(",
"s",
".",
"substr",
"(",
"0",
",",
"i",
")",
")",
";",
"s",
"=",
"s",
".",
"substr",
"(",
"i",
")",
".",
"trimLeft",
"(",
")",
";",
"}",
"result",
".",
"push",
"(",
"s",
")",
";",
"return",
"result",
";",
"}"
] |
Break a string into lines of len characters and break on spaces
@param {String} s
@param {Number} len
@return {Array.<String>}
@remarks it might return longers lines if s contains words longer than len
|
[
"Break",
"a",
"string",
"into",
"lines",
"of",
"len",
"characters",
"and",
"break",
"on",
"spaces"
] |
f1e39aac203f26e7e4e67fadba63c8dce1c7d70e
|
https://github.com/janus-toendering/options-parser/blob/f1e39aac203f26e7e4e67fadba63c8dce1c7d70e/src/helper.js#L46-L74
|
39,244 |
janus-toendering/options-parser
|
src/helper.js
|
forEach
|
function forEach(obj, cb, ctx)
{
for(var key in obj)
cb.call(ctx, key, obj[key]);
}
|
javascript
|
function forEach(obj, cb, ctx)
{
for(var key in obj)
cb.call(ctx, key, obj[key]);
}
|
[
"function",
"forEach",
"(",
"obj",
",",
"cb",
",",
"ctx",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"cb",
".",
"call",
"(",
"ctx",
",",
"key",
",",
"obj",
"[",
"key",
"]",
")",
";",
"}"
] |
Standard for-each over objects
@param {Object} obj
@param {Function} cb
@param {Object} ctx
|
[
"Standard",
"for",
"-",
"each",
"over",
"objects"
] |
f1e39aac203f26e7e4e67fadba63c8dce1c7d70e
|
https://github.com/janus-toendering/options-parser/blob/f1e39aac203f26e7e4e67fadba63c8dce1c7d70e/src/helper.js#L98-L102
|
39,245 |
janus-toendering/options-parser
|
src/helper.js
|
map
|
function map(obj, cb, ctx)
{
var result = {};
forEach(obj, function(key, val){
result[key] = cb.call(ctx, key, val);
}, ctx);
return result;
}
|
javascript
|
function map(obj, cb, ctx)
{
var result = {};
forEach(obj, function(key, val){
result[key] = cb.call(ctx, key, val);
}, ctx);
return result;
}
|
[
"function",
"map",
"(",
"obj",
",",
"cb",
",",
"ctx",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"forEach",
"(",
"obj",
",",
"function",
"(",
"key",
",",
"val",
")",
"{",
"result",
"[",
"key",
"]",
"=",
"cb",
".",
"call",
"(",
"ctx",
",",
"key",
",",
"val",
")",
";",
"}",
",",
"ctx",
")",
";",
"return",
"result",
";",
"}"
] |
Standard map over objects
@param {Object} obj
@param {Function} cb
@param {Object} ctx
@return {Object}
|
[
"Standard",
"map",
"over",
"objects"
] |
f1e39aac203f26e7e4e67fadba63c8dce1c7d70e
|
https://github.com/janus-toendering/options-parser/blob/f1e39aac203f26e7e4e67fadba63c8dce1c7d70e/src/helper.js#L111-L118
|
39,246 |
smbape/node-umd-builder
|
utils/read-components.js
|
unique
|
function unique(list) {
return Object.keys(list.reduce((obj, key) => {
if (!hasProp.call(obj, key)) {
obj[key] = true;
}
return obj;
}, {}));
}
|
javascript
|
function unique(list) {
return Object.keys(list.reduce((obj, key) => {
if (!hasProp.call(obj, key)) {
obj[key] = true;
}
return obj;
}, {}));
}
|
[
"function",
"unique",
"(",
"list",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"list",
".",
"reduce",
"(",
"(",
"obj",
",",
"key",
")",
"=>",
"{",
"if",
"(",
"!",
"hasProp",
".",
"call",
"(",
"obj",
",",
"key",
")",
")",
"{",
"obj",
"[",
"key",
"]",
"=",
"true",
";",
"}",
"return",
"obj",
";",
"}",
",",
"{",
"}",
")",
")",
";",
"}"
] |
Return unique list items.
|
[
"Return",
"unique",
"list",
"items",
"."
] |
73b03e8c985f2660948f5df71140e4a8fb162549
|
https://github.com/smbape/node-umd-builder/blob/73b03e8c985f2660948f5df71140e4a8fb162549/utils/read-components.js#L56-L63
|
39,247 |
smbape/node-umd-builder
|
utils/read-components.js
|
find
|
function find(list, predicate) { // eslint-disable-line consistent-return
for (var i = 0, length = list.length, item; i < length; i++) {
item = list[i];
if (predicate(item)) {
return item;
}
}
}
|
javascript
|
function find(list, predicate) { // eslint-disable-line consistent-return
for (var i = 0, length = list.length, item; i < length; i++) {
item = list[i];
if (predicate(item)) {
return item;
}
}
}
|
[
"function",
"find",
"(",
"list",
",",
"predicate",
")",
"{",
"// eslint-disable-line consistent-return",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"length",
"=",
"list",
".",
"length",
",",
"item",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"item",
"=",
"list",
"[",
"i",
"]",
";",
"if",
"(",
"predicate",
"(",
"item",
")",
")",
"{",
"return",
"item",
";",
"}",
"}",
"}"
] |
Find an item in list.
|
[
"Find",
"an",
"item",
"in",
"list",
"."
] |
73b03e8c985f2660948f5df71140e4a8fb162549
|
https://github.com/smbape/node-umd-builder/blob/73b03e8c985f2660948f5df71140e4a8fb162549/utils/read-components.js#L241-L248
|
39,248 |
smbape/node-umd-builder
|
utils/read-components.js
|
setSortingLevels
|
function setSortingLevels(packages, type) {
function setLevel(initial, pkg) {
var level = Math.max(pkg.sortingLevel || 0, initial);
var deps = Object.keys(pkg.dependencies);
// console.log('setLevel', pkg.name, level);
pkg.sortingLevel = level;
deps.forEach(depName => {
depName = sanitizeRepo(depName);
var dep = find(packages, _ => {
if (type === "component") {
var repo = _[dependencyLocator[type]];
if (repo === depName) {
return true;
}
// nasty hack to ensure component repo ends with the specified repo
// e.g. "repo": "https://raw.github.com/component/typeof"
var suffix = "/" + depName;
return repo.indexOf(suffix, repo.length - suffix.length) !== -1;
}
return _[dependencyLocator[type]] === depName;
});
if (!dep) {
var names = Object.keys(packages).map(_ => {
return packages[_].name;
}).join(", ");
throw new Error("Dependency \"" + depName + "\" is not present in the list of deps [" + names + "]. Specify correct dependency in " + type + ".json or contact package author.");
}
setLevel(initial + 1, dep);
});
}
packages.forEach(setLevel.bind(null, 1));
return packages;
}
|
javascript
|
function setSortingLevels(packages, type) {
function setLevel(initial, pkg) {
var level = Math.max(pkg.sortingLevel || 0, initial);
var deps = Object.keys(pkg.dependencies);
// console.log('setLevel', pkg.name, level);
pkg.sortingLevel = level;
deps.forEach(depName => {
depName = sanitizeRepo(depName);
var dep = find(packages, _ => {
if (type === "component") {
var repo = _[dependencyLocator[type]];
if (repo === depName) {
return true;
}
// nasty hack to ensure component repo ends with the specified repo
// e.g. "repo": "https://raw.github.com/component/typeof"
var suffix = "/" + depName;
return repo.indexOf(suffix, repo.length - suffix.length) !== -1;
}
return _[dependencyLocator[type]] === depName;
});
if (!dep) {
var names = Object.keys(packages).map(_ => {
return packages[_].name;
}).join(", ");
throw new Error("Dependency \"" + depName + "\" is not present in the list of deps [" + names + "]. Specify correct dependency in " + type + ".json or contact package author.");
}
setLevel(initial + 1, dep);
});
}
packages.forEach(setLevel.bind(null, 1));
return packages;
}
|
[
"function",
"setSortingLevels",
"(",
"packages",
",",
"type",
")",
"{",
"function",
"setLevel",
"(",
"initial",
",",
"pkg",
")",
"{",
"var",
"level",
"=",
"Math",
".",
"max",
"(",
"pkg",
".",
"sortingLevel",
"||",
"0",
",",
"initial",
")",
";",
"var",
"deps",
"=",
"Object",
".",
"keys",
"(",
"pkg",
".",
"dependencies",
")",
";",
"// console.log('setLevel', pkg.name, level);",
"pkg",
".",
"sortingLevel",
"=",
"level",
";",
"deps",
".",
"forEach",
"(",
"depName",
"=>",
"{",
"depName",
"=",
"sanitizeRepo",
"(",
"depName",
")",
";",
"var",
"dep",
"=",
"find",
"(",
"packages",
",",
"_",
"=>",
"{",
"if",
"(",
"type",
"===",
"\"component\"",
")",
"{",
"var",
"repo",
"=",
"_",
"[",
"dependencyLocator",
"[",
"type",
"]",
"]",
";",
"if",
"(",
"repo",
"===",
"depName",
")",
"{",
"return",
"true",
";",
"}",
"// nasty hack to ensure component repo ends with the specified repo",
"// e.g. \"repo\": \"https://raw.github.com/component/typeof\"",
"var",
"suffix",
"=",
"\"/\"",
"+",
"depName",
";",
"return",
"repo",
".",
"indexOf",
"(",
"suffix",
",",
"repo",
".",
"length",
"-",
"suffix",
".",
"length",
")",
"!==",
"-",
"1",
";",
"}",
"return",
"_",
"[",
"dependencyLocator",
"[",
"type",
"]",
"]",
"===",
"depName",
";",
"}",
")",
";",
"if",
"(",
"!",
"dep",
")",
"{",
"var",
"names",
"=",
"Object",
".",
"keys",
"(",
"packages",
")",
".",
"map",
"(",
"_",
"=>",
"{",
"return",
"packages",
"[",
"_",
"]",
".",
"name",
";",
"}",
")",
".",
"join",
"(",
"\", \"",
")",
";",
"throw",
"new",
"Error",
"(",
"\"Dependency \\\"\"",
"+",
"depName",
"+",
"\"\\\" is not present in the list of deps [\"",
"+",
"names",
"+",
"\"]. Specify correct dependency in \"",
"+",
"type",
"+",
"\".json or contact package author.\"",
")",
";",
"}",
"setLevel",
"(",
"initial",
"+",
"1",
",",
"dep",
")",
";",
"}",
")",
";",
"}",
"packages",
".",
"forEach",
"(",
"setLevel",
".",
"bind",
"(",
"null",
",",
"1",
")",
")",
";",
"return",
"packages",
";",
"}"
] |
Iterate recursively over each dependency and increase level on each iteration.
|
[
"Iterate",
"recursively",
"over",
"each",
"dependency",
"and",
"increase",
"level",
"on",
"each",
"iteration",
"."
] |
73b03e8c985f2660948f5df71140e4a8fb162549
|
https://github.com/smbape/node-umd-builder/blob/73b03e8c985f2660948f5df71140e4a8fb162549/utils/read-components.js#L252-L285
|
39,249 |
smbape/node-umd-builder
|
utils/read-components.js
|
sortPackages
|
function sortPackages(packages, type) {
return setSortingLevels(packages, type).sort((a, b) => {
return b.sortingLevel - a.sortingLevel;
});
}
|
javascript
|
function sortPackages(packages, type) {
return setSortingLevels(packages, type).sort((a, b) => {
return b.sortingLevel - a.sortingLevel;
});
}
|
[
"function",
"sortPackages",
"(",
"packages",
",",
"type",
")",
"{",
"return",
"setSortingLevels",
"(",
"packages",
",",
"type",
")",
".",
"sort",
"(",
"(",
"a",
",",
"b",
")",
"=>",
"{",
"return",
"b",
".",
"sortingLevel",
"-",
"a",
".",
"sortingLevel",
";",
"}",
")",
";",
"}"
] |
Sort packages automatically, bas'component'ed on their dependencies.
|
[
"Sort",
"packages",
"automatically",
"bas",
"component",
"ed",
"on",
"their",
"dependencies",
"."
] |
73b03e8c985f2660948f5df71140e4a8fb162549
|
https://github.com/smbape/node-umd-builder/blob/73b03e8c985f2660948f5df71140e4a8fb162549/utils/read-components.js#L288-L292
|
39,250 |
spyfu/spyfu-vue-factory
|
lib/factory.js
|
createStore
|
function createStore(ClonedVue, rawModules, state) {
let Vuex = require('vuex');
if (typeof Vuex.default !== 'undefined') {
Vuex = Vuex.default;
}
ClonedVue.use(Vuex);
// create a normalized copy of our vuex modules
const normalizedModules = normalizeModules(rawModules);
// merge in any test specific state
const modules = mergeTestState(normalizedModules, state);
// return the instantiated vuex store
return new Vuex.Store({ state, modules, strict: true });
}
|
javascript
|
function createStore(ClonedVue, rawModules, state) {
let Vuex = require('vuex');
if (typeof Vuex.default !== 'undefined') {
Vuex = Vuex.default;
}
ClonedVue.use(Vuex);
// create a normalized copy of our vuex modules
const normalizedModules = normalizeModules(rawModules);
// merge in any test specific state
const modules = mergeTestState(normalizedModules, state);
// return the instantiated vuex store
return new Vuex.Store({ state, modules, strict: true });
}
|
[
"function",
"createStore",
"(",
"ClonedVue",
",",
"rawModules",
",",
"state",
")",
"{",
"let",
"Vuex",
"=",
"require",
"(",
"'vuex'",
")",
";",
"if",
"(",
"typeof",
"Vuex",
".",
"default",
"!==",
"'undefined'",
")",
"{",
"Vuex",
"=",
"Vuex",
".",
"default",
";",
"}",
"ClonedVue",
".",
"use",
"(",
"Vuex",
")",
";",
"// create a normalized copy of our vuex modules",
"const",
"normalizedModules",
"=",
"normalizeModules",
"(",
"rawModules",
")",
";",
"// merge in any test specific state",
"const",
"modules",
"=",
"mergeTestState",
"(",
"normalizedModules",
",",
"state",
")",
";",
"// return the instantiated vuex store",
"return",
"new",
"Vuex",
".",
"Store",
"(",
"{",
"state",
",",
"modules",
",",
"strict",
":",
"true",
"}",
")",
";",
"}"
] |
helper function to create a vuex store instance
|
[
"helper",
"function",
"to",
"create",
"a",
"vuex",
"store",
"instance"
] |
9d0513ecbd7f56ab082ded01bb17a28ac4f72430
|
https://github.com/spyfu/spyfu-vue-factory/blob/9d0513ecbd7f56ab082ded01bb17a28ac4f72430/lib/factory.js#L102-L119
|
39,251 |
JohnnyTheTank/angular-masonry-packed
|
dist/angular-masonry-packed.js
|
mungeNonPixel
|
function mungeNonPixel( elem, value ) {
// IE8 and has percent value
if ( window.getComputedStyle || value.indexOf('%') === -1 ) {
return value;
}
var style = elem.style;
// Remember the original values
var left = style.left;
var rs = elem.runtimeStyle;
var rsLeft = rs && rs.left;
// Put in the new values to get a computed value out
if ( rsLeft ) {
rs.left = elem.currentStyle.left;
}
style.left = value;
value = style.pixelLeft;
// Revert the changed values
style.left = left;
if ( rsLeft ) {
rs.left = rsLeft;
}
return value;
}
|
javascript
|
function mungeNonPixel( elem, value ) {
// IE8 and has percent value
if ( window.getComputedStyle || value.indexOf('%') === -1 ) {
return value;
}
var style = elem.style;
// Remember the original values
var left = style.left;
var rs = elem.runtimeStyle;
var rsLeft = rs && rs.left;
// Put in the new values to get a computed value out
if ( rsLeft ) {
rs.left = elem.currentStyle.left;
}
style.left = value;
value = style.pixelLeft;
// Revert the changed values
style.left = left;
if ( rsLeft ) {
rs.left = rsLeft;
}
return value;
}
|
[
"function",
"mungeNonPixel",
"(",
"elem",
",",
"value",
")",
"{",
"// IE8 and has percent value",
"if",
"(",
"window",
".",
"getComputedStyle",
"||",
"value",
".",
"indexOf",
"(",
"'%'",
")",
"===",
"-",
"1",
")",
"{",
"return",
"value",
";",
"}",
"var",
"style",
"=",
"elem",
".",
"style",
";",
"// Remember the original values",
"var",
"left",
"=",
"style",
".",
"left",
";",
"var",
"rs",
"=",
"elem",
".",
"runtimeStyle",
";",
"var",
"rsLeft",
"=",
"rs",
"&&",
"rs",
".",
"left",
";",
"// Put in the new values to get a computed value out",
"if",
"(",
"rsLeft",
")",
"{",
"rs",
".",
"left",
"=",
"elem",
".",
"currentStyle",
".",
"left",
";",
"}",
"style",
".",
"left",
"=",
"value",
";",
"value",
"=",
"style",
".",
"pixelLeft",
";",
"// Revert the changed values",
"style",
".",
"left",
"=",
"left",
";",
"if",
"(",
"rsLeft",
")",
"{",
"rs",
".",
"left",
"=",
"rsLeft",
";",
"}",
"return",
"value",
";",
"}"
] |
IE8 returns percent values, not pixels taken from jQuery's curCSS
|
[
"IE8",
"returns",
"percent",
"values",
"not",
"pixels",
"taken",
"from",
"jQuery",
"s",
"curCSS"
] |
4291ed734cc17decc8bf07a376c6d82e003e8c7b
|
https://github.com/JohnnyTheTank/angular-masonry-packed/blob/4291ed734cc17decc8bf07a376c6d82e003e8c7b/dist/angular-masonry-packed.js#L407-L432
|
39,252 |
JohnnyTheTank/angular-masonry-packed
|
dist/angular-masonry-packed.js
|
onReady
|
function onReady( event ) {
// bail if already triggered or IE8 document is not ready just yet
var isIE8NotReady = event.type === 'readystatechange' && document.readyState !== 'complete';
if ( docReady.isReady || isIE8NotReady ) {
return;
}
trigger();
}
|
javascript
|
function onReady( event ) {
// bail if already triggered or IE8 document is not ready just yet
var isIE8NotReady = event.type === 'readystatechange' && document.readyState !== 'complete';
if ( docReady.isReady || isIE8NotReady ) {
return;
}
trigger();
}
|
[
"function",
"onReady",
"(",
"event",
")",
"{",
"// bail if already triggered or IE8 document is not ready just yet",
"var",
"isIE8NotReady",
"=",
"event",
".",
"type",
"===",
"'readystatechange'",
"&&",
"document",
".",
"readyState",
"!==",
"'complete'",
";",
"if",
"(",
"docReady",
".",
"isReady",
"||",
"isIE8NotReady",
")",
"{",
"return",
";",
"}",
"trigger",
"(",
")",
";",
"}"
] |
triggered on various doc ready events
|
[
"triggered",
"on",
"various",
"doc",
"ready",
"events"
] |
4291ed734cc17decc8bf07a376c6d82e003e8c7b
|
https://github.com/JohnnyTheTank/angular-masonry-packed/blob/4291ed734cc17decc8bf07a376c6d82e003e8c7b/dist/angular-masonry-packed.js#L1042-L1050
|
39,253 |
JohnnyTheTank/angular-masonry-packed
|
dist/angular-masonry-packed.js
|
query
|
function query( elem, selector ) {
// append to fragment if no parent
checkParent( elem );
// match elem with all selected elems of parent
var elems = elem.parentNode.querySelectorAll( selector );
for ( var i=0, len = elems.length; i < len; i++ ) {
// return true if match
if ( elems[i] === elem ) {
return true;
}
}
// otherwise return false
return false;
}
|
javascript
|
function query( elem, selector ) {
// append to fragment if no parent
checkParent( elem );
// match elem with all selected elems of parent
var elems = elem.parentNode.querySelectorAll( selector );
for ( var i=0, len = elems.length; i < len; i++ ) {
// return true if match
if ( elems[i] === elem ) {
return true;
}
}
// otherwise return false
return false;
}
|
[
"function",
"query",
"(",
"elem",
",",
"selector",
")",
"{",
"// append to fragment if no parent",
"checkParent",
"(",
"elem",
")",
";",
"// match elem with all selected elems of parent",
"var",
"elems",
"=",
"elem",
".",
"parentNode",
".",
"querySelectorAll",
"(",
"selector",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"elems",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"// return true if match",
"if",
"(",
"elems",
"[",
"i",
"]",
"===",
"elem",
")",
"{",
"return",
"true",
";",
"}",
"}",
"// otherwise return false",
"return",
"false",
";",
"}"
] |
fall back to using QSA thx @jonathantneal https://gist.github.com/3062955
|
[
"fall",
"back",
"to",
"using",
"QSA",
"thx"
] |
4291ed734cc17decc8bf07a376c6d82e003e8c7b
|
https://github.com/JohnnyTheTank/angular-masonry-packed/blob/4291ed734cc17decc8bf07a376c6d82e003e8c7b/dist/angular-masonry-packed.js#L1142-L1156
|
39,254 |
hogart/rpg-tools
|
lib/Dice.js
|
function (notation) {
var tokens = this.notationRe.exec(notation);
this.rolls = tokens[1] === undefined ? this.defaultRolls : parseInt(tokens[1]); // default if omitted
this.sides = tokens[2] === undefined ? this.defaultSides : parseInt(tokens[2]); // default if omitted
var after = tokens[3];
var additionTokens;
if (after) { // we have third part of notation
if (after === '-L') {
this.specials.chooseLowest = true;
} else if (after === '-H') {
this.specials.chooseHighest = true;
} else {
additionTokens = this.additionRe.exec(after);
this.specials.add = parseInt(additionTokens[2]);
if (additionTokens[1] === '-') {
this.specials.add *= -1;
}
}
}
return this;
}
|
javascript
|
function (notation) {
var tokens = this.notationRe.exec(notation);
this.rolls = tokens[1] === undefined ? this.defaultRolls : parseInt(tokens[1]); // default if omitted
this.sides = tokens[2] === undefined ? this.defaultSides : parseInt(tokens[2]); // default if omitted
var after = tokens[3];
var additionTokens;
if (after) { // we have third part of notation
if (after === '-L') {
this.specials.chooseLowest = true;
} else if (after === '-H') {
this.specials.chooseHighest = true;
} else {
additionTokens = this.additionRe.exec(after);
this.specials.add = parseInt(additionTokens[2]);
if (additionTokens[1] === '-') {
this.specials.add *= -1;
}
}
}
return this;
}
|
[
"function",
"(",
"notation",
")",
"{",
"var",
"tokens",
"=",
"this",
".",
"notationRe",
".",
"exec",
"(",
"notation",
")",
";",
"this",
".",
"rolls",
"=",
"tokens",
"[",
"1",
"]",
"===",
"undefined",
"?",
"this",
".",
"defaultRolls",
":",
"parseInt",
"(",
"tokens",
"[",
"1",
"]",
")",
";",
"// default if omitted",
"this",
".",
"sides",
"=",
"tokens",
"[",
"2",
"]",
"===",
"undefined",
"?",
"this",
".",
"defaultSides",
":",
"parseInt",
"(",
"tokens",
"[",
"2",
"]",
")",
";",
"// default if omitted",
"var",
"after",
"=",
"tokens",
"[",
"3",
"]",
";",
"var",
"additionTokens",
";",
"if",
"(",
"after",
")",
"{",
"// we have third part of notation",
"if",
"(",
"after",
"===",
"'-L'",
")",
"{",
"this",
".",
"specials",
".",
"chooseLowest",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"after",
"===",
"'-H'",
")",
"{",
"this",
".",
"specials",
".",
"chooseHighest",
"=",
"true",
";",
"}",
"else",
"{",
"additionTokens",
"=",
"this",
".",
"additionRe",
".",
"exec",
"(",
"after",
")",
";",
"this",
".",
"specials",
".",
"add",
"=",
"parseInt",
"(",
"additionTokens",
"[",
"2",
"]",
")",
";",
"if",
"(",
"additionTokens",
"[",
"1",
"]",
"===",
"'-'",
")",
"{",
"this",
".",
"specials",
".",
"add",
"*=",
"-",
"1",
";",
"}",
"}",
"}",
"return",
"this",
";",
"}"
] |
Parses a notation
@param {String} notation e.g. "3d6+6"
@returns {Dice} this instance (for chaining)
|
[
"Parses",
"a",
"notation"
] |
6909e3f3c21c2fd4c9e7d82103a69f11ae7e4375
|
https://github.com/hogart/rpg-tools/blob/6909e3f3c21c2fd4c9e7d82103a69f11ae7e4375/lib/Dice.js#L38-L62
|
|
39,255 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js
|
function( oDTSettings, oInit )
{
/* Santiy check that we are a new instance */
if ( !this.CLASS || this.CLASS != "ColVis" )
{
alert( "Warning: ColVis must be initialised with the keyword 'new'" );
}
if ( typeof oInit == 'undefined' )
{
oInit = {};
}
var camelToHungarian = $.fn.dataTable.camelToHungarian;
if ( camelToHungarian ) {
camelToHungarian( ColVis.defaults, ColVis.defaults, true );
camelToHungarian( ColVis.defaults, oInit );
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Public class variables
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* @namespace Settings object which contains customisable information for
* ColVis instance. Augmented by ColVis.defaults
*/
this.s = {
/**
* DataTables settings object
* @property dt
* @type Object
* @default null
*/
"dt": null,
/**
* Customisation object
* @property oInit
* @type Object
* @default passed in
*/
"oInit": oInit,
/**
* Flag to say if the collection is hidden
* @property hidden
* @type boolean
* @default true
*/
"hidden": true,
/**
* Store the original visibility settings so they could be restored
* @property abOriginal
* @type Array
* @default []
*/
"abOriginal": []
};
/**
* @namespace Common and useful DOM elements for the class instance
*/
this.dom = {
/**
* Wrapper for the button - given back to DataTables as the node to insert
* @property wrapper
* @type Node
* @default null
*/
"wrapper": null,
/**
* Activation button
* @property button
* @type Node
* @default null
*/
"button": null,
/**
* Collection list node
* @property collection
* @type Node
* @default null
*/
"collection": null,
/**
* Background node used for shading the display and event capturing
* @property background
* @type Node
* @default null
*/
"background": null,
/**
* Element to position over the activation button to catch mouse events when using mouseover
* @property catcher
* @type Node
* @default null
*/
"catcher": null,
/**
* List of button elements
* @property buttons
* @type Array
* @default []
*/
"buttons": [],
/**
* List of group button elements
* @property groupButtons
* @type Array
* @default []
*/
"groupButtons": [],
/**
* Restore button
* @property restore
* @type Node
* @default null
*/
"restore": null
};
/* Store global reference */
ColVis.aInstances.push( this );
/* Constructor logic */
this.s.dt = $.fn.dataTable.Api ?
new $.fn.dataTable.Api( oDTSettings ).settings()[0] :
oDTSettings;
this._fnConstruct( oInit );
return this;
}
|
javascript
|
function( oDTSettings, oInit )
{
/* Santiy check that we are a new instance */
if ( !this.CLASS || this.CLASS != "ColVis" )
{
alert( "Warning: ColVis must be initialised with the keyword 'new'" );
}
if ( typeof oInit == 'undefined' )
{
oInit = {};
}
var camelToHungarian = $.fn.dataTable.camelToHungarian;
if ( camelToHungarian ) {
camelToHungarian( ColVis.defaults, ColVis.defaults, true );
camelToHungarian( ColVis.defaults, oInit );
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Public class variables
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* @namespace Settings object which contains customisable information for
* ColVis instance. Augmented by ColVis.defaults
*/
this.s = {
/**
* DataTables settings object
* @property dt
* @type Object
* @default null
*/
"dt": null,
/**
* Customisation object
* @property oInit
* @type Object
* @default passed in
*/
"oInit": oInit,
/**
* Flag to say if the collection is hidden
* @property hidden
* @type boolean
* @default true
*/
"hidden": true,
/**
* Store the original visibility settings so they could be restored
* @property abOriginal
* @type Array
* @default []
*/
"abOriginal": []
};
/**
* @namespace Common and useful DOM elements for the class instance
*/
this.dom = {
/**
* Wrapper for the button - given back to DataTables as the node to insert
* @property wrapper
* @type Node
* @default null
*/
"wrapper": null,
/**
* Activation button
* @property button
* @type Node
* @default null
*/
"button": null,
/**
* Collection list node
* @property collection
* @type Node
* @default null
*/
"collection": null,
/**
* Background node used for shading the display and event capturing
* @property background
* @type Node
* @default null
*/
"background": null,
/**
* Element to position over the activation button to catch mouse events when using mouseover
* @property catcher
* @type Node
* @default null
*/
"catcher": null,
/**
* List of button elements
* @property buttons
* @type Array
* @default []
*/
"buttons": [],
/**
* List of group button elements
* @property groupButtons
* @type Array
* @default []
*/
"groupButtons": [],
/**
* Restore button
* @property restore
* @type Node
* @default null
*/
"restore": null
};
/* Store global reference */
ColVis.aInstances.push( this );
/* Constructor logic */
this.s.dt = $.fn.dataTable.Api ?
new $.fn.dataTable.Api( oDTSettings ).settings()[0] :
oDTSettings;
this._fnConstruct( oInit );
return this;
}
|
[
"function",
"(",
"oDTSettings",
",",
"oInit",
")",
"{",
"/* Santiy check that we are a new instance */",
"if",
"(",
"!",
"this",
".",
"CLASS",
"||",
"this",
".",
"CLASS",
"!=",
"\"ColVis\"",
")",
"{",
"alert",
"(",
"\"Warning: ColVis must be initialised with the keyword 'new'\"",
")",
";",
"}",
"if",
"(",
"typeof",
"oInit",
"==",
"'undefined'",
")",
"{",
"oInit",
"=",
"{",
"}",
";",
"}",
"var",
"camelToHungarian",
"=",
"$",
".",
"fn",
".",
"dataTable",
".",
"camelToHungarian",
";",
"if",
"(",
"camelToHungarian",
")",
"{",
"camelToHungarian",
"(",
"ColVis",
".",
"defaults",
",",
"ColVis",
".",
"defaults",
",",
"true",
")",
";",
"camelToHungarian",
"(",
"ColVis",
".",
"defaults",
",",
"oInit",
")",
";",
"}",
"/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\t * Public class variables\n\t * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */",
"/**\n\t * @namespace Settings object which contains customisable information for\n\t * ColVis instance. Augmented by ColVis.defaults\n\t */",
"this",
".",
"s",
"=",
"{",
"/**\n\t\t * DataTables settings object\n\t\t * @property dt\n\t\t * @type Object\n\t\t * @default null\n\t\t */",
"\"dt\"",
":",
"null",
",",
"/**\n\t\t * Customisation object\n\t\t * @property oInit\n\t\t * @type Object\n\t\t * @default passed in\n\t\t */",
"\"oInit\"",
":",
"oInit",
",",
"/**\n\t\t * Flag to say if the collection is hidden\n\t\t * @property hidden\n\t\t * @type boolean\n\t\t * @default true\n\t\t */",
"\"hidden\"",
":",
"true",
",",
"/**\n\t\t * Store the original visibility settings so they could be restored\n\t\t * @property abOriginal\n\t\t * @type Array\n\t\t * @default []\n\t\t */",
"\"abOriginal\"",
":",
"[",
"]",
"}",
";",
"/**\n\t * @namespace Common and useful DOM elements for the class instance\n\t */",
"this",
".",
"dom",
"=",
"{",
"/**\n\t\t * Wrapper for the button - given back to DataTables as the node to insert\n\t\t * @property wrapper\n\t\t * @type Node\n\t\t * @default null\n\t\t */",
"\"wrapper\"",
":",
"null",
",",
"/**\n\t\t * Activation button\n\t\t * @property button\n\t\t * @type Node\n\t\t * @default null\n\t\t */",
"\"button\"",
":",
"null",
",",
"/**\n\t\t * Collection list node\n\t\t * @property collection\n\t\t * @type Node\n\t\t * @default null\n\t\t */",
"\"collection\"",
":",
"null",
",",
"/**\n\t\t * Background node used for shading the display and event capturing\n\t\t * @property background\n\t\t * @type Node\n\t\t * @default null\n\t\t */",
"\"background\"",
":",
"null",
",",
"/**\n\t\t * Element to position over the activation button to catch mouse events when using mouseover\n\t\t * @property catcher\n\t\t * @type Node\n\t\t * @default null\n\t\t */",
"\"catcher\"",
":",
"null",
",",
"/**\n\t\t * List of button elements\n\t\t * @property buttons\n\t\t * @type Array\n\t\t * @default []\n\t\t */",
"\"buttons\"",
":",
"[",
"]",
",",
"/**\n\t\t * List of group button elements\n\t\t * @property groupButtons\n\t\t * @type Array\n\t\t * @default []\n\t\t */",
"\"groupButtons\"",
":",
"[",
"]",
",",
"/**\n\t\t * Restore button\n\t\t * @property restore\n\t\t * @type Node\n\t\t * @default null\n\t\t */",
"\"restore\"",
":",
"null",
"}",
";",
"/* Store global reference */",
"ColVis",
".",
"aInstances",
".",
"push",
"(",
"this",
")",
";",
"/* Constructor logic */",
"this",
".",
"s",
".",
"dt",
"=",
"$",
".",
"fn",
".",
"dataTable",
".",
"Api",
"?",
"new",
"$",
".",
"fn",
".",
"dataTable",
".",
"Api",
"(",
"oDTSettings",
")",
".",
"settings",
"(",
")",
"[",
"0",
"]",
":",
"oDTSettings",
";",
"this",
".",
"_fnConstruct",
"(",
"oInit",
")",
";",
"return",
"this",
";",
"}"
] |
ColVis provides column visibility control for DataTables
@class ColVis
@constructor
@param {object} DataTables settings object. With DataTables 1.10 this can
also be and API instance, table node, jQuery collection or jQuery selector.
@param {object} ColVis configuration options
|
[
"ColVis",
"provides",
"column",
"visibility",
"control",
"for",
"DataTables"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js#L39-L181
|
|
39,256 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js
|
function ( init )
{
$.extend( true, this.s, ColVis.defaults, init );
// Slightly messy overlap for the camelCase notation
if ( ! this.s.showAll && this.s.bShowAll ) {
this.s.showAll = this.s.sShowAll;
}
if ( ! this.s.restore && this.s.bRestore ) {
this.s.restore = this.s.sRestore;
}
// CamelCase to Hungarian for the column groups
var groups = this.s.groups;
var hungarianGroups = this.s.aoGroups;
if ( groups ) {
for ( var i=0, ien=groups.length ; i<ien ; i++ ) {
if ( groups[i].title ) {
hungarianGroups[i].sTitle = groups[i].title;
}
if ( groups[i].columns ) {
hungarianGroups[i].aiColumns = groups[i].columns;
}
}
}
}
|
javascript
|
function ( init )
{
$.extend( true, this.s, ColVis.defaults, init );
// Slightly messy overlap for the camelCase notation
if ( ! this.s.showAll && this.s.bShowAll ) {
this.s.showAll = this.s.sShowAll;
}
if ( ! this.s.restore && this.s.bRestore ) {
this.s.restore = this.s.sRestore;
}
// CamelCase to Hungarian for the column groups
var groups = this.s.groups;
var hungarianGroups = this.s.aoGroups;
if ( groups ) {
for ( var i=0, ien=groups.length ; i<ien ; i++ ) {
if ( groups[i].title ) {
hungarianGroups[i].sTitle = groups[i].title;
}
if ( groups[i].columns ) {
hungarianGroups[i].aiColumns = groups[i].columns;
}
}
}
}
|
[
"function",
"(",
"init",
")",
"{",
"$",
".",
"extend",
"(",
"true",
",",
"this",
".",
"s",
",",
"ColVis",
".",
"defaults",
",",
"init",
")",
";",
"// Slightly messy overlap for the camelCase notation",
"if",
"(",
"!",
"this",
".",
"s",
".",
"showAll",
"&&",
"this",
".",
"s",
".",
"bShowAll",
")",
"{",
"this",
".",
"s",
".",
"showAll",
"=",
"this",
".",
"s",
".",
"sShowAll",
";",
"}",
"if",
"(",
"!",
"this",
".",
"s",
".",
"restore",
"&&",
"this",
".",
"s",
".",
"bRestore",
")",
"{",
"this",
".",
"s",
".",
"restore",
"=",
"this",
".",
"s",
".",
"sRestore",
";",
"}",
"// CamelCase to Hungarian for the column groups ",
"var",
"groups",
"=",
"this",
".",
"s",
".",
"groups",
";",
"var",
"hungarianGroups",
"=",
"this",
".",
"s",
".",
"aoGroups",
";",
"if",
"(",
"groups",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ien",
"=",
"groups",
".",
"length",
";",
"i",
"<",
"ien",
";",
"i",
"++",
")",
"{",
"if",
"(",
"groups",
"[",
"i",
"]",
".",
"title",
")",
"{",
"hungarianGroups",
"[",
"i",
"]",
".",
"sTitle",
"=",
"groups",
"[",
"i",
"]",
".",
"title",
";",
"}",
"if",
"(",
"groups",
"[",
"i",
"]",
".",
"columns",
")",
"{",
"hungarianGroups",
"[",
"i",
"]",
".",
"aiColumns",
"=",
"groups",
"[",
"i",
"]",
".",
"columns",
";",
"}",
"}",
"}",
"}"
] |
Apply any customisation to the settings from the DataTables initialisation
@method _fnApplyCustomisation
@returns void
@private
|
[
"Apply",
"any",
"customisation",
"to",
"the",
"settings",
"from",
"the",
"DataTables",
"initialisation"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js#L318-L344
|
|
39,257 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js
|
function ()
{
var columns = this.s.dt.aoColumns;
var buttons = this.dom.buttons;
var groups = this.s.aoGroups;
var button;
for ( var i=0, ien=buttons.length ; i<ien ; i++ ) {
button = buttons[i];
if ( button.__columnIdx !== undefined ) {
$('input', button).prop( 'checked', columns[ button.__columnIdx ].bVisible );
}
}
var allVisible = function ( columnIndeces ) {
for ( var k=0, kLen=columnIndeces.length ; k<kLen ; k++ )
{
if ( columns[columnIndeces[k]].bVisible === false ) { return false; }
}
return true;
};
var allHidden = function ( columnIndeces ) {
for ( var m=0 , mLen=columnIndeces.length ; m<mLen ; m++ )
{
if ( columns[columnIndeces[m]].bVisible === true ) { return false; }
}
return true;
};
for ( var j=0, jLen=groups.length ; j<jLen ; j++ )
{
if ( allVisible(groups[j].aiColumns) )
{
$('input', this.dom.groupButtons[j]).prop('checked', true);
$('input', this.dom.groupButtons[j]).prop('indeterminate', false);
}
else if ( allHidden(groups[j].aiColumns) )
{
$('input', this.dom.groupButtons[j]).prop('checked', false);
$('input', this.dom.groupButtons[j]).prop('indeterminate', false);
}
else
{
$('input', this.dom.groupButtons[j]).prop('indeterminate', true);
}
}
}
|
javascript
|
function ()
{
var columns = this.s.dt.aoColumns;
var buttons = this.dom.buttons;
var groups = this.s.aoGroups;
var button;
for ( var i=0, ien=buttons.length ; i<ien ; i++ ) {
button = buttons[i];
if ( button.__columnIdx !== undefined ) {
$('input', button).prop( 'checked', columns[ button.__columnIdx ].bVisible );
}
}
var allVisible = function ( columnIndeces ) {
for ( var k=0, kLen=columnIndeces.length ; k<kLen ; k++ )
{
if ( columns[columnIndeces[k]].bVisible === false ) { return false; }
}
return true;
};
var allHidden = function ( columnIndeces ) {
for ( var m=0 , mLen=columnIndeces.length ; m<mLen ; m++ )
{
if ( columns[columnIndeces[m]].bVisible === true ) { return false; }
}
return true;
};
for ( var j=0, jLen=groups.length ; j<jLen ; j++ )
{
if ( allVisible(groups[j].aiColumns) )
{
$('input', this.dom.groupButtons[j]).prop('checked', true);
$('input', this.dom.groupButtons[j]).prop('indeterminate', false);
}
else if ( allHidden(groups[j].aiColumns) )
{
$('input', this.dom.groupButtons[j]).prop('checked', false);
$('input', this.dom.groupButtons[j]).prop('indeterminate', false);
}
else
{
$('input', this.dom.groupButtons[j]).prop('indeterminate', true);
}
}
}
|
[
"function",
"(",
")",
"{",
"var",
"columns",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
";",
"var",
"buttons",
"=",
"this",
".",
"dom",
".",
"buttons",
";",
"var",
"groups",
"=",
"this",
".",
"s",
".",
"aoGroups",
";",
"var",
"button",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"ien",
"=",
"buttons",
".",
"length",
";",
"i",
"<",
"ien",
";",
"i",
"++",
")",
"{",
"button",
"=",
"buttons",
"[",
"i",
"]",
";",
"if",
"(",
"button",
".",
"__columnIdx",
"!==",
"undefined",
")",
"{",
"$",
"(",
"'input'",
",",
"button",
")",
".",
"prop",
"(",
"'checked'",
",",
"columns",
"[",
"button",
".",
"__columnIdx",
"]",
".",
"bVisible",
")",
";",
"}",
"}",
"var",
"allVisible",
"=",
"function",
"(",
"columnIndeces",
")",
"{",
"for",
"(",
"var",
"k",
"=",
"0",
",",
"kLen",
"=",
"columnIndeces",
".",
"length",
";",
"k",
"<",
"kLen",
";",
"k",
"++",
")",
"{",
"if",
"(",
"columns",
"[",
"columnIndeces",
"[",
"k",
"]",
"]",
".",
"bVisible",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
";",
"var",
"allHidden",
"=",
"function",
"(",
"columnIndeces",
")",
"{",
"for",
"(",
"var",
"m",
"=",
"0",
",",
"mLen",
"=",
"columnIndeces",
".",
"length",
";",
"m",
"<",
"mLen",
";",
"m",
"++",
")",
"{",
"if",
"(",
"columns",
"[",
"columnIndeces",
"[",
"m",
"]",
"]",
".",
"bVisible",
"===",
"true",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}",
";",
"for",
"(",
"var",
"j",
"=",
"0",
",",
"jLen",
"=",
"groups",
".",
"length",
";",
"j",
"<",
"jLen",
";",
"j",
"++",
")",
"{",
"if",
"(",
"allVisible",
"(",
"groups",
"[",
"j",
"]",
".",
"aiColumns",
")",
")",
"{",
"$",
"(",
"'input'",
",",
"this",
".",
"dom",
".",
"groupButtons",
"[",
"j",
"]",
")",
".",
"prop",
"(",
"'checked'",
",",
"true",
")",
";",
"$",
"(",
"'input'",
",",
"this",
".",
"dom",
".",
"groupButtons",
"[",
"j",
"]",
")",
".",
"prop",
"(",
"'indeterminate'",
",",
"false",
")",
";",
"}",
"else",
"if",
"(",
"allHidden",
"(",
"groups",
"[",
"j",
"]",
".",
"aiColumns",
")",
")",
"{",
"$",
"(",
"'input'",
",",
"this",
".",
"dom",
".",
"groupButtons",
"[",
"j",
"]",
")",
".",
"prop",
"(",
"'checked'",
",",
"false",
")",
";",
"$",
"(",
"'input'",
",",
"this",
".",
"dom",
".",
"groupButtons",
"[",
"j",
"]",
")",
".",
"prop",
"(",
"'indeterminate'",
",",
"false",
")",
";",
"}",
"else",
"{",
"$",
"(",
"'input'",
",",
"this",
".",
"dom",
".",
"groupButtons",
"[",
"j",
"]",
")",
".",
"prop",
"(",
"'indeterminate'",
",",
"true",
")",
";",
"}",
"}",
"}"
] |
On each table draw, check the visibility checkboxes as needed. This allows any process to
update the table's column visibility and ColVis will still be accurate.
@method _fnDrawCallback
@returns void
@private
|
[
"On",
"each",
"table",
"draw",
"check",
"the",
"visibility",
"checkboxes",
"as",
"needed",
".",
"This",
"allows",
"any",
"process",
"to",
"update",
"the",
"table",
"s",
"column",
"visibility",
"and",
"ColVis",
"will",
"still",
"be",
"accurate",
"."
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js#L354-L401
|
|
39,258 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js
|
function ()
{
var
nButton,
columns = this.s.dt.aoColumns;
if ( $.inArray( 'all', this.s.aiExclude ) === -1 ) {
for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
{
if ( $.inArray( i, this.s.aiExclude ) === -1 )
{
nButton = this._fnDomColumnButton( i );
nButton.__columnIdx = i;
this.dom.buttons.push( nButton );
}
}
}
if ( this.s.order === 'alpha' ) {
this.dom.buttons.sort( function ( a, b ) {
var titleA = columns[ a.__columnIdx ].sTitle;
var titleB = columns[ b.__columnIdx ].sTitle;
return titleA === titleB ?
0 :
titleA < titleB ?
-1 :
1;
} );
}
if ( this.s.restore )
{
nButton = this._fnDomRestoreButton();
nButton.className += " ColVis_Restore";
this.dom.buttons.push( nButton );
}
if ( this.s.showAll )
{
nButton = this._fnDomShowXButton( this.s.showAll, true );
nButton.className += " ColVis_ShowAll";
this.dom.buttons.push( nButton );
}
if ( this.s.showNone )
{
nButton = this._fnDomShowXButton( this.s.showNone, false );
nButton.className += " ColVis_ShowNone";
this.dom.buttons.push( nButton );
}
$(this.dom.collection).append( this.dom.buttons );
}
|
javascript
|
function ()
{
var
nButton,
columns = this.s.dt.aoColumns;
if ( $.inArray( 'all', this.s.aiExclude ) === -1 ) {
for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
{
if ( $.inArray( i, this.s.aiExclude ) === -1 )
{
nButton = this._fnDomColumnButton( i );
nButton.__columnIdx = i;
this.dom.buttons.push( nButton );
}
}
}
if ( this.s.order === 'alpha' ) {
this.dom.buttons.sort( function ( a, b ) {
var titleA = columns[ a.__columnIdx ].sTitle;
var titleB = columns[ b.__columnIdx ].sTitle;
return titleA === titleB ?
0 :
titleA < titleB ?
-1 :
1;
} );
}
if ( this.s.restore )
{
nButton = this._fnDomRestoreButton();
nButton.className += " ColVis_Restore";
this.dom.buttons.push( nButton );
}
if ( this.s.showAll )
{
nButton = this._fnDomShowXButton( this.s.showAll, true );
nButton.className += " ColVis_ShowAll";
this.dom.buttons.push( nButton );
}
if ( this.s.showNone )
{
nButton = this._fnDomShowXButton( this.s.showNone, false );
nButton.className += " ColVis_ShowNone";
this.dom.buttons.push( nButton );
}
$(this.dom.collection).append( this.dom.buttons );
}
|
[
"function",
"(",
")",
"{",
"var",
"nButton",
",",
"columns",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
";",
"if",
"(",
"$",
".",
"inArray",
"(",
"'all'",
",",
"this",
".",
"s",
".",
"aiExclude",
")",
"===",
"-",
"1",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"columns",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"$",
".",
"inArray",
"(",
"i",
",",
"this",
".",
"s",
".",
"aiExclude",
")",
"===",
"-",
"1",
")",
"{",
"nButton",
"=",
"this",
".",
"_fnDomColumnButton",
"(",
"i",
")",
";",
"nButton",
".",
"__columnIdx",
"=",
"i",
";",
"this",
".",
"dom",
".",
"buttons",
".",
"push",
"(",
"nButton",
")",
";",
"}",
"}",
"}",
"if",
"(",
"this",
".",
"s",
".",
"order",
"===",
"'alpha'",
")",
"{",
"this",
".",
"dom",
".",
"buttons",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"titleA",
"=",
"columns",
"[",
"a",
".",
"__columnIdx",
"]",
".",
"sTitle",
";",
"var",
"titleB",
"=",
"columns",
"[",
"b",
".",
"__columnIdx",
"]",
".",
"sTitle",
";",
"return",
"titleA",
"===",
"titleB",
"?",
"0",
":",
"titleA",
"<",
"titleB",
"?",
"-",
"1",
":",
"1",
";",
"}",
")",
";",
"}",
"if",
"(",
"this",
".",
"s",
".",
"restore",
")",
"{",
"nButton",
"=",
"this",
".",
"_fnDomRestoreButton",
"(",
")",
";",
"nButton",
".",
"className",
"+=",
"\" ColVis_Restore\"",
";",
"this",
".",
"dom",
".",
"buttons",
".",
"push",
"(",
"nButton",
")",
";",
"}",
"if",
"(",
"this",
".",
"s",
".",
"showAll",
")",
"{",
"nButton",
"=",
"this",
".",
"_fnDomShowXButton",
"(",
"this",
".",
"s",
".",
"showAll",
",",
"true",
")",
";",
"nButton",
".",
"className",
"+=",
"\" ColVis_ShowAll\"",
";",
"this",
".",
"dom",
".",
"buttons",
".",
"push",
"(",
"nButton",
")",
";",
"}",
"if",
"(",
"this",
".",
"s",
".",
"showNone",
")",
"{",
"nButton",
"=",
"this",
".",
"_fnDomShowXButton",
"(",
"this",
".",
"s",
".",
"showNone",
",",
"false",
")",
";",
"nButton",
".",
"className",
"+=",
"\" ColVis_ShowNone\"",
";",
"this",
".",
"dom",
".",
"buttons",
".",
"push",
"(",
"nButton",
")",
";",
"}",
"$",
"(",
"this",
".",
"dom",
".",
"collection",
")",
".",
"append",
"(",
"this",
".",
"dom",
".",
"buttons",
")",
";",
"}"
] |
Loop through the columns in the table and as a new button for each one.
@method _fnAddButtons
@returns void
@private
|
[
"Loop",
"through",
"the",
"columns",
"in",
"the",
"table",
"and",
"as",
"a",
"new",
"button",
"for",
"each",
"one",
"."
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js#L433-L486
|
|
39,259 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js
|
function ()
{
var
that = this,
dt = this.s.dt;
return $(
'<li class="ColVis_Special '+(dt.bJUI ? 'ui-button ui-state-default' : '')+'">'+
this.s.restore+
'</li>'
)
.click( function (e) {
for ( var i=0, iLen=that.s.abOriginal.length ; i<iLen ; i++ )
{
that.s.dt.oInstance.fnSetColumnVis( i, that.s.abOriginal[i], false );
}
that._fnAdjustOpenRows();
that.s.dt.oInstance.fnAdjustColumnSizing( false );
that.s.dt.oInstance.fnDraw( false );
} )[0];
}
|
javascript
|
function ()
{
var
that = this,
dt = this.s.dt;
return $(
'<li class="ColVis_Special '+(dt.bJUI ? 'ui-button ui-state-default' : '')+'">'+
this.s.restore+
'</li>'
)
.click( function (e) {
for ( var i=0, iLen=that.s.abOriginal.length ; i<iLen ; i++ )
{
that.s.dt.oInstance.fnSetColumnVis( i, that.s.abOriginal[i], false );
}
that._fnAdjustOpenRows();
that.s.dt.oInstance.fnAdjustColumnSizing( false );
that.s.dt.oInstance.fnDraw( false );
} )[0];
}
|
[
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
",",
"dt",
"=",
"this",
".",
"s",
".",
"dt",
";",
"return",
"$",
"(",
"'<li class=\"ColVis_Special '",
"+",
"(",
"dt",
".",
"bJUI",
"?",
"'ui-button ui-state-default'",
":",
"''",
")",
"+",
"'\">'",
"+",
"this",
".",
"s",
".",
"restore",
"+",
"'</li>'",
")",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"that",
".",
"s",
".",
"abOriginal",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"that",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnSetColumnVis",
"(",
"i",
",",
"that",
".",
"s",
".",
"abOriginal",
"[",
"i",
"]",
",",
"false",
")",
";",
"}",
"that",
".",
"_fnAdjustOpenRows",
"(",
")",
";",
"that",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnAdjustColumnSizing",
"(",
"false",
")",
";",
"that",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnDraw",
"(",
"false",
")",
";",
"}",
")",
"[",
"0",
"]",
";",
"}"
] |
Create a button which allows a "restore" action
@method _fnDomRestoreButton
@returns {Node} Created button
@private
|
[
"Create",
"a",
"button",
"which",
"allows",
"a",
"restore",
"action"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js#L495-L515
|
|
39,260 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js
|
function ()
{
for ( var i=0, iLen=this.s.dt.oInstance.length ; i<iLen ; i++ )
{
if ( this.s.dt.oInstance[i] == this.s.dt.nTable )
{
return i;
}
}
return 0;
}
|
javascript
|
function ()
{
for ( var i=0, iLen=this.s.dt.oInstance.length ; i<iLen ; i++ )
{
if ( this.s.dt.oInstance[i] == this.s.dt.nTable )
{
return i;
}
}
return 0;
}
|
[
"function",
"(",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
"[",
"i",
"]",
"==",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"0",
";",
"}"
] |
Get the position in the DataTables instance array of the table for this
instance of ColVis
@method _fnDataTablesApiIndex
@returns {int} Index
@private
|
[
"Get",
"the",
"position",
"in",
"the",
"DataTables",
"instance",
"array",
"of",
"the",
"table",
"for",
"this",
"instance",
"of",
"ColVis"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js#L666-L676
|
|
39,261 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js
|
function ()
{
var
that = this,
nCatcher = document.createElement('div');
nCatcher.className = "ColVis_catcher";
$(nCatcher).click( function () {
that._fnCollectionHide.call( that, null, null );
} );
return nCatcher;
}
|
javascript
|
function ()
{
var
that = this,
nCatcher = document.createElement('div');
nCatcher.className = "ColVis_catcher";
$(nCatcher).click( function () {
that._fnCollectionHide.call( that, null, null );
} );
return nCatcher;
}
|
[
"function",
"(",
")",
"{",
"var",
"that",
"=",
"this",
",",
"nCatcher",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"nCatcher",
".",
"className",
"=",
"\"ColVis_catcher\"",
";",
"$",
"(",
"nCatcher",
")",
".",
"click",
"(",
"function",
"(",
")",
"{",
"that",
".",
"_fnCollectionHide",
".",
"call",
"(",
"that",
",",
"null",
",",
"null",
")",
";",
"}",
")",
";",
"return",
"nCatcher",
";",
"}"
] |
An element to be placed on top of the activate button to catch events
@method _fnDomCatcher
@returns {Node} div container for the collection
@private
|
[
"An",
"element",
"to",
"be",
"placed",
"on",
"top",
"of",
"the",
"activate",
"button",
"to",
"catch",
"events"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js#L709-L721
|
|
39,262 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js
|
function ()
{
var aoOpen = this.s.dt.aoOpenRows;
var iVisible = this.s.dt.oApi._fnVisbleColumns( this.s.dt );
for ( var i=0, iLen=aoOpen.length ; i<iLen ; i++ ) {
aoOpen[i].nTr.getElementsByTagName('td')[0].colSpan = iVisible;
}
}
|
javascript
|
function ()
{
var aoOpen = this.s.dt.aoOpenRows;
var iVisible = this.s.dt.oApi._fnVisbleColumns( this.s.dt );
for ( var i=0, iLen=aoOpen.length ; i<iLen ; i++ ) {
aoOpen[i].nTr.getElementsByTagName('td')[0].colSpan = iVisible;
}
}
|
[
"function",
"(",
")",
"{",
"var",
"aoOpen",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aoOpenRows",
";",
"var",
"iVisible",
"=",
"this",
".",
"s",
".",
"dt",
".",
"oApi",
".",
"_fnVisbleColumns",
"(",
"this",
".",
"s",
".",
"dt",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"aoOpen",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"aoOpen",
"[",
"i",
"]",
".",
"nTr",
".",
"getElementsByTagName",
"(",
"'td'",
")",
"[",
"0",
"]",
".",
"colSpan",
"=",
"iVisible",
";",
"}",
"}"
] |
Alter the colspan on any fnOpen rows
|
[
"Alter",
"the",
"colspan",
"on",
"any",
"fnOpen",
"rows"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColVis/js/dataTables.colVis.js#L863-L871
|
|
39,263 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.plus.js
|
function(match, value, len, step) {
var num = '' + value;
if (doubled(match, step)) {
while (num.length < len) {
num = '0' + num;
}
}
return num;
}
|
javascript
|
function(match, value, len, step) {
var num = '' + value;
if (doubled(match, step)) {
while (num.length < len) {
num = '0' + num;
}
}
return num;
}
|
[
"function",
"(",
"match",
",",
"value",
",",
"len",
",",
"step",
")",
"{",
"var",
"num",
"=",
"''",
"+",
"value",
";",
"if",
"(",
"doubled",
"(",
"match",
",",
"step",
")",
")",
"{",
"while",
"(",
"num",
".",
"length",
"<",
"len",
")",
"{",
"num",
"=",
"'0'",
"+",
"num",
";",
"}",
"}",
"return",
"num",
";",
"}"
] |
Format a number, with leading zeroes if necessary
|
[
"Format",
"a",
"number",
"with",
"leading",
"zeroes",
"if",
"necessary"
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.plus.js#L168-L176
|
|
39,264 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.plus.js
|
function(match, value, shortNames, longNames) {
return (doubled(match) ? longNames[value] : shortNames[value]);
}
|
javascript
|
function(match, value, shortNames, longNames) {
return (doubled(match) ? longNames[value] : shortNames[value]);
}
|
[
"function",
"(",
"match",
",",
"value",
",",
"shortNames",
",",
"longNames",
")",
"{",
"return",
"(",
"doubled",
"(",
"match",
")",
"?",
"longNames",
"[",
"value",
"]",
":",
"shortNames",
"[",
"value",
"]",
")",
";",
"}"
] |
Format a name, short or long as requested
|
[
"Format",
"a",
"name",
"short",
"or",
"long",
"as",
"requested"
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.plus.js#L178-L180
|
|
39,265 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.plus.js
|
function(date, useLongName) {
if (useLongName) {
return (typeof monthNames === 'function') ?
monthNames.call(calendar, date) :
monthNames[date.month() - calendar.minMonth];
} else {
return (typeof monthNamesShort === 'function') ?
monthNamesShort.call(calendar, date) :
monthNamesShort[date.month() - calendar.minMonth];
}
}
|
javascript
|
function(date, useLongName) {
if (useLongName) {
return (typeof monthNames === 'function') ?
monthNames.call(calendar, date) :
monthNames[date.month() - calendar.minMonth];
} else {
return (typeof monthNamesShort === 'function') ?
monthNamesShort.call(calendar, date) :
monthNamesShort[date.month() - calendar.minMonth];
}
}
|
[
"function",
"(",
"date",
",",
"useLongName",
")",
"{",
"if",
"(",
"useLongName",
")",
"{",
"return",
"(",
"typeof",
"monthNames",
"===",
"'function'",
")",
"?",
"monthNames",
".",
"call",
"(",
"calendar",
",",
"date",
")",
":",
"monthNames",
"[",
"date",
".",
"month",
"(",
")",
"-",
"calendar",
".",
"minMonth",
"]",
";",
"}",
"else",
"{",
"return",
"(",
"typeof",
"monthNamesShort",
"===",
"'function'",
")",
"?",
"monthNamesShort",
".",
"call",
"(",
"calendar",
",",
"date",
")",
":",
"monthNamesShort",
"[",
"date",
".",
"month",
"(",
")",
"-",
"calendar",
".",
"minMonth",
"]",
";",
"}",
"}"
] |
Format a month name, short or long as requested
|
[
"Format",
"a",
"month",
"name",
"short",
"or",
"long",
"as",
"requested"
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.plus.js#L190-L200
|
|
39,266 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.plus.js
|
function(match, step) {
var isDoubled = doubled(match, step);
var size = [2, 3, isDoubled ? 4 : 2, isDoubled ? 4 : 2, 10, 11, 20]['oyYJ@!'.indexOf(match) + 1];
var digits = new RegExp('^-?\\d{1,' + size + '}');
var num = value.substring(iValue).match(digits);
if (!num) {
throw ($.calendars.local.missingNumberAt || $.calendars.regionalOptions[''].missingNumberAt).
replace(/\{0\}/, iValue);
}
iValue += num[0].length;
return parseInt(num[0], 10);
}
|
javascript
|
function(match, step) {
var isDoubled = doubled(match, step);
var size = [2, 3, isDoubled ? 4 : 2, isDoubled ? 4 : 2, 10, 11, 20]['oyYJ@!'.indexOf(match) + 1];
var digits = new RegExp('^-?\\d{1,' + size + '}');
var num = value.substring(iValue).match(digits);
if (!num) {
throw ($.calendars.local.missingNumberAt || $.calendars.regionalOptions[''].missingNumberAt).
replace(/\{0\}/, iValue);
}
iValue += num[0].length;
return parseInt(num[0], 10);
}
|
[
"function",
"(",
"match",
",",
"step",
")",
"{",
"var",
"isDoubled",
"=",
"doubled",
"(",
"match",
",",
"step",
")",
";",
"var",
"size",
"=",
"[",
"2",
",",
"3",
",",
"isDoubled",
"?",
"4",
":",
"2",
",",
"isDoubled",
"?",
"4",
":",
"2",
",",
"10",
",",
"11",
",",
"20",
"]",
"[",
"'oyYJ@!'",
".",
"indexOf",
"(",
"match",
")",
"+",
"1",
"]",
";",
"var",
"digits",
"=",
"new",
"RegExp",
"(",
"'^-?\\\\d{1,'",
"+",
"size",
"+",
"'}'",
")",
";",
"var",
"num",
"=",
"value",
".",
"substring",
"(",
"iValue",
")",
".",
"match",
"(",
"digits",
")",
";",
"if",
"(",
"!",
"num",
")",
"{",
"throw",
"(",
"$",
".",
"calendars",
".",
"local",
".",
"missingNumberAt",
"||",
"$",
".",
"calendars",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"missingNumberAt",
")",
".",
"replace",
"(",
"/",
"\\{0\\}",
"/",
",",
"iValue",
")",
";",
"}",
"iValue",
"+=",
"num",
"[",
"0",
"]",
".",
"length",
";",
"return",
"parseInt",
"(",
"num",
"[",
"0",
"]",
",",
"10",
")",
";",
"}"
] |
Extract a number from the string value
|
[
"Extract",
"a",
"number",
"from",
"the",
"string",
"value"
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.plus.js#L307-L318
|
|
39,267 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.plus.js
|
function() {
if (typeof monthNames === 'function') {
var month = doubled('M') ?
monthNames.call(calendar, value.substring(iValue)) :
monthNamesShort.call(calendar, value.substring(iValue));
iValue += month.length;
return month;
}
return getName('M', monthNamesShort, monthNames);
}
|
javascript
|
function() {
if (typeof monthNames === 'function') {
var month = doubled('M') ?
monthNames.call(calendar, value.substring(iValue)) :
monthNamesShort.call(calendar, value.substring(iValue));
iValue += month.length;
return month;
}
return getName('M', monthNamesShort, monthNames);
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"typeof",
"monthNames",
"===",
"'function'",
")",
"{",
"var",
"month",
"=",
"doubled",
"(",
"'M'",
")",
"?",
"monthNames",
".",
"call",
"(",
"calendar",
",",
"value",
".",
"substring",
"(",
"iValue",
")",
")",
":",
"monthNamesShort",
".",
"call",
"(",
"calendar",
",",
"value",
".",
"substring",
"(",
"iValue",
")",
")",
";",
"iValue",
"+=",
"month",
".",
"length",
";",
"return",
"month",
";",
"}",
"return",
"getName",
"(",
"'M'",
",",
"monthNamesShort",
",",
"monthNames",
")",
";",
"}"
] |
Extract a month number from the string value
|
[
"Extract",
"a",
"month",
"number",
"from",
"the",
"string",
"value"
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.plus.js#L344-L354
|
|
39,268 |
whyhankee/node-flw
|
flw.js
|
wrap
|
function wrap(fn, args, key) {
const self = this;
if (key === undefined && typeof(args) === 'string') {
key = args;
args = [];
}
if (!args) args = [];
return function wrapper(context, cb) {
const copyArgs = args.slice(args);
copyArgs.unshift(self);
copyArgs.push(onWrappedDone);
return fn.bind.apply(fn, copyArgs)();
function onWrappedDone(err, result) {
if (err) return cb(err);
if (key) context[key] = result;
return cb(null);
}
};
}
|
javascript
|
function wrap(fn, args, key) {
const self = this;
if (key === undefined && typeof(args) === 'string') {
key = args;
args = [];
}
if (!args) args = [];
return function wrapper(context, cb) {
const copyArgs = args.slice(args);
copyArgs.unshift(self);
copyArgs.push(onWrappedDone);
return fn.bind.apply(fn, copyArgs)();
function onWrappedDone(err, result) {
if (err) return cb(err);
if (key) context[key] = result;
return cb(null);
}
};
}
|
[
"function",
"wrap",
"(",
"fn",
",",
"args",
",",
"key",
")",
"{",
"const",
"self",
"=",
"this",
";",
"if",
"(",
"key",
"===",
"undefined",
"&&",
"typeof",
"(",
"args",
")",
"===",
"'string'",
")",
"{",
"key",
"=",
"args",
";",
"args",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"args",
")",
"args",
"=",
"[",
"]",
";",
"return",
"function",
"wrapper",
"(",
"context",
",",
"cb",
")",
"{",
"const",
"copyArgs",
"=",
"args",
".",
"slice",
"(",
"args",
")",
";",
"copyArgs",
".",
"unshift",
"(",
"self",
")",
";",
"copyArgs",
".",
"push",
"(",
"onWrappedDone",
")",
";",
"return",
"fn",
".",
"bind",
".",
"apply",
"(",
"fn",
",",
"copyArgs",
")",
"(",
")",
";",
"function",
"onWrappedDone",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";",
"if",
"(",
"key",
")",
"context",
"[",
"key",
"]",
"=",
"result",
";",
"return",
"cb",
"(",
"null",
")",
";",
"}",
"}",
";",
"}"
] |
Returns wrapped regular function that stores the result on the context key
@param {function} fn function to wrap
@param {any[]} [args] Array of arguments to pass (optional)
@param {String} [key] name of context key to store the result in (optional)
|
[
"Returns",
"wrapped",
"regular",
"function",
"that",
"stores",
"the",
"result",
"on",
"the",
"context",
"key"
] |
61f438d2d9afe8acfb139f0c5f8c76452e07bedb
|
https://github.com/whyhankee/node-flw/blob/61f438d2d9afe8acfb139f0c5f8c76452e07bedb/flw.js#L122-L144
|
39,269 |
whyhankee/node-flw
|
flw.js
|
each
|
function each(items, numParralel, fn, done) {
if (done === undefined) {
done = fn; fn = numParralel;
numParralel = 3;
}
if (numParralel <= 0) numParralel = 1;
let doing = 0;
let numProcessing = 0;
let numDone = 0;
const numTotal = items.length;
const results = [];
return nextItem();
function nextItem() {
// We done-check first in case of emtpty array
if (numDone >= numTotal) return done(null, results);
// Batch (or call next item)
while (doing < numTotal && numProcessing < numParralel) {
callFn(fn, items[doing++], onDone);
numProcessing++;
}
return;
// All done
function onDone(err, result) {
if (err) return done(err);
results.push(result);
numProcessing--;
numDone++;
return nextItem();
}
}
}
|
javascript
|
function each(items, numParralel, fn, done) {
if (done === undefined) {
done = fn; fn = numParralel;
numParralel = 3;
}
if (numParralel <= 0) numParralel = 1;
let doing = 0;
let numProcessing = 0;
let numDone = 0;
const numTotal = items.length;
const results = [];
return nextItem();
function nextItem() {
// We done-check first in case of emtpty array
if (numDone >= numTotal) return done(null, results);
// Batch (or call next item)
while (doing < numTotal && numProcessing < numParralel) {
callFn(fn, items[doing++], onDone);
numProcessing++;
}
return;
// All done
function onDone(err, result) {
if (err) return done(err);
results.push(result);
numProcessing--;
numDone++;
return nextItem();
}
}
}
|
[
"function",
"each",
"(",
"items",
",",
"numParralel",
",",
"fn",
",",
"done",
")",
"{",
"if",
"(",
"done",
"===",
"undefined",
")",
"{",
"done",
"=",
"fn",
";",
"fn",
"=",
"numParralel",
";",
"numParralel",
"=",
"3",
";",
"}",
"if",
"(",
"numParralel",
"<=",
"0",
")",
"numParralel",
"=",
"1",
";",
"let",
"doing",
"=",
"0",
";",
"let",
"numProcessing",
"=",
"0",
";",
"let",
"numDone",
"=",
"0",
";",
"const",
"numTotal",
"=",
"items",
".",
"length",
";",
"const",
"results",
"=",
"[",
"]",
";",
"return",
"nextItem",
"(",
")",
";",
"function",
"nextItem",
"(",
")",
"{",
"// We done-check first in case of emtpty array",
"if",
"(",
"numDone",
">=",
"numTotal",
")",
"return",
"done",
"(",
"null",
",",
"results",
")",
";",
"// Batch (or call next item)",
"while",
"(",
"doing",
"<",
"numTotal",
"&&",
"numProcessing",
"<",
"numParralel",
")",
"{",
"callFn",
"(",
"fn",
",",
"items",
"[",
"doing",
"++",
"]",
",",
"onDone",
")",
";",
"numProcessing",
"++",
";",
"}",
"return",
";",
"// All done",
"function",
"onDone",
"(",
"err",
",",
"result",
")",
"{",
"if",
"(",
"err",
")",
"return",
"done",
"(",
"err",
")",
";",
"results",
".",
"push",
"(",
"result",
")",
";",
"numProcessing",
"--",
";",
"numDone",
"++",
";",
"return",
"nextItem",
"(",
")",
";",
"}",
"}",
"}"
] |
Calls fn with every item in the array
@param {any[]} items Array items to process
@param {Number} [numParallel] Limit parallelisation (default: 3)
@param {function} fn function call for each item
@param {function} done callback
|
[
"Calls",
"fn",
"with",
"every",
"item",
"in",
"the",
"array"
] |
61f438d2d9afe8acfb139f0c5f8c76452e07bedb
|
https://github.com/whyhankee/node-flw/blob/61f438d2d9afe8acfb139f0c5f8c76452e07bedb/flw.js#L153-L189
|
39,270 |
whyhankee/node-flw
|
flw.js
|
make
|
function make() {
// create a map of all flow functions wrapped by _make
const makeFnMap = {};
Object.keys(fnMap).forEach(function (key) {
makeFnMap[key] = _make(fnMap[key]);
});
return makeFnMap;
// takes a function and wraps it so that execution is 'postponed'
function _make(fn) {
// the user calls this function, e.g. flw.make.series(...)
return function madeFunction(fns, context, returnKey) {
if (typeof context === 'string') {
returnKey = context; context = {};
}
// this function is consumed by flw
return function flowFunction(context, cb) {
// when passed from a flw flow it's called with a premade context
// if called directly, create a new context
if (cb === undefined && typeof context === 'function') {
cb = context;
context = {};
_checkContext(context);
}
if (typeof cb !== 'function') {
throw new Error('flw: .make - cb !== function');
}
return fn(fns, context, returnKey, cb);
};
};
}
}
|
javascript
|
function make() {
// create a map of all flow functions wrapped by _make
const makeFnMap = {};
Object.keys(fnMap).forEach(function (key) {
makeFnMap[key] = _make(fnMap[key]);
});
return makeFnMap;
// takes a function and wraps it so that execution is 'postponed'
function _make(fn) {
// the user calls this function, e.g. flw.make.series(...)
return function madeFunction(fns, context, returnKey) {
if (typeof context === 'string') {
returnKey = context; context = {};
}
// this function is consumed by flw
return function flowFunction(context, cb) {
// when passed from a flw flow it's called with a premade context
// if called directly, create a new context
if (cb === undefined && typeof context === 'function') {
cb = context;
context = {};
_checkContext(context);
}
if (typeof cb !== 'function') {
throw new Error('flw: .make - cb !== function');
}
return fn(fns, context, returnKey, cb);
};
};
}
}
|
[
"function",
"make",
"(",
")",
"{",
"// create a map of all flow functions wrapped by _make",
"const",
"makeFnMap",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"fnMap",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"makeFnMap",
"[",
"key",
"]",
"=",
"_make",
"(",
"fnMap",
"[",
"key",
"]",
")",
";",
"}",
")",
";",
"return",
"makeFnMap",
";",
"// takes a function and wraps it so that execution is 'postponed'",
"function",
"_make",
"(",
"fn",
")",
"{",
"// the user calls this function, e.g. flw.make.series(...)",
"return",
"function",
"madeFunction",
"(",
"fns",
",",
"context",
",",
"returnKey",
")",
"{",
"if",
"(",
"typeof",
"context",
"===",
"'string'",
")",
"{",
"returnKey",
"=",
"context",
";",
"context",
"=",
"{",
"}",
";",
"}",
"// this function is consumed by flw",
"return",
"function",
"flowFunction",
"(",
"context",
",",
"cb",
")",
"{",
"// when passed from a flw flow it's called with a premade context",
"// if called directly, create a new context",
"if",
"(",
"cb",
"===",
"undefined",
"&&",
"typeof",
"context",
"===",
"'function'",
")",
"{",
"cb",
"=",
"context",
";",
"context",
"=",
"{",
"}",
";",
"_checkContext",
"(",
"context",
")",
";",
"}",
"if",
"(",
"typeof",
"cb",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'flw: .make - cb !== function'",
")",
";",
"}",
"return",
"fn",
"(",
"fns",
",",
"context",
",",
"returnKey",
",",
"cb",
")",
";",
"}",
";",
"}",
";",
"}",
"}"
] |
build the list of exposed methods into the .make syntax
|
[
"build",
"the",
"list",
"of",
"exposed",
"methods",
"into",
"the",
".",
"make",
"syntax"
] |
61f438d2d9afe8acfb139f0c5f8c76452e07bedb
|
https://github.com/whyhankee/node-flw/blob/61f438d2d9afe8acfb139f0c5f8c76452e07bedb/flw.js#L250-L282
|
39,271 |
whyhankee/node-flw
|
flw.js
|
_make
|
function _make(fn) {
// the user calls this function, e.g. flw.make.series(...)
return function madeFunction(fns, context, returnKey) {
if (typeof context === 'string') {
returnKey = context; context = {};
}
// this function is consumed by flw
return function flowFunction(context, cb) {
// when passed from a flw flow it's called with a premade context
// if called directly, create a new context
if (cb === undefined && typeof context === 'function') {
cb = context;
context = {};
_checkContext(context);
}
if (typeof cb !== 'function') {
throw new Error('flw: .make - cb !== function');
}
return fn(fns, context, returnKey, cb);
};
};
}
|
javascript
|
function _make(fn) {
// the user calls this function, e.g. flw.make.series(...)
return function madeFunction(fns, context, returnKey) {
if (typeof context === 'string') {
returnKey = context; context = {};
}
// this function is consumed by flw
return function flowFunction(context, cb) {
// when passed from a flw flow it's called with a premade context
// if called directly, create a new context
if (cb === undefined && typeof context === 'function') {
cb = context;
context = {};
_checkContext(context);
}
if (typeof cb !== 'function') {
throw new Error('flw: .make - cb !== function');
}
return fn(fns, context, returnKey, cb);
};
};
}
|
[
"function",
"_make",
"(",
"fn",
")",
"{",
"// the user calls this function, e.g. flw.make.series(...)",
"return",
"function",
"madeFunction",
"(",
"fns",
",",
"context",
",",
"returnKey",
")",
"{",
"if",
"(",
"typeof",
"context",
"===",
"'string'",
")",
"{",
"returnKey",
"=",
"context",
";",
"context",
"=",
"{",
"}",
";",
"}",
"// this function is consumed by flw",
"return",
"function",
"flowFunction",
"(",
"context",
",",
"cb",
")",
"{",
"// when passed from a flw flow it's called with a premade context",
"// if called directly, create a new context",
"if",
"(",
"cb",
"===",
"undefined",
"&&",
"typeof",
"context",
"===",
"'function'",
")",
"{",
"cb",
"=",
"context",
";",
"context",
"=",
"{",
"}",
";",
"_checkContext",
"(",
"context",
")",
";",
"}",
"if",
"(",
"typeof",
"cb",
"!==",
"'function'",
")",
"{",
"throw",
"new",
"Error",
"(",
"'flw: .make - cb !== function'",
")",
";",
"}",
"return",
"fn",
"(",
"fns",
",",
"context",
",",
"returnKey",
",",
"cb",
")",
";",
"}",
";",
"}",
";",
"}"
] |
takes a function and wraps it so that execution is 'postponed'
|
[
"takes",
"a",
"function",
"and",
"wraps",
"it",
"so",
"that",
"execution",
"is",
"postponed"
] |
61f438d2d9afe8acfb139f0c5f8c76452e07bedb
|
https://github.com/whyhankee/node-flw/blob/61f438d2d9afe8acfb139f0c5f8c76452e07bedb/flw.js#L259-L281
|
39,272 |
whyhankee/node-flw
|
flw.js
|
_checkContext
|
function _checkContext(c) {
if (c.hasOwnProperty('_stopped')) return; // Already done?
c._stopped = null;
// Indicate that we gracefully stop
// if set, stops the flow until we are back to the main callback
function _flw_stop(reason, cb) {
if (!cb && typeof reason === 'function') {
cb = reason;
reason = 'stopped';
}
c._stopped = reason;
return cb();
}
Object.defineProperty(c, '_stop', {
enumerable: false,
configurable: false,
writable: false,
value: _flw_stop,
});
// Stores the data returned from the callback in the context with key 'key'
// then calls the callback
function _flw_store(key, cb) {
const self = this;
const fn = function (err, data) {
if (err) return cb(err);
self[key] = data;
return cb();
};
return fn;
}
Object.defineProperty(c, '_store', {
enumerable: false,
configurable: false,
value: _flw_store,
});
// Cleans all flw related properties from the context object
function _flw_clean() {
const self = this;
const contextCopy = {};
Object.keys(this).forEach(function (k) {
if (ourContextKeys.indexOf(k) !== -1) return;
contextCopy[k] = self[k];
});
return contextCopy;
}
Object.defineProperty(c, '_clean', {
enumerable: false,
configurable: false,
value: _flw_clean,
});
// compatibilty for a while
Object.defineProperty(c, '_flw_store', {
enumerable: false,
configurable: false,
writable: false,
value: _flw_store,
});
return c;
}
|
javascript
|
function _checkContext(c) {
if (c.hasOwnProperty('_stopped')) return; // Already done?
c._stopped = null;
// Indicate that we gracefully stop
// if set, stops the flow until we are back to the main callback
function _flw_stop(reason, cb) {
if (!cb && typeof reason === 'function') {
cb = reason;
reason = 'stopped';
}
c._stopped = reason;
return cb();
}
Object.defineProperty(c, '_stop', {
enumerable: false,
configurable: false,
writable: false,
value: _flw_stop,
});
// Stores the data returned from the callback in the context with key 'key'
// then calls the callback
function _flw_store(key, cb) {
const self = this;
const fn = function (err, data) {
if (err) return cb(err);
self[key] = data;
return cb();
};
return fn;
}
Object.defineProperty(c, '_store', {
enumerable: false,
configurable: false,
value: _flw_store,
});
// Cleans all flw related properties from the context object
function _flw_clean() {
const self = this;
const contextCopy = {};
Object.keys(this).forEach(function (k) {
if (ourContextKeys.indexOf(k) !== -1) return;
contextCopy[k] = self[k];
});
return contextCopy;
}
Object.defineProperty(c, '_clean', {
enumerable: false,
configurable: false,
value: _flw_clean,
});
// compatibilty for a while
Object.defineProperty(c, '_flw_store', {
enumerable: false,
configurable: false,
writable: false,
value: _flw_store,
});
return c;
}
|
[
"function",
"_checkContext",
"(",
"c",
")",
"{",
"if",
"(",
"c",
".",
"hasOwnProperty",
"(",
"'_stopped'",
")",
")",
"return",
";",
"// Already done?",
"c",
".",
"_stopped",
"=",
"null",
";",
"// Indicate that we gracefully stop",
"// if set, stops the flow until we are back to the main callback",
"function",
"_flw_stop",
"(",
"reason",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"cb",
"&&",
"typeof",
"reason",
"===",
"'function'",
")",
"{",
"cb",
"=",
"reason",
";",
"reason",
"=",
"'stopped'",
";",
"}",
"c",
".",
"_stopped",
"=",
"reason",
";",
"return",
"cb",
"(",
")",
";",
"}",
"Object",
".",
"defineProperty",
"(",
"c",
",",
"'_stop'",
",",
"{",
"enumerable",
":",
"false",
",",
"configurable",
":",
"false",
",",
"writable",
":",
"false",
",",
"value",
":",
"_flw_stop",
",",
"}",
")",
";",
"// Stores the data returned from the callback in the context with key 'key'",
"// then calls the callback",
"function",
"_flw_store",
"(",
"key",
",",
"cb",
")",
"{",
"const",
"self",
"=",
"this",
";",
"const",
"fn",
"=",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";",
"self",
"[",
"key",
"]",
"=",
"data",
";",
"return",
"cb",
"(",
")",
";",
"}",
";",
"return",
"fn",
";",
"}",
"Object",
".",
"defineProperty",
"(",
"c",
",",
"'_store'",
",",
"{",
"enumerable",
":",
"false",
",",
"configurable",
":",
"false",
",",
"value",
":",
"_flw_store",
",",
"}",
")",
";",
"// Cleans all flw related properties from the context object",
"function",
"_flw_clean",
"(",
")",
"{",
"const",
"self",
"=",
"this",
";",
"const",
"contextCopy",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"this",
")",
".",
"forEach",
"(",
"function",
"(",
"k",
")",
"{",
"if",
"(",
"ourContextKeys",
".",
"indexOf",
"(",
"k",
")",
"!==",
"-",
"1",
")",
"return",
";",
"contextCopy",
"[",
"k",
"]",
"=",
"self",
"[",
"k",
"]",
";",
"}",
")",
";",
"return",
"contextCopy",
";",
"}",
"Object",
".",
"defineProperty",
"(",
"c",
",",
"'_clean'",
",",
"{",
"enumerable",
":",
"false",
",",
"configurable",
":",
"false",
",",
"value",
":",
"_flw_clean",
",",
"}",
")",
";",
"// compatibilty for a while",
"Object",
".",
"defineProperty",
"(",
"c",
",",
"'_flw_store'",
",",
"{",
"enumerable",
":",
"false",
",",
"configurable",
":",
"false",
",",
"writable",
":",
"false",
",",
"value",
":",
"_flw_store",
",",
"}",
")",
";",
"return",
"c",
";",
"}"
] |
Ensures a enrichched flw context when a flow is starting
@private
|
[
"Ensures",
"a",
"enrichched",
"flw",
"context",
"when",
"a",
"flow",
"is",
"starting"
] |
61f438d2d9afe8acfb139f0c5f8c76452e07bedb
|
https://github.com/whyhankee/node-flw/blob/61f438d2d9afe8acfb139f0c5f8c76452e07bedb/flw.js#L298-L364
|
39,273 |
whyhankee/node-flw
|
flw.js
|
_flw_stop
|
function _flw_stop(reason, cb) {
if (!cb && typeof reason === 'function') {
cb = reason;
reason = 'stopped';
}
c._stopped = reason;
return cb();
}
|
javascript
|
function _flw_stop(reason, cb) {
if (!cb && typeof reason === 'function') {
cb = reason;
reason = 'stopped';
}
c._stopped = reason;
return cb();
}
|
[
"function",
"_flw_stop",
"(",
"reason",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"cb",
"&&",
"typeof",
"reason",
"===",
"'function'",
")",
"{",
"cb",
"=",
"reason",
";",
"reason",
"=",
"'stopped'",
";",
"}",
"c",
".",
"_stopped",
"=",
"reason",
";",
"return",
"cb",
"(",
")",
";",
"}"
] |
Indicate that we gracefully stop if set, stops the flow until we are back to the main callback
|
[
"Indicate",
"that",
"we",
"gracefully",
"stop",
"if",
"set",
"stops",
"the",
"flow",
"until",
"we",
"are",
"back",
"to",
"the",
"main",
"callback"
] |
61f438d2d9afe8acfb139f0c5f8c76452e07bedb
|
https://github.com/whyhankee/node-flw/blob/61f438d2d9afe8acfb139f0c5f8c76452e07bedb/flw.js#L305-L312
|
39,274 |
whyhankee/node-flw
|
flw.js
|
_flw_store
|
function _flw_store(key, cb) {
const self = this;
const fn = function (err, data) {
if (err) return cb(err);
self[key] = data;
return cb();
};
return fn;
}
|
javascript
|
function _flw_store(key, cb) {
const self = this;
const fn = function (err, data) {
if (err) return cb(err);
self[key] = data;
return cb();
};
return fn;
}
|
[
"function",
"_flw_store",
"(",
"key",
",",
"cb",
")",
"{",
"const",
"self",
"=",
"this",
";",
"const",
"fn",
"=",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
";",
"self",
"[",
"key",
"]",
"=",
"data",
";",
"return",
"cb",
"(",
")",
";",
"}",
";",
"return",
"fn",
";",
"}"
] |
Stores the data returned from the callback in the context with key 'key' then calls the callback
|
[
"Stores",
"the",
"data",
"returned",
"from",
"the",
"callback",
"in",
"the",
"context",
"with",
"key",
"key",
"then",
"calls",
"the",
"callback"
] |
61f438d2d9afe8acfb139f0c5f8c76452e07bedb
|
https://github.com/whyhankee/node-flw/blob/61f438d2d9afe8acfb139f0c5f8c76452e07bedb/flw.js#L322-L332
|
39,275 |
whyhankee/node-flw
|
flw.js
|
_flw_clean
|
function _flw_clean() {
const self = this;
const contextCopy = {};
Object.keys(this).forEach(function (k) {
if (ourContextKeys.indexOf(k) !== -1) return;
contextCopy[k] = self[k];
});
return contextCopy;
}
|
javascript
|
function _flw_clean() {
const self = this;
const contextCopy = {};
Object.keys(this).forEach(function (k) {
if (ourContextKeys.indexOf(k) !== -1) return;
contextCopy[k] = self[k];
});
return contextCopy;
}
|
[
"function",
"_flw_clean",
"(",
")",
"{",
"const",
"self",
"=",
"this",
";",
"const",
"contextCopy",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"this",
")",
".",
"forEach",
"(",
"function",
"(",
"k",
")",
"{",
"if",
"(",
"ourContextKeys",
".",
"indexOf",
"(",
"k",
")",
"!==",
"-",
"1",
")",
"return",
";",
"contextCopy",
"[",
"k",
"]",
"=",
"self",
"[",
"k",
"]",
";",
"}",
")",
";",
"return",
"contextCopy",
";",
"}"
] |
Cleans all flw related properties from the context object
|
[
"Cleans",
"all",
"flw",
"related",
"properties",
"from",
"the",
"context",
"object"
] |
61f438d2d9afe8acfb139f0c5f8c76452e07bedb
|
https://github.com/whyhankee/node-flw/blob/61f438d2d9afe8acfb139f0c5f8c76452e07bedb/flw.js#L340-L348
|
39,276 |
quancheng-ec/pomjs
|
src/middleware/logger.js
|
getNullLogger
|
function getNullLogger() {
return new Proxy(
{},
{
get: function(target, propKey) {
// not proxy for Timer
if (propKey === 'Timer') {
return _.bind(InnerTimer, {}, undefined)
}
return function() {}
},
apply: function(target, object, args) {}
}
)
}
|
javascript
|
function getNullLogger() {
return new Proxy(
{},
{
get: function(target, propKey) {
// not proxy for Timer
if (propKey === 'Timer') {
return _.bind(InnerTimer, {}, undefined)
}
return function() {}
},
apply: function(target, object, args) {}
}
)
}
|
[
"function",
"getNullLogger",
"(",
")",
"{",
"return",
"new",
"Proxy",
"(",
"{",
"}",
",",
"{",
"get",
":",
"function",
"(",
"target",
",",
"propKey",
")",
"{",
"// not proxy for Timer",
"if",
"(",
"propKey",
"===",
"'Timer'",
")",
"{",
"return",
"_",
".",
"bind",
"(",
"InnerTimer",
",",
"{",
"}",
",",
"undefined",
")",
"}",
"return",
"function",
"(",
")",
"{",
"}",
"}",
",",
"apply",
":",
"function",
"(",
"target",
",",
"object",
",",
"args",
")",
"{",
"}",
"}",
")",
"}"
] |
always return a dummy logger
|
[
"always",
"return",
"a",
"dummy",
"logger"
] |
2080973d89be7156f5915b846895fb86902f1e9e
|
https://github.com/quancheng-ec/pomjs/blob/2080973d89be7156f5915b846895fb86902f1e9e/src/middleware/logger.js#L111-L126
|
39,277 |
vinkaga/angular-mock-backend
|
mock-protractor.js
|
getModuleCode
|
function getModuleCode(mocks) {
var filename = path.join(__dirname, './mock-angular.js');
var code = fs.readFileSync(filename, 'utf8');
return code.replace(/angular\.noop\(\);/, getModuleConfig(mocks));
}
|
javascript
|
function getModuleCode(mocks) {
var filename = path.join(__dirname, './mock-angular.js');
var code = fs.readFileSync(filename, 'utf8');
return code.replace(/angular\.noop\(\);/, getModuleConfig(mocks));
}
|
[
"function",
"getModuleCode",
"(",
"mocks",
")",
"{",
"var",
"filename",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"'./mock-angular.js'",
")",
";",
"var",
"code",
"=",
"fs",
".",
"readFileSync",
"(",
"filename",
",",
"'utf8'",
")",
";",
"return",
"code",
".",
"replace",
"(",
"/",
"angular\\.noop\\(\\);",
"/",
",",
"getModuleConfig",
"(",
"mocks",
")",
")",
";",
"}"
] |
Get AngularJS module code to inject into browser
@param mocks []
@returns {string}
|
[
"Get",
"AngularJS",
"module",
"code",
"to",
"inject",
"into",
"browser"
] |
bed0610d65b223430c9a52ff5c9490e6d9b7ad14
|
https://github.com/vinkaga/angular-mock-backend/blob/bed0610d65b223430c9a52ff5c9490e6d9b7ad14/mock-protractor.js#L27-L31
|
39,278 |
vinkaga/angular-mock-backend
|
mock-protractor.js
|
getModuleConfig
|
function getModuleConfig(mocks) {
// Functions cannot be transferred directly
// Convert to string
for (var i = 0; i < mocks.length; ++i) {
var mock = mocks[i];
if (typeof mock[0] === 'function') {
mock[0] = mock[0].toString();
}
}
return "angular.module('vinkaga.mockBackend').constant('vinkaga.mockBackend.mock', " + JSON.stringify(mocks) + ');';
}
|
javascript
|
function getModuleConfig(mocks) {
// Functions cannot be transferred directly
// Convert to string
for (var i = 0; i < mocks.length; ++i) {
var mock = mocks[i];
if (typeof mock[0] === 'function') {
mock[0] = mock[0].toString();
}
}
return "angular.module('vinkaga.mockBackend').constant('vinkaga.mockBackend.mock', " + JSON.stringify(mocks) + ');';
}
|
[
"function",
"getModuleConfig",
"(",
"mocks",
")",
"{",
"// Functions cannot be transferred directly",
"// Convert to string",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"mocks",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"mock",
"=",
"mocks",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
"mock",
"[",
"0",
"]",
"===",
"'function'",
")",
"{",
"mock",
"[",
"0",
"]",
"=",
"mock",
"[",
"0",
"]",
".",
"toString",
"(",
")",
";",
"}",
"}",
"return",
"\"angular.module('vinkaga.mockBackend').constant('vinkaga.mockBackend.mock', \"",
"+",
"JSON",
".",
"stringify",
"(",
"mocks",
")",
"+",
"');'",
";",
"}"
] |
Create module mock config code
@param mocks
@returns {string}
|
[
"Create",
"module",
"mock",
"config",
"code"
] |
bed0610d65b223430c9a52ff5c9490e6d9b7ad14
|
https://github.com/vinkaga/angular-mock-backend/blob/bed0610d65b223430c9a52ff5c9490e6d9b7ad14/mock-protractor.js#L38-L48
|
39,279 |
telehash/hashname
|
index.js
|
rollup
|
function rollup(imbuff)
{
var roll = new Buffer(0);
Object.keys(imbuff).sort().forEach(function(id){
roll = crypto.createHash('sha256').update(Buffer.concat([roll,new Buffer(id, 'hex')])).digest();
roll = crypto.createHash('sha256').update(Buffer.concat([roll,imbuff[id]])).digest();
});
return roll;
}
|
javascript
|
function rollup(imbuff)
{
var roll = new Buffer(0);
Object.keys(imbuff).sort().forEach(function(id){
roll = crypto.createHash('sha256').update(Buffer.concat([roll,new Buffer(id, 'hex')])).digest();
roll = crypto.createHash('sha256').update(Buffer.concat([roll,imbuff[id]])).digest();
});
return roll;
}
|
[
"function",
"rollup",
"(",
"imbuff",
")",
"{",
"var",
"roll",
"=",
"new",
"Buffer",
"(",
"0",
")",
";",
"Object",
".",
"keys",
"(",
"imbuff",
")",
".",
"sort",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"id",
")",
"{",
"roll",
"=",
"crypto",
".",
"createHash",
"(",
"'sha256'",
")",
".",
"update",
"(",
"Buffer",
".",
"concat",
"(",
"[",
"roll",
",",
"new",
"Buffer",
"(",
"id",
",",
"'hex'",
")",
"]",
")",
")",
".",
"digest",
"(",
")",
";",
"roll",
"=",
"crypto",
".",
"createHash",
"(",
"'sha256'",
")",
".",
"update",
"(",
"Buffer",
".",
"concat",
"(",
"[",
"roll",
",",
"imbuff",
"[",
"id",
"]",
"]",
")",
")",
".",
"digest",
"(",
")",
";",
"}",
")",
";",
"return",
"roll",
";",
"}"
] |
rollup uses only intermediate buffers, data must be validated first
|
[
"rollup",
"uses",
"only",
"intermediate",
"buffers",
"data",
"must",
"be",
"validated",
"first"
] |
c038acc3a96e68309135c054c68375cdc56fb62f
|
https://github.com/telehash/hashname/blob/c038acc3a96e68309135c054c68375cdc56fb62f/index.js#L6-L14
|
39,280 |
Neil-G/redux-mastermind
|
lib/createMastermind.js
|
connectStore
|
function connectStore(component, keys) {
var shouldReturnAFunction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
// function that maps store state to component props
var mapStateToProps = function mapStateToProps(state) {
// initialize return object
var mappedState = {};
// populate return object
keys.forEach(function (key) {
// add selector connection
if (key.split(':').length === 2 && selectors[key.split(':')[1]]) {
mappedState[key.split(':')[0]] = selectors[key.split(':')[1]](state);
// add branch connection
} else if (state[key]) {
mappedState[key] = state[key].toJS();
}
});
return shouldReturnAFunction ? function (state, props) {
return mappedState;
} : mappedState;
};
return (0, _reactRedux.connect)(mapStateToProps)(component);
}
|
javascript
|
function connectStore(component, keys) {
var shouldReturnAFunction = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
// function that maps store state to component props
var mapStateToProps = function mapStateToProps(state) {
// initialize return object
var mappedState = {};
// populate return object
keys.forEach(function (key) {
// add selector connection
if (key.split(':').length === 2 && selectors[key.split(':')[1]]) {
mappedState[key.split(':')[0]] = selectors[key.split(':')[1]](state);
// add branch connection
} else if (state[key]) {
mappedState[key] = state[key].toJS();
}
});
return shouldReturnAFunction ? function (state, props) {
return mappedState;
} : mappedState;
};
return (0, _reactRedux.connect)(mapStateToProps)(component);
}
|
[
"function",
"connectStore",
"(",
"component",
",",
"keys",
")",
"{",
"var",
"shouldReturnAFunction",
"=",
"arguments",
".",
"length",
">",
"2",
"&&",
"arguments",
"[",
"2",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"2",
"]",
":",
"false",
";",
"// function that maps store state to component props",
"var",
"mapStateToProps",
"=",
"function",
"mapStateToProps",
"(",
"state",
")",
"{",
"// initialize return object",
"var",
"mappedState",
"=",
"{",
"}",
";",
"// populate return object",
"keys",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"// add selector connection",
"if",
"(",
"key",
".",
"split",
"(",
"':'",
")",
".",
"length",
"===",
"2",
"&&",
"selectors",
"[",
"key",
".",
"split",
"(",
"':'",
")",
"[",
"1",
"]",
"]",
")",
"{",
"mappedState",
"[",
"key",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
"]",
"=",
"selectors",
"[",
"key",
".",
"split",
"(",
"':'",
")",
"[",
"1",
"]",
"]",
"(",
"state",
")",
";",
"// add branch connection",
"}",
"else",
"if",
"(",
"state",
"[",
"key",
"]",
")",
"{",
"mappedState",
"[",
"key",
"]",
"=",
"state",
"[",
"key",
"]",
".",
"toJS",
"(",
")",
";",
"}",
"}",
")",
";",
"return",
"shouldReturnAFunction",
"?",
"function",
"(",
"state",
",",
"props",
")",
"{",
"return",
"mappedState",
";",
"}",
":",
"mappedState",
";",
"}",
";",
"return",
"(",
"0",
",",
"_reactRedux",
".",
"connect",
")",
"(",
"mapStateToProps",
")",
"(",
"component",
")",
";",
"}"
] |
creates a mapStateToProps function for connected components takes an array of strings
|
[
"creates",
"a",
"mapStateToProps",
"function",
"for",
"connected",
"components",
"takes",
"an",
"array",
"of",
"strings"
] |
669e2978b4a7cdd48fbd33d4fd6dbe47e92d3cef
|
https://github.com/Neil-G/redux-mastermind/blob/669e2978b4a7cdd48fbd33d4fd6dbe47e92d3cef/lib/createMastermind.js#L289-L317
|
39,281 |
Neil-G/redux-mastermind
|
lib/createMastermind.js
|
mapStateToProps
|
function mapStateToProps(state) {
// initialize return object
var mappedState = {};
// populate return object
keys.forEach(function (key) {
// add selector connection
if (key.split(':').length === 2 && selectors[key.split(':')[1]]) {
mappedState[key.split(':')[0]] = selectors[key.split(':')[1]](state);
// add branch connection
} else if (state[key]) {
mappedState[key] = state[key].toJS();
}
});
return shouldReturnAFunction ? function (state, props) {
return mappedState;
} : mappedState;
}
|
javascript
|
function mapStateToProps(state) {
// initialize return object
var mappedState = {};
// populate return object
keys.forEach(function (key) {
// add selector connection
if (key.split(':').length === 2 && selectors[key.split(':')[1]]) {
mappedState[key.split(':')[0]] = selectors[key.split(':')[1]](state);
// add branch connection
} else if (state[key]) {
mappedState[key] = state[key].toJS();
}
});
return shouldReturnAFunction ? function (state, props) {
return mappedState;
} : mappedState;
}
|
[
"function",
"mapStateToProps",
"(",
"state",
")",
"{",
"// initialize return object",
"var",
"mappedState",
"=",
"{",
"}",
";",
"// populate return object",
"keys",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"// add selector connection",
"if",
"(",
"key",
".",
"split",
"(",
"':'",
")",
".",
"length",
"===",
"2",
"&&",
"selectors",
"[",
"key",
".",
"split",
"(",
"':'",
")",
"[",
"1",
"]",
"]",
")",
"{",
"mappedState",
"[",
"key",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
"]",
"=",
"selectors",
"[",
"key",
".",
"split",
"(",
"':'",
")",
"[",
"1",
"]",
"]",
"(",
"state",
")",
";",
"// add branch connection",
"}",
"else",
"if",
"(",
"state",
"[",
"key",
"]",
")",
"{",
"mappedState",
"[",
"key",
"]",
"=",
"state",
"[",
"key",
"]",
".",
"toJS",
"(",
")",
";",
"}",
"}",
")",
";",
"return",
"shouldReturnAFunction",
"?",
"function",
"(",
"state",
",",
"props",
")",
"{",
"return",
"mappedState",
";",
"}",
":",
"mappedState",
";",
"}"
] |
function that maps store state to component props
|
[
"function",
"that",
"maps",
"store",
"state",
"to",
"component",
"props"
] |
669e2978b4a7cdd48fbd33d4fd6dbe47e92d3cef
|
https://github.com/Neil-G/redux-mastermind/blob/669e2978b4a7cdd48fbd33d4fd6dbe47e92d3cef/lib/createMastermind.js#L294-L315
|
39,282 |
vinkaga/angular-mock-backend
|
mock-angular.js
|
applyTransform
|
function applyTransform(data, headers, status, fns) {
if (typeof fns === 'function') {
data = fns(data, headers, status);
} else {
for (var i = 0; i < fns.length; i++) {
data = fns[i](data, headers, status);
}
}
return data;
}
|
javascript
|
function applyTransform(data, headers, status, fns) {
if (typeof fns === 'function') {
data = fns(data, headers, status);
} else {
for (var i = 0; i < fns.length; i++) {
data = fns[i](data, headers, status);
}
}
return data;
}
|
[
"function",
"applyTransform",
"(",
"data",
",",
"headers",
",",
"status",
",",
"fns",
")",
"{",
"if",
"(",
"typeof",
"fns",
"===",
"'function'",
")",
"{",
"data",
"=",
"fns",
"(",
"data",
",",
"headers",
",",
"status",
")",
";",
"}",
"else",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"fns",
".",
"length",
";",
"i",
"++",
")",
"{",
"data",
"=",
"fns",
"[",
"i",
"]",
"(",
"data",
",",
"headers",
",",
"status",
")",
";",
"}",
"}",
"return",
"data",
";",
"}"
] |
Apply request or response transform
@param data
@param headers
@param status
@param fns
@returns {*}
|
[
"Apply",
"request",
"or",
"response",
"transform"
] |
bed0610d65b223430c9a52ff5c9490e6d9b7ad14
|
https://github.com/vinkaga/angular-mock-backend/blob/bed0610d65b223430c9a52ff5c9490e6d9b7ad14/mock-angular.js#L65-L74
|
39,283 |
vinkaga/angular-mock-backend
|
mock-angular.js
|
isMatch
|
function isMatch(config, mock) {
if (angular.isFunction(mock)) {
return !!mock(config.method, config.url, config.params, config.data, config.headers);
}
mock = mock || {};
var fail = false;
if (mock.method) {
fail = fail || (config.method ? config.method.toLowerCase() : 'get') != mock.method.toLowerCase();
}
if (mock.url && angular.isString(config.url) && angular.isString(mock.url)) {
fail = fail || config.url.split('?')[0] != mock.url.split('?')[0];
}
if (mock.params || angular.isString(config.url) && config.url.split('?')[1]) {
var configParams = angular.extend(queryParams(config.url.split('?')[1]), config.params);
var mockParams = angular.isString(mock.url) ? queryParams(mock.url.split('?')[1]) : {};
mockParams = angular.extend(mockParams, mock.params);
fail = fail || !angular.equals(configParams, mockParams);
}
if (mock.data) {
fail = fail || !angular.equals(config.data, mock.data);
}
// Header props can be functions
if (mock.headers) {
var headers = {};
angular.forEach(config.headers, function(value, key) {
if (angular.isFunction(value)) {
value = value(config);
}
if (value) {
headers[key] = value;
}
});
fail = fail || !angular.equals(headers, mock.headers);
}
return !fail;
}
|
javascript
|
function isMatch(config, mock) {
if (angular.isFunction(mock)) {
return !!mock(config.method, config.url, config.params, config.data, config.headers);
}
mock = mock || {};
var fail = false;
if (mock.method) {
fail = fail || (config.method ? config.method.toLowerCase() : 'get') != mock.method.toLowerCase();
}
if (mock.url && angular.isString(config.url) && angular.isString(mock.url)) {
fail = fail || config.url.split('?')[0] != mock.url.split('?')[0];
}
if (mock.params || angular.isString(config.url) && config.url.split('?')[1]) {
var configParams = angular.extend(queryParams(config.url.split('?')[1]), config.params);
var mockParams = angular.isString(mock.url) ? queryParams(mock.url.split('?')[1]) : {};
mockParams = angular.extend(mockParams, mock.params);
fail = fail || !angular.equals(configParams, mockParams);
}
if (mock.data) {
fail = fail || !angular.equals(config.data, mock.data);
}
// Header props can be functions
if (mock.headers) {
var headers = {};
angular.forEach(config.headers, function(value, key) {
if (angular.isFunction(value)) {
value = value(config);
}
if (value) {
headers[key] = value;
}
});
fail = fail || !angular.equals(headers, mock.headers);
}
return !fail;
}
|
[
"function",
"isMatch",
"(",
"config",
",",
"mock",
")",
"{",
"if",
"(",
"angular",
".",
"isFunction",
"(",
"mock",
")",
")",
"{",
"return",
"!",
"!",
"mock",
"(",
"config",
".",
"method",
",",
"config",
".",
"url",
",",
"config",
".",
"params",
",",
"config",
".",
"data",
",",
"config",
".",
"headers",
")",
";",
"}",
"mock",
"=",
"mock",
"||",
"{",
"}",
";",
"var",
"fail",
"=",
"false",
";",
"if",
"(",
"mock",
".",
"method",
")",
"{",
"fail",
"=",
"fail",
"||",
"(",
"config",
".",
"method",
"?",
"config",
".",
"method",
".",
"toLowerCase",
"(",
")",
":",
"'get'",
")",
"!=",
"mock",
".",
"method",
".",
"toLowerCase",
"(",
")",
";",
"}",
"if",
"(",
"mock",
".",
"url",
"&&",
"angular",
".",
"isString",
"(",
"config",
".",
"url",
")",
"&&",
"angular",
".",
"isString",
"(",
"mock",
".",
"url",
")",
")",
"{",
"fail",
"=",
"fail",
"||",
"config",
".",
"url",
".",
"split",
"(",
"'?'",
")",
"[",
"0",
"]",
"!=",
"mock",
".",
"url",
".",
"split",
"(",
"'?'",
")",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"mock",
".",
"params",
"||",
"angular",
".",
"isString",
"(",
"config",
".",
"url",
")",
"&&",
"config",
".",
"url",
".",
"split",
"(",
"'?'",
")",
"[",
"1",
"]",
")",
"{",
"var",
"configParams",
"=",
"angular",
".",
"extend",
"(",
"queryParams",
"(",
"config",
".",
"url",
".",
"split",
"(",
"'?'",
")",
"[",
"1",
"]",
")",
",",
"config",
".",
"params",
")",
";",
"var",
"mockParams",
"=",
"angular",
".",
"isString",
"(",
"mock",
".",
"url",
")",
"?",
"queryParams",
"(",
"mock",
".",
"url",
".",
"split",
"(",
"'?'",
")",
"[",
"1",
"]",
")",
":",
"{",
"}",
";",
"mockParams",
"=",
"angular",
".",
"extend",
"(",
"mockParams",
",",
"mock",
".",
"params",
")",
";",
"fail",
"=",
"fail",
"||",
"!",
"angular",
".",
"equals",
"(",
"configParams",
",",
"mockParams",
")",
";",
"}",
"if",
"(",
"mock",
".",
"data",
")",
"{",
"fail",
"=",
"fail",
"||",
"!",
"angular",
".",
"equals",
"(",
"config",
".",
"data",
",",
"mock",
".",
"data",
")",
";",
"}",
"// Header props can be functions",
"if",
"(",
"mock",
".",
"headers",
")",
"{",
"var",
"headers",
"=",
"{",
"}",
";",
"angular",
".",
"forEach",
"(",
"config",
".",
"headers",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"if",
"(",
"angular",
".",
"isFunction",
"(",
"value",
")",
")",
"{",
"value",
"=",
"value",
"(",
"config",
")",
";",
"}",
"if",
"(",
"value",
")",
"{",
"headers",
"[",
"key",
"]",
"=",
"value",
";",
"}",
"}",
")",
";",
"fail",
"=",
"fail",
"||",
"!",
"angular",
".",
"equals",
"(",
"headers",
",",
"mock",
".",
"headers",
")",
";",
"}",
"return",
"!",
"fail",
";",
"}"
] |
Any missing property on mock matches everything
@param config
@param mock
@returns bool
|
[
"Any",
"missing",
"property",
"on",
"mock",
"matches",
"everything"
] |
bed0610d65b223430c9a52ff5c9490e6d9b7ad14
|
https://github.com/vinkaga/angular-mock-backend/blob/bed0610d65b223430c9a52ff5c9490e6d9b7ad14/mock-angular.js#L82-L117
|
39,284 |
vinkaga/angular-mock-backend
|
mock-angular.js
|
applyRequestInterceptors
|
function applyRequestInterceptors(config) {
for (var i = 0; i < interceptors.length; i++) {
var interceptor = getInterceptor(interceptors[i]);
if (interceptor.request) {
config = interceptor.request(config);
}
}
if (config.transformRequest) {
config.data = applyTransform(config.data, config.headers, undefined, config.transformRequest);
}
return config;
}
|
javascript
|
function applyRequestInterceptors(config) {
for (var i = 0; i < interceptors.length; i++) {
var interceptor = getInterceptor(interceptors[i]);
if (interceptor.request) {
config = interceptor.request(config);
}
}
if (config.transformRequest) {
config.data = applyTransform(config.data, config.headers, undefined, config.transformRequest);
}
return config;
}
|
[
"function",
"applyRequestInterceptors",
"(",
"config",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"interceptors",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"interceptor",
"=",
"getInterceptor",
"(",
"interceptors",
"[",
"i",
"]",
")",
";",
"if",
"(",
"interceptor",
".",
"request",
")",
"{",
"config",
"=",
"interceptor",
".",
"request",
"(",
"config",
")",
";",
"}",
"}",
"if",
"(",
"config",
".",
"transformRequest",
")",
"{",
"config",
".",
"data",
"=",
"applyTransform",
"(",
"config",
".",
"data",
",",
"config",
".",
"headers",
",",
"undefined",
",",
"config",
".",
"transformRequest",
")",
";",
"}",
"return",
"config",
";",
"}"
] |
Apply request interceptors in forward order
@param config
@returns {*}
|
[
"Apply",
"request",
"interceptors",
"in",
"forward",
"order"
] |
bed0610d65b223430c9a52ff5c9490e6d9b7ad14
|
https://github.com/vinkaga/angular-mock-backend/blob/bed0610d65b223430c9a52ff5c9490e6d9b7ad14/mock-angular.js#L196-L207
|
39,285 |
vinkaga/angular-mock-backend
|
mock-angular.js
|
applyResponseInterceptors
|
function applyResponseInterceptors(response) {
if (response.config.transformResponse) {
response.data = applyTransform(response.data, response.headers, response.status, response.config.transformResponse);
}
for (var i = interceptors.length - 1; i >= 0; i--) {
var interceptor = getInterceptor(interceptors[i]);
if (interceptor.response) {
response = interceptor.response(response);
}
}
return response;
}
|
javascript
|
function applyResponseInterceptors(response) {
if (response.config.transformResponse) {
response.data = applyTransform(response.data, response.headers, response.status, response.config.transformResponse);
}
for (var i = interceptors.length - 1; i >= 0; i--) {
var interceptor = getInterceptor(interceptors[i]);
if (interceptor.response) {
response = interceptor.response(response);
}
}
return response;
}
|
[
"function",
"applyResponseInterceptors",
"(",
"response",
")",
"{",
"if",
"(",
"response",
".",
"config",
".",
"transformResponse",
")",
"{",
"response",
".",
"data",
"=",
"applyTransform",
"(",
"response",
".",
"data",
",",
"response",
".",
"headers",
",",
"response",
".",
"status",
",",
"response",
".",
"config",
".",
"transformResponse",
")",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"interceptors",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"interceptor",
"=",
"getInterceptor",
"(",
"interceptors",
"[",
"i",
"]",
")",
";",
"if",
"(",
"interceptor",
".",
"response",
")",
"{",
"response",
"=",
"interceptor",
".",
"response",
"(",
"response",
")",
";",
"}",
"}",
"return",
"response",
";",
"}"
] |
Apply response interceptors in reverse order
@param response
@returns {*}
|
[
"Apply",
"response",
"interceptors",
"in",
"reverse",
"order"
] |
bed0610d65b223430c9a52ff5c9490e6d9b7ad14
|
https://github.com/vinkaga/angular-mock-backend/blob/bed0610d65b223430c9a52ff5c9490e6d9b7ad14/mock-angular.js#L214-L225
|
39,286 |
vinkaga/angular-mock-backend
|
mock-angular.js
|
getMock
|
function getMock(config) {
for (var i = 0; i < mocks.length; i++) {
if (isMatch(config, mocks[i].config)) {
return mocks[i];
}
}
return undefined;
}
|
javascript
|
function getMock(config) {
for (var i = 0; i < mocks.length; i++) {
if (isMatch(config, mocks[i].config)) {
return mocks[i];
}
}
return undefined;
}
|
[
"function",
"getMock",
"(",
"config",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"mocks",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"isMatch",
"(",
"config",
",",
"mocks",
"[",
"i",
"]",
".",
"config",
")",
")",
"{",
"return",
"mocks",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"undefined",
";",
"}"
] |
Get mock config if any
@param config
@returns {*}
|
[
"Get",
"mock",
"config",
"if",
"any"
] |
bed0610d65b223430c9a52ff5c9490e6d9b7ad14
|
https://github.com/vinkaga/angular-mock-backend/blob/bed0610d65b223430c9a52ff5c9490e6d9b7ad14/mock-angular.js#L232-L239
|
39,287 |
vinkaga/angular-mock-backend
|
mock-angular.js
|
delay
|
function delay(mock, response) {
if (!mock || !mock.delay) {
return response;
}
return $q(function(resolve, reject) {
setTimeout(function() {
resolve(response);
}, mock.delay);
});
}
|
javascript
|
function delay(mock, response) {
if (!mock || !mock.delay) {
return response;
}
return $q(function(resolve, reject) {
setTimeout(function() {
resolve(response);
}, mock.delay);
});
}
|
[
"function",
"delay",
"(",
"mock",
",",
"response",
")",
"{",
"if",
"(",
"!",
"mock",
"||",
"!",
"mock",
".",
"delay",
")",
"{",
"return",
"response",
";",
"}",
"return",
"$q",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"resolve",
"(",
"response",
")",
";",
"}",
",",
"mock",
".",
"delay",
")",
";",
"}",
")",
";",
"}"
] |
Insert optional delay in response
@param mock
@param response
@returns {*}
|
[
"Insert",
"optional",
"delay",
"in",
"response"
] |
bed0610d65b223430c9a52ff5c9490e6d9b7ad14
|
https://github.com/vinkaga/angular-mock-backend/blob/bed0610d65b223430c9a52ff5c9490e6d9b7ad14/mock-angular.js#L278-L287
|
39,288 |
vinkaga/angular-mock-backend
|
mock-angular.js
|
responsePromise
|
function responsePromise(response) {
response.status = response.status || 200;
return $q(function(resolve, reject) {
(response.status >= 200 && response.status <= 299 ? resolve : reject)(response);
});
}
|
javascript
|
function responsePromise(response) {
response.status = response.status || 200;
return $q(function(resolve, reject) {
(response.status >= 200 && response.status <= 299 ? resolve : reject)(response);
});
}
|
[
"function",
"responsePromise",
"(",
"response",
")",
"{",
"response",
".",
"status",
"=",
"response",
".",
"status",
"||",
"200",
";",
"return",
"$q",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"(",
"response",
".",
"status",
">=",
"200",
"&&",
"response",
".",
"status",
"<=",
"299",
"?",
"resolve",
":",
"reject",
")",
"(",
"response",
")",
";",
"}",
")",
";",
"}"
] |
Create promise for mock response
@param response
@returns {*}
|
[
"Create",
"promise",
"for",
"mock",
"response"
] |
bed0610d65b223430c9a52ff5c9490e6d9b7ad14
|
https://github.com/vinkaga/angular-mock-backend/blob/bed0610d65b223430c9a52ff5c9490e6d9b7ad14/mock-angular.js#L294-L299
|
39,289 |
iximiuz/js-itertools
|
lib/tools.js
|
makeIter
|
function makeIter(iterable) {
if (typeof iterable[iterSymbol] === 'function') {
// passed argument can create iterators - create new one.
return iterable[iterSymbol]();
}
if (!_isSubscriptable(iterable)) {
throw Error('Unsupported argument type');
}
// passed argument can be indexed, eg. string, array, etc.
// - create new iter object.
var idx = -1;
return {
next: function() {
return ++idx < iterable.length
? {done: false, value: iterable[idx]}
: {done: true};
}
};
}
|
javascript
|
function makeIter(iterable) {
if (typeof iterable[iterSymbol] === 'function') {
// passed argument can create iterators - create new one.
return iterable[iterSymbol]();
}
if (!_isSubscriptable(iterable)) {
throw Error('Unsupported argument type');
}
// passed argument can be indexed, eg. string, array, etc.
// - create new iter object.
var idx = -1;
return {
next: function() {
return ++idx < iterable.length
? {done: false, value: iterable[idx]}
: {done: true};
}
};
}
|
[
"function",
"makeIter",
"(",
"iterable",
")",
"{",
"if",
"(",
"typeof",
"iterable",
"[",
"iterSymbol",
"]",
"===",
"'function'",
")",
"{",
"// passed argument can create iterators - create new one.",
"return",
"iterable",
"[",
"iterSymbol",
"]",
"(",
")",
";",
"}",
"if",
"(",
"!",
"_isSubscriptable",
"(",
"iterable",
")",
")",
"{",
"throw",
"Error",
"(",
"'Unsupported argument type'",
")",
";",
"}",
"// passed argument can be indexed, eg. string, array, etc.",
"// - create new iter object.",
"var",
"idx",
"=",
"-",
"1",
";",
"return",
"{",
"next",
":",
"function",
"(",
")",
"{",
"return",
"++",
"idx",
"<",
"iterable",
".",
"length",
"?",
"{",
"done",
":",
"false",
",",
"value",
":",
"iterable",
"[",
"idx",
"]",
"}",
":",
"{",
"done",
":",
"true",
"}",
";",
"}",
"}",
";",
"}"
] |
Makes a new iterator from iterable.
NOTE: an existing iterator can be passed to this function.
@param {Iterable|Array|String} iterable
@returns {Iterator}
|
[
"Makes",
"a",
"new",
"iterator",
"from",
"iterable",
"."
] |
a228cc89c39e959f0461a04cabb4f625bea1fe33
|
https://github.com/iximiuz/js-itertools/blob/a228cc89c39e959f0461a04cabb4f625bea1fe33/lib/tools.js#L46-L66
|
39,290 |
iximiuz/js-itertools
|
lib/tools.js
|
toArray
|
function toArray(iterable) {
// kinda optimisations
if (isArray(iterable)) {
return iterable.slice();
}
if (typeof iterable === 'string') {
return iterable.split('');
}
var iter = ensureIter(iterable);
var result = [];
var next = iter.next();
while (!next.done) {
result.push(next.value);
next = iter.next();
}
return result;
}
|
javascript
|
function toArray(iterable) {
// kinda optimisations
if (isArray(iterable)) {
return iterable.slice();
}
if (typeof iterable === 'string') {
return iterable.split('');
}
var iter = ensureIter(iterable);
var result = [];
var next = iter.next();
while (!next.done) {
result.push(next.value);
next = iter.next();
}
return result;
}
|
[
"function",
"toArray",
"(",
"iterable",
")",
"{",
"// kinda optimisations",
"if",
"(",
"isArray",
"(",
"iterable",
")",
")",
"{",
"return",
"iterable",
".",
"slice",
"(",
")",
";",
"}",
"if",
"(",
"typeof",
"iterable",
"===",
"'string'",
")",
"{",
"return",
"iterable",
".",
"split",
"(",
"''",
")",
";",
"}",
"var",
"iter",
"=",
"ensureIter",
"(",
"iterable",
")",
";",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"next",
"=",
"iter",
".",
"next",
"(",
")",
";",
"while",
"(",
"!",
"next",
".",
"done",
")",
"{",
"result",
".",
"push",
"(",
"next",
".",
"value",
")",
";",
"next",
"=",
"iter",
".",
"next",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Unrolls passed iterable producing new array.
@param {Iterable|Iterator|Array|String} iterable
@returns Array
|
[
"Unrolls",
"passed",
"iterable",
"producing",
"new",
"array",
"."
] |
a228cc89c39e959f0461a04cabb4f625bea1fe33
|
https://github.com/iximiuz/js-itertools/blob/a228cc89c39e959f0461a04cabb4f625bea1fe33/lib/tools.js#L83-L100
|
39,291 |
P2PVPS/openbazaar-node
|
openbazaar.js
|
getOBAuth
|
function getOBAuth(config) {
// debugger;
// Encoding as per API Specification.
const combinedCredential = `${config.clientId}:${config.clientSecret}`;
// var base64Credential = window.btoa(combinedCredential);
const base64Credential = Buffer.from(combinedCredential).toString("base64");
const readyCredential = `Basic ${base64Credential}`;
return readyCredential;
}
|
javascript
|
function getOBAuth(config) {
// debugger;
// Encoding as per API Specification.
const combinedCredential = `${config.clientId}:${config.clientSecret}`;
// var base64Credential = window.btoa(combinedCredential);
const base64Credential = Buffer.from(combinedCredential).toString("base64");
const readyCredential = `Basic ${base64Credential}`;
return readyCredential;
}
|
[
"function",
"getOBAuth",
"(",
"config",
")",
"{",
"// debugger;",
"// Encoding as per API Specification.",
"const",
"combinedCredential",
"=",
"`",
"${",
"config",
".",
"clientId",
"}",
"${",
"config",
".",
"clientSecret",
"}",
"`",
";",
"// var base64Credential = window.btoa(combinedCredential);",
"const",
"base64Credential",
"=",
"Buffer",
".",
"from",
"(",
"combinedCredential",
")",
".",
"toString",
"(",
"\"base64\"",
")",
";",
"const",
"readyCredential",
"=",
"`",
"${",
"base64Credential",
"}",
"`",
";",
"return",
"readyCredential",
";",
"}"
] |
Generate an auth key for the header. Required fall all OpenBazaar API calls.
|
[
"Generate",
"an",
"auth",
"key",
"for",
"the",
"header",
".",
"Required",
"fall",
"all",
"OpenBazaar",
"API",
"calls",
"."
] |
e75db966dfc56192db44c5fefa9a268975396204
|
https://github.com/P2PVPS/openbazaar-node/blob/e75db966dfc56192db44c5fefa9a268975396204/openbazaar.js#L45-L55
|
39,292 |
P2PVPS/openbazaar-node
|
openbazaar.js
|
getNotifications
|
async function getNotifications(config) {
try {
const options = {
method: "GET",
uri: `${config.obServer}:${config.obPort}/ob/notifications`,
json: true, // Automatically stringifies the body to JSON
headers: {
Authorization: config.apiCredentials,
},
// resolveWithFullResponse: true
};
return rp(options);
} catch (err) {
console.error(`Error in openbazaar.js/getNotifications(): ${err}`);
console.error(`Error stringified: ${JSON.stringify(err, null, 2)}`);
throw err;
}
}
|
javascript
|
async function getNotifications(config) {
try {
const options = {
method: "GET",
uri: `${config.obServer}:${config.obPort}/ob/notifications`,
json: true, // Automatically stringifies the body to JSON
headers: {
Authorization: config.apiCredentials,
},
// resolveWithFullResponse: true
};
return rp(options);
} catch (err) {
console.error(`Error in openbazaar.js/getNotifications(): ${err}`);
console.error(`Error stringified: ${JSON.stringify(err, null, 2)}`);
throw err;
}
}
|
[
"async",
"function",
"getNotifications",
"(",
"config",
")",
"{",
"try",
"{",
"const",
"options",
"=",
"{",
"method",
":",
"\"GET\"",
",",
"uri",
":",
"`",
"${",
"config",
".",
"obServer",
"}",
"${",
"config",
".",
"obPort",
"}",
"`",
",",
"json",
":",
"true",
",",
"// Automatically stringifies the body to JSON",
"headers",
":",
"{",
"Authorization",
":",
"config",
".",
"apiCredentials",
",",
"}",
",",
"// resolveWithFullResponse: true",
"}",
";",
"return",
"rp",
"(",
"options",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"`",
"${",
"err",
"}",
"`",
")",
";",
"console",
".",
"error",
"(",
"`",
"${",
"JSON",
".",
"stringify",
"(",
"err",
",",
"null",
",",
"2",
")",
"}",
"`",
")",
";",
"throw",
"err",
";",
"}",
"}"
] |
This function returns a Promise that resolves to a list of notifications recieved by the OB store.
|
[
"This",
"function",
"returns",
"a",
"Promise",
"that",
"resolves",
"to",
"a",
"list",
"of",
"notifications",
"recieved",
"by",
"the",
"OB",
"store",
"."
] |
e75db966dfc56192db44c5fefa9a268975396204
|
https://github.com/P2PVPS/openbazaar-node/blob/e75db966dfc56192db44c5fefa9a268975396204/openbazaar.js#L59-L77
|
39,293 |
P2PVPS/openbazaar-node
|
openbazaar.js
|
createListing
|
function createListing(config, listingData) {
const options = {
method: "POST",
uri: `${config.obServer}:${config.obPort}/ob/listing/`,
body: listingData,
json: true, // Automatically stringifies the body to JSON
headers: {
Authorization: config.apiCredentials,
},
};
return rp(options);
}
|
javascript
|
function createListing(config, listingData) {
const options = {
method: "POST",
uri: `${config.obServer}:${config.obPort}/ob/listing/`,
body: listingData,
json: true, // Automatically stringifies the body to JSON
headers: {
Authorization: config.apiCredentials,
},
};
return rp(options);
}
|
[
"function",
"createListing",
"(",
"config",
",",
"listingData",
")",
"{",
"const",
"options",
"=",
"{",
"method",
":",
"\"POST\"",
",",
"uri",
":",
"`",
"${",
"config",
".",
"obServer",
"}",
"${",
"config",
".",
"obPort",
"}",
"`",
",",
"body",
":",
"listingData",
",",
"json",
":",
"true",
",",
"// Automatically stringifies the body to JSON",
"headers",
":",
"{",
"Authorization",
":",
"config",
".",
"apiCredentials",
",",
"}",
",",
"}",
";",
"return",
"rp",
"(",
"options",
")",
";",
"}"
] |
Create a listing in the OB store.
|
[
"Create",
"a",
"listing",
"in",
"the",
"OB",
"store",
"."
] |
e75db966dfc56192db44c5fefa9a268975396204
|
https://github.com/P2PVPS/openbazaar-node/blob/e75db966dfc56192db44c5fefa9a268975396204/openbazaar.js#L137-L149
|
39,294 |
P2PVPS/openbazaar-node
|
openbazaar.js
|
createProfile
|
function createProfile(config, profileData) {
const options = {
method: "POST",
uri: `${config.obServer}:${config.obPort}/ob/profile/`,
body: profileData,
json: true, // Automatically stringifies the body to JSON
headers: {
Authorization: config.apiCredentials,
},
// resolveWithFullResponse: true
};
return rp(options);
}
|
javascript
|
function createProfile(config, profileData) {
const options = {
method: "POST",
uri: `${config.obServer}:${config.obPort}/ob/profile/`,
body: profileData,
json: true, // Automatically stringifies the body to JSON
headers: {
Authorization: config.apiCredentials,
},
// resolveWithFullResponse: true
};
return rp(options);
}
|
[
"function",
"createProfile",
"(",
"config",
",",
"profileData",
")",
"{",
"const",
"options",
"=",
"{",
"method",
":",
"\"POST\"",
",",
"uri",
":",
"`",
"${",
"config",
".",
"obServer",
"}",
"${",
"config",
".",
"obPort",
"}",
"`",
",",
"body",
":",
"profileData",
",",
"json",
":",
"true",
",",
"// Automatically stringifies the body to JSON",
"headers",
":",
"{",
"Authorization",
":",
"config",
".",
"apiCredentials",
",",
"}",
",",
"// resolveWithFullResponse: true",
"}",
";",
"return",
"rp",
"(",
"options",
")",
";",
"}"
] |
Create a profile for a new store
|
[
"Create",
"a",
"profile",
"for",
"a",
"new",
"store"
] |
e75db966dfc56192db44c5fefa9a268975396204
|
https://github.com/P2PVPS/openbazaar-node/blob/e75db966dfc56192db44c5fefa9a268975396204/openbazaar.js#L168-L181
|
39,295 |
P2PVPS/openbazaar-node
|
openbazaar.js
|
getExchangeRate
|
function getExchangeRate(config) {
const options = {
method: "GET",
uri: `${config.obServer}:${config.obPort}/ob/exchangerate`,
json: true, // Automatically stringifies the body to JSON
headers: {
Authorization: config.apiCredentials,
},
// resolveWithFullResponse: true
};
return rp(options);
}
|
javascript
|
function getExchangeRate(config) {
const options = {
method: "GET",
uri: `${config.obServer}:${config.obPort}/ob/exchangerate`,
json: true, // Automatically stringifies the body to JSON
headers: {
Authorization: config.apiCredentials,
},
// resolveWithFullResponse: true
};
return rp(options);
}
|
[
"function",
"getExchangeRate",
"(",
"config",
")",
"{",
"const",
"options",
"=",
"{",
"method",
":",
"\"GET\"",
",",
"uri",
":",
"`",
"${",
"config",
".",
"obServer",
"}",
"${",
"config",
".",
"obPort",
"}",
"`",
",",
"json",
":",
"true",
",",
"// Automatically stringifies the body to JSON",
"headers",
":",
"{",
"Authorization",
":",
"config",
".",
"apiCredentials",
",",
"}",
",",
"// resolveWithFullResponse: true",
"}",
";",
"return",
"rp",
"(",
"options",
")",
";",
"}"
] |
Get wallet balance
|
[
"Get",
"wallet",
"balance"
] |
e75db966dfc56192db44c5fefa9a268975396204
|
https://github.com/P2PVPS/openbazaar-node/blob/e75db966dfc56192db44c5fefa9a268975396204/openbazaar.js#L199-L211
|
39,296 |
mikolalysenko/planar-dual
|
loops.js
|
cut
|
function cut(c, i) {
var a = adj[i][c[i]]
a.splice(a.indexOf(c), 1)
}
|
javascript
|
function cut(c, i) {
var a = adj[i][c[i]]
a.splice(a.indexOf(c), 1)
}
|
[
"function",
"cut",
"(",
"c",
",",
"i",
")",
"{",
"var",
"a",
"=",
"adj",
"[",
"i",
"]",
"[",
"c",
"[",
"i",
"]",
"]",
"a",
".",
"splice",
"(",
"a",
".",
"indexOf",
"(",
"c",
")",
",",
"1",
")",
"}"
] |
Remove a half edge
|
[
"Remove",
"a",
"half",
"edge"
] |
b67fdd01b1f9f2aba08fcbac0fe8139ee96be261
|
https://github.com/mikolalysenko/planar-dual/blob/b67fdd01b1f9f2aba08fcbac0fe8139ee96be261/loops.js#L32-L35
|
39,297 |
mikolalysenko/planar-dual
|
loops.js
|
next
|
function next(a, b, noCut) {
var nextCell, nextVertex, nextDir
for(var i=0; i<2; ++i) {
if(adj[i][b].length > 0) {
nextCell = adj[i][b][0]
nextDir = i
break
}
}
nextVertex = nextCell[nextDir^1]
for(var dir=0; dir<2; ++dir) {
var nbhd = adj[dir][b]
for(var k=0; k<nbhd.length; ++k) {
var e = nbhd[k]
var p = e[dir^1]
var cmp = compareAngle(
positions[a],
positions[b],
positions[nextVertex],
positions[p])
if(cmp > 0) {
nextCell = e
nextVertex = p
nextDir = dir
}
}
}
if(noCut) {
return nextVertex
}
if(nextCell) {
cut(nextCell, nextDir)
}
return nextVertex
}
|
javascript
|
function next(a, b, noCut) {
var nextCell, nextVertex, nextDir
for(var i=0; i<2; ++i) {
if(adj[i][b].length > 0) {
nextCell = adj[i][b][0]
nextDir = i
break
}
}
nextVertex = nextCell[nextDir^1]
for(var dir=0; dir<2; ++dir) {
var nbhd = adj[dir][b]
for(var k=0; k<nbhd.length; ++k) {
var e = nbhd[k]
var p = e[dir^1]
var cmp = compareAngle(
positions[a],
positions[b],
positions[nextVertex],
positions[p])
if(cmp > 0) {
nextCell = e
nextVertex = p
nextDir = dir
}
}
}
if(noCut) {
return nextVertex
}
if(nextCell) {
cut(nextCell, nextDir)
}
return nextVertex
}
|
[
"function",
"next",
"(",
"a",
",",
"b",
",",
"noCut",
")",
"{",
"var",
"nextCell",
",",
"nextVertex",
",",
"nextDir",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"2",
";",
"++",
"i",
")",
"{",
"if",
"(",
"adj",
"[",
"i",
"]",
"[",
"b",
"]",
".",
"length",
">",
"0",
")",
"{",
"nextCell",
"=",
"adj",
"[",
"i",
"]",
"[",
"b",
"]",
"[",
"0",
"]",
"nextDir",
"=",
"i",
"break",
"}",
"}",
"nextVertex",
"=",
"nextCell",
"[",
"nextDir",
"^",
"1",
"]",
"for",
"(",
"var",
"dir",
"=",
"0",
";",
"dir",
"<",
"2",
";",
"++",
"dir",
")",
"{",
"var",
"nbhd",
"=",
"adj",
"[",
"dir",
"]",
"[",
"b",
"]",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"nbhd",
".",
"length",
";",
"++",
"k",
")",
"{",
"var",
"e",
"=",
"nbhd",
"[",
"k",
"]",
"var",
"p",
"=",
"e",
"[",
"dir",
"^",
"1",
"]",
"var",
"cmp",
"=",
"compareAngle",
"(",
"positions",
"[",
"a",
"]",
",",
"positions",
"[",
"b",
"]",
",",
"positions",
"[",
"nextVertex",
"]",
",",
"positions",
"[",
"p",
"]",
")",
"if",
"(",
"cmp",
">",
"0",
")",
"{",
"nextCell",
"=",
"e",
"nextVertex",
"=",
"p",
"nextDir",
"=",
"dir",
"}",
"}",
"}",
"if",
"(",
"noCut",
")",
"{",
"return",
"nextVertex",
"}",
"if",
"(",
"nextCell",
")",
"{",
"cut",
"(",
"nextCell",
",",
"nextDir",
")",
"}",
"return",
"nextVertex",
"}"
] |
Find next vertex and cut edge
|
[
"Find",
"next",
"vertex",
"and",
"cut",
"edge"
] |
b67fdd01b1f9f2aba08fcbac0fe8139ee96be261
|
https://github.com/mikolalysenko/planar-dual/blob/b67fdd01b1f9f2aba08fcbac0fe8139ee96be261/loops.js#L38-L73
|
39,298 |
LaxarJS/laxar-angular-adapter
|
lib/services/visibility_service.js
|
handlerFor
|
function handlerFor( scope ) {
const { axVisibility } = widgetServices( scope );
axVisibility.onChange( updateState );
scope.$on( '$destroy', () => { axVisibility.unsubscribe( updateState ); } );
let lastState = axVisibility.isVisible();
/**
* A scope bound visibility handler.
*
* @name axVisibilityServiceHandler
*/
const api = {
/**
* Determine if the governing widget scope's DOM is visible right now.
*
* @return {Boolean}
* `true` if the widget associated with this handler is visible right now, else `false`
*
* @memberOf axVisibilityServiceHandler
*/
isVisible() {
return axVisibility.isVisible();
},
//////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Schedule a handler to be called with the new DOM visibility on any DOM visibility change.
*
* @param {Function<Boolean>} handler
* the callback to process visibility changes
*
* @return {axVisibilityServiceHandler}
* this visibility handler (for chaining)
*
* @memberOf axVisibilityServiceHandler
*/
onChange( handler ) {
addHandler( handler, true );
addHandler( handler, false );
return api;
},
//////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Schedule a handler to be called with the new DOM visibility when it has changed to `true`.
*
* @param {Function<Boolean>} handler
* the callback to process visibility changes
*
* @return {axVisibilityServiceHandler}
* this visibility handler (for chaining)
*
* @memberOf axVisibilityServiceHandler
*/
onShow( handler ) {
addHandler( handler, true );
return api;
},
//////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Schedule a handler to be called with the new DOM visibility when it has changed to `false`.
*
* @param {Function<Boolean>} handler
* the callback to process visibility changes
*
* @return {axVisibilityServiceHandler}
* this visibility handler (for chaining)
*
* @memberOf axVisibilityServiceHandler
*/
onHide( handler ) {
addHandler( handler, false );
return api;
},
//////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Removes all visibility handlers.
*
* @return {axVisibilityServiceHandler}
* this visibility handler (for chaining)
*
* @memberOf axVisibilityServiceHandler
*/
clear
};
const showHandlers = [];
const hideHandlers = [];
return api;
/////////////////////////////////////////////////////////////////////////////////////////////////////
function clear() {
showHandlers.splice( 0, showHandlers.length );
hideHandlers.splice( 0, hideHandlers.length );
return api;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
// eslint-disable-next-line valid-jsdoc
/**
* Run all handlers registered for the given area and target state after the next heartbeat.
* Also remove any handlers that have been cleared since the last run.
* @private
*/
function updateState( targetState ) {
const state = axVisibility.isVisible();
if( state === lastState ) {
return;
}
lastState = state;
heartbeat.onAfterNext( () => {
const handlers = targetState ? showHandlers : hideHandlers;
handlers.forEach( f => f( targetState ) );
} );
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
// eslint-disable-next-line valid-jsdoc
/**
* Add a show/hide-handler for a given area and visibility state. Execute the handler right away if
* the state is already known, and `true` (since all widgets start as invisible).
* @private
*/
function addHandler( handler, targetState ) {
( targetState ? showHandlers : hideHandlers ).push( handler );
// State already known to be true? In that case, initialize:
if( targetState && axVisibility.isVisible() === targetState ) {
handler( targetState );
}
}
}
|
javascript
|
function handlerFor( scope ) {
const { axVisibility } = widgetServices( scope );
axVisibility.onChange( updateState );
scope.$on( '$destroy', () => { axVisibility.unsubscribe( updateState ); } );
let lastState = axVisibility.isVisible();
/**
* A scope bound visibility handler.
*
* @name axVisibilityServiceHandler
*/
const api = {
/**
* Determine if the governing widget scope's DOM is visible right now.
*
* @return {Boolean}
* `true` if the widget associated with this handler is visible right now, else `false`
*
* @memberOf axVisibilityServiceHandler
*/
isVisible() {
return axVisibility.isVisible();
},
//////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Schedule a handler to be called with the new DOM visibility on any DOM visibility change.
*
* @param {Function<Boolean>} handler
* the callback to process visibility changes
*
* @return {axVisibilityServiceHandler}
* this visibility handler (for chaining)
*
* @memberOf axVisibilityServiceHandler
*/
onChange( handler ) {
addHandler( handler, true );
addHandler( handler, false );
return api;
},
//////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Schedule a handler to be called with the new DOM visibility when it has changed to `true`.
*
* @param {Function<Boolean>} handler
* the callback to process visibility changes
*
* @return {axVisibilityServiceHandler}
* this visibility handler (for chaining)
*
* @memberOf axVisibilityServiceHandler
*/
onShow( handler ) {
addHandler( handler, true );
return api;
},
//////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Schedule a handler to be called with the new DOM visibility when it has changed to `false`.
*
* @param {Function<Boolean>} handler
* the callback to process visibility changes
*
* @return {axVisibilityServiceHandler}
* this visibility handler (for chaining)
*
* @memberOf axVisibilityServiceHandler
*/
onHide( handler ) {
addHandler( handler, false );
return api;
},
//////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Removes all visibility handlers.
*
* @return {axVisibilityServiceHandler}
* this visibility handler (for chaining)
*
* @memberOf axVisibilityServiceHandler
*/
clear
};
const showHandlers = [];
const hideHandlers = [];
return api;
/////////////////////////////////////////////////////////////////////////////////////////////////////
function clear() {
showHandlers.splice( 0, showHandlers.length );
hideHandlers.splice( 0, hideHandlers.length );
return api;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
// eslint-disable-next-line valid-jsdoc
/**
* Run all handlers registered for the given area and target state after the next heartbeat.
* Also remove any handlers that have been cleared since the last run.
* @private
*/
function updateState( targetState ) {
const state = axVisibility.isVisible();
if( state === lastState ) {
return;
}
lastState = state;
heartbeat.onAfterNext( () => {
const handlers = targetState ? showHandlers : hideHandlers;
handlers.forEach( f => f( targetState ) );
} );
}
/////////////////////////////////////////////////////////////////////////////////////////////////////
// eslint-disable-next-line valid-jsdoc
/**
* Add a show/hide-handler for a given area and visibility state. Execute the handler right away if
* the state is already known, and `true` (since all widgets start as invisible).
* @private
*/
function addHandler( handler, targetState ) {
( targetState ? showHandlers : hideHandlers ).push( handler );
// State already known to be true? In that case, initialize:
if( targetState && axVisibility.isVisible() === targetState ) {
handler( targetState );
}
}
}
|
[
"function",
"handlerFor",
"(",
"scope",
")",
"{",
"const",
"{",
"axVisibility",
"}",
"=",
"widgetServices",
"(",
"scope",
")",
";",
"axVisibility",
".",
"onChange",
"(",
"updateState",
")",
";",
"scope",
".",
"$on",
"(",
"'$destroy'",
",",
"(",
")",
"=>",
"{",
"axVisibility",
".",
"unsubscribe",
"(",
"updateState",
")",
";",
"}",
")",
";",
"let",
"lastState",
"=",
"axVisibility",
".",
"isVisible",
"(",
")",
";",
"/**\n * A scope bound visibility handler.\n *\n * @name axVisibilityServiceHandler\n */",
"const",
"api",
"=",
"{",
"/**\n * Determine if the governing widget scope's DOM is visible right now.\n *\n * @return {Boolean}\n * `true` if the widget associated with this handler is visible right now, else `false`\n *\n * @memberOf axVisibilityServiceHandler\n */",
"isVisible",
"(",
")",
"{",
"return",
"axVisibility",
".",
"isVisible",
"(",
")",
";",
"}",
",",
"//////////////////////////////////////////////////////////////////////////////////////////////////",
"/**\n * Schedule a handler to be called with the new DOM visibility on any DOM visibility change.\n *\n * @param {Function<Boolean>} handler\n * the callback to process visibility changes\n *\n * @return {axVisibilityServiceHandler}\n * this visibility handler (for chaining)\n *\n * @memberOf axVisibilityServiceHandler\n */",
"onChange",
"(",
"handler",
")",
"{",
"addHandler",
"(",
"handler",
",",
"true",
")",
";",
"addHandler",
"(",
"handler",
",",
"false",
")",
";",
"return",
"api",
";",
"}",
",",
"//////////////////////////////////////////////////////////////////////////////////////////////////",
"/**\n * Schedule a handler to be called with the new DOM visibility when it has changed to `true`.\n *\n * @param {Function<Boolean>} handler\n * the callback to process visibility changes\n *\n * @return {axVisibilityServiceHandler}\n * this visibility handler (for chaining)\n *\n * @memberOf axVisibilityServiceHandler\n */",
"onShow",
"(",
"handler",
")",
"{",
"addHandler",
"(",
"handler",
",",
"true",
")",
";",
"return",
"api",
";",
"}",
",",
"//////////////////////////////////////////////////////////////////////////////////////////////////",
"/**\n * Schedule a handler to be called with the new DOM visibility when it has changed to `false`.\n *\n * @param {Function<Boolean>} handler\n * the callback to process visibility changes\n *\n * @return {axVisibilityServiceHandler}\n * this visibility handler (for chaining)\n *\n * @memberOf axVisibilityServiceHandler\n */",
"onHide",
"(",
"handler",
")",
"{",
"addHandler",
"(",
"handler",
",",
"false",
")",
";",
"return",
"api",
";",
"}",
",",
"//////////////////////////////////////////////////////////////////////////////////////////////////",
"/**\n * Removes all visibility handlers.\n *\n * @return {axVisibilityServiceHandler}\n * this visibility handler (for chaining)\n *\n * @memberOf axVisibilityServiceHandler\n */",
"clear",
"}",
";",
"const",
"showHandlers",
"=",
"[",
"]",
";",
"const",
"hideHandlers",
"=",
"[",
"]",
";",
"return",
"api",
";",
"/////////////////////////////////////////////////////////////////////////////////////////////////////",
"function",
"clear",
"(",
")",
"{",
"showHandlers",
".",
"splice",
"(",
"0",
",",
"showHandlers",
".",
"length",
")",
";",
"hideHandlers",
".",
"splice",
"(",
"0",
",",
"hideHandlers",
".",
"length",
")",
";",
"return",
"api",
";",
"}",
"/////////////////////////////////////////////////////////////////////////////////////////////////////",
"// eslint-disable-next-line valid-jsdoc",
"/**\n * Run all handlers registered for the given area and target state after the next heartbeat.\n * Also remove any handlers that have been cleared since the last run.\n * @private\n */",
"function",
"updateState",
"(",
"targetState",
")",
"{",
"const",
"state",
"=",
"axVisibility",
".",
"isVisible",
"(",
")",
";",
"if",
"(",
"state",
"===",
"lastState",
")",
"{",
"return",
";",
"}",
"lastState",
"=",
"state",
";",
"heartbeat",
".",
"onAfterNext",
"(",
"(",
")",
"=>",
"{",
"const",
"handlers",
"=",
"targetState",
"?",
"showHandlers",
":",
"hideHandlers",
";",
"handlers",
".",
"forEach",
"(",
"f",
"=>",
"f",
"(",
"targetState",
")",
")",
";",
"}",
")",
";",
"}",
"/////////////////////////////////////////////////////////////////////////////////////////////////////",
"// eslint-disable-next-line valid-jsdoc",
"/**\n * Add a show/hide-handler for a given area and visibility state. Execute the handler right away if\n * the state is already known, and `true` (since all widgets start as invisible).\n * @private\n */",
"function",
"addHandler",
"(",
"handler",
",",
"targetState",
")",
"{",
"(",
"targetState",
"?",
"showHandlers",
":",
"hideHandlers",
")",
".",
"push",
"(",
"handler",
")",
";",
"// State already known to be true? In that case, initialize:",
"if",
"(",
"targetState",
"&&",
"axVisibility",
".",
"isVisible",
"(",
")",
"===",
"targetState",
")",
"{",
"handler",
"(",
"targetState",
")",
";",
"}",
"}",
"}"
] |
Create a DOM visibility handler for the given scope.
@param {Object} scope
the scope from which to infer visibility. Must be a widget scope or nested in a widget scope
@return {axVisibilityServiceHandler}
a visibility handler for the given scope
@memberOf axVisibilityService
|
[
"Create",
"a",
"DOM",
"visibility",
"handler",
"for",
"the",
"given",
"scope",
"."
] |
62306263c6146c71271a929585f4bd39727cb2e0
|
https://github.com/LaxarJS/laxar-angular-adapter/blob/62306263c6146c71271a929585f4bd39727cb2e0/lib/services/visibility_service.js#L53-L197
|
39,299 |
LaxarJS/laxar-angular-adapter
|
lib/services/visibility_service.js
|
updateState
|
function updateState( targetState ) {
const state = axVisibility.isVisible();
if( state === lastState ) {
return;
}
lastState = state;
heartbeat.onAfterNext( () => {
const handlers = targetState ? showHandlers : hideHandlers;
handlers.forEach( f => f( targetState ) );
} );
}
|
javascript
|
function updateState( targetState ) {
const state = axVisibility.isVisible();
if( state === lastState ) {
return;
}
lastState = state;
heartbeat.onAfterNext( () => {
const handlers = targetState ? showHandlers : hideHandlers;
handlers.forEach( f => f( targetState ) );
} );
}
|
[
"function",
"updateState",
"(",
"targetState",
")",
"{",
"const",
"state",
"=",
"axVisibility",
".",
"isVisible",
"(",
")",
";",
"if",
"(",
"state",
"===",
"lastState",
")",
"{",
"return",
";",
"}",
"lastState",
"=",
"state",
";",
"heartbeat",
".",
"onAfterNext",
"(",
"(",
")",
"=>",
"{",
"const",
"handlers",
"=",
"targetState",
"?",
"showHandlers",
":",
"hideHandlers",
";",
"handlers",
".",
"forEach",
"(",
"f",
"=>",
"f",
"(",
"targetState",
")",
")",
";",
"}",
")",
";",
"}"
] |
eslint-disable-next-line valid-jsdoc
Run all handlers registered for the given area and target state after the next heartbeat.
Also remove any handlers that have been cleared since the last run.
@private
|
[
"eslint",
"-",
"disable",
"-",
"next",
"-",
"line",
"valid",
"-",
"jsdoc",
"Run",
"all",
"handlers",
"registered",
"for",
"the",
"given",
"area",
"and",
"target",
"state",
"after",
"the",
"next",
"heartbeat",
".",
"Also",
"remove",
"any",
"handlers",
"that",
"have",
"been",
"cleared",
"since",
"the",
"last",
"run",
"."
] |
62306263c6146c71271a929585f4bd39727cb2e0
|
https://github.com/LaxarJS/laxar-angular-adapter/blob/62306263c6146c71271a929585f4bd39727cb2e0/lib/services/visibility_service.js#L168-L178
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.