_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q22800
train
function($el) { var el = joint.util.isString($el) ? this.viewport.querySelector($el) : $el instanceof $ ? $el[0] : $el; var id = this.findAttribute('model-id', el); if (id) return this._views[id]; return undefined; }
javascript
{ "resource": "" }
q22801
train
function(cell) { var id = (joint.util.isString(cell) || joint.util.isNumber(cell)) ? cell : (cell && cell.id); return this._views[id]; }
javascript
{ "resource": "" }
q22802
train
function(p) { p = new g.Point(p); var views = this.model.getElements().map(this.findViewByModel, this); return views.filter(function(view) { return view && view.vel.getBBox({ target: this.viewport }).containsPoint(p); }, this); }
javascript
{ "resource": "" }
q22803
train
function(rect, opt) { opt = joint.util.defaults(opt || {}, { strict: false }); rect = new g.Rect(rect); var views = this.model.getElements().map(this.findViewByModel, this); var method = opt.strict ? 'containsRect' : 'intersect'; return views.filter(function(view) { ...
javascript
{ "resource": "" }
q22804
train
function(evt, view) { if (evt.type === 'mousedown' && evt.button === 2) { // handled as `contextmenu` type return true; } if (this.options.guard && this.options.guard(evt, view)) { return true; } if (evt.data && evt.data.guarded !== undefine...
javascript
{ "resource": "" }
q22805
train
function() { var current = this.get('ports') || {}; var currentItemsMap = {}; util.toArray(current.items).forEach(function(item) { currentItemsMap[item.id] = true; }); var previous = this.previous('ports') || {}; var removed = {}...
javascript
{ "resource": "" }
q22806
train
function(port) { if (this._portElementsCache[port.id]) { return this._portElementsCache[port.id].portElement; } return this._createPortElement(port); }
javascript
{ "resource": "" }
q22807
freeJoin
train
function freeJoin(p1, p2, bbox) { var p = new g.Point(p1.x, p2.y); if (bbox.containsPoint(p)) p = new g.Point(p2.x, p1.y); // kept for reference // if (bbox.containsPoint(p)) p = null; return p; }
javascript
{ "resource": "" }
q22808
insideElement
train
function insideElement(from, to, fromBBox, toBBox, bearing) { var route = {}; var boundary = fromBBox.union(toBBox).inflate(1); // start from the point which is closer to the boundary var reversed = boundary.center().distance(to) > boundary.center().distance(from); var start = ...
javascript
{ "resource": "" }
q22809
router
train
function router(vertices, opt, linkView) { var sourceBBox = getSourceBBox(linkView, opt); var targetBBox = getTargetBBox(linkView, opt); var sourceAnchor = getSourceAnchor(linkView, opt); var targetAnchor = getTargetAnchor(linkView, opt); // if anchor lies outside of bbox, the...
javascript
{ "resource": "" }
q22810
modelCenter
train
function modelCenter(view, magnet) { var model = view.model; var bbox = model.getBBox(); var center = bbox.center(); var angle = model.angle(); var portId = view.findAttribute('port', magnet); if (portId) { var portGroup = model.portProp(portId, 'group'); ...
javascript
{ "resource": "" }
q22811
train
function(ctx, from, to, width, gradient) { var innerWidth = width - 4; var outerWidth = width; var buttFrom = g.point(from).move(to, -outerWidth / 2); var buttTo = g.point(to).move(from, -outerWidth / 2); ctx.beginPath(); ctx.lineWidth = outerWidth; ctx.strokeSt...
javascript
{ "resource": "" }
q22812
SeeAddKnightAttacks
train
function SeeAddKnightAttacks(target, us, attacks) { var pieceIdx = (us | pieceKnight) << 4; var attackerSq = g_pieceList[pieceIdx++]; while (attackerSq != 0) { if (IsSquareOnPieceLine(target, attackerSq)) { attacks[attacks.length] = attackerSq; } attackerSq = g_pieceList...
javascript
{ "resource": "" }
q22813
train
function(p, opt) { opt = opt || {}; var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisions; // does not use localOpt // identify the ...
javascript
{ "resource": "" }
q22814
train
function(p) { var start = this.start; var end = this.end; if (start.cross(p, end) !== 0) return false; // else: cross product of 0 indicates that this line and the vector to `p` are collinear var length = this.length(); if ((new g.Line(start, p)).length() > length) ret...
javascript
{ "resource": "" }
q22815
train
function(ratio) { var dividerPoint = this.pointAt(ratio); // return array with two new lines return [ new Line(this.start, dividerPoint), new Line(dividerPoint, this.end) ]; }
javascript
{ "resource": "" }
q22816
train
function(length) { var dividerPoint = this.pointAtLength(length); // return array with two new lines return [ new Line(this.start, dividerPoint), new Line(dividerPoint, this.end) ]; }
javascript
{ "resource": "" }
q22817
train
function(ratio, opt) { var segments = this.segments; var numSegments = segments.length; if (numSegments === 0) return null; // if segments is an empty array if (ratio < 0) ratio = 0; if (ratio > 1) ratio = 1; opt = opt || {}; var precision = (opt.precision === ...
javascript
{ "resource": "" }
q22818
train
function(index, arg) { var segments = this.segments; var numSegments = segments.length; if (numSegments === 0) throw new Error('Path has no segments.'); if (index < 0) index = numSegments + index; // convert negative indices to positive if (index >= numSegments || index < 0) th...
javascript
{ "resource": "" }
q22819
train
function(cell, portId) { console.assert(cell.isVisible()); console.assert(!cell.portProp(portId, 'collapsed'), 'port ' + portId + ' on ' + cell.id + ' should be expanded'); }
javascript
{ "resource": "" }
q22820
displayValue
train
function displayValue(gauge) { if (gauge.options.animatedValue) { return gauge.options.value; } return gauge.value; }
javascript
{ "resource": "" }
q22821
drawLinearBar
train
function drawLinearBar(context, options, x, y, w, h) { drawLinearBarShape(context, options, '', x, y, w, h); }
javascript
{ "resource": "" }
q22822
replaceVersionPlaceholders
train
function replaceVersionPlaceholders(packageDir, projectVersion) { // Resolve files that contain version placeholders using Grep or Findstr since those are // extremely fast and also have a very simple usage. const files = findFilesWithPlaceholders(packageDir); // Walk through every file that contains version p...
javascript
{ "resource": "" }
q22823
findFilesWithPlaceholders
train
function findFilesWithPlaceholders(packageDir) { const findCommand = buildPlaceholderFindCommand(packageDir); return spawnSync(findCommand.binary, findCommand.args).stdout .toString() .split(/[\n\r]/) .filter(String); }
javascript
{ "resource": "" }
q22824
buildPlaceholderFindCommand
train
function buildPlaceholderFindCommand(packageDir) { if (platform() === 'win32') { return { binary: 'findstr', args: ['/msi', `${materialVersionPlaceholderText} ${ngVersionPlaceholderText} ${versionPlaceholderText}`, `${packageDir}\\*`] }; } else { return { binary: 'grep', args: ['...
javascript
{ "resource": "" }
q22825
_cloneNode
train
function _cloneNode(deep, sourceNode, parentNode) { const clone = new sourceNode.constructor(sourceNode[symbols.windowSymbol]); clone.attrs = sourceNode.attrs; clone.tagName = sourceNode.tagName; clone.value = sourceNode.value; // Link the parent. if (parentNode) { clone.parentNode = parentNode; } // Co...
javascript
{ "resource": "" }
q22826
train
function () { var images = {}; var blobs = {}; if ( 'Video' in fbxTree.Objects ) { var videoNodes = fbxTree.Objects.Video; for ( var nodeID in videoNodes ) { var videoNode = videoNodes[ nodeID ]; var id = parseInt( nodeID ); images[ id ] = videoNode.RelativeFilename || videoNode.F...
javascript
{ "resource": "" }
q22827
train
function ( videoNode ) { var content = videoNode.Content; var fileName = videoNode.RelativeFilename || videoNode.Filename; var extension = fileName.slice( fileName.lastIndexOf( '.' ) + 1 ).toLowerCase(); var type; switch ( extension ) { case 'bmp': type = 'image/bmp'; break; case ...
javascript
{ "resource": "" }
q22828
train
function ( images ) { var textureMap = new Map(); if ( 'Texture' in fbxTree.Objects ) { var textureNodes = fbxTree.Objects.Texture; for ( var nodeID in textureNodes ) { var texture = this.parseTexture( textureNodes[ nodeID ], images ); textureMap.set( parseInt( nodeID ), texture ); } ...
javascript
{ "resource": "" }
q22829
train
function ( textureNode, images ) { var texture = this.loadTexture( textureNode, images ); texture.ID = textureNode.id; texture.name = textureNode.attrName; var wrapModeU = textureNode.WrapModeU; var wrapModeV = textureNode.WrapModeV; var valueU = wrapModeU !== undefined ? wrapModeU.value : 0; ...
javascript
{ "resource": "" }
q22830
train
function ( textureNode, images ) { var fileName; var currentPath = this.textureLoader.path; var children = connections.get( textureNode.id ).children; if ( children !== undefined && children.length > 0 && images[ children[ 0 ].ID ] !== undefined ) { fileName = images[ children[ 0 ].ID ]; if ( ...
javascript
{ "resource": "" }
q22831
train
function ( textureMap ) { var materialMap = new Map(); if ( 'Material' in fbxTree.Objects ) { var materialNodes = fbxTree.Objects.Material; for ( var nodeID in materialNodes ) { var material = this.parseMaterial( materialNodes[ nodeID ], textureMap ); if ( material !== null ) materialMap.s...
javascript
{ "resource": "" }
q22832
train
function ( materialNode, textureMap ) { var ID = materialNode.id; var name = materialNode.attrName; var type = materialNode.ShadingModel; // Case where FBX wraps shading model in property object. if ( typeof type === 'object' ) { type = type.value; } // Ignore unused materials which don't ...
javascript
{ "resource": "" }
q22833
train
function ( textureMap, id ) { // if the texture is a layered texture, just use the first layer and issue a warning if ( 'LayeredTexture' in fbxTree.Objects && id in fbxTree.Objects.LayeredTexture ) { console.warn( 'THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first lay...
javascript
{ "resource": "" }
q22834
train
function () { var skeletons = {}; var morphTargets = {}; if ( 'Deformer' in fbxTree.Objects ) { var DeformerNodes = fbxTree.Objects.Deformer; for ( var nodeID in DeformerNodes ) { var deformerNode = DeformerNodes[ nodeID ]; var relationships = connections.get( parseInt( nodeID ) ); ...
javascript
{ "resource": "" }
q22835
train
function ( relationships, deformerNodes ) { var rawBones = []; relationships.children.forEach( function ( child ) { var boneNode = deformerNodes[ child.ID ]; if ( boneNode.attrType !== 'Cluster' ) return; var rawBone = { ID: child.ID, indices: [], weights: [], transform: new ...
javascript
{ "resource": "" }
q22836
train
function ( relationships, deformerNodes ) { var rawMorphTargets = []; for ( var i = 0; i < relationships.children.length; i ++ ) { if ( i === 8 ) { console.warn( 'FBXLoader: maximum of 8 morph targets supported. Ignoring additional targets.' ); break; } var child = relationships.child...
javascript
{ "resource": "" }
q22837
train
function ( skeletons, geometryMap, materialMap ) { var modelMap = new Map(); var modelNodes = fbxTree.Objects.Model; for ( var nodeID in modelNodes ) { var id = parseInt( nodeID ); var node = modelNodes[ nodeID ]; var relationships = connections.get( id ); var model = this.buildSkeleton( re...
javascript
{ "resource": "" }
q22838
train
function ( relationships ) { var model; var cameraAttribute; relationships.children.forEach( function ( child ) { var attr = fbxTree.Objects.NodeAttribute[ child.ID ]; if ( attr !== undefined ) { cameraAttribute = attr; } } ); if ( cameraAttribute === undefined ) { model = n...
javascript
{ "resource": "" }
q22839
train
function ( relationships ) { var model; var lightAttribute; relationships.children.forEach( function ( child ) { var attr = fbxTree.Objects.NodeAttribute[ child.ID ]; if ( attr !== undefined ) { lightAttribute = attr; } } ); if ( lightAttribute === undefined ) { model = new ...
javascript
{ "resource": "" }
q22840
train
function ( deformers ) { var geometryMap = new Map(); if ( 'Geometry' in fbxTree.Objects ) { var geoNodes = fbxTree.Objects.Geometry; for ( var nodeID in geoNodes ) { var relationships = connections.get( parseInt( nodeID ) ); var geo = this.parseGeometry( relationships, geoNodes[ nodeID ], ...
javascript
{ "resource": "" }
q22841
train
function ( relationships, geoNode, deformers ) { switch ( geoNode.attrType ) { case 'Mesh': return this.parseMeshGeometry( relationships, geoNode, deformers ); break; case 'NurbsCurve': return this.parseNurbsGeometry( geoNode ); break; } }
javascript
{ "resource": "" }
q22842
train
function ( relationships, geoNode, deformers ) { var skeletons = deformers.skeletons; var morphTargets = deformers.morphTargets; var modelNodes = relationships.parents.map( function ( parent ) { return fbxTree.Objects.Model[ parent.ID ]; } ); // don't create geometry if it is not associated with...
javascript
{ "resource": "" }
q22843
train
function ( geoNode, skeleton, morphTarget, preTransform ) { var geo = new THREE.BufferGeometry(); if ( geoNode.attrName ) geo.name = geoNode.attrName; var geoInfo = this.parseGeoNode( geoNode, skeleton ); var buffers = this.genBuffers( geoInfo ); var positionAttribute = new THREE.Float32BufferAttribut...
javascript
{ "resource": "" }
q22844
train
function ( parentGeo, parentGeoNode, morphGeoNode, preTransform ) { var morphGeo = new THREE.BufferGeometry(); if ( morphGeoNode.attrName ) morphGeo.name = morphGeoNode.attrName; var vertexIndices = ( parentGeoNode.PolygonVertexIndex !== undefined ) ? parentGeoNode.PolygonVertexIndex.a : []; // make a co...
javascript
{ "resource": "" }
q22845
train
function ( NormalNode ) { var mappingType = NormalNode.MappingInformationType; var referenceType = NormalNode.ReferenceInformationType; var buffer = NormalNode.Normals.a; var indexBuffer = []; if ( referenceType === 'IndexToDirect' ) { if ( 'NormalIndex' in NormalNode ) { indexBuffer = Normal...
javascript
{ "resource": "" }
q22846
train
function ( UVNode ) { var mappingType = UVNode.MappingInformationType; var referenceType = UVNode.ReferenceInformationType; var buffer = UVNode.UV.a; var indexBuffer = []; if ( referenceType === 'IndexToDirect' ) { indexBuffer = UVNode.UVIndex.a; } return { dataSize: 2, buffer: buff...
javascript
{ "resource": "" }
q22847
train
function ( ColorNode ) { var mappingType = ColorNode.MappingInformationType; var referenceType = ColorNode.ReferenceInformationType; var buffer = ColorNode.Colors.a; var indexBuffer = []; if ( referenceType === 'IndexToDirect' ) { indexBuffer = ColorNode.ColorIndex.a; } return { dataSiz...
javascript
{ "resource": "" }
q22848
train
function ( MaterialNode ) { var mappingType = MaterialNode.MappingInformationType; var referenceType = MaterialNode.ReferenceInformationType; if ( mappingType === 'NoMappingInformation' ) { return { dataSize: 1, buffer: [ 0 ], indices: [ 0 ], mappingType: 'AllSame', referenceTyp...
javascript
{ "resource": "" }
q22849
train
function ( geoNode ) { if ( THREE.NURBSCurve === undefined ) { console.error( 'THREE.FBXLoader: The loader relies on THREE.NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry.' ); return new THREE.BufferGeometry(); } var order = parseInt( geoNode.Order ); if ( is...
javascript
{ "resource": "" }
q22850
train
function () { var animationClips = []; var rawClips = this.parseClips(); if ( rawClips === undefined ) return; for ( var key in rawClips ) { var rawClip = rawClips[ key ]; var clip = this.addClip( rawClip ); animationClips.push( clip ); } return animationClips; }
javascript
{ "resource": "" }
q22851
train
function ( layersMap ) { var rawStacks = fbxTree.Objects.AnimationStack; // connect the stacks (clips) up to the layers var rawClips = {}; for ( var nodeID in rawStacks ) { var children = connections.get( parseInt( nodeID ) ).children; if ( children.length > 1 ) { // it seems like stacks ...
javascript
{ "resource": "" }
q22852
train
function ( curves ) { var times = []; // first join together the times for each axis, if defined if ( curves.x !== undefined ) times = times.concat( curves.x.times ); if ( curves.y !== undefined ) times = times.concat( curves.y.times ); if ( curves.z !== undefined ) times = times.concat( curves.z.times...
javascript
{ "resource": "" }
q22853
train
function ( curve ) { for ( var i = 1; i < curve.values.length; i ++ ) { var initialValue = curve.values[ i - 1 ]; var valuesSpan = curve.values[ i ] - initialValue; var absoluteSpan = Math.abs( valuesSpan ); if ( absoluteSpan >= 180 ) { var numSubIntervals = absoluteSpan / 180; var st...
javascript
{ "resource": "" }
q22854
train
function ( reader ) { // footer size: 160bytes + 16-byte alignment padding // - 16bytes: magic // - padding til 16-byte alignment (at least 1byte?) // (seems like some exporters embed fixed 15 or 16bytes?) // - 4bytes: magic // - 4bytes: version // - 120bytes: zero // - 16bytes: magic if ( r...
javascript
{ "resource": "" }
q22855
train
function ( reader, version ) { var node = {}; // The first three data sizes depends on version. var endOffset = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32(); var numProperties = ( version >= 7500 ) ? reader.getUint64() : reader.getUint32(); // note: do not remove this even if you get ...
javascript
{ "resource": "" }
q22856
getData
train
function getData( polygonVertexIndex, polygonIndex, vertexIndex, infoObject ) { var index; switch ( infoObject.mappingType ) { case 'ByPolygonVertex' : index = polygonVertexIndex; break; case 'ByPolygon' : index = polygonIndex; break; case 'ByVertice' : index = vertexIndex; break...
javascript
{ "resource": "" }
q22857
parseNumberArray
train
function parseNumberArray( value ) { var array = value.split( ',' ).map( function ( val ) { return parseFloat( val ); } ); return array; }
javascript
{ "resource": "" }
q22858
inject
train
function inject( a1, index, a2 ) { return a1.slice( 0, index ).concat( a2 ).concat( a1.slice( index ) ); }
javascript
{ "resource": "" }
q22859
expandXBounds
train
function expandXBounds(bounds, value) { if (bounds[MIN_X] > value) bounds[MIN_X] = value;else if (bounds[MAX_X] < value) bounds[MAX_X] = value; }
javascript
{ "resource": "" }
q22860
expandYBounds
train
function expandYBounds(bounds, value) { if (bounds[MIN_Y] > value) bounds[MIN_Y] = value;else if (bounds[MAX_Y] < value) bounds[MAX_Y] = value; }
javascript
{ "resource": "" }
q22861
calculateBezier
train
function calculateBezier(t, p0, p1, p2, p3) { var mt = 1 - t; return mt * mt * mt * p0 + 3 * mt * mt * t * p1 + 3 * mt * t * t * p2 + t * t * t * p3; }
javascript
{ "resource": "" }
q22862
train
function (str) { var output = []; var idx = 0; var c, num; var nextNumber = function () { var chars = []; while (/[^-\d\.]/.test(str.charAt(idx))) { // skip the non-digit characters idx++; } if ('-' === str.charAt(idx)) { chars.push('-'); idx++;...
javascript
{ "resource": "" }
q22863
train
function (res, path) { let defaultSrc = "default-src 'self';"; let styleSrc = "style-src 'self' fonts.googleapis.com;"; let fontSrc = "font-src 'self' fonts.gstatic.com;"; let imgSrc = "img-src 'self' www.gravatar.com;"; res.setHeader('Cont...
javascript
{ "resource": "" }
q22864
prompt
train
async function prompt(questions=[], { onSubmit=noop, onCancel=noop }={}) { const answers = {}; const override = prompt._override || {}; questions = [].concat(questions); let answer, question, quit, name, type; const getFormattedAnswer = async (question, answer, skipValidation = false) => { if (!skipValid...
javascript
{ "resource": "" }
q22865
destroyTextures
train
function destroyTextures () { for (var i = 0; i < numTexUnits; ++i) { gl.activeTexture(GL_TEXTURE0 + i) gl.bindTexture(GL_TEXTURE_2D, null) textureUnits[i] = null } values(textureSet).forEach(destroy) stats.cubeCount = 0 stats.textureCount = 0 }
javascript
{ "resource": "" }
q22866
createDrawCall
train
function createDrawCall (props) { return regl({ attributes: { position: props.position }, uniforms: { color: props.color, scale: props.scale, offset: props.offset, phase: props.phase, freq: props.freq }, lineWidth: lineWidth, count: props.position.length, ...
javascript
{ "resource": "" }
q22867
centerMesh
train
function centerMesh (mesh) { var bb = boundingBox(mesh.positions) var _translate = [ -0.5 * (bb[0][0] + bb[1][0]), -0.5 * (bb[0][1] + bb[1][1]), -0.5 * (bb[0][2] + bb[1][2]) ] var translate = mat4.create() mat4.translate(translate, translate, _translate) mesh.positions = tform(mesh.positions, t...
javascript
{ "resource": "" }
q22868
Constraint
train
function Constraint (i0, i1) { this.i0 = i0 this.i1 = i1 this.restLength = vec3.distance(position[i0], position[i1]) }
javascript
{ "resource": "" }
q22869
step
train
function step ({tick}) { setFBO({ framebuffer: FIELDS[0] }, () => { regl.clear({ color: [0, 0, 0, 1] }) splatMouse() splatVerts({ vertexState: VERTEX_STATE[(tick + 1) % 2] }) }) for (let i = 0; i < 2 * BLUR_PASSES; ++i) { blurPass({ dest: FIELDS[(i + 1) % 2], src: FIELDS[i % ...
javascript
{ "resource": "" }
q22870
getModelMatrix
train
function getModelMatrix (rb) { var ms = rb.getMotionState() if (ms) { ms.getWorldTransform(transformTemp) var p = transformTemp.getOrigin() var q = transformTemp.getRotation() return mat4.fromRotationTranslation( [], [q.x(), q.y(), q.z(), q.w()], [p.x(), p.y(), p.z()]) } }
javascript
{ "resource": "" }
q22871
createAudioBuffer
train
function createAudioBuffer (length, createAudioDataCallback) { var channels = 2 var frameCount = context.sampleRate * length var audioBuffer = context.createBuffer(channels, frameCount, context.sampleRate) for (var channel = 0; channel < channels; channel++) { var channelData = audioBuffer.getChannelData(c...
javascript
{ "resource": "" }
q22872
block
train
function block () { var code = [] function push () { code.push.apply(code, slice(arguments)) } var vars = [] function def () { var name = 'v' + (varCounter++) vars.push(name) if (arguments.length > 0) { code.push(name, '=') code.push.apply(code, slice(argume...
javascript
{ "resource": "" }
q22873
sortState
train
function sortState (state) { return state.sort(function (a, b) { if (a === S_VIEWPORT) { return -1 } else if (b === S_VIEWPORT) { return 1 } return (a < b) ? -1 : 1 }) }
javascript
{ "resource": "" }
q22874
_unwrapStorageSnapshot
train
function _unwrapStorageSnapshot(storageSnapshot) { return { bytesTransferred: storageSnapshot.bytesTransferred, downloadURL: storageSnapshot.downloadURL, metadata: storageSnapshot.metadata, ref: storageSnapshot.ref, state: storageSnapshot.state, task: storageSnapshot.task, ...
javascript
{ "resource": "" }
q22875
FirebaseObject
train
function FirebaseObject(ref) { if( !(this instanceof FirebaseObject) ) { return new FirebaseObject(ref); } var self = this; // These are private config props and functions used internally // they are collected here to reduce clutter in console.log and forEach th...
javascript
{ "resource": "" }
q22876
train
function () { var self = this; var ref = self.$ref(); var def = $q.defer(); var dataJSON; try { dataJSON = $firebaseUtils.toJSON(self); } catch (e) { def.reject(e); } if (typeof dataJSON !== 'undefined') { ...
javascript
{ "resource": "" }
q22877
train
function() { var self = this; $firebaseUtils.trimKeys(self, {}); self.$value = null; return $firebaseUtils.doRemove(self.$ref()).then(function() { self.$$notify(); return self.$ref(); }); }
javascript
{ "resource": "" }
q22878
train
function (scope, varName) { var self = this; return self.$loaded().then(function () { return self.$$conf.binding.bindTo(scope, varName); }); }
javascript
{ "resource": "" }
q22879
train
function (stringOrProvider) { var provider; if (typeof stringOrProvider == "string") { var providerID = stringOrProvider.slice(0, 1).toUpperCase() + stringOrProvider.slice(1); provider = new firebase.auth[providerID+"AuthProvider"](); } else { provider = stringOrProvider; ...
javascript
{ "resource": "" }
q22880
train
function() { var auth = this._auth; return this._q(function(resolve) { var off; function callback() { // Turn off this onAuthStateChanged() callback since we just needed to get the authentication data once. off(); resolve(); } off = auth.onAuthS...
javascript
{ "resource": "" }
q22881
train
function(indexOrItem) { this._assertNotDestroyed('$save'); var self = this; var item = self._resolveItem(indexOrItem); var key = self.$keyAt(item); var def = $q.defer(); if( key !== null ) { var ref = self.$ref().ref.child(key); var da...
javascript
{ "resource": "" }
q22882
train
function(rec, prevChild) { var i; if( prevChild === null ) { i = 0; } else { i = this.$indexFor(prevChild)+1; if( i === 0 ) { i = this.$list.length; } } this.$list.splice(i, 0, rec); this._indexCache[this.$$getKey(...
javascript
{ "resource": "" }
q22883
train
function(indexOrItem) { var list = this.$list; if( angular.isNumber(indexOrItem) && indexOrItem >= 0 && list.length >= indexOrItem ) { return list[indexOrItem]; } else if( angular.isObject(indexOrItem) ) { // it must be an item in this array; it's not suff...
javascript
{ "resource": "" }
q22884
getBox
train
function getBox(o) { return { xMin: o.position.x, xMax: o.position.x + o.width, yMin: o.position.y, yMax: o.position.y + o.height }; }
javascript
{ "resource": "" }
q22885
clfdate
train
function clfdate (dateTime) { var date = dateTime.getUTCDate() var hour = dateTime.getUTCHours() var mins = dateTime.getUTCMinutes() var secs = dateTime.getUTCSeconds() var year = dateTime.getUTCFullYear() var month = CLF_MONTH[dateTime.getUTCMonth()] return pad2(date) + '/' + month + '/' + year + '...
javascript
{ "resource": "" }
q22886
createBufferStream
train
function createBufferStream (stream, interval) { var buf = [] var timer = null // flush function function flush () { timer = null stream.write(buf.join('')) buf.length = 0 } // write function function write (str) { if (timer === null) { timer = setTimeout(flush, interval) } ...
javascript
{ "resource": "" }
q22887
getFormatFunction
train
function getFormatFunction (name) { // lookup format var fmt = morgan[name] || name || morgan.default // return compiled format return typeof fmt !== 'function' ? compile(fmt) : fmt }
javascript
{ "resource": "" }
q22888
injectHook
train
function injectHook(options, name, hook) { const existing = options[name] options[name] = existing ? Array.isArray(existing) ? existing.concat(hook) : [existing, hook] : [hook] }
javascript
{ "resource": "" }
q22889
patchScopedSlots
train
function patchScopedSlots (instance) { if (!instance._u) return // https://github.com/vuejs/vue/blob/dev/src/core/instance/render-helpers/resolve-scoped-slots.js const original = instance._u instance._u = slots => { try { // 2.6.4 ~ 2.6.6 return original(slots, true) } catch (e) { // 2...
javascript
{ "resource": "" }
q22890
getNodeInfo
train
function getNodeInfo(x, y){ var nodeInfo = {}; var bestNodeInfo = { node: null, boundSize: 0 }; getBestNode(appTree, x, y, bestNodeInfo); var bestNode = bestNodeInfo.node; if(bestNode){ var text = bestNode.text || bestNode.label; ...
javascript
{ "resource": "" }
q22891
getRootPath
train
function getRootPath(){ var rootPath = path.resolve('.'); while(rootPath){ if(fs.existsSync(rootPath + '/config.json')){ break; } rootPath = rootPath.substring(0, rootPath.lastIndexOf(path.sep)); } return rootPath; }
javascript
{ "resource": "" }
q22892
startRecorderServer
train
function startRecorderServer(config, onReady, onCommand, onEnd){ var server = http.createServer(function(req, res){ if(req.url === '/proxy.pac'){ var wdproxy = config.wdproxy; if(wdproxy){ res.writeHead(200, { 'Content-Type': 'text/plain' }); var pacCo...
javascript
{ "resource": "" }
q22893
getDomPath
train
function getDomPath(target, isAllDom){ var arrAllPaths = []; var node = target, path; while(node){ var nodeName = node.nodeName.toLowerCase(); if(/^#document/.test(nodeName)){ path = getRelativeDomPath(node, target, isAllDom); if(path){ ...
javascript
{ "resource": "" }
q22894
getFrameId
train
function getFrameId(){ var frame = -1; if(isIframe){ try{ var frameElement = window.frameElement; if(frameElement !== null){ frame = getDomPath(frameElement) || -1; } else{ frame = '!'+loc...
javascript
{ "resource": "" }
q22895
unsafeEval
train
function unsafeEval(str){ var head = document.getElementsByTagName("head")[0]; var script = document.createElement("script"); script.innerHTML = '('+str+')();'; head.appendChild(script); head.removeChild(script); }
javascript
{ "resource": "" }
q22896
hookAlertFunction
train
function hookAlertFunction(){ var rawAlert = window.alert; function sendAlertCmd(cmd, data){ var cmdInfo = { cmd: cmd, data: data || {} }; window.postMessage({ 'type': 'uiRecorderAlertComm...
javascript
{ "resource": "" }
q22897
getFixedParent
train
function getFixedParent(target){ var documentElement = document.documentElement; var node = target; var nodeName, path, offset, left, top, savedParent; var notFirstNode = false; // 当前点击控件以可见范围内进行定位,其它以全局定位(很多局部控件是不可见的) while(node !== null){ nod...
javascript
{ "resource": "" }
q22898
setRecorderWork
train
function setRecorderWork(enable){ isWorking = enable; if(isWorking){ chrome.browserAction.setTitle({title: __('icon_record_tip')}); chrome.browserAction.setIcon({path: workIcon===1?ENABLE_ICON1:ENABLE_ICON2}); workIcon *= -1; workIconTimer = setTimeout(function(){ set...
javascript
{ "resource": "" }
q22899
saveCommand
train
function saveCommand(windowId, frame, cmd, data){ if(isModuleLoading){ return; } var cmdInfo = { window: windowId, frame: frame, cmd: cmd, data: data, fix: false }; checkLostKey(windowId); switch(cmd){ case 'keyDown': allKeyMa...
javascript
{ "resource": "" }