_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q47300
ConstructorComponent
train
function ConstructorComponent(id, ctor, hs) { Component.call(this, id, ctor, hs); this._ctor = ctor; }
javascript
{ "resource": "" }
q47301
Component
train
function Component(id, mod, asm) { var keys, i, len; this.id = id; this.dependencies = mod['@require'] || []; this.singleton = mod['@singleton']; this.implements = mod['@implements'] || []; if (typeof this.implements == 'string') { this.implements = [ this.implements ] } this.a = {}; if (typ...
javascript
{ "resource": "" }
q47302
onWritten
train
function onWritten(writeErr) { var flags = fo.getFlags({ overwrite: optResolver.resolve('overwrite', file), append: optResolver.resolve('append', file), }); if (fo.isFatalOverwriteError(writeErr, flags)) { return callback(writeErr); } callback(null, file); }
javascript
{ "resource": "" }
q47303
defaultHandler
train
function defaultHandler() { let containerBottom; let elementBottom; if (container === windowElement) { containerBottom = height(container) + pageYOffset(container[0].document.documentElement); elementBottom = offsetTop(elem) + height(elem); } else { containe...
javascript
{ "resource": "" }
q47304
throttle
train
function throttle(func, wait) { let timeout = null; let previous = 0; function later() { previous = new Date().getTime(); $interval.cancel(timeout); timeout = null; return func.call(); } function throttled() { const now = new Da...
javascript
{ "resource": "" }
q47305
changeContainer
train
function changeContainer(newContainer) { if (container != null) { container.unbind('scroll', handler); } container = newContainer; if (newContainer != null) { container.bind('scroll', handler); } }
javascript
{ "resource": "" }
q47306
train
function () { NAF.log.setDebug(this.data.debug); NAF.log.write('Networked-Aframe Connecting...'); this.checkDeprecatedProperties(); this.setupNetworkAdapter(); if (this.hasOnConnectFunction()) { this.callOnConnect(); } return NAF.connection.connect(this.data.serverURL, this.data.app,...
javascript
{ "resource": "" }
q47307
SimpsonDef
train
function SimpsonDef(func, a, b) { var c = (a + b) / 2; var d = Math.abs(b - a) / 6; return d * (func(a) + 4 * func(c) + func(b)); }
javascript
{ "resource": "" }
q47308
SimpsonRecursive
train
function SimpsonRecursive(func, a, b, whole, eps) { var c = a + b; var left = SimpsonDef(func, a, c); var right = SimpsonDef(func, c, b); if (Math.abs(left + right - whole) <= 15 * eps) { return left + right + (left + right - whole) / 15; } else { return SimpsonRecursive(func, a, c, eps / 2, left) + ...
javascript
{ "resource": "" }
q47309
train
function (M) { //starting at bottom right, moving horizontally var jump = false, tl = n * n, br = 1, inc = 1, row, col, val, i, j; M[0][0] = tl; M[n - 1][n - 1] = br; for (i = 1; i < n; i++) { //generate top/bottom row if (jump) { tl -= 4 * inc; br +=...
javascript
{ "resource": "" }
q47310
gulpSVGSprite
train
function gulpSVGSprite(config) { // Extend plugin error function extendError(pError, error) { if (error && (typeof error === 'object')) { ['name', 'errno'].forEach(function(property) { if (property in error) { this[property] = error[property]; } }, pError); } return pError; } // Instanci...
javascript
{ "resource": "" }
q47311
extendError
train
function extendError(pError, error) { if (error && (typeof error === 'object')) { ['name', 'errno'].forEach(function(property) { if (property in error) { this[property] = error[property]; } }, pError); } return pError; }
javascript
{ "resource": "" }
q47312
stringify
train
function stringify (val) { var stack = val.stack if (stack) { return String(stack) } var str = String(val) return str === toString.call(val) ? inspect(val) : str }
javascript
{ "resource": "" }
q47313
train
function(event) { var input = event.target, datalist = input.list, keyOpen = event.keyCode === keyUP || event.keyCode === keyDOWN; // Check for whether the events target was an input and still check for an existing instance of the datalist and polyfilling select if (input.tagName.toLowerCase() !== 'input' ...
javascript
{ "resource": "" }
q47314
train
function(event) { var input = event.target, datalist = input.list; if ( !input.matches('input[list]') || !input.matches('.' + classNameInput) || !datalist ) { return; } // Query for related option - and escaping the value as doublequotes wouldn't work var option = datalist.querySelector( ...
javascript
{ "resource": "" }
q47315
train
function(option, inputValue) { var optVal = option.value.toLowerCase(), inptVal = inputValue.toLowerCase(), label = option.getAttribute('label'), text = option.text.toLowerCase(); /* "Each option element that is a descendant of the datalist element, that is not disabled, and whose value is a string that...
javascript
{ "resource": "" }
q47316
train
function(event) { // Check for correct element on this event delegation if (!event.target.matches('input[list]')) { return; } var input = event.target, datalist = input.list; // Check for whether the events target was an input and still check for an existing instance of the datalist if (input.tagNam...
javascript
{ "resource": "" }
q47317
train
function(input, eventType) { // We'd like to prevent autocomplete on the input datalist field input.setAttribute('autocomplete', 'off'); // WAI ARIA attributes input.setAttribute('role', 'textbox'); input.setAttribute('aria-haspopup', 'true'); input.setAttribute('aria-autocomplete', 'list'); input.setAtt...
javascript
{ "resource": "" }
q47318
train
function(input) { // In case of type=email and multiple attribute, we would need to grab the last piece // Using .getAttribute here for IE9 purpose - elsewhere it wouldn't return the newer HTML5 values correctly return input.getAttribute('type') === 'email' && input.getAttribute('multiple') !== null ? input...
javascript
{ "resource": "" }
q47319
train
function(input, datalistSelectValue) { var lastSeperator; // In case of type=email and multiple attribute, we need to set up the resulting inputs value differently input.value = // Using .getAttribute here for IE9 purpose - elsewhere it wouldn't return the newer HTML5 values correctly input.getAttribute('t...
javascript
{ "resource": "" }
q47320
train
function(input, datalist) { // Check for whether it's of one of the supported input types defined at the beginning // Using .getAttribute here for IE9 purpose - elsewhere it wouldn't return the newer HTML5 values correctly // and still check for an existing instance if ( (input.getAttribute('type') && su...
javascript
{ "resource": "" }
q47321
train
function(event) { var datalistSelect = event.target, datalist = datalistSelect.parentNode, input = dcmnt.querySelector('input[list="' + datalist.id + '"]'); // Check for whether the events target was a select or whether the input doesn't exist if (datalistSelect.tagName.toLowerCase() !== 'select' || input ...
javascript
{ "resource": "" }
q47322
train
function(event) { var datalistSelect = event.currentTarget, datalist = datalistSelect.parentNode, input = dcmnt.querySelector('input[list="' + datalist.id + '"]'); // Check for whether the events target was a select or whether the input doesn't exist if (datalistSelect.tagName.toLowerCase() !== 'select' ||...
javascript
{ "resource": "" }
q47323
train
function(input) { var evt; if (typeof Event === 'function') { evt = new Event('input', { bubbles: true }); } else { evt = dcmnt.createEvent('Event'); evt.initEvent('input', true, false); } input.dispatchEvent(evt); }
javascript
{ "resource": "" }
q47324
train
function(visible, datalistSelect) { if (visible) { datalistSelect.removeAttribute('hidden'); } else { datalistSelect.setAttributeNode(dcmnt.createAttribute('hidden')); } datalistSelect.setAttribute('aria-hidden', (!visible).toString()); }
javascript
{ "resource": "" }
q47325
makeRecencyFilter
train
function makeRecencyFilter(timeFn) { var lastTime = 0; return function(items) { var out = []; items.forEach(function(item) { if (timeFn(item) > lastTime) { out.push(item); } }); out.forEach(function(item) { lastTime = Math.max(lastTime, timeFn(item)); }); return o...
javascript
{ "resource": "" }
q47326
getBaseDir
train
function getBaseDir(configFilePath) { // calculates the path of the project including Wist as dependency const projectPath = path.resolve(__dirname, '../../../'); if (configFilePath && pathIsInside(configFilePath, projectPath)) { // be careful of https://github.com/substack/node-resolve/issues/78...
javascript
{ "resource": "" }
q47327
handleInitialize
train
function handleInitialize(currentOptions) { const recommendedFilePath = path.resolve(__dirname, '../../config/wist-recommended.json'); let result = 0; if (currentOptions.config) { result = handleConfiguration(currentOptions.config); } else { result = handleConfiguration(recommendedFilePa...
javascript
{ "resource": "" }
q47328
handleConfiguration
train
function handleConfiguration(filePath) { if (fs.existsSync(filePath)) { filePath = path.resolve(filePath); } else { console.error('Invalid path to configuration file.'); return 1; } return setupConfigurationFile(filePath); }
javascript
{ "resource": "" }
q47329
setupConfigurationFile
train
function setupConfigurationFile(configFilePath) { const fileName = '.wistrc.json'; try { let contents = require(configFilePath); fs.writeFileSync(fileName, JSON.stringify(contents, null, 2)); log.info(`Initialized directory with a ${fileName}`) } catch (e) { console.error(e....
javascript
{ "resource": "" }
q47330
deepmerge
train
function deepmerge(target, src, combine, isRule) { /* The MIT License (MIT) Copyright (c) 2012 Nicholas Fisher Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal ...
javascript
{ "resource": "" }
q47331
createAsync
train
function createAsync() { var wired = new Async, wire = render.bind(wired), chunksReceiver ; wired.update = function () { this.callback = chunksReceiver; return chunks.apply(this, arguments); }; return function (callback) { chunksReceiver = callback || String; return wire; }; }
javascript
{ "resource": "" }
q47332
fixUpdates
train
function fixUpdates(updates) { for (var update, i = 0, length = updates.length, out = []; i < length; i++ ) { update = updates[i]; out.push(update === getUpdateForHTML ? update.call(this) : update); } return out; }
javascript
{ "resource": "" }
q47333
invokeAtDistance
train
function invokeAtDistance(value, asTPV) { var after = asTPV ? asTemplateValue : identity; if ('text' in value) { return Promise.resolve(value.text).then(String).then(after); } else if ('any' in value) { return Promise.resolve(value.any).then(after); } else if ('html' in value) { return Promise.resol...
javascript
{ "resource": "" }
q47334
invokeTransformer
train
function invokeTransformer(object) { for (var key, i = 0, length = transformersKeys.length; i < length; i++) { key = transformersKeys[i]; if (object.hasOwnProperty(key)) { // noop is passed to respect hyperHTML API but it won't have // any effect at distance for the time being return transfo...
javascript
{ "resource": "" }
q47335
asTemplateValue
train
function asTemplateValue(value, isAttribute) { var presuf = isAttribute ? '' : createHyperComment(); switch(typeof value) { case 'string': return presuf + escape(value) + presuf; case 'boolean': case 'number': return presuf + value + presuf; case 'function': return asTemplateValue(value({}), isAttri...
javascript
{ "resource": "" }
q47336
updateBoolean
train
function updateBoolean(name) { name = ' ' + name; function update(value) { switch (value) { case true: case 'true': return name; } return ''; } update[UID] = true; return update; }
javascript
{ "resource": "" }
q47337
updateEvent
train
function updateEvent(value) { switch (typeof value) { case 'function': return 'return (' + escape( JS_SHORTCUT.test(value) && !JS_FUNCTION.test(value) ? ('function ' + value) : value ) + ').call(this, event)'; case 'object': return ''; default: return escape(value || ''); } }
javascript
{ "resource": "" }
q47338
chunks
train
function chunks() { for (var update, out = [], updates = this.updates, template = this.chunks, callback = this.callback, all = Promise.resolve(template[0]), chain = function (after) { return all.then(function (through) { notify(through); return aft...
javascript
{ "resource": "" }
q47339
resolveAsTemplateValue
train
function resolveAsTemplateValue(update) { return function (value) { return asTemplateValue( value, update === updateAttribute || update === updateEvent || UID in update ); }; }
javascript
{ "resource": "" }
q47340
update
train
function update() { for (var tmp, promise = false, updates = this.updates, template = this.chunks, out = [template[0]], i = 1, length = arguments.length; i < length; i++ ) { tmp = arguments[i]; if ( (typeof tmp === 'object' && tmp !== null) && (typeof tmp.th...
javascript
{ "resource": "" }
q47341
checkAttributes
train
function checkAttributes (priority, element, ignore, path, parent = element.parentNode) { const pattern = findAttributesPattern(priority, element, ignore) if (pattern) { const matches = parent.querySelectorAll(pattern) if (matches.length === 1) { path.unshift(pattern) return true } } ret...
javascript
{ "resource": "" }
q47342
findAttributesPattern
train
function findAttributesPattern (priority, element, ignore) { const attributes = element.attributes const sortedKeys = Object.keys(attributes).sort((curr, next) => { const currPos = priority.indexOf(attributes[curr].name) const nextPos = priority.indexOf(attributes[next].name) if (nextPos === -1) { ...
javascript
{ "resource": "" }
q47343
checkTag
train
function checkTag (element, ignore, path, parent = element.parentNode) { const pattern = findTagPattern(element, ignore) if (pattern) { const matches = parent.getElementsByTagName(pattern) if (matches.length === 1) { path.unshift(pattern) return true } } return false }
javascript
{ "resource": "" }
q47344
findTagPattern
train
function findTagPattern (element, ignore) { const tagName = element.tagName.toLowerCase() if (checkIgnore(ignore.tag, null, tagName)) { return null } return tagName }
javascript
{ "resource": "" }
q47345
checkChilds
train
function checkChilds (priority, element, ignore, path) { const parent = element.parentNode const children = parent.childTags || parent.children for (var i = 0, l = children.length; i < l; i++) { const child = children[i] if (child === element) { const childPattern = findPattern(priority, child, igno...
javascript
{ "resource": "" }
q47346
checkIgnore
train
function checkIgnore (predicate, name, value, defaultPredicate) { if (!value) { return true } const check = predicate || defaultPredicate if (!check) { return false } return check(name, value, defaultPredicate) }
javascript
{ "resource": "" }
q47347
getCommonSelectors
train
function getCommonSelectors (elements) { const { classes, attributes, tag } = getCommonProperties(elements) const selectorPath = [] if (tag) { selectorPath.push(tag) } if (classes) { const classSelector = classes.map((name) => `.${name}`).join('') selectorPath.push(classSelector) } if (at...
javascript
{ "resource": "" }
q47348
traverseDescendants
train
function traverseDescendants (nodes, handler) { nodes.forEach((node) => { var progress = true handler(node, () => progress = false) if (node.childTags && progress) { traverseDescendants(node.childTags, handler) } }) }
javascript
{ "resource": "" }
q47349
getAncestor
train
function getAncestor (node, root, validate) { while (node.parent) { node = node.parent if (validate(node)) { return node } if (node === root) { break } } return null }
javascript
{ "resource": "" }
q47350
compareResults
train
function compareResults (matches, elements) { const { length } = matches return length === elements.length && elements.every((element) => { for (var i = 0; i < length; i++) { if (matches[i] === element) { return true } } return false }) }
javascript
{ "resource": "" }
q47351
$isInInvisibleState
train
function $isInInvisibleState(c) { if (c.isVisible === false || c.$container.parentNode === null || c.width <= 0 || c.height <= 0 || c.parent === null || ...
javascript
{ "resource": "" }
q47352
$resolveDOMParent
train
function $resolveDOMParent(c) { // try to find an HTML element in zebkit (pay attention, in zebkit hierarchy !) // hierarchy that has to be a DOM parent for the given component var parentElement = null; for(var p = c.parent; p !== null; p = p.parent) { ...
javascript
{ "resource": "" }
q47353
setParent
train
function setParent(p) { this.$super(p); if (p !== null && p.noSubIfEmpty === true) { this.getSub().setVisible(false); } }
javascript
{ "resource": "" }
q47354
keyPressed
train
function keyPressed(e){ if (e.code === "Escape") { if (this.parent !== null) { var p = this.$parentMenu; this.$canceled(this); this.$hideMenu(); if (p !== null) { p.requestFocus(); ...
javascript
{ "resource": "" }
q47355
addDecorative
train
function addDecorative(c) { if (c.$isDecorative !== true) { c.$$isDecorative = true; } this.$getSuper("insert").call(this, this.kids.length, null, c); }
javascript
{ "resource": "" }
q47356
setValue
train
function setValue(s) { var txt = this.getValue(); if (txt !== s){ if (this.position !== null) { this.position.setOffset(0); } this.scrollManager.scrollTo(0, 0); this.$super(s); } return th...
javascript
{ "resource": "" }
q47357
train
function(e, pr) { if (arguments.length === 0) { if (this.$error !== null) { this.dumpError(e); } } else { if (this.$error === null) { if (this.$ignoreError) { this.$ignored(e); } else { ...
javascript
{ "resource": "" }
q47358
train
function(body) { var level = this.$level; // store level then was executed for the given task // to be used to compute correct the level inside the // method below var task = function() { // clean results of execution of a...
javascript
{ "resource": "" }
q47359
train
function() { // clean results of execution of a previous task this.$busy = 0; var pc = this.$taskCounter; if (this.$error !== null) { this.$taskCounter = 0; // we have to count the tasks on this level this.$level = level + 1; ...
javascript
{ "resource": "" }
q47360
getView
train
function getView(t, v) { if (v !== null && v !== undefined && this.numPrecision !== -1 && zebkit.isNumber(v)) { v = v.toFixed(this.numPrecision); } return this.$super(t, v); }
javascript
{ "resource": "" }
q47361
setViewProvider
train
function setViewProvider(p){ if (this.provider != p) { this.stopEditing(false); this.provider = p; delete this.nodes; this.nodes = {}; this.vrp(); } return this; }
javascript
{ "resource": "" }
q47362
dumpError
train
function dumpError(e) { if (typeof console !== "undefined" && typeof console.log !== "undefined") { var msg = "zebkit.err ["; if (typeof Date !== 'undefined') { var date = new Date(); msg = msg + date.getDate() + "/" + (date.getMonth() + 1) + "/" + ...
javascript
{ "resource": "" }
q47363
image
train
function image(ph, fireErr) { if (arguments.length < 2) { fireErr = false; } var doit = new DoIt(), jn = doit.join(), marker = "data:image"; if (isString(ph) && ph.length > marker.length) { // use "for" instead of "indexOf === 0" var i = 0; for(; i ...
javascript
{ "resource": "" }
q47364
isNumber
train
function isNumber(o) { return o !== undefined && o !== null && (typeof o === "number" || o.constructor === Number); }
javascript
{ "resource": "" }
q47365
isBoolean
train
function isBoolean(o) { return o !== undefined && o !== null && (typeof o === "boolean" || o.constructor === Boolean); }
javascript
{ "resource": "" }
q47366
getPropertyValue
train
function getPropertyValue(obj, path, useGetter) { // if (arguments.length < 3) { // useGetter = false; // } path = path.trim(); if (path === undefined || path.length === 0) { throw new Error("Invalid field path: '" + path + "'"); } // if (obj === undefined || obj === null) { ...
javascript
{ "resource": "" }
q47367
train
function() { return (this.scheme !== null ? this.scheme + "://" : '') + (this.host !== null ? this.host : '' ) + (this.port !== -1 ? ":" + this.port : '' ) + (this.path !== null ? this.path : '' ) + (this.qs !== null ? "?" + this.qs : '' ); }
javascript
{ "resource": "" }
q47368
train
function() { if (this.path === null) { return null; } else { var i = this.path.lastIndexOf('/'); return (i < 0 || this.path === '/') ? null : new URI(this.scheme, ...
javascript
{ "resource": "" }
q47369
train
function(obj) { if (obj !== null) { if (this.qs === null) { this.qs = ''; } if (this.qs.length > 0) { this.qs = this.qs + "&" + URI.toQS(obj); } else { this.qs = URI.toQS(obj); } } }
javascript
{ "resource": "" }
q47370
train
function() { var args = Array.prototype.slice.call(arguments); args.splice(0, 0, this.toString()); return URI.join.apply(URI, args); }
javascript
{ "resource": "" }
q47371
train
function(to) { if ((to instanceof URI) === false) { to = new URI(to); } if (this.isAbsolute() && to.isAbsolute() && this.host === to.host ...
javascript
{ "resource": "" }
q47372
$initializeCodesMap
train
function $initializeCodesMap() { var k = null, code = null; // validate codes mapping for(k in CODES) { code = CODES[k]; if (code.map !== undefined) { if (CODES[code.map] === undefined) { throw new Error("Invalid mappin...
javascript
{ "resource": "" }
q47373
setFormat
train
function setFormat(format) { if (format === null || format === undefined) { throw new Error("Format is not defined " + this.clazz.$name); } if (this.format !== format) { this.format = format; this.$getSuper("setValue").call(this, this....
javascript
{ "resource": "" }
q47374
getCalendar
train
function getCalendar() { if (this.clazz.$name === undefined) { throw new Error(); } if (this.calendar === undefined || this.calendar === null) { var $this = this; this.$freezeCalendar = false; this.calendar = new pkg....
javascript
{ "resource": "" }
q47375
showCalendar
train
function showCalendar(anchor) { try { this.$freezeCalendar = true; this.hideCalendar(); var calendar = this.getCalendar(); this.$anchor = anchor; var c = this.getCanvas(), w = c.getLayer("win"), ...
javascript
{ "resource": "" }
q47376
hideCalendar
train
function hideCalendar() { if (this.calendar !== undefined && this.calendar !== null) { var calendar = this.getCalendar(); if (calendar.parent !== null) { calendar.removeMe(); if (this.calendarHidden !== undefined) { ...
javascript
{ "resource": "" }
q47377
setValue
train
function setValue(d1, d2) { if (compareDates(d1, d2) === 1) { throw new RangeError(); } if (compareDates(d1, this.minDateField.date) !== 0 || compareDates(d2, this.maxDateField.date) !== 0 ) { var prev = this.getValue(); ...
javascript
{ "resource": "" }
q47378
$cpMethods
train
function $cpMethods(src, dest, clazz) { var overriddenAbstractMethods = 0; for(var name in src) { if (name !== CNAME && name !== "clazz" && src.hasOwnProperty(name) ) { var method = src[name]; if (typeof method === "function" &&...
javascript
{ "resource": "" }
q47379
newInstance
train
function newInstance(clazz, args) { if (arguments.length > 1 && args.length > 0) { var f = function () {}; f.prototype = clazz.prototype; var o = new f(); clazz.apply(o, args); return o; } return new clazz(); }
javascript
{ "resource": "" }
q47380
train
function() { var methods = arguments[arguments.length - 1], hasMethod = Array.isArray(methods); // inject class if (hasMethod && this.$isExtended !== true) { // create intermediate class var A = this.$parent !== null ? Class(this.$parent, []) ...
javascript
{ "resource": "" }
q47381
train
function(clazz) { if (this !== clazz) { // detect class if (clazz.clazz === this.clazz) { for (var p = this.$parent; p !== null; p = p.$parent) { if (p === clazz) { return true; } } ...
javascript
{ "resource": "" }
q47382
train
function(name) { if ($caller !== null) { for(var $s = $caller.boundTo.$parent; $s !== null; $s = $s.$parent) { var m = $s.prototype[name]; if (typeof m === 'function') { return m; } } return null; } ...
javascript
{ "resource": "" }
q47383
instanceOf
train
function instanceOf(obj, clazz) { if (clazz !== null && clazz !== undefined) { if (obj === null || obj === undefined) { return false; } else if (obj.clazz === undefined) { return (obj instanceof clazz); } else { return obj.clazz !== null && ...
javascript
{ "resource": "" }
q47384
validateArguments
train
function validateArguments (targets, callback) { const nodes = Object.prototype.toString.call(targets) const targetsValid = typeof targets === 'string' || ((nodes === '[object NodeList]' || nodes === '[object HTMLCollection]') || targets.nodeType === 1) const callbackValid = typeof callback === 'function' ...
javascript
{ "resource": "" }
q47385
train
function (elements, callback, options) { if (!validateArguments(elements, callback)) return if (!Array.isArray(elements)) { elements = [ elements ] } each.call(elements, function (e) { const handler = function () { callback.call(e, count(e, options)) }...
javascript
{ "resource": "" }
q47386
train
function (elements) { if (!validateArguments(elements, function () {})) return if (!Array.isArray(elements)) { elements = [ elements ] } liveElements.filter(function (e) { return elements.indexOf(e.element) !== -1 }).forEach(function (e) { e.element.removeEv...
javascript
{ "resource": "" }
q47387
train
function (targets, callback, options) { if (!validateArguments(targets, callback)) return if (!Array.isArray(targets)) { targets = [ targets ] } each.call(targets, function (e) { callback.call(e, count(e, options)) }) return this }
javascript
{ "resource": "" }
q47388
train
function (elements) { if (elements.length === undefined) { elements = [ elements ] } return liveElements.filter(function (e) { return elements.indexOf(e.element) !== -1 }).length === elements.length }
javascript
{ "resource": "" }
q47389
Run
train
function Run(path, options, callback) { var p = Spawn(path, options.args), err = "", data = ""; if (options.remove !== false) { Fs.unlink(path, () => {}); } if (options.stdin) { options.stdin.pipe(p.stdin); } if (options.stdout) { p.stdout.pipe(options....
javascript
{ "resource": "" }
q47390
Move
train
function Move(old, cwd, callback) { var n = Path.join(cwd, Path.basename(old)); Fs.rename(old, n, function (err) { callback(null, [old, n][Number(!err)]); }); }
javascript
{ "resource": "" }
q47391
Compile
train
function Compile(input, options, callback) { var output = Path.join(options.cwd, Path.basename(input).slice(0, -4)); if (options.precompiled) { callback(null, output); } else { CheckCobc(function (exists) { if (!exists) { return callback(new Error("Couldn't find...
javascript
{ "resource": "" }
q47392
Cobol
train
function Cobol(input, options, callback) { var args = Sliced(arguments); if (typeof options === "function") { callback = options; options = {}; } callback = callback || function () {}; // Merge the defaults options = Ul.merge(options, { cwd: process.cwd(), com...
javascript
{ "resource": "" }
q47393
loadJSON
train
function loadJSON (path, callback) { var xobj = new XMLHttpRequest(); xobj.overrideMimeType('application/json'); xobj.open('GET', path, true); xobj.onreadystatechange = function () { if (xobj.readyState === 4 && xobj.status === 200) { callback(xobj.responseText); } }; xobj.send(null); }
javascript
{ "resource": "" }
q47394
destroyMap
train
function destroyMap (map) { var el = map.getContainer(); map.remove(); document.body.removeChild(el); }
javascript
{ "resource": "" }
q47395
startDrag
train
function startDrag(e) { // Preventing the event's default action stops text being // selectable during the drag. e.preventDefault(); var self = $(this); self.trigger('startDrag'); // Measure how far the user's mouse is from the top of the scrollbar drag handle. var eventOffse...
javascript
{ "resource": "" }
q47396
drag
train
function drag(e) { e.preventDefault(); // Calculate how far the user's mouse is from the top/left of the scrollbar (minus the dragOffset). var eventOffset = e.pageY; if (scrollDirection === 'horiz') { eventOffset = e.pageX; } var dragPos = eventOffset - $scrollbarEl.offset()...
javascript
{ "resource": "" }
q47397
resizeScrollContent
train
function resizeScrollContent() { if (scrollDirection === 'vert'){ $scrollContentEl.width($el.width()+scrollbarWidth()); $scrollContentEl.height($el.height()); } else { $scrollContentEl.width($el.width()); $scrollContentEl.height($el.height()+scrollbarWidth()); $conten...
javascript
{ "resource": "" }
q47398
scrollbarWidth
train
function scrollbarWidth() { // Append a temporary scrolling element to the DOM, then measure // the difference between between its outer and inner elements. var tempEl = $('<div class="scrollbar-width-tester" style="width:50px;height:50px;overflow-y:scroll;position:absolute;top:-200px;left:-200px;"><d...
javascript
{ "resource": "" }
q47399
train
function(imageElement) { _readyCb = function() { try { var w = imageElement.width; var h = imageElement.height; var newImg = document.createElement('img'); var ratio = (w / _w < h / _h) ? (w / _w) : (h / _h); newImg.setAttribute('src', imageElement.getAttribute('src')); newImg.heigh...
javascript
{ "resource": "" }