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
partition
stringclasses
1 value
Urigo/meteor-native-packages
packages/ddp-server/stream_server.js
function (callback) { var self = this; self.registration_callbacks.push(callback); _.each(self.all_sockets(), function (socket) { callback(socket); }); }
javascript
function (callback) { var self = this; self.registration_callbacks.push(callback); _.each(self.all_sockets(), function (socket) { callback(socket); }); }
[ "function", "(", "callback", ")", "{", "var", "self", "=", "this", ";", "self", ".", "registration_callbacks", ".", "push", "(", "callback", ")", ";", "_", ".", "each", "(", "self", ".", "all_sockets", "(", ")", ",", "function", "(", "socket", ")", "{", "callback", "(", "socket", ")", ";", "}", ")", ";", "}" ]
call my callback when a new socket connects. also call it for all current connections.
[ "call", "my", "callback", "when", "a", "new", "socket", "connects", ".", "also", "call", "it", "for", "all", "current", "connections", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-server/stream_server.js#L106-L112
train
Urigo/meteor-native-packages
packages/ddp-server/stream_server.js
function(request /*, moreArguments */) { // Store arguments for use within the closure below var args = arguments; // Rewrite /websocket and /websocket/ urls to /sockjs/websocket while // preserving query string. var parsedUrl = url.parse(request.url); if (parsedUrl.pathname === pathPrefix + '/websocket' || parsedUrl.pathname === pathPrefix + '/websocket/') { parsedUrl.pathname = self.prefix + '/websocket'; request.url = url.format(parsedUrl); } _.each(oldHttpServerListeners, function(oldListener) { oldListener.apply(httpServer, args); }); }
javascript
function(request /*, moreArguments */) { // Store arguments for use within the closure below var args = arguments; // Rewrite /websocket and /websocket/ urls to /sockjs/websocket while // preserving query string. var parsedUrl = url.parse(request.url); if (parsedUrl.pathname === pathPrefix + '/websocket' || parsedUrl.pathname === pathPrefix + '/websocket/') { parsedUrl.pathname = self.prefix + '/websocket'; request.url = url.format(parsedUrl); } _.each(oldHttpServerListeners, function(oldListener) { oldListener.apply(httpServer, args); }); }
[ "function", "(", "request", ")", "{", "var", "args", "=", "arguments", ";", "var", "parsedUrl", "=", "url", ".", "parse", "(", "request", ".", "url", ")", ";", "if", "(", "parsedUrl", ".", "pathname", "===", "pathPrefix", "+", "'/websocket'", "||", "parsedUrl", ".", "pathname", "===", "pathPrefix", "+", "'/websocket/'", ")", "{", "parsedUrl", ".", "pathname", "=", "self", ".", "prefix", "+", "'/websocket'", ";", "request", ".", "url", "=", "url", ".", "format", "(", "parsedUrl", ")", ";", "}", "_", ".", "each", "(", "oldHttpServerListeners", ",", "function", "(", "oldListener", ")", "{", "oldListener", ".", "apply", "(", "httpServer", ",", "args", ")", ";", "}", ")", ";", "}" ]
request and upgrade have different arguments passed but we only care about the first one which is always request
[ "request", "and", "upgrade", "have", "different", "arguments", "passed", "but", "we", "only", "care", "about", "the", "first", "one", "which", "is", "always", "request" ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-server/stream_server.js#L136-L151
train
a8m/agile
dist/agile.js
add
function add(object) { var args = Array.prototype.slice.call(arguments, 1); //loop through all over the arguments forEach(args, function(value, i) { switch(typeof object) { case 'object': isArray(object) ? object.push(value) : extend(object, isObject(value) ? value : creObject(i, value)); break; case 'string': object += isString(value) ? value : ''; break; case 'number': object += isNumber(value) ? value : 0; } }); return object; }
javascript
function add(object) { var args = Array.prototype.slice.call(arguments, 1); //loop through all over the arguments forEach(args, function(value, i) { switch(typeof object) { case 'object': isArray(object) ? object.push(value) : extend(object, isObject(value) ? value : creObject(i, value)); break; case 'string': object += isString(value) ? value : ''; break; case 'number': object += isNumber(value) ? value : 0; } }); return object; }
[ "function", "add", "(", "object", ")", "{", "var", "args", "=", "Array", ".", "prototype", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ";", "forEach", "(", "args", ",", "function", "(", "value", ",", "i", ")", "{", "switch", "(", "typeof", "object", ")", "{", "case", "'object'", ":", "isArray", "(", "object", ")", "?", "object", ".", "push", "(", "value", ")", ":", "extend", "(", "object", ",", "isObject", "(", "value", ")", "?", "value", ":", "creObject", "(", "i", ",", "value", ")", ")", ";", "break", ";", "case", "'string'", ":", "object", "+=", "isString", "(", "value", ")", "?", "value", ":", "''", ";", "break", ";", "case", "'number'", ":", "object", "+=", "isNumber", "(", "value", ")", "?", "value", ":", "0", ";", "}", "}", ")", ";", "return", "object", ";", "}" ]
these methods is kind of common methods for chaining wrappers @description add methods get an object extend(based on type) and return it. @param object @returns {*} @example add(1,2) ==> 3 add([],1) ==> [1] add('f','g') ==> 'fg' add({}, {a:1}) ==> {a:1}
[ "these", "methods", "is", "kind", "of", "common", "methods", "for", "chaining", "wrappers" ]
fcf3f8667e44c621bcdc3065c3a03b29e16851eb
https://github.com/a8m/agile/blob/fcf3f8667e44c621bcdc3065c3a03b29e16851eb/dist/agile.js#L938-L956
train
a8m/agile
dist/agile.js
runInContext
function runInContext(context) { // Node.js return (typeof module === "object" && module && module.exports === context) ? module.exports = agile // Browsers : context[(context._) ? 'agile' : '_'] = agile; }
javascript
function runInContext(context) { // Node.js return (typeof module === "object" && module && module.exports === context) ? module.exports = agile // Browsers : context[(context._) ? 'agile' : '_'] = agile; }
[ "function", "runInContext", "(", "context", ")", "{", "return", "(", "typeof", "module", "===", "\"object\"", "&&", "module", "&&", "module", ".", "exports", "===", "context", ")", "?", "module", ".", "exports", "=", "agile", ":", "context", "[", "(", "context", ".", "_", ")", "?", "'agile'", ":", "'_'", "]", "=", "agile", ";", "}" ]
Expose agile.js
[ "Expose", "agile", ".", "js" ]
fcf3f8667e44c621bcdc3065c3a03b29e16851eb
https://github.com/a8m/agile/blob/fcf3f8667e44c621bcdc3065c3a03b29e16851eb/dist/agile.js#L2708-L2714
train
arccoza/postcss-if-media
index.js
processIfValues
function processIfValues(css, result, rule, decl, queries) { var query = null; var re = /(.*)\s+(?:\?if|\?)\s+media\s+(.*)/; var re2 = /\s/g; var hash = null; // Check if we're working with comments. var match = decl.value ? decl.value.match(re) : decl.text.match(re); // console.log(match) if(match && match[1] && match[2]) { if(decl.value) decl.value = match[1]; else decl.text = match[1]; hash = match[2].replace(re2, ''); if(!queries[hash]) { queries[hash] = { arg: match[2], sel: rule.selector, props: [] } } queries[hash].props.push({name: decl.prop, value: match[1], query: match[2], hash: hash, decl: decl}); } else decl.warn(result, 'Appears to be a malformed `?if media` query -> ' + decl); }
javascript
function processIfValues(css, result, rule, decl, queries) { var query = null; var re = /(.*)\s+(?:\?if|\?)\s+media\s+(.*)/; var re2 = /\s/g; var hash = null; // Check if we're working with comments. var match = decl.value ? decl.value.match(re) : decl.text.match(re); // console.log(match) if(match && match[1] && match[2]) { if(decl.value) decl.value = match[1]; else decl.text = match[1]; hash = match[2].replace(re2, ''); if(!queries[hash]) { queries[hash] = { arg: match[2], sel: rule.selector, props: [] } } queries[hash].props.push({name: decl.prop, value: match[1], query: match[2], hash: hash, decl: decl}); } else decl.warn(result, 'Appears to be a malformed `?if media` query -> ' + decl); }
[ "function", "processIfValues", "(", "css", ",", "result", ",", "rule", ",", "decl", ",", "queries", ")", "{", "var", "query", "=", "null", ";", "var", "re", "=", "/", "(.*)\\s+(?:\\?if|\\?)\\s+media\\s+(.*)", "/", ";", "var", "re2", "=", "/", "\\s", "/", "g", ";", "var", "hash", "=", "null", ";", "var", "match", "=", "decl", ".", "value", "?", "decl", ".", "value", ".", "match", "(", "re", ")", ":", "decl", ".", "text", ".", "match", "(", "re", ")", ";", "if", "(", "match", "&&", "match", "[", "1", "]", "&&", "match", "[", "2", "]", ")", "{", "if", "(", "decl", ".", "value", ")", "decl", ".", "value", "=", "match", "[", "1", "]", ";", "else", "decl", ".", "text", "=", "match", "[", "1", "]", ";", "hash", "=", "match", "[", "2", "]", ".", "replace", "(", "re2", ",", "''", ")", ";", "if", "(", "!", "queries", "[", "hash", "]", ")", "{", "queries", "[", "hash", "]", "=", "{", "arg", ":", "match", "[", "2", "]", ",", "sel", ":", "rule", ".", "selector", ",", "props", ":", "[", "]", "}", "}", "queries", "[", "hash", "]", ".", "props", ".", "push", "(", "{", "name", ":", "decl", ".", "prop", ",", "value", ":", "match", "[", "1", "]", ",", "query", ":", "match", "[", "2", "]", ",", "hash", ":", "hash", ",", "decl", ":", "decl", "}", ")", ";", "}", "else", "decl", ".", "warn", "(", "result", ",", "'Appears to be a malformed `?if media` query -> '", "+", "decl", ")", ";", "}" ]
Extract the values and add them to the list of queries. Props are grouped by their queries, so that they appear in the same @media block later.
[ "Extract", "the", "values", "and", "add", "them", "to", "the", "list", "of", "queries", ".", "Props", "are", "grouped", "by", "their", "queries", "so", "that", "they", "appear", "in", "the", "same" ]
bdd4997231547cb5a82eca64c33aaec1f472c6a6
https://github.com/arccoza/postcss-if-media/blob/bdd4997231547cb5a82eca64c33aaec1f472c6a6/index.js#L77-L104
train
arccoza/postcss-if-media
index.js
createAtRules
function createAtRules(css, rule, queries) { var parent = rule.parent; var prev = rule; for(var k in queries) { var q = queries[k]; var at = postcss.atRule({name: 'media', params: q.arg, source: rule.source}); var qr = postcss.rule ({selector: q.sel, source: rule.source}); at.append(qr); for (var i = 0; i < q.props.length; i++) { var prop = q.props[i]; qr.append(prop.decl.remove()); }; // Again we keep track of the previous insert and insert after it, to maintain the original order // and CSS specificity. parent.insertAfter(prev, at); prev = at; } }
javascript
function createAtRules(css, rule, queries) { var parent = rule.parent; var prev = rule; for(var k in queries) { var q = queries[k]; var at = postcss.atRule({name: 'media', params: q.arg, source: rule.source}); var qr = postcss.rule ({selector: q.sel, source: rule.source}); at.append(qr); for (var i = 0; i < q.props.length; i++) { var prop = q.props[i]; qr.append(prop.decl.remove()); }; // Again we keep track of the previous insert and insert after it, to maintain the original order // and CSS specificity. parent.insertAfter(prev, at); prev = at; } }
[ "function", "createAtRules", "(", "css", ",", "rule", ",", "queries", ")", "{", "var", "parent", "=", "rule", ".", "parent", ";", "var", "prev", "=", "rule", ";", "for", "(", "var", "k", "in", "queries", ")", "{", "var", "q", "=", "queries", "[", "k", "]", ";", "var", "at", "=", "postcss", ".", "atRule", "(", "{", "name", ":", "'media'", ",", "params", ":", "q", ".", "arg", ",", "source", ":", "rule", ".", "source", "}", ")", ";", "var", "qr", "=", "postcss", ".", "rule", "(", "{", "selector", ":", "q", ".", "sel", ",", "source", ":", "rule", ".", "source", "}", ")", ";", "at", ".", "append", "(", "qr", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "q", ".", "props", ".", "length", ";", "i", "++", ")", "{", "var", "prop", "=", "q", ".", "props", "[", "i", "]", ";", "qr", ".", "append", "(", "prop", ".", "decl", ".", "remove", "(", ")", ")", ";", "}", ";", "parent", ".", "insertAfter", "(", "prev", ",", "at", ")", ";", "prev", "=", "at", ";", "}", "}" ]
The previously extracted inline queries and their associated properties are used to create @media rules below(to maintain CSS specificity) the parent rule.
[ "The", "previously", "extracted", "inline", "queries", "and", "their", "associated", "properties", "are", "used", "to", "create" ]
bdd4997231547cb5a82eca64c33aaec1f472c6a6
https://github.com/arccoza/postcss-if-media/blob/bdd4997231547cb5a82eca64c33aaec1f472c6a6/index.js#L108-L130
train
medialab/sandcrawler
phantom/bindings.js
getContent
function getContent() { var h = pageInformation.response.headers || {}; if (/json/.test(h['content-type'])) { try { return JSON.parse(page.plainText); } catch (e) { return page.content; } } else { return page.content; } }
javascript
function getContent() { var h = pageInformation.response.headers || {}; if (/json/.test(h['content-type'])) { try { return JSON.parse(page.plainText); } catch (e) { return page.content; } } else { return page.content; } }
[ "function", "getContent", "(", ")", "{", "var", "h", "=", "pageInformation", ".", "response", ".", "headers", "||", "{", "}", ";", "if", "(", "/", "json", "/", ".", "test", "(", "h", "[", "'content-type'", "]", ")", ")", "{", "try", "{", "return", "JSON", ".", "parse", "(", "page", ".", "plainText", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "page", ".", "content", ";", "}", "}", "else", "{", "return", "page", ".", "content", ";", "}", "}" ]
Helpers Get correct page content
[ "Helpers", "Get", "correct", "page", "content" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/phantom/bindings.js#L159-L172
train
medialab/sandcrawler
phantom/bindings.js
wrapFailure
function wrapFailure(reason) { var res = { fail: true, url: page.url, body: getContent(), headers: pageInformation.response.headers, status: pageInformation.response.status }; if (reason) res.reason = reason; if (pageInformation.error) res.error = pageInformation.error; return res; }
javascript
function wrapFailure(reason) { var res = { fail: true, url: page.url, body: getContent(), headers: pageInformation.response.headers, status: pageInformation.response.status }; if (reason) res.reason = reason; if (pageInformation.error) res.error = pageInformation.error; return res; }
[ "function", "wrapFailure", "(", "reason", ")", "{", "var", "res", "=", "{", "fail", ":", "true", ",", "url", ":", "page", ".", "url", ",", "body", ":", "getContent", "(", ")", ",", "headers", ":", "pageInformation", ".", "response", ".", "headers", ",", "status", ":", "pageInformation", ".", "response", ".", "status", "}", ";", "if", "(", "reason", ")", "res", ".", "reason", "=", "reason", ";", "if", "(", "pageInformation", ".", "error", ")", "res", ".", "error", "=", "pageInformation", ".", "error", ";", "return", "res", ";", "}" ]
Wrapping response helper
[ "Wrapping", "response", "helper" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/phantom/bindings.js#L175-L191
train
medialab/sandcrawler
phantom/bindings.js
wrapSuccess
function wrapSuccess(result) { return { url: page.url, body: getContent(), headers: pageInformation.response.headers, status: pageInformation.response.status, error: result.error ? helpers.serializeError(result.error) : null, data: result.data }; }
javascript
function wrapSuccess(result) { return { url: page.url, body: getContent(), headers: pageInformation.response.headers, status: pageInformation.response.status, error: result.error ? helpers.serializeError(result.error) : null, data: result.data }; }
[ "function", "wrapSuccess", "(", "result", ")", "{", "return", "{", "url", ":", "page", ".", "url", ",", "body", ":", "getContent", "(", ")", ",", "headers", ":", "pageInformation", ".", "response", ".", "headers", ",", "status", ":", "pageInformation", ".", "response", ".", "status", ",", "error", ":", "result", ".", "error", "?", "helpers", ".", "serializeError", "(", "result", ".", "error", ")", ":", "null", ",", "data", ":", "result", ".", "data", "}", ";", "}" ]
Wrapping success helper
[ "Wrapping", "success", "helper" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/phantom/bindings.js#L194-L203
train
medialab/sandcrawler
phantom/bindings.js
function(status) { // Page is now opened pageInformation.isOpened = true; pageInformation.status = status; // Failing if (status !== 'success') { parent.replyTo(callId, wrapFailure('fail')); return cleanup(); } // Wrong status code if (!pageInformation.response.status || pageInformation.response.status >= 400) { parent.replyTo(callId, wrapFailure('status')); return cleanup(); } // Waiting for body to load page.evaluateAsync(function() { var interval = setInterval(function() { if (document.readyState === 'complete' || document.readyState === 'interactive') { clearInterval(interval); window.callPhantom({ head: 'documentReady', body: true, passphrase: 'detoo' }); } }, 30); }); }
javascript
function(status) { // Page is now opened pageInformation.isOpened = true; pageInformation.status = status; // Failing if (status !== 'success') { parent.replyTo(callId, wrapFailure('fail')); return cleanup(); } // Wrong status code if (!pageInformation.response.status || pageInformation.response.status >= 400) { parent.replyTo(callId, wrapFailure('status')); return cleanup(); } // Waiting for body to load page.evaluateAsync(function() { var interval = setInterval(function() { if (document.readyState === 'complete' || document.readyState === 'interactive') { clearInterval(interval); window.callPhantom({ head: 'documentReady', body: true, passphrase: 'detoo' }); } }, 30); }); }
[ "function", "(", "status", ")", "{", "pageInformation", ".", "isOpened", "=", "true", ";", "pageInformation", ".", "status", "=", "status", ";", "if", "(", "status", "!==", "'success'", ")", "{", "parent", ".", "replyTo", "(", "callId", ",", "wrapFailure", "(", "'fail'", ")", ")", ";", "return", "cleanup", "(", ")", ";", "}", "if", "(", "!", "pageInformation", ".", "response", ".", "status", "||", "pageInformation", ".", "response", ".", "status", ">=", "400", ")", "{", "parent", ".", "replyTo", "(", "callId", ",", "wrapFailure", "(", "'status'", ")", ")", ";", "return", "cleanup", "(", ")", ";", "}", "page", ".", "evaluateAsync", "(", "function", "(", ")", "{", "var", "interval", "=", "setInterval", "(", "function", "(", ")", "{", "if", "(", "document", ".", "readyState", "===", "'complete'", "||", "document", ".", "readyState", "===", "'interactive'", ")", "{", "clearInterval", "(", "interval", ")", ";", "window", ".", "callPhantom", "(", "{", "head", ":", "'documentReady'", ",", "body", ":", "true", ",", "passphrase", ":", "'detoo'", "}", ")", ";", "}", "}", ",", "30", ")", ";", "}", ")", ";", "}" ]
When page load is finished
[ "When", "page", "load", "is", "finished" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/phantom/bindings.js#L395-L426
train
icelab/draft-js-ast-exporter
src/processor.js
processBlockContent
function processBlockContent (block, contentState, options) { const entityModifiers = options.entityModifiers || {} let text = block.getText() // Cribbed from sstur’s implementation in draft-js-export-html // https://github.com/sstur/draft-js-export-html/blob/master/src/stateToHTML.js#L222 let charMetaList = block.getCharacterList() let entityPieces = getEntityRanges(text, charMetaList) // Map over the block’s entities const entities = entityPieces.map(([entityKey, stylePieces]) => { let entity = entityKey ? contentState.getEntity(entityKey) : null // Extract the inline element const inline = stylePieces.map(([text, style]) => { return [ 'inline', [ style.toJS().map((s) => s), text, ], ] }) // Nest within an entity if there’s data if (entity) { const type = entity.getType() const mutability = entity.getMutability() let data = entity.getData() // Run the entity data through a modifier if one exists const modifier = entityModifiers[type] if (modifier) { data = modifier(data) } return [ [ 'entity', [ type, entityKey, mutability, data, inline, ], ], ] } else { return inline } }) // Flatten the result return entities.reduce((a, b) => { return a.concat(b) }, []) }
javascript
function processBlockContent (block, contentState, options) { const entityModifiers = options.entityModifiers || {} let text = block.getText() // Cribbed from sstur’s implementation in draft-js-export-html // https://github.com/sstur/draft-js-export-html/blob/master/src/stateToHTML.js#L222 let charMetaList = block.getCharacterList() let entityPieces = getEntityRanges(text, charMetaList) // Map over the block’s entities const entities = entityPieces.map(([entityKey, stylePieces]) => { let entity = entityKey ? contentState.getEntity(entityKey) : null // Extract the inline element const inline = stylePieces.map(([text, style]) => { return [ 'inline', [ style.toJS().map((s) => s), text, ], ] }) // Nest within an entity if there’s data if (entity) { const type = entity.getType() const mutability = entity.getMutability() let data = entity.getData() // Run the entity data through a modifier if one exists const modifier = entityModifiers[type] if (modifier) { data = modifier(data) } return [ [ 'entity', [ type, entityKey, mutability, data, inline, ], ], ] } else { return inline } }) // Flatten the result return entities.reduce((a, b) => { return a.concat(b) }, []) }
[ "function", "processBlockContent", "(", "block", ",", "contentState", ",", "options", ")", "{", "const", "entityModifiers", "=", "options", ".", "entityModifiers", "||", "{", "}", "let", "text", "=", "block", ".", "getText", "(", ")", "let", "charMetaList", "=", "block", ".", "getCharacterList", "(", ")", "let", "entityPieces", "=", "getEntityRanges", "(", "text", ",", "charMetaList", ")", "const", "entities", "=", "entityPieces", ".", "map", "(", "(", "[", "entityKey", ",", "stylePieces", "]", ")", "=>", "{", "let", "entity", "=", "entityKey", "?", "contentState", ".", "getEntity", "(", "entityKey", ")", ":", "null", "const", "inline", "=", "stylePieces", ".", "map", "(", "(", "[", "text", ",", "style", "]", ")", "=>", "{", "return", "[", "'inline'", ",", "[", "style", ".", "toJS", "(", ")", ".", "map", "(", "(", "s", ")", "=>", "s", ")", ",", "text", ",", "]", ",", "]", "}", ")", "if", "(", "entity", ")", "{", "const", "type", "=", "entity", ".", "getType", "(", ")", "const", "mutability", "=", "entity", ".", "getMutability", "(", ")", "let", "data", "=", "entity", ".", "getData", "(", ")", "const", "modifier", "=", "entityModifiers", "[", "type", "]", "if", "(", "modifier", ")", "{", "data", "=", "modifier", "(", "data", ")", "}", "return", "[", "[", "'entity'", ",", "[", "type", ",", "entityKey", ",", "mutability", ",", "data", ",", "inline", ",", "]", ",", "]", ",", "]", "}", "else", "{", "return", "inline", "}", "}", ")", "return", "entities", ".", "reduce", "(", "(", "a", ",", "b", ")", "=>", "{", "return", "a", ".", "concat", "(", "b", ")", "}", ",", "[", "]", ")", "}" ]
Process the content of a ContentBlock into appropriate abstract syntax tree nodes based on their type @param {ContentBlock} block @param {ContentState} contentState The draft-js ContentState object containing this block @param {Object} options.entityModifier Map of functions for modifying entity data as it’s exported @return {Array} List of block’s child nodes
[ "Process", "the", "content", "of", "a", "ContentBlock", "into", "appropriate", "abstract", "syntax", "tree", "nodes", "based", "on", "their", "type" ]
f4745a8a3ca94b51474f21fedc0f92dbbdafd828
https://github.com/icelab/draft-js-ast-exporter/blob/f4745a8a3ca94b51474f21fedc0f92dbbdafd828/src/processor.js#L14-L70
train
icelab/draft-js-ast-exporter
src/processor.js
processBlocks
function processBlocks (blocks, contentState, options = {}) { // Track block context let context = context || [] let currentContext = context let lastBlock = null let lastProcessed = null let parents = [] // Procedurally process individual blocks blocks.forEach(processBlock) /** * Process an individual block * @param {ContentBlock} block An individual ContentBlock instance * @return {Array} A abstract syntax tree node representing a block and its * children */ function processBlock (block) { const type = block.getType() const key = block.getKey() const data = (block.getData) ? block.getData().toJS() : {} const output = [ 'block', [ type, key, processBlockContent(block, contentState, options), data, ], ] // Push into context (or not) based on depth. This means either the top-level // context array, or the `children` of a previous block // This block is deeper if (lastBlock && block.getDepth() > lastBlock.getDepth()) { // Extract reference object from flat context // parents.push(lastProcessed) // (mutating) currentContext = lastProcessed[dataSchema.block.children] } else if (lastBlock && block.getDepth() < lastBlock.getDepth() && block.getDepth() > 0) { // This block is shallower (but not at the root). We want to find the last // block that is one level shallower than this one to append it to let parent = parents[block.getDepth() - 1] currentContext = parent[dataSchema.block.children] } else if (block.getDepth() === 0) { // Reset the parent context if we reach the top level parents = [] currentContext = context } currentContext.push(output) lastProcessed = output[1] // Store a reference to the last block at any given depth parents[block.getDepth()] = lastProcessed lastBlock = block } return context }
javascript
function processBlocks (blocks, contentState, options = {}) { // Track block context let context = context || [] let currentContext = context let lastBlock = null let lastProcessed = null let parents = [] // Procedurally process individual blocks blocks.forEach(processBlock) /** * Process an individual block * @param {ContentBlock} block An individual ContentBlock instance * @return {Array} A abstract syntax tree node representing a block and its * children */ function processBlock (block) { const type = block.getType() const key = block.getKey() const data = (block.getData) ? block.getData().toJS() : {} const output = [ 'block', [ type, key, processBlockContent(block, contentState, options), data, ], ] // Push into context (or not) based on depth. This means either the top-level // context array, or the `children` of a previous block // This block is deeper if (lastBlock && block.getDepth() > lastBlock.getDepth()) { // Extract reference object from flat context // parents.push(lastProcessed) // (mutating) currentContext = lastProcessed[dataSchema.block.children] } else if (lastBlock && block.getDepth() < lastBlock.getDepth() && block.getDepth() > 0) { // This block is shallower (but not at the root). We want to find the last // block that is one level shallower than this one to append it to let parent = parents[block.getDepth() - 1] currentContext = parent[dataSchema.block.children] } else if (block.getDepth() === 0) { // Reset the parent context if we reach the top level parents = [] currentContext = context } currentContext.push(output) lastProcessed = output[1] // Store a reference to the last block at any given depth parents[block.getDepth()] = lastProcessed lastBlock = block } return context }
[ "function", "processBlocks", "(", "blocks", ",", "contentState", ",", "options", "=", "{", "}", ")", "{", "let", "context", "=", "context", "||", "[", "]", "let", "currentContext", "=", "context", "let", "lastBlock", "=", "null", "let", "lastProcessed", "=", "null", "let", "parents", "=", "[", "]", "blocks", ".", "forEach", "(", "processBlock", ")", "function", "processBlock", "(", "block", ")", "{", "const", "type", "=", "block", ".", "getType", "(", ")", "const", "key", "=", "block", ".", "getKey", "(", ")", "const", "data", "=", "(", "block", ".", "getData", ")", "?", "block", ".", "getData", "(", ")", ".", "toJS", "(", ")", ":", "{", "}", "const", "output", "=", "[", "'block'", ",", "[", "type", ",", "key", ",", "processBlockContent", "(", "block", ",", "contentState", ",", "options", ")", ",", "data", ",", "]", ",", "]", "if", "(", "lastBlock", "&&", "block", ".", "getDepth", "(", ")", ">", "lastBlock", ".", "getDepth", "(", ")", ")", "{", "currentContext", "=", "lastProcessed", "[", "dataSchema", ".", "block", ".", "children", "]", "}", "else", "if", "(", "lastBlock", "&&", "block", ".", "getDepth", "(", ")", "<", "lastBlock", ".", "getDepth", "(", ")", "&&", "block", ".", "getDepth", "(", ")", ">", "0", ")", "{", "let", "parent", "=", "parents", "[", "block", ".", "getDepth", "(", ")", "-", "1", "]", "currentContext", "=", "parent", "[", "dataSchema", ".", "block", ".", "children", "]", "}", "else", "if", "(", "block", ".", "getDepth", "(", ")", "===", "0", ")", "{", "parents", "=", "[", "]", "currentContext", "=", "context", "}", "currentContext", ".", "push", "(", "output", ")", "lastProcessed", "=", "output", "[", "1", "]", "parents", "[", "block", ".", "getDepth", "(", ")", "]", "=", "lastProcessed", "lastBlock", "=", "block", "}", "return", "context", "}" ]
Convert the content from a series of draft-js blocks into an abstract syntax tree @param {Array} blocks @param {ContentState} contentState The draft-js ContentState object containing the blocks @param {Object} options @return {Array} An abstract syntax tree representing a draft-js content state
[ "Convert", "the", "content", "from", "a", "series", "of", "draft", "-", "js", "blocks", "into", "an", "abstract", "syntax", "tree" ]
f4745a8a3ca94b51474f21fedc0f92dbbdafd828
https://github.com/icelab/draft-js-ast-exporter/blob/f4745a8a3ca94b51474f21fedc0f92dbbdafd828/src/processor.js#L81-L138
train
Geta/NestedObjectAssign
webpack.config.js
getBaseConfig
function getBaseConfig(isProd) { // get library details from JSON config var libraryDesc = require('./package.json').library; var libraryEntryPoint = path.join('src', libraryDesc.entry); // generate webpack base config return { entry: path.join(__dirname, libraryEntryPoint), output: { // ommitted - will be filled according to target env }, module: { preLoaders: [ {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "eslint-loader"} ], loaders: [ {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "babel-loader"}, ] }, eslint: { configFile: './.eslintrc' }, resolve: { root: path.resolve('./src'), extensions: ['', '.js'] }, devtool: isProd ? null : '#eval-source-map', debug: !isProd, plugins: isProd ? [ new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"production"'}}), new UglifyJsPlugin({ minimize: true }) // Prod plugins here ] : [ new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"development"'}}) // Dev plugins here ] }; }
javascript
function getBaseConfig(isProd) { // get library details from JSON config var libraryDesc = require('./package.json').library; var libraryEntryPoint = path.join('src', libraryDesc.entry); // generate webpack base config return { entry: path.join(__dirname, libraryEntryPoint), output: { // ommitted - will be filled according to target env }, module: { preLoaders: [ {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "eslint-loader"} ], loaders: [ {test: /\.js$/, exclude: /(node_modules|bower_components)/, loader: "babel-loader"}, ] }, eslint: { configFile: './.eslintrc' }, resolve: { root: path.resolve('./src'), extensions: ['', '.js'] }, devtool: isProd ? null : '#eval-source-map', debug: !isProd, plugins: isProd ? [ new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"production"'}}), new UglifyJsPlugin({ minimize: true }) // Prod plugins here ] : [ new webpack.DefinePlugin({'process.env': {'NODE_ENV': '"development"'}}) // Dev plugins here ] }; }
[ "function", "getBaseConfig", "(", "isProd", ")", "{", "var", "libraryDesc", "=", "require", "(", "'./package.json'", ")", ".", "library", ";", "var", "libraryEntryPoint", "=", "path", ".", "join", "(", "'src'", ",", "libraryDesc", ".", "entry", ")", ";", "return", "{", "entry", ":", "path", ".", "join", "(", "__dirname", ",", "libraryEntryPoint", ")", ",", "output", ":", "{", "}", ",", "module", ":", "{", "preLoaders", ":", "[", "{", "test", ":", "/", "\\.js$", "/", ",", "exclude", ":", "/", "(node_modules|bower_components)", "/", ",", "loader", ":", "\"eslint-loader\"", "}", "]", ",", "loaders", ":", "[", "{", "test", ":", "/", "\\.js$", "/", ",", "exclude", ":", "/", "(node_modules|bower_components)", "/", ",", "loader", ":", "\"babel-loader\"", "}", ",", "]", "}", ",", "eslint", ":", "{", "configFile", ":", "'./.eslintrc'", "}", ",", "resolve", ":", "{", "root", ":", "path", ".", "resolve", "(", "'./src'", ")", ",", "extensions", ":", "[", "''", ",", "'.js'", "]", "}", ",", "devtool", ":", "isProd", "?", "null", ":", "'#eval-source-map'", ",", "debug", ":", "!", "isProd", ",", "plugins", ":", "isProd", "?", "[", "new", "webpack", ".", "DefinePlugin", "(", "{", "'process.env'", ":", "{", "'NODE_ENV'", ":", "'\"production\"'", "}", "}", ")", ",", "new", "UglifyJsPlugin", "(", "{", "minimize", ":", "true", "}", ")", "]", ":", "[", "new", "webpack", ".", "DefinePlugin", "(", "{", "'process.env'", ":", "{", "'NODE_ENV'", ":", "'\"development\"'", "}", "}", ")", "]", "}", ";", "}" ]
Build base config @param {Boolean} isProd [description] @return {[type]} [description]
[ "Build", "base", "config" ]
f63a28f1a285af31c7479a5abba88ffd5d2cb39d
https://github.com/Geta/NestedObjectAssign/blob/f63a28f1a285af31c7479a5abba88ffd5d2cb39d/webpack.config.js#L67-L105
train
jadrake75/odata-filter-parser
src/odata-parser.js
function (config) { if (!config) { config = {}; } this.subject = config.subject; this.value = config.value; this.operator = (config.operator) ? config.operator : Operators.EQUALS; return this; }
javascript
function (config) { if (!config) { config = {}; } this.subject = config.subject; this.value = config.value; this.operator = (config.operator) ? config.operator : Operators.EQUALS; return this; }
[ "function", "(", "config", ")", "{", "if", "(", "!", "config", ")", "{", "config", "=", "{", "}", ";", "}", "this", ".", "subject", "=", "config", ".", "subject", ";", "this", ".", "value", "=", "config", ".", "value", ";", "this", ".", "operator", "=", "(", "config", ".", "operator", ")", "?", "config", ".", "operator", ":", "Operators", ".", "EQUALS", ";", "return", "this", ";", "}" ]
Predicate is the basic model construct of the odata expression @param config @returns {Predicate} @constructor
[ "Predicate", "is", "the", "basic", "model", "construct", "of", "the", "odata", "expression" ]
f8e6e354bdedafe611d7fe82d5fced65ad33e19e
https://github.com/jadrake75/odata-filter-parser/blob/f8e6e354bdedafe611d7fe82d5fced65ad33e19e/src/odata-parser.js#L61-L69
train
Urigo/meteor-native-packages
packages/ddp-client/livedata_connection.js
function () { var self = this; if (!self._waitingForQuiescence()) self._flushBufferedWrites(); _.each(self._stores, function (s) { s.saveOriginals(); }); }
javascript
function () { var self = this; if (!self._waitingForQuiescence()) self._flushBufferedWrites(); _.each(self._stores, function (s) { s.saveOriginals(); }); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "!", "self", ".", "_waitingForQuiescence", "(", ")", ")", "self", ".", "_flushBufferedWrites", "(", ")", ";", "_", ".", "each", "(", "self", ".", "_stores", ",", "function", "(", "s", ")", "{", "s", ".", "saveOriginals", "(", ")", ";", "}", ")", ";", "}" ]
Before calling a method stub, prepare all stores to track changes and allow _retrieveAndStoreOriginals to get the original versions of changed documents.
[ "Before", "calling", "a", "method", "stub", "prepare", "all", "stores", "to", "track", "changes", "and", "allow", "_retrieveAndStoreOriginals", "to", "get", "the", "original", "versions", "of", "changed", "documents", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-client/livedata_connection.js#L975-L982
train
Urigo/meteor-native-packages
packages/ddp-client/livedata_connection.js
function() { var self = this; if (_.isEmpty(self._outstandingMethodBlocks)) return; _.each(self._outstandingMethodBlocks[0].methods, function (m) { m.sendMessage(); }); }
javascript
function() { var self = this; if (_.isEmpty(self._outstandingMethodBlocks)) return; _.each(self._outstandingMethodBlocks[0].methods, function (m) { m.sendMessage(); }); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "_", ".", "isEmpty", "(", "self", ".", "_outstandingMethodBlocks", ")", ")", "return", ";", "_", ".", "each", "(", "self", ".", "_outstandingMethodBlocks", "[", "0", "]", ".", "methods", ",", "function", "(", "m", ")", "{", "m", ".", "sendMessage", "(", ")", ";", "}", ")", ";", "}" ]
Sends messages for all the methods in the first block in _outstandingMethodBlocks.
[ "Sends", "messages", "for", "all", "the", "methods", "in", "the", "first", "block", "in", "_outstandingMethodBlocks", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-client/livedata_connection.js#L1662-L1669
train
jaredhanson/passport-fitbit
lib/errors/apierror.js
APIError
function APIError(message, type, field) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.name = 'APIError'; this.message = message; this.type = type; this.field = field; }
javascript
function APIError(message, type, field) { Error.call(this); Error.captureStackTrace(this, arguments.callee); this.name = 'APIError'; this.message = message; this.type = type; this.field = field; }
[ "function", "APIError", "(", "message", ",", "type", ",", "field", ")", "{", "Error", ".", "call", "(", "this", ")", ";", "Error", ".", "captureStackTrace", "(", "this", ",", "arguments", ".", "callee", ")", ";", "this", ".", "name", "=", "'APIError'", ";", "this", ".", "message", "=", "message", ";", "this", ".", "type", "=", "type", ";", "this", ".", "field", "=", "field", ";", "}" ]
`APIError` error. @constructor @param {string} [message] @param {string} [type] @param {string} [field] @access public
[ "APIError", "error", "." ]
68f730ac5a834163aeb9c33f8885888de45f0a7d
https://github.com/jaredhanson/passport-fitbit/blob/68f730ac5a834163aeb9c33f8885888de45f0a7d/lib/errors/apierror.js#L10-L17
train
Urigo/meteor-native-packages
linker.js
linkPackages
function linkPackages(dstPacksDir) { if (!dstPacksDir) { dstPacksDir = Path.resolve(rootDir, "packages"); } else { dstPacksDir = Path.resolve(cwd, dstPacksDir); } // Ensure destination dir try { Fs.mkdirSync(dstPacksDir); } catch (_) {} var packNames = Fs.readdirSync(srcPacksDir); // Ensure symlinks packNames.forEach(function (packName) { var dstPackDir = Path.resolve(dstPacksDir, packName); var linkPath = Path.relative(dstPacksDir, Path.resolve(srcPacksDir, packName)); try { Fs.symlinkSync(linkPath, dstPackDir); } catch (_) {} }); console.log(); console.log("Packages have been successfully linked at:") console.log(); console.log(" " + dstPacksDir); console.log(); }
javascript
function linkPackages(dstPacksDir) { if (!dstPacksDir) { dstPacksDir = Path.resolve(rootDir, "packages"); } else { dstPacksDir = Path.resolve(cwd, dstPacksDir); } // Ensure destination dir try { Fs.mkdirSync(dstPacksDir); } catch (_) {} var packNames = Fs.readdirSync(srcPacksDir); // Ensure symlinks packNames.forEach(function (packName) { var dstPackDir = Path.resolve(dstPacksDir, packName); var linkPath = Path.relative(dstPacksDir, Path.resolve(srcPacksDir, packName)); try { Fs.symlinkSync(linkPath, dstPackDir); } catch (_) {} }); console.log(); console.log("Packages have been successfully linked at:") console.log(); console.log(" " + dstPacksDir); console.log(); }
[ "function", "linkPackages", "(", "dstPacksDir", ")", "{", "if", "(", "!", "dstPacksDir", ")", "{", "dstPacksDir", "=", "Path", ".", "resolve", "(", "rootDir", ",", "\"packages\"", ")", ";", "}", "else", "{", "dstPacksDir", "=", "Path", ".", "resolve", "(", "cwd", ",", "dstPacksDir", ")", ";", "}", "try", "{", "Fs", ".", "mkdirSync", "(", "dstPacksDir", ")", ";", "}", "catch", "(", "_", ")", "{", "}", "var", "packNames", "=", "Fs", ".", "readdirSync", "(", "srcPacksDir", ")", ";", "packNames", ".", "forEach", "(", "function", "(", "packName", ")", "{", "var", "dstPackDir", "=", "Path", ".", "resolve", "(", "dstPacksDir", ",", "packName", ")", ";", "var", "linkPath", "=", "Path", ".", "relative", "(", "dstPacksDir", ",", "Path", ".", "resolve", "(", "srcPacksDir", ",", "packName", ")", ")", ";", "try", "{", "Fs", ".", "symlinkSync", "(", "linkPath", ",", "dstPackDir", ")", ";", "}", "catch", "(", "_", ")", "{", "}", "}", ")", ";", "console", ".", "log", "(", ")", ";", "console", ".", "log", "(", "\"Packages have been successfully linked at:\"", ")", "console", ".", "log", "(", ")", ";", "console", ".", "log", "(", "\" \"", "+", "dstPacksDir", ")", ";", "console", ".", "log", "(", ")", ";", "}" ]
Creates a symlink for each native package. @param dstPacksDir - Synlinks' output dir. Defaults to 'packages' dir.
[ "Creates", "a", "symlink", "for", "each", "native", "package", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/linker.js#L14-L46
train
zotero/zotero-api-node
lib/stream.js
Stream
function Stream(options) { /** * Whether or not the Stream was initialized as * a single- or multi-key stream. * * @property multi * @type Boolean */ reader(this, 'multi', !(options && options.apiKey)); if (!this.multi) { options.headers = options.headers || {}; options.headers['Zotero-API-Key'] = options.apiKey; delete options.apiKey; } Client.call(this, options); /** * @property retry * @type Object */ reader(this, 'retry', { delay: Stream.DEFAULT_RETRY }); /** * @property idle * @type Object */ reader(this, 'idle', { ping: Stream.IDLE_TIMEOUT, pong: Stream.IDLE_TIMEOUT / 2 }); /** * @property subscriptions * @type Subscriptions */ this.subscriptions = new Subscriptions(); this.open = this.open.bind(this); this.opened = this.opened.bind(this); this.closed = this.closed.bind(this); this.ping = this.ping.bind(this); this.pong = this.pong.bind(this); this.receive = this.receive.bind(this); this.error = this.error.bind(this); this.open(); }
javascript
function Stream(options) { /** * Whether or not the Stream was initialized as * a single- or multi-key stream. * * @property multi * @type Boolean */ reader(this, 'multi', !(options && options.apiKey)); if (!this.multi) { options.headers = options.headers || {}; options.headers['Zotero-API-Key'] = options.apiKey; delete options.apiKey; } Client.call(this, options); /** * @property retry * @type Object */ reader(this, 'retry', { delay: Stream.DEFAULT_RETRY }); /** * @property idle * @type Object */ reader(this, 'idle', { ping: Stream.IDLE_TIMEOUT, pong: Stream.IDLE_TIMEOUT / 2 }); /** * @property subscriptions * @type Subscriptions */ this.subscriptions = new Subscriptions(); this.open = this.open.bind(this); this.opened = this.opened.bind(this); this.closed = this.closed.bind(this); this.ping = this.ping.bind(this); this.pong = this.pong.bind(this); this.receive = this.receive.bind(this); this.error = this.error.bind(this); this.open(); }
[ "function", "Stream", "(", "options", ")", "{", "reader", "(", "this", ",", "'multi'", ",", "!", "(", "options", "&&", "options", ".", "apiKey", ")", ")", ";", "if", "(", "!", "this", ".", "multi", ")", "{", "options", ".", "headers", "=", "options", ".", "headers", "||", "{", "}", ";", "options", ".", "headers", "[", "'Zotero-API-Key'", "]", "=", "options", ".", "apiKey", ";", "delete", "options", ".", "apiKey", ";", "}", "Client", ".", "call", "(", "this", ",", "options", ")", ";", "reader", "(", "this", ",", "'retry'", ",", "{", "delay", ":", "Stream", ".", "DEFAULT_RETRY", "}", ")", ";", "reader", "(", "this", ",", "'idle'", ",", "{", "ping", ":", "Stream", ".", "IDLE_TIMEOUT", ",", "pong", ":", "Stream", ".", "IDLE_TIMEOUT", "/", "2", "}", ")", ";", "this", ".", "subscriptions", "=", "new", "Subscriptions", "(", ")", ";", "this", ".", "open", "=", "this", ".", "open", ".", "bind", "(", "this", ")", ";", "this", ".", "opened", "=", "this", ".", "opened", ".", "bind", "(", "this", ")", ";", "this", ".", "closed", "=", "this", ".", "closed", ".", "bind", "(", "this", ")", ";", "this", ".", "ping", "=", "this", ".", "ping", ".", "bind", "(", "this", ")", ";", "this", ".", "pong", "=", "this", ".", "pong", ".", "bind", "(", "this", ")", ";", "this", ".", "receive", "=", "this", ".", "receive", ".", "bind", "(", "this", ")", ";", "this", ".", "error", "=", "this", ".", "error", ".", "bind", "(", "this", ")", ";", "this", ".", "open", "(", ")", ";", "}" ]
Connects to the Zotero Streaming API by establishing a WebSocket connection. @class Stream @constructor @extends Client @param {Object} options
[ "Connects", "to", "the", "Zotero", "Streaming", "API", "by", "establishing", "a", "WebSocket", "connection", "." ]
df5b03cb6b66580efa52aaa22735b0058fbfdf8d
https://github.com/zotero/zotero-api-node/blob/df5b03cb6b66580efa52aaa22735b0058fbfdf8d/lib/stream.js#L52-L104
train
lukeed/dom-selection
dist/dom-selection.es.js
getRange
function getRange(sel) { sel = sel || getSelection(); return sel.rangeCount > 0 ? sel.getRangeAt(0) : null; }
javascript
function getRange(sel) { sel = sel || getSelection(); return sel.rangeCount > 0 ? sel.getRangeAt(0) : null; }
[ "function", "getRange", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "return", "sel", ".", "rangeCount", ">", "0", "?", "sel", ".", "getRangeAt", "(", "0", ")", ":", "null", ";", "}" ]
Get a Selection's Range @see http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html/13950376#13950376 @param {Selection} sel @return {Range|null}
[ "Get", "a", "Selection", "s", "Range" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L36-L39
train
lukeed/dom-selection
dist/dom-selection.es.js
setRange
function setRange(saved, sel) { if (!saved) { return; } // will make new selection, if unset sel = sel || getSelection(); sel.removeAllRanges(); sel.addRange(saved); }
javascript
function setRange(saved, sel) { if (!saved) { return; } // will make new selection, if unset sel = sel || getSelection(); sel.removeAllRanges(); sel.addRange(saved); }
[ "function", "setRange", "(", "saved", ",", "sel", ")", "{", "if", "(", "!", "saved", ")", "{", "return", ";", "}", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "sel", ".", "removeAllRanges", "(", ")", ";", "sel", ".", "addRange", "(", "saved", ")", ";", "}" ]
Restore a Selection Range @see http://stackoverflow.com/questions/13949059/persisting-the-changes-of-range-objects-after-selection-in-html/13950376#13950376 @param {Range} saved @param {Selection} sel
[ "Restore", "a", "Selection", "Range" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L47-L53
train
lukeed/dom-selection
dist/dom-selection.es.js
getRect
function getRect(sel) { sel = sel || getSelection(); if (!sel.rangeCount) { return false; } var range = sel.getRangeAt(0).cloneRange(); // on Webkit 'range.getBoundingClientRect()' sometimes return 0/0/0/0 - but 'range.getClientRects()' works var rects = range.getClientRects ? range.getClientRects() : []; for (var i = 0; i < rects.length; ++i) { var rect = rects[i]; if (rect.left && rect.top && rect.right && rect.bottom) { return { // Modern browsers return floating-point numbers left: parseInt(rect.left, 10), top: parseInt(rect.top, 10), width: parseInt(rect.right - rect.left, 10), height: parseInt(rect.bottom - rect.top, 10) }; } } return false; }
javascript
function getRect(sel) { sel = sel || getSelection(); if (!sel.rangeCount) { return false; } var range = sel.getRangeAt(0).cloneRange(); // on Webkit 'range.getBoundingClientRect()' sometimes return 0/0/0/0 - but 'range.getClientRects()' works var rects = range.getClientRects ? range.getClientRects() : []; for (var i = 0; i < rects.length; ++i) { var rect = rects[i]; if (rect.left && rect.top && rect.right && rect.bottom) { return { // Modern browsers return floating-point numbers left: parseInt(rect.left, 10), top: parseInt(rect.top, 10), width: parseInt(rect.right - rect.left, 10), height: parseInt(rect.bottom - rect.top, 10) }; } } return false; }
[ "function", "getRect", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "if", "(", "!", "sel", ".", "rangeCount", ")", "{", "return", "false", ";", "}", "var", "range", "=", "sel", ".", "getRangeAt", "(", "0", ")", ".", "cloneRange", "(", ")", ";", "var", "rects", "=", "range", ".", "getClientRects", "?", "range", ".", "getClientRects", "(", ")", ":", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "rects", ".", "length", ";", "++", "i", ")", "{", "var", "rect", "=", "rects", "[", "i", "]", ";", "if", "(", "rect", ".", "left", "&&", "rect", ".", "top", "&&", "rect", ".", "right", "&&", "rect", ".", "bottom", ")", "{", "return", "{", "left", ":", "parseInt", "(", "rect", ".", "left", ",", "10", ")", ",", "top", ":", "parseInt", "(", "rect", ".", "top", ",", "10", ")", ",", "width", ":", "parseInt", "(", "rect", ".", "right", "-", "rect", ".", "left", ",", "10", ")", ",", "height", ":", "parseInt", "(", "rect", ".", "bottom", "-", "rect", ".", "top", ",", "10", ")", "}", ";", "}", "}", "return", "false", ";", "}" ]
Get a Selection Rectangle @see http://stackoverflow.com/questions/12603397/calculate-width-height-of-the-selected-text-javascript @see http://stackoverflow.com/questions/6846230/coordinates-of-selected-text-in-browser-page @param {Selection} sel @return {Object|Boolean}
[ "Get", "a", "Selection", "Rectangle" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L62-L84
train
lukeed/dom-selection
dist/dom-selection.es.js
getNodes
function getNodes(sel) { var range = getRange(sel); if (!range) { return []; } var node = range.startContainer; var endNode = range.endContainer; // Special case for a range that is contained within a single node if (node === endNode) { return [node]; } // Iterate nodes until we hit the end container var nodes = []; while (node && node !== endNode) { nodes.push(node = nextNode(node)); } // Add partially selected nodes at the start of the range node = range.startContainer; while (node && node !== range.commonAncestorContainer) { nodes.unshift(node); node = node.parentNode; } return nodes; }
javascript
function getNodes(sel) { var range = getRange(sel); if (!range) { return []; } var node = range.startContainer; var endNode = range.endContainer; // Special case for a range that is contained within a single node if (node === endNode) { return [node]; } // Iterate nodes until we hit the end container var nodes = []; while (node && node !== endNode) { nodes.push(node = nextNode(node)); } // Add partially selected nodes at the start of the range node = range.startContainer; while (node && node !== range.commonAncestorContainer) { nodes.unshift(node); node = node.parentNode; } return nodes; }
[ "function", "getNodes", "(", "sel", ")", "{", "var", "range", "=", "getRange", "(", "sel", ")", ";", "if", "(", "!", "range", ")", "{", "return", "[", "]", ";", "}", "var", "node", "=", "range", ".", "startContainer", ";", "var", "endNode", "=", "range", ".", "endContainer", ";", "if", "(", "node", "===", "endNode", ")", "{", "return", "[", "node", "]", ";", "}", "var", "nodes", "=", "[", "]", ";", "while", "(", "node", "&&", "node", "!==", "endNode", ")", "{", "nodes", ".", "push", "(", "node", "=", "nextNode", "(", "node", ")", ")", ";", "}", "node", "=", "range", ".", "startContainer", ";", "while", "(", "node", "&&", "node", "!==", "range", ".", "commonAncestorContainer", ")", "{", "nodes", ".", "unshift", "(", "node", ")", ";", "node", "=", "node", ".", "parentNode", ";", "}", "return", "nodes", ";", "}" ]
Get all Nodes within a Selection. @see http://stackoverflow.com/questions/7781963/js-get-array-of-all-selected-nodes-in-contenteditable-div @param {Selection} sel @return {Array}
[ "Get", "all", "Nodes", "within", "a", "Selection", "." ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L92-L116
train
lukeed/dom-selection
dist/dom-selection.es.js
getHTML
function getHTML(sel) { sel = sel || getSelection(); if (!sel.rangeCount || sel.isCollapsed) { return null; } var len = sel.rangeCount; var container = doc.createElement('div'); for (var i = 0; i < len; ++i) { container.appendChild(sel.getRangeAt(i).cloneContents()); } return container.innerHTML; }
javascript
function getHTML(sel) { sel = sel || getSelection(); if (!sel.rangeCount || sel.isCollapsed) { return null; } var len = sel.rangeCount; var container = doc.createElement('div'); for (var i = 0; i < len; ++i) { container.appendChild(sel.getRangeAt(i).cloneContents()); } return container.innerHTML; }
[ "function", "getHTML", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "if", "(", "!", "sel", ".", "rangeCount", "||", "sel", ".", "isCollapsed", ")", "{", "return", "null", ";", "}", "var", "len", "=", "sel", ".", "rangeCount", ";", "var", "container", "=", "doc", ".", "createElement", "(", "'div'", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "len", ";", "++", "i", ")", "{", "container", ".", "appendChild", "(", "sel", ".", "getRangeAt", "(", "i", ")", ".", "cloneContents", "(", ")", ")", ";", "}", "return", "container", ".", "innerHTML", ";", "}" ]
Get the inner HTML content of a selection. @see http://stackoverflow.com/questions/4652734/return-html-from-a-user-selected-text/4652824#4652824 @param {Selection} sel @return {String}
[ "Get", "the", "inner", "HTML", "content", "of", "a", "selection", "." ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L124-L136
train
lukeed/dom-selection
dist/dom-selection.es.js
isWithin
function isWithin(container, sel) { sel = sel || getSelection(); return container.contains(sel.anchorNode) && container.contains(sel.focusNode); }
javascript
function isWithin(container, sel) { sel = sel || getSelection(); return container.contains(sel.anchorNode) && container.contains(sel.focusNode); }
[ "function", "isWithin", "(", "container", ",", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "return", "container", ".", "contains", "(", "sel", ".", "anchorNode", ")", "&&", "container", ".", "contains", "(", "sel", ".", "focusNode", ")", ";", "}" ]
Is the Selection within given container Node? @param {Node} container The container node @param {Selection} sel @return {Boolean}
[ "Is", "the", "Selection", "within", "given", "container", "Node?" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L170-L173
train
lukeed/dom-selection
dist/dom-selection.es.js
getCaretWord
function getCaretWord(sel) { sel = sel || getSelection(); var rng = getRange(sel); expandToWord(sel); var str = sel.toString(); // range? // Restore selection setRange(rng); return str; }
javascript
function getCaretWord(sel) { sel = sel || getSelection(); var rng = getRange(sel); expandToWord(sel); var str = sel.toString(); // range? // Restore selection setRange(rng); return str; }
[ "function", "getCaretWord", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "var", "rng", "=", "getRange", "(", "sel", ")", ";", "expandToWord", "(", "sel", ")", ";", "var", "str", "=", "sel", ".", "toString", "(", ")", ";", "setRange", "(", "rng", ")", ";", "return", "str", ";", "}" ]
Get the full word that the Caret is within. @see http://stackoverflow.com/questions/11247737/how-can-i-get-the-word-that-the-caret-is-upon-inside-a-contenteditable-div @param {Selection} sel @return {String}
[ "Get", "the", "full", "word", "that", "the", "Caret", "is", "within", "." ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L211-L219
train
lukeed/dom-selection
dist/dom-selection.es.js
isBackwards
function isBackwards(sel) { sel = sel || getSelection(); if (isCollapsed(sel)) { return; } // Detect if selection is backwards var range = doc.createRange(); range.setStart(sel.anchorNode, sel.anchorOffset); range.setEnd(sel.focusNode, sel.focusOffset); range.detach(); // if `collapsed` then it's backwards return range.collapsed; }
javascript
function isBackwards(sel) { sel = sel || getSelection(); if (isCollapsed(sel)) { return; } // Detect if selection is backwards var range = doc.createRange(); range.setStart(sel.anchorNode, sel.anchorOffset); range.setEnd(sel.focusNode, sel.focusOffset); range.detach(); // if `collapsed` then it's backwards return range.collapsed; }
[ "function", "isBackwards", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "if", "(", "isCollapsed", "(", "sel", ")", ")", "{", "return", ";", "}", "var", "range", "=", "doc", ".", "createRange", "(", ")", ";", "range", ".", "setStart", "(", "sel", ".", "anchorNode", ",", "sel", ".", "anchorOffset", ")", ";", "range", ".", "setEnd", "(", "sel", ".", "focusNode", ",", "sel", ".", "focusOffset", ")", ";", "range", ".", "detach", "(", ")", ";", "return", "range", ".", "collapsed", ";", "}" ]
Detect the direction of the Selection @param {Selection} sel @return {Boolean}
[ "Detect", "the", "direction", "of", "the", "Selection" ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L226-L238
train
lukeed/dom-selection
dist/dom-selection.es.js
snapSelected
function snapSelected(sel) { sel = sel || getSelection(); if (isCollapsed(sel)) { return; } var end = sel.focusNode; var off = sel.focusOffset; var dir = ['forward', 'backward']; isBackwards(sel) && dir.reverse(); // modify() works on the focus of the selection sel.collapse(sel.anchorNode, sel.anchorOffset); sel.modify('move', dir[0], 'character'); sel.modify('move', dir[1], 'word'); sel.extend(end, off); sel.modify('extend', dir[1], 'character'); sel.modify('extend', dir[0], 'word'); }
javascript
function snapSelected(sel) { sel = sel || getSelection(); if (isCollapsed(sel)) { return; } var end = sel.focusNode; var off = sel.focusOffset; var dir = ['forward', 'backward']; isBackwards(sel) && dir.reverse(); // modify() works on the focus of the selection sel.collapse(sel.anchorNode, sel.anchorOffset); sel.modify('move', dir[0], 'character'); sel.modify('move', dir[1], 'word'); sel.extend(end, off); sel.modify('extend', dir[1], 'character'); sel.modify('extend', dir[0], 'word'); }
[ "function", "snapSelected", "(", "sel", ")", "{", "sel", "=", "sel", "||", "getSelection", "(", ")", ";", "if", "(", "isCollapsed", "(", "sel", ")", ")", "{", "return", ";", "}", "var", "end", "=", "sel", ".", "focusNode", ";", "var", "off", "=", "sel", ".", "focusOffset", ";", "var", "dir", "=", "[", "'forward'", ",", "'backward'", "]", ";", "isBackwards", "(", "sel", ")", "&&", "dir", ".", "reverse", "(", ")", ";", "sel", ".", "collapse", "(", "sel", ".", "anchorNode", ",", "sel", ".", "anchorOffset", ")", ";", "sel", ".", "modify", "(", "'move'", ",", "dir", "[", "0", "]", ",", "'character'", ")", ";", "sel", ".", "modify", "(", "'move'", ",", "dir", "[", "1", "]", ",", "'word'", ")", ";", "sel", ".", "extend", "(", "end", ",", "off", ")", ";", "sel", ".", "modify", "(", "'extend'", ",", "dir", "[", "1", "]", ",", "'character'", ")", ";", "sel", ".", "modify", "(", "'extend'", ",", "dir", "[", "0", "]", ",", "'word'", ")", ";", "}" ]
Snap the Selection to encompass all partially-selected words. @see http://stackoverflow.com/questions/7380190/select-whole-word-with-getselection @param {Selection} sel
[ "Snap", "the", "Selection", "to", "encompass", "all", "partially", "-", "selected", "words", "." ]
b926c790347ec5b58c219c64aff6c030b2266fd1
https://github.com/lukeed/dom-selection/blob/b926c790347ec5b58c219c64aff6c030b2266fd1/dist/dom-selection.es.js#L245-L262
train
Urigo/meteor-native-packages
packages/ddp-server/writefence.js
function () { var self = this; if (self === DDPServer._CurrentWriteFence.get()) throw Error("Can't arm the current fence"); self.armed = true; self._maybeFire(); }
javascript
function () { var self = this; if (self === DDPServer._CurrentWriteFence.get()) throw Error("Can't arm the current fence"); self.armed = true; self._maybeFire(); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "self", "===", "DDPServer", ".", "_CurrentWriteFence", ".", "get", "(", ")", ")", "throw", "Error", "(", "\"Can't arm the current fence\"", ")", ";", "self", ".", "armed", "=", "true", ";", "self", ".", "_maybeFire", "(", ")", ";", "}" ]
Arm the fence. Once the fence is armed, and there are no more uncommitted writes, it will activate.
[ "Arm", "the", "fence", ".", "Once", "the", "fence", "is", "armed", "and", "there", "are", "no", "more", "uncommitted", "writes", "it", "will", "activate", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-server/writefence.js#L55-L61
train
Urigo/meteor-native-packages
packages/ddp-server/writefence.js
function () { var self = this; var future = new Future; self.onAllCommitted(function () { future['return'](); }); self.arm(); future.wait(); }
javascript
function () { var self = this; var future = new Future; self.onAllCommitted(function () { future['return'](); }); self.arm(); future.wait(); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "var", "future", "=", "new", "Future", ";", "self", ".", "onAllCommitted", "(", "function", "(", ")", "{", "future", "[", "'return'", "]", "(", ")", ";", "}", ")", ";", "self", ".", "arm", "(", ")", ";", "future", ".", "wait", "(", ")", ";", "}" ]
Convenience function. Arms the fence, then blocks until it fires.
[ "Convenience", "function", ".", "Arms", "the", "fence", "then", "blocks", "until", "it", "fires", "." ]
8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7
https://github.com/Urigo/meteor-native-packages/blob/8eb7fdd554aad0ff78a0dc19b9c62016d2b2e7a7/packages/ddp-server/writefence.js#L84-L92
train
bitinn/vdom-parser
index.js
createNode
function createNode(el, attr) { // html comment is not currently supported by virtual-dom if (el.nodeType === 3) { return createVirtualTextNode(el); // cdata or doctype is not currently supported by virtual-dom } else if (el.nodeType === 1 || el.nodeType === 9) { return createVirtualDomNode(el, attr); } // default to empty text node return new VText(''); }
javascript
function createNode(el, attr) { // html comment is not currently supported by virtual-dom if (el.nodeType === 3) { return createVirtualTextNode(el); // cdata or doctype is not currently supported by virtual-dom } else if (el.nodeType === 1 || el.nodeType === 9) { return createVirtualDomNode(el, attr); } // default to empty text node return new VText(''); }
[ "function", "createNode", "(", "el", ",", "attr", ")", "{", "if", "(", "el", ".", "nodeType", "===", "3", ")", "{", "return", "createVirtualTextNode", "(", "el", ")", ";", "}", "else", "if", "(", "el", ".", "nodeType", "===", "1", "||", "el", ".", "nodeType", "===", "9", ")", "{", "return", "createVirtualDomNode", "(", "el", ",", "attr", ")", ";", "}", "return", "new", "VText", "(", "''", ")", ";", "}" ]
Create vdom from dom node @param Object el DOM element @param String attr Attribute name that contains vdom key @return Object VNode or VText
[ "Create", "vdom", "from", "dom", "node" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L73-L85
train
bitinn/vdom-parser
index.js
createVirtualDomNode
function createVirtualDomNode(el, attr) { var ns = el.namespaceURI !== HTML_NAMESPACE ? el.namespaceURI : null; var key = attr && el.getAttribute(attr) ? el.getAttribute(attr) : null; return new VNode( el.tagName , createProperties(el) , createChildren(el, attr) , key , ns ); }
javascript
function createVirtualDomNode(el, attr) { var ns = el.namespaceURI !== HTML_NAMESPACE ? el.namespaceURI : null; var key = attr && el.getAttribute(attr) ? el.getAttribute(attr) : null; return new VNode( el.tagName , createProperties(el) , createChildren(el, attr) , key , ns ); }
[ "function", "createVirtualDomNode", "(", "el", ",", "attr", ")", "{", "var", "ns", "=", "el", ".", "namespaceURI", "!==", "HTML_NAMESPACE", "?", "el", ".", "namespaceURI", ":", "null", ";", "var", "key", "=", "attr", "&&", "el", ".", "getAttribute", "(", "attr", ")", "?", "el", ".", "getAttribute", "(", "attr", ")", ":", "null", ";", "return", "new", "VNode", "(", "el", ".", "tagName", ",", "createProperties", "(", "el", ")", ",", "createChildren", "(", "el", ",", "attr", ")", ",", "key", ",", "ns", ")", ";", "}" ]
Create vnode from dom node @param Object el DOM element @param String attr Attribute name that contains vdom key @return Object VNode
[ "Create", "vnode", "from", "dom", "node" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L104-L115
train
bitinn/vdom-parser
index.js
createChildren
function createChildren(el, attr) { var children = []; for (var i = 0; i < el.childNodes.length; i++) { children.push(createNode(el.childNodes[i], attr)); }; return children; }
javascript
function createChildren(el, attr) { var children = []; for (var i = 0; i < el.childNodes.length; i++) { children.push(createNode(el.childNodes[i], attr)); }; return children; }
[ "function", "createChildren", "(", "el", ",", "attr", ")", "{", "var", "children", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "el", ".", "childNodes", ".", "length", ";", "i", "++", ")", "{", "children", ".", "push", "(", "createNode", "(", "el", ".", "childNodes", "[", "i", "]", ",", "attr", ")", ")", ";", "}", ";", "return", "children", ";", "}" ]
Recursively create vdom @param Object el Parent element @param String attr Attribute name that contains vdom key @return Array Child vnode or vtext
[ "Recursively", "create", "vdom" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L124-L131
train
bitinn/vdom-parser
index.js
createProperties
function createProperties(el) { var properties = {}; if (!el.hasAttributes()) { return properties; } var ns; if (el.namespaceURI && el.namespaceURI !== HTML_NAMESPACE) { ns = el.namespaceURI; } var attr; for (var i = 0; i < el.attributes.length; i++) { // use built in css style parsing if(el.attributes[i].name == 'style'){ attr = createStyleProperty(el); } else if (ns) { attr = createPropertyNS(el.attributes[i]); } else { attr = createProperty(el.attributes[i]); } // special case, namespaced attribute, use properties.foobar if (attr.ns) { properties[attr.name] = { namespace: attr.ns , value: attr.value }; // special case, use properties.attributes.foobar } else if (attr.isAttr) { // init attributes object only when necessary if (!properties.attributes) { properties.attributes = {} } properties.attributes[attr.name] = attr.value; // default case, use properties.foobar } else { properties[attr.name] = attr.value; } }; return properties; }
javascript
function createProperties(el) { var properties = {}; if (!el.hasAttributes()) { return properties; } var ns; if (el.namespaceURI && el.namespaceURI !== HTML_NAMESPACE) { ns = el.namespaceURI; } var attr; for (var i = 0; i < el.attributes.length; i++) { // use built in css style parsing if(el.attributes[i].name == 'style'){ attr = createStyleProperty(el); } else if (ns) { attr = createPropertyNS(el.attributes[i]); } else { attr = createProperty(el.attributes[i]); } // special case, namespaced attribute, use properties.foobar if (attr.ns) { properties[attr.name] = { namespace: attr.ns , value: attr.value }; // special case, use properties.attributes.foobar } else if (attr.isAttr) { // init attributes object only when necessary if (!properties.attributes) { properties.attributes = {} } properties.attributes[attr.name] = attr.value; // default case, use properties.foobar } else { properties[attr.name] = attr.value; } }; return properties; }
[ "function", "createProperties", "(", "el", ")", "{", "var", "properties", "=", "{", "}", ";", "if", "(", "!", "el", ".", "hasAttributes", "(", ")", ")", "{", "return", "properties", ";", "}", "var", "ns", ";", "if", "(", "el", ".", "namespaceURI", "&&", "el", ".", "namespaceURI", "!==", "HTML_NAMESPACE", ")", "{", "ns", "=", "el", ".", "namespaceURI", ";", "}", "var", "attr", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "el", ".", "attributes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "el", ".", "attributes", "[", "i", "]", ".", "name", "==", "'style'", ")", "{", "attr", "=", "createStyleProperty", "(", "el", ")", ";", "}", "else", "if", "(", "ns", ")", "{", "attr", "=", "createPropertyNS", "(", "el", ".", "attributes", "[", "i", "]", ")", ";", "}", "else", "{", "attr", "=", "createProperty", "(", "el", ".", "attributes", "[", "i", "]", ")", ";", "}", "if", "(", "attr", ".", "ns", ")", "{", "properties", "[", "attr", ".", "name", "]", "=", "{", "namespace", ":", "attr", ".", "ns", ",", "value", ":", "attr", ".", "value", "}", ";", "}", "else", "if", "(", "attr", ".", "isAttr", ")", "{", "if", "(", "!", "properties", ".", "attributes", ")", "{", "properties", ".", "attributes", "=", "{", "}", "}", "properties", ".", "attributes", "[", "attr", ".", "name", "]", "=", "attr", ".", "value", ";", "}", "else", "{", "properties", "[", "attr", ".", "name", "]", "=", "attr", ".", "value", ";", "}", "}", ";", "return", "properties", ";", "}" ]
Create properties from dom node @param Object el DOM element @return Object Node properties and attributes
[ "Create", "properties", "from", "dom", "node" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L139-L185
train
bitinn/vdom-parser
index.js
createProperty
function createProperty(attr) { var name, value, isAttr; // using a map to find the correct case of property name if (propertyMap[attr.name]) { name = propertyMap[attr.name]; } else { name = attr.name; } // special cases for data attribute, we default to properties.attributes.data if (name.indexOf('data-') === 0 || name.indexOf('aria-') === 0) { value = attr.value; isAttr = true; } else { value = attr.value; } return { name: name , value: value , isAttr: isAttr || false }; }
javascript
function createProperty(attr) { var name, value, isAttr; // using a map to find the correct case of property name if (propertyMap[attr.name]) { name = propertyMap[attr.name]; } else { name = attr.name; } // special cases for data attribute, we default to properties.attributes.data if (name.indexOf('data-') === 0 || name.indexOf('aria-') === 0) { value = attr.value; isAttr = true; } else { value = attr.value; } return { name: name , value: value , isAttr: isAttr || false }; }
[ "function", "createProperty", "(", "attr", ")", "{", "var", "name", ",", "value", ",", "isAttr", ";", "if", "(", "propertyMap", "[", "attr", ".", "name", "]", ")", "{", "name", "=", "propertyMap", "[", "attr", ".", "name", "]", ";", "}", "else", "{", "name", "=", "attr", ".", "name", ";", "}", "if", "(", "name", ".", "indexOf", "(", "'data-'", ")", "===", "0", "||", "name", ".", "indexOf", "(", "'aria-'", ")", "===", "0", ")", "{", "value", "=", "attr", ".", "value", ";", "isAttr", "=", "true", ";", "}", "else", "{", "value", "=", "attr", ".", "value", ";", "}", "return", "{", "name", ":", "name", ",", "value", ":", "value", ",", "isAttr", ":", "isAttr", "||", "false", "}", ";", "}" ]
Create property from dom attribute @param Object attr DOM attribute @return Object Normalized attribute
[ "Create", "property", "from", "dom", "attribute" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L193-L215
train
bitinn/vdom-parser
index.js
createPropertyNS
function createPropertyNS(attr) { var name, value; return { name: attr.name , value: attr.value , ns: namespaceMap[attr.name] || '' }; }
javascript
function createPropertyNS(attr) { var name, value; return { name: attr.name , value: attr.value , ns: namespaceMap[attr.name] || '' }; }
[ "function", "createPropertyNS", "(", "attr", ")", "{", "var", "name", ",", "value", ";", "return", "{", "name", ":", "attr", ".", "name", ",", "value", ":", "attr", ".", "value", ",", "ns", ":", "namespaceMap", "[", "attr", ".", "name", "]", "||", "''", "}", ";", "}" ]
Create namespaced property from dom attribute @param Object attr DOM attribute @return Object Normalized attribute
[ "Create", "namespaced", "property", "from", "dom", "attribute" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L223-L231
train
bitinn/vdom-parser
index.js
createStyleProperty
function createStyleProperty(el) { var style = el.style; var output = {}; for (var i = 0; i < style.length; ++i) { var item = style.item(i); output[item] = String(style[item]); // hack to workaround browser inconsistency with url() if (output[item].indexOf('url') > -1) { output[item] = output[item].replace(/\"/g, '') } } return { name: 'style', value: output }; }
javascript
function createStyleProperty(el) { var style = el.style; var output = {}; for (var i = 0; i < style.length; ++i) { var item = style.item(i); output[item] = String(style[item]); // hack to workaround browser inconsistency with url() if (output[item].indexOf('url') > -1) { output[item] = output[item].replace(/\"/g, '') } } return { name: 'style', value: output }; }
[ "function", "createStyleProperty", "(", "el", ")", "{", "var", "style", "=", "el", ".", "style", ";", "var", "output", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "style", ".", "length", ";", "++", "i", ")", "{", "var", "item", "=", "style", ".", "item", "(", "i", ")", ";", "output", "[", "item", "]", "=", "String", "(", "style", "[", "item", "]", ")", ";", "if", "(", "output", "[", "item", "]", ".", "indexOf", "(", "'url'", ")", ">", "-", "1", ")", "{", "output", "[", "item", "]", "=", "output", "[", "item", "]", ".", "replace", "(", "/", "\\\"", "/", "g", ",", "''", ")", "}", "}", "return", "{", "name", ":", "'style'", ",", "value", ":", "output", "}", ";", "}" ]
Create style property from dom node @param Object el DOM node @return Object Normalized attribute
[ "Create", "style", "property", "from", "dom", "node" ]
e7dffa55bd205642ee0a675e46e738a515764390
https://github.com/bitinn/vdom-parser/blob/e7dffa55bd205642ee0a675e46e738a515764390/index.js#L239-L251
train
IronCoreLabs/ironnode
build.js
tagRepo
function tagRepo(version) { if (SHOULD_PUBLISH) { shell.exec(`git tag ${version}`); shell.exec("git push origin --tags"); } else { console.log(`\n\nWould publish git tag as version ${version}.`); } }
javascript
function tagRepo(version) { if (SHOULD_PUBLISH) { shell.exec(`git tag ${version}`); shell.exec("git push origin --tags"); } else { console.log(`\n\nWould publish git tag as version ${version}.`); } }
[ "function", "tagRepo", "(", "version", ")", "{", "if", "(", "SHOULD_PUBLISH", ")", "{", "shell", ".", "exec", "(", "`", "${", "version", "}", "`", ")", ";", "shell", ".", "exec", "(", "\"git push origin --tags\"", ")", ";", "}", "else", "{", "console", ".", "log", "(", "`", "\\n", "\\n", "${", "version", "}", "`", ")", ";", "}", "}" ]
Tag the repo with the current version that we're publishing
[ "Tag", "the", "repo", "with", "the", "current", "version", "that", "we", "re", "publishing" ]
a0c69398c75230720c4a825426d2a73925ea9053
https://github.com/IronCoreLabs/ironnode/blob/a0c69398c75230720c4a825426d2a73925ea9053/build.js#L50-L57
train
IronCoreLabs/ironnode
build.js
ensureNoChangesOnMasterBeforePublish
function ensureNoChangesOnMasterBeforePublish() { //Let users try the build script as long as they're not doing an actual publish if (!SHOULD_PUBLISH) { return true; } shell.exec("git fetch origin", {silent: true}); const currentBranch = shell.exec("git symbolic-ref --short -q HEAD", {silent: true}); if (currentBranch.stdout.trim() !== "master") { shell.echo("Modules can only be deployed off 'master' branch."); shell.exit(-1); } const changesOnBranch = shell.exec("git log HEAD..origin/master --oneline", {silent: true}); if (changesOnBranch.stdout.trim() !== "") { shell.echo("Local repo and origin are out of sync! Have you pushed all your changes? Have you pulled the latest?"); shell.exit(-1); } const localChanges = shell.exec("git status --porcelain", {silent: true}); if (localChanges.stdout.trim() !== "") { shell.echo("This git repository is has uncommitted files. Publish aborted!"); shell.exit(-1); } }
javascript
function ensureNoChangesOnMasterBeforePublish() { //Let users try the build script as long as they're not doing an actual publish if (!SHOULD_PUBLISH) { return true; } shell.exec("git fetch origin", {silent: true}); const currentBranch = shell.exec("git symbolic-ref --short -q HEAD", {silent: true}); if (currentBranch.stdout.trim() !== "master") { shell.echo("Modules can only be deployed off 'master' branch."); shell.exit(-1); } const changesOnBranch = shell.exec("git log HEAD..origin/master --oneline", {silent: true}); if (changesOnBranch.stdout.trim() !== "") { shell.echo("Local repo and origin are out of sync! Have you pushed all your changes? Have you pulled the latest?"); shell.exit(-1); } const localChanges = shell.exec("git status --porcelain", {silent: true}); if (localChanges.stdout.trim() !== "") { shell.echo("This git repository is has uncommitted files. Publish aborted!"); shell.exit(-1); } }
[ "function", "ensureNoChangesOnMasterBeforePublish", "(", ")", "{", "if", "(", "!", "SHOULD_PUBLISH", ")", "{", "return", "true", ";", "}", "shell", ".", "exec", "(", "\"git fetch origin\"", ",", "{", "silent", ":", "true", "}", ")", ";", "const", "currentBranch", "=", "shell", ".", "exec", "(", "\"git symbolic-ref --short -q HEAD\"", ",", "{", "silent", ":", "true", "}", ")", ";", "if", "(", "currentBranch", ".", "stdout", ".", "trim", "(", ")", "!==", "\"master\"", ")", "{", "shell", ".", "echo", "(", "\"Modules can only be deployed off 'master' branch.\"", ")", ";", "shell", ".", "exit", "(", "-", "1", ")", ";", "}", "const", "changesOnBranch", "=", "shell", ".", "exec", "(", "\"git log HEAD..origin/master --oneline\"", ",", "{", "silent", ":", "true", "}", ")", ";", "if", "(", "changesOnBranch", ".", "stdout", ".", "trim", "(", ")", "!==", "\"\"", ")", "{", "shell", ".", "echo", "(", "\"Local repo and origin are out of sync! Have you pushed all your changes? Have you pulled the latest?\"", ")", ";", "shell", ".", "exit", "(", "-", "1", ")", ";", "}", "const", "localChanges", "=", "shell", ".", "exec", "(", "\"git status --porcelain\"", ",", "{", "silent", ":", "true", "}", ")", ";", "if", "(", "localChanges", ".", "stdout", ".", "trim", "(", ")", "!==", "\"\"", ")", "{", "shell", ".", "echo", "(", "\"This git repository is has uncommitted files. Publish aborted!\"", ")", ";", "shell", ".", "exit", "(", "-", "1", ")", ";", "}", "}" ]
Ensure that we're in a pristine, up-to-date repo and on the master branch before allowing user to continue. Only does verification if user is actually trying to perform an NPM publish
[ "Ensure", "that", "we", "re", "in", "a", "pristine", "up", "-", "to", "-", "date", "repo", "and", "on", "the", "master", "branch", "before", "allowing", "user", "to", "continue", ".", "Only", "does", "verification", "if", "user", "is", "actually", "trying", "to", "perform", "an", "NPM", "publish" ]
a0c69398c75230720c4a825426d2a73925ea9053
https://github.com/IronCoreLabs/ironnode/blob/a0c69398c75230720c4a825426d2a73925ea9053/build.js#L63-L88
train
mjk/uber-rush
lib/Quote.js
Quote
function Quote(options) { var self = this; events.EventEmitter.call(self); this.quote_id = options.quote_id; this.start_time = new Date(parseInt(options.start_time,10)*1000); this.end_time = new Date(parseInt(options.end_time,10)*1000); this.fee = parseFloat(options.fee); this.currency_code = options.currency_code; if (options.pickup_eta) this.pickup_eta = parseInt(options.pickup_eta, 10); if (options.dropoff_eta) this.dropoff_eta = parseInt(options.dropoff_eta, 10); this.pickup_date = this.pickup_eta ? new Date(Date.now() + this.pickup_eta*60*1000) : null; this.dropoff_date = this.dropoff_eta ? new Date(Date.now() + this.dropoff_eta*60*1000) : null; }
javascript
function Quote(options) { var self = this; events.EventEmitter.call(self); this.quote_id = options.quote_id; this.start_time = new Date(parseInt(options.start_time,10)*1000); this.end_time = new Date(parseInt(options.end_time,10)*1000); this.fee = parseFloat(options.fee); this.currency_code = options.currency_code; if (options.pickup_eta) this.pickup_eta = parseInt(options.pickup_eta, 10); if (options.dropoff_eta) this.dropoff_eta = parseInt(options.dropoff_eta, 10); this.pickup_date = this.pickup_eta ? new Date(Date.now() + this.pickup_eta*60*1000) : null; this.dropoff_date = this.dropoff_eta ? new Date(Date.now() + this.dropoff_eta*60*1000) : null; }
[ "function", "Quote", "(", "options", ")", "{", "var", "self", "=", "this", ";", "events", ".", "EventEmitter", ".", "call", "(", "self", ")", ";", "this", ".", "quote_id", "=", "options", ".", "quote_id", ";", "this", ".", "start_time", "=", "new", "Date", "(", "parseInt", "(", "options", ".", "start_time", ",", "10", ")", "*", "1000", ")", ";", "this", ".", "end_time", "=", "new", "Date", "(", "parseInt", "(", "options", ".", "end_time", ",", "10", ")", "*", "1000", ")", ";", "this", ".", "fee", "=", "parseFloat", "(", "options", ".", "fee", ")", ";", "this", ".", "currency_code", "=", "options", ".", "currency_code", ";", "if", "(", "options", ".", "pickup_eta", ")", "this", ".", "pickup_eta", "=", "parseInt", "(", "options", ".", "pickup_eta", ",", "10", ")", ";", "if", "(", "options", ".", "dropoff_eta", ")", "this", ".", "dropoff_eta", "=", "parseInt", "(", "options", ".", "dropoff_eta", ",", "10", ")", ";", "this", ".", "pickup_date", "=", "this", ".", "pickup_eta", "?", "new", "Date", "(", "Date", ".", "now", "(", ")", "+", "this", ".", "pickup_eta", "*", "60", "*", "1000", ")", ":", "null", ";", "this", ".", "dropoff_date", "=", "this", ".", "dropoff_eta", "?", "new", "Date", "(", "Date", ".", "now", "(", ")", "+", "this", ".", "dropoff_eta", "*", "60", "*", "1000", ")", ":", "null", ";", "}" ]
A delivery quote. @param quote_id string The ID of the quote. @param estimated_at integer Unix timestamp of the time this quote was generated. @param start_time integer Unix timestamp of the start of the delivery window. @param end_time integer Unix timestamp of the end of the delivery window. @param fee float The fee of the delivery. @param currency_code string The currency code of the delivery fee. The currency code follows the ISO 4217 standard. @param pickup_eta integer The eta to pickup for this quote in minutes. Only applies to on­demand deliveries. @param dropoff_eta integer The eta to dropoff for this quote in minutes. Only applies to on­demand deliveries.
[ "A", "delivery", "quote", "." ]
3c43b2e8e1da428dd49e1a516f3c1588756c4576
https://github.com/mjk/uber-rush/blob/3c43b2e8e1da428dd49e1a516f3c1588756c4576/lib/Quote.js#L23-L38
train
layerhq/node-layer-api
lib/resources/messages.js
function(conversationId, userId, text, callback) { send(null, conversationId, utils.messageText('user_id', userId, text), callback); }
javascript
function(conversationId, userId, text, callback) { send(null, conversationId, utils.messageText('user_id', userId, text), callback); }
[ "function", "(", "conversationId", ",", "userId", ",", "text", ",", "callback", ")", "{", "send", "(", "null", ",", "conversationId", ",", "utils", ".", "messageText", "(", "'user_id'", ",", "userId", ",", "text", ")", ",", "callback", ")", ";", "}" ]
Send a plain text message from `userId` @param {String} conversationId Conversation ID @param {String} userId User ID @param {String} text Message text @param {Function} callback Callback function
[ "Send", "a", "plain", "text", "message", "from", "userId" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L41-L43
train
layerhq/node-layer-api
lib/resources/messages.js
function(conversationId, name, text, callback) { send(null, conversationId, utils.messageText('name', name, text), callback); }
javascript
function(conversationId, name, text, callback) { send(null, conversationId, utils.messageText('name', name, text), callback); }
[ "function", "(", "conversationId", ",", "name", ",", "text", ",", "callback", ")", "{", "send", "(", "null", ",", "conversationId", ",", "utils", ".", "messageText", "(", "'name'", ",", "name", ",", "text", ")", ",", "callback", ")", ";", "}" ]
Send a plain text message from `name` @param {String} conversationId Conversation ID @param {String} name Sender name @param {String} text Message text @param {Function} callback Callback function
[ "Send", "a", "plain", "text", "message", "from", "name" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L53-L55
train
layerhq/node-layer-api
lib/resources/messages.js
function(conversationId, params, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.messages.cid)); utils.debug('Message getAll: ' + conversationId); var queryParams = ''; if (typeof params === 'function') callback = params; else queryParams = '?' + querystring.stringify(params); request.get({ path: '/conversations/' + conversationId + '/messages' + queryParams }, callback); }
javascript
function(conversationId, params, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.messages.cid)); utils.debug('Message getAll: ' + conversationId); var queryParams = ''; if (typeof params === 'function') callback = params; else queryParams = '?' + querystring.stringify(params); request.get({ path: '/conversations/' + conversationId + '/messages' + queryParams }, callback); }
[ "function", "(", "conversationId", ",", "params", ",", "callback", ")", "{", "conversationId", "=", "utils", ".", "toUUID", "(", "conversationId", ")", ";", "if", "(", "!", "conversationId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "messages", ".", "cid", ")", ")", ";", "utils", ".", "debug", "(", "'Message getAll: '", "+", "conversationId", ")", ";", "var", "queryParams", "=", "''", ";", "if", "(", "typeof", "params", "===", "'function'", ")", "callback", "=", "params", ";", "else", "queryParams", "=", "'?'", "+", "querystring", ".", "stringify", "(", "params", ")", ";", "request", ".", "get", "(", "{", "path", ":", "'/conversations/'", "+", "conversationId", "+", "'/messages'", "+", "queryParams", "}", ",", "callback", ")", ";", "}" ]
Retrieve messages in a conversation @param {String} conversationId Conversation ID @param {String} [params] Query parameters @param {Function} callback Callback function
[ "Retrieve", "messages", "in", "a", "conversation" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L64-L76
train
layerhq/node-layer-api
lib/resources/messages.js
function(messageId, conversationId, callback) { if (!messageId) return callback(new Error(utils.i18n.messages.mid)); messageId = utils.toUUID(messageId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); conversationId = utils.toUUID(conversationId); utils.debug('Message get: ' + messageId + ', ' + conversationId); request.get({ path: '/conversations/' + conversationId + '/messages/' + messageId }, callback); }
javascript
function(messageId, conversationId, callback) { if (!messageId) return callback(new Error(utils.i18n.messages.mid)); messageId = utils.toUUID(messageId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); conversationId = utils.toUUID(conversationId); utils.debug('Message get: ' + messageId + ', ' + conversationId); request.get({ path: '/conversations/' + conversationId + '/messages/' + messageId }, callback); }
[ "function", "(", "messageId", ",", "conversationId", ",", "callback", ")", "{", "if", "(", "!", "messageId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "messages", ".", "mid", ")", ")", ";", "messageId", "=", "utils", ".", "toUUID", "(", "messageId", ")", ";", "if", "(", "!", "conversationId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "conversations", ".", "id", ")", ")", ";", "conversationId", "=", "utils", ".", "toUUID", "(", "conversationId", ")", ";", "utils", ".", "debug", "(", "'Message get: '", "+", "messageId", "+", "', '", "+", "conversationId", ")", ";", "request", ".", "get", "(", "{", "path", ":", "'/conversations/'", "+", "conversationId", "+", "'/messages/'", "+", "messageId", "}", ",", "callback", ")", ";", "}" ]
Retrieve a message in a conversation @param {String} messageId Message ID @param {String} conversationId Conversation ID @param {Function} callback Callback function
[ "Retrieve", "a", "message", "in", "a", "conversation" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L85-L94
train
layerhq/node-layer-api
lib/resources/messages.js
function(userId, messageId, callback) { if (!userId) return callback(new Error(utils.i18n.messages.userId)); messageId = utils.toUUID(messageId); if (!messageId) return callback(new Error(utils.i18n.messages.mid)); utils.debug('Message getFromUser: ' + userId + ', ' + messageId); request.get({ path: '/users/' + querystring.escape(userId) + '/messages/' + messageId }, callback); }
javascript
function(userId, messageId, callback) { if (!userId) return callback(new Error(utils.i18n.messages.userId)); messageId = utils.toUUID(messageId); if (!messageId) return callback(new Error(utils.i18n.messages.mid)); utils.debug('Message getFromUser: ' + userId + ', ' + messageId); request.get({ path: '/users/' + querystring.escape(userId) + '/messages/' + messageId }, callback); }
[ "function", "(", "userId", ",", "messageId", ",", "callback", ")", "{", "if", "(", "!", "userId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "messages", ".", "userId", ")", ")", ";", "messageId", "=", "utils", ".", "toUUID", "(", "messageId", ")", ";", "if", "(", "!", "messageId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "messages", ".", "mid", ")", ")", ";", "utils", ".", "debug", "(", "'Message getFromUser: '", "+", "userId", "+", "', '", "+", "messageId", ")", ";", "request", ".", "get", "(", "{", "path", ":", "'/users/'", "+", "querystring", ".", "escape", "(", "userId", ")", "+", "'/messages/'", "+", "messageId", "}", ",", "callback", ")", ";", "}" ]
Retrieve a message in a conversation from a user @param {String} userId User ID @param {String} messageId Message ID @param {Function} callback Callback function
[ "Retrieve", "a", "message", "in", "a", "conversation", "from", "a", "user" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/messages.js#L126-L135
train
medialab/sandcrawler
src/spider.js
retryJob
function retryJob(job, when) { when = when || 'later'; // Reaching maxRetries? if (job.req.retries >= this.options.maxRetries) return; // Dropping from remains delete this.remains[job.id]; // Request job.req.retries++; job.state.retrying = true; // Adding to the queue again this.queue[when === 'now' ? 'unshift' : 'push'](job); this.emit('job:retry', job, when); }
javascript
function retryJob(job, when) { when = when || 'later'; // Reaching maxRetries? if (job.req.retries >= this.options.maxRetries) return; // Dropping from remains delete this.remains[job.id]; // Request job.req.retries++; job.state.retrying = true; // Adding to the queue again this.queue[when === 'now' ? 'unshift' : 'push'](job); this.emit('job:retry', job, when); }
[ "function", "retryJob", "(", "job", ",", "when", ")", "{", "when", "=", "when", "||", "'later'", ";", "if", "(", "job", ".", "req", ".", "retries", ">=", "this", ".", "options", ".", "maxRetries", ")", "return", ";", "delete", "this", ".", "remains", "[", "job", ".", "id", "]", ";", "job", ".", "req", ".", "retries", "++", ";", "job", ".", "state", ".", "retrying", "=", "true", ";", "this", ".", "queue", "[", "when", "===", "'now'", "?", "'unshift'", ":", "'push'", "]", "(", "job", ")", ";", "this", ".", "emit", "(", "'job:retry'", ",", "job", ",", "when", ")", ";", "}" ]
Retrying a job
[ "Retrying", "a", "job" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L241-L259
train
medialab/sandcrawler
src/spider.js
beforeScraping
function beforeScraping(job, callback) { return async.applyEachSeries( this.middlewares.beforeScraping, job.req, callback ); }
javascript
function beforeScraping(job, callback) { return async.applyEachSeries( this.middlewares.beforeScraping, job.req, callback ); }
[ "function", "beforeScraping", "(", "job", ",", "callback", ")", "{", "return", "async", ".", "applyEachSeries", "(", "this", ".", "middlewares", ".", "beforeScraping", ",", "job", ".", "req", ",", "callback", ")", ";", "}" ]
Applying beforeScraping middlewares
[ "Applying", "beforeScraping", "middlewares" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L262-L268
train
medialab/sandcrawler
src/spider.js
afterScraping
function afterScraping(job, callback) { return async.applyEachSeries( this.middlewares.afterScraping, job.req, job.res, callback ); }
javascript
function afterScraping(job, callback) { return async.applyEachSeries( this.middlewares.afterScraping, job.req, job.res, callback ); }
[ "function", "afterScraping", "(", "job", ",", "callback", ")", "{", "return", "async", ".", "applyEachSeries", "(", "this", ".", "middlewares", ".", "afterScraping", ",", "job", ".", "req", ",", "job", ".", "res", ",", "callback", ")", ";", "}" ]
Applying afterScraping middlewares
[ "Applying", "afterScraping", "middlewares" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L276-L282
train
medialab/sandcrawler
src/spider.js
iterate
function iterate() { var lastJob = this.lastJob || {}, feed = this.iterator.call(this, this.index, lastJob.req, lastJob.res); if (feed) this.addUrl(feed); }
javascript
function iterate() { var lastJob = this.lastJob || {}, feed = this.iterator.call(this, this.index, lastJob.req, lastJob.res); if (feed) this.addUrl(feed); }
[ "function", "iterate", "(", ")", "{", "var", "lastJob", "=", "this", ".", "lastJob", "||", "{", "}", ",", "feed", "=", "this", ".", "iterator", ".", "call", "(", "this", ",", "this", ".", "index", ",", "lastJob", ".", "req", ",", "lastJob", ".", "res", ")", ";", "if", "(", "feed", ")", "this", ".", "addUrl", "(", "feed", ")", ";", "}" ]
Perform an iteration
[ "Perform", "an", "iteration" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L292-L298
train
medialab/sandcrawler
src/spider.js
addUrl
function addUrl(when, feed) { if (!types.check(feed, 'feed') && !types.check(feed, ['feed'])) throw Error('sandcrawler.spider.url(s): wrong argument.'); var a = !(feed instanceof Array) ? [feed] : feed, c = !this.state.running ? this.initialBuffer.length : this.index, job, i, l; for (i = 0, l = a.length; i < l; i++) { job = createJob(a[i]); // Don't add if already at limit if (this.options.limit && c >= this.options.limit) break; if (!this.state.running) { this.initialBuffer[when === 'later' ? 'push' : 'unshift'](job); } else { this.queue[when === 'later' ? 'push' : 'unshift'](job); this.emit('job:add', job); } } return this; }
javascript
function addUrl(when, feed) { if (!types.check(feed, 'feed') && !types.check(feed, ['feed'])) throw Error('sandcrawler.spider.url(s): wrong argument.'); var a = !(feed instanceof Array) ? [feed] : feed, c = !this.state.running ? this.initialBuffer.length : this.index, job, i, l; for (i = 0, l = a.length; i < l; i++) { job = createJob(a[i]); // Don't add if already at limit if (this.options.limit && c >= this.options.limit) break; if (!this.state.running) { this.initialBuffer[when === 'later' ? 'push' : 'unshift'](job); } else { this.queue[when === 'later' ? 'push' : 'unshift'](job); this.emit('job:add', job); } } return this; }
[ "function", "addUrl", "(", "when", ",", "feed", ")", "{", "if", "(", "!", "types", ".", "check", "(", "feed", ",", "'feed'", ")", "&&", "!", "types", ".", "check", "(", "feed", ",", "[", "'feed'", "]", ")", ")", "throw", "Error", "(", "'sandcrawler.spider.url(s): wrong argument.'", ")", ";", "var", "a", "=", "!", "(", "feed", "instanceof", "Array", ")", "?", "[", "feed", "]", ":", "feed", ",", "c", "=", "!", "this", ".", "state", ".", "running", "?", "this", ".", "initialBuffer", ".", "length", ":", "this", ".", "index", ",", "job", ",", "i", ",", "l", ";", "for", "(", "i", "=", "0", ",", "l", "=", "a", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "job", "=", "createJob", "(", "a", "[", "i", "]", ")", ";", "if", "(", "this", ".", "options", ".", "limit", "&&", "c", ">=", "this", ".", "options", ".", "limit", ")", "break", ";", "if", "(", "!", "this", ".", "state", ".", "running", ")", "{", "this", ".", "initialBuffer", "[", "when", "===", "'later'", "?", "'push'", ":", "'unshift'", "]", "(", "job", ")", ";", "}", "else", "{", "this", ".", "queue", "[", "when", "===", "'later'", "?", "'push'", ":", "'unshift'", "]", "(", "job", ")", ";", "this", ".", "emit", "(", "'job:add'", ",", "job", ")", ";", "}", "}", "return", "this", ";", "}" ]
Feeding the spider
[ "Feeding", "the", "spider" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/spider.js#L426-L453
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( a, order, prop, prop2 ) { var out = []; var i=0, ien=order.length; // Could have the test in the loop for slightly smaller code, but speed // is essential here if ( prop2 !== undefined ) { for ( ; i<ien ; i++ ) { out.push( a[ order[i] ][ prop ][ prop2 ] ); } } else { for ( ; i<ien ; i++ ) { out.push( a[ order[i] ][ prop ] ); } } return out; }
javascript
function ( a, order, prop, prop2 ) { var out = []; var i=0, ien=order.length; // Could have the test in the loop for slightly smaller code, but speed // is essential here if ( prop2 !== undefined ) { for ( ; i<ien ; i++ ) { out.push( a[ order[i] ][ prop ][ prop2 ] ); } } else { for ( ; i<ien ; i++ ) { out.push( a[ order[i] ][ prop ] ); } } return out; }
[ "function", "(", "a", ",", "order", ",", "prop", ",", "prop2", ")", "{", "var", "out", "=", "[", "]", ";", "var", "i", "=", "0", ",", "ien", "=", "order", ".", "length", ";", "if", "(", "prop2", "!==", "undefined", ")", "{", "for", "(", ";", "i", "<", "ien", ";", "i", "++", ")", "{", "out", ".", "push", "(", "a", "[", "order", "[", "i", "]", "]", "[", "prop", "]", "[", "prop2", "]", ")", ";", "}", "}", "else", "{", "for", "(", ";", "i", "<", "ien", ";", "i", "++", ")", "{", "out", ".", "push", "(", "a", "[", "order", "[", "i", "]", "]", "[", "prop", "]", ")", ";", "}", "}", "return", "out", ";", "}" ]
Basically the same as _pluck, but rather than looping over `a` we use `order` as the indexes to pick from `a`
[ "Basically", "the", "same", "as", "_pluck", "but", "rather", "than", "looping", "over", "a", "we", "use", "order", "as", "the", "indexes", "to", "pick", "from", "a" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L179-L198
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( src ) { // A faster unique method is to use object keys to identify used values, // but this doesn't work with arrays or objects, which we must also // consider. See jsperf.com/compare-array-unique-versions/4 for more // information. var out = [], val, i, ien=src.length, j, k=0; again: for ( i=0 ; i<ien ; i++ ) { val = src[i]; for ( j=0 ; j<k ; j++ ) { if ( out[j] === val ) { continue again; } } out.push( val ); k++; } return out; }
javascript
function ( src ) { // A faster unique method is to use object keys to identify used values, // but this doesn't work with arrays or objects, which we must also // consider. See jsperf.com/compare-array-unique-versions/4 for more // information. var out = [], val, i, ien=src.length, j, k=0; again: for ( i=0 ; i<ien ; i++ ) { val = src[i]; for ( j=0 ; j<k ; j++ ) { if ( out[j] === val ) { continue again; } } out.push( val ); k++; } return out; }
[ "function", "(", "src", ")", "{", "var", "out", "=", "[", "]", ",", "val", ",", "i", ",", "ien", "=", "src", ".", "length", ",", "j", ",", "k", "=", "0", ";", "again", ":", "for", "(", "i", "=", "0", ";", "i", "<", "ien", ";", "i", "++", ")", "{", "val", "=", "src", "[", "i", "]", ";", "for", "(", "j", "=", "0", ";", "j", "<", "k", ";", "j", "++", ")", "{", "if", "(", "out", "[", "j", "]", "===", "val", ")", "{", "continue", "again", ";", "}", "}", "out", ".", "push", "(", "val", ")", ";", "k", "++", ";", "}", "return", "out", ";", "}" ]
Find the unique elements in a source array. @param {array} src Source array @return {array} Array of unique items @ignore
[ "Find", "the", "unique", "elements", "in", "a", "source", "array", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L235-L261
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnHungarianMap
function _fnHungarianMap ( o ) { var hungarian = 'a aa ao as b fn i m o s ', match, newKey, map = {}; $.each( o, function (key, val) { match = key.match(/^([^A-Z]+?)([A-Z])/); if ( match && hungarian.indexOf(match[1]+' ') !== -1 ) { newKey = key.replace( match[0], match[2].toLowerCase() ); map[ newKey ] = key; if ( match[1] === 'o' ) { _fnHungarianMap( o[key] ); } } } ); o._hungarianMap = map; }
javascript
function _fnHungarianMap ( o ) { var hungarian = 'a aa ao as b fn i m o s ', match, newKey, map = {}; $.each( o, function (key, val) { match = key.match(/^([^A-Z]+?)([A-Z])/); if ( match && hungarian.indexOf(match[1]+' ') !== -1 ) { newKey = key.replace( match[0], match[2].toLowerCase() ); map[ newKey ] = key; if ( match[1] === 'o' ) { _fnHungarianMap( o[key] ); } } } ); o._hungarianMap = map; }
[ "function", "_fnHungarianMap", "(", "o", ")", "{", "var", "hungarian", "=", "'a aa ao as b fn i m o s '", ",", "match", ",", "newKey", ",", "map", "=", "{", "}", ";", "$", ".", "each", "(", "o", ",", "function", "(", "key", ",", "val", ")", "{", "match", "=", "key", ".", "match", "(", "/", "^([^A-Z]+?)([A-Z])", "/", ")", ";", "if", "(", "match", "&&", "hungarian", ".", "indexOf", "(", "match", "[", "1", "]", "+", "' '", ")", "!==", "-", "1", ")", "{", "newKey", "=", "key", ".", "replace", "(", "match", "[", "0", "]", ",", "match", "[", "2", "]", ".", "toLowerCase", "(", ")", ")", ";", "map", "[", "newKey", "]", "=", "key", ";", "if", "(", "match", "[", "1", "]", "===", "'o'", ")", "{", "_fnHungarianMap", "(", "o", "[", "key", "]", ")", ";", "}", "}", "}", ")", ";", "o", ".", "_hungarianMap", "=", "map", ";", "}" ]
Create a mapping object that allows camel case parameters to be looked up for their Hungarian counterparts. The mapping is stored in a private parameter called `_hungarianMap` which can be accessed on the source object. @param {object} o @memberof DataTable#oApi
[ "Create", "a", "mapping", "object", "that", "allows", "camel", "case", "parameters", "to", "be", "looked", "up", "for", "their", "Hungarian", "counterparts", ".", "The", "mapping", "is", "stored", "in", "a", "private", "parameter", "called", "_hungarianMap", "which", "can", "be", "accessed", "on", "the", "source", "object", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L272-L296
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnCamelToHungarian
function _fnCamelToHungarian ( src, user, force ) { if ( ! src._hungarianMap ) { _fnHungarianMap( src ); } var hungarianKey; $.each( user, function (key, val) { hungarianKey = src._hungarianMap[ key ]; if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) ) { user[hungarianKey] = user[ key ]; if ( hungarianKey.charAt(0) === 'o' ) { _fnCamelToHungarian( src[hungarianKey], user[key] ); } } } ); }
javascript
function _fnCamelToHungarian ( src, user, force ) { if ( ! src._hungarianMap ) { _fnHungarianMap( src ); } var hungarianKey; $.each( user, function (key, val) { hungarianKey = src._hungarianMap[ key ]; if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) ) { user[hungarianKey] = user[ key ]; if ( hungarianKey.charAt(0) === 'o' ) { _fnCamelToHungarian( src[hungarianKey], user[key] ); } } } ); }
[ "function", "_fnCamelToHungarian", "(", "src", ",", "user", ",", "force", ")", "{", "if", "(", "!", "src", ".", "_hungarianMap", ")", "{", "_fnHungarianMap", "(", "src", ")", ";", "}", "var", "hungarianKey", ";", "$", ".", "each", "(", "user", ",", "function", "(", "key", ",", "val", ")", "{", "hungarianKey", "=", "src", ".", "_hungarianMap", "[", "key", "]", ";", "if", "(", "hungarianKey", "!==", "undefined", "&&", "(", "force", "||", "user", "[", "hungarianKey", "]", "===", "undefined", ")", ")", "{", "user", "[", "hungarianKey", "]", "=", "user", "[", "key", "]", ";", "if", "(", "hungarianKey", ".", "charAt", "(", "0", ")", "===", "'o'", ")", "{", "_fnCamelToHungarian", "(", "src", "[", "hungarianKey", "]", ",", "user", "[", "key", "]", ")", ";", "}", "}", "}", ")", ";", "}" ]
Convert from camel case parameters to Hungarian, based on a Hungarian map created by _fnHungarianMap. @param {object} src The model object which holds all parameters that can be mapped. @param {object} user The object to convert from camel case to Hungarian. @param {boolean} force When set to `true`, properties which already have a Hungarian value in the `user` object will be overwritten. Otherwise they won't be. @memberof DataTable#oApi
[ "Convert", "from", "camel", "case", "parameters", "to", "Hungarian", "based", "on", "a", "Hungarian", "map", "created", "by", "_fnHungarianMap", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L310-L332
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnLanguageCompat
function _fnLanguageCompat( oLanguage ) { var oDefaults = DataTable.defaults.oLanguage; var zeroRecords = oLanguage.sZeroRecords; /* Backwards compatibility - if there is no sEmptyTable given, then use the same as * sZeroRecords - assuming that is given. */ if ( !oLanguage.sEmptyTable && zeroRecords && oDefaults.sEmptyTable === "No data available in table" ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sEmptyTable' ); } /* Likewise with loading records */ if ( !oLanguage.sLoadingRecords && zeroRecords && oDefaults.sLoadingRecords === "Loading..." ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sLoadingRecords' ); } }
javascript
function _fnLanguageCompat( oLanguage ) { var oDefaults = DataTable.defaults.oLanguage; var zeroRecords = oLanguage.sZeroRecords; /* Backwards compatibility - if there is no sEmptyTable given, then use the same as * sZeroRecords - assuming that is given. */ if ( !oLanguage.sEmptyTable && zeroRecords && oDefaults.sEmptyTable === "No data available in table" ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sEmptyTable' ); } /* Likewise with loading records */ if ( !oLanguage.sLoadingRecords && zeroRecords && oDefaults.sLoadingRecords === "Loading..." ) { _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sLoadingRecords' ); } }
[ "function", "_fnLanguageCompat", "(", "oLanguage", ")", "{", "var", "oDefaults", "=", "DataTable", ".", "defaults", ".", "oLanguage", ";", "var", "zeroRecords", "=", "oLanguage", ".", "sZeroRecords", ";", "if", "(", "!", "oLanguage", ".", "sEmptyTable", "&&", "zeroRecords", "&&", "oDefaults", ".", "sEmptyTable", "===", "\"No data available in table\"", ")", "{", "_fnMap", "(", "oLanguage", ",", "oLanguage", ",", "'sZeroRecords'", ",", "'sEmptyTable'", ")", ";", "}", "if", "(", "!", "oLanguage", ".", "sLoadingRecords", "&&", "zeroRecords", "&&", "oDefaults", ".", "sLoadingRecords", "===", "\"Loading...\"", ")", "{", "_fnMap", "(", "oLanguage", ",", "oLanguage", ",", "'sZeroRecords'", ",", "'sLoadingRecords'", ")", ";", "}", "}" ]
Language compatibility - when certain options are given, and others aren't, we need to duplicate the values over, in order to provide backwards compatibility with older language files. @param {object} oSettings dataTables settings object @memberof DataTable#oApi
[ "Language", "compatibility", "-", "when", "certain", "options", "are", "given", "and", "others", "aren", "t", "we", "need", "to", "duplicate", "the", "values", "over", "in", "order", "to", "provide", "backwards", "compatibility", "with", "older", "language", "files", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L342-L362
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( o, knew, old ) { if ( o[ knew ] !== undefined ) { o[ old ] = o[ knew ]; } }
javascript
function ( o, knew, old ) { if ( o[ knew ] !== undefined ) { o[ old ] = o[ knew ]; } }
[ "function", "(", "o", ",", "knew", ",", "old", ")", "{", "if", "(", "o", "[", "knew", "]", "!==", "undefined", ")", "{", "o", "[", "old", "]", "=", "o", "[", "knew", "]", ";", "}", "}" ]
Map one parameter onto another @param {object} o Object to map @param {*} knew The new parameter name @param {*} old The old parameter name
[ "Map", "one", "parameter", "onto", "another" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L371-L375
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnCompatOpts
function _fnCompatOpts ( init ) { _fnCompatMap( init, 'ordering', 'bSort' ); _fnCompatMap( init, 'orderMulti', 'bSortMulti' ); _fnCompatMap( init, 'orderClasses', 'bSortClasses' ); _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' ); _fnCompatMap( init, 'order', 'aaSorting' ); _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' ); _fnCompatMap( init, 'paging', 'bPaginate' ); _fnCompatMap( init, 'pagingType', 'sPaginationType' ); _fnCompatMap( init, 'pageLength', 'iDisplayLength' ); _fnCompatMap( init, 'searching', 'bFilter' ); }
javascript
function _fnCompatOpts ( init ) { _fnCompatMap( init, 'ordering', 'bSort' ); _fnCompatMap( init, 'orderMulti', 'bSortMulti' ); _fnCompatMap( init, 'orderClasses', 'bSortClasses' ); _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' ); _fnCompatMap( init, 'order', 'aaSorting' ); _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' ); _fnCompatMap( init, 'paging', 'bPaginate' ); _fnCompatMap( init, 'pagingType', 'sPaginationType' ); _fnCompatMap( init, 'pageLength', 'iDisplayLength' ); _fnCompatMap( init, 'searching', 'bFilter' ); }
[ "function", "_fnCompatOpts", "(", "init", ")", "{", "_fnCompatMap", "(", "init", ",", "'ordering'", ",", "'bSort'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderMulti'", ",", "'bSortMulti'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderClasses'", ",", "'bSortClasses'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderCellsTop'", ",", "'bSortCellsTop'", ")", ";", "_fnCompatMap", "(", "init", ",", "'order'", ",", "'aaSorting'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderFixed'", ",", "'aaSortingFixed'", ")", ";", "_fnCompatMap", "(", "init", ",", "'paging'", ",", "'bPaginate'", ")", ";", "_fnCompatMap", "(", "init", ",", "'pagingType'", ",", "'sPaginationType'", ")", ";", "_fnCompatMap", "(", "init", ",", "'pageLength'", ",", "'iDisplayLength'", ")", ";", "_fnCompatMap", "(", "init", ",", "'searching'", ",", "'bFilter'", ")", ";", "}" ]
Provide backwards compatibility for the main DT options. Note that the new options are mapped onto the old parameters, so this is an external interface change only. @param {object} init Object to map
[ "Provide", "backwards", "compatibility", "for", "the", "main", "DT", "options", ".", "Note", "that", "the", "new", "options", "are", "mapped", "onto", "the", "old", "parameters", "so", "this", "is", "an", "external", "interface", "change", "only", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L384-L396
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnCompatCols
function _fnCompatCols ( init ) { _fnCompatMap( init, 'orderable', 'bSortable' ); _fnCompatMap( init, 'orderData', 'aDataSort' ); _fnCompatMap( init, 'orderSequence', 'asSorting' ); _fnCompatMap( init, 'orderDataType', 'sortDataType' ); }
javascript
function _fnCompatCols ( init ) { _fnCompatMap( init, 'orderable', 'bSortable' ); _fnCompatMap( init, 'orderData', 'aDataSort' ); _fnCompatMap( init, 'orderSequence', 'asSorting' ); _fnCompatMap( init, 'orderDataType', 'sortDataType' ); }
[ "function", "_fnCompatCols", "(", "init", ")", "{", "_fnCompatMap", "(", "init", ",", "'orderable'", ",", "'bSortable'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderData'", ",", "'aDataSort'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderSequence'", ",", "'asSorting'", ")", ";", "_fnCompatMap", "(", "init", ",", "'orderDataType'", ",", "'sortDataType'", ")", ";", "}" ]
Provide backwards compatibility for column options. Note that the new options are mapped onto the old parameters, so this is an external interface change only. @param {object} init Object to map
[ "Provide", "backwards", "compatibility", "for", "column", "options", ".", "Note", "that", "the", "new", "options", "are", "mapped", "onto", "the", "old", "parameters", "so", "this", "is", "an", "external", "interface", "change", "only", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L405-L411
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnBrowserDetect
function _fnBrowserDetect( settings ) { var browser = settings.oBrowser; // Scrolling feature / quirks detection var n = $('<div/>') .css( { position: 'absolute', top: 0, left: 0, height: 1, width: 1, overflow: 'hidden' } ) .append( $('<div/>') .css( { position: 'absolute', top: 1, left: 1, width: 100, overflow: 'scroll' } ) .append( $('<div class="test"/>') .css( { width: '100%', height: 10 } ) ) ) .appendTo( 'body' ); var test = n.find('.test'); // IE6/7 will oversize a width 100% element inside a scrolling element, to // include the width of the scrollbar, while other browsers ensure the inner // element is contained without forcing scrolling browser.bScrollOversize = test[0].offsetWidth === 100; // In rtl text layout, some browsers (most, but not all) will place the // scrollbar on the left, rather than the right. browser.bScrollbarLeft = test.offset().left !== 1; n.remove(); }
javascript
function _fnBrowserDetect( settings ) { var browser = settings.oBrowser; // Scrolling feature / quirks detection var n = $('<div/>') .css( { position: 'absolute', top: 0, left: 0, height: 1, width: 1, overflow: 'hidden' } ) .append( $('<div/>') .css( { position: 'absolute', top: 1, left: 1, width: 100, overflow: 'scroll' } ) .append( $('<div class="test"/>') .css( { width: '100%', height: 10 } ) ) ) .appendTo( 'body' ); var test = n.find('.test'); // IE6/7 will oversize a width 100% element inside a scrolling element, to // include the width of the scrollbar, while other browsers ensure the inner // element is contained without forcing scrolling browser.bScrollOversize = test[0].offsetWidth === 100; // In rtl text layout, some browsers (most, but not all) will place the // scrollbar on the left, rather than the right. browser.bScrollbarLeft = test.offset().left !== 1; n.remove(); }
[ "function", "_fnBrowserDetect", "(", "settings", ")", "{", "var", "browser", "=", "settings", ".", "oBrowser", ";", "var", "n", "=", "$", "(", "'<div/>'", ")", ".", "css", "(", "{", "position", ":", "'absolute'", ",", "top", ":", "0", ",", "left", ":", "0", ",", "height", ":", "1", ",", "width", ":", "1", ",", "overflow", ":", "'hidden'", "}", ")", ".", "append", "(", "$", "(", "'<div/>'", ")", ".", "css", "(", "{", "position", ":", "'absolute'", ",", "top", ":", "1", ",", "left", ":", "1", ",", "width", ":", "100", ",", "overflow", ":", "'scroll'", "}", ")", ".", "append", "(", "$", "(", "'<div class=\"test\"/>'", ")", ".", "css", "(", "{", "width", ":", "'100%'", ",", "height", ":", "10", "}", ")", ")", ")", ".", "appendTo", "(", "'body'", ")", ";", "var", "test", "=", "n", ".", "find", "(", "'.test'", ")", ";", "browser", ".", "bScrollOversize", "=", "test", "[", "0", "]", ".", "offsetWidth", "===", "100", ";", "browser", ".", "bScrollbarLeft", "=", "test", ".", "offset", "(", ")", ".", "left", "!==", "1", ";", "n", ".", "remove", "(", ")", ";", "}" ]
Browser feature detection for capabilities, quirks @param {object} settings dataTables settings object @memberof DataTable#oApi
[ "Browser", "feature", "detection", "for", "capabilities", "quirks" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L419-L464
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnGetColumns
function _fnGetColumns( oSettings, sParam ) { var a = []; $.map( oSettings.aoColumns, function(val, i) { if ( val[sParam] ) { a.push( i ); } } ); return a; }
javascript
function _fnGetColumns( oSettings, sParam ) { var a = []; $.map( oSettings.aoColumns, function(val, i) { if ( val[sParam] ) { a.push( i ); } } ); return a; }
[ "function", "_fnGetColumns", "(", "oSettings", ",", "sParam", ")", "{", "var", "a", "=", "[", "]", ";", "$", ".", "map", "(", "oSettings", ".", "aoColumns", ",", "function", "(", "val", ",", "i", ")", "{", "if", "(", "val", "[", "sParam", "]", ")", "{", "a", ".", "push", "(", "i", ")", ";", "}", "}", ")", ";", "return", "a", ";", "}" ]
Get an array of column indexes that match a given property @param {object} oSettings dataTables settings object @param {string} sParam Parameter in aoColumns to look for - typically bVisible or bSearchable @returns {array} Array of indexes with matched properties @memberof DataTable#oApi
[ "Get", "an", "array", "of", "column", "indexes", "that", "match", "a", "given", "property" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L701-L712
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnApplyColumnDefs
function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn ) { var i, iLen, j, jLen, k, kLen, def; // Column definitions with aTargets if ( aoColDefs ) { /* Loop over the definitions array - loop in reverse so first instance has priority */ for ( i=aoColDefs.length-1 ; i>=0 ; i-- ) { def = aoColDefs[i]; /* Each definition can target multiple columns, as it is an array */ var aTargets = def.targets !== undefined ? def.targets : def.aTargets; if ( ! $.isArray( aTargets ) ) { aTargets = [ aTargets ]; } for ( j=0, jLen=aTargets.length ; j<jLen ; j++ ) { if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 ) { /* Add columns that we don't yet know about */ while( oSettings.aoColumns.length <= aTargets[j] ) { _fnAddColumn( oSettings ); } /* Integer, basic index */ fn( aTargets[j], def ); } else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 ) { /* Negative integer, right to left column counting */ fn( oSettings.aoColumns.length+aTargets[j], def ); } else if ( typeof aTargets[j] === 'string' ) { /* Class name matching on TH element */ for ( k=0, kLen=oSettings.aoColumns.length ; k<kLen ; k++ ) { if ( aTargets[j] == "_all" || $(oSettings.aoColumns[k].nTh).hasClass( aTargets[j] ) ) { fn( k, def ); } } } } } } // Statically defined columns array if ( aoCols ) { for ( i=0, iLen=aoCols.length ; i<iLen ; i++ ) { fn( i, aoCols[i] ); } } }
javascript
function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn ) { var i, iLen, j, jLen, k, kLen, def; // Column definitions with aTargets if ( aoColDefs ) { /* Loop over the definitions array - loop in reverse so first instance has priority */ for ( i=aoColDefs.length-1 ; i>=0 ; i-- ) { def = aoColDefs[i]; /* Each definition can target multiple columns, as it is an array */ var aTargets = def.targets !== undefined ? def.targets : def.aTargets; if ( ! $.isArray( aTargets ) ) { aTargets = [ aTargets ]; } for ( j=0, jLen=aTargets.length ; j<jLen ; j++ ) { if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 ) { /* Add columns that we don't yet know about */ while( oSettings.aoColumns.length <= aTargets[j] ) { _fnAddColumn( oSettings ); } /* Integer, basic index */ fn( aTargets[j], def ); } else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 ) { /* Negative integer, right to left column counting */ fn( oSettings.aoColumns.length+aTargets[j], def ); } else if ( typeof aTargets[j] === 'string' ) { /* Class name matching on TH element */ for ( k=0, kLen=oSettings.aoColumns.length ; k<kLen ; k++ ) { if ( aTargets[j] == "_all" || $(oSettings.aoColumns[k].nTh).hasClass( aTargets[j] ) ) { fn( k, def ); } } } } } } // Statically defined columns array if ( aoCols ) { for ( i=0, iLen=aoCols.length ; i<iLen ; i++ ) { fn( i, aoCols[i] ); } } }
[ "function", "_fnApplyColumnDefs", "(", "oSettings", ",", "aoColDefs", ",", "aoCols", ",", "fn", ")", "{", "var", "i", ",", "iLen", ",", "j", ",", "jLen", ",", "k", ",", "kLen", ",", "def", ";", "if", "(", "aoColDefs", ")", "{", "for", "(", "i", "=", "aoColDefs", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "def", "=", "aoColDefs", "[", "i", "]", ";", "var", "aTargets", "=", "def", ".", "targets", "!==", "undefined", "?", "def", ".", "targets", ":", "def", ".", "aTargets", ";", "if", "(", "!", "$", ".", "isArray", "(", "aTargets", ")", ")", "{", "aTargets", "=", "[", "aTargets", "]", ";", "}", "for", "(", "j", "=", "0", ",", "jLen", "=", "aTargets", ".", "length", ";", "j", "<", "jLen", ";", "j", "++", ")", "{", "if", "(", "typeof", "aTargets", "[", "j", "]", "===", "'number'", "&&", "aTargets", "[", "j", "]", ">=", "0", ")", "{", "while", "(", "oSettings", ".", "aoColumns", ".", "length", "<=", "aTargets", "[", "j", "]", ")", "{", "_fnAddColumn", "(", "oSettings", ")", ";", "}", "fn", "(", "aTargets", "[", "j", "]", ",", "def", ")", ";", "}", "else", "if", "(", "typeof", "aTargets", "[", "j", "]", "===", "'number'", "&&", "aTargets", "[", "j", "]", "<", "0", ")", "{", "fn", "(", "oSettings", ".", "aoColumns", ".", "length", "+", "aTargets", "[", "j", "]", ",", "def", ")", ";", "}", "else", "if", "(", "typeof", "aTargets", "[", "j", "]", "===", "'string'", ")", "{", "for", "(", "k", "=", "0", ",", "kLen", "=", "oSettings", ".", "aoColumns", ".", "length", ";", "k", "<", "kLen", ";", "k", "++", ")", "{", "if", "(", "aTargets", "[", "j", "]", "==", "\"_all\"", "||", "$", "(", "oSettings", ".", "aoColumns", "[", "k", "]", ".", "nTh", ")", ".", "hasClass", "(", "aTargets", "[", "j", "]", ")", ")", "{", "fn", "(", "k", ",", "def", ")", ";", "}", "}", "}", "}", "}", "}", "if", "(", "aoCols", ")", "{", "for", "(", "i", "=", "0", ",", "iLen", "=", "aoCols", ".", "length", ";", "i", "<", "iLen", ";", "i", "++", ")", "{", "fn", "(", "i", ",", "aoCols", "[", "i", "]", ")", ";", "}", "}", "}" ]
Take the column definitions and static columns arrays and calculate how they relate to column indexes. The callback function will then apply the definition found for a column to a suitable configuration object. @param {object} oSettings dataTables settings object @param {array} aoColDefs The aoColumnDefs array that is to be applied @param {array} aoCols The aoColumns array that defines columns individually @param {function} fn Callback function - takes two parameters, the calculated column index and the definition for that column. @memberof DataTable#oApi
[ "Take", "the", "column", "definitions", "and", "static", "columns", "arrays", "and", "calculate", "how", "they", "relate", "to", "column", "indexes", ".", "The", "callback", "function", "will", "then", "apply", "the", "definition", "found", "for", "a", "column", "to", "a", "suitable", "configuration", "object", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L779-L843
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnGetCellData
function _fnGetCellData( oSettings, iRow, iCol, sSpecific ) { var oCol = oSettings.aoColumns[iCol]; var oData = oSettings.aoData[iRow]._aData; var sData = oCol.fnGetData( oData, sSpecific ); if ( sData === undefined ) { if ( oSettings.iDrawError != oSettings.iDraw && oCol.sDefaultContent === null ) { _fnLog( oSettings, 0, "Requested unknown parameter "+ (typeof oCol.mData=='function' ? '{function}' : "'"+oCol.mData+"'")+ " for row "+iRow, 4 ); oSettings.iDrawError = oSettings.iDraw; } return oCol.sDefaultContent; } /* When the data source is null, we can use default column data */ if ( (sData === oData || sData === null) && oCol.sDefaultContent !== null ) { sData = oCol.sDefaultContent; } else if ( typeof sData === 'function' ) { // If the data source is a function, then we run it and use the return return sData(); } if ( sData === null && sSpecific == 'display' ) { return ''; } return sData; }
javascript
function _fnGetCellData( oSettings, iRow, iCol, sSpecific ) { var oCol = oSettings.aoColumns[iCol]; var oData = oSettings.aoData[iRow]._aData; var sData = oCol.fnGetData( oData, sSpecific ); if ( sData === undefined ) { if ( oSettings.iDrawError != oSettings.iDraw && oCol.sDefaultContent === null ) { _fnLog( oSettings, 0, "Requested unknown parameter "+ (typeof oCol.mData=='function' ? '{function}' : "'"+oCol.mData+"'")+ " for row "+iRow, 4 ); oSettings.iDrawError = oSettings.iDraw; } return oCol.sDefaultContent; } /* When the data source is null, we can use default column data */ if ( (sData === oData || sData === null) && oCol.sDefaultContent !== null ) { sData = oCol.sDefaultContent; } else if ( typeof sData === 'function' ) { // If the data source is a function, then we run it and use the return return sData(); } if ( sData === null && sSpecific == 'display' ) { return ''; } return sData; }
[ "function", "_fnGetCellData", "(", "oSettings", ",", "iRow", ",", "iCol", ",", "sSpecific", ")", "{", "var", "oCol", "=", "oSettings", ".", "aoColumns", "[", "iCol", "]", ";", "var", "oData", "=", "oSettings", ".", "aoData", "[", "iRow", "]", ".", "_aData", ";", "var", "sData", "=", "oCol", ".", "fnGetData", "(", "oData", ",", "sSpecific", ")", ";", "if", "(", "sData", "===", "undefined", ")", "{", "if", "(", "oSettings", ".", "iDrawError", "!=", "oSettings", ".", "iDraw", "&&", "oCol", ".", "sDefaultContent", "===", "null", ")", "{", "_fnLog", "(", "oSettings", ",", "0", ",", "\"Requested unknown parameter \"", "+", "(", "typeof", "oCol", ".", "mData", "==", "'function'", "?", "'{function}'", ":", "\"'\"", "+", "oCol", ".", "mData", "+", "\"'\"", ")", "+", "\" for row \"", "+", "iRow", ",", "4", ")", ";", "oSettings", ".", "iDrawError", "=", "oSettings", ".", "iDraw", ";", "}", "return", "oCol", ".", "sDefaultContent", ";", "}", "if", "(", "(", "sData", "===", "oData", "||", "sData", "===", "null", ")", "&&", "oCol", ".", "sDefaultContent", "!==", "null", ")", "{", "sData", "=", "oCol", ".", "sDefaultContent", ";", "}", "else", "if", "(", "typeof", "sData", "===", "'function'", ")", "{", "return", "sData", "(", ")", ";", "}", "if", "(", "sData", "===", "null", "&&", "sSpecific", "==", "'display'", ")", "{", "return", "''", ";", "}", "return", "sData", ";", "}" ]
Get the data for a given cell from the internal cache, taking into account data mapping @param {object} oSettings dataTables settings object @param {int} iRow aoData row id @param {int} iCol Column index @param {string} sSpecific data get type ('display', 'type' 'filter' 'sort') @returns {*} Cell data @memberof DataTable#oApi
[ "Get", "the", "data", "for", "a", "given", "cell", "from", "the", "internal", "cache", "taking", "into", "account", "data", "mapping" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L978-L1012
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnInvalidateRow
function _fnInvalidateRow( settings, rowIdx, src, column ) { var row = settings.aoData[ rowIdx ]; var i, ien; // Are we reading last data from DOM or the data object? if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) { // Read the data from the DOM row._aData = _fnGetRowElements( settings, row.nTr ).data; } else { // Reading from data object, update the DOM var cells = row.anCells; for ( i=0, ien=cells.length ; i<ien ; i++ ) { cells[i].innerHTML = _fnGetCellData( settings, rowIdx, i, 'display' ); } } row._aSortData = null; row._aFilterData = null; // Invalidate the type for a specific column (if given) or all columns since // the data might have changed var cols = settings.aoColumns; if ( column !== undefined ) { cols[ column ].sType = null; } else { for ( i=0, ien=cols.length ; i<ien ; i++ ) { cols[i].sType = null; } } // Update DataTables special `DT_*` attributes for the row _fnRowAttributes( row ); }
javascript
function _fnInvalidateRow( settings, rowIdx, src, column ) { var row = settings.aoData[ rowIdx ]; var i, ien; // Are we reading last data from DOM or the data object? if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) { // Read the data from the DOM row._aData = _fnGetRowElements( settings, row.nTr ).data; } else { // Reading from data object, update the DOM var cells = row.anCells; for ( i=0, ien=cells.length ; i<ien ; i++ ) { cells[i].innerHTML = _fnGetCellData( settings, rowIdx, i, 'display' ); } } row._aSortData = null; row._aFilterData = null; // Invalidate the type for a specific column (if given) or all columns since // the data might have changed var cols = settings.aoColumns; if ( column !== undefined ) { cols[ column ].sType = null; } else { for ( i=0, ien=cols.length ; i<ien ; i++ ) { cols[i].sType = null; } } // Update DataTables special `DT_*` attributes for the row _fnRowAttributes( row ); }
[ "function", "_fnInvalidateRow", "(", "settings", ",", "rowIdx", ",", "src", ",", "column", ")", "{", "var", "row", "=", "settings", ".", "aoData", "[", "rowIdx", "]", ";", "var", "i", ",", "ien", ";", "if", "(", "src", "===", "'dom'", "||", "(", "(", "!", "src", "||", "src", "===", "'auto'", ")", "&&", "row", ".", "src", "===", "'dom'", ")", ")", "{", "row", ".", "_aData", "=", "_fnGetRowElements", "(", "settings", ",", "row", ".", "nTr", ")", ".", "data", ";", "}", "else", "{", "var", "cells", "=", "row", ".", "anCells", ";", "for", "(", "i", "=", "0", ",", "ien", "=", "cells", ".", "length", ";", "i", "<", "ien", ";", "i", "++", ")", "{", "cells", "[", "i", "]", ".", "innerHTML", "=", "_fnGetCellData", "(", "settings", ",", "rowIdx", ",", "i", ",", "'display'", ")", ";", "}", "}", "row", ".", "_aSortData", "=", "null", ";", "row", ".", "_aFilterData", "=", "null", ";", "var", "cols", "=", "settings", ".", "aoColumns", ";", "if", "(", "column", "!==", "undefined", ")", "{", "cols", "[", "column", "]", ".", "sType", "=", "null", ";", "}", "else", "{", "for", "(", "i", "=", "0", ",", "ien", "=", "cols", ".", "length", ";", "i", "<", "ien", ";", "i", "++", ")", "{", "cols", "[", "i", "]", ".", "sType", "=", "null", ";", "}", "}", "_fnRowAttributes", "(", "row", ")", ";", "}" ]
Mark cached data as invalid such that a re-read of the data will occur when the cached data is next requested. Also update from the data source object. @param {object} settings DataTables settings object @param {int} rowIdx Row index to invalidate @memberof DataTable#oApi @todo For the modularisation of v1.11 this will need to become a callback, so the sort and filter methods can subscribe to it. That will required initialisation options for sorting, which is why it is not already baked in
[ "Mark", "cached", "data", "as", "invalid", "such", "that", "a", "re", "-", "read", "of", "the", "data", "will", "occur", "when", "the", "cached", "data", "is", "next", "requested", ".", "Also", "update", "from", "the", "data", "source", "object", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L1346-L1382
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnGetRowElements
function _fnGetRowElements( settings, row ) { var d = [], tds = [], td = row.firstChild, name, col, o, i=0, contents, columns = settings.aoColumns; var attr = function ( str, data, td ) { if ( typeof str === 'string' ) { var idx = str.indexOf('@'); if ( idx !== -1 ) { var src = str.substring( idx+1 ); o[ '@'+src ] = td.getAttribute( src ); } } }; while ( td ) { name = td.nodeName.toUpperCase(); if ( name == "TD" || name == "TH" ) { col = columns[i]; contents = $.trim(td.innerHTML); if ( col && col._bAttrSrc ) { o = { display: contents }; attr( col.mData.sort, o, td ); attr( col.mData.type, o, td ); attr( col.mData.filter, o, td ); d.push( o ); } else { d.push( contents ); } tds.push( td ); i++; } td = td.nextSibling; } return { data: d, cells: tds }; }
javascript
function _fnGetRowElements( settings, row ) { var d = [], tds = [], td = row.firstChild, name, col, o, i=0, contents, columns = settings.aoColumns; var attr = function ( str, data, td ) { if ( typeof str === 'string' ) { var idx = str.indexOf('@'); if ( idx !== -1 ) { var src = str.substring( idx+1 ); o[ '@'+src ] = td.getAttribute( src ); } } }; while ( td ) { name = td.nodeName.toUpperCase(); if ( name == "TD" || name == "TH" ) { col = columns[i]; contents = $.trim(td.innerHTML); if ( col && col._bAttrSrc ) { o = { display: contents }; attr( col.mData.sort, o, td ); attr( col.mData.type, o, td ); attr( col.mData.filter, o, td ); d.push( o ); } else { d.push( contents ); } tds.push( td ); i++; } td = td.nextSibling; } return { data: d, cells: tds }; }
[ "function", "_fnGetRowElements", "(", "settings", ",", "row", ")", "{", "var", "d", "=", "[", "]", ",", "tds", "=", "[", "]", ",", "td", "=", "row", ".", "firstChild", ",", "name", ",", "col", ",", "o", ",", "i", "=", "0", ",", "contents", ",", "columns", "=", "settings", ".", "aoColumns", ";", "var", "attr", "=", "function", "(", "str", ",", "data", ",", "td", ")", "{", "if", "(", "typeof", "str", "===", "'string'", ")", "{", "var", "idx", "=", "str", ".", "indexOf", "(", "'@'", ")", ";", "if", "(", "idx", "!==", "-", "1", ")", "{", "var", "src", "=", "str", ".", "substring", "(", "idx", "+", "1", ")", ";", "o", "[", "'@'", "+", "src", "]", "=", "td", ".", "getAttribute", "(", "src", ")", ";", "}", "}", "}", ";", "while", "(", "td", ")", "{", "name", "=", "td", ".", "nodeName", ".", "toUpperCase", "(", ")", ";", "if", "(", "name", "==", "\"TD\"", "||", "name", "==", "\"TH\"", ")", "{", "col", "=", "columns", "[", "i", "]", ";", "contents", "=", "$", ".", "trim", "(", "td", ".", "innerHTML", ")", ";", "if", "(", "col", "&&", "col", ".", "_bAttrSrc", ")", "{", "o", "=", "{", "display", ":", "contents", "}", ";", "attr", "(", "col", ".", "mData", ".", "sort", ",", "o", ",", "td", ")", ";", "attr", "(", "col", ".", "mData", ".", "type", ",", "o", ",", "td", ")", ";", "attr", "(", "col", ".", "mData", ".", "filter", ",", "o", ",", "td", ")", ";", "d", ".", "push", "(", "o", ")", ";", "}", "else", "{", "d", ".", "push", "(", "contents", ")", ";", "}", "tds", ".", "push", "(", "td", ")", ";", "i", "++", ";", "}", "td", "=", "td", ".", "nextSibling", ";", "}", "return", "{", "data", ":", "d", ",", "cells", ":", "tds", "}", ";", "}" ]
Build a data source object from an HTML row, reading the contents of the cells that are in the row. @param {object} settings DataTables settings object @param {node} TR element from which to read data @returns {object} Object with two parameters: `data` the data read, in document order, and `cells` and array of nodes (they can be useful to the caller, so rather than needing a second traversal to get them, just return them from here). @memberof DataTable#oApi
[ "Build", "a", "data", "source", "object", "from", "an", "HTML", "row", "reading", "the", "contents", "of", "the", "cells", "that", "are", "in", "the", "row", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L1397-L1450
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnBuildAjax
function _fnBuildAjax( oSettings, data, fn ) { // Compatibility with 1.9-, allow fnServerData and event to manipulate _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] ); // Convert to object based for 1.10+ if using the old scheme if ( data && data.__legacy ) { var tmp = {}; var rbracket = /(.*?)\[\]$/; $.each( data, function (key, val) { var match = val.name.match(rbracket); if ( match ) { // Support for arrays var name = match[0]; if ( ! tmp[ name ] ) { tmp[ name ] = []; } tmp[ name ].push( val.value ); } else { tmp[val.name] = val.value; } } ); data = tmp; } var ajaxData; var ajax = oSettings.ajax; var instance = oSettings.oInstance; if ( $.isPlainObject( ajax ) && ajax.data ) { ajaxData = ajax.data; var newData = $.isFunction( ajaxData ) ? ajaxData( data ) : // fn can manipulate data or return an object ajaxData; // object or array to merge // If the function returned an object, use that alone data = $.isFunction( ajaxData ) && newData ? newData : $.extend( true, data, newData ); // Remove the data property as we've resolved it already and don't want // jQuery to do it again (it is restored at the end of the function) delete ajax.data; } var baseAjax = { "data": data, "success": function (json) { var error = json.error || json.sError; if ( error ) { oSettings.oApi._fnLog( oSettings, 0, error ); } oSettings.json = json; _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] ); fn( json ); }, "dataType": "json", "cache": false, "type": oSettings.sServerMethod, "error": function (xhr, error, thrown) { var log = oSettings.oApi._fnLog; if ( error == "parsererror" ) { log( oSettings, 0, 'Invalid JSON response', 1 ); } else { log( oSettings, 0, 'Ajax error', 7 ); } } }; if ( oSettings.fnServerData ) { // DataTables 1.9- compatibility oSettings.fnServerData.call( instance, oSettings.sAjaxSource, data, fn, oSettings ); } else if ( oSettings.sAjaxSource || typeof ajax === 'string' ) { // DataTables 1.9- compatibility oSettings.jqXHR = $.ajax( $.extend( baseAjax, { url: ajax || oSettings.sAjaxSource } ) ); } else if ( $.isFunction( ajax ) ) { // Is a function - let the caller define what needs to be done oSettings.jqXHR = ajax.call( instance, data, fn, oSettings ); } else { // Object to extend the base settings oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) ); // Restore for next time around ajax.data = ajaxData; } }
javascript
function _fnBuildAjax( oSettings, data, fn ) { // Compatibility with 1.9-, allow fnServerData and event to manipulate _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] ); // Convert to object based for 1.10+ if using the old scheme if ( data && data.__legacy ) { var tmp = {}; var rbracket = /(.*?)\[\]$/; $.each( data, function (key, val) { var match = val.name.match(rbracket); if ( match ) { // Support for arrays var name = match[0]; if ( ! tmp[ name ] ) { tmp[ name ] = []; } tmp[ name ].push( val.value ); } else { tmp[val.name] = val.value; } } ); data = tmp; } var ajaxData; var ajax = oSettings.ajax; var instance = oSettings.oInstance; if ( $.isPlainObject( ajax ) && ajax.data ) { ajaxData = ajax.data; var newData = $.isFunction( ajaxData ) ? ajaxData( data ) : // fn can manipulate data or return an object ajaxData; // object or array to merge // If the function returned an object, use that alone data = $.isFunction( ajaxData ) && newData ? newData : $.extend( true, data, newData ); // Remove the data property as we've resolved it already and don't want // jQuery to do it again (it is restored at the end of the function) delete ajax.data; } var baseAjax = { "data": data, "success": function (json) { var error = json.error || json.sError; if ( error ) { oSettings.oApi._fnLog( oSettings, 0, error ); } oSettings.json = json; _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] ); fn( json ); }, "dataType": "json", "cache": false, "type": oSettings.sServerMethod, "error": function (xhr, error, thrown) { var log = oSettings.oApi._fnLog; if ( error == "parsererror" ) { log( oSettings, 0, 'Invalid JSON response', 1 ); } else { log( oSettings, 0, 'Ajax error', 7 ); } } }; if ( oSettings.fnServerData ) { // DataTables 1.9- compatibility oSettings.fnServerData.call( instance, oSettings.sAjaxSource, data, fn, oSettings ); } else if ( oSettings.sAjaxSource || typeof ajax === 'string' ) { // DataTables 1.9- compatibility oSettings.jqXHR = $.ajax( $.extend( baseAjax, { url: ajax || oSettings.sAjaxSource } ) ); } else if ( $.isFunction( ajax ) ) { // Is a function - let the caller define what needs to be done oSettings.jqXHR = ajax.call( instance, data, fn, oSettings ); } else { // Object to extend the base settings oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) ); // Restore for next time around ajax.data = ajaxData; } }
[ "function", "_fnBuildAjax", "(", "oSettings", ",", "data", ",", "fn", ")", "{", "_fnCallbackFire", "(", "oSettings", ",", "'aoServerParams'", ",", "'serverParams'", ",", "[", "data", "]", ")", ";", "if", "(", "data", "&&", "data", ".", "__legacy", ")", "{", "var", "tmp", "=", "{", "}", ";", "var", "rbracket", "=", "/", "(.*?)\\[\\]$", "/", ";", "$", ".", "each", "(", "data", ",", "function", "(", "key", ",", "val", ")", "{", "var", "match", "=", "val", ".", "name", ".", "match", "(", "rbracket", ")", ";", "if", "(", "match", ")", "{", "var", "name", "=", "match", "[", "0", "]", ";", "if", "(", "!", "tmp", "[", "name", "]", ")", "{", "tmp", "[", "name", "]", "=", "[", "]", ";", "}", "tmp", "[", "name", "]", ".", "push", "(", "val", ".", "value", ")", ";", "}", "else", "{", "tmp", "[", "val", ".", "name", "]", "=", "val", ".", "value", ";", "}", "}", ")", ";", "data", "=", "tmp", ";", "}", "var", "ajaxData", ";", "var", "ajax", "=", "oSettings", ".", "ajax", ";", "var", "instance", "=", "oSettings", ".", "oInstance", ";", "if", "(", "$", ".", "isPlainObject", "(", "ajax", ")", "&&", "ajax", ".", "data", ")", "{", "ajaxData", "=", "ajax", ".", "data", ";", "var", "newData", "=", "$", ".", "isFunction", "(", "ajaxData", ")", "?", "ajaxData", "(", "data", ")", ":", "ajaxData", ";", "data", "=", "$", ".", "isFunction", "(", "ajaxData", ")", "&&", "newData", "?", "newData", ":", "$", ".", "extend", "(", "true", ",", "data", ",", "newData", ")", ";", "delete", "ajax", ".", "data", ";", "}", "var", "baseAjax", "=", "{", "\"data\"", ":", "data", ",", "\"success\"", ":", "function", "(", "json", ")", "{", "var", "error", "=", "json", ".", "error", "||", "json", ".", "sError", ";", "if", "(", "error", ")", "{", "oSettings", ".", "oApi", ".", "_fnLog", "(", "oSettings", ",", "0", ",", "error", ")", ";", "}", "oSettings", ".", "json", "=", "json", ";", "_fnCallbackFire", "(", "oSettings", ",", "null", ",", "'xhr'", ",", "[", "oSettings", ",", "json", "]", ")", ";", "fn", "(", "json", ")", ";", "}", ",", "\"dataType\"", ":", "\"json\"", ",", "\"cache\"", ":", "false", ",", "\"type\"", ":", "oSettings", ".", "sServerMethod", ",", "\"error\"", ":", "function", "(", "xhr", ",", "error", ",", "thrown", ")", "{", "var", "log", "=", "oSettings", ".", "oApi", ".", "_fnLog", ";", "if", "(", "error", "==", "\"parsererror\"", ")", "{", "log", "(", "oSettings", ",", "0", ",", "'Invalid JSON response'", ",", "1", ")", ";", "}", "else", "{", "log", "(", "oSettings", ",", "0", ",", "'Ajax error'", ",", "7", ")", ";", "}", "}", "}", ";", "if", "(", "oSettings", ".", "fnServerData", ")", "{", "oSettings", ".", "fnServerData", ".", "call", "(", "instance", ",", "oSettings", ".", "sAjaxSource", ",", "data", ",", "fn", ",", "oSettings", ")", ";", "}", "else", "if", "(", "oSettings", ".", "sAjaxSource", "||", "typeof", "ajax", "===", "'string'", ")", "{", "oSettings", ".", "jqXHR", "=", "$", ".", "ajax", "(", "$", ".", "extend", "(", "baseAjax", ",", "{", "url", ":", "ajax", "||", "oSettings", ".", "sAjaxSource", "}", ")", ")", ";", "}", "else", "if", "(", "$", ".", "isFunction", "(", "ajax", ")", ")", "{", "oSettings", ".", "jqXHR", "=", "ajax", ".", "call", "(", "instance", ",", "data", ",", "fn", ",", "oSettings", ")", ";", "}", "else", "{", "oSettings", ".", "jqXHR", "=", "$", ".", "ajax", "(", "$", ".", "extend", "(", "baseAjax", ",", "ajax", ")", ")", ";", "ajax", ".", "data", "=", "ajaxData", ";", "}", "}" ]
Create an Ajax call based on the table's settings, taking into account that parameters can have multiple forms, and backwards compatibility. @param {object} oSettings dataTables settings object @param {array} data Data to send to the server, required by DataTables - may be augmented by developer callbacks @param {function} fn Callback function to run when data is obtained
[ "Create", "an", "Ajax", "call", "based", "on", "the", "table", "s", "settings", "taking", "into", "account", "that", "parameters", "can", "have", "multiple", "forms", "and", "backwards", "compatibility", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L2199-L2304
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnAjaxDataSrc
function _fnAjaxDataSrc ( oSettings, json ) { var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ? oSettings.ajax.dataSrc : oSettings.sAjaxDataProp; // Compatibility with 1.9-. // Compatibility with 1.9-. In order to read from aaData, check if the // default has been changed, if not, check for aaData if ( dataSrc === 'data' ) { return json.aaData || json[dataSrc]; } return dataSrc !== "" ? _fnGetObjectDataFn( dataSrc )( json ) : json; }
javascript
function _fnAjaxDataSrc ( oSettings, json ) { var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ? oSettings.ajax.dataSrc : oSettings.sAjaxDataProp; // Compatibility with 1.9-. // Compatibility with 1.9-. In order to read from aaData, check if the // default has been changed, if not, check for aaData if ( dataSrc === 'data' ) { return json.aaData || json[dataSrc]; } return dataSrc !== "" ? _fnGetObjectDataFn( dataSrc )( json ) : json; }
[ "function", "_fnAjaxDataSrc", "(", "oSettings", ",", "json", ")", "{", "var", "dataSrc", "=", "$", ".", "isPlainObject", "(", "oSettings", ".", "ajax", ")", "&&", "oSettings", ".", "ajax", ".", "dataSrc", "!==", "undefined", "?", "oSettings", ".", "ajax", ".", "dataSrc", ":", "oSettings", ".", "sAjaxDataProp", ";", "if", "(", "dataSrc", "===", "'data'", ")", "{", "return", "json", ".", "aaData", "||", "json", "[", "dataSrc", "]", ";", "}", "return", "dataSrc", "!==", "\"\"", "?", "_fnGetObjectDataFn", "(", "dataSrc", ")", "(", "json", ")", ":", "json", ";", "}" ]
Get the data from the JSON data source to use for drawing a table. Using `_fnGetObjectDataFn` allows the data to be sourced from a property of the source object, or from a processing function. @param {object} oSettings dataTables settings object @param {object} json Data source object / array from the server @return {array} Array of data to use
[ "Get", "the", "data", "from", "the", "JSON", "data", "source", "to", "use", "for", "drawing", "a", "table", ".", "Using", "_fnGetObjectDataFn", "allows", "the", "data", "to", "be", "sourced", "from", "a", "property", "of", "the", "source", "object", "or", "from", "a", "processing", "function", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L2494-L2509
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function(nSizer) { var style = nSizer.style; style.paddingTop = "0"; style.paddingBottom = "0"; style.borderTopWidth = "0"; style.borderBottomWidth = "0"; style.height = 0; }
javascript
function(nSizer) { var style = nSizer.style; style.paddingTop = "0"; style.paddingBottom = "0"; style.borderTopWidth = "0"; style.borderBottomWidth = "0"; style.height = 0; }
[ "function", "(", "nSizer", ")", "{", "var", "style", "=", "nSizer", ".", "style", ";", "style", ".", "paddingTop", "=", "\"0\"", ";", "style", ".", "paddingBottom", "=", "\"0\"", ";", "style", ".", "borderTopWidth", "=", "\"0\"", ";", "style", ".", "borderBottomWidth", "=", "\"0\"", ";", "style", ".", "height", "=", "0", ";", "}" ]
Given that this is such a monster function, a lot of variables are use to try and keep the minimised size as small as possible
[ "Given", "that", "this", "is", "such", "a", "monster", "function", "a", "lot", "of", "variables", "are", "use", "to", "try", "and", "keep", "the", "minimised", "size", "as", "small", "as", "possible" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L3473-L3480
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnScrollingWidthAdjust
function _fnScrollingWidthAdjust ( settings, n ) { var scroll = settings.oScroll; if ( scroll.sX || scroll.sY ) { // When y-scrolling only, we want to remove the width of the scroll bar // so the table + scroll bar will fit into the area available, otherwise // we fix the table at its current size with no adjustment var correction = ! scroll.sX ? scroll.iBarWidth : 0; n.style.width = _fnStringToCss( $(n).outerWidth() - correction ); } }
javascript
function _fnScrollingWidthAdjust ( settings, n ) { var scroll = settings.oScroll; if ( scroll.sX || scroll.sY ) { // When y-scrolling only, we want to remove the width of the scroll bar // so the table + scroll bar will fit into the area available, otherwise // we fix the table at its current size with no adjustment var correction = ! scroll.sX ? scroll.iBarWidth : 0; n.style.width = _fnStringToCss( $(n).outerWidth() - correction ); } }
[ "function", "_fnScrollingWidthAdjust", "(", "settings", ",", "n", ")", "{", "var", "scroll", "=", "settings", ".", "oScroll", ";", "if", "(", "scroll", ".", "sX", "||", "scroll", ".", "sY", ")", "{", "var", "correction", "=", "!", "scroll", ".", "sX", "?", "scroll", ".", "iBarWidth", ":", "0", ";", "n", ".", "style", ".", "width", "=", "_fnStringToCss", "(", "$", "(", "n", ")", ".", "outerWidth", "(", ")", "-", "correction", ")", ";", "}", "}" ]
Adjust a table's width to take account of vertical scroll bar @param {object} oSettings dataTables settings object @param {node} n table node @memberof DataTable#oApi
[ "Adjust", "a", "table", "s", "width", "to", "take", "account", "of", "vertical", "scroll", "bar" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L3986-L3997
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnScrollBarWidth
function _fnScrollBarWidth () { // On first run a static variable is set, since this is only needed once. // Subsequent runs will just use the previously calculated value if ( ! DataTable.__scrollbarWidth ) { var inner = $('<p/>').css( { width: '100%', height: 200, padding: 0 } )[0]; var outer = $('<div/>') .css( { position: 'absolute', top: 0, left: 0, width: 200, height: 150, padding: 0, overflow: 'hidden', visibility: 'hidden' } ) .append( inner ) .appendTo( 'body' ); var w1 = inner.offsetWidth; outer.css( 'overflow', 'scroll' ); var w2 = inner.offsetWidth; if ( w1 === w2 ) { w2 = outer[0].clientWidth; } outer.remove(); DataTable.__scrollbarWidth = w1 - w2; } return DataTable.__scrollbarWidth; }
javascript
function _fnScrollBarWidth () { // On first run a static variable is set, since this is only needed once. // Subsequent runs will just use the previously calculated value if ( ! DataTable.__scrollbarWidth ) { var inner = $('<p/>').css( { width: '100%', height: 200, padding: 0 } )[0]; var outer = $('<div/>') .css( { position: 'absolute', top: 0, left: 0, width: 200, height: 150, padding: 0, overflow: 'hidden', visibility: 'hidden' } ) .append( inner ) .appendTo( 'body' ); var w1 = inner.offsetWidth; outer.css( 'overflow', 'scroll' ); var w2 = inner.offsetWidth; if ( w1 === w2 ) { w2 = outer[0].clientWidth; } outer.remove(); DataTable.__scrollbarWidth = w1 - w2; } return DataTable.__scrollbarWidth; }
[ "function", "_fnScrollBarWidth", "(", ")", "{", "if", "(", "!", "DataTable", ".", "__scrollbarWidth", ")", "{", "var", "inner", "=", "$", "(", "'<p/>'", ")", ".", "css", "(", "{", "width", ":", "'100%'", ",", "height", ":", "200", ",", "padding", ":", "0", "}", ")", "[", "0", "]", ";", "var", "outer", "=", "$", "(", "'<div/>'", ")", ".", "css", "(", "{", "position", ":", "'absolute'", ",", "top", ":", "0", ",", "left", ":", "0", ",", "width", ":", "200", ",", "height", ":", "150", ",", "padding", ":", "0", ",", "overflow", ":", "'hidden'", ",", "visibility", ":", "'hidden'", "}", ")", ".", "append", "(", "inner", ")", ".", "appendTo", "(", "'body'", ")", ";", "var", "w1", "=", "inner", ".", "offsetWidth", ";", "outer", ".", "css", "(", "'overflow'", ",", "'scroll'", ")", ";", "var", "w2", "=", "inner", ".", "offsetWidth", ";", "if", "(", "w1", "===", "w2", ")", "{", "w2", "=", "outer", "[", "0", "]", ".", "clientWidth", ";", "}", "outer", ".", "remove", "(", ")", ";", "DataTable", ".", "__scrollbarWidth", "=", "w1", "-", "w2", ";", "}", "return", "DataTable", ".", "__scrollbarWidth", ";", "}" ]
Get the width of a scroll bar in this browser being used @returns {int} width in pixels @memberof DataTable#oApi
[ "Get", "the", "width", "of", "a", "scroll", "bar", "in", "this", "browser", "being", "used" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L4076-L4115
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnSortListener
function _fnSortListener ( settings, colIdx, append, callback ) { var col = settings.aoColumns[ colIdx ]; var sorting = settings.aaSorting; var asSorting = col.asSorting; var nextSortIdx; var next = function ( a ) { var idx = a._idx; if ( idx === undefined ) { idx = $.inArray( a[1], asSorting ); } return idx+1 >= asSorting.length ? 0 : idx+1; }; // If appending the sort then we are multi-column sorting if ( append && settings.oFeatures.bSortMulti ) { // Are we already doing some kind of sort on this column? var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') ); if ( sortIdx !== -1 ) { // Yes, modify the sort nextSortIdx = next( sorting[sortIdx] ); sorting[sortIdx][1] = asSorting[ nextSortIdx ]; sorting[sortIdx]._idx = nextSortIdx; } else { // No sort on this column yet sorting.push( [ colIdx, asSorting[0], 0 ] ); sorting[sorting.length-1]._idx = 0; } } else if ( sorting.length && sorting[0][0] == colIdx ) { // Single column - already sorting on this column, modify the sort nextSortIdx = next( sorting[0] ); sorting.length = 1; sorting[0][1] = asSorting[ nextSortIdx ]; sorting[0]._idx = nextSortIdx; } else { // Single column - sort only on this column sorting.length = 0; sorting.push( [ colIdx, asSorting[0] ] ); sorting[0]._idx = 0; } // Run the sort by calling a full redraw _fnReDraw( settings ); // callback used for async user interaction if ( typeof callback == 'function' ) { callback( settings ); } }
javascript
function _fnSortListener ( settings, colIdx, append, callback ) { var col = settings.aoColumns[ colIdx ]; var sorting = settings.aaSorting; var asSorting = col.asSorting; var nextSortIdx; var next = function ( a ) { var idx = a._idx; if ( idx === undefined ) { idx = $.inArray( a[1], asSorting ); } return idx+1 >= asSorting.length ? 0 : idx+1; }; // If appending the sort then we are multi-column sorting if ( append && settings.oFeatures.bSortMulti ) { // Are we already doing some kind of sort on this column? var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') ); if ( sortIdx !== -1 ) { // Yes, modify the sort nextSortIdx = next( sorting[sortIdx] ); sorting[sortIdx][1] = asSorting[ nextSortIdx ]; sorting[sortIdx]._idx = nextSortIdx; } else { // No sort on this column yet sorting.push( [ colIdx, asSorting[0], 0 ] ); sorting[sorting.length-1]._idx = 0; } } else if ( sorting.length && sorting[0][0] == colIdx ) { // Single column - already sorting on this column, modify the sort nextSortIdx = next( sorting[0] ); sorting.length = 1; sorting[0][1] = asSorting[ nextSortIdx ]; sorting[0]._idx = nextSortIdx; } else { // Single column - sort only on this column sorting.length = 0; sorting.push( [ colIdx, asSorting[0] ] ); sorting[0]._idx = 0; } // Run the sort by calling a full redraw _fnReDraw( settings ); // callback used for async user interaction if ( typeof callback == 'function' ) { callback( settings ); } }
[ "function", "_fnSortListener", "(", "settings", ",", "colIdx", ",", "append", ",", "callback", ")", "{", "var", "col", "=", "settings", ".", "aoColumns", "[", "colIdx", "]", ";", "var", "sorting", "=", "settings", ".", "aaSorting", ";", "var", "asSorting", "=", "col", ".", "asSorting", ";", "var", "nextSortIdx", ";", "var", "next", "=", "function", "(", "a", ")", "{", "var", "idx", "=", "a", ".", "_idx", ";", "if", "(", "idx", "===", "undefined", ")", "{", "idx", "=", "$", ".", "inArray", "(", "a", "[", "1", "]", ",", "asSorting", ")", ";", "}", "return", "idx", "+", "1", ">=", "asSorting", ".", "length", "?", "0", ":", "idx", "+", "1", ";", "}", ";", "if", "(", "append", "&&", "settings", ".", "oFeatures", ".", "bSortMulti", ")", "{", "var", "sortIdx", "=", "$", ".", "inArray", "(", "colIdx", ",", "_pluck", "(", "sorting", ",", "'0'", ")", ")", ";", "if", "(", "sortIdx", "!==", "-", "1", ")", "{", "nextSortIdx", "=", "next", "(", "sorting", "[", "sortIdx", "]", ")", ";", "sorting", "[", "sortIdx", "]", "[", "1", "]", "=", "asSorting", "[", "nextSortIdx", "]", ";", "sorting", "[", "sortIdx", "]", ".", "_idx", "=", "nextSortIdx", ";", "}", "else", "{", "sorting", ".", "push", "(", "[", "colIdx", ",", "asSorting", "[", "0", "]", ",", "0", "]", ")", ";", "sorting", "[", "sorting", ".", "length", "-", "1", "]", ".", "_idx", "=", "0", ";", "}", "}", "else", "if", "(", "sorting", ".", "length", "&&", "sorting", "[", "0", "]", "[", "0", "]", "==", "colIdx", ")", "{", "nextSortIdx", "=", "next", "(", "sorting", "[", "0", "]", ")", ";", "sorting", ".", "length", "=", "1", ";", "sorting", "[", "0", "]", "[", "1", "]", "=", "asSorting", "[", "nextSortIdx", "]", ";", "sorting", "[", "0", "]", ".", "_idx", "=", "nextSortIdx", ";", "}", "else", "{", "sorting", ".", "length", "=", "0", ";", "sorting", ".", "push", "(", "[", "colIdx", ",", "asSorting", "[", "0", "]", "]", ")", ";", "sorting", "[", "0", "]", ".", "_idx", "=", "0", ";", "}", "_fnReDraw", "(", "settings", ")", ";", "if", "(", "typeof", "callback", "==", "'function'", ")", "{", "callback", "(", "settings", ")", ";", "}", "}" ]
Function to run on user sort request @param {object} settings dataTables settings object @param {node} attachTo node to attach the handler to @param {int} colIdx column sorting index @param {boolean} [append=false] Append the requested sort to the existing sort if true (i.e. multi-column sort) @param {function} [callback] callback function @memberof DataTable#oApi
[ "Function", "to", "run", "on", "user", "sort", "request" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L4362-L4417
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
_fnLoadState
function _fnLoadState ( oSettings, oInit ) { var i, ien; var columns = oSettings.aoColumns; if ( !oSettings.oFeatures.bStateSave ) { return; } var oData = oSettings.fnStateLoadCallback.call( oSettings.oInstance, oSettings ); if ( !oData ) { return; } /* Allow custom and plug-in manipulation functions to alter the saved data set and * cancelling of loading by returning false */ var abStateLoad = _fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] ); if ( $.inArray( false, abStateLoad ) !== -1 ) { return; } /* Reject old data */ if ( oData.iCreate < new Date().getTime() - (oSettings.iStateDuration*1000) ) { return; } // Number of columns have changed - all bets are off, no restore of settings if ( columns.length !== oData.aoSearchCols.length ) { return; } /* Store the saved state so it might be accessed at any time */ oSettings.oLoadedState = $.extend( true, {}, oData ); /* Restore key features */ oSettings._iDisplayStart = oData.iStart; oSettings.iInitDisplayStart = oData.iStart; oSettings._iDisplayLength = oData.iLength; oSettings.aaSorting = []; var savedSort = oData.aaSorting; for ( i=0, ien=savedSort.length ; i<ien ; i++ ) { oSettings.aaSorting.push( savedSort[i][0] >= columns.length ? [ 0, savedSort[i][1] ] : savedSort[i] ); } /* Search filtering */ $.extend( oSettings.oPreviousSearch, oData.oSearch ); $.extend( true, oSettings.aoPreSearchCols, oData.aoSearchCols ); /* Column visibility state */ for ( i=0, ien=oData.abVisCols.length ; i<ien ; i++ ) { columns[i].bVisible = oData.abVisCols[i]; } _fnCallbackFire( oSettings, 'aoStateLoaded', 'stateLoaded', [oSettings, oData] ); }
javascript
function _fnLoadState ( oSettings, oInit ) { var i, ien; var columns = oSettings.aoColumns; if ( !oSettings.oFeatures.bStateSave ) { return; } var oData = oSettings.fnStateLoadCallback.call( oSettings.oInstance, oSettings ); if ( !oData ) { return; } /* Allow custom and plug-in manipulation functions to alter the saved data set and * cancelling of loading by returning false */ var abStateLoad = _fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] ); if ( $.inArray( false, abStateLoad ) !== -1 ) { return; } /* Reject old data */ if ( oData.iCreate < new Date().getTime() - (oSettings.iStateDuration*1000) ) { return; } // Number of columns have changed - all bets are off, no restore of settings if ( columns.length !== oData.aoSearchCols.length ) { return; } /* Store the saved state so it might be accessed at any time */ oSettings.oLoadedState = $.extend( true, {}, oData ); /* Restore key features */ oSettings._iDisplayStart = oData.iStart; oSettings.iInitDisplayStart = oData.iStart; oSettings._iDisplayLength = oData.iLength; oSettings.aaSorting = []; var savedSort = oData.aaSorting; for ( i=0, ien=savedSort.length ; i<ien ; i++ ) { oSettings.aaSorting.push( savedSort[i][0] >= columns.length ? [ 0, savedSort[i][1] ] : savedSort[i] ); } /* Search filtering */ $.extend( oSettings.oPreviousSearch, oData.oSearch ); $.extend( true, oSettings.aoPreSearchCols, oData.aoSearchCols ); /* Column visibility state */ for ( i=0, ien=oData.abVisCols.length ; i<ien ; i++ ) { columns[i].bVisible = oData.abVisCols[i]; } _fnCallbackFire( oSettings, 'aoStateLoaded', 'stateLoaded', [oSettings, oData] ); }
[ "function", "_fnLoadState", "(", "oSettings", ",", "oInit", ")", "{", "var", "i", ",", "ien", ";", "var", "columns", "=", "oSettings", ".", "aoColumns", ";", "if", "(", "!", "oSettings", ".", "oFeatures", ".", "bStateSave", ")", "{", "return", ";", "}", "var", "oData", "=", "oSettings", ".", "fnStateLoadCallback", ".", "call", "(", "oSettings", ".", "oInstance", ",", "oSettings", ")", ";", "if", "(", "!", "oData", ")", "{", "return", ";", "}", "var", "abStateLoad", "=", "_fnCallbackFire", "(", "oSettings", ",", "'aoStateLoadParams'", ",", "'stateLoadParams'", ",", "[", "oSettings", ",", "oData", "]", ")", ";", "if", "(", "$", ".", "inArray", "(", "false", ",", "abStateLoad", ")", "!==", "-", "1", ")", "{", "return", ";", "}", "if", "(", "oData", ".", "iCreate", "<", "new", "Date", "(", ")", ".", "getTime", "(", ")", "-", "(", "oSettings", ".", "iStateDuration", "*", "1000", ")", ")", "{", "return", ";", "}", "if", "(", "columns", ".", "length", "!==", "oData", ".", "aoSearchCols", ".", "length", ")", "{", "return", ";", "}", "oSettings", ".", "oLoadedState", "=", "$", ".", "extend", "(", "true", ",", "{", "}", ",", "oData", ")", ";", "oSettings", ".", "_iDisplayStart", "=", "oData", ".", "iStart", ";", "oSettings", ".", "iInitDisplayStart", "=", "oData", ".", "iStart", ";", "oSettings", ".", "_iDisplayLength", "=", "oData", ".", "iLength", ";", "oSettings", ".", "aaSorting", "=", "[", "]", ";", "var", "savedSort", "=", "oData", ".", "aaSorting", ";", "for", "(", "i", "=", "0", ",", "ien", "=", "savedSort", ".", "length", ";", "i", "<", "ien", ";", "i", "++", ")", "{", "oSettings", ".", "aaSorting", ".", "push", "(", "savedSort", "[", "i", "]", "[", "0", "]", ">=", "columns", ".", "length", "?", "[", "0", ",", "savedSort", "[", "i", "]", "[", "1", "]", "]", ":", "savedSort", "[", "i", "]", ")", ";", "}", "$", ".", "extend", "(", "oSettings", ".", "oPreviousSearch", ",", "oData", ".", "oSearch", ")", ";", "$", ".", "extend", "(", "true", ",", "oSettings", ".", "aoPreSearchCols", ",", "oData", ".", "aoSearchCols", ")", ";", "for", "(", "i", "=", "0", ",", "ien", "=", "oData", ".", "abVisCols", ".", "length", ";", "i", "<", "ien", ";", "i", "++", ")", "{", "columns", "[", "i", "]", ".", "bVisible", "=", "oData", ".", "abVisCols", "[", "i", "]", ";", "}", "_fnCallbackFire", "(", "oSettings", ",", "'aoStateLoaded'", ",", "'stateLoaded'", ",", "[", "oSettings", ",", "oData", "]", ")", ";", "}" ]
Attempt to load a saved table state @param {object} oSettings dataTables settings object @param {object} oInit DataTables init object so we can override settings @memberof DataTable#oApi
[ "Attempt", "to", "load", "a", "saved", "table", "state" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L4572-L4634
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( mixed ) { var idx, jq; var settings = DataTable.settings; var tables = $.map( settings, function (el, i) { return el.nTable; } ); if ( mixed.nTable && mixed.oApi ) { // DataTables settings object return [ mixed ]; } else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) { // Table node idx = $.inArray( mixed, tables ); return idx !== -1 ? [ settings[idx] ] : null; } else if ( typeof mixed === 'string' ) { // jQuery selector jq = $(mixed); } else if ( mixed instanceof $ ) { // jQuery object (also DataTables instance) jq = mixed; } if ( jq ) { return jq.map( function(i) { idx = $.inArray( this, tables ); return idx !== -1 ? settings[idx] : null; } ); } }
javascript
function ( mixed ) { var idx, jq; var settings = DataTable.settings; var tables = $.map( settings, function (el, i) { return el.nTable; } ); if ( mixed.nTable && mixed.oApi ) { // DataTables settings object return [ mixed ]; } else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) { // Table node idx = $.inArray( mixed, tables ); return idx !== -1 ? [ settings[idx] ] : null; } else if ( typeof mixed === 'string' ) { // jQuery selector jq = $(mixed); } else if ( mixed instanceof $ ) { // jQuery object (also DataTables instance) jq = mixed; } if ( jq ) { return jq.map( function(i) { idx = $.inArray( this, tables ); return idx !== -1 ? settings[idx] : null; } ); } }
[ "function", "(", "mixed", ")", "{", "var", "idx", ",", "jq", ";", "var", "settings", "=", "DataTable", ".", "settings", ";", "var", "tables", "=", "$", ".", "map", "(", "settings", ",", "function", "(", "el", ",", "i", ")", "{", "return", "el", ".", "nTable", ";", "}", ")", ";", "if", "(", "mixed", ".", "nTable", "&&", "mixed", ".", "oApi", ")", "{", "return", "[", "mixed", "]", ";", "}", "else", "if", "(", "mixed", ".", "nodeName", "&&", "mixed", ".", "nodeName", ".", "toLowerCase", "(", ")", "===", "'table'", ")", "{", "idx", "=", "$", ".", "inArray", "(", "mixed", ",", "tables", ")", ";", "return", "idx", "!==", "-", "1", "?", "[", "settings", "[", "idx", "]", "]", ":", "null", ";", "}", "else", "if", "(", "typeof", "mixed", "===", "'string'", ")", "{", "jq", "=", "$", "(", "mixed", ")", ";", "}", "else", "if", "(", "mixed", "instanceof", "$", ")", "{", "jq", "=", "mixed", ";", "}", "if", "(", "jq", ")", "{", "return", "jq", ".", "map", "(", "function", "(", "i", ")", "{", "idx", "=", "$", ".", "inArray", "(", "this", ",", "tables", ")", ";", "return", "idx", "!==", "-", "1", "?", "settings", "[", "idx", "]", ":", "null", ";", "}", ")", ";", "}", "}" ]
Abstraction for `context` parameter of the `Api` constructor to allow it to take several different forms for ease of use. Each of the input parameter types will be converted to a DataTables settings object where possible. @param {string|node|jQuery|object} mixed DataTable identifier. Can be one of: * `string` - jQuery selector. Any DataTables' matching the given selector with be found and used. * `node` - `TABLE` node which has already been formed into a DataTable. * `jQuery` - A jQuery object of `TABLE` nodes. * `object` - DataTables settings object @return {array|null} Matching DataTables settings objects. `null` or `undefined` is returned if no matching DataTable is found. @ignore
[ "Abstraction", "for", "context", "parameter", "of", "the", "Api", "constructor", "to", "allow", "it", "to", "take", "several", "different", "forms", "for", "ease", "of", "use", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L6339-L6371
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( fn ) { if ( __arrayProto.forEach ) { // Where possible, use the built-in forEach __arrayProto.forEach.call( this, fn, this ); } else { // Compatibility for browsers without EMCA-252-5 (JS 1.6) for ( var i=0, ien=this.length ; i<ien; i++ ) { // In strict mode the execution scope is the passed value fn.call( this, this[i], i, this ); } } return this; }
javascript
function ( fn ) { if ( __arrayProto.forEach ) { // Where possible, use the built-in forEach __arrayProto.forEach.call( this, fn, this ); } else { // Compatibility for browsers without EMCA-252-5 (JS 1.6) for ( var i=0, ien=this.length ; i<ien; i++ ) { // In strict mode the execution scope is the passed value fn.call( this, this[i], i, this ); } } return this; }
[ "function", "(", "fn", ")", "{", "if", "(", "__arrayProto", ".", "forEach", ")", "{", "__arrayProto", ".", "forEach", ".", "call", "(", "this", ",", "fn", ",", "this", ")", ";", "}", "else", "{", "for", "(", "var", "i", "=", "0", ",", "ien", "=", "this", ".", "length", ";", "i", "<", "ien", ";", "i", "++", ")", "{", "fn", ".", "call", "(", "this", ",", "this", "[", "i", "]", ",", "i", ",", "this", ")", ";", "}", "}", "return", "this", ";", "}" ]
array of table settings objects
[ "array", "of", "table", "settings", "objects" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L6491-L6506
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( flatten, type, fn ) { var a = [], ret, i, ien, j, jen, context = this.context, rows, items, item, selector = this.selector; // Argument shifting if ( typeof flatten === 'string' ) { fn = type; type = flatten; flatten = false; } for ( i=0, ien=context.length ; i<ien ; i++ ) { if ( type === 'table' ) { ret = fn( context[i], i ); if ( ret !== undefined ) { a.push( ret ); } } else if ( type === 'columns' || type === 'rows' ) { // this has same length as context - one entry for each table ret = fn( context[i], this[i], i ); if ( ret !== undefined ) { a.push( ret ); } } else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) { // columns and rows share the same structure. // 'this' is an array of column indexes for each context items = this[i]; if ( type === 'column-rows' ) { rows = _selector_row_indexes( context[i], selector.opts ); } for ( j=0, jen=items.length ; j<jen ; j++ ) { item = items[j]; if ( type === 'cell' ) { ret = fn( context[i], item.row, item.column, i, j ); } else { ret = fn( context[i], item, i, j, rows ); } if ( ret !== undefined ) { a.push( ret ); } } } } if ( a.length ) { var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a ); var apiSelector = api.selector; apiSelector.rows = selector.rows; apiSelector.cols = selector.cols; apiSelector.opts = selector.opts; return api; } return this; }
javascript
function ( flatten, type, fn ) { var a = [], ret, i, ien, j, jen, context = this.context, rows, items, item, selector = this.selector; // Argument shifting if ( typeof flatten === 'string' ) { fn = type; type = flatten; flatten = false; } for ( i=0, ien=context.length ; i<ien ; i++ ) { if ( type === 'table' ) { ret = fn( context[i], i ); if ( ret !== undefined ) { a.push( ret ); } } else if ( type === 'columns' || type === 'rows' ) { // this has same length as context - one entry for each table ret = fn( context[i], this[i], i ); if ( ret !== undefined ) { a.push( ret ); } } else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) { // columns and rows share the same structure. // 'this' is an array of column indexes for each context items = this[i]; if ( type === 'column-rows' ) { rows = _selector_row_indexes( context[i], selector.opts ); } for ( j=0, jen=items.length ; j<jen ; j++ ) { item = items[j]; if ( type === 'cell' ) { ret = fn( context[i], item.row, item.column, i, j ); } else { ret = fn( context[i], item, i, j, rows ); } if ( ret !== undefined ) { a.push( ret ); } } } } if ( a.length ) { var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a ); var apiSelector = api.selector; apiSelector.rows = selector.rows; apiSelector.cols = selector.cols; apiSelector.opts = selector.opts; return api; } return this; }
[ "function", "(", "flatten", ",", "type", ",", "fn", ")", "{", "var", "a", "=", "[", "]", ",", "ret", ",", "i", ",", "ien", ",", "j", ",", "jen", ",", "context", "=", "this", ".", "context", ",", "rows", ",", "items", ",", "item", ",", "selector", "=", "this", ".", "selector", ";", "if", "(", "typeof", "flatten", "===", "'string'", ")", "{", "fn", "=", "type", ";", "type", "=", "flatten", ";", "flatten", "=", "false", ";", "}", "for", "(", "i", "=", "0", ",", "ien", "=", "context", ".", "length", ";", "i", "<", "ien", ";", "i", "++", ")", "{", "if", "(", "type", "===", "'table'", ")", "{", "ret", "=", "fn", "(", "context", "[", "i", "]", ",", "i", ")", ";", "if", "(", "ret", "!==", "undefined", ")", "{", "a", ".", "push", "(", "ret", ")", ";", "}", "}", "else", "if", "(", "type", "===", "'columns'", "||", "type", "===", "'rows'", ")", "{", "ret", "=", "fn", "(", "context", "[", "i", "]", ",", "this", "[", "i", "]", ",", "i", ")", ";", "if", "(", "ret", "!==", "undefined", ")", "{", "a", ".", "push", "(", "ret", ")", ";", "}", "}", "else", "if", "(", "type", "===", "'column'", "||", "type", "===", "'column-rows'", "||", "type", "===", "'row'", "||", "type", "===", "'cell'", ")", "{", "items", "=", "this", "[", "i", "]", ";", "if", "(", "type", "===", "'column-rows'", ")", "{", "rows", "=", "_selector_row_indexes", "(", "context", "[", "i", "]", ",", "selector", ".", "opts", ")", ";", "}", "for", "(", "j", "=", "0", ",", "jen", "=", "items", ".", "length", ";", "j", "<", "jen", ";", "j", "++", ")", "{", "item", "=", "items", "[", "j", "]", ";", "if", "(", "type", "===", "'cell'", ")", "{", "ret", "=", "fn", "(", "context", "[", "i", "]", ",", "item", ".", "row", ",", "item", ".", "column", ",", "i", ",", "j", ")", ";", "}", "else", "{", "ret", "=", "fn", "(", "context", "[", "i", "]", ",", "item", ",", "i", ",", "j", ",", "rows", ")", ";", "}", "if", "(", "ret", "!==", "undefined", ")", "{", "a", ".", "push", "(", "ret", ")", ";", "}", "}", "}", "}", "if", "(", "a", ".", "length", ")", "{", "var", "api", "=", "new", "_Api", "(", "context", ",", "flatten", "?", "a", ".", "concat", ".", "apply", "(", "[", "]", ",", "a", ")", ":", "a", ")", ";", "var", "apiSelector", "=", "api", ".", "selector", ";", "apiSelector", ".", "rows", "=", "selector", ".", "rows", ";", "apiSelector", ".", "cols", "=", "selector", ".", "cols", ";", "apiSelector", ".", "opts", "=", "selector", ".", "opts", ";", "return", "api", ";", "}", "return", "this", ";", "}" ]
Internal only at the moment - relax?
[ "Internal", "only", "at", "the", "moment", "-", "relax?" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L6550-L6616
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function ( selector, a ) { // Integer is used to pick out a table by index if ( typeof selector === 'number' ) { return [ a[ selector ] ]; } // Perform a jQuery selector on the table nodes var nodes = $.map( a, function (el, i) { return el.nTable; } ); return $(nodes) .filter( selector ) .map( function (i) { // Need to translate back from the table node to the settings var idx = $.inArray( this, nodes ); return a[ idx ]; } ) .toArray(); }
javascript
function ( selector, a ) { // Integer is used to pick out a table by index if ( typeof selector === 'number' ) { return [ a[ selector ] ]; } // Perform a jQuery selector on the table nodes var nodes = $.map( a, function (el, i) { return el.nTable; } ); return $(nodes) .filter( selector ) .map( function (i) { // Need to translate back from the table node to the settings var idx = $.inArray( this, nodes ); return a[ idx ]; } ) .toArray(); }
[ "function", "(", "selector", ",", "a", ")", "{", "if", "(", "typeof", "selector", "===", "'number'", ")", "{", "return", "[", "a", "[", "selector", "]", "]", ";", "}", "var", "nodes", "=", "$", ".", "map", "(", "a", ",", "function", "(", "el", ",", "i", ")", "{", "return", "el", ".", "nTable", ";", "}", ")", ";", "return", "$", "(", "nodes", ")", ".", "filter", "(", "selector", ")", ".", "map", "(", "function", "(", "i", ")", "{", "var", "idx", "=", "$", ".", "inArray", "(", "this", ",", "nodes", ")", ";", "return", "a", "[", "idx", "]", ";", "}", ")", ".", "toArray", "(", ")", ";", "}" ]
Selector for HTML tables. Apply the given selector to the give array of DataTables settings objects. @param {string|integer} [selector] jQuery selector string or integer @param {array} Array of DataTables settings objects to be filtered @return {array} @ignore
[ "Selector", "for", "HTML", "tables", ".", "Apply", "the", "given", "selector", "to", "the", "give", "array", "of", "DataTables", "settings", "objects", "." ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L6923-L6943
train
altairstudios/nodeserver
admin/public/js/plugins/dataTables/jquery.dataTables.js
function () { var len = this._iDisplayLength, start = this._iDisplayStart, calc = start + len, records = this.aiDisplay.length, features = this.oFeatures, paginate = features.bPaginate; if ( features.bServerSide ) { return paginate === false || len === -1 ? start + records : Math.min( start+len, this._iRecordsDisplay ); } else { return ! paginate || calc>records || len===-1 ? records : calc; } }
javascript
function () { var len = this._iDisplayLength, start = this._iDisplayStart, calc = start + len, records = this.aiDisplay.length, features = this.oFeatures, paginate = features.bPaginate; if ( features.bServerSide ) { return paginate === false || len === -1 ? start + records : Math.min( start+len, this._iRecordsDisplay ); } else { return ! paginate || calc>records || len===-1 ? records : calc; } }
[ "function", "(", ")", "{", "var", "len", "=", "this", ".", "_iDisplayLength", ",", "start", "=", "this", ".", "_iDisplayStart", ",", "calc", "=", "start", "+", "len", ",", "records", "=", "this", ".", "aiDisplay", ".", "length", ",", "features", "=", "this", ".", "oFeatures", ",", "paginate", "=", "features", ".", "bPaginate", ";", "if", "(", "features", ".", "bServerSide", ")", "{", "return", "paginate", "===", "false", "||", "len", "===", "-", "1", "?", "start", "+", "records", ":", "Math", ".", "min", "(", "start", "+", "len", ",", "this", ".", "_iRecordsDisplay", ")", ";", "}", "else", "{", "return", "!", "paginate", "||", "calc", ">", "records", "||", "len", "===", "-", "1", "?", "records", ":", "calc", ";", "}", "}" ]
Get the display end point - aiDisplay index @type function
[ "Get", "the", "display", "end", "point", "-", "aiDisplay", "index" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/admin/public/js/plugins/dataTables/jquery.dataTables.js#L12783-L12803
train
layerhq/node-layer-api
lib/resources/identities.js
function(userId, callback) { if (!userId) return callback(new Error(utils.i18n.identities.id)); utils.debug('Identities get: ' + userId); request.get({ path: '/users/' + userId + '/identity' }, callback); }
javascript
function(userId, callback) { if (!userId) return callback(new Error(utils.i18n.identities.id)); utils.debug('Identities get: ' + userId); request.get({ path: '/users/' + userId + '/identity' }, callback); }
[ "function", "(", "userId", ",", "callback", ")", "{", "if", "(", "!", "userId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "identities", ".", "id", ")", ")", ";", "utils", ".", "debug", "(", "'Identities get: '", "+", "userId", ")", ";", "request", ".", "get", "(", "{", "path", ":", "'/users/'", "+", "userId", "+", "'/identity'", "}", ",", "callback", ")", ";", "}" ]
Retrieve an Identity @param {String} userId User ID @param {Function} callback Callback function
[ "Retrieve", "an", "Identity" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/identities.js#L38-L45
train
layerhq/node-layer-api
lib/resources/identities.js
function(userId, properties, callback) { if (!userId) return callback(new Error(utils.i18n.identities.id)); utils.debug('Identity edit: ' + userId); request.patch({ path: '/users/' + userId + '/identity', body: Object.keys(properties).map(function(propertyName) { return { operation: 'set', property: propertyName, value: properties[propertyName] }; }) }, callback || utils.nop); }
javascript
function(userId, properties, callback) { if (!userId) return callback(new Error(utils.i18n.identities.id)); utils.debug('Identity edit: ' + userId); request.patch({ path: '/users/' + userId + '/identity', body: Object.keys(properties).map(function(propertyName) { return { operation: 'set', property: propertyName, value: properties[propertyName] }; }) }, callback || utils.nop); }
[ "function", "(", "userId", ",", "properties", ",", "callback", ")", "{", "if", "(", "!", "userId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "identities", ".", "id", ")", ")", ";", "utils", ".", "debug", "(", "'Identity edit: '", "+", "userId", ")", ";", "request", ".", "patch", "(", "{", "path", ":", "'/users/'", "+", "userId", "+", "'/identity'", ",", "body", ":", "Object", ".", "keys", "(", "properties", ")", ".", "map", "(", "function", "(", "propertyName", ")", "{", "return", "{", "operation", ":", "'set'", ",", "property", ":", "propertyName", ",", "value", ":", "properties", "[", "propertyName", "]", "}", ";", "}", ")", "}", ",", "callback", "||", "utils", ".", "nop", ")", ";", "}" ]
Edit Identity properties. @param {String} userId User ID @param {Object} properties Hash of properties to update @param {Function} callback Callback function
[ "Edit", "Identity", "properties", "." ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/identities.js#L54-L68
train
altairstudios/nodeserver
core/workers/node.js
function(website) { var self = this; var scriptPath = path.dirname(website.script); var script = ''; var port = website.port; if(website.absoluteScript === false) { scriptPath = process.cwd() + '/' + path.dirname(website.script); } script = path.basename(website.script); var env = JSON.parse(JSON.stringify(process.env)); env.PORT = port; var spawnOptions = { env: env, cwd: scriptPath, stdio: 'pipe', detached: false }; var child = childProcess.spawn(process.execPath, [script], spawnOptions); website.process = child; website.processStatus = 'start'; child.stderr.on('data', function(chunk) { website.writeLog(chunk.toString('utf8'), 'error'); }); child.stdout.on('data', function(chunk) { website.writeLog(chunk.toString('utf8'), 'log'); }); child.on('exit', function(code, signal) { website.writeLog('cgi spawn ' + child.pid + ' "exit" event (code ' + code + ') (signal ' + signal + ') (status ' + website.processStatus + ')', 'log'); if(website.processStatus == 'stop') { website.processStatus = 'end'; } else { website.processStatus = 'end'; self.start(website); } }); website.operations = { stop: function() { website.processStatus = 'stop'; child.kill('SIGINT'); }, reboot: function() { website.processStatus = 'stop'; child.kill('SIGINT'); website.operations.stop(); website.operations.start(); }, start: function() { self.start(website); } }; }
javascript
function(website) { var self = this; var scriptPath = path.dirname(website.script); var script = ''; var port = website.port; if(website.absoluteScript === false) { scriptPath = process.cwd() + '/' + path.dirname(website.script); } script = path.basename(website.script); var env = JSON.parse(JSON.stringify(process.env)); env.PORT = port; var spawnOptions = { env: env, cwd: scriptPath, stdio: 'pipe', detached: false }; var child = childProcess.spawn(process.execPath, [script], spawnOptions); website.process = child; website.processStatus = 'start'; child.stderr.on('data', function(chunk) { website.writeLog(chunk.toString('utf8'), 'error'); }); child.stdout.on('data', function(chunk) { website.writeLog(chunk.toString('utf8'), 'log'); }); child.on('exit', function(code, signal) { website.writeLog('cgi spawn ' + child.pid + ' "exit" event (code ' + code + ') (signal ' + signal + ') (status ' + website.processStatus + ')', 'log'); if(website.processStatus == 'stop') { website.processStatus = 'end'; } else { website.processStatus = 'end'; self.start(website); } }); website.operations = { stop: function() { website.processStatus = 'stop'; child.kill('SIGINT'); }, reboot: function() { website.processStatus = 'stop'; child.kill('SIGINT'); website.operations.stop(); website.operations.start(); }, start: function() { self.start(website); } }; }
[ "function", "(", "website", ")", "{", "var", "self", "=", "this", ";", "var", "scriptPath", "=", "path", ".", "dirname", "(", "website", ".", "script", ")", ";", "var", "script", "=", "''", ";", "var", "port", "=", "website", ".", "port", ";", "if", "(", "website", ".", "absoluteScript", "===", "false", ")", "{", "scriptPath", "=", "process", ".", "cwd", "(", ")", "+", "'/'", "+", "path", ".", "dirname", "(", "website", ".", "script", ")", ";", "}", "script", "=", "path", ".", "basename", "(", "website", ".", "script", ")", ";", "var", "env", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "process", ".", "env", ")", ")", ";", "env", ".", "PORT", "=", "port", ";", "var", "spawnOptions", "=", "{", "env", ":", "env", ",", "cwd", ":", "scriptPath", ",", "stdio", ":", "'pipe'", ",", "detached", ":", "false", "}", ";", "var", "child", "=", "childProcess", ".", "spawn", "(", "process", ".", "execPath", ",", "[", "script", "]", ",", "spawnOptions", ")", ";", "website", ".", "process", "=", "child", ";", "website", ".", "processStatus", "=", "'start'", ";", "child", ".", "stderr", ".", "on", "(", "'data'", ",", "function", "(", "chunk", ")", "{", "website", ".", "writeLog", "(", "chunk", ".", "toString", "(", "'utf8'", ")", ",", "'error'", ")", ";", "}", ")", ";", "child", ".", "stdout", ".", "on", "(", "'data'", ",", "function", "(", "chunk", ")", "{", "website", ".", "writeLog", "(", "chunk", ".", "toString", "(", "'utf8'", ")", ",", "'log'", ")", ";", "}", ")", ";", "child", ".", "on", "(", "'exit'", ",", "function", "(", "code", ",", "signal", ")", "{", "website", ".", "writeLog", "(", "'cgi spawn '", "+", "child", ".", "pid", "+", "' \"exit\" event (code '", "+", "code", "+", "') (signal '", "+", "signal", "+", "') (status '", "+", "website", ".", "processStatus", "+", "')'", ",", "'log'", ")", ";", "if", "(", "website", ".", "processStatus", "==", "'stop'", ")", "{", "website", ".", "processStatus", "=", "'end'", ";", "}", "else", "{", "website", ".", "processStatus", "=", "'end'", ";", "self", ".", "start", "(", "website", ")", ";", "}", "}", ")", ";", "website", ".", "operations", "=", "{", "stop", ":", "function", "(", ")", "{", "website", ".", "processStatus", "=", "'stop'", ";", "child", ".", "kill", "(", "'SIGINT'", ")", ";", "}", ",", "reboot", ":", "function", "(", ")", "{", "website", ".", "processStatus", "=", "'stop'", ";", "child", ".", "kill", "(", "'SIGINT'", ")", ";", "website", ".", "operations", ".", "stop", "(", ")", ";", "website", ".", "operations", ".", "start", "(", ")", ";", "}", ",", "start", ":", "function", "(", ")", "{", "self", ".", "start", "(", "website", ")", ";", "}", "}", ";", "}" ]
Start the nodejs process. Spawn the proccess and listen on a port @param {Website} website Website to start
[ "Start", "the", "nodejs", "process", ".", "Spawn", "the", "proccess", "and", "listen", "on", "a", "port" ]
559ae91b025573ec772c51b838ee691d34abbbbb
https://github.com/altairstudios/nodeserver/blob/559ae91b025573ec772c51b838ee691d34abbbbb/core/workers/node.js#L16-L77
train
elidoran/comma-number
lib/index.js
commaNumber
function commaNumber(inputNumber, optionalSeparator, optionalDecimalChar) { // we'll strip off and hold the decimal value to reattach later. // we'll hold both the `number` value and `stringNumber` value. let number, stringNumber, decimal // default `separator` is a comma const separator = optionalSeparator || ',' // default `decimalChar` is a period const decimalChar = optionalDecimalChar || '.' switch (typeof inputNumber) { case 'string': // if there aren't enough digits to need separators then return it // NOTE: some numbers which are too small will get passed this // when they have decimal values which make them too long here. // but, the number value check after this switch will catch it. if (inputNumber.length < (inputNumber[0] === '-' ? 5 : 4)) { return inputNumber } // remember it as a string in `stringNumber` and convert to a Number stringNumber = inputNumber // if they're not using the Node standard decimal char then replace it // before converting. number = decimalChar !== '.' ? Number(stringNumber.replace(decimalChar, '.')) : Number(stringNumber) break // convert to a string. // NOTE: don't check if the number is too small before converting // because we'll need to return `stringNumber` anyway. case 'number': stringNumber = String(inputNumber) number = inputNumber break // return invalid type as-is default: return inputNumber } // when it doesn't need a separator or isn't a number then return it if ((-1000 < number && number < 1000) || isNaN(number) || !isFinite(number)) { return stringNumber } // strip off decimal value to append to the final result at the bottom let decimalIndex = stringNumber.lastIndexOf(decimalChar) if (decimalIndex > -1) { decimal = stringNumber.slice(decimalIndex) stringNumber = stringNumber.slice(0, -decimal.length) } // else { // decimal = null // } // finally, parse the string and add in separators stringNumber = parse(stringNumber, separator) // if there's a decimal value add it back on the end. // NOTE: we sliced() it off including the decimalChar, so it's good. return decimal ? stringNumber + decimal : stringNumber }
javascript
function commaNumber(inputNumber, optionalSeparator, optionalDecimalChar) { // we'll strip off and hold the decimal value to reattach later. // we'll hold both the `number` value and `stringNumber` value. let number, stringNumber, decimal // default `separator` is a comma const separator = optionalSeparator || ',' // default `decimalChar` is a period const decimalChar = optionalDecimalChar || '.' switch (typeof inputNumber) { case 'string': // if there aren't enough digits to need separators then return it // NOTE: some numbers which are too small will get passed this // when they have decimal values which make them too long here. // but, the number value check after this switch will catch it. if (inputNumber.length < (inputNumber[0] === '-' ? 5 : 4)) { return inputNumber } // remember it as a string in `stringNumber` and convert to a Number stringNumber = inputNumber // if they're not using the Node standard decimal char then replace it // before converting. number = decimalChar !== '.' ? Number(stringNumber.replace(decimalChar, '.')) : Number(stringNumber) break // convert to a string. // NOTE: don't check if the number is too small before converting // because we'll need to return `stringNumber` anyway. case 'number': stringNumber = String(inputNumber) number = inputNumber break // return invalid type as-is default: return inputNumber } // when it doesn't need a separator or isn't a number then return it if ((-1000 < number && number < 1000) || isNaN(number) || !isFinite(number)) { return stringNumber } // strip off decimal value to append to the final result at the bottom let decimalIndex = stringNumber.lastIndexOf(decimalChar) if (decimalIndex > -1) { decimal = stringNumber.slice(decimalIndex) stringNumber = stringNumber.slice(0, -decimal.length) } // else { // decimal = null // } // finally, parse the string and add in separators stringNumber = parse(stringNumber, separator) // if there's a decimal value add it back on the end. // NOTE: we sliced() it off including the decimalChar, so it's good. return decimal ? stringNumber + decimal : stringNumber }
[ "function", "commaNumber", "(", "inputNumber", ",", "optionalSeparator", ",", "optionalDecimalChar", ")", "{", "let", "number", ",", "stringNumber", ",", "decimal", "const", "separator", "=", "optionalSeparator", "||", "','", "const", "decimalChar", "=", "optionalDecimalChar", "||", "'.'", "switch", "(", "typeof", "inputNumber", ")", "{", "case", "'string'", ":", "if", "(", "inputNumber", ".", "length", "<", "(", "inputNumber", "[", "0", "]", "===", "'-'", "?", "5", ":", "4", ")", ")", "{", "return", "inputNumber", "}", "stringNumber", "=", "inputNumber", "number", "=", "decimalChar", "!==", "'.'", "?", "Number", "(", "stringNumber", ".", "replace", "(", "decimalChar", ",", "'.'", ")", ")", ":", "Number", "(", "stringNumber", ")", "break", "case", "'number'", ":", "stringNumber", "=", "String", "(", "inputNumber", ")", "number", "=", "inputNumber", "break", "default", ":", "return", "inputNumber", "}", "if", "(", "(", "-", "1000", "<", "number", "&&", "number", "<", "1000", ")", "||", "isNaN", "(", "number", ")", "||", "!", "isFinite", "(", "number", ")", ")", "{", "return", "stringNumber", "}", "let", "decimalIndex", "=", "stringNumber", ".", "lastIndexOf", "(", "decimalChar", ")", "if", "(", "decimalIndex", ">", "-", "1", ")", "{", "decimal", "=", "stringNumber", ".", "slice", "(", "decimalIndex", ")", "stringNumber", "=", "stringNumber", ".", "slice", "(", "0", ",", "-", "decimal", ".", "length", ")", "}", "stringNumber", "=", "parse", "(", "stringNumber", ",", "separator", ")", "return", "decimal", "?", "stringNumber", "+", "decimal", ":", "stringNumber", "}" ]
return a string with the provided number formatted with commas. can specify either a Number or a String.
[ "return", "a", "string", "with", "the", "provided", "number", "formatted", "with", "commas", ".", "can", "specify", "either", "a", "Number", "or", "a", "String", "." ]
4aaca601ec6a69b56b61d1fb104c191b1848aadc
https://github.com/elidoran/comma-number/blob/4aaca601ec6a69b56b61d1fb104c191b1848aadc/lib/index.js#L5-L74
train
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function () { var coming = F.coming; if (!coming || false === F.trigger('onCancel')) { return; } F.hideLoading(); if (F.ajaxLoad) { F.ajaxLoad.abort(); } F.ajaxLoad = null; if (F.imgPreload) { F.imgPreload.onload = F.imgPreload.onerror = null; } if (coming.wrap) { coming.wrap.stop(true, true).trigger('onReset').remove(); } F.coming = null; // If the first item has been canceled, then clear everything if (!F.current) { F._afterZoomOut( coming ); } }
javascript
function () { var coming = F.coming; if (!coming || false === F.trigger('onCancel')) { return; } F.hideLoading(); if (F.ajaxLoad) { F.ajaxLoad.abort(); } F.ajaxLoad = null; if (F.imgPreload) { F.imgPreload.onload = F.imgPreload.onerror = null; } if (coming.wrap) { coming.wrap.stop(true, true).trigger('onReset').remove(); } F.coming = null; // If the first item has been canceled, then clear everything if (!F.current) { F._afterZoomOut( coming ); } }
[ "function", "(", ")", "{", "var", "coming", "=", "F", ".", "coming", ";", "if", "(", "!", "coming", "||", "false", "===", "F", ".", "trigger", "(", "'onCancel'", ")", ")", "{", "return", ";", "}", "F", ".", "hideLoading", "(", ")", ";", "if", "(", "F", ".", "ajaxLoad", ")", "{", "F", ".", "ajaxLoad", ".", "abort", "(", ")", ";", "}", "F", ".", "ajaxLoad", "=", "null", ";", "if", "(", "F", ".", "imgPreload", ")", "{", "F", ".", "imgPreload", ".", "onload", "=", "F", ".", "imgPreload", ".", "onerror", "=", "null", ";", "}", "if", "(", "coming", ".", "wrap", ")", "{", "coming", ".", "wrap", ".", "stop", "(", "true", ",", "true", ")", ".", "trigger", "(", "'onReset'", ")", ".", "remove", "(", ")", ";", "}", "F", ".", "coming", "=", "null", ";", "if", "(", "!", "F", ".", "current", ")", "{", "F", ".", "_afterZoomOut", "(", "coming", ")", ";", "}", "}" ]
Cancel image loading or abort ajax request
[ "Cancel", "image", "loading", "or", "abort", "ajax", "request" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L363-L392
train
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function ( direction ) { var current = F.current; if (current) { if (!isString(direction)) { direction = current.direction.next; } F.jumpto(current.index + 1, direction, 'next'); } }
javascript
function ( direction ) { var current = F.current; if (current) { if (!isString(direction)) { direction = current.direction.next; } F.jumpto(current.index + 1, direction, 'next'); } }
[ "function", "(", "direction", ")", "{", "var", "current", "=", "F", ".", "current", ";", "if", "(", "current", ")", "{", "if", "(", "!", "isString", "(", "direction", ")", ")", "{", "direction", "=", "current", ".", "direction", ".", "next", ";", "}", "F", ".", "jumpto", "(", "current", ".", "index", "+", "1", ",", "direction", ",", "'next'", ")", ";", "}", "}" ]
Navigate to next gallery item
[ "Navigate", "to", "next", "gallery", "item" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L473-L483
train
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function ( direction ) { var current = F.current; if (current) { if (!isString(direction)) { direction = current.direction.prev; } F.jumpto(current.index - 1, direction, 'prev'); } }
javascript
function ( direction ) { var current = F.current; if (current) { if (!isString(direction)) { direction = current.direction.prev; } F.jumpto(current.index - 1, direction, 'prev'); } }
[ "function", "(", "direction", ")", "{", "var", "current", "=", "F", ".", "current", ";", "if", "(", "current", ")", "{", "if", "(", "!", "isString", "(", "direction", ")", ")", "{", "direction", "=", "current", ".", "direction", ".", "prev", ";", "}", "F", ".", "jumpto", "(", "current", ".", "index", "-", "1", ",", "direction", ",", "'prev'", ")", ";", "}", "}" ]
Navigate to previous gallery item
[ "Navigate", "to", "previous", "gallery", "item" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L486-L496
train
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function ( index, direction, router ) { var current = F.current; if (!current) { return; } index = getScalar(index); F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ]; F.router = router || 'jumpto'; if (current.loop) { if (index < 0) { index = current.group.length + (index % current.group.length); } index = index % current.group.length; } if (current.group[ index ] !== undefined) { F.cancel(); F._start(index); } }
javascript
function ( index, direction, router ) { var current = F.current; if (!current) { return; } index = getScalar(index); F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ]; F.router = router || 'jumpto'; if (current.loop) { if (index < 0) { index = current.group.length + (index % current.group.length); } index = index % current.group.length; } if (current.group[ index ] !== undefined) { F.cancel(); F._start(index); } }
[ "function", "(", "index", ",", "direction", ",", "router", ")", "{", "var", "current", "=", "F", ".", "current", ";", "if", "(", "!", "current", ")", "{", "return", ";", "}", "index", "=", "getScalar", "(", "index", ")", ";", "F", ".", "direction", "=", "direction", "||", "current", ".", "direction", "[", "(", "index", ">=", "current", ".", "index", "?", "'next'", ":", "'prev'", ")", "]", ";", "F", ".", "router", "=", "router", "||", "'jumpto'", ";", "if", "(", "current", ".", "loop", ")", "{", "if", "(", "index", "<", "0", ")", "{", "index", "=", "current", ".", "group", ".", "length", "+", "(", "index", "%", "current", ".", "group", ".", "length", ")", ";", "}", "index", "=", "index", "%", "current", ".", "group", ".", "length", ";", "}", "if", "(", "current", ".", "group", "[", "index", "]", "!==", "undefined", ")", "{", "F", ".", "cancel", "(", ")", ";", "F", ".", "_start", "(", "index", ")", ";", "}", "}" ]
Navigate to gallery item by index
[ "Navigate", "to", "gallery", "item", "by", "index" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L499-L524
train
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function (e, onlyAbsolute) { var current = F.current, wrap = current ? current.wrap : null, pos; if (wrap) { pos = F._getPosition(onlyAbsolute); if (e && e.type === 'scroll') { delete pos.position; wrap.stop(true, true).animate(pos, 200); } else { wrap.css(pos); current.pos = $.extend({}, current.dim, pos); } } }
javascript
function (e, onlyAbsolute) { var current = F.current, wrap = current ? current.wrap : null, pos; if (wrap) { pos = F._getPosition(onlyAbsolute); if (e && e.type === 'scroll') { delete pos.position; wrap.stop(true, true).animate(pos, 200); } else { wrap.css(pos); current.pos = $.extend({}, current.dim, pos); } } }
[ "function", "(", "e", ",", "onlyAbsolute", ")", "{", "var", "current", "=", "F", ".", "current", ",", "wrap", "=", "current", "?", "current", ".", "wrap", ":", "null", ",", "pos", ";", "if", "(", "wrap", ")", "{", "pos", "=", "F", ".", "_getPosition", "(", "onlyAbsolute", ")", ";", "if", "(", "e", "&&", "e", ".", "type", "===", "'scroll'", ")", "{", "delete", "pos", ".", "position", ";", "wrap", ".", "stop", "(", "true", ",", "true", ")", ".", "animate", "(", "pos", ",", "200", ")", ";", "}", "else", "{", "wrap", ".", "css", "(", "pos", ")", ";", "current", ".", "pos", "=", "$", ".", "extend", "(", "{", "}", ",", "current", ".", "dim", ",", "pos", ")", ";", "}", "}", "}" ]
Center inside viewport and toggle position type to fixed or absolute if needed
[ "Center", "inside", "viewport", "and", "toggle", "position", "type", "to", "fixed", "or", "absolute", "if", "needed" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L527-L546
train
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function ( action ) { if (F.isOpen) { F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView; // Help browser to restore document dimensions if (isTouch) { F.wrap.removeAttr('style').addClass('fancybox-tmp'); F.trigger('onUpdate'); } F.update(); } }
javascript
function ( action ) { if (F.isOpen) { F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView; // Help browser to restore document dimensions if (isTouch) { F.wrap.removeAttr('style').addClass('fancybox-tmp'); F.trigger('onUpdate'); } F.update(); } }
[ "function", "(", "action", ")", "{", "if", "(", "F", ".", "isOpen", ")", "{", "F", ".", "current", ".", "fitToView", "=", "$", ".", "type", "(", "action", ")", "===", "\"boolean\"", "?", "action", ":", "!", "F", ".", "current", ".", "fitToView", ";", "if", "(", "isTouch", ")", "{", "F", ".", "wrap", ".", "removeAttr", "(", "'style'", ")", ".", "addClass", "(", "'fancybox-tmp'", ")", ";", "F", ".", "trigger", "(", "'onUpdate'", ")", ";", "}", "F", ".", "update", "(", ")", ";", "}", "}" ]
Shrink content to fit inside viewport or restore if resized
[ "Shrink", "content", "to", "fit", "inside", "viewport", "or", "restore", "if", "resized" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L587-L600
train
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function(opts) { opts = $.extend({}, this.defaults, opts); if (this.overlay) { this.close(); } this.overlay = $('<div class="fancybox-overlay"></div>').appendTo( F.coming ? F.coming.parent : opts.parent ); this.fixed = false; if (opts.fixed && F.defaults.fixed) { this.overlay.addClass('fancybox-overlay-fixed'); this.fixed = true; } }
javascript
function(opts) { opts = $.extend({}, this.defaults, opts); if (this.overlay) { this.close(); } this.overlay = $('<div class="fancybox-overlay"></div>').appendTo( F.coming ? F.coming.parent : opts.parent ); this.fixed = false; if (opts.fixed && F.defaults.fixed) { this.overlay.addClass('fancybox-overlay-fixed'); this.fixed = true; } }
[ "function", "(", "opts", ")", "{", "opts", "=", "$", ".", "extend", "(", "{", "}", ",", "this", ".", "defaults", ",", "opts", ")", ";", "if", "(", "this", ".", "overlay", ")", "{", "this", ".", "close", "(", ")", ";", "}", "this", ".", "overlay", "=", "$", "(", "'<div class=\"fancybox-overlay\"></div>'", ")", ".", "appendTo", "(", "F", ".", "coming", "?", "F", ".", "coming", ".", "parent", ":", "opts", ".", "parent", ")", ";", "this", ".", "fixed", "=", "false", ";", "if", "(", "opts", ".", "fixed", "&&", "F", ".", "defaults", ".", "fixed", ")", "{", "this", ".", "overlay", ".", "addClass", "(", "'fancybox-overlay-fixed'", ")", ";", "this", ".", "fixed", "=", "true", ";", "}", "}" ]
element that contains "the lock" Public methods
[ "element", "that", "contains", "the", "lock", "Public", "methods" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L1705-L1720
train
psychobunny/nodebb-plugin-gallery
public/vendor/fancybox/jquery.fancybox.js
function (opts, obj) { var overlay = this.overlay; $('.fancybox-overlay').stop(true, true); if (!overlay) { this.create(opts); } if (opts.locked && this.fixed && obj.fixed) { if (!overlay) { this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false; } obj.locked = this.overlay.append( obj.wrap ); obj.fixed = false; } if (opts.showEarly === true) { this.beforeShow.apply(this, arguments); } }
javascript
function (opts, obj) { var overlay = this.overlay; $('.fancybox-overlay').stop(true, true); if (!overlay) { this.create(opts); } if (opts.locked && this.fixed && obj.fixed) { if (!overlay) { this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false; } obj.locked = this.overlay.append( obj.wrap ); obj.fixed = false; } if (opts.showEarly === true) { this.beforeShow.apply(this, arguments); } }
[ "function", "(", "opts", ",", "obj", ")", "{", "var", "overlay", "=", "this", ".", "overlay", ";", "$", "(", "'.fancybox-overlay'", ")", ".", "stop", "(", "true", ",", "true", ")", ";", "if", "(", "!", "overlay", ")", "{", "this", ".", "create", "(", "opts", ")", ";", "}", "if", "(", "opts", ".", "locked", "&&", "this", ".", "fixed", "&&", "obj", ".", "fixed", ")", "{", "if", "(", "!", "overlay", ")", "{", "this", ".", "margin", "=", "D", ".", "height", "(", ")", ">", "W", ".", "height", "(", ")", "?", "$", "(", "'html'", ")", ".", "css", "(", "'margin-right'", ")", ".", "replace", "(", "\"px\"", ",", "\"\"", ")", ":", "false", ";", "}", "obj", ".", "locked", "=", "this", ".", "overlay", ".", "append", "(", "obj", ".", "wrap", ")", ";", "obj", ".", "fixed", "=", "false", ";", "}", "if", "(", "opts", ".", "showEarly", "===", "true", ")", "{", "this", ".", "beforeShow", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "}" ]
This is where we can manipulate DOM, because later it would cause iframes to reload
[ "This", "is", "where", "we", "can", "manipulate", "DOM", "because", "later", "it", "would", "cause", "iframes", "to", "reload" ]
2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631
https://github.com/psychobunny/nodebb-plugin-gallery/blob/2e90f0f7a2bbfe75585bfee2cfa2df52e9a42631/public/vendor/fancybox/jquery.fancybox.js#L1805-L1826
train
layerhq/node-layer-api
lib/resources/conversations.js
function(conversationId, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); utils.debug('Conversation get: ' + conversationId); request.get({ path: '/conversations/' + conversationId }, callback); }
javascript
function(conversationId, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); utils.debug('Conversation get: ' + conversationId); request.get({ path: '/conversations/' + conversationId }, callback); }
[ "function", "(", "conversationId", ",", "callback", ")", "{", "conversationId", "=", "utils", ".", "toUUID", "(", "conversationId", ")", ";", "if", "(", "!", "conversationId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "conversations", ".", "id", ")", ")", ";", "utils", ".", "debug", "(", "'Conversation get: '", "+", "conversationId", ")", ";", "request", ".", "get", "(", "{", "path", ":", "'/conversations/'", "+", "conversationId", "}", ",", "callback", ")", ";", "}" ]
Retrieve a conversation @param {String} conversationId Conversation ID @param {Function} callback Callback function
[ "Retrieve", "a", "conversation" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/conversations.js#L37-L45
train
layerhq/node-layer-api
lib/resources/conversations.js
function(userId, conversationId, callback) { if (!userId) return callback(new Error(utils.i18n.conversations.userId)); conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); utils.debug('Conversation getFromUser: ' + userId + ', ' + conversationId); request.get({ path: '/users/' + querystring.escape(userId) + '/conversations/' + conversationId }, callback); }
javascript
function(userId, conversationId, callback) { if (!userId) return callback(new Error(utils.i18n.conversations.userId)); conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); utils.debug('Conversation getFromUser: ' + userId + ', ' + conversationId); request.get({ path: '/users/' + querystring.escape(userId) + '/conversations/' + conversationId }, callback); }
[ "function", "(", "userId", ",", "conversationId", ",", "callback", ")", "{", "if", "(", "!", "userId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "conversations", ".", "userId", ")", ")", ";", "conversationId", "=", "utils", ".", "toUUID", "(", "conversationId", ")", ";", "if", "(", "!", "conversationId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "conversations", ".", "id", ")", ")", ";", "utils", ".", "debug", "(", "'Conversation getFromUser: '", "+", "userId", "+", "', '", "+", "conversationId", ")", ";", "request", ".", "get", "(", "{", "path", ":", "'/users/'", "+", "querystring", ".", "escape", "(", "userId", ")", "+", "'/conversations/'", "+", "conversationId", "}", ",", "callback", ")", ";", "}" ]
Retrieve a conversation from user @param {String} userId User ID @param {String} conversationId Conversation ID @param {Function} callback Callback function
[ "Retrieve", "a", "conversation", "from", "user" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/conversations.js#L54-L63
train
layerhq/node-layer-api
lib/resources/conversations.js
function(userId, params, callback) { if (!userId) return callback(new Error(utils.i18n.conversations.userId)); utils.debug('Conversation getAllFromUser: ' + userId); var queryParams = ''; if (typeof params === 'function') callback = params; else queryParams = '?' + querystring.stringify(params); request.get({ path: '/users/' + querystring.escape(userId) + '/conversations' + queryParams }, callback); }
javascript
function(userId, params, callback) { if (!userId) return callback(new Error(utils.i18n.conversations.userId)); utils.debug('Conversation getAllFromUser: ' + userId); var queryParams = ''; if (typeof params === 'function') callback = params; else queryParams = '?' + querystring.stringify(params); request.get({ path: '/users/' + querystring.escape(userId) + '/conversations' + queryParams }, callback); }
[ "function", "(", "userId", ",", "params", ",", "callback", ")", "{", "if", "(", "!", "userId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "conversations", ".", "userId", ")", ")", ";", "utils", ".", "debug", "(", "'Conversation getAllFromUser: '", "+", "userId", ")", ";", "var", "queryParams", "=", "''", ";", "if", "(", "typeof", "params", "===", "'function'", ")", "callback", "=", "params", ";", "else", "queryParams", "=", "'?'", "+", "querystring", ".", "stringify", "(", "params", ")", ";", "request", ".", "get", "(", "{", "path", ":", "'/users/'", "+", "querystring", ".", "escape", "(", "userId", ")", "+", "'/conversations'", "+", "queryParams", "}", ",", "callback", ")", ";", "}" ]
Retrieve all conversations from user @param {String} userId User ID @param {String} [params] Query parameters @param {Function} callback Callback function
[ "Retrieve", "all", "conversations", "from", "user" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/conversations.js#L72-L83
train
layerhq/node-layer-api
lib/resources/conversations.js
function(conversationId, operations, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); if (!utils.isArray(operations)) return callback(new Error(utils.i18n.conversations.operations)); utils.debug('Conversation edit: ' + conversationId); edit(conversationId, operations, callback); }
javascript
function(conversationId, operations, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); if (!utils.isArray(operations)) return callback(new Error(utils.i18n.conversations.operations)); utils.debug('Conversation edit: ' + conversationId); edit(conversationId, operations, callback); }
[ "function", "(", "conversationId", ",", "operations", ",", "callback", ")", "{", "conversationId", "=", "utils", ".", "toUUID", "(", "conversationId", ")", ";", "if", "(", "!", "conversationId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "conversations", ".", "id", ")", ")", ";", "if", "(", "!", "utils", ".", "isArray", "(", "operations", ")", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "conversations", ".", "operations", ")", ")", ";", "utils", ".", "debug", "(", "'Conversation edit: '", "+", "conversationId", ")", ";", "edit", "(", "conversationId", ",", "operations", ",", "callback", ")", ";", "}" ]
Edit a conversation @param {String} conversationId Conversation UUID @param {Array} operations Array of operations @param {Function} callback Callback function
[ "Edit", "a", "conversation" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/conversations.js#L92-L99
train
layerhq/node-layer-api
lib/resources/conversations.js
function(conversationId, properties, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); utils.debug('Conversation setMetadataProperties: ' + conversationId); var operations = []; Object.keys(properties).forEach(function(name) { var fullName = name; if (name !== 'metadata' && name.indexOf('metadata.') !== 0) { fullName = 'metadata.' + name; } operations.push({ operation: 'set', property: fullName, value: String(properties[name]), }); }); edit(conversationId, operations, callback); }
javascript
function(conversationId, properties, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); utils.debug('Conversation setMetadataProperties: ' + conversationId); var operations = []; Object.keys(properties).forEach(function(name) { var fullName = name; if (name !== 'metadata' && name.indexOf('metadata.') !== 0) { fullName = 'metadata.' + name; } operations.push({ operation: 'set', property: fullName, value: String(properties[name]), }); }); edit(conversationId, operations, callback); }
[ "function", "(", "conversationId", ",", "properties", ",", "callback", ")", "{", "conversationId", "=", "utils", ".", "toUUID", "(", "conversationId", ")", ";", "if", "(", "!", "conversationId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "conversations", ".", "id", ")", ")", ";", "utils", ".", "debug", "(", "'Conversation setMetadataProperties: '", "+", "conversationId", ")", ";", "var", "operations", "=", "[", "]", ";", "Object", ".", "keys", "(", "properties", ")", ".", "forEach", "(", "function", "(", "name", ")", "{", "var", "fullName", "=", "name", ";", "if", "(", "name", "!==", "'metadata'", "&&", "name", ".", "indexOf", "(", "'metadata.'", ")", "!==", "0", ")", "{", "fullName", "=", "'metadata.'", "+", "name", ";", "}", "operations", ".", "push", "(", "{", "operation", ":", "'set'", ",", "property", ":", "fullName", ",", "value", ":", "String", "(", "properties", "[", "name", "]", ")", ",", "}", ")", ";", "}", ")", ";", "edit", "(", "conversationId", ",", "operations", ",", "callback", ")", ";", "}" ]
Set metadata on a conversation @param {String} conversationId Conversation UUID @param {Object} properties Properties object @param {Function} callback Callback function
[ "Set", "metadata", "on", "a", "conversation" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/conversations.js#L108-L126
train
layerhq/node-layer-api
lib/resources/conversations.js
function(conversationId, properties, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); utils.debug('Conversation deleteMetadataProperties: ' + conversationId); var operations = []; Object.keys(properties).forEach(function(property) { if (property !== 'metadata' && property.indexOf('metadata.') !== 0) { property = 'metadata.' + property; } operations.push({ operation: 'delete', property: property, }); }); edit(conversationId, operations, callback); }
javascript
function(conversationId, properties, callback) { conversationId = utils.toUUID(conversationId); if (!conversationId) return callback(new Error(utils.i18n.conversations.id)); utils.debug('Conversation deleteMetadataProperties: ' + conversationId); var operations = []; Object.keys(properties).forEach(function(property) { if (property !== 'metadata' && property.indexOf('metadata.') !== 0) { property = 'metadata.' + property; } operations.push({ operation: 'delete', property: property, }); }); edit(conversationId, operations, callback); }
[ "function", "(", "conversationId", ",", "properties", ",", "callback", ")", "{", "conversationId", "=", "utils", ".", "toUUID", "(", "conversationId", ")", ";", "if", "(", "!", "conversationId", ")", "return", "callback", "(", "new", "Error", "(", "utils", ".", "i18n", ".", "conversations", ".", "id", ")", ")", ";", "utils", ".", "debug", "(", "'Conversation deleteMetadataProperties: '", "+", "conversationId", ")", ";", "var", "operations", "=", "[", "]", ";", "Object", ".", "keys", "(", "properties", ")", ".", "forEach", "(", "function", "(", "property", ")", "{", "if", "(", "property", "!==", "'metadata'", "&&", "property", ".", "indexOf", "(", "'metadata.'", ")", "!==", "0", ")", "{", "property", "=", "'metadata.'", "+", "property", ";", "}", "operations", ".", "push", "(", "{", "operation", ":", "'delete'", ",", "property", ":", "property", ",", "}", ")", ";", "}", ")", ";", "edit", "(", "conversationId", ",", "operations", ",", "callback", ")", ";", "}" ]
Delete metadata on a conversation @param {String} conversationId Conversation UUID @param {Object} properties Properties object @param {Function} callback Callback function
[ "Delete", "metadata", "on", "a", "conversation" ]
284c161350e2cf3d3f5b45f2918798d981f1ada4
https://github.com/layerhq/node-layer-api/blob/284c161350e2cf3d3f5b45f2918798d981f1ada4/lib/resources/conversations.js#L135-L152
train
60frames/jestpack
Plugin.js
resolveArgument
function resolveArgument(expr, argIndex) { if (typeof argIndex === 'undefined') { argIndex = 0; } if (!expr.arguments.length || !expr.arguments[argIndex]) { return; } this.applyPluginsBailResult('call require:commonjs:item', expr, this.evaluateExpression(expr.arguments[argIndex])); }
javascript
function resolveArgument(expr, argIndex) { if (typeof argIndex === 'undefined') { argIndex = 0; } if (!expr.arguments.length || !expr.arguments[argIndex]) { return; } this.applyPluginsBailResult('call require:commonjs:item', expr, this.evaluateExpression(expr.arguments[argIndex])); }
[ "function", "resolveArgument", "(", "expr", ",", "argIndex", ")", "{", "if", "(", "typeof", "argIndex", "===", "'undefined'", ")", "{", "argIndex", "=", "0", ";", "}", "if", "(", "!", "expr", ".", "arguments", ".", "length", "||", "!", "expr", ".", "arguments", "[", "argIndex", "]", ")", "{", "return", ";", "}", "this", ".", "applyPluginsBailResult", "(", "'call require:commonjs:item'", ",", "expr", ",", "this", ".", "evaluateExpression", "(", "expr", ".", "arguments", "[", "argIndex", "]", ")", ")", ";", "}" ]
Resolves module paths. @param {Object} expr The expression. @param {Number} argIndex Which argument to resolve, defaults to the first arg.
[ "Resolves", "module", "paths", "." ]
2e3c26d856ebe4c1b3b786a26178e3ba81108616
https://github.com/60frames/jestpack/blob/2e3c26d856ebe4c1b3b786a26178e3ba81108616/Plugin.js#L10-L19
train
60frames/jestpack
example/webpack.config.js
getEntryPoints
function getEntryPoints(globPattern) { var testFiles = glob.sync(globPattern); var entryPoints = {}; testFiles.forEach(function(file) { entryPoints[file.replace(/\.js$/, '')] = './' + file; }); return entryPoints; }
javascript
function getEntryPoints(globPattern) { var testFiles = glob.sync(globPattern); var entryPoints = {}; testFiles.forEach(function(file) { entryPoints[file.replace(/\.js$/, '')] = './' + file; }); return entryPoints; }
[ "function", "getEntryPoints", "(", "globPattern", ")", "{", "var", "testFiles", "=", "glob", ".", "sync", "(", "globPattern", ")", ";", "var", "entryPoints", "=", "{", "}", ";", "testFiles", ".", "forEach", "(", "function", "(", "file", ")", "{", "entryPoints", "[", "file", ".", "replace", "(", "/", "\\.js$", "/", ",", "''", ")", "]", "=", "'./'", "+", "file", ";", "}", ")", ";", "return", "entryPoints", ";", "}" ]
Given a glob pattern returns the matched paths as an entry point object for Webpack. @param {String} globPattern A glob pattern to match tests. @return {Object} Key value pairs, keyed on filepath.
[ "Given", "a", "glob", "pattern", "returns", "the", "matched", "paths", "as", "an", "entry", "point", "object", "for", "Webpack", "." ]
2e3c26d856ebe4c1b3b786a26178e3ba81108616
https://github.com/60frames/jestpack/blob/2e3c26d856ebe4c1b3b786a26178e3ba81108616/example/webpack.config.js#L13-L20
train
Collaborne/gulp-polymer-build-utils
polymer-build.js
polymerBuild
function polymerBuild(config) { const skipRootFolder = function(file) { const rootFolder = config.root || '.'; file.dirname = path.relative(rootFolder, file.dirname); }; const project = new build.PolymerProject(config); const bundler = project.bundler({ // XXX: sourcemaps makes V8 run out of memory sourcemaps: false, stripComments: true, }).on('error', e => console.error(e)); return merge(project.sources(), project.dependencies()) .pipe(bundler) .pipe(size({title: 'polymer-bundler'})) .pipe(rename(skipRootFolder)); }
javascript
function polymerBuild(config) { const skipRootFolder = function(file) { const rootFolder = config.root || '.'; file.dirname = path.relative(rootFolder, file.dirname); }; const project = new build.PolymerProject(config); const bundler = project.bundler({ // XXX: sourcemaps makes V8 run out of memory sourcemaps: false, stripComments: true, }).on('error', e => console.error(e)); return merge(project.sources(), project.dependencies()) .pipe(bundler) .pipe(size({title: 'polymer-bundler'})) .pipe(rename(skipRootFolder)); }
[ "function", "polymerBuild", "(", "config", ")", "{", "const", "skipRootFolder", "=", "function", "(", "file", ")", "{", "const", "rootFolder", "=", "config", ".", "root", "||", "'.'", ";", "file", ".", "dirname", "=", "path", ".", "relative", "(", "rootFolder", ",", "file", ".", "dirname", ")", ";", "}", ";", "const", "project", "=", "new", "build", ".", "PolymerProject", "(", "config", ")", ";", "const", "bundler", "=", "project", ".", "bundler", "(", "{", "sourcemaps", ":", "false", ",", "stripComments", ":", "true", ",", "}", ")", ".", "on", "(", "'error'", ",", "e", "=>", "console", ".", "error", "(", "e", ")", ")", ";", "return", "merge", "(", "project", ".", "sources", "(", ")", ",", "project", ".", "dependencies", "(", ")", ")", ".", "pipe", "(", "bundler", ")", ".", "pipe", "(", "size", "(", "{", "title", ":", "'polymer-bundler'", "}", ")", ")", ".", "pipe", "(", "rename", "(", "skipRootFolder", ")", ")", ";", "}" ]
Executes the polymer-build, which a.o. vulcanizes and minifies the HTML @param {Object} config Content of polymer.json @returns
[ "Executes", "the", "polymer", "-", "build", "which", "a", ".", "o", ".", "vulcanizes", "and", "minifies", "the", "HTML" ]
76f83ea018f726a9e4390444deef65dbe9dde1ff
https://github.com/Collaborne/gulp-polymer-build-utils/blob/76f83ea018f726a9e4390444deef65dbe9dde1ff/polymer-build.js#L15-L33
train
medialab/sandcrawler
src/helpers.js
serializeError
function serializeError(err) { var o = {}; Object.getOwnPropertyNames(err).forEach(function (k) { o[k] = err[k]; }); return _.omit(o, ['stack', 'type', 'arguments']); }
javascript
function serializeError(err) { var o = {}; Object.getOwnPropertyNames(err).forEach(function (k) { o[k] = err[k]; }); return _.omit(o, ['stack', 'type', 'arguments']); }
[ "function", "serializeError", "(", "err", ")", "{", "var", "o", "=", "{", "}", ";", "Object", ".", "getOwnPropertyNames", "(", "err", ")", ".", "forEach", "(", "function", "(", "k", ")", "{", "o", "[", "k", "]", "=", "err", "[", "k", "]", ";", "}", ")", ";", "return", "_", ".", "omit", "(", "o", ",", "[", "'stack'", ",", "'type'", ",", "'arguments'", "]", ")", ";", "}" ]
Serialize a JavaScript error
[ "Serialize", "a", "JavaScript", "error" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/helpers.js#L34-L42
train
medialab/sandcrawler
src/helpers.js
serializeCookie
function serializeCookie(cookie) { return { path: cookie.path, name: cookie.key, value: cookie.value, domain: cookie.domain }; }
javascript
function serializeCookie(cookie) { return { path: cookie.path, name: cookie.key, value: cookie.value, domain: cookie.domain }; }
[ "function", "serializeCookie", "(", "cookie", ")", "{", "return", "{", "path", ":", "cookie", ".", "path", ",", "name", ":", "cookie", ".", "key", ",", "value", ":", "cookie", ".", "value", ",", "domain", ":", "cookie", ".", "domain", "}", ";", "}" ]
Serialize a tough-cookie Cookie instance
[ "Serialize", "a", "tough", "-", "cookie", "Cookie", "instance" ]
c08e19095eee42c8ce1f84685960e5ea6cb0fd1d
https://github.com/medialab/sandcrawler/blob/c08e19095eee42c8ce1f84685960e5ea6cb0fd1d/src/helpers.js#L45-L52
train
dbkaplun/hterm-umdjs
dist/index.js
norm16
function norm16(v) { v = parseInt(v, 16); return size == 2 ? v : // 16 bit size == 1 ? v << 4 : // 8 bit v >> (4 * (size - 2)); // 24 or 32 bit }
javascript
function norm16(v) { v = parseInt(v, 16); return size == 2 ? v : // 16 bit size == 1 ? v << 4 : // 8 bit v >> (4 * (size - 2)); // 24 or 32 bit }
[ "function", "norm16", "(", "v", ")", "{", "v", "=", "parseInt", "(", "v", ",", "16", ")", ";", "return", "size", "==", "2", "?", "v", ":", "size", "==", "1", "?", "v", "<<", "4", ":", "v", ">>", "(", "4", "*", "(", "size", "-", "2", ")", ")", ";", "}" ]
Normalize to 16 bits.
[ "Normalize", "to", "16", "bits", "." ]
5cf0fe1f73302ca543c6bcd2d27852362ecada97
https://github.com/dbkaplun/hterm-umdjs/blob/5cf0fe1f73302ca543c6bcd2d27852362ecada97/dist/index.js#L485-L490
train