repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
mgesmundo/authorify-client
build/authorify.js
function(objArr) { var ret = []; for(var i = 0; i < objArr.length; i ++) { ret.push(_recipientInfoFromAsn1(objArr[i])); } return ret; }
javascript
function(objArr) { var ret = []; for(var i = 0; i < objArr.length; i ++) { ret.push(_recipientInfoFromAsn1(objArr[i])); } return ret; }
[ "function", "(", "objArr", ")", "{", "var", "ret", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "objArr", ".", "length", ";", "i", "++", ")", "{", "ret", ".", "push", "(", "_recipientInfoFromAsn1", "(", "objArr", "[", "i", "]", ")", ")", ";", "}", "return", "ret", ";", "}" ]
Map a set of RecipientInfo ASN.1 objects to recipientInfo objects. @param objArr Array of ASN.1 representations RecipientInfo (i.e. SET OF). @return array of recipientInfo objects.
[ "Map", "a", "set", "of", "RecipientInfo", "ASN", ".", "1", "objects", "to", "recipientInfo", "objects", "." ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L24961-L24967
train
mgesmundo/authorify-client
build/authorify.js
function(recipientsArr) { var ret = []; for(var i = 0; i < recipientsArr.length; i ++) { ret.push(_recipientInfoToAsn1(recipientsArr[i])); } return ret; }
javascript
function(recipientsArr) { var ret = []; for(var i = 0; i < recipientsArr.length; i ++) { ret.push(_recipientInfoToAsn1(recipientsArr[i])); } return ret; }
[ "function", "(", "recipientsArr", ")", "{", "var", "ret", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "recipientsArr", ".", "length", ";", "i", "++", ")", "{", "ret", ".", "push", "(", "_recipientInfoToAsn1", "(", "recipientsArr", "[", "i", "]", ")", ")", ";", "}", "return", "ret", ";", "}" ]
Map an array of recipientInfo objects to ASN.1 objects. @param recipientsArr Array of recipientInfo objects. @return Array of ASN.1 representations RecipientInfo.
[ "Map", "an", "array", "of", "recipientInfo", "objects", "to", "ASN", ".", "1", "objects", "." ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L24976-L24982
train
mgesmundo/authorify-client
build/authorify.js
function(task, recurse) { // get time since last context swap (ms), if enough time has passed set // swap to true to indicate that doNext was performed asynchronously // also, if recurse is too high do asynchronously var swap = (recurse > sMaxRecursions) || (+new Date() - task.swapTime) > sTimeSlice; var doNext = function(recurse) { recurse++; if(task.state === RUNNING) { if(swap) { // update swap time task.swapTime = +new Date(); } if(task.subtasks.length > 0) { // run next subtask var subtask = task.subtasks.shift(); subtask.error = task.error; subtask.swapTime = task.swapTime; subtask.userData = task.userData; subtask.run(subtask); if(!subtask.error) { runNext(subtask, recurse); } } else { finish(task); if(!task.error) { // chain back up and run parent if(task.parent !== null) { // propagate task info task.parent.error = task.error; task.parent.swapTime = task.swapTime; task.parent.userData = task.userData; // no subtasks left, call run next subtask on parent runNext(task.parent, recurse); } } } } }; if(swap) { // we're swapping, so run asynchronously setTimeout(doNext, 0); } else { // not swapping, so run synchronously doNext(recurse); } }
javascript
function(task, recurse) { // get time since last context swap (ms), if enough time has passed set // swap to true to indicate that doNext was performed asynchronously // also, if recurse is too high do asynchronously var swap = (recurse > sMaxRecursions) || (+new Date() - task.swapTime) > sTimeSlice; var doNext = function(recurse) { recurse++; if(task.state === RUNNING) { if(swap) { // update swap time task.swapTime = +new Date(); } if(task.subtasks.length > 0) { // run next subtask var subtask = task.subtasks.shift(); subtask.error = task.error; subtask.swapTime = task.swapTime; subtask.userData = task.userData; subtask.run(subtask); if(!subtask.error) { runNext(subtask, recurse); } } else { finish(task); if(!task.error) { // chain back up and run parent if(task.parent !== null) { // propagate task info task.parent.error = task.error; task.parent.swapTime = task.swapTime; task.parent.userData = task.userData; // no subtasks left, call run next subtask on parent runNext(task.parent, recurse); } } } } }; if(swap) { // we're swapping, so run asynchronously setTimeout(doNext, 0); } else { // not swapping, so run synchronously doNext(recurse); } }
[ "function", "(", "task", ",", "recurse", ")", "{", "var", "swap", "=", "(", "recurse", ">", "sMaxRecursions", ")", "||", "(", "+", "new", "Date", "(", ")", "-", "task", ".", "swapTime", ")", ">", "sTimeSlice", ";", "var", "doNext", "=", "function", "(", "recurse", ")", "{", "recurse", "++", ";", "if", "(", "task", ".", "state", "===", "RUNNING", ")", "{", "if", "(", "swap", ")", "{", "task", ".", "swapTime", "=", "+", "new", "Date", "(", ")", ";", "}", "if", "(", "task", ".", "subtasks", ".", "length", ">", "0", ")", "{", "var", "subtask", "=", "task", ".", "subtasks", ".", "shift", "(", ")", ";", "subtask", ".", "error", "=", "task", ".", "error", ";", "subtask", ".", "swapTime", "=", "task", ".", "swapTime", ";", "subtask", ".", "userData", "=", "task", ".", "userData", ";", "subtask", ".", "run", "(", "subtask", ")", ";", "if", "(", "!", "subtask", ".", "error", ")", "{", "runNext", "(", "subtask", ",", "recurse", ")", ";", "}", "}", "else", "{", "finish", "(", "task", ")", ";", "if", "(", "!", "task", ".", "error", ")", "{", "if", "(", "task", ".", "parent", "!==", "null", ")", "{", "task", ".", "parent", ".", "error", "=", "task", ".", "error", ";", "task", ".", "parent", ".", "swapTime", "=", "task", ".", "swapTime", ";", "task", ".", "parent", ".", "userData", "=", "task", ".", "userData", ";", "runNext", "(", "task", ".", "parent", ",", "recurse", ")", ";", "}", "}", "}", "}", "}", ";", "if", "(", "swap", ")", "{", "setTimeout", "(", "doNext", ",", "0", ")", ";", "}", "else", "{", "doNext", "(", "recurse", ")", ";", "}", "}" ]
Run the next subtask or finish this task. @param task the task to process. @param recurse the recursion count.
[ "Run", "the", "next", "subtask", "or", "finish", "this", "task", "." ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L26112-L26165
train
mgesmundo/authorify-client
build/authorify.js
function(task, suppressCallbacks) { // subtask is now done task.state = DONE; delete sTasks[task.id]; if(sVL >= 1) { forge.log.verbose(cat, '[%s][%s] finish', task.id, task.name, task); } // only do queue processing for root tasks if(task.parent === null) { // report error if queue is missing if(!(task.type in sTaskQueues)) { forge.log.error(cat, '[%s][%s] task queue missing [%s]', task.id, task.name, task.type); } else if(sTaskQueues[task.type].length === 0) { // report error if queue is empty forge.log.error(cat, '[%s][%s] task queue empty [%s]', task.id, task.name, task.type); } else if(sTaskQueues[task.type][0] !== task) { // report error if this task isn't the first in the queue forge.log.error(cat, '[%s][%s] task not first in queue [%s]', task.id, task.name, task.type); } else { // remove ourselves from the queue sTaskQueues[task.type].shift(); // clean up queue if it is empty if(sTaskQueues[task.type].length === 0) { if(sVL >= 1) { forge.log.verbose(cat, '[%s][%s] delete queue [%s]', task.id, task.name, task.type); } /* Note: Only a task can delete a queue of its own type. This is used as a way to synchronize tasks. If a queue for a certain task type exists, then a task of that type is running. */ delete sTaskQueues[task.type]; } else { // dequeue the next task and start it if(sVL >= 1) { forge.log.verbose(cat, '[%s][%s] queue start next [%s] remain:%s', task.id, task.name, task.type, sTaskQueues[task.type].length); } sTaskQueues[task.type][0].start(); } } if(!suppressCallbacks) { // call final callback if one exists if(task.error && task.failureCallback) { task.failureCallback(task); } else if(!task.error && task.successCallback) { task.successCallback(task); } } } }
javascript
function(task, suppressCallbacks) { // subtask is now done task.state = DONE; delete sTasks[task.id]; if(sVL >= 1) { forge.log.verbose(cat, '[%s][%s] finish', task.id, task.name, task); } // only do queue processing for root tasks if(task.parent === null) { // report error if queue is missing if(!(task.type in sTaskQueues)) { forge.log.error(cat, '[%s][%s] task queue missing [%s]', task.id, task.name, task.type); } else if(sTaskQueues[task.type].length === 0) { // report error if queue is empty forge.log.error(cat, '[%s][%s] task queue empty [%s]', task.id, task.name, task.type); } else if(sTaskQueues[task.type][0] !== task) { // report error if this task isn't the first in the queue forge.log.error(cat, '[%s][%s] task not first in queue [%s]', task.id, task.name, task.type); } else { // remove ourselves from the queue sTaskQueues[task.type].shift(); // clean up queue if it is empty if(sTaskQueues[task.type].length === 0) { if(sVL >= 1) { forge.log.verbose(cat, '[%s][%s] delete queue [%s]', task.id, task.name, task.type); } /* Note: Only a task can delete a queue of its own type. This is used as a way to synchronize tasks. If a queue for a certain task type exists, then a task of that type is running. */ delete sTaskQueues[task.type]; } else { // dequeue the next task and start it if(sVL >= 1) { forge.log.verbose(cat, '[%s][%s] queue start next [%s] remain:%s', task.id, task.name, task.type, sTaskQueues[task.type].length); } sTaskQueues[task.type][0].start(); } } if(!suppressCallbacks) { // call final callback if one exists if(task.error && task.failureCallback) { task.failureCallback(task); } else if(!task.error && task.successCallback) { task.successCallback(task); } } } }
[ "function", "(", "task", ",", "suppressCallbacks", ")", "{", "task", ".", "state", "=", "DONE", ";", "delete", "sTasks", "[", "task", ".", "id", "]", ";", "if", "(", "sVL", ">=", "1", ")", "{", "forge", ".", "log", ".", "verbose", "(", "cat", ",", "'[%s][%s] finish'", ",", "task", ".", "id", ",", "task", ".", "name", ",", "task", ")", ";", "}", "if", "(", "task", ".", "parent", "===", "null", ")", "{", "if", "(", "!", "(", "task", ".", "type", "in", "sTaskQueues", ")", ")", "{", "forge", ".", "log", ".", "error", "(", "cat", ",", "'[%s][%s] task queue missing [%s]'", ",", "task", ".", "id", ",", "task", ".", "name", ",", "task", ".", "type", ")", ";", "}", "else", "if", "(", "sTaskQueues", "[", "task", ".", "type", "]", ".", "length", "===", "0", ")", "{", "forge", ".", "log", ".", "error", "(", "cat", ",", "'[%s][%s] task queue empty [%s]'", ",", "task", ".", "id", ",", "task", ".", "name", ",", "task", ".", "type", ")", ";", "}", "else", "if", "(", "sTaskQueues", "[", "task", ".", "type", "]", "[", "0", "]", "!==", "task", ")", "{", "forge", ".", "log", ".", "error", "(", "cat", ",", "'[%s][%s] task not first in queue [%s]'", ",", "task", ".", "id", ",", "task", ".", "name", ",", "task", ".", "type", ")", ";", "}", "else", "{", "sTaskQueues", "[", "task", ".", "type", "]", ".", "shift", "(", ")", ";", "if", "(", "sTaskQueues", "[", "task", ".", "type", "]", ".", "length", "===", "0", ")", "{", "if", "(", "sVL", ">=", "1", ")", "{", "forge", ".", "log", ".", "verbose", "(", "cat", ",", "'[%s][%s] delete queue [%s]'", ",", "task", ".", "id", ",", "task", ".", "name", ",", "task", ".", "type", ")", ";", "}", "delete", "sTaskQueues", "[", "task", ".", "type", "]", ";", "}", "else", "{", "if", "(", "sVL", ">=", "1", ")", "{", "forge", ".", "log", ".", "verbose", "(", "cat", ",", "'[%s][%s] queue start next [%s] remain:%s'", ",", "task", ".", "id", ",", "task", ".", "name", ",", "task", ".", "type", ",", "sTaskQueues", "[", "task", ".", "type", "]", ".", "length", ")", ";", "}", "sTaskQueues", "[", "task", ".", "type", "]", "[", "0", "]", ".", "start", "(", ")", ";", "}", "}", "if", "(", "!", "suppressCallbacks", ")", "{", "if", "(", "task", ".", "error", "&&", "task", ".", "failureCallback", ")", "{", "task", ".", "failureCallback", "(", "task", ")", ";", "}", "else", "if", "(", "!", "task", ".", "error", "&&", "task", ".", "successCallback", ")", "{", "task", ".", "successCallback", "(", "task", ")", ";", "}", "}", "}", "}" ]
Finishes a task and looks for the next task in the queue to start. @param task the task to finish. @param suppressCallbacks true to suppress callbacks.
[ "Finishes", "a", "task", "and", "looks", "for", "the", "next", "task", "in", "the", "queue", "to", "start", "." ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L26173-L26235
train
mgesmundo/authorify-client
build/authorify.js
function() { var cert; try { cert = this.keychain.getCertPem(); } catch (e) { throw new CError({ body: { code: 'ImATeapot', message: 'missing certificate', cause: e } }).log('body'); } if (!cert) { throw new CError('missing certificate').log(); } if (!this.getDate()) { throw new CError('missing date').log(); } if (!this.getSid()) { throw new CError('missing session identifier').log(); } if (!this.getId()) { throw new CError('missing id').log(); } if (!this.getApp()) { throw new CError('missing app').log(); } var tmp = this.getDate() + '::' + cert +'::' + this.getSid() + '::' + this.getId() + '::' + this.getApp() + '::'; if (this._reply) { // NOTE: username is not mandatory in non browser environment // NOTE: SECRET_SERVER is present only when the client is used inside the authorify module var username = this.getUsername(); if (!username) { username = 'anonymous'; } var password = this.getPassword(); if (!password) { password = forge.util.encode64(forge.random.getBytesSync(16)); } tmp += username + '::' + password + '::' + SECRET_SERVER; } else { tmp += SECRET_CLIENT; } var hmac = forge.hmac.create(); hmac.start('sha256', SECRET); hmac.update(tmp); return hmac.digest().toHex(); }
javascript
function() { var cert; try { cert = this.keychain.getCertPem(); } catch (e) { throw new CError({ body: { code: 'ImATeapot', message: 'missing certificate', cause: e } }).log('body'); } if (!cert) { throw new CError('missing certificate').log(); } if (!this.getDate()) { throw new CError('missing date').log(); } if (!this.getSid()) { throw new CError('missing session identifier').log(); } if (!this.getId()) { throw new CError('missing id').log(); } if (!this.getApp()) { throw new CError('missing app').log(); } var tmp = this.getDate() + '::' + cert +'::' + this.getSid() + '::' + this.getId() + '::' + this.getApp() + '::'; if (this._reply) { // NOTE: username is not mandatory in non browser environment // NOTE: SECRET_SERVER is present only when the client is used inside the authorify module var username = this.getUsername(); if (!username) { username = 'anonymous'; } var password = this.getPassword(); if (!password) { password = forge.util.encode64(forge.random.getBytesSync(16)); } tmp += username + '::' + password + '::' + SECRET_SERVER; } else { tmp += SECRET_CLIENT; } var hmac = forge.hmac.create(); hmac.start('sha256', SECRET); hmac.update(tmp); return hmac.digest().toHex(); }
[ "function", "(", ")", "{", "var", "cert", ";", "try", "{", "cert", "=", "this", ".", "keychain", ".", "getCertPem", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "throw", "new", "CError", "(", "{", "body", ":", "{", "code", ":", "'ImATeapot'", ",", "message", ":", "'missing certificate'", ",", "cause", ":", "e", "}", "}", ")", ".", "log", "(", "'body'", ")", ";", "}", "if", "(", "!", "cert", ")", "{", "throw", "new", "CError", "(", "'missing certificate'", ")", ".", "log", "(", ")", ";", "}", "if", "(", "!", "this", ".", "getDate", "(", ")", ")", "{", "throw", "new", "CError", "(", "'missing date'", ")", ".", "log", "(", ")", ";", "}", "if", "(", "!", "this", ".", "getSid", "(", ")", ")", "{", "throw", "new", "CError", "(", "'missing session identifier'", ")", ".", "log", "(", ")", ";", "}", "if", "(", "!", "this", ".", "getId", "(", ")", ")", "{", "throw", "new", "CError", "(", "'missing id'", ")", ".", "log", "(", ")", ";", "}", "if", "(", "!", "this", ".", "getApp", "(", ")", ")", "{", "throw", "new", "CError", "(", "'missing app'", ")", ".", "log", "(", ")", ";", "}", "var", "tmp", "=", "this", ".", "getDate", "(", ")", "+", "'::'", "+", "cert", "+", "'::'", "+", "this", ".", "getSid", "(", ")", "+", "'::'", "+", "this", ".", "getId", "(", ")", "+", "'::'", "+", "this", ".", "getApp", "(", ")", "+", "'::'", ";", "if", "(", "this", ".", "_reply", ")", "{", "var", "username", "=", "this", ".", "getUsername", "(", ")", ";", "if", "(", "!", "username", ")", "{", "username", "=", "'anonymous'", ";", "}", "var", "password", "=", "this", ".", "getPassword", "(", ")", ";", "if", "(", "!", "password", ")", "{", "password", "=", "forge", ".", "util", ".", "encode64", "(", "forge", ".", "random", ".", "getBytesSync", "(", "16", ")", ")", ";", "}", "tmp", "+=", "username", "+", "'::'", "+", "password", "+", "'::'", "+", "SECRET_SERVER", ";", "}", "else", "{", "tmp", "+=", "SECRET_CLIENT", ";", "}", "var", "hmac", "=", "forge", ".", "hmac", ".", "create", "(", ")", ";", "hmac", ".", "start", "(", "'sha256'", ",", "SECRET", ")", ";", "hmac", ".", "update", "(", "tmp", ")", ";", "return", "hmac", ".", "digest", "(", ")", ".", "toHex", "(", ")", ";", "}" ]
Generate a new token @returns {String} The generated token
[ "Generate", "a", "new", "token" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L29468-L29516
train
mgesmundo/authorify-client
build/authorify.js
function(data) { if (!(data && 'function' === typeof data.isBase64 && data.isBase64())) { throw new CError('wrong data format to decrypt').log(); } return JSON.parse(this.encoder.decryptAes(data, this.getSecret())); }
javascript
function(data) { if (!(data && 'function' === typeof data.isBase64 && data.isBase64())) { throw new CError('wrong data format to decrypt').log(); } return JSON.parse(this.encoder.decryptAes(data, this.getSecret())); }
[ "function", "(", "data", ")", "{", "if", "(", "!", "(", "data", "&&", "'function'", "===", "typeof", "data", ".", "isBase64", "&&", "data", ".", "isBase64", "(", ")", ")", ")", "{", "throw", "new", "CError", "(", "'wrong data format to decrypt'", ")", ".", "log", "(", ")", ";", "}", "return", "JSON", ".", "parse", "(", "this", ".", "encoder", ".", "decryptAes", "(", "data", ",", "this", ".", "getSecret", "(", ")", ")", ")", ";", "}" ]
Decrypt content. @param {String} The data to decrypt @return {Object} The decrypted result
[ "Decrypt", "content", "." ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L29599-L29604
train
mgesmundo/authorify-client
build/authorify.js
getConfigOptions
function getConfigOptions(opts) { opts = formatOptions(opts); _.forEach(config, function(value, key) { opts[key] = opts[key] || value; }); opts.headers = opts.headers || {}; return opts; }
javascript
function getConfigOptions(opts) { opts = formatOptions(opts); _.forEach(config, function(value, key) { opts[key] = opts[key] || value; }); opts.headers = opts.headers || {}; return opts; }
[ "function", "getConfigOptions", "(", "opts", ")", "{", "opts", "=", "formatOptions", "(", "opts", ")", ";", "_", ".", "forEach", "(", "config", ",", "function", "(", "value", ",", "key", ")", "{", "opts", "[", "key", "]", "=", "opts", "[", "key", "]", "||", "value", ";", "}", ")", ";", "opts", ".", "headers", "=", "opts", ".", "headers", "||", "{", "}", ";", "return", "opts", ";", "}" ]
Get all options with default values if empty @param {Object/String} opts The options object or string with the required name @returns {Object} The configuration with default values @private @ignore
[ "Get", "all", "options", "with", "default", "values", "if", "empty" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30469-L30477
train
mgesmundo/authorify-client
build/authorify.js
fixRequestOptions
function fixRequestOptions(method, path, transport, plain, callback) { var opts = { method: method, path: path }; if (_.isFunction(transport)) { opts.callback = transport; opts.plain = false; opts.transport = 'http'; } else { if (_.isString(transport)) { opts.transport = transport; } else if (_.isBoolean(transport)) { opts.plain = transport; } if (_.isFunction(plain)) { opts.callback = plain; opts.plain = opts.plain || false; } else if (_.isBoolean(plain)) { opts.callback = callback; opts.plain = plain; } } return opts; }
javascript
function fixRequestOptions(method, path, transport, plain, callback) { var opts = { method: method, path: path }; if (_.isFunction(transport)) { opts.callback = transport; opts.plain = false; opts.transport = 'http'; } else { if (_.isString(transport)) { opts.transport = transport; } else if (_.isBoolean(transport)) { opts.plain = transport; } if (_.isFunction(plain)) { opts.callback = plain; opts.plain = opts.plain || false; } else if (_.isBoolean(plain)) { opts.callback = callback; opts.plain = plain; } } return opts; }
[ "function", "fixRequestOptions", "(", "method", ",", "path", ",", "transport", ",", "plain", ",", "callback", ")", "{", "var", "opts", "=", "{", "method", ":", "method", ",", "path", ":", "path", "}", ";", "if", "(", "_", ".", "isFunction", "(", "transport", ")", ")", "{", "opts", ".", "callback", "=", "transport", ";", "opts", ".", "plain", "=", "false", ";", "opts", ".", "transport", "=", "'http'", ";", "}", "else", "{", "if", "(", "_", ".", "isString", "(", "transport", ")", ")", "{", "opts", ".", "transport", "=", "transport", ";", "}", "else", "if", "(", "_", ".", "isBoolean", "(", "transport", ")", ")", "{", "opts", ".", "plain", "=", "transport", ";", "}", "if", "(", "_", ".", "isFunction", "(", "plain", ")", ")", "{", "opts", ".", "callback", "=", "plain", ";", "opts", ".", "plain", "=", "opts", ".", "plain", "||", "false", ";", "}", "else", "if", "(", "_", ".", "isBoolean", "(", "plain", ")", ")", "{", "opts", ".", "callback", "=", "callback", ";", "opts", ".", "plain", "=", "plain", ";", "}", "}", "return", "opts", ";", "}" ]
Make an object with all params @param {String} method The required method @param {String} path The required path @param {String} [transport = 'http'] The transport protocol ('http' or 'ws') @param {Boolean} [plain = false] The required plain @param {Function} callback The required callback @return {Object} An object with all params as properties @private @ignore
[ "Make", "an", "object", "with", "all", "params" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30491-L30515
train
mgesmundo/authorify-client
build/authorify.js
logResponse
function logResponse(err, res) { if (err || (res && !res.ok)) { if (err) { log.warn('%s on response -> read plaintext body due an error (%s)', app.name, err.message); } else { log.warn('%s on response -> read plaintext body due an error (%s)', app.name, res.error); } } else if (res && !_.isEmpty(res.body)) { if (res.body[my.config.encryptedBodyName]) { log.info('%s on response -> read encrypted body', app.name); } else { log.info('%s on response -> read plaintext body', app.name); } } }
javascript
function logResponse(err, res) { if (err || (res && !res.ok)) { if (err) { log.warn('%s on response -> read plaintext body due an error (%s)', app.name, err.message); } else { log.warn('%s on response -> read plaintext body due an error (%s)', app.name, res.error); } } else if (res && !_.isEmpty(res.body)) { if (res.body[my.config.encryptedBodyName]) { log.info('%s on response -> read encrypted body', app.name); } else { log.info('%s on response -> read plaintext body', app.name); } } }
[ "function", "logResponse", "(", "err", ",", "res", ")", "{", "if", "(", "err", "||", "(", "res", "&&", "!", "res", ".", "ok", ")", ")", "{", "if", "(", "err", ")", "{", "log", ".", "warn", "(", "'%s on response -> read plaintext body due an error (%s)'", ",", "app", ".", "name", ",", "err", ".", "message", ")", ";", "}", "else", "{", "log", ".", "warn", "(", "'%s on response -> read plaintext body due an error (%s)'", ",", "app", ".", "name", ",", "res", ".", "error", ")", ";", "}", "}", "else", "if", "(", "res", "&&", "!", "_", ".", "isEmpty", "(", "res", ".", "body", ")", ")", "{", "if", "(", "res", ".", "body", "[", "my", ".", "config", ".", "encryptedBodyName", "]", ")", "{", "log", ".", "info", "(", "'%s on response -> read encrypted body'", ",", "app", ".", "name", ")", ";", "}", "else", "{", "log", ".", "info", "(", "'%s on response -> read plaintext body'", ",", "app", ".", "name", ")", ";", "}", "}", "}" ]
Log the response @param {Object} err The error if occurred @param {Object} res The response @private @ignore
[ "Log", "the", "response" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30538-L30552
train
mgesmundo/authorify-client
build/authorify.js
getModuleName
function getModuleName(module) { var script = module.replace(/[^a-zA-Z0-9]/g, '.'), parts = script.split('.'), name = parts.shift(); if (parts.length) { for (var p in parts) { name += parts[p].charAt(0).toUpperCase() + parts[p].substr(1, parts[p].length); } } return name; }
javascript
function getModuleName(module) { var script = module.replace(/[^a-zA-Z0-9]/g, '.'), parts = script.split('.'), name = parts.shift(); if (parts.length) { for (var p in parts) { name += parts[p].charAt(0).toUpperCase() + parts[p].substr(1, parts[p].length); } } return name; }
[ "function", "getModuleName", "(", "module", ")", "{", "var", "script", "=", "module", ".", "replace", "(", "/", "[^a-zA-Z0-9]", "/", "g", ",", "'.'", ")", ",", "parts", "=", "script", ".", "split", "(", "'.'", ")", ",", "name", "=", "parts", ".", "shift", "(", ")", ";", "if", "(", "parts", ".", "length", ")", "{", "for", "(", "var", "p", "in", "parts", ")", "{", "name", "+=", "parts", "[", "p", "]", ".", "charAt", "(", "0", ")", ".", "toUpperCase", "(", ")", "+", "parts", "[", "p", "]", ".", "substr", "(", "1", ",", "parts", "[", "p", "]", ".", "length", ")", ";", "}", "}", "return", "name", ";", "}" ]
Formats the name of the module loaded into the browser @param module {String} The original module name @return {String} Name of the module @private @ignore
[ "Formats", "the", "name", "of", "the", "module", "loaded", "into", "the", "browser" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30562-L30573
train
mgesmundo/authorify-client
build/authorify.js
function(opts) { opts = opts || {}; var path = opts.path || this.path, callback = opts.callback, method = opts.method || this.method, ws = getWebsocketPlugin(), transports = app.config.transports, self = this, i = 0, error, response; if (ws) { if (transports && transports.length > 0) { async.whilst( function () { return (i < transports.length); }, function (done) { self.doConnect(transports[i], method, path, function (err, res) { error = err; response = res; if (!err && res) { i = transports.length; } else { i++; if (i < transports.length) { delete self.request; } } done(); }); }, function (err) { callback(err || error, response); } ); } else { error = 'no transport available'; log.error('%s %s', app.name, error); callback(error); } } else { this.doConnect('http', method, path, callback); } return this; }
javascript
function(opts) { opts = opts || {}; var path = opts.path || this.path, callback = opts.callback, method = opts.method || this.method, ws = getWebsocketPlugin(), transports = app.config.transports, self = this, i = 0, error, response; if (ws) { if (transports && transports.length > 0) { async.whilst( function () { return (i < transports.length); }, function (done) { self.doConnect(transports[i], method, path, function (err, res) { error = err; response = res; if (!err && res) { i = transports.length; } else { i++; if (i < transports.length) { delete self.request; } } done(); }); }, function (err) { callback(err || error, response); } ); } else { error = 'no transport available'; log.error('%s %s', app.name, error); callback(error); } } else { this.doConnect('http', method, path, callback); } return this; }
[ "function", "(", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "var", "path", "=", "opts", ".", "path", "||", "this", ".", "path", ",", "callback", "=", "opts", ".", "callback", ",", "method", "=", "opts", ".", "method", "||", "this", ".", "method", ",", "ws", "=", "getWebsocketPlugin", "(", ")", ",", "transports", "=", "app", ".", "config", ".", "transports", ",", "self", "=", "this", ",", "i", "=", "0", ",", "error", ",", "response", ";", "if", "(", "ws", ")", "{", "if", "(", "transports", "&&", "transports", ".", "length", ">", "0", ")", "{", "async", ".", "whilst", "(", "function", "(", ")", "{", "return", "(", "i", "<", "transports", ".", "length", ")", ";", "}", ",", "function", "(", "done", ")", "{", "self", ".", "doConnect", "(", "transports", "[", "i", "]", ",", "method", ",", "path", ",", "function", "(", "err", ",", "res", ")", "{", "error", "=", "err", ";", "response", "=", "res", ";", "if", "(", "!", "err", "&&", "res", ")", "{", "i", "=", "transports", ".", "length", ";", "}", "else", "{", "i", "++", ";", "if", "(", "i", "<", "transports", ".", "length", ")", "{", "delete", "self", ".", "request", ";", "}", "}", "done", "(", ")", ";", "}", ")", ";", "}", ",", "function", "(", "err", ")", "{", "callback", "(", "err", "||", "error", ",", "response", ")", ";", "}", ")", ";", "}", "else", "{", "error", "=", "'no transport available'", ";", "log", ".", "error", "(", "'%s %s'", ",", "app", ".", "name", ",", "error", ")", ";", "callback", "(", "error", ")", ";", "}", "}", "else", "{", "this", ".", "doConnect", "(", "'http'", ",", "method", ",", "path", ",", "callback", ")", ";", "}", "return", "this", ";", "}" ]
A request without Authorization header @inheritdoc #authorize @private
[ "A", "request", "without", "Authorization", "header" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L30885-L30931
train
mgesmundo/authorify-client
build/authorify.js
function(value) { if (value) { if (config.encryptQuery) { this._pendingQuery = this._pendingQuery || []; this._pendingQuery.push(value); } else { this.request.query(value); } } return this; }
javascript
function(value) { if (value) { if (config.encryptQuery) { this._pendingQuery = this._pendingQuery || []; this._pendingQuery.push(value); } else { this.request.query(value); } } return this; }
[ "function", "(", "value", ")", "{", "if", "(", "value", ")", "{", "if", "(", "config", ".", "encryptQuery", ")", "{", "this", ".", "_pendingQuery", "=", "this", ".", "_pendingQuery", "||", "[", "]", ";", "this", ".", "_pendingQuery", ".", "push", "(", "value", ")", ";", "}", "else", "{", "this", ".", "request", ".", "query", "(", "value", ")", ";", "}", "}", "return", "this", ";", "}" ]
Compose a query-string ## Example To compose a query-string like "?format=json&data=here" in a GET request: var client = require('authorify-client')({ // set your options }); client .get('/someroute') .query({ format: 'json' }) .query({ data: 'here' }) .end(function(err, res){ // your logic }); @chainable @param {Object} value The object to compose the query @return {Client} The client instance
[ "Compose", "a", "query", "-", "string" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L31144-L31154
train
mgesmundo/authorify-client
build/authorify.js
function(callback) { if (res.session && res.session.cert) { if (res.parsedHeader.payload.mode === 'handshake') { if (my.config.crypter.verifyCertificate(res.session.cert)) { callback(null); } else { callback('unknown certificate'); } } else { callback(null); } } else { callback('wrong session'); } }
javascript
function(callback) { if (res.session && res.session.cert) { if (res.parsedHeader.payload.mode === 'handshake') { if (my.config.crypter.verifyCertificate(res.session.cert)) { callback(null); } else { callback('unknown certificate'); } } else { callback(null); } } else { callback('wrong session'); } }
[ "function", "(", "callback", ")", "{", "if", "(", "res", ".", "session", "&&", "res", ".", "session", ".", "cert", ")", "{", "if", "(", "res", ".", "parsedHeader", ".", "payload", ".", "mode", "===", "'handshake'", ")", "{", "if", "(", "my", ".", "config", ".", "crypter", ".", "verifyCertificate", "(", "res", ".", "session", ".", "cert", ")", ")", "{", "callback", "(", "null", ")", ";", "}", "else", "{", "callback", "(", "'unknown certificate'", ")", ";", "}", "}", "else", "{", "callback", "(", "null", ")", ";", "}", "}", "else", "{", "callback", "(", "'wrong session'", ")", ";", "}", "}" ]
verify certificate authenticity
[ "verify", "certificate", "authenticity" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L31326-L31340
train
mgesmundo/authorify-client
build/authorify.js
function(callback) { if (!res.parsedHeader.signature) { callback('unsigned'); } else { var signVerifier = new Crypter({ cert: res.session.cert }); if (signVerifier.verifySignature(JSON.stringify(res.parsedHeader.content), res.parsedHeader.signature)) { callback(null); } else { callback('forgery'); } } }
javascript
function(callback) { if (!res.parsedHeader.signature) { callback('unsigned'); } else { var signVerifier = new Crypter({ cert: res.session.cert }); if (signVerifier.verifySignature(JSON.stringify(res.parsedHeader.content), res.parsedHeader.signature)) { callback(null); } else { callback('forgery'); } } }
[ "function", "(", "callback", ")", "{", "if", "(", "!", "res", ".", "parsedHeader", ".", "signature", ")", "{", "callback", "(", "'unsigned'", ")", ";", "}", "else", "{", "var", "signVerifier", "=", "new", "Crypter", "(", "{", "cert", ":", "res", ".", "session", ".", "cert", "}", ")", ";", "if", "(", "signVerifier", ".", "verifySignature", "(", "JSON", ".", "stringify", "(", "res", ".", "parsedHeader", ".", "content", ")", ",", "res", ".", "parsedHeader", ".", "signature", ")", ")", "{", "callback", "(", "null", ")", ";", "}", "else", "{", "callback", "(", "'forgery'", ")", ";", "}", "}", "}" ]
verify signature using sender certificate
[ "verify", "signature", "using", "sender", "certificate" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L31342-L31355
train
mgesmundo/authorify-client
build/authorify.js
function(callback) { if (parseInt(config.clockSkew, 10) > 0) { var now = new Date().toSerialNumber(), sent = res.parsedHeader.content.date; if ((now - sent) > config.clockSkew * 1000) { callback('date too old'); } else { callback(null); } } else { callback(null); } }
javascript
function(callback) { if (parseInt(config.clockSkew, 10) > 0) { var now = new Date().toSerialNumber(), sent = res.parsedHeader.content.date; if ((now - sent) > config.clockSkew * 1000) { callback('date too old'); } else { callback(null); } } else { callback(null); } }
[ "function", "(", "callback", ")", "{", "if", "(", "parseInt", "(", "config", ".", "clockSkew", ",", "10", ")", ">", "0", ")", "{", "var", "now", "=", "new", "Date", "(", ")", ".", "toSerialNumber", "(", ")", ",", "sent", "=", "res", ".", "parsedHeader", ".", "content", ".", "date", ";", "if", "(", "(", "now", "-", "sent", ")", ">", "config", ".", "clockSkew", "*", "1000", ")", "{", "callback", "(", "'date too old'", ")", ";", "}", "else", "{", "callback", "(", "null", ")", ";", "}", "}", "else", "{", "callback", "(", "null", ")", ";", "}", "}" ]
verify the date
[ "verify", "the", "date" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L31357-L31369
train
mgesmundo/authorify-client
build/authorify.js
function(secret) { var keyIv; if (!secret) { throw new CError('missing secret').log(); } // secret is a Base64 string if(secret.isBase64()){ try { keyIv = forge.util.decode64(secret); } catch (e) { throw new CError('secret not valid').log(); } } else { keyIv = secret; } return keyIv; }
javascript
function(secret) { var keyIv; if (!secret) { throw new CError('missing secret').log(); } // secret is a Base64 string if(secret.isBase64()){ try { keyIv = forge.util.decode64(secret); } catch (e) { throw new CError('secret not valid').log(); } } else { keyIv = secret; } return keyIv; }
[ "function", "(", "secret", ")", "{", "var", "keyIv", ";", "if", "(", "!", "secret", ")", "{", "throw", "new", "CError", "(", "'missing secret'", ")", ".", "log", "(", ")", ";", "}", "if", "(", "secret", ".", "isBase64", "(", ")", ")", "{", "try", "{", "keyIv", "=", "forge", ".", "util", ".", "decode64", "(", "secret", ")", ";", "}", "catch", "(", "e", ")", "{", "throw", "new", "CError", "(", "'secret not valid'", ")", ".", "log", "(", ")", ";", "}", "}", "else", "{", "keyIv", "=", "secret", ";", "}", "return", "keyIv", ";", "}" ]
Get bytes from a secret key @param {String} secret The secret in Base64 format @return {Bytes} The secret bytes @static @private
[ "Get", "bytes", "from", "a", "secret", "key" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32309-L32325
train
mgesmundo/authorify-client
build/authorify.js
function (data, scheme) { // scheme = RSA-OAEP, RSAES-PKCS1-V1_5 scheme = scheme || SCHEME; return forge.util.encode64(this._cert.publicKey.encrypt(data, scheme)); }
javascript
function (data, scheme) { // scheme = RSA-OAEP, RSAES-PKCS1-V1_5 scheme = scheme || SCHEME; return forge.util.encode64(this._cert.publicKey.encrypt(data, scheme)); }
[ "function", "(", "data", ",", "scheme", ")", "{", "scheme", "=", "scheme", "||", "SCHEME", ";", "return", "forge", ".", "util", ".", "encode64", "(", "this", ".", "_cert", ".", "publicKey", ".", "encrypt", "(", "data", ",", "scheme", ")", ")", ";", "}" ]
Encrypt data using RSA public key inside the X.509 certificate @param {String} data The data to encrypt @param {String} [scheme='RSA-OAEP'] The scheme to be used in encryption. Use 'RSAES-PKCS1-V1_5' in legacy applications. @return {String} The RSA encryption result in Base64
[ "Encrypt", "data", "using", "RSA", "public", "key", "inside", "the", "X", ".", "509", "certificate" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32413-L32417
train
mgesmundo/authorify-client
build/authorify.js
function (data, scheme) { scheme = scheme || SCHEME; return this._key.decrypt(forge.util.decode64(data), scheme); }
javascript
function (data, scheme) { scheme = scheme || SCHEME; return this._key.decrypt(forge.util.decode64(data), scheme); }
[ "function", "(", "data", ",", "scheme", ")", "{", "scheme", "=", "scheme", "||", "SCHEME", ";", "return", "this", ".", "_key", ".", "decrypt", "(", "forge", ".", "util", ".", "decode64", "(", "data", ")", ",", "scheme", ")", ";", "}" ]
Decrypt RSA encrypted data @param {String} data The data to decrypt @param {String} [scheme='RSA-OAEP'] The mode to use in decryption. 'RSA-OAEP', 'RSAES-PKCS1-V1_5' are allowed schemes. @return {String} The decrypted data
[ "Decrypt", "RSA", "encrypted", "data" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32424-L32427
train
mgesmundo/authorify-client
build/authorify.js
function (data, secret, encoder, mode) { // mode = CBC, CFB, OFB, CTR mode = mode || MODE; var keyIv = this.getBytesFromSecret(secret); var cipher = forge.aes.createEncryptionCipher(keyIv, mode); cipher.start(keyIv); cipher.update(forge.util.createBuffer(data)); cipher.finish(); if (encoder === 'url') { return base64url(cipher.output.data); } return forge.util.encode64(cipher.output.data); }
javascript
function (data, secret, encoder, mode) { // mode = CBC, CFB, OFB, CTR mode = mode || MODE; var keyIv = this.getBytesFromSecret(secret); var cipher = forge.aes.createEncryptionCipher(keyIv, mode); cipher.start(keyIv); cipher.update(forge.util.createBuffer(data)); cipher.finish(); if (encoder === 'url') { return base64url(cipher.output.data); } return forge.util.encode64(cipher.output.data); }
[ "function", "(", "data", ",", "secret", ",", "encoder", ",", "mode", ")", "{", "mode", "=", "mode", "||", "MODE", ";", "var", "keyIv", "=", "this", ".", "getBytesFromSecret", "(", "secret", ")", ";", "var", "cipher", "=", "forge", ".", "aes", ".", "createEncryptionCipher", "(", "keyIv", ",", "mode", ")", ";", "cipher", ".", "start", "(", "keyIv", ")", ";", "cipher", ".", "update", "(", "forge", ".", "util", ".", "createBuffer", "(", "data", ")", ")", ";", "cipher", ".", "finish", "(", ")", ";", "if", "(", "encoder", "===", "'url'", ")", "{", "return", "base64url", "(", "cipher", ".", "output", ".", "data", ")", ";", "}", "return", "forge", ".", "util", ".", "encode64", "(", "cipher", ".", "output", ".", "data", ")", ";", "}" ]
Encrypt data using AES cipher @param {String} data The data to encrypt @param {Bytes} secret The secret to use in encryption @param {String} [encoder = 'base64'] base64 or url final encoding @param {String} [mode = 'CTR'] The mode to use in encryption. 'CBC', 'CFB', 'OFB', 'CTR' are allowed modes. @return {String} The AES encryption result in Base64
[ "Encrypt", "data", "using", "AES", "cipher" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32436-L32448
train
mgesmundo/authorify-client
build/authorify.js
function (data, secret, encoder, mode) { // mode = CBC, CFB, OFB, CTR mode = mode || MODE; var keyIv = this.getBytesFromSecret(secret); var cipher = forge.aes.createDecryptionCipher(keyIv, mode); cipher.start(keyIv); var decoded; if (encoder === 'url') { decoded = base64url.decode(data); } else { decoded = forge.util.decode64(data); } cipher.update(forge.util.createBuffer(decoded)); cipher.finish(); return cipher.output.data; }
javascript
function (data, secret, encoder, mode) { // mode = CBC, CFB, OFB, CTR mode = mode || MODE; var keyIv = this.getBytesFromSecret(secret); var cipher = forge.aes.createDecryptionCipher(keyIv, mode); cipher.start(keyIv); var decoded; if (encoder === 'url') { decoded = base64url.decode(data); } else { decoded = forge.util.decode64(data); } cipher.update(forge.util.createBuffer(decoded)); cipher.finish(); return cipher.output.data; }
[ "function", "(", "data", ",", "secret", ",", "encoder", ",", "mode", ")", "{", "mode", "=", "mode", "||", "MODE", ";", "var", "keyIv", "=", "this", ".", "getBytesFromSecret", "(", "secret", ")", ";", "var", "cipher", "=", "forge", ".", "aes", ".", "createDecryptionCipher", "(", "keyIv", ",", "mode", ")", ";", "cipher", ".", "start", "(", "keyIv", ")", ";", "var", "decoded", ";", "if", "(", "encoder", "===", "'url'", ")", "{", "decoded", "=", "base64url", ".", "decode", "(", "data", ")", ";", "}", "else", "{", "decoded", "=", "forge", ".", "util", ".", "decode64", "(", "data", ")", ";", "}", "cipher", ".", "update", "(", "forge", ".", "util", ".", "createBuffer", "(", "decoded", ")", ")", ";", "cipher", ".", "finish", "(", ")", ";", "return", "cipher", ".", "output", ".", "data", ";", "}" ]
Decrypt AES encrypted data @param {String} data The data to decrypt @param {String} secret The secret to use in decryption in Base64 format @param {String} [encoder = 'base64'] base64 or url encoding @param {String} [mode='CTR'] The mode to use in decryption. 'CBC', 'CFB', 'OFB', 'CTR' are allowed modes. @return {String} The decrypted data
[ "Decrypt", "AES", "encrypted", "data" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32457-L32472
train
mgesmundo/authorify-client
build/authorify.js
function (pem) { var certificate = forge.pki.certificateFromPem(pem); var issuerCert = caStore.getIssuer(certificate); if (issuerCert) { try { return issuerCert.verify(certificate); } catch (e) { return false; } } return false; }
javascript
function (pem) { var certificate = forge.pki.certificateFromPem(pem); var issuerCert = caStore.getIssuer(certificate); if (issuerCert) { try { return issuerCert.verify(certificate); } catch (e) { return false; } } return false; }
[ "function", "(", "pem", ")", "{", "var", "certificate", "=", "forge", ".", "pki", ".", "certificateFromPem", "(", "pem", ")", ";", "var", "issuerCert", "=", "caStore", ".", "getIssuer", "(", "certificate", ")", ";", "if", "(", "issuerCert", ")", "{", "try", "{", "return", "issuerCert", ".", "verify", "(", "certificate", ")", ";", "}", "catch", "(", "e", ")", "{", "return", "false", ";", "}", "}", "return", "false", ";", "}" ]
Verify that a X.509 certificate is generated by the CA @param {String} pem The certificate to verify in pem format @returns {Boolean} True if the X.509 certificate is original
[ "Verify", "that", "a", "X", ".", "509", "certificate", "is", "generated", "by", "the", "CA" ]
39fb57db897eaa49b76444ff62bbc0ccedc7ee16
https://github.com/mgesmundo/authorify-client/blob/39fb57db897eaa49b76444ff62bbc0ccedc7ee16/build/authorify.js#L32503-L32514
train
molecuel/mlcl_collections
index.js
function () { var self = this; this.collectionRegistry = {}; // emit molecuel elements pre init event molecuel.emit('mlcl::collections::init:pre', self); /** * Schema directory config */ if (molecuel.config.collections && molecuel.config.collections.collectionDir) { this.collectionDir = molecuel.config.collections.collectionDir; } /** * Execute after successful elasticsearch connection */ molecuel.on('mlcl::elements::init:post', function (elements) { // add the access to all the db's and searchfunctionality self.elements = elements; self.elastic = elements.elastic; self.database = elements.database; self.registerCollections(); molecuel.emit('mlcl::collections::init:post', self); }); //register block handler molecuel.on('mlcl::blocks::init:modules', function(blocks) { blocks.registerTypeHandler('collection', self.block); }); return this; }
javascript
function () { var self = this; this.collectionRegistry = {}; // emit molecuel elements pre init event molecuel.emit('mlcl::collections::init:pre', self); /** * Schema directory config */ if (molecuel.config.collections && molecuel.config.collections.collectionDir) { this.collectionDir = molecuel.config.collections.collectionDir; } /** * Execute after successful elasticsearch connection */ molecuel.on('mlcl::elements::init:post', function (elements) { // add the access to all the db's and searchfunctionality self.elements = elements; self.elastic = elements.elastic; self.database = elements.database; self.registerCollections(); molecuel.emit('mlcl::collections::init:post', self); }); //register block handler molecuel.on('mlcl::blocks::init:modules', function(blocks) { blocks.registerTypeHandler('collection', self.block); }); return this; }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "this", ".", "collectionRegistry", "=", "{", "}", ";", "molecuel", ".", "emit", "(", "'mlcl::collections::init:pre'", ",", "self", ")", ";", "if", "(", "molecuel", ".", "config", ".", "collections", "&&", "molecuel", ".", "config", ".", "collections", ".", "collectionDir", ")", "{", "this", ".", "collectionDir", "=", "molecuel", ".", "config", ".", "collections", ".", "collectionDir", ";", "}", "molecuel", ".", "on", "(", "'mlcl::elements::init:post'", ",", "function", "(", "elements", ")", "{", "self", ".", "elements", "=", "elements", ";", "self", ".", "elastic", "=", "elements", ".", "elastic", ";", "self", ".", "database", "=", "elements", ".", "database", ";", "self", ".", "registerCollections", "(", ")", ";", "molecuel", ".", "emit", "(", "'mlcl::collections::init:post'", ",", "self", ")", ";", "}", ")", ";", "molecuel", ".", "on", "(", "'mlcl::blocks::init:modules'", ",", "function", "(", "blocks", ")", "{", "blocks", ".", "registerTypeHandler", "(", "'collection'", ",", "self", ".", "block", ")", ";", "}", ")", ";", "return", "this", ";", "}" ]
This module serves the molecuel elements the type definition for database objects @todo implement the dynamic generation of elements @constructor
[ "This", "module", "serves", "the", "molecuel", "elements", "the", "type", "definition", "for", "database", "objects" ]
4b3160b1af1632ff3121ad5a1da2b3c70beb2466
https://github.com/molecuel/mlcl_collections/blob/4b3160b1af1632ff3121ad5a1da2b3c70beb2466/index.js#L18-L50
train
gummesson/ez-map
index.js
EzMap
function EzMap(arr) { this._keys = [] this._values = [] if (isArray(arr) && arr.length) this._initial(arr) }
javascript
function EzMap(arr) { this._keys = [] this._values = [] if (isArray(arr) && arr.length) this._initial(arr) }
[ "function", "EzMap", "(", "arr", ")", "{", "this", ".", "_keys", "=", "[", "]", "this", ".", "_values", "=", "[", "]", "if", "(", "isArray", "(", "arr", ")", "&&", "arr", ".", "length", ")", "this", ".", "_initial", "(", "arr", ")", "}" ]
Initialize `EzMap`. @constructor @param {array} [arr] @api public
[ "Initialize", "EzMap", "." ]
268157f1b78119d2d7e7e14b35e5283f80c0174a
https://github.com/gummesson/ez-map/blob/268157f1b78119d2d7e7e14b35e5283f80c0174a/index.js#L16-L21
train
antonycourtney/tabli-core
src/js/tabWindow.js
getOpenTabInfo
function getOpenTabInfo(tabItems, openTabs) { const chromeOpenTabItems = Immutable.Seq(openTabs.map(makeOpenTabItem)); // console.log("getOpenTabInfo: openTabs: ", openTabs); // console.log("getOpenTabInfo: chromeOpenTabItems: " + JSON.stringify(chromeOpenTabItems,null,4)); const openUrlMap = Immutable.Map(chromeOpenTabItems.groupBy((ti) => ti.url)); // console.log("getOpenTabInfo: openUrlMap: ", openUrlMap.toJS()); // Now we need to do two things: // 1. augment chromeOpenTabItems with bookmark Ids / saved state (if it exists) // 2. figure out which savedTabItems are not in openTabs const savedItems = tabItems.filter((ti) => ti.saved); // Restore the saved items to their base state (no open tab info), since we // only want to pick up open tab info from what was passed in in openTabs const baseSavedItems = savedItems.map(resetSavedItem); // The entries in savedUrlMap *should* be singletons, but we'll use groupBy to // get a type-compatible Seq so that we can merge with openUrlMap using // mergeWith: const savedUrlMap = Immutable.Map(baseSavedItems.groupBy((ti) => ti.url)); // console.log("getOpenTabInfo: savedUrlMap : " + savedUrlMap.toJS()); function mergeTabItems(openItems, mergeSavedItems) { const savedItem = mergeSavedItems.get(0); return openItems.map((openItem) => openItem.set('saved', true) .set('savedBookmarkId', savedItem.savedBookmarkId) .set('savedBookmarkIndex', savedItem.savedBookmarkIndex) .set('savedTitle', savedItem.savedTitle)); } const mergedMap = openUrlMap.mergeWith(mergeTabItems, savedUrlMap); // console.log("mergedMap: ", mergedMap.toJS()); // console.log("getOpenTabInfo: mergedMap :" + JSON.stringify(mergedMap,null,4)); // partition mergedMap into open and closed tabItems: const partitionedMap = mergedMap.toIndexedSeq().flatten(true).groupBy((ti) => ti.open); // console.log("partitionedMap: ", partitionedMap.toJS()); return partitionedMap; }
javascript
function getOpenTabInfo(tabItems, openTabs) { const chromeOpenTabItems = Immutable.Seq(openTabs.map(makeOpenTabItem)); // console.log("getOpenTabInfo: openTabs: ", openTabs); // console.log("getOpenTabInfo: chromeOpenTabItems: " + JSON.stringify(chromeOpenTabItems,null,4)); const openUrlMap = Immutable.Map(chromeOpenTabItems.groupBy((ti) => ti.url)); // console.log("getOpenTabInfo: openUrlMap: ", openUrlMap.toJS()); // Now we need to do two things: // 1. augment chromeOpenTabItems with bookmark Ids / saved state (if it exists) // 2. figure out which savedTabItems are not in openTabs const savedItems = tabItems.filter((ti) => ti.saved); // Restore the saved items to their base state (no open tab info), since we // only want to pick up open tab info from what was passed in in openTabs const baseSavedItems = savedItems.map(resetSavedItem); // The entries in savedUrlMap *should* be singletons, but we'll use groupBy to // get a type-compatible Seq so that we can merge with openUrlMap using // mergeWith: const savedUrlMap = Immutable.Map(baseSavedItems.groupBy((ti) => ti.url)); // console.log("getOpenTabInfo: savedUrlMap : " + savedUrlMap.toJS()); function mergeTabItems(openItems, mergeSavedItems) { const savedItem = mergeSavedItems.get(0); return openItems.map((openItem) => openItem.set('saved', true) .set('savedBookmarkId', savedItem.savedBookmarkId) .set('savedBookmarkIndex', savedItem.savedBookmarkIndex) .set('savedTitle', savedItem.savedTitle)); } const mergedMap = openUrlMap.mergeWith(mergeTabItems, savedUrlMap); // console.log("mergedMap: ", mergedMap.toJS()); // console.log("getOpenTabInfo: mergedMap :" + JSON.stringify(mergedMap,null,4)); // partition mergedMap into open and closed tabItems: const partitionedMap = mergedMap.toIndexedSeq().flatten(true).groupBy((ti) => ti.open); // console.log("partitionedMap: ", partitionedMap.toJS()); return partitionedMap; }
[ "function", "getOpenTabInfo", "(", "tabItems", ",", "openTabs", ")", "{", "const", "chromeOpenTabItems", "=", "Immutable", ".", "Seq", "(", "openTabs", ".", "map", "(", "makeOpenTabItem", ")", ")", ";", "const", "openUrlMap", "=", "Immutable", ".", "Map", "(", "chromeOpenTabItems", ".", "groupBy", "(", "(", "ti", ")", "=>", "ti", ".", "url", ")", ")", ";", "const", "savedItems", "=", "tabItems", ".", "filter", "(", "(", "ti", ")", "=>", "ti", ".", "saved", ")", ";", "const", "baseSavedItems", "=", "savedItems", ".", "map", "(", "resetSavedItem", ")", ";", "const", "savedUrlMap", "=", "Immutable", ".", "Map", "(", "baseSavedItems", ".", "groupBy", "(", "(", "ti", ")", "=>", "ti", ".", "url", ")", ")", ";", "function", "mergeTabItems", "(", "openItems", ",", "mergeSavedItems", ")", "{", "const", "savedItem", "=", "mergeSavedItems", ".", "get", "(", "0", ")", ";", "return", "openItems", ".", "map", "(", "(", "openItem", ")", "=>", "openItem", ".", "set", "(", "'saved'", ",", "true", ")", ".", "set", "(", "'savedBookmarkId'", ",", "savedItem", ".", "savedBookmarkId", ")", ".", "set", "(", "'savedBookmarkIndex'", ",", "savedItem", ".", "savedBookmarkIndex", ")", ".", "set", "(", "'savedTitle'", ",", "savedItem", ".", "savedTitle", ")", ")", ";", "}", "const", "mergedMap", "=", "openUrlMap", ".", "mergeWith", "(", "mergeTabItems", ",", "savedUrlMap", ")", ";", "const", "partitionedMap", "=", "mergedMap", ".", "toIndexedSeq", "(", ")", ".", "flatten", "(", "true", ")", ".", "groupBy", "(", "(", "ti", ")", "=>", "ti", ".", "open", ")", ";", "return", "partitionedMap", ";", "}" ]
Gather open tab items and a set of non-open saved tabItems from the given open tabs and tab items based on URL matching, without regard to tab ordering. Auxiliary helper function for mergeOpenTabs.
[ "Gather", "open", "tab", "items", "and", "a", "set", "of", "non", "-", "open", "saved", "tabItems", "from", "the", "given", "open", "tabs", "and", "tab", "items", "based", "on", "URL", "matching", "without", "regard", "to", "tab", "ordering", ".", "Auxiliary", "helper", "function", "for", "mergeOpenTabs", "." ]
76cc540891421bc6c8bdcf00f277ebb6e716fdd9
https://github.com/antonycourtney/tabli-core/blob/76cc540891421bc6c8bdcf00f277ebb6e716fdd9/src/js/tabWindow.js#L232-L277
train
directiv/data-hyper-bind
index.js
hyperBind
function hyperBind(store) { this.compile = function(input) { var path = input.split('.'); return { path: input, target: path[path.length - 1] }; }; this.state = function(config, state) { var res = store.get(config.path, state); if (!res.completed) return false; return state.set(config.target, res.value); }; this.children = function(config, state, children) { var value = state.get(config.target); if (typeof value === 'undefined') return ''; return value; }; }
javascript
function hyperBind(store) { this.compile = function(input) { var path = input.split('.'); return { path: input, target: path[path.length - 1] }; }; this.state = function(config, state) { var res = store.get(config.path, state); if (!res.completed) return false; return state.set(config.target, res.value); }; this.children = function(config, state, children) { var value = state.get(config.target); if (typeof value === 'undefined') return ''; return value; }; }
[ "function", "hyperBind", "(", "store", ")", "{", "this", ".", "compile", "=", "function", "(", "input", ")", "{", "var", "path", "=", "input", ".", "split", "(", "'.'", ")", ";", "return", "{", "path", ":", "input", ",", "target", ":", "path", "[", "path", ".", "length", "-", "1", "]", "}", ";", "}", ";", "this", ".", "state", "=", "function", "(", "config", ",", "state", ")", "{", "var", "res", "=", "store", ".", "get", "(", "config", ".", "path", ",", "state", ")", ";", "if", "(", "!", "res", ".", "completed", ")", "return", "false", ";", "return", "state", ".", "set", "(", "config", ".", "target", ",", "res", ".", "value", ")", ";", "}", ";", "this", ".", "children", "=", "function", "(", "config", ",", "state", ",", "children", ")", "{", "var", "value", "=", "state", ".", "get", "(", "config", ".", "target", ")", ";", "if", "(", "typeof", "value", "===", "'undefined'", ")", "return", "''", ";", "return", "value", ";", "}", ";", "}" ]
Initialize the 'hyper-bind' directive @param {StoreHyper} store
[ "Initialize", "the", "hyper", "-", "bind", "directive" ]
e9d5640f7087a30d90ce2652e9b6713da72f4b7b
https://github.com/directiv/data-hyper-bind/blob/e9d5640f7087a30d90ce2652e9b6713da72f4b7b/index.js#L19-L39
train
pgarrison/tweet-matches
lib/get-fields.js
getFields
function getFields(tweet) { return _.flatten(tweetLikeObjectsToCheck.map(function(tweetLikeName) { var tweetLike; if (tweetLikeName === null) { tweetLike = tweet; } else { tweetLike = _.get(tweet, tweetLikeName); } if (!tweetLike) return []; return getFieldsFromTweetLike(tweetLike); })); }
javascript
function getFields(tweet) { return _.flatten(tweetLikeObjectsToCheck.map(function(tweetLikeName) { var tweetLike; if (tweetLikeName === null) { tweetLike = tweet; } else { tweetLike = _.get(tweet, tweetLikeName); } if (!tweetLike) return []; return getFieldsFromTweetLike(tweetLike); })); }
[ "function", "getFields", "(", "tweet", ")", "{", "return", "_", ".", "flatten", "(", "tweetLikeObjectsToCheck", ".", "map", "(", "function", "(", "tweetLikeName", ")", "{", "var", "tweetLike", ";", "if", "(", "tweetLikeName", "===", "null", ")", "{", "tweetLike", "=", "tweet", ";", "}", "else", "{", "tweetLike", "=", "_", ".", "get", "(", "tweet", ",", "tweetLikeName", ")", ";", "}", "if", "(", "!", "tweetLike", ")", "return", "[", "]", ";", "return", "getFieldsFromTweetLike", "(", "tweetLike", ")", ";", "}", ")", ")", ";", "}" ]
Create an array of the strings at the positions in the tweet object specified by the above arrays of field names
[ "Create", "an", "array", "of", "the", "strings", "at", "the", "positions", "in", "the", "tweet", "object", "specified", "by", "the", "above", "arrays", "of", "field", "names" ]
e68a59d53b02f65f53edf10b6483dda4196150a2
https://github.com/pgarrison/tweet-matches/blob/e68a59d53b02f65f53edf10b6483dda4196150a2/lib/get-fields.js#L43-L54
train
pgarrison/tweet-matches
lib/get-fields.js
getFieldsFromTweetLike
function getFieldsFromTweetLike(tweetLike) { var fields = fieldsToCheck.map(function(fieldName) { return _.get(tweetLike, fieldName); }); arrayFieldsToCheck.forEach(function(fieldDescription) { var arr = _.get(tweetLike, fieldDescription.arrayAt); if (_.isArray(arr)) { arr.forEach(function(element) { fields.push(_.get(element, fieldDescription.inEach)); }); } }); return fields.filter(function(field) { return typeof field === 'string' && field.trim().length !== 0; }).map(function(field) { return field.toLowerCase(); }); }
javascript
function getFieldsFromTweetLike(tweetLike) { var fields = fieldsToCheck.map(function(fieldName) { return _.get(tweetLike, fieldName); }); arrayFieldsToCheck.forEach(function(fieldDescription) { var arr = _.get(tweetLike, fieldDescription.arrayAt); if (_.isArray(arr)) { arr.forEach(function(element) { fields.push(_.get(element, fieldDescription.inEach)); }); } }); return fields.filter(function(field) { return typeof field === 'string' && field.trim().length !== 0; }).map(function(field) { return field.toLowerCase(); }); }
[ "function", "getFieldsFromTweetLike", "(", "tweetLike", ")", "{", "var", "fields", "=", "fieldsToCheck", ".", "map", "(", "function", "(", "fieldName", ")", "{", "return", "_", ".", "get", "(", "tweetLike", ",", "fieldName", ")", ";", "}", ")", ";", "arrayFieldsToCheck", ".", "forEach", "(", "function", "(", "fieldDescription", ")", "{", "var", "arr", "=", "_", ".", "get", "(", "tweetLike", ",", "fieldDescription", ".", "arrayAt", ")", ";", "if", "(", "_", ".", "isArray", "(", "arr", ")", ")", "{", "arr", ".", "forEach", "(", "function", "(", "element", ")", "{", "fields", ".", "push", "(", "_", ".", "get", "(", "element", ",", "fieldDescription", ".", "inEach", ")", ")", ";", "}", ")", ";", "}", "}", ")", ";", "return", "fields", ".", "filter", "(", "function", "(", "field", ")", "{", "return", "typeof", "field", "===", "'string'", "&&", "field", ".", "trim", "(", ")", ".", "length", "!==", "0", ";", "}", ")", ".", "map", "(", "function", "(", "field", ")", "{", "return", "field", ".", "toLowerCase", "(", ")", ";", "}", ")", ";", "}" ]
Takes a tweet or a subobject of tweet and looks for strings in the positions listed in fieldsToCheck and arrayFieldsToCheck
[ "Takes", "a", "tweet", "or", "a", "subobject", "of", "tweet", "and", "looks", "for", "strings", "in", "the", "positions", "listed", "in", "fieldsToCheck", "and", "arrayFieldsToCheck" ]
e68a59d53b02f65f53edf10b6483dda4196150a2
https://github.com/pgarrison/tweet-matches/blob/e68a59d53b02f65f53edf10b6483dda4196150a2/lib/get-fields.js#L58-L77
train
paukan-org/core
service/index.js
Service
function Service(config, callback) { ld.bindAll(this); var eventEmitter = new EventEmitter2({ wildcard: true, delimiter: '.'}); this.cfg = {}; this.network = { local: eventEmitter }; ld.defaults(this.cfg, config, { // id // required, unique service id [^a-zA-Z0-9_] // version // required requestTimeout: 3000, // timeout in ms before device answer port: 6379, // network or proxy port host: 'paukan', // network or proxy host throttling: 200, // do not emit same event fired durning this period (on multiple psubscribe) connections: ['direct', 'remote', 'server'], // try next connection type if previous failed // - direct: connect to redis queue on specified host and port // - remote: connect to remote websocket proxy service on specified host and port // - server: create websocket server and wait incoming connection on specified port }); this.id = this.cfg.id; this.hostname = require('os').hostname(); this.version = this.cfg.version; this.description = this.cfg.description; this.homepage = this.cfg.homepage; this.author = this.cfg.author; this.devices = {}; // list of devices in this service this.log = this.createLogger(this.cfg.logger); if(callback) { this.init(callback); } }
javascript
function Service(config, callback) { ld.bindAll(this); var eventEmitter = new EventEmitter2({ wildcard: true, delimiter: '.'}); this.cfg = {}; this.network = { local: eventEmitter }; ld.defaults(this.cfg, config, { // id // required, unique service id [^a-zA-Z0-9_] // version // required requestTimeout: 3000, // timeout in ms before device answer port: 6379, // network or proxy port host: 'paukan', // network or proxy host throttling: 200, // do not emit same event fired durning this period (on multiple psubscribe) connections: ['direct', 'remote', 'server'], // try next connection type if previous failed // - direct: connect to redis queue on specified host and port // - remote: connect to remote websocket proxy service on specified host and port // - server: create websocket server and wait incoming connection on specified port }); this.id = this.cfg.id; this.hostname = require('os').hostname(); this.version = this.cfg.version; this.description = this.cfg.description; this.homepage = this.cfg.homepage; this.author = this.cfg.author; this.devices = {}; // list of devices in this service this.log = this.createLogger(this.cfg.logger); if(callback) { this.init(callback); } }
[ "function", "Service", "(", "config", ",", "callback", ")", "{", "ld", ".", "bindAll", "(", "this", ")", ";", "var", "eventEmitter", "=", "new", "EventEmitter2", "(", "{", "wildcard", ":", "true", ",", "delimiter", ":", "'.'", "}", ")", ";", "this", ".", "cfg", "=", "{", "}", ";", "this", ".", "network", "=", "{", "local", ":", "eventEmitter", "}", ";", "ld", ".", "defaults", "(", "this", ".", "cfg", ",", "config", ",", "{", "requestTimeout", ":", "3000", ",", "port", ":", "6379", ",", "host", ":", "'paukan'", ",", "throttling", ":", "200", ",", "connections", ":", "[", "'direct'", ",", "'remote'", ",", "'server'", "]", ",", "}", ")", ";", "this", ".", "id", "=", "this", ".", "cfg", ".", "id", ";", "this", ".", "hostname", "=", "require", "(", "'os'", ")", ".", "hostname", "(", ")", ";", "this", ".", "version", "=", "this", ".", "cfg", ".", "version", ";", "this", ".", "description", "=", "this", ".", "cfg", ".", "description", ";", "this", ".", "homepage", "=", "this", ".", "cfg", ".", "homepage", ";", "this", ".", "author", "=", "this", ".", "cfg", ".", "author", ";", "this", ".", "devices", "=", "{", "}", ";", "this", ".", "log", "=", "this", ".", "createLogger", "(", "this", ".", "cfg", ".", "logger", ")", ";", "if", "(", "callback", ")", "{", "this", ".", "init", "(", "callback", ")", ";", "}", "}" ]
required fields for device Service - interaction interface between automated network and end devices. Provice necessary functional and act as router. @param {object} config configuration parameters for service initialisation @param {function} callback if not set - only class will be instances
[ "required", "fields", "for", "device", "Service", "-", "interaction", "interface", "between", "automated", "network", "and", "end", "devices", ".", "Provice", "necessary", "functional", "and", "act", "as", "router", "." ]
e6ff0667d50bc9b25ab5678852316e89521942ad
https://github.com/paukan-org/core/blob/e6ff0667d50bc9b25ab5678852316e89521942ad/service/index.js#L18-L48
train
paukan-org/core
service/index.js
exitHandler
function exitHandler(options, err) { if (err) { log.error(err.stack); } if (options.exit) { process.exit(); } if(network) { network.emit('state.'+id+'.service.offline'); } }
javascript
function exitHandler(options, err) { if (err) { log.error(err.stack); } if (options.exit) { process.exit(); } if(network) { network.emit('state.'+id+'.service.offline'); } }
[ "function", "exitHandler", "(", "options", ",", "err", ")", "{", "if", "(", "err", ")", "{", "log", ".", "error", "(", "err", ".", "stack", ")", ";", "}", "if", "(", "options", ".", "exit", ")", "{", "process", ".", "exit", "(", ")", ";", "}", "if", "(", "network", ")", "{", "network", ".", "emit", "(", "'state.'", "+", "id", "+", "'.service.offline'", ")", ";", "}", "}" ]
so the program will not close instantly
[ "so", "the", "program", "will", "not", "close", "instantly" ]
e6ff0667d50bc9b25ab5678852316e89521942ad
https://github.com/paukan-org/core/blob/e6ff0667d50bc9b25ab5678852316e89521942ad/service/index.js#L487-L498
train
altshift/altshift
lib/altshift/cli/style.js
applyStyle
function applyStyle(str, property, value) { var styleDefinition = CONSOLE_STYLES[property][value]; //No style defined return non modified string if (styleDefinition === null) { return str; } return ESCAPE + '[' + styleDefinition[0] + 'm' + str + ESCAPE + '[' + styleDefinition[1] + 'm'; }
javascript
function applyStyle(str, property, value) { var styleDefinition = CONSOLE_STYLES[property][value]; //No style defined return non modified string if (styleDefinition === null) { return str; } return ESCAPE + '[' + styleDefinition[0] + 'm' + str + ESCAPE + '[' + styleDefinition[1] + 'm'; }
[ "function", "applyStyle", "(", "str", ",", "property", ",", "value", ")", "{", "var", "styleDefinition", "=", "CONSOLE_STYLES", "[", "property", "]", "[", "value", "]", ";", "if", "(", "styleDefinition", "===", "null", ")", "{", "return", "str", ";", "}", "return", "ESCAPE", "+", "'['", "+", "styleDefinition", "[", "0", "]", "+", "'m'", "+", "str", "+", "ESCAPE", "+", "'['", "+", "styleDefinition", "[", "1", "]", "+", "'m'", ";", "}" ]
Apply one single style on str @param {string} str @param {string} property @param {string} value @return {string}
[ "Apply", "one", "single", "style", "on", "str" ]
5c051157e6f558636c8e12081b6707caa66249de
https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/cli/style.js#L70-L79
train
altshift/altshift
lib/altshift/cli/style.js
applyStyles
function applyStyles(str, style) { //Check if not style if (! style) { return str; } //Check shortcut if string is empty //str = '' + str; if (!str || str.length === 0) { return str; } var output, i, rule, textdecoration; //style = style || {}; output = str; //1. font-weight rule = style['font-weight']; if (rule) { output = applyStyle(output, 'font-weight', rule); } //2. font-style rule = style['font-style']; if (rule) { output = applyStyle(output, 'font-style', rule); } //3. color rule = style.color; if (style.color) { output = applyStyle(output, 'color', rule); } //4. background color rule = style['background-color']; if (rule) { output = applyStyle(output, 'background-color', rule); } //Normalize as array rule = style['text-decoration']; if (isArray(rule)) { //do all decoration i = rule.length - 1; while (i >= 0) { i -= 1; output = applyStyle(output, 'text-decoration', rule[i]); } } else { output = applyStyle(output, 'text-decoration', style['text-decoration']); } }
javascript
function applyStyles(str, style) { //Check if not style if (! style) { return str; } //Check shortcut if string is empty //str = '' + str; if (!str || str.length === 0) { return str; } var output, i, rule, textdecoration; //style = style || {}; output = str; //1. font-weight rule = style['font-weight']; if (rule) { output = applyStyle(output, 'font-weight', rule); } //2. font-style rule = style['font-style']; if (rule) { output = applyStyle(output, 'font-style', rule); } //3. color rule = style.color; if (style.color) { output = applyStyle(output, 'color', rule); } //4. background color rule = style['background-color']; if (rule) { output = applyStyle(output, 'background-color', rule); } //Normalize as array rule = style['text-decoration']; if (isArray(rule)) { //do all decoration i = rule.length - 1; while (i >= 0) { i -= 1; output = applyStyle(output, 'text-decoration', rule[i]); } } else { output = applyStyle(output, 'text-decoration', style['text-decoration']); } }
[ "function", "applyStyles", "(", "str", ",", "style", ")", "{", "if", "(", "!", "style", ")", "{", "return", "str", ";", "}", "if", "(", "!", "str", "||", "str", ".", "length", "===", "0", ")", "{", "return", "str", ";", "}", "var", "output", ",", "i", ",", "rule", ",", "textdecoration", ";", "output", "=", "str", ";", "rule", "=", "style", "[", "'font-weight'", "]", ";", "if", "(", "rule", ")", "{", "output", "=", "applyStyle", "(", "output", ",", "'font-weight'", ",", "rule", ")", ";", "}", "rule", "=", "style", "[", "'font-style'", "]", ";", "if", "(", "rule", ")", "{", "output", "=", "applyStyle", "(", "output", ",", "'font-style'", ",", "rule", ")", ";", "}", "rule", "=", "style", ".", "color", ";", "if", "(", "style", ".", "color", ")", "{", "output", "=", "applyStyle", "(", "output", ",", "'color'", ",", "rule", ")", ";", "}", "rule", "=", "style", "[", "'background-color'", "]", ";", "if", "(", "rule", ")", "{", "output", "=", "applyStyle", "(", "output", ",", "'background-color'", ",", "rule", ")", ";", "}", "rule", "=", "style", "[", "'text-decoration'", "]", ";", "if", "(", "isArray", "(", "rule", ")", ")", "{", "i", "=", "rule", ".", "length", "-", "1", ";", "while", "(", "i", ">=", "0", ")", "{", "i", "-=", "1", ";", "output", "=", "applyStyle", "(", "output", ",", "'text-decoration'", ",", "rule", "[", "i", "]", ")", ";", "}", "}", "else", "{", "output", "=", "applyStyle", "(", "output", ",", "'text-decoration'", ",", "style", "[", "'text-decoration'", "]", ")", ";", "}", "}" ]
Return a formatted str @param {string} str @param {Object} style - font-weight : normal|bold - font-style : normal|italic - background-color : transparent|black|red|green|yellow|blue|magenta|cyan|white - color : default|black|red|green|yellow|blue|magenta|cyan|white - text-decoration : [underline|blink|reverse|invisible, ...] @return {string}
[ "Return", "a", "formatted", "str" ]
5c051157e6f558636c8e12081b6707caa66249de
https://github.com/altshift/altshift/blob/5c051157e6f558636c8e12081b6707caa66249de/lib/altshift/cli/style.js#L94-L147
train
robertblackwell/yake
src/yake/yakefile.js
recursiveFindFile
function recursiveFindFile(aDirectory, arrayOfFileNames) { if (debug) debugLog(`recursiveFindFile dir: ${aDirectory}, filenames: ${util.inspect(arrayOfFileNames)}`); // var directory = process.cwd(); let directory = aDirectory; const tmp = directoryHasFile(directory, arrayOfFileNames); if ((tmp === undefined) && directory !== '/') { directory = path.dirname(directory); const anotherTmp = recursiveFindFile(directory, arrayOfFileNames); return anotherTmp; } else if (tmp === undefined) { // ran out of directories return undefined; } const p = path.resolve(directory, tmp); return p; }
javascript
function recursiveFindFile(aDirectory, arrayOfFileNames) { if (debug) debugLog(`recursiveFindFile dir: ${aDirectory}, filenames: ${util.inspect(arrayOfFileNames)}`); // var directory = process.cwd(); let directory = aDirectory; const tmp = directoryHasFile(directory, arrayOfFileNames); if ((tmp === undefined) && directory !== '/') { directory = path.dirname(directory); const anotherTmp = recursiveFindFile(directory, arrayOfFileNames); return anotherTmp; } else if (tmp === undefined) { // ran out of directories return undefined; } const p = path.resolve(directory, tmp); return p; }
[ "function", "recursiveFindFile", "(", "aDirectory", ",", "arrayOfFileNames", ")", "{", "if", "(", "debug", ")", "debugLog", "(", "`", "${", "aDirectory", "}", "${", "util", ".", "inspect", "(", "arrayOfFileNames", ")", "}", "`", ")", ";", "let", "directory", "=", "aDirectory", ";", "const", "tmp", "=", "directoryHasFile", "(", "directory", ",", "arrayOfFileNames", ")", ";", "if", "(", "(", "tmp", "===", "undefined", ")", "&&", "directory", "!==", "'/'", ")", "{", "directory", "=", "path", ".", "dirname", "(", "directory", ")", ";", "const", "anotherTmp", "=", "recursiveFindFile", "(", "directory", ",", "arrayOfFileNames", ")", ";", "return", "anotherTmp", ";", "}", "else", "if", "(", "tmp", "===", "undefined", ")", "{", "return", "undefined", ";", "}", "const", "p", "=", "path", ".", "resolve", "(", "directory", ",", "tmp", ")", ";", "return", "p", ";", "}" ]
Search upwards from and including aDirectory to find one of the files named in arrayOfFiles returns the full path of the file if it exists @param {string} path to a directory where the search should start @param {array of strings} arrayOfFileNames The array of file names @return {string | undefined} full path of the jakefile that was found or undefined if none found
[ "Search", "upwards", "from", "and", "including", "aDirectory", "to", "find", "one", "of", "the", "files", "named", "in", "arrayOfFiles", "returns", "the", "full", "path", "of", "the", "file", "if", "it", "exists" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/yakefile.js#L89-L112
train
MaiaVictor/dattata
Vector2.js
angle
function angle(a, b){ var ang = (Math.atan2(b.y, b.x) - Math.atan2(a.y, a.x) + Math.PI*2) % (Math.PI*2); if (ang > Math.PI) ang -= Math.PI*2; return ang; }
javascript
function angle(a, b){ var ang = (Math.atan2(b.y, b.x) - Math.atan2(a.y, a.x) + Math.PI*2) % (Math.PI*2); if (ang > Math.PI) ang -= Math.PI*2; return ang; }
[ "function", "angle", "(", "a", ",", "b", ")", "{", "var", "ang", "=", "(", "Math", ".", "atan2", "(", "b", ".", "y", ",", "b", ".", "x", ")", "-", "Math", ".", "atan2", "(", "a", ".", "y", ",", "a", ".", "x", ")", "+", "Math", ".", "PI", "*", "2", ")", "%", "(", "Math", ".", "PI", "*", "2", ")", ";", "if", "(", "ang", ">", "Math", ".", "PI", ")", "ang", "-=", "Math", ".", "PI", "*", "2", ";", "return", "ang", ";", "}" ]
V2, V2 -> Number
[ "V2", "V2", "-", ">", "Number" ]
890d83b89b7193ce8863bb9ac9b296b3510e8db9
https://github.com/MaiaVictor/dattata/blob/890d83b89b7193ce8863bb9ac9b296b3510e8db9/Vector2.js#L8-L12
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/focusmanager.js
function( noDelay ) { if ( this._.locked ) return; function doBlur() { if ( this.hasFocus ) { this.hasFocus = false; var ct = this._.editor.container; ct && ct.removeClass( 'cke_focus' ); this._.editor.fire( 'blur' ); } } if ( this._.timer ) clearTimeout( this._.timer ); var delay = CKEDITOR.focusManager._.blurDelay; if ( noDelay || !delay ) doBlur.call( this ); else { this._.timer = CKEDITOR.tools.setTimeout( function() { delete this._.timer; doBlur.call( this ); }, delay, this ); } }
javascript
function( noDelay ) { if ( this._.locked ) return; function doBlur() { if ( this.hasFocus ) { this.hasFocus = false; var ct = this._.editor.container; ct && ct.removeClass( 'cke_focus' ); this._.editor.fire( 'blur' ); } } if ( this._.timer ) clearTimeout( this._.timer ); var delay = CKEDITOR.focusManager._.blurDelay; if ( noDelay || !delay ) doBlur.call( this ); else { this._.timer = CKEDITOR.tools.setTimeout( function() { delete this._.timer; doBlur.call( this ); }, delay, this ); } }
[ "function", "(", "noDelay", ")", "{", "if", "(", "this", ".", "_", ".", "locked", ")", "return", ";", "function", "doBlur", "(", ")", "{", "if", "(", "this", ".", "hasFocus", ")", "{", "this", ".", "hasFocus", "=", "false", ";", "var", "ct", "=", "this", ".", "_", ".", "editor", ".", "container", ";", "ct", "&&", "ct", ".", "removeClass", "(", "'cke_focus'", ")", ";", "this", ".", "_", ".", "editor", ".", "fire", "(", "'blur'", ")", ";", "}", "}", "if", "(", "this", ".", "_", ".", "timer", ")", "clearTimeout", "(", "this", ".", "_", ".", "timer", ")", ";", "var", "delay", "=", "CKEDITOR", ".", "focusManager", ".", "_", ".", "blurDelay", ";", "if", "(", "noDelay", "||", "!", "delay", ")", "doBlur", ".", "call", "(", "this", ")", ";", "else", "{", "this", ".", "_", ".", "timer", "=", "CKEDITOR", ".", "tools", ".", "setTimeout", "(", "function", "(", ")", "{", "delete", "this", ".", "_", ".", "timer", ";", "doBlur", ".", "call", "(", "this", ")", ";", "}", ",", "delay", ",", "this", ")", ";", "}", "}" ]
Used to indicate that the editor instance has been deactivated by the specified element which has just lost focus. **Note:** This function acts asynchronously with a delay of 100ms to avoid temporary deactivation. Use the `noDelay` parameter instead to deactivate immediately. var editor = CKEDITOR.instances.editor1; editor.focusManager.blur(); @param {Boolean} [noDelay=false] Immediately deactivate the editor instance synchronously. @member CKEDITOR.focusManager
[ "Used", "to", "indicate", "that", "the", "editor", "instance", "has", "been", "deactivated", "by", "the", "specified", "element", "which", "has", "just", "lost", "focus", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/focusmanager.js#L149-L175
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/focusmanager.js
function( element, isCapture ) { var fm = element.getCustomData( SLOT_NAME ); if ( !fm || fm != this ) { // If this element is already taken by another instance, dismiss it first. fm && fm.remove( element ); var focusEvent = 'focus', blurEvent = 'blur'; // Bypass the element's internal DOM focus change. if ( isCapture ) { // Use "focusin/focusout" events instead of capture phase in IEs, // which fires synchronously. if ( CKEDITOR.env.ie ) { focusEvent = 'focusin'; blurEvent = 'focusout'; } else { CKEDITOR.event.useCapture = 1; } } var listeners = { blur: function() { if ( element.equals( this.currentActive ) ) this.blur(); }, focus: function() { this.focus( element ); } }; element.on( focusEvent, listeners.focus, this ); element.on( blurEvent, listeners.blur, this ); if ( isCapture ) CKEDITOR.event.useCapture = 0; element.setCustomData( SLOT_NAME, this ); element.setCustomData( SLOT_NAME_LISTENERS, listeners ); } }
javascript
function( element, isCapture ) { var fm = element.getCustomData( SLOT_NAME ); if ( !fm || fm != this ) { // If this element is already taken by another instance, dismiss it first. fm && fm.remove( element ); var focusEvent = 'focus', blurEvent = 'blur'; // Bypass the element's internal DOM focus change. if ( isCapture ) { // Use "focusin/focusout" events instead of capture phase in IEs, // which fires synchronously. if ( CKEDITOR.env.ie ) { focusEvent = 'focusin'; blurEvent = 'focusout'; } else { CKEDITOR.event.useCapture = 1; } } var listeners = { blur: function() { if ( element.equals( this.currentActive ) ) this.blur(); }, focus: function() { this.focus( element ); } }; element.on( focusEvent, listeners.focus, this ); element.on( blurEvent, listeners.blur, this ); if ( isCapture ) CKEDITOR.event.useCapture = 0; element.setCustomData( SLOT_NAME, this ); element.setCustomData( SLOT_NAME_LISTENERS, listeners ); } }
[ "function", "(", "element", ",", "isCapture", ")", "{", "var", "fm", "=", "element", ".", "getCustomData", "(", "SLOT_NAME", ")", ";", "if", "(", "!", "fm", "||", "fm", "!=", "this", ")", "{", "fm", "&&", "fm", ".", "remove", "(", "element", ")", ";", "var", "focusEvent", "=", "'focus'", ",", "blurEvent", "=", "'blur'", ";", "if", "(", "isCapture", ")", "{", "if", "(", "CKEDITOR", ".", "env", ".", "ie", ")", "{", "focusEvent", "=", "'focusin'", ";", "blurEvent", "=", "'focusout'", ";", "}", "else", "{", "CKEDITOR", ".", "event", ".", "useCapture", "=", "1", ";", "}", "}", "var", "listeners", "=", "{", "blur", ":", "function", "(", ")", "{", "if", "(", "element", ".", "equals", "(", "this", ".", "currentActive", ")", ")", "this", ".", "blur", "(", ")", ";", "}", ",", "focus", ":", "function", "(", ")", "{", "this", ".", "focus", "(", "element", ")", ";", "}", "}", ";", "element", ".", "on", "(", "focusEvent", ",", "listeners", ".", "focus", ",", "this", ")", ";", "element", ".", "on", "(", "blurEvent", ",", "listeners", ".", "blur", ",", "this", ")", ";", "if", "(", "isCapture", ")", "CKEDITOR", ".", "event", ".", "useCapture", "=", "0", ";", "element", ".", "setCustomData", "(", "SLOT_NAME", ",", "this", ")", ";", "element", ".", "setCustomData", "(", "SLOT_NAME_LISTENERS", ",", "listeners", ")", ";", "}", "}" ]
Registers a UI DOM element to the focus manager, which will make the focus manager "hasFocus" once the input focus is relieved on the element. This method is designed to be used by plugins to expand the jurisdiction of the editor focus. @param {CKEDITOR.dom.element} element The container (topmost) element of one UI part. @param {Boolean} isCapture If specified, {@link CKEDITOR.event#useCapture} will be used when listening to the focus event. @member CKEDITOR.focusManager
[ "Registers", "a", "UI", "DOM", "element", "to", "the", "focus", "manager", "which", "will", "make", "the", "focus", "manager", "hasFocus", "once", "the", "input", "focus", "is", "relieved", "on", "the", "element", ".", "This", "method", "is", "designed", "to", "be", "used", "by", "plugins", "to", "expand", "the", "jurisdiction", "of", "the", "editor", "focus", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/focusmanager.js#L186-L227
train
n1ru4l/ember-cli-postcss-fixed
index.js
PostcssCompiler
function PostcssCompiler(inputTrees, inputFile, outputFile, plugins, map, useSass, includePaths) { if (!(this instanceof PostcssCompiler)) { return new PostcssCompiler(inputTrees, inputFile, outputFile, plugins, map); } if (!Array.isArray(inputTrees)) { throw new Error('Expected array for first argument - did you mean [tree] instead of tree?'); } CachingWriter.call(this, inputTrees, inputFile); this.inputFile = inputFile; this.outputFile = outputFile; this.plugins = plugins || []; this.map = map || {}; this.warningStream = process.stderr; this.useSass = useSass || false; this.includePaths = includePaths || []; }
javascript
function PostcssCompiler(inputTrees, inputFile, outputFile, plugins, map, useSass, includePaths) { if (!(this instanceof PostcssCompiler)) { return new PostcssCompiler(inputTrees, inputFile, outputFile, plugins, map); } if (!Array.isArray(inputTrees)) { throw new Error('Expected array for first argument - did you mean [tree] instead of tree?'); } CachingWriter.call(this, inputTrees, inputFile); this.inputFile = inputFile; this.outputFile = outputFile; this.plugins = plugins || []; this.map = map || {}; this.warningStream = process.stderr; this.useSass = useSass || false; this.includePaths = includePaths || []; }
[ "function", "PostcssCompiler", "(", "inputTrees", ",", "inputFile", ",", "outputFile", ",", "plugins", ",", "map", ",", "useSass", ",", "includePaths", ")", "{", "if", "(", "!", "(", "this", "instanceof", "PostcssCompiler", ")", ")", "{", "return", "new", "PostcssCompiler", "(", "inputTrees", ",", "inputFile", ",", "outputFile", ",", "plugins", ",", "map", ")", ";", "}", "if", "(", "!", "Array", ".", "isArray", "(", "inputTrees", ")", ")", "{", "throw", "new", "Error", "(", "'Expected array for first argument - did you mean [tree] instead of tree?'", ")", ";", "}", "CachingWriter", ".", "call", "(", "this", ",", "inputTrees", ",", "inputFile", ")", ";", "this", ".", "inputFile", "=", "inputFile", ";", "this", ".", "outputFile", "=", "outputFile", ";", "this", ".", "plugins", "=", "plugins", "||", "[", "]", ";", "this", ".", "map", "=", "map", "||", "{", "}", ";", "this", ".", "warningStream", "=", "process", ".", "stderr", ";", "this", ".", "useSass", "=", "useSass", "||", "false", ";", "this", ".", "includePaths", "=", "includePaths", "||", "[", "]", ";", "}" ]
rip of broccoli-postcss
[ "rip", "of", "broccoli", "-", "postcss" ]
7bcceaba60cfbe74e9db8e643e0ccf5ee0293bcc
https://github.com/n1ru4l/ember-cli-postcss-fixed/blob/7bcceaba60cfbe74e9db8e643e0ccf5ee0293bcc/index.js#L17-L35
train
jgrund/grunt-coverjs
tasks/cover.js
coverFile
function coverFile(srcFile) { var srcCode = grunt.file.read(srcFile); Instrument = require('coverjs').Instrument; try { return new Instrument(srcCode, {name: srcFile}).instrument(); } catch (e) { grunt.log.error('File ' + srcFile + ' could not be instrumented.'); grunt.fatal(e, 3); } }
javascript
function coverFile(srcFile) { var srcCode = grunt.file.read(srcFile); Instrument = require('coverjs').Instrument; try { return new Instrument(srcCode, {name: srcFile}).instrument(); } catch (e) { grunt.log.error('File ' + srcFile + ' could not be instrumented.'); grunt.fatal(e, 3); } }
[ "function", "coverFile", "(", "srcFile", ")", "{", "var", "srcCode", "=", "grunt", ".", "file", ".", "read", "(", "srcFile", ")", ";", "Instrument", "=", "require", "(", "'coverjs'", ")", ".", "Instrument", ";", "try", "{", "return", "new", "Instrument", "(", "srcCode", ",", "{", "name", ":", "srcFile", "}", ")", ".", "instrument", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "grunt", ".", "log", ".", "error", "(", "'File '", "+", "srcFile", "+", "' could not be instrumented.'", ")", ";", "grunt", ".", "fatal", "(", "e", ",", "3", ")", ";", "}", "}" ]
Instruments the given source file. @param srcFile @return {String} Returns the instrumented source file as a string.
[ "Instruments", "the", "given", "source", "file", "." ]
6727af0446848af11ab36eb5a961fe4735ae7064
https://github.com/jgrund/grunt-coverjs/blob/6727af0446848af11ab36eb5a961fe4735ae7064/tasks/cover.js#L39-L49
train
fieosa/webcomponent-mdl
src/utils/custom-element.js
createBaseCustomElementClass
function createBaseCustomElementClass(win) { if (win.BaseCustomElementClass) { return win.BaseCustomElementClass; } const htmlElement = win.HTMLElement; /** @abstract @extends {HTMLElement} */ class BaseCustomElement extends htmlElement { /** * @see https://github.com/WebReflection/document-register-element#v1-caveat * @suppress {checkTypes} */ constructor(self) { self = super(self); self.createdCallback(self.getChildren()); return self; } /** * Called when elements is created. Sets instance vars since there is no * constructor. * @this {!Element} */ createdCallback() { } attributeChangedCallback(attrName, oldVal, newVal) { } /** * Called when the element is first connected to the DOM. Calls * {@link firstAttachedCallback} if this is the first attachment. * @final @this {!Element} */ connectedCallback() { } /** The Custom Elements V0 sibling to `connectedCallback`. */ attachedCallback() { this.connectedCallback(); } /** * Called when the element is disconnected from the DOM. * @final @this {!Element} */ disconnectedCallback() { } /** The Custom Elements V0 sibling to `disconnectedCallback`. */ detachedCallback() { this.disconnectedCallback(); } getChildren() { return [].slice.call(this.childNodes); } } win.BaseCustomElementClass = BaseCustomElement; return win.BaseCustomElementClass; }
javascript
function createBaseCustomElementClass(win) { if (win.BaseCustomElementClass) { return win.BaseCustomElementClass; } const htmlElement = win.HTMLElement; /** @abstract @extends {HTMLElement} */ class BaseCustomElement extends htmlElement { /** * @see https://github.com/WebReflection/document-register-element#v1-caveat * @suppress {checkTypes} */ constructor(self) { self = super(self); self.createdCallback(self.getChildren()); return self; } /** * Called when elements is created. Sets instance vars since there is no * constructor. * @this {!Element} */ createdCallback() { } attributeChangedCallback(attrName, oldVal, newVal) { } /** * Called when the element is first connected to the DOM. Calls * {@link firstAttachedCallback} if this is the first attachment. * @final @this {!Element} */ connectedCallback() { } /** The Custom Elements V0 sibling to `connectedCallback`. */ attachedCallback() { this.connectedCallback(); } /** * Called when the element is disconnected from the DOM. * @final @this {!Element} */ disconnectedCallback() { } /** The Custom Elements V0 sibling to `disconnectedCallback`. */ detachedCallback() { this.disconnectedCallback(); } getChildren() { return [].slice.call(this.childNodes); } } win.BaseCustomElementClass = BaseCustomElement; return win.BaseCustomElementClass; }
[ "function", "createBaseCustomElementClass", "(", "win", ")", "{", "if", "(", "win", ".", "BaseCustomElementClass", ")", "{", "return", "win", ".", "BaseCustomElementClass", ";", "}", "const", "htmlElement", "=", "win", ".", "HTMLElement", ";", "class", "BaseCustomElement", "extends", "htmlElement", "{", "constructor", "(", "self", ")", "{", "self", "=", "super", "(", "self", ")", ";", "self", ".", "createdCallback", "(", "self", ".", "getChildren", "(", ")", ")", ";", "return", "self", ";", "}", "createdCallback", "(", ")", "{", "}", "attributeChangedCallback", "(", "attrName", ",", "oldVal", ",", "newVal", ")", "{", "}", "connectedCallback", "(", ")", "{", "}", "attachedCallback", "(", ")", "{", "this", ".", "connectedCallback", "(", ")", ";", "}", "disconnectedCallback", "(", ")", "{", "}", "detachedCallback", "(", ")", "{", "this", ".", "disconnectedCallback", "(", ")", ";", "}", "getChildren", "(", ")", "{", "return", "[", "]", ".", "slice", ".", "call", "(", "this", ".", "childNodes", ")", ";", "}", "}", "win", ".", "BaseCustomElementClass", "=", "BaseCustomElement", ";", "return", "win", ".", "BaseCustomElementClass", ";", "}" ]
Creates a base custom element class. @param {!Window} win The window in which to register the custom element. @return {!Function}
[ "Creates", "a", "base", "custom", "element", "class", "." ]
5aec1bfd5110addcbeedd01ba07b8a01c836c511
https://github.com/fieosa/webcomponent-mdl/blob/5aec1bfd5110addcbeedd01ba07b8a01c836c511/src/utils/custom-element.js#L7-L67
train
jsguy/mithril.component.mdl
lib/polyfills/dialog-polyfill.js
function(backdropZ, dialogZ) { this.backdrop_.style.zIndex = backdropZ; this.dialog_.style.zIndex = dialogZ; }
javascript
function(backdropZ, dialogZ) { this.backdrop_.style.zIndex = backdropZ; this.dialog_.style.zIndex = dialogZ; }
[ "function", "(", "backdropZ", ",", "dialogZ", ")", "{", "this", ".", "backdrop_", ".", "style", ".", "zIndex", "=", "backdropZ", ";", "this", ".", "dialog_", ".", "style", ".", "zIndex", "=", "dialogZ", ";", "}" ]
Sets the zIndex for the backdrop and dialog. @param {number} backdropZ @param {number} dialogZ
[ "Sets", "the", "zIndex", "for", "the", "backdrop", "and", "dialog", "." ]
89a132fd475e55a98b239a229842661745a53372
https://github.com/jsguy/mithril.component.mdl/blob/89a132fd475e55a98b239a229842661745a53372/lib/polyfills/dialog-polyfill.js#L168-L171
train
nfantone/mu-koan
lib/server.js
initialize
function initialize(app, options) { var log = logger.get(options); app._mukoan = app._mukoan || {}; if (!app._mukoan.initialized) { var config = defaults({}, options, DEFAULT_CONFIGURATION); log.info('Starting and configuring Koa server'); // Setup global error handler and logger app.use(middlewares.error(config.error)); app.on('error', (error) => log.error('Unexpected exception ', error)); app._mukoan.initialized = true; } else { log.warn('Trying to initialize the same Koa instance twice (ignoring action)'); } }
javascript
function initialize(app, options) { var log = logger.get(options); app._mukoan = app._mukoan || {}; if (!app._mukoan.initialized) { var config = defaults({}, options, DEFAULT_CONFIGURATION); log.info('Starting and configuring Koa server'); // Setup global error handler and logger app.use(middlewares.error(config.error)); app.on('error', (error) => log.error('Unexpected exception ', error)); app._mukoan.initialized = true; } else { log.warn('Trying to initialize the same Koa instance twice (ignoring action)'); } }
[ "function", "initialize", "(", "app", ",", "options", ")", "{", "var", "log", "=", "logger", ".", "get", "(", "options", ")", ";", "app", ".", "_mukoan", "=", "app", ".", "_mukoan", "||", "{", "}", ";", "if", "(", "!", "app", ".", "_mukoan", ".", "initialized", ")", "{", "var", "config", "=", "defaults", "(", "{", "}", ",", "options", ",", "DEFAULT_CONFIGURATION", ")", ";", "log", ".", "info", "(", "'Starting and configuring Koa server'", ")", ";", "app", ".", "use", "(", "middlewares", ".", "error", "(", "config", ".", "error", ")", ")", ";", "app", ".", "on", "(", "'error'", ",", "(", "error", ")", "=>", "log", ".", "error", "(", "'Unexpected exception '", ",", "error", ")", ")", ";", "app", ".", "_mukoan", ".", "initialized", "=", "true", ";", "}", "else", "{", "log", ".", "warn", "(", "'Trying to initialize the same Koa instance twice (ignoring action)'", ")", ";", "}", "}" ]
Configures top level middlewares and error logging. This should be called before `bootstrap`. @param {Object} app A Koa app instance as created by `new Koa()` @return {Object} The `app` instance with middleware already declared.
[ "Configures", "top", "level", "middlewares", "and", "error", "logging", ".", "This", "should", "be", "called", "before", "bootstrap", "." ]
3a5c5eec94509ef73263d8e30d9ef7df54611ece
https://github.com/nfantone/mu-koan/blob/3a5c5eec94509ef73263d8e30d9ef7df54611ece/lib/server.js#L28-L42
train
nfantone/mu-koan
lib/server.js
bootstrap
function bootstrap(app, options) { var config = defaults({}, options, DEFAULT_CONFIGURATION); var log = logger.get(options); app._mukoan = app._mukoan || {}; if (!app._mukoan.initialized) { initialize(app, options); } if (!app._mukoan.bootstrapped) { // Configure and setup middlewares app.use(middlewares.bodyparser(config.bodyParser)); app.use(middlewares.morgan(config.morgan.format, config.morgan.options)); app.use(middlewares.responseTime()); app.use(middlewares.helmet(config.helmet)); app.use(middlewares.compress({ flush: zlib.Z_SYNC_FLUSH })); app.use(middlewares.conditional()); app.use(middlewares.etag()); app.use(middlewares.cacheControl(config.cacheControl)); app.use(middlewares.cors(config.cors)); app.use(middlewares.favicon(config.favicon)); app.use(middlewares.jwt(config.jwt.options).unless(config.jwt.unless)); app.use(middlewares.json()); app._mukoan.bootstrapped = true; log.debug('Finished configuring Koa server'); } else { log.warn('Trying to bootstrap the same Koa instance twice (ignoring action)'); } return app; }
javascript
function bootstrap(app, options) { var config = defaults({}, options, DEFAULT_CONFIGURATION); var log = logger.get(options); app._mukoan = app._mukoan || {}; if (!app._mukoan.initialized) { initialize(app, options); } if (!app._mukoan.bootstrapped) { // Configure and setup middlewares app.use(middlewares.bodyparser(config.bodyParser)); app.use(middlewares.morgan(config.morgan.format, config.morgan.options)); app.use(middlewares.responseTime()); app.use(middlewares.helmet(config.helmet)); app.use(middlewares.compress({ flush: zlib.Z_SYNC_FLUSH })); app.use(middlewares.conditional()); app.use(middlewares.etag()); app.use(middlewares.cacheControl(config.cacheControl)); app.use(middlewares.cors(config.cors)); app.use(middlewares.favicon(config.favicon)); app.use(middlewares.jwt(config.jwt.options).unless(config.jwt.unless)); app.use(middlewares.json()); app._mukoan.bootstrapped = true; log.debug('Finished configuring Koa server'); } else { log.warn('Trying to bootstrap the same Koa instance twice (ignoring action)'); } return app; }
[ "function", "bootstrap", "(", "app", ",", "options", ")", "{", "var", "config", "=", "defaults", "(", "{", "}", ",", "options", ",", "DEFAULT_CONFIGURATION", ")", ";", "var", "log", "=", "logger", ".", "get", "(", "options", ")", ";", "app", ".", "_mukoan", "=", "app", ".", "_mukoan", "||", "{", "}", ";", "if", "(", "!", "app", ".", "_mukoan", ".", "initialized", ")", "{", "initialize", "(", "app", ",", "options", ")", ";", "}", "if", "(", "!", "app", ".", "_mukoan", ".", "bootstrapped", ")", "{", "app", ".", "use", "(", "middlewares", ".", "bodyparser", "(", "config", ".", "bodyParser", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "morgan", "(", "config", ".", "morgan", ".", "format", ",", "config", ".", "morgan", ".", "options", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "responseTime", "(", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "helmet", "(", "config", ".", "helmet", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "compress", "(", "{", "flush", ":", "zlib", ".", "Z_SYNC_FLUSH", "}", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "conditional", "(", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "etag", "(", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "cacheControl", "(", "config", ".", "cacheControl", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "cors", "(", "config", ".", "cors", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "favicon", "(", "config", ".", "favicon", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "jwt", "(", "config", ".", "jwt", ".", "options", ")", ".", "unless", "(", "config", ".", "jwt", ".", "unless", ")", ")", ";", "app", ".", "use", "(", "middlewares", ".", "json", "(", ")", ")", ";", "app", ".", "_mukoan", ".", "bootstrapped", "=", "true", ";", "log", ".", "debug", "(", "'Finished configuring Koa server'", ")", ";", "}", "else", "{", "log", ".", "warn", "(", "'Trying to bootstrap the same Koa instance twice (ignoring action)'", ")", ";", "}", "return", "app", ";", "}" ]
Sets up a Koa app instance. @param {Object} app A Koa app instance as created by `new Koa()` @return {Object} The `app` instance with middleware already declared.
[ "Sets", "up", "a", "Koa", "app", "instance", "." ]
3a5c5eec94509ef73263d8e30d9ef7df54611ece
https://github.com/nfantone/mu-koan/blob/3a5c5eec94509ef73263d8e30d9ef7df54611ece/lib/server.js#L50-L81
train
wilmoore/sum.js
sum.js
accessor
function accessor(object) { var ref = object || (1, eval)('this'); var len = parts.length; var idx = 0; // iteratively save each segment's reference for (; idx < len; idx += 1) { if (ref) ref = ref[parts[idx]]; } return ref; }
javascript
function accessor(object) { var ref = object || (1, eval)('this'); var len = parts.length; var idx = 0; // iteratively save each segment's reference for (; idx < len; idx += 1) { if (ref) ref = ref[parts[idx]]; } return ref; }
[ "function", "accessor", "(", "object", ")", "{", "var", "ref", "=", "object", "||", "(", "1", ",", "eval", ")", "(", "'this'", ")", ";", "var", "len", "=", "parts", ".", "length", ";", "var", "idx", "=", "0", ";", "for", "(", ";", "idx", "<", "len", ";", "idx", "+=", "1", ")", "{", "if", "(", "ref", ")", "ref", "=", "ref", "[", "parts", "[", "idx", "]", "]", ";", "}", "return", "ref", ";", "}" ]
Accessor function that accepts an object to be queried @private @param {Object} object object to access @return {Mixed} value at given reference or undefined if it does not exist
[ "Accessor", "function", "that", "accepts", "an", "object", "to", "be", "queried" ]
23630999bf8b2c4d33bb6acef6387f8597ad3a85
https://github.com/wilmoore/sum.js/blob/23630999bf8b2c4d33bb6acef6387f8597ad3a85/sum.js#L100-L111
train
willmark/img-canvas-helper
index.js
function (imgsrc, width, height, callback) { var args = new Args(arguments); checkCommonArgs(args); var Image = Canvas.Image, fs = require("fs"); var img = new Image(); img.onerror = function(err) { callback(false, err); }; img.onload = function() { var w = img.width; var h = img.height; var newx = Math.abs(w / 2 - width / 2); var newy = Math.abs(h / 2 - height / 2); var canvas = new Canvas(width, height); var ctx = canvas.getContext("2d"); ctx.drawImage(img, newx, newy, width, height, 0, 0, width, height); callback(true, canvas); }; if (!isValidFile(imgsrc)) { callback(false, new Error (imgsrc + ' is not a valid file')); } else { img.src = imgsrc; } }
javascript
function (imgsrc, width, height, callback) { var args = new Args(arguments); checkCommonArgs(args); var Image = Canvas.Image, fs = require("fs"); var img = new Image(); img.onerror = function(err) { callback(false, err); }; img.onload = function() { var w = img.width; var h = img.height; var newx = Math.abs(w / 2 - width / 2); var newy = Math.abs(h / 2 - height / 2); var canvas = new Canvas(width, height); var ctx = canvas.getContext("2d"); ctx.drawImage(img, newx, newy, width, height, 0, 0, width, height); callback(true, canvas); }; if (!isValidFile(imgsrc)) { callback(false, new Error (imgsrc + ' is not a valid file')); } else { img.src = imgsrc; } }
[ "function", "(", "imgsrc", ",", "width", ",", "height", ",", "callback", ")", "{", "var", "args", "=", "new", "Args", "(", "arguments", ")", ";", "checkCommonArgs", "(", "args", ")", ";", "var", "Image", "=", "Canvas", ".", "Image", ",", "fs", "=", "require", "(", "\"fs\"", ")", ";", "var", "img", "=", "new", "Image", "(", ")", ";", "img", ".", "onerror", "=", "function", "(", "err", ")", "{", "callback", "(", "false", ",", "err", ")", ";", "}", ";", "img", ".", "onload", "=", "function", "(", ")", "{", "var", "w", "=", "img", ".", "width", ";", "var", "h", "=", "img", ".", "height", ";", "var", "newx", "=", "Math", ".", "abs", "(", "w", "/", "2", "-", "width", "/", "2", ")", ";", "var", "newy", "=", "Math", ".", "abs", "(", "h", "/", "2", "-", "height", "/", "2", ")", ";", "var", "canvas", "=", "new", "Canvas", "(", "width", ",", "height", ")", ";", "var", "ctx", "=", "canvas", ".", "getContext", "(", "\"2d\"", ")", ";", "ctx", ".", "drawImage", "(", "img", ",", "newx", ",", "newy", ",", "width", ",", "height", ",", "0", ",", "0", ",", "width", ",", "height", ")", ";", "callback", "(", "true", ",", "canvas", ")", ";", "}", ";", "if", "(", "!", "isValidFile", "(", "imgsrc", ")", ")", "{", "callback", "(", "false", ",", "new", "Error", "(", "imgsrc", "+", "' is not a valid file'", ")", ")", ";", "}", "else", "{", "img", ".", "src", "=", "imgsrc", ";", "}", "}" ]
Crops an image to bounds specified by width and height imgsrc - string path to image to crop width - integer width of cropped image height - integer height of cropped image callback - callback function( result - boolean true on success data - canvas object on success, Error on failure
[ "Crops", "an", "image", "to", "bounds", "specified", "by", "width", "and", "height", "imgsrc", "-", "string", "path", "to", "image", "to", "crop", "width", "-", "integer", "width", "of", "cropped", "image", "height", "-", "integer", "height", "of", "cropped", "image", "callback", "-", "callback", "function", "(", "result", "-", "boolean", "true", "on", "success", "data", "-", "canvas", "object", "on", "success", "Error", "on", "failure" ]
d05ec8026eb2a74fd2dc8eec85dae3a3491ecaf1
https://github.com/willmark/img-canvas-helper/blob/d05ec8026eb2a74fd2dc8eec85dae3a3491ecaf1/index.js#L111-L135
train
mwyatt/dialogue
js/dialogue.js
handleMousedown
function handleMousedown(event) { // get currently open dialogue var dialogue = getDialogueCurrent(); if (dialogue.options.hardClose) { return; } var result = helper.isInside(event.target, dialogue.dialogue); if (!result) { closeInstance(dialogue); } }
javascript
function handleMousedown(event) { // get currently open dialogue var dialogue = getDialogueCurrent(); if (dialogue.options.hardClose) { return; } var result = helper.isInside(event.target, dialogue.dialogue); if (!result) { closeInstance(dialogue); } }
[ "function", "handleMousedown", "(", "event", ")", "{", "var", "dialogue", "=", "getDialogueCurrent", "(", ")", ";", "if", "(", "dialogue", ".", "options", ".", "hardClose", ")", "{", "return", ";", "}", "var", "result", "=", "helper", ".", "isInside", "(", "event", ".", "target", ",", "dialogue", ".", "dialogue", ")", ";", "if", "(", "!", "result", ")", "{", "closeInstance", "(", "dialogue", ")", ";", "}", "}" ]
clicking anything not inside the most current dialogue
[ "clicking", "anything", "not", "inside", "the", "most", "current", "dialogue" ]
c3d403262ce44d020438cb1e768556e459a7fd5e
https://github.com/mwyatt/dialogue/blob/c3d403262ce44d020438cb1e768556e459a7fd5e/js/dialogue.js#L152-L165
train
mwyatt/dialogue
js/dialogue.js
applyCssPosition
function applyCssPosition(dialogue) { var positionalEl = dialogue.options.positionTo; var containerPadding = 20; var cssSettings = { top: '', left: '', position: '', margin: '', marginTop: 0, marginRight: 0, marginBottom: 0, marginLeft: 0, maxWidth: dialogue.options.width }; var clientFrame = { positionVertical: window.pageYOffset, height: window.innerHeight, width: window.innerWidth }; var dialogueHeight = parseInt(dialogue.dialogue.offsetHeight); // position container dialogue.container.style.top = parsePx(clientFrame.positionVertical); // position to element or centrally window if (positionalEl) { var boundingRect = positionalEl.getBoundingClientRect(); // calc top cssSettings.position = 'absolute'; cssSettings.top = parseInt(boundingRect.top); cssSettings.left = parseInt(boundingRect.left); // if the right side of the dialogue is poking out of the clientFrame then // bring it back in plus 50px padding if ((cssSettings.left + cssSettings['maxWidth']) > clientFrame.width) { cssSettings.left = clientFrame.width - 50; cssSettings.left = cssSettings.left - cssSettings['maxWidth']; }; // no positional element so center to window } else { cssSettings.position = 'relative'; cssSettings.left = 'auto'; cssSettings.marginTop = 0; cssSettings.marginRight = 'auto'; cssSettings.marginBottom = 0; cssSettings.marginLeft = 'auto'; // center vertically if there is room // otherwise send to top and then just scroll if (dialogueHeight < clientFrame.height) { cssSettings.top = parseInt(clientFrame.height / 2) - parseInt(dialogueHeight / 2) - containerPadding; } else { cssSettings.top = 'auto'; }; }; dialogue.container.style.zIndex = 500 + dialoguesOpen.length; dialogue.dialogue.style.top = parsePx(cssSettings.top); dialogue.dialogue.style.left = parsePx(cssSettings.left); dialogue.dialogue.style.position = parsePx(cssSettings.position); dialogue.dialogue.style.marginTop = parsePx(cssSettings.marginTop); dialogue.dialogue.style.marginRight = parsePx(cssSettings.marginRight); dialogue.dialogue.style.marginBottom = parsePx(cssSettings.marginBottom); dialogue.dialogue.style.marginLeft = parsePx(cssSettings.marginLeft); dialogue.dialogue.style.maxWidth = parsePx(cssSettings.maxWidth); }
javascript
function applyCssPosition(dialogue) { var positionalEl = dialogue.options.positionTo; var containerPadding = 20; var cssSettings = { top: '', left: '', position: '', margin: '', marginTop: 0, marginRight: 0, marginBottom: 0, marginLeft: 0, maxWidth: dialogue.options.width }; var clientFrame = { positionVertical: window.pageYOffset, height: window.innerHeight, width: window.innerWidth }; var dialogueHeight = parseInt(dialogue.dialogue.offsetHeight); // position container dialogue.container.style.top = parsePx(clientFrame.positionVertical); // position to element or centrally window if (positionalEl) { var boundingRect = positionalEl.getBoundingClientRect(); // calc top cssSettings.position = 'absolute'; cssSettings.top = parseInt(boundingRect.top); cssSettings.left = parseInt(boundingRect.left); // if the right side of the dialogue is poking out of the clientFrame then // bring it back in plus 50px padding if ((cssSettings.left + cssSettings['maxWidth']) > clientFrame.width) { cssSettings.left = clientFrame.width - 50; cssSettings.left = cssSettings.left - cssSettings['maxWidth']; }; // no positional element so center to window } else { cssSettings.position = 'relative'; cssSettings.left = 'auto'; cssSettings.marginTop = 0; cssSettings.marginRight = 'auto'; cssSettings.marginBottom = 0; cssSettings.marginLeft = 'auto'; // center vertically if there is room // otherwise send to top and then just scroll if (dialogueHeight < clientFrame.height) { cssSettings.top = parseInt(clientFrame.height / 2) - parseInt(dialogueHeight / 2) - containerPadding; } else { cssSettings.top = 'auto'; }; }; dialogue.container.style.zIndex = 500 + dialoguesOpen.length; dialogue.dialogue.style.top = parsePx(cssSettings.top); dialogue.dialogue.style.left = parsePx(cssSettings.left); dialogue.dialogue.style.position = parsePx(cssSettings.position); dialogue.dialogue.style.marginTop = parsePx(cssSettings.marginTop); dialogue.dialogue.style.marginRight = parsePx(cssSettings.marginRight); dialogue.dialogue.style.marginBottom = parsePx(cssSettings.marginBottom); dialogue.dialogue.style.marginLeft = parsePx(cssSettings.marginLeft); dialogue.dialogue.style.maxWidth = parsePx(cssSettings.maxWidth); }
[ "function", "applyCssPosition", "(", "dialogue", ")", "{", "var", "positionalEl", "=", "dialogue", ".", "options", ".", "positionTo", ";", "var", "containerPadding", "=", "20", ";", "var", "cssSettings", "=", "{", "top", ":", "''", ",", "left", ":", "''", ",", "position", ":", "''", ",", "margin", ":", "''", ",", "marginTop", ":", "0", ",", "marginRight", ":", "0", ",", "marginBottom", ":", "0", ",", "marginLeft", ":", "0", ",", "maxWidth", ":", "dialogue", ".", "options", ".", "width", "}", ";", "var", "clientFrame", "=", "{", "positionVertical", ":", "window", ".", "pageYOffset", ",", "height", ":", "window", ".", "innerHeight", ",", "width", ":", "window", ".", "innerWidth", "}", ";", "var", "dialogueHeight", "=", "parseInt", "(", "dialogue", ".", "dialogue", ".", "offsetHeight", ")", ";", "dialogue", ".", "container", ".", "style", ".", "top", "=", "parsePx", "(", "clientFrame", ".", "positionVertical", ")", ";", "if", "(", "positionalEl", ")", "{", "var", "boundingRect", "=", "positionalEl", ".", "getBoundingClientRect", "(", ")", ";", "cssSettings", ".", "position", "=", "'absolute'", ";", "cssSettings", ".", "top", "=", "parseInt", "(", "boundingRect", ".", "top", ")", ";", "cssSettings", ".", "left", "=", "parseInt", "(", "boundingRect", ".", "left", ")", ";", "if", "(", "(", "cssSettings", ".", "left", "+", "cssSettings", "[", "'maxWidth'", "]", ")", ">", "clientFrame", ".", "width", ")", "{", "cssSettings", ".", "left", "=", "clientFrame", ".", "width", "-", "50", ";", "cssSettings", ".", "left", "=", "cssSettings", ".", "left", "-", "cssSettings", "[", "'maxWidth'", "]", ";", "}", ";", "}", "else", "{", "cssSettings", ".", "position", "=", "'relative'", ";", "cssSettings", ".", "left", "=", "'auto'", ";", "cssSettings", ".", "marginTop", "=", "0", ";", "cssSettings", ".", "marginRight", "=", "'auto'", ";", "cssSettings", ".", "marginBottom", "=", "0", ";", "cssSettings", ".", "marginLeft", "=", "'auto'", ";", "if", "(", "dialogueHeight", "<", "clientFrame", ".", "height", ")", "{", "cssSettings", ".", "top", "=", "parseInt", "(", "clientFrame", ".", "height", "/", "2", ")", "-", "parseInt", "(", "dialogueHeight", "/", "2", ")", "-", "containerPadding", ";", "}", "else", "{", "cssSettings", ".", "top", "=", "'auto'", ";", "}", ";", "}", ";", "dialogue", ".", "container", ".", "style", ".", "zIndex", "=", "500", "+", "dialoguesOpen", ".", "length", ";", "dialogue", ".", "dialogue", ".", "style", ".", "top", "=", "parsePx", "(", "cssSettings", ".", "top", ")", ";", "dialogue", ".", "dialogue", ".", "style", ".", "left", "=", "parsePx", "(", "cssSettings", ".", "left", ")", ";", "dialogue", ".", "dialogue", ".", "style", ".", "position", "=", "parsePx", "(", "cssSettings", ".", "position", ")", ";", "dialogue", ".", "dialogue", ".", "style", ".", "marginTop", "=", "parsePx", "(", "cssSettings", ".", "marginTop", ")", ";", "dialogue", ".", "dialogue", ".", "style", ".", "marginRight", "=", "parsePx", "(", "cssSettings", ".", "marginRight", ")", ";", "dialogue", ".", "dialogue", ".", "style", ".", "marginBottom", "=", "parsePx", "(", "cssSettings", ".", "marginBottom", ")", ";", "dialogue", ".", "dialogue", ".", "style", ".", "marginLeft", "=", "parsePx", "(", "cssSettings", ".", "marginLeft", ")", ";", "dialogue", ".", "dialogue", ".", "style", ".", "maxWidth", "=", "parsePx", "(", "cssSettings", ".", "maxWidth", ")", ";", "}" ]
apply the css to the dialogue to position correctly
[ "apply", "the", "css", "to", "the", "dialogue", "to", "position", "correctly" ]
c3d403262ce44d020438cb1e768556e459a7fd5e
https://github.com/mwyatt/dialogue/blob/c3d403262ce44d020438cb1e768556e459a7fd5e/js/dialogue.js#L213-L281
train
mwyatt/dialogue
js/dialogue.js
closeInstance
function closeInstance(dialogue) { // none may be open yet, or one may be open but may be closing another which is not open if (typeof dialogue === 'undefined' || typeof dialogue.options === 'undefined' || !dialoguesOpen.length) { return; } dialoguesOpen.forEach(function(dialogueSingle, index) { if (dialogueSingle.options.id == dialogue.options.id) { dialoguesOpen.splice(index, 1); } }); if (!dialoguesOpen.length) { document.removeEventListener('keyup', handleKeyup); document.removeEventListener('mousedown', handleMousedown); } // .off('click.dialogue.action') // dialogue.container.off(); // needed? docBody.removeChild(dialogue.container); dialogue.options.onClose.call(dialogue); }
javascript
function closeInstance(dialogue) { // none may be open yet, or one may be open but may be closing another which is not open if (typeof dialogue === 'undefined' || typeof dialogue.options === 'undefined' || !dialoguesOpen.length) { return; } dialoguesOpen.forEach(function(dialogueSingle, index) { if (dialogueSingle.options.id == dialogue.options.id) { dialoguesOpen.splice(index, 1); } }); if (!dialoguesOpen.length) { document.removeEventListener('keyup', handleKeyup); document.removeEventListener('mousedown', handleMousedown); } // .off('click.dialogue.action') // dialogue.container.off(); // needed? docBody.removeChild(dialogue.container); dialogue.options.onClose.call(dialogue); }
[ "function", "closeInstance", "(", "dialogue", ")", "{", "if", "(", "typeof", "dialogue", "===", "'undefined'", "||", "typeof", "dialogue", ".", "options", "===", "'undefined'", "||", "!", "dialoguesOpen", ".", "length", ")", "{", "return", ";", "}", "dialoguesOpen", ".", "forEach", "(", "function", "(", "dialogueSingle", ",", "index", ")", "{", "if", "(", "dialogueSingle", ".", "options", ".", "id", "==", "dialogue", ".", "options", ".", "id", ")", "{", "dialoguesOpen", ".", "splice", "(", "index", ",", "1", ")", ";", "}", "}", ")", ";", "if", "(", "!", "dialoguesOpen", ".", "length", ")", "{", "document", ".", "removeEventListener", "(", "'keyup'", ",", "handleKeyup", ")", ";", "document", ".", "removeEventListener", "(", "'mousedown'", ",", "handleMousedown", ")", ";", "}", "docBody", ".", "removeChild", "(", "dialogue", ".", "container", ")", ";", "dialogue", ".", "options", ".", "onClose", ".", "call", "(", "dialogue", ")", ";", "}" ]
call onclose and remove @param {object} data @return {null}
[ "call", "onclose", "and", "remove" ]
c3d403262ce44d020438cb1e768556e459a7fd5e
https://github.com/mwyatt/dialogue/blob/c3d403262ce44d020438cb1e768556e459a7fd5e/js/dialogue.js#L288-L311
train
UXFoundry/hashdo
lib/template.js
function (file) { return Path.join(Path.dirname(Path.relative(hbTemplatePath, file)), Path.basename(file, Path.extname(file))); }
javascript
function (file) { return Path.join(Path.dirname(Path.relative(hbTemplatePath, file)), Path.basename(file, Path.extname(file))); }
[ "function", "(", "file", ")", "{", "return", "Path", ".", "join", "(", "Path", ".", "dirname", "(", "Path", ".", "relative", "(", "hbTemplatePath", ",", "file", ")", ")", ",", "Path", ".", "basename", "(", "file", ",", "Path", ".", "extname", "(", "file", ")", ")", ")", ";", "}" ]
Consolidate needs partial paths relative to the main tempalte being rendered and without the extension.
[ "Consolidate", "needs", "partial", "paths", "relative", "to", "the", "main", "tempalte", "being", "rendered", "and", "without", "the", "extension", "." ]
c2a0adcba0cca26d6ebe56bba17017b177609057
https://github.com/UXFoundry/hashdo/blob/c2a0adcba0cca26d6ebe56bba17017b177609057/lib/template.js#L50-L52
train
pinyin/outline
vendor/transformation-matrix/scale.js
scale
function scale(sx) { var sy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; if ((0, _utils.isUndefined)(sy)) sy = sx; return { a: sx, c: 0, e: 0, b: 0, d: sy, f: 0 }; }
javascript
function scale(sx) { var sy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; if ((0, _utils.isUndefined)(sy)) sy = sx; return { a: sx, c: 0, e: 0, b: 0, d: sy, f: 0 }; }
[ "function", "scale", "(", "sx", ")", "{", "var", "sy", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "undefined", ";", "if", "(", "(", "0", ",", "_utils", ".", "isUndefined", ")", "(", "sy", ")", ")", "sy", "=", "sx", ";", "return", "{", "a", ":", "sx", ",", "c", ":", "0", ",", "e", ":", "0", ",", "b", ":", "0", ",", "d", ":", "sy", ",", "f", ":", "0", "}", ";", "}" ]
Calculate a scaling matrix @param sx Scaling on axis x @param [sy = sx] Scaling on axis y (default sx) @returns {{a: number, b: number, c: number, e: number, d: number, f: number}} Affine matrix
[ "Calculate", "a", "scaling", "matrix" ]
e49f05d2f8ab384f5b1d71b2b10875cd48d41051
https://github.com/pinyin/outline/blob/e49f05d2f8ab384f5b1d71b2b10875cd48d41051/vendor/transformation-matrix/scale.js#L16-L24
train
switer/sutils
url.js
function (surl) { var search = (surl || window.location.search).match(/\?.*(?=\b|#)/); search && (search = search[0].replace(/^\?/, '')); if (!search) return {}; var queries = {}, params = search.split('&'); util.each(params, function (item) { var param = item.split('='); queries[param[0]] = param[1]; }); return queries; }
javascript
function (surl) { var search = (surl || window.location.search).match(/\?.*(?=\b|#)/); search && (search = search[0].replace(/^\?/, '')); if (!search) return {}; var queries = {}, params = search.split('&'); util.each(params, function (item) { var param = item.split('='); queries[param[0]] = param[1]; }); return queries; }
[ "function", "(", "surl", ")", "{", "var", "search", "=", "(", "surl", "||", "window", ".", "location", ".", "search", ")", ".", "match", "(", "/", "\\?.*(?=\\b|#)", "/", ")", ";", "search", "&&", "(", "search", "=", "search", "[", "0", "]", ".", "replace", "(", "/", "^\\?", "/", ",", "''", ")", ")", ";", "if", "(", "!", "search", ")", "return", "{", "}", ";", "var", "queries", "=", "{", "}", ",", "params", "=", "search", ".", "split", "(", "'&'", ")", ";", "util", ".", "each", "(", "params", ",", "function", "(", "item", ")", "{", "var", "param", "=", "item", ".", "split", "(", "'='", ")", ";", "queries", "[", "param", "[", "0", "]", "]", "=", "param", "[", "1", "]", ";", "}", ")", ";", "return", "queries", ";", "}" ]
params in url of location.search
[ "params", "in", "url", "of", "location", ".", "search" ]
2573c2498e62837da132ada8a2109d42d9f9d0ca
https://github.com/switer/sutils/blob/2573c2498e62837da132ada8a2109d42d9f9d0ca/url.js#L44-L57
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/skin.js
function( part, fn ) { if ( CKEDITOR.skin.name != getName() ) { CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( getConfigPath() + 'skin.js' ), function() { loadCss( part, fn ); } ); } else { loadCss( part, fn ); } }
javascript
function( part, fn ) { if ( CKEDITOR.skin.name != getName() ) { CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( getConfigPath() + 'skin.js' ), function() { loadCss( part, fn ); } ); } else { loadCss( part, fn ); } }
[ "function", "(", "part", ",", "fn", ")", "{", "if", "(", "CKEDITOR", ".", "skin", ".", "name", "!=", "getName", "(", ")", ")", "{", "CKEDITOR", ".", "scriptLoader", ".", "load", "(", "CKEDITOR", ".", "getUrl", "(", "getConfigPath", "(", ")", "+", "'skin.js'", ")", ",", "function", "(", ")", "{", "loadCss", "(", "part", ",", "fn", ")", ";", "}", ")", ";", "}", "else", "{", "loadCss", "(", "part", ",", "fn", ")", ";", "}", "}" ]
Loads a skin part into the page. Does nothing if the part has already been loaded. **Note:** The "editor" part is always auto loaded upon instance creation, thus this function is mainly used to **lazy load** other parts of the skin that do not have to be displayed until requested. // Load the dialog part. editor.skin.loadPart( 'dialog' ); @param {String} part The name of the skin part CSS file that resides in the skin directory. @param {Function} fn The provided callback function which is invoked after the part is loaded.
[ "Loads", "a", "skin", "part", "into", "the", "page", ".", "Does", "nothing", "if", "the", "part", "has", "already", "been", "loaded", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/skin.js#L49-L57
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/skin.js
function( name, path, offset, bgsize ) { name = name.toLowerCase(); if ( !this.icons[ name ] ) { this.icons[ name ] = { path: path, offset: offset || 0, bgsize: bgsize || '16px' }; } }
javascript
function( name, path, offset, bgsize ) { name = name.toLowerCase(); if ( !this.icons[ name ] ) { this.icons[ name ] = { path: path, offset: offset || 0, bgsize: bgsize || '16px' }; } }
[ "function", "(", "name", ",", "path", ",", "offset", ",", "bgsize", ")", "{", "name", "=", "name", ".", "toLowerCase", "(", ")", ";", "if", "(", "!", "this", ".", "icons", "[", "name", "]", ")", "{", "this", ".", "icons", "[", "name", "]", "=", "{", "path", ":", "path", ",", "offset", ":", "offset", "||", "0", ",", "bgsize", ":", "bgsize", "||", "'16px'", "}", ";", "}", "}" ]
Registers an icon. @param {String} name The icon name. @param {String} path The path to the icon image file. @param {Number} [offset] The vertical offset position of the icon, if available inside a strip image. @param {String} [bgsize] The value of the CSS "background-size" property to use for this icon
[ "Registers", "an", "icon", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/skin.js#L83-L92
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/core/skin.js
function( name, rtl, overridePath, overrideOffset, overrideBgsize ) { var icon, path, offset, bgsize; if ( name ) { name = name.toLowerCase(); // If we're in RTL, try to get the RTL version of the icon. if ( rtl ) icon = this.icons[ name + '-rtl' ]; // If not in LTR or no RTL version available, get the generic one. if ( !icon ) icon = this.icons[ name ]; } path = overridePath || ( icon && icon.path ) || ''; offset = overrideOffset || ( icon && icon.offset ); bgsize = overrideBgsize || ( icon && icon.bgsize ) || '16px'; return path && ( 'background-image:url(' + CKEDITOR.getUrl( path ) + ');background-position:0 ' + offset + 'px;background-size:' + bgsize + ';' ); }
javascript
function( name, rtl, overridePath, overrideOffset, overrideBgsize ) { var icon, path, offset, bgsize; if ( name ) { name = name.toLowerCase(); // If we're in RTL, try to get the RTL version of the icon. if ( rtl ) icon = this.icons[ name + '-rtl' ]; // If not in LTR or no RTL version available, get the generic one. if ( !icon ) icon = this.icons[ name ]; } path = overridePath || ( icon && icon.path ) || ''; offset = overrideOffset || ( icon && icon.offset ); bgsize = overrideBgsize || ( icon && icon.bgsize ) || '16px'; return path && ( 'background-image:url(' + CKEDITOR.getUrl( path ) + ');background-position:0 ' + offset + 'px;background-size:' + bgsize + ';' ); }
[ "function", "(", "name", ",", "rtl", ",", "overridePath", ",", "overrideOffset", ",", "overrideBgsize", ")", "{", "var", "icon", ",", "path", ",", "offset", ",", "bgsize", ";", "if", "(", "name", ")", "{", "name", "=", "name", ".", "toLowerCase", "(", ")", ";", "if", "(", "rtl", ")", "icon", "=", "this", ".", "icons", "[", "name", "+", "'-rtl'", "]", ";", "if", "(", "!", "icon", ")", "icon", "=", "this", ".", "icons", "[", "name", "]", ";", "}", "path", "=", "overridePath", "||", "(", "icon", "&&", "icon", ".", "path", ")", "||", "''", ";", "offset", "=", "overrideOffset", "||", "(", "icon", "&&", "icon", ".", "offset", ")", ";", "bgsize", "=", "overrideBgsize", "||", "(", "icon", "&&", "icon", ".", "bgsize", ")", "||", "'16px'", ";", "return", "path", "&&", "(", "'background-image:url('", "+", "CKEDITOR", ".", "getUrl", "(", "path", ")", "+", "');background-position:0 '", "+", "offset", "+", "'px;background-size:'", "+", "bgsize", "+", "';'", ")", ";", "}" ]
Gets the CSS background styles to be used to render a specific icon. @param {String} name The icon name, as registered with {@link #addIcon}. @param {Boolean} [rtl] Indicates that the RTL version of the icon is to be used, if available. @param {String} [overridePath] The path to the icon image file. It overrides the path defined by the named icon, if available, and is used if the named icon was not registered. @param {Number} [overrideOffset] The vertical offset position of the icon. It overrides the offset defined by the named icon, if available, and is used if the named icon was not registered. @param {String} [overrideBgsize] The value of the CSS "background-size" property to use for the icon. It overrides the value defined by the named icon, if available, and is used if the named icon was not registered.
[ "Gets", "the", "CSS", "background", "styles", "to", "be", "used", "to", "render", "a", "specific", "icon", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/core/skin.js#L110-L130
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (LazyValue, Bounce) { var nu = function (baseFn) { var get = function(callback) { baseFn(Bounce.bounce(callback)); }; /** map :: this Future a -> (a -> b) -> Future b */ var map = function (fab) { return nu(function (callback) { get(function (a) { var value = fab(a); callback(value); }); }); }; /** bind :: this Future a -> (a -> Future b) -> Future b */ var bind = function (aFutureB) { return nu(function (callback) { get(function (a) { aFutureB(a).get(callback); }); }); }; /** anonBind :: this Future a -> Future b -> Future b * Returns a future, which evaluates the first future, ignores the result, then evaluates the second. */ var anonBind = function (futureB) { return nu(function (callback) { get(function (a) { futureB.get(callback); }); }); }; var toLazy = function () { return LazyValue.nu(get); }; return { map: map, bind: bind, anonBind: anonBind, toLazy: toLazy, get: get }; }; /** a -> Future a */ var pure = function (a) { return nu(function (callback) { callback(a); }); }; return { nu: nu, pure: pure }; }
javascript
function (LazyValue, Bounce) { var nu = function (baseFn) { var get = function(callback) { baseFn(Bounce.bounce(callback)); }; /** map :: this Future a -> (a -> b) -> Future b */ var map = function (fab) { return nu(function (callback) { get(function (a) { var value = fab(a); callback(value); }); }); }; /** bind :: this Future a -> (a -> Future b) -> Future b */ var bind = function (aFutureB) { return nu(function (callback) { get(function (a) { aFutureB(a).get(callback); }); }); }; /** anonBind :: this Future a -> Future b -> Future b * Returns a future, which evaluates the first future, ignores the result, then evaluates the second. */ var anonBind = function (futureB) { return nu(function (callback) { get(function (a) { futureB.get(callback); }); }); }; var toLazy = function () { return LazyValue.nu(get); }; return { map: map, bind: bind, anonBind: anonBind, toLazy: toLazy, get: get }; }; /** a -> Future a */ var pure = function (a) { return nu(function (callback) { callback(a); }); }; return { nu: nu, pure: pure }; }
[ "function", "(", "LazyValue", ",", "Bounce", ")", "{", "var", "nu", "=", "function", "(", "baseFn", ")", "{", "var", "get", "=", "function", "(", "callback", ")", "{", "baseFn", "(", "Bounce", ".", "bounce", "(", "callback", ")", ")", ";", "}", ";", "var", "map", "=", "function", "(", "fab", ")", "{", "return", "nu", "(", "function", "(", "callback", ")", "{", "get", "(", "function", "(", "a", ")", "{", "var", "value", "=", "fab", "(", "a", ")", ";", "callback", "(", "value", ")", ";", "}", ")", ";", "}", ")", ";", "}", ";", "var", "bind", "=", "function", "(", "aFutureB", ")", "{", "return", "nu", "(", "function", "(", "callback", ")", "{", "get", "(", "function", "(", "a", ")", "{", "aFutureB", "(", "a", ")", ".", "get", "(", "callback", ")", ";", "}", ")", ";", "}", ")", ";", "}", ";", "var", "anonBind", "=", "function", "(", "futureB", ")", "{", "return", "nu", "(", "function", "(", "callback", ")", "{", "get", "(", "function", "(", "a", ")", "{", "futureB", ".", "get", "(", "callback", ")", ";", "}", ")", ";", "}", ")", ";", "}", ";", "var", "toLazy", "=", "function", "(", ")", "{", "return", "LazyValue", ".", "nu", "(", "get", ")", ";", "}", ";", "return", "{", "map", ":", "map", ",", "bind", ":", "bind", ",", "anonBind", ":", "anonBind", ",", "toLazy", ":", "toLazy", ",", "get", ":", "get", "}", ";", "}", ";", "var", "pure", "=", "function", "(", "a", ")", "{", "return", "nu", "(", "function", "(", "callback", ")", "{", "callback", "(", "a", ")", ";", "}", ")", ";", "}", ";", "return", "{", "nu", ":", "nu", ",", "pure", ":", "pure", "}", ";", "}" ]
A future value that is evaluated on demand. The base function is re-evaluated each time 'get' is called.
[ "A", "future", "value", "that", "is", "evaluated", "on", "demand", ".", "The", "base", "function", "is", "re", "-", "evaluated", "each", "time", "get", "is", "called", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L7181-L7242
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (elm, rootElm) { var self = this, x = 0, y = 0, offsetParent, doc = self.doc, body = doc.body, pos; elm = self.get(elm); rootElm = rootElm || body; if (elm) { // Use getBoundingClientRect if it exists since it's faster than looping offset nodes // Fallback to offsetParent calculations if the body isn't static better since it stops at the body root if (rootElm === body && elm.getBoundingClientRect && DomQuery(body).css('position') === 'static') { pos = elm.getBoundingClientRect(); rootElm = self.boxModel ? doc.documentElement : body; // Add scroll offsets from documentElement or body since IE with the wrong box model will use d.body and so do WebKit // Also remove the body/documentelement clientTop/clientLeft on IE 6, 7 since they offset the position x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - rootElm.clientLeft; y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - rootElm.clientTop; return { x: x, y: y }; } offsetParent = elm; while (offsetParent && offsetParent != rootElm && offsetParent.nodeType) { x += offsetParent.offsetLeft || 0; y += offsetParent.offsetTop || 0; offsetParent = offsetParent.offsetParent; } offsetParent = elm.parentNode; while (offsetParent && offsetParent != rootElm && offsetParent.nodeType) { x -= offsetParent.scrollLeft || 0; y -= offsetParent.scrollTop || 0; offsetParent = offsetParent.parentNode; } } return { x: x, y: y }; }
javascript
function (elm, rootElm) { var self = this, x = 0, y = 0, offsetParent, doc = self.doc, body = doc.body, pos; elm = self.get(elm); rootElm = rootElm || body; if (elm) { // Use getBoundingClientRect if it exists since it's faster than looping offset nodes // Fallback to offsetParent calculations if the body isn't static better since it stops at the body root if (rootElm === body && elm.getBoundingClientRect && DomQuery(body).css('position') === 'static') { pos = elm.getBoundingClientRect(); rootElm = self.boxModel ? doc.documentElement : body; // Add scroll offsets from documentElement or body since IE with the wrong box model will use d.body and so do WebKit // Also remove the body/documentelement clientTop/clientLeft on IE 6, 7 since they offset the position x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - rootElm.clientLeft; y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - rootElm.clientTop; return { x: x, y: y }; } offsetParent = elm; while (offsetParent && offsetParent != rootElm && offsetParent.nodeType) { x += offsetParent.offsetLeft || 0; y += offsetParent.offsetTop || 0; offsetParent = offsetParent.offsetParent; } offsetParent = elm.parentNode; while (offsetParent && offsetParent != rootElm && offsetParent.nodeType) { x -= offsetParent.scrollLeft || 0; y -= offsetParent.scrollTop || 0; offsetParent = offsetParent.parentNode; } } return { x: x, y: y }; }
[ "function", "(", "elm", ",", "rootElm", ")", "{", "var", "self", "=", "this", ",", "x", "=", "0", ",", "y", "=", "0", ",", "offsetParent", ",", "doc", "=", "self", ".", "doc", ",", "body", "=", "doc", ".", "body", ",", "pos", ";", "elm", "=", "self", ".", "get", "(", "elm", ")", ";", "rootElm", "=", "rootElm", "||", "body", ";", "if", "(", "elm", ")", "{", "if", "(", "rootElm", "===", "body", "&&", "elm", ".", "getBoundingClientRect", "&&", "DomQuery", "(", "body", ")", ".", "css", "(", "'position'", ")", "===", "'static'", ")", "{", "pos", "=", "elm", ".", "getBoundingClientRect", "(", ")", ";", "rootElm", "=", "self", ".", "boxModel", "?", "doc", ".", "documentElement", ":", "body", ";", "x", "=", "pos", ".", "left", "+", "(", "doc", ".", "documentElement", ".", "scrollLeft", "||", "body", ".", "scrollLeft", ")", "-", "rootElm", ".", "clientLeft", ";", "y", "=", "pos", ".", "top", "+", "(", "doc", ".", "documentElement", ".", "scrollTop", "||", "body", ".", "scrollTop", ")", "-", "rootElm", ".", "clientTop", ";", "return", "{", "x", ":", "x", ",", "y", ":", "y", "}", ";", "}", "offsetParent", "=", "elm", ";", "while", "(", "offsetParent", "&&", "offsetParent", "!=", "rootElm", "&&", "offsetParent", ".", "nodeType", ")", "{", "x", "+=", "offsetParent", ".", "offsetLeft", "||", "0", ";", "y", "+=", "offsetParent", ".", "offsetTop", "||", "0", ";", "offsetParent", "=", "offsetParent", ".", "offsetParent", ";", "}", "offsetParent", "=", "elm", ".", "parentNode", ";", "while", "(", "offsetParent", "&&", "offsetParent", "!=", "rootElm", "&&", "offsetParent", ".", "nodeType", ")", "{", "x", "-=", "offsetParent", ".", "scrollLeft", "||", "0", ";", "y", "-=", "offsetParent", ".", "scrollTop", "||", "0", ";", "offsetParent", "=", "offsetParent", ".", "parentNode", ";", "}", "}", "return", "{", "x", ":", "x", ",", "y", ":", "y", "}", ";", "}" ]
Returns the absolute x, y position of a node. The position will be returned in an object with x, y fields. @method getPos @param {Element/String} elm HTML element or element id to get x, y position from. @param {Element} rootElm Optional root element to stop calculations at. @return {object} Absolute position of the specified element object with x, y fields.
[ "Returns", "the", "absolute", "x", "y", "position", "of", "a", "node", ".", "The", "position", "will", "be", "returned", "in", "an", "object", "with", "x", "y", "fields", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L10391-L10428
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (element) { var el = element.dom(); var defaultView = el.ownerDocument.defaultView; return Element.fromDom(defaultView); }
javascript
function (element) { var el = element.dom(); var defaultView = el.ownerDocument.defaultView; return Element.fromDom(defaultView); }
[ "function", "(", "element", ")", "{", "var", "el", "=", "element", ".", "dom", "(", ")", ";", "var", "defaultView", "=", "el", ".", "ownerDocument", ".", "defaultView", ";", "return", "Element", ".", "fromDom", "(", "defaultView", ")", ";", "}" ]
The window element associated with the element
[ "The", "window", "element", "associated", "with", "the", "element" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L16094-L16098
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (dom, selection) { var caretContainer; caretContainer = getParentCaretContainer(selection.getStart()); if (caretContainer && !dom.isEmpty(caretContainer)) { Tools.walk(caretContainer, function (node) { if (node.nodeType === 1 && node.id !== CARET_ID && !dom.isEmpty(node)) { dom.setAttrib(node, 'data-mce-bogus', null); } }, 'childNodes'); } }
javascript
function (dom, selection) { var caretContainer; caretContainer = getParentCaretContainer(selection.getStart()); if (caretContainer && !dom.isEmpty(caretContainer)) { Tools.walk(caretContainer, function (node) { if (node.nodeType === 1 && node.id !== CARET_ID && !dom.isEmpty(node)) { dom.setAttrib(node, 'data-mce-bogus', null); } }, 'childNodes'); } }
[ "function", "(", "dom", ",", "selection", ")", "{", "var", "caretContainer", ";", "caretContainer", "=", "getParentCaretContainer", "(", "selection", ".", "getStart", "(", ")", ")", ";", "if", "(", "caretContainer", "&&", "!", "dom", ".", "isEmpty", "(", "caretContainer", ")", ")", "{", "Tools", ".", "walk", "(", "caretContainer", ",", "function", "(", "node", ")", "{", "if", "(", "node", ".", "nodeType", "===", "1", "&&", "node", ".", "id", "!==", "CARET_ID", "&&", "!", "dom", ".", "isEmpty", "(", "node", ")", ")", "{", "dom", ".", "setAttrib", "(", "node", ",", "'data-mce-bogus'", ",", "null", ")", ";", "}", "}", ",", "'childNodes'", ")", ";", "}", "}" ]
Checks if the parent caret container node isn't empty if that is the case it will remove the bogus state on all children that isn't empty
[ "Checks", "if", "the", "parent", "caret", "container", "node", "isn", "t", "empty", "if", "that", "is", "the", "case", "it", "will", "remove", "the", "bogus", "state", "on", "all", "children", "that", "isn", "t", "empty" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L17568-L17579
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (node, args) { var self = this, impl, doc, oldDoc, htmlSerializer, content, rootNode; // Explorer won't clone contents of script and style and the // selected index of select elements are cleared on a clone operation. if (Env.ie && dom.select('script,style,select,map').length > 0) { content = node.innerHTML; node = node.cloneNode(false); dom.setHTML(node, content); } else { node = node.cloneNode(true); } // Nodes needs to be attached to something in WebKit/Opera // This fix will make DOM ranges and make Sizzle happy! impl = document.implementation; if (impl.createHTMLDocument) { // Create an empty HTML document doc = impl.createHTMLDocument(""); // Add the element or it's children if it's a body element to the new document each(node.nodeName == 'BODY' ? node.childNodes : [node], function (node) { doc.body.appendChild(doc.importNode(node, true)); }); // Grab first child or body element for serialization if (node.nodeName != 'BODY') { node = doc.body.firstChild; } else { node = doc.body; } // set the new document in DOMUtils so createElement etc works oldDoc = dom.doc; dom.doc = doc; } args = args || {}; args.format = args.format || 'html'; // Don't wrap content if we want selected html if (args.selection) { args.forced_root_block = ''; } // Pre process if (!args.no_events) { args.node = node; self.onPreProcess(args); } // Parse HTML content = Zwsp.trim(trim(args.getInner ? node.innerHTML : dom.getOuterHTML(node))); rootNode = htmlParser.parse(content, args); trimTrailingBr(rootNode); // Serialize HTML htmlSerializer = new Serializer(settings, schema); args.content = htmlSerializer.serialize(rootNode); // Post process if (!args.no_events) { self.onPostProcess(args); } // Restore the old document if it was changed if (oldDoc) { dom.doc = oldDoc; } args.node = null; return args.content; }
javascript
function (node, args) { var self = this, impl, doc, oldDoc, htmlSerializer, content, rootNode; // Explorer won't clone contents of script and style and the // selected index of select elements are cleared on a clone operation. if (Env.ie && dom.select('script,style,select,map').length > 0) { content = node.innerHTML; node = node.cloneNode(false); dom.setHTML(node, content); } else { node = node.cloneNode(true); } // Nodes needs to be attached to something in WebKit/Opera // This fix will make DOM ranges and make Sizzle happy! impl = document.implementation; if (impl.createHTMLDocument) { // Create an empty HTML document doc = impl.createHTMLDocument(""); // Add the element or it's children if it's a body element to the new document each(node.nodeName == 'BODY' ? node.childNodes : [node], function (node) { doc.body.appendChild(doc.importNode(node, true)); }); // Grab first child or body element for serialization if (node.nodeName != 'BODY') { node = doc.body.firstChild; } else { node = doc.body; } // set the new document in DOMUtils so createElement etc works oldDoc = dom.doc; dom.doc = doc; } args = args || {}; args.format = args.format || 'html'; // Don't wrap content if we want selected html if (args.selection) { args.forced_root_block = ''; } // Pre process if (!args.no_events) { args.node = node; self.onPreProcess(args); } // Parse HTML content = Zwsp.trim(trim(args.getInner ? node.innerHTML : dom.getOuterHTML(node))); rootNode = htmlParser.parse(content, args); trimTrailingBr(rootNode); // Serialize HTML htmlSerializer = new Serializer(settings, schema); args.content = htmlSerializer.serialize(rootNode); // Post process if (!args.no_events) { self.onPostProcess(args); } // Restore the old document if it was changed if (oldDoc) { dom.doc = oldDoc; } args.node = null; return args.content; }
[ "function", "(", "node", ",", "args", ")", "{", "var", "self", "=", "this", ",", "impl", ",", "doc", ",", "oldDoc", ",", "htmlSerializer", ",", "content", ",", "rootNode", ";", "if", "(", "Env", ".", "ie", "&&", "dom", ".", "select", "(", "'script,style,select,map'", ")", ".", "length", ">", "0", ")", "{", "content", "=", "node", ".", "innerHTML", ";", "node", "=", "node", ".", "cloneNode", "(", "false", ")", ";", "dom", ".", "setHTML", "(", "node", ",", "content", ")", ";", "}", "else", "{", "node", "=", "node", ".", "cloneNode", "(", "true", ")", ";", "}", "impl", "=", "document", ".", "implementation", ";", "if", "(", "impl", ".", "createHTMLDocument", ")", "{", "doc", "=", "impl", ".", "createHTMLDocument", "(", "\"\"", ")", ";", "each", "(", "node", ".", "nodeName", "==", "'BODY'", "?", "node", ".", "childNodes", ":", "[", "node", "]", ",", "function", "(", "node", ")", "{", "doc", ".", "body", ".", "appendChild", "(", "doc", ".", "importNode", "(", "node", ",", "true", ")", ")", ";", "}", ")", ";", "if", "(", "node", ".", "nodeName", "!=", "'BODY'", ")", "{", "node", "=", "doc", ".", "body", ".", "firstChild", ";", "}", "else", "{", "node", "=", "doc", ".", "body", ";", "}", "oldDoc", "=", "dom", ".", "doc", ";", "dom", ".", "doc", "=", "doc", ";", "}", "args", "=", "args", "||", "{", "}", ";", "args", ".", "format", "=", "args", ".", "format", "||", "'html'", ";", "if", "(", "args", ".", "selection", ")", "{", "args", ".", "forced_root_block", "=", "''", ";", "}", "if", "(", "!", "args", ".", "no_events", ")", "{", "args", ".", "node", "=", "node", ";", "self", ".", "onPreProcess", "(", "args", ")", ";", "}", "content", "=", "Zwsp", ".", "trim", "(", "trim", "(", "args", ".", "getInner", "?", "node", ".", "innerHTML", ":", "dom", ".", "getOuterHTML", "(", "node", ")", ")", ")", ";", "rootNode", "=", "htmlParser", ".", "parse", "(", "content", ",", "args", ")", ";", "trimTrailingBr", "(", "rootNode", ")", ";", "htmlSerializer", "=", "new", "Serializer", "(", "settings", ",", "schema", ")", ";", "args", ".", "content", "=", "htmlSerializer", ".", "serialize", "(", "rootNode", ")", ";", "if", "(", "!", "args", ".", "no_events", ")", "{", "self", ".", "onPostProcess", "(", "args", ")", ";", "}", "if", "(", "oldDoc", ")", "{", "dom", ".", "doc", "=", "oldDoc", ";", "}", "args", ".", "node", "=", "null", ";", "return", "args", ".", "content", ";", "}" ]
Serializes the specified browser DOM node into a HTML string. @method serialize @param {DOMNode} node DOM node to serialize. @param {Object} args Arguments option that gets passed to event handlers.
[ "Serializes", "the", "specified", "browser", "DOM", "node", "into", "a", "HTML", "string", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L23456-L23529
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (original, tag) { var nu = Element.fromTag(tag); var attributes = Attr.clone(original); Attr.setAll(nu, attributes); return nu; }
javascript
function (original, tag) { var nu = Element.fromTag(tag); var attributes = Attr.clone(original); Attr.setAll(nu, attributes); return nu; }
[ "function", "(", "original", ",", "tag", ")", "{", "var", "nu", "=", "Element", ".", "fromTag", "(", "tag", ")", ";", "var", "attributes", "=", "Attr", ".", "clone", "(", "original", ")", ";", "Attr", ".", "setAll", "(", "nu", ",", "attributes", ")", ";", "return", "nu", ";", "}" ]
Shallow clone, with a new tag
[ "Shallow", "clone", "with", "a", "new", "tag" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25059-L25066
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (original, tag) { var nu = shallowAs(original, tag); // NOTE // previously this used serialisation: // nu.dom().innerHTML = original.dom().innerHTML; // // Clone should be equivalent (and faster), but if TD <-> TH toggle breaks, put it back. var cloneChildren = Traverse.children(deep(original)); InsertAll.append(nu, cloneChildren); return nu; }
javascript
function (original, tag) { var nu = shallowAs(original, tag); // NOTE // previously this used serialisation: // nu.dom().innerHTML = original.dom().innerHTML; // // Clone should be equivalent (and faster), but if TD <-> TH toggle breaks, put it back. var cloneChildren = Traverse.children(deep(original)); InsertAll.append(nu, cloneChildren); return nu; }
[ "function", "(", "original", ",", "tag", ")", "{", "var", "nu", "=", "shallowAs", "(", "original", ",", "tag", ")", ";", "var", "cloneChildren", "=", "Traverse", ".", "children", "(", "deep", "(", "original", ")", ")", ";", "InsertAll", ".", "append", "(", "nu", ",", "cloneChildren", ")", ";", "return", "nu", ";", "}" ]
Deep clone, with a new tag
[ "Deep", "clone", "with", "a", "new", "tag" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25069-L25082
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (original, tag) { var nu = shallowAs(original, tag); Insert.before(original, nu); var children = Traverse.children(original); InsertAll.append(nu, children); Remove.remove(original); return nu; }
javascript
function (original, tag) { var nu = shallowAs(original, tag); Insert.before(original, nu); var children = Traverse.children(original); InsertAll.append(nu, children); Remove.remove(original); return nu; }
[ "function", "(", "original", ",", "tag", ")", "{", "var", "nu", "=", "shallowAs", "(", "original", ",", "tag", ")", ";", "Insert", ".", "before", "(", "original", ",", "nu", ")", ";", "var", "children", "=", "Traverse", ".", "children", "(", "original", ")", ";", "InsertAll", ".", "append", "(", "nu", ",", "children", ")", ";", "Remove", ".", "remove", "(", "original", ")", ";", "return", "nu", ";", "}" ]
Change the tag name, but keep all children
[ "Change", "the", "tag", "name", "but", "keep", "all", "children" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25085-L25093
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function(arr, f) { var r = []; for (var i = 0; i < arr.length; i++) { var x = arr[i]; if (x.isSome()) { r.push(x.getOrDie()); } else { return Option.none(); } } return Option.some(f.apply(null, r)); }
javascript
function(arr, f) { var r = []; for (var i = 0; i < arr.length; i++) { var x = arr[i]; if (x.isSome()) { r.push(x.getOrDie()); } else { return Option.none(); } } return Option.some(f.apply(null, r)); }
[ "function", "(", "arr", ",", "f", ")", "{", "var", "r", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "arr", ".", "length", ";", "i", "++", ")", "{", "var", "x", "=", "arr", "[", "i", "]", ";", "if", "(", "x", ".", "isSome", "(", ")", ")", "{", "r", ".", "push", "(", "x", ".", "getOrDie", "(", ")", ")", ";", "}", "else", "{", "return", "Option", ".", "none", "(", ")", ";", "}", "}", "return", "Option", ".", "some", "(", "f", ".", "apply", "(", "null", ",", "r", ")", ")", ";", "}" ]
if all elements in arr are 'some', their inner values are passed as arguments to f f must have arity arr.length
[ "if", "all", "elements", "in", "arr", "are", "some", "their", "inner", "values", "are", "passed", "as", "arguments", "to", "f", "f", "must", "have", "arity", "arr", ".", "length" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25213-L25224
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (args) { var self = this, rng = self.getRng(), tmpElm = self.dom.create("body"); var se = self.getSel(), whiteSpaceBefore, whiteSpaceAfter, fragment; args = args || {}; whiteSpaceBefore = whiteSpaceAfter = ''; args.get = true; args.format = args.format || 'html'; args.selection = true; self.editor.fire('BeforeGetContent', args); if (args.format === 'text') { return self.isCollapsed() ? '' : Zwsp.trim(rng.text || (se.toString ? se.toString() : '')); } if (rng.cloneContents) { fragment = args.contextual ? FragmentReader.read(self.editor.getBody(), rng).dom() : rng.cloneContents(); if (fragment) { tmpElm.appendChild(fragment); } } else if (rng.item !== undefined || rng.htmlText !== undefined) { // IE will produce invalid markup if elements are present that // it doesn't understand like custom elements or HTML5 elements. // Adding a BR in front of the contents and then remoiving it seems to fix it though. tmpElm.innerHTML = '<br>' + (rng.item ? rng.item(0).outerHTML : rng.htmlText); tmpElm.removeChild(tmpElm.firstChild); } else { tmpElm.innerHTML = rng.toString(); } // Keep whitespace before and after if (/^\s/.test(tmpElm.innerHTML)) { whiteSpaceBefore = ' '; } if (/\s+$/.test(tmpElm.innerHTML)) { whiteSpaceAfter = ' '; } args.getInner = true; args.content = self.isCollapsed() ? '' : whiteSpaceBefore + self.serializer.serialize(tmpElm, args) + whiteSpaceAfter; self.editor.fire('GetContent', args); return args.content; }
javascript
function (args) { var self = this, rng = self.getRng(), tmpElm = self.dom.create("body"); var se = self.getSel(), whiteSpaceBefore, whiteSpaceAfter, fragment; args = args || {}; whiteSpaceBefore = whiteSpaceAfter = ''; args.get = true; args.format = args.format || 'html'; args.selection = true; self.editor.fire('BeforeGetContent', args); if (args.format === 'text') { return self.isCollapsed() ? '' : Zwsp.trim(rng.text || (se.toString ? se.toString() : '')); } if (rng.cloneContents) { fragment = args.contextual ? FragmentReader.read(self.editor.getBody(), rng).dom() : rng.cloneContents(); if (fragment) { tmpElm.appendChild(fragment); } } else if (rng.item !== undefined || rng.htmlText !== undefined) { // IE will produce invalid markup if elements are present that // it doesn't understand like custom elements or HTML5 elements. // Adding a BR in front of the contents and then remoiving it seems to fix it though. tmpElm.innerHTML = '<br>' + (rng.item ? rng.item(0).outerHTML : rng.htmlText); tmpElm.removeChild(tmpElm.firstChild); } else { tmpElm.innerHTML = rng.toString(); } // Keep whitespace before and after if (/^\s/.test(tmpElm.innerHTML)) { whiteSpaceBefore = ' '; } if (/\s+$/.test(tmpElm.innerHTML)) { whiteSpaceAfter = ' '; } args.getInner = true; args.content = self.isCollapsed() ? '' : whiteSpaceBefore + self.serializer.serialize(tmpElm, args) + whiteSpaceAfter; self.editor.fire('GetContent', args); return args.content; }
[ "function", "(", "args", ")", "{", "var", "self", "=", "this", ",", "rng", "=", "self", ".", "getRng", "(", ")", ",", "tmpElm", "=", "self", ".", "dom", ".", "create", "(", "\"body\"", ")", ";", "var", "se", "=", "self", ".", "getSel", "(", ")", ",", "whiteSpaceBefore", ",", "whiteSpaceAfter", ",", "fragment", ";", "args", "=", "args", "||", "{", "}", ";", "whiteSpaceBefore", "=", "whiteSpaceAfter", "=", "''", ";", "args", ".", "get", "=", "true", ";", "args", ".", "format", "=", "args", ".", "format", "||", "'html'", ";", "args", ".", "selection", "=", "true", ";", "self", ".", "editor", ".", "fire", "(", "'BeforeGetContent'", ",", "args", ")", ";", "if", "(", "args", ".", "format", "===", "'text'", ")", "{", "return", "self", ".", "isCollapsed", "(", ")", "?", "''", ":", "Zwsp", ".", "trim", "(", "rng", ".", "text", "||", "(", "se", ".", "toString", "?", "se", ".", "toString", "(", ")", ":", "''", ")", ")", ";", "}", "if", "(", "rng", ".", "cloneContents", ")", "{", "fragment", "=", "args", ".", "contextual", "?", "FragmentReader", ".", "read", "(", "self", ".", "editor", ".", "getBody", "(", ")", ",", "rng", ")", ".", "dom", "(", ")", ":", "rng", ".", "cloneContents", "(", ")", ";", "if", "(", "fragment", ")", "{", "tmpElm", ".", "appendChild", "(", "fragment", ")", ";", "}", "}", "else", "if", "(", "rng", ".", "item", "!==", "undefined", "||", "rng", ".", "htmlText", "!==", "undefined", ")", "{", "tmpElm", ".", "innerHTML", "=", "'<br>'", "+", "(", "rng", ".", "item", "?", "rng", ".", "item", "(", "0", ")", ".", "outerHTML", ":", "rng", ".", "htmlText", ")", ";", "tmpElm", ".", "removeChild", "(", "tmpElm", ".", "firstChild", ")", ";", "}", "else", "{", "tmpElm", ".", "innerHTML", "=", "rng", ".", "toString", "(", ")", ";", "}", "if", "(", "/", "^\\s", "/", ".", "test", "(", "tmpElm", ".", "innerHTML", ")", ")", "{", "whiteSpaceBefore", "=", "' '", ";", "}", "if", "(", "/", "\\s+$", "/", ".", "test", "(", "tmpElm", ".", "innerHTML", ")", ")", "{", "whiteSpaceAfter", "=", "' '", ";", "}", "args", ".", "getInner", "=", "true", ";", "args", ".", "content", "=", "self", ".", "isCollapsed", "(", ")", "?", "''", ":", "whiteSpaceBefore", "+", "self", ".", "serializer", ".", "serialize", "(", "tmpElm", ",", "args", ")", "+", "whiteSpaceAfter", ";", "self", ".", "editor", ".", "fire", "(", "'GetContent'", ",", "args", ")", ";", "return", "args", ".", "content", ";", "}" ]
Returns the selected contents using the DOM serializer passed in to this class. @method getContent @param {Object} args Optional settings class with for example output format text or html. @return {String} Selected contents in for example HTML format. @example // Alerts the currently selected contents alert(tinymce.activeEditor.selection.getContent()); // Alerts the currently selected contents as plain text alert(tinymce.activeEditor.selection.getContent({format: 'text'}));
[ "Returns", "the", "selected", "contents", "using", "the", "DOM", "serializer", "passed", "in", "to", "this", "class", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L25512-L25557
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (rng, forward) { var self = this, sel, node, evt; if (!isValidRange(rng)) { return; } // Is IE specific range if (rng.select) { self.explicitRange = null; try { rng.select(); } catch (ex) { // Needed for some odd IE bug #1843306 } return; } if (!self.tridentSel) { sel = self.getSel(); evt = self.editor.fire('SetSelectionRange', { range: rng, forward: forward }); rng = evt.range; if (sel) { self.explicitRange = rng; try { sel.removeAllRanges(); sel.addRange(rng); } catch (ex) { // IE might throw errors here if the editor is within a hidden container and selection is changed } // Forward is set to false and we have an extend function if (forward === false && sel.extend) { sel.collapse(rng.endContainer, rng.endOffset); sel.extend(rng.startContainer, rng.startOffset); } // adding range isn't always successful so we need to check range count otherwise an exception can occur self.selectedRange = sel.rangeCount > 0 ? sel.getRangeAt(0) : null; } // WebKit egde case selecting images works better using setBaseAndExtent when the image is floated if (!rng.collapsed && rng.startContainer === rng.endContainer && sel.setBaseAndExtent && !Env.ie) { if (rng.endOffset - rng.startOffset < 2) { if (rng.startContainer.hasChildNodes()) { node = rng.startContainer.childNodes[rng.startOffset]; if (node && node.tagName === 'IMG') { sel.setBaseAndExtent( rng.startContainer, rng.startOffset, rng.endContainer, rng.endOffset ); // Since the setBaseAndExtent is fixed in more recent Blink versions we // need to detect if it's doing the wrong thing and falling back to the // crazy incorrect behavior api call since that seems to be the only way // to get it to work on Safari WebKit as of 2017-02-23 if (sel.anchorNode !== rng.startContainer || sel.focusNode !== rng.endContainer) { sel.setBaseAndExtent(node, 0, node, 1); } } } } } self.editor.fire('AfterSetSelectionRange', { range: rng, forward: forward }); } else { // Is W3C Range fake range on IE if (rng.cloneRange) { try { self.tridentSel.addRange(rng); } catch (ex) { //IE9 throws an error here if called before selection is placed in the editor } } } }
javascript
function (rng, forward) { var self = this, sel, node, evt; if (!isValidRange(rng)) { return; } // Is IE specific range if (rng.select) { self.explicitRange = null; try { rng.select(); } catch (ex) { // Needed for some odd IE bug #1843306 } return; } if (!self.tridentSel) { sel = self.getSel(); evt = self.editor.fire('SetSelectionRange', { range: rng, forward: forward }); rng = evt.range; if (sel) { self.explicitRange = rng; try { sel.removeAllRanges(); sel.addRange(rng); } catch (ex) { // IE might throw errors here if the editor is within a hidden container and selection is changed } // Forward is set to false and we have an extend function if (forward === false && sel.extend) { sel.collapse(rng.endContainer, rng.endOffset); sel.extend(rng.startContainer, rng.startOffset); } // adding range isn't always successful so we need to check range count otherwise an exception can occur self.selectedRange = sel.rangeCount > 0 ? sel.getRangeAt(0) : null; } // WebKit egde case selecting images works better using setBaseAndExtent when the image is floated if (!rng.collapsed && rng.startContainer === rng.endContainer && sel.setBaseAndExtent && !Env.ie) { if (rng.endOffset - rng.startOffset < 2) { if (rng.startContainer.hasChildNodes()) { node = rng.startContainer.childNodes[rng.startOffset]; if (node && node.tagName === 'IMG') { sel.setBaseAndExtent( rng.startContainer, rng.startOffset, rng.endContainer, rng.endOffset ); // Since the setBaseAndExtent is fixed in more recent Blink versions we // need to detect if it's doing the wrong thing and falling back to the // crazy incorrect behavior api call since that seems to be the only way // to get it to work on Safari WebKit as of 2017-02-23 if (sel.anchorNode !== rng.startContainer || sel.focusNode !== rng.endContainer) { sel.setBaseAndExtent(node, 0, node, 1); } } } } } self.editor.fire('AfterSetSelectionRange', { range: rng, forward: forward }); } else { // Is W3C Range fake range on IE if (rng.cloneRange) { try { self.tridentSel.addRange(rng); } catch (ex) { //IE9 throws an error here if called before selection is placed in the editor } } } }
[ "function", "(", "rng", ",", "forward", ")", "{", "var", "self", "=", "this", ",", "sel", ",", "node", ",", "evt", ";", "if", "(", "!", "isValidRange", "(", "rng", ")", ")", "{", "return", ";", "}", "if", "(", "rng", ".", "select", ")", "{", "self", ".", "explicitRange", "=", "null", ";", "try", "{", "rng", ".", "select", "(", ")", ";", "}", "catch", "(", "ex", ")", "{", "}", "return", ";", "}", "if", "(", "!", "self", ".", "tridentSel", ")", "{", "sel", "=", "self", ".", "getSel", "(", ")", ";", "evt", "=", "self", ".", "editor", ".", "fire", "(", "'SetSelectionRange'", ",", "{", "range", ":", "rng", ",", "forward", ":", "forward", "}", ")", ";", "rng", "=", "evt", ".", "range", ";", "if", "(", "sel", ")", "{", "self", ".", "explicitRange", "=", "rng", ";", "try", "{", "sel", ".", "removeAllRanges", "(", ")", ";", "sel", ".", "addRange", "(", "rng", ")", ";", "}", "catch", "(", "ex", ")", "{", "}", "if", "(", "forward", "===", "false", "&&", "sel", ".", "extend", ")", "{", "sel", ".", "collapse", "(", "rng", ".", "endContainer", ",", "rng", ".", "endOffset", ")", ";", "sel", ".", "extend", "(", "rng", ".", "startContainer", ",", "rng", ".", "startOffset", ")", ";", "}", "self", ".", "selectedRange", "=", "sel", ".", "rangeCount", ">", "0", "?", "sel", ".", "getRangeAt", "(", "0", ")", ":", "null", ";", "}", "if", "(", "!", "rng", ".", "collapsed", "&&", "rng", ".", "startContainer", "===", "rng", ".", "endContainer", "&&", "sel", ".", "setBaseAndExtent", "&&", "!", "Env", ".", "ie", ")", "{", "if", "(", "rng", ".", "endOffset", "-", "rng", ".", "startOffset", "<", "2", ")", "{", "if", "(", "rng", ".", "startContainer", ".", "hasChildNodes", "(", ")", ")", "{", "node", "=", "rng", ".", "startContainer", ".", "childNodes", "[", "rng", ".", "startOffset", "]", ";", "if", "(", "node", "&&", "node", ".", "tagName", "===", "'IMG'", ")", "{", "sel", ".", "setBaseAndExtent", "(", "rng", ".", "startContainer", ",", "rng", ".", "startOffset", ",", "rng", ".", "endContainer", ",", "rng", ".", "endOffset", ")", ";", "if", "(", "sel", ".", "anchorNode", "!==", "rng", ".", "startContainer", "||", "sel", ".", "focusNode", "!==", "rng", ".", "endContainer", ")", "{", "sel", ".", "setBaseAndExtent", "(", "node", ",", "0", ",", "node", ",", "1", ")", ";", "}", "}", "}", "}", "}", "self", ".", "editor", ".", "fire", "(", "'AfterSetSelectionRange'", ",", "{", "range", ":", "rng", ",", "forward", ":", "forward", "}", ")", ";", "}", "else", "{", "if", "(", "rng", ".", "cloneRange", ")", "{", "try", "{", "self", ".", "tridentSel", ".", "addRange", "(", "rng", ")", ";", "}", "catch", "(", "ex", ")", "{", "}", "}", "}", "}" ]
Changes the selection to the specified DOM range. @method setRng @param {Range} rng Range to select. @param {Boolean} forward Optional boolean if the selection is forwards or backwards.
[ "Changes", "the", "selection", "to", "the", "specified", "DOM", "range", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L26013-L26095
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function () { var level; if (self.typing) { self.add(); self.typing = false; setTyping(false); } if (index > 0) { level = data[--index]; Levels.applyToEditor(editor, level, true); setDirty(true); editor.fire('undo', { level: level }); } return level; }
javascript
function () { var level; if (self.typing) { self.add(); self.typing = false; setTyping(false); } if (index > 0) { level = data[--index]; Levels.applyToEditor(editor, level, true); setDirty(true); editor.fire('undo', { level: level }); } return level; }
[ "function", "(", ")", "{", "var", "level", ";", "if", "(", "self", ".", "typing", ")", "{", "self", ".", "add", "(", ")", ";", "self", ".", "typing", "=", "false", ";", "setTyping", "(", "false", ")", ";", "}", "if", "(", "index", ">", "0", ")", "{", "level", "=", "data", "[", "--", "index", "]", ";", "Levels", ".", "applyToEditor", "(", "editor", ",", "level", ",", "true", ")", ";", "setDirty", "(", "true", ")", ";", "editor", ".", "fire", "(", "'undo'", ",", "{", "level", ":", "level", "}", ")", ";", "}", "return", "level", ";", "}" ]
Undoes the last action. @method undo @return {Object} Undo level or null if no undo was performed.
[ "Undoes", "the", "last", "action", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L27014-L27031
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (elm, afterDeletePosOpt) { return Options.liftN([Traverse.prevSibling(elm), Traverse.nextSibling(elm), afterDeletePosOpt], function (prev, next, afterDeletePos) { var offset, prevNode = prev.dom(), nextNode = next.dom(); if (NodeType.isText(prevNode) && NodeType.isText(nextNode)) { offset = prevNode.data.length; prevNode.appendData(nextNode.data); Remove.remove(next); Remove.remove(elm); if (afterDeletePos.container() === nextNode) { return new CaretPosition(prevNode, offset); } else { return afterDeletePos; } } else { Remove.remove(elm); return afterDeletePos; } }).orThunk(function () { Remove.remove(elm); return afterDeletePosOpt; }); }
javascript
function (elm, afterDeletePosOpt) { return Options.liftN([Traverse.prevSibling(elm), Traverse.nextSibling(elm), afterDeletePosOpt], function (prev, next, afterDeletePos) { var offset, prevNode = prev.dom(), nextNode = next.dom(); if (NodeType.isText(prevNode) && NodeType.isText(nextNode)) { offset = prevNode.data.length; prevNode.appendData(nextNode.data); Remove.remove(next); Remove.remove(elm); if (afterDeletePos.container() === nextNode) { return new CaretPosition(prevNode, offset); } else { return afterDeletePos; } } else { Remove.remove(elm); return afterDeletePos; } }).orThunk(function () { Remove.remove(elm); return afterDeletePosOpt; }); }
[ "function", "(", "elm", ",", "afterDeletePosOpt", ")", "{", "return", "Options", ".", "liftN", "(", "[", "Traverse", ".", "prevSibling", "(", "elm", ")", ",", "Traverse", ".", "nextSibling", "(", "elm", ")", ",", "afterDeletePosOpt", "]", ",", "function", "(", "prev", ",", "next", ",", "afterDeletePos", ")", "{", "var", "offset", ",", "prevNode", "=", "prev", ".", "dom", "(", ")", ",", "nextNode", "=", "next", ".", "dom", "(", ")", ";", "if", "(", "NodeType", ".", "isText", "(", "prevNode", ")", "&&", "NodeType", ".", "isText", "(", "nextNode", ")", ")", "{", "offset", "=", "prevNode", ".", "data", ".", "length", ";", "prevNode", ".", "appendData", "(", "nextNode", ".", "data", ")", ";", "Remove", ".", "remove", "(", "next", ")", ";", "Remove", ".", "remove", "(", "elm", ")", ";", "if", "(", "afterDeletePos", ".", "container", "(", ")", "===", "nextNode", ")", "{", "return", "new", "CaretPosition", "(", "prevNode", ",", "offset", ")", ";", "}", "else", "{", "return", "afterDeletePos", ";", "}", "}", "else", "{", "Remove", ".", "remove", "(", "elm", ")", ";", "return", "afterDeletePos", ";", "}", "}", ")", ".", "orThunk", "(", "function", "(", ")", "{", "Remove", ".", "remove", "(", "elm", ")", ";", "return", "afterDeletePosOpt", ";", "}", ")", ";", "}" ]
When deleting an element between two text nodes IE 11 doesn't automatically merge the adjacent text nodes
[ "When", "deleting", "an", "element", "between", "two", "text", "nodes", "IE", "11", "doesn", "t", "automatically", "merge", "the", "adjacent", "text", "nodes" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L28148-L28170
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
queryCommandValue
function queryCommandValue(command) { var func; if (editor.quirks.isHidden() || editor.removed) { return; } command = command.toLowerCase(); if ((func = commands.value[command])) { return func(command); } // Browser commands try { return editor.getDoc().queryCommandValue(command); } catch (ex) { // Fails sometimes see bug: 1896577 } }
javascript
function queryCommandValue(command) { var func; if (editor.quirks.isHidden() || editor.removed) { return; } command = command.toLowerCase(); if ((func = commands.value[command])) { return func(command); } // Browser commands try { return editor.getDoc().queryCommandValue(command); } catch (ex) { // Fails sometimes see bug: 1896577 } }
[ "function", "queryCommandValue", "(", "command", ")", "{", "var", "func", ";", "if", "(", "editor", ".", "quirks", ".", "isHidden", "(", ")", "||", "editor", ".", "removed", ")", "{", "return", ";", "}", "command", "=", "command", ".", "toLowerCase", "(", ")", ";", "if", "(", "(", "func", "=", "commands", ".", "value", "[", "command", "]", ")", ")", "{", "return", "func", "(", "command", ")", ";", "}", "try", "{", "return", "editor", ".", "getDoc", "(", ")", ".", "queryCommandValue", "(", "command", ")", ";", "}", "catch", "(", "ex", ")", "{", "}", "}" ]
Queries the command value for example the current fontsize. @method queryCommandValue @param {String} command Command to check the value of. @return {Object} Command value of false if it's not found.
[ "Queries", "the", "command", "value", "for", "example", "the", "current", "fontsize", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L30131-L30149
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (dom, node) { return node && dom.isBlock(node) && !/^(TD|TH|CAPTION|FORM)$/.test(node.nodeName) && !/^(fixed|absolute)/i.test(node.style.position) && dom.getContentEditable(node) !== "true"; }
javascript
function (dom, node) { return node && dom.isBlock(node) && !/^(TD|TH|CAPTION|FORM)$/.test(node.nodeName) && !/^(fixed|absolute)/i.test(node.style.position) && dom.getContentEditable(node) !== "true"; }
[ "function", "(", "dom", ",", "node", ")", "{", "return", "node", "&&", "dom", ".", "isBlock", "(", "node", ")", "&&", "!", "/", "^(TD|TH|CAPTION|FORM)$", "/", ".", "test", "(", "node", ".", "nodeName", ")", "&&", "!", "/", "^(fixed|absolute)", "/", "i", ".", "test", "(", "node", ".", "style", ".", "position", ")", "&&", "dom", ".", "getContentEditable", "(", "node", ")", "!==", "\"true\"", ";", "}" ]
Returns true if the block can be split into two blocks or not
[ "Returns", "true", "if", "the", "block", "can", "be", "split", "into", "two", "blocks", "or", "not" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L41209-L41215
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
moveToCaretPosition
function moveToCaretPosition(root) { var walker, node, rng, lastNode = root, tempElm; if (!root) { return; } // Old IE versions doesn't properly render blocks with br elements in them // For example <p><br></p> wont be rendered correctly in a contentEditable area // until you remove the br producing <p></p> if (Env.ie && Env.ie < 9 && parentBlock && parentBlock.firstChild) { if (parentBlock.firstChild == parentBlock.lastChild && parentBlock.firstChild.tagName == 'BR') { dom.remove(parentBlock.firstChild); } } if (/^(LI|DT|DD)$/.test(root.nodeName)) { var firstChild = firstNonWhiteSpaceNodeSibling(root.firstChild); if (firstChild && /^(UL|OL|DL)$/.test(firstChild.nodeName)) { root.insertBefore(dom.doc.createTextNode('\u00a0'), root.firstChild); } } rng = dom.createRng(); // Normalize whitespace to remove empty text nodes. Fix for: #6904 // Gecko will be able to place the caret in empty text nodes but it won't render propery // Older IE versions will sometimes crash so for now ignore all IE versions if (!Env.ie) { root.normalize(); } if (root.hasChildNodes()) { walker = new TreeWalker(root, root); while ((node = walker.current())) { if (node.nodeType == 3) { rng.setStart(node, 0); rng.setEnd(node, 0); break; } if (moveCaretBeforeOnEnterElementsMap[node.nodeName.toLowerCase()]) { rng.setStartBefore(node); rng.setEndBefore(node); break; } lastNode = node; node = walker.next(); } if (!node) { rng.setStart(lastNode, 0); rng.setEnd(lastNode, 0); } } else { if (root.nodeName == 'BR') { if (root.nextSibling && dom.isBlock(root.nextSibling)) { // Trick on older IE versions to render the caret before the BR between two lists if (!documentMode || documentMode < 9) { tempElm = dom.create('br'); root.parentNode.insertBefore(tempElm, root); } rng.setStartBefore(root); rng.setEndBefore(root); } else { rng.setStartAfter(root); rng.setEndAfter(root); } } else { rng.setStart(root, 0); rng.setEnd(root, 0); } } selection.setRng(rng); // Remove tempElm created for old IE:s dom.remove(tempElm); selection.scrollIntoView(root); }
javascript
function moveToCaretPosition(root) { var walker, node, rng, lastNode = root, tempElm; if (!root) { return; } // Old IE versions doesn't properly render blocks with br elements in them // For example <p><br></p> wont be rendered correctly in a contentEditable area // until you remove the br producing <p></p> if (Env.ie && Env.ie < 9 && parentBlock && parentBlock.firstChild) { if (parentBlock.firstChild == parentBlock.lastChild && parentBlock.firstChild.tagName == 'BR') { dom.remove(parentBlock.firstChild); } } if (/^(LI|DT|DD)$/.test(root.nodeName)) { var firstChild = firstNonWhiteSpaceNodeSibling(root.firstChild); if (firstChild && /^(UL|OL|DL)$/.test(firstChild.nodeName)) { root.insertBefore(dom.doc.createTextNode('\u00a0'), root.firstChild); } } rng = dom.createRng(); // Normalize whitespace to remove empty text nodes. Fix for: #6904 // Gecko will be able to place the caret in empty text nodes but it won't render propery // Older IE versions will sometimes crash so for now ignore all IE versions if (!Env.ie) { root.normalize(); } if (root.hasChildNodes()) { walker = new TreeWalker(root, root); while ((node = walker.current())) { if (node.nodeType == 3) { rng.setStart(node, 0); rng.setEnd(node, 0); break; } if (moveCaretBeforeOnEnterElementsMap[node.nodeName.toLowerCase()]) { rng.setStartBefore(node); rng.setEndBefore(node); break; } lastNode = node; node = walker.next(); } if (!node) { rng.setStart(lastNode, 0); rng.setEnd(lastNode, 0); } } else { if (root.nodeName == 'BR') { if (root.nextSibling && dom.isBlock(root.nextSibling)) { // Trick on older IE versions to render the caret before the BR between two lists if (!documentMode || documentMode < 9) { tempElm = dom.create('br'); root.parentNode.insertBefore(tempElm, root); } rng.setStartBefore(root); rng.setEndBefore(root); } else { rng.setStartAfter(root); rng.setEndAfter(root); } } else { rng.setStart(root, 0); rng.setEnd(root, 0); } } selection.setRng(rng); // Remove tempElm created for old IE:s dom.remove(tempElm); selection.scrollIntoView(root); }
[ "function", "moveToCaretPosition", "(", "root", ")", "{", "var", "walker", ",", "node", ",", "rng", ",", "lastNode", "=", "root", ",", "tempElm", ";", "if", "(", "!", "root", ")", "{", "return", ";", "}", "if", "(", "Env", ".", "ie", "&&", "Env", ".", "ie", "<", "9", "&&", "parentBlock", "&&", "parentBlock", ".", "firstChild", ")", "{", "if", "(", "parentBlock", ".", "firstChild", "==", "parentBlock", ".", "lastChild", "&&", "parentBlock", ".", "firstChild", ".", "tagName", "==", "'BR'", ")", "{", "dom", ".", "remove", "(", "parentBlock", ".", "firstChild", ")", ";", "}", "}", "if", "(", "/", "^(LI|DT|DD)$", "/", ".", "test", "(", "root", ".", "nodeName", ")", ")", "{", "var", "firstChild", "=", "firstNonWhiteSpaceNodeSibling", "(", "root", ".", "firstChild", ")", ";", "if", "(", "firstChild", "&&", "/", "^(UL|OL|DL)$", "/", ".", "test", "(", "firstChild", ".", "nodeName", ")", ")", "{", "root", ".", "insertBefore", "(", "dom", ".", "doc", ".", "createTextNode", "(", "'\\u00a0'", ")", ",", "\\u00a0", ")", ";", "}", "}", "root", ".", "firstChild", "rng", "=", "dom", ".", "createRng", "(", ")", ";", "if", "(", "!", "Env", ".", "ie", ")", "{", "root", ".", "normalize", "(", ")", ";", "}", "if", "(", "root", ".", "hasChildNodes", "(", ")", ")", "{", "walker", "=", "new", "TreeWalker", "(", "root", ",", "root", ")", ";", "while", "(", "(", "node", "=", "walker", ".", "current", "(", ")", ")", ")", "{", "if", "(", "node", ".", "nodeType", "==", "3", ")", "{", "rng", ".", "setStart", "(", "node", ",", "0", ")", ";", "rng", ".", "setEnd", "(", "node", ",", "0", ")", ";", "break", ";", "}", "if", "(", "moveCaretBeforeOnEnterElementsMap", "[", "node", ".", "nodeName", ".", "toLowerCase", "(", ")", "]", ")", "{", "rng", ".", "setStartBefore", "(", "node", ")", ";", "rng", ".", "setEndBefore", "(", "node", ")", ";", "break", ";", "}", "lastNode", "=", "node", ";", "node", "=", "walker", ".", "next", "(", ")", ";", "}", "if", "(", "!", "node", ")", "{", "rng", ".", "setStart", "(", "lastNode", ",", "0", ")", ";", "rng", ".", "setEnd", "(", "lastNode", ",", "0", ")", ";", "}", "}", "else", "{", "if", "(", "root", ".", "nodeName", "==", "'BR'", ")", "{", "if", "(", "root", ".", "nextSibling", "&&", "dom", ".", "isBlock", "(", "root", ".", "nextSibling", ")", ")", "{", "if", "(", "!", "documentMode", "||", "documentMode", "<", "9", ")", "{", "tempElm", "=", "dom", ".", "create", "(", "'br'", ")", ";", "root", ".", "parentNode", ".", "insertBefore", "(", "tempElm", ",", "root", ")", ";", "}", "rng", ".", "setStartBefore", "(", "root", ")", ";", "rng", ".", "setEndBefore", "(", "root", ")", ";", "}", "else", "{", "rng", ".", "setStartAfter", "(", "root", ")", ";", "rng", ".", "setEndAfter", "(", "root", ")", ";", "}", "}", "else", "{", "rng", ".", "setStart", "(", "root", ",", "0", ")", ";", "rng", ".", "setEnd", "(", "root", ",", "0", ")", ";", "}", "}", "selection", ".", "setRng", "(", "rng", ")", ";", "dom", ".", "remove", "(", "tempElm", ")", ";", "}" ]
Moves the caret to a suitable position within the root for example in the first non pure whitespace text node or before an image
[ "Moves", "the", "caret", "to", "a", "suitable", "position", "within", "the", "root", "for", "example", "in", "the", "first", "non", "pure", "whitespace", "text", "node", "or", "before", "an", "image" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L41300-L41383
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (editor, clientX, clientY) { var bodyElm = Element.fromDom(editor.getBody()); var targetElm = editor.inline ? bodyElm : Traverse.documentElement(bodyElm); var transposedPoint = transpose(editor.inline, targetElm, clientX, clientY); return isInsideElementContentArea(targetElm, transposedPoint.x, transposedPoint.y); }
javascript
function (editor, clientX, clientY) { var bodyElm = Element.fromDom(editor.getBody()); var targetElm = editor.inline ? bodyElm : Traverse.documentElement(bodyElm); var transposedPoint = transpose(editor.inline, targetElm, clientX, clientY); return isInsideElementContentArea(targetElm, transposedPoint.x, transposedPoint.y); }
[ "function", "(", "editor", ",", "clientX", ",", "clientY", ")", "{", "var", "bodyElm", "=", "Element", ".", "fromDom", "(", "editor", ".", "getBody", "(", ")", ")", ";", "var", "targetElm", "=", "editor", ".", "inline", "?", "bodyElm", ":", "Traverse", ".", "documentElement", "(", "bodyElm", ")", ";", "var", "transposedPoint", "=", "transpose", "(", "editor", ".", "inline", ",", "targetElm", ",", "clientX", ",", "clientY", ")", ";", "return", "isInsideElementContentArea", "(", "targetElm", ",", "transposedPoint", ".", "x", ",", "transposedPoint", ".", "y", ")", ";", "}" ]
Checks if the specified coordinate is within the visual content area excluding the scrollbars
[ "Checks", "if", "the", "specified", "coordinate", "is", "within", "the", "visual", "content", "area", "excluding", "the", "scrollbars" ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L43027-L43033
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
Editor
function Editor(id, settings, editorManager) { var self = this, documentBaseUrl, baseUri; documentBaseUrl = self.documentBaseUrl = editorManager.documentBaseURL; baseUri = editorManager.baseURI; /** * Name/value collection with editor settings. * * @property settings * @type Object * @example * // Get the value of the theme setting * tinymce.activeEditor.windowManager.alert("You are using the " + tinymce.activeEditor.settings.theme + " theme"); */ settings = EditorSettings.getEditorSettings(self, id, documentBaseUrl, editorManager.defaultSettings, settings); self.settings = settings; AddOnManager.language = settings.language || 'en'; AddOnManager.languageLoad = settings.language_load; AddOnManager.baseURL = editorManager.baseURL; /** * Editor instance id, normally the same as the div/textarea that was replaced. * * @property id * @type String */ self.id = id; /** * State to force the editor to return false on a isDirty call. * * @property isNotDirty * @type Boolean * @deprecated Use editor.setDirty instead. */ self.setDirty(false); /** * Name/Value object containing plugin instances. * * @property plugins * @type Object * @example * // Execute a method inside a plugin directly * tinymce.activeEditor.plugins.someplugin.someMethod(); */ self.plugins = {}; /** * URI object to document configured for the TinyMCE instance. * * @property documentBaseURI * @type tinymce.util.URI * @example * // Get relative URL from the location of document_base_url * tinymce.activeEditor.documentBaseURI.toRelative('/somedir/somefile.htm'); * * // Get absolute URL from the location of document_base_url * tinymce.activeEditor.documentBaseURI.toAbsolute('somefile.htm'); */ self.documentBaseURI = new URI(settings.document_base_url, { base_uri: baseUri }); /** * URI object to current document that holds the TinyMCE editor instance. * * @property baseURI * @type tinymce.util.URI * @example * // Get relative URL from the location of the API * tinymce.activeEditor.baseURI.toRelative('/somedir/somefile.htm'); * * // Get absolute URL from the location of the API * tinymce.activeEditor.baseURI.toAbsolute('somefile.htm'); */ self.baseURI = baseUri; /** * Array with CSS files to load into the iframe. * * @property contentCSS * @type Array */ self.contentCSS = []; /** * Array of CSS styles to add to head of document when the editor loads. * * @property contentStyles * @type Array */ self.contentStyles = []; // Creates all events like onClick, onSetContent etc see Editor.Events.js for the actual logic self.shortcuts = new Shortcuts(self); self.loadedCSS = {}; self.editorCommands = new EditorCommands(self); self.suffix = editorManager.suffix; self.editorManager = editorManager; self.inline = settings.inline; if (settings.cache_suffix) { Env.cacheSuffix = settings.cache_suffix.replace(/^[\?\&]+/, ''); } if (settings.override_viewport === false) { Env.overrideViewPort = false; } // Call setup editorManager.fire('SetupEditor', self); self.execCallback('setup', self); /** * Dom query instance with default scope to the editor document and default element is the body of the editor. * * @property $ * @type tinymce.dom.DomQuery * @example * tinymce.activeEditor.$('p').css('color', 'red'); * tinymce.activeEditor.$().append('<p>new</p>'); */ self.$ = DomQuery.overrideDefaults(function () { return { context: self.inline ? self.getBody() : self.getDoc(), element: self.getBody() }; }); }
javascript
function Editor(id, settings, editorManager) { var self = this, documentBaseUrl, baseUri; documentBaseUrl = self.documentBaseUrl = editorManager.documentBaseURL; baseUri = editorManager.baseURI; /** * Name/value collection with editor settings. * * @property settings * @type Object * @example * // Get the value of the theme setting * tinymce.activeEditor.windowManager.alert("You are using the " + tinymce.activeEditor.settings.theme + " theme"); */ settings = EditorSettings.getEditorSettings(self, id, documentBaseUrl, editorManager.defaultSettings, settings); self.settings = settings; AddOnManager.language = settings.language || 'en'; AddOnManager.languageLoad = settings.language_load; AddOnManager.baseURL = editorManager.baseURL; /** * Editor instance id, normally the same as the div/textarea that was replaced. * * @property id * @type String */ self.id = id; /** * State to force the editor to return false on a isDirty call. * * @property isNotDirty * @type Boolean * @deprecated Use editor.setDirty instead. */ self.setDirty(false); /** * Name/Value object containing plugin instances. * * @property plugins * @type Object * @example * // Execute a method inside a plugin directly * tinymce.activeEditor.plugins.someplugin.someMethod(); */ self.plugins = {}; /** * URI object to document configured for the TinyMCE instance. * * @property documentBaseURI * @type tinymce.util.URI * @example * // Get relative URL from the location of document_base_url * tinymce.activeEditor.documentBaseURI.toRelative('/somedir/somefile.htm'); * * // Get absolute URL from the location of document_base_url * tinymce.activeEditor.documentBaseURI.toAbsolute('somefile.htm'); */ self.documentBaseURI = new URI(settings.document_base_url, { base_uri: baseUri }); /** * URI object to current document that holds the TinyMCE editor instance. * * @property baseURI * @type tinymce.util.URI * @example * // Get relative URL from the location of the API * tinymce.activeEditor.baseURI.toRelative('/somedir/somefile.htm'); * * // Get absolute URL from the location of the API * tinymce.activeEditor.baseURI.toAbsolute('somefile.htm'); */ self.baseURI = baseUri; /** * Array with CSS files to load into the iframe. * * @property contentCSS * @type Array */ self.contentCSS = []; /** * Array of CSS styles to add to head of document when the editor loads. * * @property contentStyles * @type Array */ self.contentStyles = []; // Creates all events like onClick, onSetContent etc see Editor.Events.js for the actual logic self.shortcuts = new Shortcuts(self); self.loadedCSS = {}; self.editorCommands = new EditorCommands(self); self.suffix = editorManager.suffix; self.editorManager = editorManager; self.inline = settings.inline; if (settings.cache_suffix) { Env.cacheSuffix = settings.cache_suffix.replace(/^[\?\&]+/, ''); } if (settings.override_viewport === false) { Env.overrideViewPort = false; } // Call setup editorManager.fire('SetupEditor', self); self.execCallback('setup', self); /** * Dom query instance with default scope to the editor document and default element is the body of the editor. * * @property $ * @type tinymce.dom.DomQuery * @example * tinymce.activeEditor.$('p').css('color', 'red'); * tinymce.activeEditor.$().append('<p>new</p>'); */ self.$ = DomQuery.overrideDefaults(function () { return { context: self.inline ? self.getBody() : self.getDoc(), element: self.getBody() }; }); }
[ "function", "Editor", "(", "id", ",", "settings", ",", "editorManager", ")", "{", "var", "self", "=", "this", ",", "documentBaseUrl", ",", "baseUri", ";", "documentBaseUrl", "=", "self", ".", "documentBaseUrl", "=", "editorManager", ".", "documentBaseURL", ";", "baseUri", "=", "editorManager", ".", "baseURI", ";", "settings", "=", "EditorSettings", ".", "getEditorSettings", "(", "self", ",", "id", ",", "documentBaseUrl", ",", "editorManager", ".", "defaultSettings", ",", "settings", ")", ";", "self", ".", "settings", "=", "settings", ";", "AddOnManager", ".", "language", "=", "settings", ".", "language", "||", "'en'", ";", "AddOnManager", ".", "languageLoad", "=", "settings", ".", "language_load", ";", "AddOnManager", ".", "baseURL", "=", "editorManager", ".", "baseURL", ";", "self", ".", "id", "=", "id", ";", "self", ".", "setDirty", "(", "false", ")", ";", "self", ".", "plugins", "=", "{", "}", ";", "self", ".", "documentBaseURI", "=", "new", "URI", "(", "settings", ".", "document_base_url", ",", "{", "base_uri", ":", "baseUri", "}", ")", ";", "self", ".", "baseURI", "=", "baseUri", ";", "self", ".", "contentCSS", "=", "[", "]", ";", "self", ".", "contentStyles", "=", "[", "]", ";", "self", ".", "shortcuts", "=", "new", "Shortcuts", "(", "self", ")", ";", "self", ".", "loadedCSS", "=", "{", "}", ";", "self", ".", "editorCommands", "=", "new", "EditorCommands", "(", "self", ")", ";", "self", ".", "suffix", "=", "editorManager", ".", "suffix", ";", "self", ".", "editorManager", "=", "editorManager", ";", "self", ".", "inline", "=", "settings", ".", "inline", ";", "if", "(", "settings", ".", "cache_suffix", ")", "{", "Env", ".", "cacheSuffix", "=", "settings", ".", "cache_suffix", ".", "replace", "(", "/", "^[\\?\\&]+", "/", ",", "''", ")", ";", "}", "if", "(", "settings", ".", "override_viewport", "===", "false", ")", "{", "Env", ".", "overrideViewPort", "=", "false", ";", "}", "editorManager", ".", "fire", "(", "'SetupEditor'", ",", "self", ")", ";", "self", ".", "execCallback", "(", "'setup'", ",", "self", ")", ";", "self", ".", "$", "=", "DomQuery", ".", "overrideDefaults", "(", "function", "(", ")", "{", "return", "{", "context", ":", "self", ".", "inline", "?", "self", ".", "getBody", "(", ")", ":", "self", ".", "getDoc", "(", ")", ",", "element", ":", "self", ".", "getBody", "(", ")", "}", ";", "}", ")", ";", "}" ]
Include Editor API docs. @include ../../../../../tools/docs/tinymce.Editor.js Constructs a editor instance by id. @constructor @method Editor @param {String} id Unique id for the editor. @param {Object} settings Settings for the editor. @param {tinymce.EditorManager} editorManager EditorManager instance.
[ "Include", "Editor", "API", "docs", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L45785-L45916
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (text) { if (text && Tools.is(text, 'string')) { var lang = this.settings.language || 'en', i18n = this.editorManager.i18n; text = i18n.data[lang + '.' + text] || text.replace(/\{\#([^\}]+)\}/g, function (a, b) { return i18n.data[lang + '.' + b] || '{#' + b + '}'; }); } return this.editorManager.translate(text); }
javascript
function (text) { if (text && Tools.is(text, 'string')) { var lang = this.settings.language || 'en', i18n = this.editorManager.i18n; text = i18n.data[lang + '.' + text] || text.replace(/\{\#([^\}]+)\}/g, function (a, b) { return i18n.data[lang + '.' + b] || '{#' + b + '}'; }); } return this.editorManager.translate(text); }
[ "function", "(", "text", ")", "{", "if", "(", "text", "&&", "Tools", ".", "is", "(", "text", ",", "'string'", ")", ")", "{", "var", "lang", "=", "this", ".", "settings", ".", "language", "||", "'en'", ",", "i18n", "=", "this", ".", "editorManager", ".", "i18n", ";", "text", "=", "i18n", ".", "data", "[", "lang", "+", "'.'", "+", "text", "]", "||", "text", ".", "replace", "(", "/", "\\{\\#([^\\}]+)\\}", "/", "g", ",", "function", "(", "a", ",", "b", ")", "{", "return", "i18n", ".", "data", "[", "lang", "+", "'.'", "+", "b", "]", "||", "'{#'", "+", "b", "+", "'}'", ";", "}", ")", ";", "}", "return", "this", ".", "editorManager", ".", "translate", "(", "text", ")", ";", "}" ]
Translates the specified string by replacing variables with language pack items it will also check if there is a key matching the input. @method translate @param {String} text String to translate by the language pack data. @return {String} Translated string.
[ "Translates", "the", "specified", "string", "by", "replacing", "variables", "with", "language", "pack", "items", "it", "will", "also", "check", "if", "there", "is", "a", "key", "matching", "the", "input", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L46056-L46066
train
adiwidjaja/frontend-pagebuilder
js/tinymce/tinymce.jquery.js
function (args) { var self = this, content, body = self.getBody(); if (self.removed) { return ''; } // Setup args object args = args || {}; args.format = args.format || 'html'; args.get = true; args.getInner = true; // Do preprocessing if (!args.no_events) { self.fire('BeforeGetContent', args); } // Get raw contents or by default the cleaned contents if (args.format == 'raw') { content = Tools.trim(self.serializer.getTrimmedContent()); } else if (args.format == 'text') { content = body.innerText || body.textContent; } else { content = self.serializer.serialize(body, args); } // Trim whitespace in beginning/end of HTML if (args.format != 'text') { args.content = trim(content); } else { args.content = content; } // Do post processing if (!args.no_events) { self.fire('GetContent', args); } return args.content; }
javascript
function (args) { var self = this, content, body = self.getBody(); if (self.removed) { return ''; } // Setup args object args = args || {}; args.format = args.format || 'html'; args.get = true; args.getInner = true; // Do preprocessing if (!args.no_events) { self.fire('BeforeGetContent', args); } // Get raw contents or by default the cleaned contents if (args.format == 'raw') { content = Tools.trim(self.serializer.getTrimmedContent()); } else if (args.format == 'text') { content = body.innerText || body.textContent; } else { content = self.serializer.serialize(body, args); } // Trim whitespace in beginning/end of HTML if (args.format != 'text') { args.content = trim(content); } else { args.content = content; } // Do post processing if (!args.no_events) { self.fire('GetContent', args); } return args.content; }
[ "function", "(", "args", ")", "{", "var", "self", "=", "this", ",", "content", ",", "body", "=", "self", ".", "getBody", "(", ")", ";", "if", "(", "self", ".", "removed", ")", "{", "return", "''", ";", "}", "args", "=", "args", "||", "{", "}", ";", "args", ".", "format", "=", "args", ".", "format", "||", "'html'", ";", "args", ".", "get", "=", "true", ";", "args", ".", "getInner", "=", "true", ";", "if", "(", "!", "args", ".", "no_events", ")", "{", "self", ".", "fire", "(", "'BeforeGetContent'", ",", "args", ")", ";", "}", "if", "(", "args", ".", "format", "==", "'raw'", ")", "{", "content", "=", "Tools", ".", "trim", "(", "self", ".", "serializer", ".", "getTrimmedContent", "(", ")", ")", ";", "}", "else", "if", "(", "args", ".", "format", "==", "'text'", ")", "{", "content", "=", "body", ".", "innerText", "||", "body", ".", "textContent", ";", "}", "else", "{", "content", "=", "self", ".", "serializer", ".", "serialize", "(", "body", ",", "args", ")", ";", "}", "if", "(", "args", ".", "format", "!=", "'text'", ")", "{", "args", ".", "content", "=", "trim", "(", "content", ")", ";", "}", "else", "{", "args", ".", "content", "=", "content", ";", "}", "if", "(", "!", "args", ".", "no_events", ")", "{", "self", ".", "fire", "(", "'GetContent'", ",", "args", ")", ";", "}", "return", "args", ".", "content", ";", "}" ]
Gets the content from the editor instance, this will cleanup the content before it gets returned using the different cleanup rules options. @method getContent @param {Object} args Optional content object, this gets passed around through the whole get process. @return {String} Cleaned content string, normally HTML contents. @example // Get the HTML contents of the currently active editor console.debug(tinymce.activeEditor.getContent()); // Get the raw contents of the currently active editor tinymce.activeEditor.getContent({format: 'raw'}); // Get content of a specific editor: tinymce.get('content id').getContent()
[ "Gets", "the", "content", "from", "the", "editor", "instance", "this", "will", "cleanup", "the", "content", "before", "it", "gets", "returned", "using", "the", "different", "cleanup", "rules", "options", "." ]
a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f
https://github.com/adiwidjaja/frontend-pagebuilder/blob/a08caa06cd9f919d575eb68f0d6b56fdedfb7d0f/js/tinymce/tinymce.jquery.js#L46694-L46734
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function() { // Call the base contructor. this.base(); /** * The characters to be used for each indentation step. * * // Use tab for indentation. * editorInstance.dataProcessor.writer.indentationChars = '\t'; */ this.indentationChars = '\t'; /** * The characters to be used to close "self-closing" elements, like `<br>` or `<img>`. * * // Use HTML4 notation for self-closing elements. * editorInstance.dataProcessor.writer.selfClosingEnd = '>'; */ this.selfClosingEnd = ' />'; /** * The characters to be used for line breaks. * * // Use CRLF for line breaks. * editorInstance.dataProcessor.writer.lineBreakChars = '\r\n'; */ this.lineBreakChars = '\n'; this.sortAttributes = 1; this._.indent = 0; this._.indentation = ''; // Indicate preformatted block context status. (#5789) this._.inPre = 0; this._.rules = {}; var dtd = CKEDITOR.dtd; for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) ) { this.setRules( e, { indent: !dtd[ e ][ '#' ], breakBeforeOpen: 1, breakBeforeClose: !dtd[ e ][ '#' ], breakAfterClose: 1, needsSpace: ( e in dtd.$block ) && !( e in { li: 1, dt: 1, dd: 1 } ) } ); } this.setRules( 'br', { breakAfterOpen: 1 } ); this.setRules( 'title', { indent: 0, breakAfterOpen: 0 } ); this.setRules( 'style', { indent: 0, breakBeforeClose: 1 } ); this.setRules( 'pre', { breakAfterOpen: 1, // Keep line break after the opening tag indent: 0 // Disable indentation on <pre>. } ); }
javascript
function() { // Call the base contructor. this.base(); /** * The characters to be used for each indentation step. * * // Use tab for indentation. * editorInstance.dataProcessor.writer.indentationChars = '\t'; */ this.indentationChars = '\t'; /** * The characters to be used to close "self-closing" elements, like `<br>` or `<img>`. * * // Use HTML4 notation for self-closing elements. * editorInstance.dataProcessor.writer.selfClosingEnd = '>'; */ this.selfClosingEnd = ' />'; /** * The characters to be used for line breaks. * * // Use CRLF for line breaks. * editorInstance.dataProcessor.writer.lineBreakChars = '\r\n'; */ this.lineBreakChars = '\n'; this.sortAttributes = 1; this._.indent = 0; this._.indentation = ''; // Indicate preformatted block context status. (#5789) this._.inPre = 0; this._.rules = {}; var dtd = CKEDITOR.dtd; for ( var e in CKEDITOR.tools.extend( {}, dtd.$nonBodyContent, dtd.$block, dtd.$listItem, dtd.$tableContent ) ) { this.setRules( e, { indent: !dtd[ e ][ '#' ], breakBeforeOpen: 1, breakBeforeClose: !dtd[ e ][ '#' ], breakAfterClose: 1, needsSpace: ( e in dtd.$block ) && !( e in { li: 1, dt: 1, dd: 1 } ) } ); } this.setRules( 'br', { breakAfterOpen: 1 } ); this.setRules( 'title', { indent: 0, breakAfterOpen: 0 } ); this.setRules( 'style', { indent: 0, breakBeforeClose: 1 } ); this.setRules( 'pre', { breakAfterOpen: 1, // Keep line break after the opening tag indent: 0 // Disable indentation on <pre>. } ); }
[ "function", "(", ")", "{", "this", ".", "base", "(", ")", ";", "this", ".", "indentationChars", "=", "'\\t'", ";", "\\t", "this", ".", "selfClosingEnd", "=", "' />'", ";", "this", ".", "lineBreakChars", "=", "'\\n'", ";", "\\n", "this", ".", "sortAttributes", "=", "1", ";", "this", ".", "_", ".", "indent", "=", "0", ";", "this", ".", "_", ".", "indentation", "=", "''", ";", "this", ".", "_", ".", "inPre", "=", "0", ";", "this", ".", "_", ".", "rules", "=", "{", "}", ";", "var", "dtd", "=", "CKEDITOR", ".", "dtd", ";", "for", "(", "var", "e", "in", "CKEDITOR", ".", "tools", ".", "extend", "(", "{", "}", ",", "dtd", ".", "$nonBodyContent", ",", "dtd", ".", "$block", ",", "dtd", ".", "$listItem", ",", "dtd", ".", "$tableContent", ")", ")", "{", "this", ".", "setRules", "(", "e", ",", "{", "indent", ":", "!", "dtd", "[", "e", "]", "[", "'#'", "]", ",", "breakBeforeOpen", ":", "1", ",", "breakBeforeClose", ":", "!", "dtd", "[", "e", "]", "[", "'#'", "]", ",", "breakAfterClose", ":", "1", ",", "needsSpace", ":", "(", "e", "in", "dtd", ".", "$block", ")", "&&", "!", "(", "e", "in", "{", "li", ":", "1", ",", "dt", ":", "1", ",", "dd", ":", "1", "}", ")", "}", ")", ";", "}", "this", ".", "setRules", "(", "'br'", ",", "{", "breakAfterOpen", ":", "1", "}", ")", ";", "this", ".", "setRules", "(", "'title'", ",", "{", "indent", ":", "0", ",", "breakAfterOpen", ":", "0", "}", ")", ";", "}" ]
Creates an `htmlWriter` class instance. @constructor
[ "Creates", "an", "htmlWriter", "class", "instance", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L40-L104
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function( tagName, attributes ) { var rules = this._.rules[ tagName ]; if ( this._.afterCloser && rules && rules.needsSpace && this._.needsSpace ) this._.output.push( '\n' ); if ( this._.indent ) this.indentation(); // Do not break if indenting. else if ( rules && rules.breakBeforeOpen ) { this.lineBreak(); this.indentation(); } this._.output.push( '<', tagName ); this._.afterCloser = 0; }
javascript
function( tagName, attributes ) { var rules = this._.rules[ tagName ]; if ( this._.afterCloser && rules && rules.needsSpace && this._.needsSpace ) this._.output.push( '\n' ); if ( this._.indent ) this.indentation(); // Do not break if indenting. else if ( rules && rules.breakBeforeOpen ) { this.lineBreak(); this.indentation(); } this._.output.push( '<', tagName ); this._.afterCloser = 0; }
[ "function", "(", "tagName", ",", "attributes", ")", "{", "var", "rules", "=", "this", ".", "_", ".", "rules", "[", "tagName", "]", ";", "if", "(", "this", ".", "_", ".", "afterCloser", "&&", "rules", "&&", "rules", ".", "needsSpace", "&&", "this", ".", "_", ".", "needsSpace", ")", "this", ".", "_", ".", "output", ".", "push", "(", "'\\n'", ")", ";", "\\n", "if", "(", "this", ".", "_", ".", "indent", ")", "this", ".", "indentation", "(", ")", ";", "else", "if", "(", "rules", "&&", "rules", ".", "breakBeforeOpen", ")", "{", "this", ".", "lineBreak", "(", ")", ";", "this", ".", "indentation", "(", ")", ";", "}", "this", ".", "_", ".", "output", ".", "push", "(", "'<'", ",", "tagName", ")", ";", "}" ]
Writes the tag opening part for an opener tag. // Writes '<p'. writer.openTag( 'p', { class : 'MyClass', id : 'MyId' } ); @param {String} tagName The element name for this tag. @param {Object} attributes The attributes defined for this tag. The attributes could be used to inspect the tag.
[ "Writes", "the", "tag", "opening", "part", "for", "an", "opener", "tag", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L117-L134
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function( tagName, isSelfClose ) { var rules = this._.rules[ tagName ]; if ( isSelfClose ) { this._.output.push( this.selfClosingEnd ); if ( rules && rules.breakAfterClose ) this._.needsSpace = rules.needsSpace; } else { this._.output.push( '>' ); if ( rules && rules.indent ) this._.indentation += this.indentationChars; } if ( rules && rules.breakAfterOpen ) this.lineBreak(); tagName == 'pre' && ( this._.inPre = 1 ); }
javascript
function( tagName, isSelfClose ) { var rules = this._.rules[ tagName ]; if ( isSelfClose ) { this._.output.push( this.selfClosingEnd ); if ( rules && rules.breakAfterClose ) this._.needsSpace = rules.needsSpace; } else { this._.output.push( '>' ); if ( rules && rules.indent ) this._.indentation += this.indentationChars; } if ( rules && rules.breakAfterOpen ) this.lineBreak(); tagName == 'pre' && ( this._.inPre = 1 ); }
[ "function", "(", "tagName", ",", "isSelfClose", ")", "{", "var", "rules", "=", "this", ".", "_", ".", "rules", "[", "tagName", "]", ";", "if", "(", "isSelfClose", ")", "{", "this", ".", "_", ".", "output", ".", "push", "(", "this", ".", "selfClosingEnd", ")", ";", "if", "(", "rules", "&&", "rules", ".", "breakAfterClose", ")", "this", ".", "_", ".", "needsSpace", "=", "rules", ".", "needsSpace", ";", "}", "else", "{", "this", ".", "_", ".", "output", ".", "push", "(", "'>'", ")", ";", "if", "(", "rules", "&&", "rules", ".", "indent", ")", "this", ".", "_", ".", "indentation", "+=", "this", ".", "indentationChars", ";", "}", "if", "(", "rules", "&&", "rules", ".", "breakAfterOpen", ")", "this", ".", "lineBreak", "(", ")", ";", "tagName", "==", "'pre'", "&&", "(", "this", ".", "_", ".", "inPre", "=", "1", ")", ";", "}" ]
Writes the tag closing part for an opener tag. // Writes '>'. writer.openTagClose( 'p', false ); // Writes ' />'. writer.openTagClose( 'br', true ); @param {String} tagName The element name for this tag. @param {Boolean} isSelfClose Indicates that this is a self-closing tag, like `<br>` or `<img>`.
[ "Writes", "the", "tag", "closing", "part", "for", "an", "opener", "tag", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L149-L167
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function( tagName ) { var rules = this._.rules[ tagName ]; if ( rules && rules.indent ) this._.indentation = this._.indentation.substr( this.indentationChars.length ); if ( this._.indent ) this.indentation(); // Do not break if indenting. else if ( rules && rules.breakBeforeClose ) { this.lineBreak(); this.indentation(); } this._.output.push( '</', tagName, '>' ); tagName == 'pre' && ( this._.inPre = 0 ); if ( rules && rules.breakAfterClose ) { this.lineBreak(); this._.needsSpace = rules.needsSpace; } this._.afterCloser = 1; }
javascript
function( tagName ) { var rules = this._.rules[ tagName ]; if ( rules && rules.indent ) this._.indentation = this._.indentation.substr( this.indentationChars.length ); if ( this._.indent ) this.indentation(); // Do not break if indenting. else if ( rules && rules.breakBeforeClose ) { this.lineBreak(); this.indentation(); } this._.output.push( '</', tagName, '>' ); tagName == 'pre' && ( this._.inPre = 0 ); if ( rules && rules.breakAfterClose ) { this.lineBreak(); this._.needsSpace = rules.needsSpace; } this._.afterCloser = 1; }
[ "function", "(", "tagName", ")", "{", "var", "rules", "=", "this", ".", "_", ".", "rules", "[", "tagName", "]", ";", "if", "(", "rules", "&&", "rules", ".", "indent", ")", "this", ".", "_", ".", "indentation", "=", "this", ".", "_", ".", "indentation", ".", "substr", "(", "this", ".", "indentationChars", ".", "length", ")", ";", "if", "(", "this", ".", "_", ".", "indent", ")", "this", ".", "indentation", "(", ")", ";", "else", "if", "(", "rules", "&&", "rules", ".", "breakBeforeClose", ")", "{", "this", ".", "lineBreak", "(", ")", ";", "this", ".", "indentation", "(", ")", ";", "}", "this", ".", "_", ".", "output", ".", "push", "(", "'</'", ",", "tagName", ",", "'>'", ")", ";", "tagName", "==", "'pre'", "&&", "(", "this", ".", "_", ".", "inPre", "=", "0", ")", ";", "if", "(", "rules", "&&", "rules", ".", "breakAfterClose", ")", "{", "this", ".", "lineBreak", "(", ")", ";", "this", ".", "_", ".", "needsSpace", "=", "rules", ".", "needsSpace", ";", "}", "this", ".", "_", ".", "afterCloser", "=", "1", ";", "}" ]
Writes a closer tag. // Writes '</p>'. writer.closeTag( 'p' ); @param {String} tagName The element name for this tag.
[ "Writes", "a", "closer", "tag", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L198-L221
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function( text ) { if ( this._.indent ) { this.indentation(); !this._.inPre && ( text = CKEDITOR.tools.ltrim( text ) ); } this._.output.push( text ); }
javascript
function( text ) { if ( this._.indent ) { this.indentation(); !this._.inPre && ( text = CKEDITOR.tools.ltrim( text ) ); } this._.output.push( text ); }
[ "function", "(", "text", ")", "{", "if", "(", "this", ".", "_", ".", "indent", ")", "{", "this", ".", "indentation", "(", ")", ";", "!", "this", ".", "_", ".", "inPre", "&&", "(", "text", "=", "CKEDITOR", ".", "tools", ".", "ltrim", "(", "text", ")", ")", ";", "}", "this", ".", "_", ".", "output", ".", "push", "(", "text", ")", ";", "}" ]
Writes text. // Writes 'Hello Word'. writer.text( 'Hello Word' ); @param {String} text The text value
[ "Writes", "text", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L231-L238
train
skerit/alchemy-styleboost
public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js
function() { this._.output = []; this._.indent = 0; this._.indentation = ''; this._.afterCloser = 0; this._.inPre = 0; }
javascript
function() { this._.output = []; this._.indent = 0; this._.indentation = ''; this._.afterCloser = 0; this._.inPre = 0; }
[ "function", "(", ")", "{", "this", ".", "_", ".", "output", "=", "[", "]", ";", "this", ".", "_", ".", "indent", "=", "0", ";", "this", ".", "_", ".", "indentation", "=", "''", ";", "this", ".", "_", ".", "afterCloser", "=", "0", ";", "this", ".", "_", ".", "inPre", "=", "0", ";", "}" ]
Empties the current output buffer. It also brings back the default values of the writer flags. writer.reset();
[ "Empties", "the", "current", "output", "buffer", ".", "It", "also", "brings", "back", "the", "default", "values", "of", "the", "writer", "flags", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/public/ckeditor/4.4dev/plugins/htmlwriter/plugin.js#L286-L292
train
skerit/alchemy-styleboost
assets/scripts/bootstrap-select1.6/bootstrap-select.js
normalizeToBase
function normalizeToBase(text) { var rExps = [ {re: /[\xC0-\xC6]/g, ch: "A"}, {re: /[\xE0-\xE6]/g, ch: "a"}, {re: /[\xC8-\xCB]/g, ch: "E"}, {re: /[\xE8-\xEB]/g, ch: "e"}, {re: /[\xCC-\xCF]/g, ch: "I"}, {re: /[\xEC-\xEF]/g, ch: "i"}, {re: /[\xD2-\xD6]/g, ch: "O"}, {re: /[\xF2-\xF6]/g, ch: "o"}, {re: /[\xD9-\xDC]/g, ch: "U"}, {re: /[\xF9-\xFC]/g, ch: "u"}, {re: /[\xC7-\xE7]/g, ch: "c"}, {re: /[\xD1]/g, ch: "N"}, {re: /[\xF1]/g, ch: "n"} ]; $.each(rExps, function () { text = text.replace(this.re, this.ch); }); return text; }
javascript
function normalizeToBase(text) { var rExps = [ {re: /[\xC0-\xC6]/g, ch: "A"}, {re: /[\xE0-\xE6]/g, ch: "a"}, {re: /[\xC8-\xCB]/g, ch: "E"}, {re: /[\xE8-\xEB]/g, ch: "e"}, {re: /[\xCC-\xCF]/g, ch: "I"}, {re: /[\xEC-\xEF]/g, ch: "i"}, {re: /[\xD2-\xD6]/g, ch: "O"}, {re: /[\xF2-\xF6]/g, ch: "o"}, {re: /[\xD9-\xDC]/g, ch: "U"}, {re: /[\xF9-\xFC]/g, ch: "u"}, {re: /[\xC7-\xE7]/g, ch: "c"}, {re: /[\xD1]/g, ch: "N"}, {re: /[\xF1]/g, ch: "n"} ]; $.each(rExps, function () { text = text.replace(this.re, this.ch); }); return text; }
[ "function", "normalizeToBase", "(", "text", ")", "{", "var", "rExps", "=", "[", "{", "re", ":", "/", "[\\xC0-\\xC6]", "/", "g", ",", "ch", ":", "\"A\"", "}", ",", "{", "re", ":", "/", "[\\xE0-\\xE6]", "/", "g", ",", "ch", ":", "\"a\"", "}", ",", "{", "re", ":", "/", "[\\xC8-\\xCB]", "/", "g", ",", "ch", ":", "\"E\"", "}", ",", "{", "re", ":", "/", "[\\xE8-\\xEB]", "/", "g", ",", "ch", ":", "\"e\"", "}", ",", "{", "re", ":", "/", "[\\xCC-\\xCF]", "/", "g", ",", "ch", ":", "\"I\"", "}", ",", "{", "re", ":", "/", "[\\xEC-\\xEF]", "/", "g", ",", "ch", ":", "\"i\"", "}", ",", "{", "re", ":", "/", "[\\xD2-\\xD6]", "/", "g", ",", "ch", ":", "\"O\"", "}", ",", "{", "re", ":", "/", "[\\xF2-\\xF6]", "/", "g", ",", "ch", ":", "\"o\"", "}", ",", "{", "re", ":", "/", "[\\xD9-\\xDC]", "/", "g", ",", "ch", ":", "\"U\"", "}", ",", "{", "re", ":", "/", "[\\xF9-\\xFC]", "/", "g", ",", "ch", ":", "\"u\"", "}", ",", "{", "re", ":", "/", "[\\xC7-\\xE7]", "/", "g", ",", "ch", ":", "\"c\"", "}", ",", "{", "re", ":", "/", "[\\xD1]", "/", "g", ",", "ch", ":", "\"N\"", "}", ",", "{", "re", ":", "/", "[\\xF1]", "/", "g", ",", "ch", ":", "\"n\"", "}", "]", ";", "$", ".", "each", "(", "rExps", ",", "function", "(", ")", "{", "text", "=", "text", ".", "replace", "(", "this", ".", "re", ",", "this", ".", "ch", ")", ";", "}", ")", ";", "return", "text", ";", "}" ]
Remove all diatrics from the given text. @access private @param {String} text @returns {String}
[ "Remove", "all", "diatrics", "from", "the", "given", "text", "." ]
2b90b8a6afc9f065f785651292fb193940021d90
https://github.com/skerit/alchemy-styleboost/blob/2b90b8a6afc9f065f785651292fb193940021d90/assets/scripts/bootstrap-select1.6/bootstrap-select.js#L37-L57
train
cliffano/buildlight
lib/drivers/usbhid.js
UsbHid
function UsbHid() { var vendorId = 0x0fc5; // always 0x0FC5 for Delcom products var productId = 0xb080; // always 0xB080 for Delcom HID device this.device = this._find(vendorId, productId); this.dataMap = { off: '\x00', green: '\x01', red: '\x02', blue: '\x04', yellow: '\x04' }; }
javascript
function UsbHid() { var vendorId = 0x0fc5; // always 0x0FC5 for Delcom products var productId = 0xb080; // always 0xB080 for Delcom HID device this.device = this._find(vendorId, productId); this.dataMap = { off: '\x00', green: '\x01', red: '\x02', blue: '\x04', yellow: '\x04' }; }
[ "function", "UsbHid", "(", ")", "{", "var", "vendorId", "=", "0x0fc5", ";", "var", "productId", "=", "0xb080", ";", "this", ".", "device", "=", "this", ".", "_find", "(", "vendorId", ",", "productId", ")", ";", "this", ".", "dataMap", "=", "{", "off", ":", "'\\x00'", ",", "\\x00", ",", "green", ":", "'\\x01'", ",", "\\x01", ",", "red", ":", "'\\x02'", "}", ";", "}" ]
class UsbHid UsbHid driver works by writing a colour data or off data to the device. Data values credit to https://github.com/ileitch/delcom_904008_driver/blob/master/delcom_904008.rb Delcom USB HID doc https://www.delcomproducts.com/productdetails.asp?productnum=900000 Delcom Visual Indicator USB HID datasheet https://www.delcomproducts.com/downloads/USBVIHID.pdf
[ "class", "UsbHid", "UsbHid", "driver", "works", "by", "writing", "a", "colour", "data", "or", "off", "data", "to", "the", "device", "." ]
f6b592acf40d58ea8a43882d4e2abe2ad1819179
https://github.com/cliffano/buildlight/blob/f6b592acf40d58ea8a43882d4e2abe2ad1819179/lib/drivers/usbhid.js#L12-L24
train
jonesetc/broccoli-anything-to-js
index.js
ToJSFilter
function ToJSFilter (inputTree, options) { if (!(this instanceof ToJSFilter)) { return new ToJSFilter(inputTree, options); } options = options || {}; options.extensions = options.extensions || ['txt']; options.targetExtension = 'js'; Filter.call(this, inputTree, options); this.trimFiles = options.trimFiles || false; }
javascript
function ToJSFilter (inputTree, options) { if (!(this instanceof ToJSFilter)) { return new ToJSFilter(inputTree, options); } options = options || {}; options.extensions = options.extensions || ['txt']; options.targetExtension = 'js'; Filter.call(this, inputTree, options); this.trimFiles = options.trimFiles || false; }
[ "function", "ToJSFilter", "(", "inputTree", ",", "options", ")", "{", "if", "(", "!", "(", "this", "instanceof", "ToJSFilter", ")", ")", "{", "return", "new", "ToJSFilter", "(", "inputTree", ",", "options", ")", ";", "}", "options", "=", "options", "||", "{", "}", ";", "options", ".", "extensions", "=", "options", ".", "extensions", "||", "[", "'txt'", "]", ";", "options", ".", "targetExtension", "=", "'js'", ";", "Filter", ".", "call", "(", "this", ",", "inputTree", ",", "options", ")", ";", "this", ".", "trimFiles", "=", "options", ".", "trimFiles", "||", "false", ";", "}" ]
Take an input tree with text files in it and return them embedded into new JS module files @class @param {string,broccoliTree} inputTree The tree of files to search for appropriate text files @param {object} options The options object
[ "Take", "an", "input", "tree", "with", "text", "files", "in", "it", "and", "return", "them", "embedded", "into", "new", "JS", "module", "files" ]
1cb101f168670c8bfb426d64af42f4c9e39c4539
https://github.com/jonesetc/broccoli-anything-to-js/blob/1cb101f168670c8bfb426d64af42f4c9e39c4539/index.js#L21-L30
train
bmancini55/super-prop
lib/super-prop.js
define
function define(scope, Type, name) { var propName = name || 'super' , propInernalName = '_' + propName; Object.defineProperty(scope, propName, { writeable: false, get: function() { if(!this[propInernalName]) { this[propInernalName] = create(this, Type); } return this[propInernalName]; } }); }
javascript
function define(scope, Type, name) { var propName = name || 'super' , propInernalName = '_' + propName; Object.defineProperty(scope, propName, { writeable: false, get: function() { if(!this[propInernalName]) { this[propInernalName] = create(this, Type); } return this[propInernalName]; } }); }
[ "function", "define", "(", "scope", ",", "Type", ",", "name", ")", "{", "var", "propName", "=", "name", "||", "'super'", ",", "propInernalName", "=", "'_'", "+", "propName", ";", "Object", ".", "defineProperty", "(", "scope", ",", "propName", ",", "{", "writeable", ":", "false", ",", "get", ":", "function", "(", ")", "{", "if", "(", "!", "this", "[", "propInernalName", "]", ")", "{", "this", "[", "propInernalName", "]", "=", "create", "(", "this", ",", "Type", ")", ";", "}", "return", "this", "[", "propInernalName", "]", ";", "}", "}", ")", ";", "}" ]
Attaches a `super` property to an object that contains the methods on the supplied Type bound to the current instance. @api public @param {Object} scope - the instance to bind methos to @param {Function} Type - the prototype of the super Type @param {String} [name] - the name of the property, defaults to 'super'
[ "Attaches", "a", "super", "property", "to", "an", "object", "that", "contains", "the", "methods", "on", "the", "supplied", "Type", "bound", "to", "the", "current", "instance", "." ]
6629d6b0a70ebb60fd333f781a459f0e3b43ede0
https://github.com/bmancini55/super-prop/blob/6629d6b0a70ebb60fd333f781a459f0e3b43ede0/lib/super-prop.js#L16-L29
train
bmancini55/super-prop
lib/super-prop.js
create
function create(scope, Type) { // make result the constructor var result = function() { Type.apply(scope, arguments); }; // attach methods to result for(var key in Type.prototype) { if(typeof Type.prototype[key] === 'function') { result[key] = Type.prototype[key].bind(scope); } } return result; }
javascript
function create(scope, Type) { // make result the constructor var result = function() { Type.apply(scope, arguments); }; // attach methods to result for(var key in Type.prototype) { if(typeof Type.prototype[key] === 'function') { result[key] = Type.prototype[key].bind(scope); } } return result; }
[ "function", "create", "(", "scope", ",", "Type", ")", "{", "var", "result", "=", "function", "(", ")", "{", "Type", ".", "apply", "(", "scope", ",", "arguments", ")", ";", "}", ";", "for", "(", "var", "key", "in", "Type", ".", "prototype", ")", "{", "if", "(", "typeof", "Type", ".", "prototype", "[", "key", "]", "===", "'function'", ")", "{", "result", "[", "key", "]", "=", "Type", ".", "prototype", "[", "key", "]", ".", "bind", "(", "scope", ")", ";", "}", "}", "return", "result", ";", "}" ]
Creates an object containing methods of the specificed proptotype that will be bound to the supplied scope. This function also creates a constructor property that is a function call for the supplied prototype @api public @param {Object} scope - the instance to bind methos to @param {Function} Type - the prototype of the super Type
[ "Creates", "an", "object", "containing", "methods", "of", "the", "specificed", "proptotype", "that", "will", "be", "bound", "to", "the", "supplied", "scope", ".", "This", "function", "also", "creates", "a", "constructor", "property", "that", "is", "a", "function", "call", "for", "the", "supplied", "prototype" ]
6629d6b0a70ebb60fd333f781a459f0e3b43ede0
https://github.com/bmancini55/super-prop/blob/6629d6b0a70ebb60fd333f781a459f0e3b43ede0/lib/super-prop.js#L44-L59
train
hoodiehq-archive/hoodie-plugins-api
lib/databases.js
function (name) { return new DatabaseAPI(hoodie, { name: name, editable_permissions: true, _id: exports.convertID, prepare: exports.prepareDoc, parse: exports.parseDoc }) }
javascript
function (name) { return new DatabaseAPI(hoodie, { name: name, editable_permissions: true, _id: exports.convertID, prepare: exports.prepareDoc, parse: exports.parseDoc }) }
[ "function", "(", "name", ")", "{", "return", "new", "DatabaseAPI", "(", "hoodie", ",", "{", "name", ":", "name", ",", "editable_permissions", ":", "true", ",", "_id", ":", "exports", ".", "convertID", ",", "prepare", ":", "exports", ".", "prepareDoc", ",", "parse", ":", "exports", ".", "parseDoc", "}", ")", "}" ]
Calling this API with a db name returns a new DatabaseAPI object
[ "Calling", "this", "API", "with", "a", "db", "name", "returns", "a", "new", "DatabaseAPI", "object" ]
25eb96a958b64e30f1092f7e06efab2d7e28f8aa
https://github.com/hoodiehq-archive/hoodie-plugins-api/blob/25eb96a958b64e30f1092f7e06efab2d7e28f8aa/lib/databases.js#L85-L93
train
genjs/gutil
lib/util/all.js
all
function all(values, keyName) { if(values instanceof Array) { var results = {}; for(var i=0; i<values.length; i++) { var obj2 = values[i]; var res = get(obj2, keyName); if(res != undefined) { results[res] = 0; } } var results2 = []; for(var result in results) { results2.push(result); } return results2; } }
javascript
function all(values, keyName) { if(values instanceof Array) { var results = {}; for(var i=0; i<values.length; i++) { var obj2 = values[i]; var res = get(obj2, keyName); if(res != undefined) { results[res] = 0; } } var results2 = []; for(var result in results) { results2.push(result); } return results2; } }
[ "function", "all", "(", "values", ",", "keyName", ")", "{", "if", "(", "values", "instanceof", "Array", ")", "{", "var", "results", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "values", ".", "length", ";", "i", "++", ")", "{", "var", "obj2", "=", "values", "[", "i", "]", ";", "var", "res", "=", "get", "(", "obj2", ",", "keyName", ")", ";", "if", "(", "res", "!=", "undefined", ")", "{", "results", "[", "res", "]", "=", "0", ";", "}", "}", "var", "results2", "=", "[", "]", ";", "for", "(", "var", "result", "in", "results", ")", "{", "results2", ".", "push", "(", "result", ")", ";", "}", "return", "results2", ";", "}", "}" ]
Get all values from an array if they are an object with a "keyName" attribute. @param values array @param keyName object attribute name @returns {Array}
[ "Get", "all", "values", "from", "an", "array", "if", "they", "are", "an", "object", "with", "a", "keyName", "attribute", "." ]
c2890fdd030bb9f0cad9f5c7c9da442411c3903a
https://github.com/genjs/gutil/blob/c2890fdd030bb9f0cad9f5c7c9da442411c3903a/lib/util/all.js#L9-L25
train
robertblackwell/yake
src/yake/main.js
getTasksFromYakefile
function getTasksFromYakefile(cwd, fileOption) { // find the yakefile and load (actually a dynamic 'require') tasks // first create an empty collection - dont need to use the global collection const tc1 = TC.TaskCollection(); //preload const tc2 = TASKS.loadPreloadedTasks(tc1); const yakefileCandidates = Yakefile.defaultFilenames(); if( fileOption !== undefined ) yakefileCandidates = [fileOption]; const yakeFilePath = Yakefile.recursiveFindFile(cwd, yakefileCandidates); if (yakeFilePath === undefined) { const msg = yakefileCandidates.join(); // console.log(util.inspect(yakefileCandidates)); ERROR.raiseError(`cannot find yakefile among : ${msg}`); } const collection = TASKS.requireTasks(yakeFilePath, tc2); return collection; }
javascript
function getTasksFromYakefile(cwd, fileOption) { // find the yakefile and load (actually a dynamic 'require') tasks // first create an empty collection - dont need to use the global collection const tc1 = TC.TaskCollection(); //preload const tc2 = TASKS.loadPreloadedTasks(tc1); const yakefileCandidates = Yakefile.defaultFilenames(); if( fileOption !== undefined ) yakefileCandidates = [fileOption]; const yakeFilePath = Yakefile.recursiveFindFile(cwd, yakefileCandidates); if (yakeFilePath === undefined) { const msg = yakefileCandidates.join(); // console.log(util.inspect(yakefileCandidates)); ERROR.raiseError(`cannot find yakefile among : ${msg}`); } const collection = TASKS.requireTasks(yakeFilePath, tc2); return collection; }
[ "function", "getTasksFromYakefile", "(", "cwd", ",", "fileOption", ")", "{", "const", "tc1", "=", "TC", ".", "TaskCollection", "(", ")", ";", "const", "tc2", "=", "TASKS", ".", "loadPreloadedTasks", "(", "tc1", ")", ";", "const", "yakefileCandidates", "=", "Yakefile", ".", "defaultFilenames", "(", ")", ";", "if", "(", "fileOption", "!==", "undefined", ")", "yakefileCandidates", "=", "[", "fileOption", "]", ";", "const", "yakeFilePath", "=", "Yakefile", ".", "recursiveFindFile", "(", "cwd", ",", "yakefileCandidates", ")", ";", "if", "(", "yakeFilePath", "===", "undefined", ")", "{", "const", "msg", "=", "yakefileCandidates", ".", "join", "(", ")", ";", "ERROR", ".", "raiseError", "(", "`", "${", "msg", "}", "`", ")", ";", "}", "const", "collection", "=", "TASKS", ".", "requireTasks", "(", "yakeFilePath", ",", "tc2", ")", ";", "return", "collection", ";", "}" ]
Collects tasks from the appropriate yakefile. @param {string} cwd The directory from which to start searching for a yakefile @param {string|undefined} fileOption The value of the -c or --file option from the command line @return {TaskCollection} The tasks from yakefile.
[ "Collects", "tasks", "from", "the", "appropriate", "yakefile", "." ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L25-L48
train
robertblackwell/yake
src/yake/main.js
getTasksFromTaskfile
function getTasksFromTaskfile() { // tasks will already be loaded and are in the global collection so get it const tc = TASKS.globals.globalTaskCollection; //this time the preloads come after the custom tasks - no choice const collection = TASKS.loadPreloadedTasks(tc); return collection; }
javascript
function getTasksFromTaskfile() { // tasks will already be loaded and are in the global collection so get it const tc = TASKS.globals.globalTaskCollection; //this time the preloads come after the custom tasks - no choice const collection = TASKS.loadPreloadedTasks(tc); return collection; }
[ "function", "getTasksFromTaskfile", "(", ")", "{", "const", "tc", "=", "TASKS", ".", "globals", ".", "globalTaskCollection", ";", "const", "collection", "=", "TASKS", ".", "loadPreloadedTasks", "(", "tc", ")", ";", "return", "collection", ";", "}" ]
In taskfile mode the tasks are defined before the mainline gets called through the use of the YAKE.task function. Hence by the time this function gets called those tasks are already in a global collection. So retreived them, add default tasks return the collection @return {TaskCollection} The tasks from taskfile.
[ "In", "taskfile", "mode", "the", "tasks", "are", "defined", "before", "the", "mainline", "gets", "called", "through", "the", "use", "of", "the", "YAKE", ".", "task", "function", ".", "Hence", "by", "the", "time", "this", "function", "gets", "called", "those", "tasks", "are", "already", "in", "a", "global", "collection", ".", "So", "retreived", "them", "add", "default", "tasks", "return", "the", "collection" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L58-L65
train
robertblackwell/yake
src/yake/main.js
getTasksFromArray
function getTasksFromArray(cfgArray) { const tc = TC.TaskCollection(); // tasks are defined in a datascripture - load it const tc2 = TASKS.loadTasksFromArray(cfgArray, tc); //this time the preloads come after the custom tasks - could have done it the other way round const collection = TASKS.loadPreloadedTasks(tc2); return collection; }
javascript
function getTasksFromArray(cfgArray) { const tc = TC.TaskCollection(); // tasks are defined in a datascripture - load it const tc2 = TASKS.loadTasksFromArray(cfgArray, tc); //this time the preloads come after the custom tasks - could have done it the other way round const collection = TASKS.loadPreloadedTasks(tc2); return collection; }
[ "function", "getTasksFromArray", "(", "cfgArray", ")", "{", "const", "tc", "=", "TC", ".", "TaskCollection", "(", ")", ";", "const", "tc2", "=", "TASKS", ".", "loadTasksFromArray", "(", "cfgArray", ",", "tc", ")", ";", "const", "collection", "=", "TASKS", ".", "loadPreloadedTasks", "(", "tc2", ")", ";", "return", "collection", ";", "}" ]
IN cfg array use a data structure will have the task definitions. This will be passed to this function @param {array} cfgArray The configuration array @return {TaskCollection} The tasks from array.
[ "IN", "cfg", "array", "use", "a", "data", "structure", "will", "have", "the", "task", "definitions", ".", "This", "will", "be", "passed", "to", "this", "function" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L74-L82
train
robertblackwell/yake
src/yake/main.js
tryShowTasks
function tryShowTasks(options, collection) { if (options.getValueFor('showTasks') !== undefined) { REPORTS.printTaskList(collection); return true; } return false; }
javascript
function tryShowTasks(options, collection) { if (options.getValueFor('showTasks') !== undefined) { REPORTS.printTaskList(collection); return true; } return false; }
[ "function", "tryShowTasks", "(", "options", ",", "collection", ")", "{", "if", "(", "options", ".", "getValueFor", "(", "'showTasks'", ")", "!==", "undefined", ")", "{", "REPORTS", ".", "printTaskList", "(", "collection", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Tests command line options for 'showTasks' value. If true reports all tasks and descriptions and returns true to indicate it did something @param {CliOptions} options The options @param {TaskCollection} collection The tasks to displays
[ "Tests", "command", "line", "options", "for", "showTasks", "value", ".", "If", "true", "reports", "all", "tasks", "and", "descriptions", "and", "returns", "true", "to", "indicate", "it", "did", "something" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L91-L99
train
robertblackwell/yake
src/yake/main.js
tryRunTask
function tryRunTask(args, collection) { let nameOfTaskToRun = 'default'; const a = args.getArgs(); if (a.length > 0) { nameOfTaskToRun = a[0]; } const firstTask = collection.getByName(nameOfTaskToRun); if (firstTask === undefined) { // console.log('ERROR'); ERROR.raiseError(`task ${nameOfTaskToRun} not found`); } TASKS.invokeTask(collection, firstTask); // console.log(chalk.white.bold(`${firstTask.name()} - completed `) + chalk.green.bold('OK')); }
javascript
function tryRunTask(args, collection) { let nameOfTaskToRun = 'default'; const a = args.getArgs(); if (a.length > 0) { nameOfTaskToRun = a[0]; } const firstTask = collection.getByName(nameOfTaskToRun); if (firstTask === undefined) { // console.log('ERROR'); ERROR.raiseError(`task ${nameOfTaskToRun} not found`); } TASKS.invokeTask(collection, firstTask); // console.log(chalk.white.bold(`${firstTask.name()} - completed `) + chalk.green.bold('OK')); }
[ "function", "tryRunTask", "(", "args", ",", "collection", ")", "{", "let", "nameOfTaskToRun", "=", "'default'", ";", "const", "a", "=", "args", ".", "getArgs", "(", ")", ";", "if", "(", "a", ".", "length", ">", "0", ")", "{", "nameOfTaskToRun", "=", "a", "[", "0", "]", ";", "}", "const", "firstTask", "=", "collection", ".", "getByName", "(", "nameOfTaskToRun", ")", ";", "if", "(", "firstTask", "===", "undefined", ")", "{", "ERROR", ".", "raiseError", "(", "`", "${", "nameOfTaskToRun", "}", "`", ")", ";", "}", "TASKS", ".", "invokeTask", "(", "collection", ",", "firstTask", ")", ";", "}" ]
Looks in the CliArguments parameter and if any strings are found tries to execute those as task names and of course the prerequisites @param {CliArguments} args - The arguments @param {TaskCollection} collection - The collection of tasks from which original taska and prerequisistes will come
[ "Looks", "in", "the", "CliArguments", "parameter", "and", "if", "any", "strings", "are", "found", "tries", "to", "execute", "those", "as", "task", "names", "and", "of", "course", "the", "prerequisites" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L136-L155
train
robertblackwell/yake
src/yake/main.js
taskFileMain
function taskFileMain(argv) { if( argv === undefined ) argv = process.argv const [options, args, helpText] = CLI.taskFileParse(argv); const collection = getTasksFromTaskfile(); const p = loadPackageJson(); if( tryShowVersion(options, p.version) ) return; if( tryShowTasks(options, collection) ) return; if( tryShowHelp(options, helpText) ) return; tryRunTask(args, collection); }
javascript
function taskFileMain(argv) { if( argv === undefined ) argv = process.argv const [options, args, helpText] = CLI.taskFileParse(argv); const collection = getTasksFromTaskfile(); const p = loadPackageJson(); if( tryShowVersion(options, p.version) ) return; if( tryShowTasks(options, collection) ) return; if( tryShowHelp(options, helpText) ) return; tryRunTask(args, collection); }
[ "function", "taskFileMain", "(", "argv", ")", "{", "if", "(", "argv", "===", "undefined", ")", "argv", "=", "process", ".", "argv", "const", "[", "options", ",", "args", ",", "helpText", "]", "=", "CLI", ".", "taskFileParse", "(", "argv", ")", ";", "const", "collection", "=", "getTasksFromTaskfile", "(", ")", ";", "const", "p", "=", "loadPackageJson", "(", ")", ";", "if", "(", "tryShowVersion", "(", "options", ",", "p", ".", "version", ")", ")", "return", ";", "if", "(", "tryShowTasks", "(", "options", ",", "collection", ")", ")", "return", ";", "if", "(", "tryShowHelp", "(", "options", ",", "helpText", ")", ")", "return", ";", "tryRunTask", "(", "args", ",", "collection", ")", ";", "}" ]
The mainline of a taskfile. Only depends on the options and arguments on the command line @param {Function} argv The argv
[ "The", "mainline", "of", "a", "taskfile", ".", "Only", "depends", "on", "the", "options", "and", "arguments", "on", "the", "command", "line" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L167-L183
train
robertblackwell/yake
src/yake/main.js
yakeFileMain
function yakeFileMain(argv, cwd) { if( cwd === undefined) cwd = process.cwd(); if( argv === undefined ) argv = process.argv const [options, args, helpText] = CLI.CliParse(argv); const collection = getTasksFromYakefile(cwd, options.getValueFor('file')); const p = loadPackageJson(); if( tryShowVersion(options, p.version) ) return; if( tryShowTasks(options, collection) ) return; if( tryShowHelp(options, helpText) ) return; tryRunTask(args, collection); }
javascript
function yakeFileMain(argv, cwd) { if( cwd === undefined) cwd = process.cwd(); if( argv === undefined ) argv = process.argv const [options, args, helpText] = CLI.CliParse(argv); const collection = getTasksFromYakefile(cwd, options.getValueFor('file')); const p = loadPackageJson(); if( tryShowVersion(options, p.version) ) return; if( tryShowTasks(options, collection) ) return; if( tryShowHelp(options, helpText) ) return; tryRunTask(args, collection); }
[ "function", "yakeFileMain", "(", "argv", ",", "cwd", ")", "{", "if", "(", "cwd", "===", "undefined", ")", "cwd", "=", "process", ".", "cwd", "(", ")", ";", "if", "(", "argv", "===", "undefined", ")", "argv", "=", "process", ".", "argv", "const", "[", "options", ",", "args", ",", "helpText", "]", "=", "CLI", ".", "CliParse", "(", "argv", ")", ";", "const", "collection", "=", "getTasksFromYakefile", "(", "cwd", ",", "options", ".", "getValueFor", "(", "'file'", ")", ")", ";", "const", "p", "=", "loadPackageJson", "(", ")", ";", "if", "(", "tryShowVersion", "(", "options", ",", "p", ".", "version", ")", ")", "return", ";", "if", "(", "tryShowTasks", "(", "options", ",", "collection", ")", ")", "return", ";", "if", "(", "tryShowHelp", "(", "options", ",", "helpText", ")", ")", "return", ";", "tryRunTask", "(", "args", ",", "collection", ")", ";", "}" ]
The mainline for use in the yake command. Depends on the options and arguments on the command line plus the directory from which to start the search for a yakefile @param {Function} argv The argv
[ "The", "mainline", "for", "use", "in", "the", "yake", "command", ".", "Depends", "on", "the", "options", "and", "arguments", "on", "the", "command", "line", "plus", "the", "directory", "from", "which", "to", "start", "the", "search", "for", "a", "yakefile" ]
172b02e29303fb718bac88bbda9b85749c57169c
https://github.com/robertblackwell/yake/blob/172b02e29303fb718bac88bbda9b85749c57169c/src/yake/main.js#L191-L208
train
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; var insightsPanel = self.buildInsightsPanel(); var media = insightsPanel + '<div class="media">' + ' <div class="media-left">' + // the visual chart as media-object. ' <div class="media-object" id="' + self.getId('chart') + '">Charts</div>' + ' </div>' + ' <div class="media-body">' + ' <div id="' + self.getId('summary') + '">Summary</div>' + ' </div>' + '</div>'; $('#' + self.attrId).html(media); }
javascript
function() { var self = this; var insightsPanel = self.buildInsightsPanel(); var media = insightsPanel + '<div class="media">' + ' <div class="media-left">' + // the visual chart as media-object. ' <div class="media-object" id="' + self.getId('chart') + '">Charts</div>' + ' </div>' + ' <div class="media-body">' + ' <div id="' + self.getId('summary') + '">Summary</div>' + ' </div>' + '</div>'; $('#' + self.attrId).html(media); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "var", "insightsPanel", "=", "self", ".", "buildInsightsPanel", "(", ")", ";", "var", "media", "=", "insightsPanel", "+", "'<div class=\"media\">'", "+", "' <div class=\"media-left\">'", "+", "' <div class=\"media-object\" id=\"'", "+", "self", ".", "getId", "(", "'chart'", ")", "+", "'\">Charts</div>'", "+", "' </div>'", "+", "' <div class=\"media-body\">'", "+", "' <div id=\"'", "+", "self", ".", "getId", "(", "'summary'", ")", "+", "'\">Summary</div>'", "+", "' </div>'", "+", "'</div>'", ";", "$", "(", "'#'", "+", "self", ".", "attrId", ")", ".", "html", "(", "media", ")", ";", "}" ]
build the dashboard as media object. build the chart, using corresponding jQuery plugins create the summary
[ "build", "the", "dashboard", "as", "media", "object", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L439-L458
train
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; var panel = '<div class="panel panel-success">' + ' <div class="panel-heading">' + ' visual data dashboard mockups' + ' </div>' + ' <div class="panel-body">' + ' <div class="row">' + // the visual chart. ' <div class="col-md-8">' + ' <div id="' + self.getId('chart') + '">Charts</div>' + ' </div>' + // the information column ' <div class="col-md-4">' + ' <div id="' + self.getId('summary') + '">Summary</div>' + ' </div>' + ' </div>' + ' </div>' + ' <div class="panel-footer">' + ' visual data footer mockups' + ' </div>' + '</div>'; $('#' + self.attrId).html(panel); // Draw the chart, $('#' + self.getId('chart')).html('') .bilevelSunburst({date: self.options.date}, self.treemapData); }
javascript
function() { var self = this; var panel = '<div class="panel panel-success">' + ' <div class="panel-heading">' + ' visual data dashboard mockups' + ' </div>' + ' <div class="panel-body">' + ' <div class="row">' + // the visual chart. ' <div class="col-md-8">' + ' <div id="' + self.getId('chart') + '">Charts</div>' + ' </div>' + // the information column ' <div class="col-md-4">' + ' <div id="' + self.getId('summary') + '">Summary</div>' + ' </div>' + ' </div>' + ' </div>' + ' <div class="panel-footer">' + ' visual data footer mockups' + ' </div>' + '</div>'; $('#' + self.attrId).html(panel); // Draw the chart, $('#' + self.getId('chart')).html('') .bilevelSunburst({date: self.options.date}, self.treemapData); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "var", "panel", "=", "'<div class=\"panel panel-success\">'", "+", "' <div class=\"panel-heading\">'", "+", "' visual data dashboard mockups'", "+", "' </div>'", "+", "' <div class=\"panel-body\">'", "+", "' <div class=\"row\">'", "+", "' <div class=\"col-md-8\">'", "+", "' <div id=\"'", "+", "self", ".", "getId", "(", "'chart'", ")", "+", "'\">Charts</div>'", "+", "' </div>'", "+", "' <div class=\"col-md-4\">'", "+", "' <div id=\"'", "+", "self", ".", "getId", "(", "'summary'", ")", "+", "'\">Summary</div>'", "+", "' </div>'", "+", "' </div>'", "+", "' </div>'", "+", "' <div class=\"panel-footer\">'", "+", "' visual data footer mockups'", "+", "' </div>'", "+", "'</div>'", ";", "$", "(", "'#'", "+", "self", ".", "attrId", ")", ".", "html", "(", "panel", ")", ";", "$", "(", "'#'", "+", "self", ".", "getId", "(", "'chart'", ")", ")", ".", "html", "(", "''", ")", ".", "bilevelSunburst", "(", "{", "date", ":", "self", ".", "options", ".", "date", "}", ",", "self", ".", "treemapData", ")", ";", "}" ]
build the panel as dashboard. Where is data from? build the chart, using corresponding jQuery plugins create the summary FIXME: panel class NOT working well with z-index. panel class seems overlap the z-index most time.
[ "build", "the", "panel", "as", "dashboard", ".", "Where", "is", "data", "from?" ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L470-L502
train
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; // Draw the chart, $('#' + self.getId('chart')).html('') .bilevelSunburst({date: self.options.date}, self.treemapData); }
javascript
function() { var self = this; // Draw the chart, $('#' + self.getId('chart')).html('') .bilevelSunburst({date: self.options.date}, self.treemapData); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "$", "(", "'#'", "+", "self", ".", "getId", "(", "'chart'", ")", ")", ".", "html", "(", "''", ")", ".", "bilevelSunburst", "(", "{", "date", ":", "self", ".", "options", ".", "date", "}", ",", "self", ".", "treemapData", ")", ";", "}" ]
create this utility function to draw chart, we could use it whenever we need. For example, after we re-arrange the dashboard, we will need re-draw the chart. the chart will re-calculate all positions.
[ "create", "this", "utility", "function", "to", "draw", "chart", "we", "could", "use", "it", "whenever", "we", "need", ".", "For", "example", "after", "we", "re", "-", "arrange", "the", "dashboard", "we", "will", "need", "re", "-", "draw", "the", "chart", ".", "the", "chart", "will", "re", "-", "calculate", "all", "positions", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L511-L519
train
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; var summary = self.tableSummaryBuilder(self.groupsSummary, self.pagesSummary, self.total); $('#' + self.getId('summary')).html(summary); }
javascript
function() { var self = this; var summary = self.tableSummaryBuilder(self.groupsSummary, self.pagesSummary, self.total); $('#' + self.getId('summary')).html(summary); }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "var", "summary", "=", "self", ".", "tableSummaryBuilder", "(", "self", ".", "groupsSummary", ",", "self", ".", "pagesSummary", ",", "self", ".", "total", ")", ";", "$", "(", "'#'", "+", "self", ".", "getId", "(", "'summary'", ")", ")", ".", "html", "(", "summary", ")", ";", "}" ]
utility function to build summary. TODO: this should allow developer to customize!
[ "utility", "function", "to", "build", "summary", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L526-L535
train
leocornus/leocornus-visualdata
src/visual-data.js
function(groupName, totalSites, totalPages, totalPageviews) { var format = d3.format(',d'); // build var summary = '<tr>' + '<td>' + groupName + '</td>' + '<td>' + format(totalPageviews) + '</td>' + '<td>' + format(totalPages) + '</td>' + //'<td>' + totalSites + '</td>' + '</tr>'; return summary; }
javascript
function(groupName, totalSites, totalPages, totalPageviews) { var format = d3.format(',d'); // build var summary = '<tr>' + '<td>' + groupName + '</td>' + '<td>' + format(totalPageviews) + '</td>' + '<td>' + format(totalPages) + '</td>' + //'<td>' + totalSites + '</td>' + '</tr>'; return summary; }
[ "function", "(", "groupName", ",", "totalSites", ",", "totalPages", ",", "totalPageviews", ")", "{", "var", "format", "=", "d3", ".", "format", "(", "',d'", ")", ";", "var", "summary", "=", "'<tr>'", "+", "'<td>'", "+", "groupName", "+", "'</td>'", "+", "'<td>'", "+", "format", "(", "totalPageviews", ")", "+", "'</td>'", "+", "'<td>'", "+", "format", "(", "totalPages", ")", "+", "'</td>'", "+", "'</tr>'", ";", "return", "summary", ";", "}" ]
build row for each table.. <tr> <td>MOF</td> <td>2089</td> <td>345</td> </tr>
[ "build", "row", "for", "each", "table", ".." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L651-L664
train
leocornus/leocornus-visualdata
src/visual-data.js
function() { var self = this; if(this.options.insightsFeeder) { // use the customize insights feeder self.options.insightsFeeder(self); } else { // using the default insights feeder. self.defaultInsightsFeeder(self); } }
javascript
function() { var self = this; if(this.options.insightsFeeder) { // use the customize insights feeder self.options.insightsFeeder(self); } else { // using the default insights feeder. self.defaultInsightsFeeder(self); } }
[ "function", "(", ")", "{", "var", "self", "=", "this", ";", "if", "(", "this", ".", "options", ".", "insightsFeeder", ")", "{", "self", ".", "options", ".", "insightsFeeder", "(", "self", ")", ";", "}", "else", "{", "self", ".", "defaultInsightsFeeder", "(", "self", ")", ";", "}", "}" ]
feed insights.
[ "feed", "insights", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L707-L718
train
leocornus/leocornus-visualdata
src/visual-data.js
function(visualData) { var insightsList = '<li class="list-group-item">The site served' + ' <strong>' + visualData.total[0] + '</strong> total pageviews on' + ' <strong>' + visualData.total[1] + '</strong> pages of' + ' <strong>' + visualData.total[2] + '</strong> sites' + '</li>' + // the first group '<li class="list-group-item">The No. 1 group is <strong>' + visualData.groupsPageviews[0][0] + '</strong>, which has <strong>' + visualData.groupsPageviews[0][1] + '</strong> pageviews' + '</li>' + // the most viewed single page '<li class="list-group-item">The most views single page is <strong>' + visualData.jsonData[0][0] + '</strong>, which has <strong>' + visualData.jsonData[0][2] + '</strong> pageviews' + '</li>'; $('#' + visualData.getId('insightsList')).html(insightsList); }
javascript
function(visualData) { var insightsList = '<li class="list-group-item">The site served' + ' <strong>' + visualData.total[0] + '</strong> total pageviews on' + ' <strong>' + visualData.total[1] + '</strong> pages of' + ' <strong>' + visualData.total[2] + '</strong> sites' + '</li>' + // the first group '<li class="list-group-item">The No. 1 group is <strong>' + visualData.groupsPageviews[0][0] + '</strong>, which has <strong>' + visualData.groupsPageviews[0][1] + '</strong> pageviews' + '</li>' + // the most viewed single page '<li class="list-group-item">The most views single page is <strong>' + visualData.jsonData[0][0] + '</strong>, which has <strong>' + visualData.jsonData[0][2] + '</strong> pageviews' + '</li>'; $('#' + visualData.getId('insightsList')).html(insightsList); }
[ "function", "(", "visualData", ")", "{", "var", "insightsList", "=", "'<li class=\"list-group-item\">The site served'", "+", "' <strong>'", "+", "visualData", ".", "total", "[", "0", "]", "+", "'</strong> total pageviews on'", "+", "' <strong>'", "+", "visualData", ".", "total", "[", "1", "]", "+", "'</strong> pages of'", "+", "' <strong>'", "+", "visualData", ".", "total", "[", "2", "]", "+", "'</strong> sites'", "+", "'</li>'", "+", "'<li class=\"list-group-item\">The No. 1 group is <strong>'", "+", "visualData", ".", "groupsPageviews", "[", "0", "]", "[", "0", "]", "+", "'</strong>, which has <strong>'", "+", "visualData", ".", "groupsPageviews", "[", "0", "]", "[", "1", "]", "+", "'</strong> pageviews'", "+", "'</li>'", "+", "'<li class=\"list-group-item\">The most views single page is <strong>'", "+", "visualData", ".", "jsonData", "[", "0", "]", "[", "0", "]", "+", "'</strong>, which has <strong>'", "+", "visualData", ".", "jsonData", "[", "0", "]", "[", "2", "]", "+", "'</strong> pageviews'", "+", "'</li>'", ";", "$", "(", "'#'", "+", "visualData", ".", "getId", "(", "'insightsList'", ")", ")", ".", "html", "(", "insightsList", ")", ";", "}" ]
the default Insights feeder.
[ "the", "default", "Insights", "feeder", "." ]
9d9714ca11c126f0250e650f3c1c4086709af3ab
https://github.com/leocornus/leocornus-visualdata/blob/9d9714ca11c126f0250e650f3c1c4086709af3ab/src/visual-data.js#L723-L743
train
michaelnisi/speculum
example.js
run
function run (x, cb) { const s = speculum(null, Echo, x) s.on('end', cb) s.on('error', cb) const reader = new Count({ highWaterMark: 0 }, 10) reader.pipe(s).resume() }
javascript
function run (x, cb) { const s = speculum(null, Echo, x) s.on('end', cb) s.on('error', cb) const reader = new Count({ highWaterMark: 0 }, 10) reader.pipe(s).resume() }
[ "function", "run", "(", "x", ",", "cb", ")", "{", "const", "s", "=", "speculum", "(", "null", ",", "Echo", ",", "x", ")", "s", ".", "on", "(", "'end'", ",", "cb", ")", "s", ".", "on", "(", "'error'", ",", "cb", ")", "const", "reader", "=", "new", "Count", "(", "{", "highWaterMark", ":", "0", "}", ",", "10", ")", "reader", ".", "pipe", "(", "s", ")", ".", "resume", "(", ")", "}" ]
Leverage x streams to transform, delayed echoing in this example, data from our readable stream.
[ "Leverage", "x", "streams", "to", "transform", "delayed", "echoing", "in", "this", "example", "data", "from", "our", "readable", "stream", "." ]
b98bfbab7ab3cf57c959967afbdf803c34abf6a6
https://github.com/michaelnisi/speculum/blob/b98bfbab7ab3cf57c959967afbdf803c34abf6a6/example.js#L44-L52
train