_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q23800
setSamplerParameters
train
function setSamplerParameters(gl, sampler, options) { setTextureSamplerParameters(gl, sampler, gl.samplerParameteri, options); }
javascript
{ "resource": "" }
q23801
createSampler
train
function createSampler(gl, options) { const sampler = gl.createSampler(); setSamplerParameters(gl, sampler, options); return sampler; }
javascript
{ "resource": "" }
q23802
createSamplers
train
function createSamplers(gl, samplerOptions) { const samplers = {}; Object.keys(samplerOptions).forEach(function(name) { samplers[name] = createSampler(gl, samplerOptions[name]); }); return samplers; }
javascript
{ "resource": "" }
q23803
make1Pixel
train
function make1Pixel(color) { color = color || defaults.textureColor; if (isArrayBuffer(color)) { return color; } return new Uint8Array([color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255]); }
javascript
{ "resource": "" }
q23804
getCubeFaceOrder
train
function getCubeFaceOrder(gl, options) { options = options || {}; return options.cubeFaceOrder || [ gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z, gl.TEXTURE_CUBE_MAP_...
javascript
{ "resource": "" }
q23805
urlIsSameOrigin
train
function urlIsSameOrigin(url) { if (typeof document !== 'undefined') { // for IE really const a = document.createElement('a'); a.href = url; return a.hostname === location.hostname && a.port === location.port && a.protocol === location.protocol; } else { const localOrig...
javascript
{ "resource": "" }
q23806
loadImage
train
function loadImage(url, crossOrigin, callback) { callback = callback || noop; let img; crossOrigin = crossOrigin !== undefined ? crossOrigin : defaults.crossOrigin; crossOrigin = setToAnonymousIfUndefinedAndURLIsNotSameOrigin(url, crossOrigin); if (typeof Image !== 'undefined') { img = new Image(); if...
javascript
{ "resource": "" }
q23807
isTexImageSource
train
function isTexImageSource(obj) { return (typeof ImageBitmap !== 'undefined' && obj instanceof ImageBitmap) || (typeof ImageData !== 'undefined' && obj instanceof ImageData) || (typeof HTMLElement !== 'undefined' && obj instanceof HTMLElement); }
javascript
{ "resource": "" }
q23808
loadAndUseImage
train
function loadAndUseImage(obj, crossOrigin, callback) { if (isTexImageSource(obj)) { setTimeout(function() { callback(null, obj); }); return obj; } return loadImage(obj, crossOrigin, callback); }
javascript
{ "resource": "" }
q23809
loadTextureFromUrl
train
function loadTextureFromUrl(gl, tex, options, callback) { callback = callback || noop; options = options || defaults.textureOptions; setTextureTo1PixelColor(gl, tex, options); // Because it's async we need to copy the options. options = Object.assign({}, options); const img = loadAndUseImage(options.src, op...
javascript
{ "resource": "" }
q23810
setEmptyTexture
train
function setEmptyTexture(gl, tex, options) { const target = options.target || gl.TEXTURE_2D; gl.bindTexture(target, tex); const level = options.level || 0; const internalFormat = options.internalFormat || options.format || gl.RGBA; const formatType = getFormatAndTypeForInternalFormat(internalFormat); const ...
javascript
{ "resource": "" }
q23811
createTexture
train
function createTexture(gl, options, callback) { callback = callback || noop; options = options || defaults.textureOptions; const tex = gl.createTexture(); const target = options.target || gl.TEXTURE_2D; let width = options.width || 1; let height = options.height || 1; const internalFormat = options.inte...
javascript
{ "resource": "" }
q23812
resizeTexture
train
function resizeTexture(gl, tex, options, width, height) { width = width || options.width; height = height || options.height; const target = options.target || gl.TEXTURE_2D; gl.bindTexture(target, tex); const level = options.level || 0; const internalFormat = options.internalFormat || options.format || gl.RG...
javascript
{ "resource": "" }
q23813
createTextures
train
function createTextures(gl, textureOptions, callback) { callback = callback || noop; let numDownloading = 0; const errors = []; const textures = {}; const images = {}; function callCallbackIfReady() { if (numDownloading === 0) { setTimeout(function() { callback(errors.length ? errors : un...
javascript
{ "resource": "" }
q23814
resizeFramebufferInfo
train
function resizeFramebufferInfo(gl, framebufferInfo, attachments, width, height) { width = width || gl.drawingBufferWidth; height = height || gl.drawingBufferHeight; framebufferInfo.width = width; framebufferInfo.height = height; attachments = attachments || defaultAttachments; attachments.forEach(function...
javascript
{ "resource": "" }
q23815
bindFramebufferInfo
train
function bindFramebufferInfo(gl, framebufferInfo, target) { target = target || gl.FRAMEBUFFER; if (framebufferInfo) { gl.bindFramebuffer(target, framebufferInfo.framebuffer); gl.viewport(0, 0, framebufferInfo.width, framebufferInfo.height); } else { gl.bindFramebuffer(target, null); gl.viewport(0,...
javascript
{ "resource": "" }
q23816
create
train
function create(x, y, z) { const dst = new VecType(3); if (x) { dst[0] = x; } if (y) { dst[1] = y; } if (z) { dst[2] = z; } return dst; }
javascript
{ "resource": "" }
q23817
add
train
function add(a, b, dst) { dst = dst || new VecType(3); dst[0] = a[0] + b[0]; dst[1] = a[1] + b[1]; dst[2] = a[2] + b[2]; return dst; }
javascript
{ "resource": "" }
q23818
subtract
train
function subtract(a, b, dst) { dst = dst || new VecType(3); dst[0] = a[0] - b[0]; dst[1] = a[1] - b[1]; dst[2] = a[2] - b[2]; return dst; }
javascript
{ "resource": "" }
q23819
mulScalar
train
function mulScalar(v, k, dst) { dst = dst || new VecType(3); dst[0] = v[0] * k; dst[1] = v[1] * k; dst[2] = v[2] * k; return dst; }
javascript
{ "resource": "" }
q23820
divScalar
train
function divScalar(v, k, dst) { dst = dst || new VecType(3); dst[0] = v[0] / k; dst[1] = v[1] / k; dst[2] = v[2] / k; return dst; }
javascript
{ "resource": "" }
q23821
cross
train
function cross(a, b, dst) { dst = dst || new VecType(3); const t1 = a[2] * b[0] - a[0] * b[2]; const t2 = a[0] * b[1] - a[1] * b[0]; dst[0] = a[1] * b[2] - a[2] * b[1]; dst[1] = t1; dst[2] = t2; return dst; }
javascript
{ "resource": "" }
q23822
normalize
train
function normalize(a, dst) { dst = dst || new VecType(3); const lenSq = a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; const len = Math.sqrt(lenSq); if (len > 0.00001) { dst[0] = a[0] / len; dst[1] = a[1] / len; dst[2] = a[2] / len; } else { dst[0] = 0; dst[1] = 0; dst[2] = 0; } return...
javascript
{ "resource": "" }
q23823
negate
train
function negate(v, dst) { dst = dst || new VecType(3); dst[0] = -v[0]; dst[1] = -v[1]; dst[2] = -v[2]; return dst; }
javascript
{ "resource": "" }
q23824
copy
train
function copy(v, dst) { dst = dst || new VecType(3); dst[0] = v[0]; dst[1] = v[1]; dst[2] = v[2]; return dst; }
javascript
{ "resource": "" }
q23825
deindexVertices
train
function deindexVertices(vertices) { const indices = vertices.indices; const newVertices = {}; const numElements = indices.length; function expandToUnindexed(channel) { const srcBuffer = vertices[channel]; const numComponents = srcBuffer.numComponents; const dstBuffer = createAugmentedTypedArray(nu...
javascript
{ "resource": "" }
q23826
flattenNormals
train
function flattenNormals(vertices) { if (vertices.indices) { throw "can't flatten normals of indexed vertices. deindex them first"; } const normals = vertices.normal; const numNormals = normals.length; for (let ii = 0; ii < numNormals; ii += 9) { // pull out the 3 normals for this triangle const n...
javascript
{ "resource": "" }
q23827
reorientNormals
train
function reorientNormals(array, matrix) { applyFuncToV3Array(array, m4.inverse(matrix), transformNormal); return array; }
javascript
{ "resource": "" }
q23828
createXYQuadVertices
train
function createXYQuadVertices(size, xOffset, yOffset) { size = size || 2; xOffset = xOffset || 0; yOffset = yOffset || 0; size *= 0.5; return { position: { numComponents: 2, data: [ xOffset + -1 * size, yOffset + -1 * size, xOffset + 1 * size, yOffset + -1 * size, xOff...
javascript
{ "resource": "" }
q23829
createPlaneVertices
train
function createPlaneVertices( width, depth, subdivisionsWidth, subdivisionsDepth, matrix) { width = width || 1; depth = depth || 1; subdivisionsWidth = subdivisionsWidth || 1; subdivisionsDepth = subdivisionsDepth || 1; matrix = matrix || m4.identity(); const numVertices = (subdivisions...
javascript
{ "resource": "" }
q23830
createSphereVertices
train
function createSphereVertices( radius, subdivisionsAxis, subdivisionsHeight, opt_startLatitudeInRadians, opt_endLatitudeInRadians, opt_startLongitudeInRadians, opt_endLongitudeInRadians) { if (subdivisionsAxis <= 0 || subdivisionsHeight <= 0) { throw Error('subdivisionAxis and subdivis...
javascript
{ "resource": "" }
q23831
createCubeVertices
train
function createCubeVertices(size) { size = size || 1; const k = size / 2; const cornerVertices = [ [-k, -k, -k], [+k, -k, -k], [-k, +k, -k], [+k, +k, -k], [-k, -k, +k], [+k, -k, +k], [-k, +k, +k], [+k, +k, +k], ]; const faceNormals = [ [+1, +0, +0], [-1, +0, +0], ...
javascript
{ "resource": "" }
q23832
expandRLEData
train
function expandRLEData(rleData, padding) { padding = padding || []; const data = []; for (let ii = 0; ii < rleData.length; ii += 4) { const runLength = rleData[ii]; const element = rleData.slice(ii + 1, ii + 4); element.push.apply(element, padding); for (let jj = 0; jj < runLength; ++jj) { d...
javascript
{ "resource": "" }
q23833
createCylinderVertices
train
function createCylinderVertices( radius, height, radialSubdivisions, verticalSubdivisions, topCap, bottomCap) { return createTruncatedConeVertices( radius, radius, height, radialSubdivisions, verticalSubdivisions, topCap, bottomCap); }
javascript
{ "resource": "" }
q23834
createTorusVertices
train
function createTorusVertices( radius, thickness, radialSubdivisions, bodySubdivisions, startAngle, endAngle) { if (radialSubdivisions < 3) { throw Error('radialSubdivisions must be 3 or greater'); } if (bodySubdivisions < 3) { throw Error('verticalSubdivisions must be 3 or greater...
javascript
{ "resource": "" }
q23835
createDiscVertices
train
function createDiscVertices( radius, divisions, stacks, innerRadius, stackPower) { if (divisions < 3) { throw Error('divisions must be at least 3'); } stacks = stacks ? stacks : 1; stackPower = stackPower ? stackPower : 1; innerRadius = innerRadius ? innerRadius : 0; // Note: We do...
javascript
{ "resource": "" }
q23836
createBufferFunc
train
function createBufferFunc(fn) { return function(gl) { const arrays = fn.apply(this, Array.prototype.slice.call(arguments, 1)); return attributes.createBuffersFromArrays(gl, arrays); }; }
javascript
{ "resource": "" }
q23837
createBufferInfoFunc
train
function createBufferInfoFunc(fn) { return function(gl) { const arrays = fn.apply(null, Array.prototype.slice.call(arguments, 1)); return attributes.createBufferInfoFromArrays(gl, arrays); }; }
javascript
{ "resource": "" }
q23838
copyElements
train
function copyElements(src, dst, dstNdx, offset) { offset = offset || 0; const length = src.length; for (let ii = 0; ii < length; ++ii) { dst[dstNdx + ii] = src[ii] + offset; } }
javascript
{ "resource": "" }
q23839
createArrayOfSameType
train
function createArrayOfSameType(srcArray, length) { const arraySrc = getArray(srcArray); const newArray = new arraySrc.constructor(length); let newArraySpec = newArray; // If it appears to have been augmented make new one augemented if (arraySrc.numComponents && arraySrc.numElements) { augmentTypedArray(ne...
javascript
{ "resource": "" }
q23840
concatVertices
train
function concatVertices(arrayOfArrays) { const names = {}; let baseName; // get names of all arrays. // and numElements for each set of vertices for (let ii = 0; ii < arrayOfArrays.length; ++ii) { const arrays = arrayOfArrays[ii]; Object.keys(arrays).forEach(function(name) { // eslint-disable-line ...
javascript
{ "resource": "" }
q23841
getLengthOfCombinedArrays
train
function getLengthOfCombinedArrays(name) { let length = 0; let arraySpec; for (let ii = 0; ii < arrayOfArrays.length; ++ii) { const arrays = arrayOfArrays[ii]; const arrayInfo = arrays[name]; const array = getArray(arrayInfo); length += array.length; if (!arraySpec || arrayInfo...
javascript
{ "resource": "" }
q23842
duplicateVertices
train
function duplicateVertices(arrays) { const newArrays = {}; Object.keys(arrays).forEach(function(name) { const arraySpec = arrays[name]; const srcArray = getArray(arraySpec); const newArraySpec = createArrayOfSameType(arraySpec, srcArray.length); copyElements(srcArray, getArray(newArraySpec), 0); ...
javascript
{ "resource": "" }
q23843
printKey
train
function printKey () { let keyid = printKeyid(this.primaryKey.getKeyId()) let userid = printUser(this.getPrimaryUser().user) return keyid + ' ' + userid }
javascript
{ "resource": "" }
q23844
otherVarIntDecode
train
function otherVarIntDecode (reader, startWith) { let result = startWith let shift = 4 let byte = null do { byte = reader.readUInt8() result |= (byte & 0b01111111) << shift shift += 7 } while (byte & 0b10000000) return result }
javascript
{ "resource": "" }
q23845
parseCacheEntryFlags
train
function parseCacheEntryFlags (bits) { return { assumeValid: Boolean(bits & 0b1000000000000000), extended: Boolean(bits & 0b0100000000000000), stage: (bits & 0b0011000000000000) >> 12, nameLength: bits & 0b0000111111111111 } }
javascript
{ "resource": "" }
q23846
fillInit
train
function fillInit() { console.log('\nThis utility will generate a resume.json file in your current working directory.'); console.log('Fill out your name and email to get started, or leave the fields blank.'); console.log('All fields are optional.\n'); console.log('Press ^C at any time to quit.'); r...
javascript
{ "resource": "" }
q23847
ToonAnimationMaterial
train
function ToonAnimationMaterial(parameters) { if (!parameters.defines) { parameters.defines = {}; } parameters.defines['TOON'] = ''; PhongAnimationMaterial.call(this, parameters); }
javascript
{ "resource": "" }
q23848
MultiPrefabBufferGeometry
train
function MultiPrefabBufferGeometry(prefabs, repeatCount) { BufferGeometry.call(this); if (Array.isArray(prefabs)) { this.prefabGeometries = prefabs; } else { this.prefabGeometries = [prefabs]; } this.prefabGeometriesCount = this.prefabGeometries.length; /** * Number of prefabs. * @type {Num...
javascript
{ "resource": "" }
q23849
InstancedPrefabBufferGeometry
train
function InstancedPrefabBufferGeometry(prefab, count) { if (prefab.isGeometry === true) { console.error('InstancedPrefabBufferGeometry prefab must be a BufferGeometry.'); } InstancedBufferGeometry.call(this); this.prefabGeometry = prefab; this.copy(prefab); this.maxInstancedCount = count; this.pref...
javascript
{ "resource": "" }
q23850
separateFaces
train
function separateFaces(geometry) { var vertices = []; for (var i = 0, il = geometry.faces.length; i < il; i++) { var n = vertices.length; var face = geometry.faces[i]; var a = face.a; var b = face.b; var c = face.c; var va = geometry.vertices[a]; var vb = geometry.ve...
javascript
{ "resource": "" }
q23851
createDepthAnimationMaterial
train
function createDepthAnimationMaterial(sourceMaterial) { return new DepthAnimationMaterial({ uniforms: sourceMaterial.uniforms, defines: sourceMaterial.defines, vertexFunctions: sourceMaterial.vertexFunctions, vertexParameters: sourceMaterial.vertexParameters, vertexInit: sourceMaterial...
javascript
{ "resource": "" }
q23852
createDistanceAnimationMaterial
train
function createDistanceAnimationMaterial(sourceMaterial) { return new DistanceAnimationMaterial({ uniforms: sourceMaterial.uniforms, defines: sourceMaterial.defines, vertexFunctions: sourceMaterial.vertexFunctions, vertexParameters: sourceMaterial.vertexParameters, vertexInit: sourceMa...
javascript
{ "resource": "" }
q23853
ModelBufferGeometry
train
function ModelBufferGeometry(model, options) { BufferGeometry.call(this); /** * A reference to the geometry used to create this instance. * @type {THREE.Geometry} */ this.modelGeometry = model; /** * Number of faces of the model. * @type {Number} */ this.faceCount = this.modelGeometry.face...
javascript
{ "resource": "" }
q23854
train
function (start, end) { var total = 0; start = start || 0; end = end || this.binCount; for (var i = start; i < end; i++) { total += this.frequencyByteData[i]; } return total / (end - start); }
javascript
{ "resource": "" }
q23855
getRandomPointOnSphere
train
function getRandomPointOnSphere(r) { var u = THREE.Math.randFloat(0, 1); var v = THREE.Math.randFloat(0, 1); var theta = 2 * Math.PI * u; var phi = Math.acos(2 * v - 1); var x = r * Math.sin(theta) * Math.sin(phi); var y = r * Math.cos(theta) * Math.sin(phi); var z = r * Math.cos(phi); return { x, ...
javascript
{ "resource": "" }
q23856
getPointsOnPicture
train
function getPointsOnPicture(selector) { var img = document.querySelector(selector); var width = img.width; var height = img.height; var canvas = document.createElement('canvas'); document.body.appendChild(canvas); canvas.width = width; canvas.height = height; var ctx = canvas.getContext('2d'); ctx.dr...
javascript
{ "resource": "" }
q23857
BasicAnimationMaterial
train
function BasicAnimationMaterial(parameters) { this.varyingParameters = []; this.vertexParameters = []; this.vertexFunctions = []; this.vertexInit = []; this.vertexNormal = []; this.vertexPosition = []; this.vertexColor = []; this.vertexPostMorph = []; this.vertexPostSkinning = []; this.fragmentFun...
javascript
{ "resource": "" }
q23858
PointsAnimationMaterial
train
function PointsAnimationMaterial(parameters) { this.varyingParameters = []; this.vertexFunctions = []; this.vertexParameters = []; this.vertexInit = []; this.vertexPosition = []; this.vertexColor = []; this.fragmentFunctions = []; this.fragmentParameters = []; this.fragmentInit = []; this.fragment...
javascript
{ "resource": "" }
q23859
PrefabBufferGeometry
train
function PrefabBufferGeometry(prefab, count) { three.BufferGeometry.call(this); /** * A reference to the prefab geometry used to create this instance. * @type {Geometry|BufferGeometry} */ this.prefabGeometry = prefab; this.isPrefabBufferGeometry = prefab.isBufferGeometry; /** * Number of prefabs...
javascript
{ "resource": "" }
q23860
RpcNotification
train
function RpcNotification(method, params) { if(defineProperty_IE8) { this.method = method this.params = params } else { Object.defineProperty(this, 'method', {value: method, enumerable: true}); Object.defineProperty(this, 'params', {value: params, enumerable: true}); } }
javascript
{ "resource": "" }
q23861
storeResponse
train
function storeResponse(message, id, dest) { var response = { message: message, /** Timeout to auto-clean old responses */ timeout: setTimeout(function() { responses.remove(id, dest); }, response_timeout) }; responses.set(response, id, dest); }
javascript
{ "resource": "" }
q23862
storeProcessedResponse
train
function storeProcessedResponse(ack, from) { var timeout = setTimeout(function() { processedResponses.remove(ack, from); }, duplicates_timeout); processedResponses.set(timeout, ack, from); }
javascript
{ "resource": "" }
q23863
formatter
train
function formatter(data, parentAuthority, parentName) { if (!data) { return undefined; } return data .map(item => { if (!item.name || !item.path) { return null; } let locale = 'menu'; if (parentName && parentName !== '/') { locale = `${parentName}.${item.name}`; ...
javascript
{ "resource": "" }
q23864
getByte
train
function getByte(array, position, length) { const d = position % 8; const a = Math.floor(position / 8); const de = 8 - d; const ef = (position + length) - ((a + 1) * 8); let fg = (8 * (a + 2)) - (position + length); const dg = ((a + 2) * 8) - position; fg = Math.max(0, fg); if (a >= array.length) { ...
javascript
{ "resource": "" }
q23865
train
function(element, options) { var that = this; that.name = NAME; that.$ = $(element); options = that.options = $.extend({}, Pager.DEFAULTS, this.$.data(), options); var lang = options.lang || $.zui.clientLang(); that.lang = $.isPlainObject(lang) ? ($.extend(true, {}, ...
javascript
{ "resource": "" }
q23866
train
function () { var ie = this.isIE() || this.isIE10() || false; if (ie) { for (var i = 10; i > 5; i--) { if (this.isIE(i)) { ie = i; break; } } } this.ie = ie; this.cssHelper(); }
javascript
{ "resource": "" }
q23867
train
function() { // Since window has its own native 'resize' event, return false so that // jQuery will bind the event using DOM methods. Since only 'window' // objects have a .setTimeout method, this should be a sufficient test. // Unless, of course, we're throttling the 're...
javascript
{ "resource": "" }
q23868
train
function() { // Since window has its own native 'resize' event, return false so that // jQuery will unbind the event using DOM methods. Since only 'window' // objects have a .setTimeout method, this should be a sufficient test. // Unless, of course, we're throttling the '...
javascript
{ "resource": "" }
q23869
new_handler
train
function new_handler(e, w, h) { var elem = $(this), data = $.data(this, str_data) || {}; // If called from the polling loop, w and h will be passed in as // arguments. If called manually, via .trigger( 'resize' ) or .resize(), // those...
javascript
{ "resource": "" }
q23870
train
function(modal, callback, redirect) { var originModal = modal; if($.isFunction(modal)) { var oldModal = redirect; redirect = callback; callback = modal; modal = oldModal; } modal = getModal(modal); if(modal && modal.length) { ...
javascript
{ "resource": "" }
q23871
train
function(element, options) { var that = this; that.name = NAME; that.$ = $(element); options = that.options = $.extend({trigger: 'contextmenu'}, ContextMenu.DEFAULTS, this.$.data(), options); var trigger = options.trigger; that.id = $.zui.uuid(); var eventHandl...
javascript
{ "resource": "" }
q23872
train
function () { if (document.body) { // make sure all resources are loaded on first activation if (!loaded) Live.loadresources(); Live.checkForChanges(); } setTimeout(Live.heartbeat, interval); }
javascript
{ "resource": "" }
q23873
train
function () { // helper method to assert if a given url is local function isLocal(url) { var loc = document.location, reg = new RegExp("^\\.|^\/(?!\/)|^[\\w]((?!://).)*$|" + loc.protocol + "//" + loc.host); return url.match(reg); } // gather all resources ...
javascript
{ "resource": "" }
q23874
isLocal
train
function isLocal(url) { var loc = document.location, reg = new RegExp("^\\.|^\/(?!\/)|^[\\w]((?!://).)*$|" + loc.protocol + "//" + loc.host); return url.match(reg); }
javascript
{ "resource": "" }
q23875
train
function () { for (var url in resources) { if (pendingRequests[url]) continue; Live.getHead(url, function (url, newInfo) { var oldInfo = resources[url], hasChanged = false; resources[url] = newInfo; for (var header in oldInfo) { ...
javascript
{ "resource": "" }
q23876
train
function (url, type) { switch (type.toLowerCase()) { // css files can be reloaded dynamically by replacing the link element case "text/css": var link = currentLinkElements[url], html = document.body.parentNode, head = link....
javascript
{ "resource": "" }
q23877
train
function () { var pending = 0; for (var url in oldLinkElements) { // if this sheet has any cssRules, delete the old link try { var link = currentLinkElements[url], oldLink = oldLinkElements[url], html = document.body.parentNode, she...
javascript
{ "resource": "" }
q23878
train
function (url, callback) { pendingRequests[url] = true; var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XmlHttp"); xhr.open("HEAD", url, true); xhr.onreadystatechange = function () { delete pendingRequests[url]; if (xhr.readyState == 4 ...
javascript
{ "resource": "" }
q23879
train
function(element, options) { var that = this; that.name = NAME; that.$ = $(element); that.options = $.extend({}, MarkDoc.DEFAULTS, this.$.data(), options); that.$.data('originContent', that.$.text()); that.render(); }
javascript
{ "resource": "" }
q23880
train
function(easeDecimal) { var animDecimal = (easeDecimal) ? easeDecimal : 1; this.clear(); // ZUI change begin var labelPositionMap; // ZUI change end helpers.each(this.segments, function(segment, index) { segment.transition({ ...
javascript
{ "resource": "" }
q23881
normalizeCaps
train
function normalizeCaps(settings) { var features = settings.required_features, caps = {}; function resolve(feature, value, strict) { // Feature notation is deprecated, use caps (this thing here is required for backward compatibility) var map = { chunks: 'slice_blob', jpgresize: 'send_binary_string', pngr...
javascript
{ "resource": "" }
q23882
train
function(str) { var xmlEncodeChars = {'<' : 'lt', '>' : 'gt', '&' : 'amp', '"' : 'quot', '\'' : '#39'}, xmlEncodeRegExp = /[<>&\"\']/g; return str ? ('' + str).replace(xmlEncodeRegExp, function(chr) { return xmlEncodeChars[chr] ? '&' + xmlEncodeChars[chr] + ';' : chr; }) : str; }
javascript
{ "resource": "" }
q23883
train
function(url, items) { var query = ''; plupload.each(items, function(value, name) { query += (query ? '&' : '') + encodeURIComponent(name) + '=' + encodeURIComponent(value); }); if (query) { url += (url.indexOf('?') > 0 ? '&' : '?') + query; } return url; }
javascript
{ "resource": "" }
q23884
train
function(size) { if (size === undef || /\D/.test(size)) { return plupload.translate('N/A'); } function round(num, precision) { return Math.round(num * Math.pow(10, precision)) / Math.pow(10, precision); } var boundary = Math.pow(1024, 4); // TB if (size > boundary) { return round(size / bound...
javascript
{ "resource": "" }
q23885
onBeforeUpload
train
function onBeforeUpload(up, file) { // Generate unique target filenames if (up.settings.unique_names) { var matches = file.name.match(/\.([^.]+)$/), ext = "part"; if (matches) { ext = matches[1]; } file.target_name = file.id + '.' + ext; } }
javascript
{ "resource": "" }
q23886
train
function(id) { var i; for (i = files.length - 1; i >= 0; i--) { if (files[i].id === id) { return files[i]; } } }
javascript
{ "resource": "" }
q23887
train
function(file) { var id = typeof(file) === 'string' ? file : file.id; for (var i = files.length - 1; i >= 0; i--) { if (files[i].id === id) { return this.splice(i, 1)[0]; } } }
javascript
{ "resource": "" }
q23888
train
function(start, length) { // Splice and trigger events var removed = files.splice(start === undef ? 0 : start, length === undef ? files.length : length); // if upload is in progress we need to stop it and restart after files are removed var restartRequired = false; if (this.state == plupload.STARTED) { ...
javascript
{ "resource": "" }
q23889
train
function(type) { var list, args, result; type = type.toLowerCase(); list = this.hasEventListener(type); if (list) { // sort event list by priority list.sort(function(a, b) { return b.priority - a.priority; }); // first argument should be current plupload.Uploader instance args = [].slice...
javascript
{ "resource": "" }
q23890
train
function() { var file = this.getSource().getSource(); return plupload.inArray(plupload.typeOf(file), ['blob', 'file']) !== -1 ? file : null; }
javascript
{ "resource": "" }
q23891
train
function(element, options) { this.name = name; this.$ = $(element); this.id = $.zui.uuid(); this.selectOrder = 1; this.selections = {}; this.getOptions(options); this._init(); }
javascript
{ "resource": "" }
q23892
getTagState
train
function getTagState(string) { for (let i = string.length - 1; i >= 0; i--) { const char = string[i]; if (char === '>') { return 0; } else if (char === '<') { return 1; } } return -1; }
javascript
{ "resource": "" }
q23893
unsafeHTMLDirective
train
function unsafeHTMLDirective(value) { return function(part) { if (!isNodePart(part)) { throw Error('The `unsafeHTML` directive can only be used in text nodes'); } part.setValue(`${unsafePrefixString}${value}`); }; }
javascript
{ "resource": "" }
q23894
reduce
train
function reduce(buffer, chunks, chunk, deep = false) { if (Buffer.isBuffer(chunk)) { return Buffer.concat([buffer, chunk], buffer.length + chunk.length); } else if (isTemplateResult(chunk)) { if (deep) { return reduce(buffer, chunks, chunk.read(deep), deep); } else { chunks.push(buffer, chun...
javascript
{ "resource": "" }
q23895
repeatDirective
train
function repeatDirective(items, keyFnOrTemplate, template) { if (template === undefined) { template = keyFnOrTemplate; } return function(part) { part.setValue(items.map((item, index) => template(item, index))); }; }
javascript
{ "resource": "" }
q23896
getTemplateResultChunk
train
function getTemplateResultChunk(result, stack) { let chunk = result.readChunk(); // Skip empty strings if (Buffer.isBuffer(chunk) && chunk.length === 0) { chunk = result.readChunk(); } // Finished reading, dispose if (chunk === null) { stack.shift(); } else if (isTemplateResult(chunk)) { // ...
javascript
{ "resource": "" }
q23897
classMapDirective
train
function classMapDirective(classInfo) { return function(part) { if (!isAttributePart(part) || part.name !== 'class') { throw Error('The `classMap` directive can only be used in the `class` attribute'); } let value = ''; for (const key in classInfo) { if (classInfo[key]) { value +...
javascript
{ "resource": "" }
q23898
ifDefinedDirective
train
function ifDefinedDirective(value) { return function(part) { if (value === undefined && isAttributePart(part)) { return part.setValue(nothingString); } part.setValue(value); }; }
javascript
{ "resource": "" }
q23899
resolveAttributeValue
train
function resolveAttributeValue(value, part) { if (isDirective(value)) { value = resolveDirectiveValue(value, part); } if (value === nothingString) { return value; } if (isTemplateResult(value)) { value = value.read(); } if (isPrimitive(value)) { const string = typeof value !== 'string' ...
javascript
{ "resource": "" }