id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
24,100
ember-cli/loader.js
benchmarks/scenarios/ember.js
Morph
function Morph(domHelper, contextualElement) { this.domHelper = domHelper; // context if content if current content is detached this.contextualElement = contextualElement; // inclusive range of morph // these should be nodeType 1, 3, or 8 this.firstNode = null; this.lastNode = null; // flag to force text to setContent to be treated as html this.parseTextAsHTML = false; // morph list graph this.parentMorphList = null; this.previousMorph = null; this.nextMorph = null; }
javascript
function Morph(domHelper, contextualElement) { this.domHelper = domHelper; // context if content if current content is detached this.contextualElement = contextualElement; // inclusive range of morph // these should be nodeType 1, 3, or 8 this.firstNode = null; this.lastNode = null; // flag to force text to setContent to be treated as html this.parseTextAsHTML = false; // morph list graph this.parentMorphList = null; this.previousMorph = null; this.nextMorph = null; }
[ "function", "Morph", "(", "domHelper", ",", "contextualElement", ")", "{", "this", ".", "domHelper", "=", "domHelper", ";", "// context if content if current content is detached", "this", ".", "contextualElement", "=", "contextualElement", ";", "// inclusive range of morph", "// these should be nodeType 1, 3, or 8", "this", ".", "firstNode", "=", "null", ";", "this", ".", "lastNode", "=", "null", ";", "// flag to force text to setContent to be treated as html", "this", ".", "parseTextAsHTML", "=", "false", ";", "// morph list graph", "this", ".", "parentMorphList", "=", "null", ";", "this", ".", "previousMorph", "=", "null", ";", "this", ".", "nextMorph", "=", "null", ";", "}" ]
constructor just initializes the fields use one of the static initializers to create a valid morph.
[ "constructor", "just", "initializes", "the", "fields", "use", "one", "of", "the", "static", "initializers", "to", "create", "a", "valid", "morph", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L51201-L51217
24,101
ember-cli/loader.js
benchmarks/scenarios/ember.js
ReferenceIterator
function ReferenceIterator(iterable) { _classCallCheck(this, ReferenceIterator); this.iterator = null; var artifacts = new IterationArtifacts(iterable); this.artifacts = artifacts; }
javascript
function ReferenceIterator(iterable) { _classCallCheck(this, ReferenceIterator); this.iterator = null; var artifacts = new IterationArtifacts(iterable); this.artifacts = artifacts; }
[ "function", "ReferenceIterator", "(", "iterable", ")", "{", "_classCallCheck", "(", "this", ",", "ReferenceIterator", ")", ";", "this", ".", "iterator", "=", "null", ";", "var", "artifacts", "=", "new", "IterationArtifacts", "(", "iterable", ")", ";", "this", ".", "artifacts", "=", "artifacts", ";", "}" ]
if anyone needs to construct this object with something other than an iterable, let @wycats know.
[ "if", "anyone", "needs", "to", "construct", "this", "object", "with", "something", "other", "than", "an", "iterable", "let" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L51675-L51681
24,102
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (ch) { // DEBUG "Processing `" + ch + "`:" var nextStates = this.nextStates, child, charSpec, chars; // DEBUG " " + debugState(this) var returned = []; for (var i = 0, l = nextStates.length; i < l; i++) { child = nextStates[i]; charSpec = child.charSpec; if (typeof (chars = charSpec.validChars) !== 'undefined') { if (chars.indexOf(ch) !== -1) { returned.push(child); } } else if (typeof (chars = charSpec.invalidChars) !== 'undefined') { if (chars.indexOf(ch) === -1) { returned.push(child); } } } return returned; }
javascript
function (ch) { // DEBUG "Processing `" + ch + "`:" var nextStates = this.nextStates, child, charSpec, chars; // DEBUG " " + debugState(this) var returned = []; for (var i = 0, l = nextStates.length; i < l; i++) { child = nextStates[i]; charSpec = child.charSpec; if (typeof (chars = charSpec.validChars) !== 'undefined') { if (chars.indexOf(ch) !== -1) { returned.push(child); } } else if (typeof (chars = charSpec.invalidChars) !== 'undefined') { if (chars.indexOf(ch) === -1) { returned.push(child); } } } return returned; }
[ "function", "(", "ch", ")", "{", "// DEBUG \"Processing `\" + ch + \"`:\"", "var", "nextStates", "=", "this", ".", "nextStates", ",", "child", ",", "charSpec", ",", "chars", ";", "// DEBUG \" \" + debugState(this)", "var", "returned", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ",", "l", "=", "nextStates", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "child", "=", "nextStates", "[", "i", "]", ";", "charSpec", "=", "child", ".", "charSpec", ";", "if", "(", "typeof", "(", "chars", "=", "charSpec", ".", "validChars", ")", "!==", "'undefined'", ")", "{", "if", "(", "chars", ".", "indexOf", "(", "ch", ")", "!==", "-", "1", ")", "{", "returned", ".", "push", "(", "child", ")", ";", "}", "}", "else", "if", "(", "typeof", "(", "chars", "=", "charSpec", ".", "invalidChars", ")", "!==", "'undefined'", ")", "{", "if", "(", "chars", ".", "indexOf", "(", "ch", ")", "===", "-", "1", ")", "{", "returned", ".", "push", "(", "child", ")", ";", "}", "}", "}", "return", "returned", ";", "}" ]
Find a list of child states matching the next character
[ "Find", "a", "list", "of", "child", "states", "matching", "the", "next", "character" ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L61012-L61039
24,103
ember-cli/loader.js
benchmarks/scenarios/ember.js
function (handlerName) { var partitionedArgs = _routerUtils.extractQueryParams(_routerUtils.slice.call(arguments, 1)), suppliedParams = partitionedArgs[0], queryParams = partitionedArgs[1]; // Construct a TransitionIntent with the provided params // and apply it to the present state of the router. var intent = new _routerTransitionIntentNamedTransitionIntent.default({ name: handlerName, contexts: suppliedParams }); var state = intent.applyToState(this.state, this.recognizer, this.getHandler); var params = {}; for (var i = 0, len = state.handlerInfos.length; i < len; ++i) { var handlerInfo = state.handlerInfos[i]; var handlerParams = handlerInfo.serialize(); _routerUtils.merge(params, handlerParams); } params.queryParams = queryParams; return this.recognizer.generate(handlerName, params); }
javascript
function (handlerName) { var partitionedArgs = _routerUtils.extractQueryParams(_routerUtils.slice.call(arguments, 1)), suppliedParams = partitionedArgs[0], queryParams = partitionedArgs[1]; // Construct a TransitionIntent with the provided params // and apply it to the present state of the router. var intent = new _routerTransitionIntentNamedTransitionIntent.default({ name: handlerName, contexts: suppliedParams }); var state = intent.applyToState(this.state, this.recognizer, this.getHandler); var params = {}; for (var i = 0, len = state.handlerInfos.length; i < len; ++i) { var handlerInfo = state.handlerInfos[i]; var handlerParams = handlerInfo.serialize(); _routerUtils.merge(params, handlerParams); } params.queryParams = queryParams; return this.recognizer.generate(handlerName, params); }
[ "function", "(", "handlerName", ")", "{", "var", "partitionedArgs", "=", "_routerUtils", ".", "extractQueryParams", "(", "_routerUtils", ".", "slice", ".", "call", "(", "arguments", ",", "1", ")", ")", ",", "suppliedParams", "=", "partitionedArgs", "[", "0", "]", ",", "queryParams", "=", "partitionedArgs", "[", "1", "]", ";", "// Construct a TransitionIntent with the provided params", "// and apply it to the present state of the router.", "var", "intent", "=", "new", "_routerTransitionIntentNamedTransitionIntent", ".", "default", "(", "{", "name", ":", "handlerName", ",", "contexts", ":", "suppliedParams", "}", ")", ";", "var", "state", "=", "intent", ".", "applyToState", "(", "this", ".", "state", ",", "this", ".", "recognizer", ",", "this", ".", "getHandler", ")", ";", "var", "params", "=", "{", "}", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "state", ".", "handlerInfos", ".", "length", ";", "i", "<", "len", ";", "++", "i", ")", "{", "var", "handlerInfo", "=", "state", ".", "handlerInfos", "[", "i", "]", ";", "var", "handlerParams", "=", "handlerInfo", ".", "serialize", "(", ")", ";", "_routerUtils", ".", "merge", "(", "params", ",", "handlerParams", ")", ";", "}", "params", ".", "queryParams", "=", "queryParams", ";", "return", "this", ".", "recognizer", ".", "generate", "(", "handlerName", ",", "params", ")", ";", "}" ]
Take a named route and context objects and generate a URL. @param {String} name the name of the route to generate a URL for @param {...Object} objects a list of objects to serialize @return {String} a URL
[ "Take", "a", "named", "route", "and", "context", "objects", "and", "generate", "a", "URL", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L61957-L61977
24,104
ember-cli/loader.js
benchmarks/scenarios/ember.js
function () { if (this.isAborted) { return this; } _routerUtils.log(this.router, this.sequence, this.targetName + ": transition was aborted"); this.intent.preTransitionState = this.router.state; this.isAborted = true; this.isActive = false; this.router.activeTransition = null; return this; }
javascript
function () { if (this.isAborted) { return this; } _routerUtils.log(this.router, this.sequence, this.targetName + ": transition was aborted"); this.intent.preTransitionState = this.router.state; this.isAborted = true; this.isActive = false; this.router.activeTransition = null; return this; }
[ "function", "(", ")", "{", "if", "(", "this", ".", "isAborted", ")", "{", "return", "this", ";", "}", "_routerUtils", ".", "log", "(", "this", ".", "router", ",", "this", ".", "sequence", ",", "this", ".", "targetName", "+", "\": transition was aborted\"", ")", ";", "this", ".", "intent", ".", "preTransitionState", "=", "this", ".", "router", ".", "state", ";", "this", ".", "isAborted", "=", "true", ";", "this", ".", "isActive", "=", "false", ";", "this", ".", "router", ".", "activeTransition", "=", "null", ";", "return", "this", ";", "}" ]
Aborts the Transition. Note you can also implicitly abort a transition by initiating another transition while a previous one is underway. @method abort @return {Transition} this transition @public
[ "Aborts", "the", "Transition", ".", "Note", "you", "can", "also", "implicitly", "abort", "a", "transition", "by", "initiating", "another", "transition", "while", "a", "previous", "one", "is", "underway", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L63069-L63079
24,105
ember-cli/loader.js
benchmarks/scenarios/ember.js
race
function race(entries, label) { /*jshint validthis:true */ var Constructor = this; var promise = new Constructor(_rsvpInternal.noop, label); if (!_rsvpUtils.isArray(entries)) { _rsvpInternal.reject(promise, new TypeError('You must pass an array to race.')); return promise; } var length = entries.length; function onFulfillment(value) { _rsvpInternal.resolve(promise, value); } function onRejection(reason) { _rsvpInternal.reject(promise, reason); } for (var i = 0; promise._state === _rsvpInternal.PENDING && i < length; i++) { _rsvpInternal.subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); } return promise; }
javascript
function race(entries, label) { /*jshint validthis:true */ var Constructor = this; var promise = new Constructor(_rsvpInternal.noop, label); if (!_rsvpUtils.isArray(entries)) { _rsvpInternal.reject(promise, new TypeError('You must pass an array to race.')); return promise; } var length = entries.length; function onFulfillment(value) { _rsvpInternal.resolve(promise, value); } function onRejection(reason) { _rsvpInternal.reject(promise, reason); } for (var i = 0; promise._state === _rsvpInternal.PENDING && i < length; i++) { _rsvpInternal.subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection); } return promise; }
[ "function", "race", "(", "entries", ",", "label", ")", "{", "/*jshint validthis:true */", "var", "Constructor", "=", "this", ";", "var", "promise", "=", "new", "Constructor", "(", "_rsvpInternal", ".", "noop", ",", "label", ")", ";", "if", "(", "!", "_rsvpUtils", ".", "isArray", "(", "entries", ")", ")", "{", "_rsvpInternal", ".", "reject", "(", "promise", ",", "new", "TypeError", "(", "'You must pass an array to race.'", ")", ")", ";", "return", "promise", ";", "}", "var", "length", "=", "entries", ".", "length", ";", "function", "onFulfillment", "(", "value", ")", "{", "_rsvpInternal", ".", "resolve", "(", "promise", ",", "value", ")", ";", "}", "function", "onRejection", "(", "reason", ")", "{", "_rsvpInternal", ".", "reject", "(", "promise", ",", "reason", ")", ";", "}", "for", "(", "var", "i", "=", "0", ";", "promise", ".", "_state", "===", "_rsvpInternal", ".", "PENDING", "&&", "i", "<", "length", ";", "i", "++", ")", "{", "_rsvpInternal", ".", "subscribe", "(", "Constructor", ".", "resolve", "(", "entries", "[", "i", "]", ")", ",", "undefined", ",", "onFulfillment", ",", "onRejection", ")", ";", "}", "return", "promise", ";", "}" ]
`RSVP.Promise.race` returns a new promise which is settled in the same way as the first passed promise to settle. Example: ```javascript var promise1 = new RSVP.Promise(function(resolve, reject){ setTimeout(function(){ resolve('promise 1'); }, 200); }); var promise2 = new RSVP.Promise(function(resolve, reject){ setTimeout(function(){ resolve('promise 2'); }, 100); }); RSVP.Promise.race([promise1, promise2]).then(function(result){ result === 'promise 2' because it was resolved before promise1 was resolved. }); ``` `RSVP.Promise.race` is deterministic in that only the state of the first settled promise matters. For example, even if other promises given to the `promises` array argument are resolved, but the first settled promise has become rejected before the other promises became fulfilled, the returned promise will become rejected: ```javascript var promise1 = new RSVP.Promise(function(resolve, reject){ setTimeout(function(){ resolve('promise 1'); }, 200); }); var promise2 = new RSVP.Promise(function(resolve, reject){ setTimeout(function(){ reject(new Error('promise 2')); }, 100); }); RSVP.Promise.race([promise1, promise2]).then(function(result){ Code here never runs }, function(reason){ reason.message === 'promise 2' because promise 2 became rejected before promise 1 became fulfilled }); ``` An example real-world use case is implementing timeouts: ```javascript RSVP.Promise.race([ajax('foo.json'), timeout(5000)]) ``` @method race @static @param {Array} entries array of promises to observe @param {String} label optional string for describing the promise returned. Useful for tooling. @return {Promise} a promise which settles in the same way as the first passed promise to settle.
[ "RSVP", ".", "Promise", ".", "race", "returns", "a", "new", "promise", "which", "is", "settled", "in", "the", "same", "way", "as", "the", "first", "passed", "promise", "to", "settle", "." ]
4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101
https://github.com/ember-cli/loader.js/blob/4fe5b3dfd5e1a30d706d289bb4e5fdbd5a799101/benchmarks/scenarios/ember.js#L65258-L65284
24,106
sindresorhus/gulp-changed
index.js
fsOperationFailed
function fsOperationFailed(stream, sourceFile, err) { if (err.code !== 'ENOENT') { stream.emit('error', new PluginError('gulp-changed', err, { fileName: sourceFile.path })); } stream.push(sourceFile); }
javascript
function fsOperationFailed(stream, sourceFile, err) { if (err.code !== 'ENOENT') { stream.emit('error', new PluginError('gulp-changed', err, { fileName: sourceFile.path })); } stream.push(sourceFile); }
[ "function", "fsOperationFailed", "(", "stream", ",", "sourceFile", ",", "err", ")", "{", "if", "(", "err", ".", "code", "!==", "'ENOENT'", ")", "{", "stream", ".", "emit", "(", "'error'", ",", "new", "PluginError", "(", "'gulp-changed'", ",", "err", ",", "{", "fileName", ":", "sourceFile", ".", "path", "}", ")", ")", ";", "}", "stream", ".", "push", "(", "sourceFile", ")", ";", "}" ]
Ignore missing file error
[ "Ignore", "missing", "file", "error" ]
df7582f848aba597b9e821dbb8507ddd208178d7
https://github.com/sindresorhus/gulp-changed/blob/df7582f848aba597b9e821dbb8507ddd208178d7/index.js#L13-L21
24,107
sindresorhus/gulp-changed
index.js
compareLastModifiedTime
function compareLastModifiedTime(stream, sourceFile, targetPath) { return stat(targetPath) .then(targetStat => { if (sourceFile.stat && sourceFile.stat.mtime > targetStat.mtime) { stream.push(sourceFile); } }); }
javascript
function compareLastModifiedTime(stream, sourceFile, targetPath) { return stat(targetPath) .then(targetStat => { if (sourceFile.stat && sourceFile.stat.mtime > targetStat.mtime) { stream.push(sourceFile); } }); }
[ "function", "compareLastModifiedTime", "(", "stream", ",", "sourceFile", ",", "targetPath", ")", "{", "return", "stat", "(", "targetPath", ")", ".", "then", "(", "targetStat", "=>", "{", "if", "(", "sourceFile", ".", "stat", "&&", "sourceFile", ".", "stat", ".", "mtime", ">", "targetStat", ".", "mtime", ")", "{", "stream", ".", "push", "(", "sourceFile", ")", ";", "}", "}", ")", ";", "}" ]
Only push through files changed more recently than the destination files
[ "Only", "push", "through", "files", "changed", "more", "recently", "than", "the", "destination", "files" ]
df7582f848aba597b9e821dbb8507ddd208178d7
https://github.com/sindresorhus/gulp-changed/blob/df7582f848aba597b9e821dbb8507ddd208178d7/index.js#L24-L31
24,108
sindresorhus/gulp-changed
index.js
compareContents
function compareContents(stream, sourceFile, targetPath) { return readFile(targetPath) .then(targetData => { if (sourceFile.isNull() || !sourceFile.contents.equals(targetData)) { stream.push(sourceFile); } }); }
javascript
function compareContents(stream, sourceFile, targetPath) { return readFile(targetPath) .then(targetData => { if (sourceFile.isNull() || !sourceFile.contents.equals(targetData)) { stream.push(sourceFile); } }); }
[ "function", "compareContents", "(", "stream", ",", "sourceFile", ",", "targetPath", ")", "{", "return", "readFile", "(", "targetPath", ")", ".", "then", "(", "targetData", "=>", "{", "if", "(", "sourceFile", ".", "isNull", "(", ")", "||", "!", "sourceFile", ".", "contents", ".", "equals", "(", "targetData", ")", ")", "{", "stream", ".", "push", "(", "sourceFile", ")", ";", "}", "}", ")", ";", "}" ]
Only push through files with different contents than the destination files
[ "Only", "push", "through", "files", "with", "different", "contents", "than", "the", "destination", "files" ]
df7582f848aba597b9e821dbb8507ddd208178d7
https://github.com/sindresorhus/gulp-changed/blob/df7582f848aba597b9e821dbb8507ddd208178d7/index.js#L34-L41
24,109
ghybs/Leaflet.MarkerCluster.LayerSupport
src/layersupport.js
function (layers) { var layersArray = this._toArray(layers), separated = this._checkInGetSeparated(layersArray), groups = separated.groups, i, group, id; // Batch add all single layers. this._originalAddLayers(separated.singles); // Add Layer Groups to the map so that they are registered there and // the map fires 'layeradd' events for them as well. for (i = 0; i < groups.length; i++) { group = groups[i]; id = L.stamp(group); this._proxyLayerGroups[id] = group; delete this._proxyLayerGroupsNeedRemoving[id]; if (this._map) { this._map._originalAddLayer(group); } } }
javascript
function (layers) { var layersArray = this._toArray(layers), separated = this._checkInGetSeparated(layersArray), groups = separated.groups, i, group, id; // Batch add all single layers. this._originalAddLayers(separated.singles); // Add Layer Groups to the map so that they are registered there and // the map fires 'layeradd' events for them as well. for (i = 0; i < groups.length; i++) { group = groups[i]; id = L.stamp(group); this._proxyLayerGroups[id] = group; delete this._proxyLayerGroupsNeedRemoving[id]; if (this._map) { this._map._originalAddLayer(group); } } }
[ "function", "(", "layers", ")", "{", "var", "layersArray", "=", "this", ".", "_toArray", "(", "layers", ")", ",", "separated", "=", "this", ".", "_checkInGetSeparated", "(", "layersArray", ")", ",", "groups", "=", "separated", ".", "groups", ",", "i", ",", "group", ",", "id", ";", "// Batch add all single layers.", "this", ".", "_originalAddLayers", "(", "separated", ".", "singles", ")", ";", "// Add Layer Groups to the map so that they are registered there and", "// the map fires 'layeradd' events for them as well.", "for", "(", "i", "=", "0", ";", "i", "<", "groups", ".", "length", ";", "i", "++", ")", "{", "group", "=", "groups", "[", "i", "]", ";", "id", "=", "L", ".", "stamp", "(", "group", ")", ";", "this", ".", "_proxyLayerGroups", "[", "id", "]", "=", "group", ";", "delete", "this", ".", "_proxyLayerGroupsNeedRemoving", "[", "id", "]", ";", "if", "(", "this", ".", "_map", ")", "{", "this", ".", "_map", ".", "_originalAddLayer", "(", "group", ")", ";", "}", "}", "}" ]
Checks in and adds an array of layers to this group. Layer Groups are also added to the map to fire their event. @param layers (L.Layer|L.Layer[]) single and/or group layers to be added. @returns {L.MarkerClusterGroup.LayerSupport} this.
[ "Checks", "in", "and", "adds", "an", "array", "of", "layers", "to", "this", "group", ".", "Layer", "Groups", "are", "also", "added", "to", "the", "map", "to", "fire", "their", "event", "." ]
649b3a94fad3e7fe6bc5870e2cca74b07604a934
https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport/blob/649b3a94fad3e7fe6bc5870e2cca74b07604a934/src/layersupport.js#L92-L112
24,110
ghybs/Leaflet.MarkerCluster.LayerSupport
src/layersupport.js
function (layers) { var layersArray = this._toArray(layers), separated = this._separateSingleFromGroupLayers(layersArray, { groups: [], singles: [] }), groups = separated.groups, singles = separated.singles, i = 0, group, id; // Batch remove single layers from MCG. this._originalRemoveLayers(singles); // Remove Layer Groups from the map so that they are un-registered // there and the map fires 'layerremove' events for them as well. for (; i < groups.length; i++) { group = groups[i]; id = L.stamp(group); delete this._proxyLayerGroups[id]; if (this._map) { this._map._originalRemoveLayer(group); } else { this._proxyLayerGroupsNeedRemoving[id] = group; } } return this; }
javascript
function (layers) { var layersArray = this._toArray(layers), separated = this._separateSingleFromGroupLayers(layersArray, { groups: [], singles: [] }), groups = separated.groups, singles = separated.singles, i = 0, group, id; // Batch remove single layers from MCG. this._originalRemoveLayers(singles); // Remove Layer Groups from the map so that they are un-registered // there and the map fires 'layerremove' events for them as well. for (; i < groups.length; i++) { group = groups[i]; id = L.stamp(group); delete this._proxyLayerGroups[id]; if (this._map) { this._map._originalRemoveLayer(group); } else { this._proxyLayerGroupsNeedRemoving[id] = group; } } return this; }
[ "function", "(", "layers", ")", "{", "var", "layersArray", "=", "this", ".", "_toArray", "(", "layers", ")", ",", "separated", "=", "this", ".", "_separateSingleFromGroupLayers", "(", "layersArray", ",", "{", "groups", ":", "[", "]", ",", "singles", ":", "[", "]", "}", ")", ",", "groups", "=", "separated", ".", "groups", ",", "singles", "=", "separated", ".", "singles", ",", "i", "=", "0", ",", "group", ",", "id", ";", "// Batch remove single layers from MCG.", "this", ".", "_originalRemoveLayers", "(", "singles", ")", ";", "// Remove Layer Groups from the map so that they are un-registered", "// there and the map fires 'layerremove' events for them as well.", "for", "(", ";", "i", "<", "groups", ".", "length", ";", "i", "++", ")", "{", "group", "=", "groups", "[", "i", "]", ";", "id", "=", "L", ".", "stamp", "(", "group", ")", ";", "delete", "this", ".", "_proxyLayerGroups", "[", "id", "]", ";", "if", "(", "this", ".", "_map", ")", "{", "this", ".", "_map", ".", "_originalRemoveLayer", "(", "group", ")", ";", "}", "else", "{", "this", ".", "_proxyLayerGroupsNeedRemoving", "[", "id", "]", "=", "group", ";", "}", "}", "return", "this", ";", "}" ]
Removes layers from this group but without check out. Layer Groups are also removed from the map to fire their event. @param layers (L.Layer|L.Layer[]) single and/or group layers to be removed. @returns {L.MarkerClusterGroup.LayerSupport} this.
[ "Removes", "layers", "from", "this", "group", "but", "without", "check", "out", ".", "Layer", "Groups", "are", "also", "removed", "from", "the", "map", "to", "fire", "their", "event", "." ]
649b3a94fad3e7fe6bc5870e2cca74b07604a934
https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport/blob/649b3a94fad3e7fe6bc5870e2cca74b07604a934/src/layersupport.js#L126-L154
24,111
ghybs/Leaflet.MarkerCluster.LayerSupport
src/layersupport.js
function (layer, operationType) { var duration = this.options.singleAddRemoveBufferDuration, fn; if (duration > 0) { this._singleAddRemoveBuffer.push({ type: operationType, layer: layer }); if (!this._singleAddRemoveBufferTimeout) { fn = L.bind(this._processSingleAddRemoveBuffer, this); this._singleAddRemoveBufferTimeout = setTimeout(fn, duration); } } else { // If duration <= 0, process synchronously. this[operationType](layer); } }
javascript
function (layer, operationType) { var duration = this.options.singleAddRemoveBufferDuration, fn; if (duration > 0) { this._singleAddRemoveBuffer.push({ type: operationType, layer: layer }); if (!this._singleAddRemoveBufferTimeout) { fn = L.bind(this._processSingleAddRemoveBuffer, this); this._singleAddRemoveBufferTimeout = setTimeout(fn, duration); } } else { // If duration <= 0, process synchronously. this[operationType](layer); } }
[ "function", "(", "layer", ",", "operationType", ")", "{", "var", "duration", "=", "this", ".", "options", ".", "singleAddRemoveBufferDuration", ",", "fn", ";", "if", "(", "duration", ">", "0", ")", "{", "this", ".", "_singleAddRemoveBuffer", ".", "push", "(", "{", "type", ":", "operationType", ",", "layer", ":", "layer", "}", ")", ";", "if", "(", "!", "this", ".", "_singleAddRemoveBufferTimeout", ")", "{", "fn", "=", "L", ".", "bind", "(", "this", ".", "_processSingleAddRemoveBuffer", ",", "this", ")", ";", "this", ".", "_singleAddRemoveBufferTimeout", "=", "setTimeout", "(", "fn", ",", "duration", ")", ";", "}", "}", "else", "{", "// If duration <= 0, process synchronously.", "this", "[", "operationType", "]", "(", "layer", ")", ";", "}", "}" ]
Do not restore the original map methods when removing the group from it. Leaving them as-is does not harm, whereas restoring the original ones may kill the functionality of potential other LayerSupport groups on the same map. Therefore we do not need to override onRemove.
[ "Do", "not", "restore", "the", "original", "map", "methods", "when", "removing", "the", "group", "from", "it", ".", "Leaving", "them", "as", "-", "is", "does", "not", "harm", "whereas", "restoring", "the", "original", "ones", "may", "kill", "the", "functionality", "of", "potential", "other", "LayerSupport", "groups", "on", "the", "same", "map", ".", "Therefore", "we", "do", "not", "need", "to", "override", "onRemove", "." ]
649b3a94fad3e7fe6bc5870e2cca74b07604a934
https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport/blob/649b3a94fad3e7fe6bc5870e2cca74b07604a934/src/layersupport.js#L210-L228
24,112
ghybs/Leaflet.MarkerCluster.LayerSupport
src/layersupport.js
function (layerGroup) { if (layerGroup._proxyMcgLayerSupportGroup === undefined || layerGroup._proxyMcgLayerSupportGroup !== this) { return; } delete layerGroup._proxyMcgLayerSupportGroup; layerGroup.addLayer = layerGroup._originalAddLayer; layerGroup.removeLayer = layerGroup._originalRemoveLayer; layerGroup.onAdd = layerGroup._originalOnAdd; layerGroup.onRemove = layerGroup._originalOnRemove; var id = L.stamp(layerGroup); delete this._proxyLayerGroups[id]; delete this._proxyLayerGroupsNeedRemoving[id]; this._removeFromOwnMap(layerGroup); }
javascript
function (layerGroup) { if (layerGroup._proxyMcgLayerSupportGroup === undefined || layerGroup._proxyMcgLayerSupportGroup !== this) { return; } delete layerGroup._proxyMcgLayerSupportGroup; layerGroup.addLayer = layerGroup._originalAddLayer; layerGroup.removeLayer = layerGroup._originalRemoveLayer; layerGroup.onAdd = layerGroup._originalOnAdd; layerGroup.onRemove = layerGroup._originalOnRemove; var id = L.stamp(layerGroup); delete this._proxyLayerGroups[id]; delete this._proxyLayerGroupsNeedRemoving[id]; this._removeFromOwnMap(layerGroup); }
[ "function", "(", "layerGroup", ")", "{", "if", "(", "layerGroup", ".", "_proxyMcgLayerSupportGroup", "===", "undefined", "||", "layerGroup", ".", "_proxyMcgLayerSupportGroup", "!==", "this", ")", "{", "return", ";", "}", "delete", "layerGroup", ".", "_proxyMcgLayerSupportGroup", ";", "layerGroup", ".", "addLayer", "=", "layerGroup", ".", "_originalAddLayer", ";", "layerGroup", ".", "removeLayer", "=", "layerGroup", ".", "_originalRemoveLayer", ";", "layerGroup", ".", "onAdd", "=", "layerGroup", ".", "_originalOnAdd", ";", "layerGroup", ".", "onRemove", "=", "layerGroup", ".", "_originalOnRemove", ";", "var", "id", "=", "L", ".", "stamp", "(", "layerGroup", ")", ";", "delete", "this", ".", "_proxyLayerGroups", "[", "id", "]", ";", "delete", "this", ".", "_proxyLayerGroupsNeedRemoving", "[", "id", "]", ";", "this", ".", "_removeFromOwnMap", "(", "layerGroup", ")", ";", "}" ]
Restore the normal LayerGroup behaviour. Removal and check out of contained markers must be taken care of externally.
[ "Restore", "the", "normal", "LayerGroup", "behaviour", ".", "Removal", "and", "check", "out", "of", "contained", "markers", "must", "be", "taken", "care", "of", "externally", "." ]
649b3a94fad3e7fe6bc5870e2cca74b07604a934
https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport/blob/649b3a94fad3e7fe6bc5870e2cca74b07604a934/src/layersupport.js#L347-L365
24,113
ghybs/Leaflet.MarkerCluster.LayerSupport
src/layersupport.js
function (map) { var layers = this._layers, toBeReAdded = [], layer; for (var id in layers) { layer = layers[id]; if (layer._map) { toBeReAdded.push(layer); map._originalRemoveLayer(layer); } } return toBeReAdded; }
javascript
function (map) { var layers = this._layers, toBeReAdded = [], layer; for (var id in layers) { layer = layers[id]; if (layer._map) { toBeReAdded.push(layer); map._originalRemoveLayer(layer); } } return toBeReAdded; }
[ "function", "(", "map", ")", "{", "var", "layers", "=", "this", ".", "_layers", ",", "toBeReAdded", "=", "[", "]", ",", "layer", ";", "for", "(", "var", "id", "in", "layers", ")", "{", "layer", "=", "layers", "[", "id", "]", ";", "if", "(", "layer", ".", "_map", ")", "{", "toBeReAdded", ".", "push", "(", "layer", ")", ";", "map", ".", "_originalRemoveLayer", "(", "layer", ")", ";", "}", "}", "return", "toBeReAdded", ";", "}" ]
In case checked in layers have been added to map whereas map is not redirected.
[ "In", "case", "checked", "in", "layers", "have", "been", "added", "to", "map", "whereas", "map", "is", "not", "redirected", "." ]
649b3a94fad3e7fe6bc5870e2cca74b07604a934
https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport/blob/649b3a94fad3e7fe6bc5870e2cca74b07604a934/src/layersupport.js#L393-L407
24,114
ghybs/Leaflet.MarkerCluster.LayerSupport
src/layersupport.js
function (layer) { var id = this.getLayerId(layer); this._layers[id] = layer; if (this._map) { this._proxyMcgLayerSupportGroup.addLayer(layer); } else { this._proxyMcgLayerSupportGroup.checkIn(layer); } return this; }
javascript
function (layer) { var id = this.getLayerId(layer); this._layers[id] = layer; if (this._map) { this._proxyMcgLayerSupportGroup.addLayer(layer); } else { this._proxyMcgLayerSupportGroup.checkIn(layer); } return this; }
[ "function", "(", "layer", ")", "{", "var", "id", "=", "this", ".", "getLayerId", "(", "layer", ")", ";", "this", ".", "_layers", "[", "id", "]", "=", "layer", ";", "if", "(", "this", ".", "_map", ")", "{", "this", ".", "_proxyMcgLayerSupportGroup", ".", "addLayer", "(", "layer", ")", ";", "}", "else", "{", "this", ".", "_proxyMcgLayerSupportGroup", ".", "checkIn", "(", "layer", ")", ";", "}", "return", "this", ";", "}" ]
Re-implement to redirect addLayer to Layer Support group instead of map.
[ "Re", "-", "implement", "to", "redirect", "addLayer", "to", "Layer", "Support", "group", "instead", "of", "map", "." ]
649b3a94fad3e7fe6bc5870e2cca74b07604a934
https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport/blob/649b3a94fad3e7fe6bc5870e2cca74b07604a934/src/layersupport.js#L489-L501
24,115
ghybs/Leaflet.MarkerCluster.LayerSupport
src/layersupport.js
function (layer) { var id = layer in this._layers ? layer : this.getLayerId(layer); this._proxyMcgLayerSupportGroup.removeLayer(layer); delete this._layers[id]; return this; }
javascript
function (layer) { var id = layer in this._layers ? layer : this.getLayerId(layer); this._proxyMcgLayerSupportGroup.removeLayer(layer); delete this._layers[id]; return this; }
[ "function", "(", "layer", ")", "{", "var", "id", "=", "layer", "in", "this", ".", "_layers", "?", "layer", ":", "this", ".", "getLayerId", "(", "layer", ")", ";", "this", ".", "_proxyMcgLayerSupportGroup", ".", "removeLayer", "(", "layer", ")", ";", "delete", "this", ".", "_layers", "[", "id", "]", ";", "return", "this", ";", "}" ]
Re-implement to redirect removeLayer to Layer Support group instead of map.
[ "Re", "-", "implement", "to", "redirect", "removeLayer", "to", "Layer", "Support", "group", "instead", "of", "map", "." ]
649b3a94fad3e7fe6bc5870e2cca74b07604a934
https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport/blob/649b3a94fad3e7fe6bc5870e2cca74b07604a934/src/layersupport.js#L504-L513
24,116
jeromeetienne/better.js
www/long-stack-traces/lib/long-stack-traces.js
wrapRegistrationFunction
function wrapRegistrationFunction(object, property, callbackArg) { if (typeof object[property] !== "function") { console.error("(long-stack-traces) Object", object, "does not contain function", property); return; } if (!has.call(object, property)) { console.warn("(long-stack-traces) Object", object, "does not directly contain function", property); } // TODO: better source position detection var sourcePosition = (object.constructor.name || Object.prototype.toString.call(object)) + "." + property; // capture the original registration function var fn = object[property]; // overwrite it with a wrapped registration function that modifies the supplied callback argument object[property] = function() { // replace the callback argument with a wrapped version that captured the current stack trace arguments[callbackArg] = makeWrappedCallback(arguments[callbackArg], sourcePosition); // call the original registration function with the modified arguments return fn.apply(this, arguments); } // check that the registration function was indeed overwritten if (object[property] === fn) console.warn("(long-stack-traces) Couldn't replace ", property, "on", object); }
javascript
function wrapRegistrationFunction(object, property, callbackArg) { if (typeof object[property] !== "function") { console.error("(long-stack-traces) Object", object, "does not contain function", property); return; } if (!has.call(object, property)) { console.warn("(long-stack-traces) Object", object, "does not directly contain function", property); } // TODO: better source position detection var sourcePosition = (object.constructor.name || Object.prototype.toString.call(object)) + "." + property; // capture the original registration function var fn = object[property]; // overwrite it with a wrapped registration function that modifies the supplied callback argument object[property] = function() { // replace the callback argument with a wrapped version that captured the current stack trace arguments[callbackArg] = makeWrappedCallback(arguments[callbackArg], sourcePosition); // call the original registration function with the modified arguments return fn.apply(this, arguments); } // check that the registration function was indeed overwritten if (object[property] === fn) console.warn("(long-stack-traces) Couldn't replace ", property, "on", object); }
[ "function", "wrapRegistrationFunction", "(", "object", ",", "property", ",", "callbackArg", ")", "{", "if", "(", "typeof", "object", "[", "property", "]", "!==", "\"function\"", ")", "{", "console", ".", "error", "(", "\"(long-stack-traces) Object\"", ",", "object", ",", "\"does not contain function\"", ",", "property", ")", ";", "return", ";", "}", "if", "(", "!", "has", ".", "call", "(", "object", ",", "property", ")", ")", "{", "console", ".", "warn", "(", "\"(long-stack-traces) Object\"", ",", "object", ",", "\"does not directly contain function\"", ",", "property", ")", ";", "}", "// TODO: better source position detection", "var", "sourcePosition", "=", "(", "object", ".", "constructor", ".", "name", "||", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "object", ")", ")", "+", "\".\"", "+", "property", ";", "// capture the original registration function", "var", "fn", "=", "object", "[", "property", "]", ";", "// overwrite it with a wrapped registration function that modifies the supplied callback argument", "object", "[", "property", "]", "=", "function", "(", ")", "{", "// replace the callback argument with a wrapped version that captured the current stack trace", "arguments", "[", "callbackArg", "]", "=", "makeWrappedCallback", "(", "arguments", "[", "callbackArg", "]", ",", "sourcePosition", ")", ";", "// call the original registration function with the modified arguments", "return", "fn", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "// check that the registration function was indeed overwritten", "if", "(", "object", "[", "property", "]", "===", "fn", ")", "console", ".", "warn", "(", "\"(long-stack-traces) Couldn't replace \"", ",", "property", ",", "\"on\"", ",", "object", ")", ";", "}" ]
Takes an object, a property name for the callback function to wrap, and an argument position and overwrites the function with a wrapper that captures the stack at the time of callback registration
[ "Takes", "an", "object", "a", "property", "name", "for", "the", "callback", "function", "to", "wrap", "and", "an", "argument", "position", "and", "overwrites", "the", "function", "with", "a", "wrapper", "that", "captures", "the", "stack", "at", "the", "time", "of", "callback", "registration" ]
248114fc31978b3c197fe227734d7da7381d4c4a
https://github.com/jeromeetienne/better.js/blob/248114fc31978b3c197fe227734d7da7381d4c4a/www/long-stack-traces/lib/long-stack-traces.js#L38-L63
24,117
jeromeetienne/better.js
www/long-stack-traces/lib/long-stack-traces.js
makeWrappedCallback
function makeWrappedCallback(callback, frameLocation) { // add a fake stack frame. we can't get a real one since we aren't inside the original function var traceError = new Error(); traceError.__location = frameLocation; traceError.__previous = currentTraceError; return function() { // if (currentTraceError) { // FIXME: This shouldn't normally happen, but it often does. Do we actually need a stack instead? // console.warn("(long-stack-traces) Internal Error: currentTrace already set."); // } // restore the trace currentTraceError = traceError; try { return callback.apply(this, arguments); } catch (e) { console.error("Uncaught " + e.stack); if (LST.rethrow) throw ""; // TODO: throw the original error, or undefined? } finally { // clear the trace so we can check that none is set above. // TODO: could we remove this for slightly better performace? currentTraceError = null; } } }
javascript
function makeWrappedCallback(callback, frameLocation) { // add a fake stack frame. we can't get a real one since we aren't inside the original function var traceError = new Error(); traceError.__location = frameLocation; traceError.__previous = currentTraceError; return function() { // if (currentTraceError) { // FIXME: This shouldn't normally happen, but it often does. Do we actually need a stack instead? // console.warn("(long-stack-traces) Internal Error: currentTrace already set."); // } // restore the trace currentTraceError = traceError; try { return callback.apply(this, arguments); } catch (e) { console.error("Uncaught " + e.stack); if (LST.rethrow) throw ""; // TODO: throw the original error, or undefined? } finally { // clear the trace so we can check that none is set above. // TODO: could we remove this for slightly better performace? currentTraceError = null; } } }
[ "function", "makeWrappedCallback", "(", "callback", ",", "frameLocation", ")", "{", "// add a fake stack frame. we can't get a real one since we aren't inside the original function", "var", "traceError", "=", "new", "Error", "(", ")", ";", "traceError", ".", "__location", "=", "frameLocation", ";", "traceError", ".", "__previous", "=", "currentTraceError", ";", "return", "function", "(", ")", "{", "// if (currentTraceError) {", "// FIXME: This shouldn't normally happen, but it often does. Do we actually need a stack instead?", "// console.warn(\"(long-stack-traces) Internal Error: currentTrace already set.\");", "// }", "// restore the trace", "currentTraceError", "=", "traceError", ";", "try", "{", "return", "callback", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", "catch", "(", "e", ")", "{", "console", ".", "error", "(", "\"Uncaught \"", "+", "e", ".", "stack", ")", ";", "if", "(", "LST", ".", "rethrow", ")", "throw", "\"\"", ";", "// TODO: throw the original error, or undefined?", "}", "finally", "{", "// clear the trace so we can check that none is set above.", "// TODO: could we remove this for slightly better performace?", "currentTraceError", "=", "null", ";", "}", "}", "}" ]
Takes a callback function and name, and captures a stack trace, returning a new callback that restores the stack frame This function adds a single function call overhead during callback registration vs. inlining it in wrapRegistationFunction
[ "Takes", "a", "callback", "function", "and", "name", "and", "captures", "a", "stack", "trace", "returning", "a", "new", "callback", "that", "restores", "the", "stack", "frame", "This", "function", "adds", "a", "single", "function", "call", "overhead", "during", "callback", "registration", "vs", ".", "inlining", "it", "in", "wrapRegistationFunction" ]
248114fc31978b3c197fe227734d7da7381d4c4a
https://github.com/jeromeetienne/better.js/blob/248114fc31978b3c197fe227734d7da7381d4c4a/www/long-stack-traces/lib/long-stack-traces.js#L67-L91
24,118
jeromeetienne/better.js
src/stacktrace.js
_parserFirefox
function _parserFirefox(error){ // start parse the error stack string var lines = error.stack.split("\n").slice(0, -1); var stacktrace = []; lines.forEach(function(line){ var matches = line.match(/^(.*)@(.+):(\d+)$/); stacktrace.push(new Stacktrace.Frame({ fct : matches[1] === '' ? '<anonymous>' : matches[1], url : matches[2], line : parseInt(matches[3], 10), column : 1 })); }); return stacktrace; }
javascript
function _parserFirefox(error){ // start parse the error stack string var lines = error.stack.split("\n").slice(0, -1); var stacktrace = []; lines.forEach(function(line){ var matches = line.match(/^(.*)@(.+):(\d+)$/); stacktrace.push(new Stacktrace.Frame({ fct : matches[1] === '' ? '<anonymous>' : matches[1], url : matches[2], line : parseInt(matches[3], 10), column : 1 })); }); return stacktrace; }
[ "function", "_parserFirefox", "(", "error", ")", "{", "// start parse the error stack string", "var", "lines", "=", "error", ".", "stack", ".", "split", "(", "\"\\n\"", ")", ".", "slice", "(", "0", ",", "-", "1", ")", ";", "var", "stacktrace", "=", "[", "]", ";", "lines", ".", "forEach", "(", "function", "(", "line", ")", "{", "var", "matches", "=", "line", ".", "match", "(", "/", "^(.*)@(.+):(\\d+)$", "/", ")", ";", "stacktrace", ".", "push", "(", "new", "Stacktrace", ".", "Frame", "(", "{", "fct", ":", "matches", "[", "1", "]", "===", "''", "?", "'<anonymous>'", ":", "matches", "[", "1", "]", ",", "url", ":", "matches", "[", "2", "]", ",", "line", ":", "parseInt", "(", "matches", "[", "3", "]", ",", "10", ")", ",", "column", ":", "1", "}", ")", ")", ";", "}", ")", ";", "return", "stacktrace", ";", "}" ]
parse the stacktrace from firefox
[ "parse", "the", "stacktrace", "from", "firefox" ]
248114fc31978b3c197fe227734d7da7381d4c4a
https://github.com/jeromeetienne/better.js/blob/248114fc31978b3c197fe227734d7da7381d4c4a/src/stacktrace.js#L108-L122
24,119
jeromeetienne/better.js
src/stacktrace.js
_parserPhantomJS
function _parserPhantomJS(error){ // start parse the error stack string var lines = error.stack.split("\n").slice(1); var stacktrace = []; lines.forEach(function(line){ if( line.match(/\(native\)$/) ){ var matches = line.match(/^\s*at (.+) \(native\)/); stacktrace.push(new Stacktrace.Frame({ fct : matches[1], url : 'native', line : 1, column : 1 })); }else if( line.match(/\)$/) ){ var matches = line.match(/^\s*at (.+) \((.+):(\d+)\)/); stacktrace.push(new Stacktrace.Frame({ fct : matches[1], url : matches[2], line : parseInt(matches[3], 10), column : 1 })); }else{ var matches = line.match(/^\s*at (.+):(\d+)/); stacktrace.push(new Stacktrace.Frame({ url : matches[1], fct : '<anonymous>', line : parseInt(matches[2], 10), column : 1 })); } }); return stacktrace; }
javascript
function _parserPhantomJS(error){ // start parse the error stack string var lines = error.stack.split("\n").slice(1); var stacktrace = []; lines.forEach(function(line){ if( line.match(/\(native\)$/) ){ var matches = line.match(/^\s*at (.+) \(native\)/); stacktrace.push(new Stacktrace.Frame({ fct : matches[1], url : 'native', line : 1, column : 1 })); }else if( line.match(/\)$/) ){ var matches = line.match(/^\s*at (.+) \((.+):(\d+)\)/); stacktrace.push(new Stacktrace.Frame({ fct : matches[1], url : matches[2], line : parseInt(matches[3], 10), column : 1 })); }else{ var matches = line.match(/^\s*at (.+):(\d+)/); stacktrace.push(new Stacktrace.Frame({ url : matches[1], fct : '<anonymous>', line : parseInt(matches[2], 10), column : 1 })); } }); return stacktrace; }
[ "function", "_parserPhantomJS", "(", "error", ")", "{", "// start parse the error stack string", "var", "lines", "=", "error", ".", "stack", ".", "split", "(", "\"\\n\"", ")", ".", "slice", "(", "1", ")", ";", "var", "stacktrace", "=", "[", "]", ";", "lines", ".", "forEach", "(", "function", "(", "line", ")", "{", "if", "(", "line", ".", "match", "(", "/", "\\(native\\)$", "/", ")", ")", "{", "var", "matches", "=", "line", ".", "match", "(", "/", "^\\s*at (.+) \\(native\\)", "/", ")", ";", "stacktrace", ".", "push", "(", "new", "Stacktrace", ".", "Frame", "(", "{", "fct", ":", "matches", "[", "1", "]", ",", "url", ":", "'native'", ",", "line", ":", "1", ",", "column", ":", "1", "}", ")", ")", ";", "}", "else", "if", "(", "line", ".", "match", "(", "/", "\\)$", "/", ")", ")", "{", "var", "matches", "=", "line", ".", "match", "(", "/", "^\\s*at (.+) \\((.+):(\\d+)\\)", "/", ")", ";", "stacktrace", ".", "push", "(", "new", "Stacktrace", ".", "Frame", "(", "{", "fct", ":", "matches", "[", "1", "]", ",", "url", ":", "matches", "[", "2", "]", ",", "line", ":", "parseInt", "(", "matches", "[", "3", "]", ",", "10", ")", ",", "column", ":", "1", "}", ")", ")", ";", "}", "else", "{", "var", "matches", "=", "line", ".", "match", "(", "/", "^\\s*at (.+):(\\d+)", "/", ")", ";", "stacktrace", ".", "push", "(", "new", "Stacktrace", ".", "Frame", "(", "{", "url", ":", "matches", "[", "1", "]", ",", "fct", ":", "'<anonymous>'", ",", "line", ":", "parseInt", "(", "matches", "[", "2", "]", ",", "10", ")", ",", "column", ":", "1", "}", ")", ")", ";", "}", "}", ")", ";", "return", "stacktrace", ";", "}" ]
parse the stacktrace from phantomJS
[ "parse", "the", "stacktrace", "from", "phantomJS" ]
248114fc31978b3c197fe227734d7da7381d4c4a
https://github.com/jeromeetienne/better.js/blob/248114fc31978b3c197fe227734d7da7381d4c4a/src/stacktrace.js#L127-L159
24,120
jeromeetienne/better.js
src/strongtyping.js
typeToString
function typeToString(allowedType){ if( allowedType === Number ) return 'Number' if( allowedType === String ) return 'String' if( allowedType === Object ) return 'Object' if( allowedType === undefined ) return 'undefined' return allowedType.toString() }
javascript
function typeToString(allowedType){ if( allowedType === Number ) return 'Number' if( allowedType === String ) return 'String' if( allowedType === Object ) return 'Object' if( allowedType === undefined ) return 'undefined' return allowedType.toString() }
[ "function", "typeToString", "(", "allowedType", ")", "{", "if", "(", "allowedType", "===", "Number", ")", "return", "'Number'", "if", "(", "allowedType", "===", "String", ")", "return", "'String'", "if", "(", "allowedType", "===", "Object", ")", "return", "'Object'", "if", "(", "allowedType", "===", "undefined", ")", "return", "'undefined'", "return", "allowedType", ".", "toString", "(", ")", "}" ]
convert one allowed type to a string @param {any} allowedType - the allowed type @return {String} - the string for this type
[ "convert", "one", "allowed", "type", "to", "a", "string" ]
248114fc31978b3c197fe227734d7da7381d4c4a
https://github.com/jeromeetienne/better.js/blob/248114fc31978b3c197fe227734d7da7381d4c4a/src/strongtyping.js#L217-L223
24,121
videojs/font
lib/grunt.js
merge
function merge(target, source) { // Check if font name is changed if (source['font-name']) { target['font-name'] = source['font-name']; } // Check if root dir is changed if (source['root-dir']) { target['root-dir'] = source['root-dir']; } // Check for icon changes if (source.icons) { for (let icon of source['icons']) { let index = iconsIndex.indexOf(icon.name); // Icon is replaced if (index !== -1) { target.icons[index] = icon; } // New icon is added else { target.icons.push(icon); iconsIndex.push(icon.name); } } } return target; }
javascript
function merge(target, source) { // Check if font name is changed if (source['font-name']) { target['font-name'] = source['font-name']; } // Check if root dir is changed if (source['root-dir']) { target['root-dir'] = source['root-dir']; } // Check for icon changes if (source.icons) { for (let icon of source['icons']) { let index = iconsIndex.indexOf(icon.name); // Icon is replaced if (index !== -1) { target.icons[index] = icon; } // New icon is added else { target.icons.push(icon); iconsIndex.push(icon.name); } } } return target; }
[ "function", "merge", "(", "target", ",", "source", ")", "{", "// Check if font name is changed", "if", "(", "source", "[", "'font-name'", "]", ")", "{", "target", "[", "'font-name'", "]", "=", "source", "[", "'font-name'", "]", ";", "}", "// Check if root dir is changed", "if", "(", "source", "[", "'root-dir'", "]", ")", "{", "target", "[", "'root-dir'", "]", "=", "source", "[", "'root-dir'", "]", ";", "}", "// Check for icon changes", "if", "(", "source", ".", "icons", ")", "{", "for", "(", "let", "icon", "of", "source", "[", "'icons'", "]", ")", "{", "let", "index", "=", "iconsIndex", ".", "indexOf", "(", "icon", ".", "name", ")", ";", "// Icon is replaced", "if", "(", "index", "!==", "-", "1", ")", "{", "target", ".", "icons", "[", "index", "]", "=", "icon", ";", "}", "// New icon is added", "else", "{", "target", ".", "icons", ".", "push", "(", "icon", ")", ";", "iconsIndex", ".", "push", "(", "icon", ".", "name", ")", ";", "}", "}", "}", "return", "target", ";", "}" ]
Merge a `source` object to a `target` recursively
[ "Merge", "a", "source", "object", "to", "a", "target", "recursively" ]
ec42c81be03f8a41f22f457eff10833e824c33b9
https://github.com/videojs/font/blob/ec42c81be03f8a41f22f457eff10833e824c33b9/lib/grunt.js#L8-L37
24,122
krampstudio/grunt-jsdoc
tasks/lib/exec.js
function(grunt, script, sources, params) { var flag; var cmd = script; var args =[]; // Compute JSDoc options for (flag in params) { if (params.hasOwnProperty(flag)) { if (params[flag] !== false) { args.push('--' + flag); } if (typeof params[flag] === 'string') { args.push(params[flag]); } } } if (!Array.isArray(sources)) { sources = [sources]; } args = args.concat(sources); grunt.log.debug('Running : ' + cmd + ' ' + args.join(' ')); return spawn(cmd, args); }
javascript
function(grunt, script, sources, params) { var flag; var cmd = script; var args =[]; // Compute JSDoc options for (flag in params) { if (params.hasOwnProperty(flag)) { if (params[flag] !== false) { args.push('--' + flag); } if (typeof params[flag] === 'string') { args.push(params[flag]); } } } if (!Array.isArray(sources)) { sources = [sources]; } args = args.concat(sources); grunt.log.debug('Running : ' + cmd + ' ' + args.join(' ')); return spawn(cmd, args); }
[ "function", "(", "grunt", ",", "script", ",", "sources", ",", "params", ")", "{", "var", "flag", ";", "var", "cmd", "=", "script", ";", "var", "args", "=", "[", "]", ";", "// Compute JSDoc options", "for", "(", "flag", "in", "params", ")", "{", "if", "(", "params", ".", "hasOwnProperty", "(", "flag", ")", ")", "{", "if", "(", "params", "[", "flag", "]", "!==", "false", ")", "{", "args", ".", "push", "(", "'--'", "+", "flag", ")", ";", "}", "if", "(", "typeof", "params", "[", "flag", "]", "===", "'string'", ")", "{", "args", ".", "push", "(", "params", "[", "flag", "]", ")", ";", "}", "}", "}", "if", "(", "!", "Array", ".", "isArray", "(", "sources", ")", ")", "{", "sources", "=", "[", "sources", "]", ";", "}", "args", "=", "args", ".", "concat", "(", "sources", ")", ";", "grunt", ".", "log", ".", "debug", "(", "'Running : '", "+", "cmd", "+", "' '", "+", "args", ".", "join", "(", "' '", ")", ")", ";", "return", "spawn", "(", "cmd", ",", "args", ")", ";", "}" ]
Build and execute a child process using the spawn function @param {Object} grunt - the grunt context @param {String} script - the script to run @param {Array} sources - the list of sources files @param {Object} params - the list of cli flags @return {ChildProcess} from the spawn
[ "Build", "and", "execute", "a", "child", "process", "using", "the", "spawn", "function" ]
7b4c6eb9db6ae207b18f1fdf37bc71d8c98c76da
https://github.com/krampstudio/grunt-jsdoc/blob/7b4c6eb9db6ae207b18f1fdf37bc71d8c98c76da/tasks/lib/exec.js#L17-L44
24,123
krampstudio/grunt-jsdoc
tasks/lib/exec.js
function(grunt) { var i, binPath, paths; var nodePath = process.env.NODE_PATH || ''; //check first the base path into the cwd paths = [ __dirname + '/../../node_modules/.bin/jsdoc', __dirname + '/../../node_modules/jsdoc/jsdoc.js', __dirname + '/../../../jsdoc/jsdoc.js' ]; //fall back on global if not found at the usual location nodePath.split(path.delimiter).forEach(function(p) { if (!/\/$/.test(p)) { p += '/'; } paths.push(p + '/jsdoc/jsdoc.js'); }); for (i in paths) { binPath = path.resolve(paths[i]); if (grunt.file.exists(binPath) && grunt.file.isFile(binPath)) { return binPath; } } return; }
javascript
function(grunt) { var i, binPath, paths; var nodePath = process.env.NODE_PATH || ''; //check first the base path into the cwd paths = [ __dirname + '/../../node_modules/.bin/jsdoc', __dirname + '/../../node_modules/jsdoc/jsdoc.js', __dirname + '/../../../jsdoc/jsdoc.js' ]; //fall back on global if not found at the usual location nodePath.split(path.delimiter).forEach(function(p) { if (!/\/$/.test(p)) { p += '/'; } paths.push(p + '/jsdoc/jsdoc.js'); }); for (i in paths) { binPath = path.resolve(paths[i]); if (grunt.file.exists(binPath) && grunt.file.isFile(binPath)) { return binPath; } } return; }
[ "function", "(", "grunt", ")", "{", "var", "i", ",", "binPath", ",", "paths", ";", "var", "nodePath", "=", "process", ".", "env", ".", "NODE_PATH", "||", "''", ";", "//check first the base path into the cwd", "paths", "=", "[", "__dirname", "+", "'/../../node_modules/.bin/jsdoc'", ",", "__dirname", "+", "'/../../node_modules/jsdoc/jsdoc.js'", ",", "__dirname", "+", "'/../../../jsdoc/jsdoc.js'", "]", ";", "//fall back on global if not found at the usual location", "nodePath", ".", "split", "(", "path", ".", "delimiter", ")", ".", "forEach", "(", "function", "(", "p", ")", "{", "if", "(", "!", "/", "\\/$", "/", ".", "test", "(", "p", ")", ")", "{", "p", "+=", "'/'", ";", "}", "paths", ".", "push", "(", "p", "+", "'/jsdoc/jsdoc.js'", ")", ";", "}", ")", ";", "for", "(", "i", "in", "paths", ")", "{", "binPath", "=", "path", ".", "resolve", "(", "paths", "[", "i", "]", ")", ";", "if", "(", "grunt", ".", "file", ".", "exists", "(", "binPath", ")", "&&", "grunt", ".", "file", ".", "isFile", "(", "binPath", ")", ")", "{", "return", "binPath", ";", "}", "}", "return", ";", "}" ]
Lookup file or path into node modules @param {Object} grunt - the grunt context @returns {String} the first matching resolved path or nothing if not found
[ "Lookup", "file", "or", "path", "into", "node", "modules" ]
7b4c6eb9db6ae207b18f1fdf37bc71d8c98c76da
https://github.com/krampstudio/grunt-jsdoc/blob/7b4c6eb9db6ae207b18f1fdf37bc71d8c98c76da/tasks/lib/exec.js#L51-L78
24,124
qlik-oss/leonardo-ui
docs/build.js
compileTemplates
function compileTemplates() { const mainHtml = fs.readFileSync(path.resolve(docsDir, 'src/template.html'), { encoding: 'utf8', }); const mainTemplate = Handlebars.compile(mainHtml); function createPage(fileName, tab, content) { const html = mainTemplate({ tabs: [{ title: 'Get started', url: 'get-started.html', selected: tab === 'get-started', }, { title: 'Components', url: 'components.html', selected: tab === 'components', }], content, luiVersion: LUI_VERSION, }); fileUtil.writeFile(path.resolve(docsDir, 'dist', fileName), html); } function createIndexPage() { const content = fs.readFileSync(path.resolve(docsDir, 'src/pages/index.html'), { encoding: 'utf8', }); const template = Handlebars.compile(content); const html = template(); return createPage('index.html', 'index', html); } function createGetStartedPage() { const content = fs.readFileSync(path.resolve(docsDir, 'src/pages/get-started.html'), { encoding: 'utf8', }); const template = Handlebars.compile(content); const html = template({ luiVersion: LUI_VERSION, }); return createPage('get-started.html', 'get-started', html); } function createComponentPage(templateName, template, tab, content) { return createPage(templateName, tab, template({ content, sections: sections.map(section => ({ name: section.name, pages: section.pages.map(page => ({ name: page.name, template: page.template, selected: page.template === templateName, })), })), })); } function createComponentPages() { const componentHtml = fs.readFileSync(path.resolve(docsDir, 'src/component-template.html'), { encoding: 'utf8', }); const componentTemplate = Handlebars.compile(componentHtml); sections.forEach((section) => { section.pages.forEach((page) => { const file = `src/pages/${page.template}`; const fileContent = fs.readFileSync(path.resolve(docsDir, file), { encoding: 'utf8', }); const template = Handlebars.compile(fileContent); const html = template(); createComponentPage(page.template, componentTemplate, 'components', html); }); }); const file = 'src/pages/components.html'; const fileContent = fs.readFileSync(path.resolve(docsDir, file), { encoding: 'utf8', }); createComponentPage('components.html', componentTemplate, 'components', fileContent); } createIndexPage(); createGetStartedPage(); createComponentPages(); }
javascript
function compileTemplates() { const mainHtml = fs.readFileSync(path.resolve(docsDir, 'src/template.html'), { encoding: 'utf8', }); const mainTemplate = Handlebars.compile(mainHtml); function createPage(fileName, tab, content) { const html = mainTemplate({ tabs: [{ title: 'Get started', url: 'get-started.html', selected: tab === 'get-started', }, { title: 'Components', url: 'components.html', selected: tab === 'components', }], content, luiVersion: LUI_VERSION, }); fileUtil.writeFile(path.resolve(docsDir, 'dist', fileName), html); } function createIndexPage() { const content = fs.readFileSync(path.resolve(docsDir, 'src/pages/index.html'), { encoding: 'utf8', }); const template = Handlebars.compile(content); const html = template(); return createPage('index.html', 'index', html); } function createGetStartedPage() { const content = fs.readFileSync(path.resolve(docsDir, 'src/pages/get-started.html'), { encoding: 'utf8', }); const template = Handlebars.compile(content); const html = template({ luiVersion: LUI_VERSION, }); return createPage('get-started.html', 'get-started', html); } function createComponentPage(templateName, template, tab, content) { return createPage(templateName, tab, template({ content, sections: sections.map(section => ({ name: section.name, pages: section.pages.map(page => ({ name: page.name, template: page.template, selected: page.template === templateName, })), })), })); } function createComponentPages() { const componentHtml = fs.readFileSync(path.resolve(docsDir, 'src/component-template.html'), { encoding: 'utf8', }); const componentTemplate = Handlebars.compile(componentHtml); sections.forEach((section) => { section.pages.forEach((page) => { const file = `src/pages/${page.template}`; const fileContent = fs.readFileSync(path.resolve(docsDir, file), { encoding: 'utf8', }); const template = Handlebars.compile(fileContent); const html = template(); createComponentPage(page.template, componentTemplate, 'components', html); }); }); const file = 'src/pages/components.html'; const fileContent = fs.readFileSync(path.resolve(docsDir, file), { encoding: 'utf8', }); createComponentPage('components.html', componentTemplate, 'components', fileContent); } createIndexPage(); createGetStartedPage(); createComponentPages(); }
[ "function", "compileTemplates", "(", ")", "{", "const", "mainHtml", "=", "fs", ".", "readFileSync", "(", "path", ".", "resolve", "(", "docsDir", ",", "'src/template.html'", ")", ",", "{", "encoding", ":", "'utf8'", ",", "}", ")", ";", "const", "mainTemplate", "=", "Handlebars", ".", "compile", "(", "mainHtml", ")", ";", "function", "createPage", "(", "fileName", ",", "tab", ",", "content", ")", "{", "const", "html", "=", "mainTemplate", "(", "{", "tabs", ":", "[", "{", "title", ":", "'Get started'", ",", "url", ":", "'get-started.html'", ",", "selected", ":", "tab", "===", "'get-started'", ",", "}", ",", "{", "title", ":", "'Components'", ",", "url", ":", "'components.html'", ",", "selected", ":", "tab", "===", "'components'", ",", "}", "]", ",", "content", ",", "luiVersion", ":", "LUI_VERSION", ",", "}", ")", ";", "fileUtil", ".", "writeFile", "(", "path", ".", "resolve", "(", "docsDir", ",", "'dist'", ",", "fileName", ")", ",", "html", ")", ";", "}", "function", "createIndexPage", "(", ")", "{", "const", "content", "=", "fs", ".", "readFileSync", "(", "path", ".", "resolve", "(", "docsDir", ",", "'src/pages/index.html'", ")", ",", "{", "encoding", ":", "'utf8'", ",", "}", ")", ";", "const", "template", "=", "Handlebars", ".", "compile", "(", "content", ")", ";", "const", "html", "=", "template", "(", ")", ";", "return", "createPage", "(", "'index.html'", ",", "'index'", ",", "html", ")", ";", "}", "function", "createGetStartedPage", "(", ")", "{", "const", "content", "=", "fs", ".", "readFileSync", "(", "path", ".", "resolve", "(", "docsDir", ",", "'src/pages/get-started.html'", ")", ",", "{", "encoding", ":", "'utf8'", ",", "}", ")", ";", "const", "template", "=", "Handlebars", ".", "compile", "(", "content", ")", ";", "const", "html", "=", "template", "(", "{", "luiVersion", ":", "LUI_VERSION", ",", "}", ")", ";", "return", "createPage", "(", "'get-started.html'", ",", "'get-started'", ",", "html", ")", ";", "}", "function", "createComponentPage", "(", "templateName", ",", "template", ",", "tab", ",", "content", ")", "{", "return", "createPage", "(", "templateName", ",", "tab", ",", "template", "(", "{", "content", ",", "sections", ":", "sections", ".", "map", "(", "section", "=>", "(", "{", "name", ":", "section", ".", "name", ",", "pages", ":", "section", ".", "pages", ".", "map", "(", "page", "=>", "(", "{", "name", ":", "page", ".", "name", ",", "template", ":", "page", ".", "template", ",", "selected", ":", "page", ".", "template", "===", "templateName", ",", "}", ")", ")", ",", "}", ")", ")", ",", "}", ")", ")", ";", "}", "function", "createComponentPages", "(", ")", "{", "const", "componentHtml", "=", "fs", ".", "readFileSync", "(", "path", ".", "resolve", "(", "docsDir", ",", "'src/component-template.html'", ")", ",", "{", "encoding", ":", "'utf8'", ",", "}", ")", ";", "const", "componentTemplate", "=", "Handlebars", ".", "compile", "(", "componentHtml", ")", ";", "sections", ".", "forEach", "(", "(", "section", ")", "=>", "{", "section", ".", "pages", ".", "forEach", "(", "(", "page", ")", "=>", "{", "const", "file", "=", "`", "${", "page", ".", "template", "}", "`", ";", "const", "fileContent", "=", "fs", ".", "readFileSync", "(", "path", ".", "resolve", "(", "docsDir", ",", "file", ")", ",", "{", "encoding", ":", "'utf8'", ",", "}", ")", ";", "const", "template", "=", "Handlebars", ".", "compile", "(", "fileContent", ")", ";", "const", "html", "=", "template", "(", ")", ";", "createComponentPage", "(", "page", ".", "template", ",", "componentTemplate", ",", "'components'", ",", "html", ")", ";", "}", ")", ";", "}", ")", ";", "const", "file", "=", "'src/pages/components.html'", ";", "const", "fileContent", "=", "fs", ".", "readFileSync", "(", "path", ".", "resolve", "(", "docsDir", ",", "file", ")", ",", "{", "encoding", ":", "'utf8'", ",", "}", ")", ";", "createComponentPage", "(", "'components.html'", ",", "componentTemplate", ",", "'components'", ",", "fileContent", ")", ";", "}", "createIndexPage", "(", ")", ";", "createGetStartedPage", "(", ")", ";", "createComponentPages", "(", ")", ";", "}" ]
Compile Handlebars templates
[ "Compile", "Handlebars", "templates" ]
b02bd30a9b951fb4fe949ff374327c2698afdb74
https://github.com/qlik-oss/leonardo-ui/blob/b02bd30a9b951fb4fe949ff374327c2698afdb74/docs/build.js#L156-L243
24,125
qlik-oss/leonardo-ui
docs/build.js
copyResources
function copyResources() { // Source code deps fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.js'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.js')); fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.js.map'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.js.map')); fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.css'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.css')); fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.css.map'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.css.map')); fileUtil.copyFile(path.resolve(docsDir, '../dist/lui-icons.ttf'), path.resolve(docsDir, 'dist/leonardo-ui/lui-icons.ttf')); fileUtil.copyFile(path.resolve(docsDir, '../dist/lui-icons.woff'), path.resolve(docsDir, 'dist/leonardo-ui/lui-icons.woff')); // Doc files glob.sync(`${path.resolve(docsDir, 'src/img')}/**.*`).forEach((file) => { const folder = path.resolve(docsDir, 'src/img/').replace(/\\/g, '/'); // Because glob uses forward slashes on all paths const fileName = file.replace(folder, ''); fileUtil.copyFile(file, path.resolve(docsDir, `dist/resources/${fileName}`)); }); }
javascript
function copyResources() { // Source code deps fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.js'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.js')); fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.js.map'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.js.map')); fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.css'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.css')); fileUtil.copyFile(path.resolve(docsDir, '../dist/leonardo-ui.css.map'), path.resolve(docsDir, 'dist/leonardo-ui/leonardo-ui.css.map')); fileUtil.copyFile(path.resolve(docsDir, '../dist/lui-icons.ttf'), path.resolve(docsDir, 'dist/leonardo-ui/lui-icons.ttf')); fileUtil.copyFile(path.resolve(docsDir, '../dist/lui-icons.woff'), path.resolve(docsDir, 'dist/leonardo-ui/lui-icons.woff')); // Doc files glob.sync(`${path.resolve(docsDir, 'src/img')}/**.*`).forEach((file) => { const folder = path.resolve(docsDir, 'src/img/').replace(/\\/g, '/'); // Because glob uses forward slashes on all paths const fileName = file.replace(folder, ''); fileUtil.copyFile(file, path.resolve(docsDir, `dist/resources/${fileName}`)); }); }
[ "function", "copyResources", "(", ")", "{", "// Source code deps", "fileUtil", ".", "copyFile", "(", "path", ".", "resolve", "(", "docsDir", ",", "'../dist/leonardo-ui.js'", ")", ",", "path", ".", "resolve", "(", "docsDir", ",", "'dist/leonardo-ui/leonardo-ui.js'", ")", ")", ";", "fileUtil", ".", "copyFile", "(", "path", ".", "resolve", "(", "docsDir", ",", "'../dist/leonardo-ui.js.map'", ")", ",", "path", ".", "resolve", "(", "docsDir", ",", "'dist/leonardo-ui/leonardo-ui.js.map'", ")", ")", ";", "fileUtil", ".", "copyFile", "(", "path", ".", "resolve", "(", "docsDir", ",", "'../dist/leonardo-ui.css'", ")", ",", "path", ".", "resolve", "(", "docsDir", ",", "'dist/leonardo-ui/leonardo-ui.css'", ")", ")", ";", "fileUtil", ".", "copyFile", "(", "path", ".", "resolve", "(", "docsDir", ",", "'../dist/leonardo-ui.css.map'", ")", ",", "path", ".", "resolve", "(", "docsDir", ",", "'dist/leonardo-ui/leonardo-ui.css.map'", ")", ")", ";", "fileUtil", ".", "copyFile", "(", "path", ".", "resolve", "(", "docsDir", ",", "'../dist/lui-icons.ttf'", ")", ",", "path", ".", "resolve", "(", "docsDir", ",", "'dist/leonardo-ui/lui-icons.ttf'", ")", ")", ";", "fileUtil", ".", "copyFile", "(", "path", ".", "resolve", "(", "docsDir", ",", "'../dist/lui-icons.woff'", ")", ",", "path", ".", "resolve", "(", "docsDir", ",", "'dist/leonardo-ui/lui-icons.woff'", ")", ")", ";", "// Doc files", "glob", ".", "sync", "(", "`", "${", "path", ".", "resolve", "(", "docsDir", ",", "'src/img'", ")", "}", "`", ")", ".", "forEach", "(", "(", "file", ")", "=>", "{", "const", "folder", "=", "path", ".", "resolve", "(", "docsDir", ",", "'src/img/'", ")", ".", "replace", "(", "/", "\\\\", "/", "g", ",", "'/'", ")", ";", "// Because glob uses forward slashes on all paths", "const", "fileName", "=", "file", ".", "replace", "(", "folder", ",", "''", ")", ";", "fileUtil", ".", "copyFile", "(", "file", ",", "path", ".", "resolve", "(", "docsDir", ",", "`", "${", "fileName", "}", "`", ")", ")", ";", "}", ")", ";", "}" ]
Copy external libraries and images
[ "Copy", "external", "libraries", "and", "images" ]
b02bd30a9b951fb4fe949ff374327c2698afdb74
https://github.com/qlik-oss/leonardo-ui/blob/b02bd30a9b951fb4fe949ff374327c2698afdb74/docs/build.js#L246-L261
24,126
systemjs/builder
lib/utils.js
getCanonicalNamePlain
function getCanonicalNamePlain(loader, normalized, isPlugin) { // now just reverse apply paths rules to get canonical name var pathMatch; // first check exact path matches for (var p in loader.paths) { if (loader.paths[p].indexOf('*') != -1) continue; var curPath = normalizePath(loader, loader.paths[p], isPlugin); // always stop on first exact match if (normalized === curPath) return p; // support trailing / in paths rules else if (curPath[curPath.length - 1] == '/' && normalized.substr(0, curPath.length - 1) == curPath.substr(0, curPath.length - 1) && (normalized.length < curPath.length || normalized[curPath.length - 1] == curPath[curPath.length - 1])) { // first case is that canonicalize('src') = 'app' for 'app/': 'src/' return normalized.length < curPath.length ? p.substr(0, p.length - 1) : p + normalized.substr(curPath.length); } } // then wildcard matches var pathMatchLength = 0; var curMatchLength; if (!pathMatch) for (var p in loader.paths) { if (loader.paths[p].indexOf('*') == -1) continue; // normalize the output path var curPath = normalizePath(loader, loader.paths[p], true); // do reverse match var wIndex = curPath.indexOf('*'); if (normalized.substr(0, wIndex) === curPath.substr(0, wIndex) && normalized.substr(normalized.length - curPath.length + wIndex + 1) === curPath.substr(wIndex + 1)) { curMatchLength = curPath.split('/').length; if (curMatchLength >= pathMatchLength) { pathMatch = p.replace('*', normalized.substr(wIndex, normalized.length - curPath.length + 1)); pathMatchLength = curMatchLength; } } } // when no path was matched, act like the standard rule is *: baseURL/* if (!pathMatch) { if (normalized.substr(0, loader.baseURL.length) == loader.baseURL) pathMatch = normalized.substr(loader.baseURL.length); else if (normalized.match(absURLRegEx)) throw new Error('Unable to calculate canonical name to bundle ' + normalized + '. Ensure that this module sits within the baseURL or a wildcard path config.'); else pathMatch = normalized; } return pathMatch; }
javascript
function getCanonicalNamePlain(loader, normalized, isPlugin) { // now just reverse apply paths rules to get canonical name var pathMatch; // first check exact path matches for (var p in loader.paths) { if (loader.paths[p].indexOf('*') != -1) continue; var curPath = normalizePath(loader, loader.paths[p], isPlugin); // always stop on first exact match if (normalized === curPath) return p; // support trailing / in paths rules else if (curPath[curPath.length - 1] == '/' && normalized.substr(0, curPath.length - 1) == curPath.substr(0, curPath.length - 1) && (normalized.length < curPath.length || normalized[curPath.length - 1] == curPath[curPath.length - 1])) { // first case is that canonicalize('src') = 'app' for 'app/': 'src/' return normalized.length < curPath.length ? p.substr(0, p.length - 1) : p + normalized.substr(curPath.length); } } // then wildcard matches var pathMatchLength = 0; var curMatchLength; if (!pathMatch) for (var p in loader.paths) { if (loader.paths[p].indexOf('*') == -1) continue; // normalize the output path var curPath = normalizePath(loader, loader.paths[p], true); // do reverse match var wIndex = curPath.indexOf('*'); if (normalized.substr(0, wIndex) === curPath.substr(0, wIndex) && normalized.substr(normalized.length - curPath.length + wIndex + 1) === curPath.substr(wIndex + 1)) { curMatchLength = curPath.split('/').length; if (curMatchLength >= pathMatchLength) { pathMatch = p.replace('*', normalized.substr(wIndex, normalized.length - curPath.length + 1)); pathMatchLength = curMatchLength; } } } // when no path was matched, act like the standard rule is *: baseURL/* if (!pathMatch) { if (normalized.substr(0, loader.baseURL.length) == loader.baseURL) pathMatch = normalized.substr(loader.baseURL.length); else if (normalized.match(absURLRegEx)) throw new Error('Unable to calculate canonical name to bundle ' + normalized + '. Ensure that this module sits within the baseURL or a wildcard path config.'); else pathMatch = normalized; } return pathMatch; }
[ "function", "getCanonicalNamePlain", "(", "loader", ",", "normalized", ",", "isPlugin", ")", "{", "// now just reverse apply paths rules to get canonical name", "var", "pathMatch", ";", "// first check exact path matches", "for", "(", "var", "p", "in", "loader", ".", "paths", ")", "{", "if", "(", "loader", ".", "paths", "[", "p", "]", ".", "indexOf", "(", "'*'", ")", "!=", "-", "1", ")", "continue", ";", "var", "curPath", "=", "normalizePath", "(", "loader", ",", "loader", ".", "paths", "[", "p", "]", ",", "isPlugin", ")", ";", "// always stop on first exact match", "if", "(", "normalized", "===", "curPath", ")", "return", "p", ";", "// support trailing / in paths rules", "else", "if", "(", "curPath", "[", "curPath", ".", "length", "-", "1", "]", "==", "'/'", "&&", "normalized", ".", "substr", "(", "0", ",", "curPath", ".", "length", "-", "1", ")", "==", "curPath", ".", "substr", "(", "0", ",", "curPath", ".", "length", "-", "1", ")", "&&", "(", "normalized", ".", "length", "<", "curPath", ".", "length", "||", "normalized", "[", "curPath", ".", "length", "-", "1", "]", "==", "curPath", "[", "curPath", ".", "length", "-", "1", "]", ")", ")", "{", "// first case is that canonicalize('src') = 'app' for 'app/': 'src/'", "return", "normalized", ".", "length", "<", "curPath", ".", "length", "?", "p", ".", "substr", "(", "0", ",", "p", ".", "length", "-", "1", ")", ":", "p", "+", "normalized", ".", "substr", "(", "curPath", ".", "length", ")", ";", "}", "}", "// then wildcard matches", "var", "pathMatchLength", "=", "0", ";", "var", "curMatchLength", ";", "if", "(", "!", "pathMatch", ")", "for", "(", "var", "p", "in", "loader", ".", "paths", ")", "{", "if", "(", "loader", ".", "paths", "[", "p", "]", ".", "indexOf", "(", "'*'", ")", "==", "-", "1", ")", "continue", ";", "// normalize the output path", "var", "curPath", "=", "normalizePath", "(", "loader", ",", "loader", ".", "paths", "[", "p", "]", ",", "true", ")", ";", "// do reverse match", "var", "wIndex", "=", "curPath", ".", "indexOf", "(", "'*'", ")", ";", "if", "(", "normalized", ".", "substr", "(", "0", ",", "wIndex", ")", "===", "curPath", ".", "substr", "(", "0", ",", "wIndex", ")", "&&", "normalized", ".", "substr", "(", "normalized", ".", "length", "-", "curPath", ".", "length", "+", "wIndex", "+", "1", ")", "===", "curPath", ".", "substr", "(", "wIndex", "+", "1", ")", ")", "{", "curMatchLength", "=", "curPath", ".", "split", "(", "'/'", ")", ".", "length", ";", "if", "(", "curMatchLength", ">=", "pathMatchLength", ")", "{", "pathMatch", "=", "p", ".", "replace", "(", "'*'", ",", "normalized", ".", "substr", "(", "wIndex", ",", "normalized", ".", "length", "-", "curPath", ".", "length", "+", "1", ")", ")", ";", "pathMatchLength", "=", "curMatchLength", ";", "}", "}", "}", "// when no path was matched, act like the standard rule is *: baseURL/*", "if", "(", "!", "pathMatch", ")", "{", "if", "(", "normalized", ".", "substr", "(", "0", ",", "loader", ".", "baseURL", ".", "length", ")", "==", "loader", ".", "baseURL", ")", "pathMatch", "=", "normalized", ".", "substr", "(", "loader", ".", "baseURL", ".", "length", ")", ";", "else", "if", "(", "normalized", ".", "match", "(", "absURLRegEx", ")", ")", "throw", "new", "Error", "(", "'Unable to calculate canonical name to bundle '", "+", "normalized", "+", "'. Ensure that this module sits within the baseURL or a wildcard path config.'", ")", ";", "else", "pathMatch", "=", "normalized", ";", "}", "return", "pathMatch", ";", "}" ]
syntax-free getCanonicalName just reverse-applies paths and defulatJSExtension to determine the canonical
[ "syntax", "-", "free", "getCanonicalName", "just", "reverse", "-", "applies", "paths", "and", "defulatJSExtension", "to", "determine", "the", "canonical" ]
e874ec6a0bdea904016bc2831f5185f38fe6c539
https://github.com/systemjs/builder/blob/e874ec6a0bdea904016bc2831f5185f38fe6c539/lib/utils.js#L175-L233
24,127
systemjs/builder
lib/utils.js
createPkgConfigPathObj
function createPkgConfigPathObj(path) { var lastWildcard = path.lastIndexOf('*'); var length = Math.max(lastWildcard + 1, path.lastIndexOf('/')); return { length: length, regEx: new RegExp('^(' + path.substr(0, length).replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[^\\/]+') + ')(\\/|$)'), wildcard: lastWildcard != -1 }; }
javascript
function createPkgConfigPathObj(path) { var lastWildcard = path.lastIndexOf('*'); var length = Math.max(lastWildcard + 1, path.lastIndexOf('/')); return { length: length, regEx: new RegExp('^(' + path.substr(0, length).replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[^\\/]+') + ')(\\/|$)'), wildcard: lastWildcard != -1 }; }
[ "function", "createPkgConfigPathObj", "(", "path", ")", "{", "var", "lastWildcard", "=", "path", ".", "lastIndexOf", "(", "'*'", ")", ";", "var", "length", "=", "Math", ".", "max", "(", "lastWildcard", "+", "1", ",", "path", ".", "lastIndexOf", "(", "'/'", ")", ")", ";", "return", "{", "length", ":", "length", ",", "regEx", ":", "new", "RegExp", "(", "'^('", "+", "path", ".", "substr", "(", "0", ",", "length", ")", ".", "replace", "(", "/", "[.+?^${}()|[\\]\\\\]", "/", "g", ",", "'\\\\$&'", ")", ".", "replace", "(", "/", "\\*", "/", "g", ",", "'[^\\\\/]+'", ")", "+", "')(\\\\/|$)'", ")", ",", "wildcard", ":", "lastWildcard", "!=", "-", "1", "}", ";", "}" ]
data object for quick checks against package paths
[ "data", "object", "for", "quick", "checks", "against", "package", "paths" ]
e874ec6a0bdea904016bc2831f5185f38fe6c539
https://github.com/systemjs/builder/blob/e874ec6a0bdea904016bc2831f5185f38fe6c539/lib/utils.js#L242-L250
24,128
systemjs/builder
lib/trace.js
booleanEnvTrace
function booleanEnvTrace(condition) { var conditionObj = parseCondition(condition); if (conditionObj.negate) return traceCondition(conditionalComplement(condition), false); else return traceCondition(condition, true); }
javascript
function booleanEnvTrace(condition) { var conditionObj = parseCondition(condition); if (conditionObj.negate) return traceCondition(conditionalComplement(condition), false); else return traceCondition(condition, true); }
[ "function", "booleanEnvTrace", "(", "condition", ")", "{", "var", "conditionObj", "=", "parseCondition", "(", "condition", ")", ";", "if", "(", "conditionObj", ".", "negate", ")", "return", "traceCondition", "(", "conditionalComplement", "(", "condition", ")", ",", "false", ")", ";", "else", "return", "traceCondition", "(", "condition", ",", "true", ")", ";", "}" ]
whether or not to include condition branch given our conditionalEnv
[ "whether", "or", "not", "to", "include", "condition", "branch", "given", "our", "conditionalEnv" ]
e874ec6a0bdea904016bc2831f5185f38fe6c539
https://github.com/systemjs/builder/blob/e874ec6a0bdea904016bc2831f5185f38fe6c539/lib/trace.js#L870-L877
24,129
systemjs/builder
compilers/json.js
optimizePackageConfig
function optimizePackageConfig(json) { if (json.systemjs) json = json.systemjs; // remove non SystemJS package config properties var loaderConfigProperties = ['baseDir', 'defaultExtension', 'format', 'meta', 'map', 'main']; for (var p in json) if (loaderConfigProperties.indexOf(p) == -1) delete json[p]; if (json.map && !json.map['@env']) { Object.keys(json.map).forEach(function(target) { var mapped = json.map[target]; if (typeof mapped == 'string' && mapped.substr(0, 6) == '@node/') delete json.map[target]; if (typeof mapped == 'object') { Object.keys(mapped).forEach(function(condition) { if (condition == 'node') delete mapped[condition]; }); if (!hasProperties(mapped)) delete json.map[target]; } }); if (!hasProperties(json.map)) delete json.map; } return json; }
javascript
function optimizePackageConfig(json) { if (json.systemjs) json = json.systemjs; // remove non SystemJS package config properties var loaderConfigProperties = ['baseDir', 'defaultExtension', 'format', 'meta', 'map', 'main']; for (var p in json) if (loaderConfigProperties.indexOf(p) == -1) delete json[p]; if (json.map && !json.map['@env']) { Object.keys(json.map).forEach(function(target) { var mapped = json.map[target]; if (typeof mapped == 'string' && mapped.substr(0, 6) == '@node/') delete json.map[target]; if (typeof mapped == 'object') { Object.keys(mapped).forEach(function(condition) { if (condition == 'node') delete mapped[condition]; }); if (!hasProperties(mapped)) delete json.map[target]; } }); if (!hasProperties(json.map)) delete json.map; } return json; }
[ "function", "optimizePackageConfig", "(", "json", ")", "{", "if", "(", "json", ".", "systemjs", ")", "json", "=", "json", ".", "systemjs", ";", "// remove non SystemJS package config properties", "var", "loaderConfigProperties", "=", "[", "'baseDir'", ",", "'defaultExtension'", ",", "'format'", ",", "'meta'", ",", "'map'", ",", "'main'", "]", ";", "for", "(", "var", "p", "in", "json", ")", "if", "(", "loaderConfigProperties", ".", "indexOf", "(", "p", ")", "==", "-", "1", ")", "delete", "json", "[", "p", "]", ";", "if", "(", "json", ".", "map", "&&", "!", "json", ".", "map", "[", "'@env'", "]", ")", "{", "Object", ".", "keys", "(", "json", ".", "map", ")", ".", "forEach", "(", "function", "(", "target", ")", "{", "var", "mapped", "=", "json", ".", "map", "[", "target", "]", ";", "if", "(", "typeof", "mapped", "==", "'string'", "&&", "mapped", ".", "substr", "(", "0", ",", "6", ")", "==", "'@node/'", ")", "delete", "json", ".", "map", "[", "target", "]", ";", "if", "(", "typeof", "mapped", "==", "'object'", ")", "{", "Object", ".", "keys", "(", "mapped", ")", ".", "forEach", "(", "function", "(", "condition", ")", "{", "if", "(", "condition", "==", "'node'", ")", "delete", "mapped", "[", "condition", "]", ";", "}", ")", ";", "if", "(", "!", "hasProperties", "(", "mapped", ")", ")", "delete", "json", ".", "map", "[", "target", "]", ";", "}", "}", ")", ";", "if", "(", "!", "hasProperties", "(", "json", ".", "map", ")", ")", "delete", "json", ".", "map", ";", "}", "return", "json", ";", "}" ]
because bundles are for the browser only if this is a package config file json we are compiling then we can optimize out the node-only configurations to make it smaller
[ "because", "bundles", "are", "for", "the", "browser", "only", "if", "this", "is", "a", "package", "config", "file", "json", "we", "are", "compiling", "then", "we", "can", "optimize", "out", "the", "node", "-", "only", "configurations", "to", "make", "it", "smaller" ]
e874ec6a0bdea904016bc2831f5185f38fe6c539
https://github.com/systemjs/builder/blob/e874ec6a0bdea904016bc2831f5185f38fe6c539/compilers/json.js#L28-L60
24,130
systemjs/builder
lib/compile.js
getCompileHash
function getCompileHash(load, compileOpts) { return createHash('md5') .update(JSON.stringify({ source: load.source, metadata: load.metadata, path: compileOpts.sourceMaps && load.path, normalize: compileOpts.normalize, anonymous: compileOpts.anonymous, systemGlobal: compileOpts.systemGlobal, static: compileOpts.static, encodeNames: compileOpts.encodeNames, sourceMaps: compileOpts.sourceMaps, lowResSourceMaps: compileOpts.lowResSourceMaps })) .digest('hex'); }
javascript
function getCompileHash(load, compileOpts) { return createHash('md5') .update(JSON.stringify({ source: load.source, metadata: load.metadata, path: compileOpts.sourceMaps && load.path, normalize: compileOpts.normalize, anonymous: compileOpts.anonymous, systemGlobal: compileOpts.systemGlobal, static: compileOpts.static, encodeNames: compileOpts.encodeNames, sourceMaps: compileOpts.sourceMaps, lowResSourceMaps: compileOpts.lowResSourceMaps })) .digest('hex'); }
[ "function", "getCompileHash", "(", "load", ",", "compileOpts", ")", "{", "return", "createHash", "(", "'md5'", ")", ".", "update", "(", "JSON", ".", "stringify", "(", "{", "source", ":", "load", ".", "source", ",", "metadata", ":", "load", ".", "metadata", ",", "path", ":", "compileOpts", ".", "sourceMaps", "&&", "load", ".", "path", ",", "normalize", ":", "compileOpts", ".", "normalize", ",", "anonymous", ":", "compileOpts", ".", "anonymous", ",", "systemGlobal", ":", "compileOpts", ".", "systemGlobal", ",", "static", ":", "compileOpts", ".", "static", ",", "encodeNames", ":", "compileOpts", ".", "encodeNames", ",", "sourceMaps", ":", "compileOpts", ".", "sourceMaps", ",", "lowResSourceMaps", ":", "compileOpts", ".", "lowResSourceMaps", "}", ")", ")", ".", "digest", "(", "'hex'", ")", ";", "}" ]
create a compile hash based on path + source + metadata + compileOpts one implication here is that plugins shouldn't rely on System.x checks as these will not be cache-invalidated but within the bundle hook is fine
[ "create", "a", "compile", "hash", "based", "on", "path", "+", "source", "+", "metadata", "+", "compileOpts", "one", "implication", "here", "is", "that", "plugins", "shouldn", "t", "rely", "on", "System", ".", "x", "checks", "as", "these", "will", "not", "be", "cache", "-", "invalidated", "but", "within", "the", "bundle", "hook", "is", "fine" ]
e874ec6a0bdea904016bc2831f5185f38fe6c539
https://github.com/systemjs/builder/blob/e874ec6a0bdea904016bc2831f5185f38fe6c539/lib/compile.js#L26-L42
24,131
systemjs/builder
lib/compile.js
remapLoadRecord
function remapLoadRecord(load, mapFunction) { load = extend({}, load); load.name = mapFunction(load.name, load.name); var depMap = {}; Object.keys(load.depMap).forEach(function(dep) { depMap[dep] = mapFunction(load.depMap[dep], dep); }); load.depMap = depMap; return load; }
javascript
function remapLoadRecord(load, mapFunction) { load = extend({}, load); load.name = mapFunction(load.name, load.name); var depMap = {}; Object.keys(load.depMap).forEach(function(dep) { depMap[dep] = mapFunction(load.depMap[dep], dep); }); load.depMap = depMap; return load; }
[ "function", "remapLoadRecord", "(", "load", ",", "mapFunction", ")", "{", "load", "=", "extend", "(", "{", "}", ",", "load", ")", ";", "load", ".", "name", "=", "mapFunction", "(", "load", ".", "name", ",", "load", ".", "name", ")", ";", "var", "depMap", "=", "{", "}", ";", "Object", ".", "keys", "(", "load", ".", "depMap", ")", ".", "forEach", "(", "function", "(", "dep", ")", "{", "depMap", "[", "dep", "]", "=", "mapFunction", "(", "load", ".", "depMap", "[", "dep", "]", ",", "dep", ")", ";", "}", ")", ";", "load", ".", "depMap", "=", "depMap", ";", "return", "load", ";", "}" ]
create a new load record with any necessary final mappings
[ "create", "a", "new", "load", "record", "with", "any", "necessary", "final", "mappings" ]
e874ec6a0bdea904016bc2831f5185f38fe6c539
https://github.com/systemjs/builder/blob/e874ec6a0bdea904016bc2831f5185f38fe6c539/lib/compile.js#L86-L95
24,132
handsontable/ngHandsontable
dist/ngHandsontable.js
function(element, htSettings) { var container = document.createElement('div'), hot; container.className = this.containerClassName; if (htSettings.hotId) { container.id = htSettings.hotId; } element[0].appendChild(container); hot = new Handsontable(container, htSettings); if (htSettings.hotId) { hotRegisterer.registerInstance(htSettings.hotId, hot); } return hot; }
javascript
function(element, htSettings) { var container = document.createElement('div'), hot; container.className = this.containerClassName; if (htSettings.hotId) { container.id = htSettings.hotId; } element[0].appendChild(container); hot = new Handsontable(container, htSettings); if (htSettings.hotId) { hotRegisterer.registerInstance(htSettings.hotId, hot); } return hot; }
[ "function", "(", "element", ",", "htSettings", ")", "{", "var", "container", "=", "document", ".", "createElement", "(", "'div'", ")", ",", "hot", ";", "container", ".", "className", "=", "this", ".", "containerClassName", ";", "if", "(", "htSettings", ".", "hotId", ")", "{", "container", ".", "id", "=", "htSettings", ".", "hotId", ";", "}", "element", "[", "0", "]", ".", "appendChild", "(", "container", ")", ";", "hot", "=", "new", "Handsontable", "(", "container", ",", "htSettings", ")", ";", "if", "(", "htSettings", ".", "hotId", ")", "{", "hotRegisterer", ".", "registerInstance", "(", "htSettings", ".", "hotId", ",", "hot", ")", ";", "}", "return", "hot", ";", "}" ]
Append handsontable container div and initialize handsontable instance inside element. @param {qLite} element @param {Object} htSettings
[ "Append", "handsontable", "container", "div", "and", "initialize", "handsontable", "instance", "inside", "element", "." ]
c23f42ac1b937794ac93ded0a6392b55bbe4c16b
https://github.com/handsontable/ngHandsontable/blob/c23f42ac1b937794ac93ded0a6392b55bbe4c16b/dist/ngHandsontable.js#L130-L147
24,133
handsontable/ngHandsontable
dist/ngHandsontable.js
function(settings, scope) { var scopeOptions = angular.extend({}, scope), htOptions, i, length; settings = settings || {}; angular.extend(scopeOptions, scope.settings || {}); htOptions = this.getAvailableSettings(); for (i = 0, length = htOptions.length; i < length; i++) { if (typeof scopeOptions[htOptions[i]] !== 'undefined') { settings[htOptions[i]] = scopeOptions[htOptions[i]]; } } return settings; }
javascript
function(settings, scope) { var scopeOptions = angular.extend({}, scope), htOptions, i, length; settings = settings || {}; angular.extend(scopeOptions, scope.settings || {}); htOptions = this.getAvailableSettings(); for (i = 0, length = htOptions.length; i < length; i++) { if (typeof scopeOptions[htOptions[i]] !== 'undefined') { settings[htOptions[i]] = scopeOptions[htOptions[i]]; } } return settings; }
[ "function", "(", "settings", ",", "scope", ")", "{", "var", "scopeOptions", "=", "angular", ".", "extend", "(", "{", "}", ",", "scope", ")", ",", "htOptions", ",", "i", ",", "length", ";", "settings", "=", "settings", "||", "{", "}", ";", "angular", ".", "extend", "(", "scopeOptions", ",", "scope", ".", "settings", "||", "{", "}", ")", ";", "htOptions", "=", "this", ".", "getAvailableSettings", "(", ")", ";", "for", "(", "i", "=", "0", ",", "length", "=", "htOptions", ".", "length", ";", "i", "<", "length", ";", "i", "++", ")", "{", "if", "(", "typeof", "scopeOptions", "[", "htOptions", "[", "i", "]", "]", "!==", "'undefined'", ")", "{", "settings", "[", "htOptions", "[", "i", "]", "]", "=", "scopeOptions", "[", "htOptions", "[", "i", "]", "]", ";", "}", "}", "return", "settings", ";", "}" ]
Merge original handsontable settings with setting defined in scope. @param {Object} settings @param {Object} scope @returns {Object}
[ "Merge", "original", "handsontable", "settings", "with", "setting", "defined", "in", "scope", "." ]
c23f42ac1b937794ac93ded0a6392b55bbe4c16b
https://github.com/handsontable/ngHandsontable/blob/c23f42ac1b937794ac93ded0a6392b55bbe4c16b/dist/ngHandsontable.js#L179-L195
24,134
handsontable/ngHandsontable
dist/ngHandsontable.js
function(settings, scope) { var scopeOptions = angular.extend({}, scope), htHooks, i, length, attribute; settings = settings || {}; angular.extend(scopeOptions, scope.settings || {}); htHooks = this.getAvailableHooks(); for (i = 0, length = htHooks.length; i < length; i++) { attribute = 'on' + ucFirst(htHooks[i]); if (typeof scopeOptions[htHooks[i]] === 'function' || typeof scopeOptions[attribute] === 'function') { settings[htHooks[i]] = scopeOptions[htHooks[i]] || scopeOptions[attribute]; } } return settings; }
javascript
function(settings, scope) { var scopeOptions = angular.extend({}, scope), htHooks, i, length, attribute; settings = settings || {}; angular.extend(scopeOptions, scope.settings || {}); htHooks = this.getAvailableHooks(); for (i = 0, length = htHooks.length; i < length; i++) { attribute = 'on' + ucFirst(htHooks[i]); if (typeof scopeOptions[htHooks[i]] === 'function' || typeof scopeOptions[attribute] === 'function') { settings[htHooks[i]] = scopeOptions[htHooks[i]] || scopeOptions[attribute]; } } return settings; }
[ "function", "(", "settings", ",", "scope", ")", "{", "var", "scopeOptions", "=", "angular", ".", "extend", "(", "{", "}", ",", "scope", ")", ",", "htHooks", ",", "i", ",", "length", ",", "attribute", ";", "settings", "=", "settings", "||", "{", "}", ";", "angular", ".", "extend", "(", "scopeOptions", ",", "scope", ".", "settings", "||", "{", "}", ")", ";", "htHooks", "=", "this", ".", "getAvailableHooks", "(", ")", ";", "for", "(", "i", "=", "0", ",", "length", "=", "htHooks", ".", "length", ";", "i", "<", "length", ";", "i", "++", ")", "{", "attribute", "=", "'on'", "+", "ucFirst", "(", "htHooks", "[", "i", "]", ")", ";", "if", "(", "typeof", "scopeOptions", "[", "htHooks", "[", "i", "]", "]", "===", "'function'", "||", "typeof", "scopeOptions", "[", "attribute", "]", "===", "'function'", ")", "{", "settings", "[", "htHooks", "[", "i", "]", "]", "=", "scopeOptions", "[", "htHooks", "[", "i", "]", "]", "||", "scopeOptions", "[", "attribute", "]", ";", "}", "}", "return", "settings", ";", "}" ]
Merge original handsontable hooks with hooks defined in scope. @param {Object} settings @param {Object} scope @returns {Object}
[ "Merge", "original", "handsontable", "hooks", "with", "hooks", "defined", "in", "scope", "." ]
c23f42ac1b937794ac93ded0a6392b55bbe4c16b
https://github.com/handsontable/ngHandsontable/blob/c23f42ac1b937794ac93ded0a6392b55bbe4c16b/dist/ngHandsontable.js#L204-L222
24,135
handsontable/ngHandsontable
dist/ngHandsontable.js
function(scopeDefinition, attrs) { for (var i in scopeDefinition) { if (scopeDefinition.hasOwnProperty(i) && attrs[i] === void 0 && attrs[scopeDefinition[i].substr(1, scopeDefinition[i].length)] === void 0) { delete scopeDefinition[i]; } } return scopeDefinition; }
javascript
function(scopeDefinition, attrs) { for (var i in scopeDefinition) { if (scopeDefinition.hasOwnProperty(i) && attrs[i] === void 0 && attrs[scopeDefinition[i].substr(1, scopeDefinition[i].length)] === void 0) { delete scopeDefinition[i]; } } return scopeDefinition; }
[ "function", "(", "scopeDefinition", ",", "attrs", ")", "{", "for", "(", "var", "i", "in", "scopeDefinition", ")", "{", "if", "(", "scopeDefinition", ".", "hasOwnProperty", "(", "i", ")", "&&", "attrs", "[", "i", "]", "===", "void", "0", "&&", "attrs", "[", "scopeDefinition", "[", "i", "]", ".", "substr", "(", "1", ",", "scopeDefinition", "[", "i", "]", ".", "length", ")", "]", "===", "void", "0", ")", "{", "delete", "scopeDefinition", "[", "i", "]", ";", "}", "}", "return", "scopeDefinition", ";", "}" ]
Trim scope definition according to attrs object from directive. @param {Object} scopeDefinition @param {Object} attrs @returns {Object}
[ "Trim", "scope", "definition", "according", "to", "attrs", "object", "from", "directive", "." ]
c23f42ac1b937794ac93ded0a6392b55bbe4c16b
https://github.com/handsontable/ngHandsontable/blob/c23f42ac1b937794ac93ded0a6392b55bbe4c16b/dist/ngHandsontable.js#L231-L240
24,136
handsontable/ngHandsontable
dist/ngHandsontable.js
function() { var scopeDefinition = {}; this.applyAvailableSettingsScopeDef(scopeDefinition); this.applyAvailableHooksScopeDef(scopeDefinition); scopeDefinition.datarows = '='; scopeDefinition.dataschema = '='; scopeDefinition.observeDomVisibility = '='; //scopeDefinition.settings = '='; return scopeDefinition; }
javascript
function() { var scopeDefinition = {}; this.applyAvailableSettingsScopeDef(scopeDefinition); this.applyAvailableHooksScopeDef(scopeDefinition); scopeDefinition.datarows = '='; scopeDefinition.dataschema = '='; scopeDefinition.observeDomVisibility = '='; //scopeDefinition.settings = '='; return scopeDefinition; }
[ "function", "(", ")", "{", "var", "scopeDefinition", "=", "{", "}", ";", "this", ".", "applyAvailableSettingsScopeDef", "(", "scopeDefinition", ")", ";", "this", ".", "applyAvailableHooksScopeDef", "(", "scopeDefinition", ")", ";", "scopeDefinition", ".", "datarows", "=", "'='", ";", "scopeDefinition", ".", "dataschema", "=", "'='", ";", "scopeDefinition", ".", "observeDomVisibility", "=", "'='", ";", "//scopeDefinition.settings = '=';", "return", "scopeDefinition", ";", "}" ]
Get isolate scope definition for main handsontable directive. @return {Object}
[ "Get", "isolate", "scope", "definition", "for", "main", "handsontable", "directive", "." ]
c23f42ac1b937794ac93ded0a6392b55bbe4c16b
https://github.com/handsontable/ngHandsontable/blob/c23f42ac1b937794ac93ded0a6392b55bbe4c16b/dist/ngHandsontable.js#L247-L259
24,137
handsontable/ngHandsontable
dist/ngHandsontable.js
function(scopeDefinition) { var options, i, length; options = this.getAvailableSettings(); for (i = 0, length = options.length; i < length; i++) { scopeDefinition[options[i]] = '='; } return scopeDefinition; }
javascript
function(scopeDefinition) { var options, i, length; options = this.getAvailableSettings(); for (i = 0, length = options.length; i < length; i++) { scopeDefinition[options[i]] = '='; } return scopeDefinition; }
[ "function", "(", "scopeDefinition", ")", "{", "var", "options", ",", "i", ",", "length", ";", "options", "=", "this", ".", "getAvailableSettings", "(", ")", ";", "for", "(", "i", "=", "0", ",", "length", "=", "options", ".", "length", ";", "i", "<", "length", ";", "i", "++", ")", "{", "scopeDefinition", "[", "options", "[", "i", "]", "]", "=", "'='", ";", "}", "return", "scopeDefinition", ";", "}" ]
Apply all available handsontable settings into object which represents scope definition. @param {Object} [scopeDefinition] @returns {Object}
[ "Apply", "all", "available", "handsontable", "settings", "into", "object", "which", "represents", "scope", "definition", "." ]
c23f42ac1b937794ac93ded0a6392b55bbe4c16b
https://github.com/handsontable/ngHandsontable/blob/c23f42ac1b937794ac93ded0a6392b55bbe4c16b/dist/ngHandsontable.js#L281-L291
24,138
handsontable/ngHandsontable
dist/ngHandsontable.js
function(scopeDefinition) { var options, i, length; options = this.getAvailableHooks(); for (i = 0, length = options.length; i < length; i++) { scopeDefinition[options[i]] = '=on' + ucFirst(options[i]); } return scopeDefinition; }
javascript
function(scopeDefinition) { var options, i, length; options = this.getAvailableHooks(); for (i = 0, length = options.length; i < length; i++) { scopeDefinition[options[i]] = '=on' + ucFirst(options[i]); } return scopeDefinition; }
[ "function", "(", "scopeDefinition", ")", "{", "var", "options", ",", "i", ",", "length", ";", "options", "=", "this", ".", "getAvailableHooks", "(", ")", ";", "for", "(", "i", "=", "0", ",", "length", "=", "options", ".", "length", ";", "i", "<", "length", ";", "i", "++", ")", "{", "scopeDefinition", "[", "options", "[", "i", "]", "]", "=", "'=on'", "+", "ucFirst", "(", "options", "[", "i", "]", ")", ";", "}", "return", "scopeDefinition", ";", "}" ]
Apply all available handsontable hooks into object which represents scope definition. @param {Object} [scopeDefinition] @returns {Object}
[ "Apply", "all", "available", "handsontable", "hooks", "into", "object", "which", "represents", "scope", "definition", "." ]
c23f42ac1b937794ac93ded0a6392b55bbe4c16b
https://github.com/handsontable/ngHandsontable/blob/c23f42ac1b937794ac93ded0a6392b55bbe4c16b/dist/ngHandsontable.js#L299-L309
24,139
handsontable/ngHandsontable
dist/ngHandsontable.js
function(hyphenateStyle) { var settings = Object.keys(Handsontable.DefaultSettings.prototype); if (settings.indexOf('contextMenuCopyPaste') === -1) { settings.push('contextMenuCopyPaste'); } if (settings.indexOf('handsontable') === -1) { settings.push('handsontable'); } if (settings.indexOf('settings') >= 0) { settings.splice(settings.indexOf('settings'), 1); } if (hyphenateStyle) { settings = settings.map(hyphenate); } return settings; }
javascript
function(hyphenateStyle) { var settings = Object.keys(Handsontable.DefaultSettings.prototype); if (settings.indexOf('contextMenuCopyPaste') === -1) { settings.push('contextMenuCopyPaste'); } if (settings.indexOf('handsontable') === -1) { settings.push('handsontable'); } if (settings.indexOf('settings') >= 0) { settings.splice(settings.indexOf('settings'), 1); } if (hyphenateStyle) { settings = settings.map(hyphenate); } return settings; }
[ "function", "(", "hyphenateStyle", ")", "{", "var", "settings", "=", "Object", ".", "keys", "(", "Handsontable", ".", "DefaultSettings", ".", "prototype", ")", ";", "if", "(", "settings", ".", "indexOf", "(", "'contextMenuCopyPaste'", ")", "===", "-", "1", ")", "{", "settings", ".", "push", "(", "'contextMenuCopyPaste'", ")", ";", "}", "if", "(", "settings", ".", "indexOf", "(", "'handsontable'", ")", "===", "-", "1", ")", "{", "settings", ".", "push", "(", "'handsontable'", ")", ";", "}", "if", "(", "settings", ".", "indexOf", "(", "'settings'", ")", ">=", "0", ")", "{", "settings", ".", "splice", "(", "settings", ".", "indexOf", "(", "'settings'", ")", ",", "1", ")", ";", "}", "if", "(", "hyphenateStyle", ")", "{", "settings", "=", "settings", ".", "map", "(", "hyphenate", ")", ";", "}", "return", "settings", ";", "}" ]
Get all available settings from handsontable, returns settings by default in camelCase mode. @param {Boolean} [hyphenateStyle=undefined] If `true` then returns options in hyphenate mode (eq. row-header) @returns {Array}
[ "Get", "all", "available", "settings", "from", "handsontable", "returns", "settings", "by", "default", "in", "camelCase", "mode", "." ]
c23f42ac1b937794ac93ded0a6392b55bbe4c16b
https://github.com/handsontable/ngHandsontable/blob/c23f42ac1b937794ac93ded0a6392b55bbe4c16b/dist/ngHandsontable.js#L317-L334
24,140
handsontable/ngHandsontable
dist/ngHandsontable.js
function(hyphenateStyle) { var settings = Handsontable.hooks.getRegistered(); if (hyphenateStyle) { settings = settings.map(function(hook) { return 'on-' + hyphenate(hook); }); } return settings; }
javascript
function(hyphenateStyle) { var settings = Handsontable.hooks.getRegistered(); if (hyphenateStyle) { settings = settings.map(function(hook) { return 'on-' + hyphenate(hook); }); } return settings; }
[ "function", "(", "hyphenateStyle", ")", "{", "var", "settings", "=", "Handsontable", ".", "hooks", ".", "getRegistered", "(", ")", ";", "if", "(", "hyphenateStyle", ")", "{", "settings", "=", "settings", ".", "map", "(", "function", "(", "hook", ")", "{", "return", "'on-'", "+", "hyphenate", "(", "hook", ")", ";", "}", ")", ";", "}", "return", "settings", ";", "}" ]
Get all available hooks from handsontable, returns hooks by default in camelCase mode. @param {Boolean} [hyphenateStyle=undefined] If `true` then returns hooks in hyphenate mode (eq. on-after-init) @returns {Array}
[ "Get", "all", "available", "hooks", "from", "handsontable", "returns", "hooks", "by", "default", "in", "camelCase", "mode", "." ]
c23f42ac1b937794ac93ded0a6392b55bbe4c16b
https://github.com/handsontable/ngHandsontable/blob/c23f42ac1b937794ac93ded0a6392b55bbe4c16b/dist/ngHandsontable.js#L342-L352
24,141
QuickBlox/quickblox-javascript-sdk
samples/video_conferencing/js/video/ui_helpers.js
autoClosePopups
function autoClosePopups(clear) { if (clear) { clearTimeout(modalTimerID); modalTimerID = undefined; } else { modalTimerID = setTimeout(function() { bootbox.hideAll(); }, 30000); } }
javascript
function autoClosePopups(clear) { if (clear) { clearTimeout(modalTimerID); modalTimerID = undefined; } else { modalTimerID = setTimeout(function() { bootbox.hideAll(); }, 30000); } }
[ "function", "autoClosePopups", "(", "clear", ")", "{", "if", "(", "clear", ")", "{", "clearTimeout", "(", "modalTimerID", ")", ";", "modalTimerID", "=", "undefined", ";", "}", "else", "{", "modalTimerID", "=", "setTimeout", "(", "function", "(", ")", "{", "bootbox", ".", "hideAll", "(", ")", ";", "}", ",", "30000", ")", ";", "}", "}" ]
modal's timer
[ "modal", "s", "timer" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/video_conferencing/js/video/ui_helpers.js#L368-L377
24,142
QuickBlox/quickblox-javascript-sdk
samples/cordova/text_chat/www/js/ui_helpers.js
buildUserHtml
function buildUserHtml(userLogin, userId, isNew) { var userHtml = "<a href='#' id='" + userId; if(isNew){ userHtml += "_new'"; }else{ userHtml += "'"; } userHtml += " class='col-md-12 col-sm-12 col-xs-12 users_form' onclick='"; userHtml += "clickToAdd"; userHtml += "(\""; userHtml += userId; if(isNew){ userHtml += "_new"; } userHtml += "\")'>"; userHtml += userLogin; userHtml +="</a>"; return userHtml; }
javascript
function buildUserHtml(userLogin, userId, isNew) { var userHtml = "<a href='#' id='" + userId; if(isNew){ userHtml += "_new'"; }else{ userHtml += "'"; } userHtml += " class='col-md-12 col-sm-12 col-xs-12 users_form' onclick='"; userHtml += "clickToAdd"; userHtml += "(\""; userHtml += userId; if(isNew){ userHtml += "_new"; } userHtml += "\")'>"; userHtml += userLogin; userHtml +="</a>"; return userHtml; }
[ "function", "buildUserHtml", "(", "userLogin", ",", "userId", ",", "isNew", ")", "{", "var", "userHtml", "=", "\"<a href='#' id='\"", "+", "userId", ";", "if", "(", "isNew", ")", "{", "userHtml", "+=", "\"_new'\"", ";", "}", "else", "{", "userHtml", "+=", "\"'\"", ";", "}", "userHtml", "+=", "\" class='col-md-12 col-sm-12 col-xs-12 users_form' onclick='\"", ";", "userHtml", "+=", "\"clickToAdd\"", ";", "userHtml", "+=", "\"(\\\"\"", ";", "userHtml", "+=", "userId", ";", "if", "(", "isNew", ")", "{", "userHtml", "+=", "\"_new\"", ";", "}", "userHtml", "+=", "\"\\\")'>\"", ";", "userHtml", "+=", "userLogin", ";", "userHtml", "+=", "\"</a>\"", ";", "return", "userHtml", ";", "}" ]
build html for users list
[ "build", "html", "for", "users", "list" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/text_chat/www/js/ui_helpers.js#L76-L95
24,143
QuickBlox/quickblox-javascript-sdk
samples/cordova/video_chat/platforms/ios/cordova/lib/prepare.js
cleanLaunchStoryboardImages
function cleanLaunchStoryboardImages(projectRoot, projectConfig, locations) { var splashScreens = projectConfig.getSplashScreens('ios'); var platformProjDir = locations.xcodeCordovaProj; var launchStoryboardImagesDir = getLaunchStoryboardImagesDir(projectRoot, platformProjDir); if (launchStoryboardImagesDir) { var resourceMap = mapLaunchStoryboardResources(splashScreens, launchStoryboardImagesDir); var contentsJSON = getLaunchStoryboardContentsJSON(splashScreens, launchStoryboardImagesDir); Object.keys(resourceMap).forEach(function (targetPath) { resourceMap[targetPath] = null; }); events.emit('verbose', 'Cleaning storyboard image set at ' + launchStoryboardImagesDir); // Source paths are removed from the map, so updatePaths() will delete the target files. FileUpdater.updatePaths( resourceMap, { rootDir: projectRoot, all: true }, logFileOp); // delete filename from contents.json contentsJSON.images.forEach(function(image) { image.filename = undefined; }); events.emit('verbose', 'Updating Storyboard image set contents.json'); fs.writeFileSync(path.join(launchStoryboardImagesDir, 'contents.json'), JSON.stringify(contentsJSON, null, 2)); } }
javascript
function cleanLaunchStoryboardImages(projectRoot, projectConfig, locations) { var splashScreens = projectConfig.getSplashScreens('ios'); var platformProjDir = locations.xcodeCordovaProj; var launchStoryboardImagesDir = getLaunchStoryboardImagesDir(projectRoot, platformProjDir); if (launchStoryboardImagesDir) { var resourceMap = mapLaunchStoryboardResources(splashScreens, launchStoryboardImagesDir); var contentsJSON = getLaunchStoryboardContentsJSON(splashScreens, launchStoryboardImagesDir); Object.keys(resourceMap).forEach(function (targetPath) { resourceMap[targetPath] = null; }); events.emit('verbose', 'Cleaning storyboard image set at ' + launchStoryboardImagesDir); // Source paths are removed from the map, so updatePaths() will delete the target files. FileUpdater.updatePaths( resourceMap, { rootDir: projectRoot, all: true }, logFileOp); // delete filename from contents.json contentsJSON.images.forEach(function(image) { image.filename = undefined; }); events.emit('verbose', 'Updating Storyboard image set contents.json'); fs.writeFileSync(path.join(launchStoryboardImagesDir, 'contents.json'), JSON.stringify(contentsJSON, null, 2)); } }
[ "function", "cleanLaunchStoryboardImages", "(", "projectRoot", ",", "projectConfig", ",", "locations", ")", "{", "var", "splashScreens", "=", "projectConfig", ".", "getSplashScreens", "(", "'ios'", ")", ";", "var", "platformProjDir", "=", "locations", ".", "xcodeCordovaProj", ";", "var", "launchStoryboardImagesDir", "=", "getLaunchStoryboardImagesDir", "(", "projectRoot", ",", "platformProjDir", ")", ";", "if", "(", "launchStoryboardImagesDir", ")", "{", "var", "resourceMap", "=", "mapLaunchStoryboardResources", "(", "splashScreens", ",", "launchStoryboardImagesDir", ")", ";", "var", "contentsJSON", "=", "getLaunchStoryboardContentsJSON", "(", "splashScreens", ",", "launchStoryboardImagesDir", ")", ";", "Object", ".", "keys", "(", "resourceMap", ")", ".", "forEach", "(", "function", "(", "targetPath", ")", "{", "resourceMap", "[", "targetPath", "]", "=", "null", ";", "}", ")", ";", "events", ".", "emit", "(", "'verbose'", ",", "'Cleaning storyboard image set at '", "+", "launchStoryboardImagesDir", ")", ";", "// Source paths are removed from the map, so updatePaths() will delete the target files.", "FileUpdater", ".", "updatePaths", "(", "resourceMap", ",", "{", "rootDir", ":", "projectRoot", ",", "all", ":", "true", "}", ",", "logFileOp", ")", ";", "// delete filename from contents.json", "contentsJSON", ".", "images", ".", "forEach", "(", "function", "(", "image", ")", "{", "image", ".", "filename", "=", "undefined", ";", "}", ")", ";", "events", ".", "emit", "(", "'verbose'", ",", "'Updating Storyboard image set contents.json'", ")", ";", "fs", ".", "writeFileSync", "(", "path", ".", "join", "(", "launchStoryboardImagesDir", ",", "'contents.json'", ")", ",", "JSON", ".", "stringify", "(", "contentsJSON", ",", "null", ",", "2", ")", ")", ";", "}", "}" ]
Removes the images from the launch storyboard's image set and updates the image set's contents.json file appropriately. @param {string} projectRoot Path to the project root @param {Object} projectConfig The project's config.xml @param {Object} locations A dictionary containing useful location paths
[ "Removes", "the", "images", "from", "the", "launch", "storyboard", "s", "image", "set", "and", "updates", "the", "image", "set", "s", "contents", ".", "json", "file", "appropriately", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/video_chat/platforms/ios/cordova/lib/prepare.js#L713-L739
24,144
QuickBlox/quickblox-javascript-sdk
src/modules/chat/qbChat.js
function(callback, isInitialConnect) { Utils.QBLog('[QBChat]', 'Status.CONNECTED at ' + chatUtils.getLocalTime()); var self = this, xmppClient = Utils.getEnv().browser ? self.connection : self.Client, presence = Utils.getEnv().browser ? $pres() : chatUtils.createStanza(XMPP.Stanza, null, 'presence'); if (config.streamManagement.enable && config.chatProtocol.active === 2) { self.streamManagement.enable(self.connection, null); self.streamManagement.sentMessageCallback = self._sentMessageCallback; } self.helpers.setUserCurrentJid(self.helpers.userCurrentJid(xmppClient)); self.isConnected = true; self._isConnecting = false; self._enableCarbons(); if (isInitialConnect) { self.roster.get(function(contacts) { xmppClient.send(presence); self.roster.contacts = contacts; callback(self.roster.contacts); }); } else { var rooms = Object.keys(self.muc.joinedRooms); xmppClient.send(presence); Utils.QBLog('[QBChat]', 'Re-joining ' + rooms.length + " rooms..."); for (var i = 0, len = rooms.length; i < len; i++) { self.muc.join(rooms[i]); } if (typeof self.onReconnectListener === 'function') { Utils.safeCallbackCall(self.onReconnectListener); } } }
javascript
function(callback, isInitialConnect) { Utils.QBLog('[QBChat]', 'Status.CONNECTED at ' + chatUtils.getLocalTime()); var self = this, xmppClient = Utils.getEnv().browser ? self.connection : self.Client, presence = Utils.getEnv().browser ? $pres() : chatUtils.createStanza(XMPP.Stanza, null, 'presence'); if (config.streamManagement.enable && config.chatProtocol.active === 2) { self.streamManagement.enable(self.connection, null); self.streamManagement.sentMessageCallback = self._sentMessageCallback; } self.helpers.setUserCurrentJid(self.helpers.userCurrentJid(xmppClient)); self.isConnected = true; self._isConnecting = false; self._enableCarbons(); if (isInitialConnect) { self.roster.get(function(contacts) { xmppClient.send(presence); self.roster.contacts = contacts; callback(self.roster.contacts); }); } else { var rooms = Object.keys(self.muc.joinedRooms); xmppClient.send(presence); Utils.QBLog('[QBChat]', 'Re-joining ' + rooms.length + " rooms..."); for (var i = 0, len = rooms.length; i < len; i++) { self.muc.join(rooms[i]); } if (typeof self.onReconnectListener === 'function') { Utils.safeCallbackCall(self.onReconnectListener); } } }
[ "function", "(", "callback", ",", "isInitialConnect", ")", "{", "Utils", ".", "QBLog", "(", "'[QBChat]'", ",", "'Status.CONNECTED at '", "+", "chatUtils", ".", "getLocalTime", "(", ")", ")", ";", "var", "self", "=", "this", ",", "xmppClient", "=", "Utils", ".", "getEnv", "(", ")", ".", "browser", "?", "self", ".", "connection", ":", "self", ".", "Client", ",", "presence", "=", "Utils", ".", "getEnv", "(", ")", ".", "browser", "?", "$pres", "(", ")", ":", "chatUtils", ".", "createStanza", "(", "XMPP", ".", "Stanza", ",", "null", ",", "'presence'", ")", ";", "if", "(", "config", ".", "streamManagement", ".", "enable", "&&", "config", ".", "chatProtocol", ".", "active", "===", "2", ")", "{", "self", ".", "streamManagement", ".", "enable", "(", "self", ".", "connection", ",", "null", ")", ";", "self", ".", "streamManagement", ".", "sentMessageCallback", "=", "self", ".", "_sentMessageCallback", ";", "}", "self", ".", "helpers", ".", "setUserCurrentJid", "(", "self", ".", "helpers", ".", "userCurrentJid", "(", "xmppClient", ")", ")", ";", "self", ".", "isConnected", "=", "true", ";", "self", ".", "_isConnecting", "=", "false", ";", "self", ".", "_enableCarbons", "(", ")", ";", "if", "(", "isInitialConnect", ")", "{", "self", ".", "roster", ".", "get", "(", "function", "(", "contacts", ")", "{", "xmppClient", ".", "send", "(", "presence", ")", ";", "self", ".", "roster", ".", "contacts", "=", "contacts", ";", "callback", "(", "self", ".", "roster", ".", "contacts", ")", ";", "}", ")", ";", "}", "else", "{", "var", "rooms", "=", "Object", ".", "keys", "(", "self", ".", "muc", ".", "joinedRooms", ")", ";", "xmppClient", ".", "send", "(", "presence", ")", ";", "Utils", ".", "QBLog", "(", "'[QBChat]'", ",", "'Re-joining '", "+", "rooms", ".", "length", "+", "\" rooms...\"", ")", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "rooms", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "self", ".", "muc", ".", "join", "(", "rooms", "[", "i", "]", ")", ";", "}", "if", "(", "typeof", "self", ".", "onReconnectListener", "===", "'function'", ")", "{", "Utils", ".", "safeCallbackCall", "(", "self", ".", "onReconnectListener", ")", ";", "}", "}", "}" ]
Actions after the connection is established - enable stream management (the configuration setting); - save user's JID; - enable carbons; - get and storage the user's roster (if the initial connect); - recover the joined rooms and fire 'onReconnectListener' (if the reconnect); - send initial presence to the chat server.
[ "Actions", "after", "the", "connection", "is", "established" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/chat/qbChat.js#L872-L913
24,145
QuickBlox/quickblox-javascript-sdk
src/modules/chat/qbChat.js
function(listWithUpdates, callback) { /** * Callback for QB.chat.privacylist.update(). * @param {Object} error - The error object * @param {Object} response - The privacy list object * @callback updatePrivacylistCallback * */ var self = this; self.getList(listWithUpdates.name, function(error, existentList) { if (error) { callback(error, null); } else { var updatedList = {}; updatedList.items = Utils.MergeArrayOfObjects(existentList.items, listWithUpdates.items); updatedList.name = listWithUpdates.name; self.create(updatedList, function(err, result) { if (error) { callback(err, null); }else{ callback(null, result); } }); } }); }
javascript
function(listWithUpdates, callback) { /** * Callback for QB.chat.privacylist.update(). * @param {Object} error - The error object * @param {Object} response - The privacy list object * @callback updatePrivacylistCallback * */ var self = this; self.getList(listWithUpdates.name, function(error, existentList) { if (error) { callback(error, null); } else { var updatedList = {}; updatedList.items = Utils.MergeArrayOfObjects(existentList.items, listWithUpdates.items); updatedList.name = listWithUpdates.name; self.create(updatedList, function(err, result) { if (error) { callback(err, null); }else{ callback(null, result); } }); } }); }
[ "function", "(", "listWithUpdates", ",", "callback", ")", "{", "/**\n * Callback for QB.chat.privacylist.update().\n * @param {Object} error - The error object\n * @param {Object} response - The privacy list object\n * @callback updatePrivacylistCallback\n * */", "var", "self", "=", "this", ";", "self", ".", "getList", "(", "listWithUpdates", ".", "name", ",", "function", "(", "error", ",", "existentList", ")", "{", "if", "(", "error", ")", "{", "callback", "(", "error", ",", "null", ")", ";", "}", "else", "{", "var", "updatedList", "=", "{", "}", ";", "updatedList", ".", "items", "=", "Utils", ".", "MergeArrayOfObjects", "(", "existentList", ".", "items", ",", "listWithUpdates", ".", "items", ")", ";", "updatedList", ".", "name", "=", "listWithUpdates", ".", "name", ";", "self", ".", "create", "(", "updatedList", ",", "function", "(", "err", ",", "result", ")", "{", "if", "(", "error", ")", "{", "callback", "(", "err", ",", "null", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "result", ")", ";", "}", "}", ")", ";", "}", "}", ")", ";", "}" ]
Update the privacy list. @memberof QB.chat.privacylist @param {String} name - The name of the list. @param {updatePrivacylistCallback} callback - The callback function.
[ "Update", "the", "privacy", "list", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/chat/qbChat.js#L2008-L2035
24,146
QuickBlox/quickblox-javascript-sdk
src/modules/chat/qbChat.js
function(jid_or_user_id) { var jid; if (typeof jid_or_user_id === 'string') { jid = jid_or_user_id; } else if (typeof jid_or_user_id === 'number') { jid = jid_or_user_id + '-' + config.creds.appId + '@' + config.endpoints.chat; } else { throw new Error('The method "jidOrUserId" may take jid or id'); } return jid; }
javascript
function(jid_or_user_id) { var jid; if (typeof jid_or_user_id === 'string') { jid = jid_or_user_id; } else if (typeof jid_or_user_id === 'number') { jid = jid_or_user_id + '-' + config.creds.appId + '@' + config.endpoints.chat; } else { throw new Error('The method "jidOrUserId" may take jid or id'); } return jid; }
[ "function", "(", "jid_or_user_id", ")", "{", "var", "jid", ";", "if", "(", "typeof", "jid_or_user_id", "===", "'string'", ")", "{", "jid", "=", "jid_or_user_id", ";", "}", "else", "if", "(", "typeof", "jid_or_user_id", "===", "'number'", ")", "{", "jid", "=", "jid_or_user_id", "+", "'-'", "+", "config", ".", "creds", ".", "appId", "+", "'@'", "+", "config", ".", "endpoints", ".", "chat", ";", "}", "else", "{", "throw", "new", "Error", "(", "'The method \"jidOrUserId\" may take jid or id'", ")", ";", "}", "return", "jid", ";", "}" ]
Get unique id. @memberof QB.chat.helpers @param {String | Number} jid_or_user_id - Jid or user id. @returns {String} - jid.
[ "Get", "unique", "id", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/chat/qbChat.js#L2270-L2280
24,147
QuickBlox/quickblox-javascript-sdk
src/modules/chat/qbChat.js
function(jid_or_user_id) { var chatType; if (typeof jid_or_user_id === 'string') { chatType = jid_or_user_id.indexOf("muc") > -1 ? 'groupchat' : 'chat'; } else if (typeof jid_or_user_id === 'number') { chatType = 'chat'; } else { throw new Error(unsupportedError); } return chatType; }
javascript
function(jid_or_user_id) { var chatType; if (typeof jid_or_user_id === 'string') { chatType = jid_or_user_id.indexOf("muc") > -1 ? 'groupchat' : 'chat'; } else if (typeof jid_or_user_id === 'number') { chatType = 'chat'; } else { throw new Error(unsupportedError); } return chatType; }
[ "function", "(", "jid_or_user_id", ")", "{", "var", "chatType", ";", "if", "(", "typeof", "jid_or_user_id", "===", "'string'", ")", "{", "chatType", "=", "jid_or_user_id", ".", "indexOf", "(", "\"muc\"", ")", ">", "-", "1", "?", "'groupchat'", ":", "'chat'", ";", "}", "else", "if", "(", "typeof", "jid_or_user_id", "===", "'number'", ")", "{", "chatType", "=", "'chat'", ";", "}", "else", "{", "throw", "new", "Error", "(", "unsupportedError", ")", ";", "}", "return", "chatType", ";", "}" ]
Get the chat type. @memberof QB.chat.helpers @param {String | Number} jid_or_user_id - Jid or user id. @returns {String} - jid.
[ "Get", "the", "chat", "type", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/chat/qbChat.js#L2288-L2298
24,148
QuickBlox/quickblox-javascript-sdk
src/modules/chat/qbChat.js
function(occupantsIds, UserId) { var recipient = null; occupantsIds.forEach(function(item) { if(item != UserId){ recipient = item; } }); return recipient; }
javascript
function(occupantsIds, UserId) { var recipient = null; occupantsIds.forEach(function(item) { if(item != UserId){ recipient = item; } }); return recipient; }
[ "function", "(", "occupantsIds", ",", "UserId", ")", "{", "var", "recipient", "=", "null", ";", "occupantsIds", ".", "forEach", "(", "function", "(", "item", ")", "{", "if", "(", "item", "!=", "UserId", ")", "{", "recipient", "=", "item", ";", "}", "}", ")", ";", "return", "recipient", ";", "}" ]
Get the recipint id. @memberof QB.chat.helpers @param {Array} occupantsIds - Array of user ids. @param {Number} UserId - Jid or user id. @returns {Number} recipient - recipient id.
[ "Get", "the", "recipint", "id", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/chat/qbChat.js#L2307-L2315
24,149
QuickBlox/quickblox-javascript-sdk
src/modules/chat/qbChat.js
function(userId, appId) { if(!appId){ return userId + '-' + config.creds.appId + '@' + config.endpoints.chat; } return userId + '-' + appId + '@' + config.endpoints.chat; }
javascript
function(userId, appId) { if(!appId){ return userId + '-' + config.creds.appId + '@' + config.endpoints.chat; } return userId + '-' + appId + '@' + config.endpoints.chat; }
[ "function", "(", "userId", ",", "appId", ")", "{", "if", "(", "!", "appId", ")", "{", "return", "userId", "+", "'-'", "+", "config", ".", "creds", ".", "appId", "+", "'@'", "+", "config", ".", "endpoints", ".", "chat", ";", "}", "return", "userId", "+", "'-'", "+", "appId", "+", "'@'", "+", "config", ".", "endpoints", ".", "chat", ";", "}" ]
Get the User jid id. @memberof QB.chat.helpers @param {Number} UserId - The user id. @param {Number} appId - The application id. @returns {String} jid - The user jid.
[ "Get", "the", "User", "jid", "id", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/chat/qbChat.js#L2324-L2329
24,150
QuickBlox/quickblox-javascript-sdk
src/modules/chat/qbChat.js
function(jid) { var s = jid.split('/'); if (s.length < 2) return null; s.splice(0, 1); return parseInt(s.join('/')); }
javascript
function(jid) { var s = jid.split('/'); if (s.length < 2) return null; s.splice(0, 1); return parseInt(s.join('/')); }
[ "function", "(", "jid", ")", "{", "var", "s", "=", "jid", ".", "split", "(", "'/'", ")", ";", "if", "(", "s", ".", "length", "<", "2", ")", "return", "null", ";", "s", ".", "splice", "(", "0", ",", "1", ")", ";", "return", "parseInt", "(", "s", ".", "join", "(", "'/'", ")", ")", ";", "}" ]
Get user id from dialog's full jid. @memberof QB.chat.helpers @param {String} jid - dialog's full jid. @returns {String} user_id - User Id.
[ "Get", "user", "id", "from", "dialog", "s", "full", "jid", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/chat/qbChat.js#L2389-L2394
24,151
QuickBlox/quickblox-javascript-sdk
src/modules/chat/qbChat.js
function(jid) { var arrayElements = jid.toString().split('/'); if(arrayElements.length === 0){ return null; } return arrayElements[arrayElements.length-1]; }
javascript
function(jid) { var arrayElements = jid.toString().split('/'); if(arrayElements.length === 0){ return null; } return arrayElements[arrayElements.length-1]; }
[ "function", "(", "jid", ")", "{", "var", "arrayElements", "=", "jid", ".", "toString", "(", ")", ".", "split", "(", "'/'", ")", ";", "if", "(", "arrayElements", ".", "length", "===", "0", ")", "{", "return", "null", ";", "}", "return", "arrayElements", "[", "arrayElements", ".", "length", "-", "1", "]", ";", "}" ]
Get the user id from the room jid. @memberof QB.chat.helpers @param {String} jid - resourse jid. @returns {String} userId - The user id.
[ "Get", "the", "user", "id", "from", "the", "room", "jid", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/chat/qbChat.js#L2423-L2429
24,152
QuickBlox/quickblox-javascript-sdk
samples/cordova/video_chat/platforms/ios/cordova/lib/run.js
filterSupportedArgs
function filterSupportedArgs(args) { var filtered = []; var sargs = ['--device', '--emulator', '--nobuild', '--list', '--target', '--debug', '--release']; var re = new RegExp(sargs.join('|')); args.forEach(function(element) { // supported args not found, we add // we do a regex search because --target can be "--target=XXX" if (element.search(re) == -1) { filtered.push(element); } }, this); return filtered; }
javascript
function filterSupportedArgs(args) { var filtered = []; var sargs = ['--device', '--emulator', '--nobuild', '--list', '--target', '--debug', '--release']; var re = new RegExp(sargs.join('|')); args.forEach(function(element) { // supported args not found, we add // we do a regex search because --target can be "--target=XXX" if (element.search(re) == -1) { filtered.push(element); } }, this); return filtered; }
[ "function", "filterSupportedArgs", "(", "args", ")", "{", "var", "filtered", "=", "[", "]", ";", "var", "sargs", "=", "[", "'--device'", ",", "'--emulator'", ",", "'--nobuild'", ",", "'--list'", ",", "'--target'", ",", "'--debug'", ",", "'--release'", "]", ";", "var", "re", "=", "new", "RegExp", "(", "sargs", ".", "join", "(", "'|'", ")", ")", ";", "args", ".", "forEach", "(", "function", "(", "element", ")", "{", "// supported args not found, we add", "// we do a regex search because --target can be \"--target=XXX\"", "if", "(", "element", ".", "search", "(", "re", ")", "==", "-", "1", ")", "{", "filtered", ".", "push", "(", "element", ")", ";", "}", "}", ",", "this", ")", ";", "return", "filtered", ";", "}" ]
Filters the args array and removes supported args for the 'run' command. @return {Array} array with unsupported args for the 'run' command
[ "Filters", "the", "args", "array", "and", "removes", "supported", "args", "for", "the", "run", "command", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/video_chat/platforms/ios/cordova/lib/run.js#L98-L112
24,153
QuickBlox/quickblox-javascript-sdk
samples/video_conferencing/js/messages.js
clickSendMessage
function clickSendMessage() { var currentText = $('#message_text').val().trim(); if (!currentText.length) { return; } $('#message_text').val('').focus(); sendMessage(currentText, null); }
javascript
function clickSendMessage() { var currentText = $('#message_text').val().trim(); if (!currentText.length) { return; } $('#message_text').val('').focus(); sendMessage(currentText, null); }
[ "function", "clickSendMessage", "(", ")", "{", "var", "currentText", "=", "$", "(", "'#message_text'", ")", ".", "val", "(", ")", ".", "trim", "(", ")", ";", "if", "(", "!", "currentText", ".", "length", ")", "{", "return", ";", "}", "$", "(", "'#message_text'", ")", ".", "val", "(", "''", ")", ".", "focus", "(", ")", ";", "sendMessage", "(", "currentText", ",", "null", ")", ";", "}" ]
sending messages after confirmation
[ "sending", "messages", "after", "confirmation" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/video_conferencing/js/messages.js#L179-L189
24,154
QuickBlox/quickblox-javascript-sdk
samples/video_conferencing/js/messages.js
showMessage
function showMessage(userId, msg, attachmentFileId) { var userLogin = getUserLoginById(userId); var messageHtml = buildMessageHTML(msg.body, userLogin, new Date(), attachmentFileId, msg.id); $('#messages-list').append(messageHtml); // scroll to bottom var mydiv = $('#messages-list'); mydiv.scrollTop(mydiv.prop('scrollHeight')); }
javascript
function showMessage(userId, msg, attachmentFileId) { var userLogin = getUserLoginById(userId); var messageHtml = buildMessageHTML(msg.body, userLogin, new Date(), attachmentFileId, msg.id); $('#messages-list').append(messageHtml); // scroll to bottom var mydiv = $('#messages-list'); mydiv.scrollTop(mydiv.prop('scrollHeight')); }
[ "function", "showMessage", "(", "userId", ",", "msg", ",", "attachmentFileId", ")", "{", "var", "userLogin", "=", "getUserLoginById", "(", "userId", ")", ";", "var", "messageHtml", "=", "buildMessageHTML", "(", "msg", ".", "body", ",", "userLogin", ",", "new", "Date", "(", ")", ",", "attachmentFileId", ",", "msg", ".", "id", ")", ";", "$", "(", "'#messages-list'", ")", ".", "append", "(", "messageHtml", ")", ";", "// scroll to bottom", "var", "mydiv", "=", "$", "(", "'#messages-list'", ")", ";", "mydiv", ".", "scrollTop", "(", "mydiv", ".", "prop", "(", "'scrollHeight'", ")", ")", ";", "}" ]
show messages in UI
[ "show", "messages", "in", "UI" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/video_conferencing/js/messages.js#L255-L264
24,155
QuickBlox/quickblox-javascript-sdk
samples/video_conferencing/js/messages.js
sendTypingStatus
function sendTypingStatus() { if (currentDialog.type == 3) { QB.chat.sendIsTypingStatus(opponentId); } else if (currentDialog && currentDialog.xmpp_room_jid) { QB.chat.sendIsTypingStatus(currentDialog.xmpp_room_jid); } }
javascript
function sendTypingStatus() { if (currentDialog.type == 3) { QB.chat.sendIsTypingStatus(opponentId); } else if (currentDialog && currentDialog.xmpp_room_jid) { QB.chat.sendIsTypingStatus(currentDialog.xmpp_room_jid); } }
[ "function", "sendTypingStatus", "(", ")", "{", "if", "(", "currentDialog", ".", "type", "==", "3", ")", "{", "QB", ".", "chat", ".", "sendIsTypingStatus", "(", "opponentId", ")", ";", "}", "else", "if", "(", "currentDialog", "&&", "currentDialog", ".", "xmpp_room_jid", ")", "{", "QB", ".", "chat", ".", "sendIsTypingStatus", "(", "currentDialog", ".", "xmpp_room_jid", ")", ";", "}", "}" ]
send 'is typing' status
[ "send", "is", "typing", "status" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/video_conferencing/js/messages.js#L311-L317
24,156
QuickBlox/quickblox-javascript-sdk
samples/video_conferencing/js/messages.js
sendStopTypinStatus
function sendStopTypinStatus() { if (currentDialog.type == 3) { QB.chat.sendIsStopTypingStatus(opponentId); } else { QB.chat.sendIsStopTypingStatus(currentDialog.xmpp_room_jid); } }
javascript
function sendStopTypinStatus() { if (currentDialog.type == 3) { QB.chat.sendIsStopTypingStatus(opponentId); } else { QB.chat.sendIsStopTypingStatus(currentDialog.xmpp_room_jid); } }
[ "function", "sendStopTypinStatus", "(", ")", "{", "if", "(", "currentDialog", ".", "type", "==", "3", ")", "{", "QB", ".", "chat", ".", "sendIsStopTypingStatus", "(", "opponentId", ")", ";", "}", "else", "{", "QB", ".", "chat", ".", "sendIsStopTypingStatus", "(", "currentDialog", ".", "xmpp_room_jid", ")", ";", "}", "}" ]
send 'stop typing' status
[ "send", "stop", "typing", "status" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/video_conferencing/js/messages.js#L320-L326
24,157
QuickBlox/quickblox-javascript-sdk
samples/video_conferencing/js/messages.js
showUserIsTypingView
function showUserIsTypingView(isTyping, userId, dialogId) { if (isMessageForCurrentDialog(userId, dialogId)) { if (!isTyping) { $('#' + userId + '_typing').remove(); } else if (userId != currentUser.id) { var userLogin = getUserLoginById(userId); var typingUserHtml = buildTypingUserHtml(userId, userLogin); $('#messages-list').append(typingUserHtml); } // scroll to bottom var mydiv = $('#messages-list'); mydiv.scrollTop(mydiv.prop('scrollHeight')); } }
javascript
function showUserIsTypingView(isTyping, userId, dialogId) { if (isMessageForCurrentDialog(userId, dialogId)) { if (!isTyping) { $('#' + userId + '_typing').remove(); } else if (userId != currentUser.id) { var userLogin = getUserLoginById(userId); var typingUserHtml = buildTypingUserHtml(userId, userLogin); $('#messages-list').append(typingUserHtml); } // scroll to bottom var mydiv = $('#messages-list'); mydiv.scrollTop(mydiv.prop('scrollHeight')); } }
[ "function", "showUserIsTypingView", "(", "isTyping", ",", "userId", ",", "dialogId", ")", "{", "if", "(", "isMessageForCurrentDialog", "(", "userId", ",", "dialogId", ")", ")", "{", "if", "(", "!", "isTyping", ")", "{", "$", "(", "'#'", "+", "userId", "+", "'_typing'", ")", ".", "remove", "(", ")", ";", "}", "else", "if", "(", "userId", "!=", "currentUser", ".", "id", ")", "{", "var", "userLogin", "=", "getUserLoginById", "(", "userId", ")", ";", "var", "typingUserHtml", "=", "buildTypingUserHtml", "(", "userId", ",", "userLogin", ")", ";", "$", "(", "'#messages-list'", ")", ".", "append", "(", "typingUserHtml", ")", ";", "}", "// scroll to bottom", "var", "mydiv", "=", "$", "(", "'#messages-list'", ")", ";", "mydiv", ".", "scrollTop", "(", "mydiv", ".", "prop", "(", "'scrollHeight'", ")", ")", ";", "}", "}" ]
show or hide typing status to other users
[ "show", "or", "hide", "typing", "status", "to", "other", "users" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/video_conferencing/js/messages.js#L329-L344
24,158
QuickBlox/quickblox-javascript-sdk
samples/video_conferencing/js/messages.js
isMessageForCurrentDialog
function isMessageForCurrentDialog(userId, dialogId) { var result = false; if (dialogId == currentDialog._id || (dialogId === null && currentDialog.type == 3 && opponentId == userId)) { result = true; } return result; }
javascript
function isMessageForCurrentDialog(userId, dialogId) { var result = false; if (dialogId == currentDialog._id || (dialogId === null && currentDialog.type == 3 && opponentId == userId)) { result = true; } return result; }
[ "function", "isMessageForCurrentDialog", "(", "userId", ",", "dialogId", ")", "{", "var", "result", "=", "false", ";", "if", "(", "dialogId", "==", "currentDialog", ".", "_id", "||", "(", "dialogId", "===", "null", "&&", "currentDialog", ".", "type", "==", "3", "&&", "opponentId", "==", "userId", ")", ")", "{", "result", "=", "true", ";", "}", "return", "result", ";", "}" ]
filter for current dialog
[ "filter", "for", "current", "dialog" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/video_conferencing/js/messages.js#L347-L353
24,159
QuickBlox/quickblox-javascript-sdk
samples/cordova/video_chat/platforms/ios/cordova/lib/check_reqs.js
checkTool
function checkTool (tool, minVersion, message, toolFriendlyName) { toolFriendlyName = toolFriendlyName || tool; // Check whether tool command is available at all var tool_command = shell.which(tool); if (!tool_command) { return Q.reject(toolFriendlyName + ' was not found. ' + (message || '')); } // check if tool version is greater than specified one return versions.get_tool_version(tool).then(function (version) { version = version.trim(); return versions.compareVersions(version, minVersion) >= 0 ? Q.resolve(version) : Q.reject('Cordova needs ' + toolFriendlyName + ' version ' + minVersion + ' or greater, you have version ' + version + '. ' + (message || '')); }); }
javascript
function checkTool (tool, minVersion, message, toolFriendlyName) { toolFriendlyName = toolFriendlyName || tool; // Check whether tool command is available at all var tool_command = shell.which(tool); if (!tool_command) { return Q.reject(toolFriendlyName + ' was not found. ' + (message || '')); } // check if tool version is greater than specified one return versions.get_tool_version(tool).then(function (version) { version = version.trim(); return versions.compareVersions(version, minVersion) >= 0 ? Q.resolve(version) : Q.reject('Cordova needs ' + toolFriendlyName + ' version ' + minVersion + ' or greater, you have version ' + version + '. ' + (message || '')); }); }
[ "function", "checkTool", "(", "tool", ",", "minVersion", ",", "message", ",", "toolFriendlyName", ")", "{", "toolFriendlyName", "=", "toolFriendlyName", "||", "tool", ";", "// Check whether tool command is available at all", "var", "tool_command", "=", "shell", ".", "which", "(", "tool", ")", ";", "if", "(", "!", "tool_command", ")", "{", "return", "Q", ".", "reject", "(", "toolFriendlyName", "+", "' was not found. '", "+", "(", "message", "||", "''", ")", ")", ";", "}", "// check if tool version is greater than specified one", "return", "versions", ".", "get_tool_version", "(", "tool", ")", ".", "then", "(", "function", "(", "version", ")", "{", "version", "=", "version", ".", "trim", "(", ")", ";", "return", "versions", ".", "compareVersions", "(", "version", ",", "minVersion", ")", ">=", "0", "?", "Q", ".", "resolve", "(", "version", ")", ":", "Q", ".", "reject", "(", "'Cordova needs '", "+", "toolFriendlyName", "+", "' version '", "+", "minVersion", "+", "' or greater, you have version '", "+", "version", "+", "'. '", "+", "(", "message", "||", "''", ")", ")", ";", "}", ")", ";", "}" ]
Checks if specific tool is available. @param {String} tool Tool name to check. Known tools are 'xcodebuild' and 'ios-deploy' @param {Number} minVersion Min allowed tool version. @param {String} message Message that will be used to reject promise. @param {String} toolFriendlyName Friendly name of the tool, to report to the user. Optional. @return {Promise} Returns a promise either resolved with tool version or rejected
[ "Checks", "if", "specific", "tool", "is", "available", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/video_chat/platforms/ios/cordova/lib/check_reqs.js#L128-L144
24,160
QuickBlox/quickblox-javascript-sdk
samples/video_conferencing/js/video/soundmeter.js
SoundMeter
function SoundMeter(context) { this.context = context; this.instant = 0.0; this.slow = 0.0; this.clip = 0.0; this.script = context.createScriptProcessor(2048, 1, 1); var that = this; this.script.onaudioprocess = function(event) { var input = event.inputBuffer.getChannelData(0); var i; var sum = 0.0; var clipcount = 0; for (i = 0; i < input.length; ++i) { sum += input[i] * input[i]; if (Math.abs(input[i]) > 0.99) { clipcount += 1; } } that.instant = Math.sqrt(sum / input.length); that.slow = 0.95 * that.slow + 0.05 * that.instant; that.clip = clipcount / input.length; }; }
javascript
function SoundMeter(context) { this.context = context; this.instant = 0.0; this.slow = 0.0; this.clip = 0.0; this.script = context.createScriptProcessor(2048, 1, 1); var that = this; this.script.onaudioprocess = function(event) { var input = event.inputBuffer.getChannelData(0); var i; var sum = 0.0; var clipcount = 0; for (i = 0; i < input.length; ++i) { sum += input[i] * input[i]; if (Math.abs(input[i]) > 0.99) { clipcount += 1; } } that.instant = Math.sqrt(sum / input.length); that.slow = 0.95 * that.slow + 0.05 * that.instant; that.clip = clipcount / input.length; }; }
[ "function", "SoundMeter", "(", "context", ")", "{", "this", ".", "context", "=", "context", ";", "this", ".", "instant", "=", "0.0", ";", "this", ".", "slow", "=", "0.0", ";", "this", ".", "clip", "=", "0.0", ";", "this", ".", "script", "=", "context", ".", "createScriptProcessor", "(", "2048", ",", "1", ",", "1", ")", ";", "var", "that", "=", "this", ";", "this", ".", "script", ".", "onaudioprocess", "=", "function", "(", "event", ")", "{", "var", "input", "=", "event", ".", "inputBuffer", ".", "getChannelData", "(", "0", ")", ";", "var", "i", ";", "var", "sum", "=", "0.0", ";", "var", "clipcount", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "input", ".", "length", ";", "++", "i", ")", "{", "sum", "+=", "input", "[", "i", "]", "*", "input", "[", "i", "]", ";", "if", "(", "Math", ".", "abs", "(", "input", "[", "i", "]", ")", ">", "0.99", ")", "{", "clipcount", "+=", "1", ";", "}", "}", "that", ".", "instant", "=", "Math", ".", "sqrt", "(", "sum", "/", "input", ".", "length", ")", ";", "that", ".", "slow", "=", "0.95", "*", "that", ".", "slow", "+", "0.05", "*", "that", ".", "instant", ";", "that", ".", "clip", "=", "clipcount", "/", "input", ".", "length", ";", "}", ";", "}" ]
Meter class that generates a number correlated to audio volume. The meter class itself displays nothing, but it makes the instantaneous and time-decaying volumes available for inspection. It also reports on the fraction of samples that were at or near the top of the measurement range.
[ "Meter", "class", "that", "generates", "a", "number", "correlated", "to", "audio", "volume", ".", "The", "meter", "class", "itself", "displays", "nothing", "but", "it", "makes", "the", "instantaneous", "and", "time", "-", "decaying", "volumes", "available", "for", "inspection", ".", "It", "also", "reports", "on", "the", "fraction", "of", "samples", "that", "were", "at", "or", "near", "the", "top", "of", "the", "measurement", "range", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/video_conferencing/js/video/soundmeter.js#L16-L38
24,161
QuickBlox/quickblox-javascript-sdk
samples/cordova/video_chat/plugins/cordova-plugin-device/www/device.js
Device
function Device() { this.available = false; this.platform = null; this.version = null; this.uuid = null; this.cordova = null; this.model = null; this.manufacturer = null; this.isVirtual = null; this.serial = null; var me = this; channel.onCordovaReady.subscribe(function() { me.getInfo(function(info) { //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js //TODO: CB-5105 native implementations should not return info.cordova var buildLabel = cordova.version; me.available = true; me.platform = info.platform; me.version = info.version; me.uuid = info.uuid; me.cordova = buildLabel; me.model = info.model; me.isVirtual = info.isVirtual; me.manufacturer = info.manufacturer || 'unknown'; me.serial = info.serial || 'unknown'; channel.onCordovaInfoReady.fire(); },function(e) { me.available = false; utils.alert("[ERROR] Error initializing Cordova: " + e); }); }); }
javascript
function Device() { this.available = false; this.platform = null; this.version = null; this.uuid = null; this.cordova = null; this.model = null; this.manufacturer = null; this.isVirtual = null; this.serial = null; var me = this; channel.onCordovaReady.subscribe(function() { me.getInfo(function(info) { //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js //TODO: CB-5105 native implementations should not return info.cordova var buildLabel = cordova.version; me.available = true; me.platform = info.platform; me.version = info.version; me.uuid = info.uuid; me.cordova = buildLabel; me.model = info.model; me.isVirtual = info.isVirtual; me.manufacturer = info.manufacturer || 'unknown'; me.serial = info.serial || 'unknown'; channel.onCordovaInfoReady.fire(); },function(e) { me.available = false; utils.alert("[ERROR] Error initializing Cordova: " + e); }); }); }
[ "function", "Device", "(", ")", "{", "this", ".", "available", "=", "false", ";", "this", ".", "platform", "=", "null", ";", "this", ".", "version", "=", "null", ";", "this", ".", "uuid", "=", "null", ";", "this", ".", "cordova", "=", "null", ";", "this", ".", "model", "=", "null", ";", "this", ".", "manufacturer", "=", "null", ";", "this", ".", "isVirtual", "=", "null", ";", "this", ".", "serial", "=", "null", ";", "var", "me", "=", "this", ";", "channel", ".", "onCordovaReady", ".", "subscribe", "(", "function", "(", ")", "{", "me", ".", "getInfo", "(", "function", "(", "info", ")", "{", "//ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js", "//TODO: CB-5105 native implementations should not return info.cordova", "var", "buildLabel", "=", "cordova", ".", "version", ";", "me", ".", "available", "=", "true", ";", "me", ".", "platform", "=", "info", ".", "platform", ";", "me", ".", "version", "=", "info", ".", "version", ";", "me", ".", "uuid", "=", "info", ".", "uuid", ";", "me", ".", "cordova", "=", "buildLabel", ";", "me", ".", "model", "=", "info", ".", "model", ";", "me", ".", "isVirtual", "=", "info", ".", "isVirtual", ";", "me", ".", "manufacturer", "=", "info", ".", "manufacturer", "||", "'unknown'", ";", "me", ".", "serial", "=", "info", ".", "serial", "||", "'unknown'", ";", "channel", ".", "onCordovaInfoReady", ".", "fire", "(", ")", ";", "}", ",", "function", "(", "e", ")", "{", "me", ".", "available", "=", "false", ";", "utils", ".", "alert", "(", "\"[ERROR] Error initializing Cordova: \"", "+", "e", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
This represents the mobile device, and provides properties for inspecting the model, version, UUID of the phone, etc. @constructor
[ "This", "represents", "the", "mobile", "device", "and", "provides", "properties", "for", "inspecting", "the", "model", "version", "UUID", "of", "the", "phone", "etc", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/video_chat/plugins/cordova-plugin-device/www/device.js#L37-L70
24,162
QuickBlox/quickblox-javascript-sdk
src/modules/qbAddressBook.js
function(isCompactOrCallback, callback) { var self = this; var isCompact, cb; if(isFunction(isCompactOrCallback)) { cb = isCompactOrCallback; } else { isCompact = isCompactOrCallback; cb = callback; } if(!isFunction(cb)) { throw new Error('The QB.addressbook.get accept callback function is required.'); } var ajaxParams = { 'type': 'GET', 'url': Utils.getUrl(config.urls.addressbookRegistered), 'contentType': 'application/json; charset=utf-8' }; if(isCompact) { ajaxParams.data = {'compact': 1}; } this.service.ajax(ajaxParams, function(err, res) { if (err) { // Don't ask me why. // Thanks to backend developers for this var isFakeErrorEmptyAddressBook = self._isFakeErrorEmptyAddressBook(err); if(isFakeErrorEmptyAddressBook) { cb(null, []); } else { cb(err, null); } } else { cb(null, res); } }); }
javascript
function(isCompactOrCallback, callback) { var self = this; var isCompact, cb; if(isFunction(isCompactOrCallback)) { cb = isCompactOrCallback; } else { isCompact = isCompactOrCallback; cb = callback; } if(!isFunction(cb)) { throw new Error('The QB.addressbook.get accept callback function is required.'); } var ajaxParams = { 'type': 'GET', 'url': Utils.getUrl(config.urls.addressbookRegistered), 'contentType': 'application/json; charset=utf-8' }; if(isCompact) { ajaxParams.data = {'compact': 1}; } this.service.ajax(ajaxParams, function(err, res) { if (err) { // Don't ask me why. // Thanks to backend developers for this var isFakeErrorEmptyAddressBook = self._isFakeErrorEmptyAddressBook(err); if(isFakeErrorEmptyAddressBook) { cb(null, []); } else { cb(err, null); } } else { cb(null, res); } }); }
[ "function", "(", "isCompactOrCallback", ",", "callback", ")", "{", "var", "self", "=", "this", ";", "var", "isCompact", ",", "cb", ";", "if", "(", "isFunction", "(", "isCompactOrCallback", ")", ")", "{", "cb", "=", "isCompactOrCallback", ";", "}", "else", "{", "isCompact", "=", "isCompactOrCallback", ";", "cb", "=", "callback", ";", "}", "if", "(", "!", "isFunction", "(", "cb", ")", ")", "{", "throw", "new", "Error", "(", "'The QB.addressbook.get accept callback function is required.'", ")", ";", "}", "var", "ajaxParams", "=", "{", "'type'", ":", "'GET'", ",", "'url'", ":", "Utils", ".", "getUrl", "(", "config", ".", "urls", ".", "addressbookRegistered", ")", ",", "'contentType'", ":", "'application/json; charset=utf-8'", "}", ";", "if", "(", "isCompact", ")", "{", "ajaxParams", ".", "data", "=", "{", "'compact'", ":", "1", "}", ";", "}", "this", ".", "service", ".", "ajax", "(", "ajaxParams", ",", "function", "(", "err", ",", "res", ")", "{", "if", "(", "err", ")", "{", "// Don't ask me why.", "// Thanks to backend developers for this", "var", "isFakeErrorEmptyAddressBook", "=", "self", ".", "_isFakeErrorEmptyAddressBook", "(", "err", ")", ";", "if", "(", "isFakeErrorEmptyAddressBook", ")", "{", "cb", "(", "null", ",", "[", "]", ")", ";", "}", "else", "{", "cb", "(", "err", ",", "null", ")", ";", "}", "}", "else", "{", "cb", "(", "null", ",", "res", ")", ";", "}", "}", ")", ";", "}" ]
Retrieve QuickBlox users that have phone numbers from your address book. The methods accepts 1 or 2 parameters. @memberof QB.addressbook @param {boolean|function} udidOrCallback - You can pass isCompact parameter or callback object. If isCompact is passed then only user's id and phone fields will be returned from server. Otherwise - all standard user's fields will be returned. @param {function} [callback] - Callback function is useв as 2nd parameter if you pass `isCompact` as 1st parameter. This callback takes 2 arguments: an error and a response.
[ "Retrieve", "QuickBlox", "users", "that", "have", "phone", "numbers", "from", "your", "address", "book", ".", "The", "methods", "accepts", "1", "or", "2", "parameters", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/qbAddressBook.js#L176-L216
24,163
QuickBlox/quickblox-javascript-sdk
src/modules/webrtc/qbWebRTCSession.js
WebRTCSession
function WebRTCSession(params) { this.ID = params.sessionID ? params.sessionID : generateUUID(); this.state = WebRTCSession.State.NEW; this.initiatorID = parseInt(params.initiatorID); this.opponentsIDs = params.opIDs; this.callType = parseInt(params.callType); this.peerConnections = {}; this.localStream = null; this.mediaParams = null; this.signalingProvider = params.signalingProvider; this.currentUserID = params.currentUserID; this.bandwidth = params.bandwidth; /** * We use this timeout to fix next issue: * "From Android/iOS make a call to Web and kill the Android/iOS app instantly. Web accept/reject popup will be still visible. * We need a way to hide it if sach situation happened." */ this.answerTimer = null; this.startCallTime = 0; this.acceptCallTime = 0; }
javascript
function WebRTCSession(params) { this.ID = params.sessionID ? params.sessionID : generateUUID(); this.state = WebRTCSession.State.NEW; this.initiatorID = parseInt(params.initiatorID); this.opponentsIDs = params.opIDs; this.callType = parseInt(params.callType); this.peerConnections = {}; this.localStream = null; this.mediaParams = null; this.signalingProvider = params.signalingProvider; this.currentUserID = params.currentUserID; this.bandwidth = params.bandwidth; /** * We use this timeout to fix next issue: * "From Android/iOS make a call to Web and kill the Android/iOS app instantly. Web accept/reject popup will be still visible. * We need a way to hide it if sach situation happened." */ this.answerTimer = null; this.startCallTime = 0; this.acceptCallTime = 0; }
[ "function", "WebRTCSession", "(", "params", ")", "{", "this", ".", "ID", "=", "params", ".", "sessionID", "?", "params", ".", "sessionID", ":", "generateUUID", "(", ")", ";", "this", ".", "state", "=", "WebRTCSession", ".", "State", ".", "NEW", ";", "this", ".", "initiatorID", "=", "parseInt", "(", "params", ".", "initiatorID", ")", ";", "this", ".", "opponentsIDs", "=", "params", ".", "opIDs", ";", "this", ".", "callType", "=", "parseInt", "(", "params", ".", "callType", ")", ";", "this", ".", "peerConnections", "=", "{", "}", ";", "this", ".", "localStream", "=", "null", ";", "this", ".", "mediaParams", "=", "null", ";", "this", ".", "signalingProvider", "=", "params", ".", "signalingProvider", ";", "this", ".", "currentUserID", "=", "params", ".", "currentUserID", ";", "this", ".", "bandwidth", "=", "params", ".", "bandwidth", ";", "/**\n * We use this timeout to fix next issue:\n * \"From Android/iOS make a call to Web and kill the Android/iOS app instantly. Web accept/reject popup will be still visible.\n * We need a way to hide it if sach situation happened.\"\n */", "this", ".", "answerTimer", "=", "null", ";", "this", ".", "startCallTime", "=", "0", ";", "this", ".", "acceptCallTime", "=", "0", ";", "}" ]
Creates a session @param {number} An ID if the call's initiator @param {array} An array with opponents @param {enum} Type of a call
[ "Creates", "a", "session" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/webrtc/qbWebRTCSession.js#L41-L70
24,164
QuickBlox/quickblox-javascript-sdk
src/modules/webrtc/qbWebRTCSession.js
_prepareExtension
function _prepareExtension(extension) { var ext = {}; try { if ( ({}).toString.call(extension) === '[object Object]' ) { ext.userInfo = extension; ext = JSON.parse( JSON.stringify(ext).replace(/null/g, "\"\"") ); } else { throw new Error('Invalid type of "extension" object.'); } } catch (err) { Helpers.traceWarning(err.message); } return ext; }
javascript
function _prepareExtension(extension) { var ext = {}; try { if ( ({}).toString.call(extension) === '[object Object]' ) { ext.userInfo = extension; ext = JSON.parse( JSON.stringify(ext).replace(/null/g, "\"\"") ); } else { throw new Error('Invalid type of "extension" object.'); } } catch (err) { Helpers.traceWarning(err.message); } return ext; }
[ "function", "_prepareExtension", "(", "extension", ")", "{", "var", "ext", "=", "{", "}", ";", "try", "{", "if", "(", "(", "{", "}", ")", ".", "toString", ".", "call", "(", "extension", ")", "===", "'[object Object]'", ")", "{", "ext", ".", "userInfo", "=", "extension", ";", "ext", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "ext", ")", ".", "replace", "(", "/", "null", "/", "g", ",", "\"\\\"\\\"\"", ")", ")", ";", "}", "else", "{", "throw", "new", "Error", "(", "'Invalid type of \"extension\" object.'", ")", ";", "}", "}", "catch", "(", "err", ")", "{", "Helpers", ".", "traceWarning", "(", "err", ".", "message", ")", ";", "}", "return", "ext", ";", "}" ]
private _prepareExtension - replace property null to empty string return object with property or empty if extension didn't set
[ "private", "_prepareExtension", "-", "replace", "property", "null", "to", "empty", "string", "return", "object", "with", "property", "or", "empty", "if", "extension", "didn", "t", "set" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/webrtc/qbWebRTCSession.js#L998-L1013
24,165
QuickBlox/quickblox-javascript-sdk
samples/cordova/text_chat/www/libs/stickerpipe/js/stickerpipe.js
defaultImageSrcGenerator
function defaultImageSrcGenerator(icon, options) { return ''.concat(options.base, options.size, '/', icon, options.ext); }
javascript
function defaultImageSrcGenerator(icon, options) { return ''.concat(options.base, options.size, '/', icon, options.ext); }
[ "function", "defaultImageSrcGenerator", "(", "icon", ",", "options", ")", "{", "return", "''", ".", "concat", "(", "options", ".", "base", ",", "options", ".", "size", ",", "'/'", ",", "icon", ",", "options", ".", "ext", ")", ";", "}" ]
Default callback used to generate emoji src based on Twitter CDN @param string the emoji codepoint string @param string the default size to use, i.e. "36x36" @param string optional "\uFE0F" variant char, ignored by default @return string the image source to use
[ "Default", "callback", "used", "to", "generate", "emoji", "src", "based", "on", "Twitter", "CDN" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/text_chat/www/libs/stickerpipe/js/stickerpipe.js#L2650-L2652
24,166
QuickBlox/quickblox-javascript-sdk
samples/cordova/text_chat/www/libs/stickerpipe/js/stickerpipe.js
grabTheRightIcon
function grabTheRightIcon(icon, variant) { // if variant is present as \uFE0F return toCodePoint( variant === '\uFE0F' ? // the icon should not contain it icon.slice(0, -1) : // fix non standard OSX behavior (icon.length === 3 && icon.charAt(1) === '\uFE0F' ? icon.charAt(0) + icon.charAt(2) : icon) ); }
javascript
function grabTheRightIcon(icon, variant) { // if variant is present as \uFE0F return toCodePoint( variant === '\uFE0F' ? // the icon should not contain it icon.slice(0, -1) : // fix non standard OSX behavior (icon.length === 3 && icon.charAt(1) === '\uFE0F' ? icon.charAt(0) + icon.charAt(2) : icon) ); }
[ "function", "grabTheRightIcon", "(", "icon", ",", "variant", ")", "{", "// if variant is present as \\uFE0F", "return", "toCodePoint", "(", "variant", "===", "'\\uFE0F'", "?", "// the icon should not contain it", "icon", ".", "slice", "(", "0", ",", "-", "1", ")", ":", "// fix non standard OSX behavior", "(", "icon", ".", "length", "===", "3", "&&", "icon", ".", "charAt", "(", "1", ")", "===", "'\\uFE0F'", "?", "icon", ".", "charAt", "(", "0", ")", "+", "icon", ".", "charAt", "(", "2", ")", ":", "icon", ")", ")", ";", "}" ]
Used to both remove the possible variant and to convert utf16 into code points @param string the emoji surrogate pair @param string the optional variant char, if any
[ "Used", "to", "both", "remove", "the", "possible", "variant", "and", "to", "convert", "utf16", "into", "code", "points" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/text_chat/www/libs/stickerpipe/js/stickerpipe.js#L2690-L2700
24,167
QuickBlox/quickblox-javascript-sdk
samples/cordova/text_chat/www/js/messages.js
sendMessage
function sendMessage(text, attachmentFileId) { stickerpipe.onUserMessageSent(stickerpipe.isSticker(text)); var msg = { type: currentDialog.type === 3 ? 'chat' : 'groupchat', body: text, extension: { save_to_history: 1, }, markable: 1 }; if(attachmentFileId !== null){ msg['extension']['attachments'] = [{id: attachmentFileId, type: 'photo'}]; } if (currentDialog.type === 3) { opponentId = QB.chat.helpers.getRecipientId(currentDialog.occupants_ids, currentUser.id); QB.chat.send(opponentId, msg); $('.list-group-item.active .list-group-item-text') .text(stickerpipe.isSticker(msg.body) ? 'Sticker' : msg.body); if(attachmentFileId === null){ showMessage(currentUser.id, msg); } else { showMessage(currentUser.id, msg, attachmentFileId); } } else { QB.chat.send(currentDialog.xmpp_room_jid, msg); } // claer timer and send 'stop typing' status clearTimeout(isTypingTimerId); isTypingTimeoutCallback(); dialogsMessages.push(msg); }
javascript
function sendMessage(text, attachmentFileId) { stickerpipe.onUserMessageSent(stickerpipe.isSticker(text)); var msg = { type: currentDialog.type === 3 ? 'chat' : 'groupchat', body: text, extension: { save_to_history: 1, }, markable: 1 }; if(attachmentFileId !== null){ msg['extension']['attachments'] = [{id: attachmentFileId, type: 'photo'}]; } if (currentDialog.type === 3) { opponentId = QB.chat.helpers.getRecipientId(currentDialog.occupants_ids, currentUser.id); QB.chat.send(opponentId, msg); $('.list-group-item.active .list-group-item-text') .text(stickerpipe.isSticker(msg.body) ? 'Sticker' : msg.body); if(attachmentFileId === null){ showMessage(currentUser.id, msg); } else { showMessage(currentUser.id, msg, attachmentFileId); } } else { QB.chat.send(currentDialog.xmpp_room_jid, msg); } // claer timer and send 'stop typing' status clearTimeout(isTypingTimerId); isTypingTimeoutCallback(); dialogsMessages.push(msg); }
[ "function", "sendMessage", "(", "text", ",", "attachmentFileId", ")", "{", "stickerpipe", ".", "onUserMessageSent", "(", "stickerpipe", ".", "isSticker", "(", "text", ")", ")", ";", "var", "msg", "=", "{", "type", ":", "currentDialog", ".", "type", "===", "3", "?", "'chat'", ":", "'groupchat'", ",", "body", ":", "text", ",", "extension", ":", "{", "save_to_history", ":", "1", ",", "}", ",", "markable", ":", "1", "}", ";", "if", "(", "attachmentFileId", "!==", "null", ")", "{", "msg", "[", "'extension'", "]", "[", "'attachments'", "]", "=", "[", "{", "id", ":", "attachmentFileId", ",", "type", ":", "'photo'", "}", "]", ";", "}", "if", "(", "currentDialog", ".", "type", "===", "3", ")", "{", "opponentId", "=", "QB", ".", "chat", ".", "helpers", ".", "getRecipientId", "(", "currentDialog", ".", "occupants_ids", ",", "currentUser", ".", "id", ")", ";", "QB", ".", "chat", ".", "send", "(", "opponentId", ",", "msg", ")", ";", "$", "(", "'.list-group-item.active .list-group-item-text'", ")", ".", "text", "(", "stickerpipe", ".", "isSticker", "(", "msg", ".", "body", ")", "?", "'Sticker'", ":", "msg", ".", "body", ")", ";", "if", "(", "attachmentFileId", "===", "null", ")", "{", "showMessage", "(", "currentUser", ".", "id", ",", "msg", ")", ";", "}", "else", "{", "showMessage", "(", "currentUser", ".", "id", ",", "msg", ",", "attachmentFileId", ")", ";", "}", "}", "else", "{", "QB", ".", "chat", ".", "send", "(", "currentDialog", ".", "xmpp_room_jid", ",", "msg", ")", ";", "}", "// claer timer and send 'stop typing' status", "clearTimeout", "(", "isTypingTimerId", ")", ";", "isTypingTimeoutCallback", "(", ")", ";", "dialogsMessages", ".", "push", "(", "msg", ")", ";", "}" ]
send text or attachment
[ "send", "text", "or", "attachment" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/text_chat/www/js/messages.js#L193-L231
24,168
QuickBlox/quickblox-javascript-sdk
samples/cordova/text_chat/www/js/dialogs.js
createNewDialog
function createNewDialog() { var usersIds = []; var usersNames = []; $('#users_list .users_form.active').each(function(index) { usersIds[index] = $(this).attr('id'); usersNames[index] = $(this).text(); }); $("#add_new_dialog").modal("hide"); $('#add_new_dialog .progress').show(); var dialogName; var dialogOccupants; var dialogType; if (usersIds.length > 1) { if (usersNames.indexOf(currentUser.login) > -1) { dialogName = usersNames.join(', '); }else{ dialogName = currentUser.login + ', ' + usersNames.join(', '); } dialogOccupants = usersIds; dialogType = 2; } else { dialogOccupants = usersIds; dialogType = 3; } var params = { type: dialogType, occupants_ids: dialogOccupants, name: dialogName }; // create a dialog // console.log("Creating a dialog with params: " + JSON.stringify(params)); QB.chat.dialog.create(params, function(err, createdDialog) { if (err) { console.log(err); } else { console.log("Dialog " + createdDialog._id + " created with users: " + dialogOccupants); // save dialog to local storage var dialogId = createdDialog._id; dialogs[dialogId] = createdDialog; currentDialog = createdDialog; joinToNewDialogAndShow(createdDialog); notifyOccupants(createdDialog.occupants_ids, createdDialog._id, 1); triggerDialog(createdDialog._id); $('a.users_form').removeClass('active'); } }); }
javascript
function createNewDialog() { var usersIds = []; var usersNames = []; $('#users_list .users_form.active').each(function(index) { usersIds[index] = $(this).attr('id'); usersNames[index] = $(this).text(); }); $("#add_new_dialog").modal("hide"); $('#add_new_dialog .progress').show(); var dialogName; var dialogOccupants; var dialogType; if (usersIds.length > 1) { if (usersNames.indexOf(currentUser.login) > -1) { dialogName = usersNames.join(', '); }else{ dialogName = currentUser.login + ', ' + usersNames.join(', '); } dialogOccupants = usersIds; dialogType = 2; } else { dialogOccupants = usersIds; dialogType = 3; } var params = { type: dialogType, occupants_ids: dialogOccupants, name: dialogName }; // create a dialog // console.log("Creating a dialog with params: " + JSON.stringify(params)); QB.chat.dialog.create(params, function(err, createdDialog) { if (err) { console.log(err); } else { console.log("Dialog " + createdDialog._id + " created with users: " + dialogOccupants); // save dialog to local storage var dialogId = createdDialog._id; dialogs[dialogId] = createdDialog; currentDialog = createdDialog; joinToNewDialogAndShow(createdDialog); notifyOccupants(createdDialog.occupants_ids, createdDialog._id, 1); triggerDialog(createdDialog._id); $('a.users_form').removeClass('active'); } }); }
[ "function", "createNewDialog", "(", ")", "{", "var", "usersIds", "=", "[", "]", ";", "var", "usersNames", "=", "[", "]", ";", "$", "(", "'#users_list .users_form.active'", ")", ".", "each", "(", "function", "(", "index", ")", "{", "usersIds", "[", "index", "]", "=", "$", "(", "this", ")", ".", "attr", "(", "'id'", ")", ";", "usersNames", "[", "index", "]", "=", "$", "(", "this", ")", ".", "text", "(", ")", ";", "}", ")", ";", "$", "(", "\"#add_new_dialog\"", ")", ".", "modal", "(", "\"hide\"", ")", ";", "$", "(", "'#add_new_dialog .progress'", ")", ".", "show", "(", ")", ";", "var", "dialogName", ";", "var", "dialogOccupants", ";", "var", "dialogType", ";", "if", "(", "usersIds", ".", "length", ">", "1", ")", "{", "if", "(", "usersNames", ".", "indexOf", "(", "currentUser", ".", "login", ")", ">", "-", "1", ")", "{", "dialogName", "=", "usersNames", ".", "join", "(", "', '", ")", ";", "}", "else", "{", "dialogName", "=", "currentUser", ".", "login", "+", "', '", "+", "usersNames", ".", "join", "(", "', '", ")", ";", "}", "dialogOccupants", "=", "usersIds", ";", "dialogType", "=", "2", ";", "}", "else", "{", "dialogOccupants", "=", "usersIds", ";", "dialogType", "=", "3", ";", "}", "var", "params", "=", "{", "type", ":", "dialogType", ",", "occupants_ids", ":", "dialogOccupants", ",", "name", ":", "dialogName", "}", ";", "// create a dialog", "//", "console", ".", "log", "(", "\"Creating a dialog with params: \"", "+", "JSON", ".", "stringify", "(", "params", ")", ")", ";", "QB", ".", "chat", ".", "dialog", ".", "create", "(", "params", ",", "function", "(", "err", ",", "createdDialog", ")", "{", "if", "(", "err", ")", "{", "console", ".", "log", "(", "err", ")", ";", "}", "else", "{", "console", ".", "log", "(", "\"Dialog \"", "+", "createdDialog", ".", "_id", "+", "\" created with users: \"", "+", "dialogOccupants", ")", ";", "// save dialog to local storage", "var", "dialogId", "=", "createdDialog", ".", "_id", ";", "dialogs", "[", "dialogId", "]", "=", "createdDialog", ";", "currentDialog", "=", "createdDialog", ";", "joinToNewDialogAndShow", "(", "createdDialog", ")", ";", "notifyOccupants", "(", "createdDialog", ".", "occupants_ids", ",", "createdDialog", ".", "_id", ",", "1", ")", ";", "triggerDialog", "(", "createdDialog", ".", "_id", ")", ";", "$", "(", "'a.users_form'", ")", ".", "removeClass", "(", "'active'", ")", ";", "}", "}", ")", ";", "}" ]
create new dialog
[ "create", "new", "dialog" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/text_chat/www/js/dialogs.js#L214-L274
24,169
QuickBlox/quickblox-javascript-sdk
samples/cordova/text_chat/www/js/dialogs.js
showDialogInfoPopup
function showDialogInfoPopup() { if(Object.keys(currentDialog).length !== 0) { $('#update_dialog').modal('show'); $('#update_dialog .progress').hide(); setupDialogInfoPopup(currentDialog.occupants_ids, currentDialog.name); } }
javascript
function showDialogInfoPopup() { if(Object.keys(currentDialog).length !== 0) { $('#update_dialog').modal('show'); $('#update_dialog .progress').hide(); setupDialogInfoPopup(currentDialog.occupants_ids, currentDialog.name); } }
[ "function", "showDialogInfoPopup", "(", ")", "{", "if", "(", "Object", ".", "keys", "(", "currentDialog", ")", ".", "length", "!==", "0", ")", "{", "$", "(", "'#update_dialog'", ")", ".", "modal", "(", "'show'", ")", ";", "$", "(", "'#update_dialog .progress'", ")", ".", "hide", "(", ")", ";", "setupDialogInfoPopup", "(", "currentDialog", ".", "occupants_ids", ",", "currentDialog", ".", "name", ")", ";", "}", "}" ]
show modal window with dialog's info
[ "show", "modal", "window", "with", "dialog", "s", "info" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/text_chat/www/js/dialogs.js#L384-L391
24,170
QuickBlox/quickblox-javascript-sdk
samples/cordova/video_chat/plugins/cordova-custom-config/hooks/applyCustomConfig.js
parseAndroidPreferences
function parseAndroidPreferences(preferences, configData){ var type = 'preference'; _.each(preferences, function (preference) { // Extract pre-defined preferences (deprecated) var target, prefData; if(preference.attrib.name.match(/^android-manifest\//)){ // Extract manifest Xpath preferences var parts = preference.attrib.name.split("/"), destination = parts.pop(); parts.shift(); prefData = { parent: parts.join("/") || "./", type: type, destination: destination, data: preference }; target = "AndroidManifest.xml"; } if(prefData){ if(!configData[target]) { configData[target] = []; } configData[target].push(prefData); } }); }
javascript
function parseAndroidPreferences(preferences, configData){ var type = 'preference'; _.each(preferences, function (preference) { // Extract pre-defined preferences (deprecated) var target, prefData; if(preference.attrib.name.match(/^android-manifest\//)){ // Extract manifest Xpath preferences var parts = preference.attrib.name.split("/"), destination = parts.pop(); parts.shift(); prefData = { parent: parts.join("/") || "./", type: type, destination: destination, data: preference }; target = "AndroidManifest.xml"; } if(prefData){ if(!configData[target]) { configData[target] = []; } configData[target].push(prefData); } }); }
[ "function", "parseAndroidPreferences", "(", "preferences", ",", "configData", ")", "{", "var", "type", "=", "'preference'", ";", "_", ".", "each", "(", "preferences", ",", "function", "(", "preference", ")", "{", "// Extract pre-defined preferences (deprecated)", "var", "target", ",", "prefData", ";", "if", "(", "preference", ".", "attrib", ".", "name", ".", "match", "(", "/", "^android-manifest\\/", "/", ")", ")", "{", "// Extract manifest Xpath preferences", "var", "parts", "=", "preference", ".", "attrib", ".", "name", ".", "split", "(", "\"/\"", ")", ",", "destination", "=", "parts", ".", "pop", "(", ")", ";", "parts", ".", "shift", "(", ")", ";", "prefData", "=", "{", "parent", ":", "parts", ".", "join", "(", "\"/\"", ")", "||", "\"./\"", ",", "type", ":", "type", ",", "destination", ":", "destination", ",", "data", ":", "preference", "}", ";", "target", "=", "\"AndroidManifest.xml\"", ";", "}", "if", "(", "prefData", ")", "{", "if", "(", "!", "configData", "[", "target", "]", ")", "{", "configData", "[", "target", "]", "=", "[", "]", ";", "}", "configData", "[", "target", "]", ".", "push", "(", "prefData", ")", ";", "}", "}", ")", ";", "}" ]
Parses supported Android preferences using the preference mapping into the appropriate XML elements in AndroidManifest.xml
[ "Parses", "supported", "Android", "preferences", "using", "the", "preference", "mapping", "into", "the", "appropriate", "XML", "elements", "in", "AndroidManifest", ".", "xml" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/video_chat/plugins/cordova-custom-config/hooks/applyCustomConfig.js#L257-L287
24,171
QuickBlox/quickblox-javascript-sdk
samples/cordova/video_chat/plugins/cordova-custom-config/hooks/applyCustomConfig.js
updateWp8Manifest
function updateWp8Manifest(targetFilePath, configItems) { var tempManifest = fileUtils.parseElementtreeSync(targetFilePath), root = tempManifest.getroot(); _.each(configItems, function (item) { // if parent is not found on the root, child/grandchild nodes are searched var parentEl = root.find(item.parent) || root.find('*/' + item.parent), parentSelector, data = item.data, childSelector = item.destination, childEl; if(!parentEl) { return; } _.each(data.attrib, function (prop, propName) { childSelector += '[@'+propName+'="'+prop+'"]'; }); childEl = parentEl.find(childSelector); // if child element doesnt exist, create new element if(!childEl) { childEl = new et.Element(item.destination); parentEl.append(childEl); } // copy all config.xml data except for the generated _id property _.each(data, function (prop, propName) { if(propName !== '_id') { childEl[propName] = prop; } }); }); fs.writeFileSync(targetFilePath, tempManifest.write({indent: 4}), 'utf-8'); }
javascript
function updateWp8Manifest(targetFilePath, configItems) { var tempManifest = fileUtils.parseElementtreeSync(targetFilePath), root = tempManifest.getroot(); _.each(configItems, function (item) { // if parent is not found on the root, child/grandchild nodes are searched var parentEl = root.find(item.parent) || root.find('*/' + item.parent), parentSelector, data = item.data, childSelector = item.destination, childEl; if(!parentEl) { return; } _.each(data.attrib, function (prop, propName) { childSelector += '[@'+propName+'="'+prop+'"]'; }); childEl = parentEl.find(childSelector); // if child element doesnt exist, create new element if(!childEl) { childEl = new et.Element(item.destination); parentEl.append(childEl); } // copy all config.xml data except for the generated _id property _.each(data, function (prop, propName) { if(propName !== '_id') { childEl[propName] = prop; } }); }); fs.writeFileSync(targetFilePath, tempManifest.write({indent: 4}), 'utf-8'); }
[ "function", "updateWp8Manifest", "(", "targetFilePath", ",", "configItems", ")", "{", "var", "tempManifest", "=", "fileUtils", ".", "parseElementtreeSync", "(", "targetFilePath", ")", ",", "root", "=", "tempManifest", ".", "getroot", "(", ")", ";", "_", ".", "each", "(", "configItems", ",", "function", "(", "item", ")", "{", "// if parent is not found on the root, child/grandchild nodes are searched", "var", "parentEl", "=", "root", ".", "find", "(", "item", ".", "parent", ")", "||", "root", ".", "find", "(", "'*/'", "+", "item", ".", "parent", ")", ",", "parentSelector", ",", "data", "=", "item", ".", "data", ",", "childSelector", "=", "item", ".", "destination", ",", "childEl", ";", "if", "(", "!", "parentEl", ")", "{", "return", ";", "}", "_", ".", "each", "(", "data", ".", "attrib", ",", "function", "(", "prop", ",", "propName", ")", "{", "childSelector", "+=", "'[@'", "+", "propName", "+", "'=\"'", "+", "prop", "+", "'\"]'", ";", "}", ")", ";", "childEl", "=", "parentEl", ".", "find", "(", "childSelector", ")", ";", "// if child element doesnt exist, create new element", "if", "(", "!", "childEl", ")", "{", "childEl", "=", "new", "et", ".", "Element", "(", "item", ".", "destination", ")", ";", "parentEl", ".", "append", "(", "childEl", ")", ";", "}", "// copy all config.xml data except for the generated _id property", "_", ".", "each", "(", "data", ",", "function", "(", "prop", ",", "propName", ")", "{", "if", "(", "propName", "!==", "'_id'", ")", "{", "childEl", "[", "propName", "]", "=", "prop", ";", "}", "}", ")", ";", "}", ")", ";", "fs", ".", "writeFileSync", "(", "targetFilePath", ",", "tempManifest", ".", "write", "(", "{", "indent", ":", "4", "}", ")", ",", "'utf-8'", ")", ";", "}" ]
Updates target file with data from config.xml
[ "Updates", "target", "file", "with", "data", "from", "config", ".", "xml" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/video_chat/plugins/cordova-custom-config/hooks/applyCustomConfig.js#L430-L464
24,172
QuickBlox/quickblox-javascript-sdk
samples/cordova/video_chat/plugins/cordova-custom-config/hooks/applyCustomConfig.js
updateIosPbxProj
function updateIosPbxProj(xcodeProjectPath, configItems) { var xcodeProject = xcode.project(xcodeProjectPath); xcodeProject.parse(function(err){ if(err){ // shell is undefined if android platform has been removed and added with a new package id but ios stayed the same. var msg = 'An error occurred during parsing of [' + xcodeProjectPath + ']: ' + JSON.stringify(err); if(typeof shell !== "undefined" && shell !== null){ shell.echo(msg); } else{ logger.error(msg + ' - Maybe you forgot to remove/add the ios platform?'); } }else{ _.each(configItems, function (item) { switch(item.type){ case "XCBuildConfiguration": var buildConfig = xcodeProject.pbxXCBuildConfigurationSection(); var replaced = updateXCBuildConfiguration(item, buildConfig, "replace"); if(!replaced){ updateXCBuildConfiguration(item, buildConfig, "add"); } break; } }); fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8'); } }); }
javascript
function updateIosPbxProj(xcodeProjectPath, configItems) { var xcodeProject = xcode.project(xcodeProjectPath); xcodeProject.parse(function(err){ if(err){ // shell is undefined if android platform has been removed and added with a new package id but ios stayed the same. var msg = 'An error occurred during parsing of [' + xcodeProjectPath + ']: ' + JSON.stringify(err); if(typeof shell !== "undefined" && shell !== null){ shell.echo(msg); } else{ logger.error(msg + ' - Maybe you forgot to remove/add the ios platform?'); } }else{ _.each(configItems, function (item) { switch(item.type){ case "XCBuildConfiguration": var buildConfig = xcodeProject.pbxXCBuildConfigurationSection(); var replaced = updateXCBuildConfiguration(item, buildConfig, "replace"); if(!replaced){ updateXCBuildConfiguration(item, buildConfig, "add"); } break; } }); fs.writeFileSync(xcodeProjectPath, xcodeProject.writeSync(), 'utf-8'); } }); }
[ "function", "updateIosPbxProj", "(", "xcodeProjectPath", ",", "configItems", ")", "{", "var", "xcodeProject", "=", "xcode", ".", "project", "(", "xcodeProjectPath", ")", ";", "xcodeProject", ".", "parse", "(", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "// shell is undefined if android platform has been removed and added with a new package id but ios stayed the same.", "var", "msg", "=", "'An error occurred during parsing of ['", "+", "xcodeProjectPath", "+", "']: '", "+", "JSON", ".", "stringify", "(", "err", ")", ";", "if", "(", "typeof", "shell", "!==", "\"undefined\"", "&&", "shell", "!==", "null", ")", "{", "shell", ".", "echo", "(", "msg", ")", ";", "}", "else", "{", "logger", ".", "error", "(", "msg", "+", "' - Maybe you forgot to remove/add the ios platform?'", ")", ";", "}", "}", "else", "{", "_", ".", "each", "(", "configItems", ",", "function", "(", "item", ")", "{", "switch", "(", "item", ".", "type", ")", "{", "case", "\"XCBuildConfiguration\"", ":", "var", "buildConfig", "=", "xcodeProject", ".", "pbxXCBuildConfigurationSection", "(", ")", ";", "var", "replaced", "=", "updateXCBuildConfiguration", "(", "item", ",", "buildConfig", ",", "\"replace\"", ")", ";", "if", "(", "!", "replaced", ")", "{", "updateXCBuildConfiguration", "(", "item", ",", "buildConfig", ",", "\"add\"", ")", ";", "}", "break", ";", "}", "}", ")", ";", "fs", ".", "writeFileSync", "(", "xcodeProjectPath", ",", "xcodeProject", ".", "writeSync", "(", ")", ",", "'utf-8'", ")", ";", "}", "}", ")", ";", "}" ]
Updates the project.pbxproj file with data from config.xml @param {String} xcodeProjectPath - path to XCode project file @param {Array} configItems - config items to update project file with
[ "Updates", "the", "project", ".", "pbxproj", "file", "with", "data", "from", "config", ".", "xml" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/video_chat/plugins/cordova-custom-config/hooks/applyCustomConfig.js#L493-L519
24,173
QuickBlox/quickblox-javascript-sdk
samples/cordova/video_chat/plugins/cordova-custom-config/hooks/applyCustomConfig.js
updateXCBuildConfiguration
function updateXCBuildConfiguration(item, buildConfig, mode){ var modified = false; for(var blockName in buildConfig){ var block = buildConfig[blockName]; if(typeof(block) !== "object" || !(block["buildSettings"])) continue; var literalMatch = !!block["buildSettings"][item.name], quotedMatch = !!block["buildSettings"][quoteEscape(item.name)], match = literalMatch || quotedMatch; if((match || mode === "add") && (!item.buildType || item.buildType.toLowerCase() === block['name'].toLowerCase())){ var name; if(match){ name = literalMatch ? item.name : quoteEscape(item.name); }else{ // adding name = (item.quote && (item.quote === "none" || item.quote === "value")) ? item.name : quoteEscape(item.name); } var value = (item.quote && (item.quote === "none" || item.quote === "key")) ? item.value : quoteEscape(item.value); block["buildSettings"][name] = value; modified = true; logger.verbose(mode+" XCBuildConfiguration key={ "+name+" } to value={ "+value+" } for build type='"+block['name']+"' in block='"+blockName+"'"); } } return modified; }
javascript
function updateXCBuildConfiguration(item, buildConfig, mode){ var modified = false; for(var blockName in buildConfig){ var block = buildConfig[blockName]; if(typeof(block) !== "object" || !(block["buildSettings"])) continue; var literalMatch = !!block["buildSettings"][item.name], quotedMatch = !!block["buildSettings"][quoteEscape(item.name)], match = literalMatch || quotedMatch; if((match || mode === "add") && (!item.buildType || item.buildType.toLowerCase() === block['name'].toLowerCase())){ var name; if(match){ name = literalMatch ? item.name : quoteEscape(item.name); }else{ // adding name = (item.quote && (item.quote === "none" || item.quote === "value")) ? item.name : quoteEscape(item.name); } var value = (item.quote && (item.quote === "none" || item.quote === "key")) ? item.value : quoteEscape(item.value); block["buildSettings"][name] = value; modified = true; logger.verbose(mode+" XCBuildConfiguration key={ "+name+" } to value={ "+value+" } for build type='"+block['name']+"' in block='"+blockName+"'"); } } return modified; }
[ "function", "updateXCBuildConfiguration", "(", "item", ",", "buildConfig", ",", "mode", ")", "{", "var", "modified", "=", "false", ";", "for", "(", "var", "blockName", "in", "buildConfig", ")", "{", "var", "block", "=", "buildConfig", "[", "blockName", "]", ";", "if", "(", "typeof", "(", "block", ")", "!==", "\"object\"", "||", "!", "(", "block", "[", "\"buildSettings\"", "]", ")", ")", "continue", ";", "var", "literalMatch", "=", "!", "!", "block", "[", "\"buildSettings\"", "]", "[", "item", ".", "name", "]", ",", "quotedMatch", "=", "!", "!", "block", "[", "\"buildSettings\"", "]", "[", "quoteEscape", "(", "item", ".", "name", ")", "]", ",", "match", "=", "literalMatch", "||", "quotedMatch", ";", "if", "(", "(", "match", "||", "mode", "===", "\"add\"", ")", "&&", "(", "!", "item", ".", "buildType", "||", "item", ".", "buildType", ".", "toLowerCase", "(", ")", "===", "block", "[", "'name'", "]", ".", "toLowerCase", "(", ")", ")", ")", "{", "var", "name", ";", "if", "(", "match", ")", "{", "name", "=", "literalMatch", "?", "item", ".", "name", ":", "quoteEscape", "(", "item", ".", "name", ")", ";", "}", "else", "{", "// adding", "name", "=", "(", "item", ".", "quote", "&&", "(", "item", ".", "quote", "===", "\"none\"", "||", "item", ".", "quote", "===", "\"value\"", ")", ")", "?", "item", ".", "name", ":", "quoteEscape", "(", "item", ".", "name", ")", ";", "}", "var", "value", "=", "(", "item", ".", "quote", "&&", "(", "item", ".", "quote", "===", "\"none\"", "||", "item", ".", "quote", "===", "\"key\"", ")", ")", "?", "item", ".", "value", ":", "quoteEscape", "(", "item", ".", "value", ")", ";", "block", "[", "\"buildSettings\"", "]", "[", "name", "]", "=", "value", ";", "modified", "=", "true", ";", "logger", ".", "verbose", "(", "mode", "+", "\" XCBuildConfiguration key={ \"", "+", "name", "+", "\" } to value={ \"", "+", "value", "+", "\" } for build type='\"", "+", "block", "[", "'name'", "]", "+", "\"' in block='\"", "+", "blockName", "+", "\"'\"", ")", ";", "}", "}", "return", "modified", ";", "}" ]
Updates an XCode build configuration setting with the given item. @param {Object} item - configuration item containing setting data @param {Object} buildConfig - XCode build config object @param {String} mode - update mode: "replace" to replace only existing keys or "add" to add a new key to every block @returns {boolean} true if buildConfig was modified
[ "Updates", "an", "XCode", "build", "configuration", "setting", "with", "the", "given", "item", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/samples/cordova/video_chat/plugins/cordova-custom-config/hooks/applyCustomConfig.js#L528-L556
24,174
QuickBlox/quickblox-javascript-sdk
src/modules/qbData.js
function(className, params) { var result = Utils.getUrl(config.urls.data, className + '/' + params.id + '/file'); result += '?field_name=' + params.field_name + '&token=' + this.service.getSession().token; return result; }
javascript
function(className, params) { var result = Utils.getUrl(config.urls.data, className + '/' + params.id + '/file'); result += '?field_name=' + params.field_name + '&token=' + this.service.getSession().token; return result; }
[ "function", "(", "className", ",", "params", ")", "{", "var", "result", "=", "Utils", ".", "getUrl", "(", "config", ".", "urls", ".", "data", ",", "className", "+", "'/'", "+", "params", ".", "id", "+", "'/file'", ")", ";", "result", "+=", "'?field_name='", "+", "params", ".", "field_name", "+", "'&token='", "+", "this", ".", "service", ".", "getSession", "(", ")", ".", "token", ";", "return", "result", ";", "}" ]
Return file's URL from file field by ID @memberof QB.data @param {string} className - A class name of record @param {object} params - Object of parameters @param {string} params.field_name - The file's field name @param {string} params.id - The record's ID
[ "Return", "file", "s", "URL", "from", "file", "field", "by", "ID" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/qbData.js#L347-L351
24,175
QuickBlox/quickblox-javascript-sdk
src/modules/qbContent.js
function(params, callback) { /** * Callback for QB.content.createAndUpload(params, callback). * @callback createAndUploadFileCallback * @param {object} error - The error object * @param {object} response - The file object (blob-object-access) */ var _this = this, createParams= {}, file, name, type, size, fileId; var clonedParams = JSON.parse(JSON.stringify(params)); clonedParams.file.data = "..."; file = params.file; name = params.name || file.name; type = params.type || file.type; size = params.size || file.size; createParams.name = name; createParams.content_type = type; if (params.public) { createParams.public = params.public; } if (params.tag_list) { createParams.tag_list = params.tag_list; } // Create a file object this.create(createParams, function(err, createResult){ if (err) { callback(err, null); } else { var uri = parseUri(createResult.blob_object_access.params), uploadUrl = uri.protocol + "://" + uri.authority + uri.path, uploadParams = {url: uploadUrl}, data = {}; fileId = createResult.id; createResult.size = size; Object.keys(uri.queryKey).forEach(function(val) { data[val] = decodeURIComponent(uri.queryKey[val]); }); data.file = file; uploadParams.data = data; // Upload the file to Amazon S3 _this.upload(uploadParams, function(err, result) { if (err) { callback(err, null); } else { // Mark file as uploaded _this.markUploaded({ id: fileId, size: size }, function(err, result){ if (err) { callback(err, null); } else { callback(null, createResult); } }); } }); } }); }
javascript
function(params, callback) { /** * Callback for QB.content.createAndUpload(params, callback). * @callback createAndUploadFileCallback * @param {object} error - The error object * @param {object} response - The file object (blob-object-access) */ var _this = this, createParams= {}, file, name, type, size, fileId; var clonedParams = JSON.parse(JSON.stringify(params)); clonedParams.file.data = "..."; file = params.file; name = params.name || file.name; type = params.type || file.type; size = params.size || file.size; createParams.name = name; createParams.content_type = type; if (params.public) { createParams.public = params.public; } if (params.tag_list) { createParams.tag_list = params.tag_list; } // Create a file object this.create(createParams, function(err, createResult){ if (err) { callback(err, null); } else { var uri = parseUri(createResult.blob_object_access.params), uploadUrl = uri.protocol + "://" + uri.authority + uri.path, uploadParams = {url: uploadUrl}, data = {}; fileId = createResult.id; createResult.size = size; Object.keys(uri.queryKey).forEach(function(val) { data[val] = decodeURIComponent(uri.queryKey[val]); }); data.file = file; uploadParams.data = data; // Upload the file to Amazon S3 _this.upload(uploadParams, function(err, result) { if (err) { callback(err, null); } else { // Mark file as uploaded _this.markUploaded({ id: fileId, size: size }, function(err, result){ if (err) { callback(err, null); } else { callback(null, createResult); } }); } }); } }); }
[ "function", "(", "params", ",", "callback", ")", "{", "/**\n * Callback for QB.content.createAndUpload(params, callback).\n * @callback createAndUploadFileCallback\n * @param {object} error - The error object\n * @param {object} response - The file object (blob-object-access)\n */", "var", "_this", "=", "this", ",", "createParams", "=", "{", "}", ",", "file", ",", "name", ",", "type", ",", "size", ",", "fileId", ";", "var", "clonedParams", "=", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "params", ")", ")", ";", "clonedParams", ".", "file", ".", "data", "=", "\"...\"", ";", "file", "=", "params", ".", "file", ";", "name", "=", "params", ".", "name", "||", "file", ".", "name", ";", "type", "=", "params", ".", "type", "||", "file", ".", "type", ";", "size", "=", "params", ".", "size", "||", "file", ".", "size", ";", "createParams", ".", "name", "=", "name", ";", "createParams", ".", "content_type", "=", "type", ";", "if", "(", "params", ".", "public", ")", "{", "createParams", ".", "public", "=", "params", ".", "public", ";", "}", "if", "(", "params", ".", "tag_list", ")", "{", "createParams", ".", "tag_list", "=", "params", ".", "tag_list", ";", "}", "// Create a file object", "this", ".", "create", "(", "createParams", ",", "function", "(", "err", ",", "createResult", ")", "{", "if", "(", "err", ")", "{", "callback", "(", "err", ",", "null", ")", ";", "}", "else", "{", "var", "uri", "=", "parseUri", "(", "createResult", ".", "blob_object_access", ".", "params", ")", ",", "uploadUrl", "=", "uri", ".", "protocol", "+", "\"://\"", "+", "uri", ".", "authority", "+", "uri", ".", "path", ",", "uploadParams", "=", "{", "url", ":", "uploadUrl", "}", ",", "data", "=", "{", "}", ";", "fileId", "=", "createResult", ".", "id", ";", "createResult", ".", "size", "=", "size", ";", "Object", ".", "keys", "(", "uri", ".", "queryKey", ")", ".", "forEach", "(", "function", "(", "val", ")", "{", "data", "[", "val", "]", "=", "decodeURIComponent", "(", "uri", ".", "queryKey", "[", "val", "]", ")", ";", "}", ")", ";", "data", ".", "file", "=", "file", ";", "uploadParams", ".", "data", "=", "data", ";", "// Upload the file to Amazon S3", "_this", ".", "upload", "(", "uploadParams", ",", "function", "(", "err", ",", "result", ")", "{", "if", "(", "err", ")", "{", "callback", "(", "err", ",", "null", ")", ";", "}", "else", "{", "// Mark file as uploaded", "_this", ".", "markUploaded", "(", "{", "id", ":", "fileId", ",", "size", ":", "size", "}", ",", "function", "(", "err", ",", "result", ")", "{", "if", "(", "err", ")", "{", "callback", "(", "err", ",", "null", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "createResult", ")", ";", "}", "}", ")", ";", "}", "}", ")", ";", "}", "}", ")", ";", "}" ]
Create file > upload file > mark file as uploaded > return result. @memberof QB.content @param {object} params - Object of parameters @param {object} params.file - File object @param {string} params.name - The file's name @param {string} params.type - The file's mime ({@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types content type}) @param {number} params.size - Size of file, in bytes @param {boolean} [params.public=false] - The file's visibility. public means it will be possible to access this file without QuickBlox session token provided. Default is 'false' @param {createAndUploadFileCallback} callback - The createAndUploadFileCallback function
[ "Create", "file", ">", "upload", "file", ">", "mark", "file", "as", "uploaded", ">", "return", "result", "." ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/qbContent.js#L122-L197
24,176
QuickBlox/quickblox-javascript-sdk
src/modules/qbContent.js
function (id, callback) { /** * Callback for QB.content.getInfo(id, callback) * @callback getFileInfoByIdCallback * @param {object} error - The error object * @param {object} response - The file object (blob-object-access) */ this.service.ajax({url: Utils.getUrl(config.urls.blobs, id)}, function (err, res) { if (err) { callback (err, null); } else { callback (null, res); } }); }
javascript
function (id, callback) { /** * Callback for QB.content.getInfo(id, callback) * @callback getFileInfoByIdCallback * @param {object} error - The error object * @param {object} response - The file object (blob-object-access) */ this.service.ajax({url: Utils.getUrl(config.urls.blobs, id)}, function (err, res) { if (err) { callback (err, null); } else { callback (null, res); } }); }
[ "function", "(", "id", ",", "callback", ")", "{", "/**\n * Callback for QB.content.getInfo(id, callback)\n * @callback getFileInfoByIdCallback\n * @param {object} error - The error object\n * @param {object} response - The file object (blob-object-access)\n */", "this", ".", "service", ".", "ajax", "(", "{", "url", ":", "Utils", ".", "getUrl", "(", "config", ".", "urls", ".", "blobs", ",", "id", ")", "}", ",", "function", "(", "err", ",", "res", ")", "{", "if", "(", "err", ")", "{", "callback", "(", "err", ",", "null", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "res", ")", ";", "}", "}", ")", ";", "}" ]
Retrieve file object by id (@link https://docsdev.quickblox.com/rest_api/Content_API.html#Retrieve_file read more}) @memberof QB.content @param {number} id - The id of file to declare as uploaded @param {getFileInfoByIdCallback} callback - The getFileInfoByIdCallback function return file's object.
[ "Retrieve", "file", "object", "by", "id", "(" ]
23edee3c5904cff3d723907a928ddf20dab8ffa5
https://github.com/QuickBlox/quickblox-javascript-sdk/blob/23edee3c5904cff3d723907a928ddf20dab8ffa5/src/modules/qbContent.js#L270-L284
24,177
McNull/angular-block-ui
dist/angular-block-ui.js
blockNavigation
function blockNavigation($scope, mainBlockUI, blockUIConfig) { if (blockUIConfig.blockBrowserNavigation) { function registerLocationChange() { $scope.$on('$locationChangeStart', function (event) { // console.log('$locationChangeStart', mainBlockUI.$_blockLocationChange + ' ' + mainBlockUI.state().blockCount); if (mainBlockUI.$_blockLocationChange && mainBlockUI.state().blockCount > 0) { event.preventDefault(); } }); $scope.$on('$locationChangeSuccess', function () { mainBlockUI.$_blockLocationChange = blockUIConfig.blockBrowserNavigation; // console.log('$locationChangeSuccess', mainBlockUI.$_blockLocationChange + ' ' + mainBlockUI.state().blockCount); }); } if (moduleLoaded('ngRoute')) { // After the initial content has been loaded we'll spy on any location // changes and discard them when needed. var fn = $scope.$on('$viewContentLoaded', function () { // Unhook the view loaded and hook a function that will prevent // location changes while the block is active. fn(); registerLocationChange(); }); } else { registerLocationChange(); } } }
javascript
function blockNavigation($scope, mainBlockUI, blockUIConfig) { if (blockUIConfig.blockBrowserNavigation) { function registerLocationChange() { $scope.$on('$locationChangeStart', function (event) { // console.log('$locationChangeStart', mainBlockUI.$_blockLocationChange + ' ' + mainBlockUI.state().blockCount); if (mainBlockUI.$_blockLocationChange && mainBlockUI.state().blockCount > 0) { event.preventDefault(); } }); $scope.$on('$locationChangeSuccess', function () { mainBlockUI.$_blockLocationChange = blockUIConfig.blockBrowserNavigation; // console.log('$locationChangeSuccess', mainBlockUI.$_blockLocationChange + ' ' + mainBlockUI.state().blockCount); }); } if (moduleLoaded('ngRoute')) { // After the initial content has been loaded we'll spy on any location // changes and discard them when needed. var fn = $scope.$on('$viewContentLoaded', function () { // Unhook the view loaded and hook a function that will prevent // location changes while the block is active. fn(); registerLocationChange(); }); } else { registerLocationChange(); } } }
[ "function", "blockNavigation", "(", "$scope", ",", "mainBlockUI", ",", "blockUIConfig", ")", "{", "if", "(", "blockUIConfig", ".", "blockBrowserNavigation", ")", "{", "function", "registerLocationChange", "(", ")", "{", "$scope", ".", "$on", "(", "'$locationChangeStart'", ",", "function", "(", "event", ")", "{", "// console.log('$locationChangeStart', mainBlockUI.$_blockLocationChange + ' ' + mainBlockUI.state().blockCount);", "if", "(", "mainBlockUI", ".", "$_blockLocationChange", "&&", "mainBlockUI", ".", "state", "(", ")", ".", "blockCount", ">", "0", ")", "{", "event", ".", "preventDefault", "(", ")", ";", "}", "}", ")", ";", "$scope", ".", "$on", "(", "'$locationChangeSuccess'", ",", "function", "(", ")", "{", "mainBlockUI", ".", "$_blockLocationChange", "=", "blockUIConfig", ".", "blockBrowserNavigation", ";", "// console.log('$locationChangeSuccess', mainBlockUI.$_blockLocationChange + ' ' + mainBlockUI.state().blockCount);", "}", ")", ";", "}", "if", "(", "moduleLoaded", "(", "'ngRoute'", ")", ")", "{", "// After the initial content has been loaded we'll spy on any location", "// changes and discard them when needed.", "var", "fn", "=", "$scope", ".", "$on", "(", "'$viewContentLoaded'", ",", "function", "(", ")", "{", "// Unhook the view loaded and hook a function that will prevent", "// location changes while the block is active.", "fn", "(", ")", ";", "registerLocationChange", "(", ")", ";", "}", ")", ";", "}", "else", "{", "registerLocationChange", "(", ")", ";", "}", "}", "}" ]
Called from block-ui-directive for the 'main' instance.
[ "Called", "from", "block", "-", "ui", "-", "directive", "for", "the", "main", "instance", "." ]
0d01eee67a6f8b0fd6beeaf16f950d1870842702
https://github.com/McNull/angular-block-ui/blob/0d01eee67a6f8b0fd6beeaf16f950d1870842702/dist/angular-block-ui.js#L104-L146
24,178
exceptionless/Exceptionless.JavaScript
dist/exceptionless.universal.js
unsubscribe
function unsubscribe(handler) { for (var i = handlers.length - 1; i >= 0; --i) { if (handlers[i] === handler) { handlers.splice(i, 1); } } if (handlers.length === 0) { window.onerror = _oldOnerrorHandler; _onErrorHandlerInstalled = false; } }
javascript
function unsubscribe(handler) { for (var i = handlers.length - 1; i >= 0; --i) { if (handlers[i] === handler) { handlers.splice(i, 1); } } if (handlers.length === 0) { window.onerror = _oldOnerrorHandler; _onErrorHandlerInstalled = false; } }
[ "function", "unsubscribe", "(", "handler", ")", "{", "for", "(", "var", "i", "=", "handlers", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "--", "i", ")", "{", "if", "(", "handlers", "[", "i", "]", "===", "handler", ")", "{", "handlers", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}", "if", "(", "handlers", ".", "length", "===", "0", ")", "{", "window", ".", "onerror", "=", "_oldOnerrorHandler", ";", "_onErrorHandlerInstalled", "=", "false", ";", "}", "}" ]
Remove a crash handler. @param {Function} handler @memberof TraceKit.report
[ "Remove", "a", "crash", "handler", "." ]
02711d099660a6d51a107b69a6e1c2aa68c9c559
https://github.com/exceptionless/Exceptionless.JavaScript/blob/02711d099660a6d51a107b69a6e1c2aa68c9c559/dist/exceptionless.universal.js#L139-L150
24,179
exceptionless/Exceptionless.JavaScript
dist/exceptionless.universal.js
installGlobalHandler
function installGlobalHandler() { if (_onErrorHandlerInstalled === true) { return; } _oldOnerrorHandler = window.onerror; window.onerror = traceKitWindowOnError; _onErrorHandlerInstalled = true; }
javascript
function installGlobalHandler() { if (_onErrorHandlerInstalled === true) { return; } _oldOnerrorHandler = window.onerror; window.onerror = traceKitWindowOnError; _onErrorHandlerInstalled = true; }
[ "function", "installGlobalHandler", "(", ")", "{", "if", "(", "_onErrorHandlerInstalled", "===", "true", ")", "{", "return", ";", "}", "_oldOnerrorHandler", "=", "window", ".", "onerror", ";", "window", ".", "onerror", "=", "traceKitWindowOnError", ";", "_onErrorHandlerInstalled", "=", "true", ";", "}" ]
Install a global onerror handler @memberof TraceKit.report
[ "Install", "a", "global", "onerror", "handler" ]
02711d099660a6d51a107b69a6e1c2aa68c9c559
https://github.com/exceptionless/Exceptionless.JavaScript/blob/02711d099660a6d51a107b69a6e1c2aa68c9c559/dist/exceptionless.universal.js#L241-L249
24,180
exceptionless/Exceptionless.JavaScript
dist/exceptionless.universal.js
processLastException
function processLastException() { var _lastExceptionStack = lastExceptionStack, _lastException = lastException; lastExceptionStack = null; lastException = null; notifyHandlers(_lastExceptionStack, false, _lastException); }
javascript
function processLastException() { var _lastExceptionStack = lastExceptionStack, _lastException = lastException; lastExceptionStack = null; lastException = null; notifyHandlers(_lastExceptionStack, false, _lastException); }
[ "function", "processLastException", "(", ")", "{", "var", "_lastExceptionStack", "=", "lastExceptionStack", ",", "_lastException", "=", "lastException", ";", "lastExceptionStack", "=", "null", ";", "lastException", "=", "null", ";", "notifyHandlers", "(", "_lastExceptionStack", ",", "false", ",", "_lastException", ")", ";", "}" ]
Process the most recent exception @memberof TraceKit.report
[ "Process", "the", "most", "recent", "exception" ]
02711d099660a6d51a107b69a6e1c2aa68c9c559
https://github.com/exceptionless/Exceptionless.JavaScript/blob/02711d099660a6d51a107b69a6e1c2aa68c9c559/dist/exceptionless.universal.js#L255-L261
24,181
exceptionless/Exceptionless.JavaScript
dist/exceptionless.universal.js
loadSource
function loadSource(url) { if (!TraceKit.remoteFetching) { //Only attempt request if remoteFetching is on. return ''; } try { var getXHR = function() { try { return new window.XMLHttpRequest(); } catch (e) { // explicitly bubble up the exception if not found return new window.ActiveXObject('Microsoft.XMLHTTP'); } }; var request = getXHR(); request.open('GET', url, false); request.send(''); return request.responseText; } catch (e) { return ''; } }
javascript
function loadSource(url) { if (!TraceKit.remoteFetching) { //Only attempt request if remoteFetching is on. return ''; } try { var getXHR = function() { try { return new window.XMLHttpRequest(); } catch (e) { // explicitly bubble up the exception if not found return new window.ActiveXObject('Microsoft.XMLHTTP'); } }; var request = getXHR(); request.open('GET', url, false); request.send(''); return request.responseText; } catch (e) { return ''; } }
[ "function", "loadSource", "(", "url", ")", "{", "if", "(", "!", "TraceKit", ".", "remoteFetching", ")", "{", "//Only attempt request if remoteFetching is on.", "return", "''", ";", "}", "try", "{", "var", "getXHR", "=", "function", "(", ")", "{", "try", "{", "return", "new", "window", ".", "XMLHttpRequest", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "// explicitly bubble up the exception if not found", "return", "new", "window", ".", "ActiveXObject", "(", "'Microsoft.XMLHTTP'", ")", ";", "}", "}", ";", "var", "request", "=", "getXHR", "(", ")", ";", "request", ".", "open", "(", "'GET'", ",", "url", ",", "false", ")", ";", "request", ".", "send", "(", "''", ")", ";", "return", "request", ".", "responseText", ";", "}", "catch", "(", "e", ")", "{", "return", "''", ";", "}", "}" ]
Attempts to retrieve source code via XMLHttpRequest, which is used to look up anonymous function names. @param {string} url URL of source code. @return {string} Source contents. @memberof TraceKit.computeStackTrace
[ "Attempts", "to", "retrieve", "source", "code", "via", "XMLHttpRequest", "which", "is", "used", "to", "look", "up", "anonymous", "function", "names", "." ]
02711d099660a6d51a107b69a6e1c2aa68c9c559
https://github.com/exceptionless/Exceptionless.JavaScript/blob/02711d099660a6d51a107b69a6e1c2aa68c9c559/dist/exceptionless.universal.js#L396-L417
24,182
exceptionless/Exceptionless.JavaScript
dist/exceptionless.universal.js
findSourceInUrls
function findSourceInUrls(re, urls) { var source, m; for (var i = 0, j = urls.length; i < j; ++i) { if ((source = getSource(urls[i])).length) { source = source.join('\n'); if ((m = re.exec(source))) { return { 'url': urls[i], 'line': source.substring(0, m.index).split('\n').length, 'column': m.index - source.lastIndexOf('\n', m.index) - 1 }; } } } return null; }
javascript
function findSourceInUrls(re, urls) { var source, m; for (var i = 0, j = urls.length; i < j; ++i) { if ((source = getSource(urls[i])).length) { source = source.join('\n'); if ((m = re.exec(source))) { return { 'url': urls[i], 'line': source.substring(0, m.index).split('\n').length, 'column': m.index - source.lastIndexOf('\n', m.index) - 1 }; } } } return null; }
[ "function", "findSourceInUrls", "(", "re", ",", "urls", ")", "{", "var", "source", ",", "m", ";", "for", "(", "var", "i", "=", "0", ",", "j", "=", "urls", ".", "length", ";", "i", "<", "j", ";", "++", "i", ")", "{", "if", "(", "(", "source", "=", "getSource", "(", "urls", "[", "i", "]", ")", ")", ".", "length", ")", "{", "source", "=", "source", ".", "join", "(", "'\\n'", ")", ";", "if", "(", "(", "m", "=", "re", ".", "exec", "(", "source", ")", ")", ")", "{", "return", "{", "'url'", ":", "urls", "[", "i", "]", ",", "'line'", ":", "source", ".", "substring", "(", "0", ",", "m", ".", "index", ")", ".", "split", "(", "'\\n'", ")", ".", "length", ",", "'column'", ":", "m", ".", "index", "-", "source", ".", "lastIndexOf", "(", "'\\n'", ",", "m", ".", "index", ")", "-", "1", "}", ";", "}", "}", "}", "return", "null", ";", "}" ]
Determines where a code fragment occurs in the source code. @param {RegExp} re The function definition. @param {Array.<string>} urls A list of URLs to search. @return {?Object.<string, (string|number)>} An object containing the url, line, and column number of the defined function. @memberof TraceKit.computeStackTrace
[ "Determines", "where", "a", "code", "fragment", "occurs", "in", "the", "source", "code", "." ]
02711d099660a6d51a107b69a6e1c2aa68c9c559
https://github.com/exceptionless/Exceptionless.JavaScript/blob/02711d099660a6d51a107b69a6e1c2aa68c9c559/dist/exceptionless.universal.js#L558-L575
24,183
exceptionless/Exceptionless.JavaScript
dist/exceptionless.universal.js
findSourceByFunctionBody
function findSourceByFunctionBody(func) { if (_isUndefined(window && window.document)) { return; } var urls = [window.location.href], scripts = window.document.getElementsByTagName('script'), body, code = '' + func, codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, eventRE = /^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, re, parts, result; for (var i = 0; i < scripts.length; ++i) { var script = scripts[i]; if (script.src) { urls.push(script.src); } } if (!(parts = codeRE.exec(code))) { re = new RegExp(escapeRegExp(code).replace(/\s+/g, '\\s+')); } // not sure if this is really necessary, but I don’t have a test // corpus large enough to confirm that and it was in the original. else { var name = parts[1] ? '\\s+' + parts[1] : '', args = parts[2].split(',').join('\\s*,\\s*'); body = escapeRegExp(parts[3]).replace(/;$/, ';?'); // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+'); re = new RegExp('function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}'); } // look for a normal function definition if ((result = findSourceInUrls(re, urls))) { return result; } // look for an old-school event handler function if ((parts = eventRE.exec(code))) { var event = parts[1]; body = escapeCodeAsRegExpForMatchingInsideHTML(parts[2]); // look for a function defined in HTML as an onXXX handler re = new RegExp('on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]', 'i'); if ((result = findSourceInUrls(re, urls[0]))) { return result; } // look for ??? re = new RegExp(body); if ((result = findSourceInUrls(re, urls))) { return result; } } return null; }
javascript
function findSourceByFunctionBody(func) { if (_isUndefined(window && window.document)) { return; } var urls = [window.location.href], scripts = window.document.getElementsByTagName('script'), body, code = '' + func, codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, eventRE = /^function on([\w$]+)\s*\(event\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/, re, parts, result; for (var i = 0; i < scripts.length; ++i) { var script = scripts[i]; if (script.src) { urls.push(script.src); } } if (!(parts = codeRE.exec(code))) { re = new RegExp(escapeRegExp(code).replace(/\s+/g, '\\s+')); } // not sure if this is really necessary, but I don’t have a test // corpus large enough to confirm that and it was in the original. else { var name = parts[1] ? '\\s+' + parts[1] : '', args = parts[2].split(',').join('\\s*,\\s*'); body = escapeRegExp(parts[3]).replace(/;$/, ';?'); // semicolon is inserted if the function ends with a comment.replace(/\s+/g, '\\s+'); re = new RegExp('function' + name + '\\s*\\(\\s*' + args + '\\s*\\)\\s*{\\s*' + body + '\\s*}'); } // look for a normal function definition if ((result = findSourceInUrls(re, urls))) { return result; } // look for an old-school event handler function if ((parts = eventRE.exec(code))) { var event = parts[1]; body = escapeCodeAsRegExpForMatchingInsideHTML(parts[2]); // look for a function defined in HTML as an onXXX handler re = new RegExp('on' + event + '=[\\\'"]\\s*' + body + '\\s*[\\\'"]', 'i'); if ((result = findSourceInUrls(re, urls[0]))) { return result; } // look for ??? re = new RegExp(body); if ((result = findSourceInUrls(re, urls))) { return result; } } return null; }
[ "function", "findSourceByFunctionBody", "(", "func", ")", "{", "if", "(", "_isUndefined", "(", "window", "&&", "window", ".", "document", ")", ")", "{", "return", ";", "}", "var", "urls", "=", "[", "window", ".", "location", ".", "href", "]", ",", "scripts", "=", "window", ".", "document", ".", "getElementsByTagName", "(", "'script'", ")", ",", "body", ",", "code", "=", "''", "+", "func", ",", "codeRE", "=", "/", "^function(?:\\s+([\\w$]+))?\\s*\\(([\\w\\s,]*)\\)\\s*\\{\\s*(\\S[\\s\\S]*\\S)\\s*\\}\\s*$", "/", ",", "eventRE", "=", "/", "^function on([\\w$]+)\\s*\\(event\\)\\s*\\{\\s*(\\S[\\s\\S]*\\S)\\s*\\}\\s*$", "/", ",", "re", ",", "parts", ",", "result", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "scripts", ".", "length", ";", "++", "i", ")", "{", "var", "script", "=", "scripts", "[", "i", "]", ";", "if", "(", "script", ".", "src", ")", "{", "urls", ".", "push", "(", "script", ".", "src", ")", ";", "}", "}", "if", "(", "!", "(", "parts", "=", "codeRE", ".", "exec", "(", "code", ")", ")", ")", "{", "re", "=", "new", "RegExp", "(", "escapeRegExp", "(", "code", ")", ".", "replace", "(", "/", "\\s+", "/", "g", ",", "'\\\\s+'", ")", ")", ";", "}", "// not sure if this is really necessary, but I don’t have a test", "// corpus large enough to confirm that and it was in the original.", "else", "{", "var", "name", "=", "parts", "[", "1", "]", "?", "'\\\\s+'", "+", "parts", "[", "1", "]", ":", "''", ",", "args", "=", "parts", "[", "2", "]", ".", "split", "(", "','", ")", ".", "join", "(", "'\\\\s*,\\\\s*'", ")", ";", "body", "=", "escapeRegExp", "(", "parts", "[", "3", "]", ")", ".", "replace", "(", "/", ";$", "/", ",", "';?'", ")", ";", "// semicolon is inserted if the function ends with a comment.replace(/\\s+/g, '\\\\s+');", "re", "=", "new", "RegExp", "(", "'function'", "+", "name", "+", "'\\\\s*\\\\(\\\\s*'", "+", "args", "+", "'\\\\s*\\\\)\\\\s*{\\\\s*'", "+", "body", "+", "'\\\\s*}'", ")", ";", "}", "// look for a normal function definition", "if", "(", "(", "result", "=", "findSourceInUrls", "(", "re", ",", "urls", ")", ")", ")", "{", "return", "result", ";", "}", "// look for an old-school event handler function", "if", "(", "(", "parts", "=", "eventRE", ".", "exec", "(", "code", ")", ")", ")", "{", "var", "event", "=", "parts", "[", "1", "]", ";", "body", "=", "escapeCodeAsRegExpForMatchingInsideHTML", "(", "parts", "[", "2", "]", ")", ";", "// look for a function defined in HTML as an onXXX handler", "re", "=", "new", "RegExp", "(", "'on'", "+", "event", "+", "'=[\\\\\\'\"]\\\\s*'", "+", "body", "+", "'\\\\s*[\\\\\\'\"]'", ",", "'i'", ")", ";", "if", "(", "(", "result", "=", "findSourceInUrls", "(", "re", ",", "urls", "[", "0", "]", ")", ")", ")", "{", "return", "result", ";", "}", "// look for ???", "re", "=", "new", "RegExp", "(", "body", ")", ";", "if", "(", "(", "result", "=", "findSourceInUrls", "(", "re", ",", "urls", ")", ")", ")", "{", "return", "result", ";", "}", "}", "return", "null", ";", "}" ]
Determines where a function was defined within the source code. @param {(Function|string)} func A function reference or serialized function definition. @return {?Object.<string, (string|number)>} An object containing the url, line, and column number of the defined function. @memberof TraceKit.computeStackTrace
[ "Determines", "where", "a", "function", "was", "defined", "within", "the", "source", "code", "." ]
02711d099660a6d51a107b69a6e1c2aa68c9c559
https://github.com/exceptionless/Exceptionless.JavaScript/blob/02711d099660a6d51a107b69a6e1c2aa68c9c559/dist/exceptionless.universal.js#L608-L670
24,184
exceptionless/Exceptionless.JavaScript
dist/exceptionless.universal.js
computeStackTraceFromStacktraceProp
function computeStackTraceFromStacktraceProp(ex) { // Access and store the stacktrace property before doing ANYTHING // else to it because Opera is not very good at providing it // reliably in other circumstances. var stacktrace = ex.stacktrace; if (!stacktrace) { return; } var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i, opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i, lines = stacktrace.split('\n'), stack = [], parts; for (var line = 0; line < lines.length; line += 2) { var element = null; if ((parts = opera10Regex.exec(lines[line]))) { element = { 'url': parts[2], 'line': +parts[1], 'column': null, 'func': parts[3], 'args':[] }; } else if ((parts = opera11Regex.exec(lines[line]))) { element = { 'url': parts[6], 'line': +parts[1], 'column': +parts[2], 'func': parts[3] || parts[4], 'args': parts[5] ? parts[5].split(',') : [] }; } if (element) { if (!element.func && element.line) { element.func = guessFunctionName(element.url, element.line); } if (element.line) { try { element.context = gatherContext(element.url, element.line); } catch (exc) {} } if (!element.context) { element.context = [lines[line + 1]]; } stack.push(element); } } if (!stack.length) { return null; } return { 'mode': 'stacktrace', 'name': ex.name, 'message': ex.message, 'stack': stack }; }
javascript
function computeStackTraceFromStacktraceProp(ex) { // Access and store the stacktrace property before doing ANYTHING // else to it because Opera is not very good at providing it // reliably in other circumstances. var stacktrace = ex.stacktrace; if (!stacktrace) { return; } var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i, opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^\)]+))\((.*)\))? in (.*):\s*$/i, lines = stacktrace.split('\n'), stack = [], parts; for (var line = 0; line < lines.length; line += 2) { var element = null; if ((parts = opera10Regex.exec(lines[line]))) { element = { 'url': parts[2], 'line': +parts[1], 'column': null, 'func': parts[3], 'args':[] }; } else if ((parts = opera11Regex.exec(lines[line]))) { element = { 'url': parts[6], 'line': +parts[1], 'column': +parts[2], 'func': parts[3] || parts[4], 'args': parts[5] ? parts[5].split(',') : [] }; } if (element) { if (!element.func && element.line) { element.func = guessFunctionName(element.url, element.line); } if (element.line) { try { element.context = gatherContext(element.url, element.line); } catch (exc) {} } if (!element.context) { element.context = [lines[line + 1]]; } stack.push(element); } } if (!stack.length) { return null; } return { 'mode': 'stacktrace', 'name': ex.name, 'message': ex.message, 'stack': stack }; }
[ "function", "computeStackTraceFromStacktraceProp", "(", "ex", ")", "{", "// Access and store the stacktrace property before doing ANYTHING", "// else to it because Opera is not very good at providing it", "// reliably in other circumstances.", "var", "stacktrace", "=", "ex", ".", "stacktrace", ";", "if", "(", "!", "stacktrace", ")", "{", "return", ";", "}", "var", "opera10Regex", "=", "/", " line (\\d+).*script (?:in )?(\\S+)(?:: in function (\\S+))?$", "/", "i", ",", "opera11Regex", "=", "/", " line (\\d+), column (\\d+)\\s*(?:in (?:<anonymous function: ([^>]+)>|([^\\)]+))\\((.*)\\))? in (.*):\\s*$", "/", "i", ",", "lines", "=", "stacktrace", ".", "split", "(", "'\\n'", ")", ",", "stack", "=", "[", "]", ",", "parts", ";", "for", "(", "var", "line", "=", "0", ";", "line", "<", "lines", ".", "length", ";", "line", "+=", "2", ")", "{", "var", "element", "=", "null", ";", "if", "(", "(", "parts", "=", "opera10Regex", ".", "exec", "(", "lines", "[", "line", "]", ")", ")", ")", "{", "element", "=", "{", "'url'", ":", "parts", "[", "2", "]", ",", "'line'", ":", "+", "parts", "[", "1", "]", ",", "'column'", ":", "null", ",", "'func'", ":", "parts", "[", "3", "]", ",", "'args'", ":", "[", "]", "}", ";", "}", "else", "if", "(", "(", "parts", "=", "opera11Regex", ".", "exec", "(", "lines", "[", "line", "]", ")", ")", ")", "{", "element", "=", "{", "'url'", ":", "parts", "[", "6", "]", ",", "'line'", ":", "+", "parts", "[", "1", "]", ",", "'column'", ":", "+", "parts", "[", "2", "]", ",", "'func'", ":", "parts", "[", "3", "]", "||", "parts", "[", "4", "]", ",", "'args'", ":", "parts", "[", "5", "]", "?", "parts", "[", "5", "]", ".", "split", "(", "','", ")", ":", "[", "]", "}", ";", "}", "if", "(", "element", ")", "{", "if", "(", "!", "element", ".", "func", "&&", "element", ".", "line", ")", "{", "element", ".", "func", "=", "guessFunctionName", "(", "element", ".", "url", ",", "element", ".", "line", ")", ";", "}", "if", "(", "element", ".", "line", ")", "{", "try", "{", "element", ".", "context", "=", "gatherContext", "(", "element", ".", "url", ",", "element", ".", "line", ")", ";", "}", "catch", "(", "exc", ")", "{", "}", "}", "if", "(", "!", "element", ".", "context", ")", "{", "element", ".", "context", "=", "[", "lines", "[", "line", "+", "1", "]", "]", ";", "}", "stack", ".", "push", "(", "element", ")", ";", "}", "}", "if", "(", "!", "stack", ".", "length", ")", "{", "return", "null", ";", "}", "return", "{", "'mode'", ":", "'stacktrace'", ",", "'name'", ":", "ex", ".", "name", ",", "'message'", ":", "ex", ".", "message", ",", "'stack'", ":", "stack", "}", ";", "}" ]
Computes stack trace information from the stacktrace property. Opera 10+ uses this property. @param {Error} ex @return {?TraceKit.StackTrace} Stack trace information. @memberof TraceKit.computeStackTrace
[ "Computes", "stack", "trace", "information", "from", "the", "stacktrace", "property", ".", "Opera", "10", "+", "uses", "this", "property", "." ]
02711d099660a6d51a107b69a6e1c2aa68c9c559
https://github.com/exceptionless/Exceptionless.JavaScript/blob/02711d099660a6d51a107b69a6e1c2aa68c9c559/dist/exceptionless.universal.js#L818-L881
24,185
marionettejs/backbone.radio
src/backbone.radio.js
callHandler
function callHandler(callback, context, args) { switch (args.length) { case 0: return callback.call(context); case 1: return callback.call(context, args[0]); case 2: return callback.call(context, args[0], args[1]); case 3: return callback.call(context, args[0], args[1], args[2]); default: return callback.apply(context, args); } }
javascript
function callHandler(callback, context, args) { switch (args.length) { case 0: return callback.call(context); case 1: return callback.call(context, args[0]); case 2: return callback.call(context, args[0], args[1]); case 3: return callback.call(context, args[0], args[1], args[2]); default: return callback.apply(context, args); } }
[ "function", "callHandler", "(", "callback", ",", "context", ",", "args", ")", "{", "switch", "(", "args", ".", "length", ")", "{", "case", "0", ":", "return", "callback", ".", "call", "(", "context", ")", ";", "case", "1", ":", "return", "callback", ".", "call", "(", "context", ",", "args", "[", "0", "]", ")", ";", "case", "2", ":", "return", "callback", ".", "call", "(", "context", ",", "args", "[", "0", "]", ",", "args", "[", "1", "]", ")", ";", "case", "3", ":", "return", "callback", ".", "call", "(", "context", ",", "args", "[", "0", "]", ",", "args", "[", "1", "]", ",", "args", "[", "2", "]", ")", ";", "default", ":", "return", "callback", ".", "apply", "(", "context", ",", "args", ")", ";", "}", "}" ]
An optimized way to execute callbacks.
[ "An", "optimized", "way", "to", "execute", "callbacks", "." ]
7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd
https://github.com/marionettejs/backbone.radio/blob/7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd/src/backbone.radio.js#L74-L82
24,186
marionettejs/backbone.radio
src/backbone.radio.js
removeHandler
function removeHandler(store, name, callback, context) { var event = store[name]; if ( (!callback || (callback === event.callback || callback === event.callback._callback)) && (!context || (context === event.context)) ) { delete store[name]; return true; } }
javascript
function removeHandler(store, name, callback, context) { var event = store[name]; if ( (!callback || (callback === event.callback || callback === event.callback._callback)) && (!context || (context === event.context)) ) { delete store[name]; return true; } }
[ "function", "removeHandler", "(", "store", ",", "name", ",", "callback", ",", "context", ")", "{", "var", "event", "=", "store", "[", "name", "]", ";", "if", "(", "(", "!", "callback", "||", "(", "callback", "===", "event", ".", "callback", "||", "callback", "===", "event", ".", "callback", ".", "_callback", ")", ")", "&&", "(", "!", "context", "||", "(", "context", "===", "event", ".", "context", ")", ")", ")", "{", "delete", "store", "[", "name", "]", ";", "return", "true", ";", "}", "}" ]
A helper used by `off` methods to the handler from the store
[ "A", "helper", "used", "by", "off", "methods", "to", "the", "handler", "from", "the", "store" ]
7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd
https://github.com/marionettejs/backbone.radio/blob/7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd/src/backbone.radio.js#L85-L94
24,187
marionettejs/backbone.radio
src/backbone.radio.js
_partial
function _partial(channelName) { return _logs[channelName] || (_logs[channelName] = Radio.log.bind(Radio, channelName)); }
javascript
function _partial(channelName) { return _logs[channelName] || (_logs[channelName] = Radio.log.bind(Radio, channelName)); }
[ "function", "_partial", "(", "channelName", ")", "{", "return", "_logs", "[", "channelName", "]", "||", "(", "_logs", "[", "channelName", "]", "=", "Radio", ".", "log", ".", "bind", "(", "Radio", ",", "channelName", ")", ")", ";", "}" ]
This is to produce an identical function in both tuneIn and tuneOut, so that Backbone.Events unregisters it.
[ "This", "is", "to", "produce", "an", "identical", "function", "in", "both", "tuneIn", "and", "tuneOut", "so", "that", "Backbone", ".", "Events", "unregisters", "it", "." ]
7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd
https://github.com/marionettejs/backbone.radio/blob/7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd/src/backbone.radio.js#L129-L131
24,188
marionettejs/backbone.radio
src/backbone.radio.js
function(channelName, eventName) { if (typeof console === 'undefined') { return; } var args = _.toArray(arguments).slice(2); console.log('[' + channelName + '] "' + eventName + '"', args); }
javascript
function(channelName, eventName) { if (typeof console === 'undefined') { return; } var args = _.toArray(arguments).slice(2); console.log('[' + channelName + '] "' + eventName + '"', args); }
[ "function", "(", "channelName", ",", "eventName", ")", "{", "if", "(", "typeof", "console", "===", "'undefined'", ")", "{", "return", ";", "}", "var", "args", "=", "_", ".", "toArray", "(", "arguments", ")", ".", "slice", "(", "2", ")", ";", "console", ".", "log", "(", "'['", "+", "channelName", "+", "'] \"'", "+", "eventName", "+", "'\"'", ",", "args", ")", ";", "}" ]
Log information about the channel and event
[ "Log", "information", "about", "the", "channel", "and", "event" ]
7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd
https://github.com/marionettejs/backbone.radio/blob/7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd/src/backbone.radio.js#L136-L140
24,189
marionettejs/backbone.radio
src/backbone.radio.js
function(channelName) { var channel = Radio.channel(channelName); channel._tunedIn = true; channel.on('all', _partial(channelName)); return this; }
javascript
function(channelName) { var channel = Radio.channel(channelName); channel._tunedIn = true; channel.on('all', _partial(channelName)); return this; }
[ "function", "(", "channelName", ")", "{", "var", "channel", "=", "Radio", ".", "channel", "(", "channelName", ")", ";", "channel", ".", "_tunedIn", "=", "true", ";", "channel", ".", "on", "(", "'all'", ",", "_partial", "(", "channelName", ")", ")", ";", "return", "this", ";", "}" ]
Logs all events on this channel to the console. It sets an internal value on the channel telling it we're listening, then sets a listener on the Backbone.Events
[ "Logs", "all", "events", "on", "this", "channel", "to", "the", "console", ".", "It", "sets", "an", "internal", "value", "on", "the", "channel", "telling", "it", "we", "re", "listening", "then", "sets", "a", "listener", "on", "the", "Backbone", ".", "Events" ]
7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd
https://github.com/marionettejs/backbone.radio/blob/7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd/src/backbone.radio.js#L145-L150
24,190
marionettejs/backbone.radio
src/backbone.radio.js
function(channelName) { var channel = Radio.channel(channelName); channel._tunedIn = false; channel.off('all', _partial(channelName)); delete _logs[channelName]; return this; }
javascript
function(channelName) { var channel = Radio.channel(channelName); channel._tunedIn = false; channel.off('all', _partial(channelName)); delete _logs[channelName]; return this; }
[ "function", "(", "channelName", ")", "{", "var", "channel", "=", "Radio", ".", "channel", "(", "channelName", ")", ";", "channel", ".", "_tunedIn", "=", "false", ";", "channel", ".", "off", "(", "'all'", ",", "_partial", "(", "channelName", ")", ")", ";", "delete", "_logs", "[", "channelName", "]", ";", "return", "this", ";", "}" ]
Stop logging all of the activities on this channel to the console
[ "Stop", "logging", "all", "of", "the", "activities", "on", "this", "channel", "to", "the", "console" ]
7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd
https://github.com/marionettejs/backbone.radio/blob/7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd/src/backbone.radio.js#L153-L159
24,191
marionettejs/backbone.radio
src/backbone.radio.js
function(name) { var args = _.toArray(arguments).slice(1); var results = eventsApi(this, 'request', name, args); if (results) { return results; } var channelName = this.channelName; var requests = this._requests; // Check if we should log the request, and if so, do it if (channelName && this._tunedIn) { Radio.log.apply(this, [channelName, name].concat(args)); } // If the request isn't handled, log it in DEBUG mode and exit if (requests && (requests[name] || requests['default'])) { var handler = requests[name] || requests['default']; args = requests[name] ? args : arguments; return callHandler(handler.callback, handler.context, args); } else { Radio.debugLog('An unhandled request was fired', name, channelName); } }
javascript
function(name) { var args = _.toArray(arguments).slice(1); var results = eventsApi(this, 'request', name, args); if (results) { return results; } var channelName = this.channelName; var requests = this._requests; // Check if we should log the request, and if so, do it if (channelName && this._tunedIn) { Radio.log.apply(this, [channelName, name].concat(args)); } // If the request isn't handled, log it in DEBUG mode and exit if (requests && (requests[name] || requests['default'])) { var handler = requests[name] || requests['default']; args = requests[name] ? args : arguments; return callHandler(handler.callback, handler.context, args); } else { Radio.debugLog('An unhandled request was fired', name, channelName); } }
[ "function", "(", "name", ")", "{", "var", "args", "=", "_", ".", "toArray", "(", "arguments", ")", ".", "slice", "(", "1", ")", ";", "var", "results", "=", "eventsApi", "(", "this", ",", "'request'", ",", "name", ",", "args", ")", ";", "if", "(", "results", ")", "{", "return", "results", ";", "}", "var", "channelName", "=", "this", ".", "channelName", ";", "var", "requests", "=", "this", ".", "_requests", ";", "// Check if we should log the request, and if so, do it", "if", "(", "channelName", "&&", "this", ".", "_tunedIn", ")", "{", "Radio", ".", "log", ".", "apply", "(", "this", ",", "[", "channelName", ",", "name", "]", ".", "concat", "(", "args", ")", ")", ";", "}", "// If the request isn't handled, log it in DEBUG mode and exit", "if", "(", "requests", "&&", "(", "requests", "[", "name", "]", "||", "requests", "[", "'default'", "]", ")", ")", "{", "var", "handler", "=", "requests", "[", "name", "]", "||", "requests", "[", "'default'", "]", ";", "args", "=", "requests", "[", "name", "]", "?", "args", ":", "arguments", ";", "return", "callHandler", "(", "handler", ".", "callback", ",", "handler", ".", "context", ",", "args", ")", ";", "}", "else", "{", "Radio", ".", "debugLog", "(", "'An unhandled request was fired'", ",", "name", ",", "channelName", ")", ";", "}", "}" ]
Make a request
[ "Make", "a", "request" ]
7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd
https://github.com/marionettejs/backbone.radio/blob/7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd/src/backbone.radio.js#L181-L203
24,192
marionettejs/backbone.radio
src/backbone.radio.js
function(name, callback, context) { if (eventsApi(this, 'replyOnce', name, [callback, context])) { return this; } var self = this; var once = _.once(function() { self.stopReplying(name); return makeCallback(callback).apply(this, arguments); }); return this.reply(name, once, context); }
javascript
function(name, callback, context) { if (eventsApi(this, 'replyOnce', name, [callback, context])) { return this; } var self = this; var once = _.once(function() { self.stopReplying(name); return makeCallback(callback).apply(this, arguments); }); return this.reply(name, once, context); }
[ "function", "(", "name", ",", "callback", ",", "context", ")", "{", "if", "(", "eventsApi", "(", "this", ",", "'replyOnce'", ",", "name", ",", "[", "callback", ",", "context", "]", ")", ")", "{", "return", "this", ";", "}", "var", "self", "=", "this", ";", "var", "once", "=", "_", ".", "once", "(", "function", "(", ")", "{", "self", ".", "stopReplying", "(", "name", ")", ";", "return", "makeCallback", "(", "callback", ")", ".", "apply", "(", "this", ",", "arguments", ")", ";", "}", ")", ";", "return", "this", ".", "reply", "(", "name", ",", "once", ",", "context", ")", ";", "}" ]
Set up a handler that can only be requested once
[ "Set", "up", "a", "handler", "that", "can", "only", "be", "requested", "once" ]
7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd
https://github.com/marionettejs/backbone.radio/blob/7a58ade84bedb5551c2e12bdd3434d0fd6b1bdbd/src/backbone.radio.js#L226-L239
24,193
lpinca/forwarded-parse
lib/ascii.js
isDelimiter
function isDelimiter(code) { return code === 0x22 // '"' || code === 0x28 // '(' || code === 0x29 // ')' || code === 0x2C // ',' || code === 0x2F // '/' || code >= 0x3A && code <= 0x40 // ':', ';', '<', '=', '>', '?' '@' || code >= 0x5B && code <= 0x5D // '[', '\', ']' || code === 0x7B // '{' || code === 0x7D; // '}' }
javascript
function isDelimiter(code) { return code === 0x22 // '"' || code === 0x28 // '(' || code === 0x29 // ')' || code === 0x2C // ',' || code === 0x2F // '/' || code >= 0x3A && code <= 0x40 // ':', ';', '<', '=', '>', '?' '@' || code >= 0x5B && code <= 0x5D // '[', '\', ']' || code === 0x7B // '{' || code === 0x7D; // '}' }
[ "function", "isDelimiter", "(", "code", ")", "{", "return", "code", "===", "0x22", "// '\"'", "||", "code", "===", "0x28", "// '('", "||", "code", "===", "0x29", "// ')'", "||", "code", "===", "0x2C", "// ','", "||", "code", "===", "0x2F", "// '/'", "||", "code", ">=", "0x3A", "&&", "code", "<=", "0x40", "// ':', ';', '<', '=', '>', '?' '@'", "||", "code", ">=", "0x5B", "&&", "code", "<=", "0x5D", "// '[', '\\', ']'", "||", "code", "===", "0x7B", "// '{'", "||", "code", "===", "0x7D", ";", "// '}'", "}" ]
Check if a character is a delimiter as defined in section 3.2.6 of RFC 7230. @param {number} code The code of the character to check. @returns {boolean} `true` if the character is a delimiter, else `false`. @public
[ "Check", "if", "a", "character", "is", "a", "delimiter", "as", "defined", "in", "section", "3", ".", "2", ".", "6", "of", "RFC", "7230", "." ]
a80ef2cb3892ff7c0a2ec80800cd8aa4580dfe89
https://github.com/lpinca/forwarded-parse/blob/a80ef2cb3892ff7c0a2ec80800cd8aa4580dfe89/lib/ascii.js#L11-L21
24,194
lpinca/forwarded-parse
lib/ascii.js
isTokenChar
function isTokenChar(code) { return code === 0x21 // '!' || code >= 0x23 && code <= 0x27 // '#', '$', '%', '&', ''' || code === 0x2A // '*' || code === 0x2B // '+' || code === 0x2D // '-' || code === 0x2E // '.' || code >= 0x30 && code <= 0x39 // 0-9 || code >= 0x41 && code <= 0x5A // A-Z || code >= 0x5E && code <= 0x7A // '^', '_', '`', a-z || code === 0x7C // '|' || code === 0x7E; // '~' }
javascript
function isTokenChar(code) { return code === 0x21 // '!' || code >= 0x23 && code <= 0x27 // '#', '$', '%', '&', ''' || code === 0x2A // '*' || code === 0x2B // '+' || code === 0x2D // '-' || code === 0x2E // '.' || code >= 0x30 && code <= 0x39 // 0-9 || code >= 0x41 && code <= 0x5A // A-Z || code >= 0x5E && code <= 0x7A // '^', '_', '`', a-z || code === 0x7C // '|' || code === 0x7E; // '~' }
[ "function", "isTokenChar", "(", "code", ")", "{", "return", "code", "===", "0x21", "// '!'", "||", "code", ">=", "0x23", "&&", "code", "<=", "0x27", "// '#', '$', '%', '&', '''", "||", "code", "===", "0x2A", "// '*'", "||", "code", "===", "0x2B", "// '+'", "||", "code", "===", "0x2D", "// '-'", "||", "code", "===", "0x2E", "// '.'", "||", "code", ">=", "0x30", "&&", "code", "<=", "0x39", "// 0-9", "||", "code", ">=", "0x41", "&&", "code", "<=", "0x5A", "// A-Z", "||", "code", ">=", "0x5E", "&&", "code", "<=", "0x7A", "// '^', '_', '`', a-z", "||", "code", "===", "0x7C", "// '|'", "||", "code", "===", "0x7E", ";", "// '~'", "}" ]
Check if a character is allowed in a token as defined in section 3.2.6 of RFC 7230. @param {number} code The code of the character to check. @returns {boolean} `true` if the character is allowed, else `false`. @public
[ "Check", "if", "a", "character", "is", "allowed", "in", "a", "token", "as", "defined", "in", "section", "3", ".", "2", ".", "6", "of", "RFC", "7230", "." ]
a80ef2cb3892ff7c0a2ec80800cd8aa4580dfe89
https://github.com/lpinca/forwarded-parse/blob/a80ef2cb3892ff7c0a2ec80800cd8aa4580dfe89/lib/ascii.js#L31-L43
24,195
lpinca/forwarded-parse
lib/error.js
ParseError
function ParseError(message, input) { Error.captureStackTrace(this, ParseError); this.name = this.constructor.name; this.message = message; this.input = input; }
javascript
function ParseError(message, input) { Error.captureStackTrace(this, ParseError); this.name = this.constructor.name; this.message = message; this.input = input; }
[ "function", "ParseError", "(", "message", ",", "input", ")", "{", "Error", ".", "captureStackTrace", "(", "this", ",", "ParseError", ")", ";", "this", ".", "name", "=", "this", ".", "constructor", ".", "name", ";", "this", ".", "message", "=", "message", ";", "this", ".", "input", "=", "input", ";", "}" ]
An error thrown by the parser on unexpected input. @constructor @param {string} message The error message. @param {string} input The unexpected input. @public
[ "An", "error", "thrown", "by", "the", "parser", "on", "unexpected", "input", "." ]
a80ef2cb3892ff7c0a2ec80800cd8aa4580dfe89
https://github.com/lpinca/forwarded-parse/blob/a80ef2cb3892ff7c0a2ec80800cd8aa4580dfe89/lib/error.js#L13-L19
24,196
RisingStack/graffiti-mongoose
src/model/model.js
extractPath
function extractPath(schemaPath) { const subNames = schemaPath.path.split('.'); return reduceRight(subNames, (fields, name, key) => { const obj = {}; if (schemaPath instanceof mongoose.Schema.Types.DocumentArray) { const subSchemaPaths = schemaPath.schema.paths; const fields = extractPaths(subSchemaPaths, { name }); // eslint-disable-line no-use-before-define obj[name] = { name, fields, nonNull: false, type: 'Array', subtype: 'Object' }; } else if (schemaPath instanceof mongoose.Schema.Types.Embedded) { schemaPath.modelName = schemaPath.schema.options.graphqlTypeName || name; // embedded model must be unique Instance const embeddedModel = embeddedModels.hasOwnProperty(schemaPath.modelName) ? embeddedModels[schemaPath.modelName] : getModel(schemaPath); // eslint-disable-line no-use-before-define embeddedModels[schemaPath.modelName] = embeddedModel; obj[name] = { ...getField(schemaPath), embeddedModel }; } else if (key === subNames.length - 1) { obj[name] = getField(schemaPath); } else { obj[name] = { name, fields, nonNull: false, type: 'Object' }; } return obj; }, {}); }
javascript
function extractPath(schemaPath) { const subNames = schemaPath.path.split('.'); return reduceRight(subNames, (fields, name, key) => { const obj = {}; if (schemaPath instanceof mongoose.Schema.Types.DocumentArray) { const subSchemaPaths = schemaPath.schema.paths; const fields = extractPaths(subSchemaPaths, { name }); // eslint-disable-line no-use-before-define obj[name] = { name, fields, nonNull: false, type: 'Array', subtype: 'Object' }; } else if (schemaPath instanceof mongoose.Schema.Types.Embedded) { schemaPath.modelName = schemaPath.schema.options.graphqlTypeName || name; // embedded model must be unique Instance const embeddedModel = embeddedModels.hasOwnProperty(schemaPath.modelName) ? embeddedModels[schemaPath.modelName] : getModel(schemaPath); // eslint-disable-line no-use-before-define embeddedModels[schemaPath.modelName] = embeddedModel; obj[name] = { ...getField(schemaPath), embeddedModel }; } else if (key === subNames.length - 1) { obj[name] = getField(schemaPath); } else { obj[name] = { name, fields, nonNull: false, type: 'Object' }; } return obj; }, {}); }
[ "function", "extractPath", "(", "schemaPath", ")", "{", "const", "subNames", "=", "schemaPath", ".", "path", ".", "split", "(", "'.'", ")", ";", "return", "reduceRight", "(", "subNames", ",", "(", "fields", ",", "name", ",", "key", ")", "=>", "{", "const", "obj", "=", "{", "}", ";", "if", "(", "schemaPath", "instanceof", "mongoose", ".", "Schema", ".", "Types", ".", "DocumentArray", ")", "{", "const", "subSchemaPaths", "=", "schemaPath", ".", "schema", ".", "paths", ";", "const", "fields", "=", "extractPaths", "(", "subSchemaPaths", ",", "{", "name", "}", ")", ";", "// eslint-disable-line no-use-before-define", "obj", "[", "name", "]", "=", "{", "name", ",", "fields", ",", "nonNull", ":", "false", ",", "type", ":", "'Array'", ",", "subtype", ":", "'Object'", "}", ";", "}", "else", "if", "(", "schemaPath", "instanceof", "mongoose", ".", "Schema", ".", "Types", ".", "Embedded", ")", "{", "schemaPath", ".", "modelName", "=", "schemaPath", ".", "schema", ".", "options", ".", "graphqlTypeName", "||", "name", ";", "// embedded model must be unique Instance", "const", "embeddedModel", "=", "embeddedModels", ".", "hasOwnProperty", "(", "schemaPath", ".", "modelName", ")", "?", "embeddedModels", "[", "schemaPath", ".", "modelName", "]", ":", "getModel", "(", "schemaPath", ")", ";", "// eslint-disable-line no-use-before-define", "embeddedModels", "[", "schemaPath", ".", "modelName", "]", "=", "embeddedModel", ";", "obj", "[", "name", "]", "=", "{", "...", "getField", "(", "schemaPath", ")", ",", "embeddedModel", "}", ";", "}", "else", "if", "(", "key", "===", "subNames", ".", "length", "-", "1", ")", "{", "obj", "[", "name", "]", "=", "getField", "(", "schemaPath", ")", ";", "}", "else", "{", "obj", "[", "name", "]", "=", "{", "name", ",", "fields", ",", "nonNull", ":", "false", ",", "type", ":", "'Object'", "}", ";", "}", "return", "obj", ";", "}", ",", "{", "}", ")", ";", "}" ]
Extracts tree chunk from path if it's a sub-document @method extractPath @param {Object} schemaPath @param {Object} model @return {Object} field
[ "Extracts", "tree", "chunk", "from", "path", "if", "it", "s", "a", "sub", "-", "document" ]
414c91e4b2081bf0d14ecd2de545f621713f5da7
https://github.com/RisingStack/graffiti-mongoose/blob/414c91e4b2081bf0d14ecd2de545f621713f5da7/src/model/model.js#L65-L106
24,197
RisingStack/graffiti-mongoose
src/model/model.js
extractPaths
function extractPaths(schemaPaths, model) { return reduce(schemaPaths, (fields, schemaPath) => ( merge(fields, extractPath(schemaPath, model)) ), {}); }
javascript
function extractPaths(schemaPaths, model) { return reduce(schemaPaths, (fields, schemaPath) => ( merge(fields, extractPath(schemaPath, model)) ), {}); }
[ "function", "extractPaths", "(", "schemaPaths", ",", "model", ")", "{", "return", "reduce", "(", "schemaPaths", ",", "(", "fields", ",", "schemaPath", ")", "=>", "(", "merge", "(", "fields", ",", "extractPath", "(", "schemaPath", ",", "model", ")", ")", ")", ",", "{", "}", ")", ";", "}" ]
Merge sub-document tree chunks @method extractPaths @param {Object} schemaPaths @param {Object} model @return {Object) extractedSchemaPaths
[ "Merge", "sub", "-", "document", "tree", "chunks" ]
414c91e4b2081bf0d14ecd2de545f621713f5da7
https://github.com/RisingStack/graffiti-mongoose/blob/414c91e4b2081bf0d14ecd2de545f621713f5da7/src/model/model.js#L115-L119
24,198
RisingStack/graffiti-mongoose
src/model/model.js
getModel
function getModel(model) { const schemaPaths = model.schema.paths; const name = model.modelName; const fields = extractPaths(schemaPaths, { name }); return { name, fields, model }; }
javascript
function getModel(model) { const schemaPaths = model.schema.paths; const name = model.modelName; const fields = extractPaths(schemaPaths, { name }); return { name, fields, model }; }
[ "function", "getModel", "(", "model", ")", "{", "const", "schemaPaths", "=", "model", ".", "schema", ".", "paths", ";", "const", "name", "=", "model", ".", "modelName", ";", "const", "fields", "=", "extractPaths", "(", "schemaPaths", ",", "{", "name", "}", ")", ";", "return", "{", "name", ",", "fields", ",", "model", "}", ";", "}" ]
Turn mongoose model to graffiti model @method getModel @param {Object} model Mongoose model @return {Object} graffiti model
[ "Turn", "mongoose", "model", "to", "graffiti", "model" ]
414c91e4b2081bf0d14ecd2de545f621713f5da7
https://github.com/RisingStack/graffiti-mongoose/blob/414c91e4b2081bf0d14ecd2de545f621713f5da7/src/model/model.js#L127-L138
24,199
RisingStack/graffiti-mongoose
src/query/query.js
getIdFetcher
function getIdFetcher(graffitiModels) { return function idFetcher(obj, { id: globalId }, context, info) { const { type, id } = fromGlobalId(globalId); if (type === 'Viewer') { return viewer; } else if (graffitiModels[type]) { const Collection = graffitiModels[type].model; return getOne(Collection, { id }, context, info); } return null; }; }
javascript
function getIdFetcher(graffitiModels) { return function idFetcher(obj, { id: globalId }, context, info) { const { type, id } = fromGlobalId(globalId); if (type === 'Viewer') { return viewer; } else if (graffitiModels[type]) { const Collection = graffitiModels[type].model; return getOne(Collection, { id }, context, info); } return null; }; }
[ "function", "getIdFetcher", "(", "graffitiModels", ")", "{", "return", "function", "idFetcher", "(", "obj", ",", "{", "id", ":", "globalId", "}", ",", "context", ",", "info", ")", "{", "const", "{", "type", ",", "id", "}", "=", "fromGlobalId", "(", "globalId", ")", ";", "if", "(", "type", "===", "'Viewer'", ")", "{", "return", "viewer", ";", "}", "else", "if", "(", "graffitiModels", "[", "type", "]", ")", "{", "const", "Collection", "=", "graffitiModels", "[", "type", "]", ".", "model", ";", "return", "getOne", "(", "Collection", ",", "{", "id", "}", ",", "context", ",", "info", ")", ";", "}", "return", "null", ";", "}", ";", "}" ]
Returns an idFetcher function, that can resolve an object based on a global id
[ "Returns", "an", "idFetcher", "function", "that", "can", "resolve", "an", "object", "based", "on", "a", "global", "id" ]
414c91e4b2081bf0d14ecd2de545f621713f5da7
https://github.com/RisingStack/graffiti-mongoose/blob/414c91e4b2081bf0d14ecd2de545f621713f5da7/src/query/query.js#L198-L211