_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q21900
train
function (renderer, size) { renderer.saveClear(); var viewport = renderer.viewport; var x = 0, y = 0; var width = size || viewport.width / 4; var height = width; if (this.softShadow === ShadowMapPass.VSM) { this._outputDepthPass.material.define('fragment', 'US...
javascript
{ "resource": "" }
q21901
train
function (x, y, forcePickAll) { var out = this.pickAll(x, y, [], forcePickAll); return out[0] || null; }
javascript
{ "resource": "" }
q21902
train
function (x, y, output, forcePickAll) { this.renderer.screenToNDC(x, y, this._ndc); this.camera.castRay(this._ndc, this._ray); output = output || []; this._intersectNode(this.scene, output, forcePickAll || false); output.sort(this._intersectionCompareFunc); return out...
javascript
{ "resource": "" }
q21903
train
function () { for (var i = 0; i < this.nodes.length; i++) { this.nodes[i].clear(); } // Traverse all the nodes and build the graph for (var i = 0; i < this.nodes.length; i++) { var node = this.nodes[i]; if (!node.inputs) { continue; ...
javascript
{ "resource": "" }
q21904
train
function (width, height) { if (this._gBufferTex1.width === width && this._gBufferTex1.height === height ) { return; } this._gBufferTex1.width = width; this._gBufferTex1.height = height; this._gBufferTex2.width = width; this._gBufferTex2.he...
javascript
{ "resource": "" }
q21905
train
function() { var cone = new Cone$1({ topRadius: this.radius, bottomRadius: this.radius, capSegments: this.capSegments, heightSegments: this.heightSegments, height: this.height }); this.attributes.position.value = cone.attributes.positi...
javascript
{ "resource": "" }
q21906
train
function (light) { var volumeMesh; if (light.volumeMesh) { volumeMesh = light.volumeMesh; } else { switch (light.type) { // Only local light (point and spot) needs volume mesh. // Directional and ambient light renders in full quad ...
javascript
{ "resource": "" }
q21907
train
function(out) { var amount = Math.min(this._particlePool.length, this.amount); var particle; for (var i = 0; i < amount; i++) { particle = this._particlePool.pop(); // Initialize particle status if (this.position) { this.position.get(particle....
javascript
{ "resource": "" }
q21908
train
function() { // Put all the particles back for (var i = 0; i < this._particles.length; i++) { var p = this._particles[i]; p.emitter.kill(p); } this._particles.length = 0; this._elapsedTime = 0; this._emitting = true; }
javascript
{ "resource": "" }
q21909
train
function(ratio) { this._texture.width = this.width * ratio; this._texture.height = this.height * ratio; this.downSampleRatio = ratio; }
javascript
{ "resource": "" }
q21910
train
function(scene, camera) { var renderer = this.renderer; if (renderer.getWidth() !== this.width || renderer.getHeight() !== this.height) { this.resize(renderer.width, renderer.height); } this._frameBuffer.attach(this._texture); this._frameBuffer.bind(renderer); ...
javascript
{ "resource": "" }
q21911
train
function(x, y) { var renderer = this.renderer; var ratio = this.downSampleRatio; x = Math.ceil(ratio * x); y = Math.ceil(ratio * (this.height - y)); this._frameBuffer.bind(renderer); var pixel = new Uint8Array(4); var _gl = renderer.gl; // TODO out of bo...
javascript
{ "resource": "" }
q21912
train
function (frameTime) { var target = this.target; var position = this.target.position; var xAxis = target.localTransform.x.normalize(); var zAxis = target.localTransform.z.normalize(); if (this.verticalMoveLock) { zAxis.y = 0; zAxis.normalize(); }...
javascript
{ "resource": "" }
q21913
train
function() { /** * When user begins to interact with connected gamepad: * * @see https://w3c.github.io/gamepad/#dom-gamepadevent */ vendor.addEventListener(window, 'gamepadconnected', this._checkGamepadCompatibility); if (this.timeline) { this.ti...
javascript
{ "resource": "" }
q21914
train
function() { vendor.removeEventListener(window, 'gamepadconnected', this._checkGamepadCompatibility); if (this.timeline) { this.timeline.off('frame', this.update); } vendor.removeEventListener(window, 'gamepaddisconnected', this._disconnectGamepad); }
javascript
{ "resource": "" }
q21915
train
function (frameTime) { if (!this._standardGamepadAvailable) { return; } this._scanPressedGamepadButtons(); this._scanInclinedGamepadAxes(); // Update target depending on user input. var target = this.target; var position = this.target.position; ...
javascript
{ "resource": "" }
q21916
train
function () { var dom = this.domElement; vendor.addEventListener(dom, 'touchstart', this._mouseDownHandler); vendor.addEventListener(dom, 'mousedown', this._mouseDownHandler); vendor.addEventListener(dom, 'wheel', this._mouseWheelHandler); if (this.timeline) { this...
javascript
{ "resource": "" }
q21917
train
function () { var dom = this.domElement; vendor.removeEventListener(dom, 'touchstart', this._mouseDownHandler); vendor.removeEventListener(dom, 'touchmove', this._mouseMoveHandler); vendor.removeEventListener(dom, 'touchend', this._mouseUpHandler); vendor.removeEventListener(do...
javascript
{ "resource": "" }
q21918
train
function (alpha) { alpha = Math.max(Math.min(this.maxAlpha, alpha), this.minAlpha); this._theta = alpha / 180 * Math.PI; this._needsUpdate = true; }
javascript
{ "resource": "" }
q21919
train
function (beta) { beta = Math.max(Math.min(this.maxBeta, beta), this.minBeta); this._phi = -beta / 180 * Math.PI; this._needsUpdate = true; }
javascript
{ "resource": "" }
q21920
train
function () { for (var i = 0; i < this._animators.length; i++) { this._animators[i].stop(); } this._animators.length = 0; }
javascript
{ "resource": "" }
q21921
train
function (deltaTime) { deltaTime = deltaTime || 16; if (this._rotating) { var radian = (this.autoRotateDirection === 'cw' ? 1 : -1) * this.autoRotateSpeed / 180 * Math.PI; this._phi -= radian * deltaTime / 1000; this._needsUpdate = true; } ...
javascript
{ "resource": "" }
q21922
train
function (geometry, shallow) { if (!geometry) { return null; } var data = { metadata : util$1.extend({}, META) }; //transferable buffers var buffers = []; //dynamic data.dynamic = geometry.dynamic; //bounding box i...
javascript
{ "resource": "" }
q21923
train
function (object) { if (!object) { return null; } if (object.data && object.buffers) { return transferableUtil.toGeometry(object.data); } if (!object.metadata || object.metadata.generator !== META.generator) { throw new Error('[util.transferabl...
javascript
{ "resource": "" }
q21924
canIuseNativeCustom
train
function canIuseNativeCustom() { try { const p = new NativeCustomEvent('t', { detail: { a: 'b' } }); return 't' === p.type && 'b' === p.detail.a; } catch (e) { } /* istanbul ignore next: hard to reproduce on test environment */ return false; }
javascript
{ "resource": "" }
q21925
CustomEvent
train
function CustomEvent(type, params) { const e = document.createEvent('CustomEvent'); if (params) { e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail); } else { e.initCustomEvent(type, false, false, undefined); } return e; }
javascript
{ "resource": "" }
q21926
emitFirst
train
function emitFirst (emitter, events, handler) { handler = once(handler) events.forEach((e) => { emitter.once(e, (...args) => { events.forEach((ev) => { emitter.removeListener(ev, handler) }) handler.apply(emitter, args) }) }) }
javascript
{ "resource": "" }
q21927
getSections
train
function getSections(sections, config, parentDepth) { return sections.map(section => processSection(section, config, parentDepth)) }
javascript
{ "resource": "" }
q21928
processSection
train
function processSection(section, config, parentDepth) { const contentRelativePath = section.content // Try to load section content file let content if (contentRelativePath) { const contentAbsolutePath = path.resolve(config.configDir, contentRelativePath) if (!fs.existsSync(contentAbsolutePath)) { throw new ...
javascript
{ "resource": "" }
q21929
getComponentMetadataPath
train
function getComponentMetadataPath(filepath) { const extname = path.extname(filepath) return filepath.substring(0, filepath.length - extname.length) + '.json' }
javascript
{ "resource": "" }
q21930
findConfigFile
train
function findConfigFile() { let configDir try { configDir = findup.sync(process.cwd(), CONFIG_FILENAME) } catch (exception) { return false } return path.join(configDir, CONFIG_FILENAME) }
javascript
{ "resource": "" }
q21931
runRecognition
train
function runRecognition() { var stdin = process.openStdin(); // Read the text to recognize write('Enter the text to recognize: '); stdin.addListener('data', function (e) { var input = e.toString().trim(); if (input) { // Exit if (input.toLowerCase() === 'exit') ...
javascript
{ "resource": "" }
q21932
shouldCompressGzip
train
function shouldCompressGzip(req) { const headers = req.headers; return headers && headers['accept-encoding'] && headers['accept-encoding'] .split(',') .some(el => ['*', 'compress', 'gzip', 'deflate'].indexOf(el.trim()) !== -1) ; }
javascript
{ "resource": "" }
q21933
tryServeWithGzip
train
function tryServeWithGzip() { fs.stat(gzippedFile, (err, stat) => { if (!err && stat.isFile()) { hasGzipId12(gzippedFile, (gzipErr, isGzip) => { if (!gzipErr && isGzip) { file = gzippedFile; serve(stat); } else { statFile(); ...
javascript
{ "resource": "" }
q21934
tryServeWithBrotli
train
function tryServeWithBrotli(shouldTryGzip) { fs.stat(brotliFile, (err, stat) => { if (!err && stat.isFile()) { file = brotliFile; serve(stat); } else if (shouldTryGzip) { tryServeWithGzip(); } else { statFile(); } }); }
javascript
{ "resource": "" }
q21935
getXHR
train
function getXHR () { if (root.XMLHttpRequest && ('file:' != root.location.protocol || !root.ActiveXObject)) { return new XMLHttpRequest } else { try { return new ActiveXObject('Microsoft.XMLHTTP') } catch(e) {} try { return new ActiveXObject('Msxml2.XMLHTTP.6.0') } catch(e) {} ...
javascript
{ "resource": "" }
q21936
params
train
function params (str){ return reduce(str.split(/ *; */), function (obj, str){ var parts = str.split(/ *= */), key = parts.shift(), val = parts.shift() if (key && val) obj[key] = val return obj }, {}) }
javascript
{ "resource": "" }
q21937
search
train
function search (){ var replaced = 0 var scripts = document.querySelectorAll('script') var script for (var i = 0; i < scripts.length; i++) { script = scripts[i] if (!script.src) continue if (/\/slackin\.js(\?.*)?$/.test(script.src)) { // replace script with iframe repla...
javascript
{ "resource": "" }
q21938
replace
train
function replace (script){ var parent = script.parentNode if (!parent) return LARGE = /\?large/.test(script.src) var iframe = document.createElement('iframe') var iframePath = '/iframe' + (LARGE ? '?large' : '') iframe.src = script.src.replace(/\/slackin\.js.*/, iframePath) iframe.style.bor...
javascript
{ "resource": "" }
q21939
setup
train
function setup (iframe){ var id = Math.random() * (1 << 24) | 0 iframe.contentWindow.postMessage('slackin:' + id, '*') window.addEventListener('message', function (e){ if (typeof e.data !== 'string') return // show dialog upon click if ('slackin-click:' + id === e.data) { showDia...
javascript
{ "resource": "" }
q21940
text
train
function text ({str, x, y}){ return [ svg(`text fill=#010101 fill-opacity=.3 x=${x} y=${y + 1}`, str), svg(`text fill=#fff x=${x} y=${y}`, str) ] }
javascript
{ "resource": "" }
q21941
topLevelRedirect
train
function topLevelRedirect (url) { if (window === top) location.href = url else parent.postMessage('slackin-redirect:' + id + ':' + url, '*') // Q: Why can't we just `top.location.href = url;`? // A: // [sandboxing]: http://www.html5rocks.com/en/tutorials/security/sandboxed-iframes/ // [CSP]: http://www.html...
javascript
{ "resource": "" }
q21942
getClassName
train
function getClassName(propValue) { if (!propValue.constructor || !propValue.constructor.name) { return ANONYMOUS; } return propValue.constructor.name; }
javascript
{ "resource": "" }
q21943
writeBuildscriptHookForCrashlytics
train
function writeBuildscriptHookForCrashlytics(enable) { var scriptPath = path.join(appRoot, "hooks", "after-prepare", "firebase-crashlytics-buildscript.js"); if (!enable) { if (fs.existsSync(scriptPath)) { fs.unlinkSync(scriptPath); } return } console.log("Install Crashlytics buildscript hook....
javascript
{ "resource": "" }
q21944
renderSimpleRuby
train
function renderSimpleRuby( $ruby ) { var frag = $.create( '!' ) var clazz = $ruby.classList var $rb, $ru frag.appendChild( $.clone( $ruby )) $ .tag( 'rt', frag.firstChild ) .forEach(function( $rt ) { var $rb = $.create( '!' ) var airb = [] var irb // Consider the previous nodes the impl...
javascript
{ "resource": "" }
q21945
renderComplexRuby
train
function renderComplexRuby( $ruby ) { var frag = $.create( '!' ) var clazz = $ruby.classList var $cloned, $rb, $ru, maxspan frag.appendChild( $.clone( $ruby )) $cloned = frag.firstChild $rb = $ru = $.tag( 'rb', $cloned ) maxspan = $rb.length // First of all, deal with Zhuyin containers // individua...
javascript
{ "resource": "" }
q21946
getZhuyinHTML
train
function getZhuyinHTML( rt ) { // #### Explanation #### // * `zhuyin`: the entire phonetic annotation // * `yin`: the plain pronunciation (w/out tone) // * `diao`: the tone // * `len`: the length of the plain pronunciation (`yin`) var zhuyin = typeof rt === 'string' ? rt : rt.textContent var yin, ...
javascript
{ "resource": "" }
q21947
train
function( target, attr ) { if ( typeof attr !== 'object' ) return var len = attr.length // Native `NamedNodeMap``: if ( typeof attr[0] === 'object' && 'name' in attr[0] ) { for ( var i = 0; i < len; i++ ) { if ( attr[ i ].value !== undefined ) { target.setAttrib...
javascript
{ "resource": "" }
q21948
train
function( target, object ) { if (( typeof target === 'object' || typeof target === 'function' ) && typeof object === 'object' ) { for ( var name in object ) { if (object.hasOwnProperty( name )) { target[ name ] = object[ name ] } } } return target ...
javascript
{ "resource": "" }
q21949
train
function() { var match var matchIndex = 0 var offset = 0 var regex = this.options.find var textAggregation = this.getAggregateText() var matches = [] var self = this regex = typeof regex === 'string' ? RegExp(escapeRegExp(regex), 'g') : regex matchAggregation(textA...
javascript
{ "resource": "" }
q21950
train
function() { var elementFilter = this.options.filterElements var forceContext = this.options.forceContext return getText(this.node) /** * Gets aggregate text of a node without resorting * to broken innerText/textContent */ function getText(node, txt) { if (no...
javascript
{ "resource": "" }
q21951
train
function() { var matches = this.matches var node = this.node var elementFilter = this.options.filterElements var startPortion, endPortion, innerPortions = [], curNode = node, match = matches.shift(), atIndex = 0, // i.e. nodeAtIndex matchIndex = 0...
javascript
{ "resource": "" }
q21952
train
function( routine ) { var it = this var routine = Array.isArray( routine ) ? routine : this.routine routine .forEach(function( method ) { if ( typeof method === 'string' && typeof it[ method ] === 'function' ) { it[ method ]() } else if ( ...
javascript
{ "resource": "" }
q21953
train
function( selector ) { return ( this .filter( selector || null ) .avoid( 'h-jinze' ) .replace( TYPESET.jinze.touwei, function( portion, match ) { var elem = $.create( 'h-jinze', 'touwei' ) elem.innerHTML = match[0] return (( portion.index === 0 && portion.isEnd ) ...
javascript
{ "resource": "" }
q21954
train
function( context, target ) { var $$target = $.qsa( target || 'u, ins', context ) var i = $$target.length traverse: while ( i-- ) { var $this = $$target[ i ] var $prev = null // Ignore all `<wbr>` and comments in between, // and add class `.adjacent` once two targets // are n...
javascript
{ "resource": "" }
q21955
train
function( context, target ) { var method = target ? 'qsa' : 'tag' var target = target || 'em' var $target = $[ method ]( target, context ) $target .forEach(function( elem ) { var $elem = Han( elem ) if ( Locale.support.textemphasis ) { $elem .avoid( 'rt, h-char' ) ...
javascript
{ "resource": "" }
q21956
inherits
train
function inherits(subClass, superClass) { // if (typeof superClass !== "function" && superClass !== null) { // throw new TypeError( // "Super expression must either be null or a function, not " + // typeof superClass // ); // } subClass.prototype = Object.create(superClass && superClass.prot...
javascript
{ "resource": "" }
q21957
canRoute
train
function canRoute(url) { for (let i=ROUTERS.length; i--; ) { if (ROUTERS[i].canRoute(url)) return true; } return false; }
javascript
{ "resource": "" }
q21958
routeTo
train
function routeTo(url) { let didRoute = false; for (let i=0; i<ROUTERS.length; i++) { if (ROUTERS[i].routeTo(url)===true) { didRoute = true; } } for (let i=subscribers.length; i--; ) { subscribers[i](url); } return didRoute; }
javascript
{ "resource": "" }
q21959
compareNodeNames
train
function compareNodeNames(fromEl, toEl) { var fromNodeName = fromEl.nodeName; var toNodeName = toEl.nodeName; if (fromNodeName === toNodeName) { return true; } if (toEl.actualize && fromNodeName.charCodeAt(0) < 91 && /* from tag name is upper case */ toNodeName.charCodeAt(0...
javascript
{ "resource": "" }
q21960
createElementNS
train
function createElementNS(name, namespaceURI) { return !namespaceURI || namespaceURI === NS_XHTML ? doc.createElement(name) : doc.createElementNS(namespaceURI, name); }
javascript
{ "resource": "" }
q21961
moveChildren
train
function moveChildren(fromEl, toEl) { var curChild = fromEl.firstChild; while (curChild) { var nextChild = curChild.nextSibling; toEl.appendChild(curChild); curChild = nextChild; } return toEl; }
javascript
{ "resource": "" }
q21962
removeNode
train
function removeNode(node, parentNode, skipKeyedNodes) { if (onBeforeNodeDiscarded(node) === false) { return; } if (parentNode) { parentNode.removeChild(node); } onNodeDiscarded(node); walkDiscardedChildNodes(node, ...
javascript
{ "resource": "" }
q21963
processCallbacks
train
function processCallbacks(items, cb){ if(!items || items.length === 0){ // empty or no list, invoke callback return cb(); } // invoke current function, pass the next part as continuation items[0](function(){ processCallbacks(items.slice(1), cb); }); }
javascript
{ "resource": "" }
q21964
processDirectory
train
function processDirectory (directory, path, items, cb) { var dirReader = directory.createReader(); var allEntries = []; function readEntries () { dirReader.readEntries(function(entries){ if (entries.length) { allEntries = allEntries.concat(entries); return re...
javascript
{ "resource": "" }
q21965
loadFiles
train
function loadFiles(items, event) { if(!items.length){ return; // nothing to do } $.fire('beforeAdd'); var files = []; processCallbacks( Array.prototype.map.call(items, function(item){ // bind all properties except for callback var entry = item; ...
javascript
{ "resource": "" }
q21966
train
function(name, options) { name = defaultValue(name, "Conditions"); options = defaultValue(options, defaultValue.EMPTY_OBJECT); DisplayVariablesConcept.call(this, name, options); }
javascript
{ "resource": "" }
q21967
closeDescendants
train
function closeDescendants(concept) { concept.isOpen = false; concept.items.forEach(child => { if (child.items) { closeDescendants(child); } }); }
javascript
{ "resource": "" }
q21968
train
function(terria) { CatalogMember.call(this, terria); this._loadingPromise = undefined; this._lastLoadInfluencingValues = undefined; this._parameters = []; /** * Gets or sets a value indicating whether the group is currently loading. This property * is observable. * @type {Boolean} */ this.isL...
javascript
{ "resource": "" }
q21969
replaceUnderscores
train
function replaceUnderscores(string) { if (typeof string === "string" || string instanceof String) { return string.replace(/_/g, " "); } return string; }
javascript
{ "resource": "" }
q21970
extractValues
train
function extractValues(response) { var observationData = response.GetObservationResponse && response.GetObservationResponse.observationData; if (defined(observationData)) { if (!Array.isArray(observationData)) { observationData = [observationData]; } var observations = obse...
javascript
{ "resource": "" }
q21971
loadObservationData
train
function loadObservationData(item) { if (!item._featureMapping) { return; } var featuresOfInterest = Object.keys(item._featureMapping); // Are there too many features to load observations (or we've been asked not to try)? if ( !item.tryToLoadObservationData || featuresOfInterest.length > item.requ...
javascript
{ "resource": "" }
q21972
createColumnsFromMapping
train
function createColumnsFromMapping(item, tableStructure, identifiers) { var featureMapping = item._featureMapping; var addChartColumn = !defined(identifiers); if (!defined(identifiers)) { identifiers = Object.keys(featureMapping); } var rows = identifiers.map(identifier => featureMapping[identifier]); va...
javascript
{ "resource": "" }
q21973
train
function(terria) { const that = this; this._terria = terria; // Note: We create a persistant object and define a transient property, since knockout needs a persistant variable // to track, but for state we want a 'maybe' intervalId. this._eventLoopState = {}; this._manualAlignment = false; this....
javascript
{ "resource": "" }
q21974
MapInteractionMode
train
function MapInteractionMode(options) { /** * Gets or sets a callback that is invoked when the user cancels the interaction mode. If this property is undefined, * the interaction mode cannot be canceled. * @type {Function} */ this.onCancel = options.onCancel; /** * Gets or sets the details of a cu...
javascript
{ "resource": "" }
q21975
train
function(options) { this._uriTemplate = new URITemplate(options.url); if (typeof options.layerName !== "string") { throw new DeveloperError( "MapboxVectorTileImageryProvider requires a layer name passed as options.layerName" ); } this._layerName = options.layerName; this._subdomains = defaultV...
javascript
{ "resource": "" }
q21976
overzoomGeometry
train
function overzoomGeometry(rings, nativeTile, newExtent, newTile) { var diffZ = newTile.level - nativeTile.level; if (diffZ === 0) { return rings; } else { var newRings = []; // (offsetX, offsetY) is the (0,0) of the new tile var offsetX = newExtent * (newTile.x - (nativeTile.x << diffZ)); var ...
javascript
{ "resource": "" }
q21977
inside
train
function inside(point, vs) { // ray-casting algorithm based on // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html var x = point.x, y = point.y; var inside = false; for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) { var xi = vs[i].x, yi = vs[i].y; var xj = v...
javascript
{ "resource": "" }
q21978
updateColumns
train
function updateColumns(item, newColumns) { item._tableStructure.columns = newColumns; if (item._tableStructure.columns.length === 0) { // Nothing to show, so the attempt to redraw will fail; need to explicitly hide the existing regions. item._regionMapping.hideImageryLayer(); item.terria.currentViewer.n...
javascript
{ "resource": "" }
q21979
fixSelectedInitially
train
function fixSelectedInitially(item, conceptDimensions) { conceptDimensions.forEach(dimension => { if (defined(item.selectedInitially)) { var thisSelectedInitially = item.selectedInitially[dimension.id]; if (thisSelectedInitially) { var valueIds = dimension.values.map(value => value.id); ...
javascript
{ "resource": "" }
q21980
buildConcepts
train
function buildConcepts(item, fullDimensions) { function isInitiallyActive(dimensionId, value, index) { if (!defined(item.selectedInitially)) { return index === 0; } var dimensionSelectedInitially = item.selectedInitially[dimensionId]; if (!defined(dimensionSelectedInitially)) { return inde...
javascript
{ "resource": "" }
q21981
canTotalBeCalculatedAndIfNotWarnUser
train
function canTotalBeCalculatedAndIfNotWarnUser(item) { if (canResultsBeSummed(item)) { return true; } var conceptItems = item._concepts[0].items; var changedActive = []; conceptItems.forEach(concept => { var numberActive = concept.items.filter(function(subconcept) { return subconcept.isActive; ...
javascript
{ "resource": "" }
q21982
changedActiveItems
train
function changedActiveItems(item) { if (!defined(item._dataflowUrl)) { // All the data is already here, just update the total columns. var shownDimensionCombinations = calculateShownDimensionCombinations( item, item._fullDimensions ); var columns = item._tableStructure.columns.slice( ...
javascript
{ "resource": "" }
q21983
getUrlFromDimensionRequestString
train
function getUrlFromDimensionRequestString(item, dimensionRequestString) { var url = item._originalUrl; if (url[url.length - 1] !== "/") { url += "/"; } url += dimensionRequestString + "/" + item.providerId; if (defined(item.startTime)) { url += "?startTime=" + item.startTime; if (defined(item.endT...
javascript
{ "resource": "" }
q21984
hashFromString
train
function hashFromString(s) { return Math.abs( s.split("").reduce(function(prev, c) { var hash = (prev << 5) - prev + c.charCodeAt(0); return hash; }, 0) ); }
javascript
{ "resource": "" }
q21985
correctEntityHeight
train
function correctEntityHeight( entity, currentCartographicPosition, terrainProvider, levelHint ) { sampleTerrain(terrainProvider, levelHint, [currentCartographicPosition]).then( function(updatedPositions) { if (updatedPositions[0].height !== undefined) { entity.position = Ellipsoid.WGS84.cart...
javascript
{ "resource": "" }
q21986
indexWithDescendants
train
function indexWithDescendants(items, index) { items.forEach(function(item) { item.allShareKeys.forEach(function(key) { var insertionKey = key; if (index[insertionKey]) { insertionKey = generateUniqueKey(index, key); if (item.uniqueId === key) { // If this duplicate was the ...
javascript
{ "resource": "" }
q21987
generateUniqueKey
train
function generateUniqueKey(index, initialKey) { var currentCandidate = initialKey; var counter = 0; while (index[currentCandidate]) { var numberAtEndOfKeyMatches = currentCandidate.match( NUMBER_AT_END_OF_KEY_REGEX ); if (numberAtEndOfKeyMatches !== null) { var nextNumber = parseInt(numbe...
javascript
{ "resource": "" }
q21988
deIndexWithDescendants
train
function deIndexWithDescendants(items, index) { items.forEach(function(item) { item.allShareKeys.forEach(function(key) { index[key] = undefined; }, this); if (defined(item.items)) { deIndexWithDescendants(item.items, index); } }); }
javascript
{ "resource": "" }
q21989
findGroup
train
function findGroup(catalogGroup, keywordsGroups, record) { for (var i = 0; i < keywordsGroups.length; i++) { var kg = keywordsGroups[i]; var fields = record[kg.field]; var matched = false; if (defined(fields)) { if (fields instanceof String || typeof fields === "string") { fields = [fiel...
javascript
{ "resource": "" }
q21990
toArrayOfRows
train
function toArrayOfRows(columnValueArrays, columnNames) { if (columnValueArrays.length < 1) { return; } const rows = columnValueArrays[0].map(function(value0, rowIndex) { return columnValueArrays.map(function(values) { return values[rowIndex]; }); }); rows.unshift(columnNames); return rows;...
javascript
{ "resource": "" }
q21991
getHeightValue
train
function getHeightValue(data, recordIndex, heightIndex) { if (recordIndex > 720) { recordIndex = 720; } else if (recordIndex < 0) { recordIndex = 0; } if (heightIndex > 1439) { heightIndex -= 1440; } else if (heightIndex < 0) { heightIndex += 1440; } return data[recordIndex * 1440 + heig...
javascript
{ "resource": "" }
q21992
train
function(terria) { CatalogFunction.call(this, terria); this.url = undefined; this.name = "Regions like this"; this.description = "Identifies regions that are _most like_ a given region according to a given set of characteristics."; this._regionTypeParameter = new RegionTypeParameter({ terria: this.t...
javascript
{ "resource": "" }
q21993
applyHintsToName
train
function applyHintsToName(hintSet, name, unallowedTypes) { for (var i in hintSet) { if (hintSet[i].hint.test(name)) { var guess = hintSet[i].type; if (unallowedTypes.indexOf(guess) === -1) { return guess; } } } }
javascript
{ "resource": "" }
q21994
formatPropertyValue
train
function formatPropertyValue(value, options) { if (typeof value === "number") { return formatNumberForLocale(value, options); } else if (typeof value === "string") { // do not linkify if it contains html elements, which we detect by looking for <x...> // this could catch some non-html strings such as "a...
javascript
{ "resource": "" }
q21995
serializeToJson
train
function serializeToJson(target, filterFunction, options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); filterFunction = defaultValue(filterFunction, function() { return true; }); var result = {}; for (var propertyName in target) { if ( target.hasOwnProperty(propertyName) && ...
javascript
{ "resource": "" }
q21996
train
function(catalogItem, tableStructure, tableStyle) { this._tableStructure = defined(tableStructure) ? tableStructure : new TableStructure(); if (defined(tableStyle) && !(tableStyle instanceof TableStyle)) { throw new DeveloperError("Please pass a TableStyle object."); } this._tableStyle = tableStyle;...
javascript
{ "resource": "" }
q21997
loadRegionIds
train
function loadRegionIds(regionMapping, rawRegionDetails) { var promises = rawRegionDetails.map(function(rawRegionDetail) { return rawRegionDetail.regionProvider.loadRegionIDs(); }); return when .all(promises) .then(function() { // Cache the details in a nicer format, storing the actual columns ra...
javascript
{ "resource": "" }
q21998
calculateRegionIndices
train
function calculateRegionIndices( regionMapping, time, failedMatches, ambiguousMatches ) { // As described in load, currently we only use the first possible region column. var regionDetail = regionMapping._regionDetails[0]; var tableStructure = regionMapping._tableStructure; var regionColumn = tableStruc...
javascript
{ "resource": "" }
q21999
train
function(tableColumn, tableStyle, regionProvider, name) { this.tableColumn = tableColumn; this.tableStyle = defined(tableStyle) ? tableStyle : new TableStyle(); // instead of defaultValue, so new object only created if needed. this.tableColumnStyle = getTableColumnStyle(tableColumn, this.tableStyle); this.name ...
javascript
{ "resource": "" }