repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
mar10/fancytree | lib/jquery.configurator.js | function(){
var plugin = $(this.element).data("ui-" + this.options.pluginName) || $(this.element).data(this.options.pluginName),
opts = this.options,
actualOpts = plugin.options,
availOptList = opts.optionList,
$opts = $(this.options.optionTarget).empty(),
$ul = $("<ul>").appendTo($opts),
$li... | javascript | function(){
var plugin = $(this.element).data("ui-" + this.options.pluginName) || $(this.element).data(this.options.pluginName),
opts = this.options,
actualOpts = plugin.options,
availOptList = opts.optionList,
$opts = $(this.options.optionTarget).empty(),
$ul = $("<ul>").appendTo($opts),
$li... | [
"function",
"(",
")",
"{",
"var",
"plugin",
"=",
"$",
"(",
"this",
".",
"element",
")",
".",
"data",
"(",
"\"ui-\"",
"+",
"this",
".",
"options",
".",
"pluginName",
")",
"||",
"$",
"(",
"this",
".",
"element",
")",
".",
"data",
"(",
"this",
".",
... | Render checkboxes and other controls into configurator panel. | [
"Render",
"checkboxes",
"and",
"other",
"controls",
"into",
"configurator",
"panel",
"."
] | 54307b76844177207e321c5b88eb03a23a6e23a2 | https://github.com/mar10/fancytree/blob/54307b76844177207e321c5b88eb03a23a6e23a2/lib/jquery.configurator.js#L93-L146 | train | |
mar10/fancytree | lib/jquery.configurator.js | function(){
var plugin = $(this.element).data("ui-" + this.options.pluginName) || $(this.element).data(this.options.pluginName),
opts = this.options,
actualOpts = plugin.options,
availOptList = opts.optionList,
lines = [],
header = opts.header || '$("#selector").' + opts.pluginName + "({",
fo... | javascript | function(){
var plugin = $(this.element).data("ui-" + this.options.pluginName) || $(this.element).data(this.options.pluginName),
opts = this.options,
actualOpts = plugin.options,
availOptList = opts.optionList,
lines = [],
header = opts.header || '$("#selector").' + opts.pluginName + "({",
fo... | [
"function",
"(",
")",
"{",
"var",
"plugin",
"=",
"$",
"(",
"this",
".",
"element",
")",
".",
"data",
"(",
"\"ui-\"",
"+",
"this",
".",
"options",
".",
"pluginName",
")",
"||",
"$",
"(",
"this",
".",
"element",
")",
".",
"data",
"(",
"this",
".",
... | Render source code into source panel. | [
"Render",
"source",
"code",
"into",
"source",
"panel",
"."
] | 54307b76844177207e321c5b88eb03a23a6e23a2 | https://github.com/mar10/fancytree/blob/54307b76844177207e321c5b88eb03a23a6e23a2/lib/jquery.configurator.js#L150-L198 | train | |
mar10/fancytree | demo/taxonomy-browser/taxonomy-browser-itis.js | updateControls | function updateControls() {
var query = $.trim($("input[name=query]").val());
$("#btnPin").attr("disabled", !taxonTree.getActiveNode());
$("#btnUnpin")
.attr("disabled", !taxonTree.isFilterActive())
.toggleClass("btn-success", taxonTree.isFilterActive());
$("#btnResetSearch").attr("disabled", query.lengt... | javascript | function updateControls() {
var query = $.trim($("input[name=query]").val());
$("#btnPin").attr("disabled", !taxonTree.getActiveNode());
$("#btnUnpin")
.attr("disabled", !taxonTree.isFilterActive())
.toggleClass("btn-success", taxonTree.isFilterActive());
$("#btnResetSearch").attr("disabled", query.lengt... | [
"function",
"updateControls",
"(",
")",
"{",
"var",
"query",
"=",
"$",
".",
"trim",
"(",
"$",
"(",
"\"input[name=query]\"",
")",
".",
"val",
"(",
")",
")",
";",
"$",
"(",
"\"#btnPin\"",
")",
".",
"attr",
"(",
"\"disabled\"",
",",
"!",
"taxonTree",
".... | Update UI elements according to current status | [
"Update",
"UI",
"elements",
"according",
"to",
"current",
"status"
] | 54307b76844177207e321c5b88eb03a23a6e23a2 | https://github.com/mar10/fancytree/blob/54307b76844177207e321c5b88eb03a23a6e23a2/demo/taxonomy-browser/taxonomy-browser-itis.js#L46-L55 | train |
mar10/fancytree | demo/taxonomy-browser/taxonomy-browser-itis.js | _delay | function _delay(tag, ms, callback) {
/*jshint -W040:true */
var self = this;
tag = "" + (tag || "default");
if (timerMap[tag] != null) {
clearTimeout(timerMap[tag]);
delete timerMap[tag];
// console.log("Cancel timer '" + tag + "'");
}
if (ms == null || callback == null) {
return;
}
// cons... | javascript | function _delay(tag, ms, callback) {
/*jshint -W040:true */
var self = this;
tag = "" + (tag || "default");
if (timerMap[tag] != null) {
clearTimeout(timerMap[tag]);
delete timerMap[tag];
// console.log("Cancel timer '" + tag + "'");
}
if (ms == null || callback == null) {
return;
}
// cons... | [
"function",
"_delay",
"(",
"tag",
",",
"ms",
",",
"callback",
")",
"{",
"/*jshint -W040:true */",
"var",
"self",
"=",
"this",
";",
"tag",
"=",
"\"\"",
"+",
"(",
"tag",
"||",
"\"default\"",
")",
";",
"if",
"(",
"timerMap",
"[",
"tag",
"]",
"!=",
"null... | Invoke callback after `ms` milliseconds.
Any pending action of this type is cancelled before. | [
"Invoke",
"callback",
"after",
"ms",
"milliseconds",
".",
"Any",
"pending",
"action",
"of",
"this",
"type",
"is",
"cancelled",
"before",
"."
] | 54307b76844177207e321c5b88eb03a23a6e23a2 | https://github.com/mar10/fancytree/blob/54307b76844177207e321c5b88eb03a23a6e23a2/demo/taxonomy-browser/taxonomy-browser-itis.js#L61-L79 | train |
UnitedIncome/serverless-python-requirements | lib/inject.js | moveModuleUp | function moveModuleUp(source, target, module) {
const targetZip = new JSZip();
return fse
.readFileAsync(source)
.then(buffer => JSZip.loadAsync(buffer))
.then(sourceZip => sourceZip.filter(file => file.startsWith(module + '/')))
.map(srcZipObj =>
zipFile(
targetZip,
srcZipObj... | javascript | function moveModuleUp(source, target, module) {
const targetZip = new JSZip();
return fse
.readFileAsync(source)
.then(buffer => JSZip.loadAsync(buffer))
.then(sourceZip => sourceZip.filter(file => file.startsWith(module + '/')))
.map(srcZipObj =>
zipFile(
targetZip,
srcZipObj... | [
"function",
"moveModuleUp",
"(",
"source",
",",
"target",
",",
"module",
")",
"{",
"const",
"targetZip",
"=",
"new",
"JSZip",
"(",
")",
";",
"return",
"fse",
".",
"readFileAsync",
"(",
"source",
")",
".",
"then",
"(",
"buffer",
"=>",
"JSZip",
".",
"loa... | Remove all modules but the selected module from a package.
@param {string} source path to original package
@param {string} target path to result package
@param {string} module module to keep
@return {Promise} the JSZip object written out. | [
"Remove",
"all",
"modules",
"but",
"the",
"selected",
"module",
"from",
"a",
"package",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/inject.js#L58-L73 | train |
UnitedIncome/serverless-python-requirements | lib/clean.js | cleanup | function cleanup() {
const artifacts = ['.requirements'];
if (this.options.zip) {
if (this.serverless.service.package.individually) {
this.targetFuncs.forEach(f => {
artifacts.push(path.join(f.module, '.requirements.zip'));
artifacts.push(path.join(f.module, 'unzip_requirements.py'));
... | javascript | function cleanup() {
const artifacts = ['.requirements'];
if (this.options.zip) {
if (this.serverless.service.package.individually) {
this.targetFuncs.forEach(f => {
artifacts.push(path.join(f.module, '.requirements.zip'));
artifacts.push(path.join(f.module, 'unzip_requirements.py'));
... | [
"function",
"cleanup",
"(",
")",
"{",
"const",
"artifacts",
"=",
"[",
"'.requirements'",
"]",
";",
"if",
"(",
"this",
".",
"options",
".",
"zip",
")",
"{",
"if",
"(",
"this",
".",
"serverless",
".",
"service",
".",
"package",
".",
"individually",
")",
... | clean up .requirements and .requirements.zip and unzip_requirements.py
@return {Promise} | [
"clean",
"up",
".",
"requirements",
"and",
".",
"requirements",
".",
"zip",
"and",
"unzip_requirements",
".",
"py"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/clean.js#L13-L32 | train |
UnitedIncome/serverless-python-requirements | lib/clean.js | cleanupCache | function cleanupCache() {
const cacheLocation = getUserCachePath(this.options);
if (fse.existsSync(cacheLocation)) {
if (this.serverless) {
this.serverless.cli.log(`Removing static caches at: ${cacheLocation}`);
}
// Only remove cache folders that we added, just incase someone accidentally puts a... | javascript | function cleanupCache() {
const cacheLocation = getUserCachePath(this.options);
if (fse.existsSync(cacheLocation)) {
if (this.serverless) {
this.serverless.cli.log(`Removing static caches at: ${cacheLocation}`);
}
// Only remove cache folders that we added, just incase someone accidentally puts a... | [
"function",
"cleanupCache",
"(",
")",
"{",
"const",
"cacheLocation",
"=",
"getUserCachePath",
"(",
"this",
".",
"options",
")",
";",
"if",
"(",
"fse",
".",
"existsSync",
"(",
"cacheLocation",
")",
")",
"{",
"if",
"(",
"this",
".",
"serverless",
")",
"{",... | Clean up static cache, remove all items in there
@return {Promise} | [
"Clean",
"up",
"static",
"cache",
"remove",
"all",
"items",
"in",
"there"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/clean.js#L38-L60 | train |
UnitedIncome/serverless-python-requirements | lib/docker.js | dockerCommand | function dockerCommand(options) {
const cmd = 'docker';
const ps = spawnSync(cmd, options, { encoding: 'utf-8' });
if (ps.error) {
if (ps.error.code === 'ENOENT') {
throw new Error('docker not found! Please install it.');
}
throw new Error(ps.error);
} else if (ps.status !== 0) {
throw new... | javascript | function dockerCommand(options) {
const cmd = 'docker';
const ps = spawnSync(cmd, options, { encoding: 'utf-8' });
if (ps.error) {
if (ps.error.code === 'ENOENT') {
throw new Error('docker not found! Please install it.');
}
throw new Error(ps.error);
} else if (ps.status !== 0) {
throw new... | [
"function",
"dockerCommand",
"(",
"options",
")",
"{",
"const",
"cmd",
"=",
"'docker'",
";",
"const",
"ps",
"=",
"spawnSync",
"(",
"cmd",
",",
"options",
",",
"{",
"encoding",
":",
"'utf-8'",
"}",
")",
";",
"if",
"(",
"ps",
".",
"error",
")",
"{",
... | Helper function to run a docker command
@param {string[]} options
@return {Object} | [
"Helper",
"function",
"to",
"run",
"a",
"docker",
"command"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/docker.js#L11-L23 | train |
UnitedIncome/serverless-python-requirements | lib/docker.js | tryBindPath | function tryBindPath(serverless, bindPath, testFile) {
const options = [
'run',
'--rm',
'-v',
`${bindPath}:/test`,
'alpine',
'ls',
`/test/${testFile}`
];
try {
const ps = dockerCommand(options);
if (process.env.SLS_DEBUG) {
serverless.cli.log(`Trying bindPath ${bindPath} ... | javascript | function tryBindPath(serverless, bindPath, testFile) {
const options = [
'run',
'--rm',
'-v',
`${bindPath}:/test`,
'alpine',
'ls',
`/test/${testFile}`
];
try {
const ps = dockerCommand(options);
if (process.env.SLS_DEBUG) {
serverless.cli.log(`Trying bindPath ${bindPath} ... | [
"function",
"tryBindPath",
"(",
"serverless",
",",
"bindPath",
",",
"testFile",
")",
"{",
"const",
"options",
"=",
"[",
"'run'",
",",
"'--rm'",
",",
"'-v'",
",",
"`",
"${",
"bindPath",
"}",
"`",
",",
"'alpine'",
",",
"'ls'",
",",
"`",
"${",
"testFile",... | Test bind path to make sure it's working
@param {string} bindPath
@return {boolean} | [
"Test",
"bind",
"path",
"to",
"make",
"sure",
"it",
"s",
"working"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/docker.js#L65-L85 | train |
UnitedIncome/serverless-python-requirements | lib/docker.js | getBindPath | function getBindPath(serverless, servicePath) {
// Determine bind path
if (process.platform !== 'win32' && !isWsl) {
return servicePath;
}
// test docker is available
dockerCommand(['version']);
// find good bind path for Windows
let bindPaths = [];
let baseBindPath = servicePath.replace(/\\([^\s]... | javascript | function getBindPath(serverless, servicePath) {
// Determine bind path
if (process.platform !== 'win32' && !isWsl) {
return servicePath;
}
// test docker is available
dockerCommand(['version']);
// find good bind path for Windows
let bindPaths = [];
let baseBindPath = servicePath.replace(/\\([^\s]... | [
"function",
"getBindPath",
"(",
"serverless",
",",
"servicePath",
")",
"{",
"// Determine bind path",
"if",
"(",
"process",
".",
"platform",
"!==",
"'win32'",
"&&",
"!",
"isWsl",
")",
"{",
"return",
"servicePath",
";",
"}",
"// test docker is available",
"dockerCo... | Get bind path depending on os platform
@param {object} serverless
@param {string} servicePath
@return {string} The bind path. | [
"Get",
"bind",
"path",
"depending",
"on",
"os",
"platform"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/docker.js#L93-L143 | train |
UnitedIncome/serverless-python-requirements | lib/docker.js | getDockerUid | function getDockerUid(bindPath) {
const options = [
'run',
'--rm',
'-v',
`${bindPath}:/test`,
'alpine',
'stat',
'-c',
'%u',
'/bin/sh'
];
const ps = dockerCommand(options);
return ps.stdout.trim();
} | javascript | function getDockerUid(bindPath) {
const options = [
'run',
'--rm',
'-v',
`${bindPath}:/test`,
'alpine',
'stat',
'-c',
'%u',
'/bin/sh'
];
const ps = dockerCommand(options);
return ps.stdout.trim();
} | [
"function",
"getDockerUid",
"(",
"bindPath",
")",
"{",
"const",
"options",
"=",
"[",
"'run'",
",",
"'--rm'",
",",
"'-v'",
",",
"`",
"${",
"bindPath",
"}",
"`",
",",
"'alpine'",
",",
"'stat'",
",",
"'-c'",
",",
"'%u'",
",",
"'/bin/sh'",
"]",
";",
"con... | Find out what uid the docker machine is using
@param {string} bindPath
@return {boolean} | [
"Find",
"out",
"what",
"uid",
"the",
"docker",
"machine",
"is",
"using"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/docker.js#L150-L164 | train |
UnitedIncome/serverless-python-requirements | lib/layer.js | zipRequirements | function zipRequirements() {
const rootZip = new JSZip();
const src = path.join('.serverless', 'requirements');
const runtimepath = 'python';
return addTree(rootZip.folder(runtimepath), src).then(() =>
writeZip(rootZip, path.join('.serverless', 'pythonRequirements.zip'))
);
} | javascript | function zipRequirements() {
const rootZip = new JSZip();
const src = path.join('.serverless', 'requirements');
const runtimepath = 'python';
return addTree(rootZip.folder(runtimepath), src).then(() =>
writeZip(rootZip, path.join('.serverless', 'pythonRequirements.zip'))
);
} | [
"function",
"zipRequirements",
"(",
")",
"{",
"const",
"rootZip",
"=",
"new",
"JSZip",
"(",
")",
";",
"const",
"src",
"=",
"path",
".",
"join",
"(",
"'.serverless'",
",",
"'requirements'",
")",
";",
"const",
"runtimepath",
"=",
"'python'",
";",
"return",
... | Zip up requirements to be used as layer package.
@return {Promise} the JSZip object constructed. | [
"Zip",
"up",
"requirements",
"to",
"be",
"used",
"as",
"layer",
"package",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/layer.js#L13-L21 | train |
UnitedIncome/serverless-python-requirements | lib/layer.js | createLayers | function createLayers() {
if (!this.serverless.service.layers) {
this.serverless.service.layers = {};
}
this.serverless.service.layers['pythonRequirements'] = Object.assign(
{
artifact: path.join('.serverless', 'pythonRequirements.zip'),
name: `${
this.serverless.service.service
... | javascript | function createLayers() {
if (!this.serverless.service.layers) {
this.serverless.service.layers = {};
}
this.serverless.service.layers['pythonRequirements'] = Object.assign(
{
artifact: path.join('.serverless', 'pythonRequirements.zip'),
name: `${
this.serverless.service.service
... | [
"function",
"createLayers",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"serverless",
".",
"service",
".",
"layers",
")",
"{",
"this",
".",
"serverless",
".",
"service",
".",
"layers",
"=",
"{",
"}",
";",
"}",
"this",
".",
"serverless",
".",
"service... | Creates a layer on the serverless service for the requirements zip.
@return {Promise} empty promise | [
"Creates",
"a",
"layer",
"on",
"the",
"serverless",
"service",
"for",
"the",
"requirements",
"zip",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/layer.js#L27-L45 | train |
UnitedIncome/serverless-python-requirements | lib/layer.js | layerRequirements | function layerRequirements() {
if (!this.options.layer) {
return BbPromise.resolve();
}
this.serverless.cli.log('Packaging Python Requirements Lambda Layer...');
return BbPromise.bind(this)
.then(zipRequirements)
.then(createLayers);
} | javascript | function layerRequirements() {
if (!this.options.layer) {
return BbPromise.resolve();
}
this.serverless.cli.log('Packaging Python Requirements Lambda Layer...');
return BbPromise.bind(this)
.then(zipRequirements)
.then(createLayers);
} | [
"function",
"layerRequirements",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"options",
".",
"layer",
")",
"{",
"return",
"BbPromise",
".",
"resolve",
"(",
")",
";",
"}",
"this",
".",
"serverless",
".",
"cli",
".",
"log",
"(",
"'Packaging Python Requirem... | Creates a layer from the installed requirements.
@return {Promise} the combined promise for requirements layer. | [
"Creates",
"a",
"layer",
"from",
"the",
"installed",
"requirements",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/layer.js#L51-L61 | train |
UnitedIncome/serverless-python-requirements | lib/zip.js | addVendorHelper | function addVendorHelper() {
if (this.options.zip) {
if (this.serverless.service.package.individually) {
return BbPromise.resolve(this.targetFuncs)
.map(f => {
if (!get(f, 'package.include')) {
set(f, ['package', 'include'], []);
}
if (!get(f, 'module')) {
... | javascript | function addVendorHelper() {
if (this.options.zip) {
if (this.serverless.service.package.individually) {
return BbPromise.resolve(this.targetFuncs)
.map(f => {
if (!get(f, 'package.include')) {
set(f, ['package', 'include'], []);
}
if (!get(f, 'module')) {
... | [
"function",
"addVendorHelper",
"(",
")",
"{",
"if",
"(",
"this",
".",
"options",
".",
"zip",
")",
"{",
"if",
"(",
"this",
".",
"serverless",
".",
"service",
".",
"package",
".",
"individually",
")",
"{",
"return",
"BbPromise",
".",
"resolve",
"(",
"thi... | Add the vendor helper to the current service tree.
@return {Promise} | [
"Add",
"the",
"vendor",
"helper",
"to",
"the",
"current",
"service",
"tree",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/zip.js#L16-L56 | train |
UnitedIncome/serverless-python-requirements | lib/zip.js | removeVendorHelper | function removeVendorHelper() {
if (this.options.zip && this.options.cleanupZipHelper) {
if (this.serverless.service.package.individually) {
return BbPromise.resolve(this.targetFuncs)
.map(f => {
if (!get(f, 'module')) {
set(f, ['module'], '.');
}
return f;
... | javascript | function removeVendorHelper() {
if (this.options.zip && this.options.cleanupZipHelper) {
if (this.serverless.service.package.individually) {
return BbPromise.resolve(this.targetFuncs)
.map(f => {
if (!get(f, 'module')) {
set(f, ['module'], '.');
}
return f;
... | [
"function",
"removeVendorHelper",
"(",
")",
"{",
"if",
"(",
"this",
".",
"options",
".",
"zip",
"&&",
"this",
".",
"options",
".",
"cleanupZipHelper",
")",
"{",
"if",
"(",
"this",
".",
"serverless",
".",
"service",
".",
"package",
".",
"individually",
")... | Remove the vendor helper from the current service tree.
@return {Promise} the promise to remove the vendor helper. | [
"Remove",
"the",
"vendor",
"helper",
"from",
"the",
"current",
"service",
"tree",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/zip.js#L62-L88 | train |
UnitedIncome/serverless-python-requirements | lib/zipTree.js | addTree | function addTree(zip, src) {
const srcN = path.normalize(src);
return fse
.readdirAsync(srcN)
.map(name => {
const srcPath = path.join(srcN, name);
return fse.statAsync(srcPath).then(stat => {
if (stat.isDirectory()) {
return addTree(zip.folder(name), srcPath);
} else... | javascript | function addTree(zip, src) {
const srcN = path.normalize(src);
return fse
.readdirAsync(srcN)
.map(name => {
const srcPath = path.join(srcN, name);
return fse.statAsync(srcPath).then(stat => {
if (stat.isDirectory()) {
return addTree(zip.folder(name), srcPath);
} else... | [
"function",
"addTree",
"(",
"zip",
",",
"src",
")",
"{",
"const",
"srcN",
"=",
"path",
".",
"normalize",
"(",
"src",
")",
";",
"return",
"fse",
".",
"readdirAsync",
"(",
"srcN",
")",
".",
"map",
"(",
"name",
"=>",
"{",
"const",
"srcPath",
"=",
"pat... | Add a directory recursively to a zip file. Files in src will be added to the top folder of zip.
@param {JSZip} zip a zip object in the folder you want to add files to.
@param {string} src the source folder.
@return {Promise} a promise offering the original JSZip object. | [
"Add",
"a",
"directory",
"recursively",
"to",
"a",
"zip",
"file",
".",
"Files",
"in",
"src",
"will",
"be",
"added",
"to",
"the",
"top",
"folder",
"of",
"zip",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/zipTree.js#L13-L33 | train |
UnitedIncome/serverless-python-requirements | lib/zipTree.js | writeZip | function writeZip(zip, targetPath) {
const opts = {
platform: process.platform == 'win32' ? 'DOS' : 'UNIX',
compression: 'DEFLATE',
compressionOptions: {
level: 9
}
};
return new BbPromise(resolve =>
zip
.generateNodeStream(opts)
.pipe(fse.createWriteStream(targetPath))
... | javascript | function writeZip(zip, targetPath) {
const opts = {
platform: process.platform == 'win32' ? 'DOS' : 'UNIX',
compression: 'DEFLATE',
compressionOptions: {
level: 9
}
};
return new BbPromise(resolve =>
zip
.generateNodeStream(opts)
.pipe(fse.createWriteStream(targetPath))
... | [
"function",
"writeZip",
"(",
"zip",
",",
"targetPath",
")",
"{",
"const",
"opts",
"=",
"{",
"platform",
":",
"process",
".",
"platform",
"==",
"'win32'",
"?",
"'DOS'",
":",
"'UNIX'",
",",
"compression",
":",
"'DEFLATE'",
",",
"compressionOptions",
":",
"{"... | Write zip contents to a file.
@param {JSZip} zip the zip object
@param {string} targetPath path to write the zip file to.
@return {Promise} a promise resolving to null. | [
"Write",
"zip",
"contents",
"to",
"a",
"file",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/zipTree.js#L41-L55 | train |
UnitedIncome/serverless-python-requirements | lib/zipTree.js | zipFile | function zipFile(zip, zipPath, bufferPromise, fileOpts) {
return bufferPromise
.then(buffer =>
zip.file(
zipPath,
buffer,
Object.assign(
{},
{
// necessary to get the same hash when zipping the same content
date: new Date(0)
},
... | javascript | function zipFile(zip, zipPath, bufferPromise, fileOpts) {
return bufferPromise
.then(buffer =>
zip.file(
zipPath,
buffer,
Object.assign(
{},
{
// necessary to get the same hash when zipping the same content
date: new Date(0)
},
... | [
"function",
"zipFile",
"(",
"zip",
",",
"zipPath",
",",
"bufferPromise",
",",
"fileOpts",
")",
"{",
"return",
"bufferPromise",
".",
"then",
"(",
"buffer",
"=>",
"zip",
".",
"file",
"(",
"zipPath",
",",
"buffer",
",",
"Object",
".",
"assign",
"(",
"{",
... | Add a new file to a zip file from a buffer.
@param {JSZip} zip the zip object to add the file to.
@param {string} zipPath the target path in the zip.
@param {Promise} bufferPromise a promise providing a nodebuffer.
@return {Promise} a promise providing the JSZip object.
@param {object} fileOpts an object with the opts ... | [
"Add",
"a",
"new",
"file",
"to",
"a",
"zip",
"file",
"from",
"a",
"buffer",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/zipTree.js#L65-L82 | train |
UnitedIncome/serverless-python-requirements | lib/pip.js | mergeCommands | function mergeCommands(commands) {
const cmds = filterCommands(commands);
if (cmds.length === 0) {
throw new Error('Expected at least one non-empty command');
} else if (cmds.length === 1) {
return cmds[0];
} else {
// Quote the arguments in each command and join them all using &&.
const script ... | javascript | function mergeCommands(commands) {
const cmds = filterCommands(commands);
if (cmds.length === 0) {
throw new Error('Expected at least one non-empty command');
} else if (cmds.length === 1) {
return cmds[0];
} else {
// Quote the arguments in each command and join them all using &&.
const script ... | [
"function",
"mergeCommands",
"(",
"commands",
")",
"{",
"const",
"cmds",
"=",
"filterCommands",
"(",
"commands",
")",
";",
"if",
"(",
"cmds",
".",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Expected at least one non-empty command'",
")",
... | Render zero or more commands as a single command for a Unix environment.
In this context, a "command" is a list of arguments. An empty list or falsy value is ommitted.
@param {string[][]} many commands to merge.
@return {string[]} a single list of words. | [
"Render",
"zero",
"or",
"more",
"commands",
"as",
"a",
"single",
"command",
"for",
"a",
"Unix",
"environment",
".",
"In",
"this",
"context",
"a",
"command",
"is",
"a",
"list",
"of",
"arguments",
".",
"An",
"empty",
"list",
"or",
"falsy",
"value",
"is",
... | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/pip.js#L34-L45 | train |
UnitedIncome/serverless-python-requirements | lib/pip.js | generateRequirementsFile | function generateRequirementsFile(
requirementsPath,
targetFile,
serverless,
servicePath,
options
) {
if (
options.usePoetry &&
fse.existsSync(path.join(servicePath, 'pyproject.toml'))
) {
filterRequirementsFile(
path.join(servicePath, '.serverless/requirements.txt'),
targetFile,
... | javascript | function generateRequirementsFile(
requirementsPath,
targetFile,
serverless,
servicePath,
options
) {
if (
options.usePoetry &&
fse.existsSync(path.join(servicePath, 'pyproject.toml'))
) {
filterRequirementsFile(
path.join(servicePath, '.serverless/requirements.txt'),
targetFile,
... | [
"function",
"generateRequirementsFile",
"(",
"requirementsPath",
",",
"targetFile",
",",
"serverless",
",",
"servicePath",
",",
"options",
")",
"{",
"if",
"(",
"options",
".",
"usePoetry",
"&&",
"fse",
".",
"existsSync",
"(",
"path",
".",
"join",
"(",
"service... | Just generate the requirements file in the .serverless folder
@param {string} requirementsPath
@param {string} targetFile
@param {Object} serverless
@param {string} servicePath
@param {Object} options
@return {undefined} | [
"Just",
"generate",
"the",
"requirements",
"file",
"in",
"the",
".",
"serverless",
"folder"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/pip.js#L56-L93 | train |
UnitedIncome/serverless-python-requirements | lib/pip.js | copyVendors | function copyVendors(vendorFolder, targetFolder, serverless) {
// Create target folder if it does not exist
fse.ensureDirSync(targetFolder);
serverless.cli.log(
`Copying vendor libraries from ${vendorFolder} to ${targetFolder}...`
);
fse.readdirSync(vendorFolder).map(file => {
let source = path.join... | javascript | function copyVendors(vendorFolder, targetFolder, serverless) {
// Create target folder if it does not exist
fse.ensureDirSync(targetFolder);
serverless.cli.log(
`Copying vendor libraries from ${vendorFolder} to ${targetFolder}...`
);
fse.readdirSync(vendorFolder).map(file => {
let source = path.join... | [
"function",
"copyVendors",
"(",
"vendorFolder",
",",
"targetFolder",
",",
"serverless",
")",
"{",
"// Create target folder if it does not exist",
"fse",
".",
"ensureDirSync",
"(",
"targetFolder",
")",
";",
"serverless",
".",
"cli",
".",
"log",
"(",
"`",
"${",
"ven... | Copy everything from vendorFolder to targetFolder
@param {string} vendorFolder
@param {string} targetFolder
@param {Object} serverless
@return {undefined} | [
"Copy",
"everything",
"from",
"vendorFolder",
"to",
"targetFolder"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/pip.js#L377-L393 | train |
UnitedIncome/serverless-python-requirements | lib/pip.js | requirementsFileExists | function requirementsFileExists(servicePath, options, fileName) {
if (
options.usePoetry &&
fse.existsSync(path.join(servicePath, 'pyproject.toml'))
) {
return true;
}
if (options.usePipenv && fse.existsSync(path.join(servicePath, 'Pipfile'))) {
return true;
}
if (fse.existsSync(fileName))... | javascript | function requirementsFileExists(servicePath, options, fileName) {
if (
options.usePoetry &&
fse.existsSync(path.join(servicePath, 'pyproject.toml'))
) {
return true;
}
if (options.usePipenv && fse.existsSync(path.join(servicePath, 'Pipfile'))) {
return true;
}
if (fse.existsSync(fileName))... | [
"function",
"requirementsFileExists",
"(",
"servicePath",
",",
"options",
",",
"fileName",
")",
"{",
"if",
"(",
"options",
".",
"usePoetry",
"&&",
"fse",
".",
"existsSync",
"(",
"path",
".",
"join",
"(",
"servicePath",
",",
"'pyproject.toml'",
")",
")",
")",... | This checks if requirements file exists.
@param {string} servicePath
@param {Object} options
@param {string} fileName | [
"This",
"checks",
"if",
"requirements",
"file",
"exists",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/pip.js#L401-L418 | train |
UnitedIncome/serverless-python-requirements | lib/pip.js | installRequirementsIfNeeded | function installRequirementsIfNeeded(
servicePath,
modulePath,
options,
funcOptions,
serverless
) {
// Our source requirements, under our service path, and our module path (if specified)
const fileName = path.join(servicePath, modulePath, options.fileName);
// Skip requirements generation, if requireme... | javascript | function installRequirementsIfNeeded(
servicePath,
modulePath,
options,
funcOptions,
serverless
) {
// Our source requirements, under our service path, and our module path (if specified)
const fileName = path.join(servicePath, modulePath, options.fileName);
// Skip requirements generation, if requireme... | [
"function",
"installRequirementsIfNeeded",
"(",
"servicePath",
",",
"modulePath",
",",
"options",
",",
"funcOptions",
",",
"serverless",
")",
"{",
"// Our source requirements, under our service path, and our module path (if specified)",
"const",
"fileName",
"=",
"path",
".",
... | This evaluates if requirements are actually needed to be installed, but fails
gracefully if no req file is found intentionally. It also assists with code
re-use for this logic pertaining to individually packaged functions
@param {string} servicePath
@param {string} modulePath
@param {Object} options
@param {Object} fu... | [
"This",
"evaluates",
"if",
"requirements",
"are",
"actually",
"needed",
"to",
"be",
"installed",
"but",
"fails",
"gracefully",
"if",
"no",
"req",
"file",
"is",
"found",
"intentionally",
".",
"It",
"also",
"assists",
"with",
"code",
"re",
"-",
"use",
"for",
... | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/pip.js#L431-L532 | train |
UnitedIncome/serverless-python-requirements | lib/pip.js | installAllRequirements | function installAllRequirements() {
// fse.ensureDirSync(path.join(this.servicePath, '.serverless'));
// First, check and delete cache versions, if enabled
checkForAndDeleteMaxCacheVersions(this.options, this.serverless);
// Then if we're going to package functions individually...
if (this.serverless.service... | javascript | function installAllRequirements() {
// fse.ensureDirSync(path.join(this.servicePath, '.serverless'));
// First, check and delete cache versions, if enabled
checkForAndDeleteMaxCacheVersions(this.options, this.serverless);
// Then if we're going to package functions individually...
if (this.serverless.service... | [
"function",
"installAllRequirements",
"(",
")",
"{",
"// fse.ensureDirSync(path.join(this.servicePath, '.serverless'));",
"// First, check and delete cache versions, if enabled",
"checkForAndDeleteMaxCacheVersions",
"(",
"this",
".",
"options",
",",
"this",
".",
"serverless",
")",
... | pip install the requirements to the requirements directory
@return {undefined} | [
"pip",
"install",
"the",
"requirements",
"to",
"the",
"requirements",
"directory"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/pip.js#L538-L621 | train |
UnitedIncome/serverless-python-requirements | lib/shared.js | checkForAndDeleteMaxCacheVersions | function checkForAndDeleteMaxCacheVersions(options, serverless) {
// If we're using the static cache, and we have static cache max versions enabled
if (
options.useStaticCache &&
options.staticCacheMaxVersions &&
parseInt(options.staticCacheMaxVersions) > 0
) {
// Get the list of our cache files
... | javascript | function checkForAndDeleteMaxCacheVersions(options, serverless) {
// If we're using the static cache, and we have static cache max versions enabled
if (
options.useStaticCache &&
options.staticCacheMaxVersions &&
parseInt(options.staticCacheMaxVersions) > 0
) {
// Get the list of our cache files
... | [
"function",
"checkForAndDeleteMaxCacheVersions",
"(",
"options",
",",
"serverless",
")",
"{",
"// If we're using the static cache, and we have static cache max versions enabled",
"if",
"(",
"options",
".",
"useStaticCache",
"&&",
"options",
".",
"staticCacheMaxVersions",
"&&",
... | This helper will check if we're using static cache and have max
versions enabled and will delete older versions in a fifo fashion
@param {Object} options
@param {Object} serverless
@return {undefined} | [
"This",
"helper",
"will",
"check",
"if",
"we",
"re",
"using",
"static",
"cache",
"and",
"have",
"max",
"versions",
"enabled",
"and",
"will",
"delete",
"older",
"versions",
"in",
"a",
"fifo",
"fashion"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/shared.js#L15-L51 | train |
UnitedIncome/serverless-python-requirements | lib/shared.js | getRequirementsWorkingPath | function getRequirementsWorkingPath(
subfolder,
requirementsTxtDirectory,
options
) {
// If we want to use the static cache
if (options && options.useStaticCache) {
if (subfolder) {
subfolder = subfolder + '_slspyc';
}
// If we have max number of cache items...
return path.join(getUserC... | javascript | function getRequirementsWorkingPath(
subfolder,
requirementsTxtDirectory,
options
) {
// If we want to use the static cache
if (options && options.useStaticCache) {
if (subfolder) {
subfolder = subfolder + '_slspyc';
}
// If we have max number of cache items...
return path.join(getUserC... | [
"function",
"getRequirementsWorkingPath",
"(",
"subfolder",
",",
"requirementsTxtDirectory",
",",
"options",
")",
"{",
"// If we want to use the static cache",
"if",
"(",
"options",
"&&",
"options",
".",
"useStaticCache",
")",
"{",
"if",
"(",
"subfolder",
")",
"{",
... | The working path that all requirements will be compiled into
@param {string} subfolder
@param {string} servicePath
@param {Object} options
@return {string} | [
"The",
"working",
"path",
"that",
"all",
"requirements",
"will",
"be",
"compiled",
"into"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/shared.js#L60-L77 | train |
UnitedIncome/serverless-python-requirements | lib/shared.js | getUserCachePath | function getUserCachePath(options) {
// If we've manually set the static cache location
if (options && options.cacheLocation) {
return path.resolve(options.cacheLocation);
}
// Otherwise, find/use the python-ey appdirs cache location
const dirs = new Appdir({
appName: 'serverless-python-requirements'... | javascript | function getUserCachePath(options) {
// If we've manually set the static cache location
if (options && options.cacheLocation) {
return path.resolve(options.cacheLocation);
}
// Otherwise, find/use the python-ey appdirs cache location
const dirs = new Appdir({
appName: 'serverless-python-requirements'... | [
"function",
"getUserCachePath",
"(",
"options",
")",
"{",
"// If we've manually set the static cache location",
"if",
"(",
"options",
"&&",
"options",
".",
"cacheLocation",
")",
"{",
"return",
"path",
".",
"resolve",
"(",
"options",
".",
"cacheLocation",
")",
";",
... | The static cache path that will be used for this system + options, used if static cache is enabled
@param {Object} options
@return {string} | [
"The",
"static",
"cache",
"path",
"that",
"will",
"be",
"used",
"for",
"this",
"system",
"+",
"options",
"used",
"if",
"static",
"cache",
"is",
"enabled"
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/shared.js#L84-L96 | train |
UnitedIncome/serverless-python-requirements | lib/poetry.js | isPoetryProject | function isPoetryProject(servicePath) {
const pyprojectPath = path.join(servicePath, 'pyproject.toml');
if (!fse.existsSync(pyprojectPath)) {
return false;
}
const pyprojectToml = fs.readFileSync(pyprojectPath);
const pyproject = tomlParse(pyprojectToml);
const buildSystemReqs =
(pyproject['build... | javascript | function isPoetryProject(servicePath) {
const pyprojectPath = path.join(servicePath, 'pyproject.toml');
if (!fse.existsSync(pyprojectPath)) {
return false;
}
const pyprojectToml = fs.readFileSync(pyprojectPath);
const pyproject = tomlParse(pyprojectToml);
const buildSystemReqs =
(pyproject['build... | [
"function",
"isPoetryProject",
"(",
"servicePath",
")",
"{",
"const",
"pyprojectPath",
"=",
"path",
".",
"join",
"(",
"servicePath",
",",
"'pyproject.toml'",
")",
";",
"if",
"(",
"!",
"fse",
".",
"existsSync",
"(",
"pyprojectPath",
")",
")",
"{",
"return",
... | Check if pyproject.toml file exists and is a poetry project. | [
"Check",
"if",
"pyproject",
".",
"toml",
"file",
"exists",
"and",
"is",
"a",
"poetry",
"project",
"."
] | 2e8117502606fd4bd82c19c3050ba0350adb2789 | https://github.com/UnitedIncome/serverless-python-requirements/blob/2e8117502606fd4bd82c19c3050ba0350adb2789/lib/poetry.js#L45-L65 | train |
google/lovefield | gulpfile.js | function(browser) {
return runner.runJsUnitTests(options.filter, browser).then(
function(results) {
var failedCount = results.reduce(function(prev, item) {
return prev + (item['pass'] ? 0 : 1);
}, 0);
log(results.length + ' tests, ' + failedCount + ' fai... | javascript | function(browser) {
return runner.runJsUnitTests(options.filter, browser).then(
function(results) {
var failedCount = results.reduce(function(prev, item) {
return prev + (item['pass'] ? 0 : 1);
}, 0);
log(results.length + ' tests, ' + failedCount + ' fai... | [
"function",
"(",
"browser",
")",
"{",
"return",
"runner",
".",
"runJsUnitTests",
"(",
"options",
".",
"filter",
",",
"browser",
")",
".",
"then",
"(",
"function",
"(",
"results",
")",
"{",
"var",
"failedCount",
"=",
"results",
".",
"reduce",
"(",
"functi... | Run only JSUnit tests. | [
"Run",
"only",
"JSUnit",
"tests",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/gulpfile.js#L153-L166 | train | |
google/lovefield | lib/proc/index_key_range_calculator.js | calculateCartesianProduct | function calculateCartesianProduct(keyRangeSets) {
goog.asserts.assert(
keyRangeSets.length > 1,
'Should only be called for cross-column indices.');
var keyRangeSetsAsArrays = keyRangeSets.map(
function(keyRangeSet) {
return keyRangeSet.getValues();
});
var it = goog.iter.product... | javascript | function calculateCartesianProduct(keyRangeSets) {
goog.asserts.assert(
keyRangeSets.length > 1,
'Should only be called for cross-column indices.');
var keyRangeSetsAsArrays = keyRangeSets.map(
function(keyRangeSet) {
return keyRangeSet.getValues();
});
var it = goog.iter.product... | [
"function",
"calculateCartesianProduct",
"(",
"keyRangeSets",
")",
"{",
"goog",
".",
"asserts",
".",
"assert",
"(",
"keyRangeSets",
".",
"length",
">",
"1",
",",
"'Should only be called for cross-column indices.'",
")",
";",
"var",
"keyRangeSetsAsArrays",
"=",
"keyRan... | Finds the cartesian product of a collection of SingleKeyRangeSets.
@param {!Array<!lf.index.SingleKeyRangeSet>} keyRangeSets A SingleKeyRangeSet
at position i in the input array corresponds to all possible values for
the ith dimension in the N-dimensional space (where N is the number of
columns in the cross-column inde... | [
"Finds",
"the",
"cartesian",
"product",
"of",
"a",
"collection",
"of",
"SingleKeyRangeSets",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/lib/proc/index_key_range_calculator.js#L227-L243 | train |
google/lovefield | tools/scan_deps.js | scanDeps | function scanDeps() {
var provideMap = new ProvideMap_();
var requireMap = new RequireMap_();
scanFiles(relativeGlob('lib'), provideMap, requireMap);
var closureRequire = new RequireMap_();
var closureProvide = new ProvideMap_();
var closurePath = config.CLOSURE_LIBRARY_PATH + '/closure/goog';
scanFiles(... | javascript | function scanDeps() {
var provideMap = new ProvideMap_();
var requireMap = new RequireMap_();
scanFiles(relativeGlob('lib'), provideMap, requireMap);
var closureRequire = new RequireMap_();
var closureProvide = new ProvideMap_();
var closurePath = config.CLOSURE_LIBRARY_PATH + '/closure/goog';
scanFiles(... | [
"function",
"scanDeps",
"(",
")",
"{",
"var",
"provideMap",
"=",
"new",
"ProvideMap_",
"(",
")",
";",
"var",
"requireMap",
"=",
"new",
"RequireMap_",
"(",
")",
";",
"scanFiles",
"(",
"relativeGlob",
"(",
"'lib'",
")",
",",
"provideMap",
",",
"requireMap",
... | Find Closure dependency files for the lib.
@return {!Array<string>} | [
"Find",
"Closure",
"dependency",
"files",
"for",
"the",
"lib",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/tools/scan_deps.js#L292-L324 | train |
google/lovefield | tools/scan_deps.js | genAddDependency | function genAddDependency(basePath, provideMap, requireMap) {
var provide = provideMap.getAllProvides();
var require = requireMap.getAllRequires();
var set = new Set();
provide.forEach(function(value, key) {
set.add(key);
});
require.forEach(function(value, key) {
set.add(key);
});
var results... | javascript | function genAddDependency(basePath, provideMap, requireMap) {
var provide = provideMap.getAllProvides();
var require = requireMap.getAllRequires();
var set = new Set();
provide.forEach(function(value, key) {
set.add(key);
});
require.forEach(function(value, key) {
set.add(key);
});
var results... | [
"function",
"genAddDependency",
"(",
"basePath",
",",
"provideMap",
",",
"requireMap",
")",
"{",
"var",
"provide",
"=",
"provideMap",
".",
"getAllProvides",
"(",
")",
";",
"var",
"require",
"=",
"requireMap",
".",
"getAllRequires",
"(",
")",
";",
"var",
"set... | Generates goog.addDependency.
@param {string} basePath
@param {!ProvideMap_} provideMap
@param {!RequireMap_} requireMap
@return {!Array<string>} | [
"Generates",
"goog",
".",
"addDependency",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/tools/scan_deps.js#L334-L380 | train |
google/lovefield | tools/scan_deps.js | genDeps | function genDeps(basePath, targets) {
var provideMap = new ProvideMap_();
var requireMap = new RequireMap_();
var files = [];
targets.forEach(function(target) {
files = files.concat(relativeGlob(target));
});
scanFiles(files, provideMap, requireMap);
var results = genAddDependency(basePath, provideM... | javascript | function genDeps(basePath, targets) {
var provideMap = new ProvideMap_();
var requireMap = new RequireMap_();
var files = [];
targets.forEach(function(target) {
files = files.concat(relativeGlob(target));
});
scanFiles(files, provideMap, requireMap);
var results = genAddDependency(basePath, provideM... | [
"function",
"genDeps",
"(",
"basePath",
",",
"targets",
")",
"{",
"var",
"provideMap",
"=",
"new",
"ProvideMap_",
"(",
")",
";",
"var",
"requireMap",
"=",
"new",
"RequireMap_",
"(",
")",
";",
"var",
"files",
"=",
"[",
"]",
";",
"targets",
".",
"forEach... | Generates deps.js used for testing.
@param {string} basePath
@param {!Array<string>} targets
@return {string} | [
"Generates",
"deps",
".",
"js",
"used",
"for",
"testing",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/tools/scan_deps.js#L389-L401 | train |
google/lovefield | tools/scan_deps.js | genModuleDeps | function genModuleDeps(scriptPath) {
var provideMap = new ProvideMap_();
var requireMap = new RequireMap_();
scanFiles([scriptPath], provideMap, requireMap);
var dumpValues = function(map) {
var results = [];
map.forEach(function(value, key) {
results = results.concat(value);
});
return re... | javascript | function genModuleDeps(scriptPath) {
var provideMap = new ProvideMap_();
var requireMap = new RequireMap_();
scanFiles([scriptPath], provideMap, requireMap);
var dumpValues = function(map) {
var results = [];
map.forEach(function(value, key) {
results = results.concat(value);
});
return re... | [
"function",
"genModuleDeps",
"(",
"scriptPath",
")",
"{",
"var",
"provideMap",
"=",
"new",
"ProvideMap_",
"(",
")",
";",
"var",
"requireMap",
"=",
"new",
"RequireMap_",
"(",
")",
";",
"scanFiles",
"(",
"[",
"scriptPath",
"]",
",",
"provideMap",
",",
"requi... | Generate addDependency for single module.
@param {string} scriptPath
@return {string} | [
"Generate",
"addDependency",
"for",
"single",
"module",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/tools/scan_deps.js#L409-L431 | train |
google/lovefield | lib/proc/index_join_pass.js | function(table) {
return table.getEffectiveName() ==
joinStep.predicate.rightColumn.getTable().getEffectiveName() ?
joinStep.predicate.rightColumn : joinStep.predicate.leftColumn;
} | javascript | function(table) {
return table.getEffectiveName() ==
joinStep.predicate.rightColumn.getTable().getEffectiveName() ?
joinStep.predicate.rightColumn : joinStep.predicate.leftColumn;
} | [
"function",
"(",
"table",
")",
"{",
"return",
"table",
".",
"getEffectiveName",
"(",
")",
"==",
"joinStep",
".",
"predicate",
".",
"rightColumn",
".",
"getTable",
"(",
")",
".",
"getEffectiveName",
"(",
")",
"?",
"joinStep",
".",
"predicate",
".",
"rightCo... | Finds which of the two joined columns corresponds to the given table.
@param {!lf.schema.Table} table
@return {!lf.schema.Column} | [
"Finds",
"which",
"of",
"the",
"two",
"joined",
"columns",
"corresponds",
"to",
"the",
"given",
"table",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/lib/proc/index_join_pass.js#L96-L100 | train | |
google/lovefield | lib/proc/index_join_pass.js | function(executionStep) {
// In order to use and index for implementing a join, the entire relation
// must be fed to the JoinStep, otherwise the index can't be used.
if (!(executionStep instanceof lf.proc.TableAccessFullStep)) {
return null;
}
var candidateColumn = getColumnForTable(execution... | javascript | function(executionStep) {
// In order to use and index for implementing a join, the entire relation
// must be fed to the JoinStep, otherwise the index can't be used.
if (!(executionStep instanceof lf.proc.TableAccessFullStep)) {
return null;
}
var candidateColumn = getColumnForTable(execution... | [
"function",
"(",
"executionStep",
")",
"{",
"// In order to use and index for implementing a join, the entire relation",
"// must be fed to the JoinStep, otherwise the index can't be used.",
"if",
"(",
"!",
"(",
"executionStep",
"instanceof",
"lf",
".",
"proc",
".",
"TableAccessFul... | Extracts the candidate indexed column for the given execution step node.
@param {!lf.proc.PhysicalQueryPlanNode} executionStep
@return {?lf.schema.Column} The candidate column or null if no such column
exists. | [
"Extracts",
"the",
"candidate",
"indexed",
"column",
"for",
"the",
"given",
"execution",
"step",
"node",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/lib/proc/index_join_pass.js#L108-L116 | train | |
google/lovefield | demos/moviedb/demo-binding.js | addSampleData | function addSampleData() {
return Promise.all([
insertPersonData('actor.json', db.getSchema().table('Actor')),
insertPersonData('director.json', db.getSchema().table('Director')),
insertData('movie.json', db.getSchema().table('Movie')),
insertData('movieactor.json', db.getSchema().table('MovieActor'))... | javascript | function addSampleData() {
return Promise.all([
insertPersonData('actor.json', db.getSchema().table('Actor')),
insertPersonData('director.json', db.getSchema().table('Director')),
insertData('movie.json', db.getSchema().table('Movie')),
insertData('movieactor.json', db.getSchema().table('MovieActor'))... | [
"function",
"addSampleData",
"(",
")",
"{",
"return",
"Promise",
".",
"all",
"(",
"[",
"insertPersonData",
"(",
"'actor.json'",
",",
"db",
".",
"getSchema",
"(",
")",
".",
"table",
"(",
"'Actor'",
")",
")",
",",
"insertPersonData",
"(",
"'director.json'",
... | Adds sample data to the database.
@return {!IThenable} | [
"Adds",
"sample",
"data",
"to",
"the",
"database",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/demos/moviedb/demo-binding.js#L128-L140 | train |
google/lovefield | lib/tree.js | function(original, clone) {
if (goog.isNull(original)) {
return;
}
var cloneFull = original.getChildCount() == clone.getChildCount();
if (cloneFull) {
var cloneIndex = copyParentStack.indexOf(clone);
if (cloneIndex != -1) {
copyParentStack.splice(cloneIndex, 1);
}
}
... | javascript | function(original, clone) {
if (goog.isNull(original)) {
return;
}
var cloneFull = original.getChildCount() == clone.getChildCount();
if (cloneFull) {
var cloneIndex = copyParentStack.indexOf(clone);
if (cloneIndex != -1) {
copyParentStack.splice(cloneIndex, 1);
}
}
... | [
"function",
"(",
"original",
",",
"clone",
")",
"{",
"if",
"(",
"goog",
".",
"isNull",
"(",
"original",
")",
")",
"{",
"return",
";",
"}",
"var",
"cloneFull",
"=",
"original",
".",
"getChildCount",
"(",
")",
"==",
"clone",
".",
"getChildCount",
"(",
... | Removes a node from the parent stack, if that node has already reached its
target number of children.
@param {?lf.structs.TreeNode} original The original node.
@param {!lf.structs.TreeNode} clone The corresponding cloned node. | [
"Removes",
"a",
"node",
"from",
"the",
"parent",
"stack",
"if",
"that",
"node",
"has",
"already",
"reached",
"its",
"target",
"number",
"of",
"children",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/lib/tree.js#L44-L56 | train | |
google/lovefield | lib/index/btree.js | function(coverage) {
return coverage[0] ?
(coverage[1] ? lf.index.Favor.TIE : lf.index.Favor.LHS) :
lf.index.Favor.RHS;
} | javascript | function(coverage) {
return coverage[0] ?
(coverage[1] ? lf.index.Favor.TIE : lf.index.Favor.LHS) :
lf.index.Favor.RHS;
} | [
"function",
"(",
"coverage",
")",
"{",
"return",
"coverage",
"[",
"0",
"]",
"?",
"(",
"coverage",
"[",
"1",
"]",
"?",
"lf",
".",
"index",
".",
"Favor",
".",
"TIE",
":",
"lf",
".",
"index",
".",
"Favor",
".",
"LHS",
")",
":",
"lf",
".",
"index",... | Position of range relative to the key. | [
"Position",
"of",
"range",
"relative",
"to",
"the",
"key",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/lib/index/btree.js#L1193-L1197 | train | |
google/lovefield | demos/moviedb/demo-jquery.js | selectAllMovies | function selectAllMovies() {
var movie = db.getSchema().table('Movie');
db.select(movie.id, movie.title, movie.year).
from(movie).exec().then(
function(results) {
var elapsed = Date.now() - startTime;
$('#load_time').text(elapsed.toString() + 'ms');
$('#master').bootstrapTable('l... | javascript | function selectAllMovies() {
var movie = db.getSchema().table('Movie');
db.select(movie.id, movie.title, movie.year).
from(movie).exec().then(
function(results) {
var elapsed = Date.now() - startTime;
$('#load_time').text(elapsed.toString() + 'ms');
$('#master').bootstrapTable('l... | [
"function",
"selectAllMovies",
"(",
")",
"{",
"var",
"movie",
"=",
"db",
".",
"getSchema",
"(",
")",
".",
"table",
"(",
"'Movie'",
")",
";",
"db",
".",
"select",
"(",
"movie",
".",
"id",
",",
"movie",
".",
"title",
",",
"movie",
".",
"year",
")",
... | Selects all movies. | [
"Selects",
"all",
"movies",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/demos/moviedb/demo-jquery.js#L148-L161 | train |
google/lovefield | demos/moviedb/demo-jquery.js | generateDetails | function generateDetails(id) {
var m = db.getSchema().table('Movie');
var ma = db.getSchema().table('MovieActor');
var md = db.getSchema().table('MovieDirector');
var a = db.getSchema().table('Actor');
var d = db.getSchema().table('Director');
var details = {};
var promises = [];
promises.push(
d... | javascript | function generateDetails(id) {
var m = db.getSchema().table('Movie');
var ma = db.getSchema().table('MovieActor');
var md = db.getSchema().table('MovieDirector');
var a = db.getSchema().table('Actor');
var d = db.getSchema().table('Director');
var details = {};
var promises = [];
promises.push(
d... | [
"function",
"generateDetails",
"(",
"id",
")",
"{",
"var",
"m",
"=",
"db",
".",
"getSchema",
"(",
")",
".",
"table",
"(",
"'Movie'",
")",
";",
"var",
"ma",
"=",
"db",
".",
"getSchema",
"(",
")",
".",
"table",
"(",
"'MovieActor'",
")",
";",
"var",
... | Display details results for selected movie.
@param {string} id | [
"Display",
"details",
"results",
"for",
"selected",
"movie",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/demos/moviedb/demo-jquery.js#L168-L214 | train |
google/lovefield | tools/node_bootstrap.js | bootstrap | function bootstrap(lovefieldBinary) {
// Setting "window" to be Node's global context.
global.window = global;
// Setting "self" to be Node's global context. This must be placed after
// global.window.
global.self = global;
// Setting "document" to a dummy object, even though it is not actually used,
//... | javascript | function bootstrap(lovefieldBinary) {
// Setting "window" to be Node's global context.
global.window = global;
// Setting "self" to be Node's global context. This must be placed after
// global.window.
global.self = global;
// Setting "document" to a dummy object, even though it is not actually used,
//... | [
"function",
"bootstrap",
"(",
"lovefieldBinary",
")",
"{",
"// Setting \"window\" to be Node's global context.",
"global",
".",
"window",
"=",
"global",
";",
"// Setting \"self\" to be Node's global context. This must be placed after",
"// global.window.",
"global",
".",
"self",
... | Bootstraps a lovefield binary such that is runnable in nodejs.
@param {string} lovefieldBinary The aboslute path of the binary file. | [
"Bootstraps",
"a",
"lovefield",
"binary",
"such",
"that",
"is",
"runnable",
"in",
"nodejs",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/tools/node_bootstrap.js#L35-L48 | train |
google/lovefield | tools/builder.js | runSpac | function runSpac(schemaFilePath, namespace, outputDir) {
var spacPath = pathMod.resolve(pathMod.join(__dirname, '../spac/spac.js'));
var spac = childProcess.fork(
spacPath,
[
'--schema=' + schemaFilePath,
'--namespace=' + namespace,
'--outputdir=' + outputDir,
'--nocombin... | javascript | function runSpac(schemaFilePath, namespace, outputDir) {
var spacPath = pathMod.resolve(pathMod.join(__dirname, '../spac/spac.js'));
var spac = childProcess.fork(
spacPath,
[
'--schema=' + schemaFilePath,
'--namespace=' + namespace,
'--outputdir=' + outputDir,
'--nocombin... | [
"function",
"runSpac",
"(",
"schemaFilePath",
",",
"namespace",
",",
"outputDir",
")",
"{",
"var",
"spacPath",
"=",
"pathMod",
".",
"resolve",
"(",
"pathMod",
".",
"join",
"(",
"__dirname",
",",
"'../spac/spac.js'",
")",
")",
";",
"var",
"spac",
"=",
"chil... | Runs SPAC to generate code.
@param {string} schemaFilePath
@param {string} namespace
@param {string} outputDir
@return {!IThenable} | [
"Runs",
"SPAC",
"to",
"generate",
"code",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/tools/builder.js#L219-L242 | train |
google/lovefield | spac/codegen.js | function(col, defaultValue) {
var lhs = ' ' + prefix + '.' + col.getName() + ' = ';
body.push(lhs + (col.isNullable() ? 'null' : defaultValue) + ';');
} | javascript | function(col, defaultValue) {
var lhs = ' ' + prefix + '.' + col.getName() + ' = ';
body.push(lhs + (col.isNullable() ? 'null' : defaultValue) + ';');
} | [
"function",
"(",
"col",
",",
"defaultValue",
")",
"{",
"var",
"lhs",
"=",
"' '",
"+",
"prefix",
"+",
"'.'",
"+",
"col",
".",
"getName",
"(",
")",
"+",
"' = '",
";",
"body",
".",
"push",
"(",
"lhs",
"+",
"(",
"col",
".",
"isNullable",
"(",
")",
... | Object body for UserType default object.
@param {!lf.schema.Column} col
@param {string} defaultValue | [
"Object",
"body",
"for",
"UserType",
"default",
"object",
"."
] | 46f70024af70dd665d790170700a3c109b4922f5 | https://github.com/google/lovefield/blob/46f70024af70dd665d790170700a3c109b4922f5/spac/codegen.js#L318-L321 | train | |
akxcv/vuera | dist/vuera.cjs.js | babelReactResolver$$1 | function babelReactResolver$$1(component, props, children) {
return isReactComponent(component) ? React.createElement(component, props, children) : React.createElement(VueContainer, Object.assign({ component: component }, props), children);
} | javascript | function babelReactResolver$$1(component, props, children) {
return isReactComponent(component) ? React.createElement(component, props, children) : React.createElement(VueContainer, Object.assign({ component: component }, props), children);
} | [
"function",
"babelReactResolver$$1",
"(",
"component",
",",
"props",
",",
"children",
")",
"{",
"return",
"isReactComponent",
"(",
"component",
")",
"?",
"React",
".",
"createElement",
"(",
"component",
",",
"props",
",",
"children",
")",
":",
"React",
".",
... | This function gets imported by the babel plugin. It wraps a suspected React element and, if it
isn't a valid React element, wraps it into a Vue container. | [
"This",
"function",
"gets",
"imported",
"by",
"the",
"babel",
"plugin",
".",
"It",
"wraps",
"a",
"suspected",
"React",
"element",
"and",
"if",
"it",
"isn",
"t",
"a",
"valid",
"React",
"element",
"wraps",
"it",
"into",
"a",
"Vue",
"container",
"."
] | 246a58c4750f4ee5a4a5980810babecac2c87c20 | https://github.com/akxcv/vuera/blob/246a58c4750f4ee5a4a5980810babecac2c87c20/dist/vuera.cjs.js#L479-L481 | train |
ericf/express-handlebars | examples/advanced/server.js | exposeTemplates | function exposeTemplates(req, res, next) {
// Uses the `ExpressHandlebars` instance to get the get the **precompiled**
// templates which will be shared with the client-side of the app.
hbs.getTemplates('shared/templates/', {
cache : app.enabled('view cache'),
precompiled: true
}).t... | javascript | function exposeTemplates(req, res, next) {
// Uses the `ExpressHandlebars` instance to get the get the **precompiled**
// templates which will be shared with the client-side of the app.
hbs.getTemplates('shared/templates/', {
cache : app.enabled('view cache'),
precompiled: true
}).t... | [
"function",
"exposeTemplates",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"// Uses the `ExpressHandlebars` instance to get the get the **precompiled**",
"// templates which will be shared with the client-side of the app.",
"hbs",
".",
"getTemplates",
"(",
"'shared/templates/'",
... | Middleware to expose the app's shared templates to the client-side of the app for pages which need them. | [
"Middleware",
"to",
"expose",
"the",
"app",
"s",
"shared",
"templates",
"to",
"the",
"client",
"-",
"side",
"of",
"the",
"app",
"for",
"pages",
"which",
"need",
"them",
"."
] | 6ce977a541d50d1b7d7bd42fadf782a48899e29a | https://github.com/ericf/express-handlebars/blob/6ce977a541d50d1b7d7bd42fadf782a48899e29a/examples/advanced/server.js#L30-L57 | train |
openseadragon/openseadragon | src/control.js | function( opacity ) {
if ( this.element[ $.SIGNAL ] && $.Browser.vendor == $.BROWSERS.IE ) {
$.setElementOpacity( this.element, opacity, true );
} else {
$.setElementOpacity( this.wrapper, opacity, true );
}
} | javascript | function( opacity ) {
if ( this.element[ $.SIGNAL ] && $.Browser.vendor == $.BROWSERS.IE ) {
$.setElementOpacity( this.element, opacity, true );
} else {
$.setElementOpacity( this.wrapper, opacity, true );
}
} | [
"function",
"(",
"opacity",
")",
"{",
"if",
"(",
"this",
".",
"element",
"[",
"$",
".",
"SIGNAL",
"]",
"&&",
"$",
".",
"Browser",
".",
"vendor",
"==",
"$",
".",
"BROWSERS",
".",
"IE",
")",
"{",
"$",
".",
"setElementOpacity",
"(",
"this",
".",
"el... | Sets the opacity level for the control.
@function
@param {Number} opactiy - a value between 1 and 0 inclusively. | [
"Sets",
"the",
"opacity",
"level",
"for",
"the",
"control",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/control.js#L192-L198 | train | |
openseadragon/openseadragon | src/navigator.js | function( viewport ) {
var viewerSize,
newWidth,
newHeight,
bounds,
topleft,
bottomright;
viewerSize = $.getElementSize( this.viewer.element );
if ( this._resizeWithViewer && viewerSize.x && viewerSize.y && !viewerSize.equals( this.ol... | javascript | function( viewport ) {
var viewerSize,
newWidth,
newHeight,
bounds,
topleft,
bottomright;
viewerSize = $.getElementSize( this.viewer.element );
if ( this._resizeWithViewer && viewerSize.x && viewerSize.y && !viewerSize.equals( this.ol... | [
"function",
"(",
"viewport",
")",
"{",
"var",
"viewerSize",
",",
"newWidth",
",",
"newHeight",
",",
"bounds",
",",
"topleft",
",",
"bottomright",
";",
"viewerSize",
"=",
"$",
".",
"getElementSize",
"(",
"this",
".",
"viewer",
".",
"element",
")",
";",
"i... | Used to update the navigator minimap's viewport rectangle when a change in the viewer's viewport occurs.
@function
@param {OpenSeadragon.Viewport} The viewport this navigator is tracking. | [
"Used",
"to",
"update",
"the",
"navigator",
"minimap",
"s",
"viewport",
"rectangle",
"when",
"a",
"change",
"in",
"the",
"viewer",
"s",
"viewport",
"occurs",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/navigator.js#L302-L353 | train | |
openseadragon/openseadragon | src/navigator.js | function(options) {
var _this = this;
var original = options.originalTiledImage;
delete options.original;
var optionsClone = $.extend({}, options, {
success: function(event) {
var myItem = event.item;
myItem._originalForNavigator = original;
... | javascript | function(options) {
var _this = this;
var original = options.originalTiledImage;
delete options.original;
var optionsClone = $.extend({}, options, {
success: function(event) {
var myItem = event.item;
myItem._originalForNavigator = original;
... | [
"function",
"(",
"options",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"var",
"original",
"=",
"options",
".",
"originalTiledImage",
";",
"delete",
"options",
".",
"original",
";",
"var",
"optionsClone",
"=",
"$",
".",
"extend",
"(",
"{",
"}",
",",
"o... | overrides Viewer.addTiledImage | [
"overrides",
"Viewer",
".",
"addTiledImage"
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/navigator.js#L356-L388 | train | |
openseadragon/openseadragon | src/tiledimage.js | function() {
var xUpdated = this._xSpring.update();
var yUpdated = this._ySpring.update();
var scaleUpdated = this._scaleSpring.update();
var degreesUpdated = this._degreesSpring.update();
if (xUpdated || yUpdated || scaleUpdated || degreesUpdated) {
this._updateForS... | javascript | function() {
var xUpdated = this._xSpring.update();
var yUpdated = this._ySpring.update();
var scaleUpdated = this._scaleSpring.update();
var degreesUpdated = this._degreesSpring.update();
if (xUpdated || yUpdated || scaleUpdated || degreesUpdated) {
this._updateForS... | [
"function",
"(",
")",
"{",
"var",
"xUpdated",
"=",
"this",
".",
"_xSpring",
".",
"update",
"(",
")",
";",
"var",
"yUpdated",
"=",
"this",
".",
"_ySpring",
".",
"update",
"(",
")",
";",
"var",
"scaleUpdated",
"=",
"this",
".",
"_scaleSpring",
".",
"up... | Updates the TiledImage's bounds, animating if needed.
@returns {Boolean} Whether the TiledImage animated. | [
"Updates",
"the",
"TiledImage",
"s",
"bounds",
"animating",
"if",
"needed",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tiledimage.js#L294-L307 | train | |
openseadragon/openseadragon | src/tiledimage.js | function(current) {
return current ?
new $.Rect(
this._xSpring.current.value,
this._ySpring.current.value,
this._worldWidthCurrent,
this._worldHeightCurrent) :
new $.Rect(
this._xSpring.target.value,
... | javascript | function(current) {
return current ?
new $.Rect(
this._xSpring.current.value,
this._ySpring.current.value,
this._worldWidthCurrent,
this._worldHeightCurrent) :
new $.Rect(
this._xSpring.target.value,
... | [
"function",
"(",
"current",
")",
"{",
"return",
"current",
"?",
"new",
"$",
".",
"Rect",
"(",
"this",
".",
"_xSpring",
".",
"current",
".",
"value",
",",
"this",
".",
"_ySpring",
".",
"current",
".",
"value",
",",
"this",
".",
"_worldWidthCurrent",
","... | Get this TiledImage's bounds in viewport coordinates without taking
rotation into account.
@param {Boolean} [current=false] - Pass true for the current location;
false for target location.
@returns {OpenSeadragon.Rect} This TiledImage's bounds in viewport coordinates. | [
"Get",
"this",
"TiledImage",
"s",
"bounds",
"in",
"viewport",
"coordinates",
"without",
"taking",
"rotation",
"into",
"account",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tiledimage.js#L349-L361 | train | |
openseadragon/openseadragon | src/tiledimage.js | function(current) {
var bounds = this.getBoundsNoRotate(current);
if (this._clip) {
var worldWidth = current ?
this._worldWidthCurrent : this._worldWidthTarget;
var ratio = worldWidth / this.source.dimensions.x;
var clip = this._clip.times(ratio);
... | javascript | function(current) {
var bounds = this.getBoundsNoRotate(current);
if (this._clip) {
var worldWidth = current ?
this._worldWidthCurrent : this._worldWidthTarget;
var ratio = worldWidth / this.source.dimensions.x;
var clip = this._clip.times(ratio);
... | [
"function",
"(",
"current",
")",
"{",
"var",
"bounds",
"=",
"this",
".",
"getBoundsNoRotate",
"(",
"current",
")",
";",
"if",
"(",
"this",
".",
"_clip",
")",
"{",
"var",
"worldWidth",
"=",
"current",
"?",
"this",
".",
"_worldWidthCurrent",
":",
"this",
... | Get the bounds of the displayed part of the tiled image.
@param {Boolean} [current=false] Pass true for the current location,
false for the target location.
@returns {$.Rect} The clipped bounds in viewport coordinates. | [
"Get",
"the",
"bounds",
"of",
"the",
"displayed",
"part",
"of",
"the",
"tiled",
"image",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tiledimage.js#L375-L389 | train | |
openseadragon/openseadragon | src/tiledimage.js | function( pixel ) {
var viewerCoordinates = pixel.minus(
OpenSeadragon.getElementPosition( this.viewer.element ));
return this.viewerElementToImageCoordinates( viewerCoordinates );
} | javascript | function( pixel ) {
var viewerCoordinates = pixel.minus(
OpenSeadragon.getElementPosition( this.viewer.element ));
return this.viewerElementToImageCoordinates( viewerCoordinates );
} | [
"function",
"(",
"pixel",
")",
"{",
"var",
"viewerCoordinates",
"=",
"pixel",
".",
"minus",
"(",
"OpenSeadragon",
".",
"getElementPosition",
"(",
"this",
".",
"viewer",
".",
"element",
")",
")",
";",
"return",
"this",
".",
"viewerElementToImageCoordinates",
"(... | Convert pixel coordinates relative to the window to image coordinates.
@param {OpenSeadragon.Point} pixel
@returns {OpenSeadragon.Point} | [
"Convert",
"pixel",
"coordinates",
"relative",
"to",
"the",
"window",
"to",
"image",
"coordinates",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tiledimage.js#L559-L563 | train | |
openseadragon/openseadragon | src/tiledimage.js | function( pixel ) {
var viewerCoordinates = this.imageToViewerElementCoordinates( pixel );
return viewerCoordinates.plus(
OpenSeadragon.getElementPosition( this.viewer.element ));
} | javascript | function( pixel ) {
var viewerCoordinates = this.imageToViewerElementCoordinates( pixel );
return viewerCoordinates.plus(
OpenSeadragon.getElementPosition( this.viewer.element ));
} | [
"function",
"(",
"pixel",
")",
"{",
"var",
"viewerCoordinates",
"=",
"this",
".",
"imageToViewerElementCoordinates",
"(",
"pixel",
")",
";",
"return",
"viewerCoordinates",
".",
"plus",
"(",
"OpenSeadragon",
".",
"getElementPosition",
"(",
"this",
".",
"viewer",
... | Convert image coordinates to pixel coordinates relative to the window.
@param {OpenSeadragon.Point} pixel
@returns {OpenSeadragon.Point} | [
"Convert",
"image",
"coordinates",
"to",
"pixel",
"coordinates",
"relative",
"to",
"the",
"window",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tiledimage.js#L570-L574 | train | |
openseadragon/openseadragon | src/tiledimage.js | function(position, immediately) {
var sameTarget = (this._xSpring.target.value === position.x &&
this._ySpring.target.value === position.y);
if (immediately) {
if (sameTarget && this._xSpring.current.value === position.x &&
this._ySpring.current.value === pos... | javascript | function(position, immediately) {
var sameTarget = (this._xSpring.target.value === position.x &&
this._ySpring.target.value === position.y);
if (immediately) {
if (sameTarget && this._xSpring.current.value === position.x &&
this._ySpring.current.value === pos... | [
"function",
"(",
"position",
",",
"immediately",
")",
"{",
"var",
"sameTarget",
"=",
"(",
"this",
".",
"_xSpring",
".",
"target",
".",
"value",
"===",
"position",
".",
"x",
"&&",
"this",
".",
"_ySpring",
".",
"target",
".",
"value",
"===",
"position",
... | Sets the TiledImage's position in the world.
@param {OpenSeadragon.Point} position - The new position, in viewport coordinates.
@param {Boolean} [immediately=false] - Whether to animate to the new position or snap immediately.
@fires OpenSeadragon.TiledImage.event:bounds-change | [
"Sets",
"the",
"TiledImage",
"s",
"position",
"in",
"the",
"world",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tiledimage.js#L629-L655 | train | |
openseadragon/openseadragon | src/tiledimage.js | function(degrees, immediately) {
if (this._degreesSpring.target.value === degrees &&
this._degreesSpring.isAtTargetValue()) {
return;
}
if (immediately) {
this._degreesSpring.resetTo(degrees);
} else {
this._degreesSpring.springTo(degrees);... | javascript | function(degrees, immediately) {
if (this._degreesSpring.target.value === degrees &&
this._degreesSpring.isAtTargetValue()) {
return;
}
if (immediately) {
this._degreesSpring.resetTo(degrees);
} else {
this._degreesSpring.springTo(degrees);... | [
"function",
"(",
"degrees",
",",
"immediately",
")",
"{",
"if",
"(",
"this",
".",
"_degreesSpring",
".",
"target",
".",
"value",
"===",
"degrees",
"&&",
"this",
".",
"_degreesSpring",
".",
"isAtTargetValue",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
... | Set the current rotation of this tiled image in degrees.
@param {Number} degrees the rotation in degrees.
@param {Boolean} [immediately=false] Whether to animate to the new angle
or rotate immediately.
@fires OpenSeadragon.TiledImage.event:bounds-change | [
"Set",
"the",
"current",
"rotation",
"of",
"this",
"tiled",
"image",
"in",
"degrees",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tiledimage.js#L845-L857 | train | |
openseadragon/openseadragon | src/drawer.js | function( opacity ) {
$.console.error("drawer.setOpacity is deprecated. Use tiledImage.setOpacity instead.");
var world = this.viewer.world;
for (var i = 0; i < world.getItemCount(); i++) {
world.getItemAt( i ).setOpacity( opacity );
}
return this;
} | javascript | function( opacity ) {
$.console.error("drawer.setOpacity is deprecated. Use tiledImage.setOpacity instead.");
var world = this.viewer.world;
for (var i = 0; i < world.getItemCount(); i++) {
world.getItemAt( i ).setOpacity( opacity );
}
return this;
} | [
"function",
"(",
"opacity",
")",
"{",
"$",
".",
"console",
".",
"error",
"(",
"\"drawer.setOpacity is deprecated. Use tiledImage.setOpacity instead.\"",
")",
";",
"var",
"world",
"=",
"this",
".",
"viewer",
".",
"world",
";",
"for",
"(",
"var",
"i",
"=",
"0",
... | Set the opacity of the drawer.
@param {Number} opacity
@return {OpenSeadragon.Drawer} Chainable. | [
"Set",
"the",
"opacity",
"of",
"the",
"drawer",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/drawer.js#L174-L181 | train | |
openseadragon/openseadragon | src/drawer.js | function() {
$.console.error("drawer.getOpacity is deprecated. Use tiledImage.getOpacity instead.");
var world = this.viewer.world;
var maxOpacity = 0;
for (var i = 0; i < world.getItemCount(); i++) {
var opacity = world.getItemAt( i ).getOpacity();
if ( opacity >... | javascript | function() {
$.console.error("drawer.getOpacity is deprecated. Use tiledImage.getOpacity instead.");
var world = this.viewer.world;
var maxOpacity = 0;
for (var i = 0; i < world.getItemCount(); i++) {
var opacity = world.getItemAt( i ).getOpacity();
if ( opacity >... | [
"function",
"(",
")",
"{",
"$",
".",
"console",
".",
"error",
"(",
"\"drawer.getOpacity is deprecated. Use tiledImage.getOpacity instead.\"",
")",
";",
"var",
"world",
"=",
"this",
".",
"viewer",
".",
"world",
";",
"var",
"maxOpacity",
"=",
"0",
";",
"for",
"(... | Get the opacity of the drawer.
@returns {Number} | [
"Get",
"the",
"opacity",
"of",
"the",
"drawer",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/drawer.js#L187-L198 | train | |
openseadragon/openseadragon | src/drawer.js | function() {
this.canvas.innerHTML = "";
if ( this.useCanvas ) {
var viewportSize = this._calculateCanvasSize();
if( this.canvas.width != viewportSize.x ||
this.canvas.height != viewportSize.y ) {
this.canvas.width = viewportSize.x;
... | javascript | function() {
this.canvas.innerHTML = "";
if ( this.useCanvas ) {
var viewportSize = this._calculateCanvasSize();
if( this.canvas.width != viewportSize.x ||
this.canvas.height != viewportSize.y ) {
this.canvas.width = viewportSize.x;
... | [
"function",
"(",
")",
"{",
"this",
".",
"canvas",
".",
"innerHTML",
"=",
"\"\"",
";",
"if",
"(",
"this",
".",
"useCanvas",
")",
"{",
"var",
"viewportSize",
"=",
"this",
".",
"_calculateCanvasSize",
"(",
")",
";",
"if",
"(",
"this",
".",
"canvas",
"."... | Clears the Drawer so it's ready to draw another frame. | [
"Clears",
"the",
"Drawer",
"so",
"it",
"s",
"ready",
"to",
"draw",
"another",
"frame",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/drawer.js#L248-L266 | train | |
openseadragon/openseadragon | src/drawer.js | function(tile, drawingHandler, useSketch, scale, translate) {
$.console.assert(tile, '[Drawer.drawTile] tile is required');
$.console.assert(drawingHandler, '[Drawer.drawTile] drawingHandler is required');
if (this.useCanvas) {
var context = this._getContext(useSketch);
... | javascript | function(tile, drawingHandler, useSketch, scale, translate) {
$.console.assert(tile, '[Drawer.drawTile] tile is required');
$.console.assert(drawingHandler, '[Drawer.drawTile] drawingHandler is required');
if (this.useCanvas) {
var context = this._getContext(useSketch);
... | [
"function",
"(",
"tile",
",",
"drawingHandler",
",",
"useSketch",
",",
"scale",
",",
"translate",
")",
"{",
"$",
".",
"console",
".",
"assert",
"(",
"tile",
",",
"'[Drawer.drawTile] tile is required'",
")",
";",
"$",
".",
"console",
".",
"assert",
"(",
"dr... | Draws the given tile.
@param {OpenSeadragon.Tile} tile - The tile to draw.
@param {Function} drawingHandler - Method for firing the drawing event if using canvas.
drawingHandler({context, tile, rendered})
@param {Boolean} useSketch - Whether to use the sketch canvas or not.
where <code>rendered</code> is the context wi... | [
"Draws",
"the",
"given",
"tile",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/drawer.js#L309-L320 | train | |
openseadragon/openseadragon | src/drawer.js | function(opacity, scale, translate, compositeOperation) {
var options = opacity;
if (!$.isPlainObject(options)) {
options = {
opacity: opacity,
scale: scale,
translate: translate,
compositeOperation: compositeOperation
... | javascript | function(opacity, scale, translate, compositeOperation) {
var options = opacity;
if (!$.isPlainObject(options)) {
options = {
opacity: opacity,
scale: scale,
translate: translate,
compositeOperation: compositeOperation
... | [
"function",
"(",
"opacity",
",",
"scale",
",",
"translate",
",",
"compositeOperation",
")",
"{",
"var",
"options",
"=",
"opacity",
";",
"if",
"(",
"!",
"$",
".",
"isPlainObject",
"(",
"options",
")",
")",
"{",
"options",
"=",
"{",
"opacity",
":",
"opac... | Blends the sketch canvas in the main canvas.
@param {Object} options The options
@param {Float} options.opacity The opacity of the blending.
@param {Float} [options.scale=1] The scale at which tiles were drawn on
the sketch. Default is 1.
Use scale to draw at a lower scale and then enlarge onto the main canvas.
@param ... | [
"Blends",
"the",
"sketch",
"canvas",
"in",
"the",
"main",
"canvas",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/drawer.js#L413-L492 | train | |
openseadragon/openseadragon | src/drawer.js | function(sketch) {
var canvas = this._getContext(sketch).canvas;
return new $.Point(canvas.width, canvas.height);
} | javascript | function(sketch) {
var canvas = this._getContext(sketch).canvas;
return new $.Point(canvas.width, canvas.height);
} | [
"function",
"(",
"sketch",
")",
"{",
"var",
"canvas",
"=",
"this",
".",
"_getContext",
"(",
"sketch",
")",
".",
"canvas",
";",
"return",
"new",
"$",
".",
"Point",
"(",
"canvas",
".",
"width",
",",
"canvas",
".",
"height",
")",
";",
"}"
] | Get the canvas size
@param {Boolean} sketch If set to true return the size of the sketch canvas
@returns {OpenSeadragon.Point} The size of the canvas | [
"Get",
"the",
"canvas",
"size"
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/drawer.js#L647-L650 | train | |
openseadragon/openseadragon | src/tilesource.js | processResponse | function processResponse( xhr ){
var responseText = xhr.responseText,
status = xhr.status,
statusText,
data;
if ( !xhr ) {
throw new Error( $.getString( "Errors.Security" ) );
} else if ( xhr.status !== 200 && xhr.status !== 0 ) {
status = xhr.status;
... | javascript | function processResponse( xhr ){
var responseText = xhr.responseText,
status = xhr.status,
statusText,
data;
if ( !xhr ) {
throw new Error( $.getString( "Errors.Security" ) );
} else if ( xhr.status !== 200 && xhr.status !== 0 ) {
status = xhr.status;
... | [
"function",
"processResponse",
"(",
"xhr",
")",
"{",
"var",
"responseText",
"=",
"xhr",
".",
"responseText",
",",
"status",
"=",
"xhr",
".",
"status",
",",
"statusText",
",",
"data",
";",
"if",
"(",
"!",
"xhr",
")",
"{",
"throw",
"new",
"Error",
"(",
... | Decides whether to try to process the response as xml, json, or hand back
the text
@private
@inner
@function
@param {XMLHttpRequest} xhr - the completed network request | [
"Decides",
"whether",
"to",
"try",
"to",
"process",
"the",
"response",
"as",
"xml",
"json",
"or",
"hand",
"back",
"the",
"text"
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tilesource.js#L633-L667 | train |
openseadragon/openseadragon | src/tilecache.js | function( options ) {
$.console.assert( options, "[TileCache.cacheTile] options is required" );
$.console.assert( options.tile, "[TileCache.cacheTile] options.tile is required" );
$.console.assert( options.tile.cacheKey, "[TileCache.cacheTile] options.tile.cacheKey is required" );
$.cons... | javascript | function( options ) {
$.console.assert( options, "[TileCache.cacheTile] options is required" );
$.console.assert( options.tile, "[TileCache.cacheTile] options.tile is required" );
$.console.assert( options.tile.cacheKey, "[TileCache.cacheTile] options.tile.cacheKey is required" );
$.cons... | [
"function",
"(",
"options",
")",
"{",
"$",
".",
"console",
".",
"assert",
"(",
"options",
",",
"\"[TileCache.cacheTile] options is required\"",
")",
";",
"$",
".",
"console",
".",
"assert",
"(",
"options",
".",
"tile",
",",
"\"[TileCache.cacheTile] options.tile is... | Caches the specified tile, removing an old tile if necessary to stay under the
maxImageCacheCount specified on construction. Note that if multiple tiles reference
the same image, there may be more tiles than maxImageCacheCount; the goal is to keep
the number of images below that number. Note, as well, that even the num... | [
"Caches",
"the",
"specified",
"tile",
"removing",
"an",
"old",
"tile",
"if",
"necessary",
"to",
"stay",
"under",
"the",
"maxImageCacheCount",
"specified",
"on",
"construction",
".",
"Note",
"that",
"if",
"multiple",
"tiles",
"reference",
"the",
"same",
"image",
... | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tilecache.js#L150-L216 | train | |
openseadragon/openseadragon | src/tilecache.js | function( tiledImage ) {
$.console.assert(tiledImage, '[TileCache.clearTilesFor] tiledImage is required');
var tileRecord;
for ( var i = 0; i < this._tilesLoaded.length; ++i ) {
tileRecord = this._tilesLoaded[ i ];
if ( tileRecord.tiledImage === tiledImage ) {
... | javascript | function( tiledImage ) {
$.console.assert(tiledImage, '[TileCache.clearTilesFor] tiledImage is required');
var tileRecord;
for ( var i = 0; i < this._tilesLoaded.length; ++i ) {
tileRecord = this._tilesLoaded[ i ];
if ( tileRecord.tiledImage === tiledImage ) {
... | [
"function",
"(",
"tiledImage",
")",
"{",
"$",
".",
"console",
".",
"assert",
"(",
"tiledImage",
",",
"'[TileCache.clearTilesFor] tiledImage is required'",
")",
";",
"var",
"tileRecord",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"_t... | Clears all tiles associated with the specified tiledImage.
@param {OpenSeadragon.TiledImage} tiledImage | [
"Clears",
"all",
"tiles",
"associated",
"with",
"the",
"specified",
"tiledImage",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/tilecache.js#L222-L233 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( object, method ) {
return function(){
var args = arguments;
if ( args === undefined ){
args = [];
}
return method.apply( object, args );
};
} | javascript | function( object, method ) {
return function(){
var args = arguments;
if ( args === undefined ){
args = [];
}
return method.apply( object, args );
};
} | [
"function",
"(",
"object",
",",
"method",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
";",
"if",
"(",
"args",
"===",
"undefined",
")",
"{",
"args",
"=",
"[",
"]",
";",
"}",
"return",
"method",
".",
"apply",
"(",
... | Returns a function which invokes the method as if it were a method belonging to the object.
@function
@param {Object} object
@param {Function} method
@returns {Function} | [
"Returns",
"a",
"function",
"which",
"invokes",
"the",
"method",
"as",
"if",
"it",
"were",
"a",
"method",
"belonging",
"to",
"the",
"object",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1297-L1305 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( element ) {
var result = new $.Point(),
isFixed,
offsetParent;
element = $.getElement( element );
isFixed = $.getElementStyle( element ).position == "fixed";
offsetParent = getOffsetParent( element, isFixed );
... | javascript | function( element ) {
var result = new $.Point(),
isFixed,
offsetParent;
element = $.getElement( element );
isFixed = $.getElementStyle( element ).position == "fixed";
offsetParent = getOffsetParent( element, isFixed );
... | [
"function",
"(",
"element",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Point",
"(",
")",
",",
"isFixed",
",",
"offsetParent",
";",
"element",
"=",
"$",
".",
"getElement",
"(",
"element",
")",
";",
"isFixed",
"=",
"$",
".",
"getElementStyle",
"... | Determines the position of the upper-left corner of the element.
@function
@param {Element|String} element - the element we want the position for.
@returns {OpenSeadragon.Point} - the position of the upper left corner of the element. | [
"Determines",
"the",
"position",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"element",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1349-L1373 | train | |
openseadragon/openseadragon | src/openseadragon.js | function(property) {
var memo = {};
$.getCssPropertyWithVendorPrefix = function(property) {
if (memo[property] !== undefined) {
return memo[property];
}
var style = document.createElement('div').style;
var resul... | javascript | function(property) {
var memo = {};
$.getCssPropertyWithVendorPrefix = function(property) {
if (memo[property] !== undefined) {
return memo[property];
}
var style = document.createElement('div').style;
var resul... | [
"function",
"(",
"property",
")",
"{",
"var",
"memo",
"=",
"{",
"}",
";",
"$",
".",
"getCssPropertyWithVendorPrefix",
"=",
"function",
"(",
"property",
")",
"{",
"if",
"(",
"memo",
"[",
"property",
"]",
"!==",
"undefined",
")",
"{",
"return",
"memo",
"... | Returns the property with the correct vendor prefix appended.
@param {String} property the property name
@returns {String} the property with the correct prefix or null if not
supported. | [
"Returns",
"the",
"property",
"with",
"the",
"correct",
"vendor",
"prefix",
"appended",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1452-L1479 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( event ) {
if( event ){
$.getEvent = function( event ) {
return event;
};
} else {
$.getEvent = function() {
return window.event;
};
}
return $.getEvent( event... | javascript | function( event ) {
if( event ){
$.getEvent = function( event ) {
return event;
};
} else {
$.getEvent = function() {
return window.event;
};
}
return $.getEvent( event... | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
")",
"{",
"$",
".",
"getEvent",
"=",
"function",
"(",
"event",
")",
"{",
"return",
"event",
";",
"}",
";",
"}",
"else",
"{",
"$",
".",
"getEvent",
"=",
"function",
"(",
")",
"{",
"return",
... | Gets the latest event, really only useful internally since its
specific to IE behavior.
@function
@param {Event} [event]
@returns {Event}
@deprecated For internal use only
@private | [
"Gets",
"the",
"latest",
"event",
"really",
"only",
"useful",
"internally",
"since",
"its",
"specific",
"to",
"IE",
"behavior",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1529-L1540 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( event ) {
if ( typeof ( event.pageX ) == "number" ) {
$.getMousePosition = function( event ){
var result = new $.Point();
event = $.getEvent( event );
result.x = event.pageX;
result.y = event.pageY;
... | javascript | function( event ) {
if ( typeof ( event.pageX ) == "number" ) {
$.getMousePosition = function( event ){
var result = new $.Point();
event = $.getEvent( event );
result.x = event.pageX;
result.y = event.pageY;
... | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"typeof",
"(",
"event",
".",
"pageX",
")",
"==",
"\"number\"",
")",
"{",
"$",
".",
"getMousePosition",
"=",
"function",
"(",
"event",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Point",
"(",
")",... | Gets the position of the mouse on the screen for a given event.
@function
@param {Event} [event]
@returns {OpenSeadragon.Point} | [
"Gets",
"the",
"position",
"of",
"the",
"mouse",
"on",
"the",
"screen",
"for",
"a",
"given",
"event",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1549-L1584 | train | |
openseadragon/openseadragon | src/openseadragon.js | function() {
var docElement = document.documentElement || {},
body = document.body || {};
if ( typeof ( window.pageXOffset ) == "number" ) {
$.getPageScroll = function(){
return new $.Point(
window.pageXOffset,
... | javascript | function() {
var docElement = document.documentElement || {},
body = document.body || {};
if ( typeof ( window.pageXOffset ) == "number" ) {
$.getPageScroll = function(){
return new $.Point(
window.pageXOffset,
... | [
"function",
"(",
")",
"{",
"var",
"docElement",
"=",
"document",
".",
"documentElement",
"||",
"{",
"}",
",",
"body",
"=",
"document",
".",
"body",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"(",
"window",
".",
"pageXOffset",
")",
"==",
"\"number\"",
... | Determines the page's current scroll position.
@function
@returns {OpenSeadragon.Point} | [
"Determines",
"the",
"page",
"s",
"current",
"scroll",
"position",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1592-L1623 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( scroll ) {
if ( typeof ( window.scrollTo ) !== "undefined" ) {
$.setPageScroll = function( scroll ) {
window.scrollTo( scroll.x, scroll.y );
};
} else {
var originalScroll = $.getPageScroll();
if ( orig... | javascript | function( scroll ) {
if ( typeof ( window.scrollTo ) !== "undefined" ) {
$.setPageScroll = function( scroll ) {
window.scrollTo( scroll.x, scroll.y );
};
} else {
var originalScroll = $.getPageScroll();
if ( orig... | [
"function",
"(",
"scroll",
")",
"{",
"if",
"(",
"typeof",
"(",
"window",
".",
"scrollTo",
")",
"!==",
"\"undefined\"",
")",
"{",
"$",
".",
"setPageScroll",
"=",
"function",
"(",
"scroll",
")",
"{",
"window",
".",
"scrollTo",
"(",
"scroll",
".",
"x",
... | Set the page scroll position.
@function
@returns {OpenSeadragon.Point} | [
"Set",
"the",
"page",
"scroll",
"position",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1630-L1674 | train | |
openseadragon/openseadragon | src/openseadragon.js | function() {
var docElement = document.documentElement || {},
body = document.body || {};
if ( typeof ( window.innerWidth ) == 'number' ) {
$.getWindowSize = function(){
return new $.Point(
window.innerWidth,
... | javascript | function() {
var docElement = document.documentElement || {},
body = document.body || {};
if ( typeof ( window.innerWidth ) == 'number' ) {
$.getWindowSize = function(){
return new $.Point(
window.innerWidth,
... | [
"function",
"(",
")",
"{",
"var",
"docElement",
"=",
"document",
".",
"documentElement",
"||",
"{",
"}",
",",
"body",
"=",
"document",
".",
"body",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"(",
"window",
".",
"innerWidth",
")",
"==",
"'number'",
")"... | Determines the size of the browsers window.
@function
@returns {OpenSeadragon.Point} | [
"Determines",
"the",
"size",
"of",
"the",
"browsers",
"window",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1681-L1711 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( element ) {
// Convert a possible ID to an actual HTMLElement
element = $.getElement( element );
/*
CSS tables require you to have a display:table/row/cell hierarchy so we need to create
three nested wrapper divs:
*/
... | javascript | function( element ) {
// Convert a possible ID to an actual HTMLElement
element = $.getElement( element );
/*
CSS tables require you to have a display:table/row/cell hierarchy so we need to create
three nested wrapper divs:
*/
... | [
"function",
"(",
"element",
")",
"{",
"// Convert a possible ID to an actual HTMLElement",
"element",
"=",
"$",
".",
"getElement",
"(",
"element",
")",
";",
"/*\n CSS tables require you to have a display:table/row/cell hierarchy so we need to create\n thre... | Wraps the given element in a nest of divs so that the element can
be easily centered using CSS tables
@function
@param {Element|String} element
@returns {Element} outermost wrapper element | [
"Wraps",
"the",
"given",
"element",
"in",
"a",
"nest",
"of",
"divs",
"so",
"that",
"the",
"element",
"can",
"be",
"easily",
"centered",
"using",
"CSS",
"tables"
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1721-L1758 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( tagName ) {
var element = document.createElement( tagName ),
style = element.style;
style.background = "transparent none";
style.border = "none";
style.margin = "0px";
style.padding = "0px";
style.position ... | javascript | function( tagName ) {
var element = document.createElement( tagName ),
style = element.style;
style.background = "transparent none";
style.border = "none";
style.margin = "0px";
style.padding = "0px";
style.position ... | [
"function",
"(",
"tagName",
")",
"{",
"var",
"element",
"=",
"document",
".",
"createElement",
"(",
"tagName",
")",
",",
"style",
"=",
"element",
".",
"style",
";",
"style",
".",
"background",
"=",
"\"transparent none\"",
";",
"style",
".",
"border",
"=",
... | Creates an easily positionable element of the given type that therefor
serves as an excellent container element.
@function
@param {String} tagName
@returns {Element} | [
"Creates",
"an",
"easily",
"positionable",
"element",
"of",
"the",
"given",
"type",
"that",
"therefor",
"serves",
"as",
"an",
"excellent",
"container",
"element",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1768-L1779 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( src ) {
$.makeTransparentImage = function( src ){
var img = $.makeNeutralElement( "img" );
img.src = src;
return img;
};
if ( $.Browser.vendor == $.BROWSERS.IE && $.Browser.version < 7 ) {
$.makeTransparen... | javascript | function( src ) {
$.makeTransparentImage = function( src ){
var img = $.makeNeutralElement( "img" );
img.src = src;
return img;
};
if ( $.Browser.vendor == $.BROWSERS.IE && $.Browser.version < 7 ) {
$.makeTransparen... | [
"function",
"(",
"src",
")",
"{",
"$",
".",
"makeTransparentImage",
"=",
"function",
"(",
"src",
")",
"{",
"var",
"img",
"=",
"$",
".",
"makeNeutralElement",
"(",
"\"img\"",
")",
";",
"img",
".",
"src",
"=",
"src",
";",
"return",
"img",
";",
"}",
"... | Ensures an image is loaded correctly to support alpha transparency.
Generally only IE has issues doing this correctly for formats like
png.
@function
@param {String} src
@returns {Element} | [
"Ensures",
"an",
"image",
"is",
"loaded",
"correctly",
"to",
"support",
"alpha",
"transparency",
".",
"Generally",
"only",
"IE",
"has",
"issues",
"doing",
"this",
"correctly",
"for",
"formats",
"like",
"png",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1807-L1846 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( element, opacity, usesAlpha ) {
var ieOpacity,
ieFilter;
element = $.getElement( element );
if ( usesAlpha && !$.Browser.alpha ) {
opacity = Math.round( opacity );
}
if ( $.Browser.opacity ) {
eleme... | javascript | function( element, opacity, usesAlpha ) {
var ieOpacity,
ieFilter;
element = $.getElement( element );
if ( usesAlpha && !$.Browser.alpha ) {
opacity = Math.round( opacity );
}
if ( $.Browser.opacity ) {
eleme... | [
"function",
"(",
"element",
",",
"opacity",
",",
"usesAlpha",
")",
"{",
"var",
"ieOpacity",
",",
"ieFilter",
";",
"element",
"=",
"$",
".",
"getElement",
"(",
"element",
")",
";",
"if",
"(",
"usesAlpha",
"&&",
"!",
"$",
".",
"Browser",
".",
"alpha",
... | Sets the opacity of the specified element.
@function
@param {Element|String} element
@param {Number} opacity
@param {Boolean} [usesAlpha] | [
"Sets",
"the",
"opacity",
"of",
"the",
"specified",
"element",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1856-L1878 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( element ) {
element = $.getElement( element );
if ( typeof element.style.touchAction !== 'undefined' ) {
element.style.touchAction = 'none';
} else if ( typeof element.style.msTouchAction !== 'undefined' ) {
element.style.msTouchAction = 'non... | javascript | function( element ) {
element = $.getElement( element );
if ( typeof element.style.touchAction !== 'undefined' ) {
element.style.touchAction = 'none';
} else if ( typeof element.style.msTouchAction !== 'undefined' ) {
element.style.msTouchAction = 'non... | [
"function",
"(",
"element",
")",
"{",
"element",
"=",
"$",
".",
"getElement",
"(",
"element",
")",
";",
"if",
"(",
"typeof",
"element",
".",
"style",
".",
"touchAction",
"!==",
"'undefined'",
")",
"{",
"element",
".",
"style",
".",
"touchAction",
"=",
... | Sets the specified element's touch-action style attribute to 'none'.
@function
@param {Element|String} element | [
"Sets",
"the",
"specified",
"element",
"s",
"touch",
"-",
"action",
"style",
"attribute",
"to",
"none",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1886-L1893 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( element, className ) {
element = $.getElement( element );
if (!element.className) {
element.className = className;
} else if ( ( ' ' + element.className + ' ' ).
indexOf( ' ' + className + ' ' ) === -1 ) {
element.className +... | javascript | function( element, className ) {
element = $.getElement( element );
if (!element.className) {
element.className = className;
} else if ( ( ' ' + element.className + ' ' ).
indexOf( ' ' + className + ' ' ) === -1 ) {
element.className +... | [
"function",
"(",
"element",
",",
"className",
")",
"{",
"element",
"=",
"$",
".",
"getElement",
"(",
"element",
")",
";",
"if",
"(",
"!",
"element",
".",
"className",
")",
"{",
"element",
".",
"className",
"=",
"className",
";",
"}",
"else",
"if",
"(... | Add the specified CSS class to the element if not present.
@function
@param {Element|String} element
@param {String} className | [
"Add",
"the",
"specified",
"CSS",
"class",
"to",
"the",
"element",
"if",
"not",
"present",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1902-L1911 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( array, searchElement, fromIndex ) {
if ( Array.prototype.indexOf ) {
this.indexOf = function( array, searchElement, fromIndex ) {
return array.indexOf( searchElement, fromIndex );
};
} else {
this.indexOf = function( a... | javascript | function( array, searchElement, fromIndex ) {
if ( Array.prototype.indexOf ) {
this.indexOf = function( array, searchElement, fromIndex ) {
return array.indexOf( searchElement, fromIndex );
};
} else {
this.indexOf = function( a... | [
"function",
"(",
"array",
",",
"searchElement",
",",
"fromIndex",
")",
"{",
"if",
"(",
"Array",
".",
"prototype",
".",
"indexOf",
")",
"{",
"this",
".",
"indexOf",
"=",
"function",
"(",
"array",
",",
"searchElement",
",",
"fromIndex",
")",
"{",
"return",... | Find the first index at which an element is found in an array or -1
if not present.
Code taken and adapted from
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf#Compatibility
@function
@param {Array} array The array from which to find the element
@param {Object} searchEle... | [
"Find",
"the",
"first",
"index",
"at",
"which",
"an",
"element",
"is",
"found",
"in",
"an",
"array",
"or",
"-",
"1",
"if",
"not",
"present",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1926-L1958 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( element, className ) {
var oldClasses,
newClasses = [],
i;
element = $.getElement( element );
oldClasses = element.className.split( /\s+/ );
for ( i = 0; i < oldClasses.length; i++ ) {
if ( oldClasses[ i ] && oldC... | javascript | function( element, className ) {
var oldClasses,
newClasses = [],
i;
element = $.getElement( element );
oldClasses = element.className.split( /\s+/ );
for ( i = 0; i < oldClasses.length; i++ ) {
if ( oldClasses[ i ] && oldC... | [
"function",
"(",
"element",
",",
"className",
")",
"{",
"var",
"oldClasses",
",",
"newClasses",
"=",
"[",
"]",
",",
"i",
";",
"element",
"=",
"$",
".",
"getElement",
"(",
"element",
")",
";",
"oldClasses",
"=",
"element",
".",
"className",
".",
"split"... | Remove the specified CSS class from the element.
@function
@param {Element|String} element
@param {String} className | [
"Remove",
"the",
"specified",
"CSS",
"class",
"from",
"the",
"element",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L1966-L1979 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( event ) {
event = $.getEvent( event );
if ( event.preventDefault ) {
$.cancelEvent = function( event ){
// W3C for preventing default
event.preventDefault();
};
} else {
$.cancelEvent =... | javascript | function( event ) {
event = $.getEvent( event );
if ( event.preventDefault ) {
$.cancelEvent = function( event ){
// W3C for preventing default
event.preventDefault();
};
} else {
$.cancelEvent =... | [
"function",
"(",
"event",
")",
"{",
"event",
"=",
"$",
".",
"getEvent",
"(",
"event",
")",
";",
"if",
"(",
"event",
".",
"preventDefault",
")",
"{",
"$",
".",
"cancelEvent",
"=",
"function",
"(",
"event",
")",
"{",
"// W3C for preventing default",
"event... | Cancels the default browser behavior had the event propagated all
the way up the DOM to the window object.
@function
@param {Event} [event] | [
"Cancels",
"the",
"default",
"browser",
"behavior",
"had",
"the",
"event",
"propagated",
"all",
"the",
"way",
"up",
"the",
"DOM",
"to",
"the",
"window",
"object",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L2039-L2057 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( event ) {
event = $.getEvent( event );
if ( event.stopPropagation ) {
// W3C for stopping propagation
$.stopEvent = function( event ){
event.stopPropagation();
};
} else {
// IE for stoppin... | javascript | function( event ) {
event = $.getEvent( event );
if ( event.stopPropagation ) {
// W3C for stopping propagation
$.stopEvent = function( event ){
event.stopPropagation();
};
} else {
// IE for stoppin... | [
"function",
"(",
"event",
")",
"{",
"event",
"=",
"$",
".",
"getEvent",
"(",
"event",
")",
";",
"if",
"(",
"event",
".",
"stopPropagation",
")",
"{",
"// W3C for stopping propagation",
"$",
".",
"stopEvent",
"=",
"function",
"(",
"event",
")",
"{",
"even... | Stops the propagation of the event up the DOM.
@function
@param {Event} [event] | [
"Stops",
"the",
"propagation",
"of",
"the",
"event",
"up",
"the",
"DOM",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L2065-L2083 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( object, method ) {
//TODO: This pattern is painful to use and debug. It's much cleaner
// to use pinning plus anonymous functions. Get rid of this
// pattern!
var initialArgs = [],
i;
for ( i = 2; i < arguments.length; i++... | javascript | function( object, method ) {
//TODO: This pattern is painful to use and debug. It's much cleaner
// to use pinning plus anonymous functions. Get rid of this
// pattern!
var initialArgs = [],
i;
for ( i = 2; i < arguments.length; i++... | [
"function",
"(",
"object",
",",
"method",
")",
"{",
"//TODO: This pattern is painful to use and debug. It's much cleaner",
"// to use pinning plus anonymous functions. Get rid of this",
"// pattern!",
"var",
"initialArgs",
"=",
"[",
"]",
",",
"i",
";",
"for",
"(",
... | Similar to OpenSeadragon.delegate, but it does not immediately call
the method on the object, returning a function which can be called
repeatedly to delegate the method. It also allows additional arguments
to be passed during construction which will be added during each
invocation, and each invocation can add additiona... | [
"Similar",
"to",
"OpenSeadragon",
".",
"delegate",
"but",
"it",
"does",
"not",
"immediately",
"call",
"the",
"method",
"on",
"the",
"object",
"returning",
"a",
"function",
"which",
"can",
"be",
"called",
"repeatedly",
"to",
"delegate",
"the",
"method",
".",
... | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L2100-L2119 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( url ) {
var match = url.match(/^([a-z]+:)\/\//i);
if ( match === null ) {
// Relative URL, retrive the protocol from window.location
return window.location.protocol;
}
return match[1].toLowerCase();
} | javascript | function( url ) {
var match = url.match(/^([a-z]+:)\/\//i);
if ( match === null ) {
// Relative URL, retrive the protocol from window.location
return window.location.protocol;
}
return match[1].toLowerCase();
} | [
"function",
"(",
"url",
")",
"{",
"var",
"match",
"=",
"url",
".",
"match",
"(",
"/",
"^([a-z]+:)\\/\\/",
"/",
"i",
")",
";",
"if",
"(",
"match",
"===",
"null",
")",
"{",
"// Relative URL, retrive the protocol from window.location",
"return",
"window",
".",
... | Retrieves the protocol used by the url. The url can either be absolute
or relative.
@function
@private
@param {String} url The url to retrieve the protocol from.
@return {String} The protocol (http:, https:, file:, ftp: ...) | [
"Retrieves",
"the",
"protocol",
"used",
"by",
"the",
"url",
".",
"The",
"url",
"can",
"either",
"be",
"absolute",
"or",
"relative",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L2142-L2149 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( local ) {
// IE11 does not support window.ActiveXObject so we just try to
// create one to see if it is supported.
// See: http://msdn.microsoft.com/en-us/library/ie/dn423948%28v=vs.85%29.aspx
var supportActiveX;
try {
/* global Activ... | javascript | function( local ) {
// IE11 does not support window.ActiveXObject so we just try to
// create one to see if it is supported.
// See: http://msdn.microsoft.com/en-us/library/ie/dn423948%28v=vs.85%29.aspx
var supportActiveX;
try {
/* global Activ... | [
"function",
"(",
"local",
")",
"{",
"// IE11 does not support window.ActiveXObject so we just try to",
"// create one to see if it is supported.",
"// See: http://msdn.microsoft.com/en-us/library/ie/dn423948%28v=vs.85%29.aspx",
"var",
"supportActiveX",
";",
"try",
"{",
"/* global ActiveXOb... | Create an XHR object
@private
@param {type} [local] If set to true, the XHR will be file: protocol
compatible if possible (but may raise a warning in the browser).
@returns {XMLHttpRequest} | [
"Create",
"an",
"XHR",
"object"
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L2158-L2191 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( options ){
var script,
url = options.url,
head = document.head ||
document.getElementsByTagName( "head" )[ 0 ] ||
document.documentElement,
jsonpCallback = options.callbackName || 'openseadragon' + $.now... | javascript | function( options ){
var script,
url = options.url,
head = document.head ||
document.getElementsByTagName( "head" )[ 0 ] ||
document.documentElement,
jsonpCallback = options.callbackName || 'openseadragon' + $.now... | [
"function",
"(",
"options",
")",
"{",
"var",
"script",
",",
"url",
"=",
"options",
".",
"url",
",",
"head",
"=",
"document",
".",
"head",
"||",
"document",
".",
"getElementsByTagName",
"(",
"\"head\"",
")",
"[",
"0",
"]",
"||",
"document",
".",
"docume... | Taken from jQuery 1.6.1
@function
@param {Object} options
@param {String} options.url
@param {Function} options.callback
@param {String} [options.param='callback'] The name of the url parameter
to request the jsonp provider with.
@param {String} [options.callbackName=] The name of the callback to
request the jsonp prov... | [
"Taken",
"from",
"jQuery",
"1",
".",
"6",
".",
"1"
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L2344-L2410 | train | |
openseadragon/openseadragon | src/openseadragon.js | function( string ) {
if ( window.DOMParser ) {
$.parseXml = function( string ) {
var xmlDoc = null,
parser;
parser = new DOMParser();
xmlDoc = parser.parseFromString( string, "text/xml" );
... | javascript | function( string ) {
if ( window.DOMParser ) {
$.parseXml = function( string ) {
var xmlDoc = null,
parser;
parser = new DOMParser();
xmlDoc = parser.parseFromString( string, "text/xml" );
... | [
"function",
"(",
"string",
")",
"{",
"if",
"(",
"window",
".",
"DOMParser",
")",
"{",
"$",
".",
"parseXml",
"=",
"function",
"(",
"string",
")",
"{",
"var",
"xmlDoc",
"=",
"null",
",",
"parser",
";",
"parser",
"=",
"new",
"DOMParser",
"(",
")",
";"... | Parses an XML string into a DOM Document.
@function
@param {String} string
@returns {Document} | [
"Parses",
"an",
"XML",
"string",
"into",
"a",
"DOM",
"Document",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L2428-L2456 | train | |
openseadragon/openseadragon | src/openseadragon.js | function(string) {
if (window.JSON && window.JSON.parse) {
$.parseJSON = window.JSON.parse;
} else {
// Should only be used by IE8 in non standards mode
$.parseJSON = function(string) {
/*jshint evil:true*/
/... | javascript | function(string) {
if (window.JSON && window.JSON.parse) {
$.parseJSON = window.JSON.parse;
} else {
// Should only be used by IE8 in non standards mode
$.parseJSON = function(string) {
/*jshint evil:true*/
/... | [
"function",
"(",
"string",
")",
"{",
"if",
"(",
"window",
".",
"JSON",
"&&",
"window",
".",
"JSON",
".",
"parse",
")",
"{",
"$",
".",
"parseJSON",
"=",
"window",
".",
"JSON",
".",
"parse",
";",
"}",
"else",
"{",
"// Should only be used by IE8 in non stan... | Parses a JSON string into a Javascript object.
@function
@param {String} string
@returns {Object} | [
"Parses",
"a",
"JSON",
"string",
"into",
"a",
"Javascript",
"object",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/openseadragon.js#L2464-L2476 | train | |
openseadragon/openseadragon | src/rectangle.js | function(other) {
return (other instanceof $.Rect) &&
this.x === other.x &&
this.y === other.y &&
this.width === other.width &&
this.height === other.height &&
this.degrees === other.degrees;
} | javascript | function(other) {
return (other instanceof $.Rect) &&
this.x === other.x &&
this.y === other.y &&
this.width === other.width &&
this.height === other.height &&
this.degrees === other.degrees;
} | [
"function",
"(",
"other",
")",
"{",
"return",
"(",
"other",
"instanceof",
"$",
".",
"Rect",
")",
"&&",
"this",
".",
"x",
"===",
"other",
".",
"x",
"&&",
"this",
".",
"y",
"===",
"other",
".",
"y",
"&&",
"this",
".",
"width",
"===",
"other",
".",
... | Determines if two Rectangles have equivalent components.
@function
@param {OpenSeadragon.Rect} rectangle The Rectangle to compare to.
@return {Boolean} 'true' if all components are equal, otherwise 'false'. | [
"Determines",
"if",
"two",
"Rectangles",
"have",
"equivalent",
"components",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/rectangle.js#L240-L247 | train | |
openseadragon/openseadragon | src/rectangle.js | function(rect) {
var thisBoundingBox = this.getBoundingBox();
var otherBoundingBox = rect.getBoundingBox();
var left = Math.min(thisBoundingBox.x, otherBoundingBox.x);
var top = Math.min(thisBoundingBox.y, otherBoundingBox.y);
var right = Math.max(
thisBoundingBox.x ... | javascript | function(rect) {
var thisBoundingBox = this.getBoundingBox();
var otherBoundingBox = rect.getBoundingBox();
var left = Math.min(thisBoundingBox.x, otherBoundingBox.x);
var top = Math.min(thisBoundingBox.y, otherBoundingBox.y);
var right = Math.max(
thisBoundingBox.x ... | [
"function",
"(",
"rect",
")",
"{",
"var",
"thisBoundingBox",
"=",
"this",
".",
"getBoundingBox",
"(",
")",
";",
"var",
"otherBoundingBox",
"=",
"rect",
".",
"getBoundingBox",
"(",
")",
";",
"var",
"left",
"=",
"Math",
".",
"min",
"(",
"thisBoundingBox",
... | Returns the smallest rectangle that will contain this and the given
rectangle bounding boxes.
@param {OpenSeadragon.Rect} rect
@return {OpenSeadragon.Rect} The new rectangle. | [
"Returns",
"the",
"smallest",
"rectangle",
"that",
"will",
"contain",
"this",
"and",
"the",
"given",
"rectangle",
"bounding",
"boxes",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/rectangle.js#L287-L305 | train | |
openseadragon/openseadragon | src/rectangle.js | function(degrees, pivot) {
degrees = $.positiveModulo(degrees, 360);
if (degrees === 0) {
return this.clone();
}
pivot = pivot || this.getCenter();
var newTopLeft = this.getTopLeft().rotate(degrees, pivot);
var newTopRight = this.getTopRight().rotate(degrees,... | javascript | function(degrees, pivot) {
degrees = $.positiveModulo(degrees, 360);
if (degrees === 0) {
return this.clone();
}
pivot = pivot || this.getCenter();
var newTopLeft = this.getTopLeft().rotate(degrees, pivot);
var newTopRight = this.getTopRight().rotate(degrees,... | [
"function",
"(",
"degrees",
",",
"pivot",
")",
"{",
"degrees",
"=",
"$",
".",
"positiveModulo",
"(",
"degrees",
",",
"360",
")",
";",
"if",
"(",
"degrees",
"===",
"0",
")",
"{",
"return",
"this",
".",
"clone",
"(",
")",
";",
"}",
"pivot",
"=",
"p... | Rotates a rectangle around a point.
@function
@param {Number} degrees The angle in degrees to rotate.
@param {OpenSeadragon.Point} [pivot] The point about which to rotate.
Defaults to the center of the rectangle.
@return {OpenSeadragon.Rect} | [
"Rotates",
"a",
"rectangle",
"around",
"a",
"point",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/rectangle.js#L441-L469 | train | |
openseadragon/openseadragon | src/rectangle.js | function() {
return "[" +
(Math.round(this.x * 100) / 100) + ", " +
(Math.round(this.y * 100) / 100) + ", " +
(Math.round(this.width * 100) / 100) + "x" +
(Math.round(this.height * 100) / 100) + ", " +
(Math.round(this.degrees * 100) / 100) + "deg" +
... | javascript | function() {
return "[" +
(Math.round(this.x * 100) / 100) + ", " +
(Math.round(this.y * 100) / 100) + ", " +
(Math.round(this.width * 100) / 100) + "x" +
(Math.round(this.height * 100) / 100) + ", " +
(Math.round(this.degrees * 100) / 100) + "deg" +
... | [
"function",
"(",
")",
"{",
"return",
"\"[\"",
"+",
"(",
"Math",
".",
"round",
"(",
"this",
".",
"x",
"*",
"100",
")",
"/",
"100",
")",
"+",
"\", \"",
"+",
"(",
"Math",
".",
"round",
"(",
"this",
".",
"y",
"*",
"100",
")",
"/",
"100",
")",
"... | Provides a string representation of the rectangle which is useful for
debugging.
@function
@returns {String} A string representation of the rectangle. | [
"Provides",
"a",
"string",
"representation",
"of",
"the",
"rectangle",
"which",
"is",
"useful",
"for",
"debugging",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/rectangle.js#L546-L554 | train | |
openseadragon/openseadragon | src/legacytilesource.js | filterFiles | function filterFiles( files ){
var filtered = [],
file,
i;
for( i = 0; i < files.length; i++ ){
file = files[ i ];
if( file.height &&
file.width &&
file.url ){
//This is sufficient to serve as a level
filtered.push({
... | javascript | function filterFiles( files ){
var filtered = [],
file,
i;
for( i = 0; i < files.length; i++ ){
file = files[ i ];
if( file.height &&
file.width &&
file.url ){
//This is sufficient to serve as a level
filtered.push({
... | [
"function",
"filterFiles",
"(",
"files",
")",
"{",
"var",
"filtered",
"=",
"[",
"]",
",",
"file",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"file",
"=",
"files",
"[",
"i",
"]",
... | This method removes any files from the Array which don't conform to our
basic requirements for a 'level' in the LegacyTileSource.
@private
@inner
@function | [
"This",
"method",
"removes",
"any",
"files",
"from",
"the",
"Array",
"which",
"don",
"t",
"conform",
"to",
"our",
"basic",
"requirements",
"for",
"a",
"level",
"in",
"the",
"LegacyTileSource",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/legacytilesource.js#L199-L224 | train |
openseadragon/openseadragon | src/viewer.js | function( ) {
if ( !THIS[ this.hash ] ) {
//this viewer has already been destroyed: returning immediately
return;
}
this.close();
this.clearOverlays();
this.overlaysContainer.innerHTML = "";
//TODO: implement this...
//this.unbindSequenc... | javascript | function( ) {
if ( !THIS[ this.hash ] ) {
//this viewer has already been destroyed: returning immediately
return;
}
this.close();
this.clearOverlays();
this.overlaysContainer.innerHTML = "";
//TODO: implement this...
//this.unbindSequenc... | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"THIS",
"[",
"this",
".",
"hash",
"]",
")",
"{",
"//this viewer has already been destroyed: returning immediately",
"return",
";",
"}",
"this",
".",
"close",
"(",
")",
";",
"this",
".",
"clearOverlays",
"(",
")",
... | Function to destroy the viewer and clean up everything created by OpenSeadragon.
Example:
var viewer = OpenSeadragon({
[...]
});
//when you are done with the viewer:
viewer.destroy();
viewer = null; //important
@function | [
"Function",
"to",
"destroy",
"the",
"viewer",
"and",
"clean",
"up",
"everything",
"created",
"by",
"OpenSeadragon",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/viewer.js#L739-L796 | train | |
openseadragon/openseadragon | src/viewer.js | function(debugMode){
for (var i = 0; i < this.world.getItemCount(); i++) {
this.world.getItemAt(i).debugMode = debugMode;
}
this.debugMode = debugMode;
this.forceRedraw();
} | javascript | function(debugMode){
for (var i = 0; i < this.world.getItemCount(); i++) {
this.world.getItemAt(i).debugMode = debugMode;
}
this.debugMode = debugMode;
this.forceRedraw();
} | [
"function",
"(",
"debugMode",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"world",
".",
"getItemCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"this",
".",
"world",
".",
"getItemAt",
"(",
"i",
")",
".",
"debugMode",
"="... | Turns debugging mode on or off for this viewer.
@function
@param {Boolean} true to turn debug on, false to turn debug off. | [
"Turns",
"debugging",
"mode",
"on",
"or",
"off",
"for",
"this",
"viewer",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/viewer.js#L878-L886 | train | |
openseadragon/openseadragon | src/viewer.js | function( fullScreen ) {
var _this = this;
if ( !$.supportsFullScreen ) {
return this.setFullPage( fullScreen );
}
if ( $.isFullScreen() === fullScreen ) {
return this;
}
var fullScreeEventArgs = {
fullScreen: fullScreen,
... | javascript | function( fullScreen ) {
var _this = this;
if ( !$.supportsFullScreen ) {
return this.setFullPage( fullScreen );
}
if ( $.isFullScreen() === fullScreen ) {
return this;
}
var fullScreeEventArgs = {
fullScreen: fullScreen,
... | [
"function",
"(",
"fullScreen",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"if",
"(",
"!",
"$",
".",
"supportsFullScreen",
")",
"{",
"return",
"this",
".",
"setFullPage",
"(",
"fullScreen",
")",
";",
"}",
"if",
"(",
"$",
".",
"isFullScreen",
"(",
")"... | Toggle full screen mode if supported. Toggle full page mode otherwise.
@function
@param {Boolean} fullScreen
If true, enter full screen mode. If false, exit full screen mode.
@return {OpenSeadragon.Viewer} Chainable.
@fires OpenSeadragon.Viewer.event:pre-full-screen
@fires OpenSeadragon.Viewer.event:full-screen | [
"Toggle",
"full",
"screen",
"mode",
"if",
"supported",
".",
"Toggle",
"full",
"page",
"mode",
"otherwise",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/viewer.js#L1116-L1203 | train | |
openseadragon/openseadragon | src/viewer.js | function( element, location, placement, onDraw ) {
var options;
if( $.isPlainObject( element ) ){
options = element;
} else {
options = {
element: element,
location: location,
placement: placement,
onDraw: on... | javascript | function( element, location, placement, onDraw ) {
var options;
if( $.isPlainObject( element ) ){
options = element;
} else {
options = {
element: element,
location: location,
placement: placement,
onDraw: on... | [
"function",
"(",
"element",
",",
"location",
",",
"placement",
",",
"onDraw",
")",
"{",
"var",
"options",
";",
"if",
"(",
"$",
".",
"isPlainObject",
"(",
"element",
")",
")",
"{",
"options",
"=",
"element",
";",
"}",
"else",
"{",
"options",
"=",
"{",... | Adds an html element as an overlay to the current viewport. Useful for
highlighting words or areas of interest on an image or other zoomable
interface. The overlays added via this method are removed when the viewport
is closed which include when changing page.
@method
@param {Element|String|Object} element - A referen... | [
"Adds",
"an",
"html",
"element",
"as",
"an",
"overlay",
"to",
"the",
"current",
"viewport",
".",
"Useful",
"for",
"highlighting",
"words",
"or",
"areas",
"of",
"interest",
"on",
"an",
"image",
"or",
"other",
"zoomable",
"interface",
".",
"The",
"overlays",
... | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/viewer.js#L1923-L1965 | train | |
openseadragon/openseadragon | src/viewer.js | function( element, location, placement ) {
var i;
element = $.getElement( element );
i = getOverlayIndex( this.currentOverlays, element );
if ( i >= 0 ) {
this.currentOverlays[ i ].update( location, placement );
THIS[ this.hash ].forceRedraw = true;
... | javascript | function( element, location, placement ) {
var i;
element = $.getElement( element );
i = getOverlayIndex( this.currentOverlays, element );
if ( i >= 0 ) {
this.currentOverlays[ i ].update( location, placement );
THIS[ this.hash ].forceRedraw = true;
... | [
"function",
"(",
"element",
",",
"location",
",",
"placement",
")",
"{",
"var",
"i",
";",
"element",
"=",
"$",
".",
"getElement",
"(",
"element",
")",
";",
"i",
"=",
"getOverlayIndex",
"(",
"this",
".",
"currentOverlays",
",",
"element",
")",
";",
"if"... | Updates the overlay represented by the reference to the element or
element id moving it to the new location, relative to the new placement.
@method
@param {Element|String} element - A reference to an element or an id for
the element which is overlaid.
@param {OpenSeadragon.Point|OpenSeadragon.Rect} location - The point... | [
"Updates",
"the",
"overlay",
"represented",
"by",
"the",
"reference",
"to",
"the",
"element",
"or",
"element",
"id",
"moving",
"it",
"to",
"the",
"new",
"location",
"relative",
"to",
"the",
"new",
"placement",
"."
] | e7108f23602575fc6eb152d4b82a8b44b2ca698e | https://github.com/openseadragon/openseadragon/blob/e7108f23602575fc6eb152d4b82a8b44b2ca698e/src/viewer.js#L1981-L2011 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.