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
57,300
AndreasMadsen/immortal
lib/module.js
checkPath
function checkPath(name, path) { helpers.exists(path, function (exist) { if (!exist) { callback(new Error(name + ' was not found (' + path + ')')); return; } progress.set(name); }); }
javascript
function checkPath(name, path) { helpers.exists(path, function (exist) { if (!exist) { callback(new Error(name + ' was not found (' + path + ')')); return; } progress.set(name); }); }
[ "function", "checkPath", "(", "name", ",", "path", ")", "{", "helpers", ".", "exists", "(", "path", ",", "function", "(", "exist", ")", "{", "if", "(", "!", "exist", ")", "{", "callback", "(", "new", "Error", "(", "name", "+", "' was not found ('", "+", "path", "+", "')'", ")", ")", ";", "return", ";", "}", "progress", ".", "set", "(", "name", ")", ";", "}", ")", ";", "}" ]
check file paths
[ "check", "file", "paths" ]
c1ab5a4287a543fdfd980604a9e9927d663a9ef2
https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/module.js#L104-L111
57,301
AndreasMadsen/immortal
lib/module.js
execFile
function execFile() { var child; if (options.strategy === 'development') { child = core.spawnPump(options, false, false); if (options.relay) child.pump(process); } else if (options.strategy === 'unattached') { child = core.spawnPump(options, true, false); } else if (options.strategy === 'daemon') { child = core.spawnDaemon(options, true); } // start child child.spawn(); child.on('start', function () { callback(null); }); }
javascript
function execFile() { var child; if (options.strategy === 'development') { child = core.spawnPump(options, false, false); if (options.relay) child.pump(process); } else if (options.strategy === 'unattached') { child = core.spawnPump(options, true, false); } else if (options.strategy === 'daemon') { child = core.spawnDaemon(options, true); } // start child child.spawn(); child.on('start', function () { callback(null); }); }
[ "function", "execFile", "(", ")", "{", "var", "child", ";", "if", "(", "options", ".", "strategy", "===", "'development'", ")", "{", "child", "=", "core", ".", "spawnPump", "(", "options", ",", "false", ",", "false", ")", ";", "if", "(", "options", ".", "relay", ")", "child", ".", "pump", "(", "process", ")", ";", "}", "else", "if", "(", "options", ".", "strategy", "===", "'unattached'", ")", "{", "child", "=", "core", ".", "spawnPump", "(", "options", ",", "true", ",", "false", ")", ";", "}", "else", "if", "(", "options", ".", "strategy", "===", "'daemon'", ")", "{", "child", "=", "core", ".", "spawnDaemon", "(", "options", ",", "true", ")", ";", "}", "// start child", "child", ".", "spawn", "(", ")", ";", "child", ".", "on", "(", "'start'", ",", "function", "(", ")", "{", "callback", "(", "null", ")", ";", "}", ")", ";", "}" ]
this will execute when all tests are made
[ "this", "will", "execute", "when", "all", "tests", "are", "made" ]
c1ab5a4287a543fdfd980604a9e9927d663a9ef2
https://github.com/AndreasMadsen/immortal/blob/c1ab5a4287a543fdfd980604a9e9927d663a9ef2/lib/module.js#L140-L158
57,302
sreenaths/em-tgraph
addon/utils/graph-view.js
function (mx, my, q1x1, q1y1, q1x, q1y, q2x1, q2y1, q2x, q2y ) { return `M ${mx} ${my} Q ${q1x1} ${q1y1} ${q1x} ${q1y} Q ${q2x1} ${q2y1} ${q2x} ${q2y}`; }
javascript
function (mx, my, q1x1, q1y1, q1x, q1y, q2x1, q2y1, q2x, q2y ) { return `M ${mx} ${my} Q ${q1x1} ${q1y1} ${q1x} ${q1y} Q ${q2x1} ${q2y1} ${q2x} ${q2y}`; }
[ "function", "(", "mx", ",", "my", ",", "q1x1", ",", "q1y1", ",", "q1x", ",", "q1y", ",", "q2x1", ",", "q2y1", ",", "q2x", ",", "q2y", ")", "{", "return", "`", "${", "mx", "}", "${", "my", "}", "${", "q1x1", "}", "${", "q1y1", "}", "${", "q1x", "}", "${", "q1y", "}", "${", "q2x1", "}", "${", "q2y1", "}", "${", "q2x", "}", "${", "q2y", "}", "`", ";", "}" ]
Defines how path between nodes are drawn
[ "Defines", "how", "path", "between", "nodes", "are", "drawn" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L86-L88
57,303
sreenaths/em-tgraph
addon/utils/graph-view.js
_addTaskBubble
function _addTaskBubble(node, d) { var group = node.append('g'); group.attr('class', 'task-bubble'); group.append('use').attr('xlink:href', '#task-bubble'); translateIfIE(group.append('text') .text(_trimText(d.get('data.totalTasks') || 0, 3)), 0, 4); translateIfIE(group, 38, -15); }
javascript
function _addTaskBubble(node, d) { var group = node.append('g'); group.attr('class', 'task-bubble'); group.append('use').attr('xlink:href', '#task-bubble'); translateIfIE(group.append('text') .text(_trimText(d.get('data.totalTasks') || 0, 3)), 0, 4); translateIfIE(group, 38, -15); }
[ "function", "_addTaskBubble", "(", "node", ",", "d", ")", "{", "var", "group", "=", "node", ".", "append", "(", "'g'", ")", ";", "group", ".", "attr", "(", "'class'", ",", "'task-bubble'", ")", ";", "group", ".", "append", "(", "'use'", ")", ".", "attr", "(", "'xlink:href'", ",", "'#task-bubble'", ")", ";", "translateIfIE", "(", "group", ".", "append", "(", "'text'", ")", ".", "text", "(", "_trimText", "(", "d", ".", "get", "(", "'data.totalTasks'", ")", "||", "0", ",", "3", ")", ")", ",", "0", ",", "4", ")", ";", "translateIfIE", "(", "group", ",", "38", ",", "-", "15", ")", ";", "}" ]
Add task bubble to a vertex node @param node {SVG DOM element} Vertex node @param d {VertexDataNode}
[ "Add", "task", "bubble", "to", "a", "vertex", "node" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L171-L179
57,304
sreenaths/em-tgraph
addon/utils/graph-view.js
_addVertexGroupBubble
function _addVertexGroupBubble(node, d) { var group; if(d.vertexGroup) { group = node.append('g'); group.attr('class', 'group-bubble'); group.append('use').attr('xlink:href', '#group-bubble'); translateIfIE(group.append('text') .text(_trimText(d.get('vertexGroup.groupMembers.length'), 2)), 0, 4); translateIfIE(group, 38, 15); } }
javascript
function _addVertexGroupBubble(node, d) { var group; if(d.vertexGroup) { group = node.append('g'); group.attr('class', 'group-bubble'); group.append('use').attr('xlink:href', '#group-bubble'); translateIfIE(group.append('text') .text(_trimText(d.get('vertexGroup.groupMembers.length'), 2)), 0, 4); translateIfIE(group, 38, 15); } }
[ "function", "_addVertexGroupBubble", "(", "node", ",", "d", ")", "{", "var", "group", ";", "if", "(", "d", ".", "vertexGroup", ")", "{", "group", "=", "node", ".", "append", "(", "'g'", ")", ";", "group", ".", "attr", "(", "'class'", ",", "'group-bubble'", ")", ";", "group", ".", "append", "(", "'use'", ")", ".", "attr", "(", "'xlink:href'", ",", "'#group-bubble'", ")", ";", "translateIfIE", "(", "group", ".", "append", "(", "'text'", ")", ".", "text", "(", "_trimText", "(", "d", ".", "get", "(", "'vertexGroup.groupMembers.length'", ")", ",", "2", ")", ")", ",", "0", ",", "4", ")", ";", "translateIfIE", "(", "group", ",", "38", ",", "15", ")", ";", "}", "}" ]
Add vertex group bubble to a vertex node @param node {SVG DOM element} Vertex node @param d {VertexDataNode}
[ "Add", "vertex", "group", "bubble", "to", "a", "vertex", "node" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L205-L217
57,305
sreenaths/em-tgraph
addon/utils/graph-view.js
_addStatusBar
function _addStatusBar(node, d) { var group = node.append('g'); group.attr('class', 'status-bar'); group.append('foreignObject') .attr("class", "status") .attr("width", 70) .attr("height", 15) .html('<span class="msg-container">' + d.get('data.status') + '</span>' ); }
javascript
function _addStatusBar(node, d) { var group = node.append('g'); group.attr('class', 'status-bar'); group.append('foreignObject') .attr("class", "status") .attr("width", 70) .attr("height", 15) .html('<span class="msg-container">' + d.get('data.status') + '</span>' ); }
[ "function", "_addStatusBar", "(", "node", ",", "d", ")", "{", "var", "group", "=", "node", ".", "append", "(", "'g'", ")", ";", "group", ".", "attr", "(", "'class'", ",", "'status-bar'", ")", ";", "group", ".", "append", "(", "'foreignObject'", ")", ".", "attr", "(", "\"class\"", ",", "\"status\"", ")", ".", "attr", "(", "\"width\"", ",", "70", ")", ".", "attr", "(", "\"height\"", ",", "15", ")", ".", "html", "(", "'<span class=\"msg-container\">'", "+", "d", ".", "get", "(", "'data.status'", ")", "+", "'</span>'", ")", ";", "}" ]
Add status bar to a vertex node @param node {SVG DOM element} Vertex node @param d {VertexDataNode}
[ "Add", "status", "bar", "to", "a", "vertex", "node" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L223-L235
57,306
sreenaths/em-tgraph
addon/utils/graph-view.js
_addBasicContents
function _addBasicContents(node, d, titleProperty, maxTitleLength) { var className = d.type; node.attr('class', `node ${className}`); node.append('use').attr('xlink:href', `#${className}-bg`); translateIfIE(node.append('text') .attr('class', 'title') .text(_trimText(d.get(titleProperty || 'name'), maxTitleLength || 12)), 0, 4); }
javascript
function _addBasicContents(node, d, titleProperty, maxTitleLength) { var className = d.type; node.attr('class', `node ${className}`); node.append('use').attr('xlink:href', `#${className}-bg`); translateIfIE(node.append('text') .attr('class', 'title') .text(_trimText(d.get(titleProperty || 'name'), maxTitleLength || 12)), 0, 4); }
[ "function", "_addBasicContents", "(", "node", ",", "d", ",", "titleProperty", ",", "maxTitleLength", ")", "{", "var", "className", "=", "d", ".", "type", ";", "node", ".", "attr", "(", "'class'", ",", "`", "${", "className", "}", "`", ")", ";", "node", ".", "append", "(", "'use'", ")", ".", "attr", "(", "'xlink:href'", ",", "`", "${", "className", "}", "`", ")", ";", "translateIfIE", "(", "node", ".", "append", "(", "'text'", ")", ".", "attr", "(", "'class'", ",", "'title'", ")", ".", "text", "(", "_trimText", "(", "d", ".", "get", "(", "titleProperty", "||", "'name'", ")", ",", "maxTitleLength", "||", "12", ")", ")", ",", "0", ",", "4", ")", ";", "}" ]
Creates a base SVG DOM node, with bg and title based on the type of DataNode @param node {SVG DOM element} Vertex node @param d {DataNode} @param titleProperty {String} d's property who's value is the title to be displayed. By default 'name'. @param maxTitleLength {Number} Title would be trimmed beyond maxTitleLength. By default 3 chars
[ "Creates", "a", "base", "SVG", "DOM", "node", "with", "bg", "and", "title", "based", "on", "the", "type", "of", "DataNode" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L244-L252
57,307
sreenaths/em-tgraph
addon/utils/graph-view.js
_addContent
function _addContent(d) { var node = d3.select(this); switch(d.type) { case 'vertex': _addBasicContents(node, d, 'vertexName'); _addStatusBar(node, d); _addTaskBubble(node, d); _addIOBubble(node, d); _addVertexGroupBubble(node, d); break; case 'input': case 'output': _addBasicContents(node, d); break; } }
javascript
function _addContent(d) { var node = d3.select(this); switch(d.type) { case 'vertex': _addBasicContents(node, d, 'vertexName'); _addStatusBar(node, d); _addTaskBubble(node, d); _addIOBubble(node, d); _addVertexGroupBubble(node, d); break; case 'input': case 'output': _addBasicContents(node, d); break; } }
[ "function", "_addContent", "(", "d", ")", "{", "var", "node", "=", "d3", ".", "select", "(", "this", ")", ";", "switch", "(", "d", ".", "type", ")", "{", "case", "'vertex'", ":", "_addBasicContents", "(", "node", ",", "d", ",", "'vertexName'", ")", ";", "_addStatusBar", "(", "node", ",", "d", ")", ";", "_addTaskBubble", "(", "node", ",", "d", ")", ";", "_addIOBubble", "(", "node", ",", "d", ")", ";", "_addVertexGroupBubble", "(", "node", ",", "d", ")", ";", "break", ";", "case", "'input'", ":", "case", "'output'", ":", "_addBasicContents", "(", "node", ",", "d", ")", ";", "break", ";", "}", "}" ]
Populates the calling node with the required content. @param s {DataNode}
[ "Populates", "the", "calling", "node", "with", "the", "required", "content", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L257-L273
57,308
sreenaths/em-tgraph
addon/utils/graph-view.js
_getLinks
function _getLinks(nodes) { var links = [], nodeHash; nodeHash = nodes.reduce(function (obj, node) { obj[node.id] = node; return obj; }, {}); _data.links.forEach(function (link) { var source = nodeHash[link.sourceId], target = nodeHash[link.targetId]; if(source && target) { link.setProperties({ source: source, target: target, isBackwardLink: source.isSelfOrAncestor(target) }); links.push(link); } }); return links; }
javascript
function _getLinks(nodes) { var links = [], nodeHash; nodeHash = nodes.reduce(function (obj, node) { obj[node.id] = node; return obj; }, {}); _data.links.forEach(function (link) { var source = nodeHash[link.sourceId], target = nodeHash[link.targetId]; if(source && target) { link.setProperties({ source: source, target: target, isBackwardLink: source.isSelfOrAncestor(target) }); links.push(link); } }); return links; }
[ "function", "_getLinks", "(", "nodes", ")", "{", "var", "links", "=", "[", "]", ",", "nodeHash", ";", "nodeHash", "=", "nodes", ".", "reduce", "(", "function", "(", "obj", ",", "node", ")", "{", "obj", "[", "node", ".", "id", "]", "=", "node", ";", "return", "obj", ";", "}", ",", "{", "}", ")", ";", "_data", ".", "links", ".", "forEach", "(", "function", "(", "link", ")", "{", "var", "source", "=", "nodeHash", "[", "link", ".", "sourceId", "]", ",", "target", "=", "nodeHash", "[", "link", ".", "targetId", "]", ";", "if", "(", "source", "&&", "target", ")", "{", "link", ".", "setProperties", "(", "{", "source", ":", "source", ",", "target", ":", "target", ",", "isBackwardLink", ":", "source", ".", "isSelfOrAncestor", "(", "target", ")", "}", ")", ";", "links", ".", "push", "(", "link", ")", ";", "}", "}", ")", ";", "return", "links", ";", "}" ]
Create a list of all links connecting nodes in the given array. @param nodes {Array} A list of d3 nodes created by tree layout @return links {Array} All links between nodes in the current DAG
[ "Create", "a", "list", "of", "all", "links", "connecting", "nodes", "in", "the", "given", "array", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L280-L303
57,309
sreenaths/em-tgraph
addon/utils/graph-view.js
_normalize
function _normalize(nodes) { // Set layout var farthestY = 0; nodes.forEach(function (d) { d.y = d.depth * -_layout.depthSpacing; if(d.y < farthestY) { farthestY = d.y; } }); farthestY -= PADDING; nodes.forEach(function (d) { d.y -= farthestY; }); //Remove space occupied by dummy var rootChildren = _treeData.get('children'), rootChildCount = rootChildren.length, dummyIndex, i; if(rootChildCount % 2 === 0) { dummyIndex = rootChildren.indexOf(_treeData.get('dummy')); if(dummyIndex >= rootChildCount / 2) { for(i = 0; i < dummyIndex; i++) { rootChildren[i].x = rootChildren[i + 1].x; rootChildren[i].y = rootChildren[i + 1].y; } } else { for(i = rootChildCount - 1; i > dummyIndex; i--) { rootChildren[i].x = rootChildren[i - 1].x; rootChildren[i].y = rootChildren[i - 1].y; } } } // Put all single vertex outputs in-line with the vertex node // So that they are directly below the respective vertex in vertical layout nodes.forEach(function (node) { if(node.type === DataProcessor.types.OUTPUT && node.get('vertex.outputs.length') === 1 && !node.get('vertex.outEdgeIds.length') && node.get('treeParent.x') !== node.get('x') ) { node.x = node.get('vertex.x'); } }); }
javascript
function _normalize(nodes) { // Set layout var farthestY = 0; nodes.forEach(function (d) { d.y = d.depth * -_layout.depthSpacing; if(d.y < farthestY) { farthestY = d.y; } }); farthestY -= PADDING; nodes.forEach(function (d) { d.y -= farthestY; }); //Remove space occupied by dummy var rootChildren = _treeData.get('children'), rootChildCount = rootChildren.length, dummyIndex, i; if(rootChildCount % 2 === 0) { dummyIndex = rootChildren.indexOf(_treeData.get('dummy')); if(dummyIndex >= rootChildCount / 2) { for(i = 0; i < dummyIndex; i++) { rootChildren[i].x = rootChildren[i + 1].x; rootChildren[i].y = rootChildren[i + 1].y; } } else { for(i = rootChildCount - 1; i > dummyIndex; i--) { rootChildren[i].x = rootChildren[i - 1].x; rootChildren[i].y = rootChildren[i - 1].y; } } } // Put all single vertex outputs in-line with the vertex node // So that they are directly below the respective vertex in vertical layout nodes.forEach(function (node) { if(node.type === DataProcessor.types.OUTPUT && node.get('vertex.outputs.length') === 1 && !node.get('vertex.outEdgeIds.length') && node.get('treeParent.x') !== node.get('x') ) { node.x = node.get('vertex.x'); } }); }
[ "function", "_normalize", "(", "nodes", ")", "{", "// Set layout", "var", "farthestY", "=", "0", ";", "nodes", ".", "forEach", "(", "function", "(", "d", ")", "{", "d", ".", "y", "=", "d", ".", "depth", "*", "-", "_layout", ".", "depthSpacing", ";", "if", "(", "d", ".", "y", "<", "farthestY", ")", "{", "farthestY", "=", "d", ".", "y", ";", "}", "}", ")", ";", "farthestY", "-=", "PADDING", ";", "nodes", ".", "forEach", "(", "function", "(", "d", ")", "{", "d", ".", "y", "-=", "farthestY", ";", "}", ")", ";", "//Remove space occupied by dummy", "var", "rootChildren", "=", "_treeData", ".", "get", "(", "'children'", ")", ",", "rootChildCount", "=", "rootChildren", ".", "length", ",", "dummyIndex", ",", "i", ";", "if", "(", "rootChildCount", "%", "2", "===", "0", ")", "{", "dummyIndex", "=", "rootChildren", ".", "indexOf", "(", "_treeData", ".", "get", "(", "'dummy'", ")", ")", ";", "if", "(", "dummyIndex", ">=", "rootChildCount", "/", "2", ")", "{", "for", "(", "i", "=", "0", ";", "i", "<", "dummyIndex", ";", "i", "++", ")", "{", "rootChildren", "[", "i", "]", ".", "x", "=", "rootChildren", "[", "i", "+", "1", "]", ".", "x", ";", "rootChildren", "[", "i", "]", ".", "y", "=", "rootChildren", "[", "i", "+", "1", "]", ".", "y", ";", "}", "}", "else", "{", "for", "(", "i", "=", "rootChildCount", "-", "1", ";", "i", ">", "dummyIndex", ";", "i", "--", ")", "{", "rootChildren", "[", "i", "]", ".", "x", "=", "rootChildren", "[", "i", "-", "1", "]", ".", "x", ";", "rootChildren", "[", "i", "]", ".", "y", "=", "rootChildren", "[", "i", "-", "1", "]", ".", "y", ";", "}", "}", "}", "// Put all single vertex outputs in-line with the vertex node", "// So that they are directly below the respective vertex in vertical layout", "nodes", ".", "forEach", "(", "function", "(", "node", ")", "{", "if", "(", "node", ".", "type", "===", "DataProcessor", ".", "types", ".", "OUTPUT", "&&", "node", ".", "get", "(", "'vertex.outputs.length'", ")", "===", "1", "&&", "!", "node", ".", "get", "(", "'vertex.outEdgeIds.length'", ")", "&&", "node", ".", "get", "(", "'treeParent.x'", ")", "!==", "node", ".", "get", "(", "'x'", ")", ")", "{", "node", ".", "x", "=", "node", ".", "get", "(", "'vertex.x'", ")", ";", "}", "}", ")", ";", "}" ]
Apply proper depth spacing and remove the space occupied by dummy node if the number of other nodes are odd. @param nodes {Array} A list of d3 nodes created by tree layout
[ "Apply", "proper", "depth", "spacing", "and", "remove", "the", "space", "occupied", "by", "dummy", "node", "if", "the", "number", "of", "other", "nodes", "are", "odd", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L310-L358
57,310
sreenaths/em-tgraph
addon/utils/graph-view.js
_scheduledClick
function _scheduledClick(d, node) { node = node.correspondingUseElement || node; _component.sendAction('entityClicked', { type: _getType(node), d: d }); _tip.hide(); _scheduledClickId = 0; }
javascript
function _scheduledClick(d, node) { node = node.correspondingUseElement || node; _component.sendAction('entityClicked', { type: _getType(node), d: d }); _tip.hide(); _scheduledClickId = 0; }
[ "function", "_scheduledClick", "(", "d", ",", "node", ")", "{", "node", "=", "node", ".", "correspondingUseElement", "||", "node", ";", "_component", ".", "sendAction", "(", "'entityClicked'", ",", "{", "type", ":", "_getType", "(", "node", ")", ",", "d", ":", "d", "}", ")", ";", "_tip", ".", "hide", "(", ")", ";", "_scheduledClickId", "=", "0", ";", "}" ]
onclick handler scheduled using setTimeout @params d {DataNode} data of the clicked element @param node {D3 element} Element that was clicked
[ "onclick", "handler", "scheduled", "using", "setTimeout" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L518-L528
57,311
sreenaths/em-tgraph
addon/utils/graph-view.js
_onClick
function _onClick(d) { if(!_scheduledClickId) { _scheduledClickId = setTimeout(_scheduledClick.bind(this, d, d3.event.target), 200); } }
javascript
function _onClick(d) { if(!_scheduledClickId) { _scheduledClickId = setTimeout(_scheduledClick.bind(this, d, d3.event.target), 200); } }
[ "function", "_onClick", "(", "d", ")", "{", "if", "(", "!", "_scheduledClickId", ")", "{", "_scheduledClickId", "=", "setTimeout", "(", "_scheduledClick", ".", "bind", "(", "this", ",", "d", ",", "d3", ".", "event", ".", "target", ")", ",", "200", ")", ";", "}", "}" ]
Schedules an onclick handler. If double click event is not triggered the handler will be called in 200ms. @param d {DataNode} Data of the clicked element
[ "Schedules", "an", "onclick", "handler", ".", "If", "double", "click", "event", "is", "not", "triggered", "the", "handler", "will", "be", "called", "in", "200ms", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L535-L539
57,312
sreenaths/em-tgraph
addon/utils/graph-view.js
_onDblclick
function _onDblclick(d) { var event = d3.event, node = event.target; node = node.correspondingUseElement || node; if(_scheduledClickId) { clearTimeout(_scheduledClickId); _scheduledClickId = 0; } switch(_getType(node)) { case "io": d.toggleAdditionalInclusion(); _update(); break; } }
javascript
function _onDblclick(d) { var event = d3.event, node = event.target; node = node.correspondingUseElement || node; if(_scheduledClickId) { clearTimeout(_scheduledClickId); _scheduledClickId = 0; } switch(_getType(node)) { case "io": d.toggleAdditionalInclusion(); _update(); break; } }
[ "function", "_onDblclick", "(", "d", ")", "{", "var", "event", "=", "d3", ".", "event", ",", "node", "=", "event", ".", "target", ";", "node", "=", "node", ".", "correspondingUseElement", "||", "node", ";", "if", "(", "_scheduledClickId", ")", "{", "clearTimeout", "(", "_scheduledClickId", ")", ";", "_scheduledClickId", "=", "0", ";", "}", "switch", "(", "_getType", "(", "node", ")", ")", "{", "case", "\"io\"", ":", "d", ".", "toggleAdditionalInclusion", "(", ")", ";", "_update", "(", ")", ";", "break", ";", "}", "}" ]
Double click event handler. @param d {DataNode} Data of the clicked element
[ "Double", "click", "event", "handler", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L553-L570
57,313
sreenaths/em-tgraph
addon/utils/graph-view.js
_createPathData
function _createPathData(d) { var sX = d.source.y, sY = d.source.x, tX = d.target.y, tY = d.target.x, mX = (sX + tX)/2, mY = (sY + tY)/2, sH = Math.abs(sX - tX) * 0.35, sV = 0; // strength if(d.isBackwardLink) { if(sY === tY) { sV = 45; mY -= 50; if(sX === tX) { sX += _layout.linkDelta; tX -= _layout.linkDelta; } } sH = Math.abs(sX - tX) * 1.1; } return _layout.pathFormatter( sX, sY, sX + sH, sY - sV, mX, mY, tX - sH, tY - sV, tX, tY ); }
javascript
function _createPathData(d) { var sX = d.source.y, sY = d.source.x, tX = d.target.y, tY = d.target.x, mX = (sX + tX)/2, mY = (sY + tY)/2, sH = Math.abs(sX - tX) * 0.35, sV = 0; // strength if(d.isBackwardLink) { if(sY === tY) { sV = 45; mY -= 50; if(sX === tX) { sX += _layout.linkDelta; tX -= _layout.linkDelta; } } sH = Math.abs(sX - tX) * 1.1; } return _layout.pathFormatter( sX, sY, sX + sH, sY - sV, mX, mY, tX - sH, tY - sV, tX, tY ); }
[ "function", "_createPathData", "(", "d", ")", "{", "var", "sX", "=", "d", ".", "source", ".", "y", ",", "sY", "=", "d", ".", "source", ".", "x", ",", "tX", "=", "d", ".", "target", ".", "y", ",", "tY", "=", "d", ".", "target", ".", "x", ",", "mX", "=", "(", "sX", "+", "tX", ")", "/", "2", ",", "mY", "=", "(", "sY", "+", "tY", ")", "/", "2", ",", "sH", "=", "Math", ".", "abs", "(", "sX", "-", "tX", ")", "*", "0.35", ",", "sV", "=", "0", ";", "// strength", "if", "(", "d", ".", "isBackwardLink", ")", "{", "if", "(", "sY", "===", "tY", ")", "{", "sV", "=", "45", ";", "mY", "-=", "50", ";", "if", "(", "sX", "===", "tX", ")", "{", "sX", "+=", "_layout", ".", "linkDelta", ";", "tX", "-=", "_layout", ".", "linkDelta", ";", "}", "}", "sH", "=", "Math", ".", "abs", "(", "sX", "-", "tX", ")", "*", "1.1", ";", "}", "return", "_layout", ".", "pathFormatter", "(", "sX", ",", "sY", ",", "sX", "+", "sH", ",", "sY", "-", "sV", ",", "mX", ",", "mY", ",", "tX", "-", "sH", ",", "tY", "-", "sV", ",", "tX", ",", "tY", ")", ";", "}" ]
Creates a path data string for the given link. Google SVG path data to learn what it is. @param d {Object} Must contain source and target properties with the start and end positions. @return pathData {String} Path data string based on the current layout
[ "Creates", "a", "path", "data", "string", "for", "the", "given", "link", ".", "Google", "SVG", "path", "data", "to", "learn", "what", "it", "is", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L577-L609
57,314
sreenaths/em-tgraph
addon/utils/graph-view.js
_updateNodes
function _updateNodes(nodes, source) { // Enter any new nodes at the parent's previous position. nodes.enter().append('g') .attr('transform', function(d) { var node = _getVertexNode(d, "x0") || source; node = _layout.projector(node.x0, node.y0); return 'translate(' + node.x + ',' + node.y + ')'; }) .on({ mouseover: _onMouseOver, mouseout: _tip.hide, mousedown: _onMouse, mousemove: _onMouse, dblclick: _onDblclick }) .style('opacity', 1e-6) .each(_addContent); // Transition nodes to their new position. nodes.transition() .duration(DURATION) .attr('transform', function(d) { d = _layout.projector(d.x, d.y); return 'translate(' + d.x + ',' + d.y + ')'; }) .style('opacity', 1); // Transition exiting nodes to the parent's new position. nodes.exit().transition() .duration(DURATION) .attr('transform', function(d) { var node = _getVertexNode(d, "x") || source; node = _layout.projector(node.x, node.y); return 'translate(' + node.x + ',' + node.y + ')'; }) .style('opacity', 1e-6) .remove(); }
javascript
function _updateNodes(nodes, source) { // Enter any new nodes at the parent's previous position. nodes.enter().append('g') .attr('transform', function(d) { var node = _getVertexNode(d, "x0") || source; node = _layout.projector(node.x0, node.y0); return 'translate(' + node.x + ',' + node.y + ')'; }) .on({ mouseover: _onMouseOver, mouseout: _tip.hide, mousedown: _onMouse, mousemove: _onMouse, dblclick: _onDblclick }) .style('opacity', 1e-6) .each(_addContent); // Transition nodes to their new position. nodes.transition() .duration(DURATION) .attr('transform', function(d) { d = _layout.projector(d.x, d.y); return 'translate(' + d.x + ',' + d.y + ')'; }) .style('opacity', 1); // Transition exiting nodes to the parent's new position. nodes.exit().transition() .duration(DURATION) .attr('transform', function(d) { var node = _getVertexNode(d, "x") || source; node = _layout.projector(node.x, node.y); return 'translate(' + node.x + ',' + node.y + ')'; }) .style('opacity', 1e-6) .remove(); }
[ "function", "_updateNodes", "(", "nodes", ",", "source", ")", "{", "// Enter any new nodes at the parent's previous position.", "nodes", ".", "enter", "(", ")", ".", "append", "(", "'g'", ")", ".", "attr", "(", "'transform'", ",", "function", "(", "d", ")", "{", "var", "node", "=", "_getVertexNode", "(", "d", ",", "\"x0\"", ")", "||", "source", ";", "node", "=", "_layout", ".", "projector", "(", "node", ".", "x0", ",", "node", ".", "y0", ")", ";", "return", "'translate('", "+", "node", ".", "x", "+", "','", "+", "node", ".", "y", "+", "')'", ";", "}", ")", ".", "on", "(", "{", "mouseover", ":", "_onMouseOver", ",", "mouseout", ":", "_tip", ".", "hide", ",", "mousedown", ":", "_onMouse", ",", "mousemove", ":", "_onMouse", ",", "dblclick", ":", "_onDblclick", "}", ")", ".", "style", "(", "'opacity'", ",", "1e-6", ")", ".", "each", "(", "_addContent", ")", ";", "// Transition nodes to their new position.", "nodes", ".", "transition", "(", ")", ".", "duration", "(", "DURATION", ")", ".", "attr", "(", "'transform'", ",", "function", "(", "d", ")", "{", "d", "=", "_layout", ".", "projector", "(", "d", ".", "x", ",", "d", ".", "y", ")", ";", "return", "'translate('", "+", "d", ".", "x", "+", "','", "+", "d", ".", "y", "+", "')'", ";", "}", ")", ".", "style", "(", "'opacity'", ",", "1", ")", ";", "// Transition exiting nodes to the parent's new position.", "nodes", ".", "exit", "(", ")", ".", "transition", "(", ")", ".", "duration", "(", "DURATION", ")", ".", "attr", "(", "'transform'", ",", "function", "(", "d", ")", "{", "var", "node", "=", "_getVertexNode", "(", "d", ",", "\"x\"", ")", "||", "source", ";", "node", "=", "_layout", ".", "projector", "(", "node", ".", "x", ",", "node", ".", "y", ")", ";", "return", "'translate('", "+", "node", ".", "x", "+", "','", "+", "node", ".", "y", "+", "')'", ";", "}", ")", ".", "style", "(", "'opacity'", ",", "1e-6", ")", ".", "remove", "(", ")", ";", "}" ]
Update position of all nodes in the list and preform required transitions. @param nodes {Array} Nodes to be updated @param source {d3 element} Node that trigged the update, in first update source will be root.
[ "Update", "position", "of", "all", "nodes", "in", "the", "list", "and", "preform", "required", "transitions", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L627-L664
57,315
sreenaths/em-tgraph
addon/utils/graph-view.js
_updateLinks
function _updateLinks(links, source) { // Enter any new links at the parent's previous position. links.enter().insert('path', 'g') .attr('class', function (d) { var type = d.get('dataMovementType') || ""; return 'link ' + type.toLowerCase(); }) /** * IE11 rendering does not work for svg path element with marker set. * See https://connect.microsoft.com/IE/feedback/details/801938 * This can be removed once the bug is fixed in all supported IE versions */ .attr("style", isIE ? "" : Ember.String.htmlSafe("marker-mid: url(" + window.location.pathname + "#arrow-marker);")) .attr('d', function(d) { var node = _getTargetNode(d, "x0") || source; var o = {x: node.x0, y: node.y0}; return _createPathData({source: o, target: o}); }) .on({ mouseover: _onMouseOver, mouseout: _tip.hide }); // Transition links to their new position. links.transition() .duration(DURATION) .attr('d', _createPathData); // Transition exiting nodes to the parent's new position. links.exit().transition() .duration(DURATION) .attr('d', function(d) { var node = _getTargetNode(d, "x") || source; var o = {x: node.x, y: node.y}; return _createPathData({source: o, target: o}); }) .remove(); }
javascript
function _updateLinks(links, source) { // Enter any new links at the parent's previous position. links.enter().insert('path', 'g') .attr('class', function (d) { var type = d.get('dataMovementType') || ""; return 'link ' + type.toLowerCase(); }) /** * IE11 rendering does not work for svg path element with marker set. * See https://connect.microsoft.com/IE/feedback/details/801938 * This can be removed once the bug is fixed in all supported IE versions */ .attr("style", isIE ? "" : Ember.String.htmlSafe("marker-mid: url(" + window.location.pathname + "#arrow-marker);")) .attr('d', function(d) { var node = _getTargetNode(d, "x0") || source; var o = {x: node.x0, y: node.y0}; return _createPathData({source: o, target: o}); }) .on({ mouseover: _onMouseOver, mouseout: _tip.hide }); // Transition links to their new position. links.transition() .duration(DURATION) .attr('d', _createPathData); // Transition exiting nodes to the parent's new position. links.exit().transition() .duration(DURATION) .attr('d', function(d) { var node = _getTargetNode(d, "x") || source; var o = {x: node.x, y: node.y}; return _createPathData({source: o, target: o}); }) .remove(); }
[ "function", "_updateLinks", "(", "links", ",", "source", ")", "{", "// Enter any new links at the parent's previous position.", "links", ".", "enter", "(", ")", ".", "insert", "(", "'path'", ",", "'g'", ")", ".", "attr", "(", "'class'", ",", "function", "(", "d", ")", "{", "var", "type", "=", "d", ".", "get", "(", "'dataMovementType'", ")", "||", "\"\"", ";", "return", "'link '", "+", "type", ".", "toLowerCase", "(", ")", ";", "}", ")", "/**\n * IE11 rendering does not work for svg path element with marker set.\n * See https://connect.microsoft.com/IE/feedback/details/801938\n * This can be removed once the bug is fixed in all supported IE versions\n */", ".", "attr", "(", "\"style\"", ",", "isIE", "?", "\"\"", ":", "Ember", ".", "String", ".", "htmlSafe", "(", "\"marker-mid: url(\"", "+", "window", ".", "location", ".", "pathname", "+", "\"#arrow-marker);\"", ")", ")", ".", "attr", "(", "'d'", ",", "function", "(", "d", ")", "{", "var", "node", "=", "_getTargetNode", "(", "d", ",", "\"x0\"", ")", "||", "source", ";", "var", "o", "=", "{", "x", ":", "node", ".", "x0", ",", "y", ":", "node", ".", "y0", "}", ";", "return", "_createPathData", "(", "{", "source", ":", "o", ",", "target", ":", "o", "}", ")", ";", "}", ")", ".", "on", "(", "{", "mouseover", ":", "_onMouseOver", ",", "mouseout", ":", "_tip", ".", "hide", "}", ")", ";", "// Transition links to their new position.", "links", ".", "transition", "(", ")", ".", "duration", "(", "DURATION", ")", ".", "attr", "(", "'d'", ",", "_createPathData", ")", ";", "// Transition exiting nodes to the parent's new position.", "links", ".", "exit", "(", ")", ".", "transition", "(", ")", ".", "duration", "(", "DURATION", ")", ".", "attr", "(", "'d'", ",", "function", "(", "d", ")", "{", "var", "node", "=", "_getTargetNode", "(", "d", ",", "\"x\"", ")", "||", "source", ";", "var", "o", "=", "{", "x", ":", "node", ".", "x", ",", "y", ":", "node", ".", "y", "}", ";", "return", "_createPathData", "(", "{", "source", ":", "o", ",", "target", ":", "o", "}", ")", ";", "}", ")", ".", "remove", "(", ")", ";", "}" ]
Update position of all links in the list and preform required transitions. @param links {Array} Links to be updated @param source {d3 element} Node that trigged the update, in first update source will be root.
[ "Update", "position", "of", "all", "links", "in", "the", "list", "and", "preform", "required", "transitions", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L685-L722
57,316
sreenaths/em-tgraph
addon/utils/graph-view.js
_update
function _update() { var nodesData = _treeLayout.nodes(_treeData), linksData = _getLinks(nodesData); _normalize(nodesData); var nodes = _g.selectAll('g.node') .data(nodesData, _getNodeId); _updateNodes(nodes, _treeData); var links = _g.selectAll('path.link') .data(linksData, _getLinkId); _updateLinks(links, _treeData); nodesData.forEach(_stashOldPositions); }
javascript
function _update() { var nodesData = _treeLayout.nodes(_treeData), linksData = _getLinks(nodesData); _normalize(nodesData); var nodes = _g.selectAll('g.node') .data(nodesData, _getNodeId); _updateNodes(nodes, _treeData); var links = _g.selectAll('path.link') .data(linksData, _getLinkId); _updateLinks(links, _treeData); nodesData.forEach(_stashOldPositions); }
[ "function", "_update", "(", ")", "{", "var", "nodesData", "=", "_treeLayout", ".", "nodes", "(", "_treeData", ")", ",", "linksData", "=", "_getLinks", "(", "nodesData", ")", ";", "_normalize", "(", "nodesData", ")", ";", "var", "nodes", "=", "_g", ".", "selectAll", "(", "'g.node'", ")", ".", "data", "(", "nodesData", ",", "_getNodeId", ")", ";", "_updateNodes", "(", "nodes", ",", "_treeData", ")", ";", "var", "links", "=", "_g", ".", "selectAll", "(", "'path.link'", ")", ".", "data", "(", "linksData", ",", "_getLinkId", ")", ";", "_updateLinks", "(", "links", ",", "_treeData", ")", ";", "nodesData", ".", "forEach", "(", "_stashOldPositions", ")", ";", "}" ]
Updates position of nodes and links based on changes in _treeData.
[ "Updates", "position", "of", "nodes", "and", "links", "based", "on", "changes", "in", "_treeData", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L738-L753
57,317
sreenaths/em-tgraph
addon/utils/graph-view.js
transform
function transform(animate) { var base = animate ? g.transition().duration(DURATION) : g; base.attr('transform', `translate(${panX}, ${panY}) scale(${scale})`); }
javascript
function transform(animate) { var base = animate ? g.transition().duration(DURATION) : g; base.attr('transform', `translate(${panX}, ${panY}) scale(${scale})`); }
[ "function", "transform", "(", "animate", ")", "{", "var", "base", "=", "animate", "?", "g", ".", "transition", "(", ")", ".", "duration", "(", "DURATION", ")", ":", "g", ";", "base", ".", "attr", "(", "'transform'", ",", "`", "${", "panX", "}", "${", "panY", "}", "${", "scale", "}", "`", ")", ";", "}" ]
Transform g to current panX, panY and scale. @param animate {Boolean} Animate the transformation in DURATION time.
[ "Transform", "g", "to", "current", "panX", "panY", "and", "scale", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L778-L781
57,318
sreenaths/em-tgraph
addon/utils/graph-view.js
visibilityCheck
function visibilityCheck() { var graphBound = g.node().getBoundingClientRect(), containerBound = container[0].getBoundingClientRect(); if(graphBound.right < containerBound.left || graphBound.bottom < containerBound.top || graphBound.left > containerBound.right || graphBound.top > containerBound.bottom) { panX = PADDING; panY = PADDING; scale = 1; transform(true); } }
javascript
function visibilityCheck() { var graphBound = g.node().getBoundingClientRect(), containerBound = container[0].getBoundingClientRect(); if(graphBound.right < containerBound.left || graphBound.bottom < containerBound.top || graphBound.left > containerBound.right || graphBound.top > containerBound.bottom) { panX = PADDING; panY = PADDING; scale = 1; transform(true); } }
[ "function", "visibilityCheck", "(", ")", "{", "var", "graphBound", "=", "g", ".", "node", "(", ")", ".", "getBoundingClientRect", "(", ")", ",", "containerBound", "=", "container", "[", "0", "]", ".", "getBoundingClientRect", "(", ")", ";", "if", "(", "graphBound", ".", "right", "<", "containerBound", ".", "left", "||", "graphBound", ".", "bottom", "<", "containerBound", ".", "top", "||", "graphBound", ".", "left", ">", "containerBound", ".", "right", "||", "graphBound", ".", "top", ">", "containerBound", ".", "bottom", ")", "{", "panX", "=", "PADDING", ";", "panY", "=", "PADDING", ";", "scale", "=", "1", ";", "transform", "(", "true", ")", ";", "}", "}" ]
Check if the item have moved out of the visible area, and reset if required
[ "Check", "if", "the", "item", "have", "moved", "out", "of", "the", "visible", "area", "and", "reset", "if", "required" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L786-L799
57,319
sreenaths/em-tgraph
addon/utils/graph-view.js
onMouseMove
function onMouseMove(event) { panX += event.pageX - prevX; panY += event.pageY - prevY; transform(); prevX = event.pageX; prevY = event.pageY; }
javascript
function onMouseMove(event) { panX += event.pageX - prevX; panY += event.pageY - prevY; transform(); prevX = event.pageX; prevY = event.pageY; }
[ "function", "onMouseMove", "(", "event", ")", "{", "panX", "+=", "event", ".", "pageX", "-", "prevX", ";", "panY", "+=", "event", ".", "pageY", "-", "prevY", ";", "transform", "(", ")", ";", "prevX", "=", "event", ".", "pageX", ";", "prevY", "=", "event", ".", "pageY", ";", "}" ]
Set pan values
[ "Set", "pan", "values" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L815-L823
57,320
sreenaths/em-tgraph
addon/utils/graph-view.js
onWheel
function onWheel(event) { var prevScale = scale, offset = container.offset(), mouseX = event.pageX - offset.left, mouseY = event.pageY - offset.top, factor = 0; scale += event.deltaY * SCALE_TUNER; if(scale < MIN_SCALE) { scale = MIN_SCALE; } else if(scale > MAX_SCALE) { scale = MAX_SCALE; } factor = 1 - scale / prevScale; panX += (mouseX - panX) * factor; panY += (mouseY - panY) * factor; transform(); scheduleVisibilityCheck(); _tip.reposition(); event.preventDefault(); }
javascript
function onWheel(event) { var prevScale = scale, offset = container.offset(), mouseX = event.pageX - offset.left, mouseY = event.pageY - offset.top, factor = 0; scale += event.deltaY * SCALE_TUNER; if(scale < MIN_SCALE) { scale = MIN_SCALE; } else if(scale > MAX_SCALE) { scale = MAX_SCALE; } factor = 1 - scale / prevScale; panX += (mouseX - panX) * factor; panY += (mouseY - panY) * factor; transform(); scheduleVisibilityCheck(); _tip.reposition(); event.preventDefault(); }
[ "function", "onWheel", "(", "event", ")", "{", "var", "prevScale", "=", "scale", ",", "offset", "=", "container", ".", "offset", "(", ")", ",", "mouseX", "=", "event", ".", "pageX", "-", "offset", ".", "left", ",", "mouseY", "=", "event", ".", "pageY", "-", "offset", ".", "top", ",", "factor", "=", "0", ";", "scale", "+=", "event", ".", "deltaY", "*", "SCALE_TUNER", ";", "if", "(", "scale", "<", "MIN_SCALE", ")", "{", "scale", "=", "MIN_SCALE", ";", "}", "else", "if", "(", "scale", ">", "MAX_SCALE", ")", "{", "scale", "=", "MAX_SCALE", ";", "}", "factor", "=", "1", "-", "scale", "/", "prevScale", ";", "panX", "+=", "(", "mouseX", "-", "panX", ")", "*", "factor", ";", "panY", "+=", "(", "mouseY", "-", "panY", ")", "*", "factor", ";", "transform", "(", ")", ";", "scheduleVisibilityCheck", "(", ")", ";", "_tip", ".", "reposition", "(", ")", ";", "event", ".", "preventDefault", "(", ")", ";", "}" ]
Set zoom values, pan also would change as we are zooming with mouse position as pivote.
[ "Set", "zoom", "values", "pan", "also", "would", "change", "as", "we", "are", "zooming", "with", "mouse", "position", "as", "pivote", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L827-L852
57,321
sreenaths/em-tgraph
addon/utils/graph-view.js
_setLayout
function _setLayout(layout) { var leafCount = _data.leafCount, dimention; // If count is even dummy will be replaced by output, so output would no more be leaf if(_data.tree.get('children.length') % 2 === 0) { leafCount--; } dimention = layout.projector(leafCount, _data.maxDepth - 1); _layout = layout; _width = dimention.x *= _layout.hSpacing; _height = dimention.y *= _layout.vSpacing; dimention = _layout.projector(dimention.x, dimention.y); // Because tree is always top to bottom _treeLayout = d3.layout.tree().size([dimention.x, dimention.y]); _update(); }
javascript
function _setLayout(layout) { var leafCount = _data.leafCount, dimention; // If count is even dummy will be replaced by output, so output would no more be leaf if(_data.tree.get('children.length') % 2 === 0) { leafCount--; } dimention = layout.projector(leafCount, _data.maxDepth - 1); _layout = layout; _width = dimention.x *= _layout.hSpacing; _height = dimention.y *= _layout.vSpacing; dimention = _layout.projector(dimention.x, dimention.y); // Because tree is always top to bottom _treeLayout = d3.layout.tree().size([dimention.x, dimention.y]); _update(); }
[ "function", "_setLayout", "(", "layout", ")", "{", "var", "leafCount", "=", "_data", ".", "leafCount", ",", "dimention", ";", "// If count is even dummy will be replaced by output, so output would no more be leaf", "if", "(", "_data", ".", "tree", ".", "get", "(", "'children.length'", ")", "%", "2", "===", "0", ")", "{", "leafCount", "--", ";", "}", "dimention", "=", "layout", ".", "projector", "(", "leafCount", ",", "_data", ".", "maxDepth", "-", "1", ")", ";", "_layout", "=", "layout", ";", "_width", "=", "dimention", ".", "x", "*=", "_layout", ".", "hSpacing", ";", "_height", "=", "dimention", ".", "y", "*=", "_layout", ".", "vSpacing", ";", "dimention", "=", "_layout", ".", "projector", "(", "dimention", ".", "x", ",", "dimention", ".", "y", ")", ";", "// Because tree is always top to bottom", "_treeLayout", "=", "d3", ".", "layout", ".", "tree", "(", ")", ".", "size", "(", "[", "dimention", ".", "x", ",", "dimention", ".", "y", "]", ")", ";", "_update", "(", ")", ";", "}" ]
Sets the layout and update the display. @param layout {Object} One of the values defined in LAYOUTS object
[ "Sets", "the", "layout", "and", "update", "the", "display", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L898-L917
57,322
sreenaths/em-tgraph
addon/utils/graph-view.js
function (component, element, data) { var svg = d3.select(element).select('svg'); _component = component; _data = data; _g = svg.append('g').attr('transform', `translate(${PADDING},${PADDING})`); _svg = Ember.$(svg.node()); _tip = Tip; _tip.init(Ember.$(element).find('.tool-tip'), _svg); _treeData = data.tree; _treeData.x0 = 0; _treeData.y0 = 0; _panZoom = _attachPanZoom(_svg, _g, element); _setLayout(LAYOUTS.topToBottom); }
javascript
function (component, element, data) { var svg = d3.select(element).select('svg'); _component = component; _data = data; _g = svg.append('g').attr('transform', `translate(${PADDING},${PADDING})`); _svg = Ember.$(svg.node()); _tip = Tip; _tip.init(Ember.$(element).find('.tool-tip'), _svg); _treeData = data.tree; _treeData.x0 = 0; _treeData.y0 = 0; _panZoom = _attachPanZoom(_svg, _g, element); _setLayout(LAYOUTS.topToBottom); }
[ "function", "(", "component", ",", "element", ",", "data", ")", "{", "var", "svg", "=", "d3", ".", "select", "(", "element", ")", ".", "select", "(", "'svg'", ")", ";", "_component", "=", "component", ";", "_data", "=", "data", ";", "_g", "=", "svg", ".", "append", "(", "'g'", ")", ".", "attr", "(", "'transform'", ",", "`", "${", "PADDING", "}", "${", "PADDING", "}", "`", ")", ";", "_svg", "=", "Ember", ".", "$", "(", "svg", ".", "node", "(", ")", ")", ";", "_tip", "=", "Tip", ";", "_tip", ".", "init", "(", "Ember", ".", "$", "(", "element", ")", ".", "find", "(", "'.tool-tip'", ")", ",", "_svg", ")", ";", "_treeData", "=", "data", ".", "tree", ";", "_treeData", ".", "x0", "=", "0", ";", "_treeData", ".", "y0", "=", "0", ";", "_panZoom", "=", "_attachPanZoom", "(", "_svg", ",", "_g", ",", "element", ")", ";", "_setLayout", "(", "LAYOUTS", ".", "topToBottom", ")", ";", "}" ]
Creates a DAG view in the given element based on the data @param component {DagViewComponent} Parent ember component, to sendAction @param element {HTML DOM Element} HTML element in which the view will be created @param data {Object} Created by data processor
[ "Creates", "a", "DAG", "view", "in", "the", "given", "element", "based", "on", "the", "data" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L926-L944
57,323
sreenaths/em-tgraph
addon/utils/graph-view.js
function (){ var scale = Math.min( (_svg.width() - PADDING * 2) / _width, (_svg.height() - PADDING * 2) / _height ), panZoomValues = _panZoom(); if( panZoomValues.panX !== PADDING || panZoomValues.panY !== PADDING || panZoomValues.scale !== scale ) { _panZoomValues = _panZoom(PADDING, PADDING, scale); } else { _panZoomValues = _panZoom( _panZoomValues.panX, _panZoomValues.panY, _panZoomValues.scale); } }
javascript
function (){ var scale = Math.min( (_svg.width() - PADDING * 2) / _width, (_svg.height() - PADDING * 2) / _height ), panZoomValues = _panZoom(); if( panZoomValues.panX !== PADDING || panZoomValues.panY !== PADDING || panZoomValues.scale !== scale ) { _panZoomValues = _panZoom(PADDING, PADDING, scale); } else { _panZoomValues = _panZoom( _panZoomValues.panX, _panZoomValues.panY, _panZoomValues.scale); } }
[ "function", "(", ")", "{", "var", "scale", "=", "Math", ".", "min", "(", "(", "_svg", ".", "width", "(", ")", "-", "PADDING", "*", "2", ")", "/", "_width", ",", "(", "_svg", ".", "height", "(", ")", "-", "PADDING", "*", "2", ")", "/", "_height", ")", ",", "panZoomValues", "=", "_panZoom", "(", ")", ";", "if", "(", "panZoomValues", ".", "panX", "!==", "PADDING", "||", "panZoomValues", ".", "panY", "!==", "PADDING", "||", "panZoomValues", ".", "scale", "!==", "scale", ")", "{", "_panZoomValues", "=", "_panZoom", "(", "PADDING", ",", "PADDING", ",", "scale", ")", ";", "}", "else", "{", "_panZoomValues", "=", "_panZoom", "(", "_panZoomValues", ".", "panX", ",", "_panZoomValues", ".", "panY", ",", "_panZoomValues", ".", "scale", ")", ";", "}", "}" ]
Calling this function would fit the graph to the available space.
[ "Calling", "this", "function", "would", "fit", "the", "graph", "to", "the", "available", "space", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L949-L969
57,324
sreenaths/em-tgraph
addon/utils/graph-view.js
function (hide) { if(hide) { _g.attr('class', 'hide-io'); _treeData.recursivelyCall('excludeAdditionals'); } else { _treeData.recursivelyCall('includeAdditionals'); _g.attr('class', null); } _update(); }
javascript
function (hide) { if(hide) { _g.attr('class', 'hide-io'); _treeData.recursivelyCall('excludeAdditionals'); } else { _treeData.recursivelyCall('includeAdditionals'); _g.attr('class', null); } _update(); }
[ "function", "(", "hide", ")", "{", "if", "(", "hide", ")", "{", "_g", ".", "attr", "(", "'class'", ",", "'hide-io'", ")", ";", "_treeData", ".", "recursivelyCall", "(", "'excludeAdditionals'", ")", ";", "}", "else", "{", "_treeData", ".", "recursivelyCall", "(", "'includeAdditionals'", ")", ";", "_g", ".", "attr", "(", "'class'", ",", "null", ")", ";", "}", "_update", "(", ")", ";", "}" ]
Control display of additionals or sources and sinks. @param hide {Boolean} If true the additionals will be excluded, else included in the display
[ "Control", "display", "of", "additionals", "or", "sources", "and", "sinks", "." ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L975-L985
57,325
sreenaths/em-tgraph
addon/utils/graph-view.js
function () { _setLayout(_layout === LAYOUTS.topToBottom ? LAYOUTS.leftToRight : LAYOUTS.topToBottom); return _layout === LAYOUTS.topToBottom; }
javascript
function () { _setLayout(_layout === LAYOUTS.topToBottom ? LAYOUTS.leftToRight : LAYOUTS.topToBottom); return _layout === LAYOUTS.topToBottom; }
[ "function", "(", ")", "{", "_setLayout", "(", "_layout", "===", "LAYOUTS", ".", "topToBottom", "?", "LAYOUTS", ".", "leftToRight", ":", "LAYOUTS", ".", "topToBottom", ")", ";", "return", "_layout", "===", "LAYOUTS", ".", "topToBottom", ";", "}" ]
Toggle graph layouts between the available options
[ "Toggle", "graph", "layouts", "between", "the", "available", "options" ]
8d6a8f46b911a165ac16561731735ab762954996
https://github.com/sreenaths/em-tgraph/blob/8d6a8f46b911a165ac16561731735ab762954996/addon/utils/graph-view.js#L990-L995
57,326
timkuijsten/node-mongo-bcrypt-user
index.js
User
function User(coll, username, opts) { if (typeof coll !== 'object') { throw new TypeError('coll must be an object'); } if (typeof username !== 'string') { throw new TypeError('username must be a string'); } // setup a resolver var db = { find: coll.findOne.bind(coll), insert: coll.insert.bind(coll), updateHash: function(lookup, hash, cb) { coll.update(lookup, { $set: { password: hash } }, function(err, updated) { if (err) { cb(err); return; } if (updated !== 1) { cb(new Error('failed to update password')); return; } cb(null); }); } }; BcryptUser.call(this, db, username, opts || {}); }
javascript
function User(coll, username, opts) { if (typeof coll !== 'object') { throw new TypeError('coll must be an object'); } if (typeof username !== 'string') { throw new TypeError('username must be a string'); } // setup a resolver var db = { find: coll.findOne.bind(coll), insert: coll.insert.bind(coll), updateHash: function(lookup, hash, cb) { coll.update(lookup, { $set: { password: hash } }, function(err, updated) { if (err) { cb(err); return; } if (updated !== 1) { cb(new Error('failed to update password')); return; } cb(null); }); } }; BcryptUser.call(this, db, username, opts || {}); }
[ "function", "User", "(", "coll", ",", "username", ",", "opts", ")", "{", "if", "(", "typeof", "coll", "!==", "'object'", ")", "{", "throw", "new", "TypeError", "(", "'coll must be an object'", ")", ";", "}", "if", "(", "typeof", "username", "!==", "'string'", ")", "{", "throw", "new", "TypeError", "(", "'username must be a string'", ")", ";", "}", "// setup a resolver", "var", "db", "=", "{", "find", ":", "coll", ".", "findOne", ".", "bind", "(", "coll", ")", ",", "insert", ":", "coll", ".", "insert", ".", "bind", "(", "coll", ")", ",", "updateHash", ":", "function", "(", "lookup", ",", "hash", ",", "cb", ")", "{", "coll", ".", "update", "(", "lookup", ",", "{", "$set", ":", "{", "password", ":", "hash", "}", "}", ",", "function", "(", "err", ",", "updated", ")", "{", "if", "(", "err", ")", "{", "cb", "(", "err", ")", ";", "return", ";", "}", "if", "(", "updated", "!==", "1", ")", "{", "cb", "(", "new", "Error", "(", "'failed to update password'", ")", ")", ";", "return", ";", "}", "cb", "(", "null", ")", ";", "}", ")", ";", "}", "}", ";", "BcryptUser", ".", "call", "(", "this", ",", "db", ",", "username", ",", "opts", "||", "{", "}", ")", ";", "}" ]
Store and verify users with bcrypt passwords located in a mongodb collection. @param {Object} coll the database that contains all user accounts @param {String} username the name of the user to bind this instance to @param {Object} [opts] object containing optional parameters opts: realm {String, default "_default"} optional realm the user belongs to debug {Boolean, default false} whether to do extra console logging or not hide {Boolean, default false} whether to suppress errors or not (for testing)
[ "Store", "and", "verify", "users", "with", "bcrypt", "passwords", "located", "in", "a", "mongodb", "collection", "." ]
2a110a07cf474bca486bf70350c828b47decae52
https://github.com/timkuijsten/node-mongo-bcrypt-user/blob/2a110a07cf474bca486bf70350c828b47decae52/index.js#L34-L54
57,327
airbrite/muni
model.js
function(options) { return function(err, resp) { if (err) { options.error(err); } else { options.success(resp); } }; }
javascript
function(options) { return function(err, resp) { if (err) { options.error(err); } else { options.success(resp); } }; }
[ "function", "(", "options", ")", "{", "return", "function", "(", "err", ",", "resp", ")", "{", "if", "(", "err", ")", "{", "options", ".", "error", "(", "err", ")", ";", "}", "else", "{", "options", ".", "success", "(", "resp", ")", ";", "}", "}", ";", "}" ]
Responsible for setting attributes after a database call Takes the mongodb response and calls the Backbone success method @param {Object} options @return {Function}
[ "Responsible", "for", "setting", "attributes", "after", "a", "database", "call", "Takes", "the", "mongodb", "response", "and", "calls", "the", "Backbone", "success", "method" ]
ea8b26aa94836514374907c325a0d79f28838e2e
https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/model.js#L52-L60
57,328
airbrite/muni
model.js
function(attrs, attrsToRemove) { _.forEach(attrs, function(val, key) { // shouldRemove is either an object or a boolean var shouldRemove = attrsToRemove[key]; if (_.isUndefined(shouldRemove)) { return; } // Support nested object if (_.isPlainObject(val) && !_.isArray(val) && _.isPlainObject(shouldRemove)) { return this._removeExpandableAttributes(val, shouldRemove); } // Make sure attribute is an object // Strip all nested properties except for `_id` if (_.isPlainObject(attrs[key]) && shouldRemove) { attrs[key] = _.pick(attrs[key], ['_id']); } }.bind(this)); }
javascript
function(attrs, attrsToRemove) { _.forEach(attrs, function(val, key) { // shouldRemove is either an object or a boolean var shouldRemove = attrsToRemove[key]; if (_.isUndefined(shouldRemove)) { return; } // Support nested object if (_.isPlainObject(val) && !_.isArray(val) && _.isPlainObject(shouldRemove)) { return this._removeExpandableAttributes(val, shouldRemove); } // Make sure attribute is an object // Strip all nested properties except for `_id` if (_.isPlainObject(attrs[key]) && shouldRemove) { attrs[key] = _.pick(attrs[key], ['_id']); } }.bind(this)); }
[ "function", "(", "attrs", ",", "attrsToRemove", ")", "{", "_", ".", "forEach", "(", "attrs", ",", "function", "(", "val", ",", "key", ")", "{", "// shouldRemove is either an object or a boolean", "var", "shouldRemove", "=", "attrsToRemove", "[", "key", "]", ";", "if", "(", "_", ".", "isUndefined", "(", "shouldRemove", ")", ")", "{", "return", ";", "}", "// Support nested object", "if", "(", "_", ".", "isPlainObject", "(", "val", ")", "&&", "!", "_", ".", "isArray", "(", "val", ")", "&&", "_", ".", "isPlainObject", "(", "shouldRemove", ")", ")", "{", "return", "this", ".", "_removeExpandableAttributes", "(", "val", ",", "shouldRemove", ")", ";", "}", "// Make sure attribute is an object", "// Strip all nested properties except for `_id`", "if", "(", "_", ".", "isPlainObject", "(", "attrs", "[", "key", "]", ")", "&&", "shouldRemove", ")", "{", "attrs", "[", "key", "]", "=", "_", ".", "pick", "(", "attrs", "[", "key", "]", ",", "[", "'_id'", "]", ")", ";", "}", "}", ".", "bind", "(", "this", ")", ")", ";", "}" ]
Remove expandable attributes Does not work for objects embedded inside arrays @param {Object} attrs @param {Object} attrsToRemove
[ "Remove", "expandable", "attributes" ]
ea8b26aa94836514374907c325a0d79f28838e2e
https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/model.js#L99-L118
57,329
airbrite/muni
model.js
function(schemaType, schemaDefault) { if (!_.isUndefined(schemaDefault)) { return schemaDefault; } switch (schemaType) { case 'integer': case 'uinteger': case 'float': case 'ufloat': return 0; case 'boolean': return false; case 'timestamp': return new Date().getTime(); // ms case 'date': return new Date(); // iso default: return null; } }
javascript
function(schemaType, schemaDefault) { if (!_.isUndefined(schemaDefault)) { return schemaDefault; } switch (schemaType) { case 'integer': case 'uinteger': case 'float': case 'ufloat': return 0; case 'boolean': return false; case 'timestamp': return new Date().getTime(); // ms case 'date': return new Date(); // iso default: return null; } }
[ "function", "(", "schemaType", ",", "schemaDefault", ")", "{", "if", "(", "!", "_", ".", "isUndefined", "(", "schemaDefault", ")", ")", "{", "return", "schemaDefault", ";", "}", "switch", "(", "schemaType", ")", "{", "case", "'integer'", ":", "case", "'uinteger'", ":", "case", "'float'", ":", "case", "'ufloat'", ":", "return", "0", ";", "case", "'boolean'", ":", "return", "false", ";", "case", "'timestamp'", ":", "return", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "// ms", "case", "'date'", ":", "return", "new", "Date", "(", ")", ";", "// iso", "default", ":", "return", "null", ";", "}", "}" ]
Return the default value for a schema type @param {string} schemaType @param {*} schemaDefault @return {*}
[ "Return", "the", "default", "value", "for", "a", "schema", "type" ]
ea8b26aa94836514374907c325a0d79f28838e2e
https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/model.js#L311-L330
57,330
airbrite/muni
model.js
function(def, withArray) { def = def ? def : _.result(this, 'definition'); return _.reduce(def, function(defaults, attr, key) { if (attr.computed) { return defaults; } if (attr.default !== undefined) { defaults[key] = _.result(attr, 'default'); } else if (attr.type === 'object') { defaults[key] = this.defaults(attr.fields || {}); } else if (attr.type === 'array') { // withArray to populate nested array values for _validateAttributes defaults[key] = withArray ? [this.defaults(attr.fields || {})] : []; } else { defaults[key] = this._defaultVal(attr.type); } return defaults; }.bind(this), {}); }
javascript
function(def, withArray) { def = def ? def : _.result(this, 'definition'); return _.reduce(def, function(defaults, attr, key) { if (attr.computed) { return defaults; } if (attr.default !== undefined) { defaults[key] = _.result(attr, 'default'); } else if (attr.type === 'object') { defaults[key] = this.defaults(attr.fields || {}); } else if (attr.type === 'array') { // withArray to populate nested array values for _validateAttributes defaults[key] = withArray ? [this.defaults(attr.fields || {})] : []; } else { defaults[key] = this._defaultVal(attr.type); } return defaults; }.bind(this), {}); }
[ "function", "(", "def", ",", "withArray", ")", "{", "def", "=", "def", "?", "def", ":", "_", ".", "result", "(", "this", ",", "'definition'", ")", ";", "return", "_", ".", "reduce", "(", "def", ",", "function", "(", "defaults", ",", "attr", ",", "key", ")", "{", "if", "(", "attr", ".", "computed", ")", "{", "return", "defaults", ";", "}", "if", "(", "attr", ".", "default", "!==", "undefined", ")", "{", "defaults", "[", "key", "]", "=", "_", ".", "result", "(", "attr", ",", "'default'", ")", ";", "}", "else", "if", "(", "attr", ".", "type", "===", "'object'", ")", "{", "defaults", "[", "key", "]", "=", "this", ".", "defaults", "(", "attr", ".", "fields", "||", "{", "}", ")", ";", "}", "else", "if", "(", "attr", ".", "type", "===", "'array'", ")", "{", "// withArray to populate nested array values for _validateAttributes", "defaults", "[", "key", "]", "=", "withArray", "?", "[", "this", ".", "defaults", "(", "attr", ".", "fields", "||", "{", "}", ")", "]", ":", "[", "]", ";", "}", "else", "{", "defaults", "[", "key", "]", "=", "this", ".", "_defaultVal", "(", "attr", ".", "type", ")", ";", "}", "return", "defaults", ";", "}", ".", "bind", "(", "this", ")", ",", "{", "}", ")", ";", "}" ]
Get the default attribute values for your model. When creating an instance of the model, any unspecified attributes will be set to their default value. Define defaults as a function. @param {Object} def @param {boolean} withArray @return {Object}
[ "Get", "the", "default", "attribute", "values", "for", "your", "model", ".", "When", "creating", "an", "instance", "of", "the", "model", "any", "unspecified", "attributes", "will", "be", "set", "to", "their", "default", "value", "." ]
ea8b26aa94836514374907c325a0d79f28838e2e
https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/model.js#L344-L363
57,331
airbrite/muni
model.js
function(def) { def = def ? def : _.result(this, 'definition'); return _.reduce(def, function(schema, attr, key) { if (attr.type === 'object') { schema[key] = this.schema(attr.fields || {}); } else if (attr.type === 'array') { if (attr.value_type === 'object') { schema[key] = [this.schema(attr.fields || {})]; } else if (attr.value_type) { schema[key] = [attr.value_type]; } else { schema[key] = []; } } else { schema[key] = attr.type; } return schema; }.bind(this), {}); }
javascript
function(def) { def = def ? def : _.result(this, 'definition'); return _.reduce(def, function(schema, attr, key) { if (attr.type === 'object') { schema[key] = this.schema(attr.fields || {}); } else if (attr.type === 'array') { if (attr.value_type === 'object') { schema[key] = [this.schema(attr.fields || {})]; } else if (attr.value_type) { schema[key] = [attr.value_type]; } else { schema[key] = []; } } else { schema[key] = attr.type; } return schema; }.bind(this), {}); }
[ "function", "(", "def", ")", "{", "def", "=", "def", "?", "def", ":", "_", ".", "result", "(", "this", ",", "'definition'", ")", ";", "return", "_", ".", "reduce", "(", "def", ",", "function", "(", "schema", ",", "attr", ",", "key", ")", "{", "if", "(", "attr", ".", "type", "===", "'object'", ")", "{", "schema", "[", "key", "]", "=", "this", ".", "schema", "(", "attr", ".", "fields", "||", "{", "}", ")", ";", "}", "else", "if", "(", "attr", ".", "type", "===", "'array'", ")", "{", "if", "(", "attr", ".", "value_type", "===", "'object'", ")", "{", "schema", "[", "key", "]", "=", "[", "this", ".", "schema", "(", "attr", ".", "fields", "||", "{", "}", ")", "]", ";", "}", "else", "if", "(", "attr", ".", "value_type", ")", "{", "schema", "[", "key", "]", "=", "[", "attr", ".", "value_type", "]", ";", "}", "else", "{", "schema", "[", "key", "]", "=", "[", "]", ";", "}", "}", "else", "{", "schema", "[", "key", "]", "=", "attr", ".", "type", ";", "}", "return", "schema", ";", "}", ".", "bind", "(", "this", ")", ",", "{", "}", ")", ";", "}" ]
Get the types of each attribute. Define schema as a function. See `model.spec.js` for how to use @param {Object} def @return {Object}
[ "Get", "the", "types", "of", "each", "attribute", "." ]
ea8b26aa94836514374907c325a0d79f28838e2e
https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/model.js#L376-L395
57,332
airbrite/muni
model.js
function(prop, def) { def = def ? def : _.result(this, 'definition'); return _.reduce(def, function(attrs, attr, key) { if (attr.type === 'object') { var nested = this.findAttributes(prop, attr.fields || {}); if (!_.isEmpty(nested)) { attrs[key] = nested; } } if (attr[prop]) { attrs[key] = true; } return attrs; }.bind(this), {}); }
javascript
function(prop, def) { def = def ? def : _.result(this, 'definition'); return _.reduce(def, function(attrs, attr, key) { if (attr.type === 'object') { var nested = this.findAttributes(prop, attr.fields || {}); if (!_.isEmpty(nested)) { attrs[key] = nested; } } if (attr[prop]) { attrs[key] = true; } return attrs; }.bind(this), {}); }
[ "function", "(", "prop", ",", "def", ")", "{", "def", "=", "def", "?", "def", ":", "_", ".", "result", "(", "this", ",", "'definition'", ")", ";", "return", "_", ".", "reduce", "(", "def", ",", "function", "(", "attrs", ",", "attr", ",", "key", ")", "{", "if", "(", "attr", ".", "type", "===", "'object'", ")", "{", "var", "nested", "=", "this", ".", "findAttributes", "(", "prop", ",", "attr", ".", "fields", "||", "{", "}", ")", ";", "if", "(", "!", "_", ".", "isEmpty", "(", "nested", ")", ")", "{", "attrs", "[", "key", "]", "=", "nested", ";", "}", "}", "if", "(", "attr", "[", "prop", "]", ")", "{", "attrs", "[", "key", "]", "=", "true", ";", "}", "return", "attrs", ";", "}", ".", "bind", "(", "this", ")", ",", "{", "}", ")", ";", "}" ]
Define attributes that are not settable from the request @param {String} prop @param {Object} def @return {Object}
[ "Define", "attributes", "that", "are", "not", "settable", "from", "the", "request" ]
ea8b26aa94836514374907c325a0d79f28838e2e
https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/model.js#L404-L418
57,333
airbrite/muni
model.js
function(resp, options) { // Mongodb sometimes returns an array of one document if (_.isArray(resp)) { resp = resp[0]; } resp = _.defaultsDeep({}, resp, this.defaults()); return resp; }
javascript
function(resp, options) { // Mongodb sometimes returns an array of one document if (_.isArray(resp)) { resp = resp[0]; } resp = _.defaultsDeep({}, resp, this.defaults()); return resp; }
[ "function", "(", "resp", ",", "options", ")", "{", "// Mongodb sometimes returns an array of one document", "if", "(", "_", ".", "isArray", "(", "resp", ")", ")", "{", "resp", "=", "resp", "[", "0", "]", ";", "}", "resp", "=", "_", ".", "defaultsDeep", "(", "{", "}", ",", "resp", ",", "this", ".", "defaults", "(", ")", ")", ";", "return", "resp", ";", "}" ]
Backbone `parse` extended with support for defaults @param {Object|Array} resp @param {Object} options @return {Object}
[ "Backbone", "parse", "extended", "with", "support", "for", "defaults" ]
ea8b26aa94836514374907c325a0d79f28838e2e
https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/model.js#L472-L479
57,334
airbrite/muni
model.js
function(key, val, options) { var attrs; if (key === null) return this; if (typeof key === 'object') { attrs = key; options = val; } else { (attrs = {})[key] = val; } options || (options = {}); // Don't override unset if (options.unset) { return Backbone.Model.prototype.set.apply(this, arguments); } // Apply schema this._validateAttributes(attrs, this._schema, this._defaults); return Backbone.Model.prototype.set.call(this, attrs, options); }
javascript
function(key, val, options) { var attrs; if (key === null) return this; if (typeof key === 'object') { attrs = key; options = val; } else { (attrs = {})[key] = val; } options || (options = {}); // Don't override unset if (options.unset) { return Backbone.Model.prototype.set.apply(this, arguments); } // Apply schema this._validateAttributes(attrs, this._schema, this._defaults); return Backbone.Model.prototype.set.call(this, attrs, options); }
[ "function", "(", "key", ",", "val", ",", "options", ")", "{", "var", "attrs", ";", "if", "(", "key", "===", "null", ")", "return", "this", ";", "if", "(", "typeof", "key", "===", "'object'", ")", "{", "attrs", "=", "key", ";", "options", "=", "val", ";", "}", "else", "{", "(", "attrs", "=", "{", "}", ")", "[", "key", "]", "=", "val", ";", "}", "options", "||", "(", "options", "=", "{", "}", ")", ";", "// Don't override unset", "if", "(", "options", ".", "unset", ")", "{", "return", "Backbone", ".", "Model", ".", "prototype", ".", "set", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "// Apply schema", "this", ".", "_validateAttributes", "(", "attrs", ",", "this", ".", "_schema", ",", "this", ".", "_defaults", ")", ";", "return", "Backbone", ".", "Model", ".", "prototype", ".", "set", ".", "call", "(", "this", ",", "attrs", ",", "options", ")", ";", "}" ]
Backbone `set` extended with support for schema TODO @ptshih Extend with lodash `set` (nested/deep) @return {*}
[ "Backbone", "set", "extended", "with", "support", "for", "schema" ]
ea8b26aa94836514374907c325a0d79f28838e2e
https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/model.js#L489-L511
57,335
airbrite/muni
model.js
function(attrs, attr) { if (!_.isString(attr)) { return undefined; } var keys = attr.split('.'); var key; var val = attrs; var context = this; for (var i = 0, n = keys.length; i < n; i++) { // get key key = keys[i]; // Hold reference to the context when diving deep into nested keys if (i > 0) { context = val; } // get value for key val = val[key]; // value for key does not exist // break out of loop early if (_.isUndefined(val) || _.isNull(val)) { break; } } // Eval computed properties that are functions if (_.isFunction(val)) { // Call it with the proper context (see above) val = val.call(context); } return val; }
javascript
function(attrs, attr) { if (!_.isString(attr)) { return undefined; } var keys = attr.split('.'); var key; var val = attrs; var context = this; for (var i = 0, n = keys.length; i < n; i++) { // get key key = keys[i]; // Hold reference to the context when diving deep into nested keys if (i > 0) { context = val; } // get value for key val = val[key]; // value for key does not exist // break out of loop early if (_.isUndefined(val) || _.isNull(val)) { break; } } // Eval computed properties that are functions if (_.isFunction(val)) { // Call it with the proper context (see above) val = val.call(context); } return val; }
[ "function", "(", "attrs", ",", "attr", ")", "{", "if", "(", "!", "_", ".", "isString", "(", "attr", ")", ")", "{", "return", "undefined", ";", "}", "var", "keys", "=", "attr", ".", "split", "(", "'.'", ")", ";", "var", "key", ";", "var", "val", "=", "attrs", ";", "var", "context", "=", "this", ";", "for", "(", "var", "i", "=", "0", ",", "n", "=", "keys", ".", "length", ";", "i", "<", "n", ";", "i", "++", ")", "{", "// get key", "key", "=", "keys", "[", "i", "]", ";", "// Hold reference to the context when diving deep into nested keys", "if", "(", "i", ">", "0", ")", "{", "context", "=", "val", ";", "}", "// get value for key", "val", "=", "val", "[", "key", "]", ";", "// value for key does not exist", "// break out of loop early", "if", "(", "_", ".", "isUndefined", "(", "val", ")", "||", "_", ".", "isNull", "(", "val", ")", ")", "{", "break", ";", "}", "}", "// Eval computed properties that are functions", "if", "(", "_", ".", "isFunction", "(", "val", ")", ")", "{", "// Call it with the proper context (see above)", "val", "=", "val", ".", "call", "(", "context", ")", ";", "}", "return", "val", ";", "}" ]
DEPRECATED 2015-05-08 Soon `get` will use lodash `get` instead of `getDeep`
[ "DEPRECATED", "2015", "-", "05", "-", "08", "Soon", "get", "will", "use", "lodash", "get", "instead", "of", "getDeep" ]
ea8b26aa94836514374907c325a0d79f28838e2e
https://github.com/airbrite/muni/blob/ea8b26aa94836514374907c325a0d79f28838e2e/model.js#L540-L576
57,336
stadt-bielefeld/wms-capabilities-tools
index.js
determineVersion
function determineVersion(json) { var version = 'unknown'; if (json) { if (json.WMS_Capabilities) { if (json.WMS_Capabilities.$) { if (json.WMS_Capabilities.$.version) { version = json.WMS_Capabilities.$.version; } } } else { if (json.WMT_MS_Capabilities) { if (json.WMT_MS_Capabilities.$) { if (json.WMT_MS_Capabilities.$.version) { version = json.WMT_MS_Capabilities.$.version; } } } } } return version; }
javascript
function determineVersion(json) { var version = 'unknown'; if (json) { if (json.WMS_Capabilities) { if (json.WMS_Capabilities.$) { if (json.WMS_Capabilities.$.version) { version = json.WMS_Capabilities.$.version; } } } else { if (json.WMT_MS_Capabilities) { if (json.WMT_MS_Capabilities.$) { if (json.WMT_MS_Capabilities.$.version) { version = json.WMT_MS_Capabilities.$.version; } } } } } return version; }
[ "function", "determineVersion", "(", "json", ")", "{", "var", "version", "=", "'unknown'", ";", "if", "(", "json", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "$", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "$", ".", "version", ")", "{", "version", "=", "json", ".", "WMS_Capabilities", ".", "$", ".", "version", ";", "}", "}", "}", "else", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "$", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "$", ".", "version", ")", "{", "version", "=", "json", ".", "WMT_MS_Capabilities", ".", "$", ".", "version", ";", "}", "}", "}", "}", "}", "return", "version", ";", "}" ]
It determines the version of GetCapabilities document. @param json {object} GetCapabilities document as JSON. @returns {String} Version of GetCapabilities document. If the version can't determined, it will return 'unknown'.
[ "It", "determines", "the", "version", "of", "GetCapabilities", "document", "." ]
647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1
https://github.com/stadt-bielefeld/wms-capabilities-tools/blob/647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1/index.js#L43-L63
57,337
stadt-bielefeld/wms-capabilities-tools
index.js
determineJSON
function determineJSON(xml) { var json = null; parseString(xml, function(err, result) { if (err) { // TODO console.log(err); } else { json = result; } }); return json; }
javascript
function determineJSON(xml) { var json = null; parseString(xml, function(err, result) { if (err) { // TODO console.log(err); } else { json = result; } }); return json; }
[ "function", "determineJSON", "(", "xml", ")", "{", "var", "json", "=", "null", ";", "parseString", "(", "xml", ",", "function", "(", "err", ",", "result", ")", "{", "if", "(", "err", ")", "{", "// TODO", "console", ".", "log", "(", "err", ")", ";", "}", "else", "{", "json", "=", "result", ";", "}", "}", ")", ";", "return", "json", ";", "}" ]
It determines the JSON object from XML. @param xml {string} GetCapabilities document as XML. @returns {object} GetCapabilities document as JSON.
[ "It", "determines", "the", "JSON", "object", "from", "XML", "." ]
647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1
https://github.com/stadt-bielefeld/wms-capabilities-tools/blob/647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1/index.js#L72-L83
57,338
stadt-bielefeld/wms-capabilities-tools
index.js
determineLayers
function determineLayers(json, version) { var layers = []; if (version == '1.3.0') { if (json.WMS_Capabilities.Capability) { if (json.WMS_Capabilities.Capability[0]) { if (json.WMS_Capabilities.Capability[0].Layer) { layers = buildLayers(json.WMS_Capabilities.Capability[0].Layer); } } } } else { if (version == '1.1.1' || version == '1.1.0' || version == '1.0.0') { if (json.WMT_MS_Capabilities.Capability) { if (json.WMT_MS_Capabilities.Capability[0]) { if (json.WMT_MS_Capabilities.Capability[0].Layer) { layers = buildLayers(json.WMT_MS_Capabilities.Capability[0].Layer); } } } } } return layers; }
javascript
function determineLayers(json, version) { var layers = []; if (version == '1.3.0') { if (json.WMS_Capabilities.Capability) { if (json.WMS_Capabilities.Capability[0]) { if (json.WMS_Capabilities.Capability[0].Layer) { layers = buildLayers(json.WMS_Capabilities.Capability[0].Layer); } } } } else { if (version == '1.1.1' || version == '1.1.0' || version == '1.0.0') { if (json.WMT_MS_Capabilities.Capability) { if (json.WMT_MS_Capabilities.Capability[0]) { if (json.WMT_MS_Capabilities.Capability[0].Layer) { layers = buildLayers(json.WMT_MS_Capabilities.Capability[0].Layer); } } } } } return layers; }
[ "function", "determineLayers", "(", "json", ",", "version", ")", "{", "var", "layers", "=", "[", "]", ";", "if", "(", "version", "==", "'1.3.0'", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Capability", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Capability", "[", "0", "]", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Capability", "[", "0", "]", ".", "Layer", ")", "{", "layers", "=", "buildLayers", "(", "json", ".", "WMS_Capabilities", ".", "Capability", "[", "0", "]", ".", "Layer", ")", ";", "}", "}", "}", "}", "else", "{", "if", "(", "version", "==", "'1.1.1'", "||", "version", "==", "'1.1.0'", "||", "version", "==", "'1.0.0'", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Capability", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Capability", "[", "0", "]", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Capability", "[", "0", "]", ".", "Layer", ")", "{", "layers", "=", "buildLayers", "(", "json", ".", "WMT_MS_Capabilities", ".", "Capability", "[", "0", "]", ".", "Layer", ")", ";", "}", "}", "}", "}", "}", "return", "layers", ";", "}" ]
It determines the layer JSON from original XML GetCapabilities document. @param json {object} GetCapabilities document as JSON. @param version {string} Version of GetCapabilities document. @returns {object} JSON object with layers from original XML GetCapabilities.
[ "It", "determines", "the", "layer", "JSON", "from", "original", "XML", "GetCapabilities", "document", "." ]
647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1
https://github.com/stadt-bielefeld/wms-capabilities-tools/blob/647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1/index.js#L94-L117
57,339
stadt-bielefeld/wms-capabilities-tools
index.js
determineLayerName
function determineLayerName(layer) { var name = ''; // Layer name available if (layer.Name) { return layer.Name; } else { // Layer name not available // Layer name will be building from sublayers for (var int = 0; int < layer.Layer.length; int++) { name += determineLayerName(layer.Layer[int]) + ','; } } // Remove last comma if (name.substring(name.length - 1, name.length) == ',') { name = name.substring(0, name.length - 1); } return name; }
javascript
function determineLayerName(layer) { var name = ''; // Layer name available if (layer.Name) { return layer.Name; } else { // Layer name not available // Layer name will be building from sublayers for (var int = 0; int < layer.Layer.length; int++) { name += determineLayerName(layer.Layer[int]) + ','; } } // Remove last comma if (name.substring(name.length - 1, name.length) == ',') { name = name.substring(0, name.length - 1); } return name; }
[ "function", "determineLayerName", "(", "layer", ")", "{", "var", "name", "=", "''", ";", "// Layer name available", "if", "(", "layer", ".", "Name", ")", "{", "return", "layer", ".", "Name", ";", "}", "else", "{", "// Layer name not available", "// Layer name will be building from sublayers", "for", "(", "var", "int", "=", "0", ";", "int", "<", "layer", ".", "Layer", ".", "length", ";", "int", "++", ")", "{", "name", "+=", "determineLayerName", "(", "layer", ".", "Layer", "[", "int", "]", ")", "+", "','", ";", "}", "}", "// Remove last comma", "if", "(", "name", ".", "substring", "(", "name", ".", "length", "-", "1", ",", "name", ".", "length", ")", "==", "','", ")", "{", "name", "=", "name", ".", "substring", "(", "0", ",", "name", ".", "length", "-", "1", ")", ";", "}", "return", "name", ";", "}" ]
It determines the name of a layer. If the layer name is not set, it will generate from the sublayers. @param {object} layer Layer object like {"Name": "LayerName", "Layer": [{"Name": "SubLayerName1"},{"Name": "SubLayerName2"}]} @returns {string} Name of layer
[ "It", "determines", "the", "name", "of", "a", "layer", ".", "If", "the", "layer", "name", "is", "not", "set", "it", "will", "generate", "from", "the", "sublayers", "." ]
647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1
https://github.com/stadt-bielefeld/wms-capabilities-tools/blob/647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1/index.js#L128-L148
57,340
stadt-bielefeld/wms-capabilities-tools
index.js
buildLayers
function buildLayers(layersObject) { // Array of layers var layers = []; if (layersObject) { // Iterate over all layers for (var int = 0; int < layersObject.length; int++) { // One layer var singleLayer = layersObject[int]; // Build a new layer object var layer = {}; // Determine name from GetCapabilities document if (singleLayer.Name) { if (singleLayer.Name[0]) { layer.Name = singleLayer.Name[0]; } } // Determine title from GetCapabilities document if (singleLayer.Title) { if (singleLayer.Title[0]) { layer.Title = singleLayer.Title[0]; } } // Determine abstract from GetCapabilities document if (singleLayer.Abstract) { if (singleLayer.Abstract[0]) { layer.Abstract = singleLayer.Abstract[0]; } } layer.Layer = buildLayers(singleLayer.Layer); // Determine layer name if not available layer.Name = determineLayerName(layer); // Determine layer title if not available if (!(layer.Title)) { layer.Title = layer.Name; } // Add layer to the array layers.push(layer); } } return layers; }
javascript
function buildLayers(layersObject) { // Array of layers var layers = []; if (layersObject) { // Iterate over all layers for (var int = 0; int < layersObject.length; int++) { // One layer var singleLayer = layersObject[int]; // Build a new layer object var layer = {}; // Determine name from GetCapabilities document if (singleLayer.Name) { if (singleLayer.Name[0]) { layer.Name = singleLayer.Name[0]; } } // Determine title from GetCapabilities document if (singleLayer.Title) { if (singleLayer.Title[0]) { layer.Title = singleLayer.Title[0]; } } // Determine abstract from GetCapabilities document if (singleLayer.Abstract) { if (singleLayer.Abstract[0]) { layer.Abstract = singleLayer.Abstract[0]; } } layer.Layer = buildLayers(singleLayer.Layer); // Determine layer name if not available layer.Name = determineLayerName(layer); // Determine layer title if not available if (!(layer.Title)) { layer.Title = layer.Name; } // Add layer to the array layers.push(layer); } } return layers; }
[ "function", "buildLayers", "(", "layersObject", ")", "{", "// Array of layers", "var", "layers", "=", "[", "]", ";", "if", "(", "layersObject", ")", "{", "// Iterate over all layers", "for", "(", "var", "int", "=", "0", ";", "int", "<", "layersObject", ".", "length", ";", "int", "++", ")", "{", "// One layer", "var", "singleLayer", "=", "layersObject", "[", "int", "]", ";", "// Build a new layer object", "var", "layer", "=", "{", "}", ";", "// Determine name from GetCapabilities document", "if", "(", "singleLayer", ".", "Name", ")", "{", "if", "(", "singleLayer", ".", "Name", "[", "0", "]", ")", "{", "layer", ".", "Name", "=", "singleLayer", ".", "Name", "[", "0", "]", ";", "}", "}", "// Determine title from GetCapabilities document", "if", "(", "singleLayer", ".", "Title", ")", "{", "if", "(", "singleLayer", ".", "Title", "[", "0", "]", ")", "{", "layer", ".", "Title", "=", "singleLayer", ".", "Title", "[", "0", "]", ";", "}", "}", "// Determine abstract from GetCapabilities document", "if", "(", "singleLayer", ".", "Abstract", ")", "{", "if", "(", "singleLayer", ".", "Abstract", "[", "0", "]", ")", "{", "layer", ".", "Abstract", "=", "singleLayer", ".", "Abstract", "[", "0", "]", ";", "}", "}", "layer", ".", "Layer", "=", "buildLayers", "(", "singleLayer", ".", "Layer", ")", ";", "// Determine layer name if not available", "layer", ".", "Name", "=", "determineLayerName", "(", "layer", ")", ";", "// Determine layer title if not available", "if", "(", "!", "(", "layer", ".", "Title", ")", ")", "{", "layer", ".", "Title", "=", "layer", ".", "Name", ";", "}", "// Add layer to the array", "layers", ".", "push", "(", "layer", ")", ";", "}", "}", "return", "layers", ";", "}" ]
It builds a simple array with layer information. @param {object} layersObject Object with layers from JSON. That JSON have to converted by the original XML GetCapabilities document. @returns {array} Array with layers and sublayers
[ "It", "builds", "a", "simple", "array", "with", "layer", "information", "." ]
647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1
https://github.com/stadt-bielefeld/wms-capabilities-tools/blob/647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1/index.js#L158-L208
57,341
stadt-bielefeld/wms-capabilities-tools
index.js
determineMaxWidth
function determineMaxWidth(json, version) { var maxWidth = 0; // Only available in WMS 1.3.0 if (version == '1.3.0') { if (json.WMS_Capabilities.Service) { if (json.WMS_Capabilities.Service[0]) { if (json.WMS_Capabilities.Service[0].MaxWidth) { if (json.WMS_Capabilities.Service[0].MaxWidth[0]) { maxWidth = json.WMS_Capabilities.Service[0].MaxWidth[0]; } } } } } return maxWidth; }
javascript
function determineMaxWidth(json, version) { var maxWidth = 0; // Only available in WMS 1.3.0 if (version == '1.3.0') { if (json.WMS_Capabilities.Service) { if (json.WMS_Capabilities.Service[0]) { if (json.WMS_Capabilities.Service[0].MaxWidth) { if (json.WMS_Capabilities.Service[0].MaxWidth[0]) { maxWidth = json.WMS_Capabilities.Service[0].MaxWidth[0]; } } } } } return maxWidth; }
[ "function", "determineMaxWidth", "(", "json", ",", "version", ")", "{", "var", "maxWidth", "=", "0", ";", "// Only available in WMS 1.3.0", "if", "(", "version", "==", "'1.3.0'", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "MaxWidth", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "MaxWidth", "[", "0", "]", ")", "{", "maxWidth", "=", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "MaxWidth", "[", "0", "]", ";", "}", "}", "}", "}", "}", "return", "maxWidth", ";", "}" ]
It determines the max width of a GetMap request in pixels. @param json {object} GetCapabilities document as JSON. @param version {string} Version of GetCapabilities document. @returns {integer} Max width of a GetMap request in pixels. It returns 0, if no value is available.
[ "It", "determines", "the", "max", "width", "of", "a", "GetMap", "request", "in", "pixels", "." ]
647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1
https://github.com/stadt-bielefeld/wms-capabilities-tools/blob/647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1/index.js#L220-L237
57,342
stadt-bielefeld/wms-capabilities-tools
index.js
determineMaxHeight
function determineMaxHeight(json, version) { var maxHeight = 0; // Only available in WMS 1.3.0 if (version == '1.3.0') { if (json.WMS_Capabilities.Service) { if (json.WMS_Capabilities.Service[0]) { if (json.WMS_Capabilities.Service[0].MaxHeight) { if (json.WMS_Capabilities.Service[0].MaxHeight[0]) { maxHeight = json.WMS_Capabilities.Service[0].MaxHeight[0]; } } } } } return maxHeight; }
javascript
function determineMaxHeight(json, version) { var maxHeight = 0; // Only available in WMS 1.3.0 if (version == '1.3.0') { if (json.WMS_Capabilities.Service) { if (json.WMS_Capabilities.Service[0]) { if (json.WMS_Capabilities.Service[0].MaxHeight) { if (json.WMS_Capabilities.Service[0].MaxHeight[0]) { maxHeight = json.WMS_Capabilities.Service[0].MaxHeight[0]; } } } } } return maxHeight; }
[ "function", "determineMaxHeight", "(", "json", ",", "version", ")", "{", "var", "maxHeight", "=", "0", ";", "// Only available in WMS 1.3.0", "if", "(", "version", "==", "'1.3.0'", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "MaxHeight", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "MaxHeight", "[", "0", "]", ")", "{", "maxHeight", "=", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "MaxHeight", "[", "0", "]", ";", "}", "}", "}", "}", "}", "return", "maxHeight", ";", "}" ]
It determines the max height of a GetMap request in pixels. @param json {object} GetCapabilities document as JSON. @param version {string} Version of GetCapabilities document. @returns {integer} Max height of a GetMap request in pixels. It returns 0, if no value is available.
[ "It", "determines", "the", "max", "height", "of", "a", "GetMap", "request", "in", "pixels", "." ]
647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1
https://github.com/stadt-bielefeld/wms-capabilities-tools/blob/647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1/index.js#L249-L266
57,343
stadt-bielefeld/wms-capabilities-tools
index.js
determineWMSTitle
function determineWMSTitle(json, version) { var ret = ''; if (version == '1.3.0') { if (json.WMS_Capabilities.Service) { if (json.WMS_Capabilities.Service[0]) { if (json.WMS_Capabilities.Service[0].Title) { if (json.WMS_Capabilities.Service[0].Title[0]) { ret = json.WMS_Capabilities.Service[0].Title[0]; } } } } } else { if (version == '1.1.1' || version == '1.1.0' || version == '1.0.0') { if (json.WMT_MS_Capabilities.Service) { if (json.WMT_MS_Capabilities.Service[0]) { if (json.WMT_MS_Capabilities.Service[0].Title) { if (json.WMT_MS_Capabilities.Service[0].Title[0]) { ret = json.WMT_MS_Capabilities.Service[0].Title[0]; } } } } } } return ret; }
javascript
function determineWMSTitle(json, version) { var ret = ''; if (version == '1.3.0') { if (json.WMS_Capabilities.Service) { if (json.WMS_Capabilities.Service[0]) { if (json.WMS_Capabilities.Service[0].Title) { if (json.WMS_Capabilities.Service[0].Title[0]) { ret = json.WMS_Capabilities.Service[0].Title[0]; } } } } } else { if (version == '1.1.1' || version == '1.1.0' || version == '1.0.0') { if (json.WMT_MS_Capabilities.Service) { if (json.WMT_MS_Capabilities.Service[0]) { if (json.WMT_MS_Capabilities.Service[0].Title) { if (json.WMT_MS_Capabilities.Service[0].Title[0]) { ret = json.WMT_MS_Capabilities.Service[0].Title[0]; } } } } } } return ret; }
[ "function", "determineWMSTitle", "(", "json", ",", "version", ")", "{", "var", "ret", "=", "''", ";", "if", "(", "version", "==", "'1.3.0'", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "Title", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "Title", "[", "0", "]", ")", "{", "ret", "=", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "Title", "[", "0", "]", ";", "}", "}", "}", "}", "}", "else", "{", "if", "(", "version", "==", "'1.1.1'", "||", "version", "==", "'1.1.0'", "||", "version", "==", "'1.0.0'", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Service", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Service", "[", "0", "]", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Service", "[", "0", "]", ".", "Title", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Service", "[", "0", "]", ".", "Title", "[", "0", "]", ")", "{", "ret", "=", "json", ".", "WMT_MS_Capabilities", ".", "Service", "[", "0", "]", ".", "Title", "[", "0", "]", ";", "}", "}", "}", "}", "}", "}", "return", "ret", ";", "}" ]
It determines the WMS title. @param {object} json GetCapabilities document as JSON. @param {string} version Version of GetCapabilities document. @returns {string} WMS title.
[ "It", "determines", "the", "WMS", "title", "." ]
647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1
https://github.com/stadt-bielefeld/wms-capabilities-tools/blob/647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1/index.js#L399-L427
57,344
stadt-bielefeld/wms-capabilities-tools
index.js
determineWMSAbstract
function determineWMSAbstract(json, version) { var ret = ''; if (version == '1.3.0') { if (json.WMS_Capabilities.Service) { if (json.WMS_Capabilities.Service[0]) { if (json.WMS_Capabilities.Service[0].Abstract) { if (json.WMS_Capabilities.Service[0].Abstract[0]) { ret = json.WMS_Capabilities.Service[0].Abstract[0]; } } } } } else { if (version == '1.1.1' || version == '1.1.0' || version == '1.0.0') { if (json.WMT_MS_Capabilities.Service) { if (json.WMT_MS_Capabilities.Service[0]) { if (json.WMT_MS_Capabilities.Service[0].Abstract) { if (json.WMT_MS_Capabilities.Service[0].Abstract[0]) { ret = json.WMT_MS_Capabilities.Service[0].Abstract[0]; } } } } } } return ret; }
javascript
function determineWMSAbstract(json, version) { var ret = ''; if (version == '1.3.0') { if (json.WMS_Capabilities.Service) { if (json.WMS_Capabilities.Service[0]) { if (json.WMS_Capabilities.Service[0].Abstract) { if (json.WMS_Capabilities.Service[0].Abstract[0]) { ret = json.WMS_Capabilities.Service[0].Abstract[0]; } } } } } else { if (version == '1.1.1' || version == '1.1.0' || version == '1.0.0') { if (json.WMT_MS_Capabilities.Service) { if (json.WMT_MS_Capabilities.Service[0]) { if (json.WMT_MS_Capabilities.Service[0].Abstract) { if (json.WMT_MS_Capabilities.Service[0].Abstract[0]) { ret = json.WMT_MS_Capabilities.Service[0].Abstract[0]; } } } } } } return ret; }
[ "function", "determineWMSAbstract", "(", "json", ",", "version", ")", "{", "var", "ret", "=", "''", ";", "if", "(", "version", "==", "'1.3.0'", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "Abstract", ")", "{", "if", "(", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "Abstract", "[", "0", "]", ")", "{", "ret", "=", "json", ".", "WMS_Capabilities", ".", "Service", "[", "0", "]", ".", "Abstract", "[", "0", "]", ";", "}", "}", "}", "}", "}", "else", "{", "if", "(", "version", "==", "'1.1.1'", "||", "version", "==", "'1.1.0'", "||", "version", "==", "'1.0.0'", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Service", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Service", "[", "0", "]", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Service", "[", "0", "]", ".", "Abstract", ")", "{", "if", "(", "json", ".", "WMT_MS_Capabilities", ".", "Service", "[", "0", "]", ".", "Abstract", "[", "0", "]", ")", "{", "ret", "=", "json", ".", "WMT_MS_Capabilities", ".", "Service", "[", "0", "]", ".", "Abstract", "[", "0", "]", ";", "}", "}", "}", "}", "}", "}", "return", "ret", ";", "}" ]
It determines the WMS abstract. @param {object} json GetCapabilities document as JSON. @param {string} version Version of GetCapabilities document. @returns {string} WMS abstract.
[ "It", "determines", "the", "WMS", "abstract", "." ]
647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1
https://github.com/stadt-bielefeld/wms-capabilities-tools/blob/647321bc7fb9a50a5fdc6c3424ede3d9c0fd1cb1/index.js#L438-L466
57,345
sazze/node-thrift
lib/_thriftHttpClient.js
Client
function Client(host, port, path, service, transport, protocol) { if (!service.hasOwnProperty('Client')) { throw new Error('Thrift Service must have a Client'); } /** * The host of the thrift server * * @type {string} */ this.host = host; /** * The port of the thrift server * * @type {Number} */ this.port = port; /** * The path for the thrift server * * @type {string} */ this.path = path; /** * Whether or not to autoClose connection * * @type {boolean} */ this.autoClose = true; /** * The thrift service * * @type {Object} */ this.service = service; /** * The thrift transport * * @type {*|TBufferedTransport} */ this.transport = transport || thrift.TBufferedTransport; /** * The thrift protocol * * @type {*|exports.TBinaryProtocol} */ this.protocol = protocol || thrift.TBinaryProtocol; /** * The Thrift Service Client * @type {Client} */ this.client = new service.Client; /** * The Thrift Client Connection * * @type {*} * @private */ this._connection = null; /** * The Thrift Client * * @type {null} * @private */ this._client = null; /** * Whether or not we are connected to thrift * * @type {boolean} */ this.isConnected = false; /** * A Success Pre-parser Callback * @param {*} data * @param {Function} Success Callback * @param {Function} Error Callback * @type {Function|null} */ this.successCallback = null; /** * A Error Pre-parser Callback * @param {*} data * @param {Function} Error Callback * @type {Function|null} */ this.errorCallback = null; }
javascript
function Client(host, port, path, service, transport, protocol) { if (!service.hasOwnProperty('Client')) { throw new Error('Thrift Service must have a Client'); } /** * The host of the thrift server * * @type {string} */ this.host = host; /** * The port of the thrift server * * @type {Number} */ this.port = port; /** * The path for the thrift server * * @type {string} */ this.path = path; /** * Whether or not to autoClose connection * * @type {boolean} */ this.autoClose = true; /** * The thrift service * * @type {Object} */ this.service = service; /** * The thrift transport * * @type {*|TBufferedTransport} */ this.transport = transport || thrift.TBufferedTransport; /** * The thrift protocol * * @type {*|exports.TBinaryProtocol} */ this.protocol = protocol || thrift.TBinaryProtocol; /** * The Thrift Service Client * @type {Client} */ this.client = new service.Client; /** * The Thrift Client Connection * * @type {*} * @private */ this._connection = null; /** * The Thrift Client * * @type {null} * @private */ this._client = null; /** * Whether or not we are connected to thrift * * @type {boolean} */ this.isConnected = false; /** * A Success Pre-parser Callback * @param {*} data * @param {Function} Success Callback * @param {Function} Error Callback * @type {Function|null} */ this.successCallback = null; /** * A Error Pre-parser Callback * @param {*} data * @param {Function} Error Callback * @type {Function|null} */ this.errorCallback = null; }
[ "function", "Client", "(", "host", ",", "port", ",", "path", ",", "service", ",", "transport", ",", "protocol", ")", "{", "if", "(", "!", "service", ".", "hasOwnProperty", "(", "'Client'", ")", ")", "{", "throw", "new", "Error", "(", "'Thrift Service must have a Client'", ")", ";", "}", "/**\n * The host of the thrift server\n *\n * @type {string}\n */", "this", ".", "host", "=", "host", ";", "/**\n * The port of the thrift server\n *\n * @type {Number}\n */", "this", ".", "port", "=", "port", ";", "/**\n * The path for the thrift server\n *\n * @type {string}\n */", "this", ".", "path", "=", "path", ";", "/**\n * Whether or not to autoClose connection\n *\n * @type {boolean}\n */", "this", ".", "autoClose", "=", "true", ";", "/**\n * The thrift service\n *\n * @type {Object}\n */", "this", ".", "service", "=", "service", ";", "/**\n * The thrift transport\n *\n * @type {*|TBufferedTransport}\n */", "this", ".", "transport", "=", "transport", "||", "thrift", ".", "TBufferedTransport", ";", "/**\n * The thrift protocol\n *\n * @type {*|exports.TBinaryProtocol}\n */", "this", ".", "protocol", "=", "protocol", "||", "thrift", ".", "TBinaryProtocol", ";", "/**\n * The Thrift Service Client\n * @type {Client}\n */", "this", ".", "client", "=", "new", "service", ".", "Client", ";", "/**\n * The Thrift Client Connection\n *\n * @type {*}\n * @private\n */", "this", ".", "_connection", "=", "null", ";", "/**\n * The Thrift Client\n *\n * @type {null}\n * @private\n */", "this", ".", "_client", "=", "null", ";", "/**\n * Whether or not we are connected to thrift\n *\n * @type {boolean}\n */", "this", ".", "isConnected", "=", "false", ";", "/**\n * A Success Pre-parser Callback\n * @param {*} data\n * @param {Function} Success Callback\n * @param {Function} Error Callback\n * @type {Function|null}\n */", "this", ".", "successCallback", "=", "null", ";", "/**\n * A Error Pre-parser Callback\n * @param {*} data\n * @param {Function} Error Callback\n * @type {Function|null}\n */", "this", ".", "errorCallback", "=", "null", ";", "}" ]
Create a new thrift client @param {string} host @param {int} port @param {string} path @param {Object} service @param {Transport} transport @param {Protocol} protocol @throws {Error} error If thrift service does not have a Client property @constructor
[ "Create", "a", "new", "thrift", "client" ]
458d1829813cbd2d50dae610bc7210b75140e58f
https://github.com/sazze/node-thrift/blob/458d1829813cbd2d50dae610bc7210b75140e58f/lib/_thriftHttpClient.js#L31-L130
57,346
llamadeus/data-to-png
es/png.js
createChunk
function createChunk(type, data) { const length = typeof data != 'undefined' ? data.length : 0; const chunk = Buffer.alloc(4 + 4 + length + 4); chunk.writeUInt32BE(length, 0); chunk.fill(type, 4, 8, 'utf8'); if (typeof data != 'undefined') { chunk.fill(data, 8, chunk.length - 4); } chunk.writeUInt32BE(crc32(chunk.slice(4, -4)), chunk.length - 4); return chunk; }
javascript
function createChunk(type, data) { const length = typeof data != 'undefined' ? data.length : 0; const chunk = Buffer.alloc(4 + 4 + length + 4); chunk.writeUInt32BE(length, 0); chunk.fill(type, 4, 8, 'utf8'); if (typeof data != 'undefined') { chunk.fill(data, 8, chunk.length - 4); } chunk.writeUInt32BE(crc32(chunk.slice(4, -4)), chunk.length - 4); return chunk; }
[ "function", "createChunk", "(", "type", ",", "data", ")", "{", "const", "length", "=", "typeof", "data", "!=", "'undefined'", "?", "data", ".", "length", ":", "0", ";", "const", "chunk", "=", "Buffer", ".", "alloc", "(", "4", "+", "4", "+", "length", "+", "4", ")", ";", "chunk", ".", "writeUInt32BE", "(", "length", ",", "0", ")", ";", "chunk", ".", "fill", "(", "type", ",", "4", ",", "8", ",", "'utf8'", ")", ";", "if", "(", "typeof", "data", "!=", "'undefined'", ")", "{", "chunk", ".", "fill", "(", "data", ",", "8", ",", "chunk", ".", "length", "-", "4", ")", ";", "}", "chunk", ".", "writeUInt32BE", "(", "crc32", "(", "chunk", ".", "slice", "(", "4", ",", "-", "4", ")", ")", ",", "chunk", ".", "length", "-", "4", ")", ";", "return", "chunk", ";", "}" ]
Create a chunk of the given type with the given data. @param type @param data @returns {Buffer}
[ "Create", "a", "chunk", "of", "the", "given", "type", "with", "the", "given", "data", "." ]
8170197b4213d86a56c7b0cc4952f80a1e840766
https://github.com/llamadeus/data-to-png/blob/8170197b4213d86a56c7b0cc4952f80a1e840766/es/png.js#L27-L39
57,347
rootslab/shashi
lib/shashi.js
function ( n, buffer, bytes ) { var s = ( n % k ) * slen // how many bytes to read/consume from the input buffer [1 to 4] , rbytes = bytes >>> 0 ? abs( bytes ) % 5 : ibytes , blen = buffer.length - rbytes , bruint = null , sum = 0 , b = 0 ; /* * NOTE: js is not capable to handle integers larger than ~2^53, * when the sum exceeds this limit, we expect to get get biased * results, or in other words, more collisions. It will happens * when we are using large primes as range, or with long buffer * in input. If sum === sum + 1, we could break the for cycle. */ if ( rbytes === 1 ) { // use [] notation when reading input, 1 byte at the time. if ( ibytes === 1 ) { // read input and seed 1 byte at the time for ( ; b <= blen && s <= rlen; ++b, ++s ) sum += buffer[ b ] * result[ s ]; return sum % prange; } for ( ; b <= blen && s <= rlen; ++b, s += ibytes ) sum += buffer[ b ] * result[ ruint ]( s ); return sum % prange; } // build string for read method (16, 24 or 32 bits unsigned integers) bruint = bruint = 'readUInt' + ( rbytes << 3 ) + 'BE'; for ( ; b <= blen && s <= rlen; b += rbytes, s += ibytes ) { sum += buffer[ bruint ]( b ) * result[ ruint ]( s ); sum %= prange; } return sum; }
javascript
function ( n, buffer, bytes ) { var s = ( n % k ) * slen // how many bytes to read/consume from the input buffer [1 to 4] , rbytes = bytes >>> 0 ? abs( bytes ) % 5 : ibytes , blen = buffer.length - rbytes , bruint = null , sum = 0 , b = 0 ; /* * NOTE: js is not capable to handle integers larger than ~2^53, * when the sum exceeds this limit, we expect to get get biased * results, or in other words, more collisions. It will happens * when we are using large primes as range, or with long buffer * in input. If sum === sum + 1, we could break the for cycle. */ if ( rbytes === 1 ) { // use [] notation when reading input, 1 byte at the time. if ( ibytes === 1 ) { // read input and seed 1 byte at the time for ( ; b <= blen && s <= rlen; ++b, ++s ) sum += buffer[ b ] * result[ s ]; return sum % prange; } for ( ; b <= blen && s <= rlen; ++b, s += ibytes ) sum += buffer[ b ] * result[ ruint ]( s ); return sum % prange; } // build string for read method (16, 24 or 32 bits unsigned integers) bruint = bruint = 'readUInt' + ( rbytes << 3 ) + 'BE'; for ( ; b <= blen && s <= rlen; b += rbytes, s += ibytes ) { sum += buffer[ bruint ]( b ) * result[ ruint ]( s ); sum %= prange; } return sum; }
[ "function", "(", "n", ",", "buffer", ",", "bytes", ")", "{", "var", "s", "=", "(", "n", "%", "k", ")", "*", "slen", "// how many bytes to read/consume from the input buffer [1 to 4]", ",", "rbytes", "=", "bytes", ">>>", "0", "?", "abs", "(", "bytes", ")", "%", "5", ":", "ibytes", ",", "blen", "=", "buffer", ".", "length", "-", "rbytes", ",", "bruint", "=", "null", ",", "sum", "=", "0", ",", "b", "=", "0", ";", "/*\n * NOTE: js is not capable to handle integers larger than ~2^53,\n * when the sum exceeds this limit, we expect to get get biased\n * results, or in other words, more collisions. It will happens\n * when we are using large primes as range, or with long buffer\n * in input. If sum === sum + 1, we could break the for cycle.\n */", "if", "(", "rbytes", "===", "1", ")", "{", "// use [] notation when reading input, 1 byte at the time.", "if", "(", "ibytes", "===", "1", ")", "{", "// read input and seed 1 byte at the time", "for", "(", ";", "b", "<=", "blen", "&&", "s", "<=", "rlen", ";", "++", "b", ",", "++", "s", ")", "sum", "+=", "buffer", "[", "b", "]", "*", "result", "[", "s", "]", ";", "return", "sum", "%", "prange", ";", "}", "for", "(", ";", "b", "<=", "blen", "&&", "s", "<=", "rlen", ";", "++", "b", ",", "s", "+=", "ibytes", ")", "sum", "+=", "buffer", "[", "b", "]", "*", "result", "[", "ruint", "]", "(", "s", ")", ";", "return", "sum", "%", "prange", ";", "}", "// build string for read method (16, 24 or 32 bits unsigned integers)", "bruint", "=", "bruint", "=", "'readUInt'", "+", "(", "rbytes", "<<", "3", ")", "+", "'BE'", ";", "for", "(", ";", "b", "<=", "blen", "&&", "s", "<=", "rlen", ";", "b", "+=", "rbytes", ",", "s", "+=", "ibytes", ")", "{", "sum", "+=", "buffer", "[", "bruint", "]", "(", "b", ")", "*", "result", "[", "ruint", "]", "(", "s", ")", ";", "sum", "%=", "prange", ";", "}", "return", "sum", ";", "}" ]
generate random seed sequence for requested range
[ "generate", "random", "seed", "sequence", "for", "requested", "range" ]
24a52dfe45035a387937de210a93411ecbac0bfc
https://github.com/rootslab/shashi/blob/24a52dfe45035a387937de210a93411ecbac0bfc/lib/shashi.js#L42-L77
57,348
daliwali/promise-middleware
lib/index.js
promiseMiddleware
function promiseMiddleware (request, response, middleware) { return new promiseMiddleware.Promise(function (resolve, reject) { middleware(request, response, function next (error) { return error ? reject(error) : resolve() }) }) }
javascript
function promiseMiddleware (request, response, middleware) { return new promiseMiddleware.Promise(function (resolve, reject) { middleware(request, response, function next (error) { return error ? reject(error) : resolve() }) }) }
[ "function", "promiseMiddleware", "(", "request", ",", "response", ",", "middleware", ")", "{", "return", "new", "promiseMiddleware", ".", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "middleware", "(", "request", ",", "response", ",", "function", "next", "(", "error", ")", "{", "return", "error", "?", "reject", "(", "error", ")", ":", "resolve", "(", ")", "}", ")", "}", ")", "}" ]
Use callback middleware functions as promises. @param {Object} request @param {Object} response @param {Function} middleware
[ "Use", "callback", "middleware", "functions", "as", "promises", "." ]
5dc63fc74e12fbd7804577b4694c2941f607ba64
https://github.com/daliwali/promise-middleware/blob/5dc63fc74e12fbd7804577b4694c2941f607ba64/lib/index.js#L14-L20
57,349
SimonSchick/esprintf
index.js
paddLeft
function paddLeft(str, length, what) { if (length <= str.length) { return str.substring(0, length); } what = what || ' '; return what.repeat(length - str.length) + str; }
javascript
function paddLeft(str, length, what) { if (length <= str.length) { return str.substring(0, length); } what = what || ' '; return what.repeat(length - str.length) + str; }
[ "function", "paddLeft", "(", "str", ",", "length", ",", "what", ")", "{", "if", "(", "length", "<=", "str", ".", "length", ")", "{", "return", "str", ".", "substring", "(", "0", ",", "length", ")", ";", "}", "what", "=", "what", "||", "' '", ";", "return", "what", ".", "repeat", "(", "length", "-", "str", ".", "length", ")", "+", "str", ";", "}" ]
Padds or truncates a string left. @param {String} str The string to be modified @param {Number} length Length of the final string @param {String} what The padding string(should be one character) @return {String}
[ "Padds", "or", "truncates", "a", "string", "left", "." ]
0aedf87a2c55a7daaa17a24d77625f5af86eea41
https://github.com/SimonSchick/esprintf/blob/0aedf87a2c55a7daaa17a24d77625f5af86eea41/index.js#L10-L16
57,350
SimonSchick/esprintf
index.js
paddRight
function paddRight(str, length, what) { if (length <= str.length) { return str.substring(0, length); } what = what || ' '; return str + what.repeat(length - str.length); }
javascript
function paddRight(str, length, what) { if (length <= str.length) { return str.substring(0, length); } what = what || ' '; return str + what.repeat(length - str.length); }
[ "function", "paddRight", "(", "str", ",", "length", ",", "what", ")", "{", "if", "(", "length", "<=", "str", ".", "length", ")", "{", "return", "str", ".", "substring", "(", "0", ",", "length", ")", ";", "}", "what", "=", "what", "||", "' '", ";", "return", "str", "+", "what", ".", "repeat", "(", "length", "-", "str", ".", "length", ")", ";", "}" ]
Padds or truncates a string right. @param {String} str The string to be modified @param {Number} length Length of the final string @param {String} what The padding string(should be one character) @return {String}
[ "Padds", "or", "truncates", "a", "string", "right", "." ]
0aedf87a2c55a7daaa17a24d77625f5af86eea41
https://github.com/SimonSchick/esprintf/blob/0aedf87a2c55a7daaa17a24d77625f5af86eea41/index.js#L25-L31
57,351
SimonSchick/esprintf
index.js
precBase
function precBase(base, value, precision) { const val = value.toString(base); const floatingPoint = val.indexOf('.'); if (precision === 0 && floatingPoint > -1) { return val.substring(0, floatingPoint);//Node version > 0.10.* } if (floatingPoint === -1) { return val; } if (val.length - floatingPoint > precision) { return val.substring(0, floatingPoint + precision + 1); } }
javascript
function precBase(base, value, precision) { const val = value.toString(base); const floatingPoint = val.indexOf('.'); if (precision === 0 && floatingPoint > -1) { return val.substring(0, floatingPoint);//Node version > 0.10.* } if (floatingPoint === -1) { return val; } if (val.length - floatingPoint > precision) { return val.substring(0, floatingPoint + precision + 1); } }
[ "function", "precBase", "(", "base", ",", "value", ",", "precision", ")", "{", "const", "val", "=", "value", ".", "toString", "(", "base", ")", ";", "const", "floatingPoint", "=", "val", ".", "indexOf", "(", "'.'", ")", ";", "if", "(", "precision", "===", "0", "&&", "floatingPoint", ">", "-", "1", ")", "{", "return", "val", ".", "substring", "(", "0", ",", "floatingPoint", ")", ";", "//Node version > 0.10.*", "}", "if", "(", "floatingPoint", "===", "-", "1", ")", "{", "return", "val", ";", "}", "if", "(", "val", ".", "length", "-", "floatingPoint", ">", "precision", ")", "{", "return", "val", ".", "substring", "(", "0", ",", "floatingPoint", "+", "precision", "+", "1", ")", ";", "}", "}" ]
Converts the given value to the new numeric base and truncates the precision to the given value. @param {Number} base Should follow the restrictions of Number.prototype.toString() @param {Number} value @param {Number} precision @return {String}
[ "Converts", "the", "given", "value", "to", "the", "new", "numeric", "base", "and", "truncates", "the", "precision", "to", "the", "given", "value", "." ]
0aedf87a2c55a7daaa17a24d77625f5af86eea41
https://github.com/SimonSchick/esprintf/blob/0aedf87a2c55a7daaa17a24d77625f5af86eea41/index.js#L45-L57
57,352
pierrec/node-atok-parser
examples/simple_CSV.js
ParserContent
function ParserContent () { // Parser reference var self = this // Current row var data = [] // Define the parser rules var eol = ['\n','\r\n'] var sep = options.separator || ',' // Handlers are used instead of events atok // Ignore comments .ignore(true) // On rule match, do not do anything, skip the token .addRule('#', eol, 'comment') .ignore() // Turn the ignore property off // Anything else is data // Rule definition: // first argument: always an exact match. To match anything, use '' // next arguments: array of possible matches (first match wins) .addRule('', { firstOf: [ sep ].concat(eol) }, function (token, idx) { // token=the matched data // idx=when using array of patterns, the index of the matched pattern if (token === 'error') { // Build the error message using positioning var err = self.trackError(new Error('Dummy message'), token) self.emit('error', err) return } // Add the data data.push(token) // EOL reached, the parser emits the row if (idx > 0) { self.emit('data', data) data = [] } }) }
javascript
function ParserContent () { // Parser reference var self = this // Current row var data = [] // Define the parser rules var eol = ['\n','\r\n'] var sep = options.separator || ',' // Handlers are used instead of events atok // Ignore comments .ignore(true) // On rule match, do not do anything, skip the token .addRule('#', eol, 'comment') .ignore() // Turn the ignore property off // Anything else is data // Rule definition: // first argument: always an exact match. To match anything, use '' // next arguments: array of possible matches (first match wins) .addRule('', { firstOf: [ sep ].concat(eol) }, function (token, idx) { // token=the matched data // idx=when using array of patterns, the index of the matched pattern if (token === 'error') { // Build the error message using positioning var err = self.trackError(new Error('Dummy message'), token) self.emit('error', err) return } // Add the data data.push(token) // EOL reached, the parser emits the row if (idx > 0) { self.emit('data', data) data = [] } }) }
[ "function", "ParserContent", "(", ")", "{", "// Parser reference", "var", "self", "=", "this", "// Current row", "var", "data", "=", "[", "]", "// Define the parser rules", "var", "eol", "=", "[", "'\\n'", ",", "'\\r\\n'", "]", "var", "sep", "=", "options", ".", "separator", "||", "','", "// Handlers are used instead of events", "atok", "// Ignore comments", ".", "ignore", "(", "true", ")", "// On rule match, do not do anything, skip the token", ".", "addRule", "(", "'#'", ",", "eol", ",", "'comment'", ")", ".", "ignore", "(", ")", "// Turn the ignore property off", "// Anything else is data", "// Rule definition:", "// first argument: always an exact match. To match anything, use ''", "// next arguments: array of possible matches (first match wins)", ".", "addRule", "(", "''", ",", "{", "firstOf", ":", "[", "sep", "]", ".", "concat", "(", "eol", ")", "}", ",", "function", "(", "token", ",", "idx", ")", "{", "// token=the matched data", "// idx=when using array of patterns, the index of the matched pattern", "if", "(", "token", "===", "'error'", ")", "{", "// Build the error message using positioning", "var", "err", "=", "self", ".", "trackError", "(", "new", "Error", "(", "'Dummy message'", ")", ",", "token", ")", "self", ".", "emit", "(", "'error'", ",", "err", ")", "return", "}", "// Add the data", "data", ".", "push", "(", "token", ")", "// EOL reached, the parser emits the row", "if", "(", "idx", ">", "0", ")", "{", "self", ".", "emit", "(", "'data'", ",", "data", ")", "data", "=", "[", "]", "}", "}", ")", "}" ]
This is a rudimentary CSV parser In this simple version, the data must not contain any coma and double quotes are not processed.
[ "This", "is", "a", "rudimentary", "CSV", "parser", "In", "this", "simple", "version", "the", "data", "must", "not", "contain", "any", "coma", "and", "double", "quotes", "are", "not", "processed", "." ]
414d39904dff73ffdde049212076c14ca40aa20b
https://github.com/pierrec/node-atok-parser/blob/414d39904dff73ffdde049212076c14ca40aa20b/examples/simple_CSV.js#L6-L42
57,353
Asw20/session-data
lib/sessionData.js
_sessionData
function _sessionData(variable, value, parameter) { if (this.session === undefined) throw Error('req.sessionData() requires sessions'); var values = this.session.sessionData = this.session.sessionData || {}; if (variable && value) { // Special handling for configuration if (parameter=='setup') { delete values[variable]; } // Special handling for breadcrumb if (variable == 'breadcrumb') { // Do not Add the same Last Url (in case of refresh if (value=='back') { // console.log('%s values[variable].length',srcName,values[variable].length) if (values[variable].length < 2 ) { return values[variable][0] } else { values[variable].pop(); return values[variable].pop(); } } else { if (values[variable] && (values[variable][values[variable].length-1] == value)){ return; } } } // util.format is available in Node.js 0.6+ if (arguments.length > 2 && format && parameter != 'setup' && parameter != 'read') { var args = Array.prototype.slice.call(arguments, 1); value = format.apply(undefined, args); } else if (isArray(value)) { value.forEach(function(val){ (values[variable] = values[variable] || []).push(val); }); return values[variable].length; } return (values[variable] = values[variable] || []).push(value); } else if (variable) { var arr = values[variable]; if ((variable != 'breadcrumb') && (parameter != 'read')){ delete values[variable]; } return arr || []; } else { this.session._sessionData = {}; return values; } }
javascript
function _sessionData(variable, value, parameter) { if (this.session === undefined) throw Error('req.sessionData() requires sessions'); var values = this.session.sessionData = this.session.sessionData || {}; if (variable && value) { // Special handling for configuration if (parameter=='setup') { delete values[variable]; } // Special handling for breadcrumb if (variable == 'breadcrumb') { // Do not Add the same Last Url (in case of refresh if (value=='back') { // console.log('%s values[variable].length',srcName,values[variable].length) if (values[variable].length < 2 ) { return values[variable][0] } else { values[variable].pop(); return values[variable].pop(); } } else { if (values[variable] && (values[variable][values[variable].length-1] == value)){ return; } } } // util.format is available in Node.js 0.6+ if (arguments.length > 2 && format && parameter != 'setup' && parameter != 'read') { var args = Array.prototype.slice.call(arguments, 1); value = format.apply(undefined, args); } else if (isArray(value)) { value.forEach(function(val){ (values[variable] = values[variable] || []).push(val); }); return values[variable].length; } return (values[variable] = values[variable] || []).push(value); } else if (variable) { var arr = values[variable]; if ((variable != 'breadcrumb') && (parameter != 'read')){ delete values[variable]; } return arr || []; } else { this.session._sessionData = {}; return values; } }
[ "function", "_sessionData", "(", "variable", ",", "value", ",", "parameter", ")", "{", "if", "(", "this", ".", "session", "===", "undefined", ")", "throw", "Error", "(", "'req.sessionData() requires sessions'", ")", ";", "var", "values", "=", "this", ".", "session", ".", "sessionData", "=", "this", ".", "session", ".", "sessionData", "||", "{", "}", ";", "if", "(", "variable", "&&", "value", ")", "{", "// Special handling for configuration", "if", "(", "parameter", "==", "'setup'", ")", "{", "delete", "values", "[", "variable", "]", ";", "}", "// Special handling for breadcrumb ", "if", "(", "variable", "==", "'breadcrumb'", ")", "{", "// Do not Add the same Last Url (in case of refresh", "if", "(", "value", "==", "'back'", ")", "{", "//\t\t\t\tconsole.log('%s values[variable].length',srcName,values[variable].length)", "if", "(", "values", "[", "variable", "]", ".", "length", "<", "2", ")", "{", "return", "values", "[", "variable", "]", "[", "0", "]", "}", "else", "{", "values", "[", "variable", "]", ".", "pop", "(", ")", ";", "return", "values", "[", "variable", "]", ".", "pop", "(", ")", ";", "}", "}", "else", "{", "if", "(", "values", "[", "variable", "]", "&&", "(", "values", "[", "variable", "]", "[", "values", "[", "variable", "]", ".", "length", "-", "1", "]", "==", "value", ")", ")", "{", "return", ";", "}", "}", "}", "// util.format is available in Node.js 0.6+", "if", "(", "arguments", ".", "length", ">", "2", "&&", "format", "&&", "parameter", "!=", "'setup'", "&&", "parameter", "!=", "'read'", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ";", "value", "=", "format", ".", "apply", "(", "undefined", ",", "args", ")", ";", "}", "else", "if", "(", "isArray", "(", "value", ")", ")", "{", "value", ".", "forEach", "(", "function", "(", "val", ")", "{", "(", "values", "[", "variable", "]", "=", "values", "[", "variable", "]", "||", "[", "]", ")", ".", "push", "(", "val", ")", ";", "}", ")", ";", "return", "values", "[", "variable", "]", ".", "length", ";", "}", "return", "(", "values", "[", "variable", "]", "=", "values", "[", "variable", "]", "||", "[", "]", ")", ".", "push", "(", "value", ")", ";", "}", "else", "if", "(", "variable", ")", "{", "var", "arr", "=", "values", "[", "variable", "]", ";", "if", "(", "(", "variable", "!=", "'breadcrumb'", ")", "&&", "(", "parameter", "!=", "'read'", ")", ")", "{", "delete", "values", "[", "variable", "]", ";", "}", "return", "arr", "||", "[", "]", ";", "}", "else", "{", "this", ".", "session", ".", "_sessionData", "=", "{", "}", ";", "return", "values", ";", "}", "}" ]
Queue sessionData `value` of the given `Variable`. Examples: Regular behavior: req.sessionData('var01', 'value01'); req.sessionData('var01', 'value02'); req.sessionData('var01', 'value03'); req.sessionData('var02', 'value20'); req.sessionData('var02', 'value21'); // req.sessionData('var01') => value01,value02,value03 // req.sessionData('var01') => [] // req.sessionData('var02') => value20,value21 // req.sessionData('var02') => [] Special behavior: config: req.sessionData('keyconf01','confvalue01', 'setup'); req.sessionData('keyconf02','confvalue01', 'setup'); req.sessionData('keyconf03','confvalue02', 'read'); // req.sessionData() => { var01 :[], var02: ['value20'], var03: ['value30','value31'] } Special behavior: breadcrumb req.sessionData('breadcrumb', 'value10'); req.sessionData('breadcrumb', 'value11'); req.sessionData('breadcrumb', 'value12'); // req.sessionData('breadcrumb') => value12 // req.sessionData('back') => value12 Formatting: sessionData notifications also support arbitrary formatting support. For example you may pass variable arguments to `req.sessionData()` and use the %s specifier to be replaced by the associated argument: req.sessionData('info', 'email has been sent to %s.', userName); Formatting uses `util.format()`, which is available on Node 0.6+. @param {String} variable (key) @param {String} value (value of the key) @param {String} parameter ( @return {Array|Object|Number} @api public
[ "Queue", "sessionData", "value", "of", "the", "given", "Variable", "." ]
3e3c645951661556354d387ebc4b8732c7c55331
https://github.com/Asw20/session-data/blob/3e3c645951661556354d387ebc4b8732c7c55331/lib/sessionData.js#L78-L130
57,354
Athaphian/grunt-websocket
tasks/websocket.js
function (server) { // Retrieve the configured handler. if (handler) { handler = require(require('path').resolve() + '/' + handler); } else { console.log('No handler defined for websocket server, not starting websocket.'); return; } // Attach websockets server to http server var WebSocketServer = require('websocket').server; var wsServer = new WebSocketServer({ httpServer: server }); // Handle requests wsServer.on('request', handler); }
javascript
function (server) { // Retrieve the configured handler. if (handler) { handler = require(require('path').resolve() + '/' + handler); } else { console.log('No handler defined for websocket server, not starting websocket.'); return; } // Attach websockets server to http server var WebSocketServer = require('websocket').server; var wsServer = new WebSocketServer({ httpServer: server }); // Handle requests wsServer.on('request', handler); }
[ "function", "(", "server", ")", "{", "// Retrieve the configured handler.", "if", "(", "handler", ")", "{", "handler", "=", "require", "(", "require", "(", "'path'", ")", ".", "resolve", "(", ")", "+", "'/'", "+", "handler", ")", ";", "}", "else", "{", "console", ".", "log", "(", "'No handler defined for websocket server, not starting websocket.'", ")", ";", "return", ";", "}", "// Attach websockets server to http server", "var", "WebSocketServer", "=", "require", "(", "'websocket'", ")", ".", "server", ";", "var", "wsServer", "=", "new", "WebSocketServer", "(", "{", "httpServer", ":", "server", "}", ")", ";", "// Handle requests", "wsServer", ".", "on", "(", "'request'", ",", "handler", ")", ";", "}" ]
Attaches a websocket server to the specified http server.
[ "Attaches", "a", "websocket", "server", "to", "the", "specified", "http", "server", "." ]
5fad7f1a568f290f9ec7ac5597b49d588de7c2ec
https://github.com/Athaphian/grunt-websocket/blob/5fad7f1a568f290f9ec7ac5597b49d588de7c2ec/tasks/websocket.js#L26-L44
57,355
nopnop/docflux
lib/transform.js
transform
function transform() { var stack = []; var inside = false; var out = false; var writable = combiner(split(), through2(function(line, encoding, done) { line = line.toString(); if(out) { // Comment with a white space below are ignored if(line.trim() != '') { readable.write(parser(stack.join('\n'), line)) } out = false; stack = []; } else if(!inside) { if(/\s*\/\*\*/.test(line)) { stack = []; inside = true; } } else if(inside) { if(/\*\/\s*$/.test(line)) { inside = false out = true } else { stack.push(line.replace(/^\s*\*{1,2}\s?/,'')); } } done(); }, function(done) { // readable.write(null) readable.emit('end') done(); })) var readable = through2.obj(); return duplexer(writable, readable) }
javascript
function transform() { var stack = []; var inside = false; var out = false; var writable = combiner(split(), through2(function(line, encoding, done) { line = line.toString(); if(out) { // Comment with a white space below are ignored if(line.trim() != '') { readable.write(parser(stack.join('\n'), line)) } out = false; stack = []; } else if(!inside) { if(/\s*\/\*\*/.test(line)) { stack = []; inside = true; } } else if(inside) { if(/\*\/\s*$/.test(line)) { inside = false out = true } else { stack.push(line.replace(/^\s*\*{1,2}\s?/,'')); } } done(); }, function(done) { // readable.write(null) readable.emit('end') done(); })) var readable = through2.obj(); return duplexer(writable, readable) }
[ "function", "transform", "(", ")", "{", "var", "stack", "=", "[", "]", ";", "var", "inside", "=", "false", ";", "var", "out", "=", "false", ";", "var", "writable", "=", "combiner", "(", "split", "(", ")", ",", "through2", "(", "function", "(", "line", ",", "encoding", ",", "done", ")", "{", "line", "=", "line", ".", "toString", "(", ")", ";", "if", "(", "out", ")", "{", "// Comment with a white space below are ignored", "if", "(", "line", ".", "trim", "(", ")", "!=", "''", ")", "{", "readable", ".", "write", "(", "parser", "(", "stack", ".", "join", "(", "'\\n'", ")", ",", "line", ")", ")", "}", "out", "=", "false", ";", "stack", "=", "[", "]", ";", "}", "else", "if", "(", "!", "inside", ")", "{", "if", "(", "/", "\\s*\\/\\*\\*", "/", ".", "test", "(", "line", ")", ")", "{", "stack", "=", "[", "]", ";", "inside", "=", "true", ";", "}", "}", "else", "if", "(", "inside", ")", "{", "if", "(", "/", "\\*\\/\\s*$", "/", ".", "test", "(", "line", ")", ")", "{", "inside", "=", "false", "out", "=", "true", "}", "else", "{", "stack", ".", "push", "(", "line", ".", "replace", "(", "/", "^\\s*\\*{1,2}\\s?", "/", ",", "''", ")", ")", ";", "}", "}", "done", "(", ")", ";", "}", ",", "function", "(", "done", ")", "{", "// readable.write(null)", "readable", ".", "emit", "(", "'end'", ")", "done", "(", ")", ";", "}", ")", ")", "var", "readable", "=", "through2", ".", "obj", "(", ")", ";", "return", "duplexer", "(", "writable", ",", "readable", ")", "}" ]
Create a doc-block extractor stream This function take a buffer stream as input and output a object stream of docflux object (objectified documentation block) Example: ```javascript var docflux = require('docflux'); process.stdin(docflux()) .on('data', function(jsdoc) { console.log(JSON.stringify(jsdoc, null, 2)) }) ``` @return {Stream}
[ "Create", "a", "doc", "-", "block", "extractor", "stream" ]
3929fdac9d1e959946fb48f3e8a269d338841902
https://github.com/nopnop/docflux/blob/3929fdac9d1e959946fb48f3e8a269d338841902/lib/transform.js#L29-L66
57,356
seanmpuckett/sai
lib/saigrammar.js
TaskClauseFormatter
function TaskClauseFormatter(o) { var params=[]; if (!o.nodefaultparam) { params.push('p'); } var expects='',locals=[];//$unused=this'; if (o.expects && o.as) fail("SAI compile: cannot have both EXPECTS and AS in a function declaration"); if (o.expects && o.expects.length) { expects=GetExpectsTester(o.expects,'in-line'); } else if (o.as) { for (var i in o.as) { if (i==0) { locals.push(o.as[i][0][1]+'='+params[0]); } else { params.push(o.as[i][0][1]); } } } if (!o.preface) o.preface=''; if (!o.postface) o.postface=''; var finallocals=[]; for (var i in locals) if (!References[locals[i]]) finallocals.push(locals[i]); locals=locals.length?('var '+finallocals.join(',')+';'):''; var code = o.kind+'('+params.join(',')+'){'+o.preface+locals+expects+'{'+o.block+'}'+o.postface+'}'; if (o.execute) code+='()'; return code; }
javascript
function TaskClauseFormatter(o) { var params=[]; if (!o.nodefaultparam) { params.push('p'); } var expects='',locals=[];//$unused=this'; if (o.expects && o.as) fail("SAI compile: cannot have both EXPECTS and AS in a function declaration"); if (o.expects && o.expects.length) { expects=GetExpectsTester(o.expects,'in-line'); } else if (o.as) { for (var i in o.as) { if (i==0) { locals.push(o.as[i][0][1]+'='+params[0]); } else { params.push(o.as[i][0][1]); } } } if (!o.preface) o.preface=''; if (!o.postface) o.postface=''; var finallocals=[]; for (var i in locals) if (!References[locals[i]]) finallocals.push(locals[i]); locals=locals.length?('var '+finallocals.join(',')+';'):''; var code = o.kind+'('+params.join(',')+'){'+o.preface+locals+expects+'{'+o.block+'}'+o.postface+'}'; if (o.execute) code+='()'; return code; }
[ "function", "TaskClauseFormatter", "(", "o", ")", "{", "var", "params", "=", "[", "]", ";", "if", "(", "!", "o", ".", "nodefaultparam", ")", "{", "params", ".", "push", "(", "'p'", ")", ";", "}", "var", "expects", "=", "''", ",", "locals", "=", "[", "]", ";", "//$unused=this';", "if", "(", "o", ".", "expects", "&&", "o", ".", "as", ")", "fail", "(", "\"SAI compile: cannot have both EXPECTS and AS in a function declaration\"", ")", ";", "if", "(", "o", ".", "expects", "&&", "o", ".", "expects", ".", "length", ")", "{", "expects", "=", "GetExpectsTester", "(", "o", ".", "expects", ",", "'in-line'", ")", ";", "}", "else", "if", "(", "o", ".", "as", ")", "{", "for", "(", "var", "i", "in", "o", ".", "as", ")", "{", "if", "(", "i", "==", "0", ")", "{", "locals", ".", "push", "(", "o", ".", "as", "[", "i", "]", "[", "0", "]", "[", "1", "]", "+", "'='", "+", "params", "[", "0", "]", ")", ";", "}", "else", "{", "params", ".", "push", "(", "o", ".", "as", "[", "i", "]", "[", "0", "]", "[", "1", "]", ")", ";", "}", "}", "}", "if", "(", "!", "o", ".", "preface", ")", "o", ".", "preface", "=", "''", ";", "if", "(", "!", "o", ".", "postface", ")", "o", ".", "postface", "=", "''", ";", "var", "finallocals", "=", "[", "]", ";", "for", "(", "var", "i", "in", "locals", ")", "if", "(", "!", "References", "[", "locals", "[", "i", "]", "]", ")", "finallocals", ".", "push", "(", "locals", "[", "i", "]", ")", ";", "locals", "=", "locals", ".", "length", "?", "(", "'var '", "+", "finallocals", ".", "join", "(", "','", ")", "+", "';'", ")", ":", "''", ";", "var", "code", "=", "o", ".", "kind", "+", "'('", "+", "params", ".", "join", "(", "','", ")", "+", "'){'", "+", "o", ".", "preface", "+", "locals", "+", "expects", "+", "'{'", "+", "o", ".", "block", "+", "'}'", "+", "o", ".", "postface", "+", "'}'", ";", "if", "(", "o", ".", "execute", ")", "code", "+=", "'()'", ";", "return", "code", ";", "}" ]
expects as kind body preface appendix
[ "expects", "as", "kind", "body", "preface", "appendix" ]
759274a3078bef6939e634f2761656dc8db547d2
https://github.com/seanmpuckett/sai/blob/759274a3078bef6939e634f2761656dc8db547d2/lib/saigrammar.js#L2352-L2378
57,357
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
handleFieldValidated
function handleFieldValidated( isValid, msg ) { var input = this.getInputElement(); if ( input ) isValid ? input.removeAttribute( 'aria-invalid' ) : input.setAttribute( 'aria-invalid', true ); if ( !isValid ) { if ( this.select ) this.select(); else this.focus(); } msg && alert( msg ); this.fire( 'validated', { valid: isValid, msg: msg } ); }
javascript
function handleFieldValidated( isValid, msg ) { var input = this.getInputElement(); if ( input ) isValid ? input.removeAttribute( 'aria-invalid' ) : input.setAttribute( 'aria-invalid', true ); if ( !isValid ) { if ( this.select ) this.select(); else this.focus(); } msg && alert( msg ); this.fire( 'validated', { valid: isValid, msg: msg } ); }
[ "function", "handleFieldValidated", "(", "isValid", ",", "msg", ")", "{", "var", "input", "=", "this", ".", "getInputElement", "(", ")", ";", "if", "(", "input", ")", "isValid", "?", "input", ".", "removeAttribute", "(", "'aria-invalid'", ")", ":", "input", ".", "setAttribute", "(", "'aria-invalid'", ",", "true", ")", ";", "if", "(", "!", "isValid", ")", "{", "if", "(", "this", ".", "select", ")", "this", ".", "select", "(", ")", ";", "else", "this", ".", "focus", "(", ")", ";", "}", "msg", "&&", "alert", "(", "msg", ")", ";", "this", ".", "fire", "(", "'validated'", ",", "{", "valid", ":", "isValid", ",", "msg", ":", "msg", "}", ")", ";", "}" ]
Handle dialog element validation state UI changes.
[ "Handle", "dialog", "element", "validation", "state", "UI", "changes", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L98-L113
57,358
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( func ) { var contents = me._.contents, stop = false; for ( var i in contents ) { for ( var j in contents[ i ] ) { stop = func.call( this, contents[ i ][ j ] ); if ( stop ) return; } } }
javascript
function( func ) { var contents = me._.contents, stop = false; for ( var i in contents ) { for ( var j in contents[ i ] ) { stop = func.call( this, contents[ i ][ j ] ); if ( stop ) return; } } }
[ "function", "(", "func", ")", "{", "var", "contents", "=", "me", ".", "_", ".", "contents", ",", "stop", "=", "false", ";", "for", "(", "var", "i", "in", "contents", ")", "{", "for", "(", "var", "j", "in", "contents", "[", "i", "]", ")", "{", "stop", "=", "func", ".", "call", "(", "this", ",", "contents", "[", "i", "]", "[", "j", "]", ")", ";", "if", "(", "stop", ")", "return", ";", "}", "}", "}" ]
Iterates over all items inside all content in the dialog, calling a function for each of them.
[ "Iterates", "over", "all", "items", "inside", "all", "content", "in", "the", "dialog", "calling", "a", "function", "for", "each", "of", "them", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L339-L350
57,359
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
setupFocus
function setupFocus() { var focusList = me._.focusList; focusList.sort( function( a, b ) { // Mimics browser tab order logics; if ( a.tabIndex != b.tabIndex ) return b.tabIndex - a.tabIndex; // Sort is not stable in some browsers, // fall-back the comparator to 'focusIndex'; else return a.focusIndex - b.focusIndex; } ); var size = focusList.length; for ( var i = 0; i < size; i++ ) focusList[ i ].focusIndex = i; }
javascript
function setupFocus() { var focusList = me._.focusList; focusList.sort( function( a, b ) { // Mimics browser tab order logics; if ( a.tabIndex != b.tabIndex ) return b.tabIndex - a.tabIndex; // Sort is not stable in some browsers, // fall-back the comparator to 'focusIndex'; else return a.focusIndex - b.focusIndex; } ); var size = focusList.length; for ( var i = 0; i < size; i++ ) focusList[ i ].focusIndex = i; }
[ "function", "setupFocus", "(", ")", "{", "var", "focusList", "=", "me", ".", "_", ".", "focusList", ";", "focusList", ".", "sort", "(", "function", "(", "a", ",", "b", ")", "{", "// Mimics browser tab order logics;\r", "if", "(", "a", ".", "tabIndex", "!=", "b", ".", "tabIndex", ")", "return", "b", ".", "tabIndex", "-", "a", ".", "tabIndex", ";", "// Sort is not stable in some browsers,\r", "// fall-back the comparator to 'focusIndex';\r", "else", "return", "a", ".", "focusIndex", "-", "b", ".", "focusIndex", ";", "}", ")", ";", "var", "size", "=", "focusList", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "size", ";", "i", "++", ")", "focusList", "[", "i", "]", ".", "focusIndex", "=", "i", ";", "}" ]
Sort focus list according to tab order definitions.
[ "Sort", "focus", "list", "according", "to", "tab", "order", "definitions", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L386-L401
57,360
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
Focusable
function Focusable( dialog, element, index ) { this.element = element; this.focusIndex = index; // TODO: support tabIndex for focusables. this.tabIndex = 0; this.isFocusable = function() { return !element.getAttribute( 'disabled' ) && element.isVisible(); }; this.focus = function() { dialog._.currentFocusIndex = this.focusIndex; this.element.focus(); }; // Bind events element.on( 'keydown', function( e ) { if ( e.data.getKeystroke() in { 32: 1, 13: 1 } ) this.fire( 'click' ); } ); element.on( 'focus', function() { this.fire( 'mouseover' ); } ); element.on( 'blur', function() { this.fire( 'mouseout' ); } ); }
javascript
function Focusable( dialog, element, index ) { this.element = element; this.focusIndex = index; // TODO: support tabIndex for focusables. this.tabIndex = 0; this.isFocusable = function() { return !element.getAttribute( 'disabled' ) && element.isVisible(); }; this.focus = function() { dialog._.currentFocusIndex = this.focusIndex; this.element.focus(); }; // Bind events element.on( 'keydown', function( e ) { if ( e.data.getKeystroke() in { 32: 1, 13: 1 } ) this.fire( 'click' ); } ); element.on( 'focus', function() { this.fire( 'mouseover' ); } ); element.on( 'blur', function() { this.fire( 'mouseout' ); } ); }
[ "function", "Focusable", "(", "dialog", ",", "element", ",", "index", ")", "{", "this", ".", "element", "=", "element", ";", "this", ".", "focusIndex", "=", "index", ";", "// TODO: support tabIndex for focusables.\r", "this", ".", "tabIndex", "=", "0", ";", "this", ".", "isFocusable", "=", "function", "(", ")", "{", "return", "!", "element", ".", "getAttribute", "(", "'disabled'", ")", "&&", "element", ".", "isVisible", "(", ")", ";", "}", ";", "this", ".", "focus", "=", "function", "(", ")", "{", "dialog", ".", "_", ".", "currentFocusIndex", "=", "this", ".", "focusIndex", ";", "this", ".", "element", ".", "focus", "(", ")", ";", "}", ";", "// Bind events\r", "element", ".", "on", "(", "'keydown'", ",", "function", "(", "e", ")", "{", "if", "(", "e", ".", "data", ".", "getKeystroke", "(", ")", "in", "{", "32", ":", "1", ",", "13", ":", "1", "}", ")", "this", ".", "fire", "(", "'click'", ")", ";", "}", ")", ";", "element", ".", "on", "(", "'focus'", ",", "function", "(", ")", "{", "this", ".", "fire", "(", "'mouseover'", ")", ";", "}", ")", ";", "element", ".", "on", "(", "'blur'", ",", "function", "(", ")", "{", "this", ".", "fire", "(", "'mouseout'", ")", ";", "}", ")", ";", "}" ]
Focusable interface. Use it via dialog.addFocusable.
[ "Focusable", "interface", ".", "Use", "it", "via", "dialog", ".", "addFocusable", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L622-L645
57,361
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
resizeWithWindow
function resizeWithWindow( dialog ) { var win = CKEDITOR.document.getWindow(); function resizeHandler() { dialog.layout(); } win.on( 'resize', resizeHandler ); dialog.on( 'hide', function() { win.removeListener( 'resize', resizeHandler ); } ); }
javascript
function resizeWithWindow( dialog ) { var win = CKEDITOR.document.getWindow(); function resizeHandler() { dialog.layout(); } win.on( 'resize', resizeHandler ); dialog.on( 'hide', function() { win.removeListener( 'resize', resizeHandler ); } ); }
[ "function", "resizeWithWindow", "(", "dialog", ")", "{", "var", "win", "=", "CKEDITOR", ".", "document", ".", "getWindow", "(", ")", ";", "function", "resizeHandler", "(", ")", "{", "dialog", ".", "layout", "(", ")", ";", "}", "win", ".", "on", "(", "'resize'", ",", "resizeHandler", ")", ";", "dialog", ".", "on", "(", "'hide'", ",", "function", "(", ")", "{", "win", ".", "removeListener", "(", "'resize'", ",", "resizeHandler", ")", ";", "}", ")", ";", "}" ]
Re-layout the dialog on window resize.
[ "Re", "-", "layout", "the", "dialog", "on", "window", "resize", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L648-L653
57,362
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function() { var element = this._.element.getFirst(); return { width: element.$.offsetWidth || 0, height: element.$.offsetHeight || 0 }; }
javascript
function() { var element = this._.element.getFirst(); return { width: element.$.offsetWidth || 0, height: element.$.offsetHeight || 0 }; }
[ "function", "(", ")", "{", "var", "element", "=", "this", ".", "_", ".", "element", ".", "getFirst", "(", ")", ";", "return", "{", "width", ":", "element", ".", "$", ".", "offsetWidth", "||", "0", ",", "height", ":", "element", ".", "$", ".", "offsetHeight", "||", "0", "}", ";", "}" ]
Gets the current size of the dialog in pixels. var width = dialogObj.getSize().width; @returns {Object} @returns {Number} return.width @returns {Number} return.height
[ "Gets", "the", "current", "size", "of", "the", "dialog", "in", "pixels", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L709-L712
57,363
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function() { var el = this.parts.dialog; var dialogSize = this.getSize(); var win = CKEDITOR.document.getWindow(), viewSize = win.getViewPaneSize(); var posX = ( viewSize.width - dialogSize.width ) / 2, posY = ( viewSize.height - dialogSize.height ) / 2; // Switch to absolute position when viewport is smaller than dialog size. if ( !CKEDITOR.env.ie6Compat ) { if ( dialogSize.height + ( posY > 0 ? posY : 0 ) > viewSize.height || dialogSize.width + ( posX > 0 ? posX : 0 ) > viewSize.width ) el.setStyle( 'position', 'absolute' ); else el.setStyle( 'position', 'fixed' ); } this.move( this._.moved ? this._.position.x : posX, this._.moved ? this._.position.y : posY ); }
javascript
function() { var el = this.parts.dialog; var dialogSize = this.getSize(); var win = CKEDITOR.document.getWindow(), viewSize = win.getViewPaneSize(); var posX = ( viewSize.width - dialogSize.width ) / 2, posY = ( viewSize.height - dialogSize.height ) / 2; // Switch to absolute position when viewport is smaller than dialog size. if ( !CKEDITOR.env.ie6Compat ) { if ( dialogSize.height + ( posY > 0 ? posY : 0 ) > viewSize.height || dialogSize.width + ( posX > 0 ? posX : 0 ) > viewSize.width ) el.setStyle( 'position', 'absolute' ); else el.setStyle( 'position', 'fixed' ); } this.move( this._.moved ? this._.position.x : posX, this._.moved ? this._.position.y : posY ); }
[ "function", "(", ")", "{", "var", "el", "=", "this", ".", "parts", ".", "dialog", ";", "var", "dialogSize", "=", "this", ".", "getSize", "(", ")", ";", "var", "win", "=", "CKEDITOR", ".", "document", ".", "getWindow", "(", ")", ",", "viewSize", "=", "win", ".", "getViewPaneSize", "(", ")", ";", "var", "posX", "=", "(", "viewSize", ".", "width", "-", "dialogSize", ".", "width", ")", "/", "2", ",", "posY", "=", "(", "viewSize", ".", "height", "-", "dialogSize", ".", "height", ")", "/", "2", ";", "// Switch to absolute position when viewport is smaller than dialog size.\r", "if", "(", "!", "CKEDITOR", ".", "env", ".", "ie6Compat", ")", "{", "if", "(", "dialogSize", ".", "height", "+", "(", "posY", ">", "0", "?", "posY", ":", "0", ")", ">", "viewSize", ".", "height", "||", "dialogSize", ".", "width", "+", "(", "posX", ">", "0", "?", "posX", ":", "0", ")", ">", "viewSize", ".", "width", ")", "el", ".", "setStyle", "(", "'position'", ",", "'absolute'", ")", ";", "else", "el", ".", "setStyle", "(", "'position'", ",", "'fixed'", ")", ";", "}", "this", ".", "move", "(", "this", ".", "_", ".", "moved", "?", "this", ".", "_", ".", "position", ".", "x", ":", "posX", ",", "this", ".", "_", ".", "moved", "?", "this", ".", "_", ".", "position", ".", "y", ":", "posY", ")", ";", "}" ]
Rearrange the dialog to its previous position or the middle of the window. @since 3.5
[ "Rearrange", "the", "dialog", "to", "its", "previous", "position", "or", "the", "middle", "of", "the", "window", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L890-L910
57,364
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( fn ) { for ( var i in this._.contents ) { for ( var j in this._.contents[ i ] ) fn.call( this, this._.contents[ i ][ j ] ); } return this; }
javascript
function( fn ) { for ( var i in this._.contents ) { for ( var j in this._.contents[ i ] ) fn.call( this, this._.contents[ i ][ j ] ); } return this; }
[ "function", "(", "fn", ")", "{", "for", "(", "var", "i", "in", "this", ".", "_", ".", "contents", ")", "{", "for", "(", "var", "j", "in", "this", ".", "_", ".", "contents", "[", "i", "]", ")", "fn", ".", "call", "(", "this", ",", "this", ".", "_", ".", "contents", "[", "i", "]", "[", "j", "]", ")", ";", "}", "return", "this", ";", "}" ]
Executes a function for each UI element. @param {Function} fn Function to execute for each UI element. @returns {CKEDITOR.dialog} The current dialog object.
[ "Executes", "a", "function", "for", "each", "UI", "element", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L918-L924
57,365
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function() { if ( !this.parts.dialog.isVisible() ) return; this.fire( 'hide', {} ); this._.editor.fire( 'dialogHide', this ); // Reset the tab page. this.selectPage( this._.tabIdList[ 0 ] ); var element = this._.element; element.setStyle( 'display', 'none' ); this.parts.dialog.setStyle( 'visibility', 'hidden' ); // Unregister all access keys associated with this dialog. unregisterAccessKey( this ); // Close any child(top) dialogs first. while ( CKEDITOR.dialog._.currentTop != this ) CKEDITOR.dialog._.currentTop.hide(); // Maintain dialog ordering and remove cover if needed. if ( !this._.parentDialog ) hideCover( this._.editor ); else { var parentElement = this._.parentDialog.getElement().getFirst(); parentElement.setStyle( 'z-index', parseInt( parentElement.$.style.zIndex, 10 ) + Math.floor( this._.editor.config.baseFloatZIndex / 2 ) ); } CKEDITOR.dialog._.currentTop = this._.parentDialog; // Deduct or clear the z-index. if ( !this._.parentDialog ) { CKEDITOR.dialog._.currentZIndex = null; // Remove access key handlers. element.removeListener( 'keydown', accessKeyDownHandler ); element.removeListener( 'keyup', accessKeyUpHandler ); var editor = this._.editor; editor.focus(); // Give a while before unlock, waiting for focus to return to the editable. (#172) setTimeout( function() { editor.focusManager.unlock(); // Fixed iOS focus issue (#12381). // Keep in mind that editor.focus() does not work in this case. if ( CKEDITOR.env.iOS ) { editor.window.focus(); } }, 0 ); } else CKEDITOR.dialog._.currentZIndex -= 10; delete this._.parentDialog; // Reset the initial values of the dialog. this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } ); }
javascript
function() { if ( !this.parts.dialog.isVisible() ) return; this.fire( 'hide', {} ); this._.editor.fire( 'dialogHide', this ); // Reset the tab page. this.selectPage( this._.tabIdList[ 0 ] ); var element = this._.element; element.setStyle( 'display', 'none' ); this.parts.dialog.setStyle( 'visibility', 'hidden' ); // Unregister all access keys associated with this dialog. unregisterAccessKey( this ); // Close any child(top) dialogs first. while ( CKEDITOR.dialog._.currentTop != this ) CKEDITOR.dialog._.currentTop.hide(); // Maintain dialog ordering and remove cover if needed. if ( !this._.parentDialog ) hideCover( this._.editor ); else { var parentElement = this._.parentDialog.getElement().getFirst(); parentElement.setStyle( 'z-index', parseInt( parentElement.$.style.zIndex, 10 ) + Math.floor( this._.editor.config.baseFloatZIndex / 2 ) ); } CKEDITOR.dialog._.currentTop = this._.parentDialog; // Deduct or clear the z-index. if ( !this._.parentDialog ) { CKEDITOR.dialog._.currentZIndex = null; // Remove access key handlers. element.removeListener( 'keydown', accessKeyDownHandler ); element.removeListener( 'keyup', accessKeyUpHandler ); var editor = this._.editor; editor.focus(); // Give a while before unlock, waiting for focus to return to the editable. (#172) setTimeout( function() { editor.focusManager.unlock(); // Fixed iOS focus issue (#12381). // Keep in mind that editor.focus() does not work in this case. if ( CKEDITOR.env.iOS ) { editor.window.focus(); } }, 0 ); } else CKEDITOR.dialog._.currentZIndex -= 10; delete this._.parentDialog; // Reset the initial values of the dialog. this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } ); }
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "parts", ".", "dialog", ".", "isVisible", "(", ")", ")", "return", ";", "this", ".", "fire", "(", "'hide'", ",", "{", "}", ")", ";", "this", ".", "_", ".", "editor", ".", "fire", "(", "'dialogHide'", ",", "this", ")", ";", "// Reset the tab page.\r", "this", ".", "selectPage", "(", "this", ".", "_", ".", "tabIdList", "[", "0", "]", ")", ";", "var", "element", "=", "this", ".", "_", ".", "element", ";", "element", ".", "setStyle", "(", "'display'", ",", "'none'", ")", ";", "this", ".", "parts", ".", "dialog", ".", "setStyle", "(", "'visibility'", ",", "'hidden'", ")", ";", "// Unregister all access keys associated with this dialog.\r", "unregisterAccessKey", "(", "this", ")", ";", "// Close any child(top) dialogs first.\r", "while", "(", "CKEDITOR", ".", "dialog", ".", "_", ".", "currentTop", "!=", "this", ")", "CKEDITOR", ".", "dialog", ".", "_", ".", "currentTop", ".", "hide", "(", ")", ";", "// Maintain dialog ordering and remove cover if needed.\r", "if", "(", "!", "this", ".", "_", ".", "parentDialog", ")", "hideCover", "(", "this", ".", "_", ".", "editor", ")", ";", "else", "{", "var", "parentElement", "=", "this", ".", "_", ".", "parentDialog", ".", "getElement", "(", ")", ".", "getFirst", "(", ")", ";", "parentElement", ".", "setStyle", "(", "'z-index'", ",", "parseInt", "(", "parentElement", ".", "$", ".", "style", ".", "zIndex", ",", "10", ")", "+", "Math", ".", "floor", "(", "this", ".", "_", ".", "editor", ".", "config", ".", "baseFloatZIndex", "/", "2", ")", ")", ";", "}", "CKEDITOR", ".", "dialog", ".", "_", ".", "currentTop", "=", "this", ".", "_", ".", "parentDialog", ";", "// Deduct or clear the z-index.\r", "if", "(", "!", "this", ".", "_", ".", "parentDialog", ")", "{", "CKEDITOR", ".", "dialog", ".", "_", ".", "currentZIndex", "=", "null", ";", "// Remove access key handlers.\r", "element", ".", "removeListener", "(", "'keydown'", ",", "accessKeyDownHandler", ")", ";", "element", ".", "removeListener", "(", "'keyup'", ",", "accessKeyUpHandler", ")", ";", "var", "editor", "=", "this", ".", "_", ".", "editor", ";", "editor", ".", "focus", "(", ")", ";", "// Give a while before unlock, waiting for focus to return to the editable. (#172)\r", "setTimeout", "(", "function", "(", ")", "{", "editor", ".", "focusManager", ".", "unlock", "(", ")", ";", "// Fixed iOS focus issue (#12381).\r", "// Keep in mind that editor.focus() does not work in this case.\r", "if", "(", "CKEDITOR", ".", "env", ".", "iOS", ")", "{", "editor", ".", "window", ".", "focus", "(", ")", ";", "}", "}", ",", "0", ")", ";", "}", "else", "CKEDITOR", ".", "dialog", ".", "_", ".", "currentZIndex", "-=", "10", ";", "delete", "this", ".", "_", ".", "parentDialog", ";", "// Reset the initial values of the dialog.\r", "this", ".", "foreach", "(", "function", "(", "contentObj", ")", "{", "contentObj", ".", "resetInitValue", "&&", "contentObj", ".", "resetInitValue", "(", ")", ";", "}", ")", ";", "}" ]
Hides the dialog box. dialogObj.hide();
[ "Hides", "the", "dialog", "box", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L991-L1048
57,366
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( id ) { if ( this._.currentTabId == id ) return; if ( this._.tabs[ id ][ 0 ].hasClass( 'cke_dialog_tab_disabled' ) ) return; // If event was canceled - do nothing. if ( this.fire( 'selectPage', { page: id, currentPage: this._.currentTabId } ) === false ) return; // Hide the non-selected tabs and pages. for ( var i in this._.tabs ) { var tab = this._.tabs[ i ][ 0 ], page = this._.tabs[ i ][ 1 ]; if ( i != id ) { tab.removeClass( 'cke_dialog_tab_selected' ); page.hide(); } page.setAttribute( 'aria-hidden', i != id ); } var selected = this._.tabs[ id ]; selected[ 0 ].addClass( 'cke_dialog_tab_selected' ); // [IE] an invisible input[type='text'] will enlarge it's width // if it's value is long when it shows, so we clear it's value // before it shows and then recover it (#5649) if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat ) { clearOrRecoverTextInputValue( selected[ 1 ] ); selected[ 1 ].show(); setTimeout( function() { clearOrRecoverTextInputValue( selected[ 1 ], 1 ); }, 0 ); } else selected[ 1 ].show(); this._.currentTabId = id; this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id ); }
javascript
function( id ) { if ( this._.currentTabId == id ) return; if ( this._.tabs[ id ][ 0 ].hasClass( 'cke_dialog_tab_disabled' ) ) return; // If event was canceled - do nothing. if ( this.fire( 'selectPage', { page: id, currentPage: this._.currentTabId } ) === false ) return; // Hide the non-selected tabs and pages. for ( var i in this._.tabs ) { var tab = this._.tabs[ i ][ 0 ], page = this._.tabs[ i ][ 1 ]; if ( i != id ) { tab.removeClass( 'cke_dialog_tab_selected' ); page.hide(); } page.setAttribute( 'aria-hidden', i != id ); } var selected = this._.tabs[ id ]; selected[ 0 ].addClass( 'cke_dialog_tab_selected' ); // [IE] an invisible input[type='text'] will enlarge it's width // if it's value is long when it shows, so we clear it's value // before it shows and then recover it (#5649) if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat ) { clearOrRecoverTextInputValue( selected[ 1 ] ); selected[ 1 ].show(); setTimeout( function() { clearOrRecoverTextInputValue( selected[ 1 ], 1 ); }, 0 ); } else selected[ 1 ].show(); this._.currentTabId = id; this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id ); }
[ "function", "(", "id", ")", "{", "if", "(", "this", ".", "_", ".", "currentTabId", "==", "id", ")", "return", ";", "if", "(", "this", ".", "_", ".", "tabs", "[", "id", "]", "[", "0", "]", ".", "hasClass", "(", "'cke_dialog_tab_disabled'", ")", ")", "return", ";", "// If event was canceled - do nothing.\r", "if", "(", "this", ".", "fire", "(", "'selectPage'", ",", "{", "page", ":", "id", ",", "currentPage", ":", "this", ".", "_", ".", "currentTabId", "}", ")", "===", "false", ")", "return", ";", "// Hide the non-selected tabs and pages.\r", "for", "(", "var", "i", "in", "this", ".", "_", ".", "tabs", ")", "{", "var", "tab", "=", "this", ".", "_", ".", "tabs", "[", "i", "]", "[", "0", "]", ",", "page", "=", "this", ".", "_", ".", "tabs", "[", "i", "]", "[", "1", "]", ";", "if", "(", "i", "!=", "id", ")", "{", "tab", ".", "removeClass", "(", "'cke_dialog_tab_selected'", ")", ";", "page", ".", "hide", "(", ")", ";", "}", "page", ".", "setAttribute", "(", "'aria-hidden'", ",", "i", "!=", "id", ")", ";", "}", "var", "selected", "=", "this", ".", "_", ".", "tabs", "[", "id", "]", ";", "selected", "[", "0", "]", ".", "addClass", "(", "'cke_dialog_tab_selected'", ")", ";", "// [IE] an invisible input[type='text'] will enlarge it's width\r", "// if it's value is long when it shows, so we clear it's value\r", "// before it shows and then recover it (#5649)\r", "if", "(", "CKEDITOR", ".", "env", ".", "ie6Compat", "||", "CKEDITOR", ".", "env", ".", "ie7Compat", ")", "{", "clearOrRecoverTextInputValue", "(", "selected", "[", "1", "]", ")", ";", "selected", "[", "1", "]", ".", "show", "(", ")", ";", "setTimeout", "(", "function", "(", ")", "{", "clearOrRecoverTextInputValue", "(", "selected", "[", "1", "]", ",", "1", ")", ";", "}", ",", "0", ")", ";", "}", "else", "selected", "[", "1", "]", ".", "show", "(", ")", ";", "this", ".", "_", ".", "currentTabId", "=", "id", ";", "this", ".", "_", ".", "currentTabIndex", "=", "CKEDITOR", ".", "tools", ".", "indexOf", "(", "this", ".", "_", ".", "tabIdList", ",", "id", ")", ";", "}" ]
Activates a tab page in the dialog by its id. dialogObj.selectPage( 'tab_1' ); @param {String} id The id of the dialog tab to be activated.
[ "Activates", "a", "tab", "page", "in", "the", "dialog", "by", "its", "id", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1141-L1180
57,367
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( id ) { var tab = this._.tabs[ id ] && this._.tabs[ id ][ 0 ]; if ( !tab || this._.pageCount == 1 || !tab.isVisible() ) return; // Switch to other tab first when we're hiding the active tab. else if ( id == this._.currentTabId ) this.selectPage( getPreviousVisibleTab.call( this ) ); tab.hide(); this._.pageCount--; this.updateStyle(); }
javascript
function( id ) { var tab = this._.tabs[ id ] && this._.tabs[ id ][ 0 ]; if ( !tab || this._.pageCount == 1 || !tab.isVisible() ) return; // Switch to other tab first when we're hiding the active tab. else if ( id == this._.currentTabId ) this.selectPage( getPreviousVisibleTab.call( this ) ); tab.hide(); this._.pageCount--; this.updateStyle(); }
[ "function", "(", "id", ")", "{", "var", "tab", "=", "this", ".", "_", ".", "tabs", "[", "id", "]", "&&", "this", ".", "_", ".", "tabs", "[", "id", "]", "[", "0", "]", ";", "if", "(", "!", "tab", "||", "this", ".", "_", ".", "pageCount", "==", "1", "||", "!", "tab", ".", "isVisible", "(", ")", ")", "return", ";", "// Switch to other tab first when we're hiding the active tab.\r", "else", "if", "(", "id", "==", "this", ".", "_", ".", "currentTabId", ")", "this", ".", "selectPage", "(", "getPreviousVisibleTab", ".", "call", "(", "this", ")", ")", ";", "tab", ".", "hide", "(", ")", ";", "this", ".", "_", ".", "pageCount", "--", ";", "this", ".", "updateStyle", "(", ")", ";", "}" ]
Hides a page's tab away from the dialog. dialog.hidePage( 'tab_3' ); @param {String} id The page's Id.
[ "Hides", "a", "page", "s", "tab", "away", "from", "the", "dialog", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1197-L1208
57,368
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( id ) { var tab = this._.tabs[ id ] && this._.tabs[ id ][ 0 ]; if ( !tab ) return; tab.show(); this._.pageCount++; this.updateStyle(); }
javascript
function( id ) { var tab = this._.tabs[ id ] && this._.tabs[ id ][ 0 ]; if ( !tab ) return; tab.show(); this._.pageCount++; this.updateStyle(); }
[ "function", "(", "id", ")", "{", "var", "tab", "=", "this", ".", "_", ".", "tabs", "[", "id", "]", "&&", "this", ".", "_", ".", "tabs", "[", "id", "]", "[", "0", "]", ";", "if", "(", "!", "tab", ")", "return", ";", "tab", ".", "show", "(", ")", ";", "this", ".", "_", ".", "pageCount", "++", ";", "this", ".", "updateStyle", "(", ")", ";", "}" ]
Unhides a page's tab. dialog.showPage( 'tab_2' ); @param {String} id The page's Id.
[ "Unhides", "a", "page", "s", "tab", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1217-L1224
57,369
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( element, index ) { if ( typeof index == 'undefined' ) { index = this._.focusList.length; this._.focusList.push( new Focusable( this, element, index ) ); } else { this._.focusList.splice( index, 0, new Focusable( this, element, index ) ); for ( var i = index + 1; i < this._.focusList.length; i++ ) this._.focusList[ i ].focusIndex++; } }
javascript
function( element, index ) { if ( typeof index == 'undefined' ) { index = this._.focusList.length; this._.focusList.push( new Focusable( this, element, index ) ); } else { this._.focusList.splice( index, 0, new Focusable( this, element, index ) ); for ( var i = index + 1; i < this._.focusList.length; i++ ) this._.focusList[ i ].focusIndex++; } }
[ "function", "(", "element", ",", "index", ")", "{", "if", "(", "typeof", "index", "==", "'undefined'", ")", "{", "index", "=", "this", ".", "_", ".", "focusList", ".", "length", ";", "this", ".", "_", ".", "focusList", ".", "push", "(", "new", "Focusable", "(", "this", ",", "element", ",", "index", ")", ")", ";", "}", "else", "{", "this", ".", "_", ".", "focusList", ".", "splice", "(", "index", ",", "0", ",", "new", "Focusable", "(", "this", ",", "element", ",", "index", ")", ")", ";", "for", "(", "var", "i", "=", "index", "+", "1", ";", "i", "<", "this", ".", "_", ".", "focusList", ".", "length", ";", "i", "++", ")", "this", ".", "_", ".", "focusList", "[", "i", "]", ".", "focusIndex", "++", ";", "}", "}" ]
Adds element to dialog's focusable list. @param {CKEDITOR.dom.element} element @param {Number} [index]
[ "Adds", "element", "to", "dialog", "s", "focusable", "list", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1362-L1371
57,370
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( name, dialogDefinition ) { // Avoid path registration from multiple instances override definition. if ( !this._.dialogDefinitions[ name ] || typeof dialogDefinition == 'function' ) this._.dialogDefinitions[ name ] = dialogDefinition; }
javascript
function( name, dialogDefinition ) { // Avoid path registration from multiple instances override definition. if ( !this._.dialogDefinitions[ name ] || typeof dialogDefinition == 'function' ) this._.dialogDefinitions[ name ] = dialogDefinition; }
[ "function", "(", "name", ",", "dialogDefinition", ")", "{", "// Avoid path registration from multiple instances override definition.\r", "if", "(", "!", "this", ".", "_", ".", "dialogDefinitions", "[", "name", "]", "||", "typeof", "dialogDefinition", "==", "'function'", ")", "this", ".", "_", ".", "dialogDefinitions", "[", "name", "]", "=", "dialogDefinition", ";", "}" ]
Registers a dialog. // Full sample plugin, which does not only register a dialog window but also adds an item to the context menu. // To open the dialog window, choose "Open dialog" in the context menu. CKEDITOR.plugins.add( 'myplugin', { init: function( editor ) { editor.addCommand( 'mydialog',new CKEDITOR.dialogCommand( 'mydialog' ) ); if ( editor.contextMenu ) { editor.addMenuGroup( 'mygroup', 10 ); editor.addMenuItem( 'My Dialog', { label: 'Open dialog', command: 'mydialog', group: 'mygroup' } ); editor.contextMenu.addListener( function( element ) { return { 'My Dialog': CKEDITOR.TRISTATE_OFF }; } ); } CKEDITOR.dialog.add( 'mydialog', function( api ) { // CKEDITOR.dialog.definition var dialogDefinition = { title: 'Sample dialog', minWidth: 390, minHeight: 130, contents: [ { id: 'tab1', label: 'Label', title: 'Title', expand: true, padding: 0, elements: [ { type: 'html', html: '<p>This is some sample HTML content.</p>' }, { type: 'textarea', id: 'textareaId', rows: 4, cols: 40 } ] } ], buttons: [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ], onOk: function() { // "this" is now a CKEDITOR.dialog object. // Accessing dialog elements: var textareaObj = this.getContentElement( 'tab1', 'textareaId' ); alert( "You have entered: " + textareaObj.getValue() ); } }; return dialogDefinition; } ); } } ); CKEDITOR.replace( 'editor1', { extraPlugins: 'myplugin' } ); @static @param {String} name The dialog's name. @param {Function/String} dialogDefinition A function returning the dialog's definition, or the URL to the `.js` file holding the function. The function should accept an argument `editor` which is the current editor instance, and return an object conforming to {@link CKEDITOR.dialog.definition}. @see CKEDITOR.dialog.definition
[ "Registers", "a", "dialog", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1447-L1451
57,371
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( array, id, recurse ) { for ( var i = 0, item; ( item = array[ i ] ); i++ ) { if ( item.id == id ) return item; if ( recurse && item[ recurse ] ) { var retval = getById( item[ recurse ], id, recurse ); if ( retval ) return retval; } } return null; }
javascript
function( array, id, recurse ) { for ( var i = 0, item; ( item = array[ i ] ); i++ ) { if ( item.id == id ) return item; if ( recurse && item[ recurse ] ) { var retval = getById( item[ recurse ], id, recurse ); if ( retval ) return retval; } } return null; }
[ "function", "(", "array", ",", "id", ",", "recurse", ")", "{", "for", "(", "var", "i", "=", "0", ",", "item", ";", "(", "item", "=", "array", "[", "i", "]", ")", ";", "i", "++", ")", "{", "if", "(", "item", ".", "id", "==", "id", ")", "return", "item", ";", "if", "(", "recurse", "&&", "item", "[", "recurse", "]", ")", "{", "var", "retval", "=", "getById", "(", "item", "[", "recurse", "]", ",", "id", ",", "recurse", ")", ";", "if", "(", "retval", ")", "return", "retval", ";", "}", "}", "return", "null", ";", "}" ]
Tool function used to return an item from an array based on its id property.
[ "Tool", "function", "used", "to", "return", "an", "item", "from", "an", "array", "based", "on", "its", "id", "property", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1581-L1593
57,372
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( array, newItem, nextSiblingId, recurse, nullIfNotFound ) { if ( nextSiblingId ) { for ( var i = 0, item; ( item = array[ i ] ); i++ ) { if ( item.id == nextSiblingId ) { array.splice( i, 0, newItem ); return newItem; } if ( recurse && item[ recurse ] ) { var retval = addById( item[ recurse ], newItem, nextSiblingId, recurse, true ); if ( retval ) return retval; } } if ( nullIfNotFound ) return null; } array.push( newItem ); return newItem; }
javascript
function( array, newItem, nextSiblingId, recurse, nullIfNotFound ) { if ( nextSiblingId ) { for ( var i = 0, item; ( item = array[ i ] ); i++ ) { if ( item.id == nextSiblingId ) { array.splice( i, 0, newItem ); return newItem; } if ( recurse && item[ recurse ] ) { var retval = addById( item[ recurse ], newItem, nextSiblingId, recurse, true ); if ( retval ) return retval; } } if ( nullIfNotFound ) return null; } array.push( newItem ); return newItem; }
[ "function", "(", "array", ",", "newItem", ",", "nextSiblingId", ",", "recurse", ",", "nullIfNotFound", ")", "{", "if", "(", "nextSiblingId", ")", "{", "for", "(", "var", "i", "=", "0", ",", "item", ";", "(", "item", "=", "array", "[", "i", "]", ")", ";", "i", "++", ")", "{", "if", "(", "item", ".", "id", "==", "nextSiblingId", ")", "{", "array", ".", "splice", "(", "i", ",", "0", ",", "newItem", ")", ";", "return", "newItem", ";", "}", "if", "(", "recurse", "&&", "item", "[", "recurse", "]", ")", "{", "var", "retval", "=", "addById", "(", "item", "[", "recurse", "]", ",", "newItem", ",", "nextSiblingId", ",", "recurse", ",", "true", ")", ";", "if", "(", "retval", ")", "return", "retval", ";", "}", "}", "if", "(", "nullIfNotFound", ")", "return", "null", ";", "}", "array", ".", "push", "(", "newItem", ")", ";", "return", "newItem", ";", "}" ]
Tool function used to add an item into an array.
[ "Tool", "function", "used", "to", "add", "an", "item", "into", "an", "array", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1596-L1618
57,373
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( array, id, recurse ) { for ( var i = 0, item; ( item = array[ i ] ); i++ ) { if ( item.id == id ) return array.splice( i, 1 ); if ( recurse && item[ recurse ] ) { var retval = removeById( item[ recurse ], id, recurse ); if ( retval ) return retval; } } return null; }
javascript
function( array, id, recurse ) { for ( var i = 0, item; ( item = array[ i ] ); i++ ) { if ( item.id == id ) return array.splice( i, 1 ); if ( recurse && item[ recurse ] ) { var retval = removeById( item[ recurse ], id, recurse ); if ( retval ) return retval; } } return null; }
[ "function", "(", "array", ",", "id", ",", "recurse", ")", "{", "for", "(", "var", "i", "=", "0", ",", "item", ";", "(", "item", "=", "array", "[", "i", "]", ")", ";", "i", "++", ")", "{", "if", "(", "item", ".", "id", "==", "id", ")", "return", "array", ".", "splice", "(", "i", ",", "1", ")", ";", "if", "(", "recurse", "&&", "item", "[", "recurse", "]", ")", "{", "var", "retval", "=", "removeById", "(", "item", "[", "recurse", "]", ",", "id", ",", "recurse", ")", ";", "if", "(", "retval", ")", "return", "retval", ";", "}", "}", "return", "null", ";", "}" ]
Tool function used to remove an item from an array based on its id.
[ "Tool", "function", "used", "to", "remove", "an", "item", "from", "an", "array", "based", "on", "its", "id", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1621-L1633
57,374
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( dialog, dialogDefinition ) { // TODO : Check if needed. this.dialog = dialog; // Transform the contents entries in contentObjects. var contents = dialogDefinition.contents; for ( var i = 0, content; ( content = contents[ i ] ); i++ ) contents[ i ] = content && new contentObject( dialog, content ); CKEDITOR.tools.extend( this, dialogDefinition ); }
javascript
function( dialog, dialogDefinition ) { // TODO : Check if needed. this.dialog = dialog; // Transform the contents entries in contentObjects. var contents = dialogDefinition.contents; for ( var i = 0, content; ( content = contents[ i ] ); i++ ) contents[ i ] = content && new contentObject( dialog, content ); CKEDITOR.tools.extend( this, dialogDefinition ); }
[ "function", "(", "dialog", ",", "dialogDefinition", ")", "{", "// TODO : Check if needed.\r", "this", ".", "dialog", "=", "dialog", ";", "// Transform the contents entries in contentObjects.\r", "var", "contents", "=", "dialogDefinition", ".", "contents", ";", "for", "(", "var", "i", "=", "0", ",", "content", ";", "(", "content", "=", "contents", "[", "i", "]", ")", ";", "i", "++", ")", "contents", "[", "i", "]", "=", "content", "&&", "new", "contentObject", "(", "dialog", ",", "content", ")", ";", "CKEDITOR", ".", "tools", ".", "extend", "(", "this", ",", "dialogDefinition", ")", ";", "}" ]
This class is not really part of the API. It is the `definition` property value passed to `dialogDefinition` event handlers. CKEDITOR.on( 'dialogDefinition', function( evt ) { var definition = evt.data.definition; var content = definition.getContents( 'page1' ); // ... } ); @private @class CKEDITOR.dialog.definitionObject @extends CKEDITOR.dialog.definition @constructor Creates a definitionObject class instance.
[ "This", "class", "is", "not", "really", "part", "of", "the", "API", ".", "It", "is", "the", "definition", "property", "value", "passed", "to", "dialogDefinition", "event", "handlers", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1650-L1661
57,375
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
contentObject
function contentObject( dialog, contentDefinition ) { this._ = { dialog: dialog }; CKEDITOR.tools.extend( this, contentDefinition ); }
javascript
function contentObject( dialog, contentDefinition ) { this._ = { dialog: dialog }; CKEDITOR.tools.extend( this, contentDefinition ); }
[ "function", "contentObject", "(", "dialog", ",", "contentDefinition", ")", "{", "this", ".", "_", "=", "{", "dialog", ":", "dialog", "}", ";", "CKEDITOR", ".", "tools", ".", "extend", "(", "this", ",", "contentDefinition", ")", ";", "}" ]
This class is not really part of the API. It is the template of the objects representing content pages inside the CKEDITOR.dialog.definitionObject. CKEDITOR.on( 'dialogDefinition', function( evt ) { var definition = evt.data.definition; var content = definition.getContents( 'page1' ); content.remove( 'textInput1' ); // ... } ); @private @class CKEDITOR.dialog.definition.contentObject @constructor Creates a contentObject class instance.
[ "This", "class", "is", "not", "really", "part", "of", "the", "API", ".", "It", "is", "the", "template", "of", "the", "objects", "representing", "content", "pages", "inside", "the", "CKEDITOR", ".", "dialog", ".", "definitionObject", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L1751-L1757
57,376
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) { if ( arguments.length < 4 ) return; this._ || ( this._ = {} ); var children = this._.children = childObjList, widths = elementDefinition && elementDefinition.widths || null, height = elementDefinition && elementDefinition.height || null, styles = {}, i; /** @ignore */ var innerHTML = function() { var html = [ '<tbody><tr class="cke_dialog_ui_hbox">' ]; for ( i = 0; i < childHtmlList.length; i++ ) { var className = 'cke_dialog_ui_hbox_child', styles = []; if ( i === 0 ) className = 'cke_dialog_ui_hbox_first'; if ( i == childHtmlList.length - 1 ) className = 'cke_dialog_ui_hbox_last'; html.push( '<td class="', className, '" role="presentation" ' ); if ( widths ) { if ( widths[ i ] ) styles.push( 'width:' + cssLength( widths[ i ] ) ); } else styles.push( 'width:' + Math.floor( 100 / childHtmlList.length ) + '%' ); if ( height ) styles.push( 'height:' + cssLength( height ) ); if ( elementDefinition && elementDefinition.padding != undefined ) styles.push( 'padding:' + cssLength( elementDefinition.padding ) ); // In IE Quirks alignment has to be done on table cells. (#7324) if ( CKEDITOR.env.ie && CKEDITOR.env.quirks && children[ i ].align ) styles.push( 'text-align:' + children[ i ].align ); if ( styles.length > 0 ) html.push( 'style="' + styles.join( '; ' ) + '" ' ); html.push( '>', childHtmlList[ i ], '</td>' ); } html.push( '</tr></tbody>' ); return html.join( '' ); }; var attribs = { role: 'presentation' }; elementDefinition && elementDefinition.align && ( attribs.align = elementDefinition.align ); CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type: 'hbox' }, htmlList, 'table', styles, attribs, innerHTML ); }
javascript
function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) { if ( arguments.length < 4 ) return; this._ || ( this._ = {} ); var children = this._.children = childObjList, widths = elementDefinition && elementDefinition.widths || null, height = elementDefinition && elementDefinition.height || null, styles = {}, i; /** @ignore */ var innerHTML = function() { var html = [ '<tbody><tr class="cke_dialog_ui_hbox">' ]; for ( i = 0; i < childHtmlList.length; i++ ) { var className = 'cke_dialog_ui_hbox_child', styles = []; if ( i === 0 ) className = 'cke_dialog_ui_hbox_first'; if ( i == childHtmlList.length - 1 ) className = 'cke_dialog_ui_hbox_last'; html.push( '<td class="', className, '" role="presentation" ' ); if ( widths ) { if ( widths[ i ] ) styles.push( 'width:' + cssLength( widths[ i ] ) ); } else styles.push( 'width:' + Math.floor( 100 / childHtmlList.length ) + '%' ); if ( height ) styles.push( 'height:' + cssLength( height ) ); if ( elementDefinition && elementDefinition.padding != undefined ) styles.push( 'padding:' + cssLength( elementDefinition.padding ) ); // In IE Quirks alignment has to be done on table cells. (#7324) if ( CKEDITOR.env.ie && CKEDITOR.env.quirks && children[ i ].align ) styles.push( 'text-align:' + children[ i ].align ); if ( styles.length > 0 ) html.push( 'style="' + styles.join( '; ' ) + '" ' ); html.push( '>', childHtmlList[ i ], '</td>' ); } html.push( '</tr></tbody>' ); return html.join( '' ); }; var attribs = { role: 'presentation' }; elementDefinition && elementDefinition.align && ( attribs.align = elementDefinition.align ); CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type: 'hbox' }, htmlList, 'table', styles, attribs, innerHTML ); }
[ "function", "(", "dialog", ",", "childObjList", ",", "childHtmlList", ",", "htmlList", ",", "elementDefinition", ")", "{", "if", "(", "arguments", ".", "length", "<", "4", ")", "return", ";", "this", ".", "_", "||", "(", "this", ".", "_", "=", "{", "}", ")", ";", "var", "children", "=", "this", ".", "_", ".", "children", "=", "childObjList", ",", "widths", "=", "elementDefinition", "&&", "elementDefinition", ".", "widths", "||", "null", ",", "height", "=", "elementDefinition", "&&", "elementDefinition", ".", "height", "||", "null", ",", "styles", "=", "{", "}", ",", "i", ";", "/** @ignore */", "var", "innerHTML", "=", "function", "(", ")", "{", "var", "html", "=", "[", "'<tbody><tr class=\"cke_dialog_ui_hbox\">'", "]", ";", "for", "(", "i", "=", "0", ";", "i", "<", "childHtmlList", ".", "length", ";", "i", "++", ")", "{", "var", "className", "=", "'cke_dialog_ui_hbox_child'", ",", "styles", "=", "[", "]", ";", "if", "(", "i", "===", "0", ")", "className", "=", "'cke_dialog_ui_hbox_first'", ";", "if", "(", "i", "==", "childHtmlList", ".", "length", "-", "1", ")", "className", "=", "'cke_dialog_ui_hbox_last'", ";", "html", ".", "push", "(", "'<td class=\"'", ",", "className", ",", "'\" role=\"presentation\" '", ")", ";", "if", "(", "widths", ")", "{", "if", "(", "widths", "[", "i", "]", ")", "styles", ".", "push", "(", "'width:'", "+", "cssLength", "(", "widths", "[", "i", "]", ")", ")", ";", "}", "else", "styles", ".", "push", "(", "'width:'", "+", "Math", ".", "floor", "(", "100", "/", "childHtmlList", ".", "length", ")", "+", "'%'", ")", ";", "if", "(", "height", ")", "styles", ".", "push", "(", "'height:'", "+", "cssLength", "(", "height", ")", ")", ";", "if", "(", "elementDefinition", "&&", "elementDefinition", ".", "padding", "!=", "undefined", ")", "styles", ".", "push", "(", "'padding:'", "+", "cssLength", "(", "elementDefinition", ".", "padding", ")", ")", ";", "// In IE Quirks alignment has to be done on table cells. (#7324)\r", "if", "(", "CKEDITOR", ".", "env", ".", "ie", "&&", "CKEDITOR", ".", "env", ".", "quirks", "&&", "children", "[", "i", "]", ".", "align", ")", "styles", ".", "push", "(", "'text-align:'", "+", "children", "[", "i", "]", ".", "align", ")", ";", "if", "(", "styles", ".", "length", ">", "0", ")", "html", ".", "push", "(", "'style=\"'", "+", "styles", ".", "join", "(", "'; '", ")", "+", "'\" '", ")", ";", "html", ".", "push", "(", "'>'", ",", "childHtmlList", "[", "i", "]", ",", "'</td>'", ")", ";", "}", "html", ".", "push", "(", "'</tr></tbody>'", ")", ";", "return", "html", ".", "join", "(", "''", ")", ";", "}", ";", "var", "attribs", "=", "{", "role", ":", "'presentation'", "}", ";", "elementDefinition", "&&", "elementDefinition", ".", "align", "&&", "(", "attribs", ".", "align", "=", "elementDefinition", ".", "align", ")", ";", "CKEDITOR", ".", "ui", ".", "dialog", ".", "uiElement", ".", "call", "(", "this", ",", "dialog", ",", "elementDefinition", "||", "{", "type", ":", "'hbox'", "}", ",", "htmlList", ",", "'table'", ",", "styles", ",", "attribs", ",", "innerHTML", ")", ";", "}" ]
Horizontal layout box for dialog UI elements, auto-expends to available width of container. @class CKEDITOR.ui.dialog.hbox @extends CKEDITOR.ui.dialog.uiElement @constructor Creates a hbox class instance. @param {CKEDITOR.dialog} dialog Parent dialog object. @param {Array} childObjList Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this container. @param {Array} childHtmlList Array of HTML code that correspond to the HTML output of all the objects in childObjList. @param {Array} htmlList Array of HTML code that this element will output to. @param {CKEDITOR.dialog.definition.uiElement} elementDefinition The element definition. Accepted fields: * `widths` (Optional) The widths of child cells. * `height` (Optional) The height of the layout. * `padding` (Optional) The padding width inside child cells. * `align` (Optional) The alignment of the whole layout.
[ "Horizontal", "layout", "box", "for", "dialog", "UI", "elements", "auto", "-", "expends", "to", "available", "width", "of", "container", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L2407-L2453
57,377
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) { if ( arguments.length < 3 ) return; this._ || ( this._ = {} ); var children = this._.children = childObjList, width = elementDefinition && elementDefinition.width || null, heights = elementDefinition && elementDefinition.heights || null; /** @ignore */ var innerHTML = function() { var html = [ '<table role="presentation" cellspacing="0" border="0" ' ]; html.push( 'style="' ); if ( elementDefinition && elementDefinition.expand ) html.push( 'height:100%;' ); html.push( 'width:' + cssLength( width || '100%' ), ';' ); // (#10123) Temp fix for dialog broken layout in latest webkit. if ( CKEDITOR.env.webkit ) html.push( 'float:none;' ); html.push( '"' ); html.push( 'align="', CKEDITOR.tools.htmlEncode( ( elementDefinition && elementDefinition.align ) || ( dialog.getParentEditor().lang.dir == 'ltr' ? 'left' : 'right' ) ), '" ' ); html.push( '><tbody>' ); for ( var i = 0; i < childHtmlList.length; i++ ) { var styles = []; html.push( '<tr><td role="presentation" ' ); if ( width ) styles.push( 'width:' + cssLength( width || '100%' ) ); if ( heights ) styles.push( 'height:' + cssLength( heights[ i ] ) ); else if ( elementDefinition && elementDefinition.expand ) styles.push( 'height:' + Math.floor( 100 / childHtmlList.length ) + '%' ); if ( elementDefinition && elementDefinition.padding != undefined ) styles.push( 'padding:' + cssLength( elementDefinition.padding ) ); // In IE Quirks alignment has to be done on table cells. (#7324) if ( CKEDITOR.env.ie && CKEDITOR.env.quirks && children[ i ].align ) styles.push( 'text-align:' + children[ i ].align ); if ( styles.length > 0 ) html.push( 'style="', styles.join( '; ' ), '" ' ); html.push( ' class="cke_dialog_ui_vbox_child">', childHtmlList[ i ], '</td></tr>' ); } html.push( '</tbody></table>' ); return html.join( '' ); }; CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type: 'vbox' }, htmlList, 'div', null, { role: 'presentation' }, innerHTML ); }
javascript
function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) { if ( arguments.length < 3 ) return; this._ || ( this._ = {} ); var children = this._.children = childObjList, width = elementDefinition && elementDefinition.width || null, heights = elementDefinition && elementDefinition.heights || null; /** @ignore */ var innerHTML = function() { var html = [ '<table role="presentation" cellspacing="0" border="0" ' ]; html.push( 'style="' ); if ( elementDefinition && elementDefinition.expand ) html.push( 'height:100%;' ); html.push( 'width:' + cssLength( width || '100%' ), ';' ); // (#10123) Temp fix for dialog broken layout in latest webkit. if ( CKEDITOR.env.webkit ) html.push( 'float:none;' ); html.push( '"' ); html.push( 'align="', CKEDITOR.tools.htmlEncode( ( elementDefinition && elementDefinition.align ) || ( dialog.getParentEditor().lang.dir == 'ltr' ? 'left' : 'right' ) ), '" ' ); html.push( '><tbody>' ); for ( var i = 0; i < childHtmlList.length; i++ ) { var styles = []; html.push( '<tr><td role="presentation" ' ); if ( width ) styles.push( 'width:' + cssLength( width || '100%' ) ); if ( heights ) styles.push( 'height:' + cssLength( heights[ i ] ) ); else if ( elementDefinition && elementDefinition.expand ) styles.push( 'height:' + Math.floor( 100 / childHtmlList.length ) + '%' ); if ( elementDefinition && elementDefinition.padding != undefined ) styles.push( 'padding:' + cssLength( elementDefinition.padding ) ); // In IE Quirks alignment has to be done on table cells. (#7324) if ( CKEDITOR.env.ie && CKEDITOR.env.quirks && children[ i ].align ) styles.push( 'text-align:' + children[ i ].align ); if ( styles.length > 0 ) html.push( 'style="', styles.join( '; ' ), '" ' ); html.push( ' class="cke_dialog_ui_vbox_child">', childHtmlList[ i ], '</td></tr>' ); } html.push( '</tbody></table>' ); return html.join( '' ); }; CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type: 'vbox' }, htmlList, 'div', null, { role: 'presentation' }, innerHTML ); }
[ "function", "(", "dialog", ",", "childObjList", ",", "childHtmlList", ",", "htmlList", ",", "elementDefinition", ")", "{", "if", "(", "arguments", ".", "length", "<", "3", ")", "return", ";", "this", ".", "_", "||", "(", "this", ".", "_", "=", "{", "}", ")", ";", "var", "children", "=", "this", ".", "_", ".", "children", "=", "childObjList", ",", "width", "=", "elementDefinition", "&&", "elementDefinition", ".", "width", "||", "null", ",", "heights", "=", "elementDefinition", "&&", "elementDefinition", ".", "heights", "||", "null", ";", "/** @ignore */", "var", "innerHTML", "=", "function", "(", ")", "{", "var", "html", "=", "[", "'<table role=\"presentation\" cellspacing=\"0\" border=\"0\" '", "]", ";", "html", ".", "push", "(", "'style=\"'", ")", ";", "if", "(", "elementDefinition", "&&", "elementDefinition", ".", "expand", ")", "html", ".", "push", "(", "'height:100%;'", ")", ";", "html", ".", "push", "(", "'width:'", "+", "cssLength", "(", "width", "||", "'100%'", ")", ",", "';'", ")", ";", "// (#10123) Temp fix for dialog broken layout in latest webkit.\r", "if", "(", "CKEDITOR", ".", "env", ".", "webkit", ")", "html", ".", "push", "(", "'float:none;'", ")", ";", "html", ".", "push", "(", "'\"'", ")", ";", "html", ".", "push", "(", "'align=\"'", ",", "CKEDITOR", ".", "tools", ".", "htmlEncode", "(", "(", "elementDefinition", "&&", "elementDefinition", ".", "align", ")", "||", "(", "dialog", ".", "getParentEditor", "(", ")", ".", "lang", ".", "dir", "==", "'ltr'", "?", "'left'", ":", "'right'", ")", ")", ",", "'\" '", ")", ";", "html", ".", "push", "(", "'><tbody>'", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "childHtmlList", ".", "length", ";", "i", "++", ")", "{", "var", "styles", "=", "[", "]", ";", "html", ".", "push", "(", "'<tr><td role=\"presentation\" '", ")", ";", "if", "(", "width", ")", "styles", ".", "push", "(", "'width:'", "+", "cssLength", "(", "width", "||", "'100%'", ")", ")", ";", "if", "(", "heights", ")", "styles", ".", "push", "(", "'height:'", "+", "cssLength", "(", "heights", "[", "i", "]", ")", ")", ";", "else", "if", "(", "elementDefinition", "&&", "elementDefinition", ".", "expand", ")", "styles", ".", "push", "(", "'height:'", "+", "Math", ".", "floor", "(", "100", "/", "childHtmlList", ".", "length", ")", "+", "'%'", ")", ";", "if", "(", "elementDefinition", "&&", "elementDefinition", ".", "padding", "!=", "undefined", ")", "styles", ".", "push", "(", "'padding:'", "+", "cssLength", "(", "elementDefinition", ".", "padding", ")", ")", ";", "// In IE Quirks alignment has to be done on table cells. (#7324)\r", "if", "(", "CKEDITOR", ".", "env", ".", "ie", "&&", "CKEDITOR", ".", "env", ".", "quirks", "&&", "children", "[", "i", "]", ".", "align", ")", "styles", ".", "push", "(", "'text-align:'", "+", "children", "[", "i", "]", ".", "align", ")", ";", "if", "(", "styles", ".", "length", ">", "0", ")", "html", ".", "push", "(", "'style=\"'", ",", "styles", ".", "join", "(", "'; '", ")", ",", "'\" '", ")", ";", "html", ".", "push", "(", "' class=\"cke_dialog_ui_vbox_child\">'", ",", "childHtmlList", "[", "i", "]", ",", "'</td></tr>'", ")", ";", "}", "html", ".", "push", "(", "'</tbody></table>'", ")", ";", "return", "html", ".", "join", "(", "''", ")", ";", "}", ";", "CKEDITOR", ".", "ui", ".", "dialog", ".", "uiElement", ".", "call", "(", "this", ",", "dialog", ",", "elementDefinition", "||", "{", "type", ":", "'vbox'", "}", ",", "htmlList", ",", "'div'", ",", "null", ",", "{", "role", ":", "'presentation'", "}", ",", "innerHTML", ")", ";", "}" ]
Vertical layout box for dialog UI elements. @class CKEDITOR.ui.dialog.vbox @extends CKEDITOR.ui.dialog.hbox @constructor Creates a vbox class instance. @param {CKEDITOR.dialog} dialog Parent dialog object. @param {Array} childObjList Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this container. @param {Array} childHtmlList Array of HTML code that correspond to the HTML output of all the objects in childObjList. @param {Array} htmlList Array of HTML code that this element will output to. @param {CKEDITOR.dialog.definition.uiElement} elementDefinition The element definition. Accepted fields: * `width` (Optional) The width of the layout. * `heights` (Optional) The heights of individual cells. * `align` (Optional) The alignment of the layout. * `padding` (Optional) The padding width inside child cells. * `expand` (Optional) Whether the layout should expand vertically to fill its container.
[ "Vertical", "layout", "box", "for", "dialog", "UI", "elements", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L2478-L2526
57,378
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( indices ) { // If no arguments, return a clone of the children array. if ( arguments.length < 1 ) return this._.children.concat(); // If indices isn't array, make it one. if ( !indices.splice ) indices = [ indices ]; // Retrieve the child element according to tree position. if ( indices.length < 2 ) return this._.children[ indices[ 0 ] ]; else return ( this._.children[ indices[ 0 ] ] && this._.children[ indices[ 0 ] ].getChild ) ? this._.children[ indices[ 0 ] ].getChild( indices.slice( 1, indices.length ) ) : null; }
javascript
function( indices ) { // If no arguments, return a clone of the children array. if ( arguments.length < 1 ) return this._.children.concat(); // If indices isn't array, make it one. if ( !indices.splice ) indices = [ indices ]; // Retrieve the child element according to tree position. if ( indices.length < 2 ) return this._.children[ indices[ 0 ] ]; else return ( this._.children[ indices[ 0 ] ] && this._.children[ indices[ 0 ] ].getChild ) ? this._.children[ indices[ 0 ] ].getChild( indices.slice( 1, indices.length ) ) : null; }
[ "function", "(", "indices", ")", "{", "// If no arguments, return a clone of the children array.\r", "if", "(", "arguments", ".", "length", "<", "1", ")", "return", "this", ".", "_", ".", "children", ".", "concat", "(", ")", ";", "// If indices isn't array, make it one.\r", "if", "(", "!", "indices", ".", "splice", ")", "indices", "=", "[", "indices", "]", ";", "// Retrieve the child element according to tree position.\r", "if", "(", "indices", ".", "length", "<", "2", ")", "return", "this", ".", "_", ".", "children", "[", "indices", "[", "0", "]", "]", ";", "else", "return", "(", "this", ".", "_", ".", "children", "[", "indices", "[", "0", "]", "]", "&&", "this", ".", "_", ".", "children", "[", "indices", "[", "0", "]", "]", ".", "getChild", ")", "?", "this", ".", "_", ".", "children", "[", "indices", "[", "0", "]", "]", ".", "getChild", "(", "indices", ".", "slice", "(", "1", ",", "indices", ".", "length", ")", ")", ":", "null", ";", "}" ]
Gets a child UI element inside this container. var checkbox = hbox.getChild( [0,1] ); checkbox.setValue( true ); @param {Array/Number} indices An array or a single number to indicate the child's position in the container's descendant tree. Omit to get all the children in an array. @returns {Array/CKEDITOR.ui.dialog.uiElement} Array of all UI elements in the container if no argument given, or the specified UI element if indices is given.
[ "Gets", "a", "child", "UI", "element", "inside", "this", "container", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L2817-L2831
57,379
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/dialog/plugin.js
function( dialogName, callback ) { var dialog = null, dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ]; if ( CKEDITOR.dialog._.currentTop === null ) showCover( this ); // If the dialogDefinition is already loaded, open it immediately. if ( typeof dialogDefinitions == 'function' ) { var storedDialogs = this._.storedDialogs || ( this._.storedDialogs = {} ); dialog = storedDialogs[ dialogName ] || ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) ); callback && callback.call( dialog, dialog ); dialog.show(); } else if ( dialogDefinitions == 'failed' ) { hideCover( this ); throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' ); } else if ( typeof dialogDefinitions == 'string' ) { CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), function() { var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ]; // In case of plugin error, mark it as loading failed. if ( typeof dialogDefinition != 'function' ) CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed'; this.openDialog( dialogName, callback ); }, this, 0, 1 ); } CKEDITOR.skin.loadPart( 'dialog' ); return dialog; }
javascript
function( dialogName, callback ) { var dialog = null, dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ]; if ( CKEDITOR.dialog._.currentTop === null ) showCover( this ); // If the dialogDefinition is already loaded, open it immediately. if ( typeof dialogDefinitions == 'function' ) { var storedDialogs = this._.storedDialogs || ( this._.storedDialogs = {} ); dialog = storedDialogs[ dialogName ] || ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) ); callback && callback.call( dialog, dialog ); dialog.show(); } else if ( dialogDefinitions == 'failed' ) { hideCover( this ); throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' ); } else if ( typeof dialogDefinitions == 'string' ) { CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), function() { var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ]; // In case of plugin error, mark it as loading failed. if ( typeof dialogDefinition != 'function' ) CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed'; this.openDialog( dialogName, callback ); }, this, 0, 1 ); } CKEDITOR.skin.loadPart( 'dialog' ); return dialog; }
[ "function", "(", "dialogName", ",", "callback", ")", "{", "var", "dialog", "=", "null", ",", "dialogDefinitions", "=", "CKEDITOR", ".", "dialog", ".", "_", ".", "dialogDefinitions", "[", "dialogName", "]", ";", "if", "(", "CKEDITOR", ".", "dialog", ".", "_", ".", "currentTop", "===", "null", ")", "showCover", "(", "this", ")", ";", "// If the dialogDefinition is already loaded, open it immediately.\r", "if", "(", "typeof", "dialogDefinitions", "==", "'function'", ")", "{", "var", "storedDialogs", "=", "this", ".", "_", ".", "storedDialogs", "||", "(", "this", ".", "_", ".", "storedDialogs", "=", "{", "}", ")", ";", "dialog", "=", "storedDialogs", "[", "dialogName", "]", "||", "(", "storedDialogs", "[", "dialogName", "]", "=", "new", "CKEDITOR", ".", "dialog", "(", "this", ",", "dialogName", ")", ")", ";", "callback", "&&", "callback", ".", "call", "(", "dialog", ",", "dialog", ")", ";", "dialog", ".", "show", "(", ")", ";", "}", "else", "if", "(", "dialogDefinitions", "==", "'failed'", ")", "{", "hideCover", "(", "this", ")", ";", "throw", "new", "Error", "(", "'[CKEDITOR.dialog.openDialog] Dialog \"'", "+", "dialogName", "+", "'\" failed when loading definition.'", ")", ";", "}", "else", "if", "(", "typeof", "dialogDefinitions", "==", "'string'", ")", "{", "CKEDITOR", ".", "scriptLoader", ".", "load", "(", "CKEDITOR", ".", "getUrl", "(", "dialogDefinitions", ")", ",", "function", "(", ")", "{", "var", "dialogDefinition", "=", "CKEDITOR", ".", "dialog", ".", "_", ".", "dialogDefinitions", "[", "dialogName", "]", ";", "// In case of plugin error, mark it as loading failed.\r", "if", "(", "typeof", "dialogDefinition", "!=", "'function'", ")", "CKEDITOR", ".", "dialog", ".", "_", ".", "dialogDefinitions", "[", "dialogName", "]", "=", "'failed'", ";", "this", ".", "openDialog", "(", "dialogName", ",", "callback", ")", ";", "}", ",", "this", ",", "0", ",", "1", ")", ";", "}", "CKEDITOR", ".", "skin", ".", "loadPart", "(", "'dialog'", ")", ";", "return", "dialog", ";", "}" ]
Loads and opens a registered dialog. CKEDITOR.instances.editor1.openDialog( 'smiley' ); @member CKEDITOR.editor @param {String} dialogName The registered name of the dialog. @param {Function} callback The function to be invoked after dialog instance created. @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. `null` if the dialog name is not registered. @see CKEDITOR.dialog#add
[ "Loads", "and", "opens", "a", "registered", "dialog", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/dialog/plugin.js#L3027-L3061
57,380
open-nata/nata-device
src/utils.js
getWidgetsFromXml
async function getWidgetsFromXml(target) { const $ = await parseFile(target) const widgets = [] let widget $('node').each((i, elem) => { const node = $(elem) widget = new Widget() widget.text = node.attr('text') widget.resourceId = node.attr('resource-id') widget.className = node.attr('class') widget.packageName = node.attr('package') widget.contentDesc = node.attr('content-desc') widget.checkable = node.attr('checkable') widget.checked = node.attr('checked') widget.clickable = node.attr('clickable') widget.enabled = node.attr('enabled') widget.focusable = node.attr('focusable') widget.focused = node.attr('focused') widget.scrollable = node.attr('scrollable') widget.longClickable = node.attr('long-clickable') widget.password = node.attr('password') widget.selected = node.attr('selected') widget.bounds = node.attr('bounds') widgets.push(widget) }) return widgets }
javascript
async function getWidgetsFromXml(target) { const $ = await parseFile(target) const widgets = [] let widget $('node').each((i, elem) => { const node = $(elem) widget = new Widget() widget.text = node.attr('text') widget.resourceId = node.attr('resource-id') widget.className = node.attr('class') widget.packageName = node.attr('package') widget.contentDesc = node.attr('content-desc') widget.checkable = node.attr('checkable') widget.checked = node.attr('checked') widget.clickable = node.attr('clickable') widget.enabled = node.attr('enabled') widget.focusable = node.attr('focusable') widget.focused = node.attr('focused') widget.scrollable = node.attr('scrollable') widget.longClickable = node.attr('long-clickable') widget.password = node.attr('password') widget.selected = node.attr('selected') widget.bounds = node.attr('bounds') widgets.push(widget) }) return widgets }
[ "async", "function", "getWidgetsFromXml", "(", "target", ")", "{", "const", "$", "=", "await", "parseFile", "(", "target", ")", "const", "widgets", "=", "[", "]", "let", "widget", "$", "(", "'node'", ")", ".", "each", "(", "(", "i", ",", "elem", ")", "=>", "{", "const", "node", "=", "$", "(", "elem", ")", "widget", "=", "new", "Widget", "(", ")", "widget", ".", "text", "=", "node", ".", "attr", "(", "'text'", ")", "widget", ".", "resourceId", "=", "node", ".", "attr", "(", "'resource-id'", ")", "widget", ".", "className", "=", "node", ".", "attr", "(", "'class'", ")", "widget", ".", "packageName", "=", "node", ".", "attr", "(", "'package'", ")", "widget", ".", "contentDesc", "=", "node", ".", "attr", "(", "'content-desc'", ")", "widget", ".", "checkable", "=", "node", ".", "attr", "(", "'checkable'", ")", "widget", ".", "checked", "=", "node", ".", "attr", "(", "'checked'", ")", "widget", ".", "clickable", "=", "node", ".", "attr", "(", "'clickable'", ")", "widget", ".", "enabled", "=", "node", ".", "attr", "(", "'enabled'", ")", "widget", ".", "focusable", "=", "node", ".", "attr", "(", "'focusable'", ")", "widget", ".", "focused", "=", "node", ".", "attr", "(", "'focused'", ")", "widget", ".", "scrollable", "=", "node", ".", "attr", "(", "'scrollable'", ")", "widget", ".", "longClickable", "=", "node", ".", "attr", "(", "'long-clickable'", ")", "widget", ".", "password", "=", "node", ".", "attr", "(", "'password'", ")", "widget", ".", "selected", "=", "node", ".", "attr", "(", "'selected'", ")", "widget", ".", "bounds", "=", "node", ".", "attr", "(", "'bounds'", ")", "widgets", ".", "push", "(", "widget", ")", "}", ")", "return", "widgets", "}" ]
get widgets from dumpfile.xml @param {String} target the local path of dumpfile.xml @return {[Widget]} Array of avaliable widgets
[ "get", "widgets", "from", "dumpfile", ".", "xml" ]
c2c1292fb0f634eab72e6770ee5b835b67186405
https://github.com/open-nata/nata-device/blob/c2c1292fb0f634eab72e6770ee5b835b67186405/src/utils.js#L26-L54
57,381
jeremenichelli/threshold
src/threshold.js
threshold
function threshold(element) { var rects = element.getBoundingClientRect(); var upperThreshold = (threshold._viewport.height - rects.top) / rects.height; var bottomThreshold = rects.bottom / rects.height; var leftThreshold = (threshold._viewport.width - rects.left) / rects.width; var rightThreshold = rects.right / rects.width; var horizontalTrajectory = rects.width + threshold._viewport.width; var verticalTrajectory = rects.height + threshold._viewport.height; /** * area * * This value represents the area of the component present in the viewport * * It is calculated by using the min value between the distance from the * top, right, bottom and left edges of the element and its height and weight * */ var minXArea = Math.min(leftThreshold, rightThreshold); var xArea = Math.min(1, Math.max(minXArea, 0)); var minYArea = Math.min(upperThreshold, bottomThreshold); var yArea = Math.min(1, Math.max(minYArea, 0)); /** * trajectory * * This value represents the translation of the element from the moment * it enters the viewport until it gets out * * It is calculated by measuring the distance between the top and left edge * of the viewport and the bottom and right edge of the element * */ var xTrajectory = (horizontalTrajectory - rects.right) / horizontalTrajectory; var yTrajectory = (verticalTrajectory - rects.bottom) / verticalTrajectory; return { area: xArea * yArea, trajectory: { x: xTrajectory, y: yTrajectory } }; }
javascript
function threshold(element) { var rects = element.getBoundingClientRect(); var upperThreshold = (threshold._viewport.height - rects.top) / rects.height; var bottomThreshold = rects.bottom / rects.height; var leftThreshold = (threshold._viewport.width - rects.left) / rects.width; var rightThreshold = rects.right / rects.width; var horizontalTrajectory = rects.width + threshold._viewport.width; var verticalTrajectory = rects.height + threshold._viewport.height; /** * area * * This value represents the area of the component present in the viewport * * It is calculated by using the min value between the distance from the * top, right, bottom and left edges of the element and its height and weight * */ var minXArea = Math.min(leftThreshold, rightThreshold); var xArea = Math.min(1, Math.max(minXArea, 0)); var minYArea = Math.min(upperThreshold, bottomThreshold); var yArea = Math.min(1, Math.max(minYArea, 0)); /** * trajectory * * This value represents the translation of the element from the moment * it enters the viewport until it gets out * * It is calculated by measuring the distance between the top and left edge * of the viewport and the bottom and right edge of the element * */ var xTrajectory = (horizontalTrajectory - rects.right) / horizontalTrajectory; var yTrajectory = (verticalTrajectory - rects.bottom) / verticalTrajectory; return { area: xArea * yArea, trajectory: { x: xTrajectory, y: yTrajectory } }; }
[ "function", "threshold", "(", "element", ")", "{", "var", "rects", "=", "element", ".", "getBoundingClientRect", "(", ")", ";", "var", "upperThreshold", "=", "(", "threshold", ".", "_viewport", ".", "height", "-", "rects", ".", "top", ")", "/", "rects", ".", "height", ";", "var", "bottomThreshold", "=", "rects", ".", "bottom", "/", "rects", ".", "height", ";", "var", "leftThreshold", "=", "(", "threshold", ".", "_viewport", ".", "width", "-", "rects", ".", "left", ")", "/", "rects", ".", "width", ";", "var", "rightThreshold", "=", "rects", ".", "right", "/", "rects", ".", "width", ";", "var", "horizontalTrajectory", "=", "rects", ".", "width", "+", "threshold", ".", "_viewport", ".", "width", ";", "var", "verticalTrajectory", "=", "rects", ".", "height", "+", "threshold", ".", "_viewport", ".", "height", ";", "/**\n * area\n *\n * This value represents the area of the component present in the viewport\n *\n * It is calculated by using the min value between the distance from the\n * top, right, bottom and left edges of the element and its height and weight\n *\n */", "var", "minXArea", "=", "Math", ".", "min", "(", "leftThreshold", ",", "rightThreshold", ")", ";", "var", "xArea", "=", "Math", ".", "min", "(", "1", ",", "Math", ".", "max", "(", "minXArea", ",", "0", ")", ")", ";", "var", "minYArea", "=", "Math", ".", "min", "(", "upperThreshold", ",", "bottomThreshold", ")", ";", "var", "yArea", "=", "Math", ".", "min", "(", "1", ",", "Math", ".", "max", "(", "minYArea", ",", "0", ")", ")", ";", "/**\n * trajectory\n *\n * This value represents the translation of the element from the moment\n * it enters the viewport until it gets out\n *\n * It is calculated by measuring the distance between the top and left edge\n * of the viewport and the bottom and right edge of the element\n *\n */", "var", "xTrajectory", "=", "(", "horizontalTrajectory", "-", "rects", ".", "right", ")", "/", "horizontalTrajectory", ";", "var", "yTrajectory", "=", "(", "verticalTrajectory", "-", "rects", ".", "bottom", ")", "/", "verticalTrajectory", ";", "return", "{", "area", ":", "xArea", "*", "yArea", ",", "trajectory", ":", "{", "x", ":", "xTrajectory", ",", "y", ":", "yTrajectory", "}", "}", ";", "}" ]
Returns metrics regarding an element's position in the viewport @method threshold @param {Node} element @returns {Object}
[ "Returns", "metrics", "regarding", "an", "element", "s", "position", "in", "the", "viewport" ]
17793f53eacaf34a398075266eeb5e1a2c020881
https://github.com/jeremenichelli/threshold/blob/17793f53eacaf34a398075266eeb5e1a2c020881/src/threshold.js#L7-L55
57,382
jeremenichelli/threshold
src/threshold.js
updateViewport
function updateViewport() { threshold._viewport.height = window.innerHeight; threshold._viewport.width = window.innerWidth; }
javascript
function updateViewport() { threshold._viewport.height = window.innerHeight; threshold._viewport.width = window.innerWidth; }
[ "function", "updateViewport", "(", ")", "{", "threshold", ".", "_viewport", ".", "height", "=", "window", ".", "innerHeight", ";", "threshold", ".", "_viewport", ".", "width", "=", "window", ".", "innerWidth", ";", "}" ]
Updates memoized viewport metrics @method updateViewport
[ "Updates", "memoized", "viewport", "metrics" ]
17793f53eacaf34a398075266eeb5e1a2c020881
https://github.com/jeremenichelli/threshold/blob/17793f53eacaf34a398075266eeb5e1a2c020881/src/threshold.js#L67-L70
57,383
bbusschots-mu/mu-qunit-util
dist/index.es.js
all
function all(func) { return function() { var params = getParams(arguments); var length = params.length; for (var i = 0; i < length; i++) { if (!func.call(null, params[i])) { return false; } } return true; }; }
javascript
function all(func) { return function() { var params = getParams(arguments); var length = params.length; for (var i = 0; i < length; i++) { if (!func.call(null, params[i])) { return false; } } return true; }; }
[ "function", "all", "(", "func", ")", "{", "return", "function", "(", ")", "{", "var", "params", "=", "getParams", "(", "arguments", ")", ";", "var", "length", "=", "params", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "!", "func", ".", "call", "(", "null", ",", "params", "[", "i", "]", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", ";", "}" ]
helper function which call predicate function per parameter and return true if all pass
[ "helper", "function", "which", "call", "predicate", "function", "per", "parameter", "and", "return", "true", "if", "all", "pass" ]
1ed4414e8b307cf6452918496ff48cf373ccb654
https://github.com/bbusschots-mu/mu-qunit-util/blob/1ed4414e8b307cf6452918496ff48cf373ccb654/dist/index.es.js#L42-L53
57,384
bbusschots-mu/mu-qunit-util
dist/index.es.js
compareVersion
function compareVersion(version, range) { var string = (range + ''); var n = +(string.match(/\d+/) || NaN); var op = string.match(/^[<>]=?|/)[0]; return comparator[op] ? comparator[op](version, n) : (version == n || n !== n); }
javascript
function compareVersion(version, range) { var string = (range + ''); var n = +(string.match(/\d+/) || NaN); var op = string.match(/^[<>]=?|/)[0]; return comparator[op] ? comparator[op](version, n) : (version == n || n !== n); }
[ "function", "compareVersion", "(", "version", ",", "range", ")", "{", "var", "string", "=", "(", "range", "+", "''", ")", ";", "var", "n", "=", "+", "(", "string", ".", "match", "(", "/", "\\d+", "/", ")", "||", "NaN", ")", ";", "var", "op", "=", "string", ".", "match", "(", "/", "^[<>]=?|", "/", ")", "[", "0", "]", ";", "return", "comparator", "[", "op", "]", "?", "comparator", "[", "op", "]", "(", "version", ",", "n", ")", ":", "(", "version", "==", "n", "||", "n", "!==", "n", ")", ";", "}" ]
helper function which compares a version to a range
[ "helper", "function", "which", "compares", "a", "version", "to", "a", "range" ]
1ed4414e8b307cf6452918496ff48cf373ccb654
https://github.com/bbusschots-mu/mu-qunit-util/blob/1ed4414e8b307cf6452918496ff48cf373ccb654/dist/index.es.js#L78-L83
57,385
bbusschots-mu/mu-qunit-util
dist/index.es.js
getParams
function getParams(args) { var params = slice.call(args); var length = params.length; if (length === 1 && is.array(params[0])) { // support array params = params[0]; } return params; }
javascript
function getParams(args) { var params = slice.call(args); var length = params.length; if (length === 1 && is.array(params[0])) { // support array params = params[0]; } return params; }
[ "function", "getParams", "(", "args", ")", "{", "var", "params", "=", "slice", ".", "call", "(", "args", ")", ";", "var", "length", "=", "params", ".", "length", ";", "if", "(", "length", "===", "1", "&&", "is", ".", "array", "(", "params", "[", "0", "]", ")", ")", "{", "// support array", "params", "=", "params", "[", "0", "]", ";", "}", "return", "params", ";", "}" ]
helper function which extracts params from arguments
[ "helper", "function", "which", "extracts", "params", "from", "arguments" ]
1ed4414e8b307cf6452918496ff48cf373ccb654
https://github.com/bbusschots-mu/mu-qunit-util/blob/1ed4414e8b307cf6452918496ff48cf373ccb654/dist/index.es.js#L86-L93
57,386
dominictarr/header-stream
index.js
merge
function merge (a, b) { for (var k in b) a[k] = a[k] || b[k] }
javascript
function merge (a, b) { for (var k in b) a[k] = a[k] || b[k] }
[ "function", "merge", "(", "a", ",", "b", ")", "{", "for", "(", "var", "k", "in", "b", ")", "a", "[", "k", "]", "=", "a", "[", "k", "]", "||", "b", "[", "k", "]", "}" ]
the first line is header, in JSON format, with no whitespace.
[ "the", "first", "line", "is", "header", "in", "JSON", "format", "with", "no", "whitespace", "." ]
1d784d589edd11c94601ca8db93d8befd4878326
https://github.com/dominictarr/header-stream/blob/1d784d589edd11c94601ca8db93d8befd4878326/index.js#L4-L7
57,387
IonicaBizau/cross-style.js
lib/index.js
CrossStyle
function CrossStyle(input) { var uInput = UFirst(input); return [ "webkit" + uInput , "moz" + uInput , "ms" + uInput , "o" + uInput , input ] }
javascript
function CrossStyle(input) { var uInput = UFirst(input); return [ "webkit" + uInput , "moz" + uInput , "ms" + uInput , "o" + uInput , input ] }
[ "function", "CrossStyle", "(", "input", ")", "{", "var", "uInput", "=", "UFirst", "(", "input", ")", ";", "return", "[", "\"webkit\"", "+", "uInput", ",", "\"moz\"", "+", "uInput", ",", "\"ms\"", "+", "uInput", ",", "\"o\"", "+", "uInput", ",", "input", "]", "}" ]
CrossStyle Returns an array of cross-browser CSS properties for given input. @name CrossStyle @function @param {String} input The CSS property (e.g. `"transform"` or `"transformOrigin"`). @return {Array} An array of strings representing the cross-browser CSS properties for the given input.
[ "CrossStyle", "Returns", "an", "array", "of", "cross", "-", "browser", "CSS", "properties", "for", "given", "input", "." ]
f3bc8b153710168a6fd5346c35d0851bd1b02f25
https://github.com/IonicaBizau/cross-style.js/blob/f3bc8b153710168a6fd5346c35d0851bd1b02f25/lib/index.js#L13-L22
57,388
brettz9/imf
dist/index-cjs.js
IMFClass
function IMFClass(opts) { if (!(this instanceof IMFClass)) { return new IMFClass(opts); } opts = opts || {}; this.defaultNamespace = opts.defaultNamespace || ''; this.defaultSeparator = opts.defaultSeparator === undefined ? '.' : opts.defaultSeparator; this.basePath = opts.basePath || 'locales/'; this.fallbackLanguages = opts.fallbackLanguages; this.localeFileResolver = opts.localeFileResolver || function (lang) { return this.basePath + lang + '.json'; }; this.locales = opts.locales || []; this.langs = opts.langs; this.fallbackLocales = opts.fallbackLocales || []; const loadFallbacks = cb => { this.loadLocales(this.fallbackLanguages, function (...fallbackLocales) { this.fallbackLocales.push(...fallbackLocales); if (cb) { return cb(fallbackLocales); } }, true); }; if (opts.languages || opts.callback) { this.loadLocales(opts.languages, () => { const locales = Array.from(arguments); const runCallback = fallbackLocales => { if (opts.callback) { opts.callback.apply(this, [this.getFormatter(opts.namespace), this.getFormatter.bind(this), locales, fallbackLocales]); } }; if (opts.hasOwnProperty('fallbackLanguages')) { loadFallbacks(runCallback); } else { runCallback(); } }); } else if (opts.hasOwnProperty('fallbackLanguages')) { loadFallbacks(); } }
javascript
function IMFClass(opts) { if (!(this instanceof IMFClass)) { return new IMFClass(opts); } opts = opts || {}; this.defaultNamespace = opts.defaultNamespace || ''; this.defaultSeparator = opts.defaultSeparator === undefined ? '.' : opts.defaultSeparator; this.basePath = opts.basePath || 'locales/'; this.fallbackLanguages = opts.fallbackLanguages; this.localeFileResolver = opts.localeFileResolver || function (lang) { return this.basePath + lang + '.json'; }; this.locales = opts.locales || []; this.langs = opts.langs; this.fallbackLocales = opts.fallbackLocales || []; const loadFallbacks = cb => { this.loadLocales(this.fallbackLanguages, function (...fallbackLocales) { this.fallbackLocales.push(...fallbackLocales); if (cb) { return cb(fallbackLocales); } }, true); }; if (opts.languages || opts.callback) { this.loadLocales(opts.languages, () => { const locales = Array.from(arguments); const runCallback = fallbackLocales => { if (opts.callback) { opts.callback.apply(this, [this.getFormatter(opts.namespace), this.getFormatter.bind(this), locales, fallbackLocales]); } }; if (opts.hasOwnProperty('fallbackLanguages')) { loadFallbacks(runCallback); } else { runCallback(); } }); } else if (opts.hasOwnProperty('fallbackLanguages')) { loadFallbacks(); } }
[ "function", "IMFClass", "(", "opts", ")", "{", "if", "(", "!", "(", "this", "instanceof", "IMFClass", ")", ")", "{", "return", "new", "IMFClass", "(", "opts", ")", ";", "}", "opts", "=", "opts", "||", "{", "}", ";", "this", ".", "defaultNamespace", "=", "opts", ".", "defaultNamespace", "||", "''", ";", "this", ".", "defaultSeparator", "=", "opts", ".", "defaultSeparator", "===", "undefined", "?", "'.'", ":", "opts", ".", "defaultSeparator", ";", "this", ".", "basePath", "=", "opts", ".", "basePath", "||", "'locales/'", ";", "this", ".", "fallbackLanguages", "=", "opts", ".", "fallbackLanguages", ";", "this", ".", "localeFileResolver", "=", "opts", ".", "localeFileResolver", "||", "function", "(", "lang", ")", "{", "return", "this", ".", "basePath", "+", "lang", "+", "'.json'", ";", "}", ";", "this", ".", "locales", "=", "opts", ".", "locales", "||", "[", "]", ";", "this", ".", "langs", "=", "opts", ".", "langs", ";", "this", ".", "fallbackLocales", "=", "opts", ".", "fallbackLocales", "||", "[", "]", ";", "const", "loadFallbacks", "=", "cb", "=>", "{", "this", ".", "loadLocales", "(", "this", ".", "fallbackLanguages", ",", "function", "(", "...", "fallbackLocales", ")", "{", "this", ".", "fallbackLocales", ".", "push", "(", "...", "fallbackLocales", ")", ";", "if", "(", "cb", ")", "{", "return", "cb", "(", "fallbackLocales", ")", ";", "}", "}", ",", "true", ")", ";", "}", ";", "if", "(", "opts", ".", "languages", "||", "opts", ".", "callback", ")", "{", "this", ".", "loadLocales", "(", "opts", ".", "languages", ",", "(", ")", "=>", "{", "const", "locales", "=", "Array", ".", "from", "(", "arguments", ")", ";", "const", "runCallback", "=", "fallbackLocales", "=>", "{", "if", "(", "opts", ".", "callback", ")", "{", "opts", ".", "callback", ".", "apply", "(", "this", ",", "[", "this", ".", "getFormatter", "(", "opts", ".", "namespace", ")", ",", "this", ".", "getFormatter", ".", "bind", "(", "this", ")", ",", "locales", ",", "fallbackLocales", "]", ")", ";", "}", "}", ";", "if", "(", "opts", ".", "hasOwnProperty", "(", "'fallbackLanguages'", ")", ")", "{", "loadFallbacks", "(", "runCallback", ")", ";", "}", "else", "{", "runCallback", "(", ")", ";", "}", "}", ")", ";", "}", "else", "if", "(", "opts", ".", "hasOwnProperty", "(", "'fallbackLanguages'", ")", ")", "{", "loadFallbacks", "(", ")", ";", "}", "}" ]
If strawman approved, this would only be
[ "If", "strawman", "approved", "this", "would", "only", "be" ]
7c701afb770517887d937f334c240964086bf86d
https://github.com/brettz9/imf/blob/7c701afb770517887d937f334c240964086bf86d/dist/index-cjs.js#L10-L58
57,389
Nichejs/Seminarjs
private/lib/core/users.js
users
function users() { var seminarjs = this; var exports = {}; exports.list = []; /** * Add a user * @param {string} name User name * @param {Object} attributes List of attributes to be added to the user */ exports.add = function (name, attributes) { if (exports.find(name)) { return false; } else { exports.list.push(new User(name, attributes)); } }; /** * Finds users * @param {string} name User name * @return {int} Integer >-1 if the user is found, or -1 if not. */ exports.find = function (name) { var total = exports.list.length; for (var i = 0; i < total; i++) { if (exports.list[i].name == name) { return i; } } return -1; }; /** * Removes a user from the list * @param {string} name User name */ exports.remove = function (name) { var index = exports.find(name); exports.list.splice(index, 1); }; /** * Set a property for a user * @param {string} name Username * @param {String} param Parameter name * @param {String} value Parameter value */ exports.set = function (name, param, value) { var index = exports.find(name); exports.list[index][param] = value; }; /** * Get a parameter * @param {string} name User name * @param {String} param Parameter name * @return {String} Parameter value */ exports.get = function (name, param) { var index = exports.find(name); return exports.list[index][param]; }; /** * User constructor * @param {string} name User name * @param {object} attributes User properties */ function User(name, attributes) { var ret = { name: user }; return extend(ret, attributes); } return exports; }
javascript
function users() { var seminarjs = this; var exports = {}; exports.list = []; /** * Add a user * @param {string} name User name * @param {Object} attributes List of attributes to be added to the user */ exports.add = function (name, attributes) { if (exports.find(name)) { return false; } else { exports.list.push(new User(name, attributes)); } }; /** * Finds users * @param {string} name User name * @return {int} Integer >-1 if the user is found, or -1 if not. */ exports.find = function (name) { var total = exports.list.length; for (var i = 0; i < total; i++) { if (exports.list[i].name == name) { return i; } } return -1; }; /** * Removes a user from the list * @param {string} name User name */ exports.remove = function (name) { var index = exports.find(name); exports.list.splice(index, 1); }; /** * Set a property for a user * @param {string} name Username * @param {String} param Parameter name * @param {String} value Parameter value */ exports.set = function (name, param, value) { var index = exports.find(name); exports.list[index][param] = value; }; /** * Get a parameter * @param {string} name User name * @param {String} param Parameter name * @return {String} Parameter value */ exports.get = function (name, param) { var index = exports.find(name); return exports.list[index][param]; }; /** * User constructor * @param {string} name User name * @param {object} attributes User properties */ function User(name, attributes) { var ret = { name: user }; return extend(ret, attributes); } return exports; }
[ "function", "users", "(", ")", "{", "var", "seminarjs", "=", "this", ";", "var", "exports", "=", "{", "}", ";", "exports", ".", "list", "=", "[", "]", ";", "/**\n\t * Add a user\n\t * @param {string} name User name\n\t * @param {Object} attributes List of attributes to be added to the user\n\t */", "exports", ".", "add", "=", "function", "(", "name", ",", "attributes", ")", "{", "if", "(", "exports", ".", "find", "(", "name", ")", ")", "{", "return", "false", ";", "}", "else", "{", "exports", ".", "list", ".", "push", "(", "new", "User", "(", "name", ",", "attributes", ")", ")", ";", "}", "}", ";", "/**\n\t * Finds users\n\t * @param {string} name User name\n\t * @return {int}\tInteger >-1 if the user is found, or -1 if not.\n\t */", "exports", ".", "find", "=", "function", "(", "name", ")", "{", "var", "total", "=", "exports", ".", "list", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "total", ";", "i", "++", ")", "{", "if", "(", "exports", ".", "list", "[", "i", "]", ".", "name", "==", "name", ")", "{", "return", "i", ";", "}", "}", "return", "-", "1", ";", "}", ";", "/**\n\t * Removes a user from the list\n\t * @param {string} name User name\n\t */", "exports", ".", "remove", "=", "function", "(", "name", ")", "{", "var", "index", "=", "exports", ".", "find", "(", "name", ")", ";", "exports", ".", "list", ".", "splice", "(", "index", ",", "1", ")", ";", "}", ";", "/**\n\t * Set a property for a user\n\t * @param {string} name Username\n\t * @param {String} param Parameter name\n\t * @param {String} value Parameter value\n\t */", "exports", ".", "set", "=", "function", "(", "name", ",", "param", ",", "value", ")", "{", "var", "index", "=", "exports", ".", "find", "(", "name", ")", ";", "exports", ".", "list", "[", "index", "]", "[", "param", "]", "=", "value", ";", "}", ";", "/**\n\t * Get a parameter\n\t * @param {string} name User name\n\t * @param {String} param Parameter name\n\t * @return {String} Parameter value\n\t */", "exports", ".", "get", "=", "function", "(", "name", ",", "param", ")", "{", "var", "index", "=", "exports", ".", "find", "(", "name", ")", ";", "return", "exports", ".", "list", "[", "index", "]", "[", "param", "]", ";", "}", ";", "/**\n\t * User constructor\n\t * @param {string} name User name\n\t * @param {object} attributes User properties\n\t */", "function", "User", "(", "name", ",", "attributes", ")", "{", "var", "ret", "=", "{", "name", ":", "user", "}", ";", "return", "extend", "(", "ret", ",", "attributes", ")", ";", "}", "return", "exports", ";", "}" ]
User handling for Seminarjs, this should hold the logged in users at any moment, and should be shared by the contest, the chat... etc
[ "User", "handling", "for", "Seminarjs", "this", "should", "hold", "the", "logged", "in", "users", "at", "any", "moment", "and", "should", "be", "shared", "by", "the", "contest", "the", "chat", "...", "etc" ]
53c4c1d5c33ffbf6320b10f25679bf181cbf853e
https://github.com/Nichejs/Seminarjs/blob/53c4c1d5c33ffbf6320b10f25679bf181cbf853e/private/lib/core/users.js#L8-L94
57,390
getstacker/stacker-args
lib/help/formatter.js
function (parts, indent, prefix) { var lines = []; var line = []; var lineLength = !!prefix ? prefix.length - 1: indent.length - 1; parts.forEach(function (part) { if (lineLength + 1 + part.length > textWidth) { lines.push(indent + line.join(' ')); line = []; lineLength = indent.length - 1; } line.push(part); lineLength += part.length + 1; }); if (line) { lines.push(indent + line.join(' ')); } if (prefix) { lines[0] = lines[0].substr(indent.length); } return lines; }
javascript
function (parts, indent, prefix) { var lines = []; var line = []; var lineLength = !!prefix ? prefix.length - 1: indent.length - 1; parts.forEach(function (part) { if (lineLength + 1 + part.length > textWidth) { lines.push(indent + line.join(' ')); line = []; lineLength = indent.length - 1; } line.push(part); lineLength += part.length + 1; }); if (line) { lines.push(indent + line.join(' ')); } if (prefix) { lines[0] = lines[0].substr(indent.length); } return lines; }
[ "function", "(", "parts", ",", "indent", ",", "prefix", ")", "{", "var", "lines", "=", "[", "]", ";", "var", "line", "=", "[", "]", ";", "var", "lineLength", "=", "!", "!", "prefix", "?", "prefix", ".", "length", "-", "1", ":", "indent", ".", "length", "-", "1", ";", "parts", ".", "forEach", "(", "function", "(", "part", ")", "{", "if", "(", "lineLength", "+", "1", "+", "part", ".", "length", ">", "textWidth", ")", "{", "lines", ".", "push", "(", "indent", "+", "line", ".", "join", "(", "' '", ")", ")", ";", "line", "=", "[", "]", ";", "lineLength", "=", "indent", ".", "length", "-", "1", ";", "}", "line", ".", "push", "(", "part", ")", ";", "lineLength", "+=", "part", ".", "length", "+", "1", ";", "}", ")", ";", "if", "(", "line", ")", "{", "lines", ".", "push", "(", "indent", "+", "line", ".", "join", "(", "' '", ")", ")", ";", "}", "if", "(", "prefix", ")", "{", "lines", "[", "0", "]", "=", "lines", "[", "0", "]", ".", "substr", "(", "indent", ".", "length", ")", ";", "}", "return", "lines", ";", "}" ]
helper for wrapping lines
[ "helper", "for", "wrapping", "lines" ]
38282619b67274c0524507abc992ab03a37f8dcb
https://github.com/getstacker/stacker-args/blob/38282619b67274c0524507abc992ab03a37f8dcb/lib/help/formatter.js#L372-L395
57,391
phun-ky/patsy
lib/proxy/index.js
function(cfg){ var self = this; var route_opts; patsy.scripture.print('[Patsy]'.yellow + ': Here\'s the proxy my King!\n'); var _getHeaders = function(path, local_headers){ var global_headers = {}; if(typeof cfg.proxy.options.headers !== 'undefined' && typeof cfg.proxy.options.headers === 'object'){ global_headers = xtend({},cfg.proxy.options.headers); } if(typeof local_headers === 'undefined'){ local_headers = {}; } try{ return xtend(global_headers, local_headers); } catch(e){ if(opts.verbose){ utils.fail('Could not extend headers!'); console.log(global_headers, local_headers, e); } else { utils.fail(); } } }; var gotMatch = false, // Find match method _findMatch = function(url, resource){ gotMatch = false; var parsed_resource_pass; if(typeof resource === 'array' || typeof resource === 'object'){ resource.forEach(function(route){ parsed_resource_pass = node_url.parse(route.pass); // First, turn the URL into a regex. // NOTE: Turning user input directly into a Regular Expression is NOT SAFE. var matchPath = new RegExp(route.path.replace(/\//, '\\/')); var matchedPath = matchPath.exec(url); //if(url.match(route.path) && (url !== '/' && route.path.indexOf(url) !== -1)){ if(matchedPath && matchedPath[0] !== '/'){ route_opts = { route : { host: parsed_resource_pass.hostname, port: parsed_resource_pass.port }, from_path : route.path, url : url.replace(route.path, parsed_resource_pass.pathname), headers: _getHeaders(route.path, route.headers || {}) }; //console.log(matchedPath[0],url, route_opts.url, route.path); gotMatch = true; } }); } else if(typeof resource === 'string'){ gotMatch = false; parsed_resource_pass = node_url.parse(resource); if(url.match(resource) && resource.indexOf(url) !== -1){ route_opts = { route : { host: parsed_resource_pass.hostname, port: parsed_resource_pass.port }, url : url, headers: cfg.proxy.options.headers || {} }; gotMatch = true; } } }; try{ // // Create a proxy server with custom application logic // var proxyServer = httpProxy.createServer(function (req, res, proxy) { // // Put your custom server logic here // _findMatch(req.url, cfg.proxy.resources); var _opts = typeof route_opts === 'object' ? route_opts : false; var _route; if(opts.verbose){ util.print('>>'.cyan + ' Setting up route for ' + req.url.cyan + '...'); } if(_opts && gotMatch){ _route = _opts.route; req.url = _opts.url; if(opts.verbose){ utils.ok(); } if(typeof _route !== 'object'){ throw new Error('Required object for proxy is not valid'); } // Set headers // Headers are overwritten like this: // Request headers are overwritten by global headers // Global headers are overwritten by local headers req.headers = xtend(req.headers,_opts.headers || {}); // Set headers with the path we're forwarding from req.headers = xtend(req.headers, { "x-forwarded-path" : _opts.from_path, "x-original-url" : req.url }); if(opts.verbose){ util.print('>>'.cyan + ' Guiding ' + req.url.cyan + ' to ' + _route.host.inverse.magenta + ':' + _route.port.inverse.magenta +'...'); } try{ // Proxy the request proxy.proxyRequest(req, res, _route); } catch( error ){ if(opts.verbose){ utils.fail('Could not proxy given URL when we have match: ' + req.url.cyan); console.log(error, 'Headers',req.headers,'Options',_opts); } else { utils.fail(); } res.writeHead(500, { 'Content-Type': 'text/plain' }); res.write('Could not proxy given URL: ' + req.url +'\n' + 'Given route: ' + JSON.stringify(_route || 'no route found', true, 2) +'\n' + 'Headers:' + JSON.stringify(req.headers, true, 2) +'\n' + 'Given options: ' + JSON.stringify(_opts, true, 2)); res.end(); } if(opts.verbose){ utils.ok(); } } else { // No match found in proxy table for incoming URL, try relay the request to the local webserver instead try{ util.print("WARN".yellow + '\n'); if(opts.verbose){ util.print('>> '.yellow + ' No match found, relaying to: ' + String(cfg.project.environment.host).inverse.magenta +':'+ String(cfg.project.environment.port).inverse.magenta + '...' ); } _route = { host: cfg.project.environment.host, port: cfg.project.environment.port }; // Set headers // Headers are overwritten like this: // Request headers are overwritten by global headers // Global headers are overwritten by local headers req.headers = xtend(req.headers,cfg.proxy.options.headers || {}); // Proxy the request proxy.proxyRequest(req, res, _route); if(opts.verbose){ utils.ok(); } } catch(error){ if(opts.verbose){ utils.fail('Could not proxy given URL with no match found: ' + req.url.cyan); console.log(error, 'Headers',req.headers,'Options',_opts); } else { utils.fail(); } res.writeHead(404, { 'Content-Type': 'text/plain' }); res.write('Could not proxy given URL: ' + req.url +'\n' + 'Headers:' + JSON.stringify(req.headers, true, 2) +'\n' + 'Given options: ' + JSON.stringify(_opts, true, 2)); res.end(); } } // Clean up vars }); proxyServer.listen(cfg.proxy.options.port || 80); proxyServer.proxy.on('proxyError', function (err, req, res) { /*if(typeof req.headers['x-forwarded-path'] !== 'undefined'){ self.mock(res, req); } else {*/ res.writeHead(500, { 'Content-Type': 'text/plain' }); res.write('Something went wrong. And we are reporting a custom error message.') res.write('Could not proxy given URL: ' + req.url +'\n' + 'Headers:' + JSON.stringify(req.headers, true, 2) +'\n'); res.end(); //} }); } catch(e){ util.puts('>> FAIL'.red + ': Could not create proxy server',e); } }
javascript
function(cfg){ var self = this; var route_opts; patsy.scripture.print('[Patsy]'.yellow + ': Here\'s the proxy my King!\n'); var _getHeaders = function(path, local_headers){ var global_headers = {}; if(typeof cfg.proxy.options.headers !== 'undefined' && typeof cfg.proxy.options.headers === 'object'){ global_headers = xtend({},cfg.proxy.options.headers); } if(typeof local_headers === 'undefined'){ local_headers = {}; } try{ return xtend(global_headers, local_headers); } catch(e){ if(opts.verbose){ utils.fail('Could not extend headers!'); console.log(global_headers, local_headers, e); } else { utils.fail(); } } }; var gotMatch = false, // Find match method _findMatch = function(url, resource){ gotMatch = false; var parsed_resource_pass; if(typeof resource === 'array' || typeof resource === 'object'){ resource.forEach(function(route){ parsed_resource_pass = node_url.parse(route.pass); // First, turn the URL into a regex. // NOTE: Turning user input directly into a Regular Expression is NOT SAFE. var matchPath = new RegExp(route.path.replace(/\//, '\\/')); var matchedPath = matchPath.exec(url); //if(url.match(route.path) && (url !== '/' && route.path.indexOf(url) !== -1)){ if(matchedPath && matchedPath[0] !== '/'){ route_opts = { route : { host: parsed_resource_pass.hostname, port: parsed_resource_pass.port }, from_path : route.path, url : url.replace(route.path, parsed_resource_pass.pathname), headers: _getHeaders(route.path, route.headers || {}) }; //console.log(matchedPath[0],url, route_opts.url, route.path); gotMatch = true; } }); } else if(typeof resource === 'string'){ gotMatch = false; parsed_resource_pass = node_url.parse(resource); if(url.match(resource) && resource.indexOf(url) !== -1){ route_opts = { route : { host: parsed_resource_pass.hostname, port: parsed_resource_pass.port }, url : url, headers: cfg.proxy.options.headers || {} }; gotMatch = true; } } }; try{ // // Create a proxy server with custom application logic // var proxyServer = httpProxy.createServer(function (req, res, proxy) { // // Put your custom server logic here // _findMatch(req.url, cfg.proxy.resources); var _opts = typeof route_opts === 'object' ? route_opts : false; var _route; if(opts.verbose){ util.print('>>'.cyan + ' Setting up route for ' + req.url.cyan + '...'); } if(_opts && gotMatch){ _route = _opts.route; req.url = _opts.url; if(opts.verbose){ utils.ok(); } if(typeof _route !== 'object'){ throw new Error('Required object for proxy is not valid'); } // Set headers // Headers are overwritten like this: // Request headers are overwritten by global headers // Global headers are overwritten by local headers req.headers = xtend(req.headers,_opts.headers || {}); // Set headers with the path we're forwarding from req.headers = xtend(req.headers, { "x-forwarded-path" : _opts.from_path, "x-original-url" : req.url }); if(opts.verbose){ util.print('>>'.cyan + ' Guiding ' + req.url.cyan + ' to ' + _route.host.inverse.magenta + ':' + _route.port.inverse.magenta +'...'); } try{ // Proxy the request proxy.proxyRequest(req, res, _route); } catch( error ){ if(opts.verbose){ utils.fail('Could not proxy given URL when we have match: ' + req.url.cyan); console.log(error, 'Headers',req.headers,'Options',_opts); } else { utils.fail(); } res.writeHead(500, { 'Content-Type': 'text/plain' }); res.write('Could not proxy given URL: ' + req.url +'\n' + 'Given route: ' + JSON.stringify(_route || 'no route found', true, 2) +'\n' + 'Headers:' + JSON.stringify(req.headers, true, 2) +'\n' + 'Given options: ' + JSON.stringify(_opts, true, 2)); res.end(); } if(opts.verbose){ utils.ok(); } } else { // No match found in proxy table for incoming URL, try relay the request to the local webserver instead try{ util.print("WARN".yellow + '\n'); if(opts.verbose){ util.print('>> '.yellow + ' No match found, relaying to: ' + String(cfg.project.environment.host).inverse.magenta +':'+ String(cfg.project.environment.port).inverse.magenta + '...' ); } _route = { host: cfg.project.environment.host, port: cfg.project.environment.port }; // Set headers // Headers are overwritten like this: // Request headers are overwritten by global headers // Global headers are overwritten by local headers req.headers = xtend(req.headers,cfg.proxy.options.headers || {}); // Proxy the request proxy.proxyRequest(req, res, _route); if(opts.verbose){ utils.ok(); } } catch(error){ if(opts.verbose){ utils.fail('Could not proxy given URL with no match found: ' + req.url.cyan); console.log(error, 'Headers',req.headers,'Options',_opts); } else { utils.fail(); } res.writeHead(404, { 'Content-Type': 'text/plain' }); res.write('Could not proxy given URL: ' + req.url +'\n' + 'Headers:' + JSON.stringify(req.headers, true, 2) +'\n' + 'Given options: ' + JSON.stringify(_opts, true, 2)); res.end(); } } // Clean up vars }); proxyServer.listen(cfg.proxy.options.port || 80); proxyServer.proxy.on('proxyError', function (err, req, res) { /*if(typeof req.headers['x-forwarded-path'] !== 'undefined'){ self.mock(res, req); } else {*/ res.writeHead(500, { 'Content-Type': 'text/plain' }); res.write('Something went wrong. And we are reporting a custom error message.') res.write('Could not proxy given URL: ' + req.url +'\n' + 'Headers:' + JSON.stringify(req.headers, true, 2) +'\n'); res.end(); //} }); } catch(e){ util.puts('>> FAIL'.red + ': Could not create proxy server',e); } }
[ "function", "(", "cfg", ")", "{", "var", "self", "=", "this", ";", "var", "route_opts", ";", "patsy", ".", "scripture", ".", "print", "(", "'[Patsy]'", ".", "yellow", "+", "': Here\\'s the proxy my King!\\n'", ")", ";", "var", "_getHeaders", "=", "function", "(", "path", ",", "local_headers", ")", "{", "var", "global_headers", "=", "{", "}", ";", "if", "(", "typeof", "cfg", ".", "proxy", ".", "options", ".", "headers", "!==", "'undefined'", "&&", "typeof", "cfg", ".", "proxy", ".", "options", ".", "headers", "===", "'object'", ")", "{", "global_headers", "=", "xtend", "(", "{", "}", ",", "cfg", ".", "proxy", ".", "options", ".", "headers", ")", ";", "}", "if", "(", "typeof", "local_headers", "===", "'undefined'", ")", "{", "local_headers", "=", "{", "}", ";", "}", "try", "{", "return", "xtend", "(", "global_headers", ",", "local_headers", ")", ";", "}", "catch", "(", "e", ")", "{", "if", "(", "opts", ".", "verbose", ")", "{", "utils", ".", "fail", "(", "'Could not extend headers!'", ")", ";", "console", ".", "log", "(", "global_headers", ",", "local_headers", ",", "e", ")", ";", "}", "else", "{", "utils", ".", "fail", "(", ")", ";", "}", "}", "}", ";", "var", "gotMatch", "=", "false", ",", "// Find match method", "_findMatch", "=", "function", "(", "url", ",", "resource", ")", "{", "gotMatch", "=", "false", ";", "var", "parsed_resource_pass", ";", "if", "(", "typeof", "resource", "===", "'array'", "||", "typeof", "resource", "===", "'object'", ")", "{", "resource", ".", "forEach", "(", "function", "(", "route", ")", "{", "parsed_resource_pass", "=", "node_url", ".", "parse", "(", "route", ".", "pass", ")", ";", "// First, turn the URL into a regex.", "// NOTE: Turning user input directly into a Regular Expression is NOT SAFE.", "var", "matchPath", "=", "new", "RegExp", "(", "route", ".", "path", ".", "replace", "(", "/", "\\/", "/", ",", "'\\\\/'", ")", ")", ";", "var", "matchedPath", "=", "matchPath", ".", "exec", "(", "url", ")", ";", "//if(url.match(route.path) && (url !== '/' && route.path.indexOf(url) !== -1)){", "if", "(", "matchedPath", "&&", "matchedPath", "[", "0", "]", "!==", "'/'", ")", "{", "route_opts", "=", "{", "route", ":", "{", "host", ":", "parsed_resource_pass", ".", "hostname", ",", "port", ":", "parsed_resource_pass", ".", "port", "}", ",", "from_path", ":", "route", ".", "path", ",", "url", ":", "url", ".", "replace", "(", "route", ".", "path", ",", "parsed_resource_pass", ".", "pathname", ")", ",", "headers", ":", "_getHeaders", "(", "route", ".", "path", ",", "route", ".", "headers", "||", "{", "}", ")", "}", ";", "//console.log(matchedPath[0],url, route_opts.url, route.path);", "gotMatch", "=", "true", ";", "}", "}", ")", ";", "}", "else", "if", "(", "typeof", "resource", "===", "'string'", ")", "{", "gotMatch", "=", "false", ";", "parsed_resource_pass", "=", "node_url", ".", "parse", "(", "resource", ")", ";", "if", "(", "url", ".", "match", "(", "resource", ")", "&&", "resource", ".", "indexOf", "(", "url", ")", "!==", "-", "1", ")", "{", "route_opts", "=", "{", "route", ":", "{", "host", ":", "parsed_resource_pass", ".", "hostname", ",", "port", ":", "parsed_resource_pass", ".", "port", "}", ",", "url", ":", "url", ",", "headers", ":", "cfg", ".", "proxy", ".", "options", ".", "headers", "||", "{", "}", "}", ";", "gotMatch", "=", "true", ";", "}", "}", "}", ";", "try", "{", "//", "// Create a proxy server with custom application logic", "//", "var", "proxyServer", "=", "httpProxy", ".", "createServer", "(", "function", "(", "req", ",", "res", ",", "proxy", ")", "{", "//", "// Put your custom server logic here", "//", "_findMatch", "(", "req", ".", "url", ",", "cfg", ".", "proxy", ".", "resources", ")", ";", "var", "_opts", "=", "typeof", "route_opts", "===", "'object'", "?", "route_opts", ":", "false", ";", "var", "_route", ";", "if", "(", "opts", ".", "verbose", ")", "{", "util", ".", "print", "(", "'>>'", ".", "cyan", "+", "' Setting up route for '", "+", "req", ".", "url", ".", "cyan", "+", "'...'", ")", ";", "}", "if", "(", "_opts", "&&", "gotMatch", ")", "{", "_route", "=", "_opts", ".", "route", ";", "req", ".", "url", "=", "_opts", ".", "url", ";", "if", "(", "opts", ".", "verbose", ")", "{", "utils", ".", "ok", "(", ")", ";", "}", "if", "(", "typeof", "_route", "!==", "'object'", ")", "{", "throw", "new", "Error", "(", "'Required object for proxy is not valid'", ")", ";", "}", "// Set headers", "// Headers are overwritten like this:", "// Request headers are overwritten by global headers", "// Global headers are overwritten by local headers", "req", ".", "headers", "=", "xtend", "(", "req", ".", "headers", ",", "_opts", ".", "headers", "||", "{", "}", ")", ";", "// Set headers with the path we're forwarding from", "req", ".", "headers", "=", "xtend", "(", "req", ".", "headers", ",", "{", "\"x-forwarded-path\"", ":", "_opts", ".", "from_path", ",", "\"x-original-url\"", ":", "req", ".", "url", "}", ")", ";", "if", "(", "opts", ".", "verbose", ")", "{", "util", ".", "print", "(", "'>>'", ".", "cyan", "+", "' Guiding '", "+", "req", ".", "url", ".", "cyan", "+", "' to '", "+", "_route", ".", "host", ".", "inverse", ".", "magenta", "+", "':'", "+", "_route", ".", "port", ".", "inverse", ".", "magenta", "+", "'...'", ")", ";", "}", "try", "{", "// Proxy the request", "proxy", ".", "proxyRequest", "(", "req", ",", "res", ",", "_route", ")", ";", "}", "catch", "(", "error", ")", "{", "if", "(", "opts", ".", "verbose", ")", "{", "utils", ".", "fail", "(", "'Could not proxy given URL when we have match: '", "+", "req", ".", "url", ".", "cyan", ")", ";", "console", ".", "log", "(", "error", ",", "'Headers'", ",", "req", ".", "headers", ",", "'Options'", ",", "_opts", ")", ";", "}", "else", "{", "utils", ".", "fail", "(", ")", ";", "}", "res", ".", "writeHead", "(", "500", ",", "{", "'Content-Type'", ":", "'text/plain'", "}", ")", ";", "res", ".", "write", "(", "'Could not proxy given URL: '", "+", "req", ".", "url", "+", "'\\n'", "+", "'Given route: '", "+", "JSON", ".", "stringify", "(", "_route", "||", "'no route found'", ",", "true", ",", "2", ")", "+", "'\\n'", "+", "'Headers:'", "+", "JSON", ".", "stringify", "(", "req", ".", "headers", ",", "true", ",", "2", ")", "+", "'\\n'", "+", "'Given options: '", "+", "JSON", ".", "stringify", "(", "_opts", ",", "true", ",", "2", ")", ")", ";", "res", ".", "end", "(", ")", ";", "}", "if", "(", "opts", ".", "verbose", ")", "{", "utils", ".", "ok", "(", ")", ";", "}", "}", "else", "{", "// No match found in proxy table for incoming URL, try relay the request to the local webserver instead", "try", "{", "util", ".", "print", "(", "\"WARN\"", ".", "yellow", "+", "'\\n'", ")", ";", "if", "(", "opts", ".", "verbose", ")", "{", "util", ".", "print", "(", "'>> '", ".", "yellow", "+", "' No match found, relaying to: '", "+", "String", "(", "cfg", ".", "project", ".", "environment", ".", "host", ")", ".", "inverse", ".", "magenta", "+", "':'", "+", "String", "(", "cfg", ".", "project", ".", "environment", ".", "port", ")", ".", "inverse", ".", "magenta", "+", "'...'", ")", ";", "}", "_route", "=", "{", "host", ":", "cfg", ".", "project", ".", "environment", ".", "host", ",", "port", ":", "cfg", ".", "project", ".", "environment", ".", "port", "}", ";", "// Set headers", "// Headers are overwritten like this:", "// Request headers are overwritten by global headers", "// Global headers are overwritten by local headers", "req", ".", "headers", "=", "xtend", "(", "req", ".", "headers", ",", "cfg", ".", "proxy", ".", "options", ".", "headers", "||", "{", "}", ")", ";", "// Proxy the request", "proxy", ".", "proxyRequest", "(", "req", ",", "res", ",", "_route", ")", ";", "if", "(", "opts", ".", "verbose", ")", "{", "utils", ".", "ok", "(", ")", ";", "}", "}", "catch", "(", "error", ")", "{", "if", "(", "opts", ".", "verbose", ")", "{", "utils", ".", "fail", "(", "'Could not proxy given URL with no match found: '", "+", "req", ".", "url", ".", "cyan", ")", ";", "console", ".", "log", "(", "error", ",", "'Headers'", ",", "req", ".", "headers", ",", "'Options'", ",", "_opts", ")", ";", "}", "else", "{", "utils", ".", "fail", "(", ")", ";", "}", "res", ".", "writeHead", "(", "404", ",", "{", "'Content-Type'", ":", "'text/plain'", "}", ")", ";", "res", ".", "write", "(", "'Could not proxy given URL: '", "+", "req", ".", "url", "+", "'\\n'", "+", "'Headers:'", "+", "JSON", ".", "stringify", "(", "req", ".", "headers", ",", "true", ",", "2", ")", "+", "'\\n'", "+", "'Given options: '", "+", "JSON", ".", "stringify", "(", "_opts", ",", "true", ",", "2", ")", ")", ";", "res", ".", "end", "(", ")", ";", "}", "}", "// Clean up vars", "}", ")", ";", "proxyServer", ".", "listen", "(", "cfg", ".", "proxy", ".", "options", ".", "port", "||", "80", ")", ";", "proxyServer", ".", "proxy", ".", "on", "(", "'proxyError'", ",", "function", "(", "err", ",", "req", ",", "res", ")", "{", "/*if(typeof req.headers['x-forwarded-path'] !== 'undefined'){\n\n self.mock(res, req);\n\n } else {*/", "res", ".", "writeHead", "(", "500", ",", "{", "'Content-Type'", ":", "'text/plain'", "}", ")", ";", "res", ".", "write", "(", "'Something went wrong. And we are reporting a custom error message.'", ")", "res", ".", "write", "(", "'Could not proxy given URL: '", "+", "req", ".", "url", "+", "'\\n'", "+", "'Headers:'", "+", "JSON", ".", "stringify", "(", "req", ".", "headers", ",", "true", ",", "2", ")", "+", "'\\n'", ")", ";", "res", ".", "end", "(", ")", ";", "//}", "}", ")", ";", "}", "catch", "(", "e", ")", "{", "util", ".", "puts", "(", "'>> FAIL'", ".", "red", "+", "': Could not create proxy server'", ",", "e", ")", ";", "}", "}" ]
The purpose of this method is to start the proxy server and route API urls from the patsy config.proxy.resources object
[ "The", "purpose", "of", "this", "method", "is", "to", "start", "the", "proxy", "server", "and", "route", "API", "urls", "from", "the", "patsy", "config", ".", "proxy", ".", "resources", "object" ]
b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5
https://github.com/phun-ky/patsy/blob/b2bf3e6c72e17c38d9b2cf2fa4306478fc3858a5/lib/proxy/index.js#L111-L379
57,392
melvincarvalho/rdf-shell
lib/put.js
put
function put(argv, callback) { if (!argv[2]) { console.error("url is required"); console.error("Usage : put <url> <data>"); process.exit(-1); } if (!argv[3]) { console.error("data is required"); console.error("Usage : put <url> <data>"); process.exit(-1); } util.put(argv[2], argv[3], function(err, val, uri) { if (!err) { console.log('PUT to : ' + argv[2]); } }); }
javascript
function put(argv, callback) { if (!argv[2]) { console.error("url is required"); console.error("Usage : put <url> <data>"); process.exit(-1); } if (!argv[3]) { console.error("data is required"); console.error("Usage : put <url> <data>"); process.exit(-1); } util.put(argv[2], argv[3], function(err, val, uri) { if (!err) { console.log('PUT to : ' + argv[2]); } }); }
[ "function", "put", "(", "argv", ",", "callback", ")", "{", "if", "(", "!", "argv", "[", "2", "]", ")", "{", "console", ".", "error", "(", "\"url is required\"", ")", ";", "console", ".", "error", "(", "\"Usage : put <url> <data>\"", ")", ";", "process", ".", "exit", "(", "-", "1", ")", ";", "}", "if", "(", "!", "argv", "[", "3", "]", ")", "{", "console", ".", "error", "(", "\"data is required\"", ")", ";", "console", ".", "error", "(", "\"Usage : put <url> <data>\"", ")", ";", "process", ".", "exit", "(", "-", "1", ")", ";", "}", "util", ".", "put", "(", "argv", "[", "2", "]", ",", "argv", "[", "3", "]", ",", "function", "(", "err", ",", "val", ",", "uri", ")", "{", "if", "(", "!", "err", ")", "{", "console", ".", "log", "(", "'PUT to : '", "+", "argv", "[", "2", "]", ")", ";", "}", "}", ")", ";", "}" ]
put gets list of files for a given container @param {String} argv[2] url @param {String} argv[3] data @callback {bin~cb} callback
[ "put", "gets", "list", "of", "files", "for", "a", "given", "container" ]
bf2015f6f333855e69a18ce3ec9e917bbddfb425
https://github.com/melvincarvalho/rdf-shell/blob/bf2015f6f333855e69a18ce3ec9e917bbddfb425/lib/put.js#L12-L28
57,393
MomsFriendlyDevCo/mfdc-email
index.js
init
function init() { // Locate config if we dont have one {{{ if (_.isUndefined(appConfig)) { appConfigLocations.forEach(function(key) { if (_.has(global, key)) { appConfig = _.get(global, key); return false; } }); if (_.isUndefined(appConfig)) throw new Error('Cannot find email config in', appConfigLocations); } // }}} this.config = { // Reset basics from: appConfig.email.from, to: appConfig.email.to, subject: appConfig.email.subject || '', cc: appConfig.email.cc || [], bcc: appConfig.email.bcc || [], }; // Work out mail transport {{{ if (appConfig.email.enabled) { switch (appConfig.email.method) { case 'mailgun': if ( /^https?:\/\//.test(appConfig.mailgun.domain) || /mailgun/.test(appConfig.mailgun.domain) ) throw new Error("Mailgun domain should not contain 'http(s)://' prefix or mailgun. Should resemble the domain name e.g. 'acme.com'"); transporter = nodemailer.createTransport(nodemailerMailgun({ auth: { api_key: appConfig.mailgun.apiKey, domain: appConfig.mailgun.domain, }, })); break case 'sendmail': transporter = nodemailer.createTransport(nodemailerSendmail()); break; default: next('Unknown mail transport method: ' + appConfig.email.method); } } // }}} return this; }
javascript
function init() { // Locate config if we dont have one {{{ if (_.isUndefined(appConfig)) { appConfigLocations.forEach(function(key) { if (_.has(global, key)) { appConfig = _.get(global, key); return false; } }); if (_.isUndefined(appConfig)) throw new Error('Cannot find email config in', appConfigLocations); } // }}} this.config = { // Reset basics from: appConfig.email.from, to: appConfig.email.to, subject: appConfig.email.subject || '', cc: appConfig.email.cc || [], bcc: appConfig.email.bcc || [], }; // Work out mail transport {{{ if (appConfig.email.enabled) { switch (appConfig.email.method) { case 'mailgun': if ( /^https?:\/\//.test(appConfig.mailgun.domain) || /mailgun/.test(appConfig.mailgun.domain) ) throw new Error("Mailgun domain should not contain 'http(s)://' prefix or mailgun. Should resemble the domain name e.g. 'acme.com'"); transporter = nodemailer.createTransport(nodemailerMailgun({ auth: { api_key: appConfig.mailgun.apiKey, domain: appConfig.mailgun.domain, }, })); break case 'sendmail': transporter = nodemailer.createTransport(nodemailerSendmail()); break; default: next('Unknown mail transport method: ' + appConfig.email.method); } } // }}} return this; }
[ "function", "init", "(", ")", "{", "// Locate config if we dont have one {{{", "if", "(", "_", ".", "isUndefined", "(", "appConfig", ")", ")", "{", "appConfigLocations", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "_", ".", "has", "(", "global", ",", "key", ")", ")", "{", "appConfig", "=", "_", ".", "get", "(", "global", ",", "key", ")", ";", "return", "false", ";", "}", "}", ")", ";", "if", "(", "_", ".", "isUndefined", "(", "appConfig", ")", ")", "throw", "new", "Error", "(", "'Cannot find email config in'", ",", "appConfigLocations", ")", ";", "}", "// }}}", "this", ".", "config", "=", "{", "// Reset basics", "from", ":", "appConfig", ".", "email", ".", "from", ",", "to", ":", "appConfig", ".", "email", ".", "to", ",", "subject", ":", "appConfig", ".", "email", ".", "subject", "||", "''", ",", "cc", ":", "appConfig", ".", "email", ".", "cc", "||", "[", "]", ",", "bcc", ":", "appConfig", ".", "email", ".", "bcc", "||", "[", "]", ",", "}", ";", "// Work out mail transport {{{", "if", "(", "appConfig", ".", "email", ".", "enabled", ")", "{", "switch", "(", "appConfig", ".", "email", ".", "method", ")", "{", "case", "'mailgun'", ":", "if", "(", "/", "^https?:\\/\\/", "/", ".", "test", "(", "appConfig", ".", "mailgun", ".", "domain", ")", "||", "/", "mailgun", "/", ".", "test", "(", "appConfig", ".", "mailgun", ".", "domain", ")", ")", "throw", "new", "Error", "(", "\"Mailgun domain should not contain 'http(s)://' prefix or mailgun. Should resemble the domain name e.g. 'acme.com'\"", ")", ";", "transporter", "=", "nodemailer", ".", "createTransport", "(", "nodemailerMailgun", "(", "{", "auth", ":", "{", "api_key", ":", "appConfig", ".", "mailgun", ".", "apiKey", ",", "domain", ":", "appConfig", ".", "mailgun", ".", "domain", ",", "}", ",", "}", ")", ")", ";", "break", "case", "'sendmail'", ":", "transporter", "=", "nodemailer", ".", "createTransport", "(", "nodemailerSendmail", "(", ")", ")", ";", "break", ";", "default", ":", "next", "(", "'Unknown mail transport method: '", "+", "appConfig", ".", "email", ".", "method", ")", ";", "}", "}", "// }}}", "return", "this", ";", "}" ]
Array of places to look for config Is expected to contain at least a 'email' object and possibly 'mailgun' Initalize the emailer If this is called multiple times it restarts the mail transport @return {Object} This chainable object
[ "Array", "of", "places", "to", "look", "for", "config", "Is", "expected", "to", "contain", "at", "least", "a", "email", "object", "and", "possibly", "mailgun", "Initalize", "the", "emailer", "If", "this", "is", "called", "multiple", "times", "it", "restarts", "the", "mail", "transport" ]
95cfc411d4f42cd5ddd446979b7c443ded87b93f
https://github.com/MomsFriendlyDevCo/mfdc-email/blob/95cfc411d4f42cd5ddd446979b7c443ded87b93f/index.js#L26-L73
57,394
widgetworks/nopt-grunt-fix
index.js
parseOptions
function parseOptions(nopt, optlist){ var params = getParams(optlist); var parsedOptions = nopt(params.known, params.aliases, process.argv, 2); initArrays(optlist, parsedOptions); return parsedOptions; }
javascript
function parseOptions(nopt, optlist){ var params = getParams(optlist); var parsedOptions = nopt(params.known, params.aliases, process.argv, 2); initArrays(optlist, parsedOptions); return parsedOptions; }
[ "function", "parseOptions", "(", "nopt", ",", "optlist", ")", "{", "var", "params", "=", "getParams", "(", "optlist", ")", ";", "var", "parsedOptions", "=", "nopt", "(", "params", ".", "known", ",", "params", ".", "aliases", ",", "process", ".", "argv", ",", "2", ")", ";", "initArrays", "(", "optlist", ",", "parsedOptions", ")", ";", "return", "parsedOptions", ";", "}" ]
Normalise the parameters and then parse them.
[ "Normalise", "the", "parameters", "and", "then", "parse", "them", "." ]
44017cb96567763124d42ab5819e71bd98d98465
https://github.com/widgetworks/nopt-grunt-fix/blob/44017cb96567763124d42ab5819e71bd98d98465/index.js#L23-L29
57,395
widgetworks/nopt-grunt-fix
index.js
resetOptions
function resetOptions(grunt, parsedOptions){ for (var i in parsedOptions){ if (parsedOptions.hasOwnProperty(i) && i != 'argv'){ grunt.option(i, parsedOptions[i]); } } }
javascript
function resetOptions(grunt, parsedOptions){ for (var i in parsedOptions){ if (parsedOptions.hasOwnProperty(i) && i != 'argv'){ grunt.option(i, parsedOptions[i]); } } }
[ "function", "resetOptions", "(", "grunt", ",", "parsedOptions", ")", "{", "for", "(", "var", "i", "in", "parsedOptions", ")", "{", "if", "(", "parsedOptions", ".", "hasOwnProperty", "(", "i", ")", "&&", "i", "!=", "'argv'", ")", "{", "grunt", ".", "option", "(", "i", ",", "parsedOptions", "[", "i", "]", ")", ";", "}", "}", "}" ]
Reassign the options on the Grunt instance.
[ "Reassign", "the", "options", "on", "the", "Grunt", "instance", "." ]
44017cb96567763124d42ab5819e71bd98d98465
https://github.com/widgetworks/nopt-grunt-fix/blob/44017cb96567763124d42ab5819e71bd98d98465/index.js#L33-L39
57,396
widgetworks/nopt-grunt-fix
index.js
getParams
function getParams(optlist){ var aliases = {}; var known = {}; Object.keys(optlist).forEach(function(key) { var short = optlist[key].short; if (short) { aliases[short] = '--' + key; } known[key] = optlist[key].type; }); return { known: known, aliases: aliases } }
javascript
function getParams(optlist){ var aliases = {}; var known = {}; Object.keys(optlist).forEach(function(key) { var short = optlist[key].short; if (short) { aliases[short] = '--' + key; } known[key] = optlist[key].type; }); return { known: known, aliases: aliases } }
[ "function", "getParams", "(", "optlist", ")", "{", "var", "aliases", "=", "{", "}", ";", "var", "known", "=", "{", "}", ";", "Object", ".", "keys", "(", "optlist", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "var", "short", "=", "optlist", "[", "key", "]", ".", "short", ";", "if", "(", "short", ")", "{", "aliases", "[", "short", "]", "=", "'--'", "+", "key", ";", "}", "known", "[", "key", "]", "=", "optlist", "[", "key", "]", ".", "type", ";", "}", ")", ";", "return", "{", "known", ":", "known", ",", "aliases", ":", "aliases", "}", "}" ]
Parse `optlist` into a form that nopt can handle.
[ "Parse", "optlist", "into", "a", "form", "that", "nopt", "can", "handle", "." ]
44017cb96567763124d42ab5819e71bd98d98465
https://github.com/widgetworks/nopt-grunt-fix/blob/44017cb96567763124d42ab5819e71bd98d98465/index.js#L43-L59
57,397
widgetworks/nopt-grunt-fix
index.js
initArrays
function initArrays(optlist, parsedOptions){ Object.keys(optlist).forEach(function(key) { if (optlist[key].type === Array && !(key in parsedOptions)) { parsedOptions[key] = []; } }); }
javascript
function initArrays(optlist, parsedOptions){ Object.keys(optlist).forEach(function(key) { if (optlist[key].type === Array && !(key in parsedOptions)) { parsedOptions[key] = []; } }); }
[ "function", "initArrays", "(", "optlist", ",", "parsedOptions", ")", "{", "Object", ".", "keys", "(", "optlist", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "optlist", "[", "key", "]", ".", "type", "===", "Array", "&&", "!", "(", "key", "in", "parsedOptions", ")", ")", "{", "parsedOptions", "[", "key", "]", "=", "[", "]", ";", "}", "}", ")", ";", "}" ]
Initialize any Array options that weren't initialized.
[ "Initialize", "any", "Array", "options", "that", "weren", "t", "initialized", "." ]
44017cb96567763124d42ab5819e71bd98d98465
https://github.com/widgetworks/nopt-grunt-fix/blob/44017cb96567763124d42ab5819e71bd98d98465/index.js#L63-L69
57,398
sagiegurari/funcs-js
funcs.js
function (fn) { /** * Chain function. * * @function * @memberof! funcs * @alias funcs.maxTimesChain * @private * @param {Number} times - The max times the provided function will be invoked * @returns {function} The new wrapper function */ fn.maxTimes = function (times) { return funcs.maxTimes(fn, times); }; /** * Chain function. * * @function * @memberof! funcs * @alias funcs.onceChain * @private * @returns {function} The new wrapper function */ fn.once = function () { return funcs.once(fn); }; /** * Chain function. * * @function * @memberof! funcs * @alias funcs.delayChain * @private * @param {Number} delay - The invocation delay in millies * @returns {function} The new wrapper function */ fn.delay = function (delay) { return funcs.delay(fn, delay); }; /** * Chain function. * * @function * @memberof! funcs * @alias funcs.asyncChain * @private * @returns {function} The new wrapper function */ fn.async = function () { return funcs.async(fn); }; }
javascript
function (fn) { /** * Chain function. * * @function * @memberof! funcs * @alias funcs.maxTimesChain * @private * @param {Number} times - The max times the provided function will be invoked * @returns {function} The new wrapper function */ fn.maxTimes = function (times) { return funcs.maxTimes(fn, times); }; /** * Chain function. * * @function * @memberof! funcs * @alias funcs.onceChain * @private * @returns {function} The new wrapper function */ fn.once = function () { return funcs.once(fn); }; /** * Chain function. * * @function * @memberof! funcs * @alias funcs.delayChain * @private * @param {Number} delay - The invocation delay in millies * @returns {function} The new wrapper function */ fn.delay = function (delay) { return funcs.delay(fn, delay); }; /** * Chain function. * * @function * @memberof! funcs * @alias funcs.asyncChain * @private * @returns {function} The new wrapper function */ fn.async = function () { return funcs.async(fn); }; }
[ "function", "(", "fn", ")", "{", "/**\n * Chain function.\n *\n * @function\n * @memberof! funcs\n * @alias funcs.maxTimesChain\n * @private\n * @param {Number} times - The max times the provided function will be invoked\n * @returns {function} The new wrapper function\n */", "fn", ".", "maxTimes", "=", "function", "(", "times", ")", "{", "return", "funcs", ".", "maxTimes", "(", "fn", ",", "times", ")", ";", "}", ";", "/**\n * Chain function.\n *\n * @function\n * @memberof! funcs\n * @alias funcs.onceChain\n * @private\n * @returns {function} The new wrapper function\n */", "fn", ".", "once", "=", "function", "(", ")", "{", "return", "funcs", ".", "once", "(", "fn", ")", ";", "}", ";", "/**\n * Chain function.\n *\n * @function\n * @memberof! funcs\n * @alias funcs.delayChain\n * @private\n * @param {Number} delay - The invocation delay in millies\n * @returns {function} The new wrapper function\n */", "fn", ".", "delay", "=", "function", "(", "delay", ")", "{", "return", "funcs", ".", "delay", "(", "fn", ",", "delay", ")", ";", "}", ";", "/**\n * Chain function.\n *\n * @function\n * @memberof! funcs\n * @alias funcs.asyncChain\n * @private\n * @returns {function} The new wrapper function\n */", "fn", ".", "async", "=", "function", "(", ")", "{", "return", "funcs", ".", "async", "(", "fn", ")", ";", "}", ";", "}" ]
Adds chaining support for the provided function. @function @memberof! funcs @alias funcs.addChaining @private @param {function} fn - Adds the funcs APIs to the provided function with this function as a context
[ "Adds", "chaining", "support", "for", "the", "provided", "function", "." ]
8ddd8b04b703d8c424818ba9d2adc0281427864c
https://github.com/sagiegurari/funcs-js/blob/8ddd8b04b703d8c424818ba9d2adc0281427864c/funcs.js#L68-L122
57,399
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/find/dialogs/find.js
nonCharactersBoundary
function nonCharactersBoundary( node ) { return !( node.type == CKEDITOR.NODE_ELEMENT && node.isBlockBoundary( CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$empty, CKEDITOR.dtd.$nonEditable ) ) ); }
javascript
function nonCharactersBoundary( node ) { return !( node.type == CKEDITOR.NODE_ELEMENT && node.isBlockBoundary( CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$empty, CKEDITOR.dtd.$nonEditable ) ) ); }
[ "function", "nonCharactersBoundary", "(", "node", ")", "{", "return", "!", "(", "node", ".", "type", "==", "CKEDITOR", ".", "NODE_ELEMENT", "&&", "node", ".", "isBlockBoundary", "(", "CKEDITOR", ".", "tools", ".", "extend", "(", "{", "}", ",", "CKEDITOR", ".", "dtd", ".", "$empty", ",", "CKEDITOR", ".", "dtd", ".", "$nonEditable", ")", ")", ")", ";", "}" ]
Elements which break characters been considered as sequence.
[ "Elements", "which", "break", "characters", "been", "considered", "as", "sequence", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/find/dialogs/find.js#L14-L16