_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q51200 | train | function(element, block) {
var selector = 'data-' + (block || this.keyName);
if (element) {
selector += '-' + element;
}
if (this.namespace) {
selector += '="' + this.namespace + '"';
}
return '[' + selector + ']';
} | javascript | {
"resource": ""
} | |
q51201 | train | function(content) {
if (content.callback) {
var namespaces = content.callback.split('.'),
func = window, prev = func;
for (var i = 0; i < namespaces.length; i++) {
prev = func;
func = func[namespaces[i]];
}
func.ca... | javascript | {
"resource": ""
} | |
q51202 | train | function(element, key) {
var value = element.data((this.keyName + '-' + key).toLowerCase());
if ($.type(value) === 'undefined') {
value = this.options[key];
}
return value;
} | javascript | {
"resource": ""
} | |
q51203 | train | function(element, query) {
if (!query) {
return null;
}
element = $(element);
if ($.type(query) === 'function') {
return query.call(this, element);
}
return element.attr(query);
} | javascript | {
"resource": ""
} | |
q51204 | train | function(options, params) {
var ajax = {};
// Determine base options
if ($.type(this.options.ajax) === 'object') {
ajax = this.options.ajax;
}
// Set default options
if ($.type(options) === 'string') {
ajax.url = options;
} else {
... | javascript | {
"resource": ""
} | |
q51205 | train | function(options, inheritFrom) {
// Inherit options from a group if the data attribute exists
// Do this first so responsive options can be triggered afterwards
if (inheritFrom) {
var group = this.readOption(inheritFrom, 'group');
if (group && options.groups[group]) {
... | javascript | {
"resource": ""
} | |
q51206 | train | function(element, options) {
var self = this;
element = this.setElement(element).attr('role', 'tablist');
options = this.setOptions(options, element);
// Find headers and cache the index of each header and set ARIA attributes
this.headers = element.find(this.ns('header')).each(... | javascript | {
"resource": ""
} | |
q51207 | train | function(options) {
options = this.setOptions(options);
this.element = this.createElement();
// Generate loader elements
this.loader = this.render(options.loaderTemplate).appendTo(this.element);
this.message = this.loader.find(this.ns('message', 'loader'));
if (options.... | javascript | {
"resource": ""
} | |
q51208 | train | function() {
this.fireEvent('hiding');
var count = this.count - 1;
if (count <= 0) {
this.count = 0;
this.element.conceal();
} else {
this.count = count;
}
this.hideLoader();
this.fireEvent('hidden', [(count <= 0)]);
} | javascript | {
"resource": ""
} | |
q51209 | train | function() {
this.fireEvent('showing');
var show = false;
this.count++;
if (this.count === 1) {
this.element.reveal();
show = true;
}
this.showLoader();
this.fireEvent('shown', [show]);
} | javascript | {
"resource": ""
} | |
q51210 | train | function() {
var self = $(this),
start,
target;
/**
* There's a major bug in Android devices where `touchend` events do not fire
* without calling `preventDefault()` in `touchstart` or `touchmove`.
* Because of this, we have... | javascript | {
"resource": ""
} | |
q51211 | cleanup | train | function cleanup() {
start = target = null;
swiping = false;
self.off(moveEvent, move);
} | javascript | {
"resource": ""
} |
q51212 | train | function() {
var options = this.options;
return this.wrapper = this.render(options.wrapperTemplate)
.addClass(Toolkit.buildTemplate(options.wrapperClass))
.attr('id', this.id('wrapper'))
.appendTo('body');
} | javascript | {
"resource": ""
} | |
q51213 | train | function(node, callback) {
var elements = this.elements,
el,
id = $(node).cache('toolkit.cid', function() {
return Math.random().toString(32).substr(2);
});
if (elements[id]) {
el = elements[id];
} else {
el = elements[... | javascript | {
"resource": ""
} | |
q51214 | train | function(e) {
var node = $(e.currentTarget),
element,
isNode = (this.node && this.node.is(node)),
cid = node.data('toolkit.cid');
// Set the current element based on the nodes composite ID
if (cid && this.elements[cid]) {
element = this.elements[c... | javascript | {
"resource": ""
} | |
q51215 | train | function(node) {
var target = this.readValue(node, this.options.getTarget);
if (!target || target.substr(0, 1) !== '#') {
throw new Error('Drop menu ' + target + ' does not exist');
}
return $(target);
} | javascript | {
"resource": ""
} | |
q51216 | train | function() {
var element = this.element,
node = this.node;
// Clickout check
if (!element && !node) {
return;
}
this.fireEvent('hiding', [element, node]);
element.conceal();
node
.aria('toggled', false)
.removeCl... | javascript | {
"resource": ""
} | |
q51217 | train | function(node) {
this.node = node = $(node);
var element = this.loadElement(node);
this.fireEvent('showing', [element, node]);
element.reveal();
node
.aria('toggled', true)
.addClass('is-active');
this.fireEvent('shown', [element, node]);
... | javascript | {
"resource": ""
} | |
q51218 | train | function(e) {
e.preventDefault();
// Hide previous drops
this.hide();
// Toggle the menu
var node = $(e.currentTarget),
menu = this.loadElement(node);
if (!menu.is(':shown')) {
this.show(node);
} else {
this.hide();
... | javascript | {
"resource": ""
} | |
q51219 | train | function(nodes, url, options) {
if (Toolkit.isTouch) {
return; // Flyouts shouldn't be usable on touch devices
}
this.nodes = $(nodes);
options = this.setOptions(options);
this.createWrapper();
if (options.mode === 'click') {
this.addEvents([
... | javascript | {
"resource": ""
} | |
q51220 | train | function(data, depth) {
depth = depth || 0;
// If root, store the data
if (!depth) {
this.data = data;
}
// Store the data indexed by URL
if (data.url) {
this.dataMap[data.url] = data;
}
if (data.children) {
for (var ... | javascript | {
"resource": ""
} | |
q51221 | train | function() {
var options = this.options,
node = this.node,
element = this.loadElement(node);
// Only position if the menu has children
if (!element.children().length) {
return;
}
this.fireEvent('showing');
var height = element.outerH... | javascript | {
"resource": ""
} | |
q51222 | train | function(node) {
node = $(node);
var target = this.readValue(node, this.options.getUrl) || node.attr('href');
// When jumping from one node to another
// Immediately hide the other menu and start the timer for the current one
if (this.url && target !== this.url) {
t... | javascript | {
"resource": ""
} | |
q51223 | train | function(key, delay, args) {
this.clearTimer(key);
var func;
if (key === 'show') {
func = this.position;
} else {
func = this.hide;
}
if (func) {
this.timers[key] = setTimeout(function() {
func.apply(this, args || [])... | javascript | {
"resource": ""
} | |
q51224 | train | function(parent) {
parent = $(parent);
parent.removeClass('is-open');
parent.children(this.ns('menu'))
.removeAttr('style')
.aria({
expanded: false,
hidden: false
})
.conceal();
this.fireEvent('hideChild', [... | javascript | {
"resource": ""
} | |
q51225 | train | function(parent) {
var menu = parent.children(this.ns('menu'));
if (!menu) {
return;
}
menu.aria({
expanded: true,
hidden: true
});
// Alter width because of columns
var children = menu.children();
menu.css('width', ... | javascript | {
"resource": ""
} | |
q51226 | train | function(element, options) {
element = this.setElement(element);
options = this.setOptions(options, element);
if (options.checkbox) {
element.find(options.checkbox).inputCheckbox(options);
}
if (options.radio) {
element.find(options.radio).inputRadio(opt... | javascript | {
"resource": ""
} | |
q51227 | train | function() {
var options = this.options,
element = this.element;
if (this.name === 'Input') {
if (options.checkbox) {
element.find(options.checkbox).each(function() {
$(this).toolkit('inputCheckbox', 'destroy');
});
... | javascript | {
"resource": ""
} | |
q51228 | train | function(from, to) {
var classes = ($(from).attr('class') || '').replace(this.options.filterClasses, '').trim();
if (classes) {
$(to).addClass(classes);
}
} | javascript | {
"resource": ""
} | |
q51229 | train | function() {
var input = this.element,
wrapper = this.render(this.options.template)
.insertBefore(input)
.append(input);
if (this.options.copyClasses) {
this.copyClasses(input, wrapper);
}
return wrapper;
} | javascript | {
"resource": ""
} | |
q51230 | train | function(checkbox, options) {
this.element = checkbox = $(checkbox);
options = this.setOptions(options, checkbox);
this.wrapper = this._buildWrapper();
// Create custom input
this.input = this.render(options.checkboxTemplate)
.attr('for', checkbox.attr('id'))
... | javascript | {
"resource": ""
} | |
q51231 | train | function(radio, options) {
this.element = radio = $(radio);
options = this.setOptions(options, radio);
this.wrapper = this._buildWrapper();
// Create custom input
this.input = this.render(options.radioTemplate)
.attr('for', radio.attr('id'))
.insertAfter(... | javascript | {
"resource": ""
} | |
q51232 | train | function(select, options) {
this.element = select = $(select);
options = this.setOptions(options, select);
this.multiple = select.prop('multiple');
// Multiple selects must use native controls
if (this.multiple && options.native) {
return;
}
// Wrapp... | javascript | {
"resource": ""
} | |
q51233 | train | function() {
var options = this.options,
button = this.render(options.selectTemplate)
.find(this.ns('arrow', 'select')).html(this.render(options.arrowTemplate)).end()
.find(this.ns('label', 'select')).html(Toolkit.messages.loading).end()
.css('min-widt... | javascript | {
"resource": ""
} | |
q51234 | train | function() {
var select = this.element,
options = this.options,
buildOption = this._buildOption.bind(this),
renderTemplate = this.render.bind(this),
dropdown = renderTemplate(options.optionsTemplate).attr('role', 'listbox').aria('multiselectable', this.multiple),
... | javascript | {
"resource": ""
} | |
q51235 | train | function(option, index) {
var select = this.element,
dropdown = this.dropdown,
options = this.options,
selected = option.prop('selected'),
activeClass = 'is-active';
// Create elements
var li = $('<li/>'),
content = option.text(),
... | javascript | {
"resource": ""
} | |
q51236 | train | function(index, step, options) {
var hideFirst = this.options.hideFirst;
index += step;
while (($.type(options[index]) === 'undefined') || options[index].disabled || (index === 0 && hideFirst)) {
index += step;
if (index >= options.length) {
index = 0;
... | javascript | {
"resource": ""
} | |
q51237 | train | function(e) {
var select = $(e.target),
options = select.find('option'),
opts = this.options,
selected = [],
label = [],
self = this;
// Fetch label from selected option
options.each(function() {
if (this.selected) {
... | javascript | {
"resource": ""
} | |
q51238 | train | function(e) {
if (!this.dropdown.is(':shown')) {
return;
}
if ($.inArray(e.keyCode, [38, 40, 13, 27]) >= 0) {
e.preventDefault();
} else {
return;
}
var options = this.element.find('option'),
items = this.dropdown.find('a'... | javascript | {
"resource": ""
} | |
q51239 | train | function(container, options) {
container = $(container);
options = this.setOptions(options, container);
this.items = container.find(this.options.lazyClass);
if (container.css('overflow') === 'auto') {
this.container = container;
}
var callback = $.throttle(... | javascript | {
"resource": ""
} | |
q51240 | train | function() {
if (this.loaded >= this.items.length) {
this.shutdown();
return;
}
this.fireEvent('loading');
this.items.each(function(index, item) {
if (item && this.inViewport(item)) {
this.show(item, index);
}
}.bi... | javascript | {
"resource": ""
} | |
q51241 | train | function(node, index) {
node = $(node);
this.fireEvent('showing', [node]);
// Set the item being loaded for so that events can be fired
this.element = node.removeClass(this.options.lazyClass.substr(1));
// Replace src attributes on images
node.find('img').each(function... | javascript | {
"resource": ""
} | |
q51242 | train | function(element, options) {
element = this.setElement(element);
options = this.setOptions(options, element);
// Add class and set relative positioning
if (!element.is('body')) {
element.addClass('is-maskable');
var position = element.css('position');
... | javascript | {
"resource": ""
} | |
q51243 | train | function(mask) {
var options = this.options,
message;
// Prepare mask
mask.addClass('hide').appendTo(this.element);
if (this.element.is('body')) {
mask.css('position', 'fixed');
}
if (options.revealOnClick) {
mask.click(this.hide.bin... | javascript | {
"resource": ""
} | |
q51244 | train | function(nodes, options) {
this.nodes = $(nodes);
options = this.setOptions(options);
this.element = this.createElement()
.attr('role', 'dialog')
.aria('labelledby', this.id('title'))
.aria('describedby', this.id('content'));
// Enable fullscreen
... | javascript | {
"resource": ""
} | |
q51245 | train | function(content) {
// AJAX is currently loading
if (content === true) {
return;
}
// Hide blackout loading message
if (this.blackout) {
this.blackout.hideLoader();
}
this.fireEvent('showing');
var body = this.element.find(this.n... | javascript | {
"resource": ""
} | |
q51246 | train | function(node, content) {
if (node) {
this.node = node = $(node);
if (!content) {
content = this.readValue(node, this.readOption(node, 'getContent')) || node.attr('href');
}
}
// Show blackout if the element is hidden
// If it is visi... | javascript | {
"resource": ""
} | |
q51247 | train | function() {
var form = this.element.find('form:first');
if (!form) {
return;
}
this.fireEvent('submit', [form]);
var options = {
url: form.attr('action'),
type: (form.attr('method') || 'post').toUpperCase()
};
if (window.Fo... | javascript | {
"resource": ""
} | |
q51248 | train | function(element, options) {
element = this.setElement(element).attr('role', 'complementary').conceal();
options = this.setOptions(options, element);
var animation = options.animation;
// Touch devices cannot use squish
if (Toolkit.isTouch && animation === 'squish') {
... | javascript | {
"resource": ""
} | |
q51249 | train | function() {
this.fireEvent('hiding');
this.container.removeClass('move-' + this.opposite);
this.element
.conceal()
.removeClass('is-expanded')
.aria('expanded', false);
if (this.options.stopScroll) {
$('body').removeClass('no-scroll');
... | javascript | {
"resource": ""
} | |
q51250 | train | function() {
var options = this.options;
if (options.hideOthers) {
this.secondary.each(function() {
var sidebar = $(this);
if (sidebar.hasClass('is-expanded')) {
sidebar.toolkit('offCanvas', 'hide');
}
});
... | javascript | {
"resource": ""
} | |
q51251 | train | function() {
if (!this.options.openOnLoad || this._loaded) {
return;
}
var sidebar = this.element,
inner = this.primary,
transClass = 'no-transition';
sidebar.addClass(transClass);
inner.addClass(transClass);
this.show();
//... | javascript | {
"resource": ""
} | |
q51252 | train | function(e) {
e.preventDefault();
var target = $(e.target),
selector = '[data-offcanvas-sidebar]';
if (target.is(selector) || target.parents(selector).length) {
return;
}
this.show();
} | javascript | {
"resource": ""
} | |
q51253 | train | function(element, options) {
element = this.setElement(element);
options = this.setOptions(options, element);
// Setup classes and ARIA
element
.attr('role', 'complementary')
.addClass(options.animation);
// Determine before calculations
var init... | javascript | {
"resource": ""
} | |
q51254 | train | function() {
var win = $(window),
options = this.options,
element = this.element,
parent = options.context ? element.parents(options.context) : element.parent();
this.viewport = {
width: win.width(),
height: win.height()
};
th... | javascript | {
"resource": ""
} | |
q51255 | train | function() {
var options = this.options;
if (options.calculate) {
this.calculate();
}
if (!this.active) {
return;
}
var eHeight = this.elementHeight,
eTop = this.elementTop,
pHeight = this.parentHeight,
pTop =... | javascript | {
"resource": ""
} | |
q51256 | train | function(nodes, options) {
this.nodes = $(nodes);
options = this.setOptions(options);
this.createWrapper();
// Remove title attributes
if (options.getTitle === 'title') {
options.getTitle = 'data-' + this.keyName + '-title';
this.nodes.each(function(i, n... | javascript | {
"resource": ""
} | |
q51257 | train | function(node, content) {
this.node = node = $(node).addClass('is-active');
// Load the new element
this.loadElement(node, function(tooltip) {
tooltip
.addClass(this.readOption(node, 'position'))
.attr('role', 'tooltip');
});
// Load ... | javascript | {
"resource": ""
} | |
q51258 | train | function(e) {
e.preventDefault();
var options = this.options;
this.element.reveal().positionTo(options.position, e, {
left: options.xOffset,
top: options.yOffset
}, true);
} | javascript | {
"resource": ""
} | |
q51259 | train | function(nodes, options) {
options = options || {};
options.mode = 'click'; // Click only
options.follow = false; // Disable mouse follow
Tooltip.prototype.constructor.call(this, nodes, options);
} | javascript | {
"resource": ""
} | |
q51260 | train | function(element, options) {
var sections, tabs, self = this;
element = this.setElement(element);
options = this.setOptions(options, element);
// Determine cookie name
if (!options.cookie) {
options.cookie = element.attr('id');
}
// Find all the sec... | javascript | {
"resource": ""
} | |
q51261 | train | function(tab) {
tab = $(tab);
var index = tab.data('tab-index'),
section = this.sections.eq(index),
options = this.options,
url = this.readValue(tab, this.readOption(tab, 'getUrl'));
this.fireEvent('showing', [this.index]);
// Load content for AJAX ... | javascript | {
"resource": ""
} | |
q51262 | train | function(e) {
if (this.options.preventDefault || e.currentTarget.getAttribute('href').substr(0, 1) !== '#') {
e.preventDefault();
}
this.show(e.currentTarget);
} | javascript | {
"resource": ""
} | |
q51263 | train | function(element, options) {
this.nodes = element = $(element); // Set to nodes so instances are unset during destroy()
options = this.setOptions(options, element);
// Create the toasts wrapper
this.createWrapper()
.addClass(options.position)
.attr('role', 'log')... | javascript | {
"resource": ""
} | |
q51264 | train | function(content, options) {
options = $.extend({}, this.options, options || {});
var self = this,
toast = this.render(options.template)
.addClass(options.animation)
.attr('role', 'note')
.html(content)
.conceal()
... | javascript | {
"resource": ""
} | |
q51265 | train | function(element) {
element = $(element);
// Pass the element since it gets removed
this.fireEvent('hiding', [element]);
element.transitionend(function() {
element.remove();
this.fireEvent('hidden');
}.bind(this)).conceal();
} | javascript | {
"resource": ""
} | |
q51266 | train | function(input, options) {
input = $(input);
if (input.prop('tagName').toLowerCase() !== 'input') {
throw new Error('TypeAhead must be initialized on an input field');
}
var self = this;
options = this.setOptions(options, input);
this.element = this.createE... | javascript | {
"resource": ""
} | |
q51267 | train | function(item) {
var a = $('<a/>', {
href: 'javascript:;',
role: 'option',
'aria-selected': 'false'
});
a.append( this.render(this.options.titleTemplate).html(this.highlight(item.title)) );
if (item.description) {
a.append( this.render(th... | javascript | {
"resource": ""
} | |
q51268 | train | function() {
this.fireEvent('hiding');
if (this.shadow) {
this.shadow.val('');
}
this.input.aria('expanded', false);
this.element.conceal();
this.fireEvent('hidden');
} | javascript | {
"resource": ""
} | |
q51269 | train | function(item) {
var terms = this.term.replace(/[\-\[\]\{\}()*+?.,\\^$|#]/g, '\\$&').split(' '),
options = this.options,
callback = function(match) {
return this.render(options.highlightTemplate).html(match).toString();
}.bind(this);
for (var i = 0, t... | javascript | {
"resource": ""
} | |
q51270 | train | function() {
if (!this.items.length) {
this.hide();
return;
}
this.fireEvent('showing');
var iPos = this.input.offset();
this.element
.css('top', iPos.top + this.input.outerHeight())
.css(Toolkit.isRTL ? 'right' : 'left', iPos.le... | javascript | {
"resource": ""
} | |
q51271 | train | function(index, event) {
this.index = index;
var rows = this.element.find('li');
rows
.removeClass('is-active')
.find('a')
.aria('selected', false);
// Select
if (index >= 0) {
if (this.items[index]) {
var ite... | javascript | {
"resource": ""
} | |
q51272 | train | function(items) {
return items.sort(function(a, b) {
return a.title.localeCompare(b.title);
});
} | javascript | {
"resource": ""
} | |
q51273 | train | function(items) {
if (!this.term.length || !items.length) {
this.hide();
return;
}
var options = this.options,
term = this.term,
categories = { _empty_: [] },
item,
list = $('<ul/>');
// Reset
this.items = ... | javascript | {
"resource": ""
} | |
q51274 | train | function() {
if (!this.shadow) {
return;
}
var term = this.input.val(),
termLower = term.toLowerCase(),
value = '';
if (this.cache[termLower] && this.cache[termLower][0]) {
var title = this.cache[termLower][0].title;
if (titl... | javascript | {
"resource": ""
} | |
q51275 | train | function(e) {
var items = this.items,
length = Math.min(this.options.itemLimit, Math.max(0, items.length)),
event = 'cycle';
if (!length || !this.element.is(':shown')) {
return;
}
switch (e.keyCode) {
// Cycle upwards (up)
cas... | javascript | {
"resource": ""
} | |
q51276 | train | function() {
var term = this.term,
options = this.options,
sourceType = $.type(options.source);
// Check the cache first
if (this.cache[term.toLowerCase()]) {
this.source(this.cache[term.toLowerCase()]);
// Use the response of an AJAX request
... | javascript | {
"resource": ""
} | |
q51277 | train | function(e) {
if ($.inArray(e.keyCode, [38, 40, 27, 9, 13]) >= 0) {
return; // Handle with onCycle()
}
clearTimeout(this.timer);
var term = this.input.val().trim();
if (term.length < this.options.minLength) {
this.fireEvent('reset');
this.hi... | javascript | {
"resource": ""
} | |
q51278 | height | train | function height(node) {
return node ? (1 + Math.max(height(node.left), height(node.right))) : 0;
} | javascript | {
"resource": ""
} |
q51279 | rotateLeft | train | function rotateLeft (node) {
var rightNode = node.right;
node.right = rightNode.left;
if (rightNode.left) rightNode.left.parent = node;
rightNode.parent = node.parent;
if (rightNode.parent) {
if (rightNode.parent.left === node) {
rightNode.parent.left = rightNode;
} else {
rightNode.p... | javascript | {
"resource": ""
} |
q51280 | train | function(repo, version, hash, meta, outDir) {
var url, tempRepoDir, packageJSONData, self = this;
if (meta.vPrefix) {
version = 'v' + version;
}
// Automatically track and cleanup files at exit
temp.track();
url = createGitUrl(self.options.baseurl, repo, self.options.reposuffix, self.a... | javascript | {
"resource": ""
} | |
q51281 | train | function(pjson, dir) {
var main = pjson.main || '';
var libDir = pjson.directories && (pjson.directories.dist || pjson.directories.lib) || '.';
// convert to windows-style paths if necessary
main = path.normalize(main);
libDir = path.normalize(libDir);
if (main.indexOf('!') !== -1) {
ret... | javascript | {
"resource": ""
} | |
q51282 | train | function () {
var createPublisher = function (publisherDiv) {
var innerDeferred = $.Deferred();
var getContainer = function () {
if (publisherDiv) { return publisherDiv; }
if (typeof _this.screenSharingContainer === 'function') {
return document.querySelector(_this.screenSha... | javascript | {
"resource": ""
} | |
q51283 | train | function (annotationContainer) {
_session.publish(_this.publisher, function (error) {
if (error) {
// Let's write our own error message
var customError = _.omit(error, 'message');
if (error.code === 1500 && navigator.userAgent.indexOf('Firefox') !== -1) {
$('#dialog-form-f... | javascript | {
"resource": ""
} | |
q51284 | train | function(){
if(Object.keys(app.getServers()).length === 0){
quick.logger.shutdown(shutdown);
}
else{
setTimeout(tryShutdown, 200);
}
} | javascript | {
"resource": ""
} | |
q51285 | Light | train | function Light(constr) {
this.client = constr.client;
this.id = constr.id; // Used to target the light
this.address = constr.address;
this.port = constr.port;
this.label = null;
this.status = 'on';
this.seenOnDiscovery = constr.seenOnDiscovery;
} | javascript | {
"resource": ""
} |
q51286 | Client | train | function Client() {
EventEmitter.call(this);
this.debug = false;
this.socket = dgram.createSocket('udp4');
this.isSocketBound = false;
this.devices = {};
this.port = null;
this.messagesQueue = [];
this.sendTimer = null;
this.discoveryTimer = null;
this.discoveryPacketSequence = 0;
this.messageHan... | javascript | {
"resource": ""
} |
q51287 | trimLine | train | function trimLine(line) {
if (!line) {
return null;
}
if (Array.isArray(line)) {
return line.map(trimLine);
}
return String(line).trim();
} | javascript | {
"resource": ""
} |
q51288 | removeComments | train | function removeComments(line) {
var commentStartIndex = line.indexOf('#');
if (commentStartIndex > -1) {
return line.substr(0, commentStartIndex);
}
return line;
} | javascript | {
"resource": ""
} |
q51289 | formatUserAgent | train | function formatUserAgent(userAgent) {
var formattedUserAgent = userAgent.toLowerCase();
// Strip the version number from robot/1.0 user agents
var idx = formattedUserAgent.indexOf('/');
if (idx > -1) {
formattedUserAgent = formattedUserAgent.substr(0, idx);
}
return formattedUserAgent.trim();
} | javascript | {
"resource": ""
} |
q51290 | parsePattern | train | function parsePattern(pattern) {
var regexSpecialChars = /[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g;
// Treat consecutive wildcards as one (#12)
var wildCardPattern = /\*+/g;
var endOfLinePattern = /\\\$$/;
pattern = normaliseEncoding(pattern)
if (pattern.indexOf('*') < 0 && pattern.indexOf('$') < 0) {
return patter... | javascript | {
"resource": ""
} |
q51291 | findRule | train | function findRule(path, rules) {
var matchingRule = null;
for (var i=0; i < rules.length; i++) {
var rule = rules[i];
if (typeof rule.pattern === 'string') {
if (path.indexOf(rule.pattern) !== 0) {
continue;
}
// The longest matching rule takes precedence
if (!matchingRule || ... | javascript | {
"resource": ""
} |
q51292 | asJson | train | function asJson(entity, shallow) {
let json;
try {
json = JSON.stringify(asObject(entity, shallow));
} catch (error) {
json = '';
}
return json;
} | javascript | {
"resource": ""
} |
q51293 | getFlat | train | function getFlat(entity, json) {
let flat = {
entity : asObject(entity, true),
collections: getCollectionsCompact(entity)
};
if (json) {
flat = JSON.stringify(flat);
}
return flat;
} | javascript | {
"resource": ""
} |
q51294 | getPropertyForAssociation | train | function getPropertyForAssociation(forEntity, entity) {
let associations = forEntity.getMeta().fetch('associations');
return Object.keys(associations).filter(key => {
return associations[key].entity === entity.getResource();
})[0];
} | javascript | {
"resource": ""
} |
q51295 | trigger | train | function trigger (state, eventName) {
var args = [].slice.call(arguments, 1)
state.emitter.emit.apply(state.emitter, args)
return this
} | javascript | {
"resource": ""
} |
q51296 | train | function( key ) {
if( this.data[ key ] == null ) {
return this.data[ key ]
}
if( Array.isArray( this.data[ key ] ) ) {
return this.data[ key ].map( function( prop ) {
return prop.clone()
})
} else {
return this.data[ key ].clone()
}
} | javascript | {
"resource": ""
} | |
q51297 | train | function( key, value, params ) {
var prop = new vCard.Property( key, value, params )
this.addProperty( prop )
return this
} | javascript | {
"resource": ""
} | |
q51298 | train | function( prop ) {
var key = prop._field
if( Array.isArray( this.data[ key ] ) ) {
this.data[ key ].push( prop )
} else if( this.data[ key ] != null ) {
this.data[ key ] = [ this.data[ key ], prop ]
} else {
this.data[ key ] = prop
}
return this
} | javascript | {
"resource": ""
} | |
q51299 | train | function( value ) {
// Normalize & split
var lines = vCard.normalize( value )
.split( /\r?\n/g )
// Keep begin and end markers
// for eventual error messages
var begin = lines[0]
var version = lines[1]
var end = lines[ lines.length - 1 ]
if( !/BEGIN:VCARD/i.test( begin ) )
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.