repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
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", ")", ";", "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
train
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
train
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", ")", "{", "node", ".", "style", ".", "width", "=", "(", "width", "+", "20", ")", "+", "\"px\"", ";", "node", ".", "style", ".", "paddingRight", "=", "\"20px\"", ";", "node", ".", "style", ".", "boxSizing", "=", "\"border-box\"", ";", "}", "else", "{", "node", ".", "style", ".", "width", "=", "(", "width", "+", "oOverflow", ".", "bar", ")", "+", "\"px\"", ";", "}", "}", ";", "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\"", ";", "}", "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
train
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
train
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", ")", ";", "if", "(", "this", ".", "s", ".", "fnDrawCallback", "!==", "null", ")", "{", "this", ".", "s", ".", "fnDrawCallback", ".", "call", "(", "this", ",", "this", ".", "dom", ".", "clone", ".", "left", ",", "this", ".", "dom", ".", "clone", ".", "right", ")", ";", "}", "$", "(", "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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", ",", "'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
train
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
train
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", ")", "}" ]
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
train
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", ")", "{", "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
train
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
train
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", ")", ")", "soup", ".", "setInnerHTML", "(", "'head > meta:last-of-type'", ",", "function", "(", "oldHTML", ")", "{", "if", "(", "oldHTML", "!==", "null", ")", "{", "insertionPoint", "=", "'meta'", "return", "oldHTML", "}", "}", ")", "if", "(", "insertionPoint", ")", "{", "return", "true", "}", "soup", ".", "setInnerHTML", "(", "'head > link:first-of-type'", ",", "function", "(", "oldHTML", ")", "{", "if", "(", "oldHTML", "!==", "null", ")", "{", "insertionPoint", "=", "'link'", "return", "oldHTML", "}", "}", ")", "if", "(", "insertionPoint", ")", "{", "return", "true", "}", "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
train
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
train
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
train
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", ")", "{", "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", ")", ")", "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
train
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
train
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
train
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
train
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
train
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", "--", ")", ";", "if", "(", "i", "==", "-", "1", ")", "{", "for", "(", "i", "=", "len", "+", "1", ";", "s", "[", "i", "]", "!=", "' '", "&&", "i", "<", "s", ".", "length", ";", "i", "++", ")", ";", "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
train
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
train
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
train
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
train
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", ")", "{", "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
train
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", ")", ";", "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", ";", "}", "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", ")", ";", "}" ]
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
train
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
train
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", ")", ";", "const", "normalizedModules", "=", "normalizeModules", "(", "rawModules", ")", ";", "const", "modules", "=", "mergeTestState", "(", "normalizedModules", ",", "state", ")", ";", "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
train
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", ")", "{", "if", "(", "window", ".", "getComputedStyle", "||", "value", ".", "indexOf", "(", "'%'", ")", "===", "-", "1", ")", "{", "return", "value", ";", "}", "var", "style", "=", "elem", ".", "style", ";", "var", "left", "=", "style", ".", "left", ";", "var", "rs", "=", "elem", ".", "runtimeStyle", ";", "var", "rsLeft", "=", "rs", "&&", "rs", ".", "left", ";", "if", "(", "rsLeft", ")", "{", "rs", ".", "left", "=", "elem", ".", "currentStyle", ".", "left", ";", "}", "style", ".", "left", "=", "value", ";", "value", "=", "style", ".", "pixelLeft", ";", "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
train
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", ")", "{", "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
train
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", ")", "{", "checkParent", "(", "elem", ")", ";", "var", "elems", "=", "elem", ".", "parentNode", ".", "querySelectorAll", "(", "selector", ")", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "elems", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "elems", "[", "i", "]", "===", "elem", ")", "{", "return", "true", ";", "}", "}", "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
train
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", "]", ")", ";", "this", ".", "sides", "=", "tokens", "[", "2", "]", "===", "undefined", "?", "this", ".", "defaultSides", ":", "parseInt", "(", "tokens", "[", "2", "]", ")", ";", "var", "after", "=", "tokens", "[", "3", "]", ";", "var", "additionTokens", ";", "if", "(", "after", ")", "{", "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
train
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", ")", "{", "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", ")", ";", "}", "this", ".", "s", "=", "{", "\"dt\"", ":", "null", ",", "\"oInit\"", ":", "oInit", ",", "\"hidden\"", ":", "true", ",", "\"abOriginal\"", ":", "[", "]", "}", ";", "this", ".", "dom", "=", "{", "\"wrapper\"", ":", "null", ",", "\"button\"", ":", "null", ",", "\"collection\"", ":", "null", ",", "\"background\"", ":", "null", ",", "\"catcher\"", ":", "null", ",", "\"buttons\"", ":", "[", "]", ",", "\"groupButtons\"", ":", "[", "]", ",", "\"restore\"", ":", "null", "}", ";", "ColVis", ".", "aInstances", ".", "push", "(", "this", ")", ";", "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
train
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", ")", ";", "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", ";", "}", "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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
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", ";", "}" ]
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
train
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
train
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
train
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", "(", ")", "{", "if", "(", "numDone", ">=", "numTotal", ")", "return", "done", "(", "null", ",", "results", ")", ";", "while", "(", "doing", "<", "numTotal", "&&", "numProcessing", "<", "numParralel", ")", "{", "callFn", "(", "fn", ",", "items", "[", "doing", "++", "]", ",", "onDone", ")", ";", "numProcessing", "++", ";", "}", "return", ";", "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
train
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", "(", ")", "{", "const", "makeFnMap", "=", "{", "}", ";", "Object", ".", "keys", "(", "fnMap", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "makeFnMap", "[", "key", "]", "=", "_make", "(", "fnMap", "[", "key", "]", ")", ";", "}", ")", ";", "return", "makeFnMap", ";", "function", "_make", "(", "fn", ")", "{", "return", "function", "madeFunction", "(", "fns", ",", "context", ",", "returnKey", ")", "{", "if", "(", "typeof", "context", "===", "'string'", ")", "{", "returnKey", "=", "context", ";", "context", "=", "{", "}", ";", "}", "return", "function", "flowFunction", "(", "context", ",", "cb", ")", "{", "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
train
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", ")", "{", "return", "function", "madeFunction", "(", "fns", ",", "context", ",", "returnKey", ")", "{", "if", "(", "typeof", "context", "===", "'string'", ")", "{", "returnKey", "=", "context", ";", "context", "=", "{", "}", ";", "}", "return", "function", "flowFunction", "(", "context", ",", "cb", ")", "{", "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
train
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", ";", "c", ".", "_stopped", "=", "null", ";", "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", ",", "}", ")", ";", "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", ",", "}", ")", ";", "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", ",", "}", ")", ";", "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
train
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
train
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
train
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
train
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", ")", "{", "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
train
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
train
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", ")", "{", "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
train
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
train
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", ";", "var", "mapStateToProps", "=", "function", "mapStateToProps", "(", "state", ")", "{", "var", "mappedState", "=", "{", "}", ";", "keys", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "key", ".", "split", "(", "':'", ")", ".", "length", "===", "2", "&&", "selectors", "[", "key", ".", "split", "(", "':'", ")", "[", "1", "]", "]", ")", "{", "mappedState", "[", "key", ".", "split", "(", "':'", ")", "[", "0", "]", "]", "=", "selectors", "[", "key", ".", "split", "(", "':'", ")", "[", "1", "]", "]", "(", "state", ")", ";", "}", "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
train
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", ")", "{", "var", "mappedState", "=", "{", "}", ";", "keys", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "key", ".", "split", "(", "':'", ")", ".", "length", "===", "2", "&&", "selectors", "[", "key", ".", "split", "(", "':'", ")", "[", "1", "]", "]", ")", "{", "mappedState", "[", "key", ".", "split", "(", "':'", ")", "[", "0", "]", "]", "=", "selectors", "[", "key", ".", "split", "(", "':'", ")", "[", "1", "]", "]", "(", "state", ")", ";", "}", "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
train
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
train
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", ")", ";", "}", "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
train
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
train
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
train
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
train
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
train
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
train
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'", ")", "{", "return", "iterable", "[", "iterSymbol", "]", "(", ")", ";", "}", "if", "(", "!", "_isSubscriptable", "(", "iterable", ")", ")", "{", "throw", "Error", "(", "'Unsupported argument type'", ")", ";", "}", "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
train
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", ")", "{", "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
train
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", ")", "{", "const", "combinedCredential", "=", "`", "${", "config", ".", "clientId", "}", "${", "config", ".", "clientSecret", "}", "`", ";", "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
train
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", ",", "headers", ":", "{", "Authorization", ":", "config", ".", "apiCredentials", ",", "}", ",", "}", ";", "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
train
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", ",", "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
train
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", ",", "headers", ":", "{", "Authorization", ":", "config", ".", "apiCredentials", ",", "}", ",", "}", ";", "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
train
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", ",", "headers", ":", "{", "Authorization", ":", "config", ".", "apiCredentials", ",", "}", ",", "}", ";", "return", "rp", "(", "options", ")", ";", "}" ]
Get wallet balance
[ "Get", "wallet", "balance" ]
e75db966dfc56192db44c5fefa9a268975396204
https://github.com/P2PVPS/openbazaar-node/blob/e75db966dfc56192db44c5fefa9a268975396204/openbazaar.js#L199-L211
train
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
train
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
train
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", "(", ")", ";", "const", "api", "=", "{", "isVisible", "(", ")", "{", "return", "axVisibility", ".", "isVisible", "(", ")", ";", "}", ",", "onChange", "(", "handler", ")", "{", "addHandler", "(", "handler", ",", "true", ")", ";", "addHandler", "(", "handler", ",", "false", ")", ";", "return", "api", ";", "}", ",", "onShow", "(", "handler", ")", "{", "addHandler", "(", "handler", ",", "true", ")", ";", "return", "api", ";", "}", ",", "onHide", "(", "handler", ")", "{", "addHandler", "(", "handler", ",", "false", ")", ";", "return", "api", ";", "}", ",", "clear", "}", ";", "const", "showHandlers", "=", "[", "]", ";", "const", "hideHandlers", "=", "[", "]", ";", "return", "api", ";", "function", "clear", "(", ")", "{", "showHandlers", ".", "splice", "(", "0", ",", "showHandlers", ".", "length", ")", ";", "hideHandlers", ".", "splice", "(", "0", ",", "hideHandlers", ".", "length", ")", ";", "return", "api", ";", "}", "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", "addHandler", "(", "handler", ",", "targetState", ")", "{", "(", "targetState", "?", "showHandlers", ":", "hideHandlers", ")", ".", "push", "(", "handler", ")", ";", "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
train
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
train
S3bb1/ah-dashboard-plugin
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js
function( oDT, oConfig ) { /* Sanity check that we are a new instance */ if ( ! (this instanceof AutoFill) ) { throw( "Warning: AutoFill must be initialised with the keyword 'new'" ); } if ( ! $.fn.dataTableExt.fnVersionCheck('1.7.0') ) { throw( "Warning: AutoFill requires DataTables 1.7 or greater"); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Public class variables * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ this.c = {}; /** * @namespace Settings object which contains customisable information for AutoFill instance */ this.s = { /** * @namespace Cached information about the little dragging icon (the filler) */ "filler": { "height": 0, "width": 0 }, /** * @namespace Cached information about the border display */ "border": { "width": 2 }, /** * @namespace Store for live information for the current drag */ "drag": { "startX": -1, "startY": -1, "startTd": null, "endTd": null, "dragging": false }, /** * @namespace Data cache for information that we need for scrolling the screen when we near * the edges */ "screen": { "interval": null, "y": 0, "height": 0, "scrollTop": 0 }, /** * @namespace Data cache for the position of the DataTables scrolling element (when scrolling * is enabled) */ "scroller": { "top": 0, "bottom": 0 }, /** * @namespace Information stored for each column. An array of objects */ "columns": [] }; /** * @namespace Common and useful DOM elements for the class instance */ this.dom = { "table": null, "filler": null, "borderTop": null, "borderRight": null, "borderBottom": null, "borderLeft": null, "currentTarget": null }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Public class methods * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /** * Retreieve the settings object from an instance * @method fnSettings * @returns {object} AutoFill settings object */ this.fnSettings = function () { return this.s; }; /* Constructor logic */ this._fnInit( oDT, oConfig ); return this; }
javascript
function( oDT, oConfig ) { /* Sanity check that we are a new instance */ if ( ! (this instanceof AutoFill) ) { throw( "Warning: AutoFill must be initialised with the keyword 'new'" ); } if ( ! $.fn.dataTableExt.fnVersionCheck('1.7.0') ) { throw( "Warning: AutoFill requires DataTables 1.7 or greater"); } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Public class variables * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ this.c = {}; /** * @namespace Settings object which contains customisable information for AutoFill instance */ this.s = { /** * @namespace Cached information about the little dragging icon (the filler) */ "filler": { "height": 0, "width": 0 }, /** * @namespace Cached information about the border display */ "border": { "width": 2 }, /** * @namespace Store for live information for the current drag */ "drag": { "startX": -1, "startY": -1, "startTd": null, "endTd": null, "dragging": false }, /** * @namespace Data cache for information that we need for scrolling the screen when we near * the edges */ "screen": { "interval": null, "y": 0, "height": 0, "scrollTop": 0 }, /** * @namespace Data cache for the position of the DataTables scrolling element (when scrolling * is enabled) */ "scroller": { "top": 0, "bottom": 0 }, /** * @namespace Information stored for each column. An array of objects */ "columns": [] }; /** * @namespace Common and useful DOM elements for the class instance */ this.dom = { "table": null, "filler": null, "borderTop": null, "borderRight": null, "borderBottom": null, "borderLeft": null, "currentTarget": null }; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Public class methods * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /** * Retreieve the settings object from an instance * @method fnSettings * @returns {object} AutoFill settings object */ this.fnSettings = function () { return this.s; }; /* Constructor logic */ this._fnInit( oDT, oConfig ); return this; }
[ "function", "(", "oDT", ",", "oConfig", ")", "{", "if", "(", "!", "(", "this", "instanceof", "AutoFill", ")", ")", "{", "throw", "(", "\"Warning: AutoFill must be initialised with the keyword 'new'\"", ")", ";", "}", "if", "(", "!", "$", ".", "fn", ".", "dataTableExt", ".", "fnVersionCheck", "(", "'1.7.0'", ")", ")", "{", "throw", "(", "\"Warning: AutoFill requires DataTables 1.7 or greater\"", ")", ";", "}", "this", ".", "c", "=", "{", "}", ";", "this", ".", "s", "=", "{", "\"filler\"", ":", "{", "\"height\"", ":", "0", ",", "\"width\"", ":", "0", "}", ",", "\"border\"", ":", "{", "\"width\"", ":", "2", "}", ",", "\"drag\"", ":", "{", "\"startX\"", ":", "-", "1", ",", "\"startY\"", ":", "-", "1", ",", "\"startTd\"", ":", "null", ",", "\"endTd\"", ":", "null", ",", "\"dragging\"", ":", "false", "}", ",", "\"screen\"", ":", "{", "\"interval\"", ":", "null", ",", "\"y\"", ":", "0", ",", "\"height\"", ":", "0", ",", "\"scrollTop\"", ":", "0", "}", ",", "\"scroller\"", ":", "{", "\"top\"", ":", "0", ",", "\"bottom\"", ":", "0", "}", ",", "\"columns\"", ":", "[", "]", "}", ";", "this", ".", "dom", "=", "{", "\"table\"", ":", "null", ",", "\"filler\"", ":", "null", ",", "\"borderTop\"", ":", "null", ",", "\"borderRight\"", ":", "null", ",", "\"borderBottom\"", ":", "null", ",", "\"borderLeft\"", ":", "null", ",", "\"currentTarget\"", ":", "null", "}", ";", "this", ".", "fnSettings", "=", "function", "(", ")", "{", "return", "this", ".", "s", ";", "}", ";", "this", ".", "_fnInit", "(", "oDT", ",", "oConfig", ")", ";", "return", "this", ";", "}" ]
AutoFill provides Excel like auto-fill features for a DataTable @class AutoFill @constructor @param {object} oTD DataTables settings object @param {object} oConfig Configuration object for AutoFill
[ "AutoFill", "provides", "Excel", "like", "auto", "-", "fill", "features", "for", "a", "DataTable" ]
c283370ec0f99a25db5bb7029a98b4febf8c5251
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js#L37-L144
train
S3bb1/ah-dashboard-plugin
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js
function ( nTd ) { var nTr = $(nTd).parents('tr')[0]; var position = this.s.dt.oInstance.fnGetPosition( nTd ); return { "x": $('td', nTr).index(nTd), "y": $('tr', nTr.parentNode).index(nTr), "row": position[0], "column": position[2] }; }
javascript
function ( nTd ) { var nTr = $(nTd).parents('tr')[0]; var position = this.s.dt.oInstance.fnGetPosition( nTd ); return { "x": $('td', nTr).index(nTd), "y": $('tr', nTr.parentNode).index(nTr), "row": position[0], "column": position[2] }; }
[ "function", "(", "nTd", ")", "{", "var", "nTr", "=", "$", "(", "nTd", ")", ".", "parents", "(", "'tr'", ")", "[", "0", "]", ";", "var", "position", "=", "this", ".", "s", ".", "dt", ".", "oInstance", ".", "fnGetPosition", "(", "nTd", ")", ";", "return", "{", "\"x\"", ":", "$", "(", "'td'", ",", "nTr", ")", ".", "index", "(", "nTd", ")", ",", "\"y\"", ":", "$", "(", "'tr'", ",", "nTr", ".", "parentNode", ")", ".", "index", "(", "nTr", ")", ",", "\"row\"", ":", "position", "[", "0", "]", ",", "\"column\"", ":", "position", "[", "2", "]", "}", ";", "}" ]
Find out the coordinates of a given TD cell in a table @method _fnTargetCoords @param {Node} nTd @returns {Object} x and y properties, for the position of the cell in the tables DOM
[ "Find", "out", "the", "coordinates", "of", "a", "given", "TD", "cell", "in", "a", "table" ]
c283370ec0f99a25db5bb7029a98b4febf8c5251
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js#L298-L309
train
S3bb1/ah-dashboard-plugin
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js
function (e) { if ( e.target && e.target.nodeName.toUpperCase() == "TD" && e.target != this.s.drag.endTd ) { var coords = this._fnTargetCoords( e.target ); if ( this.c.mode == "y" && coords.x != this.s.drag.startX ) { e.target = $('tbody>tr:eq('+coords.y+')>td:eq('+this.s.drag.startX+')', this.dom.table)[0]; } if ( this.c.mode == "x" && coords.y != this.s.drag.startY ) { e.target = $('tbody>tr:eq('+this.s.drag.startY+')>td:eq('+coords.x+')', this.dom.table)[0]; } if ( this.c.mode == "either") { if(coords.x != this.s.drag.startX ) { e.target = $('tbody>tr:eq('+this.s.drag.startY+')>td:eq('+coords.x+')', this.dom.table)[0]; } else if ( coords.y != this.s.drag.startY ) { e.target = $('tbody>tr:eq('+coords.y+')>td:eq('+this.s.drag.startX+')', this.dom.table)[0]; } } // update coords if ( this.c.mode !== "both" ) { coords = this._fnTargetCoords( e.target ); } var drag = this.s.drag; drag.endTd = e.target; if ( coords.y >= this.s.drag.startY ) { this._fnUpdateBorder( drag.startTd, drag.endTd ); } else { this._fnUpdateBorder( drag.endTd, drag.startTd ); } this._fnFillerPosition( e.target ); } /* Update the screen information so we can perform scrolling */ this.s.screen.y = e.pageY; this.s.screen.scrollTop = $(document).scrollTop(); if ( this.s.dt.oScroll.sY !== "" ) { this.s.scroller.scrollTop = $(this.s.dt.nTable.parentNode).scrollTop(); this.s.scroller.top = $(this.s.dt.nTable.parentNode).offset().top; this.s.scroller.bottom = this.s.scroller.top + $(this.s.dt.nTable.parentNode).height(); } }
javascript
function (e) { if ( e.target && e.target.nodeName.toUpperCase() == "TD" && e.target != this.s.drag.endTd ) { var coords = this._fnTargetCoords( e.target ); if ( this.c.mode == "y" && coords.x != this.s.drag.startX ) { e.target = $('tbody>tr:eq('+coords.y+')>td:eq('+this.s.drag.startX+')', this.dom.table)[0]; } if ( this.c.mode == "x" && coords.y != this.s.drag.startY ) { e.target = $('tbody>tr:eq('+this.s.drag.startY+')>td:eq('+coords.x+')', this.dom.table)[0]; } if ( this.c.mode == "either") { if(coords.x != this.s.drag.startX ) { e.target = $('tbody>tr:eq('+this.s.drag.startY+')>td:eq('+coords.x+')', this.dom.table)[0]; } else if ( coords.y != this.s.drag.startY ) { e.target = $('tbody>tr:eq('+coords.y+')>td:eq('+this.s.drag.startX+')', this.dom.table)[0]; } } // update coords if ( this.c.mode !== "both" ) { coords = this._fnTargetCoords( e.target ); } var drag = this.s.drag; drag.endTd = e.target; if ( coords.y >= this.s.drag.startY ) { this._fnUpdateBorder( drag.startTd, drag.endTd ); } else { this._fnUpdateBorder( drag.endTd, drag.startTd ); } this._fnFillerPosition( e.target ); } /* Update the screen information so we can perform scrolling */ this.s.screen.y = e.pageY; this.s.screen.scrollTop = $(document).scrollTop(); if ( this.s.dt.oScroll.sY !== "" ) { this.s.scroller.scrollTop = $(this.s.dt.nTable.parentNode).scrollTop(); this.s.scroller.top = $(this.s.dt.nTable.parentNode).offset().top; this.s.scroller.bottom = this.s.scroller.top + $(this.s.dt.nTable.parentNode).height(); } }
[ "function", "(", "e", ")", "{", "if", "(", "e", ".", "target", "&&", "e", ".", "target", ".", "nodeName", ".", "toUpperCase", "(", ")", "==", "\"TD\"", "&&", "e", ".", "target", "!=", "this", ".", "s", ".", "drag", ".", "endTd", ")", "{", "var", "coords", "=", "this", ".", "_fnTargetCoords", "(", "e", ".", "target", ")", ";", "if", "(", "this", ".", "c", ".", "mode", "==", "\"y\"", "&&", "coords", ".", "x", "!=", "this", ".", "s", ".", "drag", ".", "startX", ")", "{", "e", ".", "target", "=", "$", "(", "'tbody>tr:eq('", "+", "coords", ".", "y", "+", "')>td:eq('", "+", "this", ".", "s", ".", "drag", ".", "startX", "+", "')'", ",", "this", ".", "dom", ".", "table", ")", "[", "0", "]", ";", "}", "if", "(", "this", ".", "c", ".", "mode", "==", "\"x\"", "&&", "coords", ".", "y", "!=", "this", ".", "s", ".", "drag", ".", "startY", ")", "{", "e", ".", "target", "=", "$", "(", "'tbody>tr:eq('", "+", "this", ".", "s", ".", "drag", ".", "startY", "+", "')>td:eq('", "+", "coords", ".", "x", "+", "')'", ",", "this", ".", "dom", ".", "table", ")", "[", "0", "]", ";", "}", "if", "(", "this", ".", "c", ".", "mode", "==", "\"either\"", ")", "{", "if", "(", "coords", ".", "x", "!=", "this", ".", "s", ".", "drag", ".", "startX", ")", "{", "e", ".", "target", "=", "$", "(", "'tbody>tr:eq('", "+", "this", ".", "s", ".", "drag", ".", "startY", "+", "')>td:eq('", "+", "coords", ".", "x", "+", "')'", ",", "this", ".", "dom", ".", "table", ")", "[", "0", "]", ";", "}", "else", "if", "(", "coords", ".", "y", "!=", "this", ".", "s", ".", "drag", ".", "startY", ")", "{", "e", ".", "target", "=", "$", "(", "'tbody>tr:eq('", "+", "coords", ".", "y", "+", "')>td:eq('", "+", "this", ".", "s", ".", "drag", ".", "startX", "+", "')'", ",", "this", ".", "dom", ".", "table", ")", "[", "0", "]", ";", "}", "}", "if", "(", "this", ".", "c", ".", "mode", "!==", "\"both\"", ")", "{", "coords", "=", "this", ".", "_fnTargetCoords", "(", "e", ".", "target", ")", ";", "}", "var", "drag", "=", "this", ".", "s", ".", "drag", ";", "drag", ".", "endTd", "=", "e", ".", "target", ";", "if", "(", "coords", ".", "y", ">=", "this", ".", "s", ".", "drag", ".", "startY", ")", "{", "this", ".", "_fnUpdateBorder", "(", "drag", ".", "startTd", ",", "drag", ".", "endTd", ")", ";", "}", "else", "{", "this", ".", "_fnUpdateBorder", "(", "drag", ".", "endTd", ",", "drag", ".", "startTd", ")", ";", "}", "this", ".", "_fnFillerPosition", "(", "e", ".", "target", ")", ";", "}", "this", ".", "s", ".", "screen", ".", "y", "=", "e", ".", "pageY", ";", "this", ".", "s", ".", "screen", ".", "scrollTop", "=", "$", "(", "document", ")", ".", "scrollTop", "(", ")", ";", "if", "(", "this", ".", "s", ".", "dt", ".", "oScroll", ".", "sY", "!==", "\"\"", ")", "{", "this", ".", "s", ".", "scroller", ".", "scrollTop", "=", "$", "(", "this", ".", "s", ".", "dt", ".", "nTable", ".", "parentNode", ")", ".", "scrollTop", "(", ")", ";", "this", ".", "s", ".", "scroller", ".", "top", "=", "$", "(", "this", ".", "s", ".", "dt", ".", "nTable", ".", "parentNode", ")", ".", "offset", "(", ")", ".", "top", ";", "this", ".", "s", ".", "scroller", ".", "bottom", "=", "this", ".", "s", ".", "scroller", ".", "top", "+", "$", "(", "this", ".", "s", ".", "dt", ".", "nTable", ".", "parentNode", ")", ".", "height", "(", ")", ";", "}", "}" ]
Mouse move event handler for during a move. See if we want to update the display based on the new cursor position @method _fnFillerDragMove @param {Object} e Event object @returns void
[ "Mouse", "move", "event", "handler", "for", "during", "a", "move", ".", "See", "if", "we", "want", "to", "update", "the", "display", "based", "on", "the", "new", "cursor", "position" ]
c283370ec0f99a25db5bb7029a98b4febf8c5251
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js#L477-L531
train
S3bb1/ah-dashboard-plugin
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js
function (e) { var filler = this.dom.filler; /* Don't display automatically when dragging */ if ( this.s.drag.dragging) { return; } /* Check that we are allowed to AutoFill this column or not */ var nTd = (e.target.nodeName.toLowerCase() == 'td') ? e.target : $(e.target).parents('td')[0]; var iX = this._fnTargetCoords(nTd).column; if ( !this.s.columns[iX].enable ) { filler.style.display = "none"; return; } if (e.type == 'mouseover') { this.dom.currentTarget = nTd; this._fnFillerPosition( nTd ); filler.style.display = "block"; } else if ( !e.relatedTarget || !e.relatedTarget.className.match(/AutoFill/) ) { filler.style.display = "none"; } }
javascript
function (e) { var filler = this.dom.filler; /* Don't display automatically when dragging */ if ( this.s.drag.dragging) { return; } /* Check that we are allowed to AutoFill this column or not */ var nTd = (e.target.nodeName.toLowerCase() == 'td') ? e.target : $(e.target).parents('td')[0]; var iX = this._fnTargetCoords(nTd).column; if ( !this.s.columns[iX].enable ) { filler.style.display = "none"; return; } if (e.type == 'mouseover') { this.dom.currentTarget = nTd; this._fnFillerPosition( nTd ); filler.style.display = "block"; } else if ( !e.relatedTarget || !e.relatedTarget.className.match(/AutoFill/) ) { filler.style.display = "none"; } }
[ "function", "(", "e", ")", "{", "var", "filler", "=", "this", ".", "dom", ".", "filler", ";", "if", "(", "this", ".", "s", ".", "drag", ".", "dragging", ")", "{", "return", ";", "}", "var", "nTd", "=", "(", "e", ".", "target", ".", "nodeName", ".", "toLowerCase", "(", ")", "==", "'td'", ")", "?", "e", ".", "target", ":", "$", "(", "e", ".", "target", ")", ".", "parents", "(", "'td'", ")", "[", "0", "]", ";", "var", "iX", "=", "this", ".", "_fnTargetCoords", "(", "nTd", ")", ".", "column", ";", "if", "(", "!", "this", ".", "s", ".", "columns", "[", "iX", "]", ".", "enable", ")", "{", "filler", ".", "style", ".", "display", "=", "\"none\"", ";", "return", ";", "}", "if", "(", "e", ".", "type", "==", "'mouseover'", ")", "{", "this", ".", "dom", ".", "currentTarget", "=", "nTd", ";", "this", ".", "_fnFillerPosition", "(", "nTd", ")", ";", "filler", ".", "style", ".", "display", "=", "\"block\"", ";", "}", "else", "if", "(", "!", "e", ".", "relatedTarget", "||", "!", "e", ".", "relatedTarget", ".", "className", ".", "match", "(", "/", "AutoFill", "/", ")", ")", "{", "filler", ".", "style", ".", "display", "=", "\"none\"", ";", "}", "}" ]
Display the drag handle on mouse over cell @method _fnFillerDisplay @param {Object} e Event object @returns void
[ "Display", "the", "drag", "handle", "on", "mouse", "over", "cell" ]
c283370ec0f99a25db5bb7029a98b4febf8c5251
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js#L658-L688
train
S3bb1/ah-dashboard-plugin
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js
function ( nTd ) { var offset = $(nTd).offset(); var filler = this.dom.filler; filler.style.top = (offset.top - (this.s.filler.height / 2)-1 + $(nTd).outerHeight())+"px"; filler.style.left = (offset.left - (this.s.filler.width / 2)-1 + $(nTd).outerWidth())+"px"; }
javascript
function ( nTd ) { var offset = $(nTd).offset(); var filler = this.dom.filler; filler.style.top = (offset.top - (this.s.filler.height / 2)-1 + $(nTd).outerHeight())+"px"; filler.style.left = (offset.left - (this.s.filler.width / 2)-1 + $(nTd).outerWidth())+"px"; }
[ "function", "(", "nTd", ")", "{", "var", "offset", "=", "$", "(", "nTd", ")", ".", "offset", "(", ")", ";", "var", "filler", "=", "this", ".", "dom", ".", "filler", ";", "filler", ".", "style", ".", "top", "=", "(", "offset", ".", "top", "-", "(", "this", ".", "s", ".", "filler", ".", "height", "/", "2", ")", "-", "1", "+", "$", "(", "nTd", ")", ".", "outerHeight", "(", ")", ")", "+", "\"px\"", ";", "filler", ".", "style", ".", "left", "=", "(", "offset", ".", "left", "-", "(", "this", ".", "s", ".", "filler", ".", "width", "/", "2", ")", "-", "1", "+", "$", "(", "nTd", ")", ".", "outerWidth", "(", ")", ")", "+", "\"px\"", ";", "}" ]
Position the filler icon over a cell @method _fnFillerPosition @param {Node} nTd Cell to position filler icon over @returns void
[ "Position", "the", "filler", "icon", "over", "a", "cell" ]
c283370ec0f99a25db5bb7029a98b4febf8c5251
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js#L697-L703
train
S3bb1/ah-dashboard-plugin
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js
function ( cell, val ) { var table = $(cell).parents('table'); if ( DataTable.Api ) { // 1.10 table.DataTable().cell( cell ).data( val ); } else { // 1.9 var dt = table.dataTable(); var pos = dt.fnGetPosition( cell ); dt.fnUpdate( val, pos[0], pos[2], false ); } }
javascript
function ( cell, val ) { var table = $(cell).parents('table'); if ( DataTable.Api ) { // 1.10 table.DataTable().cell( cell ).data( val ); } else { // 1.9 var dt = table.dataTable(); var pos = dt.fnGetPosition( cell ); dt.fnUpdate( val, pos[0], pos[2], false ); } }
[ "function", "(", "cell", ",", "val", ")", "{", "var", "table", "=", "$", "(", "cell", ")", ".", "parents", "(", "'table'", ")", ";", "if", "(", "DataTable", ".", "Api", ")", "{", "table", ".", "DataTable", "(", ")", ".", "cell", "(", "cell", ")", ".", "data", "(", "val", ")", ";", "}", "else", "{", "var", "dt", "=", "table", ".", "dataTable", "(", ")", ";", "var", "pos", "=", "dt", ".", "fnGetPosition", "(", "cell", ")", ";", "dt", ".", "fnUpdate", "(", "val", ",", "pos", "[", "0", "]", ",", "pos", "[", "2", "]", ",", "false", ")", ";", "}", "}" ]
Cell write function Default function will simply write to the HTML and tell the DataTable to update. @type {function} @param {node} cell `th` / `td` element to write the value to @return {string} Data two write
[ "Cell", "write", "function" ]
c283370ec0f99a25db5bb7029a98b4febf8c5251
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js#L792-L804
train
S3bb1/ah-dashboard-plugin
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js
function ( cell, read, last, i, x, y ) { // Increment a number if it is found var re = /(\-?\d+)/; var match = this.increment && last ? last.match(re) : null; if ( match ) { return last.replace( re, parseInt(match[1],10) + (x<0 || y<0 ? -1 : 1) ); } return last === undefined ? read : last; }
javascript
function ( cell, read, last, i, x, y ) { // Increment a number if it is found var re = /(\-?\d+)/; var match = this.increment && last ? last.match(re) : null; if ( match ) { return last.replace( re, parseInt(match[1],10) + (x<0 || y<0 ? -1 : 1) ); } return last === undefined ? read : last; }
[ "function", "(", "cell", ",", "read", ",", "last", ",", "i", ",", "x", ",", "y", ")", "{", "var", "re", "=", "/", "(\\-?\\d+)", "/", ";", "var", "match", "=", "this", ".", "increment", "&&", "last", "?", "last", ".", "match", "(", "re", ")", ":", "null", ";", "if", "(", "match", ")", "{", "return", "last", ".", "replace", "(", "re", ",", "parseInt", "(", "match", "[", "1", "]", ",", "10", ")", "+", "(", "x", "<", "0", "||", "y", "<", "0", "?", "-", "1", ":", "1", ")", ")", ";", "}", "return", "last", "===", "undefined", "?", "read", ":", "last", ";", "}" ]
Step function. This provides the ability to customise how the values are incremented. @param {node} cell `th` / `td` element that is being operated upon @param {string} read Cell value from `read` function @param {string} last Value of the previous cell @param {integer} i Loop counter @param {integer} x Cell x-position in the current auto-fill. The starting cell is coordinate 0 regardless of its physical position in the DataTable. @param {integer} y Cell y-position in the current auto-fill. The starting cell is coordinate 0 regardless of its physical position in the DataTable. @return {string} Value to write
[ "Step", "function", ".", "This", "provides", "the", "ability", "to", "customise", "how", "the", "values", "are", "incremented", "." ]
c283370ec0f99a25db5bb7029a98b4febf8c5251
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/AutoFill/js/dataTables.autoFill.js#L822-L832
train
express-bem/express-bem
lib/util.js
fulfillName
function fulfillName (name, ext, mask, lang) { var shortname; var params; // support hash with params as first function param if (isPlainObject(name)) { params = name; name = params.name; ext = params.ext; mask = params.mask; lang = params.lang; } shortname = basename(name); if (mask) { name = join(name, unmaskName(shortname, mask, lang)); } var curext = extname(name); if (curext) { return name; } // prepend dot to extension if (ext[0] !== '.') { ext = '.' + ext; } return join(name, shortname + ext); }
javascript
function fulfillName (name, ext, mask, lang) { var shortname; var params; // support hash with params as first function param if (isPlainObject(name)) { params = name; name = params.name; ext = params.ext; mask = params.mask; lang = params.lang; } shortname = basename(name); if (mask) { name = join(name, unmaskName(shortname, mask, lang)); } var curext = extname(name); if (curext) { return name; } // prepend dot to extension if (ext[0] !== '.') { ext = '.' + ext; } return join(name, shortname + ext); }
[ "function", "fulfillName", "(", "name", ",", "ext", ",", "mask", ",", "lang", ")", "{", "var", "shortname", ";", "var", "params", ";", "if", "(", "isPlainObject", "(", "name", ")", ")", "{", "params", "=", "name", ";", "name", "=", "params", ".", "name", ";", "ext", "=", "params", ".", "ext", ";", "mask", "=", "params", ".", "mask", ";", "lang", "=", "params", ".", "lang", ";", "}", "shortname", "=", "basename", "(", "name", ")", ";", "if", "(", "mask", ")", "{", "name", "=", "join", "(", "name", ",", "unmaskName", "(", "shortname", ",", "mask", ",", "lang", ")", ")", ";", "}", "var", "curext", "=", "extname", "(", "name", ")", ";", "if", "(", "curext", ")", "{", "return", "name", ";", "}", "if", "(", "ext", "[", "0", "]", "!==", "'.'", ")", "{", "ext", "=", "'.'", "+", "ext", ";", "}", "return", "join", "(", "name", ",", "shortname", "+", "ext", ")", ";", "}" ]
Appends filename with extension to path @param {String|Object} name file name or hash with all function params @param {String} ext extension if not exists @param {String} [mask] @returns {String}
[ "Appends", "filename", "with", "extension", "to", "path" ]
6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c
https://github.com/express-bem/express-bem/blob/6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c/lib/util.js#L116-L146
train
express-bem/express-bem
lib/util.js
unmaskName
function unmaskName (name, mask, lang) { return mask .replace(/\?/g, name) .replace(/\{lang\}/g, lang); }
javascript
function unmaskName (name, mask, lang) { return mask .replace(/\?/g, name) .replace(/\{lang\}/g, lang); }
[ "function", "unmaskName", "(", "name", ",", "mask", ",", "lang", ")", "{", "return", "mask", ".", "replace", "(", "/", "\\?", "/", "g", ",", "name", ")", ".", "replace", "(", "/", "\\{lang\\}", "/", "g", ",", "lang", ")", ";", "}" ]
Unmask name. E.g., for name "index" will replace "_?.js" to "_index.js". @param {String} name @returns {String}
[ "Unmask", "name", ".", "E", ".", "g", ".", "for", "name", "index", "will", "replace", "_?", ".", "js", "to", "_index", ".", "js", "." ]
6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c
https://github.com/express-bem/express-bem/blob/6ea49e5ecdd8e949dd5051ecc5762e40cbcead9c/lib/util.js#L153-L157
train
chrisJohn404/ljswitchboard-ljm_device_curator
lib/file_system_operations.js
createReaddirBundle
function createReaddirBundle(options) { return { 'changeDir': false, 'pathProvided': options.pathProvided, 'path': options.path, 'readdirPath': options.path, 'cwd': '', 'startingDir': '', 'fileNames': [], 'files': [], 'noFilesOnCard': false, 'isError': false, 'errorStep': '', 'error': undefined, 'errorCode': 0, }; }
javascript
function createReaddirBundle(options) { return { 'changeDir': false, 'pathProvided': options.pathProvided, 'path': options.path, 'readdirPath': options.path, 'cwd': '', 'startingDir': '', 'fileNames': [], 'files': [], 'noFilesOnCard': false, 'isError': false, 'errorStep': '', 'error': undefined, 'errorCode': 0, }; }
[ "function", "createReaddirBundle", "(", "options", ")", "{", "return", "{", "'changeDir'", ":", "false", ",", "'pathProvided'", ":", "options", ".", "pathProvided", ",", "'path'", ":", "options", ".", "path", ",", "'readdirPath'", ":", "options", ".", "path", ",", "'cwd'", ":", "''", ",", "'startingDir'", ":", "''", ",", "'fileNames'", ":", "[", "]", ",", "'files'", ":", "[", "]", ",", "'noFilesOnCard'", ":", "false", ",", "'isError'", ":", "false", ",", "'errorStep'", ":", "''", ",", "'error'", ":", "undefined", ",", "'errorCode'", ":", "0", ",", "}", ";", "}" ]
Define object for "readdir" operation.
[ "Define", "object", "for", "readdir", "operation", "." ]
36cb25645dfa0a68e906d5ec43e5514391947257
https://github.com/chrisJohn404/ljswitchboard-ljm_device_curator/blob/36cb25645dfa0a68e906d5ec43e5514391947257/lib/file_system_operations.js#L200-L216
train
stryju/grunt-bushcaster
tasks/bushcaster.js
forEachFilename
function forEachFilename( files, callback ) { files.forEach( function ( file ) { file.src.forEach( function ( src ) { if ( ! grunt.file.exists( src ) ) { grunt.verbose.writeln( 'source file "' + src + '" not found' ); return false; } if ( grunt.file.isDir( src ) ) { grunt.verbose.writeln( 'source file "' + src + '" seems to be a directory' ); return false; } var filename = path.relative( file.orig.cwd, src ); callback( src, filename, file.dest, file.orig.cwd ); }); }); }
javascript
function forEachFilename( files, callback ) { files.forEach( function ( file ) { file.src.forEach( function ( src ) { if ( ! grunt.file.exists( src ) ) { grunt.verbose.writeln( 'source file "' + src + '" not found' ); return false; } if ( grunt.file.isDir( src ) ) { grunt.verbose.writeln( 'source file "' + src + '" seems to be a directory' ); return false; } var filename = path.relative( file.orig.cwd, src ); callback( src, filename, file.dest, file.orig.cwd ); }); }); }
[ "function", "forEachFilename", "(", "files", ",", "callback", ")", "{", "files", ".", "forEach", "(", "function", "(", "file", ")", "{", "file", ".", "src", ".", "forEach", "(", "function", "(", "src", ")", "{", "if", "(", "!", "grunt", ".", "file", ".", "exists", "(", "src", ")", ")", "{", "grunt", ".", "verbose", ".", "writeln", "(", "'source file \"'", "+", "src", "+", "'\" not found'", ")", ";", "return", "false", ";", "}", "if", "(", "grunt", ".", "file", ".", "isDir", "(", "src", ")", ")", "{", "grunt", ".", "verbose", ".", "writeln", "(", "'source file \"'", "+", "src", "+", "'\" seems to be a directory'", ")", ";", "return", "false", ";", "}", "var", "filename", "=", "path", ".", "relative", "(", "file", ".", "orig", ".", "cwd", ",", "src", ")", ";", "callback", "(", "src", ",", "filename", ",", "file", ".", "dest", ",", "file", ".", "orig", ".", "cwd", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
keeping it DRY
[ "keeping", "it", "DRY" ]
b6b53f31fcfc00edbd3b4239e409e59916e9e84e
https://github.com/stryju/grunt-bushcaster/blob/b6b53f31fcfc00edbd3b4239e409e59916e9e84e/tasks/bushcaster.js#L27-L45
train
3vot/3vot-salesforce-proxy
routes/login.js
password
function password(req, res, test) { var options = { grant_type: "password", client_id: process.env.SALESFORCE_CLIENT_ID, client_secret: process.env.SALESFORCE_CLIENT_SECRET, username: req.query.username || req.body.username || process.env.SALESFORCE_USERNAME, password: req.query.password || req.body.password || process.env.SALESFORCE_PASSWORD, } var protocol = "https://"; if(test === true || req.test) protocol = "http://"; //for testing var loginServer = req.body.login_server || req.query.login_server || "login.salesforce.com"; var url = protocol + loginServer + "/services/oauth2/token"; var r = request.post(url) .type("application/x-www-form-urlencoded") .send(options) .on("error", function(err){ return onError(res, err); }) .end(function(sfRes){ if(sfRes.error) return onError(res, sfRes.error + " " + JSON.stringify(sfRes.body) ); req.session.salesforce = JSON.stringify( sfRes.body ); if (process.env.NODE_ENV === 'development') router.session = req.session.salesforce; res.redirect( req.query.app_url || process.env.SALESFORCE_FINAL_URL || "/login/whoami" ) }) }
javascript
function password(req, res, test) { var options = { grant_type: "password", client_id: process.env.SALESFORCE_CLIENT_ID, client_secret: process.env.SALESFORCE_CLIENT_SECRET, username: req.query.username || req.body.username || process.env.SALESFORCE_USERNAME, password: req.query.password || req.body.password || process.env.SALESFORCE_PASSWORD, } var protocol = "https://"; if(test === true || req.test) protocol = "http://"; //for testing var loginServer = req.body.login_server || req.query.login_server || "login.salesforce.com"; var url = protocol + loginServer + "/services/oauth2/token"; var r = request.post(url) .type("application/x-www-form-urlencoded") .send(options) .on("error", function(err){ return onError(res, err); }) .end(function(sfRes){ if(sfRes.error) return onError(res, sfRes.error + " " + JSON.stringify(sfRes.body) ); req.session.salesforce = JSON.stringify( sfRes.body ); if (process.env.NODE_ENV === 'development') router.session = req.session.salesforce; res.redirect( req.query.app_url || process.env.SALESFORCE_FINAL_URL || "/login/whoami" ) }) }
[ "function", "password", "(", "req", ",", "res", ",", "test", ")", "{", "var", "options", "=", "{", "grant_type", ":", "\"password\"", ",", "client_id", ":", "process", ".", "env", ".", "SALESFORCE_CLIENT_ID", ",", "client_secret", ":", "process", ".", "env", ".", "SALESFORCE_CLIENT_SECRET", ",", "username", ":", "req", ".", "query", ".", "username", "||", "req", ".", "body", ".", "username", "||", "process", ".", "env", ".", "SALESFORCE_USERNAME", ",", "password", ":", "req", ".", "query", ".", "password", "||", "req", ".", "body", ".", "password", "||", "process", ".", "env", ".", "SALESFORCE_PASSWORD", ",", "}", "var", "protocol", "=", "\"https://\"", ";", "if", "(", "test", "===", "true", "||", "req", ".", "test", ")", "protocol", "=", "\"http://\"", ";", "var", "loginServer", "=", "req", ".", "body", ".", "login_server", "||", "req", ".", "query", ".", "login_server", "||", "\"login.salesforce.com\"", ";", "var", "url", "=", "protocol", "+", "loginServer", "+", "\"/services/oauth2/token\"", ";", "var", "r", "=", "request", ".", "post", "(", "url", ")", ".", "type", "(", "\"application/x-www-form-urlencoded\"", ")", ".", "send", "(", "options", ")", ".", "on", "(", "\"error\"", ",", "function", "(", "err", ")", "{", "return", "onError", "(", "res", ",", "err", ")", ";", "}", ")", ".", "end", "(", "function", "(", "sfRes", ")", "{", "if", "(", "sfRes", ".", "error", ")", "return", "onError", "(", "res", ",", "sfRes", ".", "error", "+", "\" \"", "+", "JSON", ".", "stringify", "(", "sfRes", ".", "body", ")", ")", ";", "req", ".", "session", ".", "salesforce", "=", "JSON", ".", "stringify", "(", "sfRes", ".", "body", ")", ";", "if", "(", "process", ".", "env", ".", "NODE_ENV", "===", "'development'", ")", "router", ".", "session", "=", "req", ".", "session", ".", "salesforce", ";", "res", ".", "redirect", "(", "req", ".", "query", ".", "app_url", "||", "process", ".", "env", ".", "SALESFORCE_FINAL_URL", "||", "\"/login/whoami\"", ")", "}", ")", "}" ]
Retrieves the Salesforce Auth and adds it to the session
[ "Retrieves", "the", "Salesforce", "Auth", "and", "adds", "it", "to", "the", "session" ]
33d57379217600c5bd684918d624ce52c83b875e
https://github.com/3vot/3vot-salesforce-proxy/blob/33d57379217600c5bd684918d624ce52c83b875e/routes/login.js#L60-L85
train
3vot/3vot-salesforce-proxy
routes/login.js
login
function login(req, res, test) { var protocol = "https://"; if(test === true || req.test) protocol = "http://"; //for testing var loginServer = req.query.login_server || "login.salesforce.com"; var url = protocol + loginServer + "/services/oauth2/authorize"; var state = JSON.stringify({ loginServer: loginServer, appUrl: req.query.app_url || process.env.SALESFORCE_FINAL_URL || "/login/whoami", profile: req.query.profile }); var options = { response_type: "code", client_id: process.env.SALESFORCE_CLIENT_ID, redirect_uri: process.env.SALESFORCE_REDIRECT_URL, state: state } return res.redirect(url + "?" + querystring.stringify(options) ); }
javascript
function login(req, res, test) { var protocol = "https://"; if(test === true || req.test) protocol = "http://"; //for testing var loginServer = req.query.login_server || "login.salesforce.com"; var url = protocol + loginServer + "/services/oauth2/authorize"; var state = JSON.stringify({ loginServer: loginServer, appUrl: req.query.app_url || process.env.SALESFORCE_FINAL_URL || "/login/whoami", profile: req.query.profile }); var options = { response_type: "code", client_id: process.env.SALESFORCE_CLIENT_ID, redirect_uri: process.env.SALESFORCE_REDIRECT_URL, state: state } return res.redirect(url + "?" + querystring.stringify(options) ); }
[ "function", "login", "(", "req", ",", "res", ",", "test", ")", "{", "var", "protocol", "=", "\"https://\"", ";", "if", "(", "test", "===", "true", "||", "req", ".", "test", ")", "protocol", "=", "\"http://\"", ";", "var", "loginServer", "=", "req", ".", "query", ".", "login_server", "||", "\"login.salesforce.com\"", ";", "var", "url", "=", "protocol", "+", "loginServer", "+", "\"/services/oauth2/authorize\"", ";", "var", "state", "=", "JSON", ".", "stringify", "(", "{", "loginServer", ":", "loginServer", ",", "appUrl", ":", "req", ".", "query", ".", "app_url", "||", "process", ".", "env", ".", "SALESFORCE_FINAL_URL", "||", "\"/login/whoami\"", ",", "profile", ":", "req", ".", "query", ".", "profile", "}", ")", ";", "var", "options", "=", "{", "response_type", ":", "\"code\"", ",", "client_id", ":", "process", ".", "env", ".", "SALESFORCE_CLIENT_ID", ",", "redirect_uri", ":", "process", ".", "env", ".", "SALESFORCE_REDIRECT_URL", ",", "state", ":", "state", "}", "return", "res", ".", "redirect", "(", "url", "+", "\"?\"", "+", "querystring", ".", "stringify", "(", "options", ")", ")", ";", "}" ]
Starts the Salesforce Server Dance Auth Leg 1
[ "Starts", "the", "Salesforce", "Server", "Dance", "Auth", "Leg", "1" ]
33d57379217600c5bd684918d624ce52c83b875e
https://github.com/3vot/3vot-salesforce-proxy/blob/33d57379217600c5bd684918d624ce52c83b875e/routes/login.js#L88-L109
train
3vot/3vot-salesforce-proxy
routes/login.js
loginCallback
function loginCallback(req, res, test) { var state = JSON.parse(req.query.state); console.dir( state ); var protocol = "https://"; if(test === true || req.test) protocol = "http://"; //for testing var url = protocol + state.loginServer + "/services/oauth2/token"; var options = { code: req.query.code, grant_type: 'authorization_code', client_id: process.env.SALESFORCE_CLIENT_ID, redirect_uri: process.env.SALESFORCE_REDIRECT_URL, client_secret: process.env.SALESFORCE_CLIENT_SECRET } request.post(url) .type("application/x-www-form-urlencoded") .send(options) .on("error", function(err){ return onError(res,err); }) .end(function(sfRes){ if(sfRes.error) return onError(res, sfRes.error); console.dir( sfRes.body ) req.session.salesforce = JSON.stringify( sfRes.body ); res.redirect(state.appUrl) }) }
javascript
function loginCallback(req, res, test) { var state = JSON.parse(req.query.state); console.dir( state ); var protocol = "https://"; if(test === true || req.test) protocol = "http://"; //for testing var url = protocol + state.loginServer + "/services/oauth2/token"; var options = { code: req.query.code, grant_type: 'authorization_code', client_id: process.env.SALESFORCE_CLIENT_ID, redirect_uri: process.env.SALESFORCE_REDIRECT_URL, client_secret: process.env.SALESFORCE_CLIENT_SECRET } request.post(url) .type("application/x-www-form-urlencoded") .send(options) .on("error", function(err){ return onError(res,err); }) .end(function(sfRes){ if(sfRes.error) return onError(res, sfRes.error); console.dir( sfRes.body ) req.session.salesforce = JSON.stringify( sfRes.body ); res.redirect(state.appUrl) }) }
[ "function", "loginCallback", "(", "req", ",", "res", ",", "test", ")", "{", "var", "state", "=", "JSON", ".", "parse", "(", "req", ".", "query", ".", "state", ")", ";", "console", ".", "dir", "(", "state", ")", ";", "var", "protocol", "=", "\"https://\"", ";", "if", "(", "test", "===", "true", "||", "req", ".", "test", ")", "protocol", "=", "\"http://\"", ";", "var", "url", "=", "protocol", "+", "state", ".", "loginServer", "+", "\"/services/oauth2/token\"", ";", "var", "options", "=", "{", "code", ":", "req", ".", "query", ".", "code", ",", "grant_type", ":", "'authorization_code'", ",", "client_id", ":", "process", ".", "env", ".", "SALESFORCE_CLIENT_ID", ",", "redirect_uri", ":", "process", ".", "env", ".", "SALESFORCE_REDIRECT_URL", ",", "client_secret", ":", "process", ".", "env", ".", "SALESFORCE_CLIENT_SECRET", "}", "request", ".", "post", "(", "url", ")", ".", "type", "(", "\"application/x-www-form-urlencoded\"", ")", ".", "send", "(", "options", ")", ".", "on", "(", "\"error\"", ",", "function", "(", "err", ")", "{", "return", "onError", "(", "res", ",", "err", ")", ";", "}", ")", ".", "end", "(", "function", "(", "sfRes", ")", "{", "if", "(", "sfRes", ".", "error", ")", "return", "onError", "(", "res", ",", "sfRes", ".", "error", ")", ";", "console", ".", "dir", "(", "sfRes", ".", "body", ")", "req", ".", "session", ".", "salesforce", "=", "JSON", ".", "stringify", "(", "sfRes", ".", "body", ")", ";", "res", ".", "redirect", "(", "state", ".", "appUrl", ")", "}", ")", "}" ]
Callback for the Salesforce Server Dance Auth Leg 2, adds the auth token to session
[ "Callback", "for", "the", "Salesforce", "Server", "Dance", "Auth", "Leg", "2", "adds", "the", "auth", "token", "to", "session" ]
33d57379217600c5bd684918d624ce52c83b875e
https://github.com/3vot/3vot-salesforce-proxy/blob/33d57379217600c5bd684918d624ce52c83b875e/routes/login.js#L112-L138
train
desgeeko/react-goban
lib/react-goban.js
toElem
function toElem(shapes, callback) { var typeofShape; var txt = null; var k = 0; for (var i = 0; i < shapes.length; i++) { typeofShape = shapes[i].type; if (typeofShape == "text") { txt = shapes[i].txt; delete shapes[i].txt; } if (shapes[i].class) { shapes[i].className = shapes[i].class; delete shapes[i].class; } delete shapes[i].type; shapes[i].key = shapes[i].key || k++; if (callback) shapes[i].onClick = callback.bind(null, shapes[i].key); // Replace this by null for React shapes[i] = React.createElement(typeofShape, shapes[i], txt); } return shapes; }
javascript
function toElem(shapes, callback) { var typeofShape; var txt = null; var k = 0; for (var i = 0; i < shapes.length; i++) { typeofShape = shapes[i].type; if (typeofShape == "text") { txt = shapes[i].txt; delete shapes[i].txt; } if (shapes[i].class) { shapes[i].className = shapes[i].class; delete shapes[i].class; } delete shapes[i].type; shapes[i].key = shapes[i].key || k++; if (callback) shapes[i].onClick = callback.bind(null, shapes[i].key); // Replace this by null for React shapes[i] = React.createElement(typeofShape, shapes[i], txt); } return shapes; }
[ "function", "toElem", "(", "shapes", ",", "callback", ")", "{", "var", "typeofShape", ";", "var", "txt", "=", "null", ";", "var", "k", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "shapes", ".", "length", ";", "i", "++", ")", "{", "typeofShape", "=", "shapes", "[", "i", "]", ".", "type", ";", "if", "(", "typeofShape", "==", "\"text\"", ")", "{", "txt", "=", "shapes", "[", "i", "]", ".", "txt", ";", "delete", "shapes", "[", "i", "]", ".", "txt", ";", "}", "if", "(", "shapes", "[", "i", "]", ".", "class", ")", "{", "shapes", "[", "i", "]", ".", "className", "=", "shapes", "[", "i", "]", ".", "class", ";", "delete", "shapes", "[", "i", "]", ".", "class", ";", "}", "delete", "shapes", "[", "i", "]", ".", "type", ";", "shapes", "[", "i", "]", ".", "key", "=", "shapes", "[", "i", "]", ".", "key", "||", "k", "++", ";", "if", "(", "callback", ")", "shapes", "[", "i", "]", ".", "onClick", "=", "callback", ".", "bind", "(", "null", ",", "shapes", "[", "i", "]", ".", "key", ")", ";", "shapes", "[", "i", "]", "=", "React", ".", "createElement", "(", "typeofShape", ",", "shapes", "[", "i", "]", ",", "txt", ")", ";", "}", "return", "shapes", ";", "}" ]
Converts shape list into React SVG elements. @param {Array} shape list @returns {Array} React element list
[ "Converts", "shape", "list", "into", "React", "SVG", "elements", "." ]
cbe3abc49fca9e388568d42267dd2b198c7e3dd3
https://github.com/desgeeko/react-goban/blob/cbe3abc49fca9e388568d42267dd2b198c7e3dd3/lib/react-goban.js#L23-L43
train
hogart/rpg-tools
lib/inventory.js
unEquip
function unEquip (attributes, slotName) { if (!(slotName in attributes.equipped)) { throw new SlotNameError(slotName); } if (attributes.equipped[slotName]) { attributes.inventory.push(attributes.equipped[slotName]); } attributes.equipped[slotName] = null; return attributes; }
javascript
function unEquip (attributes, slotName) { if (!(slotName in attributes.equipped)) { throw new SlotNameError(slotName); } if (attributes.equipped[slotName]) { attributes.inventory.push(attributes.equipped[slotName]); } attributes.equipped[slotName] = null; return attributes; }
[ "function", "unEquip", "(", "attributes", ",", "slotName", ")", "{", "if", "(", "!", "(", "slotName", "in", "attributes", ".", "equipped", ")", ")", "{", "throw", "new", "SlotNameError", "(", "slotName", ")", ";", "}", "if", "(", "attributes", ".", "equipped", "[", "slotName", "]", ")", "{", "attributes", ".", "inventory", ".", "push", "(", "attributes", ".", "equipped", "[", "slotName", "]", ")", ";", "}", "attributes", ".", "equipped", "[", "slotName", "]", "=", "null", ";", "return", "attributes", ";", "}" ]
Unequips item from given slotName @param {Attributes} attributes which object should be operated. In Mongoose it this, in Backbone it's this.attributes @param {String} slotName
[ "Unequips", "item", "from", "given", "slotName" ]
6909e3f3c21c2fd4c9e7d82103a69f11ae7e4375
https://github.com/hogart/rpg-tools/blob/6909e3f3c21c2fd4c9e7d82103a69f11ae7e4375/lib/inventory.js#L98-L110
train