_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q10900
train
function(name, brk, debugChildren) { var deferred = Q.defer(); var args = process.argv; grunt.task.clearQueue(); var tasks = args.slice(args.indexOf(name) + 1); if (debugChildren) { tasks.unshift('debug:hook' + (brk ? '-break' : '')); } var child = child_process.fork( args[1], tasks, { execArgv: [ brk ? '--debug-brk' : '--debug' ] } ); child.on('exit', function(code) { if (code == 0) { deferred.resolve(); } else { deferred.reject(code); } }); return deferred.promise; }
javascript
{ "resource": "" }
q10901
train
function() { var pid = process.pid; return Q.fcall(function() { if (process.platform === 'win32') { process._debugProcess(pid); } else { process.kill(pid, 'SIGUSR1'); } }); }
javascript
{ "resource": "" }
q10902
train
function(brk) { hooks.enableHooks( brk, function(module, port) { grunt.log.ok('Debugging forked process %s on port %d', module, port); } ); }
javascript
{ "resource": "" }
q10903
Transport
train
function Transport (opts) { this.path = opts.path; this.host = opts.host; this.port = opts.port; this.secure = opts.secure; this.query = opts.query; this.timestampParam = opts.timestampParam; this.timestampRequests = opts.timestampRequests; this.readyState = ''; }
javascript
{ "resource": "" }
q10904
create
train
function create (path, fn) { if (scripts[path]) return fn(); var el = document.createElement('script'); var loaded = false; // debug: loading "%s", path el.onload = el.onreadystatechange = function () { if (loaded || scripts[path]) return; var rs = el.readyState; if (!rs || 'loaded' == rs || 'complete' == rs) { // debug: loaded "%s", path el.onload = el.onreadystatechange = null; loaded = true; scripts[path] = true; fn(); } }; el.async = 1; el.src = path; var head = document.getElementsByTagName('head')[0]; head.insertBefore(el, head.firstChild); }
javascript
{ "resource": "" }
q10905
initVar
train
function initVar (key, envKey, def) { var negate = !def; switch (true) { case cacheObj.hasOwnProperty(key): return cacheObj[key]; case process.env.hasOwnProperty(envGlobalCacheKey): return process.env[envGlobalCacheKey] !== ''; case process.env.hasOwnProperty(envKey): return negate ? process.env[envKey] === 'YES' : process.env[envKey] !== 'NO'; default: return def; } }
javascript
{ "resource": "" }
q10906
train
function(node) { // declarations is an array of the comma-separated variable declarations like "var foo, zerp;" node.declarations.forEach(declaration => { // id contains info about the variable being declare. var variable_name = declaration.id.name; // Skip if the variable is already whitelisted. if (variable_whitelist.indexOf(variable_name) > -1) return; // init contains info about the value being initialized to. It is null when the variable is // being declared without being initialized. // If initialization type is "CallExpression", that means that the variable is being // initialized to a function. // init.callee contains info about the function that the value is being initialized to, // undefined if it's not being initialized to a function, or at all. // So, this filters down into variables being initialized to the "require" function. if (declaration.init && declaration.init.type === `CallExpression` && declaration.init.callee.name === `require`) { var module_name; // init.arguments is an array of the arguments being passed to the callee, undefinied if // the variable isn't being initialized to a function, or at all. Unlike the declarations, // we won't iterate over this because we only care about the first argument. if (declaration.init.arguments[0].type === `TemplateLiteral`) // The quasis array is a bit weird. Parsed template literals have them, and the number // of elements is equal to the number of placeholders, plus one for the non-placeholder // section. However, the values of the placeholder sections are always empty, so I'm // not sure what purpose they serve. // This takes the cooked non-placeholder portion as-is. module_name = declaration.init.arguments[0].quasis[0].value.cooked; else if (declaration.init.arguments[0].type === `Literal`) // Literals are easy. The value is right there. module_name = declaration.init.arguments[0].value; else // Something other than `, ', or "? ¯\_(ツ)_/¯ return; // Detect if the module is being included via a path. This means that it is a part of the // project, and not from an external dependency. This means that it's alright to correct // the case in it. if (module_name.includes(`/`)) variable_whitelist.push(variable_name); } }); }
javascript
{ "resource": "" }
q10907
train
function(connectString, options, root, prefix) { EventEmitter.call(this); if(util.isArray(connectString)) { connectString = connectString.join(","); } this.connectString = connectString; this.options = options; this.root = root || "/illyria"; this.prefix = prefix || "/HB_"; this.path = null; this.root = this.root.trim(); this.prefix = this.prefix.trim(); if(!this.root.length) this.root = "/illyria"; if(!this.prefix.length) this.prefix = "/HB_"; if(this.root[0] !== "/") this.root = "/" + this.root; if(this.prefix[0] !== "/") this.prefix = "/" + this.prefix; this.client = zookeeper.createClient(this.connectString, options); this.server = { host: "127.0.0.1", port: 3721, clients: 0 }; this.clientStatus = ZK_STATUS.NOT_CONNECTED; this._setup(); }
javascript
{ "resource": "" }
q10908
extend
train
function extend(object, properties) { object = object || { }; const anotherObject = properties || { }; for (const key in anotherObject) { const val = anotherObject[key]; if (val || (val === '')) { object[key] = val; } } return object; }
javascript
{ "resource": "" }
q10909
eliminateDuplicates
train
function eliminateDuplicates(browsers) { var set = {}; browsers.forEach(function (browser) { var osgroup = browser.os; var subgroup = browser.long_name; var version = browser.short_version; var device; var browserName; if (browser.api_name === "iphone") { osgroup = device = "iPhone Simulator"; } else if (browser.api_name === "ipad") { osgroup = device = "iPad Simulator"; } else if (browser.long_name === "Google Chrome") { browserName = 'Chrome'; } else if (browser.long_name === "Microsoft Edge") { browserName = 'MicrosoftEdge'; version = browser.long_version.substr(0, 8); } else if (browser.api_name === "android") { browserName = 'Android'; osgroup = "Android " + browser.short_version; device = browser.long_name; if (subgroup === "Android") { subgroup += " " + version + " Emulator"; device = "Android Emulator"; } } else if (osgroup in OS_ID_TO_GROUPNAME) { osgroup = OS_ID_TO_GROUPNAME[osgroup]; } set[JSON.stringify([osgroup, subgroup, version])] = { browserName: browserName || browser.long_name, platform: OS_ID_TO_GROUPNAME[browser.os] || browser.os, version: version, deviceName: device || browser.device }; }); var uniques = Object.keys(set).sort().map(function (id) { return set[id]; }); return uniques; }
javascript
{ "resource": "" }
q10910
train
function(elem, target) { this.selectDateOrig(elem, target); var inst = $.calendarsPicker._getInst(elem); if (!inst.inline && $.fn.validate) { var validation = $(elem).parents('form').validate(); if (validation) { validation.element('#' + elem.id); } } }
javascript
{ "resource": "" }
q10911
train
function(error, elem) { var inst = $.calendarsPicker._getInst(elem); if (inst) { error[inst.options.isRTL ? 'insertBefore' : 'insertAfter']( inst.trigger.length > 0 ? inst.trigger : elem); } else { error.insertAfter(elem); } }
javascript
{ "resource": "" }
q10912
train
function(source, params) { var format = ($.calendarsPicker.curInst ? $.calendarsPicker.curInst.get('dateFormat') : $.calendarsPicker.defaultOptions.dateFormat); $.each(params, function(index, value) { source = source.replace(new RegExp('\\{' + index + '\\}', 'g'), value.formatDate(format) || 'nothing'); }); return source; }
javascript
{ "resource": "" }
q10913
validateEach
train
function validateEach(value, elem) { var inst = $.calendarsPicker._getInst(elem); var dates = (inst.options.multiSelect ? value.split(inst.options.multiSeparator) : (inst.options.rangeSelect ? value.split(inst.options.rangeSeparator) : [value])); var ok = (inst.options.multiSelect && dates.length <= inst.options.multiSelect) || (!inst.options.multiSelect && inst.options.rangeSelect && dates.length === 2) || (!inst.options.multiSelect && !inst.options.rangeSelect && dates.length === 1); if (ok) { try { var dateFormat = inst.get('dateFormat'); var minDate = inst.get('minDate'); var maxDate = inst.get('maxDate'); var cp = $(elem); $.each(dates, function(i, v) { dates[i] = inst.options.calendar.parseDate(dateFormat, v); ok = ok && (!dates[i] || (cp.calendarsPicker('isSelectable', dates[i]) && (!minDate || dates[i].compareTo(minDate) !== -1) && (!maxDate || dates[i].compareTo(maxDate) !== +1))); }); } catch (e) { ok = false; } } if (ok && inst.options.rangeSelect) { ok = (dates[0].compareTo(dates[1]) !== +1); } return ok; }
javascript
{ "resource": "" }
q10914
normaliseParams
train
function normaliseParams(params) { if (typeof params === 'string') { params = params.split(' '); } else if (!$.isArray(params)) { var opts = []; for (var name in params) { opts[0] = name; opts[1] = params[name]; } params = opts; } return params; }
javascript
{ "resource": "" }
q10915
extractOtherDate
train
function extractOtherDate(elem, source, noOther) { if (source.newDate && source.extraInfo) { // Already a CDate return [source]; } var inst = $.calendarsPicker._getInst(elem); var thatDate = null; try { if (typeof source === 'string' && source !== 'today') { thatDate = inst.options.calendar.parseDate(inst.get('dateFormat'), source); } } catch (e) { // Ignore } thatDate = (thatDate ? [thatDate] : (source === 'today' ? [inst.options.calendar.today()] : (noOther ? [] : $(source).calendarsPicker('getDate')))); return thatDate; }
javascript
{ "resource": "" }
q10916
objectToArray
train
function objectToArray(object) { var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id'; var convertedArray = []; Object.keys(object).forEach(function (_key) { var item = object[_key]; item[key] = _key; convertedArray.push(item); }); return convertedArray; }
javascript
{ "resource": "" }
q10917
_nextStep
train
function _nextStep() { this._direction = 'forward'; if (typeof this._currentStepNumber !== 'undefined') { for (var i = 0, len = this._introItems.length; i < len; i++) { var item = this._introItems[i]; if (item.step === this._currentStepNumber) { this._currentStep = i - 1; this._currentStepNumber = undefined; } } } if (typeof this._currentStep === 'undefined') { this._currentStep = 0; } else { ++this._currentStep; } if (typeof this._introBeforeChangeCallback !== 'undefined') { var continueStep = this._introBeforeChangeCallback.call(this); } // if `onbeforechange` returned `false`, stop displaying the element if (continueStep === false) { --this._currentStep; return false; } if (this._introItems.length <= this._currentStep) { //end of the intro //check if any callback is defined if (typeof this._introCompleteCallback === 'function') { this._introCompleteCallback.call(this); } _exitIntro.call(this, this._targetElement); return; } var nextStep = this._introItems[this._currentStep]; _showElement.call(this, nextStep); }
javascript
{ "resource": "" }
q10918
_exitIntro
train
function _exitIntro(targetElement, force) { var continueExit = true; // calling onbeforeexit callback // // If this callback return `false`, it would halt the process if (this._introBeforeExitCallback != undefined) { continueExit = this._introBeforeExitCallback.call(self); } // skip this check if `force` parameter is `true` // otherwise, if `onbeforeexit` returned `false`, don't exit the intro if (!force && continueExit === false) return; //remove overlay layers from the page var overlayLayers = targetElement.querySelectorAll('.introjs-overlay'); if (overlayLayers && overlayLayers.length > 0) { for (var i = overlayLayers.length - 1; i >= 0; i--) { //for fade-out animation var overlayLayer = overlayLayers[i]; overlayLayer.style.opacity = 0; setTimeout( function() { if (this.parentNode) { this.parentNode.removeChild(this); } }.bind(overlayLayer), 500 ); } } //remove all helper layers var helperLayer = targetElement.querySelector('.introjs-helperLayer'); if (helperLayer) { helperLayer.parentNode.removeChild(helperLayer); } var referenceLayer = targetElement.querySelector('.introjs-tooltipReferenceLayer'); if (referenceLayer) { referenceLayer.parentNode.removeChild(referenceLayer); } //remove disableInteractionLayer var disableInteractionLayer = targetElement.querySelector('.introjs-disableInteraction'); if (disableInteractionLayer) { disableInteractionLayer.parentNode.removeChild(disableInteractionLayer); } //remove intro floating element var floatingElement = document.querySelector('.introjsFloatingElement'); if (floatingElement) { floatingElement.parentNode.removeChild(floatingElement); } _removeShowElement(); //remove `introjs-fixParent` class from the elements var fixParents = document.querySelectorAll('.introjs-fixParent'); if (fixParents && fixParents.length > 0) { for (var i = fixParents.length - 1; i >= 0; i--) { fixParents[i].className = fixParents[i].className .replace(/introjs-fixParent/g, '') .replace(/^\s+|\s+$/g, ''); } } //clean listeners if (window.removeEventListener) { window.removeEventListener('keydown', this._onKeyDown, true); } else if (document.detachEvent) { //IE document.detachEvent('onkeydown', this._onKeyDown); } //check if any callback is defined if (this._introExitCallback != undefined) { this._introExitCallback.call(self); } //set the step to zero this._currentStep = undefined; }
javascript
{ "resource": "" }
q10919
_checkRight
train
function _checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer) { if (targetOffset.left + tooltipLayerStyleLeft + tooltipOffset.width > windowSize.width) { // off the right side of the window tooltipLayer.style.left = windowSize.width - tooltipOffset.width - targetOffset.left + 'px'; return false; } tooltipLayer.style.left = tooltipLayerStyleLeft + 'px'; return true; }
javascript
{ "resource": "" }
q10920
_determineAutoPosition
train
function _determineAutoPosition(targetElement, tooltipLayer, desiredTooltipPosition) { // Take a clone of position precedence. These will be the available var possiblePositions = this._options.positionPrecedence.slice(); var windowSize = _getWinSize(); var tooltipHeight = _getOffset(tooltipLayer).height + 10; var tooltipWidth = _getOffset(tooltipLayer).width + 20; var targetOffset = _getOffset(targetElement); // If we check all the possible areas, and there are no valid places for the tooltip, the element // must take up most of the screen real estate. Show the tooltip floating in the middle of the screen. var calculatedPosition = 'floating'; // TODO Update by joyer // Check if the width of the tooltip + the starting point would spill off the right side of the screen // If no, neither bottom or top are valid // if (targetOffset.left + tooltipWidth > windowSize.width || ((targetOffset.left + (targetOffset.width / 2)) - tooltipWidth) < 0) { // _removeEntry(possiblePositions, "bottom"); // _removeEntry(possiblePositions, "top"); // } else { // Check for space below if (targetOffset.height + targetOffset.top + tooltipHeight > windowSize.height) { _removeEntry(possiblePositions, 'bottom'); } // Check for space above if (targetOffset.top - tooltipHeight < 0) { _removeEntry(possiblePositions, 'top'); } // } // Check for space to the right if (targetOffset.width + targetOffset.left + tooltipWidth > windowSize.width) { _removeEntry(possiblePositions, 'right'); } // Check for space to the left if (targetOffset.left - tooltipWidth < 0) { _removeEntry(possiblePositions, 'left'); } // At this point, our array only has positions that are valid. Pick the first one, as it remains in order if (possiblePositions.length > 0) { calculatedPosition = possiblePositions[0]; } // If the requested position is in the list, replace our calculated choice with that if (desiredTooltipPosition && desiredTooltipPosition != 'auto') { if (possiblePositions.indexOf(desiredTooltipPosition) > -1) { calculatedPosition = desiredTooltipPosition; } } return calculatedPosition; }
javascript
{ "resource": "" }
q10921
_removeEntry
train
function _removeEntry(stringArray, stringToRemove) { if (stringArray.indexOf(stringToRemove) > -1) { stringArray.splice(stringArray.indexOf(stringToRemove), 1); } }
javascript
{ "resource": "" }
q10922
_setHelperLayerPosition
train
function _setHelperLayerPosition(helperLayer) { if (helperLayer) { //prevent error when `this._currentStep` in undefined if (!this._introItems[this._currentStep]) return; var currentElement = this._introItems[this._currentStep], elementPosition = _getOffset(currentElement.element), widthHeightPadding = 10; // If the target element is fixed, the tooltip should be fixed as well. // Otherwise, remove a fixed class that may be left over from the previous // step. if (_isFixed(currentElement.element)) { helperLayer.className += ' introjs-fixedTooltip'; } else { helperLayer.className = helperLayer.className.replace(' introjs-fixedTooltip', ''); } if (currentElement.position == 'floating') { widthHeightPadding = 0; } //set new position to helper layer helperLayer.setAttribute( 'style', 'width: ' + (elementPosition.width + widthHeightPadding) + 'px; ' + 'height:' + (elementPosition.height + widthHeightPadding) + 'px; ' + 'top:' + (elementPosition.top - 5) + 'px;' + 'left: ' + (elementPosition.left - 5) + 'px;' ); } }
javascript
{ "resource": "" }
q10923
_disableInteraction
train
function _disableInteraction() { var disableInteractionLayer = document.querySelector('.introjs-disableInteraction'); if (disableInteractionLayer === null) { disableInteractionLayer = document.createElement('div'); disableInteractionLayer.className = 'introjs-disableInteraction'; this._targetElement.appendChild(disableInteractionLayer); } _setHelperLayerPosition.call(this, disableInteractionLayer); }
javascript
{ "resource": "" }
q10924
_scrollTo
train
function _scrollTo(scrollTo, targetElement, tooltipLayer) { if (!this._options.scrollToElement) return; if (scrollTo === 'tooltip') { var rect = tooltipLayer.getBoundingClientRect(); } else { var rect = targetElement.element.getBoundingClientRect(); } if (!_elementInViewport(targetElement.element)) { var winHeight = _getWinSize().height; var top = rect.bottom - (rect.bottom - rect.top); var bottom = rect.bottom - winHeight; // TODO (afshinm): do we need scroll padding now? // I have changed the scroll option and now it scrolls the window to // the center of the target element or tooltip. if (top < 0 || targetElement.element.clientHeight > winHeight) { window.scrollBy( 0, rect.top - (winHeight / 2 - rect.height / 2) - this._options.scrollPadding ); // 30px padding from edge to look nice //Scroll down } else { window.scrollBy( 0, rect.top - (winHeight / 2 - rect.height / 2) + this._options.scrollPadding ); // 30px padding from edge to look nice } } }
javascript
{ "resource": "" }
q10925
_populateHints
train
function _populateHints(targetElm) { var self = this; this._introItems = []; if (this._options.hints) { for (var i = 0, l = this._options.hints.length; i < l; i++) { var currentItem = _cloneObject(this._options.hints[i]); if (typeof currentItem.element === 'string') { //grab the element with given selector from the page currentItem.element = document.querySelector(currentItem.element); } currentItem.hintPosition = currentItem.hintPosition || this._options.hintPosition; currentItem.hintAnimation = currentItem.hintAnimation || this._options.hintAnimation; if (currentItem.element != null) { this._introItems.push(currentItem); } } } else { var hints = targetElm.querySelectorAll('*[data-hint]'); if (hints.length < 1) { return false; } //first add intro items with data-step for (var i = 0, l = hints.length; i < l; i++) { var currentElement = hints[i]; // hint animation var hintAnimation = currentElement.getAttribute('data-hintAnimation'); if (hintAnimation) { hintAnimation = hintAnimation == 'true'; } else { hintAnimation = this._options.hintAnimation; } this._introItems.push({ element: currentElement, hint: currentElement.getAttribute('data-hint'), hintPosition: currentElement.getAttribute('data-hintPosition') || this._options.hintPosition, hintAnimation: hintAnimation, tooltipClass: currentElement.getAttribute('data-tooltipClass'), position: currentElement.getAttribute('data-position') || this._options.tooltipPosition }); } } _addHints.call(this); if (document.addEventListener) { document.addEventListener('click', _removeHintTooltip.bind(this), false); //for window resize window.addEventListener('resize', _reAlignHints.bind(this), true); } else if (document.attachEvent) { //IE //for window resize document.attachEvent('onclick', _removeHintTooltip.bind(this)); document.attachEvent('onresize', _reAlignHints.bind(this)); } }
javascript
{ "resource": "" }
q10926
_reAlignHints
train
function _reAlignHints() { for (var i = 0, l = this._introItems.length; i < l; i++) { var item = this._introItems[i]; if (typeof item.targetElement == 'undefined') continue; _alignHintPosition.call(this, item.hintPosition, item.element, item.targetElement); } }
javascript
{ "resource": "" }
q10927
_hideHint
train
function _hideHint(stepId) { _removeHintTooltip.call(this); var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]'); if (hint) { hint.className += ' introjs-hidehint'; } // call the callback function (if any) if (typeof this._hintCloseCallback !== 'undefined') { this._hintCloseCallback.call(this, stepId); } }
javascript
{ "resource": "" }
q10928
_hideHints
train
function _hideHints() { var hints = this._targetElement.querySelectorAll('.introjs-hint'); if (hints && hints.length > 0) { for (var i = 0; i < hints.length; i++) { _hideHint.call(this, hints[i].getAttribute('data-step')); } } }
javascript
{ "resource": "" }
q10929
_showHints
train
function _showHints() { var hints = this._targetElement.querySelectorAll('.introjs-hint'); if (hints && hints.length > 0) { for (var i = 0; i < hints.length; i++) { _showHint.call(this, hints[i].getAttribute('data-step')); } } else { _populateHints.call(this, this._targetElement); } }
javascript
{ "resource": "" }
q10930
_showHint
train
function _showHint(stepId) { var hint = this._targetElement.querySelector('.introjs-hint[data-step="' + stepId + '"]'); if (hint) { hint.className = hint.className.replace(/introjs\-hidehint/g, ''); } }
javascript
{ "resource": "" }
q10931
_addHints
train
function _addHints() { var self = this; var oldHintsWrapper = document.querySelector('.introjs-hints'); if (oldHintsWrapper != null) { hintsWrapper = oldHintsWrapper; } else { var hintsWrapper = document.createElement('div'); hintsWrapper.className = 'introjs-hints'; } for (var i = 0, l = this._introItems.length; i < l; i++) { var item = this._introItems[i]; // avoid append a hint twice if (document.querySelector('.introjs-hint[data-step="' + i + '"]')) continue; var hint = document.createElement('a'); _setAnchorAsButton(hint); (function(hint, item, i) { // when user clicks on the hint element hint.onclick = function(e) { var evt = e ? e : window.event; if (evt.stopPropagation) evt.stopPropagation(); if (evt.cancelBubble != null) evt.cancelBubble = true; _showHintDialog.call(self, i); }; })(hint, item, i); hint.className = 'introjs-hint'; if (!item.hintAnimation) { hint.className += ' introjs-hint-no-anim'; } // hint's position should be fixed if the target element's position is fixed if (_isFixed(item.element)) { hint.className += ' introjs-fixedhint'; } var hintDot = document.createElement('div'); hintDot.className = 'introjs-hint-dot'; var hintPulse = document.createElement('div'); hintPulse.className = 'introjs-hint-pulse'; hint.appendChild(hintDot); hint.appendChild(hintPulse); hint.setAttribute('data-step', i); // we swap the hint element with target element // because _setHelperLayerPosition uses `element` property item.targetElement = item.element; item.element = hint; // align the hint position _alignHintPosition.call(this, item.hintPosition, hint, item.targetElement); hintsWrapper.appendChild(hint); } // adding the hints wrapper document.body.appendChild(hintsWrapper); // call the callback function (if any) if (typeof this._hintsAddedCallback !== 'undefined') { this._hintsAddedCallback.call(this); } }
javascript
{ "resource": "" }
q10932
turnOffListeningAndUpdate
train
function turnOffListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) { var offValueOrOffEmitFn; // Use either offValue or offEmit depending on which Symbols are on the `observable` if (listenToObservable[onValueSymbol]) { offValueOrOffEmitFn = canReflect.offValue; } else if (listenToObservable[onEmitSymbol]) { offValueOrOffEmitFn = offEmit; } if (offValueOrOffEmitFn) { offValueOrOffEmitFn(listenToObservable, updateFunction, queue); //!steal-remove-start if(process.env.NODE_ENV !== 'production') { // The updateObservable is no longer mutated by listenToObservable canReflectDeps.deleteMutatedBy(updateObservable, listenToObservable); // The updateFunction no longer mutates anything updateFunction[getChangesSymbol] = function getChangesDependencyRecord() { }; } //!steal-remove-end } }
javascript
{ "resource": "" }
q10933
turnOnListeningAndUpdate
train
function turnOnListeningAndUpdate(listenToObservable, updateObservable, updateFunction, queue) { var onValueOrOnEmitFn; // Use either onValue or onEmit depending on which Symbols are on the `observable` if (listenToObservable[onValueSymbol]) { onValueOrOnEmitFn = canReflect.onValue; } else if (listenToObservable[onEmitSymbol]) { onValueOrOnEmitFn = onEmit; } if (onValueOrOnEmitFn) { onValueOrOnEmitFn(listenToObservable, updateFunction, queue); //!steal-remove-start if(process.env.NODE_ENV !== 'production') { // The updateObservable is mutated by listenToObservable canReflectDeps.addMutatedBy(updateObservable, listenToObservable); // The updateFunction mutates updateObservable updateFunction[getChangesSymbol] = function getChangesDependencyRecord() { var s = new Set(); s.add(updateObservable); return { valueDependencies: s }; }; } //!steal-remove-end } }
javascript
{ "resource": "" }
q10934
train
function() { if (this._bindingState.child === false && this._childToParent === true) { var options = this._options; this._bindingState.child = true; turnOnListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue); } }
javascript
{ "resource": "" }
q10935
train
function() { if (this._bindingState.parent === false && this._parentToChild === true) { var options = this._options; this._bindingState.parent = true; turnOnListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue); } }
javascript
{ "resource": "" }
q10936
train
function() { var bindingState = this._bindingState; var options = this._options; // Turn off the parent listener if (bindingState.parent === true && this._parentToChild === true) { bindingState.parent = false; turnOffListeningAndUpdate(options.parent, options.child, this._updateChild, options.queue); } // Turn off the child listener if (bindingState.child === true && this._childToParent === true) { bindingState.child = false; turnOffListeningAndUpdate(options.child, options.parent, this._updateParent, options.queue); } }
javascript
{ "resource": "" }
q10937
train
function(mins, maxs) { // make sure correct number of elements in both mins and maxs if (mins.length != 3 || maxs.length != 3) throw new Error("Mins and Maxs should have 3 elements each"); // make sure all maxes are greater than mins mins.forEach(function(v, i) { if (v >= maxs[i]) throw new Error("All elements of maxs should be greater than mins"); }); this.mins = mins; this.maxs = maxs; }
javascript
{ "resource": "" }
q10938
train
function(host) { if (!host) throw new Error('Need hostname to initialize reader'); if (host.match(/^(\S+):\/\//)) throw new Error('Protocol specified, need bare hostname'); this.host = host; var portParts = this.host.match(/:(\d+)$/); if (portParts !== null) this.port = parseInt(portParts[1]); else this.port = 80; // make sure port stuff is taken out of the host // var hostParts = this.host.match(/^(\S+):/); if (hostParts) this.host = hostParts[1]; }
javascript
{ "resource": "" }
q10939
filterGenerator
train
function filterGenerator(filter) { if(typeof filter === "boolean") return () => filter; if(typeof filter === "function") return filter; if(filter instanceof RegExp) return input => filter.test(input); if(filter instanceof Set) return input => filter.has(input); if(filter instanceof Map) return input => !!filter.get(input); if(Array.isArray(filter)) return input => filter.indexOf(input) !== -1; if(filter && typeof filter === "object") return input => !!filter[input]; throw new TypeError("Invalid filter type."); }
javascript
{ "resource": "" }
q10940
preconnect
train
function preconnect(user, sshKeyPath, ipaddress, cb, pollCount) { if (pollCount === undefined) { pollCount = 0; } logger.info({ user: user, identityFile: sshKeyPath, ipAddress: ipaddress }, 'waiting for connectivity'); portscanner.checkPortStatus(22, ipaddress, function(err, status) { if (status === 'closed') { if (pollCount > MAX_POLLS) { pollCount = 0; cb('timeout exceeded - unable to connect to: ' + ipaddress); } else { pollCount = pollCount + 1; setTimeout(function() { preconnect(user, sshKeyPath, ipaddress, cb, pollCount); }, POLL_INTERVAL); } } else if (status === 'open') { pollCount = 0; sshCheck.check(ipaddress, user, sshKeyPath, null, function(err) { cb(err); }); } }); }
javascript
{ "resource": "" }
q10941
UpdateChartData
train
function UpdateChartData() { while(Points > 10) { Points -= 1; myLineChart.removeData(); } myLineChart.addData([Data["Temperature"]], Math.floor((Date.now() - StartTime) / 1000.0)); myLineChart.update(); Points+=1; }
javascript
{ "resource": "" }
q10942
train
function(err, results) { if(err) { this.success = false; this.error = err; this.results = null; // customize error for error types if(util.isError(err)) { this.error = { message: err.message, type: err.type, arguments: err.arguments }; if(NODE_ENV === 'development') { this.error.stack = err.stack; } } } else { this.success = true; this.error = null; this.results = convertToClient(results); } }
javascript
{ "resource": "" }
q10943
permutations
train
function permutations(iterable, r) { // (ABCD, 2) -> AB AC AD BA BC BD CA CB CD DA DB DC // (012, 3) -> 012 021 102 120 201 210 /* 0 1 2 3, 3 ______ (0, 1, 2) (0, 1, 3) (0, 2, 1) (0, 2, 3) (0, 3, 1) (0, 3, 2) (1, 0, 2) (1, 0, 3) (1, 2, 0) (1, 2, 3) (1, 3, 0) (1, 3, 2) (2, 0, 1) (2, 0, 3) (2, 1, 0) (2, 1, 3) (2, 3, 0) (2, 3, 1) (3, 0, 1) (3, 0, 2) (3, 1, 0) (3, 1, 2) (3, 2, 0) (3, 2, 1) */ var pool = tools.toArray(tools.ensureIter(iterable)); var n = pool.length; r = r || n; if (r > n) { throw new Error( 'Parameter r cannot be greater than amount of elements in the iterable [' + n + ']' ); } var indices = tools.newArray(r, 0, 1); function fromIndices() { state.current = indices.map(function(idx) { state.used[idx] = true; return pool[idx]; }); } function next() { // 0. indices: 0, 1, 2 // 1. indices: 0, 1, 3 // 2. indices: 0, 1, 4 -> carry = t 0, 1, -1 -> 0, 1, 0 -> 0, 1, 1 -> 0, 1, 2 var backtrack = null; var i = indices.length - 1; for (; i >= 0; i--) { indices[i]++; if (indices[i] === n) { // Time to reset current index and increase previous one. if (i === 0) { // There is no previous index, so it's the end of generation. continue; } delete state.used[indices[i - 1]]; // Release previous index backtrack = indices[i] - 1; // Pre-save current index to be able to release it in future. indices[i] = -1; // Reset current index i++; continue; } if (state.used[indices[i]]) { // Trying to increase current index until find the // lowest free value or reach the end of the range. i++; continue; } // First free value found. Release previous one. if (backtrack !== null) { // If we need to backtrack, doing it! delete state.used[backtrack]; backtrack = null; continue; } // Otherwise exiting from the generation. break; } if (i < 0) { state.finished = true; } else { fromIndices(); } } var state = {current: null, finished: false, used: {}}; var permutIter = { next: function() { state.current ? next() : fromIndices(); return { done: state.finished, value: state.finished ? undefined : state.current }; } }; return tools.fuseIter(permutIter, function() { return permutIter; }); }
javascript
{ "resource": "" }
q10944
drop
train
function drop(schemas) { var resolver = new Resolver(schemas); var knex = this.knex; return Promise.map(schemas || [], function(schema) { return (schema.preDrop || _.noop)(knex); }) .then(function () { // Reduce force sequential execution. return Promise.reduce(resolver.resolve().reverse(), dropSchema.bind(this), []); }.bind(this)); }
javascript
{ "resource": "" }
q10945
dropSchema
train
function dropSchema(result, schema) { return this.knex.schema.dropTableIfExists(schema.tableName) .then(function () { return result.concat([schema]); }); }
javascript
{ "resource": "" }
q10946
formatNumber
train
function formatNumber(value, options) { options = options || {}; value += ''; // must be String Type // not a number !! if (!__isNumber(value)) { return false; } var valueArr = __splitValue(value), integer = valueArr[0], negative = integer < 0, absInteger = Math.abs(integer) + '', formattedValue; if (options.reduce) { if (absInteger >= 100000 && absInteger <= 999999) { options.prefix = 'k' + options.prefix; integer = integer.slice(0, -3); } else if (absInteger > 999999 && absInteger <= 9999999) { options.prefix = 'Mio ' + options.prefix; integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1]; } else if (absInteger > 9999999 && absInteger <= 999999999) { options.prefix = 'Mio ' + options.prefix; integer = integer.slice(0, -6); } else if (absInteger > 999999999 && absInteger <= 9999999999) { options.prefix = 'Mrd ' + options.prefix; integer = integer.slice(0, -8); integer = negative ? '-' + absInteger[0] + ',' + absInteger[1] : absInteger[0] + ',' + absInteger[1]; } else if (absInteger > 9999999999) { options.prefix = 'Mrd ' + options.prefix; integer = integer.slice(0, -9); } // add spaces formattedValue = __addSpacesSeparator(integer); } else { // add spaces valueArr[0] = __addSpacesSeparator(integer); formattedValue = valueArr.join(','); } if (options.prefix) { formattedValue += ' ' + options.prefix; } return formattedValue; }
javascript
{ "resource": "" }
q10947
__addSpacesSeparator
train
function __addSpacesSeparator(val) { var reg = /(\d+)(\d{3})/, sep = ' '; // val must be a type String val += ''; while (reg.test(val)) { val = val.replace(reg, '$1' + sep + '$2'); } return val; }
javascript
{ "resource": "" }
q10948
train
function(name, otherArgs) { if (name === 'option' && (otherArgs.length === 0 || (otherArgs.length === 1 && typeof otherArgs[0] === 'string'))) { return true; } return $.inArray(name, this._getters) > -1; }
javascript
{ "resource": "" }
q10949
train
function(elem, options) { elem = $(elem); if (elem.hasClass(this._getMarker())) { return; } elem.addClass(this._getMarker()); options = $.extend({}, this.defaultOptions, this._getMetadata(elem), options || {}); var inst = $.extend({name: this.name, elem: elem, options: options}, this._instSettings(elem, options)); elem.data(this.name, inst); // Save instance against element this._postAttach(elem, inst); this.option(elem, options); }
javascript
{ "resource": "" }
q10950
train
function(elem, name, value) { elem = $(elem); var inst = elem.data(this.name); if (!name || (typeof name === 'string' && value == null)) { var options = (inst || {}).options; return (options && name ? options[name] : options); } if (!elem.hasClass(this._getMarker())) { return; } var options = name || {}; if (typeof name === 'string') { options = {}; options[name] = value; } this._optionsChanged(elem, inst, options); $.extend(inst.options, options); }
javascript
{ "resource": "" }
q10951
train
function(superClass, overrides) { if (typeof superClass === 'object') { overrides = superClass; superClass = 'JQPlugin'; } superClass = camelCase(superClass); var className = camelCase(overrides.name); JQClass.classes[className] = JQClass.classes[superClass].extend(overrides); new JQClass.classes[className](); }
javascript
{ "resource": "" }
q10952
fingerprint
train
function fingerprint(str) { var /** @type {?} */ utf8 = utf8Encode(str); var _a = [hash32(utf8, 0), hash32(utf8, 102072)], hi = _a[0], lo = _a[1]; if (hi == 0 && (lo == 0 || lo == 1)) { hi = hi ^ 0x130f9bef; lo = lo ^ -0x6b5f56d8; } return [hi, lo]; }
javascript
{ "resource": "" }
q10953
_removeDotSegments
train
function _removeDotSegments(path) { if (path == '/') return '/'; var /** @type {?} */ leadingSlash = path[0] == '/' ? '/' : ''; var /** @type {?} */ trailingSlash = path[path.length - 1] === '/' ? '/' : ''; var /** @type {?} */ segments = path.split('/'); var /** @type {?} */ out = []; var /** @type {?} */ up = 0; for (var /** @type {?} */ pos = 0; pos < segments.length; pos++) { var /** @type {?} */ segment = segments[pos]; switch (segment) { case '': case '.': break; case '..': if (out.length > 0) { out.pop(); } else { up++; } break; default: out.push(segment); } } if (leadingSlash == '') { while (up-- > 0) { out.unshift('..'); } if (out.length === 0) out.push('.'); } return leadingSlash + out.join('/') + trailingSlash; }
javascript
{ "resource": "" }
q10954
convertPropertyBinding
train
function convertPropertyBinding(localResolver, implicitReceiver, expressionWithoutBuiltins, bindingId) { if (!localResolver) { localResolver = new DefaultLocalResolver(); } var /** @type {?} */ currValExpr = createCurrValueExpr(bindingId); var /** @type {?} */ stmts = []; var /** @type {?} */ visitor = new _AstToIrVisitor(localResolver, implicitReceiver, bindingId); var /** @type {?} */ outputExpr = expressionWithoutBuiltins.visit(visitor, _Mode.Expression); if (visitor.temporaryCount) { for (var /** @type {?} */ i = 0; i < visitor.temporaryCount; i++) { stmts.push(temporaryDeclaration(bindingId, i)); } } stmts.push(currValExpr.set(outputExpr).toDeclStmt(null, [StmtModifier.Final])); return new ConvertPropertyBindingResult(stmts, currValExpr); }
javascript
{ "resource": "" }
q10955
Class
train
function Class(clsDef) { var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor'); var /** @type {?} */ proto = constructor.prototype; if (clsDef.hasOwnProperty('extends')) { if (typeof clsDef.extends === 'function') { ((constructor)).prototype = proto = Object.create(((clsDef.extends)).prototype); } else { throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends)); } } for (var /** @type {?} */ key in clsDef) { if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) { proto[key] = applyParams(clsDef[key], key); } } if (this && this.annotations instanceof Array) { Reflect.defineMetadata('annotations', this.annotations, constructor); } var /** @type {?} */ constructorName = constructor['name']; if (!constructorName || constructorName === 'constructor') { ((constructor))['overriddenName'] = "class" + _nextClassId++; } return (constructor); }
javascript
{ "resource": "" }
q10956
mapFromArray
train
function mapFromArray(array, prop) { var map = {}; for (var i = 0; i < array.length; i++) { map[ array[i][prop] ] = array[i]; } return map; }
javascript
{ "resource": "" }
q10957
saveCleanPeople
train
function saveCleanPeople () { var cleanPeople return Promise.resolve() .then(() => { cleanPeople = kb.sym(stats.book.dir().uri + 'clean-people.ttl') var sts = [] for (let i = 0; i < stats.uniques.length; i++) { sts = sts.concat(kb.connectedStatements(stats.uniques[i], stats.nameEmailIndex)) } var sz = (new $rdf.Serializer(kb)).setBase(stats.nameEmailIndex.uri) log('Serializing index of uniques...') var data = sz.statementsToN3(sts) return kb.fetcher.webOperation('PUT', cleanPeople, { data: data, contentType: 'text/turtle' }) }) .then(function () { log('Done uniques log ' + cleanPeople) return true }) .catch(function (e) { log('Error saving uniques: ' + e) }) }
javascript
{ "resource": "" }
q10958
train
function() { if (value.charAt(iValue) !== format.charAt(iFormat)) { throw (main.local.unexpectedLiteralAt || main.regionalOptions[''].unexpectedLiteralAt).replace(/\{0\}/, iValue); } iValue++; }
javascript
{ "resource": "" }
q10959
train
function (intersects) { if (_.isString(intersects)) { try { intersects = JSON.parse(intersects); } catch (e) { throw new Error('Invalid Geojson'); } } return intersects; }
javascript
{ "resource": "" }
q10960
train
function(callback) { server = illyria2.createServer(); server.expose("benchmark", { echo: function(req, resp) { resp.send(req.params()); } }); server.listen(SERVER_PORT, function() { callback(); }); }
javascript
{ "resource": "" }
q10961
train
function(callback) { var scarlet = new Scarlet(Math.min(opts.n, 100)); function connect(taskObject) { var client = taskObject.task.client; var i = taskObject.task.idx; client.connect(function() { scarlet.taskDone(taskObject); }); client.on("error", function(err) { console.log(err + ": Client " + i); }); } console.time("Connect"); // if mode is `clients`, we create (opts.complicating) clients, // otherwise we create only one. var max = opts["complicating-mode"] === "clients" ? opts.complicating : 1; for(var i = 0; i < max; i++) { var client = illyria2.createClient("127.0.0.1", SERVER_PORT, { runTimeout: 10000, retryInterval: 1000, reconnect: true }); scarlet.push({ idx: i, client: client }, connect); clients.push(client); } scarlet.afterFinish(max, function() { console.timeEnd("Connect"); callback(); }, false); }
javascript
{ "resource": "" }
q10962
train
function(callback) { block = ""; for(var i = 0; i < opts.size; i++) block + "."; testAbility(callback); }
javascript
{ "resource": "" }
q10963
train
function (events, options) { var eventKeys = _.keys(events || {}), limitEvents, parsedEvents = []; // Optionally filter using set of acceptable event types limitEvents = options.only; eventKeys = _.filter(eventKeys, function checkEventName (eventKey) { // Parse event string into semantic representation var event = Events.parseDOMEvent(eventKey); parsedEvents.push(event); // Optional filter if (limitEvents) { return _.contains(limitEvents, event.name); } return true; }); return parsedEvents; }
javascript
{ "resource": "" }
q10964
train
function(inst) { var maxDate = inst.get('maxDate'); return (!maxDate || inst.drawDate.newDate(). add(inst.options.monthsToJump - inst.options.monthsOffset, 'm'). day(inst.options.calendar.minDay).compareTo(maxDate) !== +1); }
javascript
{ "resource": "" }
q10965
train
function(inst) { var minDate = inst.curMinDate(); var maxDate = inst.get('maxDate'); var curDate = inst.selectedDates[0] || inst.options.calendar.today(); return (!minDate || curDate.compareTo(minDate) !== -1) && (!maxDate || curDate.compareTo(maxDate) !== +1); }
javascript
{ "resource": "" }
q10966
train
function(inst) { var minDate = inst.curMinDate(); return (!minDate || inst.drawDate.newDate(). add(-inst.options.calendar.daysInWeek(), 'd').compareTo(minDate) !== -1); }
javascript
{ "resource": "" }
q10967
train
function(inst) { var minDate = inst.curMinDate(); return (!minDate || inst.drawDate.newDate().add(-1, 'd'). compareTo(minDate) !== -1); }
javascript
{ "resource": "" }
q10968
train
function(inst) { var maxDate = inst.get('maxDate'); return (!maxDate || inst.drawDate.newDate().add(1, 'd'). compareTo(maxDate) !== +1); }
javascript
{ "resource": "" }
q10969
train
function(inst) { var maxDate = inst.get('maxDate'); return (!maxDate || inst.drawDate.newDate(). add(inst.options.calendar.daysInWeek(), 'd').compareTo(maxDate) !== +1); }
javascript
{ "resource": "" }
q10970
train
function(elem, inst) { elem.off('focus.' + inst.name); if (inst.options.showOnFocus) { elem.on('focus.' + inst.name, this.show); } if (inst.trigger) { inst.trigger.remove(); } var trigger = inst.options.showTrigger; inst.trigger = (!trigger ? $([]) : $(trigger).clone().removeAttr('id').addClass(this._triggerClass) [inst.options.isRTL ? 'insertBefore' : 'insertAfter'](elem). click(function() { if (!plugin.isDisabled(elem[0])) { plugin[plugin.curInst === inst ? 'hide' : 'show'](elem[0]); } })); this._autoSize(elem, inst); var dates = this._extractDates(inst, elem.val()); if (dates) { this.setDate(elem[0], dates, null, true); } var defaultDate = inst.get('defaultDate'); if (inst.options.selectDefaultDate && defaultDate && inst.selectedDates.length === 0) { this.setDate(elem[0], (defaultDate || inst.options.calendar.today()).newDate()); } }
javascript
{ "resource": "" }
q10971
train
function(elem, inst) { if (inst.options.autoSize && !inst.inline) { var calendar = inst.options.calendar; var date = calendar.newDate(2009, 10, 20); // Ensure double digits var dateFormat = inst.get('dateFormat'); if (dateFormat.match(/[DM]/)) { var findMax = function(names) { var max = 0; var maxI = 0; for (var i = 0; i < names.length; i++) { if (names[i].length > max) { max = names[i].length; maxI = i; } } return maxI; }; date.month(findMax(calendar.local[dateFormat.match(/MM/) ? // Longest month 'monthNames' : 'monthNamesShort']) + 1); date.day(findMax(calendar.local[dateFormat.match(/DD/) ? // Longest day 'dayNames' : 'dayNamesShort']) + 20 - date.dayOfWeek()); } inst.elem.attr('size', date.formatDate(dateFormat, {localNumbers: inst.options.localnumbers}).length); } }
javascript
{ "resource": "" }
q10972
train
function(fns) { var funcs = arguments; return function(args) { for (var i = 0; i < funcs.length; i++) { funcs[i].apply(this, arguments); } }; }
javascript
{ "resource": "" }
q10973
train
function(elem) { elem = $(elem); if (!elem.hasClass(this._getMarker())) { return; } var inst = this._getInst(elem); if (inst.inline) { elem.children('.' + this._disableClass).remove().end(). find('button,select').prop('disabled', false).end(). find('a').attr('href', 'javascript:void(0)'); } else { elem.prop('disabled', false); inst.trigger.filter('button.' + this._triggerClass).prop('disabled', false).end(). filter('img.' + this._triggerClass).css({opacity: '1.0', cursor: ''}); } this._disabled = $.map(this._disabled, function(value) { return (value === elem[0] ? null : value); }); // Delete entry }
javascript
{ "resource": "" }
q10974
train
function(elem) { elem = $(elem); if (!elem.hasClass(this._getMarker())) { return; } var inst = this._getInst(elem); if (inst.inline) { var inline = elem.children(':last'); var offset = inline.offset(); var relOffset = {left: 0, top: 0}; inline.parents().each(function() { if ($(this).css('position') === 'relative') { relOffset = $(this).offset(); return false; } }); var zIndex = elem.css('zIndex'); zIndex = (zIndex === 'auto' ? 0 : parseInt(zIndex, 10)) + 1; elem.prepend('<div class="' + this._disableClass + '" style="' + 'width: ' + inline.outerWidth() + 'px; height: ' + inline.outerHeight() + 'px; left: ' + (offset.left - relOffset.left) + 'px; top: ' + (offset.top - relOffset.top) + 'px; z-index: ' + zIndex + '"></div>'). find('button,select').prop('disabled', true).end(). find('a').removeAttr('href'); } else { elem.prop('disabled', true); inst.trigger.filter('button.' + this._triggerClass).prop('disabled', true).end(). filter('img.' + this._triggerClass).css({opacity: '0.5', cursor: 'default'}); } this._disabled = $.map(this._disabled, function(value) { return (value === elem[0] ? null : value); }); // Delete entry this._disabled.push(elem[0]); }
javascript
{ "resource": "" }
q10975
train
function(elem) { elem = $(elem.target || elem); var inst = plugin._getInst(elem); if (plugin.curInst === inst) { return; } if (plugin.curInst) { plugin.hide(plugin.curInst, true); } if (!$.isEmptyObject(inst)) { // Retrieve existing date(s) inst.lastVal = null; inst.selectedDates = plugin._extractDates(inst, elem.val()); inst.pickingRange = false; inst.drawDate = plugin._checkMinMax((inst.selectedDates[0] || inst.get('defaultDate') || inst.options.calendar.today()).newDate(), inst); inst.prevDate = inst.drawDate.newDate(); plugin.curInst = inst; // Generate content plugin._update(elem[0], true); // Adjust position before showing var offset = plugin._checkOffset(inst); inst.div.css({left: offset.left, top: offset.top}); // And display var showAnim = inst.options.showAnim; var showSpeed = inst.options.showSpeed; showSpeed = (showSpeed === 'normal' && $.ui && parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed); if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) { var data = inst.div.data(); // Update old effects data for (var key in data) { if (key.match(/^ec\.storage\./)) { data[key] = inst._mainDiv.css(key.replace(/ec\.storage\./, '')); } } inst.div.data(data).show(showAnim, inst.options.showOptions, showSpeed); } else { inst.div[showAnim || 'show'](showAnim ? showSpeed : 0); } } }
javascript
{ "resource": "" }
q10976
train
function(inst, datesText) { if (datesText === inst.lastVal) { return; } inst.lastVal = datesText; datesText = datesText.split(inst.options.multiSelect ? inst.options.multiSeparator : (inst.options.rangeSelect ? inst.options.rangeSeparator : '\x00')); var dates = []; for (var i = 0; i < datesText.length; i++) { try { var date = inst.options.calendar.parseDate(inst.get('dateFormat'), datesText[i]); if (date) { var found = false; for (var j = 0; j < dates.length; j++) { if (dates[j].compareTo(date) === 0) { found = true; break; } } if (!found) { dates.push(date); } } } catch (e) { // Ignore } } dates.splice(inst.options.multiSelect || (inst.options.rangeSelect ? 2 : 1), dates.length); if (inst.options.rangeSelect && dates.length === 1) { dates[1] = dates[0]; } return dates; }
javascript
{ "resource": "" }
q10977
train
function(elem, hidden) { elem = $(elem.target || elem); var inst = plugin._getInst(elem); if (!$.isEmptyObject(inst)) { if (inst.inline || plugin.curInst === inst) { if ($.isFunction(inst.options.onChangeMonthYear) && (!inst.prevDate || inst.prevDate.year() !== inst.drawDate.year() || inst.prevDate.month() !== inst.drawDate.month())) { inst.options.onChangeMonthYear.apply(elem[0], [inst.drawDate.year(), inst.drawDate.month()]); } } if (inst.inline) { var index = $('a, :input', elem).index($(':focus', elem)); elem.html(this._generateContent(elem[0], inst)); var focus = elem.find('a, :input'); focus.eq(Math.max(Math.min(index, focus.length - 1), 0)).focus(); } else if (plugin.curInst === inst) { if (!inst.div) { inst.div = $('<div></div>').addClass(this._popupClass). css({display: (hidden ? 'none' : 'static'), position: 'absolute', left: elem.offset().left, top: elem.offset().top + elem.outerHeight()}). appendTo($(inst.options.popupContainer || 'body')); if ($.fn.mousewheel) { inst.div.mousewheel(this._doMouseWheel); } } inst.div.html(this._generateContent(elem[0], inst)); elem.focus(); } } }
javascript
{ "resource": "" }
q10978
train
function(elem, keyUp) { var inst = this._getInst(elem); if (!$.isEmptyObject(inst)) { var value = ''; var altValue = ''; var sep = (inst.options.multiSelect ? inst.options.multiSeparator : inst.options.rangeSeparator); var calendar = inst.options.calendar; var dateFormat = inst.get('dateFormat'); var altFormat = inst.options.altFormat || dateFormat; var settings = {localNumbers: inst.options.localNumbers}; for (var i = 0; i < inst.selectedDates.length; i++) { value += (keyUp ? '' : (i > 0 ? sep : '') + calendar.formatDate(dateFormat, inst.selectedDates[i], settings)); altValue += (i > 0 ? sep : '') + calendar.formatDate(altFormat, inst.selectedDates[i], settings); } if (!inst.inline && !keyUp) { $(elem).val(value); } $(inst.options.altField).val(altValue); if ($.isFunction(inst.options.onSelect) && !keyUp && !inst.inSelect) { inst.inSelect = true; // Prevent endless loops inst.options.onSelect.apply(elem, [inst.selectedDates]); inst.inSelect = false; } } }
javascript
{ "resource": "" }
q10979
train
function(elem) { var convert = function(value) { return {thin: 1, medium: 3, thick: 5}[value] || value; }; return [parseFloat(convert(elem.css('border-left-width'))), parseFloat(convert(elem.css('border-top-width')))]; }
javascript
{ "resource": "" }
q10980
train
function(inst) { var base = (inst.elem.is(':hidden') && inst.trigger ? inst.trigger : inst.elem); var offset = base.offset(); var browserWidth = $(window).width(); var browserHeight = $(window).height(); if (browserWidth === 0) { return offset; } var isFixed = false; $(inst.elem).parents().each(function() { isFixed |= $(this).css('position') === 'fixed'; return !isFixed; }); var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; var scrollY = document.documentElement.scrollTop || document.body.scrollTop; var above = offset.top - (isFixed ? scrollY : 0) - inst.div.outerHeight(); var below = offset.top - (isFixed ? scrollY : 0) + base.outerHeight(); var alignL = offset.left - (isFixed ? scrollX : 0); var alignR = offset.left - (isFixed ? scrollX : 0) + base.outerWidth() - inst.div.outerWidth(); var tooWide = (offset.left - scrollX + inst.div.outerWidth()) > browserWidth; var tooHigh = (offset.top - scrollY + inst.elem.outerHeight() + inst.div.outerHeight()) > browserHeight; inst.div.css('position', isFixed ? 'fixed' : 'absolute'); var alignment = inst.options.alignment; if (alignment === 'topLeft') { offset = {left: alignL, top: above}; } else if (alignment === 'topRight') { offset = {left: alignR, top: above}; } else if (alignment === 'bottomLeft') { offset = {left: alignL, top: below}; } else if (alignment === 'bottomRight') { offset = {left: alignR, top: below}; } else if (alignment === 'top') { offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL), top: above}; } else { // bottom offset = {left: (inst.options.isRTL || tooWide ? alignR : alignL), top: (tooHigh ? above : below)}; } offset.left = Math.max((isFixed ? 0 : scrollX), offset.left); offset.top = Math.max((isFixed ? 0 : scrollY), offset.top); return offset; }
javascript
{ "resource": "" }
q10981
train
function(event) { if (!plugin.curInst) { return; } var elem = $(event.target); if (elem.closest('.' + plugin._popupClass + ',.' + plugin._triggerClass).length === 0 && !elem.hasClass(plugin._getMarker())) { plugin.hide(plugin.curInst); } }
javascript
{ "resource": "" }
q10982
train
function(elem, immediate) { if (!elem) { return; } var inst = this._getInst(elem); if ($.isEmptyObject(inst)) { inst = elem; } if (inst && inst === plugin.curInst) { var showAnim = (immediate ? '' : inst.options.showAnim); var showSpeed = inst.options.showSpeed; showSpeed = (showSpeed === 'normal' && $.ui && parseInt($.ui.version.substring(2)) >= 8 ? '_default' : showSpeed); var postProcess = function() { if (!inst.div) { return; } inst.div.remove(); inst.div = null; plugin.curInst = null; if ($.isFunction(inst.options.onClose)) { inst.options.onClose.apply(elem, [inst.selectedDates]); } }; inst.div.stop(); if ($.effects && ($.effects[showAnim] || ($.effects.effect && $.effects.effect[showAnim]))) { inst.div.hide(showAnim, inst.options.showOptions, showSpeed, postProcess); } else { var hideAnim = (showAnim === 'slideDown' ? 'slideUp' : (showAnim === 'fadeIn' ? 'fadeOut' : 'hide')); inst.div[hideAnim]((showAnim ? showSpeed : ''), postProcess); } if (!showAnim) { postProcess(); } } }
javascript
{ "resource": "" }
q10983
train
function(event) { var elem = (event.data && event.data.elem) || event.target; var inst = plugin._getInst(elem); var handled = false; if (inst.inline || inst.div) { if (event.keyCode === 9) { // Tab - close plugin.hide(elem); } else if (event.keyCode === 13) { // Enter - select plugin.selectDate(elem, $('a.' + inst.options.renderer.highlightedClass, inst.div)[0]); handled = true; } else { // Command keystrokes var commands = inst.options.commands; for (var name in commands) { var command = commands[name]; if (command.keystroke.keyCode === event.keyCode && !!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) && !!command.keystroke.altKey === event.altKey && !!command.keystroke.shiftKey === event.shiftKey) { plugin.performAction(elem, name); handled = true; break; } } } } else { // Show on 'current' keystroke var command = inst.options.commands.current; if (command.keystroke.keyCode === event.keyCode && !!command.keystroke.ctrlKey === !!(event.ctrlKey || event.metaKey) && !!command.keystroke.altKey === event.altKey && !!command.keystroke.shiftKey === event.shiftKey) { plugin.show(elem); handled = true; } } inst.ctrlKey = ((event.keyCode < 48 && event.keyCode !== 32) || event.ctrlKey || event.metaKey); if (handled) { event.preventDefault(); event.stopPropagation(); } return !handled; }
javascript
{ "resource": "" }
q10984
train
function(event) { var inst = plugin._getInst((event.data && event.data.elem) || event.target); if (!$.isEmptyObject(inst) && inst.options.constrainInput) { var ch = String.fromCharCode(event.keyCode || event.charCode); var allowedChars = plugin._allowedChars(inst); return (event.metaKey || inst.ctrlKey || ch < ' ' || !allowedChars || allowedChars.indexOf(ch) > -1); } return true; }
javascript
{ "resource": "" }
q10985
train
function(inst) { var allowedChars = (inst.options.multiSelect ? inst.options.multiSeparator : (inst.options.rangeSelect ? inst.options.rangeSeparator : '')); var literal = false; var hasNum = false; var dateFormat = inst.get('dateFormat'); for (var i = 0; i < dateFormat.length; i++) { var ch = dateFormat.charAt(i); if (literal) { if (ch === "'" && dateFormat.charAt(i + 1) !== "'") { literal = false; } else { allowedChars += ch; } } else { switch (ch) { case 'd': case 'm': case 'o': case 'w': allowedChars += (hasNum ? '' : '0123456789'); hasNum = true; break; case 'y': case '@': case '!': allowedChars += (hasNum ? '' : '0123456789') + '-'; hasNum = true; break; case 'J': allowedChars += (hasNum ? '' : '0123456789') + '-.'; hasNum = true; break; case 'D': case 'M': case 'Y': return null; // Accept anything case "'": if (dateFormat.charAt(i + 1) === "'") { allowedChars += "'"; } else { literal = true; } break; default: allowedChars += ch; } } } return allowedChars; }
javascript
{ "resource": "" }
q10986
train
function(event) { var elem = (event.data && event.data.elem) || event.target; var inst = plugin._getInst(elem); if (!$.isEmptyObject(inst) && !inst.ctrlKey && inst.lastVal !== inst.elem.val()) { try { var dates = plugin._extractDates(inst, inst.elem.val()); if (dates.length > 0) { plugin.setDate(elem, dates, null, true); } } catch (event) { // Ignore } } return true; }
javascript
{ "resource": "" }
q10987
train
function(elem) { var inst = this._getInst(elem); if (!$.isEmptyObject(inst)) { inst.selectedDates = []; this.hide(elem); var defaultDate = inst.get('defaultDate'); if (inst.options.selectDefaultDate && defaultDate) { this.setDate(elem, (defaultDate || inst.options.calendar.today()).newDate()); } else { this._updateInput(elem); } } }
javascript
{ "resource": "" }
q10988
train
function(elem, date) { var inst = this._getInst(elem); if ($.isEmptyObject(inst)) { return false; } date = inst.options.calendar.determineDate(date, inst.selectedDates[0] || inst.options.calendar.today(), null, inst.options.dateFormat, inst.getConfig()); return this._isSelectable(elem, date, inst.options.onDate, inst.get('minDate'), inst.get('maxDate')); }
javascript
{ "resource": "" }
q10989
train
function(elem, date, onDate, minDate, maxDate) { var dateInfo = (typeof onDate === 'boolean' ? {selectable: onDate} : (!$.isFunction(onDate) ? {} : onDate.apply(elem, [date, true]))); return (dateInfo.selectable !== false) && (!minDate || date.toJD() >= minDate.toJD()) && (!maxDate || date.toJD() <= maxDate.toJD()); }
javascript
{ "resource": "" }
q10990
train
function(elem, action) { var inst = this._getInst(elem); if (!$.isEmptyObject(inst) && !this.isDisabled(elem)) { var commands = inst.options.commands; if (commands[action] && commands[action].enabled.apply(elem, [inst])) { commands[action].action.apply(elem, [inst]); } } }
javascript
{ "resource": "" }
q10991
train
function(elem, year, month, day) { var inst = this._getInst(elem); if (!$.isEmptyObject(inst) && (day != null || (inst.drawDate.year() !== year || inst.drawDate.month() !== month))) { inst.prevDate = inst.drawDate.newDate(); var calendar = inst.options.calendar; var show = this._checkMinMax((year != null ? calendar.newDate(year, month, 1) : calendar.today()), inst); inst.drawDate.date(show.year(), show.month(), (day != null ? day : Math.min(inst.drawDate.day(), calendar.daysInMonth(show.year(), show.month())))); this._update(elem); } }
javascript
{ "resource": "" }
q10992
train
function(elem, offset) { var inst = this._getInst(elem); if (!$.isEmptyObject(inst)) { var date = inst.drawDate.newDate().add(offset, 'm'); this.showMonth(elem, date.year(), date.month()); } }
javascript
{ "resource": "" }
q10993
train
function(elem, target) { var inst = this._getInst(elem); return ($.isEmptyObject(inst) ? null : inst.options.calendar.fromJD( parseFloat(target.className.replace(/^.*jd(\d+\.5).*$/, '$1')))); }
javascript
{ "resource": "" }
q10994
train
function(elem, target) { var inst = this._getInst(elem); if (!$.isEmptyObject(inst) && !this.isDisabled(elem)) { var date = this.retrieveDate(elem, target); if (inst.options.multiSelect) { var found = false; for (var i = 0; i < inst.selectedDates.length; i++) { if (date.compareTo(inst.selectedDates[i]) === 0) { inst.selectedDates.splice(i, 1); found = true; break; } } if (!found && inst.selectedDates.length < inst.options.multiSelect) { inst.selectedDates.push(date); } } else if (inst.options.rangeSelect) { if (inst.pickingRange) { inst.selectedDates[1] = date; } else { inst.selectedDates = [date, date]; } inst.pickingRange = !inst.pickingRange; } else { inst.selectedDates = [date]; } inst.prevDate = inst.drawDate = date.newDate(); this._updateInput(elem); if (inst.inline || inst.pickingRange || inst.selectedDates.length < (inst.options.multiSelect || (inst.options.rangeSelect ? 2 : 1))) { this._update(elem); } else { this.hide(elem); } } }
javascript
{ "resource": "" }
q10995
train
function(value) { return (inst.options.localNumbers && calendar.local.digits ? calendar.local.digits(value) : value); }
javascript
{ "resource": "" }
q10996
train
function(inst, calendar, renderer) { var firstDay = inst.options.firstDay; firstDay = (firstDay == null ? calendar.local.firstDay : firstDay); var header = ''; for (var day = 0; day < calendar.daysInWeek(); day++) { var dow = (day + firstDay) % calendar.daysInWeek(); header += this._prepare(renderer.dayHeader, inst).replace(/\{day\}/g, '<span class="' + this._curDoWClass + dow + '" title="' + calendar.local.dayNames[dow] + '">' + calendar.local.dayNamesMin[dow] + '</span>'); } return header; }
javascript
{ "resource": "" }
q10997
train
function(year, month, day) { var date = this._validate(year, month, day, $.calendars.local.invalidDate); return {yearType: (this.leapYear(date) ? 'embolismic' : 'common') + ' ' + ['deficient', 'regular', 'complete'][this.daysInYear(date) % 10 - 3]}; }
javascript
{ "resource": "" }
q10998
train
function(year) { var months = Math.floor((235 * year - 234) / 19); var parts = 12084 + 13753 * months; var day = months * 29 + Math.floor(parts / 25920); if (mod(3 * (day + 1), 7) < 3) { day++; } return day; }
javascript
{ "resource": "" }
q10999
train
function(year) { var last = this._delay1(year - 1); var present = this._delay1(year); var next = this._delay1(year + 1); return ((next - present) === 356 ? 2 : ((present - last) === 382 ? 1 : 0)); }
javascript
{ "resource": "" }