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
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
54,300 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
element.find('a, button').mousemove(function(e) {
if (buttonPickerEnabled) {
if (e.target !== buttonToPickElement) {
buttonToPickCounter = 0;
buttonToPickElement = e.target;
}
buttonToPickCounter += 1;
if (buttonToPickCounter > 50) {
element.find('a, button').css('border', '');
$(e.target).css('border', 'solid 2px green');
var createSelector = function(element) {
if (element.attr('id')) {
return '#' + element.attr('id');
} else {
var classes = element.attr('class').split(/\s/);
return classes.map(function(x) {
return '.' + x;
}).join('');
}
};
if (buttonToPick === 'undo') {
editor.find('.kelmu-editor-undo-button').val(createSelector($(e.target)));
} else if (buttonToPick === 'redo') {
editor.find('.kelmu-editor-redo-button').val(createSelector($(e.target)));
} else if (buttonToPick === 'step') {
editor.find('.kelmu-editor-step-button').val(createSelector($(e.target)));
} else if (buttonToPick === 'begin') {
editor.find('.kelmu-editor-begin-button').val(createSelector($(e.target)));
}
buttonPickerEnabled = false;
buttonToPickCounter = 0;
setTimeout(function() {
element.find('a, button').css('border', '');
}, 5000);
}
}
});
buttonPickerCreated = true;
} | javascript | function() {
element.find('a, button').mousemove(function(e) {
if (buttonPickerEnabled) {
if (e.target !== buttonToPickElement) {
buttonToPickCounter = 0;
buttonToPickElement = e.target;
}
buttonToPickCounter += 1;
if (buttonToPickCounter > 50) {
element.find('a, button').css('border', '');
$(e.target).css('border', 'solid 2px green');
var createSelector = function(element) {
if (element.attr('id')) {
return '#' + element.attr('id');
} else {
var classes = element.attr('class').split(/\s/);
return classes.map(function(x) {
return '.' + x;
}).join('');
}
};
if (buttonToPick === 'undo') {
editor.find('.kelmu-editor-undo-button').val(createSelector($(e.target)));
} else if (buttonToPick === 'redo') {
editor.find('.kelmu-editor-redo-button').val(createSelector($(e.target)));
} else if (buttonToPick === 'step') {
editor.find('.kelmu-editor-step-button').val(createSelector($(e.target)));
} else if (buttonToPick === 'begin') {
editor.find('.kelmu-editor-begin-button').val(createSelector($(e.target)));
}
buttonPickerEnabled = false;
buttonToPickCounter = 0;
setTimeout(function() {
element.find('a, button').css('border', '');
}, 5000);
}
}
});
buttonPickerCreated = true;
} | [
"function",
"(",
")",
"{",
"element",
".",
"find",
"(",
"'a, button'",
")",
".",
"mousemove",
"(",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"buttonPickerEnabled",
")",
"{",
"if",
"(",
"e",
".",
"target",
"!==",
"buttonToPickElement",
")",
"{",
"buttonToPickCounter",
"=",
"0",
";",
"buttonToPickElement",
"=",
"e",
".",
"target",
";",
"}",
"buttonToPickCounter",
"+=",
"1",
";",
"if",
"(",
"buttonToPickCounter",
">",
"50",
")",
"{",
"element",
".",
"find",
"(",
"'a, button'",
")",
".",
"css",
"(",
"'border'",
",",
"''",
")",
";",
"$",
"(",
"e",
".",
"target",
")",
".",
"css",
"(",
"'border'",
",",
"'solid 2px green'",
")",
";",
"var",
"createSelector",
"=",
"function",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"attr",
"(",
"'id'",
")",
")",
"{",
"return",
"'#'",
"+",
"element",
".",
"attr",
"(",
"'id'",
")",
";",
"}",
"else",
"{",
"var",
"classes",
"=",
"element",
".",
"attr",
"(",
"'class'",
")",
".",
"split",
"(",
"/",
"\\s",
"/",
")",
";",
"return",
"classes",
".",
"map",
"(",
"function",
"(",
"x",
")",
"{",
"return",
"'.'",
"+",
"x",
";",
"}",
")",
".",
"join",
"(",
"''",
")",
";",
"}",
"}",
";",
"if",
"(",
"buttonToPick",
"===",
"'undo'",
")",
"{",
"editor",
".",
"find",
"(",
"'.kelmu-editor-undo-button'",
")",
".",
"val",
"(",
"createSelector",
"(",
"$",
"(",
"e",
".",
"target",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"buttonToPick",
"===",
"'redo'",
")",
"{",
"editor",
".",
"find",
"(",
"'.kelmu-editor-redo-button'",
")",
".",
"val",
"(",
"createSelector",
"(",
"$",
"(",
"e",
".",
"target",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"buttonToPick",
"===",
"'step'",
")",
"{",
"editor",
".",
"find",
"(",
"'.kelmu-editor-step-button'",
")",
".",
"val",
"(",
"createSelector",
"(",
"$",
"(",
"e",
".",
"target",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"buttonToPick",
"===",
"'begin'",
")",
"{",
"editor",
".",
"find",
"(",
"'.kelmu-editor-begin-button'",
")",
".",
"val",
"(",
"createSelector",
"(",
"$",
"(",
"e",
".",
"target",
")",
")",
")",
";",
"}",
"buttonPickerEnabled",
"=",
"false",
";",
"buttonToPickCounter",
"=",
"0",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"element",
".",
"find",
"(",
"'a, button'",
")",
".",
"css",
"(",
"'border'",
",",
"''",
")",
";",
"}",
",",
"5000",
")",
";",
"}",
"}",
"}",
")",
";",
"buttonPickerCreated",
"=",
"true",
";",
"}"
] | Traces mouse moves above buttons in order to bind animation buttons with Kelmu. | [
"Traces",
"mouse",
"moves",
"above",
"buttons",
"in",
"order",
"to",
"bind",
"animation",
"buttons",
"with",
"Kelmu",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L101-L146 |
|
54,301 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
if (elemData.rotate) {
elem.css('transform', 'none');
elem.css('moz-transform', 'none');
elem.css('webkit-transform', 'none');
elem.css('ms-transform', 'none');
}
} | javascript | function() {
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
if (elemData.rotate) {
elem.css('transform', 'none');
elem.css('moz-transform', 'none');
elem.css('webkit-transform', 'none');
elem.css('ms-transform', 'none');
}
} | [
"function",
"(",
")",
"{",
"var",
"elem",
"=",
"$",
"(",
"this",
")",
";",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"data",
".",
"selectedElementNumber",
"=",
"parseInt",
"(",
"elem",
".",
"attr",
"(",
"'data-annotation'",
")",
",",
"10",
")",
";",
"var",
"elemData",
"=",
"data",
".",
"definitions",
"[",
"'step'",
"+",
"data",
".",
"stepNumber",
"]",
"[",
"data",
".",
"subStepNumber",
"]",
"[",
"data",
".",
"selectedElementNumber",
"]",
";",
"if",
"(",
"elemData",
".",
"rotate",
")",
"{",
"elem",
".",
"css",
"(",
"'transform'",
",",
"'none'",
")",
";",
"elem",
".",
"css",
"(",
"'moz-transform'",
",",
"'none'",
")",
";",
"elem",
".",
"css",
"(",
"'webkit-transform'",
",",
"'none'",
")",
";",
"elem",
".",
"css",
"(",
"'ms-transform'",
",",
"'none'",
")",
";",
"}",
"}"
] | Clears the CSS rotation of an element. The function should be called
so that `this` referes to the element. | [
"Clears",
"the",
"CSS",
"rotation",
"of",
"an",
"element",
".",
"The",
"function",
"should",
"be",
"called",
"so",
"that",
"this",
"referes",
"to",
"the",
"element",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L164-L176 |
|
54,302 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
elemData.top = parseFloat(elem.css('top'));
elemData.left = parseFloat(elem.css('left'));
if (elem.hasClass('kelmu-annotation')) {
elemData.height = elem.height();
elemData.width = elem.width();
}
} | javascript | function() {
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
elemData.top = parseFloat(elem.css('top'));
elemData.left = parseFloat(elem.css('left'));
if (elem.hasClass('kelmu-annotation')) {
elemData.height = elem.height();
elemData.width = elem.width();
}
} | [
"function",
"(",
")",
"{",
"var",
"elem",
"=",
"$",
"(",
"this",
")",
";",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"data",
".",
"selectedElementNumber",
"=",
"parseInt",
"(",
"elem",
".",
"attr",
"(",
"'data-annotation'",
")",
",",
"10",
")",
";",
"var",
"elemData",
"=",
"data",
".",
"definitions",
"[",
"'step'",
"+",
"data",
".",
"stepNumber",
"]",
"[",
"data",
".",
"subStepNumber",
"]",
"[",
"data",
".",
"selectedElementNumber",
"]",
";",
"elemData",
".",
"top",
"=",
"parseFloat",
"(",
"elem",
".",
"css",
"(",
"'top'",
")",
")",
";",
"elemData",
".",
"left",
"=",
"parseFloat",
"(",
"elem",
".",
"css",
"(",
"'left'",
")",
")",
";",
"if",
"(",
"elem",
".",
"hasClass",
"(",
"'kelmu-annotation'",
")",
")",
"{",
"elemData",
".",
"height",
"=",
"elem",
".",
"height",
"(",
")",
";",
"elemData",
".",
"width",
"=",
"elem",
".",
"width",
"(",
")",
";",
"}",
"}"
] | Updates the position definition for the selected element.
The function should be called so that `this` referes to the element. | [
"Updates",
"the",
"position",
"definition",
"for",
"the",
"selected",
"element",
".",
"The",
"function",
"should",
"be",
"called",
"so",
"that",
"this",
"referes",
"to",
"the",
"element",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L205-L217 |
|
54,303 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
container.find('.kelmu-annotation, .kelmu-button').mousedown(resetRotation);
container.find('.kelmu-annotation, .kelmu-button').mouseup(restoreRotation);
container.find('.kelmu-annotation, .kelmu-button').draggable({
start: function() {
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
resetRotation.call(this);
},
stop: function() {
restoreRotation.call(this);
updatePosition.call(this);
notifyModifications();
updateView(false, true);
}
});
container.find('.kelmu-annotation-content, .kelmu-button').css('cursor', 'move');
} | javascript | function() {
container.find('.kelmu-annotation, .kelmu-button').mousedown(resetRotation);
container.find('.kelmu-annotation, .kelmu-button').mouseup(restoreRotation);
container.find('.kelmu-annotation, .kelmu-button').draggable({
start: function() {
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
resetRotation.call(this);
},
stop: function() {
restoreRotation.call(this);
updatePosition.call(this);
notifyModifications();
updateView(false, true);
}
});
container.find('.kelmu-annotation-content, .kelmu-button').css('cursor', 'move');
} | [
"function",
"(",
")",
"{",
"container",
".",
"find",
"(",
"'.kelmu-annotation, .kelmu-button'",
")",
".",
"mousedown",
"(",
"resetRotation",
")",
";",
"container",
".",
"find",
"(",
"'.kelmu-annotation, .kelmu-button'",
")",
".",
"mouseup",
"(",
"restoreRotation",
")",
";",
"container",
".",
"find",
"(",
"'.kelmu-annotation, .kelmu-button'",
")",
".",
"draggable",
"(",
"{",
"start",
":",
"function",
"(",
")",
"{",
"var",
"elem",
"=",
"$",
"(",
"this",
")",
";",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"data",
".",
"selectedElementNumber",
"=",
"parseInt",
"(",
"elem",
".",
"attr",
"(",
"'data-annotation'",
")",
",",
"10",
")",
";",
"resetRotation",
".",
"call",
"(",
"this",
")",
";",
"}",
",",
"stop",
":",
"function",
"(",
")",
"{",
"restoreRotation",
".",
"call",
"(",
"this",
")",
";",
"updatePosition",
".",
"call",
"(",
"this",
")",
";",
"notifyModifications",
"(",
")",
";",
"updateView",
"(",
"false",
",",
"true",
")",
";",
"}",
"}",
")",
";",
"container",
".",
"find",
"(",
"'.kelmu-annotation-content, .kelmu-button'",
")",
".",
"css",
"(",
"'cursor'",
",",
"'move'",
")",
";",
"}"
] | Makes the annotations to be moveable in the editor. | [
"Makes",
"the",
"annotations",
"to",
"be",
"moveable",
"in",
"the",
"editor",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L223-L244 |
|
54,304 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
container.find('.kelmu-annotation').resizable({
start: function() {
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
if (elem.css('background-color') === 'transparent' || elem.css('background-color') === 'rgba(0, 0, 0, 0)') {
elem.css('background-color', 'rgba(0, 0, 0, 0.1)');
}
},
stop: function() {
restoreRotation.call(this);
updatePosition.call(this);
notifyModifications();
updateView(false, true);
}
});
} | javascript | function() {
container.find('.kelmu-annotation').resizable({
start: function() {
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
if (elem.css('background-color') === 'transparent' || elem.css('background-color') === 'rgba(0, 0, 0, 0)') {
elem.css('background-color', 'rgba(0, 0, 0, 0.1)');
}
},
stop: function() {
restoreRotation.call(this);
updatePosition.call(this);
notifyModifications();
updateView(false, true);
}
});
} | [
"function",
"(",
")",
"{",
"container",
".",
"find",
"(",
"'.kelmu-annotation'",
")",
".",
"resizable",
"(",
"{",
"start",
":",
"function",
"(",
")",
"{",
"var",
"elem",
"=",
"$",
"(",
"this",
")",
";",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"data",
".",
"selectedElementNumber",
"=",
"parseInt",
"(",
"elem",
".",
"attr",
"(",
"'data-annotation'",
")",
",",
"10",
")",
";",
"if",
"(",
"elem",
".",
"css",
"(",
"'background-color'",
")",
"===",
"'transparent'",
"||",
"elem",
".",
"css",
"(",
"'background-color'",
")",
"===",
"'rgba(0, 0, 0, 0)'",
")",
"{",
"elem",
".",
"css",
"(",
"'background-color'",
",",
"'rgba(0, 0, 0, 0.1)'",
")",
";",
"}",
"}",
",",
"stop",
":",
"function",
"(",
")",
"{",
"restoreRotation",
".",
"call",
"(",
"this",
")",
";",
"updatePosition",
".",
"call",
"(",
"this",
")",
";",
"notifyModifications",
"(",
")",
";",
"updateView",
"(",
"false",
",",
"true",
")",
";",
"}",
"}",
")",
";",
"}"
] | Makes the annotations to be resizable in the editor. | [
"Makes",
"the",
"annotations",
"to",
"be",
"resizable",
"in",
"the",
"editor",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L250-L267 |
|
54,305 | acos-server/acos-kelmu | static/kelmu.editor.js | function(event) {
if (event.ctrlKey) {
return;
}
event.preventDefault();
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
updateView(false, true);
} | javascript | function(event) {
if (event.ctrlKey) {
return;
}
event.preventDefault();
var elem = $(this);
var data = window.kelmu.data[id];
data.selectedElementNumber = parseInt(elem.attr('data-annotation'), 10);
updateView(false, true);
} | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"ctrlKey",
")",
"{",
"return",
";",
"}",
"event",
".",
"preventDefault",
"(",
")",
";",
"var",
"elem",
"=",
"$",
"(",
"this",
")",
";",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"data",
".",
"selectedElementNumber",
"=",
"parseInt",
"(",
"elem",
".",
"attr",
"(",
"'data-annotation'",
")",
",",
"10",
")",
";",
"updateView",
"(",
"false",
",",
"true",
")",
";",
"}"
] | Selects and changes the current element after clicking it.
The function should be called so that `this` referes to the element. | [
"Selects",
"and",
"changes",
"the",
"current",
"element",
"after",
"clicking",
"it",
".",
"The",
"function",
"should",
"be",
"called",
"so",
"that",
"this",
"referes",
"to",
"the",
"element",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L274-L283 |
|
54,306 | acos-server/acos-kelmu | static/kelmu.editor.js | function(text, container, name, value, type, noBr) {
var idNumber = idCounter;
if (!noBr) {
$('<br>').appendTo(container);
}
$('<label></label>').attr('for', animationId + '-' + name + '-' + idNumber).text(text).appendTo(container);
if (type === 'text') {
$('<input type="text"></input>').addClass(name).attr('id', animationId + '-' + name + '-' + idNumber).val(value).appendTo(container);
} else if (type === 'checkbox') {
$('<input></input>').addClass(name).attr('type', 'checkbox').attr('id', animationId + '-' + name + '-' + idNumber).prop('checked', value).appendTo(container);
} else if (type === 'textarea') {
$('<textarea></textarea>').addClass(name).attr('id', animationId + '-' + name + '-' + idNumber).val(value).appendTo(container);
}
idCounter += 1;
} | javascript | function(text, container, name, value, type, noBr) {
var idNumber = idCounter;
if (!noBr) {
$('<br>').appendTo(container);
}
$('<label></label>').attr('for', animationId + '-' + name + '-' + idNumber).text(text).appendTo(container);
if (type === 'text') {
$('<input type="text"></input>').addClass(name).attr('id', animationId + '-' + name + '-' + idNumber).val(value).appendTo(container);
} else if (type === 'checkbox') {
$('<input></input>').addClass(name).attr('type', 'checkbox').attr('id', animationId + '-' + name + '-' + idNumber).prop('checked', value).appendTo(container);
} else if (type === 'textarea') {
$('<textarea></textarea>').addClass(name).attr('id', animationId + '-' + name + '-' + idNumber).val(value).appendTo(container);
}
idCounter += 1;
} | [
"function",
"(",
"text",
",",
"container",
",",
"name",
",",
"value",
",",
"type",
",",
"noBr",
")",
"{",
"var",
"idNumber",
"=",
"idCounter",
";",
"if",
"(",
"!",
"noBr",
")",
"{",
"$",
"(",
"'<br>'",
")",
".",
"appendTo",
"(",
"container",
")",
";",
"}",
"$",
"(",
"'<label></label>'",
")",
".",
"attr",
"(",
"'for'",
",",
"animationId",
"+",
"'-'",
"+",
"name",
"+",
"'-'",
"+",
"idNumber",
")",
".",
"text",
"(",
"text",
")",
".",
"appendTo",
"(",
"container",
")",
";",
"if",
"(",
"type",
"===",
"'text'",
")",
"{",
"$",
"(",
"'<input type=\"text\"></input>'",
")",
".",
"addClass",
"(",
"name",
")",
".",
"attr",
"(",
"'id'",
",",
"animationId",
"+",
"'-'",
"+",
"name",
"+",
"'-'",
"+",
"idNumber",
")",
".",
"val",
"(",
"value",
")",
".",
"appendTo",
"(",
"container",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"'checkbox'",
")",
"{",
"$",
"(",
"'<input></input>'",
")",
".",
"addClass",
"(",
"name",
")",
".",
"attr",
"(",
"'type'",
",",
"'checkbox'",
")",
".",
"attr",
"(",
"'id'",
",",
"animationId",
"+",
"'-'",
"+",
"name",
"+",
"'-'",
"+",
"idNumber",
")",
".",
"prop",
"(",
"'checked'",
",",
"value",
")",
".",
"appendTo",
"(",
"container",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"'textarea'",
")",
"{",
"$",
"(",
"'<textarea></textarea>'",
")",
".",
"addClass",
"(",
"name",
")",
".",
"attr",
"(",
"'id'",
",",
"animationId",
"+",
"'-'",
"+",
"name",
"+",
"'-'",
"+",
"idNumber",
")",
".",
"val",
"(",
"value",
")",
".",
"appendTo",
"(",
"container",
")",
";",
"}",
"idCounter",
"+=",
"1",
";",
"}"
] | A helper function for adding input elements to the editor pane. | [
"A",
"helper",
"function",
"for",
"adding",
"input",
"elements",
"to",
"the",
"editor",
"pane",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L492-L506 |
|
54,307 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
// Remove the element
return $('<button></button>').text('Remove').addClass('btn').click(function(e) {
e.preventDefault();
var data = window.kelmu.data[id];
data.definitions['step' + data.stepNumber][data.subStepNumber].splice(window.kelmu.data[id].selectedElementNumber, 1);
window.kelmu.data[id].selectedElementNumber = -1;
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
});
} | javascript | function() {
// Remove the element
return $('<button></button>').text('Remove').addClass('btn').click(function(e) {
e.preventDefault();
var data = window.kelmu.data[id];
data.definitions['step' + data.stepNumber][data.subStepNumber].splice(window.kelmu.data[id].selectedElementNumber, 1);
window.kelmu.data[id].selectedElementNumber = -1;
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
});
} | [
"function",
"(",
")",
"{",
"// Remove the element",
"return",
"$",
"(",
"'<button></button>'",
")",
".",
"text",
"(",
"'Remove'",
")",
".",
"addClass",
"(",
"'btn'",
")",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"data",
".",
"definitions",
"[",
"'step'",
"+",
"data",
".",
"stepNumber",
"]",
"[",
"data",
".",
"subStepNumber",
"]",
".",
"splice",
"(",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
".",
"selectedElementNumber",
",",
"1",
")",
";",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
".",
"selectedElementNumber",
"=",
"-",
"1",
";",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
".",
"actions",
".",
"update",
"(",
")",
";",
"updateView",
"(",
"true",
",",
"true",
")",
";",
"notifyModifications",
"(",
")",
";",
"}",
")",
";",
"}"
] | A helper function for creating remove buttons | [
"A",
"helper",
"function",
"for",
"creating",
"remove",
"buttons"
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L807-L818 |
|
54,308 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
var data = window.kelmu.data[id];
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
editor.find('.kelmu-editor-pane').remove();
var actionEditor = $('<div></div>').addClass('kelmu-action-editor').addClass('kelmu-editor-pane');
actionEditor.appendTo(editor);
actionEditor.append($('<h4>Action</h4>').css('margin', '15px 0px'));
idCounter += 1;
// Set the current values
addComponent('Action:', actionEditor, 'kelmu-action-type', elemData.action, 'text', true);
addComponent('Parameter:', actionEditor, 'kelmu-action-parameter', elemData.parameter, 'text');
addComponent('State:', actionEditor, 'kelmu-action-when', elemData.when, 'text');
// Move cursor to end
actionEditor.find('.kelmu-action-type').focus();
var val = actionEditor.find('.kelmu-action-type').val();
actionEditor.find('.kelmu-action-type').val('').val(val);
var buttonContainer = $('<div></div>').appendTo(actionEditor);
// Save the modified properties
var saveButton = function() {
elemData.action = actionEditor.find('.kelmu-action-type').val() || window.kelmu.defaults.action.action;
elemData.parameter = actionEditor.find('.kelmu-action-parameter').val() || window.kelmu.defaults.action.parameter;
elemData.when = actionEditor.find('.kelmu-action-when').val() || window.kelmu.defaults.action.when;
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
};
actionEditor.find('input').keyup(saveButton);
createRemoveButton().appendTo(buttonContainer);
// Set current properties as default settings
$('<button></button>').text('Make default').addClass('btn').appendTo(buttonContainer).click(function(e) {
e.preventDefault();
window.kelmu.defaults.action.action = actionEditor.find('.kelmu-action-type').val() || actionDefaults.action;
window.kelmu.defaults.action.parameter = actionEditor.find('.kelmu-action-parameter').val() || actionDefaults.parameter;
window.kelmu.defaults.action.when = actionEditor.find('.kelmu-action-when').val() || actionDefaults.when;
});
} | javascript | function() {
var data = window.kelmu.data[id];
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
editor.find('.kelmu-editor-pane').remove();
var actionEditor = $('<div></div>').addClass('kelmu-action-editor').addClass('kelmu-editor-pane');
actionEditor.appendTo(editor);
actionEditor.append($('<h4>Action</h4>').css('margin', '15px 0px'));
idCounter += 1;
// Set the current values
addComponent('Action:', actionEditor, 'kelmu-action-type', elemData.action, 'text', true);
addComponent('Parameter:', actionEditor, 'kelmu-action-parameter', elemData.parameter, 'text');
addComponent('State:', actionEditor, 'kelmu-action-when', elemData.when, 'text');
// Move cursor to end
actionEditor.find('.kelmu-action-type').focus();
var val = actionEditor.find('.kelmu-action-type').val();
actionEditor.find('.kelmu-action-type').val('').val(val);
var buttonContainer = $('<div></div>').appendTo(actionEditor);
// Save the modified properties
var saveButton = function() {
elemData.action = actionEditor.find('.kelmu-action-type').val() || window.kelmu.defaults.action.action;
elemData.parameter = actionEditor.find('.kelmu-action-parameter').val() || window.kelmu.defaults.action.parameter;
elemData.when = actionEditor.find('.kelmu-action-when').val() || window.kelmu.defaults.action.when;
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
};
actionEditor.find('input').keyup(saveButton);
createRemoveButton().appendTo(buttonContainer);
// Set current properties as default settings
$('<button></button>').text('Make default').addClass('btn').appendTo(buttonContainer).click(function(e) {
e.preventDefault();
window.kelmu.defaults.action.action = actionEditor.find('.kelmu-action-type').val() || actionDefaults.action;
window.kelmu.defaults.action.parameter = actionEditor.find('.kelmu-action-parameter').val() || actionDefaults.parameter;
window.kelmu.defaults.action.when = actionEditor.find('.kelmu-action-when').val() || actionDefaults.when;
});
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"var",
"elemData",
"=",
"data",
".",
"definitions",
"[",
"'step'",
"+",
"data",
".",
"stepNumber",
"]",
"[",
"data",
".",
"subStepNumber",
"]",
"[",
"data",
".",
"selectedElementNumber",
"]",
";",
"editor",
".",
"find",
"(",
"'.kelmu-editor-pane'",
")",
".",
"remove",
"(",
")",
";",
"var",
"actionEditor",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"addClass",
"(",
"'kelmu-action-editor'",
")",
".",
"addClass",
"(",
"'kelmu-editor-pane'",
")",
";",
"actionEditor",
".",
"appendTo",
"(",
"editor",
")",
";",
"actionEditor",
".",
"append",
"(",
"$",
"(",
"'<h4>Action</h4>'",
")",
".",
"css",
"(",
"'margin'",
",",
"'15px 0px'",
")",
")",
";",
"idCounter",
"+=",
"1",
";",
"// Set the current values",
"addComponent",
"(",
"'Action:'",
",",
"actionEditor",
",",
"'kelmu-action-type'",
",",
"elemData",
".",
"action",
",",
"'text'",
",",
"true",
")",
";",
"addComponent",
"(",
"'Parameter:'",
",",
"actionEditor",
",",
"'kelmu-action-parameter'",
",",
"elemData",
".",
"parameter",
",",
"'text'",
")",
";",
"addComponent",
"(",
"'State:'",
",",
"actionEditor",
",",
"'kelmu-action-when'",
",",
"elemData",
".",
"when",
",",
"'text'",
")",
";",
"// Move cursor to end",
"actionEditor",
".",
"find",
"(",
"'.kelmu-action-type'",
")",
".",
"focus",
"(",
")",
";",
"var",
"val",
"=",
"actionEditor",
".",
"find",
"(",
"'.kelmu-action-type'",
")",
".",
"val",
"(",
")",
";",
"actionEditor",
".",
"find",
"(",
"'.kelmu-action-type'",
")",
".",
"val",
"(",
"''",
")",
".",
"val",
"(",
"val",
")",
";",
"var",
"buttonContainer",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"appendTo",
"(",
"actionEditor",
")",
";",
"// Save the modified properties",
"var",
"saveButton",
"=",
"function",
"(",
")",
"{",
"elemData",
".",
"action",
"=",
"actionEditor",
".",
"find",
"(",
"'.kelmu-action-type'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"action",
".",
"action",
";",
"elemData",
".",
"parameter",
"=",
"actionEditor",
".",
"find",
"(",
"'.kelmu-action-parameter'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"action",
".",
"parameter",
";",
"elemData",
".",
"when",
"=",
"actionEditor",
".",
"find",
"(",
"'.kelmu-action-when'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"action",
".",
"when",
";",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
".",
"actions",
".",
"update",
"(",
")",
";",
"updateView",
"(",
"true",
",",
"true",
")",
";",
"notifyModifications",
"(",
")",
";",
"}",
";",
"actionEditor",
".",
"find",
"(",
"'input'",
")",
".",
"keyup",
"(",
"saveButton",
")",
";",
"createRemoveButton",
"(",
")",
".",
"appendTo",
"(",
"buttonContainer",
")",
";",
"// Set current properties as default settings",
"$",
"(",
"'<button></button>'",
")",
".",
"text",
"(",
"'Make default'",
")",
".",
"addClass",
"(",
"'btn'",
")",
".",
"appendTo",
"(",
"buttonContainer",
")",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"action",
".",
"action",
"=",
"actionEditor",
".",
"find",
"(",
"'.kelmu-action-type'",
")",
".",
"val",
"(",
")",
"||",
"actionDefaults",
".",
"action",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"action",
".",
"parameter",
"=",
"actionEditor",
".",
"find",
"(",
"'.kelmu-action-parameter'",
")",
".",
"val",
"(",
")",
"||",
"actionDefaults",
".",
"parameter",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"action",
".",
"when",
"=",
"actionEditor",
".",
"find",
"(",
"'.kelmu-action-when'",
")",
".",
"val",
"(",
")",
"||",
"actionDefaults",
".",
"when",
";",
"}",
")",
";",
"}"
] | Creates the action editor pane for the selected event. | [
"Creates",
"the",
"action",
"editor",
"pane",
"for",
"the",
"selected",
"event",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L954-L1002 |
|
54,309 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
var data = window.kelmu.data[id];
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
editor.find('.kelmu-editor-pane').remove();
var arrowEditor = $('<div></div>').addClass('kelmu-arrow-editorr').addClass('kelmu-editor-pane');
arrowEditor.appendTo(editor);
arrowEditor.append($('<h4>Arrow</h4>').css('margin', '15px 0px'));
idCounter += 1;
// Set the current values
addComponent('Size:', arrowEditor, 'kelmu-arrow-size', elemData.size, 'text', true);
addComponent('Width:', arrowEditor, 'kelmu-arrow-width', elemData.width, 'text');
addComponent('Color:', arrowEditor, 'kelmu-arrow-color', elemData.arrow, 'text');
addComponent('With sound:', arrowEditor, 'kelmu-arrow-sound-option', elemData.soundOption, 'text');
// Save the modified properties
var saveArrow = function() {
elemData.size = arrowEditor.find('.kelmu-arrow-size').val() || window.kelmu.defaults.arrow.size;
elemData.width = arrowEditor.find('.kelmu-arrow-width').val() || window.kelmu.defaults.arrow.width;
elemData.arrow = arrowEditor.find('.kelmu-arrow-color').val() || window.kelmu.defaults.arrow.arrow;
elemData.soundOption = arrowEditor.find('.kelmu-arrow-sound-option').val() || window.kelmu.defaults.arrow.soundOption;
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
};
arrowEditor.find('input').keyup(saveArrow);
var buttonContainer = $('<div></div>').appendTo(arrowEditor);
createRemoveButton().appendTo(buttonContainer);
// Save the modified properties
$('<button></button>').text('Make default').addClass('btn').appendTo(buttonContainer).click(function(e) {
e.preventDefault();
window.kelmu.defaults.arrow.width = arrowEditor.find('.kelmu-arrow-width').val() || arrowDefaults.width;
window.kelmu.defaults.arrow.arrow = arrowEditor.find('.kelmu-arrow-color').val() || arrowDefaults.arrow;
window.kelmu.defaults.arrow.size = arrowEditor.find('.kelmu-arrow-size').val() || arrowDefaults.size;
window.kelmu.defaults.arrow.soundOption = arrowEditor.find('.kelmu-arrow-sound-option').val() || arrowDefaults.soundOption;
});
} | javascript | function() {
var data = window.kelmu.data[id];
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
editor.find('.kelmu-editor-pane').remove();
var arrowEditor = $('<div></div>').addClass('kelmu-arrow-editorr').addClass('kelmu-editor-pane');
arrowEditor.appendTo(editor);
arrowEditor.append($('<h4>Arrow</h4>').css('margin', '15px 0px'));
idCounter += 1;
// Set the current values
addComponent('Size:', arrowEditor, 'kelmu-arrow-size', elemData.size, 'text', true);
addComponent('Width:', arrowEditor, 'kelmu-arrow-width', elemData.width, 'text');
addComponent('Color:', arrowEditor, 'kelmu-arrow-color', elemData.arrow, 'text');
addComponent('With sound:', arrowEditor, 'kelmu-arrow-sound-option', elemData.soundOption, 'text');
// Save the modified properties
var saveArrow = function() {
elemData.size = arrowEditor.find('.kelmu-arrow-size').val() || window.kelmu.defaults.arrow.size;
elemData.width = arrowEditor.find('.kelmu-arrow-width').val() || window.kelmu.defaults.arrow.width;
elemData.arrow = arrowEditor.find('.kelmu-arrow-color').val() || window.kelmu.defaults.arrow.arrow;
elemData.soundOption = arrowEditor.find('.kelmu-arrow-sound-option').val() || window.kelmu.defaults.arrow.soundOption;
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
};
arrowEditor.find('input').keyup(saveArrow);
var buttonContainer = $('<div></div>').appendTo(arrowEditor);
createRemoveButton().appendTo(buttonContainer);
// Save the modified properties
$('<button></button>').text('Make default').addClass('btn').appendTo(buttonContainer).click(function(e) {
e.preventDefault();
window.kelmu.defaults.arrow.width = arrowEditor.find('.kelmu-arrow-width').val() || arrowDefaults.width;
window.kelmu.defaults.arrow.arrow = arrowEditor.find('.kelmu-arrow-color').val() || arrowDefaults.arrow;
window.kelmu.defaults.arrow.size = arrowEditor.find('.kelmu-arrow-size').val() || arrowDefaults.size;
window.kelmu.defaults.arrow.soundOption = arrowEditor.find('.kelmu-arrow-sound-option').val() || arrowDefaults.soundOption;
});
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"var",
"elemData",
"=",
"data",
".",
"definitions",
"[",
"'step'",
"+",
"data",
".",
"stepNumber",
"]",
"[",
"data",
".",
"subStepNumber",
"]",
"[",
"data",
".",
"selectedElementNumber",
"]",
";",
"editor",
".",
"find",
"(",
"'.kelmu-editor-pane'",
")",
".",
"remove",
"(",
")",
";",
"var",
"arrowEditor",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"addClass",
"(",
"'kelmu-arrow-editorr'",
")",
".",
"addClass",
"(",
"'kelmu-editor-pane'",
")",
";",
"arrowEditor",
".",
"appendTo",
"(",
"editor",
")",
";",
"arrowEditor",
".",
"append",
"(",
"$",
"(",
"'<h4>Arrow</h4>'",
")",
".",
"css",
"(",
"'margin'",
",",
"'15px 0px'",
")",
")",
";",
"idCounter",
"+=",
"1",
";",
"// Set the current values",
"addComponent",
"(",
"'Size:'",
",",
"arrowEditor",
",",
"'kelmu-arrow-size'",
",",
"elemData",
".",
"size",
",",
"'text'",
",",
"true",
")",
";",
"addComponent",
"(",
"'Width:'",
",",
"arrowEditor",
",",
"'kelmu-arrow-width'",
",",
"elemData",
".",
"width",
",",
"'text'",
")",
";",
"addComponent",
"(",
"'Color:'",
",",
"arrowEditor",
",",
"'kelmu-arrow-color'",
",",
"elemData",
".",
"arrow",
",",
"'text'",
")",
";",
"addComponent",
"(",
"'With sound:'",
",",
"arrowEditor",
",",
"'kelmu-arrow-sound-option'",
",",
"elemData",
".",
"soundOption",
",",
"'text'",
")",
";",
"// Save the modified properties",
"var",
"saveArrow",
"=",
"function",
"(",
")",
"{",
"elemData",
".",
"size",
"=",
"arrowEditor",
".",
"find",
"(",
"'.kelmu-arrow-size'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"arrow",
".",
"size",
";",
"elemData",
".",
"width",
"=",
"arrowEditor",
".",
"find",
"(",
"'.kelmu-arrow-width'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"arrow",
".",
"width",
";",
"elemData",
".",
"arrow",
"=",
"arrowEditor",
".",
"find",
"(",
"'.kelmu-arrow-color'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"arrow",
".",
"arrow",
";",
"elemData",
".",
"soundOption",
"=",
"arrowEditor",
".",
"find",
"(",
"'.kelmu-arrow-sound-option'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"arrow",
".",
"soundOption",
";",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
".",
"actions",
".",
"update",
"(",
")",
";",
"updateView",
"(",
"true",
",",
"true",
")",
";",
"notifyModifications",
"(",
")",
";",
"}",
";",
"arrowEditor",
".",
"find",
"(",
"'input'",
")",
".",
"keyup",
"(",
"saveArrow",
")",
";",
"var",
"buttonContainer",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"appendTo",
"(",
"arrowEditor",
")",
";",
"createRemoveButton",
"(",
")",
".",
"appendTo",
"(",
"buttonContainer",
")",
";",
"// Save the modified properties",
"$",
"(",
"'<button></button>'",
")",
".",
"text",
"(",
"'Make default'",
")",
".",
"addClass",
"(",
"'btn'",
")",
".",
"appendTo",
"(",
"buttonContainer",
")",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"arrow",
".",
"width",
"=",
"arrowEditor",
".",
"find",
"(",
"'.kelmu-arrow-width'",
")",
".",
"val",
"(",
")",
"||",
"arrowDefaults",
".",
"width",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"arrow",
".",
"arrow",
"=",
"arrowEditor",
".",
"find",
"(",
"'.kelmu-arrow-color'",
")",
".",
"val",
"(",
")",
"||",
"arrowDefaults",
".",
"arrow",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"arrow",
".",
"size",
"=",
"arrowEditor",
".",
"find",
"(",
"'.kelmu-arrow-size'",
")",
".",
"val",
"(",
")",
"||",
"arrowDefaults",
".",
"size",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"arrow",
".",
"soundOption",
"=",
"arrowEditor",
".",
"find",
"(",
"'.kelmu-arrow-sound-option'",
")",
".",
"val",
"(",
")",
"||",
"arrowDefaults",
".",
"soundOption",
";",
"}",
")",
";",
"}"
] | Creates the action editor pane for the selected arrow. | [
"Creates",
"the",
"action",
"editor",
"pane",
"for",
"the",
"selected",
"arrow",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L1008-L1054 |
|
54,310 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
var data = window.kelmu.data[id];
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
editor.find('.kelmu-editor-pane').remove();
var lineEditor = $('<div></div>').addClass('kelmu-line-editor').addClass('kelmu-editor-pane');
lineEditor.appendTo(editor);
lineEditor.append($('<h4>Line</h4>').css('margin', '15px 0px'));
idCounter += 1;
// Set the current values
addComponent('Width:', lineEditor, 'kelmu-line-width', elemData.width, 'text', true);
addComponent('Color:', lineEditor, 'kelmu-line-color', elemData.line, 'text');
addComponent('With sound:', lineEditor, 'kelmu-line-sound-option', elemData.soundOption, 'text');
// Save the modified properties
var saveLine = function() {
elemData.width = lineEditor.find('.kelmu-line-width').val() || window.kelmu.defaults.line.width;
elemData.line = lineEditor.find('.kelmu-line-color').val() || window.kelmu.defaults.line.line;
elemData.soundOption = lineEditor.find('.kelmu-line-sound-option').val() || window.kelmu.defaults.line.soundOption;
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
};
lineEditor.find('input').keyup(saveLine);
var buttonContainer = $('<div></div>').appendTo(lineEditor);
createRemoveButton().appendTo(buttonContainer);
// Save the modified properties
$('<button></button>').text('Make default').addClass('btn').appendTo(buttonContainer).click(function(e) {
e.preventDefault();
window.kelmu.defaults.line.width = lineEditor.find('.kelmu-line-width').val() || lineDefaults.width;
window.kelmu.defaults.line.line = lineEditor.find('.kelmu-line-color').val() || lineDefaults.line;
window.kelmu.defaults.line.soundOption = lineEditor.find('.kelmu-line-sound-option').val() || lineDefaults.soundOption;
});
} | javascript | function() {
var data = window.kelmu.data[id];
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
editor.find('.kelmu-editor-pane').remove();
var lineEditor = $('<div></div>').addClass('kelmu-line-editor').addClass('kelmu-editor-pane');
lineEditor.appendTo(editor);
lineEditor.append($('<h4>Line</h4>').css('margin', '15px 0px'));
idCounter += 1;
// Set the current values
addComponent('Width:', lineEditor, 'kelmu-line-width', elemData.width, 'text', true);
addComponent('Color:', lineEditor, 'kelmu-line-color', elemData.line, 'text');
addComponent('With sound:', lineEditor, 'kelmu-line-sound-option', elemData.soundOption, 'text');
// Save the modified properties
var saveLine = function() {
elemData.width = lineEditor.find('.kelmu-line-width').val() || window.kelmu.defaults.line.width;
elemData.line = lineEditor.find('.kelmu-line-color').val() || window.kelmu.defaults.line.line;
elemData.soundOption = lineEditor.find('.kelmu-line-sound-option').val() || window.kelmu.defaults.line.soundOption;
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
};
lineEditor.find('input').keyup(saveLine);
var buttonContainer = $('<div></div>').appendTo(lineEditor);
createRemoveButton().appendTo(buttonContainer);
// Save the modified properties
$('<button></button>').text('Make default').addClass('btn').appendTo(buttonContainer).click(function(e) {
e.preventDefault();
window.kelmu.defaults.line.width = lineEditor.find('.kelmu-line-width').val() || lineDefaults.width;
window.kelmu.defaults.line.line = lineEditor.find('.kelmu-line-color').val() || lineDefaults.line;
window.kelmu.defaults.line.soundOption = lineEditor.find('.kelmu-line-sound-option').val() || lineDefaults.soundOption;
});
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"var",
"elemData",
"=",
"data",
".",
"definitions",
"[",
"'step'",
"+",
"data",
".",
"stepNumber",
"]",
"[",
"data",
".",
"subStepNumber",
"]",
"[",
"data",
".",
"selectedElementNumber",
"]",
";",
"editor",
".",
"find",
"(",
"'.kelmu-editor-pane'",
")",
".",
"remove",
"(",
")",
";",
"var",
"lineEditor",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"addClass",
"(",
"'kelmu-line-editor'",
")",
".",
"addClass",
"(",
"'kelmu-editor-pane'",
")",
";",
"lineEditor",
".",
"appendTo",
"(",
"editor",
")",
";",
"lineEditor",
".",
"append",
"(",
"$",
"(",
"'<h4>Line</h4>'",
")",
".",
"css",
"(",
"'margin'",
",",
"'15px 0px'",
")",
")",
";",
"idCounter",
"+=",
"1",
";",
"// Set the current values",
"addComponent",
"(",
"'Width:'",
",",
"lineEditor",
",",
"'kelmu-line-width'",
",",
"elemData",
".",
"width",
",",
"'text'",
",",
"true",
")",
";",
"addComponent",
"(",
"'Color:'",
",",
"lineEditor",
",",
"'kelmu-line-color'",
",",
"elemData",
".",
"line",
",",
"'text'",
")",
";",
"addComponent",
"(",
"'With sound:'",
",",
"lineEditor",
",",
"'kelmu-line-sound-option'",
",",
"elemData",
".",
"soundOption",
",",
"'text'",
")",
";",
"// Save the modified properties",
"var",
"saveLine",
"=",
"function",
"(",
")",
"{",
"elemData",
".",
"width",
"=",
"lineEditor",
".",
"find",
"(",
"'.kelmu-line-width'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"line",
".",
"width",
";",
"elemData",
".",
"line",
"=",
"lineEditor",
".",
"find",
"(",
"'.kelmu-line-color'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"line",
".",
"line",
";",
"elemData",
".",
"soundOption",
"=",
"lineEditor",
".",
"find",
"(",
"'.kelmu-line-sound-option'",
")",
".",
"val",
"(",
")",
"||",
"window",
".",
"kelmu",
".",
"defaults",
".",
"line",
".",
"soundOption",
";",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
".",
"actions",
".",
"update",
"(",
")",
";",
"updateView",
"(",
"true",
",",
"true",
")",
";",
"notifyModifications",
"(",
")",
";",
"}",
";",
"lineEditor",
".",
"find",
"(",
"'input'",
")",
".",
"keyup",
"(",
"saveLine",
")",
";",
"var",
"buttonContainer",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"appendTo",
"(",
"lineEditor",
")",
";",
"createRemoveButton",
"(",
")",
".",
"appendTo",
"(",
"buttonContainer",
")",
";",
"// Save the modified properties",
"$",
"(",
"'<button></button>'",
")",
".",
"text",
"(",
"'Make default'",
")",
".",
"addClass",
"(",
"'btn'",
")",
".",
"appendTo",
"(",
"buttonContainer",
")",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"line",
".",
"width",
"=",
"lineEditor",
".",
"find",
"(",
"'.kelmu-line-width'",
")",
".",
"val",
"(",
")",
"||",
"lineDefaults",
".",
"width",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"line",
".",
"line",
"=",
"lineEditor",
".",
"find",
"(",
"'.kelmu-line-color'",
")",
".",
"val",
"(",
")",
"||",
"lineDefaults",
".",
"line",
";",
"window",
".",
"kelmu",
".",
"defaults",
".",
"line",
".",
"soundOption",
"=",
"lineEditor",
".",
"find",
"(",
"'.kelmu-line-sound-option'",
")",
".",
"val",
"(",
")",
"||",
"lineDefaults",
".",
"soundOption",
";",
"}",
")",
";",
"}"
] | Creates the action editor pane for the selected line. | [
"Creates",
"the",
"action",
"editor",
"pane",
"for",
"the",
"selected",
"line",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L1060-L1103 |
|
54,311 | acos-server/acos-kelmu | static/kelmu.editor.js | function() {
var data = window.kelmu.data[id];
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
editor.find('.kelmu-editor-pane').remove();
var soundEditor = $('<div></div>').addClass('kelmu-sound-editor').addClass('kelmu-editor-pane');
soundEditor.appendTo(editor);
soundEditor.append($('<h4>Sound</h4>').css('margin', '15px 0px'));
idCounter += 1;
// Set the current values
addComponent('URL:', soundEditor, 'kelmu-sound-url', elemData.sound, 'text', true);
// Move cursor to end
soundEditor.find('.kelmu-sound-url').focus();
var val = soundEditor.find('.kelmu-sound-url').val();
soundEditor.find('.kelmu-sound-url').val('').val(val);
var buttonContainer = $('<div></div>').appendTo(soundEditor);
// Save the modified properties
var saveButton = function() {
elemData.sound = soundEditor.find('.kelmu-sound-url').val();
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
};
soundEditor.find('input').keyup(saveButton);
createRemoveButton().click(function(e) {
e.preventDefault();
var soundControl = container.find('.kelmu-sound-control');
soundControl.hide();
// If there are sounds for this animation, show the mute control
Object.keys(window.kelmu.data[id].definitions || {}).forEach(function(substeps) {
window.kelmu.data[id].definitions[substeps].forEach(function(substep) {
substep.forEach(function(step) {
if (step.sound !== undefined) {
soundControl.show();
}
});
});
});
}).appendTo(buttonContainer);
// Play the sound
$('<button></button>').text('Play').addClass('btn').appendTo(buttonContainer).click(function(e) {
e.preventDefault();
var sound = $('<audio></audio>').attr('src', soundEditor.find('.kelmu-sound-url').val());
container.append(sound);
sound[0].play();
});
} | javascript | function() {
var data = window.kelmu.data[id];
var elemData = data.definitions['step' + data.stepNumber][data.subStepNumber][data.selectedElementNumber];
editor.find('.kelmu-editor-pane').remove();
var soundEditor = $('<div></div>').addClass('kelmu-sound-editor').addClass('kelmu-editor-pane');
soundEditor.appendTo(editor);
soundEditor.append($('<h4>Sound</h4>').css('margin', '15px 0px'));
idCounter += 1;
// Set the current values
addComponent('URL:', soundEditor, 'kelmu-sound-url', elemData.sound, 'text', true);
// Move cursor to end
soundEditor.find('.kelmu-sound-url').focus();
var val = soundEditor.find('.kelmu-sound-url').val();
soundEditor.find('.kelmu-sound-url').val('').val(val);
var buttonContainer = $('<div></div>').appendTo(soundEditor);
// Save the modified properties
var saveButton = function() {
elemData.sound = soundEditor.find('.kelmu-sound-url').val();
window.kelmu.data[id].actions.update();
updateView(true, true);
notifyModifications();
};
soundEditor.find('input').keyup(saveButton);
createRemoveButton().click(function(e) {
e.preventDefault();
var soundControl = container.find('.kelmu-sound-control');
soundControl.hide();
// If there are sounds for this animation, show the mute control
Object.keys(window.kelmu.data[id].definitions || {}).forEach(function(substeps) {
window.kelmu.data[id].definitions[substeps].forEach(function(substep) {
substep.forEach(function(step) {
if (step.sound !== undefined) {
soundControl.show();
}
});
});
});
}).appendTo(buttonContainer);
// Play the sound
$('<button></button>').text('Play').addClass('btn').appendTo(buttonContainer).click(function(e) {
e.preventDefault();
var sound = $('<audio></audio>').attr('src', soundEditor.find('.kelmu-sound-url').val());
container.append(sound);
sound[0].play();
});
} | [
"function",
"(",
")",
"{",
"var",
"data",
"=",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
";",
"var",
"elemData",
"=",
"data",
".",
"definitions",
"[",
"'step'",
"+",
"data",
".",
"stepNumber",
"]",
"[",
"data",
".",
"subStepNumber",
"]",
"[",
"data",
".",
"selectedElementNumber",
"]",
";",
"editor",
".",
"find",
"(",
"'.kelmu-editor-pane'",
")",
".",
"remove",
"(",
")",
";",
"var",
"soundEditor",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"addClass",
"(",
"'kelmu-sound-editor'",
")",
".",
"addClass",
"(",
"'kelmu-editor-pane'",
")",
";",
"soundEditor",
".",
"appendTo",
"(",
"editor",
")",
";",
"soundEditor",
".",
"append",
"(",
"$",
"(",
"'<h4>Sound</h4>'",
")",
".",
"css",
"(",
"'margin'",
",",
"'15px 0px'",
")",
")",
";",
"idCounter",
"+=",
"1",
";",
"// Set the current values",
"addComponent",
"(",
"'URL:'",
",",
"soundEditor",
",",
"'kelmu-sound-url'",
",",
"elemData",
".",
"sound",
",",
"'text'",
",",
"true",
")",
";",
"// Move cursor to end",
"soundEditor",
".",
"find",
"(",
"'.kelmu-sound-url'",
")",
".",
"focus",
"(",
")",
";",
"var",
"val",
"=",
"soundEditor",
".",
"find",
"(",
"'.kelmu-sound-url'",
")",
".",
"val",
"(",
")",
";",
"soundEditor",
".",
"find",
"(",
"'.kelmu-sound-url'",
")",
".",
"val",
"(",
"''",
")",
".",
"val",
"(",
"val",
")",
";",
"var",
"buttonContainer",
"=",
"$",
"(",
"'<div></div>'",
")",
".",
"appendTo",
"(",
"soundEditor",
")",
";",
"// Save the modified properties",
"var",
"saveButton",
"=",
"function",
"(",
")",
"{",
"elemData",
".",
"sound",
"=",
"soundEditor",
".",
"find",
"(",
"'.kelmu-sound-url'",
")",
".",
"val",
"(",
")",
";",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
".",
"actions",
".",
"update",
"(",
")",
";",
"updateView",
"(",
"true",
",",
"true",
")",
";",
"notifyModifications",
"(",
")",
";",
"}",
";",
"soundEditor",
".",
"find",
"(",
"'input'",
")",
".",
"keyup",
"(",
"saveButton",
")",
";",
"createRemoveButton",
"(",
")",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"soundControl",
"=",
"container",
".",
"find",
"(",
"'.kelmu-sound-control'",
")",
";",
"soundControl",
".",
"hide",
"(",
")",
";",
"// If there are sounds for this animation, show the mute control",
"Object",
".",
"keys",
"(",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
".",
"definitions",
"||",
"{",
"}",
")",
".",
"forEach",
"(",
"function",
"(",
"substeps",
")",
"{",
"window",
".",
"kelmu",
".",
"data",
"[",
"id",
"]",
".",
"definitions",
"[",
"substeps",
"]",
".",
"forEach",
"(",
"function",
"(",
"substep",
")",
"{",
"substep",
".",
"forEach",
"(",
"function",
"(",
"step",
")",
"{",
"if",
"(",
"step",
".",
"sound",
"!==",
"undefined",
")",
"{",
"soundControl",
".",
"show",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
".",
"appendTo",
"(",
"buttonContainer",
")",
";",
"// Play the sound",
"$",
"(",
"'<button></button>'",
")",
".",
"text",
"(",
"'Play'",
")",
".",
"addClass",
"(",
"'btn'",
")",
".",
"appendTo",
"(",
"buttonContainer",
")",
".",
"click",
"(",
"function",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"var",
"sound",
"=",
"$",
"(",
"'<audio></audio>'",
")",
".",
"attr",
"(",
"'src'",
",",
"soundEditor",
".",
"find",
"(",
"'.kelmu-sound-url'",
")",
".",
"val",
"(",
")",
")",
";",
"container",
".",
"append",
"(",
"sound",
")",
";",
"sound",
"[",
"0",
"]",
".",
"play",
"(",
")",
";",
"}",
")",
";",
"}"
] | Creates the action editor pane for the selected sound. | [
"Creates",
"the",
"action",
"editor",
"pane",
"for",
"the",
"selected",
"sound",
"."
] | 71105b5b43027c517a1da99d6cb0a7687fe253b9 | https://github.com/acos-server/acos-kelmu/blob/71105b5b43027c517a1da99d6cb0a7687fe253b9/static/kelmu.editor.js#L1109-L1170 |
|
54,312 | jtrussell/bepacked | lib/bepacked.js | function($, $ln, contents) {
var ln = $ln[0]
, attrKeys = Object.keys(ln.attribs)
, $s = $('<style type="text/css"></style>')
, attrs = []
, ix;
for(ix = attrKeys.length; ix--;) {
$s.attr(attrKeys[ix], ln.attribs[attrKeys[ix]]);
}
// Save the origin href
// ...
$s.attr('data-bepacked-href', $s.attr('href'));
$s.attr('href', null);
$s.attr('rel', null);
$s.text(contents.toString().trim());
$ln.replaceWith($s);
} | javascript | function($, $ln, contents) {
var ln = $ln[0]
, attrKeys = Object.keys(ln.attribs)
, $s = $('<style type="text/css"></style>')
, attrs = []
, ix;
for(ix = attrKeys.length; ix--;) {
$s.attr(attrKeys[ix], ln.attribs[attrKeys[ix]]);
}
// Save the origin href
// ...
$s.attr('data-bepacked-href', $s.attr('href'));
$s.attr('href', null);
$s.attr('rel', null);
$s.text(contents.toString().trim());
$ln.replaceWith($s);
} | [
"function",
"(",
"$",
",",
"$ln",
",",
"contents",
")",
"{",
"var",
"ln",
"=",
"$ln",
"[",
"0",
"]",
",",
"attrKeys",
"=",
"Object",
".",
"keys",
"(",
"ln",
".",
"attribs",
")",
",",
"$s",
"=",
"$",
"(",
"'<style type=\"text/css\"></style>'",
")",
",",
"attrs",
"=",
"[",
"]",
",",
"ix",
";",
"for",
"(",
"ix",
"=",
"attrKeys",
".",
"length",
";",
"ix",
"--",
";",
")",
"{",
"$s",
".",
"attr",
"(",
"attrKeys",
"[",
"ix",
"]",
",",
"ln",
".",
"attribs",
"[",
"attrKeys",
"[",
"ix",
"]",
"]",
")",
";",
"}",
"// Save the origin href\r",
"// ...\r",
"$s",
".",
"attr",
"(",
"'data-bepacked-href'",
",",
"$s",
".",
"attr",
"(",
"'href'",
")",
")",
";",
"$s",
".",
"attr",
"(",
"'href'",
",",
"null",
")",
";",
"$s",
".",
"attr",
"(",
"'rel'",
",",
"null",
")",
";",
"$s",
".",
"text",
"(",
"contents",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
")",
";",
"$ln",
".",
"replaceWith",
"(",
"$s",
")",
";",
"}"
] | Replace a link tag with a script tag with the give contents | [
"Replace",
"a",
"link",
"tag",
"with",
"a",
"script",
"tag",
"with",
"the",
"give",
"contents"
] | 66749847ba1fd9ea38aa1f4cd3bb1ad98e7d5b65 | https://github.com/jtrussell/bepacked/blob/66749847ba1fd9ea38aa1f4cd3bb1ad98e7d5b65/lib/bepacked.js#L69-L87 |
|
54,313 | miguelcobain/IPapp | templates/hello/display/script/script.js | function() {
// Let's fade out the splash screen div...
$('.splash').fadeOut('slow', function() {
// ...stop the pulsing effect...
$('.splash .circle').stop().css({
opacity : 1
});
// and fade in the content div.
$('.content').fadeIn('slow', function() {
if (people.length == 0)
$('#title').fadeIn('slow');
else
greet(people, 0);
});
});
} | javascript | function() {
// Let's fade out the splash screen div...
$('.splash').fadeOut('slow', function() {
// ...stop the pulsing effect...
$('.splash .circle').stop().css({
opacity : 1
});
// and fade in the content div.
$('.content').fadeIn('slow', function() {
if (people.length == 0)
$('#title').fadeIn('slow');
else
greet(people, 0);
});
});
} | [
"function",
"(",
")",
"{",
"// Let's fade out the splash screen div...",
"$",
"(",
"'.splash'",
")",
".",
"fadeOut",
"(",
"'slow'",
",",
"function",
"(",
")",
"{",
"// ...stop the pulsing effect...",
"$",
"(",
"'.splash .circle'",
")",
".",
"stop",
"(",
")",
".",
"css",
"(",
"{",
"opacity",
":",
"1",
"}",
")",
";",
"// and fade in the content div.",
"$",
"(",
"'.content'",
")",
".",
"fadeIn",
"(",
"'slow'",
",",
"function",
"(",
")",
"{",
"if",
"(",
"people",
".",
"length",
"==",
"0",
")",
"$",
"(",
"'#title'",
")",
".",
"fadeIn",
"(",
"'slow'",
")",
";",
"else",
"greet",
"(",
"people",
",",
"0",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | onEnd will run whenever the splash screen ends | [
"onEnd",
"will",
"run",
"whenever",
"the",
"splash",
"screen",
"ends"
] | 5abee62aeeec66b674b2976c2dfdc94a4515e35c | https://github.com/miguelcobain/IPapp/blob/5abee62aeeec66b674b2976c2dfdc94a4515e35c/templates/hello/display/script/script.js#L68-L83 |
|
54,314 | zjhiphop/grunt-nest-proxy | lib/multi-data.js | getFormDataForPost | function getFormDataForPost(fields, files) {
function encodeFieldPart(boundary, name, value) {
var return_part = "--" + boundary + "\r\n";
return_part += "Content-Disposition: form-data; name=\"" + name + "\"\r\n\r\n";
return_part += value + "\r\n";
return return_part;
}
function encodeFilePart(boundary, type, name, filename) {
var return_part = "--" + boundary + "\r\n";
return_part += "Content-Disposition: form-data; name=\"" + name + "\"; filename=\"" + filename + "\"\r\n";
return_part += "Content-Type: " + type + "\r\n\r\n";
return return_part;
}
var boundary = Math.random();
var post_data = [];
if (fields) {
for (var key in fields) {
var value = fields[key];
post_data.push(new Buffer(encodeFieldPart(boundary, key, value), 'ascii'));
}
}
if (files) {
for (var key in files) {
var value = files[key];
post_data.push(new Buffer(encodeFilePart(boundary, value.type, value.keyname, value.valuename), 'ascii'));
post_data.push(new Buffer(value.data, 'utf8'))
}
}
post_data.push(new Buffer("\r\n--" + boundary + "--"), 'ascii');
var length = 0;
for (var i = 0; i < post_data.length; i++) {
length += post_data[i].length;
}
var params = {
postdata: post_data,
headers: {
'Content-Type': 'multipart/form-data; boundary=' + boundary,
'Content-Length': length
}
};
return params;
} | javascript | function getFormDataForPost(fields, files) {
function encodeFieldPart(boundary, name, value) {
var return_part = "--" + boundary + "\r\n";
return_part += "Content-Disposition: form-data; name=\"" + name + "\"\r\n\r\n";
return_part += value + "\r\n";
return return_part;
}
function encodeFilePart(boundary, type, name, filename) {
var return_part = "--" + boundary + "\r\n";
return_part += "Content-Disposition: form-data; name=\"" + name + "\"; filename=\"" + filename + "\"\r\n";
return_part += "Content-Type: " + type + "\r\n\r\n";
return return_part;
}
var boundary = Math.random();
var post_data = [];
if (fields) {
for (var key in fields) {
var value = fields[key];
post_data.push(new Buffer(encodeFieldPart(boundary, key, value), 'ascii'));
}
}
if (files) {
for (var key in files) {
var value = files[key];
post_data.push(new Buffer(encodeFilePart(boundary, value.type, value.keyname, value.valuename), 'ascii'));
post_data.push(new Buffer(value.data, 'utf8'))
}
}
post_data.push(new Buffer("\r\n--" + boundary + "--"), 'ascii');
var length = 0;
for (var i = 0; i < post_data.length; i++) {
length += post_data[i].length;
}
var params = {
postdata: post_data,
headers: {
'Content-Type': 'multipart/form-data; boundary=' + boundary,
'Content-Length': length
}
};
return params;
} | [
"function",
"getFormDataForPost",
"(",
"fields",
",",
"files",
")",
"{",
"function",
"encodeFieldPart",
"(",
"boundary",
",",
"name",
",",
"value",
")",
"{",
"var",
"return_part",
"=",
"\"--\"",
"+",
"boundary",
"+",
"\"\\r\\n\"",
";",
"return_part",
"+=",
"\"Content-Disposition: form-data; name=\\\"\"",
"+",
"name",
"+",
"\"\\\"\\r\\n\\r\\n\"",
";",
"return_part",
"+=",
"value",
"+",
"\"\\r\\n\"",
";",
"return",
"return_part",
";",
"}",
"function",
"encodeFilePart",
"(",
"boundary",
",",
"type",
",",
"name",
",",
"filename",
")",
"{",
"var",
"return_part",
"=",
"\"--\"",
"+",
"boundary",
"+",
"\"\\r\\n\"",
";",
"return_part",
"+=",
"\"Content-Disposition: form-data; name=\\\"\"",
"+",
"name",
"+",
"\"\\\"; filename=\\\"\"",
"+",
"filename",
"+",
"\"\\\"\\r\\n\"",
";",
"return_part",
"+=",
"\"Content-Type: \"",
"+",
"type",
"+",
"\"\\r\\n\\r\\n\"",
";",
"return",
"return_part",
";",
"}",
"var",
"boundary",
"=",
"Math",
".",
"random",
"(",
")",
";",
"var",
"post_data",
"=",
"[",
"]",
";",
"if",
"(",
"fields",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"fields",
")",
"{",
"var",
"value",
"=",
"fields",
"[",
"key",
"]",
";",
"post_data",
".",
"push",
"(",
"new",
"Buffer",
"(",
"encodeFieldPart",
"(",
"boundary",
",",
"key",
",",
"value",
")",
",",
"'ascii'",
")",
")",
";",
"}",
"}",
"if",
"(",
"files",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"files",
")",
"{",
"var",
"value",
"=",
"files",
"[",
"key",
"]",
";",
"post_data",
".",
"push",
"(",
"new",
"Buffer",
"(",
"encodeFilePart",
"(",
"boundary",
",",
"value",
".",
"type",
",",
"value",
".",
"keyname",
",",
"value",
".",
"valuename",
")",
",",
"'ascii'",
")",
")",
";",
"post_data",
".",
"push",
"(",
"new",
"Buffer",
"(",
"value",
".",
"data",
",",
"'utf8'",
")",
")",
"}",
"}",
"post_data",
".",
"push",
"(",
"new",
"Buffer",
"(",
"\"\\r\\n--\"",
"+",
"boundary",
"+",
"\"--\"",
")",
",",
"'ascii'",
")",
";",
"var",
"length",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"post_data",
".",
"length",
";",
"i",
"++",
")",
"{",
"length",
"+=",
"post_data",
"[",
"i",
"]",
".",
"length",
";",
"}",
"var",
"params",
"=",
"{",
"postdata",
":",
"post_data",
",",
"headers",
":",
"{",
"'Content-Type'",
":",
"'multipart/form-data; boundary='",
"+",
"boundary",
",",
"'Content-Length'",
":",
"length",
"}",
"}",
";",
"return",
"params",
";",
"}"
] | Converts a list of parameters to forum data
- `fields` - a property map of key value pairs
- `files` - a list of property maps of content
- `type` - the type of file data
- `keyname` - the name of the key corresponding to the file
- `valuename` - the name of the value corresponding to the file
- `data` - the data of the file | [
"Converts",
"a",
"list",
"of",
"parameters",
"to",
"forum",
"data",
"-",
"fields",
"-",
"a",
"property",
"map",
"of",
"key",
"value",
"pairs",
"-",
"files",
"-",
"a",
"list",
"of",
"property",
"maps",
"of",
"content",
"-",
"type",
"-",
"the",
"type",
"of",
"file",
"data",
"-",
"keyname",
"-",
"the",
"name",
"of",
"the",
"key",
"corresponding",
"to",
"the",
"file",
"-",
"valuename",
"-",
"the",
"name",
"of",
"the",
"value",
"corresponding",
"to",
"the",
"file",
"-",
"data",
"-",
"the",
"data",
"of",
"the",
"file"
] | 95083ea47854c59e1381bf867c261dca43399c5f | https://github.com/zjhiphop/grunt-nest-proxy/blob/95083ea47854c59e1381bf867c261dca43399c5f/lib/multi-data.js#L14-L59 |
54,315 | zjhiphop/grunt-nest-proxy | lib/multi-data.js | postData | function postData(fields, files, options, headers, callback) {
var headerparams = getFormDataForPost(fields, files);
var totalheaders = headerparams.headers;
for (var key in headers) totalheaders[key] = headers[key];
var post_options = {
host: options.host,
port: options.port,
path: options.path,
method: options.method || 'POST',
headers: totalheaders
};
var request = Http.request(post_options, function(response) {
response.body = '';
response.setEncoding(options.encoding);
response.on('data', function(chunk) {
console.log(chunk);
response.body += chunk;
});
response.on('end', function() {
callback(null, response)
});
});
for (var i = 0; i < headerparams.postdata.length; i++) {
request.write(headerparams.postdata[i]);
}
request.end();
} | javascript | function postData(fields, files, options, headers, callback) {
var headerparams = getFormDataForPost(fields, files);
var totalheaders = headerparams.headers;
for (var key in headers) totalheaders[key] = headers[key];
var post_options = {
host: options.host,
port: options.port,
path: options.path,
method: options.method || 'POST',
headers: totalheaders
};
var request = Http.request(post_options, function(response) {
response.body = '';
response.setEncoding(options.encoding);
response.on('data', function(chunk) {
console.log(chunk);
response.body += chunk;
});
response.on('end', function() {
callback(null, response)
});
});
for (var i = 0; i < headerparams.postdata.length; i++) {
request.write(headerparams.postdata[i]);
}
request.end();
} | [
"function",
"postData",
"(",
"fields",
",",
"files",
",",
"options",
",",
"headers",
",",
"callback",
")",
"{",
"var",
"headerparams",
"=",
"getFormDataForPost",
"(",
"fields",
",",
"files",
")",
";",
"var",
"totalheaders",
"=",
"headerparams",
".",
"headers",
";",
"for",
"(",
"var",
"key",
"in",
"headers",
")",
"totalheaders",
"[",
"key",
"]",
"=",
"headers",
"[",
"key",
"]",
";",
"var",
"post_options",
"=",
"{",
"host",
":",
"options",
".",
"host",
",",
"port",
":",
"options",
".",
"port",
",",
"path",
":",
"options",
".",
"path",
",",
"method",
":",
"options",
".",
"method",
"||",
"'POST'",
",",
"headers",
":",
"totalheaders",
"}",
";",
"var",
"request",
"=",
"Http",
".",
"request",
"(",
"post_options",
",",
"function",
"(",
"response",
")",
"{",
"response",
".",
"body",
"=",
"''",
";",
"response",
".",
"setEncoding",
"(",
"options",
".",
"encoding",
")",
";",
"response",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",
")",
"{",
"console",
".",
"log",
"(",
"chunk",
")",
";",
"response",
".",
"body",
"+=",
"chunk",
";",
"}",
")",
";",
"response",
".",
"on",
"(",
"'end'",
",",
"function",
"(",
")",
"{",
"callback",
"(",
"null",
",",
"response",
")",
"}",
")",
";",
"}",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"headerparams",
".",
"postdata",
".",
"length",
";",
"i",
"++",
")",
"{",
"request",
".",
"write",
"(",
"headerparams",
".",
"postdata",
"[",
"i",
"]",
")",
";",
"}",
"request",
".",
"end",
"(",
")",
";",
"}"
] | Sends a post form request via http
- `fields` - a property map of key value pairs
- `files` - a list of property maps of content
- `type` - the type of file data
- `keyname` - the name of the key corresponding to the file
- `valuename` - the name of the value corresponding to the file
- `data` - the data of the file
- `options` is a set of options
- host
- port
- path
- method
- encoding
- `headers` headers to be sent with the request
- `callback` - callback to handle the response | [
"Sends",
"a",
"post",
"form",
"request",
"via",
"http",
"-",
"fields",
"-",
"a",
"property",
"map",
"of",
"key",
"value",
"pairs",
"-",
"files",
"-",
"a",
"list",
"of",
"property",
"maps",
"of",
"content",
"-",
"type",
"-",
"the",
"type",
"of",
"file",
"data",
"-",
"keyname",
"-",
"the",
"name",
"of",
"the",
"key",
"corresponding",
"to",
"the",
"file",
"-",
"valuename",
"-",
"the",
"name",
"of",
"the",
"value",
"corresponding",
"to",
"the",
"file",
"-",
"data",
"-",
"the",
"data",
"of",
"the",
"file",
"-",
"options",
"is",
"a",
"set",
"of",
"options",
"-",
"host",
"-",
"port",
"-",
"path",
"-",
"method",
"-",
"encoding",
"-",
"headers",
"headers",
"to",
"be",
"sent",
"with",
"the",
"request",
"-",
"callback",
"-",
"callback",
"to",
"handle",
"the",
"response"
] | 95083ea47854c59e1381bf867c261dca43399c5f | https://github.com/zjhiphop/grunt-nest-proxy/blob/95083ea47854c59e1381bf867c261dca43399c5f/lib/multi-data.js#L78-L107 |
54,316 | zjhiphop/grunt-nest-proxy | lib/multi-data.js | postImage | function postImage(options, filename, headers, cb) {
Step(
function readImage() {
fs.readFile(filename, this);
},
function(err, filecontents) {
if (err) {
console.log('Unable to read file', __dirname);
return;
}
postData(null, [{
type: 'image/jpeg',
keyname: 'image',
valuename: 'image.jpg',
data: filecontents
}], options, headers, this);
},
function(err, response, body) {
cb && cb(err, response);
console.log("response code " + response.statusCode, ", body is : ", body);
}
);
} | javascript | function postImage(options, filename, headers, cb) {
Step(
function readImage() {
fs.readFile(filename, this);
},
function(err, filecontents) {
if (err) {
console.log('Unable to read file', __dirname);
return;
}
postData(null, [{
type: 'image/jpeg',
keyname: 'image',
valuename: 'image.jpg',
data: filecontents
}], options, headers, this);
},
function(err, response, body) {
cb && cb(err, response);
console.log("response code " + response.statusCode, ", body is : ", body);
}
);
} | [
"function",
"postImage",
"(",
"options",
",",
"filename",
",",
"headers",
",",
"cb",
")",
"{",
"Step",
"(",
"function",
"readImage",
"(",
")",
"{",
"fs",
".",
"readFile",
"(",
"filename",
",",
"this",
")",
";",
"}",
",",
"function",
"(",
"err",
",",
"filecontents",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"'Unable to read file'",
",",
"__dirname",
")",
";",
"return",
";",
"}",
"postData",
"(",
"null",
",",
"[",
"{",
"type",
":",
"'image/jpeg'",
",",
"keyname",
":",
"'image'",
",",
"valuename",
":",
"'image.jpg'",
",",
"data",
":",
"filecontents",
"}",
"]",
",",
"options",
",",
"headers",
",",
"this",
")",
";",
"}",
",",
"function",
"(",
"err",
",",
"response",
",",
"body",
")",
"{",
"cb",
"&&",
"cb",
"(",
"err",
",",
"response",
")",
";",
"console",
".",
"log",
"(",
"\"response code \"",
"+",
"response",
".",
"statusCode",
",",
"\", body is : \"",
",",
"body",
")",
";",
"}",
")",
";",
"}"
] | Sends a post form request via http
- `options` is a set of options
- host
- port
- path
- method
- encoding
- `filename` filename being uploaded
- `headers` headers to be sent with the request | [
"Sends",
"a",
"post",
"form",
"request",
"via",
"http",
"-",
"options",
"is",
"a",
"set",
"of",
"options",
"-",
"host",
"-",
"port",
"-",
"path",
"-",
"method",
"-",
"encoding",
"-",
"filename",
"filename",
"being",
"uploaded",
"-",
"headers",
"headers",
"to",
"be",
"sent",
"with",
"the",
"request"
] | 95083ea47854c59e1381bf867c261dca43399c5f | https://github.com/zjhiphop/grunt-nest-proxy/blob/95083ea47854c59e1381bf867c261dca43399c5f/lib/multi-data.js#L120-L142 |
54,317 | entrinsik-org/nonce | lib/nonce.js | Nonce | function Nonce(cache, ttl) {
this.cache = cache;
this.ttl = ttl;
if (this.ttl && this.ttl > TTLMAX) {
this.ttl = TTLMAX;
}
} | javascript | function Nonce(cache, ttl) {
this.cache = cache;
this.ttl = ttl;
if (this.ttl && this.ttl > TTLMAX) {
this.ttl = TTLMAX;
}
} | [
"function",
"Nonce",
"(",
"cache",
",",
"ttl",
")",
"{",
"this",
".",
"cache",
"=",
"cache",
";",
"this",
".",
"ttl",
"=",
"ttl",
";",
"if",
"(",
"this",
".",
"ttl",
"&&",
"this",
".",
"ttl",
">",
"TTLMAX",
")",
"{",
"this",
".",
"ttl",
"=",
"TTLMAX",
";",
"}",
"}"
] | Nonce is a UUID that is created and cached until used. When used, it is removed so that
a request cannot perform the same action more than once. There is a TTL on the cache, so the store
does not continue to grow.
@param cache - the hapi server cache
@param ttl - optional, the ttl for the nonces generated
@constructor | [
"Nonce",
"is",
"a",
"UUID",
"that",
"is",
"created",
"and",
"cached",
"until",
"used",
".",
"When",
"used",
"it",
"is",
"removed",
"so",
"that",
"a",
"request",
"cannot",
"perform",
"the",
"same",
"action",
"more",
"than",
"once",
".",
"There",
"is",
"a",
"TTL",
"on",
"the",
"cache",
"so",
"the",
"store",
"does",
"not",
"continue",
"to",
"grow",
"."
] | 271c28bade513bf269997cf867ddc3454eed0e30 | https://github.com/entrinsik-org/nonce/blob/271c28bade513bf269997cf867ddc3454eed0e30/lib/nonce.js#L15-L21 |
54,318 | gabmontes/coincap-lib | src/index.js | createCoincap | function createCoincap () {
const socket = io(baseUrl, { autoConnect: false })
const api = {}
// Add JSON API supported endpoints
;[
{
method: 'coins',
url: () => '/coins'
},
{
method: 'map',
url: () => '/map'
},
{
method: 'front',
url: () => '/front'
},
{
method: 'global',
url: () => '/global'
},
{
method: 'coin',
url: coin => `/page/${coin}`
},
{
method: 'coinHistory',
url: (coin, days) => `/history/${days ? `${days}day/` : ''}${coin}`
}
].forEach(function ({ method, url }) {
api[method] = (...args) => fetch(url(...args))
})
// Add Socket.IO methods
;[
'open',
'close',
'on',
'off'
].forEach(function (method) {
api[method] = socket[method].bind(socket)
})
return api
} | javascript | function createCoincap () {
const socket = io(baseUrl, { autoConnect: false })
const api = {}
// Add JSON API supported endpoints
;[
{
method: 'coins',
url: () => '/coins'
},
{
method: 'map',
url: () => '/map'
},
{
method: 'front',
url: () => '/front'
},
{
method: 'global',
url: () => '/global'
},
{
method: 'coin',
url: coin => `/page/${coin}`
},
{
method: 'coinHistory',
url: (coin, days) => `/history/${days ? `${days}day/` : ''}${coin}`
}
].forEach(function ({ method, url }) {
api[method] = (...args) => fetch(url(...args))
})
// Add Socket.IO methods
;[
'open',
'close',
'on',
'off'
].forEach(function (method) {
api[method] = socket[method].bind(socket)
})
return api
} | [
"function",
"createCoincap",
"(",
")",
"{",
"const",
"socket",
"=",
"io",
"(",
"baseUrl",
",",
"{",
"autoConnect",
":",
"false",
"}",
")",
"const",
"api",
"=",
"{",
"}",
"// Add JSON API supported endpoints",
";",
"[",
"{",
"method",
":",
"'coins'",
",",
"url",
":",
"(",
")",
"=>",
"'/coins'",
"}",
",",
"{",
"method",
":",
"'map'",
",",
"url",
":",
"(",
")",
"=>",
"'/map'",
"}",
",",
"{",
"method",
":",
"'front'",
",",
"url",
":",
"(",
")",
"=>",
"'/front'",
"}",
",",
"{",
"method",
":",
"'global'",
",",
"url",
":",
"(",
")",
"=>",
"'/global'",
"}",
",",
"{",
"method",
":",
"'coin'",
",",
"url",
":",
"coin",
"=>",
"`",
"${",
"coin",
"}",
"`",
"}",
",",
"{",
"method",
":",
"'coinHistory'",
",",
"url",
":",
"(",
"coin",
",",
"days",
")",
"=>",
"`",
"${",
"days",
"?",
"`",
"${",
"days",
"}",
"`",
":",
"''",
"}",
"${",
"coin",
"}",
"`",
"}",
"]",
".",
"forEach",
"(",
"function",
"(",
"{",
"method",
",",
"url",
"}",
")",
"{",
"api",
"[",
"method",
"]",
"=",
"(",
"...",
"args",
")",
"=>",
"fetch",
"(",
"url",
"(",
"...",
"args",
")",
")",
"}",
")",
"// Add Socket.IO methods",
";",
"[",
"'open'",
",",
"'close'",
",",
"'on'",
",",
"'off'",
"]",
".",
"forEach",
"(",
"function",
"(",
"method",
")",
"{",
"api",
"[",
"method",
"]",
"=",
"socket",
"[",
"method",
"]",
".",
"bind",
"(",
"socket",
")",
"}",
")",
"return",
"api",
"}"
] | Constructs the CoinCap API object.
@return {Object} | [
"Constructs",
"the",
"CoinCap",
"API",
"object",
"."
] | 7397e369b7683e4456fea378b9f6521a34e7ddba | https://github.com/gabmontes/coincap-lib/blob/7397e369b7683e4456fea378b9f6521a34e7ddba/src/index.js#L12-L58 |
54,319 | ahwayakchih/serve-files | benchmarks/index.js | logInfo | function logInfo () {
console.log(`Running on node ${process.version} with ${os.cpus()[0].model} x ${os.cpus().length}`);
console.log('');
console.log('Testing:');
var columns = columnsCreate(['name', 'version', 'homepage']);
var infoStatic = require('serve-static/package.json');
infoStatic.version = 'v' + infoStatic.version;
columnsUpdate(columns, infoStatic);
var infoStatique = require('statique/package.json');
infoStatique.version = 'v' + infoStatique.version;
columnsUpdate(columns, infoStatique);
var infoFiles = require('../package.json');
infoFiles.version = 'v' + infoFiles.version;
columnsUpdate(columns, infoFiles);
console.log('- ' + columnsText(columns, infoStatic));
console.log('- ' + columnsText(columns, infoStatique));
console.log('- ' + columnsText(columns, infoFiles));
console.log('');
function columnsCreate (names) {
return names.map(name => {
return {size: 0, source: name};
});
}
function columnsUpdate (columns, info) {
var size;
var col;
for (var i = 0; i < columns.length; i++) {
col = columns[i];
size = (info[col.source] && info[col.source].length) || 0;
if (info[col.source] && (size = info[col.source].length) && size > col.size) {
col.size = size;
}
}
}
function columnsText (columns, info) {
var result = '';
for (var i = 0; i < columns.length; i++) {
result += columnText(columns[i], info);
result += ' ';
}
return result + ' ';
}
function columnText (column, info) {
var value = info[column.source] || '';
var padSize = column.size - value.length;
var pad = '';
if (padSize) {
pad += (new Array(padSize + 1)).join(' ');
}
return value + pad;
}
} | javascript | function logInfo () {
console.log(`Running on node ${process.version} with ${os.cpus()[0].model} x ${os.cpus().length}`);
console.log('');
console.log('Testing:');
var columns = columnsCreate(['name', 'version', 'homepage']);
var infoStatic = require('serve-static/package.json');
infoStatic.version = 'v' + infoStatic.version;
columnsUpdate(columns, infoStatic);
var infoStatique = require('statique/package.json');
infoStatique.version = 'v' + infoStatique.version;
columnsUpdate(columns, infoStatique);
var infoFiles = require('../package.json');
infoFiles.version = 'v' + infoFiles.version;
columnsUpdate(columns, infoFiles);
console.log('- ' + columnsText(columns, infoStatic));
console.log('- ' + columnsText(columns, infoStatique));
console.log('- ' + columnsText(columns, infoFiles));
console.log('');
function columnsCreate (names) {
return names.map(name => {
return {size: 0, source: name};
});
}
function columnsUpdate (columns, info) {
var size;
var col;
for (var i = 0; i < columns.length; i++) {
col = columns[i];
size = (info[col.source] && info[col.source].length) || 0;
if (info[col.source] && (size = info[col.source].length) && size > col.size) {
col.size = size;
}
}
}
function columnsText (columns, info) {
var result = '';
for (var i = 0; i < columns.length; i++) {
result += columnText(columns[i], info);
result += ' ';
}
return result + ' ';
}
function columnText (column, info) {
var value = info[column.source] || '';
var padSize = column.size - value.length;
var pad = '';
if (padSize) {
pad += (new Array(padSize + 1)).join(' ');
}
return value + pad;
}
} | [
"function",
"logInfo",
"(",
")",
"{",
"console",
".",
"log",
"(",
"`",
"${",
"process",
".",
"version",
"}",
"${",
"os",
".",
"cpus",
"(",
")",
"[",
"0",
"]",
".",
"model",
"}",
"${",
"os",
".",
"cpus",
"(",
")",
".",
"length",
"}",
"`",
")",
";",
"console",
".",
"log",
"(",
"''",
")",
";",
"console",
".",
"log",
"(",
"'Testing:'",
")",
";",
"var",
"columns",
"=",
"columnsCreate",
"(",
"[",
"'name'",
",",
"'version'",
",",
"'homepage'",
"]",
")",
";",
"var",
"infoStatic",
"=",
"require",
"(",
"'serve-static/package.json'",
")",
";",
"infoStatic",
".",
"version",
"=",
"'v'",
"+",
"infoStatic",
".",
"version",
";",
"columnsUpdate",
"(",
"columns",
",",
"infoStatic",
")",
";",
"var",
"infoStatique",
"=",
"require",
"(",
"'statique/package.json'",
")",
";",
"infoStatique",
".",
"version",
"=",
"'v'",
"+",
"infoStatique",
".",
"version",
";",
"columnsUpdate",
"(",
"columns",
",",
"infoStatique",
")",
";",
"var",
"infoFiles",
"=",
"require",
"(",
"'../package.json'",
")",
";",
"infoFiles",
".",
"version",
"=",
"'v'",
"+",
"infoFiles",
".",
"version",
";",
"columnsUpdate",
"(",
"columns",
",",
"infoFiles",
")",
";",
"console",
".",
"log",
"(",
"'- '",
"+",
"columnsText",
"(",
"columns",
",",
"infoStatic",
")",
")",
";",
"console",
".",
"log",
"(",
"'- '",
"+",
"columnsText",
"(",
"columns",
",",
"infoStatique",
")",
")",
";",
"console",
".",
"log",
"(",
"'- '",
"+",
"columnsText",
"(",
"columns",
",",
"infoFiles",
")",
")",
";",
"console",
".",
"log",
"(",
"''",
")",
";",
"function",
"columnsCreate",
"(",
"names",
")",
"{",
"return",
"names",
".",
"map",
"(",
"name",
"=>",
"{",
"return",
"{",
"size",
":",
"0",
",",
"source",
":",
"name",
"}",
";",
"}",
")",
";",
"}",
"function",
"columnsUpdate",
"(",
"columns",
",",
"info",
")",
"{",
"var",
"size",
";",
"var",
"col",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"columns",
".",
"length",
";",
"i",
"++",
")",
"{",
"col",
"=",
"columns",
"[",
"i",
"]",
";",
"size",
"=",
"(",
"info",
"[",
"col",
".",
"source",
"]",
"&&",
"info",
"[",
"col",
".",
"source",
"]",
".",
"length",
")",
"||",
"0",
";",
"if",
"(",
"info",
"[",
"col",
".",
"source",
"]",
"&&",
"(",
"size",
"=",
"info",
"[",
"col",
".",
"source",
"]",
".",
"length",
")",
"&&",
"size",
">",
"col",
".",
"size",
")",
"{",
"col",
".",
"size",
"=",
"size",
";",
"}",
"}",
"}",
"function",
"columnsText",
"(",
"columns",
",",
"info",
")",
"{",
"var",
"result",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"columns",
".",
"length",
";",
"i",
"++",
")",
"{",
"result",
"+=",
"columnText",
"(",
"columns",
"[",
"i",
"]",
",",
"info",
")",
";",
"result",
"+=",
"' '",
";",
"}",
"return",
"result",
"+",
"' '",
";",
"}",
"function",
"columnText",
"(",
"column",
",",
"info",
")",
"{",
"var",
"value",
"=",
"info",
"[",
"column",
".",
"source",
"]",
"||",
"''",
";",
"var",
"padSize",
"=",
"column",
".",
"size",
"-",
"value",
".",
"length",
";",
"var",
"pad",
"=",
"''",
";",
"if",
"(",
"padSize",
")",
"{",
"pad",
"+=",
"(",
"new",
"Array",
"(",
"padSize",
"+",
"1",
")",
")",
".",
"join",
"(",
"' '",
")",
";",
"}",
"return",
"value",
"+",
"pad",
";",
"}",
"}"
] | Show info about environment and tested packages.
@private | [
"Show",
"info",
"about",
"environment",
"and",
"tested",
"packages",
"."
] | cd949252a37210bec229146ab519534ef641e942 | https://github.com/ahwayakchih/serve-files/blob/cd949252a37210bec229146ab519534ef641e942/benchmarks/index.js#L148-L212 |
54,320 | ahwayakchih/serve-files | benchmarks/index.js | fakeTask | function fakeTask () {
return callback => server.get(filename, (err, res) => callback(err, res));
} | javascript | function fakeTask () {
return callback => server.get(filename, (err, res) => callback(err, res));
} | [
"function",
"fakeTask",
"(",
")",
"{",
"return",
"callback",
"=>",
"server",
".",
"get",
"(",
"filename",
",",
"(",
"err",
",",
"res",
")",
"=>",
"callback",
"(",
"err",
",",
"res",
")",
")",
";",
"}"
] | Fake task, that simply calls back asynchronously.
@private | [
"Fake",
"task",
"that",
"simply",
"calls",
"back",
"asynchronously",
"."
] | cd949252a37210bec229146ab519534ef641e942 | https://github.com/ahwayakchih/serve-files/blob/cd949252a37210bec229146ab519534ef641e942/benchmarks/index.js#L239-L241 |
54,321 | emmoistner/serverless-endpoint | lib/endpoint/res.js | send | function send(statusCode, body) {
if (body) {
body = JSON.stringify(body);
}
return {
statusCode,
body
};
} | javascript | function send(statusCode, body) {
if (body) {
body = JSON.stringify(body);
}
return {
statusCode,
body
};
} | [
"function",
"send",
"(",
"statusCode",
",",
"body",
")",
"{",
"if",
"(",
"body",
")",
"{",
"body",
"=",
"JSON",
".",
"stringify",
"(",
"body",
")",
";",
"}",
"return",
"{",
"statusCode",
",",
"body",
"}",
";",
"}"
] | Formats statusCode, body to be sent as a HTTP response back to Api Gateway.
The body parameter can be a a String, an object, or an Array.
@name send
@function
@param {number} statusCode Http Response code - https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
@param {string|Object|Object[]} body string, Object, or Array | [
"Formats",
"statusCode",
"body",
"to",
"be",
"sent",
"as",
"a",
"HTTP",
"response",
"back",
"to",
"Api",
"Gateway",
".",
"The",
"body",
"parameter",
"can",
"be",
"a",
"a",
"String",
"an",
"object",
"or",
"an",
"Array",
"."
] | c79caaba58e2ffdc87d3ca0cf9095709e6b8b7f0 | https://github.com/emmoistner/serverless-endpoint/blob/c79caaba58e2ffdc87d3ca0cf9095709e6b8b7f0/lib/endpoint/res.js#L29-L39 |
54,322 | kyasuda2003/taurus-express-light | Gruntfile.js | function(src,dest, isfile){
//console.log('test');
if (isfile){
grunt.file.copy(src,dest+'/'+src,{});
console.log('File has been created as '+dest+'/'+src);
return;
}
grunt.file.recurse(src, function(abspath, rootdir, subdir, filename){
var _ref3=(typeof subdir=='undefined'?'':(subdir+'/'));
grunt.file.copy(abspath,dest+'/'+src+'/'+_ref3+filename, {});
console.log('File has been created as '+dest+'/'+src+'/'+filename);
});
} | javascript | function(src,dest, isfile){
//console.log('test');
if (isfile){
grunt.file.copy(src,dest+'/'+src,{});
console.log('File has been created as '+dest+'/'+src);
return;
}
grunt.file.recurse(src, function(abspath, rootdir, subdir, filename){
var _ref3=(typeof subdir=='undefined'?'':(subdir+'/'));
grunt.file.copy(abspath,dest+'/'+src+'/'+_ref3+filename, {});
console.log('File has been created as '+dest+'/'+src+'/'+filename);
});
} | [
"function",
"(",
"src",
",",
"dest",
",",
"isfile",
")",
"{",
"//console.log('test');",
"if",
"(",
"isfile",
")",
"{",
"grunt",
".",
"file",
".",
"copy",
"(",
"src",
",",
"dest",
"+",
"'/'",
"+",
"src",
",",
"{",
"}",
")",
";",
"console",
".",
"log",
"(",
"'File has been created as '",
"+",
"dest",
"+",
"'/'",
"+",
"src",
")",
";",
"return",
";",
"}",
"grunt",
".",
"file",
".",
"recurse",
"(",
"src",
",",
"function",
"(",
"abspath",
",",
"rootdir",
",",
"subdir",
",",
"filename",
")",
"{",
"var",
"_ref3",
"=",
"(",
"typeof",
"subdir",
"==",
"'undefined'",
"?",
"''",
":",
"(",
"subdir",
"+",
"'/'",
")",
")",
";",
"grunt",
".",
"file",
".",
"copy",
"(",
"abspath",
",",
"dest",
"+",
"'/'",
"+",
"src",
"+",
"'/'",
"+",
"_ref3",
"+",
"filename",
",",
"{",
"}",
")",
";",
"console",
".",
"log",
"(",
"'File has been created as '",
"+",
"dest",
"+",
"'/'",
"+",
"src",
"+",
"'/'",
"+",
"filename",
")",
";",
"}",
")",
";",
"}"
] | copy dicts pattern designed | [
"copy",
"dicts",
"pattern",
"designed"
] | 985fa80c0ba0eddbe6112ebb7b29ca299880cdc6 | https://github.com/kyasuda2003/taurus-express-light/blob/985fa80c0ba0eddbe6112ebb7b29ca299880cdc6/Gruntfile.js#L59-L74 |
|
54,323 | melvincarvalho/rdf-shell | bin/tail.js | tail | function tail (argv, callback) {
if (!argv[2]) {
console.error('url is required')
console.error('Usage : tail <url>')
process.exit(-1)
}
var uri = argv[2]
var wss = 'wss://' + uri.split('/')[2] + '/'
var s = new ws(wss, {
origin: 'http://websocket.org'
})
s.on('open', function open () {
s.send('sub ' + uri)
})
s.on('close', function close () {
console.log('disconnected')
})
s.on('message', function message (data, flags) {
var a = data.split(' ')
if (a.length && a[0] === 'pub') {
util.get(a[1], function (err, res) {
if (err) {
console.error('Error : ' + err)
} else {
console.log(res)
}
})
}
})
} | javascript | function tail (argv, callback) {
if (!argv[2]) {
console.error('url is required')
console.error('Usage : tail <url>')
process.exit(-1)
}
var uri = argv[2]
var wss = 'wss://' + uri.split('/')[2] + '/'
var s = new ws(wss, {
origin: 'http://websocket.org'
})
s.on('open', function open () {
s.send('sub ' + uri)
})
s.on('close', function close () {
console.log('disconnected')
})
s.on('message', function message (data, flags) {
var a = data.split(' ')
if (a.length && a[0] === 'pub') {
util.get(a[1], function (err, res) {
if (err) {
console.error('Error : ' + err)
} else {
console.log(res)
}
})
}
})
} | [
"function",
"tail",
"(",
"argv",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"argv",
"[",
"2",
"]",
")",
"{",
"console",
".",
"error",
"(",
"'url is required'",
")",
"console",
".",
"error",
"(",
"'Usage : tail <url>'",
")",
"process",
".",
"exit",
"(",
"-",
"1",
")",
"}",
"var",
"uri",
"=",
"argv",
"[",
"2",
"]",
"var",
"wss",
"=",
"'wss://'",
"+",
"uri",
".",
"split",
"(",
"'/'",
")",
"[",
"2",
"]",
"+",
"'/'",
"var",
"s",
"=",
"new",
"ws",
"(",
"wss",
",",
"{",
"origin",
":",
"'http://websocket.org'",
"}",
")",
"s",
".",
"on",
"(",
"'open'",
",",
"function",
"open",
"(",
")",
"{",
"s",
".",
"send",
"(",
"'sub '",
"+",
"uri",
")",
"}",
")",
"s",
".",
"on",
"(",
"'close'",
",",
"function",
"close",
"(",
")",
"{",
"console",
".",
"log",
"(",
"'disconnected'",
")",
"}",
")",
"s",
".",
"on",
"(",
"'message'",
",",
"function",
"message",
"(",
"data",
",",
"flags",
")",
"{",
"var",
"a",
"=",
"data",
".",
"split",
"(",
"' '",
")",
"if",
"(",
"a",
".",
"length",
"&&",
"a",
"[",
"0",
"]",
"===",
"'pub'",
")",
"{",
"util",
".",
"get",
"(",
"a",
"[",
"1",
"]",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"{",
"console",
".",
"error",
"(",
"'Error : '",
"+",
"err",
")",
"}",
"else",
"{",
"console",
".",
"log",
"(",
"res",
")",
"}",
"}",
")",
"}",
"}",
")",
"}"
] | tail gets list of files for a given container
@param {String} argv[2] url
@callback {bin~cb} callback | [
"tail",
"gets",
"list",
"of",
"files",
"for",
"a",
"given",
"container"
] | bf2015f6f333855e69a18ce3ec9e917bbddfb425 | https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/bin/tail.js#L12-L45 |
54,324 | vorg/hammersley | index.js | radicalInverse_VdC | function radicalInverse_VdC(i) {
bits[0] = i;
bits[0] = ((bits[0] << 16) | (bits[0] >> 16))>>>0;
bits[0] = ((bits[0] & 0x55555555) << 1) | ((bits[0] & 0xAAAAAAAA) >>> 1) >>>0;
bits[0] = ((bits[0] & 0x33333333) << 2) | ((bits[0] & 0xCCCCCCCC) >>> 2) >>>0;
bits[0] = ((bits[0] & 0x0F0F0F0F) << 4) | ((bits[0] & 0xF0F0F0F0) >>> 4) >>>0;
bits[0] = ((bits[0] & 0x00FF00FF) << 8) | ((bits[0] & 0xFF00FF00) >>> 8) >>>0;
return bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
} | javascript | function radicalInverse_VdC(i) {
bits[0] = i;
bits[0] = ((bits[0] << 16) | (bits[0] >> 16))>>>0;
bits[0] = ((bits[0] & 0x55555555) << 1) | ((bits[0] & 0xAAAAAAAA) >>> 1) >>>0;
bits[0] = ((bits[0] & 0x33333333) << 2) | ((bits[0] & 0xCCCCCCCC) >>> 2) >>>0;
bits[0] = ((bits[0] & 0x0F0F0F0F) << 4) | ((bits[0] & 0xF0F0F0F0) >>> 4) >>>0;
bits[0] = ((bits[0] & 0x00FF00FF) << 8) | ((bits[0] & 0xFF00FF00) >>> 8) >>>0;
return bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
} | [
"function",
"radicalInverse_VdC",
"(",
"i",
")",
"{",
"bits",
"[",
"0",
"]",
"=",
"i",
";",
"bits",
"[",
"0",
"]",
"=",
"(",
"(",
"bits",
"[",
"0",
"]",
"<<",
"16",
")",
"|",
"(",
"bits",
"[",
"0",
"]",
">>",
"16",
")",
")",
">>>",
"0",
";",
"bits",
"[",
"0",
"]",
"=",
"(",
"(",
"bits",
"[",
"0",
"]",
"&",
"0x55555555",
")",
"<<",
"1",
")",
"|",
"(",
"(",
"bits",
"[",
"0",
"]",
"&",
"0xAAAAAAAA",
")",
">>>",
"1",
")",
">>>",
"0",
";",
"bits",
"[",
"0",
"]",
"=",
"(",
"(",
"bits",
"[",
"0",
"]",
"&",
"0x33333333",
")",
"<<",
"2",
")",
"|",
"(",
"(",
"bits",
"[",
"0",
"]",
"&",
"0xCCCCCCCC",
")",
">>>",
"2",
")",
">>>",
"0",
";",
"bits",
"[",
"0",
"]",
"=",
"(",
"(",
"bits",
"[",
"0",
"]",
"&",
"0x0F0F0F0F",
")",
"<<",
"4",
")",
"|",
"(",
"(",
"bits",
"[",
"0",
"]",
"&",
"0xF0F0F0F0",
")",
">>>",
"4",
")",
">>>",
"0",
";",
"bits",
"[",
"0",
"]",
"=",
"(",
"(",
"bits",
"[",
"0",
"]",
"&",
"0x00FF00FF",
")",
"<<",
"8",
")",
"|",
"(",
"(",
"bits",
"[",
"0",
"]",
"&",
"0xFF00FF00",
")",
">>>",
"8",
")",
">>>",
"0",
";",
"return",
"bits",
"[",
"0",
"]",
"*",
"2.3283064365386963e-10",
";",
"// / 0x100000000 or / 4294967296",
"}"
] | Van der Corput radical inverse | [
"Van",
"der",
"Corput",
"radical",
"inverse"
] | 300047be38d59e99f7e3c3424f0b9b65597f2bbe | https://github.com/vorg/hammersley/blob/300047be38d59e99f7e3c3424f0b9b65597f2bbe/index.js#L4-L12 |
54,325 | ugate/releasebot | lib/coopt.js | genEnvOptions | function genEnvOptions(commitMsg) {
return {
pluginName : globalOpts.pluginName,
pluginDesc : globalOpts.pluginDesc,
pkgPath : 'package.json',
pkgPathBower : 'bower.json',
pkgPropSync : [ 'name', 'version', 'repository' ],
gitCliSubstitute : '',
buildDir : process.env.TRAVIS_BUILD_DIR || process.cwd(),
branch : process.env.TRAVIS_BRANCH,
commitHash : process.env.TRAVIS_COMMIT,
commitMessage : commitMsg || process.env.TRAVIS_COMMIT_MESSAGE,
repoSlug : process.env.TRAVIS_REPO_SLUG,
releaseVersionDefaultLabel : 'release',
releaseVersionDefaultType : 'v',
releaseVersionRegExp : globalOpts.regexRelease,
releaseVersionSemverIncRegExp : globalOpts.regexReleaseSemverInc,
bumpVersionDefaultLabel : 'bump',
bumpVersionDefaultType : 'v',
bumpVersionRegExp : globalOpts.regexBump,
bumpVersionSemverIncRegExp : globalOpts.regexBumpSemverInc,
prevVersionMsgIgnoreRegExp : /No names found/i,
gitToken : process.env.GH_TOKEN,
npmToken : process.env.NPM_TOKEN
};
} | javascript | function genEnvOptions(commitMsg) {
return {
pluginName : globalOpts.pluginName,
pluginDesc : globalOpts.pluginDesc,
pkgPath : 'package.json',
pkgPathBower : 'bower.json',
pkgPropSync : [ 'name', 'version', 'repository' ],
gitCliSubstitute : '',
buildDir : process.env.TRAVIS_BUILD_DIR || process.cwd(),
branch : process.env.TRAVIS_BRANCH,
commitHash : process.env.TRAVIS_COMMIT,
commitMessage : commitMsg || process.env.TRAVIS_COMMIT_MESSAGE,
repoSlug : process.env.TRAVIS_REPO_SLUG,
releaseVersionDefaultLabel : 'release',
releaseVersionDefaultType : 'v',
releaseVersionRegExp : globalOpts.regexRelease,
releaseVersionSemverIncRegExp : globalOpts.regexReleaseSemverInc,
bumpVersionDefaultLabel : 'bump',
bumpVersionDefaultType : 'v',
bumpVersionRegExp : globalOpts.regexBump,
bumpVersionSemverIncRegExp : globalOpts.regexBumpSemverInc,
prevVersionMsgIgnoreRegExp : /No names found/i,
gitToken : process.env.GH_TOKEN,
npmToken : process.env.NPM_TOKEN
};
} | [
"function",
"genEnvOptions",
"(",
"commitMsg",
")",
"{",
"return",
"{",
"pluginName",
":",
"globalOpts",
".",
"pluginName",
",",
"pluginDesc",
":",
"globalOpts",
".",
"pluginDesc",
",",
"pkgPath",
":",
"'package.json'",
",",
"pkgPathBower",
":",
"'bower.json'",
",",
"pkgPropSync",
":",
"[",
"'name'",
",",
"'version'",
",",
"'repository'",
"]",
",",
"gitCliSubstitute",
":",
"''",
",",
"buildDir",
":",
"process",
".",
"env",
".",
"TRAVIS_BUILD_DIR",
"||",
"process",
".",
"cwd",
"(",
")",
",",
"branch",
":",
"process",
".",
"env",
".",
"TRAVIS_BRANCH",
",",
"commitHash",
":",
"process",
".",
"env",
".",
"TRAVIS_COMMIT",
",",
"commitMessage",
":",
"commitMsg",
"||",
"process",
".",
"env",
".",
"TRAVIS_COMMIT_MESSAGE",
",",
"repoSlug",
":",
"process",
".",
"env",
".",
"TRAVIS_REPO_SLUG",
",",
"releaseVersionDefaultLabel",
":",
"'release'",
",",
"releaseVersionDefaultType",
":",
"'v'",
",",
"releaseVersionRegExp",
":",
"globalOpts",
".",
"regexRelease",
",",
"releaseVersionSemverIncRegExp",
":",
"globalOpts",
".",
"regexReleaseSemverInc",
",",
"bumpVersionDefaultLabel",
":",
"'bump'",
",",
"bumpVersionDefaultType",
":",
"'v'",
",",
"bumpVersionRegExp",
":",
"globalOpts",
".",
"regexBump",
",",
"bumpVersionSemverIncRegExp",
":",
"globalOpts",
".",
"regexBumpSemverInc",
",",
"prevVersionMsgIgnoreRegExp",
":",
"/",
"No names found",
"/",
"i",
",",
"gitToken",
":",
"process",
".",
"env",
".",
"GH_TOKEN",
",",
"npmToken",
":",
"process",
".",
"env",
".",
"NPM_TOKEN",
"}",
";",
"}"
] | Generates environment options for a commit
@param commitMsg
the commit message (optional)
@returns {___anonymous1480_2103} | [
"Generates",
"environment",
"options",
"for",
"a",
"commit"
] | 1a2ff42796e77f47f9590992c014fee461aad80b | https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/lib/coopt.js#L64-L89 |
54,326 | ugate/releasebot | lib/coopt.js | genTaskOptions | function genTaskOptions(env) {
var mp = env.pluginName + ': ';
return {
name : '<%= commit.versionTag %>',
pkgCurrVerBumpMsg : mp
+ 'Updating <%= env.pkgPath %> version to match release version <%= commit.version %> <%= commit.skipTaskGen(options.releaseSkipTasks) %>',
pkgNextVerBumpMsg : mp
+ 'Bumping <%= env.pkgPath %> version to <%= commit.next.version %> <%= commit.skipTaskGen(options.releaseSkipTasks) %>',
distBranchPubMsg : mp + 'Publishing <%= commit.version %> <%= commit.skipTaskGen(options.releaseSkipTasks) %>',
pkgJsonReplacer : null,
pkgJsonSpace : 2,
gitHostname : github.hostname,
repoName : 'origin',
repoUser : env.pluginName,
repoEmail : env.pluginName + '@' + (process.env.TRAVIS_BUILD_NUMBER ? 'travis-ci.org' : 'example.org'),
chgLog : 'HISTORY.md',
authors : 'AUTHORS.md',
chgLogLineFormat : ' * %s',
chgLogRequired : true,
chgLogSkipRegExps : [ mp ],
authorsRequired : false,
authorsSkipLineRegExp : null,
distBranch : 'gh-pages',
distDir : 'dist',
distBranchCreateRegExp : /Couldn't find remote ref/i,
distExcludeDirRegExp : /.?node_modules.?/gmi,
distExcludeFileRegExp : /.?\.zip|tar.?/gmi,
distAssetCompressRatio : 9,
distAssetDir : '..',
distAssetUpdateFunction : null,
distAssetUpdateFiles : [],
distBranchUpdateFunction : null,
distBranchUpdateFiles : [],
rollbackStrategy : 'queue',
rollbackAsyncTimeout : 60000,
asyncTimeout : 60000,
releaseSkipTasks : [ 'ci' ],
npmTag : '',
npmRegistryURL : 'https://registry.npmjs.org'
};
} | javascript | function genTaskOptions(env) {
var mp = env.pluginName + ': ';
return {
name : '<%= commit.versionTag %>',
pkgCurrVerBumpMsg : mp
+ 'Updating <%= env.pkgPath %> version to match release version <%= commit.version %> <%= commit.skipTaskGen(options.releaseSkipTasks) %>',
pkgNextVerBumpMsg : mp
+ 'Bumping <%= env.pkgPath %> version to <%= commit.next.version %> <%= commit.skipTaskGen(options.releaseSkipTasks) %>',
distBranchPubMsg : mp + 'Publishing <%= commit.version %> <%= commit.skipTaskGen(options.releaseSkipTasks) %>',
pkgJsonReplacer : null,
pkgJsonSpace : 2,
gitHostname : github.hostname,
repoName : 'origin',
repoUser : env.pluginName,
repoEmail : env.pluginName + '@' + (process.env.TRAVIS_BUILD_NUMBER ? 'travis-ci.org' : 'example.org'),
chgLog : 'HISTORY.md',
authors : 'AUTHORS.md',
chgLogLineFormat : ' * %s',
chgLogRequired : true,
chgLogSkipRegExps : [ mp ],
authorsRequired : false,
authorsSkipLineRegExp : null,
distBranch : 'gh-pages',
distDir : 'dist',
distBranchCreateRegExp : /Couldn't find remote ref/i,
distExcludeDirRegExp : /.?node_modules.?/gmi,
distExcludeFileRegExp : /.?\.zip|tar.?/gmi,
distAssetCompressRatio : 9,
distAssetDir : '..',
distAssetUpdateFunction : null,
distAssetUpdateFiles : [],
distBranchUpdateFunction : null,
distBranchUpdateFiles : [],
rollbackStrategy : 'queue',
rollbackAsyncTimeout : 60000,
asyncTimeout : 60000,
releaseSkipTasks : [ 'ci' ],
npmTag : '',
npmRegistryURL : 'https://registry.npmjs.org'
};
} | [
"function",
"genTaskOptions",
"(",
"env",
")",
"{",
"var",
"mp",
"=",
"env",
".",
"pluginName",
"+",
"': '",
";",
"return",
"{",
"name",
":",
"'<%= commit.versionTag %>'",
",",
"pkgCurrVerBumpMsg",
":",
"mp",
"+",
"'Updating <%= env.pkgPath %> version to match release version <%= commit.version %> <%= commit.skipTaskGen(options.releaseSkipTasks) %>'",
",",
"pkgNextVerBumpMsg",
":",
"mp",
"+",
"'Bumping <%= env.pkgPath %> version to <%= commit.next.version %> <%= commit.skipTaskGen(options.releaseSkipTasks) %>'",
",",
"distBranchPubMsg",
":",
"mp",
"+",
"'Publishing <%= commit.version %> <%= commit.skipTaskGen(options.releaseSkipTasks) %>'",
",",
"pkgJsonReplacer",
":",
"null",
",",
"pkgJsonSpace",
":",
"2",
",",
"gitHostname",
":",
"github",
".",
"hostname",
",",
"repoName",
":",
"'origin'",
",",
"repoUser",
":",
"env",
".",
"pluginName",
",",
"repoEmail",
":",
"env",
".",
"pluginName",
"+",
"'@'",
"+",
"(",
"process",
".",
"env",
".",
"TRAVIS_BUILD_NUMBER",
"?",
"'travis-ci.org'",
":",
"'example.org'",
")",
",",
"chgLog",
":",
"'HISTORY.md'",
",",
"authors",
":",
"'AUTHORS.md'",
",",
"chgLogLineFormat",
":",
"' * %s'",
",",
"chgLogRequired",
":",
"true",
",",
"chgLogSkipRegExps",
":",
"[",
"mp",
"]",
",",
"authorsRequired",
":",
"false",
",",
"authorsSkipLineRegExp",
":",
"null",
",",
"distBranch",
":",
"'gh-pages'",
",",
"distDir",
":",
"'dist'",
",",
"distBranchCreateRegExp",
":",
"/",
"Couldn't find remote ref",
"/",
"i",
",",
"distExcludeDirRegExp",
":",
"/",
".?node_modules.?",
"/",
"gmi",
",",
"distExcludeFileRegExp",
":",
"/",
".?\\.zip|tar.?",
"/",
"gmi",
",",
"distAssetCompressRatio",
":",
"9",
",",
"distAssetDir",
":",
"'..'",
",",
"distAssetUpdateFunction",
":",
"null",
",",
"distAssetUpdateFiles",
":",
"[",
"]",
",",
"distBranchUpdateFunction",
":",
"null",
",",
"distBranchUpdateFiles",
":",
"[",
"]",
",",
"rollbackStrategy",
":",
"'queue'",
",",
"rollbackAsyncTimeout",
":",
"60000",
",",
"asyncTimeout",
":",
"60000",
",",
"releaseSkipTasks",
":",
"[",
"'ci'",
"]",
",",
"npmTag",
":",
"''",
",",
"npmRegistryURL",
":",
"'https://registry.npmjs.org'",
"}",
";",
"}"
] | Generates task options
@param env
the environment options
@returns {___anonymous3636_5131} | [
"Generates",
"task",
"options"
] | 1a2ff42796e77f47f9590992c014fee461aad80b | https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/lib/coopt.js#L98-L138 |
54,327 | ugate/releasebot | lib/coopt.js | getLineReplRegExp | function getLineReplRegExp(rxa, tasks) {
var r = '', sf = null;
function rxItem(o, i, a) {
var s = util.isRegExp(o) ? o.source : escapeRegExp(o);
if (s) {
r += (sf ? sf(true, s) : '(?:' + s + ')') + (i < (a.length - 1) ? '|' : '');
}
}
if (Array.isArray(rxa) && rxa.length) {
rxa.forEach(rxItem);
// join tasks with or clause
r += '|';
}
var tsks = Array.isArray(tasks) ? tasks : [];
if (tsks.indexOf(chgLog) < 0) {
tsks.push(chgLog);
}
sf = committer.skipTaskGen;
tsks.forEach(rxItem);
return new RegExp('^.*(' + r + ').*$\n?\r?', 'gmi');
} | javascript | function getLineReplRegExp(rxa, tasks) {
var r = '', sf = null;
function rxItem(o, i, a) {
var s = util.isRegExp(o) ? o.source : escapeRegExp(o);
if (s) {
r += (sf ? sf(true, s) : '(?:' + s + ')') + (i < (a.length - 1) ? '|' : '');
}
}
if (Array.isArray(rxa) && rxa.length) {
rxa.forEach(rxItem);
// join tasks with or clause
r += '|';
}
var tsks = Array.isArray(tasks) ? tasks : [];
if (tsks.indexOf(chgLog) < 0) {
tsks.push(chgLog);
}
sf = committer.skipTaskGen;
tsks.forEach(rxItem);
return new RegExp('^.*(' + r + ').*$\n?\r?', 'gmi');
} | [
"function",
"getLineReplRegExp",
"(",
"rxa",
",",
"tasks",
")",
"{",
"var",
"r",
"=",
"''",
",",
"sf",
"=",
"null",
";",
"function",
"rxItem",
"(",
"o",
",",
"i",
",",
"a",
")",
"{",
"var",
"s",
"=",
"util",
".",
"isRegExp",
"(",
"o",
")",
"?",
"o",
".",
"source",
":",
"escapeRegExp",
"(",
"o",
")",
";",
"if",
"(",
"s",
")",
"{",
"r",
"+=",
"(",
"sf",
"?",
"sf",
"(",
"true",
",",
"s",
")",
":",
"'(?:'",
"+",
"s",
"+",
"')'",
")",
"+",
"(",
"i",
"<",
"(",
"a",
".",
"length",
"-",
"1",
")",
"?",
"'|'",
":",
"''",
")",
";",
"}",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"rxa",
")",
"&&",
"rxa",
".",
"length",
")",
"{",
"rxa",
".",
"forEach",
"(",
"rxItem",
")",
";",
"// join tasks with or clause",
"r",
"+=",
"'|'",
";",
"}",
"var",
"tsks",
"=",
"Array",
".",
"isArray",
"(",
"tasks",
")",
"?",
"tasks",
":",
"[",
"]",
";",
"if",
"(",
"tsks",
".",
"indexOf",
"(",
"chgLog",
")",
"<",
"0",
")",
"{",
"tsks",
".",
"push",
"(",
"chgLog",
")",
";",
"}",
"sf",
"=",
"committer",
".",
"skipTaskGen",
";",
"tsks",
".",
"forEach",
"(",
"rxItem",
")",
";",
"return",
"new",
"RegExp",
"(",
"'^.*('",
"+",
"r",
"+",
"').*$\\n?\\r?'",
",",
"'gmi'",
")",
";",
"}"
] | Creates a regular expression for replacing line items
@param rxa
the optional {Array} of {RegExp} or strings (strings will be
escaped) that will be included in the final expression
(concatenated via OR in final expression)
@param tasks
an optional {Array} of task names to replace using the generated
sequence syntax (concatenated via OR in final expression)
@returns {RegExp} the generated regular expression | [
"Creates",
"a",
"regular",
"expression",
"for",
"replacing",
"line",
"items"
] | 1a2ff42796e77f47f9590992c014fee461aad80b | https://github.com/ugate/releasebot/blob/1a2ff42796e77f47f9590992c014fee461aad80b/lib/coopt.js#L223-L243 |
54,328 | hoodiehq-archive/hoodie.admin.js | src/hoodie.admin.js | applyExtensions | function applyExtensions(hoodie) {
for (var i = 0; i < extensions.length; i++) {
extensions[i](hoodie);
}
} | javascript | function applyExtensions(hoodie) {
for (var i = 0; i < extensions.length; i++) {
extensions[i](hoodie);
}
} | [
"function",
"applyExtensions",
"(",
"hoodie",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"extensions",
".",
"length",
";",
"i",
"++",
")",
"{",
"extensions",
"[",
"i",
"]",
"(",
"hoodie",
")",
";",
"}",
"}"
] | detect available extensions and attach to Hoodie Object. | [
"detect",
"available",
"extensions",
"and",
"attach",
"to",
"Hoodie",
"Object",
"."
] | eb3444d8fb1df6cbff112bb6dac17f0213c3de93 | https://github.com/hoodiehq-archive/hoodie.admin.js/blob/eb3444d8fb1df6cbff112bb6dac17f0213c3de93/src/hoodie.admin.js#L108-L112 |
54,329 | commenthol/streamss | lib/writearray.js | WriteArray | function WriteArray (options, callback) {
var self = this
if (!(this instanceof WriteArray)) {
return new WriteArray(options, callback)
}
if (typeof options === 'function') {
callback = options
options = {}
}
options = Object.assign({}, options)
Writable.call(self, options)
self.array = []
self.callback = callback
self.on('pipe', function (src) {
src.on('error', function (err) {
self.callback(err)
})
})
self.on('finish', function () {
self.callback(null, self.array)
})
return self
} | javascript | function WriteArray (options, callback) {
var self = this
if (!(this instanceof WriteArray)) {
return new WriteArray(options, callback)
}
if (typeof options === 'function') {
callback = options
options = {}
}
options = Object.assign({}, options)
Writable.call(self, options)
self.array = []
self.callback = callback
self.on('pipe', function (src) {
src.on('error', function (err) {
self.callback(err)
})
})
self.on('finish', function () {
self.callback(null, self.array)
})
return self
} | [
"function",
"WriteArray",
"(",
"options",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"WriteArray",
")",
")",
"{",
"return",
"new",
"WriteArray",
"(",
"options",
",",
"callback",
")",
"}",
"if",
"(",
"typeof",
"options",
"===",
"'function'",
")",
"{",
"callback",
"=",
"options",
"options",
"=",
"{",
"}",
"}",
"options",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
")",
"Writable",
".",
"call",
"(",
"self",
",",
"options",
")",
"self",
".",
"array",
"=",
"[",
"]",
"self",
".",
"callback",
"=",
"callback",
"self",
".",
"on",
"(",
"'pipe'",
",",
"function",
"(",
"src",
")",
"{",
"src",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"self",
".",
"callback",
"(",
"err",
")",
"}",
")",
"}",
")",
"self",
".",
"on",
"(",
"'finish'",
",",
"function",
"(",
")",
"{",
"self",
".",
"callback",
"(",
"null",
",",
"self",
".",
"array",
")",
"}",
")",
"return",
"self",
"}"
] | Write stream into an Array
@constructor
@param {Object} [options] - Stream Options `{encoding, highWaterMark, decodeStrings, objectMode, ...}`
@param {Function} callback - callback function `function({Error}err, {Array}array)` called on `finish` or `error` event.
@return {Writable} A writable stream | [
"Write",
"stream",
"into",
"an",
"Array"
] | cfef5d0ed30c7efe002018886e2e843c91d3558f | https://github.com/commenthol/streamss/blob/cfef5d0ed30c7efe002018886e2e843c91d3558f/lib/writearray.js#L19-L48 |
54,330 | angeloocana/joj-core | dist/Move.js | getGameAfterMoves | function getGameAfterMoves(game, moves) {
return moves.reduce(function (lastGame, move) {
return getGameAfterMove(lastGame, move);
}, game);
} | javascript | function getGameAfterMoves(game, moves) {
return moves.reduce(function (lastGame, move) {
return getGameAfterMove(lastGame, move);
}, game);
} | [
"function",
"getGameAfterMoves",
"(",
"game",
",",
"moves",
")",
"{",
"return",
"moves",
".",
"reduce",
"(",
"function",
"(",
"lastGame",
",",
"move",
")",
"{",
"return",
"getGameAfterMove",
"(",
"lastGame",
",",
"move",
")",
";",
"}",
",",
"game",
")",
";",
"}"
] | Get game after n moves. | [
"Get",
"game",
"after",
"n",
"moves",
"."
] | 14bc7801c004271cefafff6cc0abb0c3173c805a | https://github.com/angeloocana/joj-core/blob/14bc7801c004271cefafff6cc0abb0c3173c805a/dist/Move.js#L154-L158 |
54,331 | thotzl/grunt-css-statistics | tasks/cssstats.js | sortFontSizes | function sortFontSizes(fontSizes) {
var r = {};
var temp = [];
var size = 0;
var biggest = 0;
for (var prop in fontSizes) {
if (fontSizes.hasOwnProperty(prop)) {
size++;
var val = prop.replace(/[^0-9.\/]/g, '').replace(/\/[0-9]/g, '');
if (prop.indexOf('%') > -1) {
val = 16 / 100 * val;
}
if (prop.indexOf('em') > -1
|| prop.indexOf('rem') > -1
|| prop.indexOf('vw') > -1
|| prop.indexOf('vh') > -1) {
val = 16 * val;
}
if (val === '') {
val = prop;
}
biggest = val > biggest ? val : biggest;
if (/[0-9.]/g.test(val)) {
temp.push({
viewSizePx: val,
viewSizeStr: '',
cssSize: prop,
amount: fontSizes[prop]
});
} else {
temp.push({
viewSizePx: 0,
viewSizeStr: val,
cssSize: prop,
amount: fontSizes[prop]
});
}
}
}
r = temp.sort(function (a, b) {
return b.viewSizePx - a.viewSizePx;
});
return r;
} | javascript | function sortFontSizes(fontSizes) {
var r = {};
var temp = [];
var size = 0;
var biggest = 0;
for (var prop in fontSizes) {
if (fontSizes.hasOwnProperty(prop)) {
size++;
var val = prop.replace(/[^0-9.\/]/g, '').replace(/\/[0-9]/g, '');
if (prop.indexOf('%') > -1) {
val = 16 / 100 * val;
}
if (prop.indexOf('em') > -1
|| prop.indexOf('rem') > -1
|| prop.indexOf('vw') > -1
|| prop.indexOf('vh') > -1) {
val = 16 * val;
}
if (val === '') {
val = prop;
}
biggest = val > biggest ? val : biggest;
if (/[0-9.]/g.test(val)) {
temp.push({
viewSizePx: val,
viewSizeStr: '',
cssSize: prop,
amount: fontSizes[prop]
});
} else {
temp.push({
viewSizePx: 0,
viewSizeStr: val,
cssSize: prop,
amount: fontSizes[prop]
});
}
}
}
r = temp.sort(function (a, b) {
return b.viewSizePx - a.viewSizePx;
});
return r;
} | [
"function",
"sortFontSizes",
"(",
"fontSizes",
")",
"{",
"var",
"r",
"=",
"{",
"}",
";",
"var",
"temp",
"=",
"[",
"]",
";",
"var",
"size",
"=",
"0",
";",
"var",
"biggest",
"=",
"0",
";",
"for",
"(",
"var",
"prop",
"in",
"fontSizes",
")",
"{",
"if",
"(",
"fontSizes",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"{",
"size",
"++",
";",
"var",
"val",
"=",
"prop",
".",
"replace",
"(",
"/",
"[^0-9.\\/]",
"/",
"g",
",",
"''",
")",
".",
"replace",
"(",
"/",
"\\/[0-9]",
"/",
"g",
",",
"''",
")",
";",
"if",
"(",
"prop",
".",
"indexOf",
"(",
"'%'",
")",
">",
"-",
"1",
")",
"{",
"val",
"=",
"16",
"/",
"100",
"*",
"val",
";",
"}",
"if",
"(",
"prop",
".",
"indexOf",
"(",
"'em'",
")",
">",
"-",
"1",
"||",
"prop",
".",
"indexOf",
"(",
"'rem'",
")",
">",
"-",
"1",
"||",
"prop",
".",
"indexOf",
"(",
"'vw'",
")",
">",
"-",
"1",
"||",
"prop",
".",
"indexOf",
"(",
"'vh'",
")",
">",
"-",
"1",
")",
"{",
"val",
"=",
"16",
"*",
"val",
";",
"}",
"if",
"(",
"val",
"===",
"''",
")",
"{",
"val",
"=",
"prop",
";",
"}",
"biggest",
"=",
"val",
">",
"biggest",
"?",
"val",
":",
"biggest",
";",
"if",
"(",
"/",
"[0-9.]",
"/",
"g",
".",
"test",
"(",
"val",
")",
")",
"{",
"temp",
".",
"push",
"(",
"{",
"viewSizePx",
":",
"val",
",",
"viewSizeStr",
":",
"''",
",",
"cssSize",
":",
"prop",
",",
"amount",
":",
"fontSizes",
"[",
"prop",
"]",
"}",
")",
";",
"}",
"else",
"{",
"temp",
".",
"push",
"(",
"{",
"viewSizePx",
":",
"0",
",",
"viewSizeStr",
":",
"val",
",",
"cssSize",
":",
"prop",
",",
"amount",
":",
"fontSizes",
"[",
"prop",
"]",
"}",
")",
";",
"}",
"}",
"}",
"r",
"=",
"temp",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"b",
".",
"viewSizePx",
"-",
"a",
".",
"viewSizePx",
";",
"}",
")",
";",
"return",
"r",
";",
"}"
] | sorts the font sizes from big too small
@param fontSizes
@returns {{}} | [
"sorts",
"the",
"font",
"sizes",
"from",
"big",
"too",
"small"
] | 6b0c9057bded1d5df20d43baaa015b51926888ad | https://github.com/thotzl/grunt-css-statistics/blob/6b0c9057bded1d5df20d43baaa015b51926888ad/tasks/cssstats.js#L238-L294 |
54,332 | thotzl/grunt-css-statistics | tasks/cssstats.js | getValueCount | function getValueCount(values, property) {
var arr = {};
property = property ? property : '';
if (!values) {
grunt.log.writeln(app.chalkWarn('no ' + property + ' defined in your css'));
return arr;
}
values.forEach(function (v) {
v = v.replace(/['"]/g, '');
if (arr.hasOwnProperty(v)) {
arr[v] = arr[v] + 1;
} else {
arr[v] = 1;
}
});
return arr;
} | javascript | function getValueCount(values, property) {
var arr = {};
property = property ? property : '';
if (!values) {
grunt.log.writeln(app.chalkWarn('no ' + property + ' defined in your css'));
return arr;
}
values.forEach(function (v) {
v = v.replace(/['"]/g, '');
if (arr.hasOwnProperty(v)) {
arr[v] = arr[v] + 1;
} else {
arr[v] = 1;
}
});
return arr;
} | [
"function",
"getValueCount",
"(",
"values",
",",
"property",
")",
"{",
"var",
"arr",
"=",
"{",
"}",
";",
"property",
"=",
"property",
"?",
"property",
":",
"''",
";",
"if",
"(",
"!",
"values",
")",
"{",
"grunt",
".",
"log",
".",
"writeln",
"(",
"app",
".",
"chalkWarn",
"(",
"'no '",
"+",
"property",
"+",
"' defined in your css'",
")",
")",
";",
"return",
"arr",
";",
"}",
"values",
".",
"forEach",
"(",
"function",
"(",
"v",
")",
"{",
"v",
"=",
"v",
".",
"replace",
"(",
"/",
"['\"]",
"/",
"g",
",",
"''",
")",
";",
"if",
"(",
"arr",
".",
"hasOwnProperty",
"(",
"v",
")",
")",
"{",
"arr",
"[",
"v",
"]",
"=",
"arr",
"[",
"v",
"]",
"+",
"1",
";",
"}",
"else",
"{",
"arr",
"[",
"v",
"]",
"=",
"1",
";",
"}",
"}",
")",
";",
"return",
"arr",
";",
"}"
] | sets the css property as key
set the amount of the property as value
@param values
@returns {{}} | [
"sets",
"the",
"css",
"property",
"as",
"key",
"set",
"the",
"amount",
"of",
"the",
"property",
"as",
"value"
] | 6b0c9057bded1d5df20d43baaa015b51926888ad | https://github.com/thotzl/grunt-css-statistics/blob/6b0c9057bded1d5df20d43baaa015b51926888ad/tasks/cssstats.js#L303-L325 |
54,333 | raineorshine/striate | index.js | deindentBlocks | function deindentBlocks(input) {
var indent = detectIndent(input).indent
return input.replace(regex.blocks, function (match, start, body, end) {
return start + deindent(body, indent) + end
})
} | javascript | function deindentBlocks(input) {
var indent = detectIndent(input).indent
return input.replace(regex.blocks, function (match, start, body, end) {
return start + deindent(body, indent) + end
})
} | [
"function",
"deindentBlocks",
"(",
"input",
")",
"{",
"var",
"indent",
"=",
"detectIndent",
"(",
"input",
")",
".",
"indent",
"return",
"input",
".",
"replace",
"(",
"regex",
".",
"blocks",
",",
"function",
"(",
"match",
",",
"start",
",",
"body",
",",
"end",
")",
"{",
"return",
"start",
"+",
"deindent",
"(",
"body",
",",
"indent",
")",
"+",
"end",
"}",
")",
"}"
] | replace blocks as long as there is a match | [
"replace",
"blocks",
"as",
"long",
"as",
"there",
"is",
"a",
"match"
] | 44819f3fc248e7cb02ceac7e2f4ff792c69bd130 | https://github.com/raineorshine/striate/blob/44819f3fc248e7cb02ceac7e2f4ff792c69bd130/index.js#L18-L23 |
54,334 | deepjs/deep-restful | lib/relations.js | function() {
var self = this;
var relations = utils.argToArr.call(arguments);
var func = function(s, e) {
if(!s)
return s;
var alls = [];
var doGet = function(entry) {
if (!entry.schema || !entry.schema.links)
return;
var r = {
value: entry.value,
schema: entry.schema
};
querier.query(entry.schema.links, "./*?rel=in=(" + relations.join(",") + ")")
.forEach(function(relation) {
//console.log("getRelations : got : ", relation)
var path = utils.interpret(relation.href, entry.value);
var parsed = utils.parseRequest(path);
var wrap = {
rel: relation,
href: parsed
};
r[relation] = wrap;
alls.push(protoc.get(parsed, {
wrap: wrap
}));
});
}
if(s._deep_array_)
s.forEach(doGet);
else if(s._deep_query_node_)
doGet(s);
if (alls.length)
return prom.all(alls);
return null;
};
func._isDone_ = true;
return self._enqueue(func);
} | javascript | function() {
var self = this;
var relations = utils.argToArr.call(arguments);
var func = function(s, e) {
if(!s)
return s;
var alls = [];
var doGet = function(entry) {
if (!entry.schema || !entry.schema.links)
return;
var r = {
value: entry.value,
schema: entry.schema
};
querier.query(entry.schema.links, "./*?rel=in=(" + relations.join(",") + ")")
.forEach(function(relation) {
//console.log("getRelations : got : ", relation)
var path = utils.interpret(relation.href, entry.value);
var parsed = utils.parseRequest(path);
var wrap = {
rel: relation,
href: parsed
};
r[relation] = wrap;
alls.push(protoc.get(parsed, {
wrap: wrap
}));
});
}
if(s._deep_array_)
s.forEach(doGet);
else if(s._deep_query_node_)
doGet(s);
if (alls.length)
return prom.all(alls);
return null;
};
func._isDone_ = true;
return self._enqueue(func);
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"relations",
"=",
"utils",
".",
"argToArr",
".",
"call",
"(",
"arguments",
")",
";",
"var",
"func",
"=",
"function",
"(",
"s",
",",
"e",
")",
"{",
"if",
"(",
"!",
"s",
")",
"return",
"s",
";",
"var",
"alls",
"=",
"[",
"]",
";",
"var",
"doGet",
"=",
"function",
"(",
"entry",
")",
"{",
"if",
"(",
"!",
"entry",
".",
"schema",
"||",
"!",
"entry",
".",
"schema",
".",
"links",
")",
"return",
";",
"var",
"r",
"=",
"{",
"value",
":",
"entry",
".",
"value",
",",
"schema",
":",
"entry",
".",
"schema",
"}",
";",
"querier",
".",
"query",
"(",
"entry",
".",
"schema",
".",
"links",
",",
"\"./*?rel=in=(\"",
"+",
"relations",
".",
"join",
"(",
"\",\"",
")",
"+",
"\")\"",
")",
".",
"forEach",
"(",
"function",
"(",
"relation",
")",
"{",
"//console.log(\"getRelations : got : \", relation)",
"var",
"path",
"=",
"utils",
".",
"interpret",
"(",
"relation",
".",
"href",
",",
"entry",
".",
"value",
")",
";",
"var",
"parsed",
"=",
"utils",
".",
"parseRequest",
"(",
"path",
")",
";",
"var",
"wrap",
"=",
"{",
"rel",
":",
"relation",
",",
"href",
":",
"parsed",
"}",
";",
"r",
"[",
"relation",
"]",
"=",
"wrap",
";",
"alls",
".",
"push",
"(",
"protoc",
".",
"get",
"(",
"parsed",
",",
"{",
"wrap",
":",
"wrap",
"}",
")",
")",
";",
"}",
")",
";",
"}",
"if",
"(",
"s",
".",
"_deep_array_",
")",
"s",
".",
"forEach",
"(",
"doGet",
")",
";",
"else",
"if",
"(",
"s",
".",
"_deep_query_node_",
")",
"doGet",
"(",
"s",
")",
";",
"if",
"(",
"alls",
".",
"length",
")",
"return",
"prom",
".",
"all",
"(",
"alls",
")",
";",
"return",
"null",
";",
"}",
";",
"func",
".",
"_isDone_",
"=",
"true",
";",
"return",
"self",
".",
"_enqueue",
"(",
"func",
")",
";",
"}"
] | retrieve relations described in schema links.
Inject as success in chain an object that hold each relation, their result and the associated (parsed) request object
@method getRelations
@chainable
@example
var schema3 = {
properties:{
id:{ type:"string", required:false, indexed:true },
label:{ type:"string" },
plantId:{ type:"string" },
userId:{ type:"string" }
},
links:[
{
href:"plant::{ plantId }",
rel:"plant"
},
{
href:"user::{ userId }",
rel:"user"
}
]
}
____________________________
deep.nodes({
plantId:"e1",
userId:"e1",
label:"hello"
}, schema3)
.getRelations("plant", "user")
.log();
@param a list of string arguments that gives which relation to retrieve
@return {NodesChain} this | [
"retrieve",
"relations",
"described",
"in",
"schema",
"links",
"."
] | 44c5e1e5526a821522ab5e3004f66ffc7840f551 | https://github.com/deepjs/deep-restful/blob/44c5e1e5526a821522ab5e3004f66ffc7840f551/lib/relations.js#L175-L214 |
|
54,335 | deepjs/deep-restful | lib/relations.js | function(map, delimitter) {
if (!delimitter)
delimitter = ".";
var self = this;
var relations = [];
for (var i in map)
relations.push(i);
//console.log("mapRelations : relations : ", relations);
var func = function(s, e) {
if(!s || (!s._deep_query_node_ && !s._deep_array_))
return s;
var doMap = function(entry) {
if (!entry.schema || !entry.schema.links)
return;
var alls = [];
querier.query(entry.schema.links, "./*?rel=in=(" + relations.join(",") + ")")
.forEach(function(relation) {
//console.log("do map relations on : ", relation);
var path = utils.interpret(relation.href, entry.value);
alls.push(protoc.get(path, {
defaultProtocole: "json",
wrap: {
path: map[relation.rel]
}
}));
});
var d = prom.all(alls)
.done(function(results) {
//console.log("mapRelations : results : ");
//console.log(JSON.stringify(results));
results.forEach(function(r) {
//console.log("do : ", r, " - on : ", entry.value)
utils.toPath(entry.value, r.path, r.result, delimitter);
});
return results;
});
promises.push(d);
};
var promises = [];
if(s._deep_array_)
s.forEach(doMap);
else
doMap(s);
if (!promises.length)
return s;
return prom.all(promises)
.done(function() {
return s;
});
};
func._isDone_ = true;
return self._enqueue(func);
} | javascript | function(map, delimitter) {
if (!delimitter)
delimitter = ".";
var self = this;
var relations = [];
for (var i in map)
relations.push(i);
//console.log("mapRelations : relations : ", relations);
var func = function(s, e) {
if(!s || (!s._deep_query_node_ && !s._deep_array_))
return s;
var doMap = function(entry) {
if (!entry.schema || !entry.schema.links)
return;
var alls = [];
querier.query(entry.schema.links, "./*?rel=in=(" + relations.join(",") + ")")
.forEach(function(relation) {
//console.log("do map relations on : ", relation);
var path = utils.interpret(relation.href, entry.value);
alls.push(protoc.get(path, {
defaultProtocole: "json",
wrap: {
path: map[relation.rel]
}
}));
});
var d = prom.all(alls)
.done(function(results) {
//console.log("mapRelations : results : ");
//console.log(JSON.stringify(results));
results.forEach(function(r) {
//console.log("do : ", r, " - on : ", entry.value)
utils.toPath(entry.value, r.path, r.result, delimitter);
});
return results;
});
promises.push(d);
};
var promises = [];
if(s._deep_array_)
s.forEach(doMap);
else
doMap(s);
if (!promises.length)
return s;
return prom.all(promises)
.done(function() {
return s;
});
};
func._isDone_ = true;
return self._enqueue(func);
} | [
"function",
"(",
"map",
",",
"delimitter",
")",
"{",
"if",
"(",
"!",
"delimitter",
")",
"delimitter",
"=",
"\".\"",
";",
"var",
"self",
"=",
"this",
";",
"var",
"relations",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"in",
"map",
")",
"relations",
".",
"push",
"(",
"i",
")",
";",
"//console.log(\"mapRelations : relations : \", relations);",
"var",
"func",
"=",
"function",
"(",
"s",
",",
"e",
")",
"{",
"if",
"(",
"!",
"s",
"||",
"(",
"!",
"s",
".",
"_deep_query_node_",
"&&",
"!",
"s",
".",
"_deep_array_",
")",
")",
"return",
"s",
";",
"var",
"doMap",
"=",
"function",
"(",
"entry",
")",
"{",
"if",
"(",
"!",
"entry",
".",
"schema",
"||",
"!",
"entry",
".",
"schema",
".",
"links",
")",
"return",
";",
"var",
"alls",
"=",
"[",
"]",
";",
"querier",
".",
"query",
"(",
"entry",
".",
"schema",
".",
"links",
",",
"\"./*?rel=in=(\"",
"+",
"relations",
".",
"join",
"(",
"\",\"",
")",
"+",
"\")\"",
")",
".",
"forEach",
"(",
"function",
"(",
"relation",
")",
"{",
"//console.log(\"do map relations on : \", relation);",
"var",
"path",
"=",
"utils",
".",
"interpret",
"(",
"relation",
".",
"href",
",",
"entry",
".",
"value",
")",
";",
"alls",
".",
"push",
"(",
"protoc",
".",
"get",
"(",
"path",
",",
"{",
"defaultProtocole",
":",
"\"json\"",
",",
"wrap",
":",
"{",
"path",
":",
"map",
"[",
"relation",
".",
"rel",
"]",
"}",
"}",
")",
")",
";",
"}",
")",
";",
"var",
"d",
"=",
"prom",
".",
"all",
"(",
"alls",
")",
".",
"done",
"(",
"function",
"(",
"results",
")",
"{",
"//console.log(\"mapRelations : results : \");",
"//console.log(JSON.stringify(results));",
"results",
".",
"forEach",
"(",
"function",
"(",
"r",
")",
"{",
"//console.log(\"do : \", r, \" - on : \", entry.value)",
"utils",
".",
"toPath",
"(",
"entry",
".",
"value",
",",
"r",
".",
"path",
",",
"r",
".",
"result",
",",
"delimitter",
")",
";",
"}",
")",
";",
"return",
"results",
";",
"}",
")",
";",
"promises",
".",
"push",
"(",
"d",
")",
";",
"}",
";",
"var",
"promises",
"=",
"[",
"]",
";",
"if",
"(",
"s",
".",
"_deep_array_",
")",
"s",
".",
"forEach",
"(",
"doMap",
")",
";",
"else",
"doMap",
"(",
"s",
")",
";",
"if",
"(",
"!",
"promises",
".",
"length",
")",
"return",
"s",
";",
"return",
"prom",
".",
"all",
"(",
"promises",
")",
".",
"done",
"(",
"function",
"(",
")",
"{",
"return",
"s",
";",
"}",
")",
";",
"}",
";",
"func",
".",
"_isDone_",
"=",
"true",
";",
"return",
"self",
".",
"_enqueue",
"(",
"func",
")",
";",
"}"
] | map relations in current entries values
@method mapRelations
@chainable
@param {Object} map the map (see examples)
@param {String} delimitter (optional) the paths delimitter
@return {NodesChain} this
@example
var schema3 = {
properties:{
id:{ type:"string", required:false, indexed:true },
label:{ type:"string" },
plantId:{ type:"string" },
userId:{ type:"string" }
},
links:[
{
href:"plant::{ plantId }",
rel:"plant"
},
{
href:"user::{ userId }",
rel:"user"
}
]
};
deep.nodes({
plantId:"e1",
userId:"e1",
label:"hello"
}, schema3)
.mapRelations({
user:"relations.user",
plant:"relations.plant"
})
.logValues(); | [
"map",
"relations",
"in",
"current",
"entries",
"values"
] | 44c5e1e5526a821522ab5e3004f66ffc7840f551 | https://github.com/deepjs/deep-restful/blob/44c5e1e5526a821522ab5e3004f66ffc7840f551/lib/relations.js#L255-L307 |
|
54,336 | posttool/currentcms | lib/public/js/browse.js | create_header_col | function create_header_col(m) {
var $e = $$('hcol nowrap');
$e.css({width: p});
if (m.options) {
$e.css(m.options);
}
$e.text(m.name);
var hilight = function () {
if (!order)
return;
if (order == m.name)
{
$e.addClass('order asc');
$lh = $e;
}
else if (order.substring(1) == m.name)
{
$e.addClass('order desc');
$lh = $e;
}
}
hilight();
$e.click(function () {
if (order == m.name) {
order = '-' + m.name;
}
else {
order = m.name;
}
zcookie.set('order-'+type, order);
if ($lh)
$lh.removeClass('order asc desc');
hilight();
$lh = $e;
request_data();
});
return $e;
} | javascript | function create_header_col(m) {
var $e = $$('hcol nowrap');
$e.css({width: p});
if (m.options) {
$e.css(m.options);
}
$e.text(m.name);
var hilight = function () {
if (!order)
return;
if (order == m.name)
{
$e.addClass('order asc');
$lh = $e;
}
else if (order.substring(1) == m.name)
{
$e.addClass('order desc');
$lh = $e;
}
}
hilight();
$e.click(function () {
if (order == m.name) {
order = '-' + m.name;
}
else {
order = m.name;
}
zcookie.set('order-'+type, order);
if ($lh)
$lh.removeClass('order asc desc');
hilight();
$lh = $e;
request_data();
});
return $e;
} | [
"function",
"create_header_col",
"(",
"m",
")",
"{",
"var",
"$e",
"=",
"$$",
"(",
"'hcol nowrap'",
")",
";",
"$e",
".",
"css",
"(",
"{",
"width",
":",
"p",
"}",
")",
";",
"if",
"(",
"m",
".",
"options",
")",
"{",
"$e",
".",
"css",
"(",
"m",
".",
"options",
")",
";",
"}",
"$e",
".",
"text",
"(",
"m",
".",
"name",
")",
";",
"var",
"hilight",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"order",
")",
"return",
";",
"if",
"(",
"order",
"==",
"m",
".",
"name",
")",
"{",
"$e",
".",
"addClass",
"(",
"'order asc'",
")",
";",
"$lh",
"=",
"$e",
";",
"}",
"else",
"if",
"(",
"order",
".",
"substring",
"(",
"1",
")",
"==",
"m",
".",
"name",
")",
"{",
"$e",
".",
"addClass",
"(",
"'order desc'",
")",
";",
"$lh",
"=",
"$e",
";",
"}",
"}",
"hilight",
"(",
")",
";",
"$e",
".",
"click",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"order",
"==",
"m",
".",
"name",
")",
"{",
"order",
"=",
"'-'",
"+",
"m",
".",
"name",
";",
"}",
"else",
"{",
"order",
"=",
"m",
".",
"name",
";",
"}",
"zcookie",
".",
"set",
"(",
"'order-'",
"+",
"type",
",",
"order",
")",
";",
"if",
"(",
"$lh",
")",
"$lh",
".",
"removeClass",
"(",
"'order asc desc'",
")",
";",
"hilight",
"(",
")",
";",
"$lh",
"=",
"$e",
";",
"request_data",
"(",
")",
";",
"}",
")",
";",
"return",
"$e",
";",
"}"
] | last header clicked | [
"last",
"header",
"clicked"
] | 9afc9f907bad3b018d961af66c3abb33cd82b051 | https://github.com/posttool/currentcms/blob/9afc9f907bad3b018d961af66c3abb33cd82b051/lib/public/js/browse.js#L99-L136 |
54,337 | posttool/currentcms | lib/public/js/browse.js | make_page | function make_page(i, total) {
var $p = $$('page', {el: 'span'});
if (i == page) {
$p.addClass('selected');
$lp = $p;
}
var top = Math.min(i*pagesize+pagesize, total);
$p.text((i*pagesize+1)+'-'+top);
$p.text(i+1);
$p.click(function () {
page = i;
zcookie.set('page-'+type, page);
if ($lp)
$lp.removeClass('selected');
$lp = $p;
$lp.addClass('selected');
request_data();
});
return $p;
} | javascript | function make_page(i, total) {
var $p = $$('page', {el: 'span'});
if (i == page) {
$p.addClass('selected');
$lp = $p;
}
var top = Math.min(i*pagesize+pagesize, total);
$p.text((i*pagesize+1)+'-'+top);
$p.text(i+1);
$p.click(function () {
page = i;
zcookie.set('page-'+type, page);
if ($lp)
$lp.removeClass('selected');
$lp = $p;
$lp.addClass('selected');
request_data();
});
return $p;
} | [
"function",
"make_page",
"(",
"i",
",",
"total",
")",
"{",
"var",
"$p",
"=",
"$$",
"(",
"'page'",
",",
"{",
"el",
":",
"'span'",
"}",
")",
";",
"if",
"(",
"i",
"==",
"page",
")",
"{",
"$p",
".",
"addClass",
"(",
"'selected'",
")",
";",
"$lp",
"=",
"$p",
";",
"}",
"var",
"top",
"=",
"Math",
".",
"min",
"(",
"i",
"*",
"pagesize",
"+",
"pagesize",
",",
"total",
")",
";",
"$p",
".",
"text",
"(",
"(",
"i",
"*",
"pagesize",
"+",
"1",
")",
"+",
"'-'",
"+",
"top",
")",
";",
"$p",
".",
"text",
"(",
"i",
"+",
"1",
")",
";",
"$p",
".",
"click",
"(",
"function",
"(",
")",
"{",
"page",
"=",
"i",
";",
"zcookie",
".",
"set",
"(",
"'page-'",
"+",
"type",
",",
"page",
")",
";",
"if",
"(",
"$lp",
")",
"$lp",
".",
"removeClass",
"(",
"'selected'",
")",
";",
"$lp",
"=",
"$p",
";",
"$lp",
".",
"addClass",
"(",
"'selected'",
")",
";",
"request_data",
"(",
")",
";",
"}",
")",
";",
"return",
"$p",
";",
"}"
] | last page clicked | [
"last",
"page",
"clicked"
] | 9afc9f907bad3b018d961af66c3abb33cd82b051 | https://github.com/posttool/currentcms/blob/9afc9f907bad3b018d961af66c3abb33cd82b051/lib/public/js/browse.js#L207-L226 |
54,338 | finalclass/com | index.js | function (object) {
object.id = object.id || this.generateId();
this.data.push(object);
this.mapValues[object.id] = {};
this.eachMap(function (map, mapName) {
this.addObjectToMap(mapName, object);
});
return this;
} | javascript | function (object) {
object.id = object.id || this.generateId();
this.data.push(object);
this.mapValues[object.id] = {};
this.eachMap(function (map, mapName) {
this.addObjectToMap(mapName, object);
});
return this;
} | [
"function",
"(",
"object",
")",
"{",
"object",
".",
"id",
"=",
"object",
".",
"id",
"||",
"this",
".",
"generateId",
"(",
")",
";",
"this",
".",
"data",
".",
"push",
"(",
"object",
")",
";",
"this",
".",
"mapValues",
"[",
"object",
".",
"id",
"]",
"=",
"{",
"}",
";",
"this",
".",
"eachMap",
"(",
"function",
"(",
"map",
",",
"mapName",
")",
"{",
"this",
".",
"addObjectToMap",
"(",
"mapName",
",",
"object",
")",
";",
"}",
")",
";",
"return",
"this",
";",
"}"
] | adds the object
@public
@param {Object} object
@return {Com} | [
"adds",
"the",
"object"
] | 15e080f1a8353c72d9f9216dee830c0efe6ad93a | https://github.com/finalclass/com/blob/15e080f1a8353c72d9f9216dee830c0efe6ad93a/index.js#L105-L113 |
|
54,339 | finalclass/com | index.js | function (object) {
var index = this.data.indexOf(object);
if (index !== -1) {
this.data.splice(index, 1);
}
this.eachMap(function (map, mapName) {
this.removeObjectFromMap(mapName, object);
});
delete this.mapValues[object.id];
return this;
} | javascript | function (object) {
var index = this.data.indexOf(object);
if (index !== -1) {
this.data.splice(index, 1);
}
this.eachMap(function (map, mapName) {
this.removeObjectFromMap(mapName, object);
});
delete this.mapValues[object.id];
return this;
} | [
"function",
"(",
"object",
")",
"{",
"var",
"index",
"=",
"this",
".",
"data",
".",
"indexOf",
"(",
"object",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"this",
".",
"data",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"this",
".",
"eachMap",
"(",
"function",
"(",
"map",
",",
"mapName",
")",
"{",
"this",
".",
"removeObjectFromMap",
"(",
"mapName",
",",
"object",
")",
";",
"}",
")",
";",
"delete",
"this",
".",
"mapValues",
"[",
"object",
".",
"id",
"]",
";",
"return",
"this",
";",
"}"
] | Removes the object
@public
@param {Object} object
@return {Com} | [
"Removes",
"the",
"object"
] | 15e080f1a8353c72d9f9216dee830c0efe6ad93a | https://github.com/finalclass/com/blob/15e080f1a8353c72d9f9216dee830c0efe6ad93a/index.js#L124-L134 |
|
54,340 | finalclass/com | index.js | function (id, length) {
length = length || 8;
id = id || words.generate(length);
while (this.mapValues[id] !== undefined) {
id = words.generate(length);
length += 1;
}
return id.toString();
} | javascript | function (id, length) {
length = length || 8;
id = id || words.generate(length);
while (this.mapValues[id] !== undefined) {
id = words.generate(length);
length += 1;
}
return id.toString();
} | [
"function",
"(",
"id",
",",
"length",
")",
"{",
"length",
"=",
"length",
"||",
"8",
";",
"id",
"=",
"id",
"||",
"words",
".",
"generate",
"(",
"length",
")",
";",
"while",
"(",
"this",
".",
"mapValues",
"[",
"id",
"]",
"!==",
"undefined",
")",
"{",
"id",
"=",
"words",
".",
"generate",
"(",
"length",
")",
";",
"length",
"+=",
"1",
";",
"}",
"return",
"id",
".",
"toString",
"(",
")",
";",
"}"
] | Generate random, unique id
@private
@param {String} [id=null]
@param {Number} [length=8]
@return {String} | [
"Generate",
"random",
"unique",
"id"
] | 15e080f1a8353c72d9f9216dee830c0efe6ad93a | https://github.com/finalclass/com/blob/15e080f1a8353c72d9f9216dee830c0efe6ad93a/index.js#L161-L172 |
|
54,341 | finalclass/com | index.js | function (mapName, index) {
if (this.maps[mapName][index] === undefined) {
return [];
}
return this.maps[mapName][index].slice(); //slice() makes a copy of the array
} | javascript | function (mapName, index) {
if (this.maps[mapName][index] === undefined) {
return [];
}
return this.maps[mapName][index].slice(); //slice() makes a copy of the array
} | [
"function",
"(",
"mapName",
",",
"index",
")",
"{",
"if",
"(",
"this",
".",
"maps",
"[",
"mapName",
"]",
"[",
"index",
"]",
"===",
"undefined",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"this",
".",
"maps",
"[",
"mapName",
"]",
"[",
"index",
"]",
".",
"slice",
"(",
")",
";",
"//slice() makes a copy of the array",
"}"
] | Returns all the records stored in the `mapName` with the map value
equal to `index`
@public
@param {String} mapName
@param {String} index
@return {Object[]} | [
"Returns",
"all",
"the",
"records",
"stored",
"in",
"the",
"mapName",
"with",
"the",
"map",
"value",
"equal",
"to",
"index"
] | 15e080f1a8353c72d9f9216dee830c0efe6ad93a | https://github.com/finalclass/com/blob/15e080f1a8353c72d9f9216dee830c0efe6ad93a/index.js#L202-L207 |
|
54,342 | finalclass/com | index.js | function (callback) {
var mapName;
for (mapName in this.maps) {
if (this.maps.hasOwnProperty(mapName)) {
callback.call(this, this.maps[mapName], mapName);
}
}
} | javascript | function (callback) {
var mapName;
for (mapName in this.maps) {
if (this.maps.hasOwnProperty(mapName)) {
callback.call(this, this.maps[mapName], mapName);
}
}
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"mapName",
";",
"for",
"(",
"mapName",
"in",
"this",
".",
"maps",
")",
"{",
"if",
"(",
"this",
".",
"maps",
".",
"hasOwnProperty",
"(",
"mapName",
")",
")",
"{",
"callback",
".",
"call",
"(",
"this",
",",
"this",
".",
"maps",
"[",
"mapName",
"]",
",",
"mapName",
")",
";",
"}",
"}",
"}"
] | Iterates through all the maps
@private
@param {Function(Object[], String)} callback | [
"Iterates",
"through",
"all",
"the",
"maps"
] | 15e080f1a8353c72d9f9216dee830c0efe6ad93a | https://github.com/finalclass/com/blob/15e080f1a8353c72d9f9216dee830c0efe6ad93a/index.js#L228-L236 |
|
54,343 | finalclass/com | index.js | function (callback) {
var i;
for (i = 0; i < this.data.length; i += 1) {
callback.call(this, this.data[i], i);
}
return this;
} | javascript | function (callback) {
var i;
for (i = 0; i < this.data.length; i += 1) {
callback.call(this, this.data[i], i);
}
return this;
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"data",
".",
"length",
";",
"i",
"+=",
"1",
")",
"{",
"callback",
".",
"call",
"(",
"this",
",",
"this",
".",
"data",
"[",
"i",
"]",
",",
"i",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Iterates through all the objects
@public
@param {Function(Object, Number)} callback
@return {Com} | [
"Iterates",
"through",
"all",
"the",
"objects"
] | 15e080f1a8353c72d9f9216dee830c0efe6ad93a | https://github.com/finalclass/com/blob/15e080f1a8353c72d9f9216dee830c0efe6ad93a/index.js#L247-L254 |
|
54,344 | finalclass/com | index.js | function (mapName, object) {
var mapFunction = this.mapFunctions[mapName],
index,
value,
emit = function (idx, val) {
index = idx;
value = val;
};
mapFunction.call(object, object, emit);
if (this.maps[mapName][index] === undefined) {
this.maps[mapName][index] = [];
}
this.maps[mapName][index].push(value);
this.mapValues[object.id][mapName] = index;
return this;
} | javascript | function (mapName, object) {
var mapFunction = this.mapFunctions[mapName],
index,
value,
emit = function (idx, val) {
index = idx;
value = val;
};
mapFunction.call(object, object, emit);
if (this.maps[mapName][index] === undefined) {
this.maps[mapName][index] = [];
}
this.maps[mapName][index].push(value);
this.mapValues[object.id][mapName] = index;
return this;
} | [
"function",
"(",
"mapName",
",",
"object",
")",
"{",
"var",
"mapFunction",
"=",
"this",
".",
"mapFunctions",
"[",
"mapName",
"]",
",",
"index",
",",
"value",
",",
"emit",
"=",
"function",
"(",
"idx",
",",
"val",
")",
"{",
"index",
"=",
"idx",
";",
"value",
"=",
"val",
";",
"}",
";",
"mapFunction",
".",
"call",
"(",
"object",
",",
"object",
",",
"emit",
")",
";",
"if",
"(",
"this",
".",
"maps",
"[",
"mapName",
"]",
"[",
"index",
"]",
"===",
"undefined",
")",
"{",
"this",
".",
"maps",
"[",
"mapName",
"]",
"[",
"index",
"]",
"=",
"[",
"]",
";",
"}",
"this",
".",
"maps",
"[",
"mapName",
"]",
"[",
"index",
"]",
".",
"push",
"(",
"value",
")",
";",
"this",
".",
"mapValues",
"[",
"object",
".",
"id",
"]",
"[",
"mapName",
"]",
"=",
"index",
";",
"return",
"this",
";",
"}"
] | Adds object to `mapName` map
@private
@param {String} mapName
@param {Object} object
@return {Com} | [
"Adds",
"object",
"to",
"mapName",
"map"
] | 15e080f1a8353c72d9f9216dee830c0efe6ad93a | https://github.com/finalclass/com/blob/15e080f1a8353c72d9f9216dee830c0efe6ad93a/index.js#L266-L283 |
|
54,345 | finalclass/com | index.js | function (mapName, object) {
var mapValue = this.mapValues[object.id][mapName],
index = this.maps[mapName][mapValue].indexOf(object);
if (index !== -1) {
this.maps[mapName][mapValue].splice(index, 1);
}
return this;
} | javascript | function (mapName, object) {
var mapValue = this.mapValues[object.id][mapName],
index = this.maps[mapName][mapValue].indexOf(object);
if (index !== -1) {
this.maps[mapName][mapValue].splice(index, 1);
}
return this;
} | [
"function",
"(",
"mapName",
",",
"object",
")",
"{",
"var",
"mapValue",
"=",
"this",
".",
"mapValues",
"[",
"object",
".",
"id",
"]",
"[",
"mapName",
"]",
",",
"index",
"=",
"this",
".",
"maps",
"[",
"mapName",
"]",
"[",
"mapValue",
"]",
".",
"indexOf",
"(",
"object",
")",
";",
"if",
"(",
"index",
"!==",
"-",
"1",
")",
"{",
"this",
".",
"maps",
"[",
"mapName",
"]",
"[",
"mapValue",
"]",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Removes object from `mapName` map
@private
@param {String} mapName
@param {Object} object
@return {Com} | [
"Removes",
"object",
"from",
"mapName",
"map"
] | 15e080f1a8353c72d9f9216dee830c0efe6ad93a | https://github.com/finalclass/com/blob/15e080f1a8353c72d9f9216dee830c0efe6ad93a/index.js#L295-L304 |
|
54,346 | frisb/fdboost | lib/enhance/encoding/adapters/abstract.js | AbstractAdapter | function AbstractAdapter(valueOrBuffer, pos) {
this.pos = pos != null ? pos : 0;
this.data = null;
if (Buffer.isBuffer(valueOrBuffer)) {
this.value = this.getValue(valueOrBuffer);
} else {
this.loadData(valueOrBuffer);
}
} | javascript | function AbstractAdapter(valueOrBuffer, pos) {
this.pos = pos != null ? pos : 0;
this.data = null;
if (Buffer.isBuffer(valueOrBuffer)) {
this.value = this.getValue(valueOrBuffer);
} else {
this.loadData(valueOrBuffer);
}
} | [
"function",
"AbstractAdapter",
"(",
"valueOrBuffer",
",",
"pos",
")",
"{",
"this",
".",
"pos",
"=",
"pos",
"!=",
"null",
"?",
"pos",
":",
"0",
";",
"this",
".",
"data",
"=",
"null",
";",
"if",
"(",
"Buffer",
".",
"isBuffer",
"(",
"valueOrBuffer",
")",
")",
"{",
"this",
".",
"value",
"=",
"this",
".",
"getValue",
"(",
"valueOrBuffer",
")",
";",
"}",
"else",
"{",
"this",
".",
"loadData",
"(",
"valueOrBuffer",
")",
";",
"}",
"}"
] | Extend an AbstractAdapter instance for encoding and decoding typed values.
@abstract
@param {(Buffer|undefined|string|integer|double|boolean|null|date|array|object)} valueOrBuffer Value to encode or buffer instance to decode.
@param {integer} [pos=0] Buffer position to start writing data.
@property {Buffer} data Encoded buffer.
@property {(undefined|string|integer|double|boolean|null|date|array|object)} value Decoded value.
@return {object} Extended AbstractAdapter instance. | [
"Extend",
"an",
"AbstractAdapter",
"instance",
"for",
"encoding",
"and",
"decoding",
"typed",
"values",
"."
] | 66cfb6552940aa92f35dbb1cf4d0695d842205c2 | https://github.com/frisb/fdboost/blob/66cfb6552940aa92f35dbb1cf4d0695d842205c2/lib/enhance/encoding/adapters/abstract.js#L28-L36 |
54,347 | Industryswarm/isnode-mod-data | lib/mongodb/mongodb-core/lib/auth/plain.js | function(authStore, session) {
var found = false;
for (var i = 0; i < authStore.length; i++) {
if (authStore[i].equal(session)) {
found = true;
break;
}
}
if (!found) authStore.push(session);
} | javascript | function(authStore, session) {
var found = false;
for (var i = 0; i < authStore.length; i++) {
if (authStore[i].equal(session)) {
found = true;
break;
}
}
if (!found) authStore.push(session);
} | [
"function",
"(",
"authStore",
",",
"session",
")",
"{",
"var",
"found",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"authStore",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"authStore",
"[",
"i",
"]",
".",
"equal",
"(",
"session",
")",
")",
"{",
"found",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"found",
")",
"authStore",
".",
"push",
"(",
"session",
")",
";",
"}"
] | Add to store only if it does not exist | [
"Add",
"to",
"store",
"only",
"if",
"it",
"does",
"not",
"exist"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb-core/lib/auth/plain.js#L119-L130 |
|
54,348 | Industryswarm/isnode-mod-data | lib/mysql/bignumber.js/bignumber.js | maxOrMin | function maxOrMin( args, method ) {
var m, n,
i = 0;
if ( isArray( args[0] ) ) args = args[0];
m = new BigNumber( args[0] );
for ( ; ++i < args.length; ) {
n = new BigNumber( args[i] );
// If any number is NaN, return NaN.
if ( !n.s ) {
m = n;
break;
} else if ( method.call( m, n ) ) {
m = n;
}
}
return m;
} | javascript | function maxOrMin( args, method ) {
var m, n,
i = 0;
if ( isArray( args[0] ) ) args = args[0];
m = new BigNumber( args[0] );
for ( ; ++i < args.length; ) {
n = new BigNumber( args[i] );
// If any number is NaN, return NaN.
if ( !n.s ) {
m = n;
break;
} else if ( method.call( m, n ) ) {
m = n;
}
}
return m;
} | [
"function",
"maxOrMin",
"(",
"args",
",",
"method",
")",
"{",
"var",
"m",
",",
"n",
",",
"i",
"=",
"0",
";",
"if",
"(",
"isArray",
"(",
"args",
"[",
"0",
"]",
")",
")",
"args",
"=",
"args",
"[",
"0",
"]",
";",
"m",
"=",
"new",
"BigNumber",
"(",
"args",
"[",
"0",
"]",
")",
";",
"for",
"(",
";",
"++",
"i",
"<",
"args",
".",
"length",
";",
")",
"{",
"n",
"=",
"new",
"BigNumber",
"(",
"args",
"[",
"i",
"]",
")",
";",
"// If any number is NaN, return NaN.\r",
"if",
"(",
"!",
"n",
".",
"s",
")",
"{",
"m",
"=",
"n",
";",
"break",
";",
"}",
"else",
"if",
"(",
"method",
".",
"call",
"(",
"m",
",",
"n",
")",
")",
"{",
"m",
"=",
"n",
";",
"}",
"}",
"return",
"m",
";",
"}"
] | Handle BigNumber.max and BigNumber.min. | [
"Handle",
"BigNumber",
".",
"max",
"and",
"BigNumber",
".",
"min",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mysql/bignumber.js/bignumber.js#L1071-L1091 |
54,349 | Industryswarm/isnode-mod-data | lib/mysql/bignumber.js/bignumber.js | raise | function raise( caller, msg, val ) {
var error = new Error( [
'new BigNumber', // 0
'cmp', // 1
'config', // 2
'div', // 3
'divToInt', // 4
'eq', // 5
'gt', // 6
'gte', // 7
'lt', // 8
'lte', // 9
'minus', // 10
'mod', // 11
'plus', // 12
'precision', // 13
'random', // 14
'round', // 15
'shift', // 16
'times', // 17
'toDigits', // 18
'toExponential', // 19
'toFixed', // 20
'toFormat', // 21
'toFraction', // 22
'pow', // 23
'toPrecision', // 24
'toString', // 25
'BigNumber' // 26
][caller] + '() ' + msg + ': ' + val );
error.name = 'BigNumber Error';
id = 0;
throw error;
} | javascript | function raise( caller, msg, val ) {
var error = new Error( [
'new BigNumber', // 0
'cmp', // 1
'config', // 2
'div', // 3
'divToInt', // 4
'eq', // 5
'gt', // 6
'gte', // 7
'lt', // 8
'lte', // 9
'minus', // 10
'mod', // 11
'plus', // 12
'precision', // 13
'random', // 14
'round', // 15
'shift', // 16
'times', // 17
'toDigits', // 18
'toExponential', // 19
'toFixed', // 20
'toFormat', // 21
'toFraction', // 22
'pow', // 23
'toPrecision', // 24
'toString', // 25
'BigNumber' // 26
][caller] + '() ' + msg + ': ' + val );
error.name = 'BigNumber Error';
id = 0;
throw error;
} | [
"function",
"raise",
"(",
"caller",
",",
"msg",
",",
"val",
")",
"{",
"var",
"error",
"=",
"new",
"Error",
"(",
"[",
"'new BigNumber'",
",",
"// 0\r",
"'cmp'",
",",
"// 1\r",
"'config'",
",",
"// 2\r",
"'div'",
",",
"// 3\r",
"'divToInt'",
",",
"// 4\r",
"'eq'",
",",
"// 5\r",
"'gt'",
",",
"// 6\r",
"'gte'",
",",
"// 7\r",
"'lt'",
",",
"// 8\r",
"'lte'",
",",
"// 9\r",
"'minus'",
",",
"// 10\r",
"'mod'",
",",
"// 11\r",
"'plus'",
",",
"// 12\r",
"'precision'",
",",
"// 13\r",
"'random'",
",",
"// 14\r",
"'round'",
",",
"// 15\r",
"'shift'",
",",
"// 16\r",
"'times'",
",",
"// 17\r",
"'toDigits'",
",",
"// 18\r",
"'toExponential'",
",",
"// 19\r",
"'toFixed'",
",",
"// 20\r",
"'toFormat'",
",",
"// 21\r",
"'toFraction'",
",",
"// 22\r",
"'pow'",
",",
"// 23\r",
"'toPrecision'",
",",
"// 24\r",
"'toString'",
",",
"// 25\r",
"'BigNumber'",
"// 26\r",
"]",
"[",
"caller",
"]",
"+",
"'() '",
"+",
"msg",
"+",
"': '",
"+",
"val",
")",
";",
"error",
".",
"name",
"=",
"'BigNumber Error'",
";",
"id",
"=",
"0",
";",
"throw",
"error",
";",
"}"
] | Throw a BigNumber Error. | [
"Throw",
"a",
"BigNumber",
"Error",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mysql/bignumber.js/bignumber.js#L1189-L1223 |
54,350 | Industryswarm/isnode-mod-data | lib/mysql/bignumber.js/bignumber.js | coeffToString | function coeffToString(a) {
var s, z,
i = 1,
j = a.length,
r = a[0] + '';
for ( ; i < j; ) {
s = a[i++] + '';
z = LOG_BASE - s.length;
for ( ; z--; s = '0' + s );
r += s;
}
// Determine trailing zeros.
for ( j = r.length; r.charCodeAt(--j) === 48; );
return r.slice( 0, j + 1 || 1 );
} | javascript | function coeffToString(a) {
var s, z,
i = 1,
j = a.length,
r = a[0] + '';
for ( ; i < j; ) {
s = a[i++] + '';
z = LOG_BASE - s.length;
for ( ; z--; s = '0' + s );
r += s;
}
// Determine trailing zeros.
for ( j = r.length; r.charCodeAt(--j) === 48; );
return r.slice( 0, j + 1 || 1 );
} | [
"function",
"coeffToString",
"(",
"a",
")",
"{",
"var",
"s",
",",
"z",
",",
"i",
"=",
"1",
",",
"j",
"=",
"a",
".",
"length",
",",
"r",
"=",
"a",
"[",
"0",
"]",
"+",
"''",
";",
"for",
"(",
";",
"i",
"<",
"j",
";",
")",
"{",
"s",
"=",
"a",
"[",
"i",
"++",
"]",
"+",
"''",
";",
"z",
"=",
"LOG_BASE",
"-",
"s",
".",
"length",
";",
"for",
"(",
";",
"z",
"--",
";",
"s",
"=",
"'0'",
"+",
"s",
")",
";",
"r",
"+=",
"s",
";",
"}",
"// Determine trailing zeros.\r",
"for",
"(",
"j",
"=",
"r",
".",
"length",
";",
"r",
".",
"charCodeAt",
"(",
"--",
"j",
")",
"===",
"48",
";",
")",
";",
"return",
"r",
".",
"slice",
"(",
"0",
",",
"j",
"+",
"1",
"||",
"1",
")",
";",
"}"
] | Return a coefficient array as a string of base 10 digits. | [
"Return",
"a",
"coefficient",
"array",
"as",
"a",
"string",
"of",
"base",
"10",
"digits",
"."
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mysql/bignumber.js/bignumber.js#L2570-L2586 |
54,351 | mgesmundo/authorify-client | lib/class/Authorization.js | function() {
var secret;
if (!this.getSecret()) {
throw new CError('missing secret').log();
}
try {
secret = this.encoder.encryptRsa(this.getSecret());
} catch (e) {
throw new CError({
body: {
code: 'ImATeapot',
message: 'unable to encrypt secret',
cause: e
}
}).log('body');
}
if (this.getMode() !== mode1 && this.getMode() !== mode2) {
throw new CError('unexpected mode').log();
}
if (!this.getSid()) {
throw new CError('missing sid').log();
}
return {
mode: this.getMode(),
secret: secret,
sid: this.getSid()
};
} | javascript | function() {
var secret;
if (!this.getSecret()) {
throw new CError('missing secret').log();
}
try {
secret = this.encoder.encryptRsa(this.getSecret());
} catch (e) {
throw new CError({
body: {
code: 'ImATeapot',
message: 'unable to encrypt secret',
cause: e
}
}).log('body');
}
if (this.getMode() !== mode1 && this.getMode() !== mode2) {
throw new CError('unexpected mode').log();
}
if (!this.getSid()) {
throw new CError('missing sid').log();
}
return {
mode: this.getMode(),
secret: secret,
sid: this.getSid()
};
} | [
"function",
"(",
")",
"{",
"var",
"secret",
";",
"if",
"(",
"!",
"this",
".",
"getSecret",
"(",
")",
")",
"{",
"throw",
"new",
"CError",
"(",
"'missing secret'",
")",
".",
"log",
"(",
")",
";",
"}",
"try",
"{",
"secret",
"=",
"this",
".",
"encoder",
".",
"encryptRsa",
"(",
"this",
".",
"getSecret",
"(",
")",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"new",
"CError",
"(",
"{",
"body",
":",
"{",
"code",
":",
"'ImATeapot'",
",",
"message",
":",
"'unable to encrypt secret'",
",",
"cause",
":",
"e",
"}",
"}",
")",
".",
"log",
"(",
"'body'",
")",
";",
"}",
"if",
"(",
"this",
".",
"getMode",
"(",
")",
"!==",
"mode1",
"&&",
"this",
".",
"getMode",
"(",
")",
"!==",
"mode2",
")",
"{",
"throw",
"new",
"CError",
"(",
"'unexpected mode'",
")",
".",
"log",
"(",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"getSid",
"(",
")",
")",
"{",
"throw",
"new",
"CError",
"(",
"'missing sid'",
")",
".",
"log",
"(",
")",
";",
"}",
"return",
"{",
"mode",
":",
"this",
".",
"getMode",
"(",
")",
",",
"secret",
":",
"secret",
",",
"sid",
":",
"this",
".",
"getSid",
"(",
")",
"}",
";",
"}"
] | Get the payload property of the header.
@return {Object} The payload property of the header | [
"Get",
"the",
"payload",
"property",
"of",
"the",
"header",
"."
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Authorization.js#L82-L109 |
|
54,352 | mgesmundo/authorify-client | lib/class/Authorization.js | function(data) {
if (!data) {
data = this.getContent();
}
return this.encoder.encryptAes(JSON.stringify(data), this.getSecret());
} | javascript | function(data) {
if (!data) {
data = this.getContent();
}
return this.encoder.encryptAes(JSON.stringify(data), this.getSecret());
} | [
"function",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"data",
"=",
"this",
".",
"getContent",
"(",
")",
";",
"}",
"return",
"this",
".",
"encoder",
".",
"encryptAes",
"(",
"JSON",
".",
"stringify",
"(",
"data",
")",
",",
"this",
".",
"getSecret",
"(",
")",
")",
";",
"}"
] | Encrypt data or content
@param {Object} [data] The data to encrypt or content if missing
@return {String} The encrypted result in Base64 format | [
"Encrypt",
"data",
"or",
"content"
] | 39fb57db897eaa49b76444ff62bbc0ccedc7ee16 | https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/lib/class/Authorization.js#L135-L140 |
|
54,353 | skerit/alchemy-styleboost | assets/scripts/medium-insert/embeds.js | function (options) {
this.options = $.extend(this.defaults, options);
this.$el = $.fn.mediumInsert.insert.$el;
this.setEmbedButtonEvents();
this.preparePreviousEmbeds();
} | javascript | function (options) {
this.options = $.extend(this.defaults, options);
this.$el = $.fn.mediumInsert.insert.$el;
this.setEmbedButtonEvents();
this.preparePreviousEmbeds();
} | [
"function",
"(",
"options",
")",
"{",
"this",
".",
"options",
"=",
"$",
".",
"extend",
"(",
"this",
".",
"defaults",
",",
"options",
")",
";",
"this",
".",
"$el",
"=",
"$",
".",
"fn",
".",
"mediumInsert",
".",
"insert",
".",
"$el",
";",
"this",
".",
"setEmbedButtonEvents",
"(",
")",
";",
"this",
".",
"preparePreviousEmbeds",
"(",
")",
";",
"}"
] | Embeds initial function
@return {void} | [
"Embeds",
"initial",
"function"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/medium-insert/embeds.js#L18-L23 |
|
54,354 | gahlotnikhil/bower-component-files | lib/Component.js | Component | function Component(bowerObj, files) {
this.bowerObj = bowerObj;
this.files = files;
this.name = bowerObj['name'];
this.version = bowerObj['version'];
} | javascript | function Component(bowerObj, files) {
this.bowerObj = bowerObj;
this.files = files;
this.name = bowerObj['name'];
this.version = bowerObj['version'];
} | [
"function",
"Component",
"(",
"bowerObj",
",",
"files",
")",
"{",
"this",
".",
"bowerObj",
"=",
"bowerObj",
";",
"this",
".",
"files",
"=",
"files",
";",
"this",
".",
"name",
"=",
"bowerObj",
"[",
"'name'",
"]",
";",
"this",
".",
"version",
"=",
"bowerObj",
"[",
"'version'",
"]",
";",
"}"
] | Class to represent individual component.
@constructor
@param {Object} bowerObj
@param {Array<String>} files | [
"Class",
"to",
"represent",
"individual",
"component",
"."
] | f57111e2718517d2c86995975be0d862dc83c7bd | https://github.com/gahlotnikhil/bower-component-files/blob/f57111e2718517d2c86995975be0d862dc83c7bd/lib/Component.js#L10-L15 |
54,355 | AltaModaTech/azure-metrics-for-node | lib/services/metricsservice.js | MetricsService | function MetricsService(storageAccount, storageAccessKey, host, authenticationProvider) {
if (!host) {
// Dev Stg does not support metrics
host = azure.ServiceClient.CLOUD_TABLE_HOST;
}
MetricsService.super_.call(this, host, storageAccount, storageAccessKey, authenticationProvider);
if (!this.authenticationProvider) {
this.authenticationProvider = new azure.SharedKeyTable(this.storageAccount, this.storageAccessKey, this.usePathStyleUri);
}
} | javascript | function MetricsService(storageAccount, storageAccessKey, host, authenticationProvider) {
if (!host) {
// Dev Stg does not support metrics
host = azure.ServiceClient.CLOUD_TABLE_HOST;
}
MetricsService.super_.call(this, host, storageAccount, storageAccessKey, authenticationProvider);
if (!this.authenticationProvider) {
this.authenticationProvider = new azure.SharedKeyTable(this.storageAccount, this.storageAccessKey, this.usePathStyleUri);
}
} | [
"function",
"MetricsService",
"(",
"storageAccount",
",",
"storageAccessKey",
",",
"host",
",",
"authenticationProvider",
")",
"{",
"if",
"(",
"!",
"host",
")",
"{",
"// Dev Stg does not support metrics",
"host",
"=",
"azure",
".",
"ServiceClient",
".",
"CLOUD_TABLE_HOST",
";",
"}",
"MetricsService",
".",
"super_",
".",
"call",
"(",
"this",
",",
"host",
",",
"storageAccount",
",",
"storageAccessKey",
",",
"authenticationProvider",
")",
";",
"if",
"(",
"!",
"this",
".",
"authenticationProvider",
")",
"{",
"this",
".",
"authenticationProvider",
"=",
"new",
"azure",
".",
"SharedKeyTable",
"(",
"this",
".",
"storageAccount",
",",
"this",
".",
"storageAccessKey",
",",
"this",
".",
"usePathStyleUri",
")",
";",
"}",
"}"
] | Creates a new MetricsService object.
If no storageaccount or storageaccesskey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables will be used.
@constructor
@extends {ServiceClient}
@param {string} [storageAccount] The storage account.
@param {string} [storageAccessKey] The storage access key.
@param {string} [host] The host address.
@param {object} [authenticationProvider] The authentication provider. | [
"Creates",
"a",
"new",
"MetricsService",
"object",
".",
"If",
"no",
"storageaccount",
"or",
"storageaccesskey",
"are",
"provided",
"the",
"AZURE_STORAGE_ACCOUNT",
"and",
"AZURE_STORAGE_ACCESS_KEY",
"environment",
"variables",
"will",
"be",
"used",
"."
] | f2eb49cb34448575b106ac972dee40b914490bb0 | https://github.com/AltaModaTech/azure-metrics-for-node/blob/f2eb49cb34448575b106ac972dee40b914490bb0/lib/services/metricsservice.js#L49-L60 |
54,356 | Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/bulk/unordered.js | executeBatch | function executeBatch(bulkOperation, batch, options, callback) {
function resultHandler(err, result) {
// Error is a driver related error not a bulk op error, terminate
if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) {
return handleCallback(callback, err);
}
// If we have and error
if (err) err.ok = 0;
if (err instanceof MongoWriteConcernError) {
return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, false, err, callback);
}
handleCallback(
callback,
null,
mergeBatchResults(false, batch, bulkOperation.s.bulkResult, err, result)
);
}
bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback);
} | javascript | function executeBatch(bulkOperation, batch, options, callback) {
function resultHandler(err, result) {
// Error is a driver related error not a bulk op error, terminate
if (((err && err.driver) || (err && err.message)) && !(err instanceof MongoWriteConcernError)) {
return handleCallback(callback, err);
}
// If we have and error
if (err) err.ok = 0;
if (err instanceof MongoWriteConcernError) {
return handleMongoWriteConcernError(batch, bulkOperation.s.bulkResult, false, err, callback);
}
handleCallback(
callback,
null,
mergeBatchResults(false, batch, bulkOperation.s.bulkResult, err, result)
);
}
bulkOperation.finalOptionsHandler({ options, batch, resultHandler }, callback);
} | [
"function",
"executeBatch",
"(",
"bulkOperation",
",",
"batch",
",",
"options",
",",
"callback",
")",
"{",
"function",
"resultHandler",
"(",
"err",
",",
"result",
")",
"{",
"// Error is a driver related error not a bulk op error, terminate",
"if",
"(",
"(",
"(",
"err",
"&&",
"err",
".",
"driver",
")",
"||",
"(",
"err",
"&&",
"err",
".",
"message",
")",
")",
"&&",
"!",
"(",
"err",
"instanceof",
"MongoWriteConcernError",
")",
")",
"{",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
")",
";",
"}",
"// If we have and error",
"if",
"(",
"err",
")",
"err",
".",
"ok",
"=",
"0",
";",
"if",
"(",
"err",
"instanceof",
"MongoWriteConcernError",
")",
"{",
"return",
"handleMongoWriteConcernError",
"(",
"batch",
",",
"bulkOperation",
".",
"s",
".",
"bulkResult",
",",
"false",
",",
"err",
",",
"callback",
")",
";",
"}",
"handleCallback",
"(",
"callback",
",",
"null",
",",
"mergeBatchResults",
"(",
"false",
",",
"batch",
",",
"bulkOperation",
".",
"s",
".",
"bulkResult",
",",
"err",
",",
"result",
")",
")",
";",
"}",
"bulkOperation",
".",
"finalOptionsHandler",
"(",
"{",
"options",
",",
"batch",
",",
"resultHandler",
"}",
",",
"callback",
")",
";",
"}"
] | Execute the command
@param {UnorderedBulkOperation} bulkOperation
@param {object} batch
@param {object} options
@param {function} callback | [
"Execute",
"the",
"command"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/bulk/unordered.js#L141-L161 |
54,357 | Industryswarm/isnode-mod-data | lib/mongodb/mongodb/lib/bulk/unordered.js | executeBatches | function executeBatches(bulkOperation, options, callback) {
let numberOfCommandsToExecute = bulkOperation.s.batches.length;
// Execute over all the batches
for (let i = 0; i < bulkOperation.s.batches.length; i++) {
executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) {
// Count down the number of commands left to execute
numberOfCommandsToExecute = numberOfCommandsToExecute - 1;
// Execute
if (numberOfCommandsToExecute === 0) {
// Driver level error
if (err) return handleCallback(callback, err);
const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
if (bulkOperation.handleWriteError(callback, writeResult)) return;
return handleCallback(callback, null, writeResult);
}
});
}
} | javascript | function executeBatches(bulkOperation, options, callback) {
let numberOfCommandsToExecute = bulkOperation.s.batches.length;
// Execute over all the batches
for (let i = 0; i < bulkOperation.s.batches.length; i++) {
executeBatch(bulkOperation, bulkOperation.s.batches[i], options, function(err) {
// Count down the number of commands left to execute
numberOfCommandsToExecute = numberOfCommandsToExecute - 1;
// Execute
if (numberOfCommandsToExecute === 0) {
// Driver level error
if (err) return handleCallback(callback, err);
const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
if (bulkOperation.handleWriteError(callback, writeResult)) return;
return handleCallback(callback, null, writeResult);
}
});
}
} | [
"function",
"executeBatches",
"(",
"bulkOperation",
",",
"options",
",",
"callback",
")",
"{",
"let",
"numberOfCommandsToExecute",
"=",
"bulkOperation",
".",
"s",
".",
"batches",
".",
"length",
";",
"// Execute over all the batches",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"bulkOperation",
".",
"s",
".",
"batches",
".",
"length",
";",
"i",
"++",
")",
"{",
"executeBatch",
"(",
"bulkOperation",
",",
"bulkOperation",
".",
"s",
".",
"batches",
"[",
"i",
"]",
",",
"options",
",",
"function",
"(",
"err",
")",
"{",
"// Count down the number of commands left to execute",
"numberOfCommandsToExecute",
"=",
"numberOfCommandsToExecute",
"-",
"1",
";",
"// Execute",
"if",
"(",
"numberOfCommandsToExecute",
"===",
"0",
")",
"{",
"// Driver level error",
"if",
"(",
"err",
")",
"return",
"handleCallback",
"(",
"callback",
",",
"err",
")",
";",
"const",
"writeResult",
"=",
"new",
"BulkWriteResult",
"(",
"bulkOperation",
".",
"s",
".",
"bulkResult",
")",
";",
"if",
"(",
"bulkOperation",
".",
"handleWriteError",
"(",
"callback",
",",
"writeResult",
")",
")",
"return",
";",
"return",
"handleCallback",
"(",
"callback",
",",
"null",
",",
"writeResult",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | Execute all the commands
@param {UnorderedBulkOperation} bulkOperation
@param {object} options
@param {function} callback | [
"Execute",
"all",
"the",
"commands"
] | 5adc639b88a0d72cbeef23a6b5df7f4540745089 | https://github.com/Industryswarm/isnode-mod-data/blob/5adc639b88a0d72cbeef23a6b5df7f4540745089/lib/mongodb/mongodb/lib/bulk/unordered.js#L170-L190 |
54,358 | crysalead-js/dom-event-manager | spec/helper/trigger-event.js | triggerEvent | function triggerEvent(name, element) {
var eventType;
switch (name) {
case "click":
case "mousedown":
case "mouseup":
eventType = "MouseEvents";
break;
case "focus":
case "change":
case "blur":
case "select":
eventType = "HTMLEvents";
break;
default:
throw new Error('Unsupported `"' + name + '"`event');
break;
}
var event = document.createEvent(eventType);
event.initEvent(name, name !== "change" , true);
element.dispatchEvent(event, true);
} | javascript | function triggerEvent(name, element) {
var eventType;
switch (name) {
case "click":
case "mousedown":
case "mouseup":
eventType = "MouseEvents";
break;
case "focus":
case "change":
case "blur":
case "select":
eventType = "HTMLEvents";
break;
default:
throw new Error('Unsupported `"' + name + '"`event');
break;
}
var event = document.createEvent(eventType);
event.initEvent(name, name !== "change" , true);
element.dispatchEvent(event, true);
} | [
"function",
"triggerEvent",
"(",
"name",
",",
"element",
")",
"{",
"var",
"eventType",
";",
"switch",
"(",
"name",
")",
"{",
"case",
"\"click\"",
":",
"case",
"\"mousedown\"",
":",
"case",
"\"mouseup\"",
":",
"eventType",
"=",
"\"MouseEvents\"",
";",
"break",
";",
"case",
"\"focus\"",
":",
"case",
"\"change\"",
":",
"case",
"\"blur\"",
":",
"case",
"\"select\"",
":",
"eventType",
"=",
"\"HTMLEvents\"",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Error",
"(",
"'Unsupported `\"'",
"+",
"name",
"+",
"'\"`event'",
")",
";",
"break",
";",
"}",
"var",
"event",
"=",
"document",
".",
"createEvent",
"(",
"eventType",
")",
";",
"event",
".",
"initEvent",
"(",
"name",
",",
"name",
"!==",
"\"change\"",
",",
"true",
")",
";",
"element",
".",
"dispatchEvent",
"(",
"event",
",",
"true",
")",
";",
"}"
] | Trigger an event on the specified element.
@param String name The name of the event to trigger the "on" (e.g., "focus")
@param Object element The DOM element to trigger the event on. | [
"Trigger",
"an",
"event",
"on",
"the",
"specified",
"element",
"."
] | e61e6b23ea7baef6e55ebd6df3762473c47a9a99 | https://github.com/crysalead-js/dom-event-manager/blob/e61e6b23ea7baef6e55ebd6df3762473c47a9a99/spec/helper/trigger-event.js#L7-L30 |
54,359 | sandcastle/vs_projectname | index.js | isValid | function isValid(ch){
var code = ch.charCodeAt(0);
return is_letter(code)
|| is_digit(code)
|| (ch === '.')
|| (ch === '_')
|| is_unicode_connector_punctuation(ch)
|| is_unicode_format(ch)
|| is_unicode_combining_mark(ch)
|| is_unicode_digit(ch);
} | javascript | function isValid(ch){
var code = ch.charCodeAt(0);
return is_letter(code)
|| is_digit(code)
|| (ch === '.')
|| (ch === '_')
|| is_unicode_connector_punctuation(ch)
|| is_unicode_format(ch)
|| is_unicode_combining_mark(ch)
|| is_unicode_digit(ch);
} | [
"function",
"isValid",
"(",
"ch",
")",
"{",
"var",
"code",
"=",
"ch",
".",
"charCodeAt",
"(",
"0",
")",
";",
"return",
"is_letter",
"(",
"code",
")",
"||",
"is_digit",
"(",
"code",
")",
"||",
"(",
"ch",
"===",
"'.'",
")",
"||",
"(",
"ch",
"===",
"'_'",
")",
"||",
"is_unicode_connector_punctuation",
"(",
"ch",
")",
"||",
"is_unicode_format",
"(",
"ch",
")",
"||",
"is_unicode_combining_mark",
"(",
"ch",
")",
"||",
"is_unicode_digit",
"(",
"ch",
")",
";",
"}"
] | Tests if the specified character is valid.
@param {String} ch The character to test.
@returns {Boolean} The | [
"Tests",
"if",
"the",
"specified",
"character",
"is",
"valid",
"."
] | 405531a6de45e9ca140fb58529986b2fcf048d60 | https://github.com/sandcastle/vs_projectname/blob/405531a6de45e9ca140fb58529986b2fcf048d60/index.js#L52-L62 |
54,360 | six-plus/omni-di | dependency_injector.js | function(levels) {
for (var i = 0; i < levels.length; ++i) {
var level = levels[i];
for (var j = 0; j < level.length; ++j) {
if (level[j].factory) {
_this.injectAndRegister(level[j].name, level[j].factory);
} else if (level[j].obj) {
_this.register(level[j].name, level[j].obj);
}
}
}
} | javascript | function(levels) {
for (var i = 0; i < levels.length; ++i) {
var level = levels[i];
for (var j = 0; j < level.length; ++j) {
if (level[j].factory) {
_this.injectAndRegister(level[j].name, level[j].factory);
} else if (level[j].obj) {
_this.register(level[j].name, level[j].obj);
}
}
}
} | [
"function",
"(",
"levels",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"levels",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"level",
"=",
"levels",
"[",
"i",
"]",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"level",
".",
"length",
";",
"++",
"j",
")",
"{",
"if",
"(",
"level",
"[",
"j",
"]",
".",
"factory",
")",
"{",
"_this",
".",
"injectAndRegister",
"(",
"level",
"[",
"j",
"]",
".",
"name",
",",
"level",
"[",
"j",
"]",
".",
"factory",
")",
";",
"}",
"else",
"if",
"(",
"level",
"[",
"j",
"]",
".",
"obj",
")",
"{",
"_this",
".",
"register",
"(",
"level",
"[",
"j",
"]",
".",
"name",
",",
"level",
"[",
"j",
"]",
".",
"obj",
")",
";",
"}",
"}",
"}",
"}"
] | Given a dependency graph in topological order, assemble it. | [
"Given",
"a",
"dependency",
"graph",
"in",
"topological",
"order",
"assemble",
"it",
"."
] | 6160562747129695d631622da35dbf4cddd577f0 | https://github.com/six-plus/omni-di/blob/6160562747129695d631622da35dbf4cddd577f0/dependency_injector.js#L64-L75 |
|
54,361 | RedKenrok/node-planckmatch | library/index.js | function(value, patterns, options, isPath) {
// Parse patterns, match value per pattern, and return results.
return planckmatch.match(value, planckmatch.parse(patterns, options, isPath));
} | javascript | function(value, patterns, options, isPath) {
// Parse patterns, match value per pattern, and return results.
return planckmatch.match(value, planckmatch.parse(patterns, options, isPath));
} | [
"function",
"(",
"value",
",",
"patterns",
",",
"options",
",",
"isPath",
")",
"{",
"// Parse patterns, match value per pattern, and return results.",
"return",
"planckmatch",
".",
"match",
"(",
"value",
",",
"planckmatch",
".",
"parse",
"(",
"patterns",
",",
"options",
",",
"isPath",
")",
")",
";",
"}"
] | Matches extended glob patterns with a given value.
@param {String} value A value to match to.
@param {String|Array} patterns An extended glob pattern or array of extended glob patterns.
@param {Object} options Glob pattern to regular expression options.
@param {Boolean} isPath Whether it should adapt the pattern to match paths.
@returns Boolean or Array of Booleans in pattern order with whether the pattern matched. | [
"Matches",
"extended",
"glob",
"patterns",
"with",
"a",
"given",
"value",
"."
] | eb33f15032272dd835effec862d537ad69abd61c | https://github.com/RedKenrok/node-planckmatch/blob/eb33f15032272dd835effec862d537ad69abd61c/library/index.js#L9-L12 |
|
54,362 | justin-calleja/no-dups-validator | lib/index.js | noDups | function noDups (iterable = []) {
return (errMsgPrefix = '') => {
const dups = extractDuplicates(iterable)
return dups.size === 0
? [ true, [] ]
: [ false, [ new Error(errMsgPrefix + Array.from(dups).join(', ')) ] ]
}
} | javascript | function noDups (iterable = []) {
return (errMsgPrefix = '') => {
const dups = extractDuplicates(iterable)
return dups.size === 0
? [ true, [] ]
: [ false, [ new Error(errMsgPrefix + Array.from(dups).join(', ')) ] ]
}
} | [
"function",
"noDups",
"(",
"iterable",
"=",
"[",
"]",
")",
"{",
"return",
"(",
"errMsgPrefix",
"=",
"''",
")",
"=>",
"{",
"const",
"dups",
"=",
"extractDuplicates",
"(",
"iterable",
")",
"return",
"dups",
".",
"size",
"===",
"0",
"?",
"[",
"true",
",",
"[",
"]",
"]",
":",
"[",
"false",
",",
"[",
"new",
"Error",
"(",
"errMsgPrefix",
"+",
"Array",
".",
"from",
"(",
"dups",
")",
".",
"join",
"(",
"', '",
")",
")",
"]",
"]",
"}",
"}"
] | This function is curried.
@param {Iterable} [iterable=[]] - The iterable whose elements are checked for duplicates
@param {String} [errMsgPrefix=''] - A string to prefix any found duplicates in the error message
@return {Tuple<Boolean, Array<Error>>}
@see {@link module:@justinc/jsdocs.Tuple}
@tutorial curry | [
"This",
"function",
"is",
"curried",
"."
] | 5fea089b825c9c18f04cb299e01da81afb84cf13 | https://github.com/justin-calleja/no-dups-validator/blob/5fea089b825c9c18f04cb299e01da81afb84cf13/lib/index.js#L15-L22 |
54,363 | zerkalica/regexp-string-mapper | lib/regexp-string-mapper.js | RegExpStringMapper | function RegExpStringMapper(options) {
if (!(this instanceof RegExpStringMapper)) {
return new RegExpStringMapper(options);
}
options = options || {};
this._formatters = [];
this.addFormatter(createDefaultFormatter(options.serialize || getSerializeFn()));
this.addFormatter(createMomentFormatter(options.moment));
this._separator = options.separator || '%';
this._regex = buildDefaultRegex(this._separator);
this._magic = '@RegExpStringMapper';
this._separatorRegExp = RegExp(this._separator + this._separator, 'g');
this._magicRegExp = RegExp(this._magic, 'g');
} | javascript | function RegExpStringMapper(options) {
if (!(this instanceof RegExpStringMapper)) {
return new RegExpStringMapper(options);
}
options = options || {};
this._formatters = [];
this.addFormatter(createDefaultFormatter(options.serialize || getSerializeFn()));
this.addFormatter(createMomentFormatter(options.moment));
this._separator = options.separator || '%';
this._regex = buildDefaultRegex(this._separator);
this._magic = '@RegExpStringMapper';
this._separatorRegExp = RegExp(this._separator + this._separator, 'g');
this._magicRegExp = RegExp(this._magic, 'g');
} | [
"function",
"RegExpStringMapper",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"RegExpStringMapper",
")",
")",
"{",
"return",
"new",
"RegExpStringMapper",
"(",
"options",
")",
";",
"}",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"_formatters",
"=",
"[",
"]",
";",
"this",
".",
"addFormatter",
"(",
"createDefaultFormatter",
"(",
"options",
".",
"serialize",
"||",
"getSerializeFn",
"(",
")",
")",
")",
";",
"this",
".",
"addFormatter",
"(",
"createMomentFormatter",
"(",
"options",
".",
"moment",
")",
")",
";",
"this",
".",
"_separator",
"=",
"options",
".",
"separator",
"||",
"'%'",
";",
"this",
".",
"_regex",
"=",
"buildDefaultRegex",
"(",
"this",
".",
"_separator",
")",
";",
"this",
".",
"_magic",
"=",
"'@RegExpStringMapper'",
";",
"this",
".",
"_separatorRegExp",
"=",
"RegExp",
"(",
"this",
".",
"_separator",
"+",
"this",
".",
"_separator",
",",
"'g'",
")",
";",
"this",
".",
"_magicRegExp",
"=",
"RegExp",
"(",
"this",
".",
"_magic",
",",
"'g'",
")",
";",
"}"
] | RegExp string mapper
@param {Object} options Options
@param {[String]} options.separator Token match separator, default - %
@param {[Formatter[]]} options.formatters Array of formatters | [
"RegExp",
"string",
"mapper"
] | f4ec8a8c5fed5b34dbf8b48948aff7ba73ba268c | https://github.com/zerkalica/regexp-string-mapper/blob/f4ec8a8c5fed5b34dbf8b48948aff7ba73ba268c/lib/regexp-string-mapper.js#L59-L72 |
54,364 | pierrec/node-atok-parser | lib/parser.js | merge | function merge (a, b, soft) {
for (var k in b)
if (!soft || !a.hasOwnProperty(k)) a[k] = b[k]
return a
} | javascript | function merge (a, b, soft) {
for (var k in b)
if (!soft || !a.hasOwnProperty(k)) a[k] = b[k]
return a
} | [
"function",
"merge",
"(",
"a",
",",
"b",
",",
"soft",
")",
"{",
"for",
"(",
"var",
"k",
"in",
"b",
")",
"if",
"(",
"!",
"soft",
"||",
"!",
"a",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"a",
"[",
"k",
"]",
"=",
"b",
"[",
"k",
"]",
"return",
"a",
"}"
] | Copy properties from one object to another - not replacing if required | [
"Copy",
"properties",
"from",
"one",
"object",
"to",
"another",
"-",
"not",
"replacing",
"if",
"required"
] | 414d39904dff73ffdde049212076c14ca40aa20b | https://github.com/pierrec/node-atok-parser/blob/414d39904dff73ffdde049212076c14ca40aa20b/lib/parser.js#L23-L27 |
54,365 | pierrec/node-atok-parser | lib/parser.js | inspect | function inspect (s) {
return s
.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
.replace(/"/g, '\\"')
.replace(/\r/g, '\\r')
} | javascript | function inspect (s) {
return s
.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
.replace(/"/g, '\\"')
.replace(/\r/g, '\\r')
} | [
"function",
"inspect",
"(",
"s",
")",
"{",
"return",
"s",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"'\\\\\\\\'",
")",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"'\\\\n'",
")",
".",
"replace",
"(",
"/",
"\\t",
"/",
"g",
",",
"'\\\\t'",
")",
".",
"replace",
"(",
"/",
"\"",
"/",
"g",
",",
"'\\\\\"'",
")",
".",
"replace",
"(",
"/",
"\\r",
"/",
"g",
",",
"'\\\\r'",
")",
"}"
] | Show special characters for display | [
"Show",
"special",
"characters",
"for",
"display"
] | 414d39904dff73ffdde049212076c14ca40aa20b | https://github.com/pierrec/node-atok-parser/blob/414d39904dff73ffdde049212076c14ca40aa20b/lib/parser.js#L30-L37 |
54,366 | pierrec/node-atok-parser | lib/parser.js | forwardEvent | function forwardEvent (event) {
var n = Atok.events[event]
, args = []
while (n > 0) args.push('a' + n--)
args = args.join()
return 'atok.on("'
+ event
+ '", function forwardEvent (' + args + ') { self.emit_' + event + '(' + args + ') })'
} | javascript | function forwardEvent (event) {
var n = Atok.events[event]
, args = []
while (n > 0) args.push('a' + n--)
args = args.join()
return 'atok.on("'
+ event
+ '", function forwardEvent (' + args + ') { self.emit_' + event + '(' + args + ') })'
} | [
"function",
"forwardEvent",
"(",
"event",
")",
"{",
"var",
"n",
"=",
"Atok",
".",
"events",
"[",
"event",
"]",
",",
"args",
"=",
"[",
"]",
"while",
"(",
"n",
">",
"0",
")",
"args",
".",
"push",
"(",
"'a'",
"+",
"n",
"--",
")",
"args",
"=",
"args",
".",
"join",
"(",
")",
"return",
"'atok.on(\"'",
"+",
"event",
"+",
"'\", function forwardEvent ('",
"+",
"args",
"+",
"') { self.emit_'",
"+",
"event",
"+",
"'('",
"+",
"args",
"+",
"') })'",
"}"
] | Set an event arguments list | [
"Set",
"an",
"event",
"arguments",
"list"
] | 414d39904dff73ffdde049212076c14ca40aa20b | https://github.com/pierrec/node-atok-parser/blob/414d39904dff73ffdde049212076c14ca40aa20b/lib/parser.js#L76-L86 |
54,367 | mauritsl/bluegate | bluegate.js | function(log) {
var date = this.date.toISOString().substring(0, 19);
var duration = new Date() - this.date;
log(date + ' ' + this.ip + ' "' + this.method + ' ' + this.path + '" ' + this.status + ' ' + this._length + ' ' + duration);
} | javascript | function(log) {
var date = this.date.toISOString().substring(0, 19);
var duration = new Date() - this.date;
log(date + ' ' + this.ip + ' "' + this.method + ' ' + this.path + '" ' + this.status + ' ' + this._length + ' ' + duration);
} | [
"function",
"(",
"log",
")",
"{",
"var",
"date",
"=",
"this",
".",
"date",
".",
"toISOString",
"(",
")",
".",
"substring",
"(",
"0",
",",
"19",
")",
";",
"var",
"duration",
"=",
"new",
"Date",
"(",
")",
"-",
"this",
".",
"date",
";",
"log",
"(",
"date",
"+",
"' '",
"+",
"this",
".",
"ip",
"+",
"' \"'",
"+",
"this",
".",
"method",
"+",
"' '",
"+",
"this",
".",
"path",
"+",
"'\" '",
"+",
"this",
".",
"status",
"+",
"' '",
"+",
"this",
".",
"_length",
"+",
"' '",
"+",
"duration",
")",
";",
"}"
] | Log response.
@param {function} log | [
"Log",
"response",
"."
] | 0760e30841709d2e415b5315cf83225614c6dbfe | https://github.com/mauritsl/bluegate/blob/0760e30841709d2e415b5315cf83225614c6dbfe/bluegate.js#L507-L511 |
|
54,368 | mauritsl/bluegate | bluegate.js | function(fn) {
var code = fn.toString();
var match = code.match(/^(?:(?:function)?[\s]*\(([^)]*)\)|([^\=\(]+))/);
var args = (match[1] || match[2]);
if (typeof args === 'undefined') {
return [];
}
return args.split(',').map(function(item) {
return item.trim();
}).filter(function(item) {
return item;
});
} | javascript | function(fn) {
var code = fn.toString();
var match = code.match(/^(?:(?:function)?[\s]*\(([^)]*)\)|([^\=\(]+))/);
var args = (match[1] || match[2]);
if (typeof args === 'undefined') {
return [];
}
return args.split(',').map(function(item) {
return item.trim();
}).filter(function(item) {
return item;
});
} | [
"function",
"(",
"fn",
")",
"{",
"var",
"code",
"=",
"fn",
".",
"toString",
"(",
")",
";",
"var",
"match",
"=",
"code",
".",
"match",
"(",
"/",
"^(?:(?:function)?[\\s]*\\(([^)]*)\\)|([^\\=\\(]+))",
"/",
")",
";",
"var",
"args",
"=",
"(",
"match",
"[",
"1",
"]",
"||",
"match",
"[",
"2",
"]",
")",
";",
"if",
"(",
"typeof",
"args",
"===",
"'undefined'",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"args",
".",
"split",
"(",
"','",
")",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"item",
".",
"trim",
"(",
")",
";",
"}",
")",
".",
"filter",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"item",
";",
"}",
")",
";",
"}"
] | List function arguments. | [
"List",
"function",
"arguments",
"."
] | 0760e30841709d2e415b5315cf83225614c6dbfe | https://github.com/mauritsl/bluegate/blob/0760e30841709d2e415b5315cf83225614c6dbfe/bluegate.js#L531-L543 |
|
54,369 | aleclarson/is-open-comment | index.js | findTags | function findTags(code) {
const tags = []
findTag(code, '\n', tags)
findTag(code, '//', tags)
findTag(code, '/*', tags)
findTag(code, '*/', tags)
return tags
} | javascript | function findTags(code) {
const tags = []
findTag(code, '\n', tags)
findTag(code, '//', tags)
findTag(code, '/*', tags)
findTag(code, '*/', tags)
return tags
} | [
"function",
"findTags",
"(",
"code",
")",
"{",
"const",
"tags",
"=",
"[",
"]",
"findTag",
"(",
"code",
",",
"'\\n'",
",",
"tags",
")",
"findTag",
"(",
"code",
",",
"'//'",
",",
"tags",
")",
"findTag",
"(",
"code",
",",
"'/*'",
",",
"tags",
")",
"findTag",
"(",
"code",
",",
"'*/'",
",",
"tags",
")",
"return",
"tags",
"}"
] | Returns a sparse array of comment tags | [
"Returns",
"a",
"sparse",
"array",
"of",
"comment",
"tags"
] | f2f775cbc473afdbfd7f0da49cdfcb9b759a1ca9 | https://github.com/aleclarson/is-open-comment/blob/f2f775cbc473afdbfd7f0da49cdfcb9b759a1ca9/index.js#L67-L74 |
54,370 | leozdgao/elecpen | src/index.js | createLogger | function createLogger (writables, prefix, dateFormat) {
if (!Array.isArray(writables)) writables = [ writables ]
writables = writables.filter(w => isDefined(w) && isFunction(w.write))
debug(`There are ${writables.length} writables for this logger`)
let pre = `[${prefix}]`
// default timestamp format
if (dateFormat === true) dateFormat = 'YYYY-MM-DD HH:mm:ss'
if (typeof dateFormat === 'string') {
pre += ` ${moment().format(dateFormat)}`
}
return msg => {
writables.forEach(w => w.write(`${pre} ${msg}\n`))
}
} | javascript | function createLogger (writables, prefix, dateFormat) {
if (!Array.isArray(writables)) writables = [ writables ]
writables = writables.filter(w => isDefined(w) && isFunction(w.write))
debug(`There are ${writables.length} writables for this logger`)
let pre = `[${prefix}]`
// default timestamp format
if (dateFormat === true) dateFormat = 'YYYY-MM-DD HH:mm:ss'
if (typeof dateFormat === 'string') {
pre += ` ${moment().format(dateFormat)}`
}
return msg => {
writables.forEach(w => w.write(`${pre} ${msg}\n`))
}
} | [
"function",
"createLogger",
"(",
"writables",
",",
"prefix",
",",
"dateFormat",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"writables",
")",
")",
"writables",
"=",
"[",
"writables",
"]",
"writables",
"=",
"writables",
".",
"filter",
"(",
"w",
"=>",
"isDefined",
"(",
"w",
")",
"&&",
"isFunction",
"(",
"w",
".",
"write",
")",
")",
"debug",
"(",
"`",
"${",
"writables",
".",
"length",
"}",
"`",
")",
"let",
"pre",
"=",
"`",
"${",
"prefix",
"}",
"`",
"// default timestamp format",
"if",
"(",
"dateFormat",
"===",
"true",
")",
"dateFormat",
"=",
"'YYYY-MM-DD HH:mm:ss'",
"if",
"(",
"typeof",
"dateFormat",
"===",
"'string'",
")",
"{",
"pre",
"+=",
"`",
"${",
"moment",
"(",
")",
".",
"format",
"(",
"dateFormat",
")",
"}",
"`",
"}",
"return",
"msg",
"=>",
"{",
"writables",
".",
"forEach",
"(",
"w",
"=>",
"w",
".",
"write",
"(",
"`",
"${",
"pre",
"}",
"${",
"msg",
"}",
"\\n",
"`",
")",
")",
"}",
"}"
] | Main method for create logger. The logger is just a function to recieve
the record and write to a stream.
@param {Writable} writable A writable stream for logging
@param {string} prefix The prefix to write
@param {string | bool} date The date format
@return {function} A function use like `console.log` | [
"Main",
"method",
"for",
"create",
"logger",
".",
"The",
"logger",
"is",
"just",
"a",
"function",
"to",
"recieve",
"the",
"record",
"and",
"write",
"to",
"a",
"stream",
"."
] | 9048727800efc1a4e1ca9b4526f449b878f851b4 | https://github.com/leozdgao/elecpen/blob/9048727800efc1a4e1ca9b4526f449b878f851b4/src/index.js#L30-L47 |
54,371 | leozdgao/elecpen | src/index.js | useDefaultLogger | function useDefaultLogger (opts) {
const {
infoFile, errFile,
append = true,
timestamp = true, // string for a date format or pass true to use default format
} = opts
// The value of `logToConsole` default to true in dev mode
let logToConsole = opts.logToConsole
if (isDev() && !isDefined(logToConsole)) {
debug('In dev mode and `logToConsole` is set to true.')
logToConsole = true
}
const flag = append ? 'a' : 'w'
const infoStream = infoFile && fs.createWriteStream(infoFile, { flags: flag })
const errStream = errFile && fs.createWriteStream(errFile, { flags: flag })
const infoRecorder = streamRecorder()
const errRecorder = streamRecorder()
return {
verbose () {
let stream = infoRecorder(infoFile, name => fs.createWriteStream(name, { flags: flag }))
if (logToConsole) stream = [ process.stdout, stream ]
createLogger(stream, 'Verbose', timestamp).apply(this, arguments)
},
info () {
let stream = infoRecorder(infoFile, name => fs.createWriteStream(name, { flags: flag }))
if (logToConsole) stream = [ process.stdout, stream ]
createLogger(stream, 'Info', timestamp).apply(this, arguments)
},
warning () {
let stream = errRecorder(errFile, name => fs.createWriteStream(name, { flags: flag }))
if (logToConsole) stream = [ process.stderr, stream ]
createLogger(stream, 'Warning', timestamp).apply(this, arguments)
},
error () {
let stream = errRecorder(errFile, name => fs.createWriteStream(name, { flags: flag }))
if (logToConsole) stream = [ process.stderr, stream ]
createLogger(stream, 'Error', timestamp).apply(this, arguments)
}
}
} | javascript | function useDefaultLogger (opts) {
const {
infoFile, errFile,
append = true,
timestamp = true, // string for a date format or pass true to use default format
} = opts
// The value of `logToConsole` default to true in dev mode
let logToConsole = opts.logToConsole
if (isDev() && !isDefined(logToConsole)) {
debug('In dev mode and `logToConsole` is set to true.')
logToConsole = true
}
const flag = append ? 'a' : 'w'
const infoStream = infoFile && fs.createWriteStream(infoFile, { flags: flag })
const errStream = errFile && fs.createWriteStream(errFile, { flags: flag })
const infoRecorder = streamRecorder()
const errRecorder = streamRecorder()
return {
verbose () {
let stream = infoRecorder(infoFile, name => fs.createWriteStream(name, { flags: flag }))
if (logToConsole) stream = [ process.stdout, stream ]
createLogger(stream, 'Verbose', timestamp).apply(this, arguments)
},
info () {
let stream = infoRecorder(infoFile, name => fs.createWriteStream(name, { flags: flag }))
if (logToConsole) stream = [ process.stdout, stream ]
createLogger(stream, 'Info', timestamp).apply(this, arguments)
},
warning () {
let stream = errRecorder(errFile, name => fs.createWriteStream(name, { flags: flag }))
if (logToConsole) stream = [ process.stderr, stream ]
createLogger(stream, 'Warning', timestamp).apply(this, arguments)
},
error () {
let stream = errRecorder(errFile, name => fs.createWriteStream(name, { flags: flag }))
if (logToConsole) stream = [ process.stderr, stream ]
createLogger(stream, 'Error', timestamp).apply(this, arguments)
}
}
} | [
"function",
"useDefaultLogger",
"(",
"opts",
")",
"{",
"const",
"{",
"infoFile",
",",
"errFile",
",",
"append",
"=",
"true",
",",
"timestamp",
"=",
"true",
",",
"// string for a date format or pass true to use default format",
"}",
"=",
"opts",
"// The value of `logToConsole` default to true in dev mode",
"let",
"logToConsole",
"=",
"opts",
".",
"logToConsole",
"if",
"(",
"isDev",
"(",
")",
"&&",
"!",
"isDefined",
"(",
"logToConsole",
")",
")",
"{",
"debug",
"(",
"'In dev mode and `logToConsole` is set to true.'",
")",
"logToConsole",
"=",
"true",
"}",
"const",
"flag",
"=",
"append",
"?",
"'a'",
":",
"'w'",
"const",
"infoStream",
"=",
"infoFile",
"&&",
"fs",
".",
"createWriteStream",
"(",
"infoFile",
",",
"{",
"flags",
":",
"flag",
"}",
")",
"const",
"errStream",
"=",
"errFile",
"&&",
"fs",
".",
"createWriteStream",
"(",
"errFile",
",",
"{",
"flags",
":",
"flag",
"}",
")",
"const",
"infoRecorder",
"=",
"streamRecorder",
"(",
")",
"const",
"errRecorder",
"=",
"streamRecorder",
"(",
")",
"return",
"{",
"verbose",
"(",
")",
"{",
"let",
"stream",
"=",
"infoRecorder",
"(",
"infoFile",
",",
"name",
"=>",
"fs",
".",
"createWriteStream",
"(",
"name",
",",
"{",
"flags",
":",
"flag",
"}",
")",
")",
"if",
"(",
"logToConsole",
")",
"stream",
"=",
"[",
"process",
".",
"stdout",
",",
"stream",
"]",
"createLogger",
"(",
"stream",
",",
"'Verbose'",
",",
"timestamp",
")",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
"}",
",",
"info",
"(",
")",
"{",
"let",
"stream",
"=",
"infoRecorder",
"(",
"infoFile",
",",
"name",
"=>",
"fs",
".",
"createWriteStream",
"(",
"name",
",",
"{",
"flags",
":",
"flag",
"}",
")",
")",
"if",
"(",
"logToConsole",
")",
"stream",
"=",
"[",
"process",
".",
"stdout",
",",
"stream",
"]",
"createLogger",
"(",
"stream",
",",
"'Info'",
",",
"timestamp",
")",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
"}",
",",
"warning",
"(",
")",
"{",
"let",
"stream",
"=",
"errRecorder",
"(",
"errFile",
",",
"name",
"=>",
"fs",
".",
"createWriteStream",
"(",
"name",
",",
"{",
"flags",
":",
"flag",
"}",
")",
")",
"if",
"(",
"logToConsole",
")",
"stream",
"=",
"[",
"process",
".",
"stderr",
",",
"stream",
"]",
"createLogger",
"(",
"stream",
",",
"'Warning'",
",",
"timestamp",
")",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
"}",
",",
"error",
"(",
")",
"{",
"let",
"stream",
"=",
"errRecorder",
"(",
"errFile",
",",
"name",
"=>",
"fs",
".",
"createWriteStream",
"(",
"name",
",",
"{",
"flags",
":",
"flag",
"}",
")",
")",
"if",
"(",
"logToConsole",
")",
"stream",
"=",
"[",
"process",
".",
"stderr",
",",
"stream",
"]",
"createLogger",
"(",
"stream",
",",
"'Error'",
",",
"timestamp",
")",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
"}",
"}",
"}"
] | Construct a default logger, it can record the verbose, info , warning, error message and
write it to the file you specified.
Options:
infoFile: Path of the file for recording verbose and info message.
errFile: Path of the file for recording warning and error message.
append: Decide append or truncate the file if it exists. Default to be true.
timestamp: Represents the date format or pass true to use default format.
@param {object} opts - options
@returns {object} The logger | [
"Construct",
"a",
"default",
"logger",
"it",
"can",
"record",
"the",
"verbose",
"info",
"warning",
"error",
"message",
"and",
"write",
"it",
"to",
"the",
"file",
"you",
"specified",
"."
] | 9048727800efc1a4e1ca9b4526f449b878f851b4 | https://github.com/leozdgao/elecpen/blob/9048727800efc1a4e1ca9b4526f449b878f851b4/src/index.js#L62-L110 |
54,372 | leozdgao/elecpen | src/index.js | streamRecorder | function streamRecorder () {
let lastKey, lastStream
return (key, createStream) => {
if (isFunction(key)) key = key.call()
debug(`Recorder get key: ${key}`)
if (key !== lastKey) {
debug(`Recorder will return a new stream`)
lastKey = key
lastStream = createStream.call(null, key)
}
return lastStream
}
} | javascript | function streamRecorder () {
let lastKey, lastStream
return (key, createStream) => {
if (isFunction(key)) key = key.call()
debug(`Recorder get key: ${key}`)
if (key !== lastKey) {
debug(`Recorder will return a new stream`)
lastKey = key
lastStream = createStream.call(null, key)
}
return lastStream
}
} | [
"function",
"streamRecorder",
"(",
")",
"{",
"let",
"lastKey",
",",
"lastStream",
"return",
"(",
"key",
",",
"createStream",
")",
"=>",
"{",
"if",
"(",
"isFunction",
"(",
"key",
")",
")",
"key",
"=",
"key",
".",
"call",
"(",
")",
"debug",
"(",
"`",
"${",
"key",
"}",
"`",
")",
"if",
"(",
"key",
"!==",
"lastKey",
")",
"{",
"debug",
"(",
"`",
"`",
")",
"lastKey",
"=",
"key",
"lastStream",
"=",
"createStream",
".",
"call",
"(",
"null",
",",
"key",
")",
"}",
"return",
"lastStream",
"}",
"}"
] | Record the stream by key
@return {function} A function return stream | [
"Record",
"the",
"stream",
"by",
"key"
] | 9048727800efc1a4e1ca9b4526f449b878f851b4 | https://github.com/leozdgao/elecpen/blob/9048727800efc1a4e1ca9b4526f449b878f851b4/src/index.js#L116-L132 |
54,373 | ezseed/watcher | process/helpers.js | function(arr, iterator) {
var i = arr.length - 1, index = null
if(i >= 0){
do {
if(iterator(arr[i])) {
index = i
break
}
} while(i--)
}
return index
} | javascript | function(arr, iterator) {
var i = arr.length - 1, index = null
if(i >= 0){
do {
if(iterator(arr[i])) {
index = i
break
}
} while(i--)
}
return index
} | [
"function",
"(",
"arr",
",",
"iterator",
")",
"{",
"var",
"i",
"=",
"arr",
".",
"length",
"-",
"1",
",",
"index",
"=",
"null",
"if",
"(",
"i",
">=",
"0",
")",
"{",
"do",
"{",
"if",
"(",
"iterator",
"(",
"arr",
"[",
"i",
"]",
")",
")",
"{",
"index",
"=",
"i",
"break",
"}",
"}",
"while",
"(",
"i",
"--",
")",
"}",
"return",
"index",
"}"
] | Returnn the first index of the array matching the iterator | [
"Returnn",
"the",
"first",
"index",
"of",
"the",
"array",
"matching",
"the",
"iterator"
] | 63c74abd20d2093ae0b05981802d0cb98e4becdb | https://github.com/ezseed/watcher/blob/63c74abd20d2093ae0b05981802d0cb98e4becdb/process/helpers.js#L11-L24 |
|
54,374 | codeactual/long-con | lib/long-con/index.js | LongCon | function LongCon() {
this.settings = {
namespace: '',
nlFirst: false,
quiet: false,
time: false,
traceIndent: ' ',
traceLanes: true
};
this.stackDepth = 0;
this.firstLine = true;
} | javascript | function LongCon() {
this.settings = {
namespace: '',
nlFirst: false,
quiet: false,
time: false,
traceIndent: ' ',
traceLanes: true
};
this.stackDepth = 0;
this.firstLine = true;
} | [
"function",
"LongCon",
"(",
")",
"{",
"this",
".",
"settings",
"=",
"{",
"namespace",
":",
"''",
",",
"nlFirst",
":",
"false",
",",
"quiet",
":",
"false",
",",
"time",
":",
"false",
",",
"traceIndent",
":",
"' '",
",",
"traceLanes",
":",
"true",
"}",
";",
"this",
".",
"stackDepth",
"=",
"0",
";",
"this",
".",
"firstLine",
"=",
"true",
";",
"}"
] | LongCon constructor.
Usage:
var longCon = require('long-con').create(); // new LongCon() instance
Example configuration:
loncCon
.set('namespace', 'myLib');
var log = longCon.create('[stderr]', console.error, 'red.bold');
// [stderr] myLib error message: ...
log('error message: %s', ...);
Configuration:
- `{string} [namespace='']` Prepend to each message
- `{string} [nlFirst=false]` Prepend `\n` to first log
- `{string} [quiet=false]` Drop all messages
- `{string} [time=false]` Prepend `toUTCString()`
- `{string} [traceIndent=' ']` Represent a stack level (default: 4 spaces)
- `{string} [traceLanes=true]` Prepend each traceIndent with `|`
Properties:
- `{number} [stackDepth=0]` Used to size indentation and draw trace lanes
- `{boolean} firstLine` Supports `nlFirst` config option
@see cli-color https://github.com/medikoo/cli-color | [
"LongCon",
"constructor",
"."
] | e5fb172636ed2f5668068277efdab062ba1cb05d | https://github.com/codeactual/long-con/blob/e5fb172636ed2f5668068277efdab062ba1cb05d/lib/long-con/index.js#L75-L87 |
54,375 | sittingbool/sbool-node-utils | util/promises.js | promiseWithError | function promiseWithError( err, callback) {
var deferred = Q.defer();
if ( err instanceof Error ) {
deferred.reject( err);
} else {
deferred.reject(new Error(err));
}
if ( typeof callback === 'function' ) {
callback(err, null);
}
return deferred.promise;
} | javascript | function promiseWithError( err, callback) {
var deferred = Q.defer();
if ( err instanceof Error ) {
deferred.reject( err);
} else {
deferred.reject(new Error(err));
}
if ( typeof callback === 'function' ) {
callback(err, null);
}
return deferred.promise;
} | [
"function",
"promiseWithError",
"(",
"err",
",",
"callback",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"if",
"(",
"err",
"instanceof",
"Error",
")",
"{",
"deferred",
".",
"reject",
"(",
"err",
")",
";",
"}",
"else",
"{",
"deferred",
".",
"reject",
"(",
"new",
"Error",
"(",
"err",
")",
")",
";",
"}",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"callback",
"(",
"err",
",",
"null",
")",
";",
"}",
"return",
"deferred",
".",
"promise",
";",
"}"
] | Creates a promise that only returns an error to be used when promise is expected
but an error is already known and calls the callback if given
@param err - the error object or message as a string
@param callback - optional, a callback with signature function( error, result).
if given this one will be called despite returning a promise
@returns {*|promise} - the promise | [
"Creates",
"a",
"promise",
"that",
"only",
"returns",
"an",
"error",
"to",
"be",
"used",
"when",
"promise",
"is",
"expected",
"but",
"an",
"error",
"is",
"already",
"known",
"and",
"calls",
"the",
"callback",
"if",
"given"
] | 30a5b71bc258b160883451ede8c6c3991294fd68 | https://github.com/sittingbool/sbool-node-utils/blob/30a5b71bc258b160883451ede8c6c3991294fd68/util/promises.js#L15-L26 |
54,376 | sittingbool/sbool-node-utils | util/promises.js | promiseWithError | function promiseWithError( result, callback) {
var deferred = Q.defer();
deferred.resolve(result);
if ( typeof callback === 'function' ) {
callback(null, result);
}
return deferred.promise;
} | javascript | function promiseWithError( result, callback) {
var deferred = Q.defer();
deferred.resolve(result);
if ( typeof callback === 'function' ) {
callback(null, result);
}
return deferred.promise;
} | [
"function",
"promiseWithError",
"(",
"result",
",",
"callback",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"deferred",
".",
"resolve",
"(",
"result",
")",
";",
"if",
"(",
"typeof",
"callback",
"===",
"'function'",
")",
"{",
"callback",
"(",
"null",
",",
"result",
")",
";",
"}",
"return",
"deferred",
".",
"promise",
";",
"}"
] | Creates a promise that only returns a result to be used when promise is expected
but the result is already known and calls the callback if given
@param result - the result value
@param callback - optional, a callback with signature function( error, result).
if given this one will be called despite returning a promise
@returns {*|promise} - the promise | [
"Creates",
"a",
"promise",
"that",
"only",
"returns",
"a",
"result",
"to",
"be",
"used",
"when",
"promise",
"is",
"expected",
"but",
"the",
"result",
"is",
"already",
"known",
"and",
"calls",
"the",
"callback",
"if",
"given"
] | 30a5b71bc258b160883451ede8c6c3991294fd68 | https://github.com/sittingbool/sbool-node-utils/blob/30a5b71bc258b160883451ede8c6c3991294fd68/util/promises.js#L36-L43 |
54,377 | sittingbool/sbool-node-utils | util/promises.js | promiseForCallback | function promiseForCallback( fun, callback) {
var deferred = Q.defer();
fun( function( error, result) {
callback(error, result, deferred);
});
return deferred.promise;
} | javascript | function promiseForCallback( fun, callback) {
var deferred = Q.defer();
fun( function( error, result) {
callback(error, result, deferred);
});
return deferred.promise;
} | [
"function",
"promiseForCallback",
"(",
"fun",
",",
"callback",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"fun",
"(",
"function",
"(",
"error",
",",
"result",
")",
"{",
"callback",
"(",
"error",
",",
"result",
",",
"deferred",
")",
";",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] | Returns a promise handling the function and taking a callback to state what to do with the deferred object
@param fun - the function to be executed
@param callback - the callback with signature function ( err, result, deferred)
@returns {*|promise} - the promise generated | [
"Returns",
"a",
"promise",
"handling",
"the",
"function",
"and",
"taking",
"a",
"callback",
"to",
"state",
"what",
"to",
"do",
"with",
"the",
"deferred",
"object"
] | 30a5b71bc258b160883451ede8c6c3991294fd68 | https://github.com/sittingbool/sbool-node-utils/blob/30a5b71bc258b160883451ede8c6c3991294fd68/util/promises.js#L51-L57 |
54,378 | cartridge/cartridge-static-html | task.js | getDataSource | function getDataSource(projectConfig) {
var api = {};
api.getDataForPath = function getDataForPath(requestedPath) {
var templateData, dataPath;
dataPath = path.resolve(projectConfig.paths.src.views.data, requestedPath + '.json');
try{
templateData = require(dataPath);
} catch(err){
templateData = {};
}
return templateData;
};
api.getPaths = function getPaths() {
return;
};
return api;
} | javascript | function getDataSource(projectConfig) {
var api = {};
api.getDataForPath = function getDataForPath(requestedPath) {
var templateData, dataPath;
dataPath = path.resolve(projectConfig.paths.src.views.data, requestedPath + '.json');
try{
templateData = require(dataPath);
} catch(err){
templateData = {};
}
return templateData;
};
api.getPaths = function getPaths() {
return;
};
return api;
} | [
"function",
"getDataSource",
"(",
"projectConfig",
")",
"{",
"var",
"api",
"=",
"{",
"}",
";",
"api",
".",
"getDataForPath",
"=",
"function",
"getDataForPath",
"(",
"requestedPath",
")",
"{",
"var",
"templateData",
",",
"dataPath",
";",
"dataPath",
"=",
"path",
".",
"resolve",
"(",
"projectConfig",
".",
"paths",
".",
"src",
".",
"views",
".",
"data",
",",
"requestedPath",
"+",
"'.json'",
")",
";",
"try",
"{",
"templateData",
"=",
"require",
"(",
"dataPath",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"templateData",
"=",
"{",
"}",
";",
"}",
"return",
"templateData",
";",
"}",
";",
"api",
".",
"getPaths",
"=",
"function",
"getPaths",
"(",
")",
"{",
"return",
";",
"}",
";",
"return",
"api",
";",
"}"
] | Basic data source api pending it being split out to another file | [
"Basic",
"data",
"source",
"api",
"pending",
"it",
"being",
"split",
"out",
"to",
"another",
"file"
] | a0ef21f14664cbb24e28f48efff05abf7fd95ff4 | https://github.com/cartridge/cartridge-static-html/blob/a0ef21f14664cbb24e28f48efff05abf7fd95ff4/task.js#L16-L38 |
54,379 | cartridge/cartridge-static-html | task.js | DefaultData | function DefaultData(projectConfig) {
var defaultData = require(path.resolve(projectConfig.paths.src.views.data, '_default.json'));
return {
apply: function apply(data) {
return merge.recursive(defaultData, data);
}
};
} | javascript | function DefaultData(projectConfig) {
var defaultData = require(path.resolve(projectConfig.paths.src.views.data, '_default.json'));
return {
apply: function apply(data) {
return merge.recursive(defaultData, data);
}
};
} | [
"function",
"DefaultData",
"(",
"projectConfig",
")",
"{",
"var",
"defaultData",
"=",
"require",
"(",
"path",
".",
"resolve",
"(",
"projectConfig",
".",
"paths",
".",
"src",
".",
"views",
".",
"data",
",",
"'_default.json'",
")",
")",
";",
"return",
"{",
"apply",
":",
"function",
"apply",
"(",
"data",
")",
"{",
"return",
"merge",
".",
"recursive",
"(",
"defaultData",
",",
"data",
")",
";",
"}",
"}",
";",
"}"
] | Basic default data source pending it being split out | [
"Basic",
"default",
"data",
"source",
"pending",
"it",
"being",
"split",
"out"
] | a0ef21f14664cbb24e28f48efff05abf7fd95ff4 | https://github.com/cartridge/cartridge-static-html/blob/a0ef21f14664cbb24e28f48efff05abf7fd95ff4/task.js#L41-L49 |
54,380 | heineiuo/express-res-html | lib/index.js | extend | function extend() {
var result = {};
var objs = Array.prototype.slice.call(arguments,0);
objs.forEach(function(props, index){
for(var prop in props) {
if(props.hasOwnProperty(prop)) {
result[prop] = props[prop]
}
}
});
return result;
} | javascript | function extend() {
var result = {};
var objs = Array.prototype.slice.call(arguments,0);
objs.forEach(function(props, index){
for(var prop in props) {
if(props.hasOwnProperty(prop)) {
result[prop] = props[prop]
}
}
});
return result;
} | [
"function",
"extend",
"(",
")",
"{",
"var",
"result",
"=",
"{",
"}",
";",
"var",
"objs",
"=",
"Array",
".",
"prototype",
".",
"slice",
".",
"call",
"(",
"arguments",
",",
"0",
")",
";",
"objs",
".",
"forEach",
"(",
"function",
"(",
"props",
",",
"index",
")",
"{",
"for",
"(",
"var",
"prop",
"in",
"props",
")",
"{",
"if",
"(",
"props",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"{",
"result",
"[",
"prop",
"]",
"=",
"props",
"[",
"prop",
"]",
"}",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
] | Extend multi objects.
@returns {object} | [
"Extend",
"multi",
"objects",
"."
] | a3bb3adb807885ce052997b9c9316a35d1b2dc76 | https://github.com/heineiuo/express-res-html/blob/a3bb3adb807885ce052997b9c9316a35d1b2dc76/lib/index.js#L213-L224 |
54,381 | charlieroberts/gibber.graphics.lib | scripts/gibber/geometry.js | function() {
obj.mesh[ propertyName ].set( propertyObject.x, propertyObject.y, propertyObject.z )
} | javascript | function() {
obj.mesh[ propertyName ].set( propertyObject.x, propertyObject.y, propertyObject.z )
} | [
"function",
"(",
")",
"{",
"obj",
".",
"mesh",
"[",
"propertyName",
"]",
".",
"set",
"(",
"propertyObject",
".",
"x",
",",
"propertyObject",
".",
"y",
",",
"propertyObject",
".",
"z",
")",
"}"
] | for each vector rotation, scale, position | [
"for",
"each",
"vector",
"rotation",
"scale",
"position"
] | 2b684b04406bf174a3795d3d360e3a3ca39531cf | https://github.com/charlieroberts/gibber.graphics.lib/blob/2b684b04406bf174a3795d3d360e3a3ca39531cf/scripts/gibber/geometry.js#L196-L198 |
|
54,382 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(point, curve) {
var candidates = [],
w = _convertToBezier(point, curve),
degree = curve.length - 1, higherDegree = (2 * degree) - 1,
numSolutions = _findRoots(w, higherDegree, candidates, 0),
v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0;
for (var i = 0; i < numSolutions; i++) {
v = Vectors.subtract(point, _bezier(curve, degree, candidates[i], null, null));
var newDist = Vectors.square(v);
if (newDist < dist) {
dist = newDist;
t = candidates[i];
}
}
v = Vectors.subtract(point, curve[degree]);
newDist = Vectors.square(v);
if (newDist < dist) {
dist = newDist;
t = 1.0;
}
return {location:t, distance:dist};
} | javascript | function(point, curve) {
var candidates = [],
w = _convertToBezier(point, curve),
degree = curve.length - 1, higherDegree = (2 * degree) - 1,
numSolutions = _findRoots(w, higherDegree, candidates, 0),
v = Vectors.subtract(point, curve[0]), dist = Vectors.square(v), t = 0.0;
for (var i = 0; i < numSolutions; i++) {
v = Vectors.subtract(point, _bezier(curve, degree, candidates[i], null, null));
var newDist = Vectors.square(v);
if (newDist < dist) {
dist = newDist;
t = candidates[i];
}
}
v = Vectors.subtract(point, curve[degree]);
newDist = Vectors.square(v);
if (newDist < dist) {
dist = newDist;
t = 1.0;
}
return {location:t, distance:dist};
} | [
"function",
"(",
"point",
",",
"curve",
")",
"{",
"var",
"candidates",
"=",
"[",
"]",
",",
"w",
"=",
"_convertToBezier",
"(",
"point",
",",
"curve",
")",
",",
"degree",
"=",
"curve",
".",
"length",
"-",
"1",
",",
"higherDegree",
"=",
"(",
"2",
"*",
"degree",
")",
"-",
"1",
",",
"numSolutions",
"=",
"_findRoots",
"(",
"w",
",",
"higherDegree",
",",
"candidates",
",",
"0",
")",
",",
"v",
"=",
"Vectors",
".",
"subtract",
"(",
"point",
",",
"curve",
"[",
"0",
"]",
")",
",",
"dist",
"=",
"Vectors",
".",
"square",
"(",
"v",
")",
",",
"t",
"=",
"0.0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"numSolutions",
";",
"i",
"++",
")",
"{",
"v",
"=",
"Vectors",
".",
"subtract",
"(",
"point",
",",
"_bezier",
"(",
"curve",
",",
"degree",
",",
"candidates",
"[",
"i",
"]",
",",
"null",
",",
"null",
")",
")",
";",
"var",
"newDist",
"=",
"Vectors",
".",
"square",
"(",
"v",
")",
";",
"if",
"(",
"newDist",
"<",
"dist",
")",
"{",
"dist",
"=",
"newDist",
";",
"t",
"=",
"candidates",
"[",
"i",
"]",
";",
"}",
"}",
"v",
"=",
"Vectors",
".",
"subtract",
"(",
"point",
",",
"curve",
"[",
"degree",
"]",
")",
";",
"newDist",
"=",
"Vectors",
".",
"square",
"(",
"v",
")",
";",
"if",
"(",
"newDist",
"<",
"dist",
")",
"{",
"dist",
"=",
"newDist",
";",
"t",
"=",
"1.0",
";",
"}",
"return",
"{",
"location",
":",
"t",
",",
"distance",
":",
"dist",
"}",
";",
"}"
] | Calculates the distance that the point lies from the curve.
@param point a point in the form {x:567, y:3342}
@param curve a Bezier curve in the form [{x:..., y:...}, {x:..., y:...}, {x:..., y:...}, {x:..., y:...}]. note that this is currently
hardcoded to assume cubiz beziers, but would be better off supporting any degree.
@return a JS object literal containing location and distance, for example: {location:0.35, distance:10}. Location is analogous to the location
argument you pass to the pointOnPath function: it is a ratio of distance travelled along the curve. Distance is the distance in pixels from
the point to the curve. | [
"Calculates",
"the",
"distance",
"that",
"the",
"point",
"lies",
"from",
"the",
"curve",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L94-L116 |
|
54,383 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(point, curve) {
var td = _distanceFromCurve(point, curve);
return {point:_bezier(curve, curve.length - 1, td.location, null, null), location:td.location};
} | javascript | function(point, curve) {
var td = _distanceFromCurve(point, curve);
return {point:_bezier(curve, curve.length - 1, td.location, null, null), location:td.location};
} | [
"function",
"(",
"point",
",",
"curve",
")",
"{",
"var",
"td",
"=",
"_distanceFromCurve",
"(",
"point",
",",
"curve",
")",
";",
"return",
"{",
"point",
":",
"_bezier",
"(",
"curve",
",",
"curve",
".",
"length",
"-",
"1",
",",
"td",
".",
"location",
",",
"null",
",",
"null",
")",
",",
"location",
":",
"td",
".",
"location",
"}",
";",
"}"
] | finds the nearest point on the curve to the given point. | [
"finds",
"the",
"nearest",
"point",
"on",
"the",
"curve",
"to",
"the",
"given",
"point",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L120-L123 |
|
54,384 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(w, degree, t, depth) {
var left = [], right = [],
left_count, right_count,
left_t = [], right_t = [];
switch (_getCrossingCount(w, degree)) {
case 0 : {
return 0;
}
case 1 : {
if (depth >= maxRecursion) {
t[0] = (w[0].x + w[degree].x) / 2.0;
return 1;
}
if (_isFlatEnough(w, degree)) {
t[0] = _computeXIntercept(w, degree);
return 1;
}
break;
}
}
_bezier(w, degree, 0.5, left, right);
left_count = _findRoots(left, degree, left_t, depth+1);
right_count = _findRoots(right, degree, right_t, depth+1);
for (var i = 0; i < left_count; i++) t[i] = left_t[i];
for (var i = 0; i < right_count; i++) t[i+left_count] = right_t[i];
return (left_count+right_count);
} | javascript | function(w, degree, t, depth) {
var left = [], right = [],
left_count, right_count,
left_t = [], right_t = [];
switch (_getCrossingCount(w, degree)) {
case 0 : {
return 0;
}
case 1 : {
if (depth >= maxRecursion) {
t[0] = (w[0].x + w[degree].x) / 2.0;
return 1;
}
if (_isFlatEnough(w, degree)) {
t[0] = _computeXIntercept(w, degree);
return 1;
}
break;
}
}
_bezier(w, degree, 0.5, left, right);
left_count = _findRoots(left, degree, left_t, depth+1);
right_count = _findRoots(right, degree, right_t, depth+1);
for (var i = 0; i < left_count; i++) t[i] = left_t[i];
for (var i = 0; i < right_count; i++) t[i+left_count] = right_t[i];
return (left_count+right_count);
} | [
"function",
"(",
"w",
",",
"degree",
",",
"t",
",",
"depth",
")",
"{",
"var",
"left",
"=",
"[",
"]",
",",
"right",
"=",
"[",
"]",
",",
"left_count",
",",
"right_count",
",",
"left_t",
"=",
"[",
"]",
",",
"right_t",
"=",
"[",
"]",
";",
"switch",
"(",
"_getCrossingCount",
"(",
"w",
",",
"degree",
")",
")",
"{",
"case",
"0",
":",
"{",
"return",
"0",
";",
"}",
"case",
"1",
":",
"{",
"if",
"(",
"depth",
">=",
"maxRecursion",
")",
"{",
"t",
"[",
"0",
"]",
"=",
"(",
"w",
"[",
"0",
"]",
".",
"x",
"+",
"w",
"[",
"degree",
"]",
".",
"x",
")",
"/",
"2.0",
";",
"return",
"1",
";",
"}",
"if",
"(",
"_isFlatEnough",
"(",
"w",
",",
"degree",
")",
")",
"{",
"t",
"[",
"0",
"]",
"=",
"_computeXIntercept",
"(",
"w",
",",
"degree",
")",
";",
"return",
"1",
";",
"}",
"break",
";",
"}",
"}",
"_bezier",
"(",
"w",
",",
"degree",
",",
"0.5",
",",
"left",
",",
"right",
")",
";",
"left_count",
"=",
"_findRoots",
"(",
"left",
",",
"degree",
",",
"left_t",
",",
"depth",
"+",
"1",
")",
";",
"right_count",
"=",
"_findRoots",
"(",
"right",
",",
"degree",
",",
"right_t",
",",
"depth",
"+",
"1",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"left_count",
";",
"i",
"++",
")",
"t",
"[",
"i",
"]",
"=",
"left_t",
"[",
"i",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"right_count",
";",
"i",
"++",
")",
"t",
"[",
"i",
"+",
"left_count",
"]",
"=",
"right_t",
"[",
"i",
"]",
";",
"return",
"(",
"left_count",
"+",
"right_count",
")",
";",
"}"
] | counts how many roots there are. | [
"counts",
"how",
"many",
"roots",
"there",
"are",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L159-L186 |
|
54,385 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(curve, location) {
var cc = _getCurveFunctions(curve.length - 1),
_x = 0, _y = 0;
for (var i = 0; i < curve.length ; i++) {
_x = _x + (curve[i].x * cc[i](location));
_y = _y + (curve[i].y * cc[i](location));
}
return {x:_x, y:_y};
} | javascript | function(curve, location) {
var cc = _getCurveFunctions(curve.length - 1),
_x = 0, _y = 0;
for (var i = 0; i < curve.length ; i++) {
_x = _x + (curve[i].x * cc[i](location));
_y = _y + (curve[i].y * cc[i](location));
}
return {x:_x, y:_y};
} | [
"function",
"(",
"curve",
",",
"location",
")",
"{",
"var",
"cc",
"=",
"_getCurveFunctions",
"(",
"curve",
".",
"length",
"-",
"1",
")",
",",
"_x",
"=",
"0",
",",
"_y",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"curve",
".",
"length",
";",
"i",
"++",
")",
"{",
"_x",
"=",
"_x",
"+",
"(",
"curve",
"[",
"i",
"]",
".",
"x",
"*",
"cc",
"[",
"i",
"]",
"(",
"location",
")",
")",
";",
"_y",
"=",
"_y",
"+",
"(",
"curve",
"[",
"i",
"]",
".",
"y",
"*",
"cc",
"[",
"i",
"]",
"(",
"location",
")",
")",
";",
"}",
"return",
"{",
"x",
":",
"_x",
",",
"y",
":",
"_y",
"}",
";",
"}"
] | calculates a point on the curve, for a Bezier of arbitrary order.
@param curve an array of control points, eg [{x:10,y:20}, {x:50,y:50}, {x:100,y:100}, {x:120,y:100}]. For a cubic bezier this should have four points.
@param location a decimal indicating the distance along the curve the point should be located at. this is the distance along the curve as it travels, taking the way it bends into account. should be a number from 0 to 1, inclusive. | [
"calculates",
"a",
"point",
"on",
"the",
"curve",
"for",
"a",
"Bezier",
"of",
"arbitrary",
"order",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L295-L304 |
|
54,386 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(curve, location) {
var p1 = _pointOnPath(curve, location),
p2 = _pointOnPath(curve.slice(0, curve.length - 1), location),
dy = p2.y - p1.y, dx = p2.x - p1.x;
return dy == 0 ? Infinity : Math.atan(dy / dx);
} | javascript | function(curve, location) {
var p1 = _pointOnPath(curve, location),
p2 = _pointOnPath(curve.slice(0, curve.length - 1), location),
dy = p2.y - p1.y, dx = p2.x - p1.x;
return dy == 0 ? Infinity : Math.atan(dy / dx);
} | [
"function",
"(",
"curve",
",",
"location",
")",
"{",
"var",
"p1",
"=",
"_pointOnPath",
"(",
"curve",
",",
"location",
")",
",",
"p2",
"=",
"_pointOnPath",
"(",
"curve",
".",
"slice",
"(",
"0",
",",
"curve",
".",
"length",
"-",
"1",
")",
",",
"location",
")",
",",
"dy",
"=",
"p2",
".",
"y",
"-",
"p1",
".",
"y",
",",
"dx",
"=",
"p2",
".",
"x",
"-",
"p1",
".",
"x",
";",
"return",
"dy",
"==",
"0",
"?",
"Infinity",
":",
"Math",
".",
"atan",
"(",
"dy",
"/",
"dx",
")",
";",
"}"
] | returns the gradient of the curve at the given location, which is a decimal between 0 and 1 inclusive.
thanks // http://bimixual.org/AnimationLibrary/beziertangents.html | [
"returns",
"the",
"gradient",
"of",
"the",
"curve",
"at",
"the",
"given",
"location",
"which",
"is",
"a",
"decimal",
"between",
"0",
"and",
"1",
"inclusive",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L380-L385 |
|
54,387 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(curve, location, distance) {
var p = _pointAlongPath(curve, location, distance);
if (p.location > 1) p.location = 1;
if (p.location < 0) p.location = 0;
return _gradientAtPoint(curve, p.location);
} | javascript | function(curve, location, distance) {
var p = _pointAlongPath(curve, location, distance);
if (p.location > 1) p.location = 1;
if (p.location < 0) p.location = 0;
return _gradientAtPoint(curve, p.location);
} | [
"function",
"(",
"curve",
",",
"location",
",",
"distance",
")",
"{",
"var",
"p",
"=",
"_pointAlongPath",
"(",
"curve",
",",
"location",
",",
"distance",
")",
";",
"if",
"(",
"p",
".",
"location",
">",
"1",
")",
"p",
".",
"location",
"=",
"1",
";",
"if",
"(",
"p",
".",
"location",
"<",
"0",
")",
"p",
".",
"location",
"=",
"0",
";",
"return",
"_gradientAtPoint",
"(",
"curve",
",",
"p",
".",
"location",
")",
";",
"}"
] | returns the gradient of the curve at the point which is 'distance' from the given location.
if this point is greater than location 1, the gradient at location 1 is returned.
if this point is less than location 0, the gradient at location 0 is returned. | [
"returns",
"the",
"gradient",
"of",
"the",
"curve",
"at",
"the",
"point",
"which",
"is",
"distance",
"from",
"the",
"given",
"location",
".",
"if",
"this",
"point",
"is",
"greater",
"than",
"location",
"1",
"the",
"gradient",
"at",
"location",
"1",
"is",
"returned",
".",
"if",
"this",
"point",
"is",
"less",
"than",
"location",
"0",
"the",
"gradient",
"at",
"location",
"0",
"is",
"returned",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L392-L397 |
|
54,388 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function(kObj, scopes, map, fn) {
_each(kObj, function(_kObj) {
_unreg(_kObj, map); // deregister existing scopes
_kObj[fn](scopes); // set scopes
_reg(_kObj, map); // register new ones
});
} | javascript | function(kObj, scopes, map, fn) {
_each(kObj, function(_kObj) {
_unreg(_kObj, map); // deregister existing scopes
_kObj[fn](scopes); // set scopes
_reg(_kObj, map); // register new ones
});
} | [
"function",
"(",
"kObj",
",",
"scopes",
",",
"map",
",",
"fn",
")",
"{",
"_each",
"(",
"kObj",
",",
"function",
"(",
"_kObj",
")",
"{",
"_unreg",
"(",
"_kObj",
",",
"map",
")",
";",
"// deregister existing scopes",
"_kObj",
"[",
"fn",
"]",
"(",
"scopes",
")",
";",
"// set scopes",
"_reg",
"(",
"_kObj",
",",
"map",
")",
";",
"// register new ones",
"}",
")",
";",
"}"
] | does the work of changing scopes | [
"does",
"the",
"work",
"of",
"changing",
"scopes"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L2055-L2061 |
|
54,389 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (_e) {
_draw(_e[0], uip);
_currentInstance.removeClass(_e[0], "jsplumb-dragged");
_currentInstance.select({source: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true);
_currentInstance.select({target: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.targetElementDraggingClass, true);
_currentInstance.getDragManager().dragEnded(_e[0]);
} | javascript | function (_e) {
_draw(_e[0], uip);
_currentInstance.removeClass(_e[0], "jsplumb-dragged");
_currentInstance.select({source: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.sourceElementDraggingClass, true);
_currentInstance.select({target: _e[0]}).removeClass(_currentInstance.elementDraggingClass + " " + _currentInstance.targetElementDraggingClass, true);
_currentInstance.getDragManager().dragEnded(_e[0]);
} | [
"function",
"(",
"_e",
")",
"{",
"_draw",
"(",
"_e",
"[",
"0",
"]",
",",
"uip",
")",
";",
"_currentInstance",
".",
"removeClass",
"(",
"_e",
"[",
"0",
"]",
",",
"\"jsplumb-dragged\"",
")",
";",
"_currentInstance",
".",
"select",
"(",
"{",
"source",
":",
"_e",
"[",
"0",
"]",
"}",
")",
".",
"removeClass",
"(",
"_currentInstance",
".",
"elementDraggingClass",
"+",
"\" \"",
"+",
"_currentInstance",
".",
"sourceElementDraggingClass",
",",
"true",
")",
";",
"_currentInstance",
".",
"select",
"(",
"{",
"target",
":",
"_e",
"[",
"0",
"]",
"}",
")",
".",
"removeClass",
"(",
"_currentInstance",
".",
"elementDraggingClass",
"+",
"\" \"",
"+",
"_currentInstance",
".",
"targetElementDraggingClass",
",",
"true",
")",
";",
"_currentInstance",
".",
"getDragManager",
"(",
")",
".",
"dragEnded",
"(",
"_e",
"[",
"0",
"]",
")",
";",
"}"
] | this is one element | [
"this",
"is",
"one",
"element"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L3556-L3562 |
|
54,390 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (p) {
if (p) {
for (var i = 0; i < p.childNodes.length; i++) {
if (p.childNodes[i].nodeType != 3 && p.childNodes[i].nodeType != 8) {
var cEl = jsPlumb.getElement(p.childNodes[i]),
cid = _currentInstance.getId(p.childNodes[i], null, true);
if (cid && _elementsWithEndpoints[cid] && _elementsWithEndpoints[cid] > 0) {
var cOff = _currentInstance.getOffset(cEl);
_delements[id][cid] = {
id: cid,
offset: {
left: cOff.left - parentOffset.left,
top: cOff.top - parentOffset.top
}
};
_draggablesForElements[cid] = id;
}
_oneLevel(p.childNodes[i]);
}
}
}
} | javascript | function (p) {
if (p) {
for (var i = 0; i < p.childNodes.length; i++) {
if (p.childNodes[i].nodeType != 3 && p.childNodes[i].nodeType != 8) {
var cEl = jsPlumb.getElement(p.childNodes[i]),
cid = _currentInstance.getId(p.childNodes[i], null, true);
if (cid && _elementsWithEndpoints[cid] && _elementsWithEndpoints[cid] > 0) {
var cOff = _currentInstance.getOffset(cEl);
_delements[id][cid] = {
id: cid,
offset: {
left: cOff.left - parentOffset.left,
top: cOff.top - parentOffset.top
}
};
_draggablesForElements[cid] = id;
}
_oneLevel(p.childNodes[i]);
}
}
}
} | [
"function",
"(",
"p",
")",
"{",
"if",
"(",
"p",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"p",
".",
"childNodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"p",
".",
"childNodes",
"[",
"i",
"]",
".",
"nodeType",
"!=",
"3",
"&&",
"p",
".",
"childNodes",
"[",
"i",
"]",
".",
"nodeType",
"!=",
"8",
")",
"{",
"var",
"cEl",
"=",
"jsPlumb",
".",
"getElement",
"(",
"p",
".",
"childNodes",
"[",
"i",
"]",
")",
",",
"cid",
"=",
"_currentInstance",
".",
"getId",
"(",
"p",
".",
"childNodes",
"[",
"i",
"]",
",",
"null",
",",
"true",
")",
";",
"if",
"(",
"cid",
"&&",
"_elementsWithEndpoints",
"[",
"cid",
"]",
"&&",
"_elementsWithEndpoints",
"[",
"cid",
"]",
">",
"0",
")",
"{",
"var",
"cOff",
"=",
"_currentInstance",
".",
"getOffset",
"(",
"cEl",
")",
";",
"_delements",
"[",
"id",
"]",
"[",
"cid",
"]",
"=",
"{",
"id",
":",
"cid",
",",
"offset",
":",
"{",
"left",
":",
"cOff",
".",
"left",
"-",
"parentOffset",
".",
"left",
",",
"top",
":",
"cOff",
".",
"top",
"-",
"parentOffset",
".",
"top",
"}",
"}",
";",
"_draggablesForElements",
"[",
"cid",
"]",
"=",
"id",
";",
"}",
"_oneLevel",
"(",
"p",
".",
"childNodes",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}",
"}"
] | look for child elements that have endpoints and register them against this draggable. | [
"look",
"for",
"child",
"elements",
"that",
"have",
"endpoints",
"and",
"register",
"them",
"against",
"this",
"draggable",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L5957-L5978 |
|
54,391 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (evt, el, zoom) {
var box = typeof el.getBoundingClientRect !== "undefined" ? el.getBoundingClientRect() : { left: 0, top: 0, width: 0, height: 0 },
body = document.body,
docElem = document.documentElement,
scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop,
scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft,
clientTop = docElem.clientTop || body.clientTop || 0,
clientLeft = docElem.clientLeft || body.clientLeft || 0,
pst = 0,
psl = 0,
top = box.top + scrollTop - clientTop + (pst * zoom),
left = box.left + scrollLeft - clientLeft + (psl * zoom),
cl = jsPlumb.pageLocation(evt),
w = box.width || (el.offsetWidth * zoom),
h = box.height || (el.offsetHeight * zoom),
x = (cl[0] - left) / w,
y = (cl[1] - top) / h;
return [ x, y ];
} | javascript | function (evt, el, zoom) {
var box = typeof el.getBoundingClientRect !== "undefined" ? el.getBoundingClientRect() : { left: 0, top: 0, width: 0, height: 0 },
body = document.body,
docElem = document.documentElement,
scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop,
scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft,
clientTop = docElem.clientTop || body.clientTop || 0,
clientLeft = docElem.clientLeft || body.clientLeft || 0,
pst = 0,
psl = 0,
top = box.top + scrollTop - clientTop + (pst * zoom),
left = box.left + scrollLeft - clientLeft + (psl * zoom),
cl = jsPlumb.pageLocation(evt),
w = box.width || (el.offsetWidth * zoom),
h = box.height || (el.offsetHeight * zoom),
x = (cl[0] - left) / w,
y = (cl[1] - top) / h;
return [ x, y ];
} | [
"function",
"(",
"evt",
",",
"el",
",",
"zoom",
")",
"{",
"var",
"box",
"=",
"typeof",
"el",
".",
"getBoundingClientRect",
"!==",
"\"undefined\"",
"?",
"el",
".",
"getBoundingClientRect",
"(",
")",
":",
"{",
"left",
":",
"0",
",",
"top",
":",
"0",
",",
"width",
":",
"0",
",",
"height",
":",
"0",
"}",
",",
"body",
"=",
"document",
".",
"body",
",",
"docElem",
"=",
"document",
".",
"documentElement",
",",
"scrollTop",
"=",
"window",
".",
"pageYOffset",
"||",
"docElem",
".",
"scrollTop",
"||",
"body",
".",
"scrollTop",
",",
"scrollLeft",
"=",
"window",
".",
"pageXOffset",
"||",
"docElem",
".",
"scrollLeft",
"||",
"body",
".",
"scrollLeft",
",",
"clientTop",
"=",
"docElem",
".",
"clientTop",
"||",
"body",
".",
"clientTop",
"||",
"0",
",",
"clientLeft",
"=",
"docElem",
".",
"clientLeft",
"||",
"body",
".",
"clientLeft",
"||",
"0",
",",
"pst",
"=",
"0",
",",
"psl",
"=",
"0",
",",
"top",
"=",
"box",
".",
"top",
"+",
"scrollTop",
"-",
"clientTop",
"+",
"(",
"pst",
"*",
"zoom",
")",
",",
"left",
"=",
"box",
".",
"left",
"+",
"scrollLeft",
"-",
"clientLeft",
"+",
"(",
"psl",
"*",
"zoom",
")",
",",
"cl",
"=",
"jsPlumb",
".",
"pageLocation",
"(",
"evt",
")",
",",
"w",
"=",
"box",
".",
"width",
"||",
"(",
"el",
".",
"offsetWidth",
"*",
"zoom",
")",
",",
"h",
"=",
"box",
".",
"height",
"||",
"(",
"el",
".",
"offsetHeight",
"*",
"zoom",
")",
",",
"x",
"=",
"(",
"cl",
"[",
"0",
"]",
"-",
"left",
")",
"/",
"w",
",",
"y",
"=",
"(",
"cl",
"[",
"1",
"]",
"-",
"top",
")",
"/",
"h",
";",
"return",
"[",
"x",
",",
"y",
"]",
";",
"}"
] | return x+y proportion of the given element's size corresponding to the location of the given event. | [
"return",
"x",
"+",
"y",
"proportion",
"of",
"the",
"given",
"element",
"s",
"size",
"corresponding",
"to",
"the",
"location",
"of",
"the",
"given",
"event",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L6322-L6341 |
|
54,392 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (endpoint, placeholder, _jsPlumb) {
var stopped = false;
return {
drag: function () {
if (stopped) {
stopped = false;
return true;
}
if (placeholder.element) {
var _ui = _jsPlumb.getUIPosition(arguments, _jsPlumb.getZoom());
jsPlumb.setPosition(placeholder.element, _ui);
_jsPlumb.repaint(placeholder.element, _ui);
// always repaint the source endpoint, because only continuous/dynamic anchors cause the endpoint
// to be repainted, so static anchors need to be told (or the endpoint gets dragged around)
endpoint.paint({anchorPoint:endpoint.anchor.getCurrentLocation({element:endpoint.element})});
}
},
stopDrag: function () {
stopped = true;
}
};
} | javascript | function (endpoint, placeholder, _jsPlumb) {
var stopped = false;
return {
drag: function () {
if (stopped) {
stopped = false;
return true;
}
if (placeholder.element) {
var _ui = _jsPlumb.getUIPosition(arguments, _jsPlumb.getZoom());
jsPlumb.setPosition(placeholder.element, _ui);
_jsPlumb.repaint(placeholder.element, _ui);
// always repaint the source endpoint, because only continuous/dynamic anchors cause the endpoint
// to be repainted, so static anchors need to be told (or the endpoint gets dragged around)
endpoint.paint({anchorPoint:endpoint.anchor.getCurrentLocation({element:endpoint.element})});
}
},
stopDrag: function () {
stopped = true;
}
};
} | [
"function",
"(",
"endpoint",
",",
"placeholder",
",",
"_jsPlumb",
")",
"{",
"var",
"stopped",
"=",
"false",
";",
"return",
"{",
"drag",
":",
"function",
"(",
")",
"{",
"if",
"(",
"stopped",
")",
"{",
"stopped",
"=",
"false",
";",
"return",
"true",
";",
"}",
"if",
"(",
"placeholder",
".",
"element",
")",
"{",
"var",
"_ui",
"=",
"_jsPlumb",
".",
"getUIPosition",
"(",
"arguments",
",",
"_jsPlumb",
".",
"getZoom",
"(",
")",
")",
";",
"jsPlumb",
".",
"setPosition",
"(",
"placeholder",
".",
"element",
",",
"_ui",
")",
";",
"_jsPlumb",
".",
"repaint",
"(",
"placeholder",
".",
"element",
",",
"_ui",
")",
";",
"// always repaint the source endpoint, because only continuous/dynamic anchors cause the endpoint",
"// to be repainted, so static anchors need to be told (or the endpoint gets dragged around)",
"endpoint",
".",
"paint",
"(",
"{",
"anchorPoint",
":",
"endpoint",
".",
"anchor",
".",
"getCurrentLocation",
"(",
"{",
"element",
":",
"endpoint",
".",
"element",
"}",
")",
"}",
")",
";",
"}",
"}",
",",
"stopDrag",
":",
"function",
"(",
")",
"{",
"stopped",
"=",
"true",
";",
"}",
"}",
";",
"}"
] | create the drag handler for a connection | [
"create",
"the",
"drag",
"handler",
"for",
"a",
"connection"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L6682-L6704 |
|
54,393 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (placeholder, _jsPlumb, ipco, ips) {
var n = jsPlumb.createElement("div", { position : "absolute" });
_jsPlumb.appendElement(n);
var id = _jsPlumb.getId(n);
jsPlumb.setPosition(n, ipco);
n.style.width = ips[0] + "px";
n.style.height = ips[1] + "px";
_jsPlumb.manage(id, n, true); // TRANSIENT MANAGE
// create and assign an id, and initialize the offset.
placeholder.id = id;
placeholder.element = n;
} | javascript | function (placeholder, _jsPlumb, ipco, ips) {
var n = jsPlumb.createElement("div", { position : "absolute" });
_jsPlumb.appendElement(n);
var id = _jsPlumb.getId(n);
jsPlumb.setPosition(n, ipco);
n.style.width = ips[0] + "px";
n.style.height = ips[1] + "px";
_jsPlumb.manage(id, n, true); // TRANSIENT MANAGE
// create and assign an id, and initialize the offset.
placeholder.id = id;
placeholder.element = n;
} | [
"function",
"(",
"placeholder",
",",
"_jsPlumb",
",",
"ipco",
",",
"ips",
")",
"{",
"var",
"n",
"=",
"jsPlumb",
".",
"createElement",
"(",
"\"div\"",
",",
"{",
"position",
":",
"\"absolute\"",
"}",
")",
";",
"_jsPlumb",
".",
"appendElement",
"(",
"n",
")",
";",
"var",
"id",
"=",
"_jsPlumb",
".",
"getId",
"(",
"n",
")",
";",
"jsPlumb",
".",
"setPosition",
"(",
"n",
",",
"ipco",
")",
";",
"n",
".",
"style",
".",
"width",
"=",
"ips",
"[",
"0",
"]",
"+",
"\"px\"",
";",
"n",
".",
"style",
".",
"height",
"=",
"ips",
"[",
"1",
"]",
"+",
"\"px\"",
";",
"_jsPlumb",
".",
"manage",
"(",
"id",
",",
"n",
",",
"true",
")",
";",
"// TRANSIENT MANAGE",
"// create and assign an id, and initialize the offset.",
"placeholder",
".",
"id",
"=",
"id",
";",
"placeholder",
".",
"element",
"=",
"n",
";",
"}"
] | creates a placeholder div for dragging purposes, adds it, and pre-computes its offset. | [
"creates",
"a",
"placeholder",
"div",
"for",
"dragging",
"purposes",
"adds",
"it",
"and",
"pre",
"-",
"computes",
"its",
"offset",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L6707-L6718 |
|
54,394 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (ep, elementWithPrecedence) {
var idx = 0;
if (elementWithPrecedence != null) {
for (var i = 0; i < ep.connections.length; i++) {
if (ep.connections[i].sourceId == elementWithPrecedence || ep.connections[i].targetId == elementWithPrecedence) {
idx = i;
break;
}
}
}
return ep.connections[idx];
} | javascript | function (ep, elementWithPrecedence) {
var idx = 0;
if (elementWithPrecedence != null) {
for (var i = 0; i < ep.connections.length; i++) {
if (ep.connections[i].sourceId == elementWithPrecedence || ep.connections[i].targetId == elementWithPrecedence) {
idx = i;
break;
}
}
}
return ep.connections[idx];
} | [
"function",
"(",
"ep",
",",
"elementWithPrecedence",
")",
"{",
"var",
"idx",
"=",
"0",
";",
"if",
"(",
"elementWithPrecedence",
"!=",
"null",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ep",
".",
"connections",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"ep",
".",
"connections",
"[",
"i",
"]",
".",
"sourceId",
"==",
"elementWithPrecedence",
"||",
"ep",
".",
"connections",
"[",
"i",
"]",
".",
"targetId",
"==",
"elementWithPrecedence",
")",
"{",
"idx",
"=",
"i",
";",
"break",
";",
"}",
"}",
"}",
"return",
"ep",
".",
"connections",
"[",
"idx",
"]",
";",
"}"
] | a helper function that tries to find a connection to the given element, and returns it if so. if elementWithPrecedence is null, or no connection to it is found, we return the first connection in our list. | [
"a",
"helper",
"function",
"that",
"tries",
"to",
"find",
"a",
"connection",
"to",
"the",
"given",
"element",
"and",
"returns",
"it",
"if",
"so",
".",
"if",
"elementWithPrecedence",
"is",
"null",
"or",
"no",
"connection",
"to",
"it",
"is",
"found",
"we",
"return",
"the",
"first",
"connection",
"in",
"our",
"list",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L6740-L6752 |
|
54,395 | skerit/alchemy-styleboost | assets/scripts/jsplumb/2.0/jsplumb.js | function (a, b, c) {
return c >= Math.min(a, b) && c <= Math.max(a, b);
} | javascript | function (a, b, c) {
return c >= Math.min(a, b) && c <= Math.max(a, b);
} | [
"function",
"(",
"a",
",",
"b",
",",
"c",
")",
"{",
"return",
"c",
">=",
"Math",
".",
"min",
"(",
"a",
",",
"b",
")",
"&&",
"c",
"<=",
"Math",
".",
"max",
"(",
"a",
",",
"b",
")",
";",
"}"
] | is c between a and b? | [
"is",
"c",
"between",
"a",
"and",
"b?"
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/jsplumb/2.0/jsplumb.js#L9757-L9759 |
|
54,396 | DmitryMyadzelets/u-machine | examples/oauth-client/oauth/provider.js | done | function done(req, next, err, obj) {
if (err) {
req.error = {error: err.error || err.message};
} else {
req.provider = obj;
}
next();
} | javascript | function done(req, next, err, obj) {
if (err) {
req.error = {error: err.error || err.message};
} else {
req.provider = obj;
}
next();
} | [
"function",
"done",
"(",
"req",
",",
"next",
",",
"err",
",",
"obj",
")",
"{",
"if",
"(",
"err",
")",
"{",
"req",
".",
"error",
"=",
"{",
"error",
":",
"err",
".",
"error",
"||",
"err",
".",
"message",
"}",
";",
"}",
"else",
"{",
"req",
".",
"provider",
"=",
"obj",
";",
"}",
"next",
"(",
")",
";",
"}"
] | Sets error and data object | [
"Sets",
"error",
"and",
"data",
"object"
] | 1a01636b0211abc148feeda4108383d93368c4c7 | https://github.com/DmitryMyadzelets/u-machine/blob/1a01636b0211abc148feeda4108383d93368c4c7/examples/oauth-client/oauth/provider.js#L9-L16 |
54,397 | DmitryMyadzelets/u-machine | examples/oauth-client/oauth/provider.js | check | function check(err, res, body) {
if (err) {
return this.machine(err);
}
var obj;
try {
obj = JSON.parse(body);
} catch (e) {
return this.machine(new Error('Failed to parse as JSON (' + e.message + ') the text: ' + body));
}
if (res.statusCode !== 200) {
return this.machine(obj);
}
this.machine(err, obj);
} | javascript | function check(err, res, body) {
if (err) {
return this.machine(err);
}
var obj;
try {
obj = JSON.parse(body);
} catch (e) {
return this.machine(new Error('Failed to parse as JSON (' + e.message + ') the text: ' + body));
}
if (res.statusCode !== 200) {
return this.machine(obj);
}
this.machine(err, obj);
} | [
"function",
"check",
"(",
"err",
",",
"res",
",",
"body",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"this",
".",
"machine",
"(",
"err",
")",
";",
"}",
"var",
"obj",
";",
"try",
"{",
"obj",
"=",
"JSON",
".",
"parse",
"(",
"body",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"return",
"this",
".",
"machine",
"(",
"new",
"Error",
"(",
"'Failed to parse as JSON ('",
"+",
"e",
".",
"message",
"+",
"') the text: '",
"+",
"body",
")",
")",
";",
"}",
"if",
"(",
"res",
".",
"statusCode",
"!==",
"200",
")",
"{",
"return",
"this",
".",
"machine",
"(",
"obj",
")",
";",
"}",
"this",
".",
"machine",
"(",
"err",
",",
"obj",
")",
";",
"}"
] | Callback for 'request'. Checks response | [
"Callback",
"for",
"request",
".",
"Checks",
"response"
] | 1a01636b0211abc148feeda4108383d93368c4c7 | https://github.com/DmitryMyadzelets/u-machine/blob/1a01636b0211abc148feeda4108383d93368c4c7/examples/oauth-client/oauth/provider.js#L19-L33 |
54,398 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/templates/dialogs/templates.js | renderTemplatesList | function renderTemplatesList( container, templatesDefinitions ) {
// clear loading wait text.
container.setHtml( '' );
for ( var i = 0, totalDefs = templatesDefinitions.length; i < totalDefs; i++ ) {
var definition = CKEDITOR.getTemplates( templatesDefinitions[ i ] ),
imagesPath = definition.imagesPath,
templates = definition.templates,
count = templates.length;
for ( var j = 0; j < count; j++ ) {
var template = templates[ j ],
item = createTemplateItem( template, imagesPath );
item.setAttribute( 'aria-posinset', j + 1 );
item.setAttribute( 'aria-setsize', count );
container.append( item );
}
}
} | javascript | function renderTemplatesList( container, templatesDefinitions ) {
// clear loading wait text.
container.setHtml( '' );
for ( var i = 0, totalDefs = templatesDefinitions.length; i < totalDefs; i++ ) {
var definition = CKEDITOR.getTemplates( templatesDefinitions[ i ] ),
imagesPath = definition.imagesPath,
templates = definition.templates,
count = templates.length;
for ( var j = 0; j < count; j++ ) {
var template = templates[ j ],
item = createTemplateItem( template, imagesPath );
item.setAttribute( 'aria-posinset', j + 1 );
item.setAttribute( 'aria-setsize', count );
container.append( item );
}
}
} | [
"function",
"renderTemplatesList",
"(",
"container",
",",
"templatesDefinitions",
")",
"{",
"// clear loading wait text.\r",
"container",
".",
"setHtml",
"(",
"''",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"totalDefs",
"=",
"templatesDefinitions",
".",
"length",
";",
"i",
"<",
"totalDefs",
";",
"i",
"++",
")",
"{",
"var",
"definition",
"=",
"CKEDITOR",
".",
"getTemplates",
"(",
"templatesDefinitions",
"[",
"i",
"]",
")",
",",
"imagesPath",
"=",
"definition",
".",
"imagesPath",
",",
"templates",
"=",
"definition",
".",
"templates",
",",
"count",
"=",
"templates",
".",
"length",
";",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"count",
";",
"j",
"++",
")",
"{",
"var",
"template",
"=",
"templates",
"[",
"j",
"]",
",",
"item",
"=",
"createTemplateItem",
"(",
"template",
",",
"imagesPath",
")",
";",
"item",
".",
"setAttribute",
"(",
"'aria-posinset'",
",",
"j",
"+",
"1",
")",
";",
"item",
".",
"setAttribute",
"(",
"'aria-setsize'",
",",
"count",
")",
";",
"container",
".",
"append",
"(",
"item",
")",
";",
"}",
"}",
"}"
] | Constructs the HTML view of the specified templates data. | [
"Constructs",
"the",
"HTML",
"view",
"of",
"the",
"specified",
"templates",
"data",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/templates/dialogs/templates.js#L11-L29 |
54,399 | skerit/alchemy-styleboost | public/ckeditor/4.4dev/plugins/templates/dialogs/templates.js | insertTemplate | function insertTemplate( html ) {
var dialog = CKEDITOR.dialog.getCurrent(),
isReplace = dialog.getValueOf( 'selectTpl', 'chkInsertOpt' );
if ( isReplace ) {
editor.fire( 'saveSnapshot' );
// Everything should happen after the document is loaded (#4073).
editor.setData( html, function() {
dialog.hide();
// Place the cursor at the first editable place.
var range = editor.createRange();
range.moveToElementEditStart( editor.editable() );
range.select();
setTimeout( function() {
editor.fire( 'saveSnapshot' );
}, 0 );
} );
} else {
editor.insertHtml( html );
dialog.hide();
}
} | javascript | function insertTemplate( html ) {
var dialog = CKEDITOR.dialog.getCurrent(),
isReplace = dialog.getValueOf( 'selectTpl', 'chkInsertOpt' );
if ( isReplace ) {
editor.fire( 'saveSnapshot' );
// Everything should happen after the document is loaded (#4073).
editor.setData( html, function() {
dialog.hide();
// Place the cursor at the first editable place.
var range = editor.createRange();
range.moveToElementEditStart( editor.editable() );
range.select();
setTimeout( function() {
editor.fire( 'saveSnapshot' );
}, 0 );
} );
} else {
editor.insertHtml( html );
dialog.hide();
}
} | [
"function",
"insertTemplate",
"(",
"html",
")",
"{",
"var",
"dialog",
"=",
"CKEDITOR",
".",
"dialog",
".",
"getCurrent",
"(",
")",
",",
"isReplace",
"=",
"dialog",
".",
"getValueOf",
"(",
"'selectTpl'",
",",
"'chkInsertOpt'",
")",
";",
"if",
"(",
"isReplace",
")",
"{",
"editor",
".",
"fire",
"(",
"'saveSnapshot'",
")",
";",
"// Everything should happen after the document is loaded (#4073).\r",
"editor",
".",
"setData",
"(",
"html",
",",
"function",
"(",
")",
"{",
"dialog",
".",
"hide",
"(",
")",
";",
"// Place the cursor at the first editable place.\r",
"var",
"range",
"=",
"editor",
".",
"createRange",
"(",
")",
";",
"range",
".",
"moveToElementEditStart",
"(",
"editor",
".",
"editable",
"(",
")",
")",
";",
"range",
".",
"select",
"(",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"editor",
".",
"fire",
"(",
"'saveSnapshot'",
")",
";",
"}",
",",
"0",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"editor",
".",
"insertHtml",
"(",
"html",
")",
";",
"dialog",
".",
"hide",
"(",
")",
";",
"}",
"}"
] | Insert the specified template content into editor. @param {Number} index | [
"Insert",
"the",
"specified",
"template",
"content",
"into",
"editor",
"."
] | 2b90b8a6afc9f065f785651292fb193940021d90 | https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/templates/dialogs/templates.js#L60-L83 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.