id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
39,300 |
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",
")",
"{",
"/* 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\"",
")",
";",
"}",
"/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\t * Public class variables\n\t * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */",
"this",
".",
"c",
"=",
"{",
"}",
";",
"/**\n\t * @namespace Settings object which contains customisable information for AutoFill instance\n\t */",
"this",
".",
"s",
"=",
"{",
"/**\n\t\t * @namespace Cached information about the little dragging icon (the filler)\n\t\t */",
"\"filler\"",
":",
"{",
"\"height\"",
":",
"0",
",",
"\"width\"",
":",
"0",
"}",
",",
"/**\n\t\t * @namespace Cached information about the border display\n\t\t */",
"\"border\"",
":",
"{",
"\"width\"",
":",
"2",
"}",
",",
"/**\n\t\t * @namespace Store for live information for the current drag\n\t\t */",
"\"drag\"",
":",
"{",
"\"startX\"",
":",
"-",
"1",
",",
"\"startY\"",
":",
"-",
"1",
",",
"\"startTd\"",
":",
"null",
",",
"\"endTd\"",
":",
"null",
",",
"\"dragging\"",
":",
"false",
"}",
",",
"/**\n\t\t * @namespace Data cache for information that we need for scrolling the screen when we near\n\t\t * the edges\n\t\t */",
"\"screen\"",
":",
"{",
"\"interval\"",
":",
"null",
",",
"\"y\"",
":",
"0",
",",
"\"height\"",
":",
"0",
",",
"\"scrollTop\"",
":",
"0",
"}",
",",
"/**\n\t\t * @namespace Data cache for the position of the DataTables scrolling element (when scrolling\n\t\t * is enabled)\n\t\t */",
"\"scroller\"",
":",
"{",
"\"top\"",
":",
"0",
",",
"\"bottom\"",
":",
"0",
"}",
",",
"/**\n\t\t * @namespace Information stored for each column. An array of objects\n\t\t */",
"\"columns\"",
":",
"[",
"]",
"}",
";",
"/**\n\t * @namespace Common and useful DOM elements for the class instance\n\t */",
"this",
".",
"dom",
"=",
"{",
"\"table\"",
":",
"null",
",",
"\"filler\"",
":",
"null",
",",
"\"borderTop\"",
":",
"null",
",",
"\"borderRight\"",
":",
"null",
",",
"\"borderBottom\"",
":",
"null",
",",
"\"borderLeft\"",
":",
"null",
",",
"\"currentTarget\"",
":",
"null",
"}",
";",
"/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\t * Public class methods\n\t * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */",
"/**\n\t * Retreieve the settings object from an instance\n\t * @method fnSettings\n\t * @returns {object} AutoFill settings object\n\t */",
"this",
".",
"fnSettings",
"=",
"function",
"(",
")",
"{",
"return",
"this",
".",
"s",
";",
"}",
";",
"/* Constructor logic */",
"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
|
|
39,301 |
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
|
|
39,302 |
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",
"]",
";",
"}",
"}",
"// 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",
"(",
")",
";",
"}",
"}"
] |
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
|
|
39,303 |
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",
";",
"/* 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\"",
";",
"}",
"}"
] |
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
|
|
39,304 |
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
|
|
39,305 |
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",
")",
"{",
"// 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",
")",
";",
"}",
"}"
] |
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
|
|
39,306 |
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",
")",
"{",
"// 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",
";",
"}"
] |
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
|
|
39,307 |
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",
";",
"// 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",
")",
";",
"}"
] |
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
|
39,308 |
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
|
39,309 |
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
|
39,310 |
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
|
39,311 |
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://\"",
";",
"//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\"",
")",
"}",
")",
"}"
] |
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
|
39,312 |
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://\"",
";",
"//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",
")",
")",
";",
"}"
] |
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
|
39,313 |
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://\"",
";",
"//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",
")",
"}",
")",
"}"
] |
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
|
39,314 |
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",
")",
";",
"// Replace this by null for React",
"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
|
39,315 |
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
|
39,316 |
hogart/rpg-tools
|
lib/inventory.js
|
equipFromInventory
|
function equipFromInventory (attributes, index, slotName) {
if (index >= attributes.inventory.length) {
throw new InventoryIndexError(index);
}
var item = attributes.inventory[index];
if (!slotName) {
slotName = item.slot;
}
if (!slotName) {
throw new UnequippableItemError(item.name);
}
if (!(slotName in attributes.equipped)) {
throw new SlotNameError(slotName);
}
if (item.slot !== slotName) {
throw new InvalidSlotError(item.slot, slotName);
}
if (!requirements.met(attributes, item.requirements)) {
throw new RequirementsNotMetError();
}
if (attributes.equipped[slotName]) {
unEquip(attributes, slotName);
}
attributes.inventory.splice(index, 1);
attributes.equipped[slotName] = item;
return attributes;
}
|
javascript
|
function equipFromInventory (attributes, index, slotName) {
if (index >= attributes.inventory.length) {
throw new InventoryIndexError(index);
}
var item = attributes.inventory[index];
if (!slotName) {
slotName = item.slot;
}
if (!slotName) {
throw new UnequippableItemError(item.name);
}
if (!(slotName in attributes.equipped)) {
throw new SlotNameError(slotName);
}
if (item.slot !== slotName) {
throw new InvalidSlotError(item.slot, slotName);
}
if (!requirements.met(attributes, item.requirements)) {
throw new RequirementsNotMetError();
}
if (attributes.equipped[slotName]) {
unEquip(attributes, slotName);
}
attributes.inventory.splice(index, 1);
attributes.equipped[slotName] = item;
return attributes;
}
|
[
"function",
"equipFromInventory",
"(",
"attributes",
",",
"index",
",",
"slotName",
")",
"{",
"if",
"(",
"index",
">=",
"attributes",
".",
"inventory",
".",
"length",
")",
"{",
"throw",
"new",
"InventoryIndexError",
"(",
"index",
")",
";",
"}",
"var",
"item",
"=",
"attributes",
".",
"inventory",
"[",
"index",
"]",
";",
"if",
"(",
"!",
"slotName",
")",
"{",
"slotName",
"=",
"item",
".",
"slot",
";",
"}",
"if",
"(",
"!",
"slotName",
")",
"{",
"throw",
"new",
"UnequippableItemError",
"(",
"item",
".",
"name",
")",
";",
"}",
"if",
"(",
"!",
"(",
"slotName",
"in",
"attributes",
".",
"equipped",
")",
")",
"{",
"throw",
"new",
"SlotNameError",
"(",
"slotName",
")",
";",
"}",
"if",
"(",
"item",
".",
"slot",
"!==",
"slotName",
")",
"{",
"throw",
"new",
"InvalidSlotError",
"(",
"item",
".",
"slot",
",",
"slotName",
")",
";",
"}",
"if",
"(",
"!",
"requirements",
".",
"met",
"(",
"attributes",
",",
"item",
".",
"requirements",
")",
")",
"{",
"throw",
"new",
"RequirementsNotMetError",
"(",
")",
";",
"}",
"if",
"(",
"attributes",
".",
"equipped",
"[",
"slotName",
"]",
")",
"{",
"unEquip",
"(",
"attributes",
",",
"slotName",
")",
";",
"}",
"attributes",
".",
"inventory",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"attributes",
".",
"equipped",
"[",
"slotName",
"]",
"=",
"item",
";",
"return",
"attributes",
";",
"}"
] |
Equips item which is located in inventory by given index
@param {Attributes} attributes which object should be operated.
@param {number} index inventory slot number
@param {String} slotName where to equip
|
[
"Equips",
"item",
"which",
"is",
"located",
"in",
"inventory",
"by",
"given",
"index"
] |
6909e3f3c21c2fd4c9e7d82103a69f11ae7e4375
|
https://github.com/hogart/rpg-tools/blob/6909e3f3c21c2fd4c9e7d82103a69f11ae7e4375/lib/inventory.js#L118-L153
|
39,317 |
hogart/rpg-tools
|
lib/inventory.js
|
isWearable
|
function isWearable (attributes, index) {
if (index >= attributes.inventory.length) {
throw new InventoryIndexError(index);
}
var item = attributes.inventory[index];
if (!requirements.met(attributes, item.requirements)) {
throw new RequirementsNotMetError();
}
var slotName = item.slot;
if (!slotName) {
throw new UnequippableItemError(item.name);
}
return slotName;
}
|
javascript
|
function isWearable (attributes, index) {
if (index >= attributes.inventory.length) {
throw new InventoryIndexError(index);
}
var item = attributes.inventory[index];
if (!requirements.met(attributes, item.requirements)) {
throw new RequirementsNotMetError();
}
var slotName = item.slot;
if (!slotName) {
throw new UnequippableItemError(item.name);
}
return slotName;
}
|
[
"function",
"isWearable",
"(",
"attributes",
",",
"index",
")",
"{",
"if",
"(",
"index",
">=",
"attributes",
".",
"inventory",
".",
"length",
")",
"{",
"throw",
"new",
"InventoryIndexError",
"(",
"index",
")",
";",
"}",
"var",
"item",
"=",
"attributes",
".",
"inventory",
"[",
"index",
"]",
";",
"if",
"(",
"!",
"requirements",
".",
"met",
"(",
"attributes",
",",
"item",
".",
"requirements",
")",
")",
"{",
"throw",
"new",
"RequirementsNotMetError",
"(",
")",
";",
"}",
"var",
"slotName",
"=",
"item",
".",
"slot",
";",
"if",
"(",
"!",
"slotName",
")",
"{",
"throw",
"new",
"UnequippableItemError",
"(",
"item",
".",
"name",
")",
";",
"}",
"return",
"slotName",
";",
"}"
] |
Given index of item, returns list of possible slots
@param {Attributes} attributes
@param {number} index
@return {String}
|
[
"Given",
"index",
"of",
"item",
"returns",
"list",
"of",
"possible",
"slots"
] |
6909e3f3c21c2fd4c9e7d82103a69f11ae7e4375
|
https://github.com/hogart/rpg-tools/blob/6909e3f3c21c2fd4c9e7d82103a69f11ae7e4375/lib/inventory.js#L161-L179
|
39,318 |
okunishinishi/node-mysqldesc
|
lib/describing/mysql_describer.js
|
function (database, callback) {
var s = this,
querier = s._querier;
querier.connect();
async.waterfall([
function (callback) {
querier.showTables(database, function (err, tables) {
callback(err, tables);
});
},
function (tables, callback) {
var tableNames = s._parseTableNames(tables);
async.map(tableNames, function (table, callback) {
querier.descTable(database, table, function (err, data1) {
querier.selectKeyColumnUsage(database, table, function (err, data2) {
callback(err, {
name: table,
columns: s._parseTableData(data1),
relations: s._getRelations(data2, table)
});
});
});
}, callback);
},
function (data, callback) {
var database = {};
data.forEach(function (data) {
database[data.name] = data;
});
callback(null, database);
}
], function (err, result) {
querier.disconnect();
callback(err, result);
});
return s;
}
|
javascript
|
function (database, callback) {
var s = this,
querier = s._querier;
querier.connect();
async.waterfall([
function (callback) {
querier.showTables(database, function (err, tables) {
callback(err, tables);
});
},
function (tables, callback) {
var tableNames = s._parseTableNames(tables);
async.map(tableNames, function (table, callback) {
querier.descTable(database, table, function (err, data1) {
querier.selectKeyColumnUsage(database, table, function (err, data2) {
callback(err, {
name: table,
columns: s._parseTableData(data1),
relations: s._getRelations(data2, table)
});
});
});
}, callback);
},
function (data, callback) {
var database = {};
data.forEach(function (data) {
database[data.name] = data;
});
callback(null, database);
}
], function (err, result) {
querier.disconnect();
callback(err, result);
});
return s;
}
|
[
"function",
"(",
"database",
",",
"callback",
")",
"{",
"var",
"s",
"=",
"this",
",",
"querier",
"=",
"s",
".",
"_querier",
";",
"querier",
".",
"connect",
"(",
")",
";",
"async",
".",
"waterfall",
"(",
"[",
"function",
"(",
"callback",
")",
"{",
"querier",
".",
"showTables",
"(",
"database",
",",
"function",
"(",
"err",
",",
"tables",
")",
"{",
"callback",
"(",
"err",
",",
"tables",
")",
";",
"}",
")",
";",
"}",
",",
"function",
"(",
"tables",
",",
"callback",
")",
"{",
"var",
"tableNames",
"=",
"s",
".",
"_parseTableNames",
"(",
"tables",
")",
";",
"async",
".",
"map",
"(",
"tableNames",
",",
"function",
"(",
"table",
",",
"callback",
")",
"{",
"querier",
".",
"descTable",
"(",
"database",
",",
"table",
",",
"function",
"(",
"err",
",",
"data1",
")",
"{",
"querier",
".",
"selectKeyColumnUsage",
"(",
"database",
",",
"table",
",",
"function",
"(",
"err",
",",
"data2",
")",
"{",
"callback",
"(",
"err",
",",
"{",
"name",
":",
"table",
",",
"columns",
":",
"s",
".",
"_parseTableData",
"(",
"data1",
")",
",",
"relations",
":",
"s",
".",
"_getRelations",
"(",
"data2",
",",
"table",
")",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
",",
"callback",
")",
";",
"}",
",",
"function",
"(",
"data",
",",
"callback",
")",
"{",
"var",
"database",
"=",
"{",
"}",
";",
"data",
".",
"forEach",
"(",
"function",
"(",
"data",
")",
"{",
"database",
"[",
"data",
".",
"name",
"]",
"=",
"data",
";",
"}",
")",
";",
"callback",
"(",
"null",
",",
"database",
")",
";",
"}",
"]",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"querier",
".",
"disconnect",
"(",
")",
";",
"callback",
"(",
"err",
",",
"result",
")",
";",
"}",
")",
";",
"return",
"s",
";",
"}"
] |
Describe database.
@param {string} database - Name of database.
@param {function} callback - Callback when done.
@returns {MysqlDescriber} - Returns self.
|
[
"Describe",
"database",
"."
] |
df88626bce889cb1d4f1879387a77d3a480d676a
|
https://github.com/okunishinishi/node-mysqldesc/blob/df88626bce889cb1d4f1879387a77d3a480d676a/lib/describing/mysql_describer.js#L30-L66
|
|
39,319 |
okunishinishi/node-mysqldesc
|
lib/describing/mysql_describer.js
|
function (database, table, callback) {
var s = this,
querier = s._querier;
querier.connect();
querier.descTable(database, table, function (err, data) {
querier.disconnect();
callback(err, s._parseTableData(data || {}));
});
return s;
}
|
javascript
|
function (database, table, callback) {
var s = this,
querier = s._querier;
querier.connect();
querier.descTable(database, table, function (err, data) {
querier.disconnect();
callback(err, s._parseTableData(data || {}));
});
return s;
}
|
[
"function",
"(",
"database",
",",
"table",
",",
"callback",
")",
"{",
"var",
"s",
"=",
"this",
",",
"querier",
"=",
"s",
".",
"_querier",
";",
"querier",
".",
"connect",
"(",
")",
";",
"querier",
".",
"descTable",
"(",
"database",
",",
"table",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"querier",
".",
"disconnect",
"(",
")",
";",
"callback",
"(",
"err",
",",
"s",
".",
"_parseTableData",
"(",
"data",
"||",
"{",
"}",
")",
")",
";",
"}",
")",
";",
"return",
"s",
";",
"}"
] |
Describe mysql table.
@param {string} database - Name of database.
@param {string} table - Name of table.
@param {function} callback - Callback when done.
@returns {MysqlDescriber}
|
[
"Describe",
"mysql",
"table",
"."
] |
df88626bce889cb1d4f1879387a77d3a480d676a
|
https://github.com/okunishinishi/node-mysqldesc/blob/df88626bce889cb1d4f1879387a77d3a480d676a/lib/describing/mysql_describer.js#L74-L83
|
|
39,320 |
okunishinishi/node-mysqldesc
|
lib/describing/mysql_describer.js
|
function (database, callback) {
var s = this,
querier = s._querier;
querier.connect();
async.waterfall([
function (callback) {
querier.showTables(database, function (err, tables) {
callback(err, tables);
});
},
function (tables, callback) {
var tableNames = s._parseTableNames(tables);
async.map(tableNames, function (table, callback) {
querier.selectKeyColumnUsage(database, table, function (err, data) {
callback(err, {
name: table,
keyColumnUsage: s._parseTableKeyColumnUsageData(data)
});
});
}, callback);
},
function (data, callback) {
var database = {};
data.forEach(function (data) {
database[data.name] = data.keyColumnUsage;
});
callback(null, database);
}
], function (err, result) {
querier.disconnect();
callback(err, result);
});
return s;
}
|
javascript
|
function (database, callback) {
var s = this,
querier = s._querier;
querier.connect();
async.waterfall([
function (callback) {
querier.showTables(database, function (err, tables) {
callback(err, tables);
});
},
function (tables, callback) {
var tableNames = s._parseTableNames(tables);
async.map(tableNames, function (table, callback) {
querier.selectKeyColumnUsage(database, table, function (err, data) {
callback(err, {
name: table,
keyColumnUsage: s._parseTableKeyColumnUsageData(data)
});
});
}, callback);
},
function (data, callback) {
var database = {};
data.forEach(function (data) {
database[data.name] = data.keyColumnUsage;
});
callback(null, database);
}
], function (err, result) {
querier.disconnect();
callback(err, result);
});
return s;
}
|
[
"function",
"(",
"database",
",",
"callback",
")",
"{",
"var",
"s",
"=",
"this",
",",
"querier",
"=",
"s",
".",
"_querier",
";",
"querier",
".",
"connect",
"(",
")",
";",
"async",
".",
"waterfall",
"(",
"[",
"function",
"(",
"callback",
")",
"{",
"querier",
".",
"showTables",
"(",
"database",
",",
"function",
"(",
"err",
",",
"tables",
")",
"{",
"callback",
"(",
"err",
",",
"tables",
")",
";",
"}",
")",
";",
"}",
",",
"function",
"(",
"tables",
",",
"callback",
")",
"{",
"var",
"tableNames",
"=",
"s",
".",
"_parseTableNames",
"(",
"tables",
")",
";",
"async",
".",
"map",
"(",
"tableNames",
",",
"function",
"(",
"table",
",",
"callback",
")",
"{",
"querier",
".",
"selectKeyColumnUsage",
"(",
"database",
",",
"table",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"callback",
"(",
"err",
",",
"{",
"name",
":",
"table",
",",
"keyColumnUsage",
":",
"s",
".",
"_parseTableKeyColumnUsageData",
"(",
"data",
")",
"}",
")",
";",
"}",
")",
";",
"}",
",",
"callback",
")",
";",
"}",
",",
"function",
"(",
"data",
",",
"callback",
")",
"{",
"var",
"database",
"=",
"{",
"}",
";",
"data",
".",
"forEach",
"(",
"function",
"(",
"data",
")",
"{",
"database",
"[",
"data",
".",
"name",
"]",
"=",
"data",
".",
"keyColumnUsage",
";",
"}",
")",
";",
"callback",
"(",
"null",
",",
"database",
")",
";",
"}",
"]",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"querier",
".",
"disconnect",
"(",
")",
";",
"callback",
"(",
"err",
",",
"result",
")",
";",
"}",
")",
";",
"return",
"s",
";",
"}"
] |
Describe key column usages in database.
@param {string} database - Name of database.
@param {function} callback - Callback when done.
@returns {MysqlDescriber}
|
[
"Describe",
"key",
"column",
"usages",
"in",
"database",
"."
] |
df88626bce889cb1d4f1879387a77d3a480d676a
|
https://github.com/okunishinishi/node-mysqldesc/blob/df88626bce889cb1d4f1879387a77d3a480d676a/lib/describing/mysql_describer.js#L90-L123
|
|
39,321 |
okunishinishi/node-mysqldesc
|
lib/describing/mysql_describer.js
|
function (database, table, callback) {
var s = this,
querier = s._querier;
querier.connect();
querier.selectKeyColumnUsage(database, table, function (err, data) {
querier.disconnect();
callback(err, s._parseTableKeyColumnUsageData(data));
});
return s;
}
|
javascript
|
function (database, table, callback) {
var s = this,
querier = s._querier;
querier.connect();
querier.selectKeyColumnUsage(database, table, function (err, data) {
querier.disconnect();
callback(err, s._parseTableKeyColumnUsageData(data));
});
return s;
}
|
[
"function",
"(",
"database",
",",
"table",
",",
"callback",
")",
"{",
"var",
"s",
"=",
"this",
",",
"querier",
"=",
"s",
".",
"_querier",
";",
"querier",
".",
"connect",
"(",
")",
";",
"querier",
".",
"selectKeyColumnUsage",
"(",
"database",
",",
"table",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"querier",
".",
"disconnect",
"(",
")",
";",
"callback",
"(",
"err",
",",
"s",
".",
"_parseTableKeyColumnUsageData",
"(",
"data",
")",
")",
";",
"}",
")",
";",
"return",
"s",
";",
"}"
] |
Describe key column usage for a table.
@param {string} database - Name of database.
@param {string} table - Name of table.
@param {function} callback - Callback when done.
@returns {MysqlDescriber}
|
[
"Describe",
"key",
"column",
"usage",
"for",
"a",
"table",
"."
] |
df88626bce889cb1d4f1879387a77d3a480d676a
|
https://github.com/okunishinishi/node-mysqldesc/blob/df88626bce889cb1d4f1879387a77d3a480d676a/lib/describing/mysql_describer.js#L131-L140
|
|
39,322 |
vieron/ui-docs
|
lib/doc-parser.js
|
function() {
var block_tpl_content = fs.readFileSync(
path.join(this.opts.templatePath, 'doc-block.hbs'));
this.tpl_block = this.hbs.compile(block_tpl_content.toString());
includeHelper.register(this.hbs, this);
this._postProcessDocFiles();
return this;
}
|
javascript
|
function() {
var block_tpl_content = fs.readFileSync(
path.join(this.opts.templatePath, 'doc-block.hbs'));
this.tpl_block = this.hbs.compile(block_tpl_content.toString());
includeHelper.register(this.hbs, this);
this._postProcessDocFiles();
return this;
}
|
[
"function",
"(",
")",
"{",
"var",
"block_tpl_content",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"this",
".",
"opts",
".",
"templatePath",
",",
"'doc-block.hbs'",
")",
")",
";",
"this",
".",
"tpl_block",
"=",
"this",
".",
"hbs",
".",
"compile",
"(",
"block_tpl_content",
".",
"toString",
"(",
")",
")",
";",
"includeHelper",
".",
"register",
"(",
"this",
".",
"hbs",
",",
"this",
")",
";",
"this",
".",
"_postProcessDocFiles",
"(",
")",
";",
"return",
"this",
";",
"}"
] |
ADDING NEW THINGS TO DOC BLOCKS
|
[
"ADDING",
"NEW",
"THINGS",
"TO",
"DOC",
"BLOCKS"
] |
8cf2ed4da9dc676d23170ba3612df7e1d4e15b11
|
https://github.com/vieron/ui-docs/blob/8cf2ed4da9dc676d23170ba3612df7e1d4e15b11/lib/doc-parser.js#L264-L273
|
|
39,323 |
unshiftio/beacons
|
image.js
|
Image
|
function Image() {
if (!this) return new Image();
this.url = null;
EventEmitter.call(this);
setTimeout(function timeout() {
if (this.onerror) this.on('error', this.onerror);
if (this.onload) this.on('load', this.onload);
}.bind(this));
}
|
javascript
|
function Image() {
if (!this) return new Image();
this.url = null;
EventEmitter.call(this);
setTimeout(function timeout() {
if (this.onerror) this.on('error', this.onerror);
if (this.onload) this.on('load', this.onload);
}.bind(this));
}
|
[
"function",
"Image",
"(",
")",
"{",
"if",
"(",
"!",
"this",
")",
"return",
"new",
"Image",
"(",
")",
";",
"this",
".",
"url",
"=",
"null",
";",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"setTimeout",
"(",
"function",
"timeout",
"(",
")",
"{",
"if",
"(",
"this",
".",
"onerror",
")",
"this",
".",
"on",
"(",
"'error'",
",",
"this",
".",
"onerror",
")",
";",
"if",
"(",
"this",
".",
"onload",
")",
"this",
".",
"on",
"(",
"'load'",
",",
"this",
".",
"onload",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] |
Image instance.
@constructor
@param {String} url URL we want to connect to
@api private
/* istanbul ignore next
|
[
"Image",
"instance",
"."
] |
baf355d411ec22ebd557a296113ee3f3256ead6e
|
https://github.com/unshiftio/beacons/blob/baf355d411ec22ebd557a296113ee3f3256ead6e/image.js#L14-L25
|
39,324 |
sagely/grunt-zaproxy
|
tasks/zaproxy.js
|
function (zaproxy, statusFn, callback) {
var wait = function () {
statusFn(function (err, body) {
if (err) {
callback(err);
return;
}
if (body.status < 100) {
grunt.log.write('.');
setTimeout(function () {
wait(callback);
}, 1000);
} else {
callback(null, body);
}
});
};
wait();
}
|
javascript
|
function (zaproxy, statusFn, callback) {
var wait = function () {
statusFn(function (err, body) {
if (err) {
callback(err);
return;
}
if (body.status < 100) {
grunt.log.write('.');
setTimeout(function () {
wait(callback);
}, 1000);
} else {
callback(null, body);
}
});
};
wait();
}
|
[
"function",
"(",
"zaproxy",
",",
"statusFn",
",",
"callback",
")",
"{",
"var",
"wait",
"=",
"function",
"(",
")",
"{",
"statusFn",
"(",
"function",
"(",
"err",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"if",
"(",
"body",
".",
"status",
"<",
"100",
")",
"{",
"grunt",
".",
"log",
".",
"write",
"(",
"'.'",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"wait",
"(",
"callback",
")",
";",
"}",
",",
"1000",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"null",
",",
"body",
")",
";",
"}",
"}",
")",
";",
"}",
";",
"wait",
"(",
")",
";",
"}"
] |
Wait for a scan to finish.
|
[
"Wait",
"for",
"a",
"scan",
"to",
"finish",
"."
] |
f93fd5c8f37f3c2ec3bddf7c9d0ad631a088d92d
|
https://github.com/sagely/grunt-zaproxy/blob/f93fd5c8f37f3c2ec3bddf7c9d0ad631a088d92d/tasks/zaproxy.js#L157-L175
|
|
39,325 |
navicore/aglio-theme-bluecase
|
src/makecases.js
|
numberType
|
function numberType(mname, tpe, options) {
const doubles = options.themeDoubles.split(',')
if (doubles && doubles.includes(mname)) {
return 'Double'
} else {
return 'Int'
}
}
|
javascript
|
function numberType(mname, tpe, options) {
const doubles = options.themeDoubles.split(',')
if (doubles && doubles.includes(mname)) {
return 'Double'
} else {
return 'Int'
}
}
|
[
"function",
"numberType",
"(",
"mname",
",",
"tpe",
",",
"options",
")",
"{",
"const",
"doubles",
"=",
"options",
".",
"themeDoubles",
".",
"split",
"(",
"','",
")",
"if",
"(",
"doubles",
"&&",
"doubles",
".",
"includes",
"(",
"mname",
")",
")",
"{",
"return",
"'Double'",
"}",
"else",
"{",
"return",
"'Int'",
"}",
"}"
] |
turn number into scala Double if element name matches cmdline arg list
|
[
"turn",
"number",
"into",
"scala",
"Double",
"if",
"element",
"name",
"matches",
"cmdline",
"arg",
"list"
] |
eae6c191b3cc8724cbca46ad9853e3270f20baff
|
https://github.com/navicore/aglio-theme-bluecase/blob/eae6c191b3cc8724cbca46ad9853e3270f20baff/src/makecases.js#L2-L9
|
39,326 |
chrisJohn404/ljswitchboard-ljm_device_curator
|
lib/t7_calibration_operations.js
|
getCurrentConfigs
|
function getCurrentConfigs(bundle) {
dbgHWTest('getCurrentConfigs', bundle.calibrationInfoValid);
var defered = q.defer();
bundle.device.sReadMany(bundle.infoToCache)
.then(function(results) {
// bundle.currentDeviceConfigs
results.forEach(function(result) {
bundle.currentDeviceConfigs[result.name] = result;
});
defered.resolve(bundle);
}, function(err) {
bundle.overallResult = false;
bundle.overallMessage = 'Failed to read current device configs.';
bundle.shortMessage = 'Failed';
defered.resolve(bundle);
});
return defered.promise;
}
|
javascript
|
function getCurrentConfigs(bundle) {
dbgHWTest('getCurrentConfigs', bundle.calibrationInfoValid);
var defered = q.defer();
bundle.device.sReadMany(bundle.infoToCache)
.then(function(results) {
// bundle.currentDeviceConfigs
results.forEach(function(result) {
bundle.currentDeviceConfigs[result.name] = result;
});
defered.resolve(bundle);
}, function(err) {
bundle.overallResult = false;
bundle.overallMessage = 'Failed to read current device configs.';
bundle.shortMessage = 'Failed';
defered.resolve(bundle);
});
return defered.promise;
}
|
[
"function",
"getCurrentConfigs",
"(",
"bundle",
")",
"{",
"dbgHWTest",
"(",
"'getCurrentConfigs'",
",",
"bundle",
".",
"calibrationInfoValid",
")",
";",
"var",
"defered",
"=",
"q",
".",
"defer",
"(",
")",
";",
"bundle",
".",
"device",
".",
"sReadMany",
"(",
"bundle",
".",
"infoToCache",
")",
".",
"then",
"(",
"function",
"(",
"results",
")",
"{",
"// bundle.currentDeviceConfigs",
"results",
".",
"forEach",
"(",
"function",
"(",
"result",
")",
"{",
"bundle",
".",
"currentDeviceConfigs",
"[",
"result",
".",
"name",
"]",
"=",
"result",
";",
"}",
")",
";",
"defered",
".",
"resolve",
"(",
"bundle",
")",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"bundle",
".",
"overallResult",
"=",
"false",
";",
"bundle",
".",
"overallMessage",
"=",
"'Failed to read current device configs.'",
";",
"bundle",
".",
"shortMessage",
"=",
"'Failed'",
";",
"defered",
".",
"resolve",
"(",
"bundle",
")",
";",
"}",
")",
";",
"return",
"defered",
".",
"promise",
";",
"}"
] |
Read current device configuration & save it to the bundle.
|
[
"Read",
"current",
"device",
"configuration",
"&",
"save",
"it",
"to",
"the",
"bundle",
"."
] |
36cb25645dfa0a68e906d5ec43e5514391947257
|
https://github.com/chrisJohn404/ljswitchboard-ljm_device_curator/blob/36cb25645dfa0a68e906d5ec43e5514391947257/lib/t7_calibration_operations.js#L1266-L1284
|
39,327 |
feedhenry/grunt-fh-build
|
tasks/fh-build.js
|
function(bundle_deps) {
var patterns = [
'**',
'!dist/**',
'!plato/**',
'!cov-*/**',
'!test*/**',
'!config/**',
'!output/**',
'!coverage/**',
'!node_modules/**',
'!package.json', // this will be processed
'!Gruntfile.js',
'!Makefile',
'!makefile',
'!npm-debug.log',
'!*.sublime-project',
'!sonar-project.properties',
'!**/*.tar.gz'
];
if (bundle_deps) {
var nodeModulePatterns = _.uniq(getProductionNodeModules().map(formatDirectory));
patterns = patterns.concat(nodeModulePatterns);
}
var fhignore = grunt.config.get('fhignore');
var extras = [];
if (fhignore && _.isArray(fhignore)) {
extras = fhignore.map(function(elem) {
return '!' + elem;
});
}
Array.prototype.push.apply(patterns, extras);
var fhinclude = grunt.config.get('fhinclude');
extras = [];
if(fhinclude && _.isArray(fhinclude)) {
extras = fhinclude;
}
Array.prototype.push.apply(patterns, extras);
grunt.log.debug("Patterns: " + patterns);
return patterns;
}
|
javascript
|
function(bundle_deps) {
var patterns = [
'**',
'!dist/**',
'!plato/**',
'!cov-*/**',
'!test*/**',
'!config/**',
'!output/**',
'!coverage/**',
'!node_modules/**',
'!package.json', // this will be processed
'!Gruntfile.js',
'!Makefile',
'!makefile',
'!npm-debug.log',
'!*.sublime-project',
'!sonar-project.properties',
'!**/*.tar.gz'
];
if (bundle_deps) {
var nodeModulePatterns = _.uniq(getProductionNodeModules().map(formatDirectory));
patterns = patterns.concat(nodeModulePatterns);
}
var fhignore = grunt.config.get('fhignore');
var extras = [];
if (fhignore && _.isArray(fhignore)) {
extras = fhignore.map(function(elem) {
return '!' + elem;
});
}
Array.prototype.push.apply(patterns, extras);
var fhinclude = grunt.config.get('fhinclude');
extras = [];
if(fhinclude && _.isArray(fhinclude)) {
extras = fhinclude;
}
Array.prototype.push.apply(patterns, extras);
grunt.log.debug("Patterns: " + patterns);
return patterns;
}
|
[
"function",
"(",
"bundle_deps",
")",
"{",
"var",
"patterns",
"=",
"[",
"'**'",
",",
"'!dist/**'",
",",
"'!plato/**'",
",",
"'!cov-*/**'",
",",
"'!test*/**'",
",",
"'!config/**'",
",",
"'!output/**'",
",",
"'!coverage/**'",
",",
"'!node_modules/**'",
",",
"'!package.json'",
",",
"// this will be processed",
"'!Gruntfile.js'",
",",
"'!Makefile'",
",",
"'!makefile'",
",",
"'!npm-debug.log'",
",",
"'!*.sublime-project'",
",",
"'!sonar-project.properties'",
",",
"'!**/*.tar.gz'",
"]",
";",
"if",
"(",
"bundle_deps",
")",
"{",
"var",
"nodeModulePatterns",
"=",
"_",
".",
"uniq",
"(",
"getProductionNodeModules",
"(",
")",
".",
"map",
"(",
"formatDirectory",
")",
")",
";",
"patterns",
"=",
"patterns",
".",
"concat",
"(",
"nodeModulePatterns",
")",
";",
"}",
"var",
"fhignore",
"=",
"grunt",
".",
"config",
".",
"get",
"(",
"'fhignore'",
")",
";",
"var",
"extras",
"=",
"[",
"]",
";",
"if",
"(",
"fhignore",
"&&",
"_",
".",
"isArray",
"(",
"fhignore",
")",
")",
"{",
"extras",
"=",
"fhignore",
".",
"map",
"(",
"function",
"(",
"elem",
")",
"{",
"return",
"'!'",
"+",
"elem",
";",
"}",
")",
";",
"}",
"Array",
".",
"prototype",
".",
"push",
".",
"apply",
"(",
"patterns",
",",
"extras",
")",
";",
"var",
"fhinclude",
"=",
"grunt",
".",
"config",
".",
"get",
"(",
"'fhinclude'",
")",
";",
"extras",
"=",
"[",
"]",
";",
"if",
"(",
"fhinclude",
"&&",
"_",
".",
"isArray",
"(",
"fhinclude",
")",
")",
"{",
"extras",
"=",
"fhinclude",
";",
"}",
"Array",
".",
"prototype",
".",
"push",
".",
"apply",
"(",
"patterns",
",",
"extras",
")",
";",
"grunt",
".",
"log",
".",
"debug",
"(",
"\"Patterns: \"",
"+",
"patterns",
")",
";",
"return",
"patterns",
";",
"}"
] |
If grunt config contains an array property called 'fhignore',
its elements will be excluded from the tarball.
|
[
"If",
"grunt",
"config",
"contains",
"an",
"array",
"property",
"called",
"fhignore",
"its",
"elements",
"will",
"be",
"excluded",
"from",
"the",
"tarball",
"."
] |
527e8d7806a80e10b479864ba142b4c8192babb6
|
https://github.com/feedhenry/grunt-fh-build/blob/527e8d7806a80e10b479864ba142b4c8192babb6/tasks/fh-build.js#L71-L111
|
|
39,328 |
lemonde/knex-schema
|
lib/reset.js
|
reset
|
function reset(schemas) {
var resolver = new Resolver(schemas);
// Reduce force sequential execution.
return Promise.reduce(resolver.resolve().reverse(), resetSchema.bind(this), []);
}
|
javascript
|
function reset(schemas) {
var resolver = new Resolver(schemas);
// Reduce force sequential execution.
return Promise.reduce(resolver.resolve().reverse(), resetSchema.bind(this), []);
}
|
[
"function",
"reset",
"(",
"schemas",
")",
"{",
"var",
"resolver",
"=",
"new",
"Resolver",
"(",
"schemas",
")",
";",
"// Reduce force sequential execution.",
"return",
"Promise",
".",
"reduce",
"(",
"resolver",
".",
"resolve",
"(",
")",
".",
"reverse",
"(",
")",
",",
"resetSchema",
".",
"bind",
"(",
"this",
")",
",",
"[",
"]",
")",
";",
"}"
] |
Delete schemas tables data.
@param {[Schemas]} schemas
@return {Promise}
|
[
"Delete",
"schemas",
"tables",
"data",
"."
] |
3e0f6cde374d240552eb08e50e123a513fda44ae
|
https://github.com/lemonde/knex-schema/blob/3e0f6cde374d240552eb08e50e123a513fda44ae/lib/reset.js#L19-L23
|
39,329 |
lemonde/knex-schema
|
lib/reset.js
|
resetSchema
|
function resetSchema(result, schema) {
var knex = this.knex;
return knex.schema.hasTable(schema.tableName)
.then(function (exists) {
if (! exists) return result;
return knex(schema.tableName).del()
.then(function () {
return result.concat([schema]);
});
});
}
|
javascript
|
function resetSchema(result, schema) {
var knex = this.knex;
return knex.schema.hasTable(schema.tableName)
.then(function (exists) {
if (! exists) return result;
return knex(schema.tableName).del()
.then(function () {
return result.concat([schema]);
});
});
}
|
[
"function",
"resetSchema",
"(",
"result",
",",
"schema",
")",
"{",
"var",
"knex",
"=",
"this",
".",
"knex",
";",
"return",
"knex",
".",
"schema",
".",
"hasTable",
"(",
"schema",
".",
"tableName",
")",
".",
"then",
"(",
"function",
"(",
"exists",
")",
"{",
"if",
"(",
"!",
"exists",
")",
"return",
"result",
";",
"return",
"knex",
"(",
"schema",
".",
"tableName",
")",
".",
"del",
"(",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"return",
"result",
".",
"concat",
"(",
"[",
"schema",
"]",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Delete schema table data.
@param {[Schema]} result - reduce accumulator
@param {Schema} schema
@return {Promise}
|
[
"Delete",
"schema",
"table",
"data",
"."
] |
3e0f6cde374d240552eb08e50e123a513fda44ae
|
https://github.com/lemonde/knex-schema/blob/3e0f6cde374d240552eb08e50e123a513fda44ae/lib/reset.js#L33-L43
|
39,330 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/Scroller/js/dataTables.scroller.js
|
function ()
{
var heights = this.s.heights;
var max = 1000000;
heights.virtual = heights.row * this.s.dt.fnRecordsDisplay();
heights.scroll = heights.virtual;
if ( heights.scroll > max ) {
heights.scroll = max;
}
this.dom.force.style.height = heights.scroll+"px";
}
|
javascript
|
function ()
{
var heights = this.s.heights;
var max = 1000000;
heights.virtual = heights.row * this.s.dt.fnRecordsDisplay();
heights.scroll = heights.virtual;
if ( heights.scroll > max ) {
heights.scroll = max;
}
this.dom.force.style.height = heights.scroll+"px";
}
|
[
"function",
"(",
")",
"{",
"var",
"heights",
"=",
"this",
".",
"s",
".",
"heights",
";",
"var",
"max",
"=",
"1000000",
";",
"heights",
".",
"virtual",
"=",
"heights",
".",
"row",
"*",
"this",
".",
"s",
".",
"dt",
".",
"fnRecordsDisplay",
"(",
")",
";",
"heights",
".",
"scroll",
"=",
"heights",
".",
"virtual",
";",
"if",
"(",
"heights",
".",
"scroll",
">",
"max",
")",
"{",
"heights",
".",
"scroll",
"=",
"max",
";",
"}",
"this",
".",
"dom",
".",
"force",
".",
"style",
".",
"height",
"=",
"heights",
".",
"scroll",
"+",
"\"px\"",
";",
"}"
] |
Force the scrolling container to have height beyond that of just the
table that has been drawn so the user can scroll the whole data set.
Note that if the calculated required scrolling height exceeds a maximum
value (1 million pixels - hard-coded) the forcing element will be set
only to that maximum value and virtual / physical domain transforms will
be used to allow Scroller to display tables of any number of records.
@returns {void}
@private
|
[
"Force",
"the",
"scrolling",
"container",
"to",
"have",
"height",
"beyond",
"that",
"of",
"just",
"the",
"table",
"that",
"has",
"been",
"drawn",
"so",
"the",
"user",
"can",
"scroll",
"the",
"whole",
"data",
"set",
"."
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/Scroller/js/dataTables.scroller.js#L859-L872
|
|
39,331 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/Scroller/js/dataTables.scroller.js
|
function ()
{
var dt = this.s.dt;
var origTable = dt.nTable;
var nTable = origTable.cloneNode( false );
var tbody = $('<tbody/>').appendTo( nTable );
var container = $(
'<div class="'+dt.oClasses.sWrapper+' DTS">'+
'<div class="'+dt.oClasses.sScrollWrapper+'">'+
'<div class="'+dt.oClasses.sScrollBody+'"></div>'+
'</div>'+
'</div>'
);
// Want 3 rows in the sizing table so :first-child and :last-child
// CSS styles don't come into play - take the size of the middle row
$('tbody tr:lt(4)', origTable).clone().appendTo( tbody );
while( $('tr', tbody).length < 3 ) {
tbody.append( '<tr><td> </td></tr>' );
}
$('div.'+dt.oClasses.sScrollBody, container).append( nTable );
var appendTo;
if (dt._bInitComplete) {
appendTo = origTable.parentNode;
} else {
if (!this.s.dt.nHolding) {
this.s.dt.nHolding = $( '<div></div>' ).insertBefore( this.s.dt.nTable );
}
appendTo = this.s.dt.nHolding;
}
container.appendTo( appendTo );
this.s.heights.row = $('tr', tbody).eq(1).outerHeight();
container.remove();
}
|
javascript
|
function ()
{
var dt = this.s.dt;
var origTable = dt.nTable;
var nTable = origTable.cloneNode( false );
var tbody = $('<tbody/>').appendTo( nTable );
var container = $(
'<div class="'+dt.oClasses.sWrapper+' DTS">'+
'<div class="'+dt.oClasses.sScrollWrapper+'">'+
'<div class="'+dt.oClasses.sScrollBody+'"></div>'+
'</div>'+
'</div>'
);
// Want 3 rows in the sizing table so :first-child and :last-child
// CSS styles don't come into play - take the size of the middle row
$('tbody tr:lt(4)', origTable).clone().appendTo( tbody );
while( $('tr', tbody).length < 3 ) {
tbody.append( '<tr><td> </td></tr>' );
}
$('div.'+dt.oClasses.sScrollBody, container).append( nTable );
var appendTo;
if (dt._bInitComplete) {
appendTo = origTable.parentNode;
} else {
if (!this.s.dt.nHolding) {
this.s.dt.nHolding = $( '<div></div>' ).insertBefore( this.s.dt.nTable );
}
appendTo = this.s.dt.nHolding;
}
container.appendTo( appendTo );
this.s.heights.row = $('tr', tbody).eq(1).outerHeight();
container.remove();
}
|
[
"function",
"(",
")",
"{",
"var",
"dt",
"=",
"this",
".",
"s",
".",
"dt",
";",
"var",
"origTable",
"=",
"dt",
".",
"nTable",
";",
"var",
"nTable",
"=",
"origTable",
".",
"cloneNode",
"(",
"false",
")",
";",
"var",
"tbody",
"=",
"$",
"(",
"'<tbody/>'",
")",
".",
"appendTo",
"(",
"nTable",
")",
";",
"var",
"container",
"=",
"$",
"(",
"'<div class=\"'",
"+",
"dt",
".",
"oClasses",
".",
"sWrapper",
"+",
"' DTS\">'",
"+",
"'<div class=\"'",
"+",
"dt",
".",
"oClasses",
".",
"sScrollWrapper",
"+",
"'\">'",
"+",
"'<div class=\"'",
"+",
"dt",
".",
"oClasses",
".",
"sScrollBody",
"+",
"'\"></div>'",
"+",
"'</div>'",
"+",
"'</div>'",
")",
";",
"// Want 3 rows in the sizing table so :first-child and :last-child",
"// CSS styles don't come into play - take the size of the middle row",
"$",
"(",
"'tbody tr:lt(4)'",
",",
"origTable",
")",
".",
"clone",
"(",
")",
".",
"appendTo",
"(",
"tbody",
")",
";",
"while",
"(",
"$",
"(",
"'tr'",
",",
"tbody",
")",
".",
"length",
"<",
"3",
")",
"{",
"tbody",
".",
"append",
"(",
"'<tr><td> </td></tr>'",
")",
";",
"}",
"$",
"(",
"'div.'",
"+",
"dt",
".",
"oClasses",
".",
"sScrollBody",
",",
"container",
")",
".",
"append",
"(",
"nTable",
")",
";",
"var",
"appendTo",
";",
"if",
"(",
"dt",
".",
"_bInitComplete",
")",
"{",
"appendTo",
"=",
"origTable",
".",
"parentNode",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"this",
".",
"s",
".",
"dt",
".",
"nHolding",
")",
"{",
"this",
".",
"s",
".",
"dt",
".",
"nHolding",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"insertBefore",
"(",
"this",
".",
"s",
".",
"dt",
".",
"nTable",
")",
";",
"}",
"appendTo",
"=",
"this",
".",
"s",
".",
"dt",
".",
"nHolding",
";",
"}",
"container",
".",
"appendTo",
"(",
"appendTo",
")",
";",
"this",
".",
"s",
".",
"heights",
".",
"row",
"=",
"$",
"(",
"'tr'",
",",
"tbody",
")",
".",
"eq",
"(",
"1",
")",
".",
"outerHeight",
"(",
")",
";",
"container",
".",
"remove",
"(",
")",
";",
"}"
] |
Automatic calculation of table row height. This is just a little tricky here as using
initialisation DataTables has tale the table out of the document, so we need to create
a new table and insert it into the document, calculate the row height and then whip the
table out.
@returns {void}
@private
|
[
"Automatic",
"calculation",
"of",
"table",
"row",
"height",
".",
"This",
"is",
"just",
"a",
"little",
"tricky",
"here",
"as",
"using",
"initialisation",
"DataTables",
"has",
"tale",
"the",
"table",
"out",
"of",
"the",
"document",
"so",
"we",
"need",
"to",
"create",
"a",
"new",
"table",
"and",
"insert",
"it",
"into",
"the",
"document",
"calculate",
"the",
"row",
"height",
"and",
"then",
"whip",
"the",
"table",
"out",
"."
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/Scroller/js/dataTables.scroller.js#L883-L919
|
|
39,332 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/Scroller/js/dataTables.scroller.js
|
function ()
{
if ( !this.s.dt.oFeatures.bInfo )
{
return;
}
var
dt = this.s.dt,
language = dt.oLanguage,
iScrollTop = this.dom.scroller.scrollTop,
iStart = Math.floor( this.fnPixelsToRow(iScrollTop, false, this.s.ani)+1 ),
iMax = dt.fnRecordsTotal(),
iTotal = dt.fnRecordsDisplay(),
iPossibleEnd = Math.ceil( this.fnPixelsToRow(iScrollTop+this.s.heights.viewport, false, this.s.ani) ),
iEnd = iTotal < iPossibleEnd ? iTotal : iPossibleEnd,
sStart = dt.fnFormatNumber( iStart ),
sEnd = dt.fnFormatNumber( iEnd ),
sMax = dt.fnFormatNumber( iMax ),
sTotal = dt.fnFormatNumber( iTotal ),
sOut;
if ( dt.fnRecordsDisplay() === 0 &&
dt.fnRecordsDisplay() == dt.fnRecordsTotal() )
{
/* Empty record set */
sOut = language.sInfoEmpty+ language.sInfoPostFix;
}
else if ( dt.fnRecordsDisplay() === 0 )
{
/* Empty record set after filtering */
sOut = language.sInfoEmpty +' '+
language.sInfoFiltered.replace('_MAX_', sMax)+
language.sInfoPostFix;
}
else if ( dt.fnRecordsDisplay() == dt.fnRecordsTotal() )
{
/* Normal record set */
sOut = language.sInfo.
replace('_START_', sStart).
replace('_END_', sEnd).
replace('_MAX_', sMax).
replace('_TOTAL_', sTotal)+
language.sInfoPostFix;
}
else
{
/* Record set after filtering */
sOut = language.sInfo.
replace('_START_', sStart).
replace('_END_', sEnd).
replace('_MAX_', sMax).
replace('_TOTAL_', sTotal) +' '+
language.sInfoFiltered.replace(
'_MAX_',
dt.fnFormatNumber(dt.fnRecordsTotal())
)+
language.sInfoPostFix;
}
var callback = language.fnInfoCallback;
if ( callback ) {
sOut = callback.call( dt.oInstance,
dt, iStart, iEnd, iMax, iTotal, sOut
);
}
var n = dt.aanFeatures.i;
if ( typeof n != 'undefined' )
{
for ( var i=0, iLen=n.length ; i<iLen ; i++ )
{
$(n[i]).html( sOut );
}
}
}
|
javascript
|
function ()
{
if ( !this.s.dt.oFeatures.bInfo )
{
return;
}
var
dt = this.s.dt,
language = dt.oLanguage,
iScrollTop = this.dom.scroller.scrollTop,
iStart = Math.floor( this.fnPixelsToRow(iScrollTop, false, this.s.ani)+1 ),
iMax = dt.fnRecordsTotal(),
iTotal = dt.fnRecordsDisplay(),
iPossibleEnd = Math.ceil( this.fnPixelsToRow(iScrollTop+this.s.heights.viewport, false, this.s.ani) ),
iEnd = iTotal < iPossibleEnd ? iTotal : iPossibleEnd,
sStart = dt.fnFormatNumber( iStart ),
sEnd = dt.fnFormatNumber( iEnd ),
sMax = dt.fnFormatNumber( iMax ),
sTotal = dt.fnFormatNumber( iTotal ),
sOut;
if ( dt.fnRecordsDisplay() === 0 &&
dt.fnRecordsDisplay() == dt.fnRecordsTotal() )
{
/* Empty record set */
sOut = language.sInfoEmpty+ language.sInfoPostFix;
}
else if ( dt.fnRecordsDisplay() === 0 )
{
/* Empty record set after filtering */
sOut = language.sInfoEmpty +' '+
language.sInfoFiltered.replace('_MAX_', sMax)+
language.sInfoPostFix;
}
else if ( dt.fnRecordsDisplay() == dt.fnRecordsTotal() )
{
/* Normal record set */
sOut = language.sInfo.
replace('_START_', sStart).
replace('_END_', sEnd).
replace('_MAX_', sMax).
replace('_TOTAL_', sTotal)+
language.sInfoPostFix;
}
else
{
/* Record set after filtering */
sOut = language.sInfo.
replace('_START_', sStart).
replace('_END_', sEnd).
replace('_MAX_', sMax).
replace('_TOTAL_', sTotal) +' '+
language.sInfoFiltered.replace(
'_MAX_',
dt.fnFormatNumber(dt.fnRecordsTotal())
)+
language.sInfoPostFix;
}
var callback = language.fnInfoCallback;
if ( callback ) {
sOut = callback.call( dt.oInstance,
dt, iStart, iEnd, iMax, iTotal, sOut
);
}
var n = dt.aanFeatures.i;
if ( typeof n != 'undefined' )
{
for ( var i=0, iLen=n.length ; i<iLen ; i++ )
{
$(n[i]).html( sOut );
}
}
}
|
[
"function",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"s",
".",
"dt",
".",
"oFeatures",
".",
"bInfo",
")",
"{",
"return",
";",
"}",
"var",
"dt",
"=",
"this",
".",
"s",
".",
"dt",
",",
"language",
"=",
"dt",
".",
"oLanguage",
",",
"iScrollTop",
"=",
"this",
".",
"dom",
".",
"scroller",
".",
"scrollTop",
",",
"iStart",
"=",
"Math",
".",
"floor",
"(",
"this",
".",
"fnPixelsToRow",
"(",
"iScrollTop",
",",
"false",
",",
"this",
".",
"s",
".",
"ani",
")",
"+",
"1",
")",
",",
"iMax",
"=",
"dt",
".",
"fnRecordsTotal",
"(",
")",
",",
"iTotal",
"=",
"dt",
".",
"fnRecordsDisplay",
"(",
")",
",",
"iPossibleEnd",
"=",
"Math",
".",
"ceil",
"(",
"this",
".",
"fnPixelsToRow",
"(",
"iScrollTop",
"+",
"this",
".",
"s",
".",
"heights",
".",
"viewport",
",",
"false",
",",
"this",
".",
"s",
".",
"ani",
")",
")",
",",
"iEnd",
"=",
"iTotal",
"<",
"iPossibleEnd",
"?",
"iTotal",
":",
"iPossibleEnd",
",",
"sStart",
"=",
"dt",
".",
"fnFormatNumber",
"(",
"iStart",
")",
",",
"sEnd",
"=",
"dt",
".",
"fnFormatNumber",
"(",
"iEnd",
")",
",",
"sMax",
"=",
"dt",
".",
"fnFormatNumber",
"(",
"iMax",
")",
",",
"sTotal",
"=",
"dt",
".",
"fnFormatNumber",
"(",
"iTotal",
")",
",",
"sOut",
";",
"if",
"(",
"dt",
".",
"fnRecordsDisplay",
"(",
")",
"===",
"0",
"&&",
"dt",
".",
"fnRecordsDisplay",
"(",
")",
"==",
"dt",
".",
"fnRecordsTotal",
"(",
")",
")",
"{",
"/* Empty record set */",
"sOut",
"=",
"language",
".",
"sInfoEmpty",
"+",
"language",
".",
"sInfoPostFix",
";",
"}",
"else",
"if",
"(",
"dt",
".",
"fnRecordsDisplay",
"(",
")",
"===",
"0",
")",
"{",
"/* Empty record set after filtering */",
"sOut",
"=",
"language",
".",
"sInfoEmpty",
"+",
"' '",
"+",
"language",
".",
"sInfoFiltered",
".",
"replace",
"(",
"'_MAX_'",
",",
"sMax",
")",
"+",
"language",
".",
"sInfoPostFix",
";",
"}",
"else",
"if",
"(",
"dt",
".",
"fnRecordsDisplay",
"(",
")",
"==",
"dt",
".",
"fnRecordsTotal",
"(",
")",
")",
"{",
"/* Normal record set */",
"sOut",
"=",
"language",
".",
"sInfo",
".",
"replace",
"(",
"'_START_'",
",",
"sStart",
")",
".",
"replace",
"(",
"'_END_'",
",",
"sEnd",
")",
".",
"replace",
"(",
"'_MAX_'",
",",
"sMax",
")",
".",
"replace",
"(",
"'_TOTAL_'",
",",
"sTotal",
")",
"+",
"language",
".",
"sInfoPostFix",
";",
"}",
"else",
"{",
"/* Record set after filtering */",
"sOut",
"=",
"language",
".",
"sInfo",
".",
"replace",
"(",
"'_START_'",
",",
"sStart",
")",
".",
"replace",
"(",
"'_END_'",
",",
"sEnd",
")",
".",
"replace",
"(",
"'_MAX_'",
",",
"sMax",
")",
".",
"replace",
"(",
"'_TOTAL_'",
",",
"sTotal",
")",
"+",
"' '",
"+",
"language",
".",
"sInfoFiltered",
".",
"replace",
"(",
"'_MAX_'",
",",
"dt",
".",
"fnFormatNumber",
"(",
"dt",
".",
"fnRecordsTotal",
"(",
")",
")",
")",
"+",
"language",
".",
"sInfoPostFix",
";",
"}",
"var",
"callback",
"=",
"language",
".",
"fnInfoCallback",
";",
"if",
"(",
"callback",
")",
"{",
"sOut",
"=",
"callback",
".",
"call",
"(",
"dt",
".",
"oInstance",
",",
"dt",
",",
"iStart",
",",
"iEnd",
",",
"iMax",
",",
"iTotal",
",",
"sOut",
")",
";",
"}",
"var",
"n",
"=",
"dt",
".",
"aanFeatures",
".",
"i",
";",
"if",
"(",
"typeof",
"n",
"!=",
"'undefined'",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"n",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"$",
"(",
"n",
"[",
"i",
"]",
")",
".",
"html",
"(",
"sOut",
")",
";",
"}",
"}",
"}"
] |
Update any information elements that are controlled by the DataTable based on the scrolling
viewport and what rows are visible in it. This function basically acts in the same way as
_fnUpdateInfo in DataTables, and effectively replaces that function.
@returns {void}
@private
|
[
"Update",
"any",
"information",
"elements",
"that",
"are",
"controlled",
"by",
"the",
"DataTable",
"based",
"on",
"the",
"scrolling",
"viewport",
"and",
"what",
"rows",
"are",
"visible",
"in",
"it",
".",
"This",
"function",
"basically",
"acts",
"in",
"the",
"same",
"way",
"as",
"_fnUpdateInfo",
"in",
"DataTables",
"and",
"effectively",
"replaces",
"that",
"function",
"."
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/Scroller/js/dataTables.scroller.js#L929-L1004
|
|
39,333 |
mangojuicejs/mangojuice
|
packages/mangojuice-core/src/classes/Process.js
|
forEachChildren
|
function forEachChildren(proc, iterator) {
for (let id in proc.children) {
iterator(proc.children[id]);
}
}
|
javascript
|
function forEachChildren(proc, iterator) {
for (let id in proc.children) {
iterator(proc.children[id]);
}
}
|
[
"function",
"forEachChildren",
"(",
"proc",
",",
"iterator",
")",
"{",
"for",
"(",
"let",
"id",
"in",
"proc",
".",
"children",
")",
"{",
"iterator",
"(",
"proc",
".",
"children",
"[",
"id",
"]",
")",
";",
"}",
"}"
] |
Iterate through all active child processes and run
given iterator for every model.
@param {Process} proc
|
[
"Iterate",
"through",
"all",
"active",
"child",
"processes",
"and",
"run",
"given",
"iterator",
"for",
"every",
"model",
"."
] |
15bda5648462c171cc8e2dd0f8f15696655ce11a
|
https://github.com/mangojuicejs/mangojuice/blob/15bda5648462c171cc8e2dd0f8f15696655ce11a/packages/mangojuice-core/src/classes/Process.js#L48-L52
|
39,334 |
mangojuicejs/mangojuice
|
packages/mangojuice-core/src/classes/Process.js
|
bindChild
|
function bindChild(proc, model, key, childCmd) {
const { logicClass, updateMsg, createArgs } = childCmd;
const originalModel = model[key];
let actualModel = originalModel || {};
let currProc = procOf(actualModel);
// Protect update of the model of the same type
if (updateMsg && (!currProc || !(currProc.logic instanceof logicClass))) {
proc.logger.onCatchError(new Error('Child model does not exists or have incorrect type'), proc);
return;
}
// Re-run prepare with new config args if proc already running
// with the same logic class, otherwise destroy the logic
if (currProc) {
if (!updateMsg) {
currProc.destroy();
currProc = null;
actualModel = {};
} else {
runLogicUpdate(currProc, updateMsg);
}
}
// Run new process for given child definition if no proc was
// binded to the model or if it was destroyed
if (!currProc) {
const shouldRehydrate = actualModel && actualModel === originalModel;
currProc = new proc.constructor({
createArgs,
logicClass,
parent: proc,
logger: proc.logger,
contexts: proc.contexts,
internalContext: proc.internalContext
});
model[key] = actualModel;
currProc.bind(actualModel);
currProc.run(shouldRehydrate);
proc.children[currProc.id] = currProc;
}
return currProc;
}
|
javascript
|
function bindChild(proc, model, key, childCmd) {
const { logicClass, updateMsg, createArgs } = childCmd;
const originalModel = model[key];
let actualModel = originalModel || {};
let currProc = procOf(actualModel);
// Protect update of the model of the same type
if (updateMsg && (!currProc || !(currProc.logic instanceof logicClass))) {
proc.logger.onCatchError(new Error('Child model does not exists or have incorrect type'), proc);
return;
}
// Re-run prepare with new config args if proc already running
// with the same logic class, otherwise destroy the logic
if (currProc) {
if (!updateMsg) {
currProc.destroy();
currProc = null;
actualModel = {};
} else {
runLogicUpdate(currProc, updateMsg);
}
}
// Run new process for given child definition if no proc was
// binded to the model or if it was destroyed
if (!currProc) {
const shouldRehydrate = actualModel && actualModel === originalModel;
currProc = new proc.constructor({
createArgs,
logicClass,
parent: proc,
logger: proc.logger,
contexts: proc.contexts,
internalContext: proc.internalContext
});
model[key] = actualModel;
currProc.bind(actualModel);
currProc.run(shouldRehydrate);
proc.children[currProc.id] = currProc;
}
return currProc;
}
|
[
"function",
"bindChild",
"(",
"proc",
",",
"model",
",",
"key",
",",
"childCmd",
")",
"{",
"const",
"{",
"logicClass",
",",
"updateMsg",
",",
"createArgs",
"}",
"=",
"childCmd",
";",
"const",
"originalModel",
"=",
"model",
"[",
"key",
"]",
";",
"let",
"actualModel",
"=",
"originalModel",
"||",
"{",
"}",
";",
"let",
"currProc",
"=",
"procOf",
"(",
"actualModel",
")",
";",
"// Protect update of the model of the same type",
"if",
"(",
"updateMsg",
"&&",
"(",
"!",
"currProc",
"||",
"!",
"(",
"currProc",
".",
"logic",
"instanceof",
"logicClass",
")",
")",
")",
"{",
"proc",
".",
"logger",
".",
"onCatchError",
"(",
"new",
"Error",
"(",
"'Child model does not exists or have incorrect type'",
")",
",",
"proc",
")",
";",
"return",
";",
"}",
"// Re-run prepare with new config args if proc already running",
"// with the same logic class, otherwise destroy the logic",
"if",
"(",
"currProc",
")",
"{",
"if",
"(",
"!",
"updateMsg",
")",
"{",
"currProc",
".",
"destroy",
"(",
")",
";",
"currProc",
"=",
"null",
";",
"actualModel",
"=",
"{",
"}",
";",
"}",
"else",
"{",
"runLogicUpdate",
"(",
"currProc",
",",
"updateMsg",
")",
";",
"}",
"}",
"// Run new process for given child definition if no proc was",
"// binded to the model or if it was destroyed",
"if",
"(",
"!",
"currProc",
")",
"{",
"const",
"shouldRehydrate",
"=",
"actualModel",
"&&",
"actualModel",
"===",
"originalModel",
";",
"currProc",
"=",
"new",
"proc",
".",
"constructor",
"(",
"{",
"createArgs",
",",
"logicClass",
",",
"parent",
":",
"proc",
",",
"logger",
":",
"proc",
".",
"logger",
",",
"contexts",
":",
"proc",
".",
"contexts",
",",
"internalContext",
":",
"proc",
".",
"internalContext",
"}",
")",
";",
"model",
"[",
"key",
"]",
"=",
"actualModel",
";",
"currProc",
".",
"bind",
"(",
"actualModel",
")",
";",
"currProc",
".",
"run",
"(",
"shouldRehydrate",
")",
";",
"proc",
".",
"children",
"[",
"currProc",
".",
"id",
"]",
"=",
"currProc",
";",
"}",
"return",
"currProc",
";",
"}"
] |
Create process and bind the process to child model
with given name. If model field is empty then do nothing.
If model already binded to some model do nothing.
Return true if model sucessfully binded to the process.
Othersise returns false
@private
@param {Object} childModel
@param {String} fieldName
@return {Boolean}
|
[
"Create",
"process",
"and",
"bind",
"the",
"process",
"to",
"child",
"model",
"with",
"given",
"name",
".",
"If",
"model",
"field",
"is",
"empty",
"then",
"do",
"nothing",
".",
"If",
"model",
"already",
"binded",
"to",
"some",
"model",
"do",
"nothing",
".",
"Return",
"true",
"if",
"model",
"sucessfully",
"binded",
"to",
"the",
"process",
".",
"Othersise",
"returns",
"false"
] |
15bda5648462c171cc8e2dd0f8f15696655ce11a
|
https://github.com/mangojuicejs/mangojuice/blob/15bda5648462c171cc8e2dd0f8f15696655ce11a/packages/mangojuice-core/src/classes/Process.js#L66-L109
|
39,335 |
mangojuicejs/mangojuice
|
packages/mangojuice-core/src/classes/Process.js
|
bindComputedFieldCmd
|
function bindComputedFieldCmd(proc, model, key, computeVal) {
const { logger } = proc;
// Create getter function
const isMemoized = computeVal instanceof MemoizedFieldCmd;
const computeFn = isMemoized ? computeVal.computeFn : computeVal;
const safeComputeValue = () => safeExecFunction(logger, computeFn)
const getter = isMemoized ? memoize(safeComputeValue) : safeComputeValue;
// Register memoized field in the process to be able to reset
// when the model changed
if (isMemoized) {
proc.computedFields[key] = getter;
}
// Set the getter in the model
Object.defineProperty(model, key, {
enumerable: true,
configurable: true,
set: noop,
get: getter
});
}
|
javascript
|
function bindComputedFieldCmd(proc, model, key, computeVal) {
const { logger } = proc;
// Create getter function
const isMemoized = computeVal instanceof MemoizedFieldCmd;
const computeFn = isMemoized ? computeVal.computeFn : computeVal;
const safeComputeValue = () => safeExecFunction(logger, computeFn)
const getter = isMemoized ? memoize(safeComputeValue) : safeComputeValue;
// Register memoized field in the process to be able to reset
// when the model changed
if (isMemoized) {
proc.computedFields[key] = getter;
}
// Set the getter in the model
Object.defineProperty(model, key, {
enumerable: true,
configurable: true,
set: noop,
get: getter
});
}
|
[
"function",
"bindComputedFieldCmd",
"(",
"proc",
",",
"model",
",",
"key",
",",
"computeVal",
")",
"{",
"const",
"{",
"logger",
"}",
"=",
"proc",
";",
"// Create getter function",
"const",
"isMemoized",
"=",
"computeVal",
"instanceof",
"MemoizedFieldCmd",
";",
"const",
"computeFn",
"=",
"isMemoized",
"?",
"computeVal",
".",
"computeFn",
":",
"computeVal",
";",
"const",
"safeComputeValue",
"=",
"(",
")",
"=>",
"safeExecFunction",
"(",
"logger",
",",
"computeFn",
")",
"const",
"getter",
"=",
"isMemoized",
"?",
"memoize",
"(",
"safeComputeValue",
")",
":",
"safeComputeValue",
";",
"// Register memoized field in the process to be able to reset",
"// when the model changed",
"if",
"(",
"isMemoized",
")",
"{",
"proc",
".",
"computedFields",
"[",
"key",
"]",
"=",
"getter",
";",
"}",
"// Set the getter in the model",
"Object",
".",
"defineProperty",
"(",
"model",
",",
"key",
",",
"{",
"enumerable",
":",
"true",
",",
"configurable",
":",
"true",
",",
"set",
":",
"noop",
",",
"get",
":",
"getter",
"}",
")",
";",
"}"
] |
Bind field in the model with given computed function or dependency
object.
@private
@param {Process} proc
@param {string} fieldName
@param {function} computeVal
|
[
"Bind",
"field",
"in",
"the",
"model",
"with",
"given",
"computed",
"function",
"or",
"dependency",
"object",
"."
] |
15bda5648462c171cc8e2dd0f8f15696655ce11a
|
https://github.com/mangojuicejs/mangojuice/blob/15bda5648462c171cc8e2dd0f8f15696655ce11a/packages/mangojuice-core/src/classes/Process.js#L120-L142
|
39,336 |
mangojuicejs/mangojuice
|
packages/mangojuice-core/src/classes/Process.js
|
runLogicCreate
|
function runLogicCreate(proc, rehydrate) {
const { exec, logic, createArgs, model } = proc;
if (logic.create) {
const commandFactory = () => {
logic.model = !rehydrate ? undefined : model;
const res = logic.create.apply(logic, createArgs);
logic.model = model;
return res;
};
exec(commandFactory);
}
}
|
javascript
|
function runLogicCreate(proc, rehydrate) {
const { exec, logic, createArgs, model } = proc;
if (logic.create) {
const commandFactory = () => {
logic.model = !rehydrate ? undefined : model;
const res = logic.create.apply(logic, createArgs);
logic.model = model;
return res;
};
exec(commandFactory);
}
}
|
[
"function",
"runLogicCreate",
"(",
"proc",
",",
"rehydrate",
")",
"{",
"const",
"{",
"exec",
",",
"logic",
",",
"createArgs",
",",
"model",
"}",
"=",
"proc",
";",
"if",
"(",
"logic",
".",
"create",
")",
"{",
"const",
"commandFactory",
"=",
"(",
")",
"=>",
"{",
"logic",
".",
"model",
"=",
"!",
"rehydrate",
"?",
"undefined",
":",
"model",
";",
"const",
"res",
"=",
"logic",
".",
"create",
".",
"apply",
"(",
"logic",
",",
"createArgs",
")",
";",
"logic",
".",
"model",
"=",
"model",
";",
"return",
"res",
";",
"}",
";",
"exec",
"(",
"commandFactory",
")",
";",
"}",
"}"
] |
Run init command depending on from what state the logic
is runinng. Run `logic.rehydrate` if some model was provided
and `prepare` if model was not provided and we need to create
it from scratch.
@param {Process} proc
|
[
"Run",
"init",
"command",
"depending",
"on",
"from",
"what",
"state",
"the",
"logic",
"is",
"runinng",
".",
"Run",
"logic",
".",
"rehydrate",
"if",
"some",
"model",
"was",
"provided",
"and",
"prepare",
"if",
"model",
"was",
"not",
"provided",
"and",
"we",
"need",
"to",
"create",
"it",
"from",
"scratch",
"."
] |
15bda5648462c171cc8e2dd0f8f15696655ce11a
|
https://github.com/mangojuicejs/mangojuice/blob/15bda5648462c171cc8e2dd0f8f15696655ce11a/packages/mangojuice-core/src/classes/Process.js#L186-L197
|
39,337 |
mangojuicejs/mangojuice
|
packages/mangojuice-core/src/classes/Process.js
|
runModelObservers
|
function runModelObservers(proc) {
const observersIterator = (obs) => obs();
maybeForEach(proc.observers, observersIterator);
if (proc.parent) {
maybeForEach(proc.childrenObservers, observersIterator);
}
}
|
javascript
|
function runModelObservers(proc) {
const observersIterator = (obs) => obs();
maybeForEach(proc.observers, observersIterator);
if (proc.parent) {
maybeForEach(proc.childrenObservers, observersIterator);
}
}
|
[
"function",
"runModelObservers",
"(",
"proc",
")",
"{",
"const",
"observersIterator",
"=",
"(",
"obs",
")",
"=>",
"obs",
"(",
")",
";",
"maybeForEach",
"(",
"proc",
".",
"observers",
",",
"observersIterator",
")",
";",
"if",
"(",
"proc",
".",
"parent",
")",
"{",
"maybeForEach",
"(",
"proc",
".",
"childrenObservers",
",",
"observersIterator",
")",
";",
"}",
"}"
] |
Ren all model observers and returns a Promise which will
be resolved when all handlers executed and returned promises
is also resolved
@private
@param {Process} proc
@return {Promise}
|
[
"Ren",
"all",
"model",
"observers",
"and",
"returns",
"a",
"Promise",
"which",
"will",
"be",
"resolved",
"when",
"all",
"handlers",
"executed",
"and",
"returned",
"promises",
"is",
"also",
"resolved"
] |
15bda5648462c171cc8e2dd0f8f15696655ce11a
|
https://github.com/mangojuicejs/mangojuice/blob/15bda5648462c171cc8e2dd0f8f15696655ce11a/packages/mangojuice-core/src/classes/Process.js#L216-L222
|
39,338 |
mangojuicejs/mangojuice
|
packages/mangojuice-core/src/classes/Process.js
|
execTask
|
function execTask(proc, taskObj) {
const { tasks, logger, model, sharedModel, config, logic } = proc;
const { task, executor, notifyCmd, successCmd, failCmd,
customArgs, execEvery, customExecId, id: taskId } = taskObj;
// If not in multi-thread mode or just need to cancel a tak –
// cancel all running task with same identifier (command id)
if (taskObj.cancelTask || !execEvery) {
cancelTask(proc, taskId);
if (taskObj.cancelTask) return;
}
// Define next execution id
const execId = customExecId || nextId();
const executions = tasks[taskId] = tasks[taskId] || {};
const cleanup = () => delete executions[execId];
// Do not create any new task if the task with given exec id
// already exists. Usefull for throttle/debounce tasks
if (executions[execId]) {
executions[execId].exec(taskObj);
} else {
const taskCall = executor(proc, taskObj);
executions[execId] = taskCall;
taskCall.exec(taskObj).then(cleanup, cleanup);
}
}
|
javascript
|
function execTask(proc, taskObj) {
const { tasks, logger, model, sharedModel, config, logic } = proc;
const { task, executor, notifyCmd, successCmd, failCmd,
customArgs, execEvery, customExecId, id: taskId } = taskObj;
// If not in multi-thread mode or just need to cancel a tak –
// cancel all running task with same identifier (command id)
if (taskObj.cancelTask || !execEvery) {
cancelTask(proc, taskId);
if (taskObj.cancelTask) return;
}
// Define next execution id
const execId = customExecId || nextId();
const executions = tasks[taskId] = tasks[taskId] || {};
const cleanup = () => delete executions[execId];
// Do not create any new task if the task with given exec id
// already exists. Usefull for throttle/debounce tasks
if (executions[execId]) {
executions[execId].exec(taskObj);
} else {
const taskCall = executor(proc, taskObj);
executions[execId] = taskCall;
taskCall.exec(taskObj).then(cleanup, cleanup);
}
}
|
[
"function",
"execTask",
"(",
"proc",
",",
"taskObj",
")",
"{",
"const",
"{",
"tasks",
",",
"logger",
",",
"model",
",",
"sharedModel",
",",
"config",
",",
"logic",
"}",
"=",
"proc",
";",
"const",
"{",
"task",
",",
"executor",
",",
"notifyCmd",
",",
"successCmd",
",",
"failCmd",
",",
"customArgs",
",",
"execEvery",
",",
"customExecId",
",",
"id",
":",
"taskId",
"}",
"=",
"taskObj",
";",
"// If not in multi-thread mode or just need to cancel a tak –",
"// cancel all running task with same identifier (command id)",
"if",
"(",
"taskObj",
".",
"cancelTask",
"||",
"!",
"execEvery",
")",
"{",
"cancelTask",
"(",
"proc",
",",
"taskId",
")",
";",
"if",
"(",
"taskObj",
".",
"cancelTask",
")",
"return",
";",
"}",
"// Define next execution id",
"const",
"execId",
"=",
"customExecId",
"||",
"nextId",
"(",
")",
";",
"const",
"executions",
"=",
"tasks",
"[",
"taskId",
"]",
"=",
"tasks",
"[",
"taskId",
"]",
"||",
"{",
"}",
";",
"const",
"cleanup",
"=",
"(",
")",
"=>",
"delete",
"executions",
"[",
"execId",
"]",
";",
"// Do not create any new task if the task with given exec id",
"// already exists. Usefull for throttle/debounce tasks",
"if",
"(",
"executions",
"[",
"execId",
"]",
")",
"{",
"executions",
"[",
"execId",
"]",
".",
"exec",
"(",
"taskObj",
")",
";",
"}",
"else",
"{",
"const",
"taskCall",
"=",
"executor",
"(",
"proc",
",",
"taskObj",
")",
";",
"executions",
"[",
"execId",
"]",
"=",
"taskCall",
";",
"taskCall",
".",
"exec",
"(",
"taskObj",
")",
".",
"then",
"(",
"cleanup",
",",
"cleanup",
")",
";",
"}",
"}"
] |
Execute given task object in scope of given Process.
Returns a Promise which will be resolved when task will
be resolved or reject with with a command, which should
be executed next.
@private
@param {Process} proc
@param {Task} taskObj
@return {Promise}
|
[
"Execute",
"given",
"task",
"object",
"in",
"scope",
"of",
"given",
"Process",
".",
"Returns",
"a",
"Promise",
"which",
"will",
"be",
"resolved",
"when",
"task",
"will",
"be",
"resolved",
"or",
"reject",
"with",
"with",
"a",
"command",
"which",
"should",
"be",
"executed",
"next",
"."
] |
15bda5648462c171cc8e2dd0f8f15696655ce11a
|
https://github.com/mangojuicejs/mangojuice/blob/15bda5648462c171cc8e2dd0f8f15696655ce11a/packages/mangojuice-core/src/classes/Process.js#L328-L354
|
39,339 |
ply-ct/ply
|
lib/subst.js
|
function(template, map, fallback) {
if (!map)
return template;
return template.replace(/\$\{.+?}/g, (match) => {
const path = match.substr(2, match.length - 3).trim();
return get(path, map, fallback);
});
}
|
javascript
|
function(template, map, fallback) {
if (!map)
return template;
return template.replace(/\$\{.+?}/g, (match) => {
const path = match.substr(2, match.length - 3).trim();
return get(path, map, fallback);
});
}
|
[
"function",
"(",
"template",
",",
"map",
",",
"fallback",
")",
"{",
"if",
"(",
"!",
"map",
")",
"return",
"template",
";",
"return",
"template",
".",
"replace",
"(",
"/",
"\\$\\{.+?}",
"/",
"g",
",",
"(",
"match",
")",
"=>",
"{",
"const",
"path",
"=",
"match",
".",
"substr",
"(",
"2",
",",
"match",
".",
"length",
"-",
"3",
")",
".",
"trim",
"(",
")",
";",
"return",
"get",
"(",
"path",
",",
"map",
",",
"fallback",
")",
";",
"}",
")",
";",
"}"
] |
Replaces template expressions with values.
|
[
"Replaces",
"template",
"expressions",
"with",
"values",
"."
] |
1d4146829845fedd917f5f0626cd74cc3845d0c8
|
https://github.com/ply-ct/ply/blob/1d4146829845fedd917f5f0626cd74cc3845d0c8/lib/subst.js#L11-L18
|
|
39,340 |
chrisJohn404/ljswitchboard-ljm_device_curator
|
lib/t7_flash_operations.js
|
function(address, innerSize, writeValues)
{
return function (lastResults) {
var innerDeferred = q.defer();
var addresses = [];
var values = [];
var directions = [];
var numFrames;
var numValues;
// Flash memory pointer
directions.push(driver_const.LJM_WRITE);
// Key
if (key === undefined) {
numFrames = 2;
numValues = [1];
} else {
// Write for key
directions.push(driver_const.LJM_WRITE);
addresses.push(driver_const.T7_MA_EXF_KEY);
values.push(key);
numFrames = 3;
numValues = [1, 1];
}
if (isReadOp)
directions.push(driver_const.LJM_READ);
else
directions.push(driver_const.LJM_WRITE);
addresses.push(ptrAddress);
values.push(address);
addresses.push(flashAddress);
if (isReadOp) {
for (var i=0; i<innerSize; i++) {
values.push(null);
}
} else {
values.push.apply(values, writeValues);
}
numValues.push(innerSize);
device.rwMany(
addresses,
directions,
numValues,
values,
// createSafeReject(innerDeferred),
function(err) {
// console.log('tseries_upgrade: calling rwMany', isReadOp, addresses, directions, numValues, values);
// console.log('tseries_upgrade: rwMany Error', err);
// console.log('Throwing Upgrade Error', err);
if(!isReadOp) {
// console.log('Failed to write flash data', addresses, numValues, values, err);
}
var callFunc = createSafeReject(innerDeferred);
callFunc(err);
},
function (newResults) {
if(!isReadOp) {
// console.log('Successfully wrote flash data', addresses, numValues, values);
}
lastResults.push.apply(lastResults, newResults);
innerDeferred.resolve(lastResults);
}
);
return innerDeferred.promise;
};
}
|
javascript
|
function(address, innerSize, writeValues)
{
return function (lastResults) {
var innerDeferred = q.defer();
var addresses = [];
var values = [];
var directions = [];
var numFrames;
var numValues;
// Flash memory pointer
directions.push(driver_const.LJM_WRITE);
// Key
if (key === undefined) {
numFrames = 2;
numValues = [1];
} else {
// Write for key
directions.push(driver_const.LJM_WRITE);
addresses.push(driver_const.T7_MA_EXF_KEY);
values.push(key);
numFrames = 3;
numValues = [1, 1];
}
if (isReadOp)
directions.push(driver_const.LJM_READ);
else
directions.push(driver_const.LJM_WRITE);
addresses.push(ptrAddress);
values.push(address);
addresses.push(flashAddress);
if (isReadOp) {
for (var i=0; i<innerSize; i++) {
values.push(null);
}
} else {
values.push.apply(values, writeValues);
}
numValues.push(innerSize);
device.rwMany(
addresses,
directions,
numValues,
values,
// createSafeReject(innerDeferred),
function(err) {
// console.log('tseries_upgrade: calling rwMany', isReadOp, addresses, directions, numValues, values);
// console.log('tseries_upgrade: rwMany Error', err);
// console.log('Throwing Upgrade Error', err);
if(!isReadOp) {
// console.log('Failed to write flash data', addresses, numValues, values, err);
}
var callFunc = createSafeReject(innerDeferred);
callFunc(err);
},
function (newResults) {
if(!isReadOp) {
// console.log('Successfully wrote flash data', addresses, numValues, values);
}
lastResults.push.apply(lastResults, newResults);
innerDeferred.resolve(lastResults);
}
);
return innerDeferred.promise;
};
}
|
[
"function",
"(",
"address",
",",
"innerSize",
",",
"writeValues",
")",
"{",
"return",
"function",
"(",
"lastResults",
")",
"{",
"var",
"innerDeferred",
"=",
"q",
".",
"defer",
"(",
")",
";",
"var",
"addresses",
"=",
"[",
"]",
";",
"var",
"values",
"=",
"[",
"]",
";",
"var",
"directions",
"=",
"[",
"]",
";",
"var",
"numFrames",
";",
"var",
"numValues",
";",
"// Flash memory pointer",
"directions",
".",
"push",
"(",
"driver_const",
".",
"LJM_WRITE",
")",
";",
"// Key",
"if",
"(",
"key",
"===",
"undefined",
")",
"{",
"numFrames",
"=",
"2",
";",
"numValues",
"=",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"// Write for key",
"directions",
".",
"push",
"(",
"driver_const",
".",
"LJM_WRITE",
")",
";",
"addresses",
".",
"push",
"(",
"driver_const",
".",
"T7_MA_EXF_KEY",
")",
";",
"values",
".",
"push",
"(",
"key",
")",
";",
"numFrames",
"=",
"3",
";",
"numValues",
"=",
"[",
"1",
",",
"1",
"]",
";",
"}",
"if",
"(",
"isReadOp",
")",
"directions",
".",
"push",
"(",
"driver_const",
".",
"LJM_READ",
")",
";",
"else",
"directions",
".",
"push",
"(",
"driver_const",
".",
"LJM_WRITE",
")",
";",
"addresses",
".",
"push",
"(",
"ptrAddress",
")",
";",
"values",
".",
"push",
"(",
"address",
")",
";",
"addresses",
".",
"push",
"(",
"flashAddress",
")",
";",
"if",
"(",
"isReadOp",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"innerSize",
";",
"i",
"++",
")",
"{",
"values",
".",
"push",
"(",
"null",
")",
";",
"}",
"}",
"else",
"{",
"values",
".",
"push",
".",
"apply",
"(",
"values",
",",
"writeValues",
")",
";",
"}",
"numValues",
".",
"push",
"(",
"innerSize",
")",
";",
"device",
".",
"rwMany",
"(",
"addresses",
",",
"directions",
",",
"numValues",
",",
"values",
",",
"// createSafeReject(innerDeferred),",
"function",
"(",
"err",
")",
"{",
"// console.log('tseries_upgrade: calling rwMany', isReadOp, addresses, directions, numValues, values);",
"// console.log('tseries_upgrade: rwMany Error', err);",
"// console.log('Throwing Upgrade Error', err);",
"if",
"(",
"!",
"isReadOp",
")",
"{",
"// console.log('Failed to write flash data', addresses, numValues, values, err);",
"}",
"var",
"callFunc",
"=",
"createSafeReject",
"(",
"innerDeferred",
")",
";",
"callFunc",
"(",
"err",
")",
";",
"}",
",",
"function",
"(",
"newResults",
")",
"{",
"if",
"(",
"!",
"isReadOp",
")",
"{",
"// console.log('Successfully wrote flash data', addresses, numValues, values);",
"}",
"lastResults",
".",
"push",
".",
"apply",
"(",
"lastResults",
",",
"newResults",
")",
";",
"innerDeferred",
".",
"resolve",
"(",
"lastResults",
")",
";",
"}",
")",
";",
"return",
"innerDeferred",
".",
"promise",
";",
"}",
";",
"}"
] |
Creates a closure over a rw excutiong with an address and size
|
[
"Creates",
"a",
"closure",
"over",
"a",
"rw",
"excutiong",
"with",
"an",
"address",
"and",
"size"
] |
36cb25645dfa0a68e906d5ec43e5514391947257
|
https://github.com/chrisJohn404/ljswitchboard-ljm_device_curator/blob/36cb25645dfa0a68e906d5ec43e5514391947257/lib/t7_flash_operations.js#L104-L176
|
|
39,341 |
zettaforge/unity-module-scripts
|
lib/index.js
|
function (name, pkgDir) {
if (!isString(name) || !isString(pkgDir) ||
S(name).isEmpty() || S(pkgDir).isEmpty() || !isDirectory.sync(pkgDir)) {
return 1
}
var scope = utils(name, pkgDir)
try {
scope.validateIsUnityRoot()
scope.createModulesDirectoryInAssets()
scope.createModuleDirectory()
scope.copyModuleResources()
} catch (err) {
scope.cleanupOnPostInstallError()
scope.printError(err)
return 1
}
return 0
}
|
javascript
|
function (name, pkgDir) {
if (!isString(name) || !isString(pkgDir) ||
S(name).isEmpty() || S(pkgDir).isEmpty() || !isDirectory.sync(pkgDir)) {
return 1
}
var scope = utils(name, pkgDir)
try {
scope.validateIsUnityRoot()
scope.createModulesDirectoryInAssets()
scope.createModuleDirectory()
scope.copyModuleResources()
} catch (err) {
scope.cleanupOnPostInstallError()
scope.printError(err)
return 1
}
return 0
}
|
[
"function",
"(",
"name",
",",
"pkgDir",
")",
"{",
"if",
"(",
"!",
"isString",
"(",
"name",
")",
"||",
"!",
"isString",
"(",
"pkgDir",
")",
"||",
"S",
"(",
"name",
")",
".",
"isEmpty",
"(",
")",
"||",
"S",
"(",
"pkgDir",
")",
".",
"isEmpty",
"(",
")",
"||",
"!",
"isDirectory",
".",
"sync",
"(",
"pkgDir",
")",
")",
"{",
"return",
"1",
"}",
"var",
"scope",
"=",
"utils",
"(",
"name",
",",
"pkgDir",
")",
"try",
"{",
"scope",
".",
"validateIsUnityRoot",
"(",
")",
"scope",
".",
"createModulesDirectoryInAssets",
"(",
")",
"scope",
".",
"createModuleDirectory",
"(",
")",
"scope",
".",
"copyModuleResources",
"(",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"scope",
".",
"cleanupOnPostInstallError",
"(",
")",
"scope",
".",
"printError",
"(",
"err",
")",
"return",
"1",
"}",
"return",
"0",
"}"
] |
A simple implementation of postinstall that would be suitable for most packages that only contain git-hosted assets. Returns a falsy value if the routine succeeded.
|
[
"A",
"simple",
"implementation",
"of",
"postinstall",
"that",
"would",
"be",
"suitable",
"for",
"most",
"packages",
"that",
"only",
"contain",
"git",
"-",
"hosted",
"assets",
".",
"Returns",
"a",
"falsy",
"value",
"if",
"the",
"routine",
"succeeded",
"."
] |
e058e258939fc2e8ea0514eb406d49bb3f6140de
|
https://github.com/zettaforge/unity-module-scripts/blob/e058e258939fc2e8ea0514eb406d49bb3f6140de/lib/index.js#L72-L89
|
|
39,342 |
zettaforge/unity-module-scripts
|
lib/index.js
|
function (name, pkgDir) {
if (!isString(name) || !isString(pkgDir) ||
S(name).isEmpty() || S(pkgDir).isEmpty() || !isDirectory.sync(pkgDir)) {
return 1
}
var scope = utils(name, pkgDir)
try {
scope.removeModuleDirectory()
} catch (err) {
scope.printError(err)
return 1
}
return 0
}
|
javascript
|
function (name, pkgDir) {
if (!isString(name) || !isString(pkgDir) ||
S(name).isEmpty() || S(pkgDir).isEmpty() || !isDirectory.sync(pkgDir)) {
return 1
}
var scope = utils(name, pkgDir)
try {
scope.removeModuleDirectory()
} catch (err) {
scope.printError(err)
return 1
}
return 0
}
|
[
"function",
"(",
"name",
",",
"pkgDir",
")",
"{",
"if",
"(",
"!",
"isString",
"(",
"name",
")",
"||",
"!",
"isString",
"(",
"pkgDir",
")",
"||",
"S",
"(",
"name",
")",
".",
"isEmpty",
"(",
")",
"||",
"S",
"(",
"pkgDir",
")",
".",
"isEmpty",
"(",
")",
"||",
"!",
"isDirectory",
".",
"sync",
"(",
"pkgDir",
")",
")",
"{",
"return",
"1",
"}",
"var",
"scope",
"=",
"utils",
"(",
"name",
",",
"pkgDir",
")",
"try",
"{",
"scope",
".",
"removeModuleDirectory",
"(",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"scope",
".",
"printError",
"(",
"err",
")",
"return",
"1",
"}",
"return",
"0",
"}"
] |
A simple implementation of postuninstall that would be suitable for most packages that only contain git-hosted assets. Returns a falsy value if the routine succeeded.
|
[
"A",
"simple",
"implementation",
"of",
"postuninstall",
"that",
"would",
"be",
"suitable",
"for",
"most",
"packages",
"that",
"only",
"contain",
"git",
"-",
"hosted",
"assets",
".",
"Returns",
"a",
"falsy",
"value",
"if",
"the",
"routine",
"succeeded",
"."
] |
e058e258939fc2e8ea0514eb406d49bb3f6140de
|
https://github.com/zettaforge/unity-module-scripts/blob/e058e258939fc2e8ea0514eb406d49bb3f6140de/lib/index.js#L94-L107
|
|
39,343 |
burnnat/grunt-debug
|
tasks/lib/hooks.js
|
function(grunt) {
var me = this;
this.hookChild(
grunt.util,
'spawn',
function(original, spawnArgs) {
var options = spawnArgs[0];
var callback = spawnArgs[1];
if (options.cmd === process.argv[0]) {
var module;
for (var i = 0; i < options.args.length; i++) {
if (options.args[i].lastIndexOf('--') != 0) {
module = options.args[i];
break;
}
}
me.addDebugArg(options.args, module);
}
return original.call(this, options, callback);
}
);
}
|
javascript
|
function(grunt) {
var me = this;
this.hookChild(
grunt.util,
'spawn',
function(original, spawnArgs) {
var options = spawnArgs[0];
var callback = spawnArgs[1];
if (options.cmd === process.argv[0]) {
var module;
for (var i = 0; i < options.args.length; i++) {
if (options.args[i].lastIndexOf('--') != 0) {
module = options.args[i];
break;
}
}
me.addDebugArg(options.args, module);
}
return original.call(this, options, callback);
}
);
}
|
[
"function",
"(",
"grunt",
")",
"{",
"var",
"me",
"=",
"this",
";",
"this",
".",
"hookChild",
"(",
"grunt",
".",
"util",
",",
"'spawn'",
",",
"function",
"(",
"original",
",",
"spawnArgs",
")",
"{",
"var",
"options",
"=",
"spawnArgs",
"[",
"0",
"]",
";",
"var",
"callback",
"=",
"spawnArgs",
"[",
"1",
"]",
";",
"if",
"(",
"options",
".",
"cmd",
"===",
"process",
".",
"argv",
"[",
"0",
"]",
")",
"{",
"var",
"module",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"options",
".",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"options",
".",
"args",
"[",
"i",
"]",
".",
"lastIndexOf",
"(",
"'--'",
")",
"!=",
"0",
")",
"{",
"module",
"=",
"options",
".",
"args",
"[",
"i",
"]",
";",
"break",
";",
"}",
"}",
"me",
".",
"addDebugArg",
"(",
"options",
".",
"args",
",",
"module",
")",
";",
"}",
"return",
"original",
".",
"call",
"(",
"this",
",",
"options",
",",
"callback",
")",
";",
"}",
")",
";",
"}"
] |
Monkey-patch grunt `spawn` function to enable debugging on child processes.
|
[
"Monkey",
"-",
"patch",
"grunt",
"spawn",
"function",
"to",
"enable",
"debugging",
"on",
"child",
"processes",
"."
] |
968fefb5c99621752bc8b81d0fe865c1f90b8eb0
|
https://github.com/burnnat/grunt-debug/blob/968fefb5c99621752bc8b81d0fe865c1f90b8eb0/tasks/lib/hooks.js#L59-L85
|
|
39,344 |
alexcjohnson/world-calendars
|
dist/calendars/chinese.js
|
function(year, monthIndex) {
if (year.year) {
year = year.year();
monthIndex = year.month();
}
var intercalaryMonth = this.intercalaryMonth(year);
return !!intercalaryMonth && intercalaryMonth === monthIndex;
}
|
javascript
|
function(year, monthIndex) {
if (year.year) {
year = year.year();
monthIndex = year.month();
}
var intercalaryMonth = this.intercalaryMonth(year);
return !!intercalaryMonth && intercalaryMonth === monthIndex;
}
|
[
"function",
"(",
"year",
",",
"monthIndex",
")",
"{",
"if",
"(",
"year",
".",
"year",
")",
"{",
"year",
"=",
"year",
".",
"year",
"(",
")",
";",
"monthIndex",
"=",
"year",
".",
"month",
"(",
")",
";",
"}",
"var",
"intercalaryMonth",
"=",
"this",
".",
"intercalaryMonth",
"(",
"year",
")",
";",
"return",
"!",
"!",
"intercalaryMonth",
"&&",
"intercalaryMonth",
"===",
"monthIndex",
";",
"}"
] |
Determine whether this date is an intercalary month.
@memberof ChineseCalendar
@param year {CDate|number} The date to examine or the year to examine.
@param [monthIndex] {number} The month index to examine.
@return {boolean} <code>true</code> if this is an intercalary month, <code>false</code> if not.
@throws Error if an invalid year or a different calendar used.
|
[
"Determine",
"whether",
"this",
"date",
"is",
"an",
"intercalary",
"month",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/calendars/chinese.js#L278-L287
|
|
39,345 |
alexcjohnson/world-calendars
|
dist/calendars/chinese.js
|
function(dateString) {
var match = dateString.match(DATE_REGEXP);
var year = this._validateYear(+match[1]);
var month = +match[2];
var isIntercalary = !!match[3];
var monthIndex = this.toMonthIndex(year, month, isIntercalary);
var day = +match[4];
return this.newDate(year, monthIndex, day);
}
|
javascript
|
function(dateString) {
var match = dateString.match(DATE_REGEXP);
var year = this._validateYear(+match[1]);
var month = +match[2];
var isIntercalary = !!match[3];
var monthIndex = this.toMonthIndex(year, month, isIntercalary);
var day = +match[4];
return this.newDate(year, monthIndex, day);
}
|
[
"function",
"(",
"dateString",
")",
"{",
"var",
"match",
"=",
"dateString",
".",
"match",
"(",
"DATE_REGEXP",
")",
";",
"var",
"year",
"=",
"this",
".",
"_validateYear",
"(",
"+",
"match",
"[",
"1",
"]",
")",
";",
"var",
"month",
"=",
"+",
"match",
"[",
"2",
"]",
";",
"var",
"isIntercalary",
"=",
"!",
"!",
"match",
"[",
"3",
"]",
";",
"var",
"monthIndex",
"=",
"this",
".",
"toMonthIndex",
"(",
"year",
",",
"month",
",",
"isIntercalary",
")",
";",
"var",
"day",
"=",
"+",
"match",
"[",
"4",
"]",
";",
"return",
"this",
".",
"newDate",
"(",
"year",
",",
"monthIndex",
",",
"day",
")",
";",
"}"
] |
Create a new date from a string.
@memberof ChineseCalendar
@param dateString {string} String representing a Chinese date
@return {CDate} The new date.
@throws Error if an invalid date.
|
[
"Create",
"a",
"new",
"date",
"from",
"a",
"string",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/dist/calendars/chinese.js#L415-L427
|
|
39,346 |
bfontaine/ArrayDB
|
src/arraydb.js
|
cleanMarks
|
function cleanMarks( o ) {
delete o[randKey];
for ( prop in o ) {
if ( p.hasOwnProperty( prop )
&& get_type( p[prop] ) == 'object'
&& randKey in p[prop]) {
cleanMarks( p[prop] );
}
}
}
|
javascript
|
function cleanMarks( o ) {
delete o[randKey];
for ( prop in o ) {
if ( p.hasOwnProperty( prop )
&& get_type( p[prop] ) == 'object'
&& randKey in p[prop]) {
cleanMarks( p[prop] );
}
}
}
|
[
"function",
"cleanMarks",
"(",
"o",
")",
"{",
"delete",
"o",
"[",
"randKey",
"]",
";",
"for",
"(",
"prop",
"in",
"o",
")",
"{",
"if",
"(",
"p",
".",
"hasOwnProperty",
"(",
"prop",
")",
"&&",
"get_type",
"(",
"p",
"[",
"prop",
"]",
")",
"==",
"'object'",
"&&",
"randKey",
"in",
"p",
"[",
"prop",
"]",
")",
"{",
"cleanMarks",
"(",
"p",
"[",
"prop",
"]",
")",
";",
"}",
"}",
"}"
] |
clean up marked objects
|
[
"clean",
"up",
"marked",
"objects"
] |
011939dda73cfbea112bb803480e849afba14e92
|
https://github.com/bfontaine/ArrayDB/blob/011939dda73cfbea112bb803480e849afba14e92/src/arraydb.js#L117-L127
|
39,347 |
bfontaine/ArrayDB
|
src/arraydb.js
|
match_objects_teardown
|
function match_objects_teardown( o, p, result ) {
if ( get_type( o ) == 'object' ) { cleanMarks( o ); }
if ( get_type( p ) == 'object' ) { cleanMarks( p ); }
return result;
}
|
javascript
|
function match_objects_teardown( o, p, result ) {
if ( get_type( o ) == 'object' ) { cleanMarks( o ); }
if ( get_type( p ) == 'object' ) { cleanMarks( p ); }
return result;
}
|
[
"function",
"match_objects_teardown",
"(",
"o",
",",
"p",
",",
"result",
")",
"{",
"if",
"(",
"get_type",
"(",
"o",
")",
"==",
"'object'",
")",
"{",
"cleanMarks",
"(",
"o",
")",
";",
"}",
"if",
"(",
"get_type",
"(",
"p",
")",
"==",
"'object'",
")",
"{",
"cleanMarks",
"(",
"p",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
clean up marked objects and return result
|
[
"clean",
"up",
"marked",
"objects",
"and",
"return",
"result"
] |
011939dda73cfbea112bb803480e849afba14e92
|
https://github.com/bfontaine/ArrayDB/blob/011939dda73cfbea112bb803480e849afba14e92/src/arraydb.js#L130-L134
|
39,348 |
bfontaine/ArrayDB
|
src/arraydb.js
|
query
|
function query( q, limit, offset ) {
var i, _l, res,
strict = true,
reverse = false;
if ( this.length === 0 || arguments.length === 0 ) {
return [];
}
if ( typeof q === 'object' && q != null
&& 'query' in q
&& arguments.length === 1 ) {
limit = +q.limit;
offset = +q.offset;
strict = !!q.strict;
reverse = !!q.reverse;
q = q.query;
}
if ( isNaN( limit ) ) {
limit = Infinity;
}
offset = offset || 0;
if ( typeof Array.prototype.filter === 'function' ) {
return this.filter(function( o ) {
return match( o, q, strict ) === !reverse;
}).slice( offset, offset + limit );
}
res = [];
_l = Math.min( this.length, limit + offset );
i = 0;
for ( ; i<_l; i++ ) {
if ( match( this[ i ], q, strict ) === !reverse ) {
if ( offset-- > 0 ) { continue; }
res.push( this[ i ] );
}
}
return res;
}
|
javascript
|
function query( q, limit, offset ) {
var i, _l, res,
strict = true,
reverse = false;
if ( this.length === 0 || arguments.length === 0 ) {
return [];
}
if ( typeof q === 'object' && q != null
&& 'query' in q
&& arguments.length === 1 ) {
limit = +q.limit;
offset = +q.offset;
strict = !!q.strict;
reverse = !!q.reverse;
q = q.query;
}
if ( isNaN( limit ) ) {
limit = Infinity;
}
offset = offset || 0;
if ( typeof Array.prototype.filter === 'function' ) {
return this.filter(function( o ) {
return match( o, q, strict ) === !reverse;
}).slice( offset, offset + limit );
}
res = [];
_l = Math.min( this.length, limit + offset );
i = 0;
for ( ; i<_l; i++ ) {
if ( match( this[ i ], q, strict ) === !reverse ) {
if ( offset-- > 0 ) { continue; }
res.push( this[ i ] );
}
}
return res;
}
|
[
"function",
"query",
"(",
"q",
",",
"limit",
",",
"offset",
")",
"{",
"var",
"i",
",",
"_l",
",",
"res",
",",
"strict",
"=",
"true",
",",
"reverse",
"=",
"false",
";",
"if",
"(",
"this",
".",
"length",
"===",
"0",
"||",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"typeof",
"q",
"===",
"'object'",
"&&",
"q",
"!=",
"null",
"&&",
"'query'",
"in",
"q",
"&&",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"limit",
"=",
"+",
"q",
".",
"limit",
";",
"offset",
"=",
"+",
"q",
".",
"offset",
";",
"strict",
"=",
"!",
"!",
"q",
".",
"strict",
";",
"reverse",
"=",
"!",
"!",
"q",
".",
"reverse",
";",
"q",
"=",
"q",
".",
"query",
";",
"}",
"if",
"(",
"isNaN",
"(",
"limit",
")",
")",
"{",
"limit",
"=",
"Infinity",
";",
"}",
"offset",
"=",
"offset",
"||",
"0",
";",
"if",
"(",
"typeof",
"Array",
".",
"prototype",
".",
"filter",
"===",
"'function'",
")",
"{",
"return",
"this",
".",
"filter",
"(",
"function",
"(",
"o",
")",
"{",
"return",
"match",
"(",
"o",
",",
"q",
",",
"strict",
")",
"===",
"!",
"reverse",
";",
"}",
")",
".",
"slice",
"(",
"offset",
",",
"offset",
"+",
"limit",
")",
";",
"}",
"res",
"=",
"[",
"]",
";",
"_l",
"=",
"Math",
".",
"min",
"(",
"this",
".",
"length",
",",
"limit",
"+",
"offset",
")",
";",
"i",
"=",
"0",
";",
"for",
"(",
";",
"i",
"<",
"_l",
";",
"i",
"++",
")",
"{",
"if",
"(",
"match",
"(",
"this",
"[",
"i",
"]",
",",
"q",
",",
"strict",
")",
"===",
"!",
"reverse",
")",
"{",
"if",
"(",
"offset",
"--",
">",
"0",
")",
"{",
"continue",
";",
"}",
"res",
".",
"push",
"(",
"this",
"[",
"i",
"]",
")",
";",
"}",
"}",
"return",
"res",
";",
"}"
] |
Main function. Will be called on an ArrayDB or Array
object.
@q [Object]: the query. If it's the only one argument and it has
a 'query' property, it's used to specify other arguments,
e.g.: {
query: <the query>,
limit: <the limit>,
offset: <the offset>,
strict: <strict mode?>,
reverse: <reversed query?>
}
@limit [Number]: optional. The maximum number of results. Default
to Infinity.
@offset [Number]: optional. Default to 0.
|
[
"Main",
"function",
".",
"Will",
"be",
"called",
"on",
"an",
"ArrayDB",
"or",
"Array",
"object",
"."
] |
011939dda73cfbea112bb803480e849afba14e92
|
https://github.com/bfontaine/ArrayDB/blob/011939dda73cfbea112bb803480e849afba14e92/src/arraydb.js#L247-L308
|
39,349 |
quick-sort/jstock
|
index.js
|
wma
|
function wma(close, n = 5) {
let result = []
let len = close.length
if (len === 0 || n <= 0) {
return result
}
let avg = close[0]
result.push(avg)
let T_m = close[0]
let div = n * (n + 1) / 2
for (let i = 1; i < len; i++) {
if (i < n) {
T_m += close[i]
let sum = 0
let d = 0
for (let j = 0; j <= i; j++) {
sum += close[i - j] * (n - j)
d += (n - j)
}
avg = sum / d
} else {
avg += (n * close[i] - T_m) / div
T_m += close[i] - close[i - n]
}
result.push(avg)
}
return result
}
|
javascript
|
function wma(close, n = 5) {
let result = []
let len = close.length
if (len === 0 || n <= 0) {
return result
}
let avg = close[0]
result.push(avg)
let T_m = close[0]
let div = n * (n + 1) / 2
for (let i = 1; i < len; i++) {
if (i < n) {
T_m += close[i]
let sum = 0
let d = 0
for (let j = 0; j <= i; j++) {
sum += close[i - j] * (n - j)
d += (n - j)
}
avg = sum / d
} else {
avg += (n * close[i] - T_m) / div
T_m += close[i] - close[i - n]
}
result.push(avg)
}
return result
}
|
[
"function",
"wma",
"(",
"close",
",",
"n",
"=",
"5",
")",
"{",
"let",
"result",
"=",
"[",
"]",
"let",
"len",
"=",
"close",
".",
"length",
"if",
"(",
"len",
"===",
"0",
"||",
"n",
"<=",
"0",
")",
"{",
"return",
"result",
"}",
"let",
"avg",
"=",
"close",
"[",
"0",
"]",
"result",
".",
"push",
"(",
"avg",
")",
"let",
"T_m",
"=",
"close",
"[",
"0",
"]",
"let",
"div",
"=",
"n",
"*",
"(",
"n",
"+",
"1",
")",
"/",
"2",
"for",
"(",
"let",
"i",
"=",
"1",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"<",
"n",
")",
"{",
"T_m",
"+=",
"close",
"[",
"i",
"]",
"let",
"sum",
"=",
"0",
"let",
"d",
"=",
"0",
"for",
"(",
"let",
"j",
"=",
"0",
";",
"j",
"<=",
"i",
";",
"j",
"++",
")",
"{",
"sum",
"+=",
"close",
"[",
"i",
"-",
"j",
"]",
"*",
"(",
"n",
"-",
"j",
")",
"d",
"+=",
"(",
"n",
"-",
"j",
")",
"}",
"avg",
"=",
"sum",
"/",
"d",
"}",
"else",
"{",
"avg",
"+=",
"(",
"n",
"*",
"close",
"[",
"i",
"]",
"-",
"T_m",
")",
"/",
"div",
"T_m",
"+=",
"close",
"[",
"i",
"]",
"-",
"close",
"[",
"i",
"-",
"n",
"]",
"}",
"result",
".",
"push",
"(",
"avg",
")",
"}",
"return",
"result",
"}"
] |
Weighted moving average
|
[
"Weighted",
"moving",
"average"
] |
52e58c982c72b97bf55e1efc3f2637bf4c209181
|
https://github.com/quick-sort/jstock/blob/52e58c982c72b97bf55e1efc3f2637bf4c209181/index.js#L32-L60
|
39,350 |
quick-sort/jstock
|
index.js
|
ema
|
function ema(close, n = 5) {
let len = close.length
let result = []
if (len === 0 || n <= 0) {
return result
}
let alpha = 2 / (n + 1)
let avg = close[0]
result.push(avg)
for (let i = 1; i < len; i++) {
avg = alpha * close[i] + (1 - alpha) * avg
result.push(avg)
}
return result
}
|
javascript
|
function ema(close, n = 5) {
let len = close.length
let result = []
if (len === 0 || n <= 0) {
return result
}
let alpha = 2 / (n + 1)
let avg = close[0]
result.push(avg)
for (let i = 1; i < len; i++) {
avg = alpha * close[i] + (1 - alpha) * avg
result.push(avg)
}
return result
}
|
[
"function",
"ema",
"(",
"close",
",",
"n",
"=",
"5",
")",
"{",
"let",
"len",
"=",
"close",
".",
"length",
"let",
"result",
"=",
"[",
"]",
"if",
"(",
"len",
"===",
"0",
"||",
"n",
"<=",
"0",
")",
"{",
"return",
"result",
"}",
"let",
"alpha",
"=",
"2",
"/",
"(",
"n",
"+",
"1",
")",
"let",
"avg",
"=",
"close",
"[",
"0",
"]",
"result",
".",
"push",
"(",
"avg",
")",
"for",
"(",
"let",
"i",
"=",
"1",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"avg",
"=",
"alpha",
"*",
"close",
"[",
"i",
"]",
"+",
"(",
"1",
"-",
"alpha",
")",
"*",
"avg",
"result",
".",
"push",
"(",
"avg",
")",
"}",
"return",
"result",
"}"
] |
Exponential moving average
alpha = 2 / (N + 1)
|
[
"Exponential",
"moving",
"average"
] |
52e58c982c72b97bf55e1efc3f2637bf4c209181
|
https://github.com/quick-sort/jstock/blob/52e58c982c72b97bf55e1efc3f2637bf4c209181/index.js#L66-L80
|
39,351 |
quick-sort/jstock
|
index.js
|
kdj
|
function kdj(close, high, low, n = 5) {
let len = close.length
let k = []
let d = []
let j = []
if (len === 0 || n <= 0) {
return {k, d, j}
}
let ik = 50
let id = 50
let ij = 50
let rsv = (close[0] - low[0]) * 100 / (high[0] - low[0])
ik = 2 * ik / 3 + rsv / 3
id = 2 * id / 3 + ik / 3
ij = 3 * ik - 2 * id
k.push(ik)
d.push(id)
j.push(ij)
let ln = low[0]
let hn = high[0]
for (let i = 1; i < len; i++) {
if (i < n) {
if (ln > low[i]) {
ln = low[i]
}
if (hn < high[i]) {
hn = high[i]
}
} else {
if (ln === low[i - n]) {
ln = low[i]
for (let j = 1; j < n; j++) {
if (low[i - j] < ln) {
ln = low[i - j]
}
}
} else {
if (ln > low[i]) {
ln = low[i]
}
}
if (hn === high[i - n]) {
hn = high[i]
for (let j = 1; j < n; j++) {
if (high[i - j] > hn) {
hn = high[i - j]
}
}
} else {
if (hn < high[i]) {
hn = high[i]
}
}
}
rsv = (close[i] - ln) * 100 / (hn - ln)
ik = 2 * ik / 3 + rsv / 3
id = 2 * id / 3 + ik / 3
ij = 3 * ik - 2 * id
k.push(ik)
d.push(id)
j.push(ij)
}
return {k, d, j}
}
|
javascript
|
function kdj(close, high, low, n = 5) {
let len = close.length
let k = []
let d = []
let j = []
if (len === 0 || n <= 0) {
return {k, d, j}
}
let ik = 50
let id = 50
let ij = 50
let rsv = (close[0] - low[0]) * 100 / (high[0] - low[0])
ik = 2 * ik / 3 + rsv / 3
id = 2 * id / 3 + ik / 3
ij = 3 * ik - 2 * id
k.push(ik)
d.push(id)
j.push(ij)
let ln = low[0]
let hn = high[0]
for (let i = 1; i < len; i++) {
if (i < n) {
if (ln > low[i]) {
ln = low[i]
}
if (hn < high[i]) {
hn = high[i]
}
} else {
if (ln === low[i - n]) {
ln = low[i]
for (let j = 1; j < n; j++) {
if (low[i - j] < ln) {
ln = low[i - j]
}
}
} else {
if (ln > low[i]) {
ln = low[i]
}
}
if (hn === high[i - n]) {
hn = high[i]
for (let j = 1; j < n; j++) {
if (high[i - j] > hn) {
hn = high[i - j]
}
}
} else {
if (hn < high[i]) {
hn = high[i]
}
}
}
rsv = (close[i] - ln) * 100 / (hn - ln)
ik = 2 * ik / 3 + rsv / 3
id = 2 * id / 3 + ik / 3
ij = 3 * ik - 2 * id
k.push(ik)
d.push(id)
j.push(ij)
}
return {k, d, j}
}
|
[
"function",
"kdj",
"(",
"close",
",",
"high",
",",
"low",
",",
"n",
"=",
"5",
")",
"{",
"let",
"len",
"=",
"close",
".",
"length",
"let",
"k",
"=",
"[",
"]",
"let",
"d",
"=",
"[",
"]",
"let",
"j",
"=",
"[",
"]",
"if",
"(",
"len",
"===",
"0",
"||",
"n",
"<=",
"0",
")",
"{",
"return",
"{",
"k",
",",
"d",
",",
"j",
"}",
"}",
"let",
"ik",
"=",
"50",
"let",
"id",
"=",
"50",
"let",
"ij",
"=",
"50",
"let",
"rsv",
"=",
"(",
"close",
"[",
"0",
"]",
"-",
"low",
"[",
"0",
"]",
")",
"*",
"100",
"/",
"(",
"high",
"[",
"0",
"]",
"-",
"low",
"[",
"0",
"]",
")",
"ik",
"=",
"2",
"*",
"ik",
"/",
"3",
"+",
"rsv",
"/",
"3",
"id",
"=",
"2",
"*",
"id",
"/",
"3",
"+",
"ik",
"/",
"3",
"ij",
"=",
"3",
"*",
"ik",
"-",
"2",
"*",
"id",
"k",
".",
"push",
"(",
"ik",
")",
"d",
".",
"push",
"(",
"id",
")",
"j",
".",
"push",
"(",
"ij",
")",
"let",
"ln",
"=",
"low",
"[",
"0",
"]",
"let",
"hn",
"=",
"high",
"[",
"0",
"]",
"for",
"(",
"let",
"i",
"=",
"1",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"<",
"n",
")",
"{",
"if",
"(",
"ln",
">",
"low",
"[",
"i",
"]",
")",
"{",
"ln",
"=",
"low",
"[",
"i",
"]",
"}",
"if",
"(",
"hn",
"<",
"high",
"[",
"i",
"]",
")",
"{",
"hn",
"=",
"high",
"[",
"i",
"]",
"}",
"}",
"else",
"{",
"if",
"(",
"ln",
"===",
"low",
"[",
"i",
"-",
"n",
"]",
")",
"{",
"ln",
"=",
"low",
"[",
"i",
"]",
"for",
"(",
"let",
"j",
"=",
"1",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"if",
"(",
"low",
"[",
"i",
"-",
"j",
"]",
"<",
"ln",
")",
"{",
"ln",
"=",
"low",
"[",
"i",
"-",
"j",
"]",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"ln",
">",
"low",
"[",
"i",
"]",
")",
"{",
"ln",
"=",
"low",
"[",
"i",
"]",
"}",
"}",
"if",
"(",
"hn",
"===",
"high",
"[",
"i",
"-",
"n",
"]",
")",
"{",
"hn",
"=",
"high",
"[",
"i",
"]",
"for",
"(",
"let",
"j",
"=",
"1",
";",
"j",
"<",
"n",
";",
"j",
"++",
")",
"{",
"if",
"(",
"high",
"[",
"i",
"-",
"j",
"]",
">",
"hn",
")",
"{",
"hn",
"=",
"high",
"[",
"i",
"-",
"j",
"]",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"hn",
"<",
"high",
"[",
"i",
"]",
")",
"{",
"hn",
"=",
"high",
"[",
"i",
"]",
"}",
"}",
"}",
"rsv",
"=",
"(",
"close",
"[",
"i",
"]",
"-",
"ln",
")",
"*",
"100",
"/",
"(",
"hn",
"-",
"ln",
")",
"ik",
"=",
"2",
"*",
"ik",
"/",
"3",
"+",
"rsv",
"/",
"3",
"id",
"=",
"2",
"*",
"id",
"/",
"3",
"+",
"ik",
"/",
"3",
"ij",
"=",
"3",
"*",
"ik",
"-",
"2",
"*",
"id",
"k",
".",
"push",
"(",
"ik",
")",
"d",
".",
"push",
"(",
"id",
")",
"j",
".",
"push",
"(",
"ij",
")",
"}",
"return",
"{",
"k",
",",
"d",
",",
"j",
"}",
"}"
] |
KDJ
close should have
|
[
"KDJ",
"close",
"should",
"have"
] |
52e58c982c72b97bf55e1efc3f2637bf4c209181
|
https://github.com/quick-sort/jstock/blob/52e58c982c72b97bf55e1efc3f2637bf4c209181/index.js#L138-L203
|
39,352 |
ply-ct/ply
|
lib/storage.js
|
function(location, name) {
this.location = location;
this.name = name;
if (typeof localStorage === 'undefined' || localStorage === null) {
if (this.name) {
this.name = require('sanitize-filename')(this.name, {replacement: '_'});
require('mkdirp').sync(this.location);
}
}
else {
this.localStorage = localStorage;
}
this.path = this.location;
if (this.name)
this.path += '/' + this.name;
}
|
javascript
|
function(location, name) {
this.location = location;
this.name = name;
if (typeof localStorage === 'undefined' || localStorage === null) {
if (this.name) {
this.name = require('sanitize-filename')(this.name, {replacement: '_'});
require('mkdirp').sync(this.location);
}
}
else {
this.localStorage = localStorage;
}
this.path = this.location;
if (this.name)
this.path += '/' + this.name;
}
|
[
"function",
"(",
"location",
",",
"name",
")",
"{",
"this",
".",
"location",
"=",
"location",
";",
"this",
".",
"name",
"=",
"name",
";",
"if",
"(",
"typeof",
"localStorage",
"===",
"'undefined'",
"||",
"localStorage",
"===",
"null",
")",
"{",
"if",
"(",
"this",
".",
"name",
")",
"{",
"this",
".",
"name",
"=",
"require",
"(",
"'sanitize-filename'",
")",
"(",
"this",
".",
"name",
",",
"{",
"replacement",
":",
"'_'",
"}",
")",
";",
"require",
"(",
"'mkdirp'",
")",
".",
"sync",
"(",
"this",
".",
"location",
")",
";",
"}",
"}",
"else",
"{",
"this",
".",
"localStorage",
"=",
"localStorage",
";",
"}",
"this",
".",
"path",
"=",
"this",
".",
"location",
";",
"if",
"(",
"this",
".",
"name",
")",
"this",
".",
"path",
"+=",
"'/'",
"+",
"this",
".",
"name",
";",
"}"
] |
Abstracts storage to file system or html5 localStorage. name is optional
|
[
"Abstracts",
"storage",
"to",
"file",
"system",
"or",
"html5",
"localStorage",
".",
"name",
"is",
"optional"
] |
1d4146829845fedd917f5f0626cd74cc3845d0c8
|
https://github.com/ply-ct/ply/blob/1d4146829845fedd917f5f0626cd74cc3845d0c8/lib/storage.js#L7-L22
|
|
39,353 |
jkawamoto/psi
|
node/dlpa/lib/dlpa.js
|
flatten
|
function flatten(matrix) {
const res = [];
// If the given matrix is not a matrix but a scalar.
if (!Array.isArray(matrix)) {
matrix = [
[matrix]
];
}
matrix.forEach((row) => {
// If the given matrix is a vector.
if (!Array.isArray(row)) {
row = [row];
}
row.forEach((elem) => {
res.push(elem.real);
res.push(elem.imag);
});
});
return res;
}
|
javascript
|
function flatten(matrix) {
const res = [];
// If the given matrix is not a matrix but a scalar.
if (!Array.isArray(matrix)) {
matrix = [
[matrix]
];
}
matrix.forEach((row) => {
// If the given matrix is a vector.
if (!Array.isArray(row)) {
row = [row];
}
row.forEach((elem) => {
res.push(elem.real);
res.push(elem.imag);
});
});
return res;
}
|
[
"function",
"flatten",
"(",
"matrix",
")",
"{",
"const",
"res",
"=",
"[",
"]",
";",
"// If the given matrix is not a matrix but a scalar.",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"matrix",
")",
")",
"{",
"matrix",
"=",
"[",
"[",
"matrix",
"]",
"]",
";",
"}",
"matrix",
".",
"forEach",
"(",
"(",
"row",
")",
"=>",
"{",
"// If the given matrix is a vector.",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"row",
")",
")",
"{",
"row",
"=",
"[",
"row",
"]",
";",
"}",
"row",
".",
"forEach",
"(",
"(",
"elem",
")",
"=>",
"{",
"res",
".",
"push",
"(",
"elem",
".",
"real",
")",
";",
"res",
".",
"push",
"(",
"elem",
".",
"imag",
")",
";",
"}",
")",
";",
"}",
")",
";",
"return",
"res",
";",
"}"
] |
flatten returns a list which flatten the given matrix.
|
[
"flatten",
"returns",
"a",
"list",
"which",
"flatten",
"the",
"given",
"matrix",
"."
] |
94c75c5b6fbd3380b1729ce61ed2fc6538278a1e
|
https://github.com/jkawamoto/psi/blob/94c75c5b6fbd3380b1729ce61ed2fc6538278a1e/node/dlpa/lib/dlpa.js#L29-L51
|
39,354 |
jkawamoto/psi
|
node/dlpa/lib/dlpa.js
|
matrix
|
function matrix(rows, columns, values) {
// console.log(values);
const res = [];
let row = [];
let real;
values.forEach((v, i) => {
if (i % 2 == 0) {
real = v;
} else {
row.push({
real: real,
imag: v
});
if ((i + 1) / 2 % columns == 0) {
res.push(row);
row = [];
}
}
});
return res;
}
|
javascript
|
function matrix(rows, columns, values) {
// console.log(values);
const res = [];
let row = [];
let real;
values.forEach((v, i) => {
if (i % 2 == 0) {
real = v;
} else {
row.push({
real: real,
imag: v
});
if ((i + 1) / 2 % columns == 0) {
res.push(row);
row = [];
}
}
});
return res;
}
|
[
"function",
"matrix",
"(",
"rows",
",",
"columns",
",",
"values",
")",
"{",
"// console.log(values);",
"const",
"res",
"=",
"[",
"]",
";",
"let",
"row",
"=",
"[",
"]",
";",
"let",
"real",
";",
"values",
".",
"forEach",
"(",
"(",
"v",
",",
"i",
")",
"=>",
"{",
"if",
"(",
"i",
"%",
"2",
"==",
"0",
")",
"{",
"real",
"=",
"v",
";",
"}",
"else",
"{",
"row",
".",
"push",
"(",
"{",
"real",
":",
"real",
",",
"imag",
":",
"v",
"}",
")",
";",
"if",
"(",
"(",
"i",
"+",
"1",
")",
"/",
"2",
"%",
"columns",
"==",
"0",
")",
"{",
"res",
".",
"push",
"(",
"row",
")",
";",
"row",
"=",
"[",
"]",
";",
"}",
"}",
"}",
")",
";",
"return",
"res",
";",
"}"
] |
matrix returns a matrix of which values are given ones.
|
[
"matrix",
"returns",
"a",
"matrix",
"of",
"which",
"values",
"are",
"given",
"ones",
"."
] |
94c75c5b6fbd3380b1729ce61ed2fc6538278a1e
|
https://github.com/jkawamoto/psi/blob/94c75c5b6fbd3380b1729ce61ed2fc6538278a1e/node/dlpa/lib/dlpa.js#L55-L75
|
39,355 |
jkawamoto/psi
|
node/dlpa/lib/dlpa.js
|
Client
|
function Client(config) {
RED.nodes.createNode(this, config);
const port = String(Math.floor(Math.random() * (40000 - 30000 + 1)) + 30000);
// Start a DLPA-Node server.
// Options:
// --listen LISTEN Listening port.
// --host HOST Address of the DLPA server to be connected.
// --port PORT Port number of the DLPA server to be connected.
// --id CLIENT_ID Client ID
// --epsilon EPSILON Epsilon used in the Laplace distribution to add noises.
const proc = spawn("python3", [
"-m", "dlpanode.server",
"--listen", port,
"--host", config.host,
"--port", config.port,
"--id", config.client_id,
"--epsilon", config.epsilon
], {
"cwd": __dirname,
stdio: ["pipe", process.stdout, "pipe"]
});
let exited = false;
proc.on("exit", (code, signal) => {
this.log(`DLPA-Node server is closed: ${signal}`);
exited = true;
})
const logger = readline.createInterface({
input: proc.stderr,
});
logger.on("line", (line) => {
this.log(line)
})
const client = new dlpanode.DLPAClient(
`localhost:${port}`, grpc.credentials.createInsecure());
this.on("input", (msg) => {
// Send a message to the server.
client.encryptNoisySum({
values: flatten(msg.payload).map(v => Math.round((v + MAG) * MAG))
}, (err, response) => {
if (err) {
this.error(err);
}
});
});
// Stop the server.
this.on("close", (done) => {
if (exited) {
done();
return;
}
// Wait the server is closed.
proc.on("exit", () => {
done();
});
// Send a signal.
this.log("DLPA-Node server is closing");
proc.stdin.close();
proc.stdout.close();
logger.close();
proc.kill();
});
}
|
javascript
|
function Client(config) {
RED.nodes.createNode(this, config);
const port = String(Math.floor(Math.random() * (40000 - 30000 + 1)) + 30000);
// Start a DLPA-Node server.
// Options:
// --listen LISTEN Listening port.
// --host HOST Address of the DLPA server to be connected.
// --port PORT Port number of the DLPA server to be connected.
// --id CLIENT_ID Client ID
// --epsilon EPSILON Epsilon used in the Laplace distribution to add noises.
const proc = spawn("python3", [
"-m", "dlpanode.server",
"--listen", port,
"--host", config.host,
"--port", config.port,
"--id", config.client_id,
"--epsilon", config.epsilon
], {
"cwd": __dirname,
stdio: ["pipe", process.stdout, "pipe"]
});
let exited = false;
proc.on("exit", (code, signal) => {
this.log(`DLPA-Node server is closed: ${signal}`);
exited = true;
})
const logger = readline.createInterface({
input: proc.stderr,
});
logger.on("line", (line) => {
this.log(line)
})
const client = new dlpanode.DLPAClient(
`localhost:${port}`, grpc.credentials.createInsecure());
this.on("input", (msg) => {
// Send a message to the server.
client.encryptNoisySum({
values: flatten(msg.payload).map(v => Math.round((v + MAG) * MAG))
}, (err, response) => {
if (err) {
this.error(err);
}
});
});
// Stop the server.
this.on("close", (done) => {
if (exited) {
done();
return;
}
// Wait the server is closed.
proc.on("exit", () => {
done();
});
// Send a signal.
this.log("DLPA-Node server is closing");
proc.stdin.close();
proc.stdout.close();
logger.close();
proc.kill();
});
}
|
[
"function",
"Client",
"(",
"config",
")",
"{",
"RED",
".",
"nodes",
".",
"createNode",
"(",
"this",
",",
"config",
")",
";",
"const",
"port",
"=",
"String",
"(",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"(",
"40000",
"-",
"30000",
"+",
"1",
")",
")",
"+",
"30000",
")",
";",
"// Start a DLPA-Node server.",
"// Options:",
"// --listen LISTEN Listening port.",
"// --host HOST Address of the DLPA server to be connected.",
"// --port PORT Port number of the DLPA server to be connected.",
"// --id CLIENT_ID Client ID",
"// --epsilon EPSILON Epsilon used in the Laplace distribution to add noises.",
"const",
"proc",
"=",
"spawn",
"(",
"\"python3\"",
",",
"[",
"\"-m\"",
",",
"\"dlpanode.server\"",
",",
"\"--listen\"",
",",
"port",
",",
"\"--host\"",
",",
"config",
".",
"host",
",",
"\"--port\"",
",",
"config",
".",
"port",
",",
"\"--id\"",
",",
"config",
".",
"client_id",
",",
"\"--epsilon\"",
",",
"config",
".",
"epsilon",
"]",
",",
"{",
"\"cwd\"",
":",
"__dirname",
",",
"stdio",
":",
"[",
"\"pipe\"",
",",
"process",
".",
"stdout",
",",
"\"pipe\"",
"]",
"}",
")",
";",
"let",
"exited",
"=",
"false",
";",
"proc",
".",
"on",
"(",
"\"exit\"",
",",
"(",
"code",
",",
"signal",
")",
"=>",
"{",
"this",
".",
"log",
"(",
"`",
"${",
"signal",
"}",
"`",
")",
";",
"exited",
"=",
"true",
";",
"}",
")",
"const",
"logger",
"=",
"readline",
".",
"createInterface",
"(",
"{",
"input",
":",
"proc",
".",
"stderr",
",",
"}",
")",
";",
"logger",
".",
"on",
"(",
"\"line\"",
",",
"(",
"line",
")",
"=>",
"{",
"this",
".",
"log",
"(",
"line",
")",
"}",
")",
"const",
"client",
"=",
"new",
"dlpanode",
".",
"DLPAClient",
"(",
"`",
"${",
"port",
"}",
"`",
",",
"grpc",
".",
"credentials",
".",
"createInsecure",
"(",
")",
")",
";",
"this",
".",
"on",
"(",
"\"input\"",
",",
"(",
"msg",
")",
"=>",
"{",
"// Send a message to the server.",
"client",
".",
"encryptNoisySum",
"(",
"{",
"values",
":",
"flatten",
"(",
"msg",
".",
"payload",
")",
".",
"map",
"(",
"v",
"=>",
"Math",
".",
"round",
"(",
"(",
"v",
"+",
"MAG",
")",
"*",
"MAG",
")",
")",
"}",
",",
"(",
"err",
",",
"response",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"this",
".",
"error",
"(",
"err",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"// Stop the server.",
"this",
".",
"on",
"(",
"\"close\"",
",",
"(",
"done",
")",
"=>",
"{",
"if",
"(",
"exited",
")",
"{",
"done",
"(",
")",
";",
"return",
";",
"}",
"// Wait the server is closed.",
"proc",
".",
"on",
"(",
"\"exit\"",
",",
"(",
")",
"=>",
"{",
"done",
"(",
")",
";",
"}",
")",
";",
"// Send a signal.",
"this",
".",
"log",
"(",
"\"DLPA-Node server is closing\"",
")",
";",
"proc",
".",
"stdin",
".",
"close",
"(",
")",
";",
"proc",
".",
"stdout",
".",
"close",
"(",
")",
";",
"logger",
".",
"close",
"(",
")",
";",
"proc",
".",
"kill",
"(",
")",
";",
"}",
")",
";",
"}"
] |
DLPA Client Node.
|
[
"DLPA",
"Client",
"Node",
"."
] |
94c75c5b6fbd3380b1729ce61ed2fc6538278a1e
|
https://github.com/jkawamoto/psi/blob/94c75c5b6fbd3380b1729ce61ed2fc6538278a1e/node/dlpa/lib/dlpa.js#L84-L156
|
39,356 |
jkawamoto/psi
|
node/dlpa/lib/dlpa.js
|
Server
|
function Server(config) {
RED.nodes.createNode(this, config);
// Start a DLPA server.
// Options:
// --port PORT Listening port number.
// --clients CLIENTS The number of clicents.
// --max-workers MAX_WORKERS
// The maximum number of workiers (default: 10).
const proc = spawn("python3", [
"-m", "dlpa.server",
"--port", config.port,
"--clients", config.nclient,
"--key-length", "128",
"--time-span", config.span ? config.span : "300"
], {
cwd: __dirname,
});
let exited = false;
proc.on("exit", (code, signal) => {
this.log(`DLPA server is closed: ${signal}`);
exited = true;
})
const logger = readline.createInterface({
input: proc.stderr
});
logger.on("line", (line) => {
this.log(line);
})
// Wait results which should be outputted into stderr; and then
// post a message based on each output.
const rl = readline.createInterface({
input: proc.stdout
});
rl.on("line", (line) => {
const payload = JSON.parse(line);
this.send({
"topic": config.topic,
"payload": matrix(
parseInt(config.rows, 10),
parseInt(config.columns, 10),
payload.value.map(v => (v / MAG) - MAG))
});
});
// Stop the server.
this.on("close", (done) => {
if (exited) {
done();
return;
}
// Wait the server is closed.
proc.on("exit", () => {
done();
});
// Send a signal.
this.log("DLPA server is closing");
proc.stdin.close();
rl.close();
logger.close();
proc.kill();
});
}
|
javascript
|
function Server(config) {
RED.nodes.createNode(this, config);
// Start a DLPA server.
// Options:
// --port PORT Listening port number.
// --clients CLIENTS The number of clicents.
// --max-workers MAX_WORKERS
// The maximum number of workiers (default: 10).
const proc = spawn("python3", [
"-m", "dlpa.server",
"--port", config.port,
"--clients", config.nclient,
"--key-length", "128",
"--time-span", config.span ? config.span : "300"
], {
cwd: __dirname,
});
let exited = false;
proc.on("exit", (code, signal) => {
this.log(`DLPA server is closed: ${signal}`);
exited = true;
})
const logger = readline.createInterface({
input: proc.stderr
});
logger.on("line", (line) => {
this.log(line);
})
// Wait results which should be outputted into stderr; and then
// post a message based on each output.
const rl = readline.createInterface({
input: proc.stdout
});
rl.on("line", (line) => {
const payload = JSON.parse(line);
this.send({
"topic": config.topic,
"payload": matrix(
parseInt(config.rows, 10),
parseInt(config.columns, 10),
payload.value.map(v => (v / MAG) - MAG))
});
});
// Stop the server.
this.on("close", (done) => {
if (exited) {
done();
return;
}
// Wait the server is closed.
proc.on("exit", () => {
done();
});
// Send a signal.
this.log("DLPA server is closing");
proc.stdin.close();
rl.close();
logger.close();
proc.kill();
});
}
|
[
"function",
"Server",
"(",
"config",
")",
"{",
"RED",
".",
"nodes",
".",
"createNode",
"(",
"this",
",",
"config",
")",
";",
"// Start a DLPA server.",
"// Options:",
"// --port PORT Listening port number.",
"// --clients CLIENTS The number of clicents.",
"// --max-workers MAX_WORKERS",
"// The maximum number of workiers (default: 10).",
"const",
"proc",
"=",
"spawn",
"(",
"\"python3\"",
",",
"[",
"\"-m\"",
",",
"\"dlpa.server\"",
",",
"\"--port\"",
",",
"config",
".",
"port",
",",
"\"--clients\"",
",",
"config",
".",
"nclient",
",",
"\"--key-length\"",
",",
"\"128\"",
",",
"\"--time-span\"",
",",
"config",
".",
"span",
"?",
"config",
".",
"span",
":",
"\"300\"",
"]",
",",
"{",
"cwd",
":",
"__dirname",
",",
"}",
")",
";",
"let",
"exited",
"=",
"false",
";",
"proc",
".",
"on",
"(",
"\"exit\"",
",",
"(",
"code",
",",
"signal",
")",
"=>",
"{",
"this",
".",
"log",
"(",
"`",
"${",
"signal",
"}",
"`",
")",
";",
"exited",
"=",
"true",
";",
"}",
")",
"const",
"logger",
"=",
"readline",
".",
"createInterface",
"(",
"{",
"input",
":",
"proc",
".",
"stderr",
"}",
")",
";",
"logger",
".",
"on",
"(",
"\"line\"",
",",
"(",
"line",
")",
"=>",
"{",
"this",
".",
"log",
"(",
"line",
")",
";",
"}",
")",
"// Wait results which should be outputted into stderr; and then",
"// post a message based on each output.",
"const",
"rl",
"=",
"readline",
".",
"createInterface",
"(",
"{",
"input",
":",
"proc",
".",
"stdout",
"}",
")",
";",
"rl",
".",
"on",
"(",
"\"line\"",
",",
"(",
"line",
")",
"=>",
"{",
"const",
"payload",
"=",
"JSON",
".",
"parse",
"(",
"line",
")",
";",
"this",
".",
"send",
"(",
"{",
"\"topic\"",
":",
"config",
".",
"topic",
",",
"\"payload\"",
":",
"matrix",
"(",
"parseInt",
"(",
"config",
".",
"rows",
",",
"10",
")",
",",
"parseInt",
"(",
"config",
".",
"columns",
",",
"10",
")",
",",
"payload",
".",
"value",
".",
"map",
"(",
"v",
"=>",
"(",
"v",
"/",
"MAG",
")",
"-",
"MAG",
")",
")",
"}",
")",
";",
"}",
")",
";",
"// Stop the server.",
"this",
".",
"on",
"(",
"\"close\"",
",",
"(",
"done",
")",
"=>",
"{",
"if",
"(",
"exited",
")",
"{",
"done",
"(",
")",
";",
"return",
";",
"}",
"// Wait the server is closed.",
"proc",
".",
"on",
"(",
"\"exit\"",
",",
"(",
")",
"=>",
"{",
"done",
"(",
")",
";",
"}",
")",
";",
"// Send a signal.",
"this",
".",
"log",
"(",
"\"DLPA server is closing\"",
")",
";",
"proc",
".",
"stdin",
".",
"close",
"(",
")",
";",
"rl",
".",
"close",
"(",
")",
";",
"logger",
".",
"close",
"(",
")",
";",
"proc",
".",
"kill",
"(",
")",
";",
"}",
")",
";",
"}"
] |
DLPA Server Node.
|
[
"DLPA",
"Server",
"Node",
"."
] |
94c75c5b6fbd3380b1729ce61ed2fc6538278a1e
|
https://github.com/jkawamoto/psi/blob/94c75c5b6fbd3380b1729ce61ed2fc6538278a1e/node/dlpa/lib/dlpa.js#L163-L230
|
39,357 |
sverweij/upem
|
src/core.js
|
updateAllDeps
|
function updateAllDeps (pPackageObject, pOutdatedPackages = {}, pOptions = {}) {
return Object.assign(
{},
pPackageObject,
Object.keys(pPackageObject)
.filter(pPkgKey => pPkgKey.includes('ependencies'))
.reduce(
(pAll, pDepKey) => {
pAll[pDepKey] = updateDeps(pPackageObject[pDepKey], pOutdatedPackages, pOptions)
return pAll
},
{}
)
)
}
|
javascript
|
function updateAllDeps (pPackageObject, pOutdatedPackages = {}, pOptions = {}) {
return Object.assign(
{},
pPackageObject,
Object.keys(pPackageObject)
.filter(pPkgKey => pPkgKey.includes('ependencies'))
.reduce(
(pAll, pDepKey) => {
pAll[pDepKey] = updateDeps(pPackageObject[pDepKey], pOutdatedPackages, pOptions)
return pAll
},
{}
)
)
}
|
[
"function",
"updateAllDeps",
"(",
"pPackageObject",
",",
"pOutdatedPackages",
"=",
"{",
"}",
",",
"pOptions",
"=",
"{",
"}",
")",
"{",
"return",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"pPackageObject",
",",
"Object",
".",
"keys",
"(",
"pPackageObject",
")",
".",
"filter",
"(",
"pPkgKey",
"=>",
"pPkgKey",
".",
"includes",
"(",
"'ependencies'",
")",
")",
".",
"reduce",
"(",
"(",
"pAll",
",",
"pDepKey",
")",
"=>",
"{",
"pAll",
"[",
"pDepKey",
"]",
"=",
"updateDeps",
"(",
"pPackageObject",
"[",
"pDepKey",
"]",
",",
"pOutdatedPackages",
",",
"pOptions",
")",
"return",
"pAll",
"}",
",",
"{",
"}",
")",
")",
"}"
] |
Updates all dependencies in the passed package.json that match a key in the
passed outdated object to the _latest_ in that object, ignoring the
packages mentioned in the upem.donotup key.
@param {any} pPackageObject - the contents of a package.json in object format
@param {any} pOutdatedObject - the output of npm outdated --json, in object format
@param {string} pSavePrefix - how updated packages get prefixed; either '~',
'^' or '' (the default)
@return {any} - the transformed pPackageObject
|
[
"Updates",
"all",
"dependencies",
"in",
"the",
"passed",
"package",
".",
"json",
"that",
"match",
"a",
"key",
"in",
"the",
"passed",
"outdated",
"object",
"to",
"the",
"_latest_",
"in",
"that",
"object",
"ignoring",
"the",
"packages",
"mentioned",
"in",
"the",
"upem",
".",
"donotup",
"key",
"."
] |
6523056076917923f1c9bfb9b96454002145e683
|
https://github.com/sverweij/upem/blob/6523056076917923f1c9bfb9b96454002145e683/src/core.js#L42-L56
|
39,358 |
nuttyjs/nutty
|
index.js
|
function(index)
{
//Check the index value
if(index >= nutty._middlewares.length){ return; }
//Call the middleware
nutty._middlewares[index](args, function(error)
{
//Check for undefined error
if(typeof error === 'undefined'){ var error = null; }
//Check for error
if(error && error instanceof Error)
{
//Throw the error
throw error;
}
//Next middleware on the list
return middlewares_recursive(index + 1);
});
}
|
javascript
|
function(index)
{
//Check the index value
if(index >= nutty._middlewares.length){ return; }
//Call the middleware
nutty._middlewares[index](args, function(error)
{
//Check for undefined error
if(typeof error === 'undefined'){ var error = null; }
//Check for error
if(error && error instanceof Error)
{
//Throw the error
throw error;
}
//Next middleware on the list
return middlewares_recursive(index + 1);
});
}
|
[
"function",
"(",
"index",
")",
"{",
"//Check the index value",
"if",
"(",
"index",
">=",
"nutty",
".",
"_middlewares",
".",
"length",
")",
"{",
"return",
";",
"}",
"//Call the middleware",
"nutty",
".",
"_middlewares",
"[",
"index",
"]",
"(",
"args",
",",
"function",
"(",
"error",
")",
"{",
"//Check for undefined error",
"if",
"(",
"typeof",
"error",
"===",
"'undefined'",
")",
"{",
"var",
"error",
"=",
"null",
";",
"}",
"//Check for error",
"if",
"(",
"error",
"&&",
"error",
"instanceof",
"Error",
")",
"{",
"//Throw the error",
"throw",
"error",
";",
"}",
"//Next middleware on the list",
"return",
"middlewares_recursive",
"(",
"index",
"+",
"1",
")",
";",
"}",
")",
";",
"}"
] |
Middlewares recursive caller
|
[
"Middlewares",
"recursive",
"caller"
] |
1006c57c78d01b7b117af1dec03a64d444632f33
|
https://github.com/nuttyjs/nutty/blob/1006c57c78d01b7b117af1dec03a64d444632f33/index.js#L63-L84
|
|
39,359 |
ofzza/enTT
|
dist/entt/extensions.js
|
getEntityExtensions
|
function getEntityExtensions(entity) {
// Check if entity passed as instance or class
if (entity instanceof _entt2.default) {
// Return property configuration from instance
return _cache.ConfigurationCache.get(entity).extensions;
} else if (_lodash2.default.isFunction(entity) && entity.prototype instanceof _entt2.default) {
// Return property configuration from class
return _cache.ConfigurationCache.get(new entity()).extensions;
}
}
|
javascript
|
function getEntityExtensions(entity) {
// Check if entity passed as instance or class
if (entity instanceof _entt2.default) {
// Return property configuration from instance
return _cache.ConfigurationCache.get(entity).extensions;
} else if (_lodash2.default.isFunction(entity) && entity.prototype instanceof _entt2.default) {
// Return property configuration from class
return _cache.ConfigurationCache.get(new entity()).extensions;
}
}
|
[
"function",
"getEntityExtensions",
"(",
"entity",
")",
"{",
"// Check if entity passed as instance or class",
"if",
"(",
"entity",
"instanceof",
"_entt2",
".",
"default",
")",
"{",
"// Return property configuration from instance",
"return",
"_cache",
".",
"ConfigurationCache",
".",
"get",
"(",
"entity",
")",
".",
"extensions",
";",
"}",
"else",
"if",
"(",
"_lodash2",
".",
"default",
".",
"isFunction",
"(",
"entity",
")",
"&&",
"entity",
".",
"prototype",
"instanceof",
"_entt2",
".",
"default",
")",
"{",
"// Return property configuration from class",
"return",
"_cache",
".",
"ConfigurationCache",
".",
"get",
"(",
"new",
"entity",
"(",
")",
")",
".",
"extensions",
";",
"}",
"}"
] |
Retrieves extensions for an Entity instance or class
@static
@param {any} entity Entity instance or EnTT extending class to get extensions for
@returns {any} EnTT Extensions
@memberof Extensions
|
[
"Retrieves",
"extensions",
"for",
"an",
"Entity",
"instance",
"or",
"class"
] |
fdf27de4142b3c65a3e51dee70e0d7625dff897c
|
https://github.com/ofzza/enTT/blob/fdf27de4142b3c65a3e51dee70e0d7625dff897c/dist/entt/extensions.js#L50-L59
|
39,360 |
yuichi-tanaka/connect-aerospike
|
lib/connect-aerospike.js
|
AerospikeStore
|
function AerospikeStore(options){
var self = this;
options = options || {};
Store.call(self,options);
self.prefix = null == options.prefix ? _default_prefix : options.prefix;
self.ns = null == options.ns ? _default_ns : options.ns;
self.st = null == options.st ? _default_set : options.st;
self.ttl = null == options.ttl ? _default_ttl : options.ttl;
if(!options.hosts || options.hosts.length<=0){
options.hosts = [_default_host];
}
if(options.hosts){
var hosts = options.hosts.map(function(host){
var _val = host.split(':');
var _host = _val[0];
var _port = ~~_val[1] || _default_port;
return { addr:_host,port:_port};
});
var timeout = (typeof options.timeout === 'number' ? options.timeout : _default_timeout);
aerospike.client({
hosts:hosts,
log:{
level: _default_log_level
},
policies:{
timeout: timeout
}
}).connect(function(err,client){
if(err && err.code !== aerospike.status.AEROSPIKE_OK){
console.error('Aerospike server connection Error : %j',err);
}else{
self.client = client;
}
});
}
}
|
javascript
|
function AerospikeStore(options){
var self = this;
options = options || {};
Store.call(self,options);
self.prefix = null == options.prefix ? _default_prefix : options.prefix;
self.ns = null == options.ns ? _default_ns : options.ns;
self.st = null == options.st ? _default_set : options.st;
self.ttl = null == options.ttl ? _default_ttl : options.ttl;
if(!options.hosts || options.hosts.length<=0){
options.hosts = [_default_host];
}
if(options.hosts){
var hosts = options.hosts.map(function(host){
var _val = host.split(':');
var _host = _val[0];
var _port = ~~_val[1] || _default_port;
return { addr:_host,port:_port};
});
var timeout = (typeof options.timeout === 'number' ? options.timeout : _default_timeout);
aerospike.client({
hosts:hosts,
log:{
level: _default_log_level
},
policies:{
timeout: timeout
}
}).connect(function(err,client){
if(err && err.code !== aerospike.status.AEROSPIKE_OK){
console.error('Aerospike server connection Error : %j',err);
}else{
self.client = client;
}
});
}
}
|
[
"function",
"AerospikeStore",
"(",
"options",
")",
"{",
"var",
"self",
"=",
"this",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"Store",
".",
"call",
"(",
"self",
",",
"options",
")",
";",
"self",
".",
"prefix",
"=",
"null",
"==",
"options",
".",
"prefix",
"?",
"_default_prefix",
":",
"options",
".",
"prefix",
";",
"self",
".",
"ns",
"=",
"null",
"==",
"options",
".",
"ns",
"?",
"_default_ns",
":",
"options",
".",
"ns",
";",
"self",
".",
"st",
"=",
"null",
"==",
"options",
".",
"st",
"?",
"_default_set",
":",
"options",
".",
"st",
";",
"self",
".",
"ttl",
"=",
"null",
"==",
"options",
".",
"ttl",
"?",
"_default_ttl",
":",
"options",
".",
"ttl",
";",
"if",
"(",
"!",
"options",
".",
"hosts",
"||",
"options",
".",
"hosts",
".",
"length",
"<=",
"0",
")",
"{",
"options",
".",
"hosts",
"=",
"[",
"_default_host",
"]",
";",
"}",
"if",
"(",
"options",
".",
"hosts",
")",
"{",
"var",
"hosts",
"=",
"options",
".",
"hosts",
".",
"map",
"(",
"function",
"(",
"host",
")",
"{",
"var",
"_val",
"=",
"host",
".",
"split",
"(",
"':'",
")",
";",
"var",
"_host",
"=",
"_val",
"[",
"0",
"]",
";",
"var",
"_port",
"=",
"~",
"~",
"_val",
"[",
"1",
"]",
"||",
"_default_port",
";",
"return",
"{",
"addr",
":",
"_host",
",",
"port",
":",
"_port",
"}",
";",
"}",
")",
";",
"var",
"timeout",
"=",
"(",
"typeof",
"options",
".",
"timeout",
"===",
"'number'",
"?",
"options",
".",
"timeout",
":",
"_default_timeout",
")",
";",
"aerospike",
".",
"client",
"(",
"{",
"hosts",
":",
"hosts",
",",
"log",
":",
"{",
"level",
":",
"_default_log_level",
"}",
",",
"policies",
":",
"{",
"timeout",
":",
"timeout",
"}",
"}",
")",
".",
"connect",
"(",
"function",
"(",
"err",
",",
"client",
")",
"{",
"if",
"(",
"err",
"&&",
"err",
".",
"code",
"!==",
"aerospike",
".",
"status",
".",
"AEROSPIKE_OK",
")",
"{",
"console",
".",
"error",
"(",
"'Aerospike server connection Error : %j'",
",",
"err",
")",
";",
"}",
"else",
"{",
"self",
".",
"client",
"=",
"client",
";",
"}",
"}",
")",
";",
"}",
"}"
] |
Initialize AerospikeStore with the given options
pparam {Object} options
@api public
|
[
"Initialize",
"AerospikeStore",
"with",
"the",
"given",
"options"
] |
483a4d7123366b4e67d5de55ad5c57146590e4d5
|
https://github.com/yuichi-tanaka/connect-aerospike/blob/483a4d7123366b4e67d5de55ad5c57146590e4d5/lib/connect-aerospike.js#L46-L84
|
39,361 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js
|
function($menu) {
// position to the lower middle of the trigger element
if ($.ui && $.ui.position) {
// .position() is provided as a jQuery UI utility
// (...and it won't work on hidden elements)
$menu.css('display', 'block').position({
my: "center top",
at: "center bottom",
of: this,
offset: "0 5",
collision: "fit"
}).css('display', 'none');
} else {
// determine contextMenu position
var offset = this.offset();
offset.top += this.outerHeight();
offset.left += this.outerWidth() / 2 - $menu.outerWidth() / 2;
$menu.css(offset);
}
}
|
javascript
|
function($menu) {
// position to the lower middle of the trigger element
if ($.ui && $.ui.position) {
// .position() is provided as a jQuery UI utility
// (...and it won't work on hidden elements)
$menu.css('display', 'block').position({
my: "center top",
at: "center bottom",
of: this,
offset: "0 5",
collision: "fit"
}).css('display', 'none');
} else {
// determine contextMenu position
var offset = this.offset();
offset.top += this.outerHeight();
offset.left += this.outerWidth() / 2 - $menu.outerWidth() / 2;
$menu.css(offset);
}
}
|
[
"function",
"(",
"$menu",
")",
"{",
"// position to the lower middle of the trigger element",
"if",
"(",
"$",
".",
"ui",
"&&",
"$",
".",
"ui",
".",
"position",
")",
"{",
"// .position() is provided as a jQuery UI utility",
"// (...and it won't work on hidden elements)",
"$menu",
".",
"css",
"(",
"'display'",
",",
"'block'",
")",
".",
"position",
"(",
"{",
"my",
":",
"\"center top\"",
",",
"at",
":",
"\"center bottom\"",
",",
"of",
":",
"this",
",",
"offset",
":",
"\"0 5\"",
",",
"collision",
":",
"\"fit\"",
"}",
")",
".",
"css",
"(",
"'display'",
",",
"'none'",
")",
";",
"}",
"else",
"{",
"// determine contextMenu position",
"var",
"offset",
"=",
"this",
".",
"offset",
"(",
")",
";",
"offset",
".",
"top",
"+=",
"this",
".",
"outerHeight",
"(",
")",
";",
"offset",
".",
"left",
"+=",
"this",
".",
"outerWidth",
"(",
")",
"/",
"2",
"-",
"$menu",
".",
"outerWidth",
"(",
")",
"/",
"2",
";",
"$menu",
".",
"css",
"(",
"offset",
")",
";",
"}",
"}"
] |
determine position to show menu at
|
[
"determine",
"position",
"to",
"show",
"menu",
"at"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js#L92-L111
|
|
39,362 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js
|
function(e) {
e.preventDefault();
e.stopImmediatePropagation();
$(this).trigger($.Event("contextmenu", { data: e.data, pageX: e.pageX, pageY: e.pageY }));
}
|
javascript
|
function(e) {
e.preventDefault();
e.stopImmediatePropagation();
$(this).trigger($.Event("contextmenu", { data: e.data, pageX: e.pageX, pageY: e.pageY }));
}
|
[
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"e",
".",
"stopImmediatePropagation",
"(",
")",
";",
"$",
"(",
"this",
")",
".",
"trigger",
"(",
"$",
".",
"Event",
"(",
"\"contextmenu\"",
",",
"{",
"data",
":",
"e",
".",
"data",
",",
"pageX",
":",
"e",
".",
"pageX",
",",
"pageY",
":",
"e",
".",
"pageY",
"}",
")",
")",
";",
"}"
] |
contextMenu left-click trigger
|
[
"contextMenu",
"left",
"-",
"click",
"trigger"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js#L272-L276
|
|
39,363 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js
|
function(e) {
// show menu
var $this = $(this);
if ($this.data('contextMenuActive') && $currentTrigger && $currentTrigger.length && $currentTrigger.is($this) && !$this.hasClass('context-menu-disabled')) {
e.preventDefault();
e.stopImmediatePropagation();
$currentTrigger = $this;
$this.trigger($.Event("contextmenu", { data: e.data, pageX: e.pageX, pageY: e.pageY }));
}
$this.removeData('contextMenuActive');
}
|
javascript
|
function(e) {
// show menu
var $this = $(this);
if ($this.data('contextMenuActive') && $currentTrigger && $currentTrigger.length && $currentTrigger.is($this) && !$this.hasClass('context-menu-disabled')) {
e.preventDefault();
e.stopImmediatePropagation();
$currentTrigger = $this;
$this.trigger($.Event("contextmenu", { data: e.data, pageX: e.pageX, pageY: e.pageY }));
}
$this.removeData('contextMenuActive');
}
|
[
"function",
"(",
"e",
")",
"{",
"// show menu",
"var",
"$this",
"=",
"$",
"(",
"this",
")",
";",
"if",
"(",
"$this",
".",
"data",
"(",
"'contextMenuActive'",
")",
"&&",
"$currentTrigger",
"&&",
"$currentTrigger",
".",
"length",
"&&",
"$currentTrigger",
".",
"is",
"(",
"$this",
")",
"&&",
"!",
"$this",
".",
"hasClass",
"(",
"'context-menu-disabled'",
")",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"e",
".",
"stopImmediatePropagation",
"(",
")",
";",
"$currentTrigger",
"=",
"$this",
";",
"$this",
".",
"trigger",
"(",
"$",
".",
"Event",
"(",
"\"contextmenu\"",
",",
"{",
"data",
":",
"e",
".",
"data",
",",
"pageX",
":",
"e",
".",
"pageX",
",",
"pageY",
":",
"e",
".",
"pageY",
"}",
")",
")",
";",
"}",
"$this",
".",
"removeData",
"(",
"'contextMenuActive'",
")",
";",
"}"
] |
contextMenu right-click trigger
|
[
"contextMenu",
"right",
"-",
"click",
"trigger"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js#L293-L304
|
|
39,364 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js
|
function(e) {
e.stopPropagation();
var opt = $(this).data('contextMenu') || {};
// obtain currently selected menu
if (opt.$selected) {
var $s = opt.$selected;
opt = opt.$selected.parent().data('contextMenu') || {};
opt.$selected = $s;
}
var $children = opt.$menu.children(),
$prev = !opt.$selected || !opt.$selected.prev().length ? $children.last() : opt.$selected.prev(),
$round = $prev;
// skip disabled
while ($prev.hasClass('disabled') || $prev.hasClass('not-selectable')) {
if ($prev.prev().length) {
$prev = $prev.prev();
} else {
$prev = $children.last();
}
if ($prev.is($round)) {
// break endless loop
return;
}
}
// leave current
if (opt.$selected) {
handle.itemMouseleave.call(opt.$selected.get(0), e);
}
// activate next
handle.itemMouseenter.call($prev.get(0), e);
// focus input
var $input = $prev.find('input, textarea, select');
if ($input.length) {
$input.focus();
}
}
|
javascript
|
function(e) {
e.stopPropagation();
var opt = $(this).data('contextMenu') || {};
// obtain currently selected menu
if (opt.$selected) {
var $s = opt.$selected;
opt = opt.$selected.parent().data('contextMenu') || {};
opt.$selected = $s;
}
var $children = opt.$menu.children(),
$prev = !opt.$selected || !opt.$selected.prev().length ? $children.last() : opt.$selected.prev(),
$round = $prev;
// skip disabled
while ($prev.hasClass('disabled') || $prev.hasClass('not-selectable')) {
if ($prev.prev().length) {
$prev = $prev.prev();
} else {
$prev = $children.last();
}
if ($prev.is($round)) {
// break endless loop
return;
}
}
// leave current
if (opt.$selected) {
handle.itemMouseleave.call(opt.$selected.get(0), e);
}
// activate next
handle.itemMouseenter.call($prev.get(0), e);
// focus input
var $input = $prev.find('input, textarea, select');
if ($input.length) {
$input.focus();
}
}
|
[
"function",
"(",
"e",
")",
"{",
"e",
".",
"stopPropagation",
"(",
")",
";",
"var",
"opt",
"=",
"$",
"(",
"this",
")",
".",
"data",
"(",
"'contextMenu'",
")",
"||",
"{",
"}",
";",
"// obtain currently selected menu",
"if",
"(",
"opt",
".",
"$selected",
")",
"{",
"var",
"$s",
"=",
"opt",
".",
"$selected",
";",
"opt",
"=",
"opt",
".",
"$selected",
".",
"parent",
"(",
")",
".",
"data",
"(",
"'contextMenu'",
")",
"||",
"{",
"}",
";",
"opt",
".",
"$selected",
"=",
"$s",
";",
"}",
"var",
"$children",
"=",
"opt",
".",
"$menu",
".",
"children",
"(",
")",
",",
"$prev",
"=",
"!",
"opt",
".",
"$selected",
"||",
"!",
"opt",
".",
"$selected",
".",
"prev",
"(",
")",
".",
"length",
"?",
"$children",
".",
"last",
"(",
")",
":",
"opt",
".",
"$selected",
".",
"prev",
"(",
")",
",",
"$round",
"=",
"$prev",
";",
"// skip disabled",
"while",
"(",
"$prev",
".",
"hasClass",
"(",
"'disabled'",
")",
"||",
"$prev",
".",
"hasClass",
"(",
"'not-selectable'",
")",
")",
"{",
"if",
"(",
"$prev",
".",
"prev",
"(",
")",
".",
"length",
")",
"{",
"$prev",
"=",
"$prev",
".",
"prev",
"(",
")",
";",
"}",
"else",
"{",
"$prev",
"=",
"$children",
".",
"last",
"(",
")",
";",
"}",
"if",
"(",
"$prev",
".",
"is",
"(",
"$round",
")",
")",
"{",
"// break endless loop",
"return",
";",
"}",
"}",
"// leave current",
"if",
"(",
"opt",
".",
"$selected",
")",
"{",
"handle",
".",
"itemMouseleave",
".",
"call",
"(",
"opt",
".",
"$selected",
".",
"get",
"(",
"0",
")",
",",
"e",
")",
";",
"}",
"// activate next",
"handle",
".",
"itemMouseenter",
".",
"call",
"(",
"$prev",
".",
"get",
"(",
"0",
")",
",",
"e",
")",
";",
"// focus input",
"var",
"$input",
"=",
"$prev",
".",
"find",
"(",
"'input, textarea, select'",
")",
";",
"if",
"(",
"$input",
".",
"length",
")",
"{",
"$input",
".",
"focus",
"(",
")",
";",
"}",
"}"
] |
select previous possible command in menu
|
[
"select",
"previous",
"possible",
"command",
"in",
"menu"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js#L558-L599
|
|
39,365 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js
|
function(e) {
var $this = $(this).closest('.context-menu-item'),
data = $this.data(),
opt = data.contextMenu,
root = data.contextMenuRoot;
root.$selected = opt.$selected = $this;
root.isInput = opt.isInput = true;
}
|
javascript
|
function(e) {
var $this = $(this).closest('.context-menu-item'),
data = $this.data(),
opt = data.contextMenu,
root = data.contextMenuRoot;
root.$selected = opt.$selected = $this;
root.isInput = opt.isInput = true;
}
|
[
"function",
"(",
"e",
")",
"{",
"var",
"$this",
"=",
"$",
"(",
"this",
")",
".",
"closest",
"(",
"'.context-menu-item'",
")",
",",
"data",
"=",
"$this",
".",
"data",
"(",
")",
",",
"opt",
"=",
"data",
".",
"contextMenu",
",",
"root",
"=",
"data",
".",
"contextMenuRoot",
";",
"root",
".",
"$selected",
"=",
"opt",
".",
"$selected",
"=",
"$this",
";",
"root",
".",
"isInput",
"=",
"opt",
".",
"isInput",
"=",
"true",
";",
"}"
] |
flag that we're inside an input so the key handler can act accordingly
|
[
"flag",
"that",
"we",
"re",
"inside",
"an",
"input",
"so",
"the",
"key",
"handler",
"can",
"act",
"accordingly"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js#L645-L653
|
|
39,366 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js
|
function(e) {
var $this = $(this),
data = $this.data(),
opt = data.contextMenu,
root = data.contextMenuRoot,
key = data.contextMenuKey,
callback;
// abort if the key is unknown or disabled or is a menu
if (!opt.items[key] || $this.is('.disabled, .context-menu-submenu, .context-menu-separator, .not-selectable')) {
return;
}
e.preventDefault();
e.stopImmediatePropagation();
if ($.isFunction(root.callbacks[key]) && Object.prototype.hasOwnProperty.call(root.callbacks, key)) {
// item-specific callback
callback = root.callbacks[key];
} else if ($.isFunction(root.callback)) {
// default callback
callback = root.callback;
} else {
// no callback, no action
return;
}
// hide menu if callback doesn't stop that
if (callback.call(root.$trigger, key, root) !== false) {
root.$menu.trigger('contextmenu:hide');
} else if (root.$menu.parent().length) {
op.update.call(root.$trigger, root);
}
}
|
javascript
|
function(e) {
var $this = $(this),
data = $this.data(),
opt = data.contextMenu,
root = data.contextMenuRoot,
key = data.contextMenuKey,
callback;
// abort if the key is unknown or disabled or is a menu
if (!opt.items[key] || $this.is('.disabled, .context-menu-submenu, .context-menu-separator, .not-selectable')) {
return;
}
e.preventDefault();
e.stopImmediatePropagation();
if ($.isFunction(root.callbacks[key]) && Object.prototype.hasOwnProperty.call(root.callbacks, key)) {
// item-specific callback
callback = root.callbacks[key];
} else if ($.isFunction(root.callback)) {
// default callback
callback = root.callback;
} else {
// no callback, no action
return;
}
// hide menu if callback doesn't stop that
if (callback.call(root.$trigger, key, root) !== false) {
root.$menu.trigger('contextmenu:hide');
} else if (root.$menu.parent().length) {
op.update.call(root.$trigger, root);
}
}
|
[
"function",
"(",
"e",
")",
"{",
"var",
"$this",
"=",
"$",
"(",
"this",
")",
",",
"data",
"=",
"$this",
".",
"data",
"(",
")",
",",
"opt",
"=",
"data",
".",
"contextMenu",
",",
"root",
"=",
"data",
".",
"contextMenuRoot",
",",
"key",
"=",
"data",
".",
"contextMenuKey",
",",
"callback",
";",
"// abort if the key is unknown or disabled or is a menu",
"if",
"(",
"!",
"opt",
".",
"items",
"[",
"key",
"]",
"||",
"$this",
".",
"is",
"(",
"'.disabled, .context-menu-submenu, .context-menu-separator, .not-selectable'",
")",
")",
"{",
"return",
";",
"}",
"e",
".",
"preventDefault",
"(",
")",
";",
"e",
".",
"stopImmediatePropagation",
"(",
")",
";",
"if",
"(",
"$",
".",
"isFunction",
"(",
"root",
".",
"callbacks",
"[",
"key",
"]",
")",
"&&",
"Object",
".",
"prototype",
".",
"hasOwnProperty",
".",
"call",
"(",
"root",
".",
"callbacks",
",",
"key",
")",
")",
"{",
"// item-specific callback",
"callback",
"=",
"root",
".",
"callbacks",
"[",
"key",
"]",
";",
"}",
"else",
"if",
"(",
"$",
".",
"isFunction",
"(",
"root",
".",
"callback",
")",
")",
"{",
"// default callback",
"callback",
"=",
"root",
".",
"callback",
";",
"}",
"else",
"{",
"// no callback, no action",
"return",
";",
"}",
"// hide menu if callback doesn't stop that",
"if",
"(",
"callback",
".",
"call",
"(",
"root",
".",
"$trigger",
",",
"key",
",",
"root",
")",
"!==",
"false",
")",
"{",
"root",
".",
"$menu",
".",
"trigger",
"(",
"'contextmenu:hide'",
")",
";",
"}",
"else",
"if",
"(",
"root",
".",
"$menu",
".",
"parent",
"(",
")",
".",
"length",
")",
"{",
"op",
".",
"update",
".",
"call",
"(",
"root",
".",
"$trigger",
",",
"root",
")",
";",
"}",
"}"
] |
contextMenu item click
|
[
"contextMenu",
"item",
"click"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/jQuery-contextMenu/src/jquery.contextMenu.js#L721-L754
|
|
39,367 |
theetrain/gulp-resource-hints
|
lib/index.js
|
gulpResourceHints
|
function gulpResourceHints (opt) {
var options = helpers.options(opt)
helpers.reset()
return new Transform({
objectMode: true,
transform: function (file, enc, cb) {
if (file.isNull()) {
helpers.logger(PLUGIN_NAME, 'no file', true)
cb(null, file)
return
}
var fileContents = String(file.contents)
// Gather assets, keep unique values
// Using https://www.npmjs.com/package/list-assets
var assets = new Set(listAssets.html(
fileContents,
{
absolute: true,
protocolRelative: true
}
).map(ob => ob.url))
if (assets.size < 0) {
// Skip file: no static assets
cb(null, file)
return
}
if (!helpers.hasInsertionPoint(file)) {
helpers.logger(PLUGIN_NAME, 'Skipping file: no <head> or token found', true)
cb(null, file)
return
}
// Future feature! Gotta do more stream madness
// if (options.getCSSAssets) {
// for (var k = 0, cssLen = assets.length; k < cssLen; k++) {
// if (assets[k].endsWith('.css') || assets[k].endsWith('.CSS')) {
// assets.push(listAssets.css(
// fileContents
// ))
// }
// }
// }
// Build resource hints based on user-selected assets
var data = ['']
assets.forEach((aVal, aKey, set) => {
Object.keys(options.paths).forEach((key) => {
if (options.paths[key] === '') {
return
}
data.push(helpers.buildResourceHint(key, aVal, options.paths[key]))
})
})
data = data.reduce((a, b) => a + b)
var newFile = helpers.writeDataToFile(file, data, options.pageToken)
if (!newFile) {
helpers.logger(PLUGIN_NAME + ': Could not write data to file. ' + file.relative)
cb(null, file)
return
} else {
file.contents = new Buffer(newFile)
}
cb(null, file)
}
})
}
|
javascript
|
function gulpResourceHints (opt) {
var options = helpers.options(opt)
helpers.reset()
return new Transform({
objectMode: true,
transform: function (file, enc, cb) {
if (file.isNull()) {
helpers.logger(PLUGIN_NAME, 'no file', true)
cb(null, file)
return
}
var fileContents = String(file.contents)
// Gather assets, keep unique values
// Using https://www.npmjs.com/package/list-assets
var assets = new Set(listAssets.html(
fileContents,
{
absolute: true,
protocolRelative: true
}
).map(ob => ob.url))
if (assets.size < 0) {
// Skip file: no static assets
cb(null, file)
return
}
if (!helpers.hasInsertionPoint(file)) {
helpers.logger(PLUGIN_NAME, 'Skipping file: no <head> or token found', true)
cb(null, file)
return
}
// Future feature! Gotta do more stream madness
// if (options.getCSSAssets) {
// for (var k = 0, cssLen = assets.length; k < cssLen; k++) {
// if (assets[k].endsWith('.css') || assets[k].endsWith('.CSS')) {
// assets.push(listAssets.css(
// fileContents
// ))
// }
// }
// }
// Build resource hints based on user-selected assets
var data = ['']
assets.forEach((aVal, aKey, set) => {
Object.keys(options.paths).forEach((key) => {
if (options.paths[key] === '') {
return
}
data.push(helpers.buildResourceHint(key, aVal, options.paths[key]))
})
})
data = data.reduce((a, b) => a + b)
var newFile = helpers.writeDataToFile(file, data, options.pageToken)
if (!newFile) {
helpers.logger(PLUGIN_NAME + ': Could not write data to file. ' + file.relative)
cb(null, file)
return
} else {
file.contents = new Buffer(newFile)
}
cb(null, file)
}
})
}
|
[
"function",
"gulpResourceHints",
"(",
"opt",
")",
"{",
"var",
"options",
"=",
"helpers",
".",
"options",
"(",
"opt",
")",
"helpers",
".",
"reset",
"(",
")",
"return",
"new",
"Transform",
"(",
"{",
"objectMode",
":",
"true",
",",
"transform",
":",
"function",
"(",
"file",
",",
"enc",
",",
"cb",
")",
"{",
"if",
"(",
"file",
".",
"isNull",
"(",
")",
")",
"{",
"helpers",
".",
"logger",
"(",
"PLUGIN_NAME",
",",
"'no file'",
",",
"true",
")",
"cb",
"(",
"null",
",",
"file",
")",
"return",
"}",
"var",
"fileContents",
"=",
"String",
"(",
"file",
".",
"contents",
")",
"// Gather assets, keep unique values",
"// Using https://www.npmjs.com/package/list-assets",
"var",
"assets",
"=",
"new",
"Set",
"(",
"listAssets",
".",
"html",
"(",
"fileContents",
",",
"{",
"absolute",
":",
"true",
",",
"protocolRelative",
":",
"true",
"}",
")",
".",
"map",
"(",
"ob",
"=>",
"ob",
".",
"url",
")",
")",
"if",
"(",
"assets",
".",
"size",
"<",
"0",
")",
"{",
"// Skip file: no static assets",
"cb",
"(",
"null",
",",
"file",
")",
"return",
"}",
"if",
"(",
"!",
"helpers",
".",
"hasInsertionPoint",
"(",
"file",
")",
")",
"{",
"helpers",
".",
"logger",
"(",
"PLUGIN_NAME",
",",
"'Skipping file: no <head> or token found'",
",",
"true",
")",
"cb",
"(",
"null",
",",
"file",
")",
"return",
"}",
"// Future feature! Gotta do more stream madness",
"// if (options.getCSSAssets) {",
"// for (var k = 0, cssLen = assets.length; k < cssLen; k++) {",
"// if (assets[k].endsWith('.css') || assets[k].endsWith('.CSS')) {",
"// assets.push(listAssets.css(",
"// fileContents",
"// ))",
"// }",
"// }",
"// }",
"// Build resource hints based on user-selected assets",
"var",
"data",
"=",
"[",
"''",
"]",
"assets",
".",
"forEach",
"(",
"(",
"aVal",
",",
"aKey",
",",
"set",
")",
"=>",
"{",
"Object",
".",
"keys",
"(",
"options",
".",
"paths",
")",
".",
"forEach",
"(",
"(",
"key",
")",
"=>",
"{",
"if",
"(",
"options",
".",
"paths",
"[",
"key",
"]",
"===",
"''",
")",
"{",
"return",
"}",
"data",
".",
"push",
"(",
"helpers",
".",
"buildResourceHint",
"(",
"key",
",",
"aVal",
",",
"options",
".",
"paths",
"[",
"key",
"]",
")",
")",
"}",
")",
"}",
")",
"data",
"=",
"data",
".",
"reduce",
"(",
"(",
"a",
",",
"b",
")",
"=>",
"a",
"+",
"b",
")",
"var",
"newFile",
"=",
"helpers",
".",
"writeDataToFile",
"(",
"file",
",",
"data",
",",
"options",
".",
"pageToken",
")",
"if",
"(",
"!",
"newFile",
")",
"{",
"helpers",
".",
"logger",
"(",
"PLUGIN_NAME",
"+",
"': Could not write data to file. '",
"+",
"file",
".",
"relative",
")",
"cb",
"(",
"null",
",",
"file",
")",
"return",
"}",
"else",
"{",
"file",
".",
"contents",
"=",
"new",
"Buffer",
"(",
"newFile",
")",
"}",
"cb",
"(",
"null",
",",
"file",
")",
"}",
"}",
")",
"}"
] |
Main Function
Read file streams, parse assets, build resource hints
@param {object} opt
|
[
"Main",
"Function",
"Read",
"file",
"streams",
"parse",
"assets",
"build",
"resource",
"hints"
] |
12a01e42b35ed07ddef80bddf07e21a69f2138f4
|
https://github.com/theetrain/gulp-resource-hints/blob/12a01e42b35ed07ddef80bddf07e21a69f2138f4/lib/index.js#L14-L89
|
39,368 |
EvilDevRu/node-redis-dump
|
lib/node-redis-dump.js
|
function(key, data, callback) {
'use strict';
/**
* Read scores by values.
*
* @param {Array} values
* @param {Function} callback
*/
var ReadScores = function(values, callback) {
var result = [];
/**
* Get scores recursive.
*/
var GetRecursive = function() {
if (!values.length) {
callback(null, result);
return;
}
var value = values.pop();
this.getClient().zscore(key, value, function(err, score) {
if (err) {
callback(err);
return;
}
result.push(score);
GetRecursive();
});
}.bind(this);
GetRecursive();
}.bind(this);
/**
* Read key.
*
* @param {String} key
* @param {String} type
* @param {Function} rkCallback
*/
var ReadKey = function(key, type, rkCallback) {
var params = [ key ],
command = {
set: 'smembers',
zset: 'zrange',
list: 'lrange',
hash: 'hgetall'
}[ type ] || 'get';
if (command.indexOf('range') !== -1) {
params.push(0);
params.push(-1);
}
params.push(function(err, values) {
if (err) {
rkCallback(err);
return;
}
switch (type) {
case 'zset':
ReadScores(_.clone(values).reverse(), function(err, scores) {
rkCallback(null, _.zip(scores, values));
});
break;
default:
rkCallback(null, values);
break;
}
});
this.getClient()[ command ].apply(this.getClient(), params);
}.bind(this);
switch (this.getExportParams().type) {
// Export as redis type.
case 'redis':
return function(err, type) {
var type2PrintSetCommand = {
string: 'SET',
set: 'SADD',
zset: 'ZADD',
list: 'RPUSH',
hash: 'HSET'
};
if (!data) {
data = '';
}
ReadKey(key, type, function(err, value) {
if (err) {
callback(err);
return;
}
var command = type2PrintSetCommand[ type ];
key = key.trim();
switch (type) {
case 'set':
_.each(value, function(item) {
data += command + ' "' + key + '" "' + item + "\"\n";
});
break;
case 'zset':
_.each(value, function(item) {
data += command + ' "' + key + '" ' + item[0] + ' "' + item[1] + "\"\n";
});
break;
case 'hash':
_.each(_.pairs(value), function(item) {
data += command + ' "' + key + '" "' + item[0] + '" "' + item[1] + "\"\n";
});
break;
default:
data += command + ' "' + key + '" "' + value + "\"\n";
break;
}
callback(null, data);
});
};
// Export as json type.
case 'json':
return function(err, type) {
if (!data) {
data = {};
}
ReadKey(key, type, function(err, value) {
if (err) {
callback(err);
return;
}
switch (type) {
case 'zset':
var withoutScores = [];
_.each(value, function(item) {
withoutScores.push(item[1]);
});
value = withoutScores;
break;
}
data[ key.trim() ] = value;
callback(null, data);
});
};
}
}
|
javascript
|
function(key, data, callback) {
'use strict';
/**
* Read scores by values.
*
* @param {Array} values
* @param {Function} callback
*/
var ReadScores = function(values, callback) {
var result = [];
/**
* Get scores recursive.
*/
var GetRecursive = function() {
if (!values.length) {
callback(null, result);
return;
}
var value = values.pop();
this.getClient().zscore(key, value, function(err, score) {
if (err) {
callback(err);
return;
}
result.push(score);
GetRecursive();
});
}.bind(this);
GetRecursive();
}.bind(this);
/**
* Read key.
*
* @param {String} key
* @param {String} type
* @param {Function} rkCallback
*/
var ReadKey = function(key, type, rkCallback) {
var params = [ key ],
command = {
set: 'smembers',
zset: 'zrange',
list: 'lrange',
hash: 'hgetall'
}[ type ] || 'get';
if (command.indexOf('range') !== -1) {
params.push(0);
params.push(-1);
}
params.push(function(err, values) {
if (err) {
rkCallback(err);
return;
}
switch (type) {
case 'zset':
ReadScores(_.clone(values).reverse(), function(err, scores) {
rkCallback(null, _.zip(scores, values));
});
break;
default:
rkCallback(null, values);
break;
}
});
this.getClient()[ command ].apply(this.getClient(), params);
}.bind(this);
switch (this.getExportParams().type) {
// Export as redis type.
case 'redis':
return function(err, type) {
var type2PrintSetCommand = {
string: 'SET',
set: 'SADD',
zset: 'ZADD',
list: 'RPUSH',
hash: 'HSET'
};
if (!data) {
data = '';
}
ReadKey(key, type, function(err, value) {
if (err) {
callback(err);
return;
}
var command = type2PrintSetCommand[ type ];
key = key.trim();
switch (type) {
case 'set':
_.each(value, function(item) {
data += command + ' "' + key + '" "' + item + "\"\n";
});
break;
case 'zset':
_.each(value, function(item) {
data += command + ' "' + key + '" ' + item[0] + ' "' + item[1] + "\"\n";
});
break;
case 'hash':
_.each(_.pairs(value), function(item) {
data += command + ' "' + key + '" "' + item[0] + '" "' + item[1] + "\"\n";
});
break;
default:
data += command + ' "' + key + '" "' + value + "\"\n";
break;
}
callback(null, data);
});
};
// Export as json type.
case 'json':
return function(err, type) {
if (!data) {
data = {};
}
ReadKey(key, type, function(err, value) {
if (err) {
callback(err);
return;
}
switch (type) {
case 'zset':
var withoutScores = [];
_.each(value, function(item) {
withoutScores.push(item[1]);
});
value = withoutScores;
break;
}
data[ key.trim() ] = value;
callback(null, data);
});
};
}
}
|
[
"function",
"(",
"key",
",",
"data",
",",
"callback",
")",
"{",
"'use strict'",
";",
"/**\n\t * Read scores by values.\n\t *\n\t * @param {Array} values\n\t * @param {Function} callback\n\t */",
"var",
"ReadScores",
"=",
"function",
"(",
"values",
",",
"callback",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"/**\n\t\t * Get scores recursive.\n\t\t */",
"var",
"GetRecursive",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"values",
".",
"length",
")",
"{",
"callback",
"(",
"null",
",",
"result",
")",
";",
"return",
";",
"}",
"var",
"value",
"=",
"values",
".",
"pop",
"(",
")",
";",
"this",
".",
"getClient",
"(",
")",
".",
"zscore",
"(",
"key",
",",
"value",
",",
"function",
"(",
"err",
",",
"score",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"result",
".",
"push",
"(",
"score",
")",
";",
"GetRecursive",
"(",
")",
";",
"}",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
";",
"GetRecursive",
"(",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
";",
"/**\n\t * Read key.\n\t *\n\t * @param {String} key\n\t * @param {String} type\n\t * @param {Function} rkCallback\n\t */",
"var",
"ReadKey",
"=",
"function",
"(",
"key",
",",
"type",
",",
"rkCallback",
")",
"{",
"var",
"params",
"=",
"[",
"key",
"]",
",",
"command",
"=",
"{",
"set",
":",
"'smembers'",
",",
"zset",
":",
"'zrange'",
",",
"list",
":",
"'lrange'",
",",
"hash",
":",
"'hgetall'",
"}",
"[",
"type",
"]",
"||",
"'get'",
";",
"if",
"(",
"command",
".",
"indexOf",
"(",
"'range'",
")",
"!==",
"-",
"1",
")",
"{",
"params",
".",
"push",
"(",
"0",
")",
";",
"params",
".",
"push",
"(",
"-",
"1",
")",
";",
"}",
"params",
".",
"push",
"(",
"function",
"(",
"err",
",",
"values",
")",
"{",
"if",
"(",
"err",
")",
"{",
"rkCallback",
"(",
"err",
")",
";",
"return",
";",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"'zset'",
":",
"ReadScores",
"(",
"_",
".",
"clone",
"(",
"values",
")",
".",
"reverse",
"(",
")",
",",
"function",
"(",
"err",
",",
"scores",
")",
"{",
"rkCallback",
"(",
"null",
",",
"_",
".",
"zip",
"(",
"scores",
",",
"values",
")",
")",
";",
"}",
")",
";",
"break",
";",
"default",
":",
"rkCallback",
"(",
"null",
",",
"values",
")",
";",
"break",
";",
"}",
"}",
")",
";",
"this",
".",
"getClient",
"(",
")",
"[",
"command",
"]",
".",
"apply",
"(",
"this",
".",
"getClient",
"(",
")",
",",
"params",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
";",
"switch",
"(",
"this",
".",
"getExportParams",
"(",
")",
".",
"type",
")",
"{",
"//\tExport as redis type.",
"case",
"'redis'",
":",
"return",
"function",
"(",
"err",
",",
"type",
")",
"{",
"var",
"type2PrintSetCommand",
"=",
"{",
"string",
":",
"'SET'",
",",
"set",
":",
"'SADD'",
",",
"zset",
":",
"'ZADD'",
",",
"list",
":",
"'RPUSH'",
",",
"hash",
":",
"'HSET'",
"}",
";",
"if",
"(",
"!",
"data",
")",
"{",
"data",
"=",
"''",
";",
"}",
"ReadKey",
"(",
"key",
",",
"type",
",",
"function",
"(",
"err",
",",
"value",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"var",
"command",
"=",
"type2PrintSetCommand",
"[",
"type",
"]",
";",
"key",
"=",
"key",
".",
"trim",
"(",
")",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"'set'",
":",
"_",
".",
"each",
"(",
"value",
",",
"function",
"(",
"item",
")",
"{",
"data",
"+=",
"command",
"+",
"' \"'",
"+",
"key",
"+",
"'\" \"'",
"+",
"item",
"+",
"\"\\\"\\n\"",
";",
"}",
")",
";",
"break",
";",
"case",
"'zset'",
":",
"_",
".",
"each",
"(",
"value",
",",
"function",
"(",
"item",
")",
"{",
"data",
"+=",
"command",
"+",
"' \"'",
"+",
"key",
"+",
"'\" '",
"+",
"item",
"[",
"0",
"]",
"+",
"' \"'",
"+",
"item",
"[",
"1",
"]",
"+",
"\"\\\"\\n\"",
";",
"}",
")",
";",
"break",
";",
"case",
"'hash'",
":",
"_",
".",
"each",
"(",
"_",
".",
"pairs",
"(",
"value",
")",
",",
"function",
"(",
"item",
")",
"{",
"data",
"+=",
"command",
"+",
"' \"'",
"+",
"key",
"+",
"'\" \"'",
"+",
"item",
"[",
"0",
"]",
"+",
"'\" \"'",
"+",
"item",
"[",
"1",
"]",
"+",
"\"\\\"\\n\"",
";",
"}",
")",
";",
"break",
";",
"default",
":",
"data",
"+=",
"command",
"+",
"' \"'",
"+",
"key",
"+",
"'\" \"'",
"+",
"value",
"+",
"\"\\\"\\n\"",
";",
"break",
";",
"}",
"callback",
"(",
"null",
",",
"data",
")",
";",
"}",
")",
";",
"}",
";",
"//\tExport as json type.",
"case",
"'json'",
":",
"return",
"function",
"(",
"err",
",",
"type",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"data",
"=",
"{",
"}",
";",
"}",
"ReadKey",
"(",
"key",
",",
"type",
",",
"function",
"(",
"err",
",",
"value",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"'zset'",
":",
"var",
"withoutScores",
"=",
"[",
"]",
";",
"_",
".",
"each",
"(",
"value",
",",
"function",
"(",
"item",
")",
"{",
"withoutScores",
".",
"push",
"(",
"item",
"[",
"1",
"]",
")",
";",
"}",
")",
";",
"value",
"=",
"withoutScores",
";",
"break",
";",
"}",
"data",
"[",
"key",
".",
"trim",
"(",
")",
"]",
"=",
"value",
";",
"callback",
"(",
"null",
",",
"data",
")",
";",
"}",
")",
";",
"}",
";",
"}",
"}"
] |
Read key callback by type.
|
[
"Read",
"key",
"callback",
"by",
"type",
"."
] |
27f30b4c5a20f2a001e00d732d3c1d4ef67ddbad
|
https://github.com/EvilDevRu/node-redis-dump/blob/27f30b4c5a20f2a001e00d732d3c1d4ef67ddbad/lib/node-redis-dump.js#L61-L225
|
|
39,369 |
EvilDevRu/node-redis-dump
|
lib/node-redis-dump.js
|
function(err, status) {
if (err) {
callback(err);
return;
}
if (status || status === 'OK') {
report.inserted += _.isNumber(status) ? status : 1;
} else {
// Hm...
report.errors += 1;
}
AddRecursive();
}
|
javascript
|
function(err, status) {
if (err) {
callback(err);
return;
}
if (status || status === 'OK') {
report.inserted += _.isNumber(status) ? status : 1;
} else {
// Hm...
report.errors += 1;
}
AddRecursive();
}
|
[
"function",
"(",
"err",
",",
"status",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"if",
"(",
"status",
"||",
"status",
"===",
"'OK'",
")",
"{",
"report",
".",
"inserted",
"+=",
"_",
".",
"isNumber",
"(",
"status",
")",
"?",
"status",
":",
"1",
";",
"}",
"else",
"{",
"//\tHm...",
"report",
".",
"errors",
"+=",
"1",
";",
"}",
"AddRecursive",
"(",
")",
";",
"}"
] |
Callback function.
|
[
"Callback",
"function",
"."
] |
27f30b4c5a20f2a001e00d732d3c1d4ef67ddbad
|
https://github.com/EvilDevRu/node-redis-dump/blob/27f30b4c5a20f2a001e00d732d3c1d4ef67ddbad/lib/node-redis-dump.js#L374-L388
|
|
39,370 |
arhs/grunt-untar
|
tasks/untar.js
|
mustUnzip
|
function mustUnzip(file, mode){
if (mode){
return mode === 'tgz';
}
var extension = path.extname(file);
return contains(['.tgz', '.gz'], extension);
}
|
javascript
|
function mustUnzip(file, mode){
if (mode){
return mode === 'tgz';
}
var extension = path.extname(file);
return contains(['.tgz', '.gz'], extension);
}
|
[
"function",
"mustUnzip",
"(",
"file",
",",
"mode",
")",
"{",
"if",
"(",
"mode",
")",
"{",
"return",
"mode",
"===",
"'tgz'",
";",
"}",
"var",
"extension",
"=",
"path",
".",
"extname",
"(",
"file",
")",
";",
"return",
"contains",
"(",
"[",
"'.tgz'",
",",
"'.gz'",
"]",
",",
"extension",
")",
";",
"}"
] |
Return true if the processed file must be unzipped.
Check the mode and default to analyzing the file extension.
@param file the processed file
@param [mode] the mode
@returns {Boolean} true if the file must be unzipped
|
[
"Return",
"true",
"if",
"the",
"processed",
"file",
"must",
"be",
"unzipped",
".",
"Check",
"the",
"mode",
"and",
"default",
"to",
"analyzing",
"the",
"file",
"extension",
"."
] |
092fd0b1c9d9c864c6a905cfa616b0439df39214
|
https://github.com/arhs/grunt-untar/blob/092fd0b1c9d9c864c6a905cfa616b0439df39214/tasks/untar.js#L21-L27
|
39,371 |
ofzza/enTT
|
src/ext/dynamic-properties.js
|
isDynamicProperty
|
function isDynamicProperty (propertyConfiguration) {
return propertyConfiguration
// Is defined as dynamic
&& propertyConfiguration.dynamic
// Dynamic option value is a function
&& _.isFunction(propertyConfiguration.dynamic)
// Dynamic option value is not a EnTT class
&& (propertyConfiguration.dynamic !== EnTT);
}
|
javascript
|
function isDynamicProperty (propertyConfiguration) {
return propertyConfiguration
// Is defined as dynamic
&& propertyConfiguration.dynamic
// Dynamic option value is a function
&& _.isFunction(propertyConfiguration.dynamic)
// Dynamic option value is not a EnTT class
&& (propertyConfiguration.dynamic !== EnTT);
}
|
[
"function",
"isDynamicProperty",
"(",
"propertyConfiguration",
")",
"{",
"return",
"propertyConfiguration",
"// Is defined as dynamic",
"&&",
"propertyConfiguration",
".",
"dynamic",
"// Dynamic option value is a function",
"&&",
"_",
".",
"isFunction",
"(",
"propertyConfiguration",
".",
"dynamic",
")",
"// Dynamic option value is not a EnTT class",
"&&",
"(",
"propertyConfiguration",
".",
"dynamic",
"!==",
"EnTT",
")",
";",
"}"
] |
Checks if property is defined as a dynamic property
@param {any} propertyConfiguration Property configuration
@returns {bool} If property is defined as a dynamic property
|
[
"Checks",
"if",
"property",
"is",
"defined",
"as",
"a",
"dynamic",
"property"
] |
fdf27de4142b3c65a3e51dee70e0d7625dff897c
|
https://github.com/ofzza/enTT/blob/fdf27de4142b3c65a3e51dee70e0d7625dff897c/src/ext/dynamic-properties.js#L114-L122
|
39,372 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.js
|
function(name, language) {
name = (name || 'gregorian').toLowerCase();
language = language || '';
var cal = this._localCals[name + '-' + language];
if (!cal && this.calendars[name]) {
cal = new this.calendars[name](language);
this._localCals[name + '-' + language] = cal;
}
if (!cal) {
throw (this.local.invalidCalendar || this.regionalOptions[''].invalidCalendar).
replace(/\{0\}/, name);
}
return cal;
}
|
javascript
|
function(name, language) {
name = (name || 'gregorian').toLowerCase();
language = language || '';
var cal = this._localCals[name + '-' + language];
if (!cal && this.calendars[name]) {
cal = new this.calendars[name](language);
this._localCals[name + '-' + language] = cal;
}
if (!cal) {
throw (this.local.invalidCalendar || this.regionalOptions[''].invalidCalendar).
replace(/\{0\}/, name);
}
return cal;
}
|
[
"function",
"(",
"name",
",",
"language",
")",
"{",
"name",
"=",
"(",
"name",
"||",
"'gregorian'",
")",
".",
"toLowerCase",
"(",
")",
";",
"language",
"=",
"language",
"||",
"''",
";",
"var",
"cal",
"=",
"this",
".",
"_localCals",
"[",
"name",
"+",
"'-'",
"+",
"language",
"]",
";",
"if",
"(",
"!",
"cal",
"&&",
"this",
".",
"calendars",
"[",
"name",
"]",
")",
"{",
"cal",
"=",
"new",
"this",
".",
"calendars",
"[",
"name",
"]",
"(",
"language",
")",
";",
"this",
".",
"_localCals",
"[",
"name",
"+",
"'-'",
"+",
"language",
"]",
"=",
"cal",
";",
"}",
"if",
"(",
"!",
"cal",
")",
"{",
"throw",
"(",
"this",
".",
"local",
".",
"invalidCalendar",
"||",
"this",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidCalendar",
")",
".",
"replace",
"(",
"/",
"\\{0\\}",
"/",
",",
"name",
")",
";",
"}",
"return",
"cal",
";",
"}"
] |
Obtain a calendar implementation and localisation.
@memberof Calendars
@param [name='gregorian'] {string} The name of the calendar, e.g. 'gregorian', 'persian', 'islamic'.
@param [language=''] {string} The language code to use for localisation (default is English).
@return {Calendar} The calendar and localisation.
@throws Error if calendar not found.
|
[
"Obtain",
"a",
"calendar",
"implementation",
"and",
"localisation",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.js#L35-L48
|
|
39,373 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.js
|
function(year, month, day, calendar, language) {
calendar = (year != null && year.year ? year.calendar() : (typeof calendar === 'string' ?
this.instance(calendar, language) : calendar)) || this.instance();
return calendar.newDate(year, month, day);
}
|
javascript
|
function(year, month, day, calendar, language) {
calendar = (year != null && year.year ? year.calendar() : (typeof calendar === 'string' ?
this.instance(calendar, language) : calendar)) || this.instance();
return calendar.newDate(year, month, day);
}
|
[
"function",
"(",
"year",
",",
"month",
",",
"day",
",",
"calendar",
",",
"language",
")",
"{",
"calendar",
"=",
"(",
"year",
"!=",
"null",
"&&",
"year",
".",
"year",
"?",
"year",
".",
"calendar",
"(",
")",
":",
"(",
"typeof",
"calendar",
"===",
"'string'",
"?",
"this",
".",
"instance",
"(",
"calendar",
",",
"language",
")",
":",
"calendar",
")",
")",
"||",
"this",
".",
"instance",
"(",
")",
";",
"return",
"calendar",
".",
"newDate",
"(",
"year",
",",
"month",
",",
"day",
")",
";",
"}"
] |
Create a new date - for today if no other parameters given.
@memberof Calendars
@param year {CDate|number} The date to copy or the year for the date.
@param [month] {number} The month for the date.
@param [day] {number} The day for the date.
@param [calendar='gregorian'] {BaseCalendar|string} The underlying calendar or the name of the calendar.
@param [language=''] {string} The language to use for localisation (default English).
@return {CDate} The new date.
@throws Error if an invalid date.
|
[
"Create",
"a",
"new",
"date",
"-",
"for",
"today",
"if",
"no",
"other",
"parameters",
"given",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.js#L59-L63
|
|
39,374 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.js
|
function(digits, powers) {
return function(value) {
var localNumber = '';
var power = 0;
while (value > 0) {
var units = value % 10;
localNumber = (units === 0 ? '' : digits[units] + powers[power]) + localNumber;
power++;
value = Math.floor(value / 10);
}
if (localNumber.indexOf(digits[1] + powers[1]) === 0) {
localNumber = localNumber.substr(1);
}
return localNumber || digits[0];
}
}
|
javascript
|
function(digits, powers) {
return function(value) {
var localNumber = '';
var power = 0;
while (value > 0) {
var units = value % 10;
localNumber = (units === 0 ? '' : digits[units] + powers[power]) + localNumber;
power++;
value = Math.floor(value / 10);
}
if (localNumber.indexOf(digits[1] + powers[1]) === 0) {
localNumber = localNumber.substr(1);
}
return localNumber || digits[0];
}
}
|
[
"function",
"(",
"digits",
",",
"powers",
")",
"{",
"return",
"function",
"(",
"value",
")",
"{",
"var",
"localNumber",
"=",
"''",
";",
"var",
"power",
"=",
"0",
";",
"while",
"(",
"value",
">",
"0",
")",
"{",
"var",
"units",
"=",
"value",
"%",
"10",
";",
"localNumber",
"=",
"(",
"units",
"===",
"0",
"?",
"''",
":",
"digits",
"[",
"units",
"]",
"+",
"powers",
"[",
"power",
"]",
")",
"+",
"localNumber",
";",
"power",
"++",
";",
"value",
"=",
"Math",
".",
"floor",
"(",
"value",
"/",
"10",
")",
";",
"}",
"if",
"(",
"localNumber",
".",
"indexOf",
"(",
"digits",
"[",
"1",
"]",
"+",
"powers",
"[",
"1",
"]",
")",
"===",
"0",
")",
"{",
"localNumber",
"=",
"localNumber",
".",
"substr",
"(",
"1",
")",
";",
"}",
"return",
"localNumber",
"||",
"digits",
"[",
"0",
"]",
";",
"}",
"}"
] |
Digit substitution function for localising Chinese style numbers via the Calendar digits option.
@member Calendars
@param digits {string[]} The substitute digits, for 0 through 9.
@param powers {string[]} The characters denoting powers of 10, i.e. 1, 10, 100, 1000.
@return {function} The substitution function.
|
[
"Digit",
"substitution",
"function",
"for",
"localising",
"Chinese",
"style",
"numbers",
"via",
"the",
"Calendar",
"digits",
"option",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.js#L82-L97
|
|
39,375 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.js
|
CDate
|
function CDate(calendar, year, month, day) {
this._calendar = calendar;
this._year = year;
this._month = month;
this._day = day;
if (this._calendar._validateLevel === 0 &&
!this._calendar.isValid(this._year, this._month, this._day)) {
throw ($.calendars.local.invalidDate || $.calendars.regionalOptions[''].invalidDate).
replace(/\{0\}/, this._calendar.local.name);
}
}
|
javascript
|
function CDate(calendar, year, month, day) {
this._calendar = calendar;
this._year = year;
this._month = month;
this._day = day;
if (this._calendar._validateLevel === 0 &&
!this._calendar.isValid(this._year, this._month, this._day)) {
throw ($.calendars.local.invalidDate || $.calendars.regionalOptions[''].invalidDate).
replace(/\{0\}/, this._calendar.local.name);
}
}
|
[
"function",
"CDate",
"(",
"calendar",
",",
"year",
",",
"month",
",",
"day",
")",
"{",
"this",
".",
"_calendar",
"=",
"calendar",
";",
"this",
".",
"_year",
"=",
"year",
";",
"this",
".",
"_month",
"=",
"month",
";",
"this",
".",
"_day",
"=",
"day",
";",
"if",
"(",
"this",
".",
"_calendar",
".",
"_validateLevel",
"===",
"0",
"&&",
"!",
"this",
".",
"_calendar",
".",
"isValid",
"(",
"this",
".",
"_year",
",",
"this",
".",
"_month",
",",
"this",
".",
"_day",
")",
")",
"{",
"throw",
"(",
"$",
".",
"calendars",
".",
"local",
".",
"invalidDate",
"||",
"$",
".",
"calendars",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidDate",
")",
".",
"replace",
"(",
"/",
"\\{0\\}",
"/",
",",
"this",
".",
"_calendar",
".",
"local",
".",
"name",
")",
";",
"}",
"}"
] |
Generic date, based on a particular calendar.
@class CDate
@param calendar {BaseCalendar} The underlying calendar implementation.
@param year {number} The year for this date.
@param month {number} The month for this date.
@param day {number} The day for this date.
@return {CDate} The date object.
@throws Error if an invalid date.
|
[
"Generic",
"date",
"based",
"on",
"a",
"particular",
"calendar",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.js#L108-L118
|
39,376 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.js
|
pad
|
function pad(value, length) {
value = '' + value;
return '000000'.substring(0, length - value.length) + value;
}
|
javascript
|
function pad(value, length) {
value = '' + value;
return '000000'.substring(0, length - value.length) + value;
}
|
[
"function",
"pad",
"(",
"value",
",",
"length",
")",
"{",
"value",
"=",
"''",
"+",
"value",
";",
"return",
"'000000'",
".",
"substring",
"(",
"0",
",",
"length",
"-",
"value",
".",
"length",
")",
"+",
"value",
";",
"}"
] |
Pad a numeric value with leading zeroes.
@private
@param value {number} The number to format.
@param length {number} The minimum length.
@return {string} The formatted number.
|
[
"Pad",
"a",
"numeric",
"value",
"with",
"leading",
"zeroes",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.js#L125-L128
|
39,377 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.js
|
function(year, month, day) {
return this._calendar.newDate((year == null ? this : year), month, day);
}
|
javascript
|
function(year, month, day) {
return this._calendar.newDate((year == null ? this : year), month, day);
}
|
[
"function",
"(",
"year",
",",
"month",
",",
"day",
")",
"{",
"return",
"this",
".",
"_calendar",
".",
"newDate",
"(",
"(",
"year",
"==",
"null",
"?",
"this",
":",
"year",
")",
",",
"month",
",",
"day",
")",
";",
"}"
] |
Create a new date.
@memberof CDate
@param [year] {CDate|number} The date to copy or the year for the date (default this date).
@param [month] {number} The month for the date.
@param [day] {number} The day for the date.
@return {CDate} The new date.
@throws Error if an invalid date.
|
[
"Create",
"a",
"new",
"date",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.js#L139-L141
|
|
39,378 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.js
|
function(year, month, day) {
if (!this._calendar.isValid(year, month, day)) {
throw ($.calendars.local.invalidDate || $.calendars.regionalOptions[''].invalidDate).
replace(/\{0\}/, this._calendar.local.name);
}
this._year = year;
this._month = month;
this._day = day;
return this;
}
|
javascript
|
function(year, month, day) {
if (!this._calendar.isValid(year, month, day)) {
throw ($.calendars.local.invalidDate || $.calendars.regionalOptions[''].invalidDate).
replace(/\{0\}/, this._calendar.local.name);
}
this._year = year;
this._month = month;
this._day = day;
return this;
}
|
[
"function",
"(",
"year",
",",
"month",
",",
"day",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_calendar",
".",
"isValid",
"(",
"year",
",",
"month",
",",
"day",
")",
")",
"{",
"throw",
"(",
"$",
".",
"calendars",
".",
"local",
".",
"invalidDate",
"||",
"$",
".",
"calendars",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidDate",
")",
".",
"replace",
"(",
"/",
"\\{0\\}",
"/",
",",
"this",
".",
"_calendar",
".",
"local",
".",
"name",
")",
";",
"}",
"this",
".",
"_year",
"=",
"year",
";",
"this",
".",
"_month",
"=",
"month",
";",
"this",
".",
"_day",
"=",
"day",
";",
"return",
"this",
";",
"}"
] |
Set new values for this date.
@memberof CDate
@param year {number} The year for the date.
@param month {number} The month for the date.
@param day {number} The day for the date.
@return {CDate} The updated date.
@throws Error if an invalid date.
|
[
"Set",
"new",
"values",
"for",
"this",
"date",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.js#L177-L186
|
|
39,379 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.js
|
function(year) {
var date = this._validate(year, this.minMonth, this.minDay,
$.calendars.local.invalidYear || $.calendars.regionalOptions[''].invalidYear);
return (date.year() < 0 ? this.local.epochs[0] : this.local.epochs[1]);
}
|
javascript
|
function(year) {
var date = this._validate(year, this.minMonth, this.minDay,
$.calendars.local.invalidYear || $.calendars.regionalOptions[''].invalidYear);
return (date.year() < 0 ? this.local.epochs[0] : this.local.epochs[1]);
}
|
[
"function",
"(",
"year",
")",
"{",
"var",
"date",
"=",
"this",
".",
"_validate",
"(",
"year",
",",
"this",
".",
"minMonth",
",",
"this",
".",
"minDay",
",",
"$",
".",
"calendars",
".",
"local",
".",
"invalidYear",
"||",
"$",
".",
"calendars",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidYear",
")",
";",
"return",
"(",
"date",
".",
"year",
"(",
")",
"<",
"0",
"?",
"this",
".",
"local",
".",
"epochs",
"[",
"0",
"]",
":",
"this",
".",
"local",
".",
"epochs",
"[",
"1",
"]",
")",
";",
"}"
] |
Retrieve the epoch designator for this date.
@memberof BaseCalendar
@param year {CDate|number} The date to examine or the year to examine.
@return {string} The current epoch.
@throws Error if an invalid year or a different calendar used.
|
[
"Retrieve",
"the",
"epoch",
"designator",
"for",
"this",
"date",
"."
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.js#L392-L396
|
|
39,380 |
alexcjohnson/world-calendars
|
jquery-src/jquery.calendars.js
|
function(year, month) {
var date = this._validate(year, month, this.minDay,
$.calendars.local.invalidMonth || $.calendars.regionalOptions[''].invalidMonth);
return (date.month() + this.monthsInYear(date) - this.firstMonth) %
this.monthsInYear(date) + this.minMonth;
}
|
javascript
|
function(year, month) {
var date = this._validate(year, month, this.minDay,
$.calendars.local.invalidMonth || $.calendars.regionalOptions[''].invalidMonth);
return (date.month() + this.monthsInYear(date) - this.firstMonth) %
this.monthsInYear(date) + this.minMonth;
}
|
[
"function",
"(",
"year",
",",
"month",
")",
"{",
"var",
"date",
"=",
"this",
".",
"_validate",
"(",
"year",
",",
"month",
",",
"this",
".",
"minDay",
",",
"$",
".",
"calendars",
".",
"local",
".",
"invalidMonth",
"||",
"$",
".",
"calendars",
".",
"regionalOptions",
"[",
"''",
"]",
".",
"invalidMonth",
")",
";",
"return",
"(",
"date",
".",
"month",
"(",
")",
"+",
"this",
".",
"monthsInYear",
"(",
"date",
")",
"-",
"this",
".",
"firstMonth",
")",
"%",
"this",
".",
"monthsInYear",
"(",
"date",
")",
"+",
"this",
".",
"minMonth",
";",
"}"
] |
Calculate the month's ordinal position within the year -
for those calendars that don't start at month 1!
@memberof BaseCalendar
@param year {CDate|number} The date to examine or the year to examine.
@param month {number} The month to examine.
@return {number} The ordinal position, starting from <code>minMonth</code>.
@throws Error if an invalid year/month or a different calendar used.
|
[
"Calculate",
"the",
"month",
"s",
"ordinal",
"position",
"within",
"the",
"year",
"-",
"for",
"those",
"calendars",
"that",
"don",
"t",
"start",
"at",
"month",
"1!"
] |
810693882512dec1b804456f8d435b962bd6cf31
|
https://github.com/alexcjohnson/world-calendars/blob/810693882512dec1b804456f8d435b962bd6cf31/jquery-src/jquery.calendars.js#L427-L432
|
|
39,381 |
dominictarr/lossy-store
|
store.js
|
apply_write
|
function apply_write (key, value, err) {
var _reading = reading[key]
reading[key] = null
while(_reading && _reading.length)
_reading.shift()(err, value)
_write()
}
|
javascript
|
function apply_write (key, value, err) {
var _reading = reading[key]
reading[key] = null
while(_reading && _reading.length)
_reading.shift()(err, value)
_write()
}
|
[
"function",
"apply_write",
"(",
"key",
",",
"value",
",",
"err",
")",
"{",
"var",
"_reading",
"=",
"reading",
"[",
"key",
"]",
"reading",
"[",
"key",
"]",
"=",
"null",
"while",
"(",
"_reading",
"&&",
"_reading",
".",
"length",
")",
"_reading",
".",
"shift",
"(",
")",
"(",
"err",
",",
"value",
")",
"_write",
"(",
")",
"}"
] |
this writes only once at a time. at least, we want it to write at most once per file. or maybe if it's written recently then wait. anyway, this is good enough for now.
|
[
"this",
"writes",
"only",
"once",
"at",
"a",
"time",
".",
"at",
"least",
"we",
"want",
"it",
"to",
"write",
"at",
"most",
"once",
"per",
"file",
".",
"or",
"maybe",
"if",
"it",
"s",
"written",
"recently",
"then",
"wait",
".",
"anyway",
"this",
"is",
"good",
"enough",
"for",
"now",
"."
] |
713fadc62c730b8dfd15547dafde9c683424e7da
|
https://github.com/dominictarr/lossy-store/blob/713fadc62c730b8dfd15547dafde9c683424e7da/store.js#L15-L21
|
39,382 |
dominictarr/lossy-store
|
store.js
|
function (key, value) {
store[key] = value
//not urgent, but save this if we are not doing anything.
dirty[key] = true
apply_write(key, value)
}
|
javascript
|
function (key, value) {
store[key] = value
//not urgent, but save this if we are not doing anything.
dirty[key] = true
apply_write(key, value)
}
|
[
"function",
"(",
"key",
",",
"value",
")",
"{",
"store",
"[",
"key",
"]",
"=",
"value",
"//not urgent, but save this if we are not doing anything.",
"dirty",
"[",
"key",
"]",
"=",
"true",
"apply_write",
"(",
"key",
",",
"value",
")",
"}"
] |
if set is called during a read, cb the readers immediately, and cancel the current read.
|
[
"if",
"set",
"is",
"called",
"during",
"a",
"read",
"cb",
"the",
"readers",
"immediately",
"and",
"cancel",
"the",
"current",
"read",
"."
] |
713fadc62c730b8dfd15547dafde9c683424e7da
|
https://github.com/dominictarr/lossy-store/blob/713fadc62c730b8dfd15547dafde9c683424e7da/store.js#L71-L76
|
|
39,383 |
i0null/node-lgtv-2012
|
index.js
|
send_commands
|
function send_commands(cmds, cb) {
function callback(value) {
if (cb) cb(value)
this.locked = false
}
function run() {
if (this.locked = cmds.length > 0) send_command(cmds.shift(), (success) => {
if (success) setTimeout(run, 200);
else callback(false);
});
else callback(true);
};
if(!this.locked) run();
}
|
javascript
|
function send_commands(cmds, cb) {
function callback(value) {
if (cb) cb(value)
this.locked = false
}
function run() {
if (this.locked = cmds.length > 0) send_command(cmds.shift(), (success) => {
if (success) setTimeout(run, 200);
else callback(false);
});
else callback(true);
};
if(!this.locked) run();
}
|
[
"function",
"send_commands",
"(",
"cmds",
",",
"cb",
")",
"{",
"function",
"callback",
"(",
"value",
")",
"{",
"if",
"(",
"cb",
")",
"cb",
"(",
"value",
")",
"this",
".",
"locked",
"=",
"false",
"}",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"this",
".",
"locked",
"=",
"cmds",
".",
"length",
">",
"0",
")",
"send_command",
"(",
"cmds",
".",
"shift",
"(",
")",
",",
"(",
"success",
")",
"=>",
"{",
"if",
"(",
"success",
")",
"setTimeout",
"(",
"run",
",",
"200",
")",
";",
"else",
"callback",
"(",
"false",
")",
";",
"}",
")",
";",
"else",
"callback",
"(",
"true",
")",
";",
"}",
";",
"if",
"(",
"!",
"this",
".",
"locked",
")",
"run",
"(",
")",
";",
"}"
] |
Send Multiple Commands
|
[
"Send",
"Multiple",
"Commands"
] |
a579c7d6024c309575c43adc81c7b64d748692ee
|
https://github.com/i0null/node-lgtv-2012/blob/a579c7d6024c309575c43adc81c7b64d748692ee/index.js#L130-L143
|
39,384 |
CumberlandGroup/node-spark
|
lib/spark.js
|
getDefPath
|
function getDefPath(defPath) {
// if path passed...
if(defPath) {
// if not url and not absolute...
if(!/^https?:/.test(defPath) && !path.isAbsolute(defPath)) {
// normalize path as relative to folder containing node_modules
return path.normalize(path.join(__dirname, '/../../../', defPath));
}
// else, return unchanged...
else {
return defPath;
}
}
// else, return defualt path...
else {
return path.normalize(path.join(__dirname, _swaggerDef));
}
}
|
javascript
|
function getDefPath(defPath) {
// if path passed...
if(defPath) {
// if not url and not absolute...
if(!/^https?:/.test(defPath) && !path.isAbsolute(defPath)) {
// normalize path as relative to folder containing node_modules
return path.normalize(path.join(__dirname, '/../../../', defPath));
}
// else, return unchanged...
else {
return defPath;
}
}
// else, return defualt path...
else {
return path.normalize(path.join(__dirname, _swaggerDef));
}
}
|
[
"function",
"getDefPath",
"(",
"defPath",
")",
"{",
"// if path passed...",
"if",
"(",
"defPath",
")",
"{",
"// if not url and not absolute...",
"if",
"(",
"!",
"/",
"^https?:",
"/",
".",
"test",
"(",
"defPath",
")",
"&&",
"!",
"path",
".",
"isAbsolute",
"(",
"defPath",
")",
")",
"{",
"// normalize path as relative to folder containing node_modules",
"return",
"path",
".",
"normalize",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"'/../../../'",
",",
"defPath",
")",
")",
";",
"}",
"// else, return unchanged...",
"else",
"{",
"return",
"defPath",
";",
"}",
"}",
"// else, return defualt path...",
"else",
"{",
"return",
"path",
".",
"normalize",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"_swaggerDef",
")",
")",
";",
"}",
"}"
] |
get full path for spark swagger definition file
|
[
"get",
"full",
"path",
"for",
"spark",
"swagger",
"definition",
"file"
] |
dc4a50c5ba487af56173ac8316d8dc6a87dccd32
|
https://github.com/CumberlandGroup/node-spark/blob/dc4a50c5ba487af56173ac8316d8dc6a87dccd32/lib/spark.js#L21-L40
|
39,385 |
rochars/bitdepth
|
index.js
|
truncateSamples
|
function truncateSamples(samples) {
/** @type {number} */
let len = samples.length;
for (let i=0; i<len; i++) {
if (samples[i] > 1) {
samples[i] = 1;
} else if (samples[i] < -1) {
samples[i] = -1;
}
}
}
|
javascript
|
function truncateSamples(samples) {
/** @type {number} */
let len = samples.length;
for (let i=0; i<len; i++) {
if (samples[i] > 1) {
samples[i] = 1;
} else if (samples[i] < -1) {
samples[i] = -1;
}
}
}
|
[
"function",
"truncateSamples",
"(",
"samples",
")",
"{",
"/** @type {number} */",
"let",
"len",
"=",
"samples",
".",
"length",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"samples",
"[",
"i",
"]",
">",
"1",
")",
"{",
"samples",
"[",
"i",
"]",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"samples",
"[",
"i",
"]",
"<",
"-",
"1",
")",
"{",
"samples",
"[",
"i",
"]",
"=",
"-",
"1",
";",
"}",
"}",
"}"
] |
Truncate float samples on over and underflow.
@private
|
[
"Truncate",
"float",
"samples",
"on",
"over",
"and",
"underflow",
"."
] |
19921a297bc254ce80c90c793db99e40ad105385
|
https://github.com/rochars/bitdepth/blob/19921a297bc254ce80c90c793db99e40ad105385/index.js#L179-L189
|
39,386 |
fex-team/fis-prepackager-auto-pack
|
lib/request-sync.js
|
Response
|
function Response(statusCode, headers, body) {
this.statusCode = statusCode;
this.headers = {};
for (var key in headers) {
this.headers[key.toLowerCase()] = headers[key];
}
this.body = body;
}
|
javascript
|
function Response(statusCode, headers, body) {
this.statusCode = statusCode;
this.headers = {};
for (var key in headers) {
this.headers[key.toLowerCase()] = headers[key];
}
this.body = body;
}
|
[
"function",
"Response",
"(",
"statusCode",
",",
"headers",
",",
"body",
")",
"{",
"this",
".",
"statusCode",
"=",
"statusCode",
";",
"this",
".",
"headers",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"headers",
")",
"{",
"this",
".",
"headers",
"[",
"key",
".",
"toLowerCase",
"(",
")",
"]",
"=",
"headers",
"[",
"key",
"]",
";",
"}",
"this",
".",
"body",
"=",
"body",
";",
"}"
] |
A response from a web request
@param {Number} statusCode
@param {Object} headers
@param {Buffer} body
|
[
"A",
"response",
"from",
"a",
"web",
"request"
] |
4b45a5cfa6741fbe287d5e664f7dff129015c41b
|
https://github.com/fex-team/fis-prepackager-auto-pack/blob/4b45a5cfa6741fbe287d5e664f7dff129015c41b/lib/request-sync.js#L159-L166
|
39,387 |
alchemy-fr/Phraseanet-common
|
src/components/vendors/contextMenu.js
|
function (menu, cmenu) {
var className = cmenu.className;
$.each(cmenu.theme.split(","), function (i, n) {
className += ' ' + cmenu.themePrefix + n;
});
// var $t = $('<div style="background-color:#ffff00; xwidth:200px; height:200px"><table style="" cellspacing=0 cellpadding=0></table></div>').click(function(){cmenu.hide(); return false;}); // We wrap a table around it so width can be flexible
var $t = $('<table style="" cellspacing="0" cellpadding="0"></table>').click(function () {
cmenu.hide();
return false;
}); // We wrap a table around it so width can be flexible
var $tr = $('<tr></tr>');
var $td = $('<td></td>');
var $div = cmenu._div = $('<div class="' + className + '"></div>');
cmenu._div.hover(
function () {
if (cmenu.closeTimer) {
clearTimeout(cmenu.closeTimer);
cmenu.closeTimer = null;
}
},
function () {
var myClass = cmenu;
function timerRelay() {
myClass.hide();
}
myClass.closeTimer = setTimeout(timerRelay, 500);
}
);
// Each menu item is specified as either:
// title:function
// or title: { property:value ... }
/*
for (var i=0; i<menu.length; i++) {
var m = menu[i];
if (m==$.contextMenu.separator) {
$div.append(cmenu.createSeparator());
}
else {
for (var opt in menu[i]) {
$div.append(cmenu.createMenuItem(opt,menu[i][opt])); // Extracted to method for extensibility
}
}
}
*/
for (var i = 0; i < menu.length; i++) {
var m = menu[i];
if (m === $.contextMenu.separator) {
$div.append(cmenu.createSeparator());
}
else {
$div.append(cmenu.createMenuItem(m)); // Extracted to method for extensibility
}
}
if (cmenu.useIframe) {
$td.append(cmenu.createIframe());
}
$t.append($tr.append($td.append($div)));
return $t;
}
|
javascript
|
function (menu, cmenu) {
var className = cmenu.className;
$.each(cmenu.theme.split(","), function (i, n) {
className += ' ' + cmenu.themePrefix + n;
});
// var $t = $('<div style="background-color:#ffff00; xwidth:200px; height:200px"><table style="" cellspacing=0 cellpadding=0></table></div>').click(function(){cmenu.hide(); return false;}); // We wrap a table around it so width can be flexible
var $t = $('<table style="" cellspacing="0" cellpadding="0"></table>').click(function () {
cmenu.hide();
return false;
}); // We wrap a table around it so width can be flexible
var $tr = $('<tr></tr>');
var $td = $('<td></td>');
var $div = cmenu._div = $('<div class="' + className + '"></div>');
cmenu._div.hover(
function () {
if (cmenu.closeTimer) {
clearTimeout(cmenu.closeTimer);
cmenu.closeTimer = null;
}
},
function () {
var myClass = cmenu;
function timerRelay() {
myClass.hide();
}
myClass.closeTimer = setTimeout(timerRelay, 500);
}
);
// Each menu item is specified as either:
// title:function
// or title: { property:value ... }
/*
for (var i=0; i<menu.length; i++) {
var m = menu[i];
if (m==$.contextMenu.separator) {
$div.append(cmenu.createSeparator());
}
else {
for (var opt in menu[i]) {
$div.append(cmenu.createMenuItem(opt,menu[i][opt])); // Extracted to method for extensibility
}
}
}
*/
for (var i = 0; i < menu.length; i++) {
var m = menu[i];
if (m === $.contextMenu.separator) {
$div.append(cmenu.createSeparator());
}
else {
$div.append(cmenu.createMenuItem(m)); // Extracted to method for extensibility
}
}
if (cmenu.useIframe) {
$td.append(cmenu.createIframe());
}
$t.append($tr.append($td.append($div)));
return $t;
}
|
[
"function",
"(",
"menu",
",",
"cmenu",
")",
"{",
"var",
"className",
"=",
"cmenu",
".",
"className",
";",
"$",
".",
"each",
"(",
"cmenu",
".",
"theme",
".",
"split",
"(",
"\",\"",
")",
",",
"function",
"(",
"i",
",",
"n",
")",
"{",
"className",
"+=",
"' '",
"+",
"cmenu",
".",
"themePrefix",
"+",
"n",
";",
"}",
")",
";",
"//\t\t\tvar $t = $('<div style=\"background-color:#ffff00; xwidth:200px; height:200px\"><table style=\"\" cellspacing=0 cellpadding=0></table></div>').click(function(){cmenu.hide(); return false;}); // We wrap a table around it so width can be flexible",
"var",
"$t",
"=",
"$",
"(",
"'<table style=\"\" cellspacing=\"0\" cellpadding=\"0\"></table>'",
")",
".",
"click",
"(",
"function",
"(",
")",
"{",
"cmenu",
".",
"hide",
"(",
")",
";",
"return",
"false",
";",
"}",
")",
";",
"// We wrap a table around it so width can be flexible",
"var",
"$tr",
"=",
"$",
"(",
"'<tr></tr>'",
")",
";",
"var",
"$td",
"=",
"$",
"(",
"'<td></td>'",
")",
";",
"var",
"$div",
"=",
"cmenu",
".",
"_div",
"=",
"$",
"(",
"'<div class=\"'",
"+",
"className",
"+",
"'\"></div>'",
")",
";",
"cmenu",
".",
"_div",
".",
"hover",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"cmenu",
".",
"closeTimer",
")",
"{",
"clearTimeout",
"(",
"cmenu",
".",
"closeTimer",
")",
";",
"cmenu",
".",
"closeTimer",
"=",
"null",
";",
"}",
"}",
",",
"function",
"(",
")",
"{",
"var",
"myClass",
"=",
"cmenu",
";",
"function",
"timerRelay",
"(",
")",
"{",
"myClass",
".",
"hide",
"(",
")",
";",
"}",
"myClass",
".",
"closeTimer",
"=",
"setTimeout",
"(",
"timerRelay",
",",
"500",
")",
";",
"}",
")",
";",
"// Each menu item is specified as either:",
"// title:function",
"// or title: { property:value ... }",
"/*\n for (var i=0; i<menu.length; i++) {\n var m = menu[i];\n if (m==$.contextMenu.separator) {\n $div.append(cmenu.createSeparator());\n }\n else {\n for (var opt in menu[i]) {\n $div.append(cmenu.createMenuItem(opt,menu[i][opt])); // Extracted to method for extensibility\n }\n }\n }\n */",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"menu",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"m",
"=",
"menu",
"[",
"i",
"]",
";",
"if",
"(",
"m",
"===",
"$",
".",
"contextMenu",
".",
"separator",
")",
"{",
"$div",
".",
"append",
"(",
"cmenu",
".",
"createSeparator",
"(",
")",
")",
";",
"}",
"else",
"{",
"$div",
".",
"append",
"(",
"cmenu",
".",
"createMenuItem",
"(",
"m",
")",
")",
";",
"// Extracted to method for extensibility",
"}",
"}",
"if",
"(",
"cmenu",
".",
"useIframe",
")",
"{",
"$td",
".",
"append",
"(",
"cmenu",
".",
"createIframe",
"(",
")",
")",
";",
"}",
"$t",
".",
"append",
"(",
"$tr",
".",
"append",
"(",
"$td",
".",
"append",
"(",
"$div",
")",
")",
")",
";",
"return",
"$t",
";",
"}"
] |
Accept an Array representing a menu structure and turn it into HTML
|
[
"Accept",
"an",
"Array",
"representing",
"a",
"menu",
"structure",
"and",
"turn",
"it",
"into",
"HTML"
] |
84eacc15a65694ace4e7a2df46638c3a98252cab
|
https://github.com/alchemy-fr/Phraseanet-common/blob/84eacc15a65694ace4e7a2df46638c3a98252cab/src/components/vendors/contextMenu.js#L161-L223
|
|
39,388 |
alchemy-fr/Phraseanet-common
|
src/components/vendors/contextMenu.js
|
function (obj) {
var cmenu = this;
var label = obj.label;
if (typeof obj === "function") {
obj = {onclick: obj};
} // If passed a simple function, turn it into a property of an object
// Default properties, extended in case properties are passed
var o = $.extend({
onclick: function () {
},
className: '',
hoverClassName: cmenu.itemHoverClassName,
icon: '',
disabled: false,
title: '',
hoverItem: cmenu.hoverItem,
hoverItemOut: cmenu.hoverItemOut
}, obj);
// If an icon is specified, hard-code the background-image style. Themes that don't show images should take this into account in their CSS
var iconStyle = (o.icon) ? 'background-image:url(' + o.icon + ');' : '';
var $div = $('<div class="' + cmenu.itemClassName + ' ' + o.className + ((o.disabled) ? ' ' + cmenu.disabledItemClassName : '') + '" title="' + o.title + '"></div>')
// If the item is disabled, don't do anything when it is clicked
.click(
function (e) {
if (cmenu.isItemDisabled(this)) {
return false;
}
else {
return o.onclick.call(cmenu.target, this, cmenu, e, label);
}
}
)
// Change the class of the item when hovered over
.hover(
function () {
o.hoverItem.call(this, (cmenu.isItemDisabled(this)) ? cmenu.disabledItemHoverClassName : o.hoverClassName);
}
, function () {
o.hoverItemOut.call(this, (cmenu.isItemDisabled(this)) ? cmenu.disabledItemHoverClassName : o.hoverClassName);
}
);
var $idiv = $('<div class="' + cmenu.innerDivClassName + '" style="' + iconStyle + '">' + label + '</div>');
$div.append($idiv);
return $div;
}
|
javascript
|
function (obj) {
var cmenu = this;
var label = obj.label;
if (typeof obj === "function") {
obj = {onclick: obj};
} // If passed a simple function, turn it into a property of an object
// Default properties, extended in case properties are passed
var o = $.extend({
onclick: function () {
},
className: '',
hoverClassName: cmenu.itemHoverClassName,
icon: '',
disabled: false,
title: '',
hoverItem: cmenu.hoverItem,
hoverItemOut: cmenu.hoverItemOut
}, obj);
// If an icon is specified, hard-code the background-image style. Themes that don't show images should take this into account in their CSS
var iconStyle = (o.icon) ? 'background-image:url(' + o.icon + ');' : '';
var $div = $('<div class="' + cmenu.itemClassName + ' ' + o.className + ((o.disabled) ? ' ' + cmenu.disabledItemClassName : '') + '" title="' + o.title + '"></div>')
// If the item is disabled, don't do anything when it is clicked
.click(
function (e) {
if (cmenu.isItemDisabled(this)) {
return false;
}
else {
return o.onclick.call(cmenu.target, this, cmenu, e, label);
}
}
)
// Change the class of the item when hovered over
.hover(
function () {
o.hoverItem.call(this, (cmenu.isItemDisabled(this)) ? cmenu.disabledItemHoverClassName : o.hoverClassName);
}
, function () {
o.hoverItemOut.call(this, (cmenu.isItemDisabled(this)) ? cmenu.disabledItemHoverClassName : o.hoverClassName);
}
);
var $idiv = $('<div class="' + cmenu.innerDivClassName + '" style="' + iconStyle + '">' + label + '</div>');
$div.append($idiv);
return $div;
}
|
[
"function",
"(",
"obj",
")",
"{",
"var",
"cmenu",
"=",
"this",
";",
"var",
"label",
"=",
"obj",
".",
"label",
";",
"if",
"(",
"typeof",
"obj",
"===",
"\"function\"",
")",
"{",
"obj",
"=",
"{",
"onclick",
":",
"obj",
"}",
";",
"}",
"// If passed a simple function, turn it into a property of an object",
"// Default properties, extended in case properties are passed",
"var",
"o",
"=",
"$",
".",
"extend",
"(",
"{",
"onclick",
":",
"function",
"(",
")",
"{",
"}",
",",
"className",
":",
"''",
",",
"hoverClassName",
":",
"cmenu",
".",
"itemHoverClassName",
",",
"icon",
":",
"''",
",",
"disabled",
":",
"false",
",",
"title",
":",
"''",
",",
"hoverItem",
":",
"cmenu",
".",
"hoverItem",
",",
"hoverItemOut",
":",
"cmenu",
".",
"hoverItemOut",
"}",
",",
"obj",
")",
";",
"// If an icon is specified, hard-code the background-image style. Themes that don't show images should take this into account in their CSS",
"var",
"iconStyle",
"=",
"(",
"o",
".",
"icon",
")",
"?",
"'background-image:url('",
"+",
"o",
".",
"icon",
"+",
"');'",
":",
"''",
";",
"var",
"$div",
"=",
"$",
"(",
"'<div class=\"'",
"+",
"cmenu",
".",
"itemClassName",
"+",
"' '",
"+",
"o",
".",
"className",
"+",
"(",
"(",
"o",
".",
"disabled",
")",
"?",
"' '",
"+",
"cmenu",
".",
"disabledItemClassName",
":",
"''",
")",
"+",
"'\" title=\"'",
"+",
"o",
".",
"title",
"+",
"'\"></div>'",
")",
"// If the item is disabled, don't do anything when it is clicked",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"cmenu",
".",
"isItemDisabled",
"(",
"this",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"o",
".",
"onclick",
".",
"call",
"(",
"cmenu",
".",
"target",
",",
"this",
",",
"cmenu",
",",
"e",
",",
"label",
")",
";",
"}",
"}",
")",
"// Change the class of the item when hovered over",
".",
"hover",
"(",
"function",
"(",
")",
"{",
"o",
".",
"hoverItem",
".",
"call",
"(",
"this",
",",
"(",
"cmenu",
".",
"isItemDisabled",
"(",
"this",
")",
")",
"?",
"cmenu",
".",
"disabledItemHoverClassName",
":",
"o",
".",
"hoverClassName",
")",
";",
"}",
",",
"function",
"(",
")",
"{",
"o",
".",
"hoverItemOut",
".",
"call",
"(",
"this",
",",
"(",
"cmenu",
".",
"isItemDisabled",
"(",
"this",
")",
")",
"?",
"cmenu",
".",
"disabledItemHoverClassName",
":",
"o",
".",
"hoverClassName",
")",
";",
"}",
")",
";",
"var",
"$idiv",
"=",
"$",
"(",
"'<div class=\"'",
"+",
"cmenu",
".",
"innerDivClassName",
"+",
"'\" style=\"'",
"+",
"iconStyle",
"+",
"'\">'",
"+",
"label",
"+",
"'</div>'",
")",
";",
"$div",
".",
"append",
"(",
"$idiv",
")",
";",
"return",
"$div",
";",
"}"
] |
Create an individual menu item
|
[
"Create",
"an",
"individual",
"menu",
"item"
] |
84eacc15a65694ace4e7a2df46638c3a98252cab
|
https://github.com/alchemy-fr/Phraseanet-common/blob/84eacc15a65694ace4e7a2df46638c3a98252cab/src/components/vendors/contextMenu.js#L226-L270
|
|
39,389 |
alchemy-fr/Phraseanet-common
|
src/components/vendors/contextMenu.js
|
function (cmenu) {
cmenu.shadowObj = $('<div class="' + cmenu.shadowClass + '"></div>').css({
display: 'none',
position: "absolute",
zIndex: 9998,
opacity: cmenu.shadowOpacity,
backgroundColor: cmenu.shadowColor
});
$(cmenu.appendTo).append(cmenu.shadowObj);
}
|
javascript
|
function (cmenu) {
cmenu.shadowObj = $('<div class="' + cmenu.shadowClass + '"></div>').css({
display: 'none',
position: "absolute",
zIndex: 9998,
opacity: cmenu.shadowOpacity,
backgroundColor: cmenu.shadowColor
});
$(cmenu.appendTo).append(cmenu.shadowObj);
}
|
[
"function",
"(",
"cmenu",
")",
"{",
"cmenu",
".",
"shadowObj",
"=",
"$",
"(",
"'<div class=\"'",
"+",
"cmenu",
".",
"shadowClass",
"+",
"'\"></div>'",
")",
".",
"css",
"(",
"{",
"display",
":",
"'none'",
",",
"position",
":",
"\"absolute\"",
",",
"zIndex",
":",
"9998",
",",
"opacity",
":",
"cmenu",
".",
"shadowOpacity",
",",
"backgroundColor",
":",
"cmenu",
".",
"shadowColor",
"}",
")",
";",
"$",
"(",
"cmenu",
".",
"appendTo",
")",
".",
"append",
"(",
"cmenu",
".",
"shadowObj",
")",
";",
"}"
] |
Create the shadow object
|
[
"Create",
"the",
"shadow",
"object"
] |
84eacc15a65694ace4e7a2df46638c3a98252cab
|
https://github.com/alchemy-fr/Phraseanet-common/blob/84eacc15a65694ace4e7a2df46638c3a98252cab/src/components/vendors/contextMenu.js#L291-L300
|
|
39,390 |
alchemy-fr/Phraseanet-common
|
src/components/vendors/contextMenu.js
|
function (x, y, e) {
var cmenu = this;
if (cmenu.shadow) {
cmenu.shadowObj.css({
width: (cmenu.menu.width() + cmenu.shadowWidthAdjust) + "px",
height: (cmenu.menu.height() + cmenu.shadowHeightAdjust) + "px",
top: (y + cmenu.shadowOffsetY) + "px",
left: (x + cmenu.shadowOffsetX) + "px"
}).addClass(cmenu.shadowClass)[cmenu.showTransition](cmenu.showSpeed);
}
}
|
javascript
|
function (x, y, e) {
var cmenu = this;
if (cmenu.shadow) {
cmenu.shadowObj.css({
width: (cmenu.menu.width() + cmenu.shadowWidthAdjust) + "px",
height: (cmenu.menu.height() + cmenu.shadowHeightAdjust) + "px",
top: (y + cmenu.shadowOffsetY) + "px",
left: (x + cmenu.shadowOffsetX) + "px"
}).addClass(cmenu.shadowClass)[cmenu.showTransition](cmenu.showSpeed);
}
}
|
[
"function",
"(",
"x",
",",
"y",
",",
"e",
")",
"{",
"var",
"cmenu",
"=",
"this",
";",
"if",
"(",
"cmenu",
".",
"shadow",
")",
"{",
"cmenu",
".",
"shadowObj",
".",
"css",
"(",
"{",
"width",
":",
"(",
"cmenu",
".",
"menu",
".",
"width",
"(",
")",
"+",
"cmenu",
".",
"shadowWidthAdjust",
")",
"+",
"\"px\"",
",",
"height",
":",
"(",
"cmenu",
".",
"menu",
".",
"height",
"(",
")",
"+",
"cmenu",
".",
"shadowHeightAdjust",
")",
"+",
"\"px\"",
",",
"top",
":",
"(",
"y",
"+",
"cmenu",
".",
"shadowOffsetY",
")",
"+",
"\"px\"",
",",
"left",
":",
"(",
"x",
"+",
"cmenu",
".",
"shadowOffsetX",
")",
"+",
"\"px\"",
"}",
")",
".",
"addClass",
"(",
"cmenu",
".",
"shadowClass",
")",
"[",
"cmenu",
".",
"showTransition",
"]",
"(",
"cmenu",
".",
"showSpeed",
")",
";",
"}",
"}"
] |
Display the shadow object, given the position of the menu itself
|
[
"Display",
"the",
"shadow",
"object",
"given",
"the",
"position",
"of",
"the",
"menu",
"itself"
] |
84eacc15a65694ace4e7a2df46638c3a98252cab
|
https://github.com/alchemy-fr/Phraseanet-common/blob/84eacc15a65694ace4e7a2df46638c3a98252cab/src/components/vendors/contextMenu.js#L303-L313
|
|
39,391 |
alchemy-fr/Phraseanet-common
|
src/components/vendors/contextMenu.js
|
function (clickX, clickY, cmenu, e) {
var x = clickX + cmenu.offsetX;
var y = clickY + cmenu.offsetY;
var h = $(cmenu.menu).height();
var w = $(cmenu.menu).width();
var dir = cmenu.direction;
if (cmenu.constrainToScreen) {
var $w = $(window);
var wh = $w.height();
var ww = $w.width();
var st = $w.scrollTop();
var maxTop = y - st - 5;
var maxBottom = wh + st - y - 5;
if (h > maxBottom) {
if (h > maxTop) {
if (maxTop > maxBottom) {
// scrollable en haut
h = maxTop;
cmenu._div.css('height', h + 'px').css('overflow-y', 'scroll');
y -= h;
}
else {
// scrollable en bas
h = maxBottom;
cmenu._div.css('height', h + 'px').css('overflow-y', 'scroll');
}
}
else {
// menu ok en haut
y -= h;
}
}
else {
// menu ok en bas
}
var maxRight = x + w - $w.scrollLeft();
if (maxRight > ww) {
x -= (maxRight - ww);
}
}
return {'x': x, 'y': y};
}
|
javascript
|
function (clickX, clickY, cmenu, e) {
var x = clickX + cmenu.offsetX;
var y = clickY + cmenu.offsetY;
var h = $(cmenu.menu).height();
var w = $(cmenu.menu).width();
var dir = cmenu.direction;
if (cmenu.constrainToScreen) {
var $w = $(window);
var wh = $w.height();
var ww = $w.width();
var st = $w.scrollTop();
var maxTop = y - st - 5;
var maxBottom = wh + st - y - 5;
if (h > maxBottom) {
if (h > maxTop) {
if (maxTop > maxBottom) {
// scrollable en haut
h = maxTop;
cmenu._div.css('height', h + 'px').css('overflow-y', 'scroll');
y -= h;
}
else {
// scrollable en bas
h = maxBottom;
cmenu._div.css('height', h + 'px').css('overflow-y', 'scroll');
}
}
else {
// menu ok en haut
y -= h;
}
}
else {
// menu ok en bas
}
var maxRight = x + w - $w.scrollLeft();
if (maxRight > ww) {
x -= (maxRight - ww);
}
}
return {'x': x, 'y': y};
}
|
[
"function",
"(",
"clickX",
",",
"clickY",
",",
"cmenu",
",",
"e",
")",
"{",
"var",
"x",
"=",
"clickX",
"+",
"cmenu",
".",
"offsetX",
";",
"var",
"y",
"=",
"clickY",
"+",
"cmenu",
".",
"offsetY",
";",
"var",
"h",
"=",
"$",
"(",
"cmenu",
".",
"menu",
")",
".",
"height",
"(",
")",
";",
"var",
"w",
"=",
"$",
"(",
"cmenu",
".",
"menu",
")",
".",
"width",
"(",
")",
";",
"var",
"dir",
"=",
"cmenu",
".",
"direction",
";",
"if",
"(",
"cmenu",
".",
"constrainToScreen",
")",
"{",
"var",
"$w",
"=",
"$",
"(",
"window",
")",
";",
"var",
"wh",
"=",
"$w",
".",
"height",
"(",
")",
";",
"var",
"ww",
"=",
"$w",
".",
"width",
"(",
")",
";",
"var",
"st",
"=",
"$w",
".",
"scrollTop",
"(",
")",
";",
"var",
"maxTop",
"=",
"y",
"-",
"st",
"-",
"5",
";",
"var",
"maxBottom",
"=",
"wh",
"+",
"st",
"-",
"y",
"-",
"5",
";",
"if",
"(",
"h",
">",
"maxBottom",
")",
"{",
"if",
"(",
"h",
">",
"maxTop",
")",
"{",
"if",
"(",
"maxTop",
">",
"maxBottom",
")",
"{",
"// scrollable en haut",
"h",
"=",
"maxTop",
";",
"cmenu",
".",
"_div",
".",
"css",
"(",
"'height'",
",",
"h",
"+",
"'px'",
")",
".",
"css",
"(",
"'overflow-y'",
",",
"'scroll'",
")",
";",
"y",
"-=",
"h",
";",
"}",
"else",
"{",
"// scrollable en bas",
"h",
"=",
"maxBottom",
";",
"cmenu",
".",
"_div",
".",
"css",
"(",
"'height'",
",",
"h",
"+",
"'px'",
")",
".",
"css",
"(",
"'overflow-y'",
",",
"'scroll'",
")",
";",
"}",
"}",
"else",
"{",
"// menu ok en haut",
"y",
"-=",
"h",
";",
"}",
"}",
"else",
"{",
"// menu ok en bas",
"}",
"var",
"maxRight",
"=",
"x",
"+",
"w",
"-",
"$w",
".",
"scrollLeft",
"(",
")",
";",
"if",
"(",
"maxRight",
">",
"ww",
")",
"{",
"x",
"-=",
"(",
"maxRight",
"-",
"ww",
")",
";",
"}",
"}",
"return",
"{",
"'x'",
":",
"x",
",",
"'y'",
":",
"y",
"}",
";",
"}"
] |
Find the position where the menu should appear, given an x,y of the click event
|
[
"Find",
"the",
"position",
"where",
"the",
"menu",
"should",
"appear",
"given",
"an",
"x",
"y",
"of",
"the",
"click",
"event"
] |
84eacc15a65694ace4e7a2df46638c3a98252cab
|
https://github.com/alchemy-fr/Phraseanet-common/blob/84eacc15a65694ace4e7a2df46638c3a98252cab/src/components/vendors/contextMenu.js#L418-L460
|
|
39,392 |
alchemy-fr/Phraseanet-common
|
src/components/vendors/contextMenu.js
|
function () {
var cmenu = this;
if (cmenu.shown) {
if (cmenu.iframe) {
$(cmenu.iframe).hide();
}
if (cmenu.menu) {
cmenu.menu[cmenu.hideTransition](cmenu.hideSpeed, ((cmenu.hideCallback) ? function () {
cmenu.hideCallback.call(cmenu);
} : null));
}
if (cmenu.shadow) {
cmenu.shadowObj[cmenu.hideTransition](cmenu.hideSpeed);
}
}
cmenu.shown = false;
}
|
javascript
|
function () {
var cmenu = this;
if (cmenu.shown) {
if (cmenu.iframe) {
$(cmenu.iframe).hide();
}
if (cmenu.menu) {
cmenu.menu[cmenu.hideTransition](cmenu.hideSpeed, ((cmenu.hideCallback) ? function () {
cmenu.hideCallback.call(cmenu);
} : null));
}
if (cmenu.shadow) {
cmenu.shadowObj[cmenu.hideTransition](cmenu.hideSpeed);
}
}
cmenu.shown = false;
}
|
[
"function",
"(",
")",
"{",
"var",
"cmenu",
"=",
"this",
";",
"if",
"(",
"cmenu",
".",
"shown",
")",
"{",
"if",
"(",
"cmenu",
".",
"iframe",
")",
"{",
"$",
"(",
"cmenu",
".",
"iframe",
")",
".",
"hide",
"(",
")",
";",
"}",
"if",
"(",
"cmenu",
".",
"menu",
")",
"{",
"cmenu",
".",
"menu",
"[",
"cmenu",
".",
"hideTransition",
"]",
"(",
"cmenu",
".",
"hideSpeed",
",",
"(",
"(",
"cmenu",
".",
"hideCallback",
")",
"?",
"function",
"(",
")",
"{",
"cmenu",
".",
"hideCallback",
".",
"call",
"(",
"cmenu",
")",
";",
"}",
":",
"null",
")",
")",
";",
"}",
"if",
"(",
"cmenu",
".",
"shadow",
")",
"{",
"cmenu",
".",
"shadowObj",
"[",
"cmenu",
".",
"hideTransition",
"]",
"(",
"cmenu",
".",
"hideSpeed",
")",
";",
"}",
"}",
"cmenu",
".",
"shown",
"=",
"false",
";",
"}"
] |
Hide the menu, of course
|
[
"Hide",
"the",
"menu",
"of",
"course"
] |
84eacc15a65694ace4e7a2df46638c3a98252cab
|
https://github.com/alchemy-fr/Phraseanet-common/blob/84eacc15a65694ace4e7a2df46638c3a98252cab/src/components/vendors/contextMenu.js#L463-L479
|
|
39,393 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js
|
fnArraySwitch
|
function fnArraySwitch( aArray, iFrom, iTo )
{
var mStore = aArray.splice( iFrom, 1 )[0];
aArray.splice( iTo, 0, mStore );
}
|
javascript
|
function fnArraySwitch( aArray, iFrom, iTo )
{
var mStore = aArray.splice( iFrom, 1 )[0];
aArray.splice( iTo, 0, mStore );
}
|
[
"function",
"fnArraySwitch",
"(",
"aArray",
",",
"iFrom",
",",
"iTo",
")",
"{",
"var",
"mStore",
"=",
"aArray",
".",
"splice",
"(",
"iFrom",
",",
"1",
")",
"[",
"0",
"]",
";",
"aArray",
".",
"splice",
"(",
"iTo",
",",
"0",
",",
"mStore",
")",
";",
"}"
] |
Modify an array by switching the position of two elements
@method fnArraySwitch
@param array aArray Array to consider, will be modified by reference (i.e. no return)
@param int iFrom From point
@param int iTo Insert point
@returns void
|
[
"Modify",
"an",
"array",
"by",
"switching",
"the",
"position",
"of",
"two",
"elements"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L53-L57
|
39,394 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js
|
function( dt, opts )
{
var oDTSettings;
if ( $.fn.dataTable.Api ) {
oDTSettings = new $.fn.dataTable.Api( dt ).settings()[0];
}
// 1.9 compatibility
else if ( dt.fnSettings ) {
// DataTables object, convert to the settings object
oDTSettings = dt.fnSettings();
}
else if ( typeof dt === 'string' ) {
// jQuery selector
if ( $.fn.dataTable.fnIsDataTable( $(dt)[0] ) ) {
oDTSettings = $(dt).eq(0).dataTable().fnSettings();
}
}
else if ( dt.nodeName && dt.nodeName.toLowerCase() === 'table' ) {
// Table node
if ( $.fn.dataTable.fnIsDataTable( dt.nodeName ) ) {
oDTSettings = $(dt.nodeName).dataTable().fnSettings();
}
}
else if ( dt instanceof jQuery ) {
// jQuery object
if ( $.fn.dataTable.fnIsDataTable( dt[0] ) ) {
oDTSettings = dt.eq(0).dataTable().fnSettings();
}
}
else {
// DataTables settings object
oDTSettings = dt;
}
// Ensure that we can't initialise on the same table twice
if ( oDTSettings._colReorder ) {
throw "ColReorder already initialised on table #"+oDTSettings.nTable.id;
}
// Convert from camelCase to Hungarian, just as DataTables does
var camelToHungarian = $.fn.dataTable.camelToHungarian;
if ( camelToHungarian ) {
camelToHungarian( ColReorder.defaults, ColReorder.defaults, true );
camelToHungarian( ColReorder.defaults, opts || {} );
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Public class variables
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* @namespace Settings object which contains customisable information for ColReorder instance
*/
this.s = {
/**
* DataTables settings object
* @property dt
* @type Object
* @default null
*/
"dt": null,
/**
* Initialisation object used for this instance
* @property init
* @type object
* @default {}
*/
"init": $.extend( true, {}, ColReorder.defaults, opts ),
/**
* Number of columns to fix (not allow to be reordered)
* @property fixed
* @type int
* @default 0
*/
"fixed": 0,
/**
* Number of columns to fix counting from right (not allow to be reordered)
* @property fixedRight
* @type int
* @default 0
*/
"fixedRight": 0,
/**
* Callback function for once the reorder has been done
* @property reorderCallback
* @type function
* @default null
*/
"reorderCallback": null,
/**
* @namespace Information used for the mouse drag
*/
"mouse": {
"startX": -1,
"startY": -1,
"offsetX": -1,
"offsetY": -1,
"target": -1,
"targetIndex": -1,
"fromIndex": -1
},
/**
* Information which is used for positioning the insert cusor and knowing where to do the
* insert. Array of objects with the properties:
* x: x-axis position
* to: insert point
* @property aoTargets
* @type array
* @default []
*/
"aoTargets": []
};
/**
* @namespace Common and useful DOM elements for the class instance
*/
this.dom = {
/**
* Dragging element (the one the mouse is moving)
* @property drag
* @type element
* @default null
*/
"drag": null,
/**
* The insert cursor
* @property pointer
* @type element
* @default null
*/
"pointer": null
};
/* Constructor logic */
this.s.dt = oDTSettings;
this.s.dt._colReorder = this;
this._fnConstruct();
/* Add destroy callback */
oDTSettings.oApi._fnCallbackReg(oDTSettings, 'aoDestroyCallback', $.proxy(this._fnDestroy, this), 'ColReorder');
return this;
}
|
javascript
|
function( dt, opts )
{
var oDTSettings;
if ( $.fn.dataTable.Api ) {
oDTSettings = new $.fn.dataTable.Api( dt ).settings()[0];
}
// 1.9 compatibility
else if ( dt.fnSettings ) {
// DataTables object, convert to the settings object
oDTSettings = dt.fnSettings();
}
else if ( typeof dt === 'string' ) {
// jQuery selector
if ( $.fn.dataTable.fnIsDataTable( $(dt)[0] ) ) {
oDTSettings = $(dt).eq(0).dataTable().fnSettings();
}
}
else if ( dt.nodeName && dt.nodeName.toLowerCase() === 'table' ) {
// Table node
if ( $.fn.dataTable.fnIsDataTable( dt.nodeName ) ) {
oDTSettings = $(dt.nodeName).dataTable().fnSettings();
}
}
else if ( dt instanceof jQuery ) {
// jQuery object
if ( $.fn.dataTable.fnIsDataTable( dt[0] ) ) {
oDTSettings = dt.eq(0).dataTable().fnSettings();
}
}
else {
// DataTables settings object
oDTSettings = dt;
}
// Ensure that we can't initialise on the same table twice
if ( oDTSettings._colReorder ) {
throw "ColReorder already initialised on table #"+oDTSettings.nTable.id;
}
// Convert from camelCase to Hungarian, just as DataTables does
var camelToHungarian = $.fn.dataTable.camelToHungarian;
if ( camelToHungarian ) {
camelToHungarian( ColReorder.defaults, ColReorder.defaults, true );
camelToHungarian( ColReorder.defaults, opts || {} );
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Public class variables
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/**
* @namespace Settings object which contains customisable information for ColReorder instance
*/
this.s = {
/**
* DataTables settings object
* @property dt
* @type Object
* @default null
*/
"dt": null,
/**
* Initialisation object used for this instance
* @property init
* @type object
* @default {}
*/
"init": $.extend( true, {}, ColReorder.defaults, opts ),
/**
* Number of columns to fix (not allow to be reordered)
* @property fixed
* @type int
* @default 0
*/
"fixed": 0,
/**
* Number of columns to fix counting from right (not allow to be reordered)
* @property fixedRight
* @type int
* @default 0
*/
"fixedRight": 0,
/**
* Callback function for once the reorder has been done
* @property reorderCallback
* @type function
* @default null
*/
"reorderCallback": null,
/**
* @namespace Information used for the mouse drag
*/
"mouse": {
"startX": -1,
"startY": -1,
"offsetX": -1,
"offsetY": -1,
"target": -1,
"targetIndex": -1,
"fromIndex": -1
},
/**
* Information which is used for positioning the insert cusor and knowing where to do the
* insert. Array of objects with the properties:
* x: x-axis position
* to: insert point
* @property aoTargets
* @type array
* @default []
*/
"aoTargets": []
};
/**
* @namespace Common and useful DOM elements for the class instance
*/
this.dom = {
/**
* Dragging element (the one the mouse is moving)
* @property drag
* @type element
* @default null
*/
"drag": null,
/**
* The insert cursor
* @property pointer
* @type element
* @default null
*/
"pointer": null
};
/* Constructor logic */
this.s.dt = oDTSettings;
this.s.dt._colReorder = this;
this._fnConstruct();
/* Add destroy callback */
oDTSettings.oApi._fnCallbackReg(oDTSettings, 'aoDestroyCallback', $.proxy(this._fnDestroy, this), 'ColReorder');
return this;
}
|
[
"function",
"(",
"dt",
",",
"opts",
")",
"{",
"var",
"oDTSettings",
";",
"if",
"(",
"$",
".",
"fn",
".",
"dataTable",
".",
"Api",
")",
"{",
"oDTSettings",
"=",
"new",
"$",
".",
"fn",
".",
"dataTable",
".",
"Api",
"(",
"dt",
")",
".",
"settings",
"(",
")",
"[",
"0",
"]",
";",
"}",
"// 1.9 compatibility",
"else",
"if",
"(",
"dt",
".",
"fnSettings",
")",
"{",
"// DataTables object, convert to the settings object",
"oDTSettings",
"=",
"dt",
".",
"fnSettings",
"(",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"dt",
"===",
"'string'",
")",
"{",
"// jQuery selector",
"if",
"(",
"$",
".",
"fn",
".",
"dataTable",
".",
"fnIsDataTable",
"(",
"$",
"(",
"dt",
")",
"[",
"0",
"]",
")",
")",
"{",
"oDTSettings",
"=",
"$",
"(",
"dt",
")",
".",
"eq",
"(",
"0",
")",
".",
"dataTable",
"(",
")",
".",
"fnSettings",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"dt",
".",
"nodeName",
"&&",
"dt",
".",
"nodeName",
".",
"toLowerCase",
"(",
")",
"===",
"'table'",
")",
"{",
"// Table node",
"if",
"(",
"$",
".",
"fn",
".",
"dataTable",
".",
"fnIsDataTable",
"(",
"dt",
".",
"nodeName",
")",
")",
"{",
"oDTSettings",
"=",
"$",
"(",
"dt",
".",
"nodeName",
")",
".",
"dataTable",
"(",
")",
".",
"fnSettings",
"(",
")",
";",
"}",
"}",
"else",
"if",
"(",
"dt",
"instanceof",
"jQuery",
")",
"{",
"// jQuery object",
"if",
"(",
"$",
".",
"fn",
".",
"dataTable",
".",
"fnIsDataTable",
"(",
"dt",
"[",
"0",
"]",
")",
")",
"{",
"oDTSettings",
"=",
"dt",
".",
"eq",
"(",
"0",
")",
".",
"dataTable",
"(",
")",
".",
"fnSettings",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// DataTables settings object",
"oDTSettings",
"=",
"dt",
";",
"}",
"// Ensure that we can't initialise on the same table twice",
"if",
"(",
"oDTSettings",
".",
"_colReorder",
")",
"{",
"throw",
"\"ColReorder already initialised on table #\"",
"+",
"oDTSettings",
".",
"nTable",
".",
"id",
";",
"}",
"// Convert from camelCase to Hungarian, just as DataTables does",
"var",
"camelToHungarian",
"=",
"$",
".",
"fn",
".",
"dataTable",
".",
"camelToHungarian",
";",
"if",
"(",
"camelToHungarian",
")",
"{",
"camelToHungarian",
"(",
"ColReorder",
".",
"defaults",
",",
"ColReorder",
".",
"defaults",
",",
"true",
")",
";",
"camelToHungarian",
"(",
"ColReorder",
".",
"defaults",
",",
"opts",
"||",
"{",
"}",
")",
";",
"}",
"/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\t * Public class variables\n\t * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */",
"/**\n\t * @namespace Settings object which contains customisable information for ColReorder instance\n\t */",
"this",
".",
"s",
"=",
"{",
"/**\n\t\t * DataTables settings object\n\t\t * @property dt\n\t\t * @type Object\n\t\t * @default null\n\t\t */",
"\"dt\"",
":",
"null",
",",
"/**\n\t\t * Initialisation object used for this instance\n\t\t * @property init\n\t\t * @type object\n\t\t * @default {}\n\t\t */",
"\"init\"",
":",
"$",
".",
"extend",
"(",
"true",
",",
"{",
"}",
",",
"ColReorder",
".",
"defaults",
",",
"opts",
")",
",",
"/**\n\t\t * Number of columns to fix (not allow to be reordered)\n\t\t * @property fixed\n\t\t * @type int\n\t\t * @default 0\n\t\t */",
"\"fixed\"",
":",
"0",
",",
"/**\n\t\t * Number of columns to fix counting from right (not allow to be reordered)\n\t\t * @property fixedRight\n\t\t * @type int\n\t\t * @default 0\n\t\t */",
"\"fixedRight\"",
":",
"0",
",",
"/**\n\t\t * Callback function for once the reorder has been done\n\t\t * @property reorderCallback\n\t\t * @type function\n\t\t * @default null\n\t\t */",
"\"reorderCallback\"",
":",
"null",
",",
"/**\n\t\t * @namespace Information used for the mouse drag\n\t\t */",
"\"mouse\"",
":",
"{",
"\"startX\"",
":",
"-",
"1",
",",
"\"startY\"",
":",
"-",
"1",
",",
"\"offsetX\"",
":",
"-",
"1",
",",
"\"offsetY\"",
":",
"-",
"1",
",",
"\"target\"",
":",
"-",
"1",
",",
"\"targetIndex\"",
":",
"-",
"1",
",",
"\"fromIndex\"",
":",
"-",
"1",
"}",
",",
"/**\n\t\t * Information which is used for positioning the insert cusor and knowing where to do the\n\t\t * insert. Array of objects with the properties:\n\t\t * x: x-axis position\n\t\t * to: insert point\n\t\t * @property aoTargets\n\t\t * @type array\n\t\t * @default []\n\t\t */",
"\"aoTargets\"",
":",
"[",
"]",
"}",
";",
"/**\n\t * @namespace Common and useful DOM elements for the class instance\n\t */",
"this",
".",
"dom",
"=",
"{",
"/**\n\t\t * Dragging element (the one the mouse is moving)\n\t\t * @property drag\n\t\t * @type element\n\t\t * @default null\n\t\t */",
"\"drag\"",
":",
"null",
",",
"/**\n\t\t * The insert cursor\n\t\t * @property pointer\n\t\t * @type element\n\t\t * @default null\n\t\t */",
"\"pointer\"",
":",
"null",
"}",
";",
"/* Constructor logic */",
"this",
".",
"s",
".",
"dt",
"=",
"oDTSettings",
";",
"this",
".",
"s",
".",
"dt",
".",
"_colReorder",
"=",
"this",
";",
"this",
".",
"_fnConstruct",
"(",
")",
";",
"/* Add destroy callback */",
"oDTSettings",
".",
"oApi",
".",
"_fnCallbackReg",
"(",
"oDTSettings",
",",
"'aoDestroyCallback'",
",",
"$",
".",
"proxy",
"(",
"this",
".",
"_fnDestroy",
",",
"this",
")",
",",
"'ColReorder'",
")",
";",
"return",
"this",
";",
"}"
] |
ColReorder provides column visibility control for DataTables
@class ColReorder
@constructor
@param {object} dt DataTables settings object
@param {object} opts ColReorder options
|
[
"ColReorder",
"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/ColReorder/js/dataTables.colReorder.js#L349-L502
|
|
39,395 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js
|
function ( a )
{
if ( a.length != this.s.dt.aoColumns.length )
{
this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+
"match known number of columns. Skipping." );
return;
}
for ( var i=0, iLen=a.length ; i<iLen ; i++ )
{
var currIndex = $.inArray( i, a );
if ( i != currIndex )
{
/* Reorder our switching array */
fnArraySwitch( a, currIndex, i );
/* Do the column reorder in the table */
this.s.dt.oInstance.fnColReorder( currIndex, i );
}
}
/* When scrolling we need to recalculate the column sizes to allow for the shift */
if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
{
this.s.dt.oInstance.fnAdjustColumnSizing( false );
}
/* Save the state */
this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
this._fnSetColumnIndexes();
if ( this.s.reorderCallback !== null )
{
this.s.reorderCallback.call( this );
}
}
|
javascript
|
function ( a )
{
if ( a.length != this.s.dt.aoColumns.length )
{
this.s.dt.oInstance.oApi._fnLog( this.s.dt, 1, "ColReorder - array reorder does not "+
"match known number of columns. Skipping." );
return;
}
for ( var i=0, iLen=a.length ; i<iLen ; i++ )
{
var currIndex = $.inArray( i, a );
if ( i != currIndex )
{
/* Reorder our switching array */
fnArraySwitch( a, currIndex, i );
/* Do the column reorder in the table */
this.s.dt.oInstance.fnColReorder( currIndex, i );
}
}
/* When scrolling we need to recalculate the column sizes to allow for the shift */
if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
{
this.s.dt.oInstance.fnAdjustColumnSizing( false );
}
/* Save the state */
this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
this._fnSetColumnIndexes();
if ( this.s.reorderCallback !== null )
{
this.s.reorderCallback.call( this );
}
}
|
[
"function",
"(",
"a",
")",
"{",
"if",
"(",
"a",
".",
"length",
"!=",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
".",
"length",
")",
"{",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"oApi",
".",
"_fnLog",
"(",
"this",
".",
"s",
".",
"dt",
",",
"1",
",",
"\"ColReorder - array reorder does not \"",
"+",
"\"match known number of columns. Skipping.\"",
")",
";",
"return",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"iLen",
"=",
"a",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"var",
"currIndex",
"=",
"$",
".",
"inArray",
"(",
"i",
",",
"a",
")",
";",
"if",
"(",
"i",
"!=",
"currIndex",
")",
"{",
"/* Reorder our switching array */",
"fnArraySwitch",
"(",
"a",
",",
"currIndex",
",",
"i",
")",
";",
"/* Do the column reorder in the table */",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnColReorder",
"(",
"currIndex",
",",
"i",
")",
";",
"}",
"}",
"/* When scrolling we need to recalculate the column sizes to allow for the shift */",
"if",
"(",
"this",
".",
"s",
".",
"dt",
".",
"oScroll",
".",
"sX",
"!==",
"\"\"",
"||",
"this",
".",
"s",
".",
"dt",
".",
"oScroll",
".",
"sY",
"!==",
"\"\"",
")",
"{",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnAdjustColumnSizing",
"(",
"false",
")",
";",
"}",
"/* Save the state */",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"oApi",
".",
"_fnSaveState",
"(",
"this",
".",
"s",
".",
"dt",
")",
";",
"this",
".",
"_fnSetColumnIndexes",
"(",
")",
";",
"if",
"(",
"this",
".",
"s",
".",
"reorderCallback",
"!==",
"null",
")",
"{",
"this",
".",
"s",
".",
"reorderCallback",
".",
"call",
"(",
"this",
")",
";",
"}",
"}"
] |
Set the column order from an array
@method _fnOrderColumns
@param array a An array of integers which dictate the column order that should be applied
@returns void
@private
|
[
"Set",
"the",
"column",
"order",
"from",
"an",
"array"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L710-L747
|
|
39,396 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js
|
function ( oState )
{
var i, iLen, aCopy, iOrigColumn;
var oSettings = this.s.dt;
var columns = oSettings.aoColumns;
oState.ColReorder = [];
/* Sorting */
if ( oState.aaSorting ) {
// 1.10.0-
for ( i=0 ; i<oState.aaSorting.length ; i++ ) {
oState.aaSorting[i][0] = columns[ oState.aaSorting[i][0] ]._ColReorder_iOrigCol;
}
var aSearchCopy = $.extend( true, [], oState.aoSearchCols );
for ( i=0, iLen=columns.length ; i<iLen ; i++ )
{
iOrigColumn = columns[i]._ColReorder_iOrigCol;
/* Column filter */
oState.aoSearchCols[ iOrigColumn ] = aSearchCopy[i];
/* Visibility */
oState.abVisCols[ iOrigColumn ] = columns[i].bVisible;
/* Column reordering */
oState.ColReorder.push( iOrigColumn );
}
}
else if ( oState.order ) {
// 1.10.1+
for ( i=0 ; i<oState.order.length ; i++ ) {
oState.order[i][0] = columns[ oState.order[i][0] ]._ColReorder_iOrigCol;
}
var stateColumnsCopy = $.extend( true, [], oState.columns );
for ( i=0, iLen=columns.length ; i<iLen ; i++ )
{
iOrigColumn = columns[i]._ColReorder_iOrigCol;
/* Columns */
oState.columns[ iOrigColumn ] = stateColumnsCopy[i];
/* Column reordering */
oState.ColReorder.push( iOrigColumn );
}
}
}
|
javascript
|
function ( oState )
{
var i, iLen, aCopy, iOrigColumn;
var oSettings = this.s.dt;
var columns = oSettings.aoColumns;
oState.ColReorder = [];
/* Sorting */
if ( oState.aaSorting ) {
// 1.10.0-
for ( i=0 ; i<oState.aaSorting.length ; i++ ) {
oState.aaSorting[i][0] = columns[ oState.aaSorting[i][0] ]._ColReorder_iOrigCol;
}
var aSearchCopy = $.extend( true, [], oState.aoSearchCols );
for ( i=0, iLen=columns.length ; i<iLen ; i++ )
{
iOrigColumn = columns[i]._ColReorder_iOrigCol;
/* Column filter */
oState.aoSearchCols[ iOrigColumn ] = aSearchCopy[i];
/* Visibility */
oState.abVisCols[ iOrigColumn ] = columns[i].bVisible;
/* Column reordering */
oState.ColReorder.push( iOrigColumn );
}
}
else if ( oState.order ) {
// 1.10.1+
for ( i=0 ; i<oState.order.length ; i++ ) {
oState.order[i][0] = columns[ oState.order[i][0] ]._ColReorder_iOrigCol;
}
var stateColumnsCopy = $.extend( true, [], oState.columns );
for ( i=0, iLen=columns.length ; i<iLen ; i++ )
{
iOrigColumn = columns[i]._ColReorder_iOrigCol;
/* Columns */
oState.columns[ iOrigColumn ] = stateColumnsCopy[i];
/* Column reordering */
oState.ColReorder.push( iOrigColumn );
}
}
}
|
[
"function",
"(",
"oState",
")",
"{",
"var",
"i",
",",
"iLen",
",",
"aCopy",
",",
"iOrigColumn",
";",
"var",
"oSettings",
"=",
"this",
".",
"s",
".",
"dt",
";",
"var",
"columns",
"=",
"oSettings",
".",
"aoColumns",
";",
"oState",
".",
"ColReorder",
"=",
"[",
"]",
";",
"/* Sorting */",
"if",
"(",
"oState",
".",
"aaSorting",
")",
"{",
"// 1.10.0-",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"oState",
".",
"aaSorting",
".",
"length",
";",
"i",
"++",
")",
"{",
"oState",
".",
"aaSorting",
"[",
"i",
"]",
"[",
"0",
"]",
"=",
"columns",
"[",
"oState",
".",
"aaSorting",
"[",
"i",
"]",
"[",
"0",
"]",
"]",
".",
"_ColReorder_iOrigCol",
";",
"}",
"var",
"aSearchCopy",
"=",
"$",
".",
"extend",
"(",
"true",
",",
"[",
"]",
",",
"oState",
".",
"aoSearchCols",
")",
";",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"columns",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"iOrigColumn",
"=",
"columns",
"[",
"i",
"]",
".",
"_ColReorder_iOrigCol",
";",
"/* Column filter */",
"oState",
".",
"aoSearchCols",
"[",
"iOrigColumn",
"]",
"=",
"aSearchCopy",
"[",
"i",
"]",
";",
"/* Visibility */",
"oState",
".",
"abVisCols",
"[",
"iOrigColumn",
"]",
"=",
"columns",
"[",
"i",
"]",
".",
"bVisible",
";",
"/* Column reordering */",
"oState",
".",
"ColReorder",
".",
"push",
"(",
"iOrigColumn",
")",
";",
"}",
"}",
"else",
"if",
"(",
"oState",
".",
"order",
")",
"{",
"// 1.10.1+",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"oState",
".",
"order",
".",
"length",
";",
"i",
"++",
")",
"{",
"oState",
".",
"order",
"[",
"i",
"]",
"[",
"0",
"]",
"=",
"columns",
"[",
"oState",
".",
"order",
"[",
"i",
"]",
"[",
"0",
"]",
"]",
".",
"_ColReorder_iOrigCol",
";",
"}",
"var",
"stateColumnsCopy",
"=",
"$",
".",
"extend",
"(",
"true",
",",
"[",
"]",
",",
"oState",
".",
"columns",
")",
";",
"for",
"(",
"i",
"=",
"0",
",",
"iLen",
"=",
"columns",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"iOrigColumn",
"=",
"columns",
"[",
"i",
"]",
".",
"_ColReorder_iOrigCol",
";",
"/* Columns */",
"oState",
".",
"columns",
"[",
"iOrigColumn",
"]",
"=",
"stateColumnsCopy",
"[",
"i",
"]",
";",
"/* Column reordering */",
"oState",
".",
"ColReorder",
".",
"push",
"(",
"iOrigColumn",
")",
";",
"}",
"}",
"}"
] |
Because we change the indexes of columns in the table, relative to their starting point
we need to reorder the state columns to what they are at the starting point so we can
then rearrange them again on state load!
@method _fnStateSave
@param object oState DataTables state
@returns string JSON encoded cookie string for DataTables
@private
|
[
"Because",
"we",
"change",
"the",
"indexes",
"of",
"columns",
"in",
"the",
"table",
"relative",
"to",
"their",
"starting",
"point",
"we",
"need",
"to",
"reorder",
"the",
"state",
"columns",
"to",
"what",
"they",
"are",
"at",
"the",
"starting",
"point",
"so",
"we",
"can",
"then",
"rearrange",
"them",
"again",
"on",
"state",
"load!"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L759-L809
|
|
39,397 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js
|
function ( e, nTh )
{
var that = this;
/* Store information about the mouse position */
var target = $(e.target).closest('th, td');
var offset = target.offset();
var idx = parseInt( $(nTh).attr('data-column-index'), 10 );
if ( idx === undefined ) {
return;
}
this.s.mouse.startX = e.pageX;
this.s.mouse.startY = e.pageY;
this.s.mouse.offsetX = e.pageX - offset.left;
this.s.mouse.offsetY = e.pageY - offset.top;
this.s.mouse.target = this.s.dt.aoColumns[ idx ].nTh;//target[0];
this.s.mouse.targetIndex = idx;
this.s.mouse.fromIndex = idx;
this._fnRegions();
/* Add event handlers to the document */
$(document)
.on( 'mousemove.ColReorder', function (e) {
that._fnMouseMove.call( that, e );
} )
.on( 'mouseup.ColReorder', function (e) {
that._fnMouseUp.call( that, e );
} );
}
|
javascript
|
function ( e, nTh )
{
var that = this;
/* Store information about the mouse position */
var target = $(e.target).closest('th, td');
var offset = target.offset();
var idx = parseInt( $(nTh).attr('data-column-index'), 10 );
if ( idx === undefined ) {
return;
}
this.s.mouse.startX = e.pageX;
this.s.mouse.startY = e.pageY;
this.s.mouse.offsetX = e.pageX - offset.left;
this.s.mouse.offsetY = e.pageY - offset.top;
this.s.mouse.target = this.s.dt.aoColumns[ idx ].nTh;//target[0];
this.s.mouse.targetIndex = idx;
this.s.mouse.fromIndex = idx;
this._fnRegions();
/* Add event handlers to the document */
$(document)
.on( 'mousemove.ColReorder', function (e) {
that._fnMouseMove.call( that, e );
} )
.on( 'mouseup.ColReorder', function (e) {
that._fnMouseUp.call( that, e );
} );
}
|
[
"function",
"(",
"e",
",",
"nTh",
")",
"{",
"var",
"that",
"=",
"this",
";",
"/* Store information about the mouse position */",
"var",
"target",
"=",
"$",
"(",
"e",
".",
"target",
")",
".",
"closest",
"(",
"'th, td'",
")",
";",
"var",
"offset",
"=",
"target",
".",
"offset",
"(",
")",
";",
"var",
"idx",
"=",
"parseInt",
"(",
"$",
"(",
"nTh",
")",
".",
"attr",
"(",
"'data-column-index'",
")",
",",
"10",
")",
";",
"if",
"(",
"idx",
"===",
"undefined",
")",
"{",
"return",
";",
"}",
"this",
".",
"s",
".",
"mouse",
".",
"startX",
"=",
"e",
".",
"pageX",
";",
"this",
".",
"s",
".",
"mouse",
".",
"startY",
"=",
"e",
".",
"pageY",
";",
"this",
".",
"s",
".",
"mouse",
".",
"offsetX",
"=",
"e",
".",
"pageX",
"-",
"offset",
".",
"left",
";",
"this",
".",
"s",
".",
"mouse",
".",
"offsetY",
"=",
"e",
".",
"pageY",
"-",
"offset",
".",
"top",
";",
"this",
".",
"s",
".",
"mouse",
".",
"target",
"=",
"this",
".",
"s",
".",
"dt",
".",
"aoColumns",
"[",
"idx",
"]",
".",
"nTh",
";",
"//target[0];",
"this",
".",
"s",
".",
"mouse",
".",
"targetIndex",
"=",
"idx",
";",
"this",
".",
"s",
".",
"mouse",
".",
"fromIndex",
"=",
"idx",
";",
"this",
".",
"_fnRegions",
"(",
")",
";",
"/* Add event handlers to the document */",
"$",
"(",
"document",
")",
".",
"on",
"(",
"'mousemove.ColReorder'",
",",
"function",
"(",
"e",
")",
"{",
"that",
".",
"_fnMouseMove",
".",
"call",
"(",
"that",
",",
"e",
")",
";",
"}",
")",
".",
"on",
"(",
"'mouseup.ColReorder'",
",",
"function",
"(",
"e",
")",
"{",
"that",
".",
"_fnMouseUp",
".",
"call",
"(",
"that",
",",
"e",
")",
";",
"}",
")",
";",
"}"
] |
Mouse down on a TH element in the table header
@method _fnMouseDown
@param event e Mouse event
@param element nTh TH element to be dragged
@returns void
@private
|
[
"Mouse",
"down",
"on",
"a",
"TH",
"element",
"in",
"the",
"table",
"header"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L842-L873
|
|
39,398 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js
|
function ( e )
{
var that = this;
if ( this.dom.drag === null )
{
/* Only create the drag element if the mouse has moved a specific distance from the start
* point - this allows the user to make small mouse movements when sorting and not have a
* possibly confusing drag element showing up
*/
if ( Math.pow(
Math.pow(e.pageX - this.s.mouse.startX, 2) +
Math.pow(e.pageY - this.s.mouse.startY, 2), 0.5 ) < 5 )
{
return;
}
this._fnCreateDragNode();
}
/* Position the element - we respect where in the element the click occured */
this.dom.drag.css( {
left: e.pageX - this.s.mouse.offsetX,
top: e.pageY - this.s.mouse.offsetY
} );
/* Based on the current mouse position, calculate where the insert should go */
var bSet = false;
var lastToIndex = this.s.mouse.toIndex;
for ( var i=1, iLen=this.s.aoTargets.length ; i<iLen ; i++ )
{
if ( e.pageX < this.s.aoTargets[i-1].x + ((this.s.aoTargets[i].x-this.s.aoTargets[i-1].x)/2) )
{
this.dom.pointer.css( 'left', this.s.aoTargets[i-1].x );
this.s.mouse.toIndex = this.s.aoTargets[i-1].to;
bSet = true;
break;
}
}
// The insert element wasn't positioned in the array (less than
// operator), so we put it at the end
if ( !bSet )
{
this.dom.pointer.css( 'left', this.s.aoTargets[this.s.aoTargets.length-1].x );
this.s.mouse.toIndex = this.s.aoTargets[this.s.aoTargets.length-1].to;
}
// Perform reordering if realtime updating is on and the column has moved
if ( this.s.init.bRealtime && lastToIndex !== this.s.mouse.toIndex ) {
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
this.s.mouse.fromIndex = this.s.mouse.toIndex;
this._fnRegions();
}
}
|
javascript
|
function ( e )
{
var that = this;
if ( this.dom.drag === null )
{
/* Only create the drag element if the mouse has moved a specific distance from the start
* point - this allows the user to make small mouse movements when sorting and not have a
* possibly confusing drag element showing up
*/
if ( Math.pow(
Math.pow(e.pageX - this.s.mouse.startX, 2) +
Math.pow(e.pageY - this.s.mouse.startY, 2), 0.5 ) < 5 )
{
return;
}
this._fnCreateDragNode();
}
/* Position the element - we respect where in the element the click occured */
this.dom.drag.css( {
left: e.pageX - this.s.mouse.offsetX,
top: e.pageY - this.s.mouse.offsetY
} );
/* Based on the current mouse position, calculate where the insert should go */
var bSet = false;
var lastToIndex = this.s.mouse.toIndex;
for ( var i=1, iLen=this.s.aoTargets.length ; i<iLen ; i++ )
{
if ( e.pageX < this.s.aoTargets[i-1].x + ((this.s.aoTargets[i].x-this.s.aoTargets[i-1].x)/2) )
{
this.dom.pointer.css( 'left', this.s.aoTargets[i-1].x );
this.s.mouse.toIndex = this.s.aoTargets[i-1].to;
bSet = true;
break;
}
}
// The insert element wasn't positioned in the array (less than
// operator), so we put it at the end
if ( !bSet )
{
this.dom.pointer.css( 'left', this.s.aoTargets[this.s.aoTargets.length-1].x );
this.s.mouse.toIndex = this.s.aoTargets[this.s.aoTargets.length-1].to;
}
// Perform reordering if realtime updating is on and the column has moved
if ( this.s.init.bRealtime && lastToIndex !== this.s.mouse.toIndex ) {
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
this.s.mouse.fromIndex = this.s.mouse.toIndex;
this._fnRegions();
}
}
|
[
"function",
"(",
"e",
")",
"{",
"var",
"that",
"=",
"this",
";",
"if",
"(",
"this",
".",
"dom",
".",
"drag",
"===",
"null",
")",
"{",
"/* Only create the drag element if the mouse has moved a specific distance from the start\n\t\t\t * point - this allows the user to make small mouse movements when sorting and not have a\n\t\t\t * possibly confusing drag element showing up\n\t\t\t */",
"if",
"(",
"Math",
".",
"pow",
"(",
"Math",
".",
"pow",
"(",
"e",
".",
"pageX",
"-",
"this",
".",
"s",
".",
"mouse",
".",
"startX",
",",
"2",
")",
"+",
"Math",
".",
"pow",
"(",
"e",
".",
"pageY",
"-",
"this",
".",
"s",
".",
"mouse",
".",
"startY",
",",
"2",
")",
",",
"0.5",
")",
"<",
"5",
")",
"{",
"return",
";",
"}",
"this",
".",
"_fnCreateDragNode",
"(",
")",
";",
"}",
"/* Position the element - we respect where in the element the click occured */",
"this",
".",
"dom",
".",
"drag",
".",
"css",
"(",
"{",
"left",
":",
"e",
".",
"pageX",
"-",
"this",
".",
"s",
".",
"mouse",
".",
"offsetX",
",",
"top",
":",
"e",
".",
"pageY",
"-",
"this",
".",
"s",
".",
"mouse",
".",
"offsetY",
"}",
")",
";",
"/* Based on the current mouse position, calculate where the insert should go */",
"var",
"bSet",
"=",
"false",
";",
"var",
"lastToIndex",
"=",
"this",
".",
"s",
".",
"mouse",
".",
"toIndex",
";",
"for",
"(",
"var",
"i",
"=",
"1",
",",
"iLen",
"=",
"this",
".",
"s",
".",
"aoTargets",
".",
"length",
";",
"i",
"<",
"iLen",
";",
"i",
"++",
")",
"{",
"if",
"(",
"e",
".",
"pageX",
"<",
"this",
".",
"s",
".",
"aoTargets",
"[",
"i",
"-",
"1",
"]",
".",
"x",
"+",
"(",
"(",
"this",
".",
"s",
".",
"aoTargets",
"[",
"i",
"]",
".",
"x",
"-",
"this",
".",
"s",
".",
"aoTargets",
"[",
"i",
"-",
"1",
"]",
".",
"x",
")",
"/",
"2",
")",
")",
"{",
"this",
".",
"dom",
".",
"pointer",
".",
"css",
"(",
"'left'",
",",
"this",
".",
"s",
".",
"aoTargets",
"[",
"i",
"-",
"1",
"]",
".",
"x",
")",
";",
"this",
".",
"s",
".",
"mouse",
".",
"toIndex",
"=",
"this",
".",
"s",
".",
"aoTargets",
"[",
"i",
"-",
"1",
"]",
".",
"to",
";",
"bSet",
"=",
"true",
";",
"break",
";",
"}",
"}",
"// The insert element wasn't positioned in the array (less than",
"// operator), so we put it at the end",
"if",
"(",
"!",
"bSet",
")",
"{",
"this",
".",
"dom",
".",
"pointer",
".",
"css",
"(",
"'left'",
",",
"this",
".",
"s",
".",
"aoTargets",
"[",
"this",
".",
"s",
".",
"aoTargets",
".",
"length",
"-",
"1",
"]",
".",
"x",
")",
";",
"this",
".",
"s",
".",
"mouse",
".",
"toIndex",
"=",
"this",
".",
"s",
".",
"aoTargets",
"[",
"this",
".",
"s",
".",
"aoTargets",
".",
"length",
"-",
"1",
"]",
".",
"to",
";",
"}",
"// Perform reordering if realtime updating is on and the column has moved",
"if",
"(",
"this",
".",
"s",
".",
"init",
".",
"bRealtime",
"&&",
"lastToIndex",
"!==",
"this",
".",
"s",
".",
"mouse",
".",
"toIndex",
")",
"{",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnColReorder",
"(",
"this",
".",
"s",
".",
"mouse",
".",
"fromIndex",
",",
"this",
".",
"s",
".",
"mouse",
".",
"toIndex",
")",
";",
"this",
".",
"s",
".",
"mouse",
".",
"fromIndex",
"=",
"this",
".",
"s",
".",
"mouse",
".",
"toIndex",
";",
"this",
".",
"_fnRegions",
"(",
")",
";",
"}",
"}"
] |
Deal with a mouse move event while dragging a node
@method _fnMouseMove
@param event e Mouse event
@returns void
@private
|
[
"Deal",
"with",
"a",
"mouse",
"move",
"event",
"while",
"dragging",
"a",
"node"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L883-L937
|
|
39,399 |
S3bb1/ah-dashboard-plugin
|
public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js
|
function ( e )
{
var that = this;
$(document).off( 'mousemove.ColReorder mouseup.ColReorder' );
if ( this.dom.drag !== null )
{
/* Remove the guide elements */
this.dom.drag.remove();
this.dom.pointer.remove();
this.dom.drag = null;
this.dom.pointer = null;
/* Actually do the reorder */
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
this._fnSetColumnIndexes();
/* When scrolling we need to recalculate the column sizes to allow for the shift */
if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
{
this.s.dt.oInstance.fnAdjustColumnSizing( false );
}
/* Save the state */
this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
if ( this.s.reorderCallback !== null )
{
this.s.reorderCallback.call( this );
}
}
}
|
javascript
|
function ( e )
{
var that = this;
$(document).off( 'mousemove.ColReorder mouseup.ColReorder' );
if ( this.dom.drag !== null )
{
/* Remove the guide elements */
this.dom.drag.remove();
this.dom.pointer.remove();
this.dom.drag = null;
this.dom.pointer = null;
/* Actually do the reorder */
this.s.dt.oInstance.fnColReorder( this.s.mouse.fromIndex, this.s.mouse.toIndex );
this._fnSetColumnIndexes();
/* When scrolling we need to recalculate the column sizes to allow for the shift */
if ( this.s.dt.oScroll.sX !== "" || this.s.dt.oScroll.sY !== "" )
{
this.s.dt.oInstance.fnAdjustColumnSizing( false );
}
/* Save the state */
this.s.dt.oInstance.oApi._fnSaveState( this.s.dt );
if ( this.s.reorderCallback !== null )
{
this.s.reorderCallback.call( this );
}
}
}
|
[
"function",
"(",
"e",
")",
"{",
"var",
"that",
"=",
"this",
";",
"$",
"(",
"document",
")",
".",
"off",
"(",
"'mousemove.ColReorder mouseup.ColReorder'",
")",
";",
"if",
"(",
"this",
".",
"dom",
".",
"drag",
"!==",
"null",
")",
"{",
"/* Remove the guide elements */",
"this",
".",
"dom",
".",
"drag",
".",
"remove",
"(",
")",
";",
"this",
".",
"dom",
".",
"pointer",
".",
"remove",
"(",
")",
";",
"this",
".",
"dom",
".",
"drag",
"=",
"null",
";",
"this",
".",
"dom",
".",
"pointer",
"=",
"null",
";",
"/* Actually do the reorder */",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnColReorder",
"(",
"this",
".",
"s",
".",
"mouse",
".",
"fromIndex",
",",
"this",
".",
"s",
".",
"mouse",
".",
"toIndex",
")",
";",
"this",
".",
"_fnSetColumnIndexes",
"(",
")",
";",
"/* When scrolling we need to recalculate the column sizes to allow for the shift */",
"if",
"(",
"this",
".",
"s",
".",
"dt",
".",
"oScroll",
".",
"sX",
"!==",
"\"\"",
"||",
"this",
".",
"s",
".",
"dt",
".",
"oScroll",
".",
"sY",
"!==",
"\"\"",
")",
"{",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"fnAdjustColumnSizing",
"(",
"false",
")",
";",
"}",
"/* Save the state */",
"this",
".",
"s",
".",
"dt",
".",
"oInstance",
".",
"oApi",
".",
"_fnSaveState",
"(",
"this",
".",
"s",
".",
"dt",
")",
";",
"if",
"(",
"this",
".",
"s",
".",
"reorderCallback",
"!==",
"null",
")",
"{",
"this",
".",
"s",
".",
"reorderCallback",
".",
"call",
"(",
"this",
")",
";",
"}",
"}",
"}"
] |
Finish off the mouse drag and insert the column where needed
@method _fnMouseUp
@param event e Mouse event
@returns void
@private
|
[
"Finish",
"off",
"the",
"mouse",
"drag",
"and",
"insert",
"the",
"column",
"where",
"needed"
] |
c283370ec0f99a25db5bb7029a98b4febf8c5251
|
https://github.com/S3bb1/ah-dashboard-plugin/blob/c283370ec0f99a25db5bb7029a98b4febf8c5251/public/dashboard/bower_components/admin-lte/plugins/datatables/extensions/ColReorder/js/dataTables.colReorder.js#L947-L979
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.