_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q48800
getStreamStream
train
function getStreamStream (readable, file) { return () => { const counter = new stream.Transform() counter._transform = function (buf, enc, done) { file.length += buf.length this.push(buf) done() } readable.pipe(counter) return counter } }
javascript
{ "resource": "" }
q48801
doReconnect
train
function doReconnect() { // // Cleanup and recreate the socket associated // with this instance. // self.retry.waiting = true; self.socket.removeAllListeners(); self.socket = common.createSocket(self._options); // // Cleanup reconnect logic once the socket connects // self.socket.once('connect', function () { self.retry.waiting = false; self.retry.retries = 0; }); // // Attempt to reconnect the socket // self._setup(); self.connect(); }
javascript
{ "resource": "" }
q48802
tryReconnect
train
function tryReconnect() { self.retry.retries++; if (self.retry.retries >= self.retry.max) { return self.emit('error', new Error('Did not reconnect after maximum retries: ' + self.retry.max)); } doReconnect(); }
javascript
{ "resource": "" }
q48803
assert
train
function assert(expr) { if (expr) return; var stack = callsite(); var call = stack[1]; var file = call.getFileName(); var lineno = call.getLineNumber(); var src = fs.readFileSync(file, 'utf8'); var line = src.split('\n')[lineno-1]; var src = line.match(/assert\((.*)\)/)[1]; var err = new AssertionError({ message: src, stackStartFunction: stack[0].getFunction() }); throw err; }
javascript
{ "resource": "" }
q48804
add
train
function add(x, y) { var z = []; var n = Math.max(x.length, y.length); var carry = 0; var i = 0; while (i < n || carry) { var xi = i < x.length ? x[i] : 0; var yi = i < y.length ? y[i] : 0; var zi = carry + xi + yi; z.push(zi % 10); carry = Math.floor(zi / 10); i++; } return z; }
javascript
{ "resource": "" }
q48805
getPluginPath
train
function getPluginPath(rootPath, plugin) { // Check in project folder const pluginPath = path.join(rootPath, PROJECT_PLUGIN_FOLDER_NAME, `${plugin}.js`); if (fs.existsSync(pluginPath)) { return pluginPath; } // Check in src folder const srcPath = path.join(__dirname, BUILT_IN_PLUGIN_FOLDER_NAME, `${plugin}.js`); if (fs.existsSync(srcPath)) { return srcPath; } // Check in default folder const defaultPath = path.join(__dirname, BUILT_IN_DEFAULT_PLUGIN_FOLDER_NAME, `${plugin}.js`); if (fs.existsSync(defaultPath)) { return defaultPath; } return ''; }
javascript
{ "resource": "" }
q48806
findDefaultPlugins
train
function findDefaultPlugins() { const globPath = path.join(__dirname, BUILT_IN_DEFAULT_PLUGIN_FOLDER_NAME); if (!fs.existsSync(globPath)) { return []; } return walkSync(globPath, { directories: false, globs: [`${MARKBIND_PLUGIN_PREFIX}*.js`], }).map(file => path.parse(file).name); }
javascript
{ "resource": "" }
q48807
filterTags
train
function filterTags(tags, content) { if (!tags) { return content; } const $ = cheerio.load(content, { xmlMode: false }); const tagOperations = tags.map(tag => ({ // Trim leading + or -, replace * with .*, add ^ and $ tagExp: `^${escapeRegExp(tag.replace(/^(\+|-)/g, '')).replace(/\\\*/, '.*')}$`, // Whether it is makes tags visible or hides them isHidden: tag.startsWith('-'), })); $('[tags]').each((i, element) => { $(element).attr('hidden', true); $(element).attr('tags').split(' ').forEach((tag) => { tagOperations.forEach((tagOperation) => { if (!tag.match(tagOperation.tagExp)) { return; } if (tagOperation.isHidden) { $(element).attr('hidden', true); } else { $(element).removeAttr('hidden'); } }); }); }); $('[hidden]').remove(); return $.html(); }
javascript
{ "resource": "" }
q48808
rimraf
train
function rimraf(dirPath) { if (fs.existsSync(dirPath)) { fs.readdirSync(dirPath).forEach((entry) => { const entryPath = path.join(dirPath, entry); if (fs.lstatSync(entryPath).isDirectory()) { rimraf(entryPath); } else { fs.unlinkSync(entryPath); } }); fs.rmdirSync(dirPath); } }
javascript
{ "resource": "" }
q48809
createDir
train
function createDir(pathArg) { const { dir, ext } = path.parse(pathArg); const dirNames = (ext === '') ? pathArg.split(path.sep) : dir.split(pathArg.sep); dirNames.reduce((accumDir, currentdir) => { const jointDir = path.join(accumDir, currentdir); if (!fs.existsSync(jointDir)) { fs.mkdirSync(jointDir); } return jointDir; }, ''); }
javascript
{ "resource": "" }
q48810
copyDirSync
train
function copyDirSync(src, dest) { if (fs.lstatSync(src).isDirectory()) { const files = fs.readdirSync(src); files.forEach((file) => { const curSource = path.join(src, file); const curDest = path.join(dest, file); if (fs.lstatSync(curSource).isDirectory()) { if (!fs.existsSync(curDest)) { createDir(curDest); } copyDirSync(curSource, curDest); } else { copyFileSync(curSource, curDest); } }); } }
javascript
{ "resource": "" }
q48811
copyDirAsync
train
function copyDirAsync(src, dest) { if (fs.lstatSync(src).isDirectory()) { const files = fs.readdirSync(src); files.forEach((file) => { const curSource = path.join(src, file); const curDest = path.join(dest, file); if (fs.lstatSync(curSource).isDirectory()) { if (!fs.existsSync(curDest)) { createDir(curDest); } copyDirAsync(curSource, curDest); } else { fs.copyAsync(curSource, curDest); } }); } }
javascript
{ "resource": "" }
q48812
generateHeadingSelector
train
function generateHeadingSelector(headingIndexingLevel) { let headingsSelector = 'h1'; for (let i = 2; i <= headingIndexingLevel; i += 1) { headingsSelector += `, h${i}`; } return headingsSelector; }
javascript
{ "resource": "" }
q48813
Page
train
function Page(pageConfig) { this.asset = pageConfig.asset; this.baseUrl = pageConfig.baseUrl; this.baseUrlMap = pageConfig.baseUrlMap; this.content = pageConfig.content || ''; this.faviconUrl = pageConfig.faviconUrl; this.frontmatterOverride = pageConfig.frontmatter || {}; this.layout = pageConfig.layout; this.layoutsAssetPath = pageConfig.layoutsAssetPath; this.rootPath = pageConfig.rootPath; this.enableSearch = pageConfig.enableSearch; this.globalOverride = pageConfig.globalOverride; this.plugins = pageConfig.plugins; this.pluginsContext = pageConfig.pluginsContext; this.searchable = pageConfig.searchable; this.src = pageConfig.src; this.template = pageConfig.pageTemplate; this.title = pageConfig.title || ''; this.titlePrefix = pageConfig.titlePrefix; this.userDefinedVariablesMap = pageConfig.userDefinedVariablesMap; // the source file for rendering this page this.sourcePath = pageConfig.sourcePath; // the temp path for writing intermediate result this.tempPath = pageConfig.tempPath; // the output path of this page this.resultPath = pageConfig.resultPath; this.frontMatter = {}; this.headFileBottomContent = ''; this.headFileTopContent = ''; this.headings = {}; this.headingIndexingLevel = pageConfig.headingIndexingLevel; this.includedFiles = {}; this.keywords = {}; this.navigableHeadings = {}; this.pageSectionsHtml = {}; // Flag to indicate whether this page has a site nav this.hasSiteNav = false; }
javascript
{ "resource": "" }
q48814
generateHeadingSelector
train
function generateHeadingSelector(headingIndexingLevel) { let headingsSelectors = ['.always-index:header', 'h1']; for (let i = 2; i <= headingIndexingLevel; i += 1) { headingsSelectors.push(`h${i}`); } headingsSelectors = headingsSelectors.map(selector => `${selector}:not(.no-index)`); return headingsSelectors.join(','); }
javascript
{ "resource": "" }
q48815
getClosestHeading
train
function getClosestHeading($, headingsSelector, element) { const prevElements = $(element).prevAll(); for (let i = 0; i < prevElements.length; i += 1) { const currentElement = $(prevElements[i]); if (currentElement.is(headingsSelector)) { return currentElement; } const childHeadings = currentElement.find(headingsSelector); if (childHeadings.length > 0) { return childHeadings.last(); } } if ($(element).parent().length === 0) { return null; } return getClosestHeading($, headingsSelector, $(element).parent()); }
javascript
{ "resource": "" }
q48816
extractIncludeVariables
train
function extractIncludeVariables(includeElement, contextVariables) { const includedVariables = { ...contextVariables }; Object.keys(includeElement.attribs).forEach((attribute) => { if (!attribute.startsWith('var-')) { return; } const variableName = attribute.replace(/^var-/, ''); if (!includedVariables[variableName]) { includedVariables[variableName] = includeElement.attribs[attribute]; } }); if (includeElement.children) { includeElement.children.forEach((child) => { if (child.name !== 'variable' && child.name !== 'span') { return; } const variableName = child.attribs.name || child.attribs.id; if (!variableName) { // eslint-disable-next-line no-console console.warn(`Missing reference in ${includeElement.attribs[ATTRIB_CWF]}\n` + `Missing 'name' or 'id' in variable for ${includeElement.attribs.src} include.`); return; } if (!includedVariables[variableName]) { includedVariables[variableName] = cheerio.html(child.children); } }); } return includedVariables; }
javascript
{ "resource": "" }
q48817
extractPageVariables
train
function extractPageVariables(fileName, data, userDefinedVariables, includedVariables) { const $ = cheerio.load(data); const pageVariables = { }; $('variable').each(function () { const variableElement = $(this); const variableName = variableElement.attr('name'); if (!variableName) { // eslint-disable-next-line no-console console.warn(`Missing 'name' for variable in ${fileName}\n`); return; } if (!pageVariables[variableName]) { const variableValue = nunjucks.renderString(md.renderInline(variableElement.html()), { ...pageVariables, ...userDefinedVariables, ...includedVariables }); pageVariables[variableName] = variableValue; if (!VARIABLE_LOOKUP[fileName]) { VARIABLE_LOOKUP[fileName] = {}; } VARIABLE_LOOKUP[fileName][variableName] = variableValue; } }); return pageVariables; }
javascript
{ "resource": "" }
q48818
extractImportedVariables
train
function extractImportedVariables(context) { if (!context.importedVariables) { return {}; } const importedVariables = {}; Object.entries(context.importedVariables).forEach(([src, variables]) => { variables.forEach((variableName) => { const actualFilePath = utils.isUrl() ? src : path.resolve(path.dirname(context.cwf), decodeURIComponent(url.parse(src).path)); if (!VARIABLE_LOOKUP[actualFilePath] || !VARIABLE_LOOKUP[actualFilePath][variableName]) { // eslint-disable-next-line no-console console.warn(`Missing variable ${variableName} in ${src} referenced by ${context.cwf}\n`); return; } const variableValue = VARIABLE_LOOKUP[actualFilePath][variableName]; if (!importedVariables[variableName]) { importedVariables[variableName] = variableValue; } }); }); return importedVariables; }
javascript
{ "resource": "" }
q48819
encode
train
function encode(url) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { string: false, local: false }; var callback = arguments[2]; // eslint-disable-line if (_lodash2.default.isUndefined(url) || _lodash2.default.isNull(url) || !_lodash2.default.isString(url)) { return callback(new Error('URL is undefined or not properly formatted')); } if (options.local) { (0, _fs.readFile)(url, function (err, body) { if (err) { return callback(err); } /** * @todo Handle this better. */ var result = options.string ? body.toString('base64') : new Buffer(body, 'base64'); return callback(null, result); }); } else { (0, _request2.default)({ url: url, encoding: null }, function (err, response, body) { if (err) { return callback(err); } if (!body) { return callback(new Error('Error retrieving image - Empty Body!')); } if (body && response.statusCode === 200) { /** * @todo Handle this better. */ var result = options.string ? body.toString('base64') : new Buffer(body, 'base64'); return callback(null, result); } return callback(new Error('Error retrieving image - Status Code ' + response.statusCode)); }); } }
javascript
{ "resource": "" }
q48820
decode
train
function decode(imageBuffer) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { filename: 'saved-image' }; var callback = arguments[2]; // eslint-disable-line if (!_lodash2.default.isBuffer(imageBuffer)) { return callback(new Error('The image is not a Buffer object type')); } (0, _fs.writeFile)(options.filename + '.jpg', imageBuffer, 'base64', function (err) { if (err) { return callback(err); } return callback(null, 'Image saved successfully to disk!'); }); }
javascript
{ "resource": "" }
q48821
newDirectoryApi
train
function newDirectoryApi(input, opts, cb) { var fd = new FormData(), files = []; var iterate = function(entries, path, resolve) { var promises = []; entries.forEach(function(entry) { promises.push(new Promise(function(resolve) { if ("getFilesAndDirectories" in entry) { entry.getFilesAndDirectories().then(function(entries) { iterate(entries, entry.path + "/", resolve); }); } else { if (entry.name) { var p = (path + entry.name).replace(/^[/\\]/, ""); fd.append(opts.name, entry, p); files.push(p); } resolve(); } })); }); Promise.all(promises).then(resolve); }; input.getFilesAndDirectories().then(function(entries) { new Promise(function(resolve) { iterate(entries, "/", resolve); }).then(cb.bind(null, fd, files)); }); }
javascript
{ "resource": "" }
q48822
arrayApi
train
function arrayApi(input, opts, cb) { var fd = new FormData(), files = []; [].slice.call(input.files).forEach(function(file) { fd.append(opts.name, file, file.webkitRelativePath || file.name); files.push(file.webkitRelativePath || file.name); }); cb(fd, files); }
javascript
{ "resource": "" }
q48823
entriesApi
train
function entriesApi(items, opts, cb) { var fd = new FormData(), files = [], rootPromises = []; function readEntries(entry, reader, oldEntries, cb) { var dirReader = reader || entry.createReader(); dirReader.readEntries(function(entries) { var newEntries = oldEntries ? oldEntries.concat(entries) : entries; if (entries.length) { setTimeout(readEntries.bind(null, entry, dirReader, newEntries, cb), 0); } else { cb(newEntries); } }); } function readDirectory(entry, path, resolve) { if (!path) path = entry.name; readEntries(entry, 0, 0, function(entries) { var promises = []; entries.forEach(function(entry) { promises.push(new Promise(function(resolve) { if (entry.isFile) { entry.file(function(file) { var p = path + "/" + file.name; fd.append(opts.name, file, p); files.push(p); resolve(); }, resolve.bind()); } else readDirectory(entry, path + "/" + entry.name, resolve); })); }); Promise.all(promises).then(resolve.bind()); }); } [].slice.call(items).forEach(function(entry) { entry = entry.webkitGetAsEntry(); if (entry) { rootPromises.push(new Promise(function(resolve) { if (entry.isFile) { entry.file(function(file) { fd.append(opts.name, file, file.name); files.push(file.name); resolve(); }, resolve.bind()); } else if (entry.isDirectory) { readDirectory(entry, null, resolve); } })); } }); Promise.all(rootPromises).then(cb.bind(null, fd, files)); }
javascript
{ "resource": "" }
q48824
train
function(axis, theta) { var x, y, z, s, c, t, tx, ty; x = axis.x; y = axis.y; z = axis.z; s = Math.sin(theta); c = Math.cos(theta); t = 1 - c; tx = t * x; ty = t * y; _TEMP.set( tx * x + c, tx * y + s * z, tx * z - s * y, 0, tx * y - s * z, ty * y + c, ty * z + s * x, 0, tx * z + s * y, ty * z - s * x, t * z * z + c, 0, 0, 0, 0, 1 ); return this.multiplySelf(_TEMP); }
javascript
{ "resource": "" }
q48825
train
function(theta) { _TEMP.identity(); _TEMP.matrix[1][1] = _TEMP.matrix[2][2] = Math.cos(theta); _TEMP.matrix[2][1] = Math.sin(theta); _TEMP.matrix[1][2] = -_TEMP.matrix[2][1]; return this.multiplySelf(_TEMP); }
javascript
{ "resource": "" }
q48826
train
function(p) { var v = this.b.sub(this.a); var t = p.sub(this.a).dot(v) / v.magSquared(); // Check to see if t is beyond the extents of the line segment if (t < 0.0) { return this.a.copy(); } else if (t > 1.0) { return this.b.copy(); } // Return the point between 'a' and 'b' return this.a.add(v.scaleSelf(t)); }
javascript
{ "resource": "" }
q48827
train
function(obj_or_mesh,threeMaterials){ var toxiTriangleMesh; if(arguments.length == 1){ //it needs to be an param object toxiTriangleMesh = obj_or_mesh.geometry; threeMaterials = obj_or_mesh.materials; } else { toxiTriangleMesh = obj_or_mesh; } var threeMesh = this.createMesh(toxiTriangleMesh,threeMaterials); this.scene.add(threeMesh); return threeMesh; }
javascript
{ "resource": "" }
q48828
train
function(_p){ var v1 = _p.sub(this.a).normalize(), v2 = _p.sub(this.b).normalize(), v3 = _p.sub(this.c).normalize(), totalAngles = Math.acos(v1.dot(v2)); totalAngles += Math.acos(v2.dot(v3)); totalAngles += Math.acos(v3.dot(v1)); return (mathUtils.abs(totalAngles- mathUtils.TWO_PI) <= 0.01); }
javascript
{ "resource": "" }
q48829
train
function(list, q){ for(var i=0, l=list.length; i<l; i++){ if( list[i].equalsWitTolerance(q, 0.001) ){ return true; } } return false; }
javascript
{ "resource": "" }
q48830
train
function(iterator, shapeID, closed){ //if first param wasnt passed in as a pjs Iterator, make it one if(iterator.hasNext === undefined || iterator.next === undefined){ iterator = new this.app.ObjectIterator( iterator ); } this.gfx.beginShape(shapeID); for(var v = void(0); iterator.hasNext() && ((v = iterator.next()) || true);){ this.gfx.vertex(v.x,v.y); } /*var i=0, len = points.length; for(i=0;i<len;i++){ var v = points[i]; this.gfx.vertex(v.x,v.y); }*/ if(closed){ this.gfx.endShape(this.app.CLOSE); } else { this.gfx.endShape(); } }
javascript
{ "resource": "" }
q48831
train
function(tri,isFullShape){ var isTriangle = function(){ if(tri.a !== undefined && tri.b !== undefined && tri.c !== undefined){ return (tri.a.x !== undefined); } return false; }, isTriangle3D = function(){ if(isTriangle()){ return (tri.a.z !== undefined); } return false; }; if(isFullShape || isFullShape === undefined){ this.gfx.beginShape(this.app.TRIANGLES); } if(isTriangle3D()){ var n = tri.computeNormal(); this.gfx.normal(n.x,n.y,n.z); this.gfx.vertex(tri.a.x, tri.a.y, tri.a.z); this.gfx.vertex(tri.b.x, tri.b.y, tri.b.z); this.gfx.vertex(tri.c.x, tri.c.y, tri.c.z); } else { //should be Triangle2D this.gfx.vertex(tri.a.x,tri.a.y); this.gfx.vertex(tri.b.x,tri.b.y); this.gfx.vertex(tri.c.x,tri.c.y); } if(isFullShape || isFullShape === undefined){ this.gfx.endShape(); } }
javascript
{ "resource": "" }
q48832
train
function(a,b) { if( hasXY( a ) && hasXY( b ) ){ this.x = mathUtils.clip(this.x, a.x, b.x); this.y = mathUtils.clip(this.y, a.y, b.y); } else if( isRect( a ) ){ this.x = mathUtils.clip(this.x, a.x, a.x + a.width); this.y = mathUtils.clip(this.y, a.y, a.y + a.height); } return this; }
javascript
{ "resource": "" }
q48833
train
function() { var mag = this.x * this.x + this.y * this.y; if (mag > 0) { mag = 1.0 / Math.sqrt(mag); this.x *= mag; this.y *= mag; } return this; }
javascript
{ "resource": "" }
q48834
train
function(theta) { var co = Math.cos(theta); var si = Math.sin(theta); var xx = co * this.x - si * this.y; this.y = si * this.x + co * this.y; this.x = xx; return this; }
javascript
{ "resource": "" }
q48835
train
function(box_or_min, max){ var min; if( is.AABB( box_or_min ) ){ max = box_or_min.getMax(); min = box_or_min.getMin(); } else { min = box_or_min; } this.x = mathUtils.clip(this.x, min.x, max.x); this.y = mathUtils.clip(this.y, min.y, max.y); this.z = mathUtils.clip(this.z, min.z, max.z); return this; }
javascript
{ "resource": "" }
q48836
train
function(vec){ var cx = this.y * vec.z - vec.y * this.z; var cy = this.z * vec.x - vec.z * this.x; this.z = this.x * vec.y - vec.x * this.y; this.y = cy; this.x = cx; return this; }
javascript
{ "resource": "" }
q48837
train
function(vec_axis,theta){ var ax = vec_axis.x, ay = vec_axis.y, az = vec_axis.z, ux = ax * this.x, uy = ax * this.y, uz = ax * this.z, vx = ay * this.x, vy = ay * this.y, vz = ay * this.z, wx = az * this.x, wy = az * this.y, wz = az * this.z, si = Math.sin(theta), co = Math.cos(theta); var xx = (ax * (ux + vy + wz) + (this.x * (ay * ay + az * az) - ax * (vy + wz)) * co + (-wy + vz) * si); var yy = (ay * (ux + vy + wz) + (this.y * (ax * ax + az * az) - ay * (ux + wz)) * co + (wx - uz) * si); var zz = (az * (ux + vy + wz) + (this.z * (ax * ax + ay * ay) - az * (ux + vy)) * co + (-vx + uy) * si); this.x = xx; this.y = yy; this.z = zz; return this; }
javascript
{ "resource": "" }
q48838
train
function(theta){ var co = Math.cos(theta); var si = Math.sin(theta); var zz = co *this.z - si * this.y; this.y = si * this.z + co * this.y; this.z = zz; return this; }
javascript
{ "resource": "" }
q48839
train
function() { if (Math.abs(this.x) < 0.5) { this.x = 0; } else { this.x = this.x < 0 ? -1 : 1; this.y = this.z = 0; } if (Math.abs(this.y) < 0.5) { this.y = 0; } else { this.y = this.y < 0 ? -1 : 1; this.x = this.z = 0; } if (Math.abs(this.z) < 0.5) { this.z = 0; } else { this.z = this.z < 0 ? -1 : 1; this.x = this.y = 0; } return this; }
javascript
{ "resource": "" }
q48840
train
function( t ){ var idx; if( this.colors.size() > 2 ){ idx = Math.floor( this.map.getClippedValueFor(t) + 0.5 ); } else { idx = t >= this.map.getInputMedian() ? 1 : 0; } return this.colors.get(idx); }
javascript
{ "resource": "" }
q48841
train
function( src, pixels, offset ){ if( typeof offset !== 'number'){ offset = 0; } else if ( offset < 0 ){ throw new Error("offset into target pixel array is negative"); } pixels = pixels || new Array(src.length); for(var i=0, l=src.length; i<l; i++){ pixels[offset++] = this.getToneFor(src[i]).toARGB(); } return pixels; }
javascript
{ "resource": "" }
q48842
train
function( list, q ){ for( var i=0, l=list.length; i<l; i++){ if( list[i].equalsWithTolerance(q, 0.0001) ){ return true; } } return false; }
javascript
{ "resource": "" }
q48843
train
function(freq){ if(freq === undefined)freq = 0; this.phase = (this.phase + freq) % AbstractWave.TWO_PI; if(this.phase < 0){ this.phase += AbstractWave.TWO_PI; } return this.phase; }
javascript
{ "resource": "" }
q48844
paramThreeToGL
train
function paramThreeToGL ( p ) { if ( p === THREE.RepeatWrapping ) return _gl.REPEAT; if ( p === THREE.ClampToEdgeWrapping ) return _gl.CLAMP_TO_EDGE; if ( p === THREE.MirroredRepeatWrapping ) return _gl.MIRRORED_REPEAT; if ( p === THREE.NearestFilter ) return _gl.NEAREST; if ( p === THREE.NearestMipMapNearestFilter ) return _gl.NEAREST_MIPMAP_NEAREST; if ( p === THREE.NearestMipMapLinearFilter ) return _gl.NEAREST_MIPMAP_LINEAR; if ( p === THREE.LinearFilter ) return _gl.LINEAR; if ( p === THREE.LinearMipMapNearestFilter ) return _gl.LINEAR_MIPMAP_NEAREST; if ( p === THREE.LinearMipMapLinearFilter ) return _gl.LINEAR_MIPMAP_LINEAR; if ( p === THREE.UnsignedByteType ) return _gl.UNSIGNED_BYTE; if ( p === THREE.UnsignedShort4444Type ) return _gl.UNSIGNED_SHORT_4_4_4_4; if ( p === THREE.UnsignedShort5551Type ) return _gl.UNSIGNED_SHORT_5_5_5_1; if ( p === THREE.UnsignedShort565Type ) return _gl.UNSIGNED_SHORT_5_6_5; if ( p === THREE.ByteType ) return _gl.BYTE; if ( p === THREE.ShortType ) return _gl.SHORT; if ( p === THREE.UnsignedShortType ) return _gl.UNSIGNED_SHORT; if ( p === THREE.IntType ) return _gl.INT; if ( p === THREE.UnsignedIntType ) return _gl.UNSIGNED_INT; if ( p === THREE.FloatType ) return _gl.FLOAT; if ( p === THREE.AlphaFormat ) return _gl.ALPHA; if ( p === THREE.RGBFormat ) return _gl.RGB; if ( p === THREE.RGBAFormat ) return _gl.RGBA; if ( p === THREE.LuminanceFormat ) return _gl.LUMINANCE; if ( p === THREE.LuminanceAlphaFormat ) return _gl.LUMINANCE_ALPHA; if ( p === THREE.AddEquation ) return _gl.FUNC_ADD; if ( p === THREE.SubtractEquation ) return _gl.FUNC_SUBTRACT; if ( p === THREE.ReverseSubtractEquation ) return _gl.FUNC_REVERSE_SUBTRACT; if ( p === THREE.ZeroFactor ) return _gl.ZERO; if ( p === THREE.OneFactor ) return _gl.ONE; if ( p === THREE.SrcColorFactor ) return _gl.SRC_COLOR; if ( p === THREE.OneMinusSrcColorFactor ) return _gl.ONE_MINUS_SRC_COLOR; if ( p === THREE.SrcAlphaFactor ) return _gl.SRC_ALPHA; if ( p === THREE.OneMinusSrcAlphaFactor ) return _gl.ONE_MINUS_SRC_ALPHA; if ( p === THREE.DstAlphaFactor ) return _gl.DST_ALPHA; if ( p === THREE.OneMinusDstAlphaFactor ) return _gl.ONE_MINUS_DST_ALPHA; if ( p === THREE.DstColorFactor ) return _gl.DST_COLOR; if ( p === THREE.OneMinusDstColorFactor ) return _gl.ONE_MINUS_DST_COLOR; if ( p === THREE.SrcAlphaSaturateFactor ) return _gl.SRC_ALPHA_SATURATE; return 0; }
javascript
{ "resource": "" }
q48845
prepare
train
function prepare( vector ) { var vertex = vector.normalize().clone(); vertex.index = that.vertices.push( vertex ) - 1; // Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle. var u = azimuth( vector ) / 2 / Math.PI + 0.5; var v = inclination( vector ) / Math.PI + 0.5; vertex.uv = new THREE.UV( u, 1 - v ); return vertex; }
javascript
{ "resource": "" }
q48846
visible
train
function visible( face, vertex ) { var va = vertices[ face[ 0 ] ]; var vb = vertices[ face[ 1 ] ]; var vc = vertices[ face[ 2 ] ]; var n = normal( va, vb, vc ); // distance from face to origin var dist = n.dot( va ); return n.dot( vertex ) >= dist; }
javascript
{ "resource": "" }
q48847
train
function() { var newSel = []; var vertices = this.mesh.getVertices(); var l = vertices.length; for (var i=0;i<l;i++) { var v = vertices[i]; if (this.selection.indexOf(v) < 0 ) { newSel.push(v); } } this.selection = newSel; return this; }
javascript
{ "resource": "" }
q48848
train
function(points) { var l = points.length; for (var i=0;i<l;i++) { var v = points[i]; this.selection.push( this.mesh.getClosestVertexToPoint(v) ); } return this; }
javascript
{ "resource": "" }
q48849
train
function(sel2) { this.checkMeshIdentity(sel2.getMesh()); var removeThese = sel2.getSelection(); var i,l = removeThese.length; for ( i=0; i<l; i++ ) { this.selection.splice( this.selection.indexOf(removeThese[i]), 1 ); } return this; }
javascript
{ "resource": "" }
q48850
train
function( rc ){ if( is.ColorRange(rc) ){ addAll(this.hueConstraint, rc.hueConstraint); addAll(this.saturationConstraint, rc.saturationConstraint); addAll(this.brightnessConstraint, rc.brightnessConstraint); addAll(this.alphaConstraint, rc.alphaConstraint); this.black.min = Math.min( this.black.min, rc.black.min ); this.black.max = Math.max( this.black.max, rc.black.max ); this.white.min = Math.min( this.white.min, rc.white.min ); this.white.max = Math.max( this.white.max, rc.white.max ); } else { this.hueConstraint.push( new FloatRange(rc.hue(),rc.hue()) ); this.saturationConstraint.push( new FloatRange(rc.saturation(),rc.saturation()) ); this.brightnessConstraint.push( new FloatRange(rc.brightness(),rc.brightness()) ); this.alphaConstraint.push( new FloatRange(rc.alpha(),rc.alpha()) ); } return this; }
javascript
{ "resource": "" }
q48851
train
function( c ){ var isInRange = this.isValueInConstraint(c.hue(), this.hueConstraint); isInRange &= this.isValueInConstraint(c.saturation(), this.saturationConstraint); isInRange &= this.isValueInConstraint(c.brightness(), this.brightnessConstraint); isInRange &= this.isValueInConstraint(c.alpha(), this.alphaConstraint); return isInRange || false; //if its 0, return false }
javascript
{ "resource": "" }
q48852
train
function( c, num, variance ){ if( arguments.length < 3 ){ variance = ColorRange.DEFAULT_VARIANCE; } if( arguments.length === 1 ){ num = c; c = undefined; } var list = new ColorList(); for( var i=0; i<num; i++){ list.add(this.getColor(c, variance)); } return list; }
javascript
{ "resource": "" }
q48853
train
function(min, max){ min = min || 0.0; max = typeof max === 'number' ? max : 1.0; // swap if necessary if(min > max){ var t= max; max = min; min = t; } this.min = min; this.max = max; this.currValue = min; }
javascript
{ "resource": "" }
q48854
train
function(a,b,c,n,uvA,uvB,uvC){ //can be 3 args, 4 args, 6 args, or 7 args //if it was 6 swap vars around, if( arguments.length == 6 ){ uvC = uvB; uvB = uvA; uvA = n; n = undefined; } //7 param method var va = this.__checkVertex(a); var vb = this.__checkVertex(b); var vc = this.__checkVertex(c); if(va.id === vb.id || va.id === vc.id || vb.id === vc.id){ //console.log("ignoring invalid face: "+a + ", " +b+ ", "+c); } else { if(n != null ){ var nc = va.sub(vc).crossSelf(va.sub(vb)); if(n.dot(nc)<0){ var t = va; va = vb; vb = t; } } var f = new Face(va,vb,vc,uvA,uvB,uvC); this.faces.push(f); } return this; }
javascript
{ "resource": "" }
q48855
train
function(m){ var l = m.getFaces().length; for(var i=0;i<l;i++){ var f = m.getFaces()[i]; this.addFace(f.a,f.b,f.c); } return this; }
javascript
{ "resource": "" }
q48856
train
function(array) { array = array || []; var i = 0; var l = this.vertices.length; for (var j=0;j<l;j++) { var v = this.vertices[j]; array[i++] = v.x; array[i++] = v.y; array[i++] = v.z; } return array; }
javascript
{ "resource": "" }
q48857
train
function(array){ array = array || []; var n = 0; for(i=0; i<this.vertices.length; i++){ var v = this.vertices[i]; array[n++] = v.normal.x; array[n++] = v.normal.y; array[n++] = v.normal.z; } return array; }
javascript
{ "resource": "" }
q48858
train
function(array){ array = array || []; var i = 0; for(f=0; f<this.faces.length; f++){ var face = this.faces[f]; array[i++] = face.uvA ? face.uvA.x : 0; array[i++] = face.uvA ? face.uvA.y : 0; array[i++] = face.uvB ? face.uvB.x : 0; array[i++] = face.uvB ? face.uvB.y : 0; array[i++] = face.uvC ? face.uvC.x : 0; array[i++] = face.uvC ? face.uvC.y : 0; } return array; }
javascript
{ "resource": "" }
q48859
train
function(vec) { var matchedVertex = -1; var l = this.vertices.length; for(var i=0;i<l;i++) { var vert = this.vertices[i]; if(vert.equals(vec)) { matchedVertex =i; } } return matchedVertex; }
javascript
{ "resource": "" }
q48860
train
function(dir, forward) { forward = forward || Vec3D.Z_AXIS; return this.transform( Quaternion.getAlignmentQuat(dir, forward).toMatrix4x4(this.matrix), true); }
javascript
{ "resource": "" }
q48861
train
function(mat,updateNormals) { if(updateNormals === undefined){ updateNormals = true; } var l = this.vertices.length; for(var i=0;i<l;i++){ var v = this.vertices[i]; v.set(mat.applyTo(v)); } if(updateNormals){ this.computeFaceNormals(); } return this; }
javascript
{ "resource": "" }
q48862
train
function(elevation){ if(this.__elevationLength == elevation.length){ for(var i = 0, len = elevation.length; i<len; i++){ this.vertices[i].y = this.elevation[i] = elevation[i]; } } else { throw new Error("the given elevation array size does not match terrain"); } return this; }
javascript
{ "resource": "" }
q48863
train
function(x,z,h){ var index = this._getIndex(x,z); this.elevation[index] = h; this.vertices[index].y = h; return this; }
javascript
{ "resource": "" }
q48864
train
function( theta, contrast ){ this.contrast = typeof contrast === 'number' ? contrast : 0.25; this.theta = MathUtils.radians( typeof theta === 'number' ? theta : 10 ); }
javascript
{ "resource": "" }
q48865
train
function(a,b,c) { var opts = { mesh: undefined, steps: 12, thetaOffset: 0 }; if(arguments.length == 1 && typeof arguments[0] == 'object'){ //options object for(var prop in arguments[0]){ opts[prop] = arguments[0][prop]; } } else if(arguments.length == 2){ opts.steps = arguments[0]; opts.thetaOffset = arguments[1]; } var cone = new Cone(this.pos,this.getMajorAxis().getVector(), this.radius, this.radius, this.length); return cone.toMesh(opts.mesh,opts.steps,opts.thetaOffset,true,true); }
javascript
{ "resource": "" }
q48866
train
function(theta) { while (theta < 0) { theta += mathUtils.TWO_PI; } return this.sinLUT[((theta * this.rad2deg) + this.quadrant) % this.period]; }
javascript
{ "resource": "" }
q48867
train
function( x, y, z ){ if( hasXYZ( x ) ){ //it was 1 param, it was a vector or object this.vertices.push( new Vec3D(x) ); } else { this.vertices.push( new Vec3D(x,y,z) ); } return this; }
javascript
{ "resource": "" }
q48868
train
function( step, doAddFinalVertex ){ if( doAddFinalVertex !== false ){ doAddFinalVertex = true; } var uniform = []; if( this.vertices.length < 3 ){ if( this.vertices.length === 2 ){ new Line3D( this.vertices[0], this.vertices[1]) .splitIntoSegments( uniform, step, true ); if( !doAddFinalVertex ){ uniform.pop(); } } else { return; } } var arcLen = this.getEstimatedArcLength(), delta = step / arcLen, currIdx = 0, currT, t, p, q, frac, i; for( t = 0; t<1.0; t+=delta ){ currT = t * arcLen; while( currT >= this.arcLenIndex[currIdx] ){ currIdx++; } p = this.get(currIdx-1); q = this.get(currIdx); frac = ((currT-this.arcLenIndex[currIdx-1]) / (this.arcLenIndex[currIdx] - this.arcLenIndex[currIdx-1]) ); i = p.interpolateTo( q, frac ); uniform.push( i ); } if( doAddFinalVertex ){ uniform.push( this.get(-1).copy() ); } return uniform; }
javascript
{ "resource": "" }
q48869
train
function(p,phi,theta) { var r = 0; r += Math.pow(mathUtils.sin(this.m[0] * theta), this.m[1]); r += Math.pow(mathUtils.cos(this.m[2] * theta), this.m[3]); r += Math.pow(mathUtils.sin(this.m[4] * phi), this.m[5]); r += Math.pow(mathUtils.cos(this.m[6] * phi), this.m[7]); var sinTheta = mathUtils.sin(theta); p.x = r * sinTheta * mathUtils.cos(phi); p.y = r * mathUtils.cos(theta); p.z = r * sinTheta * mathUtils.sin(phi); return p; }
javascript
{ "resource": "" }
q48870
train
function(h, s, v) { return this.setHSV([ this.hsv[0] + h, this.hsv[1] + s, this.hsv[2] + v ]); }
javascript
{ "resource": "" }
q48871
train
function(r, g,b) { return this.setRGB([this.rgb[0] + r, this.rgb[1] + g, this.rgb[2] + b]); }
javascript
{ "resource": "" }
q48872
train
function(c, t) { if(t === undefined) { t = 0.5; } var crgb = c.toRGBAArray(); this.rgb[0] += (crgb[0] - this.rgb[0]) * t; this.rgb[1] += (crgb[1] - this.rgb[1]) * t; this.rgb[2] += (crgb[2] - this.rgb[2]) * t; this._alpha += (c._alpha - this._alpha) * t; return this.setRGB(this.rgb); }
javascript
{ "resource": "" }
q48873
train
function(rgba, offset) { rgba = rgba || []; offset = offset || 0; rgba[offset++] = this.rgb[0]; rgba[offset++] = this.rgb[1]; rgba[offset++] = this.rgb[2]; rgba[offset] = this._alpha; return rgba; }
javascript
{ "resource": "" }
q48874
train
function(color){ for( var i=0, l= this.colors.length; i<l; i++){ if( this.colors[i].equals( color ) ){ return true; } } return false; }
javascript
{ "resource": "" }
q48875
train
function(){ var r = 0, g = 0, b = 0, a = 0; this.each(function(c){ r += c.rgb[0]; g += c.rgb[1]; b += c.rgb[2]; a += c.alpha(); }); var num = this.colors.length; if(num > 0){ return TColor.newRGBA(r / num, g / num, b / num, a / num); } return undefined; }
javascript
{ "resource": "" }
q48876
train
function(){ var darkest, minBrightness = Number.MAX_VALUE; this.each(function(c){ var luma = c.luminance(); if(luma < minBrightness){ darkest = c; minBrightness = luma; } }); return darkest; }
javascript
{ "resource": "" }
q48877
train
function(comp, isReversed){ //if a normal ( a, b ) sort function instead of an AccessCriteria, //wrap it so it can be invoked the same if( typeof comp === 'function' && typeof comp.compare === 'undefined' ){ comp = { compare: comp }; } this.colors.sort( comp.compare ); if(isReversed){ this.colors.reverse(); } return this; }
javascript
{ "resource": "" }
q48878
train
function(proxy, isReversed){ if(arguments.length === 1){ isReversed = arguments[0]; proxy = new HSVDistanceProxy(); } if(this.colors.length === 0){ return this; } // Remove the darkest color from the stack, // put it in the sorted list as starting element. var root = this.getDarkest(), stack = this.colors.slice(0), sorted = []; stack.splice(stack.indexOf(root),1); sorted.push(root); // Now find the color in the stack closest to that color. // Take this color from the stack and add it to the sorted list. // Now find the color closest to that color, etc. var sortedCount = 0; while(stack.length > 1){ var closest = stack[0], lastSorted = sorted[sortedCount], distance = proxy.distanceBetween(closest, lastSorted); for(var i = stack.length - 1; i >= 0; i--){ var c = stack[i], d = proxy.distanceBetween(c, lastSorted); if(d < distance){ closest = c; distance = d; } } stack.splice(stack.indexOf(closest),1); sorted.push(closest); sortedCount++; } sorted.push(stack[0]); if(isReversed){ sorted.reverse(); } this.colors = sorted; return this; }
javascript
{ "resource": "" }
q48879
train
function(g, x, y, z, w) { var n = g[0] * x + g[1] * y; if(z){ n += g[2] * z; if(w){ n += g[3] * w; } } return n; }
javascript
{ "resource": "" }
q48880
make
train
function make( type, setters ){ var name = type + 'Accessor', arry = type.toLowerCase(); //make HSV hsv etc exports[name] = function( comp ){ this.component = comp; //compare() could easily be used in incorrect scope, bind it this.compare = bind( this.compare, this ); }; exports[name].prototype.compare = function( a, b ){ var ca = a[arry][this.component], cb = b[arry][this.component]; return numberComparator( ca, cb ); }; exports[name].prototype.getComponentValueFor = function( col ){ return col[arry][this.component]; }; exports[name].prototype.setComponentValueFor = function( col, val ){ col[ 'set'+setters[this.component] ]( val ); }; }
javascript
{ "resource": "" }
q48881
train
function(theta_p,theta){ if(arguments.length > 1){ this.theta = theta; this.rootPos = new Vec2D(theta_p); } else { this.rootPos = new Vec2D(); this.theta = theta_p; } //due to lack-of int/float types, no support of theta in degrees }
javascript
{ "resource": "" }
q48882
train
function( origin ){ var centroid = this.getCentroid(); var delta = origin !== undefined ? origin.sub( centroid ) : centroid.invert(); for( var i=0, l = this.vertices.length; i<l; i++){ this.vertices[i].addSelf( delta ); } return this; }
javascript
{ "resource": "" }
q48883
train
function( count ){ var num = this.vertices.length, longestID = 0, maxD = 0, i = 0, d, m; while( num < count ){ //find longest edge longestID = 0; maxD = 0; for( i=0; i<num; i++ ){ d = this.vertices[i].distanceToSquared( this.vertices[ (i+1) % num ] ); if( d > maxD ){ longestID = i; maxD = d; } } //insert mid point of longest segment m = this.vertices[longestID] .add(this.vertices[(longestID + 1) % num]) .scaleSelf(0.5); //push this into the array inbetween the 2 points this.vertices.splice( longestID+1, 0, m ); num++; } return this; }
javascript
{ "resource": "" }
q48884
train
function(){ var isPositive = false, num = this.vertices.length, prev, next, d0, d1, newIsP; for( var i = 0; i < num; i++ ){ prev = (i===0) ? num -1 : i - 1; next = (i===num-1) ? 0 : i + 1; d0 = this.vertices[i].sub(this.vertices[prev]); d1 = this.vertices[next].sub(this.vertices[i]); newIsP = (d0.cross(d1) > 0); if( i === 0 ) { isPositive = true; } else if( isPositive != newIsP ) { return false; } } return true; }
javascript
{ "resource": "" }
q48885
train
function( x1, y1, x2, y2, x3, y3, distance, out ){ var c1 = x2, d1 = y2, c2 = x2, d2 = y2; var dx1, dy1, dist1, dx2, dy2, dist2, insetX, insetY; dx1 = x2-x1; dy1 = y2-y1; dist1 = Math.sqrt(dx1*dx1 + dy1*dy1); dx2 = x3-x2; dy2 = y3-y2; dist2 = Math.sqrt(dx2*dx2 + dy2*dy2); if( dist1 < MathUtils.EPS || dist2 < MathUtils.EPS ){ return; } dist1 = distance / dist1; dist2 = distance / dist2; insetX = dy1 * dist1; insetY = -dx1 * dist1; x1 += insetX; c1 += insetX; y1 += insetY; d1 += insetY; insetX = dy2 * dist2; insetY = -dx2 * dist2; x3 += insetX; c2 += insetX; y3 += insetY; d2 += insetY; if( c1 === c2 && d1 === d2 ){ out.set(c1,d1); return; } var l1 = new Line2D( new Vec2D(x1,y1), new Vec2D(c1,d1) ), l2 = new Line2D( new Vec2D(c2,d2), new Vec2D(x3,y3) ), isec = l1.intersectLine(l2), ipos = isec.getPos(); if( ipos !== null || ipos !== undefined ){ out.set(ipos); } }
javascript
{ "resource": "" }
q48886
train
function( minEdgeLen ){ minEdgeLen *= minEdgeLen; var vs = this.vertices, reduced = [], prev = vs[0], num = vs.length - 1, vec; reduced.push(prev); for( var i = 0; i < num; i++ ){ vec = vs[i]; if( prev.distanceToSquared(vec) >= minEdgeLen ){ reduced.push(vec); prev = vec; } } if( vs[0].distanceToSquared(vs[num]) >= minEdgeLen ){ reduced.push(vs[num]); } this.vertices = reduced; return this; }
javascript
{ "resource": "" }
q48887
train
function( tolerance ){ //if tolerance is 0, it will be faster to just use 'equals' method var equals = tolerance ? 'equalsWithTolerance' : 'equals'; var p, prev, i = 0, num = this.vertices.length; var last; for( ; i<num; i++ ){ p = this.vertices[i]; //if its the 'equals' method tolerance will just be ingored if( p[equals]( prev, tolerance ) ){ //remove from array, step back counter this.vertices.splice( i, 1 ); i--; num--; } else { prev = p; } } num = this.vertices.length; if( num > 0 ){ last = this.vertices[num-1]; if( last[equals]( this.vertices[0], tolerance ) ){ this.vertices.splice( num-1, 1 ); } } return this; }
javascript
{ "resource": "" }
q48888
train
function(val) { var t = ((val - this._in.min) / this._interval); return this.mapFunction.interpolate(0, this.mapRange, t) + this._out.min; }
javascript
{ "resource": "" }
q48889
onPlayChange
train
function onPlayChange() { if (paused !== media.paused) { paused = media.paused; $(self.play, { 'aria-label': paused ? lang.play || 'play' : lang.pause || 'pause' }); $(self.playSymbol, { 'aria-hidden': !paused }); $(self.pauseSymbol, { 'aria-hidden': paused }); clearInterval(interval); if (!paused) { // listen for time changes every 30th of a second interval = setInterval(onTimeChange, 34); } // dispatch new "playchange" event dispatchCustomEvent(media, 'playchange'); } }
javascript
{ "resource": "" }
q48890
onTimeChange
train
function onTimeChange() { if (currentTime !== media.currentTime || duration !== media.duration) { currentTime = media.currentTime; duration = media.duration || 0; const currentTimePercentage = currentTime / duration; const currentTimeCode = timeToTimecode(currentTime); const remainingTimeCode = timeToTimecode(duration - Math.floor(currentTime)); if (currentTimeCode !== self.currentTimeText.nodeValue) { self.currentTimeText.nodeValue = currentTimeCode; $(self.currentTime, { title: `${timeToAural(currentTime, lang.minutes || 'minutes', lang.seconds || 'seconds')}` }); } if (remainingTimeCode !== self.remainingTimeText.nodeValue) { self.remainingTimeText.nodeValue = remainingTimeCode; $(self.remainingTime, { title: `${timeToAural(duration - currentTime, lang.minutes || 'minutes', lang.seconds || 'seconds')}` }); } $(self.time, { 'aria-valuenow': currentTime, 'aria-valuemin': 0, 'aria-valuemax': duration }); const dirIsInline = /^(ltr|rtl)$/i.test(timeDir); const axisProp = dirIsInline ? 'width' : 'height'; self.timeMeter.style[axisProp] = `${currentTimePercentage * 100}%`; // dispatch new "timechange" event dispatchCustomEvent(media, 'timechange'); } }
javascript
{ "resource": "" }
q48891
onLoadStart
train
function onLoadStart() { media.removeEventListener('canplaythrough', onCanPlayStart); $(media, { canplaythrough: onCanPlayStart }); $(self.download, { href: media.src, download: media.src }); onPlayChange(); onVolumeChange(); onFullscreenChange(); onTimeChange(); }
javascript
{ "resource": "" }
q48892
onCanPlayStart
train
function onCanPlayStart() { media.removeEventListener('canplaythrough', onCanPlayStart); // dispatch new "canplaystart" event dispatchCustomEvent(media, 'canplaystart'); if (!paused || media.autoplay) { media.play(); } }
javascript
{ "resource": "" }
q48893
onVolumeChange
train
function onVolumeChange() { const volumePercentage = media.muted ? 0 : media.volume; const isMuted = !volumePercentage; $(self.volume, { 'aria-valuenow': volumePercentage, 'aria-valuemin': 0, 'aria-valuemax': 1 }); const dirIsInline = /^(ltr|rtl)$/i.test(volumeDir); const axisProp = dirIsInline ? 'width' : 'height'; self.volumeMeter.style[axisProp] = `${volumePercentage * 100}%`; $(self.mute, { 'aria-label': isMuted ? lang.unmute || 'unmute' : lang.mute || 'mute' }); $(self.muteSymbol, { 'aria-hidden': isMuted }); $(self.unmuteSymbol, { 'aria-hidden': !isMuted }); }
javascript
{ "resource": "" }
q48894
onDownloadClick
train
function onDownloadClick() { const a = document.head.appendChild($('a', { download: '', href: media.src })); a.click(); document.head.removeChild(a); }
javascript
{ "resource": "" }
q48895
onFullscreenClick
train
function onFullscreenClick() { if (requestFullscreen) { if (player === fullscreenElement()) { // exit fullscreen exitFullscreen().call(document); } else { // enter fullscreen requestFullscreen.call(player); // maintain focus in internet explorer self.fullscreen.focus(); // maintain focus in safari setTimeout(() => { self.fullscreen.focus(); }, 200); } } else if (media.webkitSupportsFullscreen) { // iOS allows fullscreen of the video itself if (media.webkitDisplayingFullscreen) { // exit ios fullscreen media.webkitExitFullscreen(); } else { // enter ios fullscreen media.webkitEnterFullscreen(); } onFullscreenChange(); } }
javascript
{ "resource": "" }
q48896
onTimeKeydown
train
function onTimeKeydown(event) { const { keyCode, shiftKey } = event; // 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN if (37 <= keyCode && 40 >= keyCode) { event.preventDefault(); const isLTR = /^(btt|ltr)$/.test(timeDir); const offset = 37 === keyCode || 39 === keyCode ? keyCode - 38 : keyCode - 39; media.currentTime = Math.max(0, Math.min(duration, currentTime + offset * (isLTR ? 1 : -1) * (shiftKey ? 10 : 1))); onTimeChange(); } }
javascript
{ "resource": "" }
q48897
onVolumeKeydown
train
function onVolumeKeydown(event) { const { keyCode, shiftKey } = event; // 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN if (37 <= keyCode && 40 >= keyCode) { event.preventDefault(); const isLTR = /^(btt|ltr)$/.test(volumeDir); const offset = 37 === keyCode || 39 === keyCode ? keyCode - 38 : isLTR ? 39 - keyCode : keyCode - 39; media.volume = Math.max(0, Math.min(1, media.volume + offset * (isLTR ? 0.1 : -0.1) * (shiftKey ? 1 : 0.2))); } }
javascript
{ "resource": "" }
q48898
createBindingsTag
train
function createBindingsTag(sourceNode, bindingsSelector) { if (!bindingsSelector) return sourceNode return { ...sourceNode, // inject the selector bindings into the node attributes attributes: [{ name: bindingsSelector }, ...getNodeAttributes(sourceNode)] } }
javascript
{ "resource": "" }
q48899
createTagWithBindings
train
function createTagWithBindings(sourceNode, sourceFile, sourceCode) { const bindingsSelector = isRootNode(sourceNode) ? null : createBindingSelector() const cloneNode = createBindingsTag(sourceNode, bindingsSelector) const tagOpeningHTML = nodeToString(cloneNode) switch(true) { // EACH bindings have prio 1 case hasEachAttribute(cloneNode): return [tagOpeningHTML, [eachBinding(cloneNode, bindingsSelector, sourceFile, sourceCode)]] // IF bindings have prio 2 case hasIfAttribute(cloneNode): return [tagOpeningHTML, [ifBinding(cloneNode, bindingsSelector, sourceFile, sourceCode)]] // TAG bindings have prio 3 case isCustomNode(cloneNode): return [tagOpeningHTML, [tagBinding(cloneNode, bindingsSelector, sourceFile, sourceCode)]] // this node has expressions bound to it default: return [tagOpeningHTML, [simpleBinding(cloneNode, bindingsSelector, sourceFile, sourceCode)]] } }
javascript
{ "resource": "" }