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
22,400
joewalker/gcli
lib/gcli/languages/command.js
function() { // If the user is on a valid value, then we increment the value, but if // they've typed something that's not right we page through predictions if (this.assignment.getStatus() === Status.VALID) { return this.requisition.nudge(this.assignment, 1).then(function() { this.textChanged(); this.focusManager.onInputChange(); return true; }.bind(this)); } return Promise.resolve(false); }
javascript
function() { // If the user is on a valid value, then we increment the value, but if // they've typed something that's not right we page through predictions if (this.assignment.getStatus() === Status.VALID) { return this.requisition.nudge(this.assignment, 1).then(function() { this.textChanged(); this.focusManager.onInputChange(); return true; }.bind(this)); } return Promise.resolve(false); }
[ "function", "(", ")", "{", "// If the user is on a valid value, then we increment the value, but if", "// they've typed something that's not right we page through predictions", "if", "(", "this", ".", "assignment", ".", "getStatus", "(", ")", "===", "Status", ".", "VALID", ")", "{", "return", "this", ".", "requisition", ".", "nudge", "(", "this", ".", "assignment", ",", "1", ")", ".", "then", "(", "function", "(", ")", "{", "this", ".", "textChanged", "(", ")", ";", "this", ".", "focusManager", ".", "onInputChange", "(", ")", ";", "return", "true", ";", "}", ".", "bind", "(", "this", ")", ")", ";", "}", "return", "Promise", ".", "resolve", "(", "false", ")", ";", "}" ]
See also handleDownArrow for some symmetry
[ "See", "also", "handleDownArrow", "for", "some", "symmetry" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/languages/command.js#L248-L260
22,401
joewalker/gcli
lib/gcli/languages/command.js
function(input) { // Deny RETURN unless the command might work if (this.requisition.status !== Status.VALID) { return Promise.resolve(false); } this.terminal.history.add(input); this.terminal.unsetChoice().catch(util.errorHandler); this.terminal._previousValue = this.terminal.inputElement.value; this.terminal.inputElement.value = ''; return this.requisition.exec().then(function() { this.textChanged(); return true; }.bind(this)); }
javascript
function(input) { // Deny RETURN unless the command might work if (this.requisition.status !== Status.VALID) { return Promise.resolve(false); } this.terminal.history.add(input); this.terminal.unsetChoice().catch(util.errorHandler); this.terminal._previousValue = this.terminal.inputElement.value; this.terminal.inputElement.value = ''; return this.requisition.exec().then(function() { this.textChanged(); return true; }.bind(this)); }
[ "function", "(", "input", ")", "{", "// Deny RETURN unless the command might work", "if", "(", "this", ".", "requisition", ".", "status", "!==", "Status", ".", "VALID", ")", "{", "return", "Promise", ".", "resolve", "(", "false", ")", ";", "}", "this", ".", "terminal", ".", "history", ".", "add", "(", "input", ")", ";", "this", ".", "terminal", ".", "unsetChoice", "(", ")", ".", "catch", "(", "util", ".", "errorHandler", ")", ";", "this", ".", "terminal", ".", "_previousValue", "=", "this", ".", "terminal", ".", "inputElement", ".", "value", ";", "this", ".", "terminal", ".", "inputElement", ".", "value", "=", "''", ";", "return", "this", ".", "requisition", ".", "exec", "(", ")", ".", "then", "(", "function", "(", ")", "{", "this", ".", "textChanged", "(", ")", ";", "return", "true", ";", "}", ".", "bind", "(", "this", ")", ")", ";", "}" ]
RETURN checks status and might exec
[ "RETURN", "checks", "status", "and", "might", "exec" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/languages/command.js#L280-L296
22,402
joewalker/gcli
lib/gcli/languages/command.js
function(value) { this.terminal._caretChange = Caret.NO_CHANGE; return this.requisition.update(value).then(function(updated) { // Abort UI changes if this UI update has been overtaken if (!updated) { return RESOLVED; } this.textChanged(); return this.terminal.unsetChoice(); }.bind(this)); }
javascript
function(value) { this.terminal._caretChange = Caret.NO_CHANGE; return this.requisition.update(value).then(function(updated) { // Abort UI changes if this UI update has been overtaken if (!updated) { return RESOLVED; } this.textChanged(); return this.terminal.unsetChoice(); }.bind(this)); }
[ "function", "(", "value", ")", "{", "this", ".", "terminal", ".", "_caretChange", "=", "Caret", ".", "NO_CHANGE", ";", "return", "this", ".", "requisition", ".", "update", "(", "value", ")", ".", "then", "(", "function", "(", "updated", ")", "{", "// Abort UI changes if this UI update has been overtaken", "if", "(", "!", "updated", ")", "{", "return", "RESOLVED", ";", "}", "this", ".", "textChanged", "(", ")", ";", "return", "this", ".", "terminal", ".", "unsetChoice", "(", ")", ";", "}", ".", "bind", "(", "this", ")", ")", ";", "}" ]
The input text has changed in some way.
[ "The", "input", "text", "has", "changed", "in", "some", "way", "." ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/languages/command.js#L329-L340
22,403
joewalker/gcli
lib/gcli/languages/command.js
function(cursor) { this._caretChange = Caret.NO_CHANGE; this._processCaretChange({ typed: this.terminal.inputElement.value, cursor: cursor }); }
javascript
function(cursor) { this._caretChange = Caret.NO_CHANGE; this._processCaretChange({ typed: this.terminal.inputElement.value, cursor: cursor }); }
[ "function", "(", "cursor", ")", "{", "this", ".", "_caretChange", "=", "Caret", ".", "NO_CHANGE", ";", "this", ".", "_processCaretChange", "(", "{", "typed", ":", "this", ".", "terminal", ".", "inputElement", ".", "value", ",", "cursor", ":", "cursor", "}", ")", ";", "}" ]
Counterpart to |setInput| for moving the cursor. @param cursor A JS object shaped like { start: x, end: y }
[ "Counterpart", "to", "|setInput|", "for", "moving", "the", "cursor", "." ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/languages/command.js#L346-L352
22,404
joewalker/gcli
lib/gcli/languages/command.js
function() { var input = this.terminal.getInputState(); var start = input.cursor.start; var index = this.terminal.getChoiceIndex(); return this.requisition.getStateData(start, index).then(function(data) { // Calculate the statusMarkup required to show wavy lines underneath the // input text (like that of an inline spell-checker) which used by the // template process for completer.html // i.e. s/space/&nbsp/g in the string (for HTML display) and status to an // appropriate class name (i.e. lower cased, prefixed with gcli-in-) data.statusMarkup.forEach(function(member) { member.string = member.string.replace(/ /g, '\u00a0'); // i.e.   member.className = 'gcli-in-' + member.status.toString().toLowerCase(); }, this); return data; }); }
javascript
function() { var input = this.terminal.getInputState(); var start = input.cursor.start; var index = this.terminal.getChoiceIndex(); return this.requisition.getStateData(start, index).then(function(data) { // Calculate the statusMarkup required to show wavy lines underneath the // input text (like that of an inline spell-checker) which used by the // template process for completer.html // i.e. s/space/&nbsp/g in the string (for HTML display) and status to an // appropriate class name (i.e. lower cased, prefixed with gcli-in-) data.statusMarkup.forEach(function(member) { member.string = member.string.replace(/ /g, '\u00a0'); // i.e.   member.className = 'gcli-in-' + member.status.toString().toLowerCase(); }, this); return data; }); }
[ "function", "(", ")", "{", "var", "input", "=", "this", ".", "terminal", ".", "getInputState", "(", ")", ";", "var", "start", "=", "input", ".", "cursor", ".", "start", ";", "var", "index", "=", "this", ".", "terminal", ".", "getChoiceIndex", "(", ")", ";", "return", "this", ".", "requisition", ".", "getStateData", "(", "start", ",", "index", ")", ".", "then", "(", "function", "(", "data", ")", "{", "// Calculate the statusMarkup required to show wavy lines underneath the", "// input text (like that of an inline spell-checker) which used by the", "// template process for completer.html", "// i.e. s/space/&nbsp/g in the string (for HTML display) and status to an", "// appropriate class name (i.e. lower cased, prefixed with gcli-in-)", "data", ".", "statusMarkup", ".", "forEach", "(", "function", "(", "member", ")", "{", "member", ".", "string", "=", "member", ".", "string", ".", "replace", "(", "/", " ", "/", "g", ",", "'\\u00a0'", ")", ";", "// i.e.  ", "member", ".", "className", "=", "'gcli-in-'", "+", "member", ".", "status", ".", "toString", "(", ")", ".", "toLowerCase", "(", ")", ";", "}", ",", "this", ")", ";", "return", "data", ";", "}", ")", ";", "}" ]
Calculate the properties required by the template process for completer.html
[ "Calculate", "the", "properties", "required", "by", "the", "template", "process", "for", "completer", ".", "html" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/languages/command.js#L415-L433
22,405
joewalker/gcli
lib/gcli/languages/command.js
function(ev) { if (ev.output.hidden) { return; } var template = this.commandDom.cloneNode(true); var templateOptions = { stack: 'terminal.html#outputView' }; var context = this.requisition.conversionContext; var data = { onclick: context.update, ondblclick: context.updateExec, language: this, output: ev.output, promptClass: (ev.output.error ? 'gcli-row-error' : '') + (ev.output.completed ? ' gcli-row-complete' : ''), // Elements attached to this by template(). rowinEle: null, rowoutEle: null, throbEle: null, promptEle: null }; domtemplate.template(template, data, templateOptions); ev.output.promise.then(function() { var document = data.rowoutEle.ownerDocument; if (ev.output.completed) { data.promptEle.classList.add('gcli-row-complete'); } if (ev.output.error) { data.promptEle.classList.add('gcli-row-error'); } util.clearElement(data.rowoutEle); return ev.output.convert('dom', context).then(function(node) { this.terminal.scrollToBottom(); data.throbEle.style.display = ev.output.completed ? 'none' : 'block'; if (node == null) { data.promptEle.classList.add('gcli-row-error'); // TODO: show some error to the user } this._linksToNewTab(node); data.rowoutEle.appendChild(node); var event = document.createEvent('Event'); event.initEvent('load', true, true); event.addedElement = node; node.dispatchEvent(event); }.bind(this)); }.bind(this)).catch(console.error); this.terminal.addElement(data.rowinEle); this.terminal.addElement(data.rowoutEle); this.terminal.scrollToBottom(); this.focusManager.outputted(); }
javascript
function(ev) { if (ev.output.hidden) { return; } var template = this.commandDom.cloneNode(true); var templateOptions = { stack: 'terminal.html#outputView' }; var context = this.requisition.conversionContext; var data = { onclick: context.update, ondblclick: context.updateExec, language: this, output: ev.output, promptClass: (ev.output.error ? 'gcli-row-error' : '') + (ev.output.completed ? ' gcli-row-complete' : ''), // Elements attached to this by template(). rowinEle: null, rowoutEle: null, throbEle: null, promptEle: null }; domtemplate.template(template, data, templateOptions); ev.output.promise.then(function() { var document = data.rowoutEle.ownerDocument; if (ev.output.completed) { data.promptEle.classList.add('gcli-row-complete'); } if (ev.output.error) { data.promptEle.classList.add('gcli-row-error'); } util.clearElement(data.rowoutEle); return ev.output.convert('dom', context).then(function(node) { this.terminal.scrollToBottom(); data.throbEle.style.display = ev.output.completed ? 'none' : 'block'; if (node == null) { data.promptEle.classList.add('gcli-row-error'); // TODO: show some error to the user } this._linksToNewTab(node); data.rowoutEle.appendChild(node); var event = document.createEvent('Event'); event.initEvent('load', true, true); event.addedElement = node; node.dispatchEvent(event); }.bind(this)); }.bind(this)).catch(console.error); this.terminal.addElement(data.rowinEle); this.terminal.addElement(data.rowoutEle); this.terminal.scrollToBottom(); this.focusManager.outputted(); }
[ "function", "(", "ev", ")", "{", "if", "(", "ev", ".", "output", ".", "hidden", ")", "{", "return", ";", "}", "var", "template", "=", "this", ".", "commandDom", ".", "cloneNode", "(", "true", ")", ";", "var", "templateOptions", "=", "{", "stack", ":", "'terminal.html#outputView'", "}", ";", "var", "context", "=", "this", ".", "requisition", ".", "conversionContext", ";", "var", "data", "=", "{", "onclick", ":", "context", ".", "update", ",", "ondblclick", ":", "context", ".", "updateExec", ",", "language", ":", "this", ",", "output", ":", "ev", ".", "output", ",", "promptClass", ":", "(", "ev", ".", "output", ".", "error", "?", "'gcli-row-error'", ":", "''", ")", "+", "(", "ev", ".", "output", ".", "completed", "?", "' gcli-row-complete'", ":", "''", ")", ",", "// Elements attached to this by template().", "rowinEle", ":", "null", ",", "rowoutEle", ":", "null", ",", "throbEle", ":", "null", ",", "promptEle", ":", "null", "}", ";", "domtemplate", ".", "template", "(", "template", ",", "data", ",", "templateOptions", ")", ";", "ev", ".", "output", ".", "promise", ".", "then", "(", "function", "(", ")", "{", "var", "document", "=", "data", ".", "rowoutEle", ".", "ownerDocument", ";", "if", "(", "ev", ".", "output", ".", "completed", ")", "{", "data", ".", "promptEle", ".", "classList", ".", "add", "(", "'gcli-row-complete'", ")", ";", "}", "if", "(", "ev", ".", "output", ".", "error", ")", "{", "data", ".", "promptEle", ".", "classList", ".", "add", "(", "'gcli-row-error'", ")", ";", "}", "util", ".", "clearElement", "(", "data", ".", "rowoutEle", ")", ";", "return", "ev", ".", "output", ".", "convert", "(", "'dom'", ",", "context", ")", ".", "then", "(", "function", "(", "node", ")", "{", "this", ".", "terminal", ".", "scrollToBottom", "(", ")", ";", "data", ".", "throbEle", ".", "style", ".", "display", "=", "ev", ".", "output", ".", "completed", "?", "'none'", ":", "'block'", ";", "if", "(", "node", "==", "null", ")", "{", "data", ".", "promptEle", ".", "classList", ".", "add", "(", "'gcli-row-error'", ")", ";", "// TODO: show some error to the user", "}", "this", ".", "_linksToNewTab", "(", "node", ")", ";", "data", ".", "rowoutEle", ".", "appendChild", "(", "node", ")", ";", "var", "event", "=", "document", ".", "createEvent", "(", "'Event'", ")", ";", "event", ".", "initEvent", "(", "'load'", ",", "true", ",", "true", ")", ";", "event", ".", "addedElement", "=", "node", ";", "node", ".", "dispatchEvent", "(", "event", ")", ";", "}", ".", "bind", "(", "this", ")", ")", ";", "}", ".", "bind", "(", "this", ")", ")", ".", "catch", "(", "console", ".", "error", ")", ";", "this", ".", "terminal", ".", "addElement", "(", "data", ".", "rowinEle", ")", ";", "this", ".", "terminal", ".", "addElement", "(", "data", ".", "rowoutEle", ")", ";", "this", ".", "terminal", ".", "scrollToBottom", "(", ")", ";", "this", ".", "focusManager", ".", "outputted", "(", ")", ";", "}" ]
Monitor for new command executions
[ "Monitor", "for", "new", "command", "executions" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/languages/command.js#L451-L512
22,406
joewalker/gcli
lib/gcli/languages/command.js
function(element) { var links = element.querySelectorAll('*[href]'); for (var i = 0; i < links.length; i++) { links[i].setAttribute('target', '_blank'); } return element; }
javascript
function(element) { var links = element.querySelectorAll('*[href]'); for (var i = 0; i < links.length; i++) { links[i].setAttribute('target', '_blank'); } return element; }
[ "function", "(", "element", ")", "{", "var", "links", "=", "element", ".", "querySelectorAll", "(", "'*[href]'", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "links", ".", "length", ";", "i", "++", ")", "{", "links", "[", "i", "]", ".", "setAttribute", "(", "'target'", ",", "'_blank'", ")", ";", "}", "return", "element", ";", "}" ]
Find elements with href attributes and add a target=_blank so opened links will open in a new window
[ "Find", "elements", "with", "href", "attributes", "and", "add", "a", "target", "=", "_blank", "so", "opened", "links", "will", "open", "in", "a", "new", "window" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/languages/command.js#L518-L524
22,407
joewalker/gcli
lib/gcli/util/domtemplate.js
cloneState
function cloneState(state) { return { options: state.options, stack: state.stack.slice(), nodes: state.nodes.slice() }; }
javascript
function cloneState(state) { return { options: state.options, stack: state.stack.slice(), nodes: state.nodes.slice() }; }
[ "function", "cloneState", "(", "state", ")", "{", "return", "{", "options", ":", "state", ".", "options", ",", "stack", ":", "state", ".", "stack", ".", "slice", "(", ")", ",", "nodes", ":", "state", ".", "nodes", ".", "slice", "(", ")", "}", ";", "}" ]
Helper for the places where we need to act asynchronously and keep track of where we are right now
[ "Helper", "for", "the", "places", "where", "we", "need", "to", "act", "asynchronously", "and", "keep", "track", "of", "where", "we", "are", "right", "now" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/util/domtemplate.js#L71-L77
22,408
joewalker/gcli
lib/gcli/util/domtemplate.js
processString
function processString(state, value, data) { return value.replace(TEMPLATE_REGION, function(path) { var insert = envEval(state, path.slice(2, -1), data, value); return state.options.blankNullUndefined && insert == null ? '' : insert; }); }
javascript
function processString(state, value, data) { return value.replace(TEMPLATE_REGION, function(path) { var insert = envEval(state, path.slice(2, -1), data, value); return state.options.blankNullUndefined && insert == null ? '' : insert; }); }
[ "function", "processString", "(", "state", ",", "value", ",", "data", ")", "{", "return", "value", ".", "replace", "(", "TEMPLATE_REGION", ",", "function", "(", "path", ")", "{", "var", "insert", "=", "envEval", "(", "state", ",", "path", ".", "slice", "(", "2", ",", "-", "1", ")", ",", "data", ",", "value", ")", ";", "return", "state", ".", "options", ".", "blankNullUndefined", "&&", "insert", "==", "null", "?", "''", ":", "insert", ";", "}", ")", ";", "}" ]
Handle attribute values where the output can only be a string
[ "Handle", "attribute", "values", "where", "the", "output", "can", "only", "be", "a", "string" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/util/domtemplate.js#L221-L226
22,409
joewalker/gcli
lib/gcli/util/domtemplate.js
maybeImportNode
function maybeImportNode(state, node, doc) { return node.ownerDocument === doc ? node : doc.importNode(node, true); }
javascript
function maybeImportNode(state, node, doc) { return node.ownerDocument === doc ? node : doc.importNode(node, true); }
[ "function", "maybeImportNode", "(", "state", ",", "node", ",", "doc", ")", "{", "return", "node", ".", "ownerDocument", "===", "doc", "?", "node", ":", "doc", ".", "importNode", "(", "node", ",", "true", ")", ";", "}" ]
Return node or a import of node, if it's not in the given document @param node The node that we want to be properly owned @param doc The document that the given node should belong to @return A node that belongs to the given document
[ "Return", "node", "or", "a", "import", "of", "node", "if", "it", "s", "not", "in", "the", "given", "document" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/util/domtemplate.js#L446-L448
22,410
joewalker/gcli
lib/gcli/util/domtemplate.js
handleError
function handleError(state, message, ex) { logError(message + ' (In: ' + state.stack.join(' > ') + ')'); if (ex) { logError(ex); } }
javascript
function handleError(state, message, ex) { logError(message + ' (In: ' + state.stack.join(' > ') + ')'); if (ex) { logError(ex); } }
[ "function", "handleError", "(", "state", ",", "message", ",", "ex", ")", "{", "logError", "(", "message", "+", "' (In: '", "+", "state", ".", "stack", ".", "join", "(", "' > '", ")", "+", "')'", ")", ";", "if", "(", "ex", ")", "{", "logError", "(", "ex", ")", ";", "}", "}" ]
A generic way of reporting errors, for easy overloading in different environments. @param message the error message to report. @param ex optional associated exception.
[ "A", "generic", "way", "of", "reporting", "errors", "for", "easy", "overloading", "in", "different", "environments", "." ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/util/domtemplate.js#L604-L609
22,411
joewalker/gcli
lib/gcli/settings.js
Settings
function Settings(types, settingValues) { this._types = types; // Where we store the settings that we've created this._settings = {}; // Where the values for the settings are stored while in use. this._settingValues = settingValues || {}; // Where the values for the settings are persisted for next use. this._settingStorage = new LocalSettingStorage(); this._settingStorage.load(this._settingValues); // Event for use to detect when the list of settings changes this.onChange = util.createEvent('Settings.onChange'); }
javascript
function Settings(types, settingValues) { this._types = types; // Where we store the settings that we've created this._settings = {}; // Where the values for the settings are stored while in use. this._settingValues = settingValues || {}; // Where the values for the settings are persisted for next use. this._settingStorage = new LocalSettingStorage(); this._settingStorage.load(this._settingValues); // Event for use to detect when the list of settings changes this.onChange = util.createEvent('Settings.onChange'); }
[ "function", "Settings", "(", "types", ",", "settingValues", ")", "{", "this", ".", "_types", "=", "types", ";", "// Where we store the settings that we've created", "this", ".", "_settings", "=", "{", "}", ";", "// Where the values for the settings are stored while in use.", "this", ".", "_settingValues", "=", "settingValues", "||", "{", "}", ";", "// Where the values for the settings are persisted for next use.", "this", ".", "_settingStorage", "=", "new", "LocalSettingStorage", "(", ")", ";", "this", ".", "_settingStorage", ".", "load", "(", "this", ".", "_settingValues", ")", ";", "// Event for use to detect when the list of settings changes", "this", ".", "onChange", "=", "util", ".", "createEvent", "(", "'Settings.onChange'", ")", ";", "}" ]
A manager for the registered Settings
[ "A", "manager", "for", "the", "registered", "Settings" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/settings.js#L24-L39
22,412
joewalker/gcli
lib/gcli/settings.js
Setting
function Setting(settings, name, type, description, defaultValue) { this._settings = settings; this.name = name; this.type = type; this.description = description; this._defaultValue = defaultValue; this.onChange = util.createEvent('Setting.onChange'); this.setDefault(); }
javascript
function Setting(settings, name, type, description, defaultValue) { this._settings = settings; this.name = name; this.type = type; this.description = description; this._defaultValue = defaultValue; this.onChange = util.createEvent('Setting.onChange'); this.setDefault(); }
[ "function", "Setting", "(", "settings", ",", "name", ",", "type", ",", "description", ",", "defaultValue", ")", "{", "this", ".", "_settings", "=", "settings", ";", "this", ".", "name", "=", "name", ";", "this", ".", "type", "=", "type", ";", "this", ".", "description", "=", "description", ";", "this", ".", "_defaultValue", "=", "defaultValue", ";", "this", ".", "onChange", "=", "util", ".", "createEvent", "(", "'Setting.onChange'", ")", ";", "this", ".", "setDefault", "(", ")", ";", "}" ]
A class to wrap up the properties of a Setting. @see toolkit/components/viewconfig/content/config.js
[ "A", "class", "to", "wrap", "up", "the", "properties", "of", "a", "Setting", "." ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/settings.js#L139-L148
22,413
joewalker/gcli
lib/gcli/types/node.js
onEnter
function onEnter(assignment) { // TODO: GCLI doesn't support passing a context to notifications of cursor // position, so onEnter/onLeave/onChange are disabled below until we fix this assignment.highlighter = new Highlighter(context.environment.window.document); assignment.highlighter.nodelist = assignment.conversion.matches; }
javascript
function onEnter(assignment) { // TODO: GCLI doesn't support passing a context to notifications of cursor // position, so onEnter/onLeave/onChange are disabled below until we fix this assignment.highlighter = new Highlighter(context.environment.window.document); assignment.highlighter.nodelist = assignment.conversion.matches; }
[ "function", "onEnter", "(", "assignment", ")", "{", "// TODO: GCLI doesn't support passing a context to notifications of cursor", "// position, so onEnter/onLeave/onChange are disabled below until we fix this", "assignment", ".", "highlighter", "=", "new", "Highlighter", "(", "context", ".", "environment", ".", "window", ".", "document", ")", ";", "assignment", ".", "highlighter", ".", "nodelist", "=", "assignment", ".", "conversion", ".", "matches", ";", "}" ]
Helper functions to be attached to the prototypes of NodeType and NodeListType to allow terminal to tell us which nodes should be highlighted
[ "Helper", "functions", "to", "be", "attached", "to", "the", "prototypes", "of", "NodeType", "and", "NodeListType", "to", "allow", "terminal", "to", "tell", "us", "which", "nodes", "should", "be", "highlighted" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/types/node.js#L30-L35
22,414
joewalker/gcli
lib/gcli/system.js
removeItemsFromFront
function removeItemsFromFront(system, front) { system.commands.getAll().forEach(function(command) { if (command.front === front) { system.commands.remove(command); } }); }
javascript
function removeItemsFromFront(system, front) { system.commands.getAll().forEach(function(command) { if (command.front === front) { system.commands.remove(command); } }); }
[ "function", "removeItemsFromFront", "(", "system", ",", "front", ")", "{", "system", ".", "commands", ".", "getAll", "(", ")", ".", "forEach", "(", "function", "(", "command", ")", "{", "if", "(", "command", ".", "front", "===", "front", ")", "{", "system", ".", "commands", ".", "remove", "(", "command", ")", ";", "}", "}", ")", ";", "}" ]
Go through all the commands removing any that are associated with the given front. The method of association is the hack in addLocalFunctions.
[ "Go", "through", "all", "the", "commands", "removing", "any", "that", "are", "associated", "with", "the", "given", "front", ".", "The", "method", "of", "association", "is", "the", "hack", "in", "addLocalFunctions", "." ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/system.js#L364-L370
22,415
joewalker/gcli
lib/gcli/converters/converters.js
getChainConverter
function getChainConverter(first, second) { if (first.to !== second.from) { throw new Error('Chain convert impossible: ' + first.to + '!=' + second.from); } return { from: first.from, to: second.to, exec: function(data, conversionContext) { var intermediate = first.exec(data, conversionContext); return second.exec(intermediate, conversionContext); } }; }
javascript
function getChainConverter(first, second) { if (first.to !== second.from) { throw new Error('Chain convert impossible: ' + first.to + '!=' + second.from); } return { from: first.from, to: second.to, exec: function(data, conversionContext) { var intermediate = first.exec(data, conversionContext); return second.exec(intermediate, conversionContext); } }; }
[ "function", "getChainConverter", "(", "first", ",", "second", ")", "{", "if", "(", "first", ".", "to", "!==", "second", ".", "from", ")", "{", "throw", "new", "Error", "(", "'Chain convert impossible: '", "+", "first", ".", "to", "+", "'!='", "+", "second", ".", "from", ")", ";", "}", "return", "{", "from", ":", "first", ".", "from", ",", "to", ":", "second", ".", "to", ",", "exec", ":", "function", "(", "data", ",", "conversionContext", ")", "{", "var", "intermediate", "=", "first", ".", "exec", "(", "data", ",", "conversionContext", ")", ";", "return", "second", ".", "exec", "(", "intermediate", ",", "conversionContext", ")", ";", "}", "}", ";", "}" ]
Create a new converter by using 2 converters, one after the other
[ "Create", "a", "new", "converter", "by", "using", "2", "converters", "one", "after", "the", "other" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/converters/converters.js#L130-L142
22,416
joewalker/gcli
lib/gcli/util/util.js
function(ev) { if (fireHoldCount > 0) { heldEvents.push(ev); if (eventDebug) { console.log('Held fire: ' + name, ev); } return; } if (eventDebug) { console.group('Fire: ' + name + ' to ' + handlers.length + ' listeners', ev); } // Use for rather than forEach because it step debugs better, which is // important for debugging events for (var i = 0; i < handlers.length; i++) { var handler = handlers[i]; if (eventDebug) { console.log(nameFunction(handler)); } handler.func.call(handler.scope, ev); } if (eventDebug) { console.groupEnd(); } }
javascript
function(ev) { if (fireHoldCount > 0) { heldEvents.push(ev); if (eventDebug) { console.log('Held fire: ' + name, ev); } return; } if (eventDebug) { console.group('Fire: ' + name + ' to ' + handlers.length + ' listeners', ev); } // Use for rather than forEach because it step debugs better, which is // important for debugging events for (var i = 0; i < handlers.length; i++) { var handler = handlers[i]; if (eventDebug) { console.log(nameFunction(handler)); } handler.func.call(handler.scope, ev); } if (eventDebug) { console.groupEnd(); } }
[ "function", "(", "ev", ")", "{", "if", "(", "fireHoldCount", ">", "0", ")", "{", "heldEvents", ".", "push", "(", "ev", ")", ";", "if", "(", "eventDebug", ")", "{", "console", ".", "log", "(", "'Held fire: '", "+", "name", ",", "ev", ")", ";", "}", "return", ";", "}", "if", "(", "eventDebug", ")", "{", "console", ".", "group", "(", "'Fire: '", "+", "name", "+", "' to '", "+", "handlers", ".", "length", "+", "' listeners'", ",", "ev", ")", ";", "}", "// Use for rather than forEach because it step debugs better, which is", "// important for debugging events", "for", "(", "var", "i", "=", "0", ";", "i", "<", "handlers", ".", "length", ";", "i", "++", ")", "{", "var", "handler", "=", "handlers", "[", "i", "]", ";", "if", "(", "eventDebug", ")", "{", "console", ".", "log", "(", "nameFunction", "(", "handler", ")", ")", ";", "}", "handler", ".", "func", ".", "call", "(", "handler", ".", "scope", ",", "ev", ")", ";", "}", "if", "(", "eventDebug", ")", "{", "console", ".", "groupEnd", "(", ")", ";", "}", "}" ]
This is how the event is triggered. @param ev The event object to be passed to the event listeners
[ "This", "is", "how", "the", "event", "is", "triggered", "." ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/util/util.js#L86-L112
22,417
joewalker/gcli
lib/gcli/types/date.js
toDate
function toDate(str) { var millis = Date.parse(str); if (isNaN(millis)) { throw new Error(l10n.lookupFormat('typesDateNan', [ str ])); } return new Date(millis); }
javascript
function toDate(str) { var millis = Date.parse(str); if (isNaN(millis)) { throw new Error(l10n.lookupFormat('typesDateNan', [ str ])); } return new Date(millis); }
[ "function", "toDate", "(", "str", ")", "{", "var", "millis", "=", "Date", ".", "parse", "(", "str", ")", ";", "if", "(", "isNaN", "(", "millis", ")", ")", "{", "throw", "new", "Error", "(", "l10n", ".", "lookupFormat", "(", "'typesDateNan'", ",", "[", "str", "]", ")", ")", ";", "}", "return", "new", "Date", "(", "millis", ")", ";", "}" ]
Utility to convert a string to a date, throwing if the date can't be parsed rather than having an invalid date
[ "Utility", "to", "convert", "a", "string", "to", "a", "date", "throwing", "if", "the", "date", "can", "t", "be", "parsed", "rather", "than", "having", "an", "invalid", "date" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/types/date.js#L36-L42
22,418
joewalker/gcli
lib/gcli/types/date.js
isDate
function isDate(thing) { return Object.prototype.toString.call(thing) === '[object Date]' && !isNaN(thing.getTime()); }
javascript
function isDate(thing) { return Object.prototype.toString.call(thing) === '[object Date]' && !isNaN(thing.getTime()); }
[ "function", "isDate", "(", "thing", ")", "{", "return", "Object", ".", "prototype", ".", "toString", ".", "call", "(", "thing", ")", "===", "'[object Date]'", "&&", "!", "isNaN", "(", "thing", ".", "getTime", "(", ")", ")", ";", "}" ]
Is |thing| a valid date? @see http://stackoverflow.com/questions/1353684/detecting-an-invalid-date-date-instance-in-javascript
[ "Is", "|thing|", "a", "valid", "date?" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/types/date.js#L48-L51
22,419
joewalker/gcli
lib/gcli/connectors/websocketserver.js
function(err) { console.log('SOCKET ' + command + '(' + debugStr(request.data, 30) + ') Exception'); util.errorHandler(err); socket.emit('reply', { id: request.id, exception: '' + err }); }
javascript
function(err) { console.log('SOCKET ' + command + '(' + debugStr(request.data, 30) + ') Exception'); util.errorHandler(err); socket.emit('reply', { id: request.id, exception: '' + err }); }
[ "function", "(", "err", ")", "{", "console", ".", "log", "(", "'SOCKET '", "+", "command", "+", "'('", "+", "debugStr", "(", "request", ".", "data", ",", "30", ")", "+", "') Exception'", ")", ";", "util", ".", "errorHandler", "(", "err", ")", ";", "socket", ".", "emit", "(", "'reply'", ",", "{", "id", ":", "request", ".", "id", ",", "exception", ":", "''", "+", "err", "}", ")", ";", "}" ]
Handle errors from exceptions an promise rejections
[ "Handle", "errors", "from", "exceptions", "an", "promise", "rejections" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/connectors/websocketserver.js#L42-L51
22,420
joewalker/gcli
lib/gcli/connectors/websocketserver.js
debugStr
function debugStr(obj) { var summary = JSON.stringify(obj) || ''; return summary.length > 40 ? summary.substr(0, 39) + '…' : summary; }
javascript
function debugStr(obj) { var summary = JSON.stringify(obj) || ''; return summary.length > 40 ? summary.substr(0, 39) + '…' : summary; }
[ "function", "debugStr", "(", "obj", ")", "{", "var", "summary", "=", "JSON", ".", "stringify", "(", "obj", ")", "||", "''", ";", "return", "summary", ".", "length", ">", "40", "?", "summary", ".", "substr", "(", "0", ",", "39", ")", "+", "'…' :", "s", "mmary;", "", "}" ]
Get a quick one line debug summary of an object
[ "Get", "a", "quick", "one", "line", "debug", "summary", "of", "an", "object" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/connectors/websocketserver.js#L78-L81
22,421
joewalker/gcli
lib/gcli/commands/commands.js
Commands
function Commands(types, location) { this.types = types; this.location = location; // A lookup hash of our registered commands this._commands = {}; // A sorted list of command names, we regularly want them in order, so pre-sort this._commandNames = []; // A lookup of the original commandSpecs by command name this._commandSpecs = {}; // Enable people to be notified of changes to the list of commands this.onCommandsChange = util.createEvent('commands.onCommandsChange'); }
javascript
function Commands(types, location) { this.types = types; this.location = location; // A lookup hash of our registered commands this._commands = {}; // A sorted list of command names, we regularly want them in order, so pre-sort this._commandNames = []; // A lookup of the original commandSpecs by command name this._commandSpecs = {}; // Enable people to be notified of changes to the list of commands this.onCommandsChange = util.createEvent('commands.onCommandsChange'); }
[ "function", "Commands", "(", "types", ",", "location", ")", "{", "this", ".", "types", "=", "types", ";", "this", ".", "location", "=", "location", ";", "// A lookup hash of our registered commands", "this", ".", "_commands", "=", "{", "}", ";", "// A sorted list of command names, we regularly want them in order, so pre-sort", "this", ".", "_commandNames", "=", "[", "]", ";", "// A lookup of the original commandSpecs by command name", "this", ".", "_commandSpecs", "=", "{", "}", ";", "// Enable people to be notified of changes to the list of commands", "this", ".", "onCommandsChange", "=", "util", ".", "createEvent", "(", "'commands.onCommandsChange'", ")", ";", "}" ]
A store for a list of commands @param types Each command uses a set of Types to parse its parameters so the Commands container needs access to the list of available types. @param location String that, if set will force all commands to have a matching runAt property to be accepted
[ "A", "store", "for", "a", "list", "of", "commands" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/commands/commands.js#L372-L385
22,422
joewalker/gcli
lib/gcli/commands/server/server.js
stringify
function stringify(data, action) { try { return JSON.stringify(data); } catch (ex) { console.error('Performing "' + action + '". Failed to stringify', data); util.errorHandler(ex); data = { code: -1, data: ex.toString() }; return JSON.stringify(data); } }
javascript
function stringify(data, action) { try { return JSON.stringify(data); } catch (ex) { console.error('Performing "' + action + '". Failed to stringify', data); util.errorHandler(ex); data = { code: -1, data: ex.toString() }; return JSON.stringify(data); } }
[ "function", "stringify", "(", "data", ",", "action", ")", "{", "try", "{", "return", "JSON", ".", "stringify", "(", "data", ")", ";", "}", "catch", "(", "ex", ")", "{", "console", ".", "error", "(", "'Performing \"'", "+", "action", "+", "'\". Failed to stringify'", ",", "data", ")", ";", "util", ".", "errorHandler", "(", "ex", ")", ";", "data", "=", "{", "code", ":", "-", "1", ",", "data", ":", "ex", ".", "toString", "(", ")", "}", ";", "return", "JSON", ".", "stringify", "(", "data", ")", ";", "}", "}" ]
A wrapper around JSON.stringify to fail gracefully
[ "A", "wrapper", "around", "JSON", ".", "stringify", "to", "fail", "gracefully" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/commands/server/server.js#L201-L215
22,423
joewalker/gcli
lib/gcli/connectors/websocket.js
WebsocketConnection
function WebsocketConnection(socket, url) { this.socket = socket; this.url = url; this.deferreds = {}; this.nextRequestId = 0; this.onReply = this.onReply.bind(this); this.onEvent = this.onEvent.bind(this); }
javascript
function WebsocketConnection(socket, url) { this.socket = socket; this.url = url; this.deferreds = {}; this.nextRequestId = 0; this.onReply = this.onReply.bind(this); this.onEvent = this.onEvent.bind(this); }
[ "function", "WebsocketConnection", "(", "socket", ",", "url", ")", "{", "this", ".", "socket", "=", "socket", ";", "this", ".", "url", "=", "url", ";", "this", ".", "deferreds", "=", "{", "}", ";", "this", ".", "nextRequestId", "=", "0", ";", "this", ".", "onReply", "=", "this", ".", "onReply", ".", "bind", "(", "this", ")", ";", "this", ".", "onEvent", "=", "this", ".", "onEvent", ".", "bind", "(", "this", ")", ";", "}" ]
Handle a 'session' in which we make a number of calls
[ "Handle", "a", "session", "in", "which", "we", "make", "a", "number", "of", "calls" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/connectors/websocket.js#L71-L80
22,424
joewalker/gcli
lib/gcli/commands/help.js
addParamGroups
function addParamGroups(command) { Object.defineProperty(command, 'paramGroups', { get: function() { var paramGroups = {}; this.params.forEach(function(param) { var groupName = param.option || l10n.lookup('canonDefaultGroupName'); if (paramGroups[groupName] == null) { paramGroups[groupName] = []; } paramGroups[groupName].push(param); }); return paramGroups; }, enumerable: true }); }
javascript
function addParamGroups(command) { Object.defineProperty(command, 'paramGroups', { get: function() { var paramGroups = {}; this.params.forEach(function(param) { var groupName = param.option || l10n.lookup('canonDefaultGroupName'); if (paramGroups[groupName] == null) { paramGroups[groupName] = []; } paramGroups[groupName].push(param); }); return paramGroups; }, enumerable: true }); }
[ "function", "addParamGroups", "(", "command", ")", "{", "Object", ".", "defineProperty", "(", "command", ",", "'paramGroups'", ",", "{", "get", ":", "function", "(", ")", "{", "var", "paramGroups", "=", "{", "}", ";", "this", ".", "params", ".", "forEach", "(", "function", "(", "param", ")", "{", "var", "groupName", "=", "param", ".", "option", "||", "l10n", ".", "lookup", "(", "'canonDefaultGroupName'", ")", ";", "if", "(", "paramGroups", "[", "groupName", "]", "==", "null", ")", "{", "paramGroups", "[", "groupName", "]", "=", "[", "]", ";", "}", "paramGroups", "[", "groupName", "]", ".", "push", "(", "param", ")", ";", "}", ")", ";", "return", "paramGroups", ";", "}", ",", "enumerable", ":", "true", "}", ")", ";", "}" ]
Add an 'paramGroups' accessor to a command metadata object to sort the params into groups according to the option of the param.
[ "Add", "an", "paramGroups", "accessor", "to", "a", "command", "metadata", "object", "to", "sort", "the", "params", "into", "groups", "according", "to", "the", "option", "of", "the", "param", "." ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/commands/help.js#L26-L41
22,425
joewalker/gcli
lib/gcli/commands/help.js
getSubCommands
function getSubCommands(context, command) { var commands = cli.getMapping(context).requisition.system.commands; var subcommands = commands.getAll().filter(function(subcommand) { return subcommand.name.indexOf(command.name) === 0 && subcommand.name !== command.name && !subcommand.hidden; }); subcommands.sort(function(c1, c2) { return c1.name.localeCompare(c2.name); }); subcommands = subcommands.map(function(subcommand) { return subcommand.toJson(); }); return subcommands; }
javascript
function getSubCommands(context, command) { var commands = cli.getMapping(context).requisition.system.commands; var subcommands = commands.getAll().filter(function(subcommand) { return subcommand.name.indexOf(command.name) === 0 && subcommand.name !== command.name && !subcommand.hidden; }); subcommands.sort(function(c1, c2) { return c1.name.localeCompare(c2.name); }); subcommands = subcommands.map(function(subcommand) { return subcommand.toJson(); }); return subcommands; }
[ "function", "getSubCommands", "(", "context", ",", "command", ")", "{", "var", "commands", "=", "cli", ".", "getMapping", "(", "context", ")", ".", "requisition", ".", "system", ".", "commands", ";", "var", "subcommands", "=", "commands", ".", "getAll", "(", ")", ".", "filter", "(", "function", "(", "subcommand", ")", "{", "return", "subcommand", ".", "name", ".", "indexOf", "(", "command", ".", "name", ")", "===", "0", "&&", "subcommand", ".", "name", "!==", "command", ".", "name", "&&", "!", "subcommand", ".", "hidden", ";", "}", ")", ";", "subcommands", ".", "sort", "(", "function", "(", "c1", ",", "c2", ")", "{", "return", "c1", ".", "name", ".", "localeCompare", "(", "c2", ".", "name", ")", ";", "}", ")", ";", "subcommands", "=", "subcommands", ".", "map", "(", "function", "(", "subcommand", ")", "{", "return", "subcommand", ".", "toJson", "(", ")", ";", "}", ")", ";", "return", "subcommands", ";", "}" ]
Find all the sub commands of the given command
[ "Find", "all", "the", "sub", "commands", "of", "the", "given", "command" ]
672ddac06402c82c44b4e45fe9336347b9c810bb
https://github.com/joewalker/gcli/blob/672ddac06402c82c44b4e45fe9336347b9c810bb/lib/gcli/commands/help.js#L165-L182
22,426
prescottprue/cypress-firebase
src/extendWithFirebaseConfig.js
loadFirebaseRc
function loadFirebaseRc() { const rcFilePath = `${process.cwd()}/.firebaserc`; if (!fs.existsSync(rcFilePath)) { throw new Error('.firebaserc file not found'); } try { const fileStr = fs.readFileSync(rcFilePath); return JSON.parse(fileStr); } catch (err) { console.log('Error loading .firebaserc: ', err); // eslint-disable-line no-console throw err; } }
javascript
function loadFirebaseRc() { const rcFilePath = `${process.cwd()}/.firebaserc`; if (!fs.existsSync(rcFilePath)) { throw new Error('.firebaserc file not found'); } try { const fileStr = fs.readFileSync(rcFilePath); return JSON.parse(fileStr); } catch (err) { console.log('Error loading .firebaserc: ', err); // eslint-disable-line no-console throw err; } }
[ "function", "loadFirebaseRc", "(", ")", "{", "const", "rcFilePath", "=", "`", "${", "process", ".", "cwd", "(", ")", "}", "`", ";", "if", "(", "!", "fs", ".", "existsSync", "(", "rcFilePath", ")", ")", "{", "throw", "new", "Error", "(", "'.firebaserc file not found'", ")", ";", "}", "try", "{", "const", "fileStr", "=", "fs", ".", "readFileSync", "(", "rcFilePath", ")", ";", "return", "JSON", ".", "parse", "(", "fileStr", ")", ";", "}", "catch", "(", "err", ")", "{", "console", ".", "log", "(", "'Error loading .firebaserc: '", ",", "err", ")", ";", "// eslint-disable-line no-console", "throw", "err", ";", "}", "}" ]
Load .firebaserc file
[ "Load", ".", "firebaserc", "file" ]
8735eb651f7ae154f73aaa10efb4ee6317a9c2af
https://github.com/prescottprue/cypress-firebase/blob/8735eb651f7ae154f73aaa10efb4ee6317a9c2af/src/extendWithFirebaseConfig.js#L7-L19
22,427
prescottprue/cypress-firebase
src/extendWithFirebaseConfig.js
getEnvNameFromConfig
function getEnvNameFromConfig(cypressConfig) { if (!cypressConfig.env || !cypressConfig.env.envName) { return 'local'; } return cypressConfig.env.envName; }
javascript
function getEnvNameFromConfig(cypressConfig) { if (!cypressConfig.env || !cypressConfig.env.envName) { return 'local'; } return cypressConfig.env.envName; }
[ "function", "getEnvNameFromConfig", "(", "cypressConfig", ")", "{", "if", "(", "!", "cypressConfig", ".", "env", "||", "!", "cypressConfig", ".", "env", ".", "envName", ")", "{", "return", "'local'", ";", "}", "return", "cypressConfig", ".", "env", ".", "envName", ";", "}" ]
Get environment name from cypress config or default to "local" @param {Object} cypressConfig - Cypress config object
[ "Get", "environment", "name", "from", "cypress", "config", "or", "default", "to", "local" ]
8735eb651f7ae154f73aaa10efb4ee6317a9c2af
https://github.com/prescottprue/cypress-firebase/blob/8735eb651f7ae154f73aaa10efb4ee6317a9c2af/src/extendWithFirebaseConfig.js#L25-L30
22,428
prescottprue/cypress-firebase
src/utils.js
getParsedEnvVar
function getParsedEnvVar(varNameRoot) { const val = envVarBasedOnCIEnv(varNameRoot); const prefix = getEnvPrefix(); const combinedVar = `${prefix}${varNameRoot}`; if (!val) { error( `${chalk.cyan( combinedVar, )} not found, make sure it is set within environment variables.`, ); } try { if (isString(val)) { return JSON.parse(val); } return val; } catch (err) { error(`Error parsing ${combinedVar}`); return val; } }
javascript
function getParsedEnvVar(varNameRoot) { const val = envVarBasedOnCIEnv(varNameRoot); const prefix = getEnvPrefix(); const combinedVar = `${prefix}${varNameRoot}`; if (!val) { error( `${chalk.cyan( combinedVar, )} not found, make sure it is set within environment variables.`, ); } try { if (isString(val)) { return JSON.parse(val); } return val; } catch (err) { error(`Error parsing ${combinedVar}`); return val; } }
[ "function", "getParsedEnvVar", "(", "varNameRoot", ")", "{", "const", "val", "=", "envVarBasedOnCIEnv", "(", "varNameRoot", ")", ";", "const", "prefix", "=", "getEnvPrefix", "(", ")", ";", "const", "combinedVar", "=", "`", "${", "prefix", "}", "${", "varNameRoot", "}", "`", ";", "if", "(", "!", "val", ")", "{", "error", "(", "`", "${", "chalk", ".", "cyan", "(", "combinedVar", ",", ")", "}", "`", ",", ")", ";", "}", "try", "{", "if", "(", "isString", "(", "val", ")", ")", "{", "return", "JSON", ".", "parse", "(", "val", ")", ";", "}", "return", "val", ";", "}", "catch", "(", "err", ")", "{", "error", "(", "`", "${", "combinedVar", "}", "`", ")", ";", "return", "val", ";", "}", "}" ]
Get parsed value of environment variable. Useful for environment variables which have characters that need to be escaped. @param {String} varNameRoot - variable name without the environment prefix @return {Any} Value of the environment variable @example getParsedEnvVar('FIREBASE_PRIVATE_KEY_ID') // => 'fireadmin-stage' (parsed value of 'STAGE_FIREBASE_PRIVATE_KEY_ID' environment var)
[ "Get", "parsed", "value", "of", "environment", "variable", ".", "Useful", "for", "environment", "variables", "which", "have", "characters", "that", "need", "to", "be", "escaped", "." ]
8735eb651f7ae154f73aaa10efb4ee6317a9c2af
https://github.com/prescottprue/cypress-firebase/blob/8735eb651f7ae154f73aaa10efb4ee6317a9c2af/src/utils.js#L115-L135
22,429
albertorestifo/node-dijkstra
libs/validateDeep.js
validateDeep
function validateDeep(map) { if (!(map instanceof Map)) { throw new Error(`Invalid graph: Expected Map instead found ${typeof map}`); } map.forEach((value, key) => { if (typeof value === 'object' && value instanceof Map) { validateDeep(value); return; } if (typeof value !== 'number' || value <= 0) { throw new Error(`Values must be numbers greater than 0. Found value ${value} at ${key}`); } }); }
javascript
function validateDeep(map) { if (!(map instanceof Map)) { throw new Error(`Invalid graph: Expected Map instead found ${typeof map}`); } map.forEach((value, key) => { if (typeof value === 'object' && value instanceof Map) { validateDeep(value); return; } if (typeof value !== 'number' || value <= 0) { throw new Error(`Values must be numbers greater than 0. Found value ${value} at ${key}`); } }); }
[ "function", "validateDeep", "(", "map", ")", "{", "if", "(", "!", "(", "map", "instanceof", "Map", ")", ")", "{", "throw", "new", "Error", "(", "`", "${", "typeof", "map", "}", "`", ")", ";", "}", "map", ".", "forEach", "(", "(", "value", ",", "key", ")", "=>", "{", "if", "(", "typeof", "value", "===", "'object'", "&&", "value", "instanceof", "Map", ")", "{", "validateDeep", "(", "value", ")", ";", "return", ";", "}", "if", "(", "typeof", "value", "!==", "'number'", "||", "value", "<=", "0", ")", "{", "throw", "new", "Error", "(", "`", "${", "value", "}", "${", "key", "}", "`", ")", ";", "}", "}", ")", ";", "}" ]
Validate a map to ensure all it's values are either a number or a map @param {Map} map - Map to valiadte
[ "Validate", "a", "map", "to", "ensure", "all", "it", "s", "values", "are", "either", "a", "number", "or", "a", "map" ]
2de3f878f2e816b21bc063e38231d857d7f1afd1
https://github.com/albertorestifo/node-dijkstra/blob/2de3f878f2e816b21bc063e38231d857d7f1afd1/libs/validateDeep.js#L6-L21
22,430
albertorestifo/node-dijkstra
libs/toDeepMap.js
isValidNode
function isValidNode(val) { const cost = Number(val); if (isNaN(cost) || cost <= 0) { return false; } return true; }
javascript
function isValidNode(val) { const cost = Number(val); if (isNaN(cost) || cost <= 0) { return false; } return true; }
[ "function", "isValidNode", "(", "val", ")", "{", "const", "cost", "=", "Number", "(", "val", ")", ";", "if", "(", "isNaN", "(", "cost", ")", "||", "cost", "<=", "0", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validates a cost for a node @private @param {number} val - Cost to validate @return {bool}
[ "Validates", "a", "cost", "for", "a", "node" ]
2de3f878f2e816b21bc063e38231d857d7f1afd1
https://github.com/albertorestifo/node-dijkstra/blob/2de3f878f2e816b21bc063e38231d857d7f1afd1/libs/toDeepMap.js#L8-L16
22,431
albertorestifo/node-dijkstra
libs/toDeepMap.js
toDeepMap
function toDeepMap(source) { const map = new Map(); const keys = Object.keys(source); keys.forEach((key) => { const val = source[key]; if (val !== null && typeof val === 'object' && !Array.isArray(val)) { return map.set(key, toDeepMap(val)); } if (!isValidNode(val)) { throw new Error(`Could not add node at key "${key}", make sure it's a valid node`, val); } return map.set(key, Number(val)); }); return map; }
javascript
function toDeepMap(source) { const map = new Map(); const keys = Object.keys(source); keys.forEach((key) => { const val = source[key]; if (val !== null && typeof val === 'object' && !Array.isArray(val)) { return map.set(key, toDeepMap(val)); } if (!isValidNode(val)) { throw new Error(`Could not add node at key "${key}", make sure it's a valid node`, val); } return map.set(key, Number(val)); }); return map; }
[ "function", "toDeepMap", "(", "source", ")", "{", "const", "map", "=", "new", "Map", "(", ")", ";", "const", "keys", "=", "Object", ".", "keys", "(", "source", ")", ";", "keys", ".", "forEach", "(", "(", "key", ")", "=>", "{", "const", "val", "=", "source", "[", "key", "]", ";", "if", "(", "val", "!==", "null", "&&", "typeof", "val", "===", "'object'", "&&", "!", "Array", ".", "isArray", "(", "val", ")", ")", "{", "return", "map", ".", "set", "(", "key", ",", "toDeepMap", "(", "val", ")", ")", ";", "}", "if", "(", "!", "isValidNode", "(", "val", ")", ")", "{", "throw", "new", "Error", "(", "`", "${", "key", "}", "`", ",", "val", ")", ";", "}", "return", "map", ".", "set", "(", "key", ",", "Number", "(", "val", ")", ")", ";", "}", ")", ";", "return", "map", ";", "}" ]
Creates a deep `Map` from the passed object. @param {Object} source - Object to populate the map with @return {Map} New map with the passed object data
[ "Creates", "a", "deep", "Map", "from", "the", "passed", "object", "." ]
2de3f878f2e816b21bc063e38231d857d7f1afd1
https://github.com/albertorestifo/node-dijkstra/blob/2de3f878f2e816b21bc063e38231d857d7f1afd1/libs/toDeepMap.js#L24-L43
22,432
albertorestifo/node-dijkstra
libs/removeDeepFromMap.js
removeDeepFromMap
function removeDeepFromMap(map, key) { const newMap = new Map(); for (const [aKey, val] of map) { if (aKey !== key && val instanceof Map) { newMap.set(aKey, removeDeepFromMap(val, key)); } else if (aKey !== key) { newMap.set(aKey, val); } } return newMap; }
javascript
function removeDeepFromMap(map, key) { const newMap = new Map(); for (const [aKey, val] of map) { if (aKey !== key && val instanceof Map) { newMap.set(aKey, removeDeepFromMap(val, key)); } else if (aKey !== key) { newMap.set(aKey, val); } } return newMap; }
[ "function", "removeDeepFromMap", "(", "map", ",", "key", ")", "{", "const", "newMap", "=", "new", "Map", "(", ")", ";", "for", "(", "const", "[", "aKey", ",", "val", "]", "of", "map", ")", "{", "if", "(", "aKey", "!==", "key", "&&", "val", "instanceof", "Map", ")", "{", "newMap", ".", "set", "(", "aKey", ",", "removeDeepFromMap", "(", "val", ",", "key", ")", ")", ";", "}", "else", "if", "(", "aKey", "!==", "key", ")", "{", "newMap", ".", "set", "(", "aKey", ",", "val", ")", ";", "}", "}", "return", "newMap", ";", "}" ]
Removes a key and all of its references from a map. This function has no side-effects as it returns a brand new map. @param {Map} map - Map to remove the key from @param {string} key - Key to remove from the map @return {Map} New map without the passed key
[ "Removes", "a", "key", "and", "all", "of", "its", "references", "from", "a", "map", ".", "This", "function", "has", "no", "side", "-", "effects", "as", "it", "returns", "a", "brand", "new", "map", "." ]
2de3f878f2e816b21bc063e38231d857d7f1afd1
https://github.com/albertorestifo/node-dijkstra/blob/2de3f878f2e816b21bc063e38231d857d7f1afd1/libs/removeDeepFromMap.js#L10-L22
22,433
ooade/pimg
examples/nextjs/.next/bundles/pages/index.js
createConnect
function createConnect() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, _ref$connectHOC = _ref.connectHOC, connectHOC = _ref$connectHOC === undefined ? __WEBPACK_IMPORTED_MODULE_0__components_connectAdvanced__["a" /* default */] : _ref$connectHOC, _ref$mapStateToPropsF = _ref.mapStateToPropsFactories, mapStateToPropsFactories = _ref$mapStateToPropsF === undefined ? __WEBPACK_IMPORTED_MODULE_3__mapStateToProps__["a" /* default */] : _ref$mapStateToPropsF, _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories, mapDispatchToPropsFactories = _ref$mapDispatchToPro === undefined ? __WEBPACK_IMPORTED_MODULE_2__mapDispatchToProps__["a" /* default */] : _ref$mapDispatchToPro, _ref$mergePropsFactor = _ref.mergePropsFactories, mergePropsFactories = _ref$mergePropsFactor === undefined ? __WEBPACK_IMPORTED_MODULE_4__mergeProps__["a" /* default */] : _ref$mergePropsFactor, _ref$selectorFactory = _ref.selectorFactory, selectorFactory = _ref$selectorFactory === undefined ? __WEBPACK_IMPORTED_MODULE_5__selectorFactory__["a" /* default */] : _ref$selectorFactory; return function connect(mapStateToProps, mapDispatchToProps, mergeProps) { var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}, _ref2$pure = _ref2.pure, pure = _ref2$pure === undefined ? true : _ref2$pure, _ref2$areStatesEqual = _ref2.areStatesEqual, areStatesEqual = _ref2$areStatesEqual === undefined ? strictEqual : _ref2$areStatesEqual, _ref2$areOwnPropsEqua = _ref2.areOwnPropsEqual, areOwnPropsEqual = _ref2$areOwnPropsEqua === undefined ? __WEBPACK_IMPORTED_MODULE_1__utils_shallowEqual__["a" /* default */] : _ref2$areOwnPropsEqua, _ref2$areStatePropsEq = _ref2.areStatePropsEqual, areStatePropsEqual = _ref2$areStatePropsEq === undefined ? __WEBPACK_IMPORTED_MODULE_1__utils_shallowEqual__["a" /* default */] : _ref2$areStatePropsEq, _ref2$areMergedPropsE = _ref2.areMergedPropsEqual, areMergedPropsEqual = _ref2$areMergedPropsE === undefined ? __WEBPACK_IMPORTED_MODULE_1__utils_shallowEqual__["a" /* default */] : _ref2$areMergedPropsE, extraOptions = _objectWithoutProperties(_ref2, ['pure', 'areStatesEqual', 'areOwnPropsEqual', 'areStatePropsEqual', 'areMergedPropsEqual']); var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps'); var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps'); var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps'); return connectHOC(selectorFactory, _extends({ // used in error messages methodName: 'connect', // used to compute Connect's displayName from the wrapped component's displayName. getDisplayName: function getDisplayName(name) { return 'Connect(' + name + ')'; }, // if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes shouldHandleStateChanges: Boolean(mapStateToProps), // passed through to selectorFactory initMapStateToProps: initMapStateToProps, initMapDispatchToProps: initMapDispatchToProps, initMergeProps: initMergeProps, pure: pure, areStatesEqual: areStatesEqual, areOwnPropsEqual: areOwnPropsEqual, areStatePropsEqual: areStatePropsEqual, areMergedPropsEqual: areMergedPropsEqual }, extraOptions)); }; }
javascript
function createConnect() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, _ref$connectHOC = _ref.connectHOC, connectHOC = _ref$connectHOC === undefined ? __WEBPACK_IMPORTED_MODULE_0__components_connectAdvanced__["a" /* default */] : _ref$connectHOC, _ref$mapStateToPropsF = _ref.mapStateToPropsFactories, mapStateToPropsFactories = _ref$mapStateToPropsF === undefined ? __WEBPACK_IMPORTED_MODULE_3__mapStateToProps__["a" /* default */] : _ref$mapStateToPropsF, _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories, mapDispatchToPropsFactories = _ref$mapDispatchToPro === undefined ? __WEBPACK_IMPORTED_MODULE_2__mapDispatchToProps__["a" /* default */] : _ref$mapDispatchToPro, _ref$mergePropsFactor = _ref.mergePropsFactories, mergePropsFactories = _ref$mergePropsFactor === undefined ? __WEBPACK_IMPORTED_MODULE_4__mergeProps__["a" /* default */] : _ref$mergePropsFactor, _ref$selectorFactory = _ref.selectorFactory, selectorFactory = _ref$selectorFactory === undefined ? __WEBPACK_IMPORTED_MODULE_5__selectorFactory__["a" /* default */] : _ref$selectorFactory; return function connect(mapStateToProps, mapDispatchToProps, mergeProps) { var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}, _ref2$pure = _ref2.pure, pure = _ref2$pure === undefined ? true : _ref2$pure, _ref2$areStatesEqual = _ref2.areStatesEqual, areStatesEqual = _ref2$areStatesEqual === undefined ? strictEqual : _ref2$areStatesEqual, _ref2$areOwnPropsEqua = _ref2.areOwnPropsEqual, areOwnPropsEqual = _ref2$areOwnPropsEqua === undefined ? __WEBPACK_IMPORTED_MODULE_1__utils_shallowEqual__["a" /* default */] : _ref2$areOwnPropsEqua, _ref2$areStatePropsEq = _ref2.areStatePropsEqual, areStatePropsEqual = _ref2$areStatePropsEq === undefined ? __WEBPACK_IMPORTED_MODULE_1__utils_shallowEqual__["a" /* default */] : _ref2$areStatePropsEq, _ref2$areMergedPropsE = _ref2.areMergedPropsEqual, areMergedPropsEqual = _ref2$areMergedPropsE === undefined ? __WEBPACK_IMPORTED_MODULE_1__utils_shallowEqual__["a" /* default */] : _ref2$areMergedPropsE, extraOptions = _objectWithoutProperties(_ref2, ['pure', 'areStatesEqual', 'areOwnPropsEqual', 'areStatePropsEqual', 'areMergedPropsEqual']); var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps'); var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps'); var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps'); return connectHOC(selectorFactory, _extends({ // used in error messages methodName: 'connect', // used to compute Connect's displayName from the wrapped component's displayName. getDisplayName: function getDisplayName(name) { return 'Connect(' + name + ')'; }, // if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes shouldHandleStateChanges: Boolean(mapStateToProps), // passed through to selectorFactory initMapStateToProps: initMapStateToProps, initMapDispatchToProps: initMapDispatchToProps, initMergeProps: initMergeProps, pure: pure, areStatesEqual: areStatesEqual, areOwnPropsEqual: areOwnPropsEqual, areStatePropsEqual: areStatePropsEqual, areMergedPropsEqual: areMergedPropsEqual }, extraOptions)); }; }
[ "function", "createConnect", "(", ")", "{", "var", "_ref", "=", "arguments", ".", "length", ">", "0", "&&", "arguments", "[", "0", "]", "!==", "undefined", "?", "arguments", "[", "0", "]", ":", "{", "}", ",", "_ref$connectHOC", "=", "_ref", ".", "connectHOC", ",", "connectHOC", "=", "_ref$connectHOC", "===", "undefined", "?", "__WEBPACK_IMPORTED_MODULE_0__components_connectAdvanced__", "[", "\"a\"", "/* default */", "]", ":", "_ref$connectHOC", ",", "_ref$mapStateToPropsF", "=", "_ref", ".", "mapStateToPropsFactories", ",", "mapStateToPropsFactories", "=", "_ref$mapStateToPropsF", "===", "undefined", "?", "__WEBPACK_IMPORTED_MODULE_3__mapStateToProps__", "[", "\"a\"", "/* default */", "]", ":", "_ref$mapStateToPropsF", ",", "_ref$mapDispatchToPro", "=", "_ref", ".", "mapDispatchToPropsFactories", ",", "mapDispatchToPropsFactories", "=", "_ref$mapDispatchToPro", "===", "undefined", "?", "__WEBPACK_IMPORTED_MODULE_2__mapDispatchToProps__", "[", "\"a\"", "/* default */", "]", ":", "_ref$mapDispatchToPro", ",", "_ref$mergePropsFactor", "=", "_ref", ".", "mergePropsFactories", ",", "mergePropsFactories", "=", "_ref$mergePropsFactor", "===", "undefined", "?", "__WEBPACK_IMPORTED_MODULE_4__mergeProps__", "[", "\"a\"", "/* default */", "]", ":", "_ref$mergePropsFactor", ",", "_ref$selectorFactory", "=", "_ref", ".", "selectorFactory", ",", "selectorFactory", "=", "_ref$selectorFactory", "===", "undefined", "?", "__WEBPACK_IMPORTED_MODULE_5__selectorFactory__", "[", "\"a\"", "/* default */", "]", ":", "_ref$selectorFactory", ";", "return", "function", "connect", "(", "mapStateToProps", ",", "mapDispatchToProps", ",", "mergeProps", ")", "{", "var", "_ref2", "=", "arguments", ".", "length", ">", "3", "&&", "arguments", "[", "3", "]", "!==", "undefined", "?", "arguments", "[", "3", "]", ":", "{", "}", ",", "_ref2$pure", "=", "_ref2", ".", "pure", ",", "pure", "=", "_ref2$pure", "===", "undefined", "?", "true", ":", "_ref2$pure", ",", "_ref2$areStatesEqual", "=", "_ref2", ".", "areStatesEqual", ",", "areStatesEqual", "=", "_ref2$areStatesEqual", "===", "undefined", "?", "strictEqual", ":", "_ref2$areStatesEqual", ",", "_ref2$areOwnPropsEqua", "=", "_ref2", ".", "areOwnPropsEqual", ",", "areOwnPropsEqual", "=", "_ref2$areOwnPropsEqua", "===", "undefined", "?", "__WEBPACK_IMPORTED_MODULE_1__utils_shallowEqual__", "[", "\"a\"", "/* default */", "]", ":", "_ref2$areOwnPropsEqua", ",", "_ref2$areStatePropsEq", "=", "_ref2", ".", "areStatePropsEqual", ",", "areStatePropsEqual", "=", "_ref2$areStatePropsEq", "===", "undefined", "?", "__WEBPACK_IMPORTED_MODULE_1__utils_shallowEqual__", "[", "\"a\"", "/* default */", "]", ":", "_ref2$areStatePropsEq", ",", "_ref2$areMergedPropsE", "=", "_ref2", ".", "areMergedPropsEqual", ",", "areMergedPropsEqual", "=", "_ref2$areMergedPropsE", "===", "undefined", "?", "__WEBPACK_IMPORTED_MODULE_1__utils_shallowEqual__", "[", "\"a\"", "/* default */", "]", ":", "_ref2$areMergedPropsE", ",", "extraOptions", "=", "_objectWithoutProperties", "(", "_ref2", ",", "[", "'pure'", ",", "'areStatesEqual'", ",", "'areOwnPropsEqual'", ",", "'areStatePropsEqual'", ",", "'areMergedPropsEqual'", "]", ")", ";", "var", "initMapStateToProps", "=", "match", "(", "mapStateToProps", ",", "mapStateToPropsFactories", ",", "'mapStateToProps'", ")", ";", "var", "initMapDispatchToProps", "=", "match", "(", "mapDispatchToProps", ",", "mapDispatchToPropsFactories", ",", "'mapDispatchToProps'", ")", ";", "var", "initMergeProps", "=", "match", "(", "mergeProps", ",", "mergePropsFactories", ",", "'mergeProps'", ")", ";", "return", "connectHOC", "(", "selectorFactory", ",", "_extends", "(", "{", "// used in error messages", "methodName", ":", "'connect'", ",", "// used to compute Connect's displayName from the wrapped component's displayName.", "getDisplayName", ":", "function", "getDisplayName", "(", "name", ")", "{", "return", "'Connect('", "+", "name", "+", "')'", ";", "}", ",", "// if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes", "shouldHandleStateChanges", ":", "Boolean", "(", "mapStateToProps", ")", ",", "// passed through to selectorFactory", "initMapStateToProps", ":", "initMapStateToProps", ",", "initMapDispatchToProps", ":", "initMapDispatchToProps", ",", "initMergeProps", ":", "initMergeProps", ",", "pure", ":", "pure", ",", "areStatesEqual", ":", "areStatesEqual", ",", "areOwnPropsEqual", ":", "areOwnPropsEqual", ",", "areStatePropsEqual", ":", "areStatePropsEqual", ",", "areMergedPropsEqual", ":", "areMergedPropsEqual", "}", ",", "extraOptions", ")", ")", ";", "}", ";", "}" ]
createConnect with default args builds the 'official' connect behavior. Calling it with different options opens up some testing and extensibility scenarios
[ "createConnect", "with", "default", "args", "builds", "the", "official", "connect", "behavior", ".", "Calling", "it", "with", "different", "options", "opens", "up", "some", "testing", "and", "extensibility", "scenarios" ]
bde8db962d60e68f91f41ff45c20e86b5df73931
https://github.com/ooade/pimg/blob/bde8db962d60e68f91f41ff45c20e86b5df73931/examples/nextjs/.next/bundles/pages/index.js#L4727-L4782
22,434
ooade/pimg
examples/nextjs/.next/bundles/pages/index.js
finalPropsSelectorFactory
function finalPropsSelectorFactory(dispatch, _ref2) { var initMapStateToProps = _ref2.initMapStateToProps, initMapDispatchToProps = _ref2.initMapDispatchToProps, initMergeProps = _ref2.initMergeProps, options = _objectWithoutProperties(_ref2, ['initMapStateToProps', 'initMapDispatchToProps', 'initMergeProps']); var mapStateToProps = initMapStateToProps(dispatch, options); var mapDispatchToProps = initMapDispatchToProps(dispatch, options); var mergeProps = initMergeProps(dispatch, options); if (true) { Object(__WEBPACK_IMPORTED_MODULE_0__verifySubselectors__["a" /* default */])(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName); } var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory; return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options); }
javascript
function finalPropsSelectorFactory(dispatch, _ref2) { var initMapStateToProps = _ref2.initMapStateToProps, initMapDispatchToProps = _ref2.initMapDispatchToProps, initMergeProps = _ref2.initMergeProps, options = _objectWithoutProperties(_ref2, ['initMapStateToProps', 'initMapDispatchToProps', 'initMergeProps']); var mapStateToProps = initMapStateToProps(dispatch, options); var mapDispatchToProps = initMapDispatchToProps(dispatch, options); var mergeProps = initMergeProps(dispatch, options); if (true) { Object(__WEBPACK_IMPORTED_MODULE_0__verifySubselectors__["a" /* default */])(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName); } var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory; return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options); }
[ "function", "finalPropsSelectorFactory", "(", "dispatch", ",", "_ref2", ")", "{", "var", "initMapStateToProps", "=", "_ref2", ".", "initMapStateToProps", ",", "initMapDispatchToProps", "=", "_ref2", ".", "initMapDispatchToProps", ",", "initMergeProps", "=", "_ref2", ".", "initMergeProps", ",", "options", "=", "_objectWithoutProperties", "(", "_ref2", ",", "[", "'initMapStateToProps'", ",", "'initMapDispatchToProps'", ",", "'initMergeProps'", "]", ")", ";", "var", "mapStateToProps", "=", "initMapStateToProps", "(", "dispatch", ",", "options", ")", ";", "var", "mapDispatchToProps", "=", "initMapDispatchToProps", "(", "dispatch", ",", "options", ")", ";", "var", "mergeProps", "=", "initMergeProps", "(", "dispatch", ",", "options", ")", ";", "if", "(", "true", ")", "{", "Object", "(", "__WEBPACK_IMPORTED_MODULE_0__verifySubselectors__", "[", "\"a\"", "/* default */", "]", ")", "(", "mapStateToProps", ",", "mapDispatchToProps", ",", "mergeProps", ",", "options", ".", "displayName", ")", ";", "}", "var", "selectorFactory", "=", "options", ".", "pure", "?", "pureFinalPropsSelectorFactory", ":", "impureFinalPropsSelectorFactory", ";", "return", "selectorFactory", "(", "mapStateToProps", ",", "mapDispatchToProps", ",", "mergeProps", ",", "dispatch", ",", "options", ")", ";", "}" ]
If pure is true, the selector returned by selectorFactory will memoize its results, allowing connectAdvanced's shouldComponentUpdate to return false if final props have not changed. If false, the selector will always return a new object and shouldComponentUpdate will always return true.
[ "If", "pure", "is", "true", "the", "selector", "returned", "by", "selectorFactory", "will", "memoize", "its", "results", "allowing", "connectAdvanced", "s", "shouldComponentUpdate", "to", "return", "false", "if", "final", "props", "have", "not", "changed", ".", "If", "false", "the", "selector", "will", "always", "return", "a", "new", "object", "and", "shouldComponentUpdate", "will", "always", "return", "true", "." ]
bde8db962d60e68f91f41ff45c20e86b5df73931
https://github.com/ooade/pimg/blob/bde8db962d60e68f91f41ff45c20e86b5df73931/examples/nextjs/.next/bundles/pages/index.js#L4992-L5009
22,435
ooade/pimg
examples/nextjs/.next/bundles/pages/index.js
getDependsOnOwnProps
function getDependsOnOwnProps(mapToProps) { return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1; }
javascript
function getDependsOnOwnProps(mapToProps) { return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1; }
[ "function", "getDependsOnOwnProps", "(", "mapToProps", ")", "{", "return", "mapToProps", ".", "dependsOnOwnProps", "!==", "null", "&&", "mapToProps", ".", "dependsOnOwnProps", "!==", "undefined", "?", "Boolean", "(", "mapToProps", ".", "dependsOnOwnProps", ")", ":", "mapToProps", ".", "length", "!==", "1", ";", "}" ]
dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine whether mapToProps needs to be invoked when props have changed. A length of one signals that mapToProps does not depend on props from the parent component. A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and therefore not reporting its length accurately..
[ "dependsOnOwnProps", "is", "used", "by", "createMapToPropsProxy", "to", "determine", "whether", "to", "pass", "props", "as", "args", "to", "the", "mapToProps", "function", "being", "wrapped", ".", "It", "is", "also", "used", "by", "makePurePropsSelector", "to", "determine", "whether", "mapToProps", "needs", "to", "be", "invoked", "when", "props", "have", "changed", ".", "A", "length", "of", "one", "signals", "that", "mapToProps", "does", "not", "depend", "on", "props", "from", "the", "parent", "component", ".", "A", "length", "of", "zero", "is", "assumed", "to", "mean", "mapToProps", "is", "getting", "args", "via", "arguments", "or", "...", "args", "and", "therefore", "not", "reporting", "its", "length", "accurately", ".." ]
bde8db962d60e68f91f41ff45c20e86b5df73931
https://github.com/ooade/pimg/blob/bde8db962d60e68f91f41ff45c20e86b5df73931/examples/nextjs/.next/bundles/pages/index.js#L5068-L5070
22,436
ooade/pimg
examples/vue/.nuxt/client.js
resolveComponents
function resolveComponents(router) { const path = getLocation(router.options.base, router.options.mode) return flatMapComponents(router.match(path), async (Component, _, match, key, index) => { // If component is not resolved yet, resolve it if (typeof Component === 'function' && !Component.options) { Component = await Component() } // Sanitize it and save it const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null) match.components[key] = _Component return _Component }) }
javascript
function resolveComponents(router) { const path = getLocation(router.options.base, router.options.mode) return flatMapComponents(router.match(path), async (Component, _, match, key, index) => { // If component is not resolved yet, resolve it if (typeof Component === 'function' && !Component.options) { Component = await Component() } // Sanitize it and save it const _Component = applySSRData(sanitizeComponent(Component), NUXT.data ? NUXT.data[index] : null) match.components[key] = _Component return _Component }) }
[ "function", "resolveComponents", "(", "router", ")", "{", "const", "path", "=", "getLocation", "(", "router", ".", "options", ".", "base", ",", "router", ".", "options", ".", "mode", ")", "return", "flatMapComponents", "(", "router", ".", "match", "(", "path", ")", ",", "async", "(", "Component", ",", "_", ",", "match", ",", "key", ",", "index", ")", "=>", "{", "// If component is not resolved yet, resolve it", "if", "(", "typeof", "Component", "===", "'function'", "&&", "!", "Component", ".", "options", ")", "{", "Component", "=", "await", "Component", "(", ")", "}", "// Sanitize it and save it", "const", "_Component", "=", "applySSRData", "(", "sanitizeComponent", "(", "Component", ")", ",", "NUXT", ".", "data", "?", "NUXT", ".", "data", "[", "index", "]", ":", "null", ")", "match", ".", "components", "[", "key", "]", "=", "_Component", "return", "_Component", "}", ")", "}" ]
Get matched components
[ "Get", "matched", "components" ]
bde8db962d60e68f91f41ff45c20e86b5df73931
https://github.com/ooade/pimg/blob/bde8db962d60e68f91f41ff45c20e86b5df73931/examples/vue/.nuxt/client.js#L149-L162
22,437
ooade/pimg
examples/nextjs/.next/app.js
function(str1, str2, options) { var useCollator = (options && collator && options.useCollator); var str1Len = str1.length, str2Len = str2.length; // base cases if (str1Len === 0) return str2Len; if (str2Len === 0) return str1Len; // two rows var curCol, nextCol, i, j, tmp; // initialise previous row for (i=0; i<str2Len; ++i) { prevRow[i] = i; str2Char[i] = str2.charCodeAt(i); } prevRow[str2Len] = str2Len; var strCmp; if (useCollator) { // calculate current row distance from previous row using collator for (i = 0; i < str1Len; ++i) { nextCol = i + 1; for (j = 0; j < str2Len; ++j) { curCol = nextCol; // substution strCmp = 0 === collator.compare(str1.charAt(i), String.fromCharCode(str2Char[j])); nextCol = prevRow[j] + (strCmp ? 0 : 1); // insertion tmp = curCol + 1; if (nextCol > tmp) { nextCol = tmp; } // deletion tmp = prevRow[j + 1] + 1; if (nextCol > tmp) { nextCol = tmp; } // copy current col value into previous (in preparation for next iteration) prevRow[j] = curCol; } // copy last col value into previous (in preparation for next iteration) prevRow[j] = nextCol; } } else { // calculate current row distance from previous row without collator for (i = 0; i < str1Len; ++i) { nextCol = i + 1; for (j = 0; j < str2Len; ++j) { curCol = nextCol; // substution strCmp = str1.charCodeAt(i) === str2Char[j]; nextCol = prevRow[j] + (strCmp ? 0 : 1); // insertion tmp = curCol + 1; if (nextCol > tmp) { nextCol = tmp; } // deletion tmp = prevRow[j + 1] + 1; if (nextCol > tmp) { nextCol = tmp; } // copy current col value into previous (in preparation for next iteration) prevRow[j] = curCol; } // copy last col value into previous (in preparation for next iteration) prevRow[j] = nextCol; } } return nextCol; }
javascript
function(str1, str2, options) { var useCollator = (options && collator && options.useCollator); var str1Len = str1.length, str2Len = str2.length; // base cases if (str1Len === 0) return str2Len; if (str2Len === 0) return str1Len; // two rows var curCol, nextCol, i, j, tmp; // initialise previous row for (i=0; i<str2Len; ++i) { prevRow[i] = i; str2Char[i] = str2.charCodeAt(i); } prevRow[str2Len] = str2Len; var strCmp; if (useCollator) { // calculate current row distance from previous row using collator for (i = 0; i < str1Len; ++i) { nextCol = i + 1; for (j = 0; j < str2Len; ++j) { curCol = nextCol; // substution strCmp = 0 === collator.compare(str1.charAt(i), String.fromCharCode(str2Char[j])); nextCol = prevRow[j] + (strCmp ? 0 : 1); // insertion tmp = curCol + 1; if (nextCol > tmp) { nextCol = tmp; } // deletion tmp = prevRow[j + 1] + 1; if (nextCol > tmp) { nextCol = tmp; } // copy current col value into previous (in preparation for next iteration) prevRow[j] = curCol; } // copy last col value into previous (in preparation for next iteration) prevRow[j] = nextCol; } } else { // calculate current row distance from previous row without collator for (i = 0; i < str1Len; ++i) { nextCol = i + 1; for (j = 0; j < str2Len; ++j) { curCol = nextCol; // substution strCmp = str1.charCodeAt(i) === str2Char[j]; nextCol = prevRow[j] + (strCmp ? 0 : 1); // insertion tmp = curCol + 1; if (nextCol > tmp) { nextCol = tmp; } // deletion tmp = prevRow[j + 1] + 1; if (nextCol > tmp) { nextCol = tmp; } // copy current col value into previous (in preparation for next iteration) prevRow[j] = curCol; } // copy last col value into previous (in preparation for next iteration) prevRow[j] = nextCol; } } return nextCol; }
[ "function", "(", "str1", ",", "str2", ",", "options", ")", "{", "var", "useCollator", "=", "(", "options", "&&", "collator", "&&", "options", ".", "useCollator", ")", ";", "var", "str1Len", "=", "str1", ".", "length", ",", "str2Len", "=", "str2", ".", "length", ";", "// base cases", "if", "(", "str1Len", "===", "0", ")", "return", "str2Len", ";", "if", "(", "str2Len", "===", "0", ")", "return", "str1Len", ";", "// two rows", "var", "curCol", ",", "nextCol", ",", "i", ",", "j", ",", "tmp", ";", "// initialise previous row", "for", "(", "i", "=", "0", ";", "i", "<", "str2Len", ";", "++", "i", ")", "{", "prevRow", "[", "i", "]", "=", "i", ";", "str2Char", "[", "i", "]", "=", "str2", ".", "charCodeAt", "(", "i", ")", ";", "}", "prevRow", "[", "str2Len", "]", "=", "str2Len", ";", "var", "strCmp", ";", "if", "(", "useCollator", ")", "{", "// calculate current row distance from previous row using collator", "for", "(", "i", "=", "0", ";", "i", "<", "str1Len", ";", "++", "i", ")", "{", "nextCol", "=", "i", "+", "1", ";", "for", "(", "j", "=", "0", ";", "j", "<", "str2Len", ";", "++", "j", ")", "{", "curCol", "=", "nextCol", ";", "// substution", "strCmp", "=", "0", "===", "collator", ".", "compare", "(", "str1", ".", "charAt", "(", "i", ")", ",", "String", ".", "fromCharCode", "(", "str2Char", "[", "j", "]", ")", ")", ";", "nextCol", "=", "prevRow", "[", "j", "]", "+", "(", "strCmp", "?", "0", ":", "1", ")", ";", "// insertion", "tmp", "=", "curCol", "+", "1", ";", "if", "(", "nextCol", ">", "tmp", ")", "{", "nextCol", "=", "tmp", ";", "}", "// deletion", "tmp", "=", "prevRow", "[", "j", "+", "1", "]", "+", "1", ";", "if", "(", "nextCol", ">", "tmp", ")", "{", "nextCol", "=", "tmp", ";", "}", "// copy current col value into previous (in preparation for next iteration)", "prevRow", "[", "j", "]", "=", "curCol", ";", "}", "// copy last col value into previous (in preparation for next iteration)", "prevRow", "[", "j", "]", "=", "nextCol", ";", "}", "}", "else", "{", "// calculate current row distance from previous row without collator", "for", "(", "i", "=", "0", ";", "i", "<", "str1Len", ";", "++", "i", ")", "{", "nextCol", "=", "i", "+", "1", ";", "for", "(", "j", "=", "0", ";", "j", "<", "str2Len", ";", "++", "j", ")", "{", "curCol", "=", "nextCol", ";", "// substution", "strCmp", "=", "str1", ".", "charCodeAt", "(", "i", ")", "===", "str2Char", "[", "j", "]", ";", "nextCol", "=", "prevRow", "[", "j", "]", "+", "(", "strCmp", "?", "0", ":", "1", ")", ";", "// insertion", "tmp", "=", "curCol", "+", "1", ";", "if", "(", "nextCol", ">", "tmp", ")", "{", "nextCol", "=", "tmp", ";", "}", "// deletion", "tmp", "=", "prevRow", "[", "j", "+", "1", "]", "+", "1", ";", "if", "(", "nextCol", ">", "tmp", ")", "{", "nextCol", "=", "tmp", ";", "}", "// copy current col value into previous (in preparation for next iteration)", "prevRow", "[", "j", "]", "=", "curCol", ";", "}", "// copy last col value into previous (in preparation for next iteration)", "prevRow", "[", "j", "]", "=", "nextCol", ";", "}", "}", "return", "nextCol", ";", "}" ]
Calculate levenshtein distance of the two strings. @param str1 String the first string. @param str2 String the second string. @param [options] Additional options. @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison. @return Integer the levenshtein distance (0 and above).
[ "Calculate", "levenshtein", "distance", "of", "the", "two", "strings", "." ]
bde8db962d60e68f91f41ff45c20e86b5df73931
https://github.com/ooade/pimg/blob/bde8db962d60e68f91f41ff45c20e86b5df73931/examples/nextjs/.next/app.js#L22672-L22758
22,438
ooade/pimg
examples/vue/.nuxt/utils.js
formatUrl
function formatUrl (url, query) { let protocol let index = url.indexOf('://') if (index !== -1) { protocol = url.substring(0, index) url = url.substring(index + 3) } else if (url.indexOf('//') === 0) { url = url.substring(2) } let parts = url.split('/') let result = (protocol ? protocol + '://' : '//') + parts.shift() let path = parts.filter(Boolean).join('/') let hash parts = path.split('#') if (parts.length === 2) { path = parts[0] hash = parts[1] } result += path ? '/' + path : '' if (query && JSON.stringify(query) !== '{}') { result += (url.split('?').length === 2 ? '&' : '?') + formatQuery(query) } result += hash ? '#' + hash : '' return result }
javascript
function formatUrl (url, query) { let protocol let index = url.indexOf('://') if (index !== -1) { protocol = url.substring(0, index) url = url.substring(index + 3) } else if (url.indexOf('//') === 0) { url = url.substring(2) } let parts = url.split('/') let result = (protocol ? protocol + '://' : '//') + parts.shift() let path = parts.filter(Boolean).join('/') let hash parts = path.split('#') if (parts.length === 2) { path = parts[0] hash = parts[1] } result += path ? '/' + path : '' if (query && JSON.stringify(query) !== '{}') { result += (url.split('?').length === 2 ? '&' : '?') + formatQuery(query) } result += hash ? '#' + hash : '' return result }
[ "function", "formatUrl", "(", "url", ",", "query", ")", "{", "let", "protocol", "let", "index", "=", "url", ".", "indexOf", "(", "'://'", ")", "if", "(", "index", "!==", "-", "1", ")", "{", "protocol", "=", "url", ".", "substring", "(", "0", ",", "index", ")", "url", "=", "url", ".", "substring", "(", "index", "+", "3", ")", "}", "else", "if", "(", "url", ".", "indexOf", "(", "'//'", ")", "===", "0", ")", "{", "url", "=", "url", ".", "substring", "(", "2", ")", "}", "let", "parts", "=", "url", ".", "split", "(", "'/'", ")", "let", "result", "=", "(", "protocol", "?", "protocol", "+", "'://'", ":", "'//'", ")", "+", "parts", ".", "shift", "(", ")", "let", "path", "=", "parts", ".", "filter", "(", "Boolean", ")", ".", "join", "(", "'/'", ")", "let", "hash", "parts", "=", "path", ".", "split", "(", "'#'", ")", "if", "(", "parts", ".", "length", "===", "2", ")", "{", "path", "=", "parts", "[", "0", "]", "hash", "=", "parts", "[", "1", "]", "}", "result", "+=", "path", "?", "'/'", "+", "path", ":", "''", "if", "(", "query", "&&", "JSON", ".", "stringify", "(", "query", ")", "!==", "'{}'", ")", "{", "result", "+=", "(", "url", ".", "split", "(", "'?'", ")", ".", "length", "===", "2", "?", "'&'", ":", "'?'", ")", "+", "formatQuery", "(", "query", ")", "}", "result", "+=", "hash", "?", "'#'", "+", "hash", ":", "''", "return", "result", "}" ]
Format given url, append query to url query string @param {string} url @param {string} query @return {string}
[ "Format", "given", "url", "append", "query", "to", "url", "query", "string" ]
bde8db962d60e68f91f41ff45c20e86b5df73931
https://github.com/ooade/pimg/blob/bde8db962d60e68f91f41ff45c20e86b5df73931/examples/vue/.nuxt/utils.js#L471-L500
22,439
ooade/pimg
examples/vue/.nuxt/utils.js
formatQuery
function formatQuery (query) { return Object.keys(query).sort().map(key => { var val = query[key] if (val == null) { return '' } if (Array.isArray(val)) { return val.slice().map(val2 => [key, '=', val2].join('')).join('&') } return key + '=' + val }).filter(Boolean).join('&') }
javascript
function formatQuery (query) { return Object.keys(query).sort().map(key => { var val = query[key] if (val == null) { return '' } if (Array.isArray(val)) { return val.slice().map(val2 => [key, '=', val2].join('')).join('&') } return key + '=' + val }).filter(Boolean).join('&') }
[ "function", "formatQuery", "(", "query", ")", "{", "return", "Object", ".", "keys", "(", "query", ")", ".", "sort", "(", ")", ".", "map", "(", "key", "=>", "{", "var", "val", "=", "query", "[", "key", "]", "if", "(", "val", "==", "null", ")", "{", "return", "''", "}", "if", "(", "Array", ".", "isArray", "(", "val", ")", ")", "{", "return", "val", ".", "slice", "(", ")", ".", "map", "(", "val2", "=>", "[", "key", ",", "'='", ",", "val2", "]", ".", "join", "(", "''", ")", ")", ".", "join", "(", "'&'", ")", "}", "return", "key", "+", "'='", "+", "val", "}", ")", ".", "filter", "(", "Boolean", ")", ".", "join", "(", "'&'", ")", "}" ]
Transform data object to query string @param {object} query @return {string}
[ "Transform", "data", "object", "to", "query", "string" ]
bde8db962d60e68f91f41ff45c20e86b5df73931
https://github.com/ooade/pimg/blob/bde8db962d60e68f91f41ff45c20e86b5df73931/examples/vue/.nuxt/utils.js#L508-L519
22,440
nodeca/tabex
lib/timer.js
cleanup
function cleanup() { if (url) { URL.revokeObjectURL(url); } if (ww) { ww.terminate(); } if (timeout) { clearTimeout(timeout); } }
javascript
function cleanup() { if (url) { URL.revokeObjectURL(url); } if (ww) { ww.terminate(); } if (timeout) { clearTimeout(timeout); } }
[ "function", "cleanup", "(", ")", "{", "if", "(", "url", ")", "{", "URL", ".", "revokeObjectURL", "(", "url", ")", ";", "}", "if", "(", "ww", ")", "{", "ww", ".", "terminate", "(", ")", ";", "}", "if", "(", "timeout", ")", "{", "clearTimeout", "(", "timeout", ")", ";", "}", "}" ]
Remove created data on fallback
[ "Remove", "created", "data", "on", "fallback" ]
d77ac4808838d5f158c3143d9e83f7ac69fc4444
https://github.com/nodeca/tabex/blob/d77ac4808838d5f158c3143d9e83f7ac69fc4444/lib/timer.js#L141-L145
22,441
digitalie/one-loader
src/parse.js
append
function append(object, path, value) { set(object, path, get(object, path, '') + `\r\n${value}`); }
javascript
function append(object, path, value) { set(object, path, get(object, path, '') + `\r\n${value}`); }
[ "function", "append", "(", "object", ",", "path", ",", "value", ")", "{", "set", "(", "object", ",", "path", ",", "get", "(", "object", ",", "path", ",", "''", ")", "+", "`", "\\r", "\\n", "${", "value", "}", "`", ")", ";", "}" ]
Add property of given path to the object @param {object} object @param {array} path @param {string} value
[ "Add", "property", "of", "given", "path", "to", "the", "object" ]
316e6302ccbb982504ef68a7c160c85a01c8e8f0
https://github.com/digitalie/one-loader/blob/316e6302ccbb982504ef68a7c160c85a01c8e8f0/src/parse.js#L34-L36
22,442
digitalie/one-loader
src/parse.js
getType
function getType(node) { const tagLoaders = { script: 'javascript', style: 'text/css' }; return get(node, 'attrs.type', tagLoaders[node.tag]); }
javascript
function getType(node) { const tagLoaders = { script: 'javascript', style: 'text/css' }; return get(node, 'attrs.type', tagLoaders[node.tag]); }
[ "function", "getType", "(", "node", ")", "{", "const", "tagLoaders", "=", "{", "script", ":", "'javascript'", ",", "style", ":", "'text/css'", "}", ";", "return", "get", "(", "node", ",", "'attrs.type'", ",", "tagLoaders", "[", "node", ".", "tag", "]", ")", ";", "}" ]
Get tag type property @param {object} node @returns {string}
[ "Get", "tag", "type", "property" ]
316e6302ccbb982504ef68a7c160c85a01c8e8f0
https://github.com/digitalie/one-loader/blob/316e6302ccbb982504ef68a7c160c85a01c8e8f0/src/parse.js#L52-L59
22,443
phamtrisi/airapi
helpers/serialize.js
serialize
function serialize(obj) { var params = [], encodedBrackets = encodeURIComponent('[]'); _.forOwn(obj, function(value, key) { if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { params.push(key + '=' + encodeURIComponent(value)); } else if (typeof value === 'object' && Array.isArray(value)) { params.push(value.map(function(param) { return key + encodedBrackets + '=' + encodeURIComponent(param); }).join('&')); } }); return params.join('&'); }
javascript
function serialize(obj) { var params = [], encodedBrackets = encodeURIComponent('[]'); _.forOwn(obj, function(value, key) { if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { params.push(key + '=' + encodeURIComponent(value)); } else if (typeof value === 'object' && Array.isArray(value)) { params.push(value.map(function(param) { return key + encodedBrackets + '=' + encodeURIComponent(param); }).join('&')); } }); return params.join('&'); }
[ "function", "serialize", "(", "obj", ")", "{", "var", "params", "=", "[", "]", ",", "encodedBrackets", "=", "encodeURIComponent", "(", "'[]'", ")", ";", "_", ".", "forOwn", "(", "obj", ",", "function", "(", "value", ",", "key", ")", "{", "if", "(", "typeof", "value", "===", "'string'", "||", "typeof", "value", "===", "'number'", "||", "typeof", "value", "===", "'boolean'", ")", "{", "params", ".", "push", "(", "key", "+", "'='", "+", "encodeURIComponent", "(", "value", ")", ")", ";", "}", "else", "if", "(", "typeof", "value", "===", "'object'", "&&", "Array", ".", "isArray", "(", "value", ")", ")", "{", "params", ".", "push", "(", "value", ".", "map", "(", "function", "(", "param", ")", "{", "return", "key", "+", "encodedBrackets", "+", "'='", "+", "encodeURIComponent", "(", "param", ")", ";", "}", ")", ".", "join", "(", "'&'", ")", ")", ";", "}", "}", ")", ";", "return", "params", ".", "join", "(", "'&'", ")", ";", "}" ]
Serialize an object into a valid URL string @param {Object} obj - Params object @return {String} - A valid encoded URL string
[ "Serialize", "an", "object", "into", "a", "valid", "URL", "string" ]
1828b761573321c2e46834907f06bb3536f446b8
https://github.com/phamtrisi/airapi/blob/1828b761573321c2e46834907f06bb3536f446b8/helpers/serialize.js#L8-L25
22,444
phamtrisi/airapi
api/getInfo.js
getInfo
function getInfo(hostingId) { var requestConfigs = _.assign({}, configs.DEFAULT_REQUEST_CONFIGS, { url: configs.HOSTING_INFO_URL + '/' + hostingId + '?' + serialize(configs.DEFAULT_REQUEST_PARAMS) }); return new Promise(function(resolve, reject) { // Make request to parse hosting info request(requestConfigs, function(err, res, body) { if (!err && res.statusCode == 200) { resolve(JSON.parse(body)); } else if (err) { reject(err); } }); }); }
javascript
function getInfo(hostingId) { var requestConfigs = _.assign({}, configs.DEFAULT_REQUEST_CONFIGS, { url: configs.HOSTING_INFO_URL + '/' + hostingId + '?' + serialize(configs.DEFAULT_REQUEST_PARAMS) }); return new Promise(function(resolve, reject) { // Make request to parse hosting info request(requestConfigs, function(err, res, body) { if (!err && res.statusCode == 200) { resolve(JSON.parse(body)); } else if (err) { reject(err); } }); }); }
[ "function", "getInfo", "(", "hostingId", ")", "{", "var", "requestConfigs", "=", "_", ".", "assign", "(", "{", "}", ",", "configs", ".", "DEFAULT_REQUEST_CONFIGS", ",", "{", "url", ":", "configs", ".", "HOSTING_INFO_URL", "+", "'/'", "+", "hostingId", "+", "'?'", "+", "serialize", "(", "configs", ".", "DEFAULT_REQUEST_PARAMS", ")", "}", ")", ";", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "// Make request to parse hosting info", "request", "(", "requestConfigs", ",", "function", "(", "err", ",", "res", ",", "body", ")", "{", "if", "(", "!", "err", "&&", "res", ".", "statusCode", "==", "200", ")", "{", "resolve", "(", "JSON", ".", "parse", "(", "body", ")", ")", ";", "}", "else", "if", "(", "err", ")", "{", "reject", "(", "err", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}" ]
Get info for a particular hosting @param {Number, String} hosting - Hosting ID @param {Function} successCallback - Success callback to invoke @param {Function} failureCallback - Failure callback to invoke @return {Void} - Hosting info is passed onto callbacks
[ "Get", "info", "for", "a", "particular", "hosting" ]
1828b761573321c2e46834907f06bb3536f446b8
https://github.com/phamtrisi/airapi/blob/1828b761573321c2e46834907f06bb3536f446b8/api/getInfo.js#L15-L30
22,445
nolanlawson/pseudo-worker
index.js
executeEach
function executeEach(arr, fun) { var i = -1; while (++i < arr.length) { if (arr[i]) { fun(arr[i]); } } }
javascript
function executeEach(arr, fun) { var i = -1; while (++i < arr.length) { if (arr[i]) { fun(arr[i]); } } }
[ "function", "executeEach", "(", "arr", ",", "fun", ")", "{", "var", "i", "=", "-", "1", ";", "while", "(", "++", "i", "<", "arr", ".", "length", ")", "{", "if", "(", "arr", "[", "i", "]", ")", "{", "fun", "(", "arr", "[", "i", "]", ")", ";", "}", "}", "}" ]
custom each loop is for IE8 support
[ "custom", "each", "loop", "is", "for", "IE8", "support" ]
920c7be811ac9309b29692a8ac6183665d00e203
https://github.com/nolanlawson/pseudo-worker/blob/920c7be811ac9309b29692a8ac6183665d00e203/index.js#L24-L31
22,446
OpenF2/F2
sdk/src/F2.js
function (ns, obj, overwrite) { var isFunc = typeof obj === 'function'; var parts = ns ? ns.split('.') : []; var parent = this; obj = obj || {}; // ignore leading global if (parts[0] === 'F2') { parts = parts.slice(1); } // create namespaces for (var i = 0, len = parts.length; i < len; i++) { if (!parent[parts[i]]) { parent[parts[i]] = isFunc && i + 1 == len ? obj : {}; } parent = parent[parts[i]]; } // copy object into namespace if (!isFunc) { for (var prop in obj) { if (typeof parent[prop] === 'undefined' || overwrite) { parent[prop] = obj[prop]; } } } return parent; }
javascript
function (ns, obj, overwrite) { var isFunc = typeof obj === 'function'; var parts = ns ? ns.split('.') : []; var parent = this; obj = obj || {}; // ignore leading global if (parts[0] === 'F2') { parts = parts.slice(1); } // create namespaces for (var i = 0, len = parts.length; i < len; i++) { if (!parent[parts[i]]) { parent[parts[i]] = isFunc && i + 1 == len ? obj : {}; } parent = parent[parts[i]]; } // copy object into namespace if (!isFunc) { for (var prop in obj) { if (typeof parent[prop] === 'undefined' || overwrite) { parent[prop] = obj[prop]; } } } return parent; }
[ "function", "(", "ns", ",", "obj", ",", "overwrite", ")", "{", "var", "isFunc", "=", "typeof", "obj", "===", "'function'", ";", "var", "parts", "=", "ns", "?", "ns", ".", "split", "(", "'.'", ")", ":", "[", "]", ";", "var", "parent", "=", "this", ";", "obj", "=", "obj", "||", "{", "}", ";", "// ignore leading global", "if", "(", "parts", "[", "0", "]", "===", "'F2'", ")", "{", "parts", "=", "parts", ".", "slice", "(", "1", ")", ";", "}", "// create namespaces", "for", "(", "var", "i", "=", "0", ",", "len", "=", "parts", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "!", "parent", "[", "parts", "[", "i", "]", "]", ")", "{", "parent", "[", "parts", "[", "i", "]", "]", "=", "isFunc", "&&", "i", "+", "1", "==", "len", "?", "obj", ":", "{", "}", ";", "}", "parent", "=", "parent", "[", "parts", "[", "i", "]", "]", ";", "}", "// copy object into namespace", "if", "(", "!", "isFunc", ")", "{", "for", "(", "var", "prop", "in", "obj", ")", "{", "if", "(", "typeof", "parent", "[", "prop", "]", "===", "'undefined'", "||", "overwrite", ")", "{", "parent", "[", "prop", "]", "=", "obj", "[", "prop", "]", ";", "}", "}", "}", "return", "parent", ";", "}" ]
Creates a namespace on F2 and copies the contents of an object into that namespace optionally overwriting existing properties. @method extend @param {string} ns The namespace to create. Pass a falsy value to add properties to the F2 namespace directly. @param {object} obj The object to copy into the namespace. @param {bool} overwrite True if object properties should be overwritten @return {object} The created object
[ "Creates", "a", "namespace", "on", "F2", "and", "copies", "the", "contents", "of", "an", "object", "into", "that", "namespace", "optionally", "overwriting", "existing", "properties", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/F2.js#L160-L189
22,447
OpenF2/F2
sdk/src/F2.js
function(testObject) { var bIsNode = ( typeof Node === 'object' ? testObject instanceof Node : testObject && typeof testObject === 'object' && typeof testObject.nodeType === 'number' && typeof testObject.nodeName === 'string' ); var bIsElement = ( typeof HTMLElement === 'object' ? testObject instanceof HTMLElement : //DOM2 testObject && typeof testObject === 'object' && testObject.nodeType === 1 && typeof testObject.nodeName === 'string' ); return (bIsNode || bIsElement); }
javascript
function(testObject) { var bIsNode = ( typeof Node === 'object' ? testObject instanceof Node : testObject && typeof testObject === 'object' && typeof testObject.nodeType === 'number' && typeof testObject.nodeName === 'string' ); var bIsElement = ( typeof HTMLElement === 'object' ? testObject instanceof HTMLElement : //DOM2 testObject && typeof testObject === 'object' && testObject.nodeType === 1 && typeof testObject.nodeName === 'string' ); return (bIsNode || bIsElement); }
[ "function", "(", "testObject", ")", "{", "var", "bIsNode", "=", "(", "typeof", "Node", "===", "'object'", "?", "testObject", "instanceof", "Node", ":", "testObject", "&&", "typeof", "testObject", "===", "'object'", "&&", "typeof", "testObject", ".", "nodeType", "===", "'number'", "&&", "typeof", "testObject", ".", "nodeName", "===", "'string'", ")", ";", "var", "bIsElement", "=", "(", "typeof", "HTMLElement", "===", "'object'", "?", "testObject", "instanceof", "HTMLElement", ":", "//DOM2", "testObject", "&&", "typeof", "testObject", "===", "'object'", "&&", "testObject", ".", "nodeType", "===", "1", "&&", "typeof", "testObject", ".", "nodeName", "===", "'string'", ")", ";", "return", "(", "bIsNode", "||", "bIsElement", ")", ";", "}" ]
Utility method to determine whether or not the argument passed in is or is not a native dom node. @method isNativeDOMNode @param {object} testObject The object you want to check as native dom node. @return {bool} Returns true if the object passed is a native dom node.
[ "Utility", "method", "to", "determine", "whether", "or", "not", "the", "argument", "passed", "in", "is", "or", "is", "not", "a", "native", "dom", "node", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/F2.js#L262-L274
22,448
OpenF2/F2
dist/f2.basic.js
function(token, eventKey) // additional arguments will likely be passed { // will throw an exception and stop execution if the token is invalid if(token != _f2t) { throw ('Token passed is invalid. Only F2 is allowed to call F2.AppHandlers.__trigger().'); } if(_handlerCollection && _handlerCollection[eventKey]) { // create a collection of arguments that are safe to pass to the callback. var passableArgs = []; // populate that collection with all arguments except token and eventKey for(var i = 2, j = arguments.length; i < j; i++) { passableArgs.push(arguments[i]); } if(_handlerCollection[eventKey].length === 0 && _defaultMethods[eventKey]) { _defaultMethods[eventKey].apply(F2, passableArgs); return this; } else if(_handlerCollection[eventKey].length === 0 && !_handlerCollection[eventKey]) { return this; } // fire all event listeners in the order that they were added. for(var iCounter = 0, hcl = _handlerCollection[eventKey].length; iCounter < hcl; iCounter++) { var handler = _handlerCollection[eventKey][iCounter]; // appRender where root is already defined if (handler.domNode && arguments[2] && arguments[2].root && arguments[3]) { var $appRoot = jQuery(arguments[2].root).append(arguments[3]); jQuery(handler.domNode).append($appRoot); } else if (handler.domNode && arguments[2] && !arguments[2].root && arguments[3]) { // set the root to the actual HTML of the app arguments[2].root = jQuery(arguments[3]).get(0); // appends the root to the dom node specified jQuery(handler.domNode).append(arguments[2].root); } else { handler.func.apply(F2, passableArgs); } } } else { throw ('Invalid EventKey passed. Check your inputs and try again.'); } return this; }
javascript
function(token, eventKey) // additional arguments will likely be passed { // will throw an exception and stop execution if the token is invalid if(token != _f2t) { throw ('Token passed is invalid. Only F2 is allowed to call F2.AppHandlers.__trigger().'); } if(_handlerCollection && _handlerCollection[eventKey]) { // create a collection of arguments that are safe to pass to the callback. var passableArgs = []; // populate that collection with all arguments except token and eventKey for(var i = 2, j = arguments.length; i < j; i++) { passableArgs.push(arguments[i]); } if(_handlerCollection[eventKey].length === 0 && _defaultMethods[eventKey]) { _defaultMethods[eventKey].apply(F2, passableArgs); return this; } else if(_handlerCollection[eventKey].length === 0 && !_handlerCollection[eventKey]) { return this; } // fire all event listeners in the order that they were added. for(var iCounter = 0, hcl = _handlerCollection[eventKey].length; iCounter < hcl; iCounter++) { var handler = _handlerCollection[eventKey][iCounter]; // appRender where root is already defined if (handler.domNode && arguments[2] && arguments[2].root && arguments[3]) { var $appRoot = jQuery(arguments[2].root).append(arguments[3]); jQuery(handler.domNode).append($appRoot); } else if (handler.domNode && arguments[2] && !arguments[2].root && arguments[3]) { // set the root to the actual HTML of the app arguments[2].root = jQuery(arguments[3]).get(0); // appends the root to the dom node specified jQuery(handler.domNode).append(arguments[2].root); } else { handler.func.apply(F2, passableArgs); } } } else { throw ('Invalid EventKey passed. Check your inputs and try again.'); } return this; }
[ "function", "(", "token", ",", "eventKey", ")", "// additional arguments will likely be passed", "{", "// will throw an exception and stop execution if the token is invalid", "if", "(", "token", "!=", "_f2t", ")", "{", "throw", "(", "'Token passed is invalid. Only F2 is allowed to call F2.AppHandlers.__trigger().'", ")", ";", "}", "if", "(", "_handlerCollection", "&&", "_handlerCollection", "[", "eventKey", "]", ")", "{", "// create a collection of arguments that are safe to pass to the callback.", "var", "passableArgs", "=", "[", "]", ";", "// populate that collection with all arguments except token and eventKey", "for", "(", "var", "i", "=", "2", ",", "j", "=", "arguments", ".", "length", ";", "i", "<", "j", ";", "i", "++", ")", "{", "passableArgs", ".", "push", "(", "arguments", "[", "i", "]", ")", ";", "}", "if", "(", "_handlerCollection", "[", "eventKey", "]", ".", "length", "===", "0", "&&", "_defaultMethods", "[", "eventKey", "]", ")", "{", "_defaultMethods", "[", "eventKey", "]", ".", "apply", "(", "F2", ",", "passableArgs", ")", ";", "return", "this", ";", "}", "else", "if", "(", "_handlerCollection", "[", "eventKey", "]", ".", "length", "===", "0", "&&", "!", "_handlerCollection", "[", "eventKey", "]", ")", "{", "return", "this", ";", "}", "// fire all event listeners in the order that they were added.", "for", "(", "var", "iCounter", "=", "0", ",", "hcl", "=", "_handlerCollection", "[", "eventKey", "]", ".", "length", ";", "iCounter", "<", "hcl", ";", "iCounter", "++", ")", "{", "var", "handler", "=", "_handlerCollection", "[", "eventKey", "]", "[", "iCounter", "]", ";", "// appRender where root is already defined", "if", "(", "handler", ".", "domNode", "&&", "arguments", "[", "2", "]", "&&", "arguments", "[", "2", "]", ".", "root", "&&", "arguments", "[", "3", "]", ")", "{", "var", "$appRoot", "=", "jQuery", "(", "arguments", "[", "2", "]", ".", "root", ")", ".", "append", "(", "arguments", "[", "3", "]", ")", ";", "jQuery", "(", "handler", ".", "domNode", ")", ".", "append", "(", "$appRoot", ")", ";", "}", "else", "if", "(", "handler", ".", "domNode", "&&", "arguments", "[", "2", "]", "&&", "!", "arguments", "[", "2", "]", ".", "root", "&&", "arguments", "[", "3", "]", ")", "{", "// set the root to the actual HTML of the app", "arguments", "[", "2", "]", ".", "root", "=", "jQuery", "(", "arguments", "[", "3", "]", ")", ".", "get", "(", "0", ")", ";", "// appends the root to the dom node specified", "jQuery", "(", "handler", ".", "domNode", ")", ".", "append", "(", "arguments", "[", "2", "]", ".", "root", ")", ";", "}", "else", "{", "handler", ".", "func", ".", "apply", "(", "F2", ",", "passableArgs", ")", ";", "}", "}", "}", "else", "{", "throw", "(", "'Invalid EventKey passed. Check your inputs and try again.'", ")", ";", "}", "return", "this", ";", "}" ]
Allows F2 to trigger specific events internally. @method __trigger @private @chainable @param {String} token The token received from {{#crossLink "F2.AppHandlers/\_\_f2GetToken:method"}}{{/crossLink}}. @param {String} eventKey The event to fire. The complete list of event keys is available in {{#crossLink "F2.Constants.AppHandlers"}}{{/crossLink}}.
[ "Allows", "F2", "to", "trigger", "specific", "events", "internally", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L2094-L2153
22,449
OpenF2/F2
dist/f2.basic.js
function(appConfig, message, origin) { var obj, func; function parseFunction(parent, functionName) { var path = String(functionName).split('.'); for (var i = 0; i < path.length; i++) { if (parent[path[i]] === undefined) { parent = undefined; break; } parent = parent[path[i]]; } return parent; } function parseMessage(regEx, message, instanceId) { var o = F2.parse(message.replace(regEx, '')); // if obj.callbacks // for each callback // for each params // if callback matches param // replace param with _createRpcCallback(app.instanceId, callback) if (o.params && o.params.length && o.callbacks && o.callbacks.length) { jQuery.each(o.callbacks, function(i, c) { jQuery.each(o.params, function(i, p) { if (c == p) { o.params[i] = _createRpcCallback(instanceId, c); } }); }); } return o; } // handle UI Call if (_rUiCall.test(message)) { obj = parseMessage(_rUiCall, message, appConfig.instanceId); func = parseFunction(appConfig.ui, obj.functionName); // if we found the function, call it if (func !== undefined) { func.apply(appConfig.ui, obj.params); } else { F2.log('Unable to locate UI RPC function: ' + obj.functionName); } // handle RPC } else if (_rRpc.test(message)) { obj = parseMessage(_rRpc, message, appConfig.instanceId); func = parseFunction(window, obj.functionName); if (func !== undefined) { func.apply(func, obj.params); } else { F2.log('Unable to locate RPC function: ' + obj.functionName); } // handle RPC Callback } else if (_rRpcCallback.test(message)) { obj = parseMessage(_rRpcCallback, message, appConfig.instanceId); if (_callbacks[obj.functionName] !== undefined) { _callbacks[obj.functionName].apply(_callbacks[obj.functionName], obj.params); delete _callbacks[obj.functionName]; } // handle Events } else if (_rEvents.test(message)) { obj = parseMessage(_rEvents, message, appConfig.instanceId); F2.Events._socketEmit.apply(F2.Events, obj); } }
javascript
function(appConfig, message, origin) { var obj, func; function parseFunction(parent, functionName) { var path = String(functionName).split('.'); for (var i = 0; i < path.length; i++) { if (parent[path[i]] === undefined) { parent = undefined; break; } parent = parent[path[i]]; } return parent; } function parseMessage(regEx, message, instanceId) { var o = F2.parse(message.replace(regEx, '')); // if obj.callbacks // for each callback // for each params // if callback matches param // replace param with _createRpcCallback(app.instanceId, callback) if (o.params && o.params.length && o.callbacks && o.callbacks.length) { jQuery.each(o.callbacks, function(i, c) { jQuery.each(o.params, function(i, p) { if (c == p) { o.params[i] = _createRpcCallback(instanceId, c); } }); }); } return o; } // handle UI Call if (_rUiCall.test(message)) { obj = parseMessage(_rUiCall, message, appConfig.instanceId); func = parseFunction(appConfig.ui, obj.functionName); // if we found the function, call it if (func !== undefined) { func.apply(appConfig.ui, obj.params); } else { F2.log('Unable to locate UI RPC function: ' + obj.functionName); } // handle RPC } else if (_rRpc.test(message)) { obj = parseMessage(_rRpc, message, appConfig.instanceId); func = parseFunction(window, obj.functionName); if (func !== undefined) { func.apply(func, obj.params); } else { F2.log('Unable to locate RPC function: ' + obj.functionName); } // handle RPC Callback } else if (_rRpcCallback.test(message)) { obj = parseMessage(_rRpcCallback, message, appConfig.instanceId); if (_callbacks[obj.functionName] !== undefined) { _callbacks[obj.functionName].apply(_callbacks[obj.functionName], obj.params); delete _callbacks[obj.functionName]; } // handle Events } else if (_rEvents.test(message)) { obj = parseMessage(_rEvents, message, appConfig.instanceId); F2.Events._socketEmit.apply(F2.Events, obj); } }
[ "function", "(", "appConfig", ",", "message", ",", "origin", ")", "{", "var", "obj", ",", "func", ";", "function", "parseFunction", "(", "parent", ",", "functionName", ")", "{", "var", "path", "=", "String", "(", "functionName", ")", ".", "split", "(", "'.'", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "path", ".", "length", ";", "i", "++", ")", "{", "if", "(", "parent", "[", "path", "[", "i", "]", "]", "===", "undefined", ")", "{", "parent", "=", "undefined", ";", "break", ";", "}", "parent", "=", "parent", "[", "path", "[", "i", "]", "]", ";", "}", "return", "parent", ";", "}", "function", "parseMessage", "(", "regEx", ",", "message", ",", "instanceId", ")", "{", "var", "o", "=", "F2", ".", "parse", "(", "message", ".", "replace", "(", "regEx", ",", "''", ")", ")", ";", "// if obj.callbacks", "// for each callback", "// for each params", "// if callback matches param", "// replace param with _createRpcCallback(app.instanceId, callback)", "if", "(", "o", ".", "params", "&&", "o", ".", "params", ".", "length", "&&", "o", ".", "callbacks", "&&", "o", ".", "callbacks", ".", "length", ")", "{", "jQuery", ".", "each", "(", "o", ".", "callbacks", ",", "function", "(", "i", ",", "c", ")", "{", "jQuery", ".", "each", "(", "o", ".", "params", ",", "function", "(", "i", ",", "p", ")", "{", "if", "(", "c", "==", "p", ")", "{", "o", ".", "params", "[", "i", "]", "=", "_createRpcCallback", "(", "instanceId", ",", "c", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}", "return", "o", ";", "}", "// handle UI Call", "if", "(", "_rUiCall", ".", "test", "(", "message", ")", ")", "{", "obj", "=", "parseMessage", "(", "_rUiCall", ",", "message", ",", "appConfig", ".", "instanceId", ")", ";", "func", "=", "parseFunction", "(", "appConfig", ".", "ui", ",", "obj", ".", "functionName", ")", ";", "// if we found the function, call it", "if", "(", "func", "!==", "undefined", ")", "{", "func", ".", "apply", "(", "appConfig", ".", "ui", ",", "obj", ".", "params", ")", ";", "}", "else", "{", "F2", ".", "log", "(", "'Unable to locate UI RPC function: '", "+", "obj", ".", "functionName", ")", ";", "}", "// handle RPC", "}", "else", "if", "(", "_rRpc", ".", "test", "(", "message", ")", ")", "{", "obj", "=", "parseMessage", "(", "_rRpc", ",", "message", ",", "appConfig", ".", "instanceId", ")", ";", "func", "=", "parseFunction", "(", "window", ",", "obj", ".", "functionName", ")", ";", "if", "(", "func", "!==", "undefined", ")", "{", "func", ".", "apply", "(", "func", ",", "obj", ".", "params", ")", ";", "}", "else", "{", "F2", ".", "log", "(", "'Unable to locate RPC function: '", "+", "obj", ".", "functionName", ")", ";", "}", "// handle RPC Callback", "}", "else", "if", "(", "_rRpcCallback", ".", "test", "(", "message", ")", ")", "{", "obj", "=", "parseMessage", "(", "_rRpcCallback", ",", "message", ",", "appConfig", ".", "instanceId", ")", ";", "if", "(", "_callbacks", "[", "obj", ".", "functionName", "]", "!==", "undefined", ")", "{", "_callbacks", "[", "obj", ".", "functionName", "]", ".", "apply", "(", "_callbacks", "[", "obj", ".", "functionName", "]", ",", "obj", ".", "params", ")", ";", "delete", "_callbacks", "[", "obj", ".", "functionName", "]", ";", "}", "// handle Events", "}", "else", "if", "(", "_rEvents", ".", "test", "(", "message", ")", ")", "{", "obj", "=", "parseMessage", "(", "_rEvents", ",", "message", ",", "appConfig", ".", "instanceId", ")", ";", "F2", ".", "Events", ".", "_socketEmit", ".", "apply", "(", "F2", ".", "Events", ",", "obj", ")", ";", "}", "}" ]
Handles messages that come across the sockets @method _onMessage @private @param {F2.AppConfig} appConfig The F2.AppConfig object @param {string} message The socket message @param {string} origin The originator
[ "Handles", "messages", "that", "come", "across", "the", "sockets" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L3602-L3673
22,450
OpenF2/F2
dist/f2.basic.js
function(messageType, params) { // check valid messageType var message = messageType + F2.stringify(params); jQuery.each(_apps, function(i, a) { a.socket.postMessage(message); }); }
javascript
function(messageType, params) { // check valid messageType var message = messageType + F2.stringify(params); jQuery.each(_apps, function(i, a) { a.socket.postMessage(message); }); }
[ "function", "(", "messageType", ",", "params", ")", "{", "// check valid messageType", "var", "message", "=", "messageType", "+", "F2", ".", "stringify", "(", "params", ")", ";", "jQuery", ".", "each", "(", "_apps", ",", "function", "(", "i", ",", "a", ")", "{", "a", ".", "socket", ".", "postMessage", "(", "message", ")", ";", "}", ")", ";", "}" ]
Broadcast an RPC function to all sockets @method broadcast @param {string} messageType The message type @param {Array} params The parameters to broadcast
[ "Broadcast", "an", "RPC", "function", "to", "all", "sockets" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L3695-L3701
22,451
OpenF2/F2
dist/f2.basic.js
function(instanceId, messageType, functionName, params) { // loop through params and find functions and convert them to callbacks var callbacks = []; jQuery.each(params, function(i, e) { if (typeof e === 'function') { var cid = _registerCallback(e); params[i] = cid; callbacks.push(cid); } }); // check valid messageType _apps[instanceId].socket.postMessage( messageType + F2.stringify({ functionName:functionName, params:params, callbacks:callbacks }) ); }
javascript
function(instanceId, messageType, functionName, params) { // loop through params and find functions and convert them to callbacks var callbacks = []; jQuery.each(params, function(i, e) { if (typeof e === 'function') { var cid = _registerCallback(e); params[i] = cid; callbacks.push(cid); } }); // check valid messageType _apps[instanceId].socket.postMessage( messageType + F2.stringify({ functionName:functionName, params:params, callbacks:callbacks }) ); }
[ "function", "(", "instanceId", ",", "messageType", ",", "functionName", ",", "params", ")", "{", "// loop through params and find functions and convert them to callbacks", "var", "callbacks", "=", "[", "]", ";", "jQuery", ".", "each", "(", "params", ",", "function", "(", "i", ",", "e", ")", "{", "if", "(", "typeof", "e", "===", "'function'", ")", "{", "var", "cid", "=", "_registerCallback", "(", "e", ")", ";", "params", "[", "i", "]", "=", "cid", ";", "callbacks", ".", "push", "(", "cid", ")", ";", "}", "}", ")", ";", "// check valid messageType", "_apps", "[", "instanceId", "]", ".", "socket", ".", "postMessage", "(", "messageType", "+", "F2", ".", "stringify", "(", "{", "functionName", ":", "functionName", ",", "params", ":", "params", ",", "callbacks", ":", "callbacks", "}", ")", ")", ";", "}" ]
Calls a remote function @method call @param {string} instanceId The app's Instance ID @param {string} messageType The message type @param {string} functionName The name of the remote function @param {Array} params An array of parameters to pass to the remote function. Any functions found within the params will be treated as a callback function.
[ "Calls", "a", "remote", "function" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L3712-L3730
22,452
OpenF2/F2
dist/f2.basic.js
function(instanceId) { return ( // we have an app _apps[instanceId] !== undefined && // the app is secure _apps[instanceId].config.isSecure && // we can't access the iframe jQuery(_apps[instanceId].config.root).find('iframe').length === 0 ); }
javascript
function(instanceId) { return ( // we have an app _apps[instanceId] !== undefined && // the app is secure _apps[instanceId].config.isSecure && // we can't access the iframe jQuery(_apps[instanceId].config.root).find('iframe').length === 0 ); }
[ "function", "(", "instanceId", ")", "{", "return", "(", "// we have an app", "_apps", "[", "instanceId", "]", "!==", "undefined", "&&", "// the app is secure", "_apps", "[", "instanceId", "]", ".", "config", ".", "isSecure", "&&", "// we can't access the iframe", "jQuery", "(", "_apps", "[", "instanceId", "]", ".", "config", ".", "root", ")", ".", "find", "(", "'iframe'", ")", ".", "length", "===", "0", ")", ";", "}" ]
Determines whether the Instance ID is considered to be 'remote'. This is determined by checking if 1) the app has an open socket and 2) whether F2.Rpc is running inside of an iframe @method isRemote @param {string} instanceId The Instance ID @return {bool} True if there is an open socket
[ "Determines", "whether", "the", "Instance", "ID", "is", "considered", "to", "be", "remote", ".", "This", "is", "determined", "by", "checking", "if", "1", ")", "the", "app", "has", "an", "open", "socket", "and", "2", ")", "whether", "F2", ".", "Rpc", "is", "running", "inside", "of", "an", "iframe" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L3756-L3765
22,453
OpenF2/F2
dist/f2.basic.js
function(appConfig, appManifest) { if (!!appConfig && !!appManifest) { _apps[appConfig.instanceId] = { config:appConfig, socket:_createContainerToAppSocket(appConfig, appManifest) }; } else { F2.log('Unable to register socket connection. Please check container configuration.'); } }
javascript
function(appConfig, appManifest) { if (!!appConfig && !!appManifest) { _apps[appConfig.instanceId] = { config:appConfig, socket:_createContainerToAppSocket(appConfig, appManifest) }; } else { F2.log('Unable to register socket connection. Please check container configuration.'); } }
[ "function", "(", "appConfig", ",", "appManifest", ")", "{", "if", "(", "!", "!", "appConfig", "&&", "!", "!", "appManifest", ")", "{", "_apps", "[", "appConfig", ".", "instanceId", "]", "=", "{", "config", ":", "appConfig", ",", "socket", ":", "_createContainerToAppSocket", "(", "appConfig", ",", "appManifest", ")", "}", ";", "}", "else", "{", "F2", ".", "log", "(", "'Unable to register socket connection. Please check container configuration.'", ")", ";", "}", "}" ]
Creates a container-to-app or app-to-container socket for communication @method register @param {F2.AppConfig} [appConfig] The F2.AppConfig object @param {F2.AppManifest} [appManifest] The F2.AppManifest object
[ "Creates", "a", "container", "-", "to", "-", "app", "or", "app", "-", "to", "-", "container", "socket", "for", "communication" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L3773-L3782
22,454
OpenF2/F2
dist/f2.basic.js
function(message, callback) { if (!F2.isInit()) { F2.log('F2.init() must be called before F2.UI.Modals.alert()'); return; } if (F2.Rpc.isRemote(_appConfig.instanceId)) { F2.Rpc.call( _appConfig.instanceId, F2.Constants.Sockets.UI_RPC, 'Modals.alert', [].slice.call(arguments) ); } else { // display the alert jQuery(_renderAlert(message)) .on('show.bs.modal', function() { var modal = this; jQuery(modal).find('.btn-primary').on('click', function() { jQuery(modal).modal('hide').remove(); (callback || jQuery.noop)(); }); }) .modal({backdrop:true}); } }
javascript
function(message, callback) { if (!F2.isInit()) { F2.log('F2.init() must be called before F2.UI.Modals.alert()'); return; } if (F2.Rpc.isRemote(_appConfig.instanceId)) { F2.Rpc.call( _appConfig.instanceId, F2.Constants.Sockets.UI_RPC, 'Modals.alert', [].slice.call(arguments) ); } else { // display the alert jQuery(_renderAlert(message)) .on('show.bs.modal', function() { var modal = this; jQuery(modal).find('.btn-primary').on('click', function() { jQuery(modal).modal('hide').remove(); (callback || jQuery.noop)(); }); }) .modal({backdrop:true}); } }
[ "function", "(", "message", ",", "callback", ")", "{", "if", "(", "!", "F2", ".", "isInit", "(", ")", ")", "{", "F2", ".", "log", "(", "'F2.init() must be called before F2.UI.Modals.alert()'", ")", ";", "return", ";", "}", "if", "(", "F2", ".", "Rpc", ".", "isRemote", "(", "_appConfig", ".", "instanceId", ")", ")", "{", "F2", ".", "Rpc", ".", "call", "(", "_appConfig", ".", "instanceId", ",", "F2", ".", "Constants", ".", "Sockets", ".", "UI_RPC", ",", "'Modals.alert'", ",", "[", "]", ".", "slice", ".", "call", "(", "arguments", ")", ")", ";", "}", "else", "{", "// display the alert", "jQuery", "(", "_renderAlert", "(", "message", ")", ")", ".", "on", "(", "'show.bs.modal'", ",", "function", "(", ")", "{", "var", "modal", "=", "this", ";", "jQuery", "(", "modal", ")", ".", "find", "(", "'.btn-primary'", ")", ".", "on", "(", "'click'", ",", "function", "(", ")", "{", "jQuery", "(", "modal", ")", ".", "modal", "(", "'hide'", ")", ".", "remove", "(", ")", ";", "(", "callback", "||", "jQuery", ".", "noop", ")", "(", ")", ";", "}", ")", ";", "}", ")", ".", "modal", "(", "{", "backdrop", ":", "true", "}", ")", ";", "}", "}" ]
Display an alert message on the page @method alert @param {string} message The message to be displayed @param {function} [callback] The callback to be fired when the user closes the dialog @for F2.UI.Modals
[ "Display", "an", "alert", "message", "on", "the", "page" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L3875-L3901
22,455
OpenF2/F2
dist/f2.basic.js
function(message, okCallback, cancelCallback) { if (!F2.isInit()) { F2.log('F2.init() must be called before F2.UI.Modals.confirm()'); return; } if (F2.Rpc.isRemote(_appConfig.instanceId)) { F2.Rpc.call( _appConfig.instanceId, F2.Constants.Sockets.UI_RPC, 'Modals.confirm', [].slice.call(arguments) ); } else { // display the alert jQuery(_renderConfirm(message)) .on('show.bs.modal', function() { var modal = this; jQuery(modal).find('.btn-ok').on('click', function() { jQuery(modal).modal('hide').remove(); (okCallback || jQuery.noop)(); }); jQuery(modal).find('.btn-cancel').on('click', function() { jQuery(modal).modal('hide').remove(); (cancelCallback || jQuery.noop)(); }); }) .modal({backdrop:true}); } }
javascript
function(message, okCallback, cancelCallback) { if (!F2.isInit()) { F2.log('F2.init() must be called before F2.UI.Modals.confirm()'); return; } if (F2.Rpc.isRemote(_appConfig.instanceId)) { F2.Rpc.call( _appConfig.instanceId, F2.Constants.Sockets.UI_RPC, 'Modals.confirm', [].slice.call(arguments) ); } else { // display the alert jQuery(_renderConfirm(message)) .on('show.bs.modal', function() { var modal = this; jQuery(modal).find('.btn-ok').on('click', function() { jQuery(modal).modal('hide').remove(); (okCallback || jQuery.noop)(); }); jQuery(modal).find('.btn-cancel').on('click', function() { jQuery(modal).modal('hide').remove(); (cancelCallback || jQuery.noop)(); }); }) .modal({backdrop:true}); } }
[ "function", "(", "message", ",", "okCallback", ",", "cancelCallback", ")", "{", "if", "(", "!", "F2", ".", "isInit", "(", ")", ")", "{", "F2", ".", "log", "(", "'F2.init() must be called before F2.UI.Modals.confirm()'", ")", ";", "return", ";", "}", "if", "(", "F2", ".", "Rpc", ".", "isRemote", "(", "_appConfig", ".", "instanceId", ")", ")", "{", "F2", ".", "Rpc", ".", "call", "(", "_appConfig", ".", "instanceId", ",", "F2", ".", "Constants", ".", "Sockets", ".", "UI_RPC", ",", "'Modals.confirm'", ",", "[", "]", ".", "slice", ".", "call", "(", "arguments", ")", ")", ";", "}", "else", "{", "// display the alert", "jQuery", "(", "_renderConfirm", "(", "message", ")", ")", ".", "on", "(", "'show.bs.modal'", ",", "function", "(", ")", "{", "var", "modal", "=", "this", ";", "jQuery", "(", "modal", ")", ".", "find", "(", "'.btn-ok'", ")", ".", "on", "(", "'click'", ",", "function", "(", ")", "{", "jQuery", "(", "modal", ")", ".", "modal", "(", "'hide'", ")", ".", "remove", "(", ")", ";", "(", "okCallback", "||", "jQuery", ".", "noop", ")", "(", ")", ";", "}", ")", ";", "jQuery", "(", "modal", ")", ".", "find", "(", "'.btn-cancel'", ")", ".", "on", "(", "'click'", ",", "function", "(", ")", "{", "jQuery", "(", "modal", ")", ".", "modal", "(", "'hide'", ")", ".", "remove", "(", ")", ";", "(", "cancelCallback", "||", "jQuery", ".", "noop", ")", "(", ")", ";", "}", ")", ";", "}", ")", ".", "modal", "(", "{", "backdrop", ":", "true", "}", ")", ";", "}", "}" ]
Display a confirm message on the page @method confirm @param {string} message The message to be displayed @param {function} okCallback The function that will be called when the OK button is pressed @param {function} cancelCallback The function that will be called when the Cancel button is pressed @for F2.UI.Modals
[ "Display", "a", "confirm", "message", "on", "the", "page" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L3912-L3944
22,456
OpenF2/F2
dist/f2.basic.js
function(title) { if (F2.Rpc.isRemote(_appConfig.instanceId)) { F2.Rpc.call( _appConfig.instanceId, F2.Constants.Sockets.UI_RPC, 'setTitle', [ title ] ); } else { jQuery(_appConfig.root).find('.' + F2.Constants.Css.APP_TITLE).text(title); } }
javascript
function(title) { if (F2.Rpc.isRemote(_appConfig.instanceId)) { F2.Rpc.call( _appConfig.instanceId, F2.Constants.Sockets.UI_RPC, 'setTitle', [ title ] ); } else { jQuery(_appConfig.root).find('.' + F2.Constants.Css.APP_TITLE).text(title); } }
[ "function", "(", "title", ")", "{", "if", "(", "F2", ".", "Rpc", ".", "isRemote", "(", "_appConfig", ".", "instanceId", ")", ")", "{", "F2", ".", "Rpc", ".", "call", "(", "_appConfig", ".", "instanceId", ",", "F2", ".", "Constants", ".", "Sockets", ".", "UI_RPC", ",", "'setTitle'", ",", "[", "title", "]", ")", ";", "}", "else", "{", "jQuery", "(", "_appConfig", ".", "root", ")", ".", "find", "(", "'.'", "+", "F2", ".", "Constants", ".", "Css", ".", "APP_TITLE", ")", ".", "text", "(", "title", ")", ";", "}", "}" ]
Sets the title of the app as shown in the browser. Depending on the container HTML, this method may do nothing if the container has not been configured properly or else the container provider does not allow Title's to be set. @method setTitle @params {string} title The title of the app @for F2.UI
[ "Sets", "the", "title", "of", "the", "app", "as", "shown", "in", "the", "browser", ".", "Depending", "on", "the", "container", "HTML", "this", "method", "may", "do", "nothing", "if", "the", "container", "has", "not", "been", "configured", "properly", "or", "else", "the", "container", "provider", "does", "not", "allow", "Title", "s", "to", "be", "set", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L3956-L3970
22,457
OpenF2/F2
dist/f2.basic.js
function(input) { if (typeof input === 'function') { this.on('change', input); } else if (typeof input === 'string') { if (_appConfig.isSecure && !F2.Rpc.isRemote(_appConfig.instanceId)) { F2.Rpc.call( _appConfig.instanceId, F2.Constants.Sockets.UI_RPC, 'Views.change', [].slice.call(arguments) ); } else if (F2.inArray(input, _appConfig.views)) { jQuery('.' + F2.Constants.Css.APP_VIEW, $root) .addClass('hide') .filter('[data-f2-view="' + input + '"]', $root) .removeClass('hide'); _updateHeight(); _events.emit('change', input); } } }
javascript
function(input) { if (typeof input === 'function') { this.on('change', input); } else if (typeof input === 'string') { if (_appConfig.isSecure && !F2.Rpc.isRemote(_appConfig.instanceId)) { F2.Rpc.call( _appConfig.instanceId, F2.Constants.Sockets.UI_RPC, 'Views.change', [].slice.call(arguments) ); } else if (F2.inArray(input, _appConfig.views)) { jQuery('.' + F2.Constants.Css.APP_VIEW, $root) .addClass('hide') .filter('[data-f2-view="' + input + '"]', $root) .removeClass('hide'); _updateHeight(); _events.emit('change', input); } } }
[ "function", "(", "input", ")", "{", "if", "(", "typeof", "input", "===", "'function'", ")", "{", "this", ".", "on", "(", "'change'", ",", "input", ")", ";", "}", "else", "if", "(", "typeof", "input", "===", "'string'", ")", "{", "if", "(", "_appConfig", ".", "isSecure", "&&", "!", "F2", ".", "Rpc", ".", "isRemote", "(", "_appConfig", ".", "instanceId", ")", ")", "{", "F2", ".", "Rpc", ".", "call", "(", "_appConfig", ".", "instanceId", ",", "F2", ".", "Constants", ".", "Sockets", ".", "UI_RPC", ",", "'Views.change'", ",", "[", "]", ".", "slice", ".", "call", "(", "arguments", ")", ")", ";", "}", "else", "if", "(", "F2", ".", "inArray", "(", "input", ",", "_appConfig", ".", "views", ")", ")", "{", "jQuery", "(", "'.'", "+", "F2", ".", "Constants", ".", "Css", ".", "APP_VIEW", ",", "$root", ")", ".", "addClass", "(", "'hide'", ")", ".", "filter", "(", "'[data-f2-view=\"'", "+", "input", "+", "'\"]'", ",", "$root", ")", ".", "removeClass", "(", "'hide'", ")", ";", "_updateHeight", "(", ")", ";", "_events", ".", "emit", "(", "'change'", ",", "input", ")", ";", "}", "}", "}" ]
Change the current view for the app or add an event listener @method change @param {string|function} [input] If a string is passed in, the view will be changed for the app. If a function is passed in, a change event listener will be added. @for F2.UI.Views
[ "Change", "the", "current", "view", "for", "the", "app", "or", "add", "an", "event", "listener" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4020-L4043
22,458
OpenF2/F2
dist/f2.basic.js
function(appConfig, html) { var handler = _config.afterAppRender || function(appConfig, html) { return jQuery(html).appendTo('body'); }; var appContainer = handler(appConfig, html); if ( !! _config.afterAppRender && !appContainer) { F2.log('F2.ContainerConfig.afterAppRender() must return the DOM Element that contains the app'); return; } else { // apply APP class jQuery(appContainer).addClass(F2.Constants.Css.APP); return appContainer.get(0); } }
javascript
function(appConfig, html) { var handler = _config.afterAppRender || function(appConfig, html) { return jQuery(html).appendTo('body'); }; var appContainer = handler(appConfig, html); if ( !! _config.afterAppRender && !appContainer) { F2.log('F2.ContainerConfig.afterAppRender() must return the DOM Element that contains the app'); return; } else { // apply APP class jQuery(appContainer).addClass(F2.Constants.Css.APP); return appContainer.get(0); } }
[ "function", "(", "appConfig", ",", "html", ")", "{", "var", "handler", "=", "_config", ".", "afterAppRender", "||", "function", "(", "appConfig", ",", "html", ")", "{", "return", "jQuery", "(", "html", ")", ".", "appendTo", "(", "'body'", ")", ";", "}", ";", "var", "appContainer", "=", "handler", "(", "appConfig", ",", "html", ")", ";", "if", "(", "!", "!", "_config", ".", "afterAppRender", "&&", "!", "appContainer", ")", "{", "F2", ".", "log", "(", "'F2.ContainerConfig.afterAppRender() must return the DOM Element that contains the app'", ")", ";", "return", ";", "}", "else", "{", "// apply APP class", "jQuery", "(", "appContainer", ")", ".", "addClass", "(", "F2", ".", "Constants", ".", "Css", ".", "APP", ")", ";", "return", "appContainer", ".", "get", "(", "0", ")", ";", "}", "}" ]
Appends the app's html to the DOM @method _afterAppRender @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0 @private @param {F2.AppConfig} appConfig The F2.AppConfig object @param {string} html The string of html @return {Element} The DOM Element that contains the app
[ "Appends", "the", "app", "s", "html", "to", "the", "DOM" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4227-L4243
22,459
OpenF2/F2
dist/f2.basic.js
function(appConfig, html) { // apply APP_CONTAINER class and AppID html = _outerHtml(jQuery(html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfig.appId)); // optionally apply wrapper html if (_config.appRender) { html = _config.appRender(appConfig, html); } return _outerHtml(html); }
javascript
function(appConfig, html) { // apply APP_CONTAINER class and AppID html = _outerHtml(jQuery(html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfig.appId)); // optionally apply wrapper html if (_config.appRender) { html = _config.appRender(appConfig, html); } return _outerHtml(html); }
[ "function", "(", "appConfig", ",", "html", ")", "{", "// apply APP_CONTAINER class and AppID", "html", "=", "_outerHtml", "(", "jQuery", "(", "html", ")", ".", "addClass", "(", "F2", ".", "Constants", ".", "Css", ".", "APP_CONTAINER", "+", "' '", "+", "appConfig", ".", "appId", ")", ")", ";", "// optionally apply wrapper html", "if", "(", "_config", ".", "appRender", ")", "{", "html", "=", "_config", ".", "appRender", "(", "appConfig", ",", "html", ")", ";", "}", "return", "_outerHtml", "(", "html", ")", ";", "}" ]
Renders the html for an app. @method _appRender @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0 @private @param {F2.AppConfig} appConfig The F2.AppConfig object @param {string} html The string of html
[ "Renders", "the", "html", "for", "an", "app", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4253-L4264
22,460
OpenF2/F2
dist/f2.basic.js
function(appConfig, scriptInfo) { var handler = _config.appScriptLoadFailed || jQuery.noop; return handler(appConfig, scriptInfo); }
javascript
function(appConfig, scriptInfo) { var handler = _config.appScriptLoadFailed || jQuery.noop; return handler(appConfig, scriptInfo); }
[ "function", "(", "appConfig", ",", "scriptInfo", ")", "{", "var", "handler", "=", "_config", ".", "appScriptLoadFailed", "||", "jQuery", ".", "noop", ";", "return", "handler", "(", "appConfig", ",", "scriptInfo", ")", ";", "}" ]
Handler to inform the container that a script failed to load @method _onScriptLoadFailure @deprecated This has been replaced with {{#crossLink "F2.AppHandlers"}}{{/crossLink}} and will be removed in v2.0 @private @param {F2.AppConfig} appConfig The F2.AppConfig object @param scriptInfo The path of the script that failed to load or the exception info for the inline script that failed to execute
[ "Handler", "to", "inform", "the", "container", "that", "a", "script", "failed", "to", "load" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4289-L4292
22,461
OpenF2/F2
dist/f2.basic.js
function(appConfig) { // make a copy of the app config to ensure that the original is not modified appConfig = jQuery.extend(true, {}, appConfig); // create the instanceId for the app appConfig.instanceId = appConfig.instanceId || F2.guid(); // default the views if not provided appConfig.views = appConfig.views || []; if (!F2.inArray(F2.Constants.Views.HOME, appConfig.views)) { appConfig.views.push(F2.Constants.Views.HOME); } //pass container-defined locale to each app if (F2.ContainerConfig.locale){ appConfig.containerLocale = F2.ContainerConfig.locale; } return appConfig; }
javascript
function(appConfig) { // make a copy of the app config to ensure that the original is not modified appConfig = jQuery.extend(true, {}, appConfig); // create the instanceId for the app appConfig.instanceId = appConfig.instanceId || F2.guid(); // default the views if not provided appConfig.views = appConfig.views || []; if (!F2.inArray(F2.Constants.Views.HOME, appConfig.views)) { appConfig.views.push(F2.Constants.Views.HOME); } //pass container-defined locale to each app if (F2.ContainerConfig.locale){ appConfig.containerLocale = F2.ContainerConfig.locale; } return appConfig; }
[ "function", "(", "appConfig", ")", "{", "// make a copy of the app config to ensure that the original is not modified", "appConfig", "=", "jQuery", ".", "extend", "(", "true", ",", "{", "}", ",", "appConfig", ")", ";", "// create the instanceId for the app", "appConfig", ".", "instanceId", "=", "appConfig", ".", "instanceId", "||", "F2", ".", "guid", "(", ")", ";", "// default the views if not provided", "appConfig", ".", "views", "=", "appConfig", ".", "views", "||", "[", "]", ";", "if", "(", "!", "F2", ".", "inArray", "(", "F2", ".", "Constants", ".", "Views", ".", "HOME", ",", "appConfig", ".", "views", ")", ")", "{", "appConfig", ".", "views", ".", "push", "(", "F2", ".", "Constants", ".", "Views", ".", "HOME", ")", ";", "}", "//pass container-defined locale to each app", "if", "(", "F2", ".", "ContainerConfig", ".", "locale", ")", "{", "appConfig", ".", "containerLocale", "=", "F2", ".", "ContainerConfig", ".", "locale", ";", "}", "return", "appConfig", ";", "}" ]
Adds properties to the AppConfig object @method _createAppConfig @private @param {F2.AppConfig} appConfig The F2.AppConfig object @return {F2.AppConfig} The new F2.AppConfig object, prepopulated with necessary properties
[ "Adds", "properties", "to", "the", "AppConfig", "object" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4302-L4322
22,462
OpenF2/F2
dist/f2.basic.js
function(node) { var appConfig; if (node) { var appId = node.getAttribute('data-f2-appid'); var manifestUrl = node.getAttribute('data-f2-manifesturl'); if (appId && manifestUrl) { appConfig = { appId: appId, enableBatchRequests: node.hasAttribute('data-f2-enablebatchrequests'), isSecure: node.hasAttribute('data-f2-issecure'), manifestUrl: manifestUrl, root: node }; // See if the user passed in a block of serialized json var contextJson = node.getAttribute('data-f2-context'); if (contextJson) { try { appConfig.context = F2.parse(contextJson); } catch (e) { console.warn('F2: "data-f2-context" of node is not valid JSON', '"' + e + '"'); } } } } return appConfig; }
javascript
function(node) { var appConfig; if (node) { var appId = node.getAttribute('data-f2-appid'); var manifestUrl = node.getAttribute('data-f2-manifesturl'); if (appId && manifestUrl) { appConfig = { appId: appId, enableBatchRequests: node.hasAttribute('data-f2-enablebatchrequests'), isSecure: node.hasAttribute('data-f2-issecure'), manifestUrl: manifestUrl, root: node }; // See if the user passed in a block of serialized json var contextJson = node.getAttribute('data-f2-context'); if (contextJson) { try { appConfig.context = F2.parse(contextJson); } catch (e) { console.warn('F2: "data-f2-context" of node is not valid JSON', '"' + e + '"'); } } } } return appConfig; }
[ "function", "(", "node", ")", "{", "var", "appConfig", ";", "if", "(", "node", ")", "{", "var", "appId", "=", "node", ".", "getAttribute", "(", "'data-f2-appid'", ")", ";", "var", "manifestUrl", "=", "node", ".", "getAttribute", "(", "'data-f2-manifesturl'", ")", ";", "if", "(", "appId", "&&", "manifestUrl", ")", "{", "appConfig", "=", "{", "appId", ":", "appId", ",", "enableBatchRequests", ":", "node", ".", "hasAttribute", "(", "'data-f2-enablebatchrequests'", ")", ",", "isSecure", ":", "node", ".", "hasAttribute", "(", "'data-f2-issecure'", ")", ",", "manifestUrl", ":", "manifestUrl", ",", "root", ":", "node", "}", ";", "// See if the user passed in a block of serialized json", "var", "contextJson", "=", "node", ".", "getAttribute", "(", "'data-f2-context'", ")", ";", "if", "(", "contextJson", ")", "{", "try", "{", "appConfig", ".", "context", "=", "F2", ".", "parse", "(", "contextJson", ")", ";", "}", "catch", "(", "e", ")", "{", "console", ".", "warn", "(", "'F2: \"data-f2-context\" of node is not valid JSON'", ",", "'\"'", "+", "e", "+", "'\"'", ")", ";", "}", "}", "}", "}", "return", "appConfig", ";", "}" ]
Generate an AppConfig from the element's attributes @method _getAppConfigFromElement @private @param {Element} node The DOM node from which to generate the F2.AppConfig object @return {F2.AppConfig} The new F2.AppConfig object
[ "Generate", "an", "AppConfig", "from", "the", "element", "s", "attributes" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4331-L4362
22,463
OpenF2/F2
dist/f2.basic.js
function(node) { var hasNodes = false; if (node.hasChildNodes()) { for (var i = 0, len = node.childNodes.length; i < len; i++) { if (node.childNodes[i].nodeType === 1) { hasNodes = true; break; } } } return hasNodes; }
javascript
function(node) { var hasNodes = false; if (node.hasChildNodes()) { for (var i = 0, len = node.childNodes.length; i < len; i++) { if (node.childNodes[i].nodeType === 1) { hasNodes = true; break; } } } return hasNodes; }
[ "function", "(", "node", ")", "{", "var", "hasNodes", "=", "false", ";", "if", "(", "node", ".", "hasChildNodes", "(", ")", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "node", ".", "childNodes", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "if", "(", "node", ".", "childNodes", "[", "i", "]", ".", "nodeType", "===", "1", ")", "{", "hasNodes", "=", "true", ";", "break", ";", "}", "}", "}", "return", "hasNodes", ";", "}" ]
Returns true if the DOM node has children that are not text nodes @method _hasNonTextChildNodes @private @param {Element} node The DOM node @return {bool} True if there are non-text children
[ "Returns", "true", "if", "the", "DOM", "node", "has", "children", "that", "are", "not", "text", "nodes" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4371-L4384
22,464
OpenF2/F2
dist/f2.basic.js
function(containerConfig) { if (!containerConfig.scriptErrorTimeout) { containerConfig.scriptErrorTimeout = F2.ContainerConfig.scriptErrorTimeout; } if (containerConfig.debugMode !== true) { containerConfig.debugMode = F2.ContainerConfig.debugMode; } if (containerConfig.locale && typeof containerConfig.locale == 'string'){ F2.ContainerConfig.locale = containerConfig.locale; } }
javascript
function(containerConfig) { if (!containerConfig.scriptErrorTimeout) { containerConfig.scriptErrorTimeout = F2.ContainerConfig.scriptErrorTimeout; } if (containerConfig.debugMode !== true) { containerConfig.debugMode = F2.ContainerConfig.debugMode; } if (containerConfig.locale && typeof containerConfig.locale == 'string'){ F2.ContainerConfig.locale = containerConfig.locale; } }
[ "function", "(", "containerConfig", ")", "{", "if", "(", "!", "containerConfig", ".", "scriptErrorTimeout", ")", "{", "containerConfig", ".", "scriptErrorTimeout", "=", "F2", ".", "ContainerConfig", ".", "scriptErrorTimeout", ";", "}", "if", "(", "containerConfig", ".", "debugMode", "!==", "true", ")", "{", "containerConfig", ".", "debugMode", "=", "F2", ".", "ContainerConfig", ".", "debugMode", ";", "}", "if", "(", "containerConfig", ".", "locale", "&&", "typeof", "containerConfig", ".", "locale", "==", "'string'", ")", "{", "F2", ".", "ContainerConfig", ".", "locale", "=", "containerConfig", ".", "locale", ";", "}", "}" ]
Adds properties to the ContainerConfig object to take advantage of defaults @method _hydrateContainerConfig @private @param {F2.ContainerConfig} containerConfig The F2.ContainerConfig object
[ "Adds", "properties", "to", "the", "ContainerConfig", "object", "to", "take", "advantage", "of", "defaults" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4392-L4405
22,465
OpenF2/F2
dist/f2.basic.js
function(appConfig) { jQuery(appConfig.root).on('click', '.' + F2.Constants.Css.APP_VIEW_TRIGGER + '[' + F2.Constants.Views.DATA_ATTRIBUTE + ']', function(event) { event.preventDefault(); var view = jQuery(this).attr(F2.Constants.Views.DATA_ATTRIBUTE).toLowerCase(); // handle the special REMOVE view if (view == F2.Constants.Views.REMOVE) { F2.removeApp(appConfig.instanceId); } else { appConfig.ui.Views.change(view); } }); }
javascript
function(appConfig) { jQuery(appConfig.root).on('click', '.' + F2.Constants.Css.APP_VIEW_TRIGGER + '[' + F2.Constants.Views.DATA_ATTRIBUTE + ']', function(event) { event.preventDefault(); var view = jQuery(this).attr(F2.Constants.Views.DATA_ATTRIBUTE).toLowerCase(); // handle the special REMOVE view if (view == F2.Constants.Views.REMOVE) { F2.removeApp(appConfig.instanceId); } else { appConfig.ui.Views.change(view); } }); }
[ "function", "(", "appConfig", ")", "{", "jQuery", "(", "appConfig", ".", "root", ")", ".", "on", "(", "'click'", ",", "'.'", "+", "F2", ".", "Constants", ".", "Css", ".", "APP_VIEW_TRIGGER", "+", "'['", "+", "F2", ".", "Constants", ".", "Views", ".", "DATA_ATTRIBUTE", "+", "']'", ",", "function", "(", "event", ")", "{", "event", ".", "preventDefault", "(", ")", ";", "var", "view", "=", "jQuery", "(", "this", ")", ".", "attr", "(", "F2", ".", "Constants", ".", "Views", ".", "DATA_ATTRIBUTE", ")", ".", "toLowerCase", "(", ")", ";", "// handle the special REMOVE view", "if", "(", "view", "==", "F2", ".", "Constants", ".", "Views", ".", "REMOVE", ")", "{", "F2", ".", "removeApp", "(", "appConfig", ".", "instanceId", ")", ";", "}", "else", "{", "appConfig", ".", "ui", ".", "Views", ".", "change", "(", "view", ")", ";", "}", "}", ")", ";", "}" ]
Attach app events @method _initAppEvents @private
[ "Attach", "app", "events" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4412-L4428
22,466
OpenF2/F2
dist/f2.basic.js
function() { var resizeTimeout; var resizeHandler = function() { F2.Events.emit(F2.Constants.Events.CONTAINER_WIDTH_CHANGE); }; jQuery(window).on('resize', function() { clearTimeout(resizeTimeout); resizeTimeout = setTimeout(resizeHandler, 100); }); //listen for container-broadcasted locale changes F2.Events.on(F2.Constants.Events.CONTAINER_LOCALE_CHANGE,function(data){ if (data.locale && typeof data.locale == 'string'){ F2.ContainerConfig.locale = data.locale; } }); }
javascript
function() { var resizeTimeout; var resizeHandler = function() { F2.Events.emit(F2.Constants.Events.CONTAINER_WIDTH_CHANGE); }; jQuery(window).on('resize', function() { clearTimeout(resizeTimeout); resizeTimeout = setTimeout(resizeHandler, 100); }); //listen for container-broadcasted locale changes F2.Events.on(F2.Constants.Events.CONTAINER_LOCALE_CHANGE,function(data){ if (data.locale && typeof data.locale == 'string'){ F2.ContainerConfig.locale = data.locale; } }); }
[ "function", "(", ")", "{", "var", "resizeTimeout", ";", "var", "resizeHandler", "=", "function", "(", ")", "{", "F2", ".", "Events", ".", "emit", "(", "F2", ".", "Constants", ".", "Events", ".", "CONTAINER_WIDTH_CHANGE", ")", ";", "}", ";", "jQuery", "(", "window", ")", ".", "on", "(", "'resize'", ",", "function", "(", ")", "{", "clearTimeout", "(", "resizeTimeout", ")", ";", "resizeTimeout", "=", "setTimeout", "(", "resizeHandler", ",", "100", ")", ";", "}", ")", ";", "//listen for container-broadcasted locale changes", "F2", ".", "Events", ".", "on", "(", "F2", ".", "Constants", ".", "Events", ".", "CONTAINER_LOCALE_CHANGE", ",", "function", "(", "data", ")", "{", "if", "(", "data", ".", "locale", "&&", "typeof", "data", ".", "locale", "==", "'string'", ")", "{", "F2", ".", "ContainerConfig", ".", "locale", "=", "data", ".", "locale", ";", "}", "}", ")", ";", "}" ]
Attach container Events @method _initContainerEvents @private
[ "Attach", "container", "Events" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4435-L4453
22,467
OpenF2/F2
dist/f2.basic.js
function(node) { return ( F2.isNativeDOMNode(node) && !_hasNonTextChildNodes(node) && !!node.getAttribute('data-f2-appid') && !!node.getAttribute('data-f2-manifesturl') ); }
javascript
function(node) { return ( F2.isNativeDOMNode(node) && !_hasNonTextChildNodes(node) && !!node.getAttribute('data-f2-appid') && !!node.getAttribute('data-f2-manifesturl') ); }
[ "function", "(", "node", ")", "{", "return", "(", "F2", ".", "isNativeDOMNode", "(", "node", ")", "&&", "!", "_hasNonTextChildNodes", "(", "node", ")", "&&", "!", "!", "node", ".", "getAttribute", "(", "'data-f2-appid'", ")", "&&", "!", "!", "node", ".", "getAttribute", "(", "'data-f2-manifesturl'", ")", ")", ";", "}" ]
Checks if an element is a placeholder element @method _isPlaceholderElement @private @param {Element} node The DOM element to check @return {bool} True if the element is a placeholder
[ "Checks", "if", "an", "element", "is", "a", "placeholder", "element" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4462-L4469
22,468
OpenF2/F2
dist/f2.basic.js
function(appConfig, appContent) { // instantiate F2.UI appConfig.ui = new F2.UI(appConfig); // instantiate F2.App if (F2.Apps[appConfig.appId] !== undefined) { if (typeof F2.Apps[appConfig.appId] === 'function') { // IE setTimeout(function() { _apps[appConfig.instanceId].app = new F2.Apps[appConfig.appId](appConfig, appContent, appConfig.root); if (_apps[appConfig.instanceId].app['init'] !== undefined) { _apps[appConfig.instanceId].app.init(); } }, 0); } else { F2.log('app initialization class is defined but not a function. (' + appConfig.appId + ')'); } } }
javascript
function(appConfig, appContent) { // instantiate F2.UI appConfig.ui = new F2.UI(appConfig); // instantiate F2.App if (F2.Apps[appConfig.appId] !== undefined) { if (typeof F2.Apps[appConfig.appId] === 'function') { // IE setTimeout(function() { _apps[appConfig.instanceId].app = new F2.Apps[appConfig.appId](appConfig, appContent, appConfig.root); if (_apps[appConfig.instanceId].app['init'] !== undefined) { _apps[appConfig.instanceId].app.init(); } }, 0); } else { F2.log('app initialization class is defined but not a function. (' + appConfig.appId + ')'); } } }
[ "function", "(", "appConfig", ",", "appContent", ")", "{", "// instantiate F2.UI", "appConfig", ".", "ui", "=", "new", "F2", ".", "UI", "(", "appConfig", ")", ";", "// instantiate F2.App", "if", "(", "F2", ".", "Apps", "[", "appConfig", ".", "appId", "]", "!==", "undefined", ")", "{", "if", "(", "typeof", "F2", ".", "Apps", "[", "appConfig", ".", "appId", "]", "===", "'function'", ")", "{", "// IE", "setTimeout", "(", "function", "(", ")", "{", "_apps", "[", "appConfig", ".", "instanceId", "]", ".", "app", "=", "new", "F2", ".", "Apps", "[", "appConfig", ".", "appId", "]", "(", "appConfig", ",", "appContent", ",", "appConfig", ".", "root", ")", ";", "if", "(", "_apps", "[", "appConfig", ".", "instanceId", "]", ".", "app", "[", "'init'", "]", "!==", "undefined", ")", "{", "_apps", "[", "appConfig", ".", "instanceId", "]", ".", "app", ".", "init", "(", ")", ";", "}", "}", ",", "0", ")", ";", "}", "else", "{", "F2", ".", "log", "(", "'app initialization class is defined but not a function. ('", "+", "appConfig", ".", "appId", "+", "')'", ")", ";", "}", "}", "}" ]
Instantiates each app from it's appConfig and stores that in a local private collection @method _createAppInstance @private @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}} objects
[ "Instantiates", "each", "app", "from", "it", "s", "appConfig", "and", "stores", "that", "in", "a", "local", "private", "collection" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4487-L4508
22,469
OpenF2/F2
dist/f2.basic.js
function(styles, cb) { // Reduce the list to styles that haven't been loaded var existingStyles = _findExistingStyles(); styles = jQuery.grep(styles, function(url) { return url && jQuery.inArray(url, existingStyles) === -1; }); // Attempt to use the user provided method if (_config.loadStyles) { return _config.loadStyles(styles, cb); } // load styles, see #101 var stylesFragment = null, useCreateStyleSheet = !!document.createStyleSheet; jQuery.each(styles, function(i, resourceUrl) { if (useCreateStyleSheet) { document.createStyleSheet(resourceUrl); } else { stylesFragment = stylesFragment || []; stylesFragment.push('<link rel="stylesheet" type="text/css" href="' + resourceUrl + '"/>'); } }); if (stylesFragment) { jQuery('head').append(stylesFragment.join('')); } cb(); }
javascript
function(styles, cb) { // Reduce the list to styles that haven't been loaded var existingStyles = _findExistingStyles(); styles = jQuery.grep(styles, function(url) { return url && jQuery.inArray(url, existingStyles) === -1; }); // Attempt to use the user provided method if (_config.loadStyles) { return _config.loadStyles(styles, cb); } // load styles, see #101 var stylesFragment = null, useCreateStyleSheet = !!document.createStyleSheet; jQuery.each(styles, function(i, resourceUrl) { if (useCreateStyleSheet) { document.createStyleSheet(resourceUrl); } else { stylesFragment = stylesFragment || []; stylesFragment.push('<link rel="stylesheet" type="text/css" href="' + resourceUrl + '"/>'); } }); if (stylesFragment) { jQuery('head').append(stylesFragment.join('')); } cb(); }
[ "function", "(", "styles", ",", "cb", ")", "{", "// Reduce the list to styles that haven't been loaded", "var", "existingStyles", "=", "_findExistingStyles", "(", ")", ";", "styles", "=", "jQuery", ".", "grep", "(", "styles", ",", "function", "(", "url", ")", "{", "return", "url", "&&", "jQuery", ".", "inArray", "(", "url", ",", "existingStyles", ")", "===", "-", "1", ";", "}", ")", ";", "// Attempt to use the user provided method", "if", "(", "_config", ".", "loadStyles", ")", "{", "return", "_config", ".", "loadStyles", "(", "styles", ",", "cb", ")", ";", "}", "// load styles, see #101", "var", "stylesFragment", "=", "null", ",", "useCreateStyleSheet", "=", "!", "!", "document", ".", "createStyleSheet", ";", "jQuery", ".", "each", "(", "styles", ",", "function", "(", "i", ",", "resourceUrl", ")", "{", "if", "(", "useCreateStyleSheet", ")", "{", "document", ".", "createStyleSheet", "(", "resourceUrl", ")", ";", "}", "else", "{", "stylesFragment", "=", "stylesFragment", "||", "[", "]", ";", "stylesFragment", ".", "push", "(", "'<link rel=\"stylesheet\" type=\"text/css\" href=\"'", "+", "resourceUrl", "+", "'\"/>'", ")", ";", "}", "}", ")", ";", "if", "(", "stylesFragment", ")", "{", "jQuery", "(", "'head'", ")", ".", "append", "(", "stylesFragment", ".", "join", "(", "''", ")", ")", ";", "}", "cb", "(", ")", ";", "}" ]
Fn for loading manifest Styles
[ "Fn", "for", "loading", "manifest", "Styles" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4546-L4577
22,470
OpenF2/F2
dist/f2.basic.js
function(scripts, cb) { // Reduce the list to scripts that haven't been loaded var existingScripts = _findExistingScripts(); var loadingScripts = Object.keys(_loadingScripts); scripts = jQuery.grep(scripts, function(url) { return url && (jQuery.inArray(url, existingScripts) === -1 || jQuery.inArray(url, loadingScripts) !== -1); }); // Attempt to use the user provided method if (_config.loadScripts) { return _config.loadScripts(scripts, cb); } if (!scripts.length) { return cb(); } var doc = window.document; var scriptCount = scripts.length; var scriptsLoaded = 0; //http://caniuse.com/#feat=script-async // var supportsAsync = 'async' in doc.createElement('script') || 'MozAppearance' in doc.documentElement.style || window.opera; var head = doc && (doc['head'] || doc.getElementsByTagName('head')[0]); // to keep IE from crying, we need to put scripts before any // <base> elements, but after any <meta>. this should do it: var insertBeforeEl = head && head.getElementsByTagName('base')[0] || null; // Check for IE10+ so that we don't rely on onreadystatechange, readyStates for IE6-9 var readyStates = 'addEventListener' in window ? {} : { 'loaded': true, 'complete': true }; // Log and emit event for the failed (400,500) scripts var _error = function(e) { setTimeout(function() { var evtData = { src: e.target.src, appId: appConfigs[0].appId }; // Send error to console F2.log('Script defined in \'' + evtData.appId + '\' failed to load \'' + evtData.src + '\''); // TODO: deprecate, see #222 F2.Events.emit(F2.Constants.Events.RESOURCE_FAILED_TO_LOAD, evtData); if (!_bUsesAppHandlers) { _appScriptLoadFailed(appConfigs[0], evtData.src); } else { F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED, appConfigs[0], evtData.src ); } }, _config.scriptErrorTimeout); // Defaults to 7000 }; var _checkComplete = function() { // Are we done loading all scripts for this app? if (++scriptsLoaded === scriptCount) { // success cb(); } }; var _emptyWaitlist = function(resourceKey, errorEvt) { var waiting, waitlist = _loadingScripts[resourceKey]; if (!waitlist) { return; } for (var i=0; i<waitlist.length; i++) { waiting = waitlist [i]; if (errorEvt) { waiting.error(errorEvt); } else { waiting.success(); } } _loadingScripts[resourceKey] = null; }; // Load scripts and eval inlines once complete jQuery.each(scripts, function(i, e) { var script = doc.createElement('script'), resourceUrl = e, resourceKey = resourceUrl.toLowerCase(); // this script is actively loading, add this app to the wait list if (_loadingScripts[resourceKey]) { _loadingScripts[resourceKey].push({ success: _checkComplete, error: _error }); return; } // create the waitlist _loadingScripts[resourceKey] = []; // If in debugMode, add cache buster to each script URL if (_config.debugMode) { resourceUrl += '?cachebuster=' + new Date().getTime(); } // Scripts are loaded asynchronously and executed in order // in supported browsers: http://caniuse.com/#feat=script-async script.async = false; script.type = 'text/javascript'; script.charset = 'utf-8'; script.onerror = function(e) { _error(e); _emptyWaitlist(resourceKey, e); }; // Use a closure for the load event so that we can dereference the original script script.onload = script.onreadystatechange = function(e) { e = e || window.event; // For older IE // detect when it's done loading // ev.type == 'load' is for all browsers except IE6-9 // IE6-9 need to use onreadystatechange and look for // el.readyState in {loaded, complete} (yes, we need both) if (e.type == 'load' || readyStates[script.readyState]) { // Done, cleanup script.onload = script.onreadystatechange = script.onerror = ''; // increment and check if scripts are done _checkComplete(); // empty wait list _emptyWaitlist(resourceKey); // Dereference script script = null; } }; //set the src, start loading script.src = resourceUrl; //<head> really is the best head.insertBefore(script, insertBeforeEl); }); }
javascript
function(scripts, cb) { // Reduce the list to scripts that haven't been loaded var existingScripts = _findExistingScripts(); var loadingScripts = Object.keys(_loadingScripts); scripts = jQuery.grep(scripts, function(url) { return url && (jQuery.inArray(url, existingScripts) === -1 || jQuery.inArray(url, loadingScripts) !== -1); }); // Attempt to use the user provided method if (_config.loadScripts) { return _config.loadScripts(scripts, cb); } if (!scripts.length) { return cb(); } var doc = window.document; var scriptCount = scripts.length; var scriptsLoaded = 0; //http://caniuse.com/#feat=script-async // var supportsAsync = 'async' in doc.createElement('script') || 'MozAppearance' in doc.documentElement.style || window.opera; var head = doc && (doc['head'] || doc.getElementsByTagName('head')[0]); // to keep IE from crying, we need to put scripts before any // <base> elements, but after any <meta>. this should do it: var insertBeforeEl = head && head.getElementsByTagName('base')[0] || null; // Check for IE10+ so that we don't rely on onreadystatechange, readyStates for IE6-9 var readyStates = 'addEventListener' in window ? {} : { 'loaded': true, 'complete': true }; // Log and emit event for the failed (400,500) scripts var _error = function(e) { setTimeout(function() { var evtData = { src: e.target.src, appId: appConfigs[0].appId }; // Send error to console F2.log('Script defined in \'' + evtData.appId + '\' failed to load \'' + evtData.src + '\''); // TODO: deprecate, see #222 F2.Events.emit(F2.Constants.Events.RESOURCE_FAILED_TO_LOAD, evtData); if (!_bUsesAppHandlers) { _appScriptLoadFailed(appConfigs[0], evtData.src); } else { F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_SCRIPT_LOAD_FAILED, appConfigs[0], evtData.src ); } }, _config.scriptErrorTimeout); // Defaults to 7000 }; var _checkComplete = function() { // Are we done loading all scripts for this app? if (++scriptsLoaded === scriptCount) { // success cb(); } }; var _emptyWaitlist = function(resourceKey, errorEvt) { var waiting, waitlist = _loadingScripts[resourceKey]; if (!waitlist) { return; } for (var i=0; i<waitlist.length; i++) { waiting = waitlist [i]; if (errorEvt) { waiting.error(errorEvt); } else { waiting.success(); } } _loadingScripts[resourceKey] = null; }; // Load scripts and eval inlines once complete jQuery.each(scripts, function(i, e) { var script = doc.createElement('script'), resourceUrl = e, resourceKey = resourceUrl.toLowerCase(); // this script is actively loading, add this app to the wait list if (_loadingScripts[resourceKey]) { _loadingScripts[resourceKey].push({ success: _checkComplete, error: _error }); return; } // create the waitlist _loadingScripts[resourceKey] = []; // If in debugMode, add cache buster to each script URL if (_config.debugMode) { resourceUrl += '?cachebuster=' + new Date().getTime(); } // Scripts are loaded asynchronously and executed in order // in supported browsers: http://caniuse.com/#feat=script-async script.async = false; script.type = 'text/javascript'; script.charset = 'utf-8'; script.onerror = function(e) { _error(e); _emptyWaitlist(resourceKey, e); }; // Use a closure for the load event so that we can dereference the original script script.onload = script.onreadystatechange = function(e) { e = e || window.event; // For older IE // detect when it's done loading // ev.type == 'load' is for all browsers except IE6-9 // IE6-9 need to use onreadystatechange and look for // el.readyState in {loaded, complete} (yes, we need both) if (e.type == 'load' || readyStates[script.readyState]) { // Done, cleanup script.onload = script.onreadystatechange = script.onerror = ''; // increment and check if scripts are done _checkComplete(); // empty wait list _emptyWaitlist(resourceKey); // Dereference script script = null; } }; //set the src, start loading script.src = resourceUrl; //<head> really is the best head.insertBefore(script, insertBeforeEl); }); }
[ "function", "(", "scripts", ",", "cb", ")", "{", "// Reduce the list to scripts that haven't been loaded", "var", "existingScripts", "=", "_findExistingScripts", "(", ")", ";", "var", "loadingScripts", "=", "Object", ".", "keys", "(", "_loadingScripts", ")", ";", "scripts", "=", "jQuery", ".", "grep", "(", "scripts", ",", "function", "(", "url", ")", "{", "return", "url", "&&", "(", "jQuery", ".", "inArray", "(", "url", ",", "existingScripts", ")", "===", "-", "1", "||", "jQuery", ".", "inArray", "(", "url", ",", "loadingScripts", ")", "!==", "-", "1", ")", ";", "}", ")", ";", "// Attempt to use the user provided method", "if", "(", "_config", ".", "loadScripts", ")", "{", "return", "_config", ".", "loadScripts", "(", "scripts", ",", "cb", ")", ";", "}", "if", "(", "!", "scripts", ".", "length", ")", "{", "return", "cb", "(", ")", ";", "}", "var", "doc", "=", "window", ".", "document", ";", "var", "scriptCount", "=", "scripts", ".", "length", ";", "var", "scriptsLoaded", "=", "0", ";", "//http://caniuse.com/#feat=script-async", "// var supportsAsync = 'async' in doc.createElement('script') || 'MozAppearance' in doc.documentElement.style || window.opera;", "var", "head", "=", "doc", "&&", "(", "doc", "[", "'head'", "]", "||", "doc", ".", "getElementsByTagName", "(", "'head'", ")", "[", "0", "]", ")", ";", "// to keep IE from crying, we need to put scripts before any", "// <base> elements, but after any <meta>. this should do it:", "var", "insertBeforeEl", "=", "head", "&&", "head", ".", "getElementsByTagName", "(", "'base'", ")", "[", "0", "]", "||", "null", ";", "// Check for IE10+ so that we don't rely on onreadystatechange, readyStates for IE6-9", "var", "readyStates", "=", "'addEventListener'", "in", "window", "?", "{", "}", ":", "{", "'loaded'", ":", "true", ",", "'complete'", ":", "true", "}", ";", "// Log and emit event for the failed (400,500) scripts", "var", "_error", "=", "function", "(", "e", ")", "{", "setTimeout", "(", "function", "(", ")", "{", "var", "evtData", "=", "{", "src", ":", "e", ".", "target", ".", "src", ",", "appId", ":", "appConfigs", "[", "0", "]", ".", "appId", "}", ";", "// Send error to console", "F2", ".", "log", "(", "'Script defined in \\''", "+", "evtData", ".", "appId", "+", "'\\' failed to load \\''", "+", "evtData", ".", "src", "+", "'\\''", ")", ";", "// TODO: deprecate, see #222", "F2", ".", "Events", ".", "emit", "(", "F2", ".", "Constants", ".", "Events", ".", "RESOURCE_FAILED_TO_LOAD", ",", "evtData", ")", ";", "if", "(", "!", "_bUsesAppHandlers", ")", "{", "_appScriptLoadFailed", "(", "appConfigs", "[", "0", "]", ",", "evtData", ".", "src", ")", ";", "}", "else", "{", "F2", ".", "AppHandlers", ".", "__trigger", "(", "_sAppHandlerToken", ",", "F2", ".", "Constants", ".", "AppHandlers", ".", "APP_SCRIPT_LOAD_FAILED", ",", "appConfigs", "[", "0", "]", ",", "evtData", ".", "src", ")", ";", "}", "}", ",", "_config", ".", "scriptErrorTimeout", ")", ";", "// Defaults to 7000", "}", ";", "var", "_checkComplete", "=", "function", "(", ")", "{", "// Are we done loading all scripts for this app?", "if", "(", "++", "scriptsLoaded", "===", "scriptCount", ")", "{", "// success", "cb", "(", ")", ";", "}", "}", ";", "var", "_emptyWaitlist", "=", "function", "(", "resourceKey", ",", "errorEvt", ")", "{", "var", "waiting", ",", "waitlist", "=", "_loadingScripts", "[", "resourceKey", "]", ";", "if", "(", "!", "waitlist", ")", "{", "return", ";", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "waitlist", ".", "length", ";", "i", "++", ")", "{", "waiting", "=", "waitlist", "[", "i", "]", ";", "if", "(", "errorEvt", ")", "{", "waiting", ".", "error", "(", "errorEvt", ")", ";", "}", "else", "{", "waiting", ".", "success", "(", ")", ";", "}", "}", "_loadingScripts", "[", "resourceKey", "]", "=", "null", ";", "}", ";", "// Load scripts and eval inlines once complete", "jQuery", ".", "each", "(", "scripts", ",", "function", "(", "i", ",", "e", ")", "{", "var", "script", "=", "doc", ".", "createElement", "(", "'script'", ")", ",", "resourceUrl", "=", "e", ",", "resourceKey", "=", "resourceUrl", ".", "toLowerCase", "(", ")", ";", "// this script is actively loading, add this app to the wait list", "if", "(", "_loadingScripts", "[", "resourceKey", "]", ")", "{", "_loadingScripts", "[", "resourceKey", "]", ".", "push", "(", "{", "success", ":", "_checkComplete", ",", "error", ":", "_error", "}", ")", ";", "return", ";", "}", "// create the waitlist", "_loadingScripts", "[", "resourceKey", "]", "=", "[", "]", ";", "// If in debugMode, add cache buster to each script URL", "if", "(", "_config", ".", "debugMode", ")", "{", "resourceUrl", "+=", "'?cachebuster='", "+", "new", "Date", "(", ")", ".", "getTime", "(", ")", ";", "}", "// Scripts are loaded asynchronously and executed in order", "// in supported browsers: http://caniuse.com/#feat=script-async", "script", ".", "async", "=", "false", ";", "script", ".", "type", "=", "'text/javascript'", ";", "script", ".", "charset", "=", "'utf-8'", ";", "script", ".", "onerror", "=", "function", "(", "e", ")", "{", "_error", "(", "e", ")", ";", "_emptyWaitlist", "(", "resourceKey", ",", "e", ")", ";", "}", ";", "// Use a closure for the load event so that we can dereference the original script", "script", ".", "onload", "=", "script", ".", "onreadystatechange", "=", "function", "(", "e", ")", "{", "e", "=", "e", "||", "window", ".", "event", ";", "// For older IE", "// detect when it's done loading", "// ev.type == 'load' is for all browsers except IE6-9", "// IE6-9 need to use onreadystatechange and look for", "// el.readyState in {loaded, complete} (yes, we need both)", "if", "(", "e", ".", "type", "==", "'load'", "||", "readyStates", "[", "script", ".", "readyState", "]", ")", "{", "// Done, cleanup", "script", ".", "onload", "=", "script", ".", "onreadystatechange", "=", "script", ".", "onerror", "=", "''", ";", "// increment and check if scripts are done", "_checkComplete", "(", ")", ";", "// empty wait list", "_emptyWaitlist", "(", "resourceKey", ")", ";", "// Dereference script", "script", "=", "null", ";", "}", "}", ";", "//set the src, start loading", "script", ".", "src", "=", "resourceUrl", ";", "//<head> really is the best", "head", ".", "insertBefore", "(", "script", ",", "insertBeforeEl", ")", ";", "}", ")", ";", "}" ]
For loading AppManifest.scripts Parts derived from curljs, headjs, requirejs, dojo
[ "For", "loading", "AppManifest", ".", "scripts", "Parts", "derived", "from", "curljs", "headjs", "requirejs", "dojo" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4581-L4727
22,471
OpenF2/F2
dist/f2.basic.js
function(apps) { jQuery.each(apps, function(i, a) { if (_isPlaceholderElement(appConfigs[i].root)) { jQuery(appConfigs[i].root) .addClass(F2.Constants.Css.APP) .append(jQuery(a.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfigs[i].appId)); } else if (!_bUsesAppHandlers) { // load html and save the root node appConfigs[i].root = _afterAppRender(appConfigs[i], _appRender(appConfigs[i], a.html)); } else { F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_RENDER, appConfigs[i], // the app config _outerHtml(jQuery(a.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfigs[i].appId)) ); var appId = appConfigs[i].appId, root = appConfigs[i].root; if (!root) { throw ('Root for ' + appId + ' must be a native DOM element and cannot be null or undefined. Check your AppHandler callbacks to ensure you have set App root to a native DOM element.'); } if (!elementInDocument(root)) { throw ('App root for ' + appId + ' was not appended to the DOM. Check your AppHandler callbacks to ensure you have rendered the app root to the DOM.'); } F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_RENDER_AFTER, appConfigs[i] // the app config ); if (!F2.isNativeDOMNode(root)) { throw ('App root for ' + appId + ' must be a native DOM element. Check your AppHandler callbacks to ensure you have set app root to a native DOM element.'); } } // init events _initAppEvents(appConfigs[i]); }); }
javascript
function(apps) { jQuery.each(apps, function(i, a) { if (_isPlaceholderElement(appConfigs[i].root)) { jQuery(appConfigs[i].root) .addClass(F2.Constants.Css.APP) .append(jQuery(a.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfigs[i].appId)); } else if (!_bUsesAppHandlers) { // load html and save the root node appConfigs[i].root = _afterAppRender(appConfigs[i], _appRender(appConfigs[i], a.html)); } else { F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_RENDER, appConfigs[i], // the app config _outerHtml(jQuery(a.html).addClass(F2.Constants.Css.APP_CONTAINER + ' ' + appConfigs[i].appId)) ); var appId = appConfigs[i].appId, root = appConfigs[i].root; if (!root) { throw ('Root for ' + appId + ' must be a native DOM element and cannot be null or undefined. Check your AppHandler callbacks to ensure you have set App root to a native DOM element.'); } if (!elementInDocument(root)) { throw ('App root for ' + appId + ' was not appended to the DOM. Check your AppHandler callbacks to ensure you have rendered the app root to the DOM.'); } F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_RENDER_AFTER, appConfigs[i] // the app config ); if (!F2.isNativeDOMNode(root)) { throw ('App root for ' + appId + ' must be a native DOM element. Check your AppHandler callbacks to ensure you have set app root to a native DOM element.'); } } // init events _initAppEvents(appConfigs[i]); }); }
[ "function", "(", "apps", ")", "{", "jQuery", ".", "each", "(", "apps", ",", "function", "(", "i", ",", "a", ")", "{", "if", "(", "_isPlaceholderElement", "(", "appConfigs", "[", "i", "]", ".", "root", ")", ")", "{", "jQuery", "(", "appConfigs", "[", "i", "]", ".", "root", ")", ".", "addClass", "(", "F2", ".", "Constants", ".", "Css", ".", "APP", ")", ".", "append", "(", "jQuery", "(", "a", ".", "html", ")", ".", "addClass", "(", "F2", ".", "Constants", ".", "Css", ".", "APP_CONTAINER", "+", "' '", "+", "appConfigs", "[", "i", "]", ".", "appId", ")", ")", ";", "}", "else", "if", "(", "!", "_bUsesAppHandlers", ")", "{", "// load html and save the root node", "appConfigs", "[", "i", "]", ".", "root", "=", "_afterAppRender", "(", "appConfigs", "[", "i", "]", ",", "_appRender", "(", "appConfigs", "[", "i", "]", ",", "a", ".", "html", ")", ")", ";", "}", "else", "{", "F2", ".", "AppHandlers", ".", "__trigger", "(", "_sAppHandlerToken", ",", "F2", ".", "Constants", ".", "AppHandlers", ".", "APP_RENDER", ",", "appConfigs", "[", "i", "]", ",", "// the app config", "_outerHtml", "(", "jQuery", "(", "a", ".", "html", ")", ".", "addClass", "(", "F2", ".", "Constants", ".", "Css", ".", "APP_CONTAINER", "+", "' '", "+", "appConfigs", "[", "i", "]", ".", "appId", ")", ")", ")", ";", "var", "appId", "=", "appConfigs", "[", "i", "]", ".", "appId", ",", "root", "=", "appConfigs", "[", "i", "]", ".", "root", ";", "if", "(", "!", "root", ")", "{", "throw", "(", "'Root for '", "+", "appId", "+", "' must be a native DOM element and cannot be null or undefined. Check your AppHandler callbacks to ensure you have set App root to a native DOM element.'", ")", ";", "}", "if", "(", "!", "elementInDocument", "(", "root", ")", ")", "{", "throw", "(", "'App root for '", "+", "appId", "+", "' was not appended to the DOM. Check your AppHandler callbacks to ensure you have rendered the app root to the DOM.'", ")", ";", "}", "F2", ".", "AppHandlers", ".", "__trigger", "(", "_sAppHandlerToken", ",", "F2", ".", "Constants", ".", "AppHandlers", ".", "APP_RENDER_AFTER", ",", "appConfigs", "[", "i", "]", "// the app config", ")", ";", "if", "(", "!", "F2", ".", "isNativeDOMNode", "(", "root", ")", ")", "{", "throw", "(", "'App root for '", "+", "appId", "+", "' must be a native DOM element. Check your AppHandler callbacks to ensure you have set app root to a native DOM element.'", ")", ";", "}", "}", "// init events", "_initAppEvents", "(", "appConfigs", "[", "i", "]", ")", ";", "}", ")", ";", "}" ]
Fn for loading manifest app html
[ "Fn", "for", "loading", "manifest", "app", "html" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4778-L4822
22,472
OpenF2/F2
dist/f2.basic.js
function(appConfig) { // check for valid app configurations if (!appConfig.appId) { F2.log('"appId" missing from app object'); return false; } else if (!appConfig.root && !appConfig.manifestUrl) { F2.log('"manifestUrl" missing from app object'); return false; } return true; }
javascript
function(appConfig) { // check for valid app configurations if (!appConfig.appId) { F2.log('"appId" missing from app object'); return false; } else if (!appConfig.root && !appConfig.manifestUrl) { F2.log('"manifestUrl" missing from app object'); return false; } return true; }
[ "function", "(", "appConfig", ")", "{", "// check for valid app configurations", "if", "(", "!", "appConfig", ".", "appId", ")", "{", "F2", ".", "log", "(", "'\"appId\" missing from app object'", ")", ";", "return", "false", ";", "}", "else", "if", "(", "!", "appConfig", ".", "root", "&&", "!", "appConfig", ".", "manifestUrl", ")", "{", "F2", ".", "log", "(", "'\"manifestUrl\" missing from app object'", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks if the app is valid @method _validateApp @private @param {F2.AppConfig} appConfig The F2.AppConfig object @returns {bool} True if the app is valid
[ "Checks", "if", "the", "app", "is", "valid" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4922-L4935
22,473
OpenF2/F2
dist/f2.basic.js
function() { if (_config) { if (_config.xhr) { if (!(typeof _config.xhr === 'function' || typeof _config.xhr === 'object')) { throw ('ContainerConfig.xhr should be a function or an object'); } if (_config.xhr.dataType && typeof _config.xhr.dataType !== 'function') { throw ('ContainerConfig.xhr.dataType should be a function'); } if (_config.xhr.type && typeof _config.xhr.type !== 'function') { throw ('ContainerConfig.xhr.type should be a function'); } if (_config.xhr.url && typeof _config.xhr.url !== 'function') { throw ('ContainerConfig.xhr.url should be a function'); } } } return true; }
javascript
function() { if (_config) { if (_config.xhr) { if (!(typeof _config.xhr === 'function' || typeof _config.xhr === 'object')) { throw ('ContainerConfig.xhr should be a function or an object'); } if (_config.xhr.dataType && typeof _config.xhr.dataType !== 'function') { throw ('ContainerConfig.xhr.dataType should be a function'); } if (_config.xhr.type && typeof _config.xhr.type !== 'function') { throw ('ContainerConfig.xhr.type should be a function'); } if (_config.xhr.url && typeof _config.xhr.url !== 'function') { throw ('ContainerConfig.xhr.url should be a function'); } } } return true; }
[ "function", "(", ")", "{", "if", "(", "_config", ")", "{", "if", "(", "_config", ".", "xhr", ")", "{", "if", "(", "!", "(", "typeof", "_config", ".", "xhr", "===", "'function'", "||", "typeof", "_config", ".", "xhr", "===", "'object'", ")", ")", "{", "throw", "(", "'ContainerConfig.xhr should be a function or an object'", ")", ";", "}", "if", "(", "_config", ".", "xhr", ".", "dataType", "&&", "typeof", "_config", ".", "xhr", ".", "dataType", "!==", "'function'", ")", "{", "throw", "(", "'ContainerConfig.xhr.dataType should be a function'", ")", ";", "}", "if", "(", "_config", ".", "xhr", ".", "type", "&&", "typeof", "_config", ".", "xhr", ".", "type", "!==", "'function'", ")", "{", "throw", "(", "'ContainerConfig.xhr.type should be a function'", ")", ";", "}", "if", "(", "_config", ".", "xhr", ".", "url", "&&", "typeof", "_config", ".", "xhr", ".", "url", "!==", "'function'", ")", "{", "throw", "(", "'ContainerConfig.xhr.url should be a function'", ")", ";", "}", "}", "}", "return", "true", ";", "}" ]
Checks if the ContainerConfig is valid @method _validateContainerConfig @private @returns {bool} True if the config is valid
[ "Checks", "if", "the", "ContainerConfig", "is", "valid" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4943-L4963
22,474
OpenF2/F2
dist/f2.basic.js
function() { if (!_isInit()) { F2.log('F2.init() must be called before F2.getContainerState()'); return; } return jQuery.map(_apps, function(app) { return { appId: app.config.appId }; }); }
javascript
function() { if (!_isInit()) { F2.log('F2.init() must be called before F2.getContainerState()'); return; } return jQuery.map(_apps, function(app) { return { appId: app.config.appId }; }); }
[ "function", "(", ")", "{", "if", "(", "!", "_isInit", "(", ")", ")", "{", "F2", ".", "log", "(", "'F2.init() must be called before F2.getContainerState()'", ")", ";", "return", ";", "}", "return", "jQuery", ".", "map", "(", "_apps", ",", "function", "(", "app", ")", "{", "return", "{", "appId", ":", "app", ".", "config", ".", "appId", "}", ";", "}", ")", ";", "}" ]
Gets the current list of apps in the container @method getContainerState @returns {Array} An array of objects containing the appId
[ "Gets", "the", "current", "list", "of", "apps", "in", "the", "container" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L4971-L4982
22,475
OpenF2/F2
dist/f2.basic.js
function(parentNode) { var elements = [], appConfigs = [], add = function(e) { if (!e) { return; } elements.push(e); }, addAll = function(els) { if (!els) { return; } for (var i = 0, len = els.length; i < len; i++) { add(els[i]); } }; if (!!parentNode && !F2.isNativeDOMNode(parentNode)) { throw ('"parentNode" must be null or a DOM node'); } // if the passed in element has a data-f2-appid attribute add // it to the list of elements but to not search within that // element for other placeholders if (parentNode && parentNode.hasAttribute('data-f2-appid')) { add(parentNode); } else { // find placeholders within the parentNode only if // querySelectorAll exists parentNode = parentNode || document; if (parentNode.querySelectorAll) { addAll(parentNode.querySelectorAll('[data-f2-appid]')); } } for (var i = 0, len = elements.length; i < len; i++) { var appConfig = _getAppConfigFromElement(elements[i]); appConfigs.push(appConfig); } if (appConfigs.length) { F2.registerApps(appConfigs); } }
javascript
function(parentNode) { var elements = [], appConfigs = [], add = function(e) { if (!e) { return; } elements.push(e); }, addAll = function(els) { if (!els) { return; } for (var i = 0, len = els.length; i < len; i++) { add(els[i]); } }; if (!!parentNode && !F2.isNativeDOMNode(parentNode)) { throw ('"parentNode" must be null or a DOM node'); } // if the passed in element has a data-f2-appid attribute add // it to the list of elements but to not search within that // element for other placeholders if (parentNode && parentNode.hasAttribute('data-f2-appid')) { add(parentNode); } else { // find placeholders within the parentNode only if // querySelectorAll exists parentNode = parentNode || document; if (parentNode.querySelectorAll) { addAll(parentNode.querySelectorAll('[data-f2-appid]')); } } for (var i = 0, len = elements.length; i < len; i++) { var appConfig = _getAppConfigFromElement(elements[i]); appConfigs.push(appConfig); } if (appConfigs.length) { F2.registerApps(appConfigs); } }
[ "function", "(", "parentNode", ")", "{", "var", "elements", "=", "[", "]", ",", "appConfigs", "=", "[", "]", ",", "add", "=", "function", "(", "e", ")", "{", "if", "(", "!", "e", ")", "{", "return", ";", "}", "elements", ".", "push", "(", "e", ")", ";", "}", ",", "addAll", "=", "function", "(", "els", ")", "{", "if", "(", "!", "els", ")", "{", "return", ";", "}", "for", "(", "var", "i", "=", "0", ",", "len", "=", "els", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "add", "(", "els", "[", "i", "]", ")", ";", "}", "}", ";", "if", "(", "!", "!", "parentNode", "&&", "!", "F2", ".", "isNativeDOMNode", "(", "parentNode", ")", ")", "{", "throw", "(", "'\"parentNode\" must be null or a DOM node'", ")", ";", "}", "// if the passed in element has a data-f2-appid attribute add", "// it to the list of elements but to not search within that", "// element for other placeholders", "if", "(", "parentNode", "&&", "parentNode", ".", "hasAttribute", "(", "'data-f2-appid'", ")", ")", "{", "add", "(", "parentNode", ")", ";", "}", "else", "{", "// find placeholders within the parentNode only if ", "// querySelectorAll exists", "parentNode", "=", "parentNode", "||", "document", ";", "if", "(", "parentNode", ".", "querySelectorAll", ")", "{", "addAll", "(", "parentNode", ".", "querySelectorAll", "(", "'[data-f2-appid]'", ")", ")", ";", "}", "}", "for", "(", "var", "i", "=", "0", ",", "len", "=", "elements", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "appConfig", "=", "_getAppConfigFromElement", "(", "elements", "[", "i", "]", ")", ";", "appConfigs", ".", "push", "(", "appConfig", ")", ";", "}", "if", "(", "appConfigs", ".", "length", ")", "{", "F2", ".", "registerApps", "(", "appConfigs", ")", ";", "}", "}" ]
Automatically load apps that are already defined in the DOM. Elements will be rendered into the location of the placeholder DOM element. Any AppHandlers that are defined will be bypassed. @method loadPlaceholders @param {Element} parentNode The element to search for placeholder apps
[ "Automatically", "load", "apps", "that", "are", "already", "defined", "in", "the", "DOM", ".", "Elements", "will", "be", "rendered", "into", "the", "location", "of", "the", "placeholder", "DOM", "element", ".", "Any", "AppHandlers", "that", "are", "defined", "will", "be", "bypassed", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L5037-L5079
22,476
OpenF2/F2
dist/f2.basic.js
function() { jQuery.each(req.apps, function(idx, item) { item.name = item.name || item.appId; F2.log('Removed failed ' + item.name + ' app', item); F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_MANIFEST_REQUEST_FAIL, item // the app config ); F2.removeApp(item.instanceId); }); }
javascript
function() { jQuery.each(req.apps, function(idx, item) { item.name = item.name || item.appId; F2.log('Removed failed ' + item.name + ' app', item); F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_MANIFEST_REQUEST_FAIL, item // the app config ); F2.removeApp(item.instanceId); }); }
[ "function", "(", ")", "{", "jQuery", ".", "each", "(", "req", ".", "apps", ",", "function", "(", "idx", ",", "item", ")", "{", "item", ".", "name", "=", "item", ".", "name", "||", "item", ".", "appId", ";", "F2", ".", "log", "(", "'Removed failed '", "+", "item", ".", "name", "+", "' app'", ",", "item", ")", ";", "F2", ".", "AppHandlers", ".", "__trigger", "(", "_sAppHandlerToken", ",", "F2", ".", "Constants", ".", "AppHandlers", ".", "APP_MANIFEST_REQUEST_FAIL", ",", "item", "// the app config", ")", ";", "F2", ".", "removeApp", "(", "item", ".", "instanceId", ")", ";", "}", ")", ";", "}" ]
setup defaults and callbacks
[ "setup", "defaults", "and", "callbacks" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.basic.js#L5346-L5357
22,477
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
whenReady
function whenReady(fn, scope){ if (domIsReady) { fn.call(scope); return; } domReadyQueue.push(function(){ fn.call(scope); }); }
javascript
function whenReady(fn, scope){ if (domIsReady) { fn.call(scope); return; } domReadyQueue.push(function(){ fn.call(scope); }); }
[ "function", "whenReady", "(", "fn", ",", "scope", ")", "{", "if", "(", "domIsReady", ")", "{", "fn", ".", "call", "(", "scope", ")", ";", "return", ";", "}", "domReadyQueue", ".", "push", "(", "function", "(", ")", "{", "fn", ".", "call", "(", "scope", ")", ";", "}", ")", ";", "}" ]
This will add a function to the queue of functions to be run once the DOM reaches a ready state. If functions are added after this event then they will be executed immediately. @param {function} fn The function to add @param {Object} scope An optional scope for the function to be called with.
[ "This", "will", "add", "a", "function", "to", "the", "queue", "of", "functions", "to", "be", "run", "once", "the", "DOM", "reaches", "a", "ready", "state", ".", "If", "functions", "are", "added", "after", "this", "event", "then", "they", "will", "be", "executed", "immediately", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L207-L215
22,478
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
getParentObject
function getParentObject(){ var obj = parent; if (namespace !== "") { for (var i = 0, ii = namespace.split("."); i < ii.length; i++) { obj = obj[ii[i]]; } } return obj.easyXDM; }
javascript
function getParentObject(){ var obj = parent; if (namespace !== "") { for (var i = 0, ii = namespace.split("."); i < ii.length; i++) { obj = obj[ii[i]]; } } return obj.easyXDM; }
[ "function", "getParentObject", "(", ")", "{", "var", "obj", "=", "parent", ";", "if", "(", "namespace", "!==", "\"\"", ")", "{", "for", "(", "var", "i", "=", "0", ",", "ii", "=", "namespace", ".", "split", "(", "\".\"", ")", ";", "i", "<", "ii", ".", "length", ";", "i", "++", ")", "{", "obj", "=", "obj", "[", "ii", "[", "i", "]", "]", ";", "}", "}", "return", "obj", ".", "easyXDM", ";", "}" ]
Returns an instance of easyXDM from the parent window with respect to the namespace. @return An instance of easyXDM (in the parent window)
[ "Returns", "an", "instance", "of", "easyXDM", "from", "the", "parent", "window", "with", "respect", "to", "the", "namespace", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L223-L231
22,479
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
noConflict
function noConflict(ns){ window.easyXDM = _easyXDM; namespace = ns; if (namespace) { IFRAME_PREFIX = "easyXDM_" + namespace.replace(".", "_") + "_"; } return easyXDM; }
javascript
function noConflict(ns){ window.easyXDM = _easyXDM; namespace = ns; if (namespace) { IFRAME_PREFIX = "easyXDM_" + namespace.replace(".", "_") + "_"; } return easyXDM; }
[ "function", "noConflict", "(", "ns", ")", "{", "window", ".", "easyXDM", "=", "_easyXDM", ";", "namespace", "=", "ns", ";", "if", "(", "namespace", ")", "{", "IFRAME_PREFIX", "=", "\"easyXDM_\"", "+", "namespace", ".", "replace", "(", "\".\"", ",", "\"_\"", ")", "+", "\"_\"", ";", "}", "return", "easyXDM", ";", "}" ]
Removes easyXDM variable from the global scope. It also returns control of the easyXDM variable to whatever code used it before. @param {String} ns A string representation of an object that will hold an instance of easyXDM. @return An instance of easyXDM
[ "Removes", "easyXDM", "variable", "from", "the", "global", "scope", ".", "It", "also", "returns", "control", "of", "the", "easyXDM", "variable", "to", "whatever", "code", "used", "it", "before", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L241-L249
22,480
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
getLocation
function getLocation(url){ var m = url.toLowerCase().match(reURI); var proto = m[2], domain = m[3], port = m[4] || ""; if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) { port = ""; } return proto + "//" + domain + port; }
javascript
function getLocation(url){ var m = url.toLowerCase().match(reURI); var proto = m[2], domain = m[3], port = m[4] || ""; if ((proto == "http:" && port == ":80") || (proto == "https:" && port == ":443")) { port = ""; } return proto + "//" + domain + port; }
[ "function", "getLocation", "(", "url", ")", "{", "var", "m", "=", "url", ".", "toLowerCase", "(", ")", ".", "match", "(", "reURI", ")", ";", "var", "proto", "=", "m", "[", "2", "]", ",", "domain", "=", "m", "[", "3", "]", ",", "port", "=", "m", "[", "4", "]", "||", "\"\"", ";", "if", "(", "(", "proto", "==", "\"http:\"", "&&", "port", "==", "\":80\"", ")", "||", "(", "proto", "==", "\"https:\"", "&&", "port", "==", "\":443\"", ")", ")", "{", "port", "=", "\"\"", ";", "}", "return", "proto", "+", "\"//\"", "+", "domain", "+", "port", ";", "}" ]
Returns a string containing the schema, domain and if present the port @param {String} url The url to extract the location from @return {String} The location part of the url
[ "Returns", "a", "string", "containing", "the", "schema", "domain", "and", "if", "present", "the", "port" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L279-L286
22,481
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
resolveUrl
function resolveUrl(url){ // replace all // except the one in proto with / url = url.replace(reDoubleSlash, "$1/"); // If the url is a valid url we do nothing if (!url.match(/^(http||https):\/\//)) { // If this is a relative path var path = (url.substring(0, 1) === "/") ? "" : location.pathname; if (path.substring(path.length - 1) !== "/") { path = path.substring(0, path.lastIndexOf("/") + 1); } url = location.protocol + "//" + location.host + path + url; } // reduce all 'xyz/../' to just '' while (reParent.test(url)) { url = url.replace(reParent, ""); } return url; }
javascript
function resolveUrl(url){ // replace all // except the one in proto with / url = url.replace(reDoubleSlash, "$1/"); // If the url is a valid url we do nothing if (!url.match(/^(http||https):\/\//)) { // If this is a relative path var path = (url.substring(0, 1) === "/") ? "" : location.pathname; if (path.substring(path.length - 1) !== "/") { path = path.substring(0, path.lastIndexOf("/") + 1); } url = location.protocol + "//" + location.host + path + url; } // reduce all 'xyz/../' to just '' while (reParent.test(url)) { url = url.replace(reParent, ""); } return url; }
[ "function", "resolveUrl", "(", "url", ")", "{", "// replace all // except the one in proto with /", "url", "=", "url", ".", "replace", "(", "reDoubleSlash", ",", "\"$1/\"", ")", ";", "// If the url is a valid url we do nothing", "if", "(", "!", "url", ".", "match", "(", "/", "^(http||https):\\/\\/", "/", ")", ")", "{", "// If this is a relative path", "var", "path", "=", "(", "url", ".", "substring", "(", "0", ",", "1", ")", "===", "\"/\"", ")", "?", "\"\"", ":", "location", ".", "pathname", ";", "if", "(", "path", ".", "substring", "(", "path", ".", "length", "-", "1", ")", "!==", "\"/\"", ")", "{", "path", "=", "path", ".", "substring", "(", "0", ",", "path", ".", "lastIndexOf", "(", "\"/\"", ")", "+", "1", ")", ";", "}", "url", "=", "location", ".", "protocol", "+", "\"//\"", "+", "location", ".", "host", "+", "path", "+", "url", ";", "}", "// reduce all 'xyz/../' to just '' ", "while", "(", "reParent", ".", "test", "(", "url", ")", ")", "{", "url", "=", "url", ".", "replace", "(", "reParent", ",", "\"\"", ")", ";", "}", "return", "url", ";", "}" ]
Resolves a relative url into an absolute one. @param {String} url The path to resolve. @return {String} The resolved url.
[ "Resolves", "a", "relative", "url", "into", "an", "absolute", "one", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L293-L315
22,482
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
function(){ var cached = {}; var obj = { a: [1, 2, 3] }, json = "{\"a\":[1,2,3]}"; if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) { // this is a working JSON instance return JSON; } if (Object.toJSON) { if (Object.toJSON(obj).replace((/\s/g), "") === json) { // this is a working stringify method cached.stringify = Object.toJSON; } } if (typeof String.prototype.evalJSON === "function") { obj = json.evalJSON(); if (obj.a && obj.a.length === 3 && obj.a[2] === 3) { // this is a working parse method cached.parse = function(str){ return str.evalJSON(); }; } } if (cached.stringify && cached.parse) { // Only memoize the result if we have valid instance getJSON = function(){ return cached; }; return cached; } return null; }
javascript
function(){ var cached = {}; var obj = { a: [1, 2, 3] }, json = "{\"a\":[1,2,3]}"; if (typeof JSON != "undefined" && typeof JSON.stringify === "function" && JSON.stringify(obj).replace((/\s/g), "") === json) { // this is a working JSON instance return JSON; } if (Object.toJSON) { if (Object.toJSON(obj).replace((/\s/g), "") === json) { // this is a working stringify method cached.stringify = Object.toJSON; } } if (typeof String.prototype.evalJSON === "function") { obj = json.evalJSON(); if (obj.a && obj.a.length === 3 && obj.a[2] === 3) { // this is a working parse method cached.parse = function(str){ return str.evalJSON(); }; } } if (cached.stringify && cached.parse) { // Only memoize the result if we have valid instance getJSON = function(){ return cached; }; return cached; } return null; }
[ "function", "(", ")", "{", "var", "cached", "=", "{", "}", ";", "var", "obj", "=", "{", "a", ":", "[", "1", ",", "2", ",", "3", "]", "}", ",", "json", "=", "\"{\\\"a\\\":[1,2,3]}\"", ";", "if", "(", "typeof", "JSON", "!=", "\"undefined\"", "&&", "typeof", "JSON", ".", "stringify", "===", "\"function\"", "&&", "JSON", ".", "stringify", "(", "obj", ")", ".", "replace", "(", "(", "/", "\\s", "/", "g", ")", ",", "\"\"", ")", "===", "json", ")", "{", "// this is a working JSON instance", "return", "JSON", ";", "}", "if", "(", "Object", ".", "toJSON", ")", "{", "if", "(", "Object", ".", "toJSON", "(", "obj", ")", ".", "replace", "(", "(", "/", "\\s", "/", "g", ")", ",", "\"\"", ")", "===", "json", ")", "{", "// this is a working stringify method", "cached", ".", "stringify", "=", "Object", ".", "toJSON", ";", "}", "}", "if", "(", "typeof", "String", ".", "prototype", ".", "evalJSON", "===", "\"function\"", ")", "{", "obj", "=", "json", ".", "evalJSON", "(", ")", ";", "if", "(", "obj", ".", "a", "&&", "obj", ".", "a", ".", "length", "===", "3", "&&", "obj", ".", "a", "[", "2", "]", "===", "3", ")", "{", "// this is a working parse method ", "cached", ".", "parse", "=", "function", "(", "str", ")", "{", "return", "str", ".", "evalJSON", "(", ")", ";", "}", ";", "}", "}", "if", "(", "cached", ".", "stringify", "&&", "cached", ".", "parse", ")", "{", "// Only memoize the result if we have valid instance", "getJSON", "=", "function", "(", ")", "{", "return", "cached", ";", "}", ";", "return", "cached", ";", "}", "return", "null", ";", "}" ]
A safe implementation of HTML5 JSON. Feature testing is used to make sure the implementation works. @return {JSON} A valid JSON conforming object, or null if not found.
[ "A", "safe", "implementation", "of", "HTML5", "JSON", ".", "Feature", "testing", "is", "used", "to", "make", "sure", "the", "implementation", "works", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L368-L403
22,483
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
createFrame
function createFrame(config){ if (undef(HAS_NAME_PROPERTY_BUG)) { testForNamePropertyBug(); } var frame; // This is to work around the problems in IE6/7 with setting the name property. // Internally this is set as 'submitName' instead when using 'iframe.name = ...' // This is not required by easyXDM itself, but is to facilitate other use cases if (HAS_NAME_PROPERTY_BUG) { frame = document.createElement("<iframe name=\"" + config.props.name + "\"/>"); } else { frame = document.createElement("IFRAME"); frame.name = config.props.name; } frame.id = frame.name = config.props.name; delete config.props.name; if (typeof config.container == "string") { config.container = document.getElementById(config.container); } if (!config.container) { // This needs to be hidden like this, simply setting display:none and the like will cause failures in some browsers. apply(frame.style, { position: "absolute", top: "-2000px", // Avoid potential horizontal scrollbar left: "0px" }); config.container = document.body; } // HACK: IE cannot have the src attribute set when the frame is appended // into the container, so we set it to "javascript:false" as a // placeholder for now. If we left the src undefined, it would // instead default to "about:blank", which causes SSL mixed-content // warnings in IE6 when on an SSL parent page. var src = config.props.src; config.props.src = "javascript:false"; // transfer properties to the frame apply(frame, config.props); frame.border = frame.frameBorder = 0; frame.allowTransparency = true; config.container.appendChild(frame); if (config.onLoad) { on(frame, "load", config.onLoad); } // set the frame URL to the proper value (we previously set it to // "javascript:false" to work around the IE issue mentioned above) if(config.usePost) { var form = config.container.appendChild(document.createElement('form')), input; form.target = frame.name; form.action = src; form.method = 'POST'; if (typeof(config.usePost) === 'object') { for (var i in config.usePost) { if (config.usePost.hasOwnProperty(i)) { if (HAS_NAME_PROPERTY_BUG) { input = document.createElement('<input name="' + i + '"/>'); } else { input = document.createElement("INPUT"); input.name = i; } input.value = config.usePost[i]; form.appendChild(input); } } } form.submit(); form.parentNode.removeChild(form); } else { frame.src = src; } config.props.src = src; return frame; }
javascript
function createFrame(config){ if (undef(HAS_NAME_PROPERTY_BUG)) { testForNamePropertyBug(); } var frame; // This is to work around the problems in IE6/7 with setting the name property. // Internally this is set as 'submitName' instead when using 'iframe.name = ...' // This is not required by easyXDM itself, but is to facilitate other use cases if (HAS_NAME_PROPERTY_BUG) { frame = document.createElement("<iframe name=\"" + config.props.name + "\"/>"); } else { frame = document.createElement("IFRAME"); frame.name = config.props.name; } frame.id = frame.name = config.props.name; delete config.props.name; if (typeof config.container == "string") { config.container = document.getElementById(config.container); } if (!config.container) { // This needs to be hidden like this, simply setting display:none and the like will cause failures in some browsers. apply(frame.style, { position: "absolute", top: "-2000px", // Avoid potential horizontal scrollbar left: "0px" }); config.container = document.body; } // HACK: IE cannot have the src attribute set when the frame is appended // into the container, so we set it to "javascript:false" as a // placeholder for now. If we left the src undefined, it would // instead default to "about:blank", which causes SSL mixed-content // warnings in IE6 when on an SSL parent page. var src = config.props.src; config.props.src = "javascript:false"; // transfer properties to the frame apply(frame, config.props); frame.border = frame.frameBorder = 0; frame.allowTransparency = true; config.container.appendChild(frame); if (config.onLoad) { on(frame, "load", config.onLoad); } // set the frame URL to the proper value (we previously set it to // "javascript:false" to work around the IE issue mentioned above) if(config.usePost) { var form = config.container.appendChild(document.createElement('form')), input; form.target = frame.name; form.action = src; form.method = 'POST'; if (typeof(config.usePost) === 'object') { for (var i in config.usePost) { if (config.usePost.hasOwnProperty(i)) { if (HAS_NAME_PROPERTY_BUG) { input = document.createElement('<input name="' + i + '"/>'); } else { input = document.createElement("INPUT"); input.name = i; } input.value = config.usePost[i]; form.appendChild(input); } } } form.submit(); form.parentNode.removeChild(form); } else { frame.src = src; } config.props.src = src; return frame; }
[ "function", "createFrame", "(", "config", ")", "{", "if", "(", "undef", "(", "HAS_NAME_PROPERTY_BUG", ")", ")", "{", "testForNamePropertyBug", "(", ")", ";", "}", "var", "frame", ";", "// This is to work around the problems in IE6/7 with setting the name property. ", "// Internally this is set as 'submitName' instead when using 'iframe.name = ...'", "// This is not required by easyXDM itself, but is to facilitate other use cases ", "if", "(", "HAS_NAME_PROPERTY_BUG", ")", "{", "frame", "=", "document", ".", "createElement", "(", "\"<iframe name=\\\"\"", "+", "config", ".", "props", ".", "name", "+", "\"\\\"/>\"", ")", ";", "}", "else", "{", "frame", "=", "document", ".", "createElement", "(", "\"IFRAME\"", ")", ";", "frame", ".", "name", "=", "config", ".", "props", ".", "name", ";", "}", "frame", ".", "id", "=", "frame", ".", "name", "=", "config", ".", "props", ".", "name", ";", "delete", "config", ".", "props", ".", "name", ";", "if", "(", "typeof", "config", ".", "container", "==", "\"string\"", ")", "{", "config", ".", "container", "=", "document", ".", "getElementById", "(", "config", ".", "container", ")", ";", "}", "if", "(", "!", "config", ".", "container", ")", "{", "// This needs to be hidden like this, simply setting display:none and the like will cause failures in some browsers.", "apply", "(", "frame", ".", "style", ",", "{", "position", ":", "\"absolute\"", ",", "top", ":", "\"-2000px\"", ",", "// Avoid potential horizontal scrollbar", "left", ":", "\"0px\"", "}", ")", ";", "config", ".", "container", "=", "document", ".", "body", ";", "}", "// HACK: IE cannot have the src attribute set when the frame is appended", "// into the container, so we set it to \"javascript:false\" as a", "// placeholder for now. If we left the src undefined, it would", "// instead default to \"about:blank\", which causes SSL mixed-content", "// warnings in IE6 when on an SSL parent page.", "var", "src", "=", "config", ".", "props", ".", "src", ";", "config", ".", "props", ".", "src", "=", "\"javascript:false\"", ";", "// transfer properties to the frame", "apply", "(", "frame", ",", "config", ".", "props", ")", ";", "frame", ".", "border", "=", "frame", ".", "frameBorder", "=", "0", ";", "frame", ".", "allowTransparency", "=", "true", ";", "config", ".", "container", ".", "appendChild", "(", "frame", ")", ";", "if", "(", "config", ".", "onLoad", ")", "{", "on", "(", "frame", ",", "\"load\"", ",", "config", ".", "onLoad", ")", ";", "}", "// set the frame URL to the proper value (we previously set it to", "// \"javascript:false\" to work around the IE issue mentioned above)", "if", "(", "config", ".", "usePost", ")", "{", "var", "form", "=", "config", ".", "container", ".", "appendChild", "(", "document", ".", "createElement", "(", "'form'", ")", ")", ",", "input", ";", "form", ".", "target", "=", "frame", ".", "name", ";", "form", ".", "action", "=", "src", ";", "form", ".", "method", "=", "'POST'", ";", "if", "(", "typeof", "(", "config", ".", "usePost", ")", "===", "'object'", ")", "{", "for", "(", "var", "i", "in", "config", ".", "usePost", ")", "{", "if", "(", "config", ".", "usePost", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "if", "(", "HAS_NAME_PROPERTY_BUG", ")", "{", "input", "=", "document", ".", "createElement", "(", "'<input name=\"'", "+", "i", "+", "'\"/>'", ")", ";", "}", "else", "{", "input", "=", "document", ".", "createElement", "(", "\"INPUT\"", ")", ";", "input", ".", "name", "=", "i", ";", "}", "input", ".", "value", "=", "config", ".", "usePost", "[", "i", "]", ";", "form", ".", "appendChild", "(", "input", ")", ";", "}", "}", "}", "form", ".", "submit", "(", ")", ";", "form", ".", "parentNode", ".", "removeChild", "(", "form", ")", ";", "}", "else", "{", "frame", ".", "src", "=", "src", ";", "}", "config", ".", "props", ".", "src", "=", "src", ";", "return", "frame", ";", "}" ]
Creates a frame and appends it to the DOM. @param config {object} This object can have the following properties <ul> <li> {object} prop The properties that should be set on the frame. This should include the 'src' property.</li> <li> {object} attr The attributes that should be set on the frame.</li> <li> {DOMElement} container Its parent element (Optional).</li> <li> {function} onLoad A method that should be called with the frames contentWindow as argument when the frame is fully loaded. (Optional)</li> </ul> @return The frames DOMElement @type DOMElement
[ "Creates", "a", "frame", "and", "appends", "it", "to", "the", "DOM", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L452-L534
22,484
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
removeFromStack
function removeFromStack(element){ element.up.down = element.down; element.down.up = element.up; element.up = element.down = null; }
javascript
function removeFromStack(element){ element.up.down = element.down; element.down.up = element.up; element.up = element.down = null; }
[ "function", "removeFromStack", "(", "element", ")", "{", "element", ".", "up", ".", "down", "=", "element", ".", "down", ";", "element", ".", "down", ".", "up", "=", "element", ".", "up", ";", "element", ".", "up", "=", "element", ".", "down", "=", "null", ";", "}" ]
This will remove a stackelement from its stack while leaving the stack functional. @param {Object} element The elment to remove from the stack.
[ "This", "will", "remove", "a", "stackelement", "from", "its", "stack", "while", "leaving", "the", "stack", "functional", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L776-L780
22,485
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
function(name, del){ if (!_map.hasOwnProperty(name)) { return; } var fn = _map[name]; if (del) { delete _map[name]; } return fn; }
javascript
function(name, del){ if (!_map.hasOwnProperty(name)) { return; } var fn = _map[name]; if (del) { delete _map[name]; } return fn; }
[ "function", "(", "name", ",", "del", ")", "{", "if", "(", "!", "_map", ".", "hasOwnProperty", "(", "name", ")", ")", "{", "return", ";", "}", "var", "fn", "=", "_map", "[", "name", "]", ";", "if", "(", "del", ")", "{", "delete", "_map", "[", "name", "]", ";", "}", "return", "fn", ";", "}" ]
Retrieves the function referred to by the given name @param {String} name The name of the function to retrieve @param {Boolean} del If the function should be deleted after retrieval @return {Function} The stored function @namespace easyXDM.fn
[ "Retrieves", "the", "function", "referred", "to", "by", "the", "given", "name" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L978-L988
22,486
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
addSwf
function addSwf(domain){ // the differentiating query argument is needed in Flash9 to avoid a caching issue where LocalConnection would throw an error. var url = config.swf + "?host=" + config.isHost; var id = "easyXDM_swf_" + Math.floor(Math.random() * 10000); // prepare the init function that will fire once the swf is ready easyXDM.Fn.set("flash_loaded" + domain.replace(/[\-.]/g, "_"), function(){ easyXDM.stack.FlashTransport[domain].swf = swf = swfContainer.firstChild; var queue = easyXDM.stack.FlashTransport[domain].queue; for (var i = 0; i < queue.length; i++) { queue[i](); } queue.length = 0; }); if (config.swfContainer) { swfContainer = (typeof config.swfContainer == "string") ? document.getElementById(config.swfContainer) : config.swfContainer; } else { // create the container that will hold the swf swfContainer = document.createElement('div'); // http://bugs.adobe.com/jira/browse/FP-4796 // http://tech.groups.yahoo.com/group/flexcoders/message/162365 // https://groups.google.com/forum/#!topic/easyxdm/mJZJhWagoLc apply(swfContainer.style, HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle ? { height: "20px", width: "20px", position: "fixed", right: 0, top: 0 } : { height: "1px", width: "1px", position: "absolute", overflow: "hidden", right: 0, top: 0 }); document.body.appendChild(swfContainer); } // create the object/embed var flashVars = "callback=flash_loaded" + encodeURIComponent(domain.replace(/[\-.]/g, "_")) + "&proto=" + global.location.protocol + "&domain=" + encodeURIComponent(getDomainName(global.location.href)) + "&port=" + encodeURIComponent(getPort(global.location.href)) + "&ns=" + encodeURIComponent(namespace); swfContainer.innerHTML = "<object height='20' width='20' type='application/x-shockwave-flash' id='" + id + "' data='" + url + "'>" + "<param name='allowScriptAccess' value='always'></param>" + "<param name='wmode' value='transparent'>" + "<param name='movie' value='" + url + "'></param>" + "<param name='flashvars' value='" + flashVars + "'></param>" + "<embed type='application/x-shockwave-flash' FlashVars='" + flashVars + "' allowScriptAccess='always' wmode='transparent' src='" + url + "' height='1' width='1'></embed>" + "</object>"; }
javascript
function addSwf(domain){ // the differentiating query argument is needed in Flash9 to avoid a caching issue where LocalConnection would throw an error. var url = config.swf + "?host=" + config.isHost; var id = "easyXDM_swf_" + Math.floor(Math.random() * 10000); // prepare the init function that will fire once the swf is ready easyXDM.Fn.set("flash_loaded" + domain.replace(/[\-.]/g, "_"), function(){ easyXDM.stack.FlashTransport[domain].swf = swf = swfContainer.firstChild; var queue = easyXDM.stack.FlashTransport[domain].queue; for (var i = 0; i < queue.length; i++) { queue[i](); } queue.length = 0; }); if (config.swfContainer) { swfContainer = (typeof config.swfContainer == "string") ? document.getElementById(config.swfContainer) : config.swfContainer; } else { // create the container that will hold the swf swfContainer = document.createElement('div'); // http://bugs.adobe.com/jira/browse/FP-4796 // http://tech.groups.yahoo.com/group/flexcoders/message/162365 // https://groups.google.com/forum/#!topic/easyxdm/mJZJhWagoLc apply(swfContainer.style, HAS_FLASH_THROTTLED_BUG && config.swfNoThrottle ? { height: "20px", width: "20px", position: "fixed", right: 0, top: 0 } : { height: "1px", width: "1px", position: "absolute", overflow: "hidden", right: 0, top: 0 }); document.body.appendChild(swfContainer); } // create the object/embed var flashVars = "callback=flash_loaded" + encodeURIComponent(domain.replace(/[\-.]/g, "_")) + "&proto=" + global.location.protocol + "&domain=" + encodeURIComponent(getDomainName(global.location.href)) + "&port=" + encodeURIComponent(getPort(global.location.href)) + "&ns=" + encodeURIComponent(namespace); swfContainer.innerHTML = "<object height='20' width='20' type='application/x-shockwave-flash' id='" + id + "' data='" + url + "'>" + "<param name='allowScriptAccess' value='always'></param>" + "<param name='wmode' value='transparent'>" + "<param name='movie' value='" + url + "'></param>" + "<param name='flashvars' value='" + flashVars + "'></param>" + "<embed type='application/x-shockwave-flash' FlashVars='" + flashVars + "' allowScriptAccess='always' wmode='transparent' src='" + url + "' height='1' width='1'></embed>" + "</object>"; }
[ "function", "addSwf", "(", "domain", ")", "{", "// the differentiating query argument is needed in Flash9 to avoid a caching issue where LocalConnection would throw an error.", "var", "url", "=", "config", ".", "swf", "+", "\"?host=\"", "+", "config", ".", "isHost", ";", "var", "id", "=", "\"easyXDM_swf_\"", "+", "Math", ".", "floor", "(", "Math", ".", "random", "(", ")", "*", "10000", ")", ";", "// prepare the init function that will fire once the swf is ready", "easyXDM", ".", "Fn", ".", "set", "(", "\"flash_loaded\"", "+", "domain", ".", "replace", "(", "/", "[\\-.]", "/", "g", ",", "\"_\"", ")", ",", "function", "(", ")", "{", "easyXDM", ".", "stack", ".", "FlashTransport", "[", "domain", "]", ".", "swf", "=", "swf", "=", "swfContainer", ".", "firstChild", ";", "var", "queue", "=", "easyXDM", ".", "stack", ".", "FlashTransport", "[", "domain", "]", ".", "queue", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "queue", ".", "length", ";", "i", "++", ")", "{", "queue", "[", "i", "]", "(", ")", ";", "}", "queue", ".", "length", "=", "0", ";", "}", ")", ";", "if", "(", "config", ".", "swfContainer", ")", "{", "swfContainer", "=", "(", "typeof", "config", ".", "swfContainer", "==", "\"string\"", ")", "?", "document", ".", "getElementById", "(", "config", ".", "swfContainer", ")", ":", "config", ".", "swfContainer", ";", "}", "else", "{", "// create the container that will hold the swf", "swfContainer", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "// http://bugs.adobe.com/jira/browse/FP-4796", "// http://tech.groups.yahoo.com/group/flexcoders/message/162365", "// https://groups.google.com/forum/#!topic/easyxdm/mJZJhWagoLc", "apply", "(", "swfContainer", ".", "style", ",", "HAS_FLASH_THROTTLED_BUG", "&&", "config", ".", "swfNoThrottle", "?", "{", "height", ":", "\"20px\"", ",", "width", ":", "\"20px\"", ",", "position", ":", "\"fixed\"", ",", "right", ":", "0", ",", "top", ":", "0", "}", ":", "{", "height", ":", "\"1px\"", ",", "width", ":", "\"1px\"", ",", "position", ":", "\"absolute\"", ",", "overflow", ":", "\"hidden\"", ",", "right", ":", "0", ",", "top", ":", "0", "}", ")", ";", "document", ".", "body", ".", "appendChild", "(", "swfContainer", ")", ";", "}", "// create the object/embed", "var", "flashVars", "=", "\"callback=flash_loaded\"", "+", "encodeURIComponent", "(", "domain", ".", "replace", "(", "/", "[\\-.]", "/", "g", ",", "\"_\"", ")", ")", "+", "\"&proto=\"", "+", "global", ".", "location", ".", "protocol", "+", "\"&domain=\"", "+", "encodeURIComponent", "(", "getDomainName", "(", "global", ".", "location", ".", "href", ")", ")", "+", "\"&port=\"", "+", "encodeURIComponent", "(", "getPort", "(", "global", ".", "location", ".", "href", ")", ")", "+", "\"&ns=\"", "+", "encodeURIComponent", "(", "namespace", ")", ";", "swfContainer", ".", "innerHTML", "=", "\"<object height='20' width='20' type='application/x-shockwave-flash' id='\"", "+", "id", "+", "\"' data='\"", "+", "url", "+", "\"'>\"", "+", "\"<param name='allowScriptAccess' value='always'></param>\"", "+", "\"<param name='wmode' value='transparent'>\"", "+", "\"<param name='movie' value='\"", "+", "url", "+", "\"'></param>\"", "+", "\"<param name='flashvars' value='\"", "+", "flashVars", "+", "\"'></param>\"", "+", "\"<embed type='application/x-shockwave-flash' FlashVars='\"", "+", "flashVars", "+", "\"' allowScriptAccess='always' wmode='transparent' src='\"", "+", "url", "+", "\"' height='1' width='1'></embed>\"", "+", "\"</object>\"", ";", "}" ]
This method adds the SWF to the DOM and prepares the initialization of the channel
[ "This", "method", "adds", "the", "SWF", "to", "the", "DOM", "and", "prepares", "the", "initialization", "of", "the", "channel" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L1412-L1475
22,487
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
_getOrigin
function _getOrigin(event){ if (event.origin) { // This is the HTML5 property return getLocation(event.origin); } if (event.uri) { // From earlier implementations return getLocation(event.uri); } if (event.domain) { // This is the last option and will fail if the // origin is not using the same schema as we are return location.protocol + "//" + event.domain; } throw "Unable to retrieve the origin of the event"; }
javascript
function _getOrigin(event){ if (event.origin) { // This is the HTML5 property return getLocation(event.origin); } if (event.uri) { // From earlier implementations return getLocation(event.uri); } if (event.domain) { // This is the last option and will fail if the // origin is not using the same schema as we are return location.protocol + "//" + event.domain; } throw "Unable to retrieve the origin of the event"; }
[ "function", "_getOrigin", "(", "event", ")", "{", "if", "(", "event", ".", "origin", ")", "{", "// This is the HTML5 property", "return", "getLocation", "(", "event", ".", "origin", ")", ";", "}", "if", "(", "event", ".", "uri", ")", "{", "// From earlier implementations ", "return", "getLocation", "(", "event", ".", "uri", ")", ";", "}", "if", "(", "event", ".", "domain", ")", "{", "// This is the last option and will fail if the ", "// origin is not using the same schema as we are", "return", "location", ".", "protocol", "+", "\"//\"", "+", "event", ".", "domain", ";", "}", "throw", "\"Unable to retrieve the origin of the event\"", ";", "}" ]
the domain to communicate with Resolves the origin from the event object @private @param {Object} event The messageevent @return {String} The scheme, host and port of the origin
[ "the", "domain", "to", "communicate", "with", "Resolves", "the", "origin", "from", "the", "event", "object" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L1614-L1629
22,488
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
function(event){ if (event.data == config.channel + "-ready") { // replace the eventlistener callerWindow = ("postMessage" in frame.contentWindow) ? frame.contentWindow : frame.contentWindow.document; un(window, "message", waitForReady); on(window, "message", _window_onMessage); setTimeout(function(){ pub.up.callback(true); }, 0); } }
javascript
function(event){ if (event.data == config.channel + "-ready") { // replace the eventlistener callerWindow = ("postMessage" in frame.contentWindow) ? frame.contentWindow : frame.contentWindow.document; un(window, "message", waitForReady); on(window, "message", _window_onMessage); setTimeout(function(){ pub.up.callback(true); }, 0); } }
[ "function", "(", "event", ")", "{", "if", "(", "event", ".", "data", "==", "config", ".", "channel", "+", "\"-ready\"", ")", "{", "// replace the eventlistener", "callerWindow", "=", "(", "\"postMessage\"", "in", "frame", ".", "contentWindow", ")", "?", "frame", ".", "contentWindow", ":", "frame", ".", "contentWindow", ".", "document", ";", "un", "(", "window", ",", "\"message\"", ",", "waitForReady", ")", ";", "on", "(", "window", ",", "\"message\"", ",", "_window_onMessage", ")", ";", "setTimeout", "(", "function", "(", ")", "{", "pub", ".", "up", ".", "callback", "(", "true", ")", ";", "}", ",", "0", ")", ";", "}", "}" ]
add the event handler for listening
[ "add", "the", "event", "handler", "for", "listening" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L1663-L1673
22,489
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
function(){ // Remove the handler var w = callerWindow || this; un(w, "load", onLoad); easyXDM.Fn.set(config.channel + "_load", _onLoad); (function test(){ if (typeof w.contentWindow.sendMessage == "function") { _onReady(); } else { setTimeout(test, 50); } }()); }
javascript
function(){ // Remove the handler var w = callerWindow || this; un(w, "load", onLoad); easyXDM.Fn.set(config.channel + "_load", _onLoad); (function test(){ if (typeof w.contentWindow.sendMessage == "function") { _onReady(); } else { setTimeout(test, 50); } }()); }
[ "function", "(", ")", "{", "// Remove the handler", "var", "w", "=", "callerWindow", "||", "this", ";", "un", "(", "w", ",", "\"load\"", ",", "onLoad", ")", ";", "easyXDM", ".", "Fn", ".", "set", "(", "config", ".", "channel", "+", "\"_load\"", ",", "_onLoad", ")", ";", "(", "function", "test", "(", ")", "{", "if", "(", "typeof", "w", ".", "contentWindow", ".", "sendMessage", "==", "\"function\"", ")", "{", "_onReady", "(", ")", ";", "}", "else", "{", "setTimeout", "(", "test", ",", "50", ")", ";", "}", "}", "(", ")", ")", ";", "}" ]
Set up the iframe that will be used for the transport
[ "Set", "up", "the", "iframe", "that", "will", "be", "used", "for", "the", "transport" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L1913-L1926
22,490
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
_pollHash
function _pollHash(){ if (!_listenerWindow) { return; } var href = _listenerWindow.location.href, hash = "", indexOf = href.indexOf("#"); if (indexOf != -1) { hash = href.substring(indexOf); } if (hash && hash != _lastMsg) { _handleHash(hash); } }
javascript
function _pollHash(){ if (!_listenerWindow) { return; } var href = _listenerWindow.location.href, hash = "", indexOf = href.indexOf("#"); if (indexOf != -1) { hash = href.substring(indexOf); } if (hash && hash != _lastMsg) { _handleHash(hash); } }
[ "function", "_pollHash", "(", ")", "{", "if", "(", "!", "_listenerWindow", ")", "{", "return", ";", "}", "var", "href", "=", "_listenerWindow", ".", "location", ".", "href", ",", "hash", "=", "\"\"", ",", "indexOf", "=", "href", ".", "indexOf", "(", "\"#\"", ")", ";", "if", "(", "indexOf", "!=", "-", "1", ")", "{", "hash", "=", "href", ".", "substring", "(", "indexOf", ")", ";", "}", "if", "(", "hash", "&&", "hash", "!=", "_lastMsg", ")", "{", "_handleHash", "(", "hash", ")", ";", "}", "}" ]
Checks location.hash for a new message and relays this to the receiver. @private
[ "Checks", "location", ".", "hash", "for", "a", "new", "message", "and", "relays", "this", "to", "the", "receiver", "." ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L1999-L2010
22,491
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
_send
function _send(data){ data.jsonrpc = "2.0"; pub.down.outgoing(serializer.stringify(data)); }
javascript
function _send(data){ data.jsonrpc = "2.0"; pub.down.outgoing(serializer.stringify(data)); }
[ "function", "_send", "(", "data", ")", "{", "data", ".", "jsonrpc", "=", "\"2.0\"", ";", "pub", ".", "down", ".", "outgoing", "(", "serializer", ".", "stringify", "(", "data", ")", ")", ";", "}" ]
Serializes and sends the message @private @param {Object} data The JSON-RPC message to be sent. The jsonrpc property will be added.
[ "Serializes", "and", "sends", "the", "message" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L2420-L2423
22,492
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
_createMethod
function _createMethod(definition, method){ var slice = Array.prototype.slice; return function(){ var l = arguments.length, callback, message = { method: method }; if (l > 0 && typeof arguments[l - 1] === "function") { //with callback, procedure if (l > 1 && typeof arguments[l - 2] === "function") { // two callbacks, success and error callback = { success: arguments[l - 2], error: arguments[l - 1] }; message.params = slice.call(arguments, 0, l - 2); } else { // single callback, success callback = { success: arguments[l - 1] }; message.params = slice.call(arguments, 0, l - 1); } _callbacks["" + (++_callbackCounter)] = callback; message.id = _callbackCounter; } else { // no callbacks, a notification message.params = slice.call(arguments, 0); } if (definition.namedParams && message.params.length === 1) { message.params = message.params[0]; } // Send the method request _send(message); }; }
javascript
function _createMethod(definition, method){ var slice = Array.prototype.slice; return function(){ var l = arguments.length, callback, message = { method: method }; if (l > 0 && typeof arguments[l - 1] === "function") { //with callback, procedure if (l > 1 && typeof arguments[l - 2] === "function") { // two callbacks, success and error callback = { success: arguments[l - 2], error: arguments[l - 1] }; message.params = slice.call(arguments, 0, l - 2); } else { // single callback, success callback = { success: arguments[l - 1] }; message.params = slice.call(arguments, 0, l - 1); } _callbacks["" + (++_callbackCounter)] = callback; message.id = _callbackCounter; } else { // no callbacks, a notification message.params = slice.call(arguments, 0); } if (definition.namedParams && message.params.length === 1) { message.params = message.params[0]; } // Send the method request _send(message); }; }
[ "function", "_createMethod", "(", "definition", ",", "method", ")", "{", "var", "slice", "=", "Array", ".", "prototype", ".", "slice", ";", "return", "function", "(", ")", "{", "var", "l", "=", "arguments", ".", "length", ",", "callback", ",", "message", "=", "{", "method", ":", "method", "}", ";", "if", "(", "l", ">", "0", "&&", "typeof", "arguments", "[", "l", "-", "1", "]", "===", "\"function\"", ")", "{", "//with callback, procedure", "if", "(", "l", ">", "1", "&&", "typeof", "arguments", "[", "l", "-", "2", "]", "===", "\"function\"", ")", "{", "// two callbacks, success and error", "callback", "=", "{", "success", ":", "arguments", "[", "l", "-", "2", "]", ",", "error", ":", "arguments", "[", "l", "-", "1", "]", "}", ";", "message", ".", "params", "=", "slice", ".", "call", "(", "arguments", ",", "0", ",", "l", "-", "2", ")", ";", "}", "else", "{", "// single callback, success", "callback", "=", "{", "success", ":", "arguments", "[", "l", "-", "1", "]", "}", ";", "message", ".", "params", "=", "slice", ".", "call", "(", "arguments", ",", "0", ",", "l", "-", "1", ")", ";", "}", "_callbacks", "[", "\"\"", "+", "(", "++", "_callbackCounter", ")", "]", "=", "callback", ";", "message", ".", "id", "=", "_callbackCounter", ";", "}", "else", "{", "// no callbacks, a notification", "message", ".", "params", "=", "slice", ".", "call", "(", "arguments", ",", "0", ")", ";", "}", "if", "(", "definition", ".", "namedParams", "&&", "message", ".", "params", ".", "length", "===", "1", ")", "{", "message", ".", "params", "=", "message", ".", "params", "[", "0", "]", ";", "}", "// Send the method request", "_send", "(", "message", ")", ";", "}", ";", "}" ]
Creates a method that implements the given definition @private @param {Object} The method configuration @param {String} method The name of the method @return {Function} A stub capable of proxying the requested method call
[ "Creates", "a", "method", "that", "implements", "the", "given", "definition" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L2432-L2470
22,493
OpenF2/F2
sdk/src/third-party/easyXDM/easyXDM.js
_executeMethod
function _executeMethod(method, id, fn, params){ if (!fn) { if (id) { _send({ id: id, error: { code: -32601, message: "Procedure not found." } }); } return; } var success, error; if (id) { success = function(result){ success = emptyFn; _send({ id: id, result: result }); }; error = function(message, data){ error = emptyFn; var msg = { id: id, error: { code: -32099, message: message } }; if (data) { msg.error.data = data; } _send(msg); }; } else { success = error = emptyFn; } // Call local method if (!isArray(params)) { params = [params]; } try { var result = fn.method.apply(fn.scope, params.concat([success, error])); if (!undef(result)) { success(result); } } catch (ex1) { error(ex1.message); } }
javascript
function _executeMethod(method, id, fn, params){ if (!fn) { if (id) { _send({ id: id, error: { code: -32601, message: "Procedure not found." } }); } return; } var success, error; if (id) { success = function(result){ success = emptyFn; _send({ id: id, result: result }); }; error = function(message, data){ error = emptyFn; var msg = { id: id, error: { code: -32099, message: message } }; if (data) { msg.error.data = data; } _send(msg); }; } else { success = error = emptyFn; } // Call local method if (!isArray(params)) { params = [params]; } try { var result = fn.method.apply(fn.scope, params.concat([success, error])); if (!undef(result)) { success(result); } } catch (ex1) { error(ex1.message); } }
[ "function", "_executeMethod", "(", "method", ",", "id", ",", "fn", ",", "params", ")", "{", "if", "(", "!", "fn", ")", "{", "if", "(", "id", ")", "{", "_send", "(", "{", "id", ":", "id", ",", "error", ":", "{", "code", ":", "-", "32601", ",", "message", ":", "\"Procedure not found.\"", "}", "}", ")", ";", "}", "return", ";", "}", "var", "success", ",", "error", ";", "if", "(", "id", ")", "{", "success", "=", "function", "(", "result", ")", "{", "success", "=", "emptyFn", ";", "_send", "(", "{", "id", ":", "id", ",", "result", ":", "result", "}", ")", ";", "}", ";", "error", "=", "function", "(", "message", ",", "data", ")", "{", "error", "=", "emptyFn", ";", "var", "msg", "=", "{", "id", ":", "id", ",", "error", ":", "{", "code", ":", "-", "32099", ",", "message", ":", "message", "}", "}", ";", "if", "(", "data", ")", "{", "msg", ".", "error", ".", "data", "=", "data", ";", "}", "_send", "(", "msg", ")", ";", "}", ";", "}", "else", "{", "success", "=", "error", "=", "emptyFn", ";", "}", "// Call local method", "if", "(", "!", "isArray", "(", "params", ")", ")", "{", "params", "=", "[", "params", "]", ";", "}", "try", "{", "var", "result", "=", "fn", ".", "method", ".", "apply", "(", "fn", ".", "scope", ",", "params", ".", "concat", "(", "[", "success", ",", "error", "]", ")", ")", ";", "if", "(", "!", "undef", "(", "result", ")", ")", "{", "success", "(", "result", ")", ";", "}", "}", "catch", "(", "ex1", ")", "{", "error", "(", "ex1", ".", "message", ")", ";", "}", "}" ]
Executes the exposed method @private @param {String} method The name of the method @param {Number} id The callback id to use @param {Function} method The exposed implementation @param {Array} params The parameters supplied by the remote end
[ "Executes", "the", "exposed", "method" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/sdk/src/third-party/easyXDM/easyXDM.js#L2480-L2534
22,494
OpenF2/F2
dist/f2.debug.js
function(instanceId) { if (_apps[instanceId] && _apps[instanceId].socket) { _apps[instanceId].socket.destroy(); } delete _apps[instanceId]; }
javascript
function(instanceId) { if (_apps[instanceId] && _apps[instanceId].socket) { _apps[instanceId].socket.destroy(); } delete _apps[instanceId]; }
[ "function", "(", "instanceId", ")", "{", "if", "(", "_apps", "[", "instanceId", "]", "&&", "_apps", "[", "instanceId", "]", ".", "socket", ")", "{", "_apps", "[", "instanceId", "]", ".", "socket", ".", "destroy", "(", ")", ";", "}", "delete", "_apps", "[", "instanceId", "]", ";", "}" ]
Cleans up a given app instance @method destroy @param {string} instanceId The Instance ID
[ "Cleans", "up", "a", "given", "app", "instance" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.debug.js#L17070-L17075
22,495
OpenF2/F2
dist/f2.debug.js
function(instanceId) { if (!_isInit()) { F2.log('F2.init() must be called before F2.removeApp()'); return; } if (_apps[instanceId]) { F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_BEFORE, _apps[instanceId] // the app instance ); F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY, _apps[instanceId] // the app instance ); F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_AFTER, _apps[instanceId] // the app instance ); if (_apps[instanceId].config.isSecure) { F2.Rpc.destroy(instanceId); } delete _apps[instanceId]; } }
javascript
function(instanceId) { if (!_isInit()) { F2.log('F2.init() must be called before F2.removeApp()'); return; } if (_apps[instanceId]) { F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_BEFORE, _apps[instanceId] // the app instance ); F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY, _apps[instanceId] // the app instance ); F2.AppHandlers.__trigger( _sAppHandlerToken, F2.Constants.AppHandlers.APP_DESTROY_AFTER, _apps[instanceId] // the app instance ); if (_apps[instanceId].config.isSecure) { F2.Rpc.destroy(instanceId); } delete _apps[instanceId]; } }
[ "function", "(", "instanceId", ")", "{", "if", "(", "!", "_isInit", "(", ")", ")", "{", "F2", ".", "log", "(", "'F2.init() must be called before F2.removeApp()'", ")", ";", "return", ";", "}", "if", "(", "_apps", "[", "instanceId", "]", ")", "{", "F2", ".", "AppHandlers", ".", "__trigger", "(", "_sAppHandlerToken", ",", "F2", ".", "Constants", ".", "AppHandlers", ".", "APP_DESTROY_BEFORE", ",", "_apps", "[", "instanceId", "]", "// the app instance", ")", ";", "F2", ".", "AppHandlers", ".", "__trigger", "(", "_sAppHandlerToken", ",", "F2", ".", "Constants", ".", "AppHandlers", ".", "APP_DESTROY", ",", "_apps", "[", "instanceId", "]", "// the app instance", ")", ";", "F2", ".", "AppHandlers", ".", "__trigger", "(", "_sAppHandlerToken", ",", "F2", ".", "Constants", ".", "AppHandlers", ".", "APP_DESTROY_AFTER", ",", "_apps", "[", "instanceId", "]", "// the app instance", ")", ";", "if", "(", "_apps", "[", "instanceId", "]", ".", "config", ".", "isSecure", ")", "{", "F2", ".", "Rpc", ".", "destroy", "(", "instanceId", ")", ";", "}", "delete", "_apps", "[", "instanceId", "]", ";", "}", "}" ]
Removes an app from the container @method removeApp @param {string} instanceId The app's instanceId
[ "Removes", "an", "app", "from", "the", "container" ]
6e1e554e29b622f7007292a3e2a35feeb22f2b27
https://github.com/OpenF2/F2/blob/6e1e554e29b622f7007292a3e2a35feeb22f2b27/dist/f2.debug.js#L18725-L18757
22,496
dasmoth/dalliance
js/bam.js
parseBamHeader
function parseBamHeader(r) { if (!r) { return callback(null, "Couldn't access BAM"); } var unc = unbgzf(r, r.byteLength); var uncba = new Uint8Array(unc); var magic = readInt(uncba, 0); if (magic != BAM_MAGIC) { return callback(null, "Not a BAM file, magic=0x" + magic.toString(16)); } var headLen = readInt(uncba, 4); var header = ''; for (var i = 0; i < headLen; ++i) { header += String.fromCharCode(uncba[i + 8]); } var nRef = readInt(uncba, headLen + 8); var p = headLen + 12; bam.chrToIndex = {}; bam.indexToChr = []; for (var i = 0; i < nRef; ++i) { var lName = readInt(uncba, p); var name = ''; for (var j = 0; j < lName-1; ++j) { name += String.fromCharCode(uncba[p + 4 + j]); } var lRef = readInt(uncba, p + lName + 4); bam.chrToIndex[name] = i; if (name.indexOf('chr') == 0) { bam.chrToIndex[name.substring(3)] = i; } else { bam.chrToIndex['chr' + name] = i; } bam.indexToChr.push(name); p = p + 8 + lName; } if (bam.indices) { return callback(bam); } }
javascript
function parseBamHeader(r) { if (!r) { return callback(null, "Couldn't access BAM"); } var unc = unbgzf(r, r.byteLength); var uncba = new Uint8Array(unc); var magic = readInt(uncba, 0); if (magic != BAM_MAGIC) { return callback(null, "Not a BAM file, magic=0x" + magic.toString(16)); } var headLen = readInt(uncba, 4); var header = ''; for (var i = 0; i < headLen; ++i) { header += String.fromCharCode(uncba[i + 8]); } var nRef = readInt(uncba, headLen + 8); var p = headLen + 12; bam.chrToIndex = {}; bam.indexToChr = []; for (var i = 0; i < nRef; ++i) { var lName = readInt(uncba, p); var name = ''; for (var j = 0; j < lName-1; ++j) { name += String.fromCharCode(uncba[p + 4 + j]); } var lRef = readInt(uncba, p + lName + 4); bam.chrToIndex[name] = i; if (name.indexOf('chr') == 0) { bam.chrToIndex[name.substring(3)] = i; } else { bam.chrToIndex['chr' + name] = i; } bam.indexToChr.push(name); p = p + 8 + lName; } if (bam.indices) { return callback(bam); } }
[ "function", "parseBamHeader", "(", "r", ")", "{", "if", "(", "!", "r", ")", "{", "return", "callback", "(", "null", ",", "\"Couldn't access BAM\"", ")", ";", "}", "var", "unc", "=", "unbgzf", "(", "r", ",", "r", ".", "byteLength", ")", ";", "var", "uncba", "=", "new", "Uint8Array", "(", "unc", ")", ";", "var", "magic", "=", "readInt", "(", "uncba", ",", "0", ")", ";", "if", "(", "magic", "!=", "BAM_MAGIC", ")", "{", "return", "callback", "(", "null", ",", "\"Not a BAM file, magic=0x\"", "+", "magic", ".", "toString", "(", "16", ")", ")", ";", "}", "var", "headLen", "=", "readInt", "(", "uncba", ",", "4", ")", ";", "var", "header", "=", "''", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "headLen", ";", "++", "i", ")", "{", "header", "+=", "String", ".", "fromCharCode", "(", "uncba", "[", "i", "+", "8", "]", ")", ";", "}", "var", "nRef", "=", "readInt", "(", "uncba", ",", "headLen", "+", "8", ")", ";", "var", "p", "=", "headLen", "+", "12", ";", "bam", ".", "chrToIndex", "=", "{", "}", ";", "bam", ".", "indexToChr", "=", "[", "]", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "nRef", ";", "++", "i", ")", "{", "var", "lName", "=", "readInt", "(", "uncba", ",", "p", ")", ";", "var", "name", "=", "''", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<", "lName", "-", "1", ";", "++", "j", ")", "{", "name", "+=", "String", ".", "fromCharCode", "(", "uncba", "[", "p", "+", "4", "+", "j", "]", ")", ";", "}", "var", "lRef", "=", "readInt", "(", "uncba", ",", "p", "+", "lName", "+", "4", ")", ";", "bam", ".", "chrToIndex", "[", "name", "]", "=", "i", ";", "if", "(", "name", ".", "indexOf", "(", "'chr'", ")", "==", "0", ")", "{", "bam", ".", "chrToIndex", "[", "name", ".", "substring", "(", "3", ")", "]", "=", "i", ";", "}", "else", "{", "bam", ".", "chrToIndex", "[", "'chr'", "+", "name", "]", "=", "i", ";", "}", "bam", ".", "indexToChr", ".", "push", "(", "name", ")", ";", "p", "=", "p", "+", "8", "+", "lName", ";", "}", "if", "(", "bam", ".", "indices", ")", "{", "return", "callback", "(", "bam", ")", ";", "}", "}" ]
Fills out bam.chrToIndex and bam.indexToChr based on the first few bytes of the BAM.
[ "Fills", "out", "bam", ".", "chrToIndex", "and", "bam", ".", "indexToChr", "based", "on", "the", "first", "few", "bytes", "of", "the", "BAM", "." ]
64565abc974433a5dcd5406d17fa0a202e1e55fc
https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/bam.js#L111-L155
22,497
dasmoth/dalliance
js/twoBit.js
function() { while (i < tb.seqCount) { var ns = ba[p]; if (p + ns + 2 + (tb.version == 0 ? 4 : 8) >= ba.length) { headerBlocksFetched += headerBlockSize; headerBlockSize = Math.max(HEADER_BLOCK_SIZE,Math.floor(headerBlocksFetched*tb.seqCount/i)); return tb.data.slice(o + p, headerBlockSize).fetch(function (r) { o += p; p = 0; ba = new Uint8Array(r); parseSeqInfo(); }); } else { ++p; var name = ''; for (var j = 1; j <= ns; ++j) { name += String.fromCharCode(ba[p++]); } if (tb.version == 0) { var offset = tb.readInt(ba, p); p += 4; } else { var offset = tb.readInt64(ba, p); p += 8; } tb.seqDict[name] = new TwoBitSeq(tb, offset); ++i; } } return cnt(tb); }
javascript
function() { while (i < tb.seqCount) { var ns = ba[p]; if (p + ns + 2 + (tb.version == 0 ? 4 : 8) >= ba.length) { headerBlocksFetched += headerBlockSize; headerBlockSize = Math.max(HEADER_BLOCK_SIZE,Math.floor(headerBlocksFetched*tb.seqCount/i)); return tb.data.slice(o + p, headerBlockSize).fetch(function (r) { o += p; p = 0; ba = new Uint8Array(r); parseSeqInfo(); }); } else { ++p; var name = ''; for (var j = 1; j <= ns; ++j) { name += String.fromCharCode(ba[p++]); } if (tb.version == 0) { var offset = tb.readInt(ba, p); p += 4; } else { var offset = tb.readInt64(ba, p); p += 8; } tb.seqDict[name] = new TwoBitSeq(tb, offset); ++i; } } return cnt(tb); }
[ "function", "(", ")", "{", "while", "(", "i", "<", "tb", ".", "seqCount", ")", "{", "var", "ns", "=", "ba", "[", "p", "]", ";", "if", "(", "p", "+", "ns", "+", "2", "+", "(", "tb", ".", "version", "==", "0", "?", "4", ":", "8", ")", ">=", "ba", ".", "length", ")", "{", "headerBlocksFetched", "+=", "headerBlockSize", ";", "headerBlockSize", "=", "Math", ".", "max", "(", "HEADER_BLOCK_SIZE", ",", "Math", ".", "floor", "(", "headerBlocksFetched", "*", "tb", ".", "seqCount", "/", "i", ")", ")", ";", "return", "tb", ".", "data", ".", "slice", "(", "o", "+", "p", ",", "headerBlockSize", ")", ".", "fetch", "(", "function", "(", "r", ")", "{", "o", "+=", "p", ";", "p", "=", "0", ";", "ba", "=", "new", "Uint8Array", "(", "r", ")", ";", "parseSeqInfo", "(", ")", ";", "}", ")", ";", "}", "else", "{", "++", "p", ";", "var", "name", "=", "''", ";", "for", "(", "var", "j", "=", "1", ";", "j", "<=", "ns", ";", "++", "j", ")", "{", "name", "+=", "String", ".", "fromCharCode", "(", "ba", "[", "p", "++", "]", ")", ";", "}", "if", "(", "tb", ".", "version", "==", "0", ")", "{", "var", "offset", "=", "tb", ".", "readInt", "(", "ba", ",", "p", ")", ";", "p", "+=", "4", ";", "}", "else", "{", "var", "offset", "=", "tb", ".", "readInt64", "(", "ba", ",", "p", ")", ";", "p", "+=", "8", ";", "}", "tb", ".", "seqDict", "[", "name", "]", "=", "new", "TwoBitSeq", "(", "tb", ",", "offset", ")", ";", "++", "i", ";", "}", "}", "return", "cnt", "(", "tb", ")", ";", "}" ]
Offset of the current block if we need to fetch multiple header blocks.
[ "Offset", "of", "the", "current", "block", "if", "we", "need", "to", "fetch", "multiple", "header", "blocks", "." ]
64565abc974433a5dcd5406d17fa0a202e1e55fc
https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/twoBit.js#L65-L95
22,498
dasmoth/dalliance
js/sample.js
alignSeqUsingCigar
function alignSeqUsingCigar(rawseq, rawquals, cigar) { var ops = parseCigar(cigar); var seq = []; var quals = []; var cursor = 0; for (var ci = 0; ci < ops.length; ++ci) { var co = ops[ci]; if (co.op == 'M') { seq.push(rawseq.substr(cursor, co.cnt)); quals.push(rawquals.substr(cursor, co.cnt)); cursor += co.cnt; } else if (co.op == 'D') { for (var oi = 0; oi < co.cnt; ++oi) { seq.push('-'); quals.push('Z'); } } else if (co.op == 'I') { cursor += co.cnt; } else if (co.op == 'S') { cursor += co.cnt; } else { console.log('unknown cigop' + co.op); } } var processedSeq = {seq: seq.join(''), quals: quals.join('')}; return processedSeq; }
javascript
function alignSeqUsingCigar(rawseq, rawquals, cigar) { var ops = parseCigar(cigar); var seq = []; var quals = []; var cursor = 0; for (var ci = 0; ci < ops.length; ++ci) { var co = ops[ci]; if (co.op == 'M') { seq.push(rawseq.substr(cursor, co.cnt)); quals.push(rawquals.substr(cursor, co.cnt)); cursor += co.cnt; } else if (co.op == 'D') { for (var oi = 0; oi < co.cnt; ++oi) { seq.push('-'); quals.push('Z'); } } else if (co.op == 'I') { cursor += co.cnt; } else if (co.op == 'S') { cursor += co.cnt; } else { console.log('unknown cigop' + co.op); } } var processedSeq = {seq: seq.join(''), quals: quals.join('')}; return processedSeq; }
[ "function", "alignSeqUsingCigar", "(", "rawseq", ",", "rawquals", ",", "cigar", ")", "{", "var", "ops", "=", "parseCigar", "(", "cigar", ")", ";", "var", "seq", "=", "[", "]", ";", "var", "quals", "=", "[", "]", ";", "var", "cursor", "=", "0", ";", "for", "(", "var", "ci", "=", "0", ";", "ci", "<", "ops", ".", "length", ";", "++", "ci", ")", "{", "var", "co", "=", "ops", "[", "ci", "]", ";", "if", "(", "co", ".", "op", "==", "'M'", ")", "{", "seq", ".", "push", "(", "rawseq", ".", "substr", "(", "cursor", ",", "co", ".", "cnt", ")", ")", ";", "quals", ".", "push", "(", "rawquals", ".", "substr", "(", "cursor", ",", "co", ".", "cnt", ")", ")", ";", "cursor", "+=", "co", ".", "cnt", ";", "}", "else", "if", "(", "co", ".", "op", "==", "'D'", ")", "{", "for", "(", "var", "oi", "=", "0", ";", "oi", "<", "co", ".", "cnt", ";", "++", "oi", ")", "{", "seq", ".", "push", "(", "'-'", ")", ";", "quals", ".", "push", "(", "'Z'", ")", ";", "}", "}", "else", "if", "(", "co", ".", "op", "==", "'I'", ")", "{", "cursor", "+=", "co", ".", "cnt", ";", "}", "else", "if", "(", "co", ".", "op", "==", "'S'", ")", "{", "cursor", "+=", "co", ".", "cnt", ";", "}", "else", "{", "console", ".", "log", "(", "'unknown cigop'", "+", "co", ".", "op", ")", ";", "}", "}", "var", "processedSeq", "=", "{", "seq", ":", "seq", ".", "join", "(", "''", ")", ",", "quals", ":", "quals", ".", "join", "(", "''", ")", "}", ";", "return", "processedSeq", ";", "}" ]
Generates an aligned read from the raw sequence of a BAM record using given cigar string. Params: rawseq: unaligned read sequence from Bam record rawquals: unaligned read quals from Bam record cigar: Bam cigar string from Bam record Returns an object with 2 properties: seq: string containing aligned read quals: string containing printable-character representation of sequencing quality score
[ "Generates", "an", "aligned", "read", "from", "the", "raw", "sequence", "of", "a", "BAM", "record", "using", "given", "cigar", "string", "." ]
64565abc974433a5dcd5406d17fa0a202e1e55fc
https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/sample.js#L279-L305
22,499
dasmoth/dalliance
js/sample.js
getRefSeq
function getRefSeq(currentSequence, min, max) { var refSeq = []; if (currentSequence) { var csStart = currentSequence.start|0; var csEnd = currentSequence.end|0; if (csStart <= max && csEnd >= min) { var sfMin = Math.max(min, csStart); var sfMax = Math.min(max, csEnd); for (var i = 0; i < sfMin - min; i++) refSeq.push('N'); refSeq.push(currentSequence.seq.substr(sfMin - csStart, sfMax - sfMin + 1)); for (var i = 0; i < max - sfMax; i++) refSeq.push('N'); } } return refSeq.join(''); }
javascript
function getRefSeq(currentSequence, min, max) { var refSeq = []; if (currentSequence) { var csStart = currentSequence.start|0; var csEnd = currentSequence.end|0; if (csStart <= max && csEnd >= min) { var sfMin = Math.max(min, csStart); var sfMax = Math.min(max, csEnd); for (var i = 0; i < sfMin - min; i++) refSeq.push('N'); refSeq.push(currentSequence.seq.substr(sfMin - csStart, sfMax - sfMin + 1)); for (var i = 0; i < max - sfMax; i++) refSeq.push('N'); } } return refSeq.join(''); }
[ "function", "getRefSeq", "(", "currentSequence", ",", "min", ",", "max", ")", "{", "var", "refSeq", "=", "[", "]", ";", "if", "(", "currentSequence", ")", "{", "var", "csStart", "=", "currentSequence", ".", "start", "|", "0", ";", "var", "csEnd", "=", "currentSequence", ".", "end", "|", "0", ";", "if", "(", "csStart", "<=", "max", "&&", "csEnd", ">=", "min", ")", "{", "var", "sfMin", "=", "Math", ".", "max", "(", "min", ",", "csStart", ")", ";", "var", "sfMax", "=", "Math", ".", "min", "(", "max", ",", "csEnd", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "sfMin", "-", "min", ";", "i", "++", ")", "refSeq", ".", "push", "(", "'N'", ")", ";", "refSeq", ".", "push", "(", "currentSequence", ".", "seq", ".", "substr", "(", "sfMin", "-", "csStart", ",", "sfMax", "-", "sfMin", "+", "1", ")", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "max", "-", "sfMax", ";", "i", "++", ")", "refSeq", ".", "push", "(", "'N'", ")", ";", "}", "}", "return", "refSeq", ".", "join", "(", "''", ")", ";", "}" ]
Constructs the reference sequence for a given window. Params currentSequence: DasSequence object containing ref sequence in current browser view. min, max: min and max position for window. Returns a string containing the refseq, padded with 'N' where sequence is not available.
[ "Constructs", "the", "reference", "sequence", "for", "a", "given", "window", "." ]
64565abc974433a5dcd5406d17fa0a202e1e55fc
https://github.com/dasmoth/dalliance/blob/64565abc974433a5dcd5406d17fa0a202e1e55fc/js/sample.js#L317-L334