id
int32 0
58k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
9,700
|
SAP/ui5-builder
|
lib/processors/jsdoc/jsdocGenerator.js
|
writeJsdocConfig
|
async function writeJsdocConfig(targetDirPath, config) {
const configPath = path.join(targetDirPath, "jsdoc-config.json");
await writeFile(configPath, config);
return configPath;
}
|
javascript
|
async function writeJsdocConfig(targetDirPath, config) {
const configPath = path.join(targetDirPath, "jsdoc-config.json");
await writeFile(configPath, config);
return configPath;
}
|
[
"async",
"function",
"writeJsdocConfig",
"(",
"targetDirPath",
",",
"config",
")",
"{",
"const",
"configPath",
"=",
"path",
".",
"join",
"(",
"targetDirPath",
",",
"\"jsdoc-config.json\"",
")",
";",
"await",
"writeFile",
"(",
"configPath",
",",
"config",
")",
";",
"return",
"configPath",
";",
"}"
] |
Write jsdoc-config.json to file system
@private
@param {string} targetDirPath Directory Path to write the jsdoc-config.json file to
@param {string} config jsdoc-config.json content
@returns {string} Full path to the written jsdoc-config.json file
|
[
"Write",
"jsdoc",
"-",
"config",
".",
"json",
"to",
"file",
"system"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/processors/jsdoc/jsdocGenerator.js#L123-L127
|
9,701
|
SAP/ui5-builder
|
lib/processors/jsdoc/jsdocGenerator.js
|
buildJsdoc
|
async function buildJsdoc({sourcePath, configPath}) {
const args = [
require.resolve("jsdoc/jsdoc"),
"-c",
configPath,
"--verbose",
sourcePath
];
return new Promise((resolve, reject) => {
const child = spawn("node", args, {
stdio: ["ignore", "ignore", process.stderr]
});
child.on("close", function(code) {
if (code === 0 || code === 1) {
resolve();
} else {
reject(new Error(`JSDoc child process closed with code ${code}`));
}
});
});
}
|
javascript
|
async function buildJsdoc({sourcePath, configPath}) {
const args = [
require.resolve("jsdoc/jsdoc"),
"-c",
configPath,
"--verbose",
sourcePath
];
return new Promise((resolve, reject) => {
const child = spawn("node", args, {
stdio: ["ignore", "ignore", process.stderr]
});
child.on("close", function(code) {
if (code === 0 || code === 1) {
resolve();
} else {
reject(new Error(`JSDoc child process closed with code ${code}`));
}
});
});
}
|
[
"async",
"function",
"buildJsdoc",
"(",
"{",
"sourcePath",
",",
"configPath",
"}",
")",
"{",
"const",
"args",
"=",
"[",
"require",
".",
"resolve",
"(",
"\"jsdoc/jsdoc\"",
")",
",",
"\"-c\"",
",",
"configPath",
",",
"\"--verbose\"",
",",
"sourcePath",
"]",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"const",
"child",
"=",
"spawn",
"(",
"\"node\"",
",",
"args",
",",
"{",
"stdio",
":",
"[",
"\"ignore\"",
",",
"\"ignore\"",
",",
"process",
".",
"stderr",
"]",
"}",
")",
";",
"child",
".",
"on",
"(",
"\"close\"",
",",
"function",
"(",
"code",
")",
"{",
"if",
"(",
"code",
"===",
"0",
"||",
"code",
"===",
"1",
")",
"{",
"resolve",
"(",
")",
";",
"}",
"else",
"{",
"reject",
"(",
"new",
"Error",
"(",
"`",
"${",
"code",
"}",
"`",
")",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Execute JSDoc build by spawning JSDoc as an external process
@private
@param {Object} parameters Parameters
@param {string} parameters.sourcePath Project resources (input for JSDoc generation)
@param {string} parameters.configPath Full path to jsdoc-config.json file
@returns {Promise<undefined>}
|
[
"Execute",
"JSDoc",
"build",
"by",
"spawning",
"JSDoc",
"as",
"an",
"external",
"process"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/processors/jsdoc/jsdocGenerator.js#L139-L159
|
9,702
|
SAP/ui5-builder
|
lib/lbt/utils/ModuleName.js
|
fromUI5LegacyName
|
function fromUI5LegacyName(name, suffix) {
// UI5 only supports a few names with dots in them, anything else will be converted to slashes
if ( name.startsWith("sap.ui.thirdparty.jquery.jquery-") ) {
name = "sap/ui/thirdparty/jquery/jquery-" + name.slice("sap.ui.thirdparty.jquery.jquery-".length);
} else if ( name.startsWith("jquery.sap.") || name.startsWith("jquery-") ) {
// do nothing
} else {
name = name.replace(/\./g, "/");
}
return name + (suffix || ".js");
}
|
javascript
|
function fromUI5LegacyName(name, suffix) {
// UI5 only supports a few names with dots in them, anything else will be converted to slashes
if ( name.startsWith("sap.ui.thirdparty.jquery.jquery-") ) {
name = "sap/ui/thirdparty/jquery/jquery-" + name.slice("sap.ui.thirdparty.jquery.jquery-".length);
} else if ( name.startsWith("jquery.sap.") || name.startsWith("jquery-") ) {
// do nothing
} else {
name = name.replace(/\./g, "/");
}
return name + (suffix || ".js");
}
|
[
"function",
"fromUI5LegacyName",
"(",
"name",
",",
"suffix",
")",
"{",
"// UI5 only supports a few names with dots in them, anything else will be converted to slashes",
"if",
"(",
"name",
".",
"startsWith",
"(",
"\"sap.ui.thirdparty.jquery.jquery-\"",
")",
")",
"{",
"name",
"=",
"\"sap/ui/thirdparty/jquery/jquery-\"",
"+",
"name",
".",
"slice",
"(",
"\"sap.ui.thirdparty.jquery.jquery-\"",
".",
"length",
")",
";",
"}",
"else",
"if",
"(",
"name",
".",
"startsWith",
"(",
"\"jquery.sap.\"",
")",
"||",
"name",
".",
"startsWith",
"(",
"\"jquery-\"",
")",
")",
"{",
"// do nothing",
"}",
"else",
"{",
"name",
"=",
"name",
".",
"replace",
"(",
"/",
"\\.",
"/",
"g",
",",
"\"/\"",
")",
";",
"}",
"return",
"name",
"+",
"(",
"suffix",
"||",
"\".js\"",
")",
";",
"}"
] |
Creates a ModuleName from a string in UI5 module name syntax.
@private
@param {string} name String that represents a UI5 module name (dot separated)
@param {string} [suffix='.js'] Suffix to add to the resulting resource name
@returns {string} URN representing the same resource
|
[
"Creates",
"a",
"ModuleName",
"from",
"a",
"string",
"in",
"UI5",
"module",
"name",
"syntax",
"."
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/lbt/utils/ModuleName.js#L11-L21
|
9,703
|
SAP/ui5-builder
|
lib/types/typeRepository.js
|
addType
|
function addType(typeName, type) {
if (types[typeName]) {
throw new Error("Type already registered '" + typeName + "'");
}
types[typeName] = type;
}
|
javascript
|
function addType(typeName, type) {
if (types[typeName]) {
throw new Error("Type already registered '" + typeName + "'");
}
types[typeName] = type;
}
|
[
"function",
"addType",
"(",
"typeName",
",",
"type",
")",
"{",
"if",
"(",
"types",
"[",
"typeName",
"]",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Type already registered '\"",
"+",
"typeName",
"+",
"\"'\"",
")",
";",
"}",
"types",
"[",
"typeName",
"]",
"=",
"type",
";",
"}"
] |
Adds a type
@param {string} typeName unique identifier for the type
@param {Object} type
@throws {Error} if duplicate with same name was found
|
[
"Adds",
"a",
"type"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/types/typeRepository.js#L34-L39
|
9,704
|
SAP/ui5-builder
|
lib/tasks/jsdoc/generateJsdoc.js
|
async function({workspace, dependencies, options} = {}) {
if (!options || !options.projectName || !options.namespace || !options.version || !options.pattern) {
throw new Error("[generateJsdoc]: One or more mandatory options not provided");
}
const {sourcePath: resourcePath, targetPath, tmpPath} = await generateJsdoc._createTmpDirs(options.projectName);
const [writtenResourcesCount] = await Promise.all([
generateJsdoc._writeResourcesToDir({
workspace,
pattern: options.pattern,
targetPath: resourcePath
}),
generateJsdoc._writeDependencyApisToDir({
dependencies,
targetPath: path.posix.join(tmpPath, "dependency-apis")
})
]);
if (writtenResourcesCount === 0) {
log.info(`Failed to find any input resources for project ${options.projectName} using pattern ` +
`${options.pattern}. Skipping JSDoc generation...`);
return;
}
const createdResources = await jsdocGenerator({
sourcePath: resourcePath,
targetPath,
tmpPath,
options: {
projectName: options.projectName,
namespace: options.namespace,
version: options.version,
variants: ["apijson"]
}
});
await Promise.all(createdResources.map((resource) => {
return workspace.write(resource);
}));
}
|
javascript
|
async function({workspace, dependencies, options} = {}) {
if (!options || !options.projectName || !options.namespace || !options.version || !options.pattern) {
throw new Error("[generateJsdoc]: One or more mandatory options not provided");
}
const {sourcePath: resourcePath, targetPath, tmpPath} = await generateJsdoc._createTmpDirs(options.projectName);
const [writtenResourcesCount] = await Promise.all([
generateJsdoc._writeResourcesToDir({
workspace,
pattern: options.pattern,
targetPath: resourcePath
}),
generateJsdoc._writeDependencyApisToDir({
dependencies,
targetPath: path.posix.join(tmpPath, "dependency-apis")
})
]);
if (writtenResourcesCount === 0) {
log.info(`Failed to find any input resources for project ${options.projectName} using pattern ` +
`${options.pattern}. Skipping JSDoc generation...`);
return;
}
const createdResources = await jsdocGenerator({
sourcePath: resourcePath,
targetPath,
tmpPath,
options: {
projectName: options.projectName,
namespace: options.namespace,
version: options.version,
variants: ["apijson"]
}
});
await Promise.all(createdResources.map((resource) => {
return workspace.write(resource);
}));
}
|
[
"async",
"function",
"(",
"{",
"workspace",
",",
"dependencies",
",",
"options",
"}",
"=",
"{",
"}",
")",
"{",
"if",
"(",
"!",
"options",
"||",
"!",
"options",
".",
"projectName",
"||",
"!",
"options",
".",
"namespace",
"||",
"!",
"options",
".",
"version",
"||",
"!",
"options",
".",
"pattern",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"[generateJsdoc]: One or more mandatory options not provided\"",
")",
";",
"}",
"const",
"{",
"sourcePath",
":",
"resourcePath",
",",
"targetPath",
",",
"tmpPath",
"}",
"=",
"await",
"generateJsdoc",
".",
"_createTmpDirs",
"(",
"options",
".",
"projectName",
")",
";",
"const",
"[",
"writtenResourcesCount",
"]",
"=",
"await",
"Promise",
".",
"all",
"(",
"[",
"generateJsdoc",
".",
"_writeResourcesToDir",
"(",
"{",
"workspace",
",",
"pattern",
":",
"options",
".",
"pattern",
",",
"targetPath",
":",
"resourcePath",
"}",
")",
",",
"generateJsdoc",
".",
"_writeDependencyApisToDir",
"(",
"{",
"dependencies",
",",
"targetPath",
":",
"path",
".",
"posix",
".",
"join",
"(",
"tmpPath",
",",
"\"dependency-apis\"",
")",
"}",
")",
"]",
")",
";",
"if",
"(",
"writtenResourcesCount",
"===",
"0",
")",
"{",
"log",
".",
"info",
"(",
"`",
"${",
"options",
".",
"projectName",
"}",
"`",
"+",
"`",
"${",
"options",
".",
"pattern",
"}",
"`",
")",
";",
"return",
";",
"}",
"const",
"createdResources",
"=",
"await",
"jsdocGenerator",
"(",
"{",
"sourcePath",
":",
"resourcePath",
",",
"targetPath",
",",
"tmpPath",
",",
"options",
":",
"{",
"projectName",
":",
"options",
".",
"projectName",
",",
"namespace",
":",
"options",
".",
"namespace",
",",
"version",
":",
"options",
".",
"version",
",",
"variants",
":",
"[",
"\"apijson\"",
"]",
"}",
"}",
")",
";",
"await",
"Promise",
".",
"all",
"(",
"createdResources",
".",
"map",
"(",
"(",
"resource",
")",
"=>",
"{",
"return",
"workspace",
".",
"write",
"(",
"resource",
")",
";",
"}",
")",
")",
";",
"}"
] |
Task to execute a JSDoc build for UI5 projects
@public
@alias module:@ui5/builder.tasks.generateJsdoc
@param {Object} parameters Parameters
@param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
@param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
@param {Object} parameters.options Options
@param {string|Array} parameters.options.pattern Pattern to locate the files to be processed
@param {string} parameters.options.projectName Project name
@param {string} parameters.options.namespace Namespace to build (e.g. <code>some/project/name</code>)
@param {string} parameters.options.version Project version
@returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
[
"Task",
"to",
"execute",
"a",
"JSDoc",
"build",
"for",
"UI5",
"projects"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/tasks/jsdoc/generateJsdoc.js#L25-L65
|
|
9,705
|
SAP/ui5-builder
|
lib/tasks/jsdoc/generateJsdoc.js
|
createTmpDirs
|
async function createTmpDirs(projectName) {
const {path: tmpDirPath} = await createTmpDir(projectName);
const sourcePath = path.join(tmpDirPath, "src"); // dir will be created by writing project resources below
await makeDir(sourcePath, {fs});
const targetPath = path.join(tmpDirPath, "target"); // dir will be created by jsdoc itself
await makeDir(targetPath, {fs});
const tmpPath = path.join(tmpDirPath, "tmp"); // dir needs to be created by us
await makeDir(tmpPath, {fs});
return {
sourcePath,
targetPath,
tmpPath
};
}
|
javascript
|
async function createTmpDirs(projectName) {
const {path: tmpDirPath} = await createTmpDir(projectName);
const sourcePath = path.join(tmpDirPath, "src"); // dir will be created by writing project resources below
await makeDir(sourcePath, {fs});
const targetPath = path.join(tmpDirPath, "target"); // dir will be created by jsdoc itself
await makeDir(targetPath, {fs});
const tmpPath = path.join(tmpDirPath, "tmp"); // dir needs to be created by us
await makeDir(tmpPath, {fs});
return {
sourcePath,
targetPath,
tmpPath
};
}
|
[
"async",
"function",
"createTmpDirs",
"(",
"projectName",
")",
"{",
"const",
"{",
"path",
":",
"tmpDirPath",
"}",
"=",
"await",
"createTmpDir",
"(",
"projectName",
")",
";",
"const",
"sourcePath",
"=",
"path",
".",
"join",
"(",
"tmpDirPath",
",",
"\"src\"",
")",
";",
"// dir will be created by writing project resources below",
"await",
"makeDir",
"(",
"sourcePath",
",",
"{",
"fs",
"}",
")",
";",
"const",
"targetPath",
"=",
"path",
".",
"join",
"(",
"tmpDirPath",
",",
"\"target\"",
")",
";",
"// dir will be created by jsdoc itself",
"await",
"makeDir",
"(",
"targetPath",
",",
"{",
"fs",
"}",
")",
";",
"const",
"tmpPath",
"=",
"path",
".",
"join",
"(",
"tmpDirPath",
",",
"\"tmp\"",
")",
";",
"// dir needs to be created by us",
"await",
"makeDir",
"(",
"tmpPath",
",",
"{",
"fs",
"}",
")",
";",
"return",
"{",
"sourcePath",
",",
"targetPath",
",",
"tmpPath",
"}",
";",
"}"
] |
Create temporary directories for JSDoc generation processor
@private
@param {string} projectName Project name used for naming the temporary working directory
@returns {Promise<Object>} Promise resolving with sourcePath, targetPath and tmpPath strings
|
[
"Create",
"temporary",
"directories",
"for",
"JSDoc",
"generation",
"processor"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/tasks/jsdoc/generateJsdoc.js#L75-L91
|
9,706
|
SAP/ui5-builder
|
lib/tasks/jsdoc/generateJsdoc.js
|
createTmpDir
|
function createTmpDir(projectName, keep = false) {
// Remove all non alpha-num characters from project name
const sanitizedProjectName = projectName.replace(/[^A-Za-z0-9]/g, "");
return new Promise((resolve, reject) => {
tmp.dir({
prefix: `ui5-tooling-tmp-jsdoc-${sanitizedProjectName}-`,
keep,
unsafeCleanup: true
}, (err, path) => {
if (err) {
reject(err);
return;
}
resolve({
path
});
});
});
}
|
javascript
|
function createTmpDir(projectName, keep = false) {
// Remove all non alpha-num characters from project name
const sanitizedProjectName = projectName.replace(/[^A-Za-z0-9]/g, "");
return new Promise((resolve, reject) => {
tmp.dir({
prefix: `ui5-tooling-tmp-jsdoc-${sanitizedProjectName}-`,
keep,
unsafeCleanup: true
}, (err, path) => {
if (err) {
reject(err);
return;
}
resolve({
path
});
});
});
}
|
[
"function",
"createTmpDir",
"(",
"projectName",
",",
"keep",
"=",
"false",
")",
"{",
"// Remove all non alpha-num characters from project name",
"const",
"sanitizedProjectName",
"=",
"projectName",
".",
"replace",
"(",
"/",
"[^A-Za-z0-9]",
"/",
"g",
",",
"\"\"",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"tmp",
".",
"dir",
"(",
"{",
"prefix",
":",
"`",
"${",
"sanitizedProjectName",
"}",
"`",
",",
"keep",
",",
"unsafeCleanup",
":",
"true",
"}",
",",
"(",
"err",
",",
"path",
")",
"=>",
"{",
"if",
"(",
"err",
")",
"{",
"reject",
"(",
"err",
")",
";",
"return",
";",
"}",
"resolve",
"(",
"{",
"path",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Create a temporary directory on the host system
@private
@param {string} projectName Project name used for naming the temporary directory
@param {boolean} [keep=false] Whether to keep the temporary directory
@returns {Promise<Object>} Promise resolving with path of the temporary directory
|
[
"Create",
"a",
"temporary",
"directory",
"on",
"the",
"host",
"system"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/tasks/jsdoc/generateJsdoc.js#L101-L120
|
9,707
|
SAP/ui5-builder
|
lib/tasks/jsdoc/generateJsdoc.js
|
writeResourcesToDir
|
async function writeResourcesToDir({workspace, pattern, targetPath}) {
const fsTarget = resourceFactory.createAdapter({
fsBasePath: targetPath,
virBasePath: "/resources/"
});
let allResources;
if (workspace.byGlobSource) { // API only available on duplex collections
allResources = await workspace.byGlobSource(pattern);
} else {
allResources = await workspace.byGlob(pattern);
}
// write all resources to the tmp folder
await Promise.all(allResources.map((resource) => fsTarget.write(resource)));
return allResources.length;
}
|
javascript
|
async function writeResourcesToDir({workspace, pattern, targetPath}) {
const fsTarget = resourceFactory.createAdapter({
fsBasePath: targetPath,
virBasePath: "/resources/"
});
let allResources;
if (workspace.byGlobSource) { // API only available on duplex collections
allResources = await workspace.byGlobSource(pattern);
} else {
allResources = await workspace.byGlob(pattern);
}
// write all resources to the tmp folder
await Promise.all(allResources.map((resource) => fsTarget.write(resource)));
return allResources.length;
}
|
[
"async",
"function",
"writeResourcesToDir",
"(",
"{",
"workspace",
",",
"pattern",
",",
"targetPath",
"}",
")",
"{",
"const",
"fsTarget",
"=",
"resourceFactory",
".",
"createAdapter",
"(",
"{",
"fsBasePath",
":",
"targetPath",
",",
"virBasePath",
":",
"\"/resources/\"",
"}",
")",
";",
"let",
"allResources",
";",
"if",
"(",
"workspace",
".",
"byGlobSource",
")",
"{",
"// API only available on duplex collections",
"allResources",
"=",
"await",
"workspace",
".",
"byGlobSource",
"(",
"pattern",
")",
";",
"}",
"else",
"{",
"allResources",
"=",
"await",
"workspace",
".",
"byGlob",
"(",
"pattern",
")",
";",
"}",
"// write all resources to the tmp folder",
"await",
"Promise",
".",
"all",
"(",
"allResources",
".",
"map",
"(",
"(",
"resource",
")",
"=>",
"fsTarget",
".",
"write",
"(",
"resource",
")",
")",
")",
";",
"return",
"allResources",
".",
"length",
";",
"}"
] |
Write resources from workspace matching the given pattern to the given fs destination
@private
@param {Object} parameters Parameters
@param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
@param {string} parameters.pattern Pattern to match resources in workspace against
@param {string} parameters.targetPath Path to write the resources to
@returns {Promise<number>} Promise resolving with number of resources written to given directory
|
[
"Write",
"resources",
"from",
"workspace",
"matching",
"the",
"given",
"pattern",
"to",
"the",
"given",
"fs",
"destination"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/tasks/jsdoc/generateJsdoc.js#L132-L148
|
9,708
|
SAP/ui5-builder
|
lib/tasks/jsdoc/generateJsdoc.js
|
writeDependencyApisToDir
|
async function writeDependencyApisToDir({dependencies, targetPath}) {
const depApis = await dependencies.byGlob("/test-resources/**/designtime/api.json");
// Clone resources before changing their path
const apis = await Promise.all(depApis.map((resource) => resource.clone()));
for (let i = 0; i < apis.length; i++) {
apis[i].setPath(`/api-${i}.json`);
}
const fsTarget = resourceFactory.createAdapter({
fsBasePath: targetPath,
virBasePath: "/"
});
await Promise.all(apis.map((resource) => fsTarget.write(resource)));
return apis.length;
}
|
javascript
|
async function writeDependencyApisToDir({dependencies, targetPath}) {
const depApis = await dependencies.byGlob("/test-resources/**/designtime/api.json");
// Clone resources before changing their path
const apis = await Promise.all(depApis.map((resource) => resource.clone()));
for (let i = 0; i < apis.length; i++) {
apis[i].setPath(`/api-${i}.json`);
}
const fsTarget = resourceFactory.createAdapter({
fsBasePath: targetPath,
virBasePath: "/"
});
await Promise.all(apis.map((resource) => fsTarget.write(resource)));
return apis.length;
}
|
[
"async",
"function",
"writeDependencyApisToDir",
"(",
"{",
"dependencies",
",",
"targetPath",
"}",
")",
"{",
"const",
"depApis",
"=",
"await",
"dependencies",
".",
"byGlob",
"(",
"\"/test-resources/**/designtime/api.json\"",
")",
";",
"// Clone resources before changing their path",
"const",
"apis",
"=",
"await",
"Promise",
".",
"all",
"(",
"depApis",
".",
"map",
"(",
"(",
"resource",
")",
"=>",
"resource",
".",
"clone",
"(",
")",
")",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"apis",
".",
"length",
";",
"i",
"++",
")",
"{",
"apis",
"[",
"i",
"]",
".",
"setPath",
"(",
"`",
"${",
"i",
"}",
"`",
")",
";",
"}",
"const",
"fsTarget",
"=",
"resourceFactory",
".",
"createAdapter",
"(",
"{",
"fsBasePath",
":",
"targetPath",
",",
"virBasePath",
":",
"\"/\"",
"}",
")",
";",
"await",
"Promise",
".",
"all",
"(",
"apis",
".",
"map",
"(",
"(",
"resource",
")",
"=>",
"fsTarget",
".",
"write",
"(",
"resource",
")",
")",
")",
";",
"return",
"apis",
".",
"length",
";",
"}"
] |
Write api.json files of dependencies to given target path in a flat structure
@private
@param {Object} parameters Parameters
@param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
@param {string} parameters.targetPath Path to write the resources to
@returns {Promise<number>} Promise resolving with number of resources written to given directory
|
[
"Write",
"api",
".",
"json",
"files",
"of",
"dependencies",
"to",
"given",
"target",
"path",
"in",
"a",
"flat",
"structure"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/tasks/jsdoc/generateJsdoc.js#L159-L175
|
9,709
|
SAP/ui5-builder
|
lib/builder/builder.js
|
getElapsedTime
|
function getElapsedTime(startTime) {
const prettyHrtime = require("pretty-hrtime");
const timeDiff = process.hrtime(startTime);
return prettyHrtime(timeDiff);
}
|
javascript
|
function getElapsedTime(startTime) {
const prettyHrtime = require("pretty-hrtime");
const timeDiff = process.hrtime(startTime);
return prettyHrtime(timeDiff);
}
|
[
"function",
"getElapsedTime",
"(",
"startTime",
")",
"{",
"const",
"prettyHrtime",
"=",
"require",
"(",
"\"pretty-hrtime\"",
")",
";",
"const",
"timeDiff",
"=",
"process",
".",
"hrtime",
"(",
"startTime",
")",
";",
"return",
"prettyHrtime",
"(",
"timeDiff",
")",
";",
"}"
] |
Calculates the elapsed build time and returns a prettified output
@private
@param {Array} startTime Array provided by <code>process.hrtime()</code>
@returns {string} Difference between now and the provided time array as formatted string
|
[
"Calculates",
"the",
"elapsed",
"build",
"time",
"and",
"returns",
"a",
"prettified",
"output"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/builder/builder.js#L23-L27
|
9,710
|
SAP/ui5-builder
|
lib/builder/builder.js
|
composeTaskList
|
function composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTasks}) {
let selectedTasks = Object.keys(definedTasks).reduce((list, key) => {
list[key] = true;
return list;
}, {});
// Exclude non default tasks
selectedTasks.generateManifestBundle = false;
selectedTasks.generateStandaloneAppBundle = false;
selectedTasks.transformBootstrapHtml = false;
selectedTasks.generateJsdoc = false;
selectedTasks.executeJsdocSdkTransformation = false;
selectedTasks.generateCachebusterInfo = false;
selectedTasks.generateApiIndex = false;
if (selfContained) {
// No preloads, bundle only
selectedTasks.generateComponentPreload = false;
selectedTasks.generateStandaloneAppBundle = true;
selectedTasks.transformBootstrapHtml = true;
selectedTasks.generateLibraryPreload = false;
}
if (jsdoc) {
// Include JSDoc tasks
selectedTasks.generateJsdoc = true;
selectedTasks.executeJsdocSdkTransformation = true;
selectedTasks.generateApiIndex = true;
// Include theme build as required for SDK
selectedTasks.buildThemes = true;
// Exclude all tasks not relevant to JSDoc generation
selectedTasks.replaceCopyright = false;
selectedTasks.replaceVersion = false;
selectedTasks.generateComponentPreload = false;
selectedTasks.generateLibraryPreload = false;
selectedTasks.generateLibraryManifest = false;
selectedTasks.createDebugFiles = false;
selectedTasks.uglify = false;
selectedTasks.generateFlexChangesBundle = false;
selectedTasks.generateManifestBundle = false;
}
// Only run essential tasks in development mode, it is not desired to run time consuming tasks during development.
if (dev) {
// Overwrite all other tasks with noop promise
Object.keys(selectedTasks).forEach((key) => {
if (devTasks.indexOf(key) === -1) {
selectedTasks[key] = false;
}
});
}
// Exclude tasks
for (let i = 0; i < excludedTasks.length; i++) {
const taskName = excludedTasks[i];
if (taskName === "*") {
Object.keys(selectedTasks).forEach((sKey) => {
selectedTasks[sKey] = false;
});
break;
}
if (selectedTasks[taskName] !== false) {
selectedTasks[taskName] = false;
}
}
// Include tasks
for (let i = 0; i < includedTasks.length; i++) {
const taskName = includedTasks[i];
if (taskName === "*") {
Object.keys(selectedTasks).forEach((sKey) => {
selectedTasks[sKey] = true;
});
break;
}
if (selectedTasks[taskName] === false) {
selectedTasks[taskName] = true;
}
}
// Filter only for tasks that will be executed
selectedTasks = Object.keys(selectedTasks).filter((task) => selectedTasks[task]);
return selectedTasks;
}
|
javascript
|
function composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTasks}) {
let selectedTasks = Object.keys(definedTasks).reduce((list, key) => {
list[key] = true;
return list;
}, {});
// Exclude non default tasks
selectedTasks.generateManifestBundle = false;
selectedTasks.generateStandaloneAppBundle = false;
selectedTasks.transformBootstrapHtml = false;
selectedTasks.generateJsdoc = false;
selectedTasks.executeJsdocSdkTransformation = false;
selectedTasks.generateCachebusterInfo = false;
selectedTasks.generateApiIndex = false;
if (selfContained) {
// No preloads, bundle only
selectedTasks.generateComponentPreload = false;
selectedTasks.generateStandaloneAppBundle = true;
selectedTasks.transformBootstrapHtml = true;
selectedTasks.generateLibraryPreload = false;
}
if (jsdoc) {
// Include JSDoc tasks
selectedTasks.generateJsdoc = true;
selectedTasks.executeJsdocSdkTransformation = true;
selectedTasks.generateApiIndex = true;
// Include theme build as required for SDK
selectedTasks.buildThemes = true;
// Exclude all tasks not relevant to JSDoc generation
selectedTasks.replaceCopyright = false;
selectedTasks.replaceVersion = false;
selectedTasks.generateComponentPreload = false;
selectedTasks.generateLibraryPreload = false;
selectedTasks.generateLibraryManifest = false;
selectedTasks.createDebugFiles = false;
selectedTasks.uglify = false;
selectedTasks.generateFlexChangesBundle = false;
selectedTasks.generateManifestBundle = false;
}
// Only run essential tasks in development mode, it is not desired to run time consuming tasks during development.
if (dev) {
// Overwrite all other tasks with noop promise
Object.keys(selectedTasks).forEach((key) => {
if (devTasks.indexOf(key) === -1) {
selectedTasks[key] = false;
}
});
}
// Exclude tasks
for (let i = 0; i < excludedTasks.length; i++) {
const taskName = excludedTasks[i];
if (taskName === "*") {
Object.keys(selectedTasks).forEach((sKey) => {
selectedTasks[sKey] = false;
});
break;
}
if (selectedTasks[taskName] !== false) {
selectedTasks[taskName] = false;
}
}
// Include tasks
for (let i = 0; i < includedTasks.length; i++) {
const taskName = includedTasks[i];
if (taskName === "*") {
Object.keys(selectedTasks).forEach((sKey) => {
selectedTasks[sKey] = true;
});
break;
}
if (selectedTasks[taskName] === false) {
selectedTasks[taskName] = true;
}
}
// Filter only for tasks that will be executed
selectedTasks = Object.keys(selectedTasks).filter((task) => selectedTasks[task]);
return selectedTasks;
}
|
[
"function",
"composeTaskList",
"(",
"{",
"dev",
",",
"selfContained",
",",
"jsdoc",
",",
"includedTasks",
",",
"excludedTasks",
"}",
")",
"{",
"let",
"selectedTasks",
"=",
"Object",
".",
"keys",
"(",
"definedTasks",
")",
".",
"reduce",
"(",
"(",
"list",
",",
"key",
")",
"=>",
"{",
"list",
"[",
"key",
"]",
"=",
"true",
";",
"return",
"list",
";",
"}",
",",
"{",
"}",
")",
";",
"// Exclude non default tasks",
"selectedTasks",
".",
"generateManifestBundle",
"=",
"false",
";",
"selectedTasks",
".",
"generateStandaloneAppBundle",
"=",
"false",
";",
"selectedTasks",
".",
"transformBootstrapHtml",
"=",
"false",
";",
"selectedTasks",
".",
"generateJsdoc",
"=",
"false",
";",
"selectedTasks",
".",
"executeJsdocSdkTransformation",
"=",
"false",
";",
"selectedTasks",
".",
"generateCachebusterInfo",
"=",
"false",
";",
"selectedTasks",
".",
"generateApiIndex",
"=",
"false",
";",
"if",
"(",
"selfContained",
")",
"{",
"// No preloads, bundle only",
"selectedTasks",
".",
"generateComponentPreload",
"=",
"false",
";",
"selectedTasks",
".",
"generateStandaloneAppBundle",
"=",
"true",
";",
"selectedTasks",
".",
"transformBootstrapHtml",
"=",
"true",
";",
"selectedTasks",
".",
"generateLibraryPreload",
"=",
"false",
";",
"}",
"if",
"(",
"jsdoc",
")",
"{",
"// Include JSDoc tasks",
"selectedTasks",
".",
"generateJsdoc",
"=",
"true",
";",
"selectedTasks",
".",
"executeJsdocSdkTransformation",
"=",
"true",
";",
"selectedTasks",
".",
"generateApiIndex",
"=",
"true",
";",
"// Include theme build as required for SDK",
"selectedTasks",
".",
"buildThemes",
"=",
"true",
";",
"// Exclude all tasks not relevant to JSDoc generation",
"selectedTasks",
".",
"replaceCopyright",
"=",
"false",
";",
"selectedTasks",
".",
"replaceVersion",
"=",
"false",
";",
"selectedTasks",
".",
"generateComponentPreload",
"=",
"false",
";",
"selectedTasks",
".",
"generateLibraryPreload",
"=",
"false",
";",
"selectedTasks",
".",
"generateLibraryManifest",
"=",
"false",
";",
"selectedTasks",
".",
"createDebugFiles",
"=",
"false",
";",
"selectedTasks",
".",
"uglify",
"=",
"false",
";",
"selectedTasks",
".",
"generateFlexChangesBundle",
"=",
"false",
";",
"selectedTasks",
".",
"generateManifestBundle",
"=",
"false",
";",
"}",
"// Only run essential tasks in development mode, it is not desired to run time consuming tasks during development.",
"if",
"(",
"dev",
")",
"{",
"// Overwrite all other tasks with noop promise",
"Object",
".",
"keys",
"(",
"selectedTasks",
")",
".",
"forEach",
"(",
"(",
"key",
")",
"=>",
"{",
"if",
"(",
"devTasks",
".",
"indexOf",
"(",
"key",
")",
"===",
"-",
"1",
")",
"{",
"selectedTasks",
"[",
"key",
"]",
"=",
"false",
";",
"}",
"}",
")",
";",
"}",
"// Exclude tasks",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"excludedTasks",
".",
"length",
";",
"i",
"++",
")",
"{",
"const",
"taskName",
"=",
"excludedTasks",
"[",
"i",
"]",
";",
"if",
"(",
"taskName",
"===",
"\"*\"",
")",
"{",
"Object",
".",
"keys",
"(",
"selectedTasks",
")",
".",
"forEach",
"(",
"(",
"sKey",
")",
"=>",
"{",
"selectedTasks",
"[",
"sKey",
"]",
"=",
"false",
";",
"}",
")",
";",
"break",
";",
"}",
"if",
"(",
"selectedTasks",
"[",
"taskName",
"]",
"!==",
"false",
")",
"{",
"selectedTasks",
"[",
"taskName",
"]",
"=",
"false",
";",
"}",
"}",
"// Include tasks",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"includedTasks",
".",
"length",
";",
"i",
"++",
")",
"{",
"const",
"taskName",
"=",
"includedTasks",
"[",
"i",
"]",
";",
"if",
"(",
"taskName",
"===",
"\"*\"",
")",
"{",
"Object",
".",
"keys",
"(",
"selectedTasks",
")",
".",
"forEach",
"(",
"(",
"sKey",
")",
"=>",
"{",
"selectedTasks",
"[",
"sKey",
"]",
"=",
"true",
";",
"}",
")",
";",
"break",
";",
"}",
"if",
"(",
"selectedTasks",
"[",
"taskName",
"]",
"===",
"false",
")",
"{",
"selectedTasks",
"[",
"taskName",
"]",
"=",
"true",
";",
"}",
"}",
"// Filter only for tasks that will be executed",
"selectedTasks",
"=",
"Object",
".",
"keys",
"(",
"selectedTasks",
")",
".",
"filter",
"(",
"(",
"task",
")",
"=>",
"selectedTasks",
"[",
"task",
"]",
")",
";",
"return",
"selectedTasks",
";",
"}"
] |
Creates the list of tasks to be executed by the build process
Sets specific tasks to be disabled by default, these tasks need to be included explicitly.
Based on the selected build mode (dev|selfContained|preload), different tasks are enabled.
Tasks can be enabled or disabled. The wildcard <code>*</code> is also supported and affects all tasks.
@private
@param {Object} parameters
@param {boolean} parameters.dev Sets development mode, which only runs essential tasks
@param {boolean} parameters.selfContained True if a the build should be self-contained or false for prelead build bundles
@param {boolean} parameters.jsdoc True if a JSDoc build should be executed
@param {Array} parameters.includedTasks Task list to be included from build
@param {Array} parameters.excludedTasks Task list to be excluded from build
@returns {Array} Return a task list for the builder
|
[
"Creates",
"the",
"list",
"of",
"tasks",
"to",
"be",
"executed",
"by",
"the",
"build",
"process"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/builder/builder.js#L45-L131
|
9,711
|
SAP/ui5-builder
|
lib/processors/manifestCreator.js
|
registrationIds
|
function registrationIds() {
const ids = [];
for (const regid of findChildren(sapFioriAppData, "registrationId")) {
ids.push(regid._);
}
return ids.length > 0 ? ids : undefined;
}
|
javascript
|
function registrationIds() {
const ids = [];
for (const regid of findChildren(sapFioriAppData, "registrationId")) {
ids.push(regid._);
}
return ids.length > 0 ? ids : undefined;
}
|
[
"function",
"registrationIds",
"(",
")",
"{",
"const",
"ids",
"=",
"[",
"]",
";",
"for",
"(",
"const",
"regid",
"of",
"findChildren",
"(",
"sapFioriAppData",
",",
"\"registrationId\"",
")",
")",
"{",
"ids",
".",
"push",
"(",
"regid",
".",
"_",
")",
";",
"}",
"return",
"ids",
".",
"length",
">",
"0",
"?",
"ids",
":",
"undefined",
";",
"}"
] |
collect registrationIds if present
|
[
"collect",
"registrationIds",
"if",
"present"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/processors/manifestCreator.js#L470-L476
|
9,712
|
SAP/ui5-builder
|
lib/lbt/graph/topologicalSort.js
|
createDependencyGraph
|
function createDependencyGraph(pool, moduleNames, indegreeOnly) {
const graph = Object.create(null);
const promises = moduleNames.map( (moduleName) => {
return pool.getModuleInfo(moduleName).
then( (module) => {
let node = graph[moduleName];
if ( node == null ) {
node = new GraphNode(moduleName, indegreeOnly);
graph[moduleName] = node;
}
const p = module.dependencies.map( function(dep) {
if ( module.isConditionalDependency(dep) ) {
return;
}
return pool.getModuleInfo(dep).then( (depModule) => {
if ( moduleNames.indexOf(dep) >= 0 ) {
let depNode = graph[dep];
if ( depNode == null ) {
depNode = new GraphNode(dep, indegreeOnly);
graph[dep] = depNode;
}
node.outgoing.push(depNode);
if ( indegreeOnly ) {
depNode.indegree++;
} else {
depNode.incoming.push(node);
}
}
}, (erro) => null);
});
return Promise.all(p);
}, (err) => {
log.error("module %s not found in pool", moduleName);
});
});
return Promise.all(promises).then(function() {
// if ( trace.isTrace() ) trace.trace("initial module dependency graph: %s", dumpGraph(graph, moduleNames));
return graph;
});
}
|
javascript
|
function createDependencyGraph(pool, moduleNames, indegreeOnly) {
const graph = Object.create(null);
const promises = moduleNames.map( (moduleName) => {
return pool.getModuleInfo(moduleName).
then( (module) => {
let node = graph[moduleName];
if ( node == null ) {
node = new GraphNode(moduleName, indegreeOnly);
graph[moduleName] = node;
}
const p = module.dependencies.map( function(dep) {
if ( module.isConditionalDependency(dep) ) {
return;
}
return pool.getModuleInfo(dep).then( (depModule) => {
if ( moduleNames.indexOf(dep) >= 0 ) {
let depNode = graph[dep];
if ( depNode == null ) {
depNode = new GraphNode(dep, indegreeOnly);
graph[dep] = depNode;
}
node.outgoing.push(depNode);
if ( indegreeOnly ) {
depNode.indegree++;
} else {
depNode.incoming.push(node);
}
}
}, (erro) => null);
});
return Promise.all(p);
}, (err) => {
log.error("module %s not found in pool", moduleName);
});
});
return Promise.all(promises).then(function() {
// if ( trace.isTrace() ) trace.trace("initial module dependency graph: %s", dumpGraph(graph, moduleNames));
return graph;
});
}
|
[
"function",
"createDependencyGraph",
"(",
"pool",
",",
"moduleNames",
",",
"indegreeOnly",
")",
"{",
"const",
"graph",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"const",
"promises",
"=",
"moduleNames",
".",
"map",
"(",
"(",
"moduleName",
")",
"=>",
"{",
"return",
"pool",
".",
"getModuleInfo",
"(",
"moduleName",
")",
".",
"then",
"(",
"(",
"module",
")",
"=>",
"{",
"let",
"node",
"=",
"graph",
"[",
"moduleName",
"]",
";",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"node",
"=",
"new",
"GraphNode",
"(",
"moduleName",
",",
"indegreeOnly",
")",
";",
"graph",
"[",
"moduleName",
"]",
"=",
"node",
";",
"}",
"const",
"p",
"=",
"module",
".",
"dependencies",
".",
"map",
"(",
"function",
"(",
"dep",
")",
"{",
"if",
"(",
"module",
".",
"isConditionalDependency",
"(",
"dep",
")",
")",
"{",
"return",
";",
"}",
"return",
"pool",
".",
"getModuleInfo",
"(",
"dep",
")",
".",
"then",
"(",
"(",
"depModule",
")",
"=>",
"{",
"if",
"(",
"moduleNames",
".",
"indexOf",
"(",
"dep",
")",
">=",
"0",
")",
"{",
"let",
"depNode",
"=",
"graph",
"[",
"dep",
"]",
";",
"if",
"(",
"depNode",
"==",
"null",
")",
"{",
"depNode",
"=",
"new",
"GraphNode",
"(",
"dep",
",",
"indegreeOnly",
")",
";",
"graph",
"[",
"dep",
"]",
"=",
"depNode",
";",
"}",
"node",
".",
"outgoing",
".",
"push",
"(",
"depNode",
")",
";",
"if",
"(",
"indegreeOnly",
")",
"{",
"depNode",
".",
"indegree",
"++",
";",
"}",
"else",
"{",
"depNode",
".",
"incoming",
".",
"push",
"(",
"node",
")",
";",
"}",
"}",
"}",
",",
"(",
"erro",
")",
"=>",
"null",
")",
";",
"}",
")",
";",
"return",
"Promise",
".",
"all",
"(",
"p",
")",
";",
"}",
",",
"(",
"err",
")",
"=>",
"{",
"log",
".",
"error",
"(",
"\"module %s not found in pool\"",
",",
"moduleName",
")",
";",
"}",
")",
";",
"}",
")",
";",
"return",
"Promise",
".",
"all",
"(",
"promises",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"// if ( trace.isTrace() ) trace.trace(\"initial module dependency graph: %s\", dumpGraph(graph, moduleNames));",
"return",
"graph",
";",
"}",
")",
";",
"}"
] |
Creates a dependency graph from the given moduleNames.
Ignores modules not in the pool
@param {ResourcePool} pool
@param {string[]} moduleNames
@param {boolean} indegreeOnly
@returns {Promise<Object>}
@private
|
[
"Creates",
"a",
"dependency",
"graph",
"from",
"the",
"given",
"moduleNames",
".",
"Ignores",
"modules",
"not",
"in",
"the",
"pool"
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/lbt/graph/topologicalSort.js#L40-L81
|
9,713
|
SAP/ui5-builder
|
lib/lbt/utils/ASTUtils.js
|
isString
|
function isString(node, literal) {
if ( node == null || node.type !== Syntax.Literal || typeof node.value !== "string" ) {
return false;
}
return literal == null ? true : node.value === literal;
}
|
javascript
|
function isString(node, literal) {
if ( node == null || node.type !== Syntax.Literal || typeof node.value !== "string" ) {
return false;
}
return literal == null ? true : node.value === literal;
}
|
[
"function",
"isString",
"(",
"node",
",",
"literal",
")",
"{",
"if",
"(",
"node",
"==",
"null",
"||",
"node",
".",
"type",
"!==",
"Syntax",
".",
"Literal",
"||",
"typeof",
"node",
".",
"value",
"!==",
"\"string\"",
")",
"{",
"return",
"false",
";",
"}",
"return",
"literal",
"==",
"null",
"?",
"true",
":",
"node",
".",
"value",
"===",
"literal",
";",
"}"
] |
Checks whether the given node is a string literal.
If second parameter 'literal' is given, the value of the node is additionally compared with that literal.
@private
@param {ESTree} node
@param {string} [literal]
@returns {boolean} Whether the node is a literal and whether its value matches the given string
|
[
"Checks",
"whether",
"the",
"given",
"node",
"is",
"a",
"string",
"literal",
"."
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/lbt/utils/ASTUtils.js#L15-L20
|
9,714
|
SAP/ui5-builder
|
lib/lbt/utils/ASTUtils.js
|
getStringArray
|
function getStringArray(array, skipNonStringLiterals) {
return array.elements.reduce( (result, item) => {
if ( isString(item) ) {
result.push(item.value);
} else if ( !skipNonStringLiterals ) {
throw new TypeError("array element is not a string literal:" + item.type);
}
return result;
}, []);
}
|
javascript
|
function getStringArray(array, skipNonStringLiterals) {
return array.elements.reduce( (result, item) => {
if ( isString(item) ) {
result.push(item.value);
} else if ( !skipNonStringLiterals ) {
throw new TypeError("array element is not a string literal:" + item.type);
}
return result;
}, []);
}
|
[
"function",
"getStringArray",
"(",
"array",
",",
"skipNonStringLiterals",
")",
"{",
"return",
"array",
".",
"elements",
".",
"reduce",
"(",
"(",
"result",
",",
"item",
")",
"=>",
"{",
"if",
"(",
"isString",
"(",
"item",
")",
")",
"{",
"result",
".",
"push",
"(",
"item",
".",
"value",
")",
";",
"}",
"else",
"if",
"(",
"!",
"skipNonStringLiterals",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"\"array element is not a string literal:\"",
"+",
"item",
".",
"type",
")",
";",
"}",
"return",
"result",
";",
"}",
",",
"[",
"]",
")",
";",
"}"
] |
Converts an AST node of type 'ArrayExpression' into an array of strings,
assuming that each item in the array literal is a string literal.
Depending on the parameter skipNonStringLiterals, unexpected items
in the array are either ignored or cause the method to fail with
a TypeError.
@param {ESTree} array
@param {boolean } skipNonStringLiterals
@throws {TypeError}
@returns {string[]}
|
[
"Converts",
"an",
"AST",
"node",
"of",
"type",
"ArrayExpression",
"into",
"an",
"array",
"of",
"strings",
"assuming",
"that",
"each",
"item",
"in",
"the",
"array",
"literal",
"is",
"a",
"string",
"literal",
"."
] |
bea878bd64d7d6a9b549717d26e4e928355a0c6c
|
https://github.com/SAP/ui5-builder/blob/bea878bd64d7d6a9b549717d26e4e928355a0c6c/lib/lbt/utils/ASTUtils.js#L96-L105
|
9,715
|
perry-mitchell/webdav-client
|
source/factory.js
|
copyFile
|
function copyFile(remotePath, targetRemotePath, options) {
const copyOptions = merge(baseOptions, options || {});
return copy.copyFile(remotePath, targetRemotePath, copyOptions);
}
|
javascript
|
function copyFile(remotePath, targetRemotePath, options) {
const copyOptions = merge(baseOptions, options || {});
return copy.copyFile(remotePath, targetRemotePath, copyOptions);
}
|
[
"function",
"copyFile",
"(",
"remotePath",
",",
"targetRemotePath",
",",
"options",
")",
"{",
"const",
"copyOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"copy",
".",
"copyFile",
"(",
"remotePath",
",",
"targetRemotePath",
",",
"copyOptions",
")",
";",
"}"
] |
Copy a remote item to another path
@param {String} remotePath The remote item path
@param {String} targetRemotePath The path file will be copied to
@param {UserOptions=} options Options for the request
@memberof ClientInterface
@returns {Promise} A promise that resolves once the request has completed
@example
await client.copyFile("/photos/pic1.jpg", "/backup/pic1.jpg");
|
[
"Copy",
"a",
"remote",
"item",
"to",
"another",
"path"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L127-L130
|
9,716
|
perry-mitchell/webdav-client
|
source/factory.js
|
createReadStream
|
function createReadStream(remoteFilename, options) {
const createOptions = merge(baseOptions, options || {});
return createStream.createReadStream(remoteFilename, createOptions);
}
|
javascript
|
function createReadStream(remoteFilename, options) {
const createOptions = merge(baseOptions, options || {});
return createStream.createReadStream(remoteFilename, createOptions);
}
|
[
"function",
"createReadStream",
"(",
"remoteFilename",
",",
"options",
")",
"{",
"const",
"createOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"createStream",
".",
"createReadStream",
"(",
"remoteFilename",
",",
"createOptions",
")",
";",
"}"
] |
Create a readable stream of a remote file
@param {String} remoteFilename The file to stream
@param {UserOptions=} options Options for the request
@memberof ClientInterface
@returns {Readable} A readable stream
@example
const remote = client.createReadStream("/data.zip");
remote.pipe(someWriteStream);
|
[
"Create",
"a",
"readable",
"stream",
"of",
"a",
"remote",
"file"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L156-L159
|
9,717
|
perry-mitchell/webdav-client
|
source/factory.js
|
createWriteStream
|
function createWriteStream(remoteFilename, options) {
const createOptions = merge(baseOptions, options || {});
return createStream.createWriteStream(remoteFilename, createOptions);
}
|
javascript
|
function createWriteStream(remoteFilename, options) {
const createOptions = merge(baseOptions, options || {});
return createStream.createWriteStream(remoteFilename, createOptions);
}
|
[
"function",
"createWriteStream",
"(",
"remoteFilename",
",",
"options",
")",
"{",
"const",
"createOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"createStream",
".",
"createWriteStream",
"(",
"remoteFilename",
",",
"createOptions",
")",
";",
"}"
] |
Create a writeable stream to a remote file
@param {String} remoteFilename The file to write to
@param {PutOptions=} options Options for the request
@memberof ClientInterface
@returns {Writeable} A writeable stream
@example
const remote = client.createWriteStream("/data.zip");
fs.createReadStream("~/myData.zip").pipe(remote);
|
[
"Create",
"a",
"writeable",
"stream",
"to",
"a",
"remote",
"file"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L171-L174
|
9,718
|
perry-mitchell/webdav-client
|
source/factory.js
|
deleteFile
|
function deleteFile(remotePath, options) {
const deleteOptions = merge(baseOptions, options || {});
return deletion.deleteFile(remotePath, deleteOptions);
}
|
javascript
|
function deleteFile(remotePath, options) {
const deleteOptions = merge(baseOptions, options || {});
return deletion.deleteFile(remotePath, deleteOptions);
}
|
[
"function",
"deleteFile",
"(",
"remotePath",
",",
"options",
")",
"{",
"const",
"deleteOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"deletion",
".",
"deleteFile",
"(",
"remotePath",
",",
"deleteOptions",
")",
";",
"}"
] |
Delete a remote file
@param {String} remotePath The remote path to delete
@param {UserOptions=} options The options for the request
@memberof ClientInterface
@returns {Promise} A promise that resolves when the remote file as been deleted
@example
await client.deleteFile("/some/file.txt");
|
[
"Delete",
"a",
"remote",
"file"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L185-L188
|
9,719
|
perry-mitchell/webdav-client
|
source/factory.js
|
getDirectoryContents
|
function getDirectoryContents(remotePath, options) {
const getOptions = merge(baseOptions, options || {});
return directoryContents.getDirectoryContents(remotePath, getOptions);
}
|
javascript
|
function getDirectoryContents(remotePath, options) {
const getOptions = merge(baseOptions, options || {});
return directoryContents.getDirectoryContents(remotePath, getOptions);
}
|
[
"function",
"getDirectoryContents",
"(",
"remotePath",
",",
"options",
")",
"{",
"const",
"getOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"directoryContents",
".",
"getDirectoryContents",
"(",
"remotePath",
",",
"getOptions",
")",
";",
"}"
] |
Get the contents of a remote directory
@param {String} remotePath The path to fetch the contents of
@param {GetDirectoryContentsOptions=} options Options for the remote the request
@returns {Promise.<Array.<Stat>>} A promise that resolves with an array of remote item stats
@memberof ClientInterface
@example
const contents = await client.getDirectoryContents("/");
|
[
"Get",
"the",
"contents",
"of",
"a",
"remote",
"directory"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L199-L202
|
9,720
|
perry-mitchell/webdav-client
|
source/factory.js
|
getFileContents
|
function getFileContents(remoteFilename, options) {
const getOptions = merge(baseOptions, options || {});
getOptions.format = getOptions.format || "binary";
if (["binary", "text"].indexOf(getOptions.format) < 0) {
throw new Error("Unknown format: " + getOptions.format);
}
return getOptions.format === "text"
? getFile.getFileContentsString(remoteFilename, getOptions)
: getFile.getFileContentsBuffer(remoteFilename, getOptions);
}
|
javascript
|
function getFileContents(remoteFilename, options) {
const getOptions = merge(baseOptions, options || {});
getOptions.format = getOptions.format || "binary";
if (["binary", "text"].indexOf(getOptions.format) < 0) {
throw new Error("Unknown format: " + getOptions.format);
}
return getOptions.format === "text"
? getFile.getFileContentsString(remoteFilename, getOptions)
: getFile.getFileContentsBuffer(remoteFilename, getOptions);
}
|
[
"function",
"getFileContents",
"(",
"remoteFilename",
",",
"options",
")",
"{",
"const",
"getOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"getOptions",
".",
"format",
"=",
"getOptions",
".",
"format",
"||",
"\"binary\"",
";",
"if",
"(",
"[",
"\"binary\"",
",",
"\"text\"",
"]",
".",
"indexOf",
"(",
"getOptions",
".",
"format",
")",
"<",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Unknown format: \"",
"+",
"getOptions",
".",
"format",
")",
";",
"}",
"return",
"getOptions",
".",
"format",
"===",
"\"text\"",
"?",
"getFile",
".",
"getFileContentsString",
"(",
"remoteFilename",
",",
"getOptions",
")",
":",
"getFile",
".",
"getFileContentsBuffer",
"(",
"remoteFilename",
",",
"getOptions",
")",
";",
"}"
] |
Get the contents of a remote file
@param {String} remoteFilename The file to fetch
@param {OptionsWithFormat=} options Options for the request
@memberof ClientInterface
@returns {Promise.<Buffer|String>} A promise that resolves with the contents of the remote file
@example
// Fetching data:
const buff = await client.getFileContents("/image.png");
// Fetching text:
const txt = await client.getFileContents("/list.txt", { format: "text" });
|
[
"Get",
"the",
"contents",
"of",
"a",
"remote",
"file"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L216-L225
|
9,721
|
perry-mitchell/webdav-client
|
source/factory.js
|
getFileDownloadLink
|
function getFileDownloadLink(remoteFilename, options) {
const getOptions = merge(baseOptions, options || {});
return getFile.getFileLink(remoteFilename, getOptions);
}
|
javascript
|
function getFileDownloadLink(remoteFilename, options) {
const getOptions = merge(baseOptions, options || {});
return getFile.getFileLink(remoteFilename, getOptions);
}
|
[
"function",
"getFileDownloadLink",
"(",
"remoteFilename",
",",
"options",
")",
"{",
"const",
"getOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"getFile",
".",
"getFileLink",
"(",
"remoteFilename",
",",
"getOptions",
")",
";",
"}"
] |
Get the download link of a remote file
Only supported for Basic authentication or unauthenticated connections.
@param {String} remoteFilename The file url to fetch
@param {UserOptions=} options Options for the request
@memberof ClientInterface
@returns {String} A download URL
|
[
"Get",
"the",
"download",
"link",
"of",
"a",
"remote",
"file",
"Only",
"supported",
"for",
"Basic",
"authentication",
"or",
"unauthenticated",
"connections",
"."
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L235-L238
|
9,722
|
perry-mitchell/webdav-client
|
source/factory.js
|
getFileUploadLink
|
function getFileUploadLink(remoteFilename, options) {
var putOptions = merge(baseOptions, options || {});
return putFile.getFileUploadLink(remoteFilename, putOptions);
}
|
javascript
|
function getFileUploadLink(remoteFilename, options) {
var putOptions = merge(baseOptions, options || {});
return putFile.getFileUploadLink(remoteFilename, putOptions);
}
|
[
"function",
"getFileUploadLink",
"(",
"remoteFilename",
",",
"options",
")",
"{",
"var",
"putOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"putFile",
".",
"getFileUploadLink",
"(",
"remoteFilename",
",",
"putOptions",
")",
";",
"}"
] |
Get a file upload link
Only supported for Basic authentication or unauthenticated connections.
@param {String} remoteFilename The path of the remote file location
@param {PutOptions=} options The options for the request
@memberof ClientInterface
@returns {String} A upload URL
|
[
"Get",
"a",
"file",
"upload",
"link",
"Only",
"supported",
"for",
"Basic",
"authentication",
"or",
"unauthenticated",
"connections",
"."
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L248-L251
|
9,723
|
perry-mitchell/webdav-client
|
source/factory.js
|
moveFile
|
function moveFile(remotePath, targetRemotePath, options) {
const moveOptions = merge(baseOptions, options || {});
return move.moveFile(remotePath, targetRemotePath, moveOptions);
}
|
javascript
|
function moveFile(remotePath, targetRemotePath, options) {
const moveOptions = merge(baseOptions, options || {});
return move.moveFile(remotePath, targetRemotePath, moveOptions);
}
|
[
"function",
"moveFile",
"(",
"remotePath",
",",
"targetRemotePath",
",",
"options",
")",
"{",
"const",
"moveOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"move",
".",
"moveFile",
"(",
"remotePath",
",",
"targetRemotePath",
",",
"moveOptions",
")",
";",
"}"
] |
Move a remote item to another path
@param {String} remotePath The remote item path
@param {String} targetRemotePath The new path after moving
@param {UserOptions=} options Options for the request
@memberof ClientInterface
@returns {Promise} A promise that resolves once the request has completed
@example
await client.moveFile("/sub/file.dat", "/another/dir/file.dat");
|
[
"Move",
"a",
"remote",
"item",
"to",
"another",
"path"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L274-L277
|
9,724
|
perry-mitchell/webdav-client
|
source/factory.js
|
putFileContents
|
function putFileContents(remoteFilename, data, options) {
const putOptions = merge(baseOptions, options || {});
return putFile.putFileContents(remoteFilename, data, putOptions);
}
|
javascript
|
function putFileContents(remoteFilename, data, options) {
const putOptions = merge(baseOptions, options || {});
return putFile.putFileContents(remoteFilename, data, putOptions);
}
|
[
"function",
"putFileContents",
"(",
"remoteFilename",
",",
"data",
",",
"options",
")",
"{",
"const",
"putOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"putFile",
".",
"putFileContents",
"(",
"remoteFilename",
",",
"data",
",",
"putOptions",
")",
";",
"}"
] |
Write contents to a remote file path
@param {String} remoteFilename The path of the remote file
@param {String|Buffer} data The data to write
@param {PutOptions=} options The options for the request
@returns {Promise} A promise that resolves once the contents have been written
@memberof ClientInterface
@example
await client.putFileContents("/dir/image.png", myImageBuffer);
// Put contents without overwriting:
await client.putFileContents("/dir/image.png", myImageBuffer, { overwrite: false });
|
[
"Write",
"contents",
"to",
"a",
"remote",
"file",
"path"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L291-L294
|
9,725
|
perry-mitchell/webdav-client
|
source/factory.js
|
stat
|
function stat(remotePath, options) {
const getOptions = merge(baseOptions, options || {});
return stats.getStat(remotePath, getOptions);
}
|
javascript
|
function stat(remotePath, options) {
const getOptions = merge(baseOptions, options || {});
return stats.getStat(remotePath, getOptions);
}
|
[
"function",
"stat",
"(",
"remotePath",
",",
"options",
")",
"{",
"const",
"getOptions",
"=",
"merge",
"(",
"baseOptions",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"stats",
".",
"getStat",
"(",
"remotePath",
",",
"getOptions",
")",
";",
"}"
] |
Stat a remote object
@param {String} remotePath The path of the item
@param {OptionsForAdvancedResponses=} options Options for the request
@memberof ClientInterface
@returns {Promise.<Stat>} A promise that resolves with the stat data
|
[
"Stat",
"a",
"remote",
"object"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/factory.js#L303-L306
|
9,726
|
perry-mitchell/webdav-client
|
source/request.js
|
encodePath
|
function encodePath(path) {
const replaced = path.replace(/\//g, SEP_PATH_POSIX).replace(/\\\\/g, SEP_PATH_WINDOWS);
const formatted = encodeURIComponent(replaced);
return formatted
.split(SEP_PATH_WINDOWS)
.join("\\\\")
.split(SEP_PATH_POSIX)
.join("/");
}
|
javascript
|
function encodePath(path) {
const replaced = path.replace(/\//g, SEP_PATH_POSIX).replace(/\\\\/g, SEP_PATH_WINDOWS);
const formatted = encodeURIComponent(replaced);
return formatted
.split(SEP_PATH_WINDOWS)
.join("\\\\")
.split(SEP_PATH_POSIX)
.join("/");
}
|
[
"function",
"encodePath",
"(",
"path",
")",
"{",
"const",
"replaced",
"=",
"path",
".",
"replace",
"(",
"/",
"\\/",
"/",
"g",
",",
"SEP_PATH_POSIX",
")",
".",
"replace",
"(",
"/",
"\\\\\\\\",
"/",
"g",
",",
"SEP_PATH_WINDOWS",
")",
";",
"const",
"formatted",
"=",
"encodeURIComponent",
"(",
"replaced",
")",
";",
"return",
"formatted",
".",
"split",
"(",
"SEP_PATH_WINDOWS",
")",
".",
"join",
"(",
"\"\\\\\\\\\"",
")",
".",
"split",
"(",
"SEP_PATH_POSIX",
")",
".",
"join",
"(",
"\"/\"",
")",
";",
"}"
] |
Encode a path for use with WebDAV servers
@param {String} path The path to encode
@returns {String} The encoded path (separators protected)
|
[
"Encode",
"a",
"path",
"for",
"use",
"with",
"WebDAV",
"servers"
] |
d23165a7e3e3760312fe39ec1227e729a4e3ab80
|
https://github.com/perry-mitchell/webdav-client/blob/d23165a7e3e3760312fe39ec1227e729a4e3ab80/source/request.js#L13-L21
|
9,727
|
lumapps/lumX
|
modules/select/demo/js/demo-select_controller.js
|
callApi
|
function callApi() {
vm.pageInfiniteScroll++;
vm.loadingInfiniteScroll = true;
return $http
.get(
'https://randomuser.me/api/?results=10&seed=lumapps&page=' + vm.pageInfiniteScroll
)
.then(function(response) {
if (response.data && response.data.results) {
return response.data.results.map(function(person) {
return {
name: person.name.first,
email: person.email,
age: person.dob.age
};
});
} else {
return [];
}
})
.catch(function() {
return [];
})
.finally(function() {
vm.loadingInfiniteScroll = false;
});
}
|
javascript
|
function callApi() {
vm.pageInfiniteScroll++;
vm.loadingInfiniteScroll = true;
return $http
.get(
'https://randomuser.me/api/?results=10&seed=lumapps&page=' + vm.pageInfiniteScroll
)
.then(function(response) {
if (response.data && response.data.results) {
return response.data.results.map(function(person) {
return {
name: person.name.first,
email: person.email,
age: person.dob.age
};
});
} else {
return [];
}
})
.catch(function() {
return [];
})
.finally(function() {
vm.loadingInfiniteScroll = false;
});
}
|
[
"function",
"callApi",
"(",
")",
"{",
"vm",
".",
"pageInfiniteScroll",
"++",
";",
"vm",
".",
"loadingInfiniteScroll",
"=",
"true",
";",
"return",
"$http",
".",
"get",
"(",
"'https://randomuser.me/api/?results=10&seed=lumapps&page='",
"+",
"vm",
".",
"pageInfiniteScroll",
")",
".",
"then",
"(",
"function",
"(",
"response",
")",
"{",
"if",
"(",
"response",
".",
"data",
"&&",
"response",
".",
"data",
".",
"results",
")",
"{",
"return",
"response",
".",
"data",
".",
"results",
".",
"map",
"(",
"function",
"(",
"person",
")",
"{",
"return",
"{",
"name",
":",
"person",
".",
"name",
".",
"first",
",",
"email",
":",
"person",
".",
"email",
",",
"age",
":",
"person",
".",
"dob",
".",
"age",
"}",
";",
"}",
")",
";",
"}",
"else",
"{",
"return",
"[",
"]",
";",
"}",
"}",
")",
".",
"catch",
"(",
"function",
"(",
")",
"{",
"return",
"[",
"]",
";",
"}",
")",
".",
"finally",
"(",
"function",
"(",
")",
"{",
"vm",
".",
"loadingInfiniteScroll",
"=",
"false",
";",
"}",
")",
";",
"}"
] |
Call sample API.
@return {Promise} Promise containing an array of users.
|
[
"Call",
"sample",
"API",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/modules/select/demo/js/demo-select_controller.js#L405-L432
|
9,728
|
lumapps/lumX
|
modules/notification/js/notification_service.js
|
reComputeElementsPosition
|
function reComputeElementsPosition()
{
var baseOffset = 0;
for (var idx = notificationList.length -1; idx >= 0; idx--)
{
notificationList[idx].height = getElementHeight(notificationList[idx].elem[0]);
notificationList[idx].margin = baseOffset;
notificationList[idx].elem.css('marginBottom', notificationList[idx].margin + 'px');
baseOffset += notificationList[idx].height + 24;
}
}
|
javascript
|
function reComputeElementsPosition()
{
var baseOffset = 0;
for (var idx = notificationList.length -1; idx >= 0; idx--)
{
notificationList[idx].height = getElementHeight(notificationList[idx].elem[0]);
notificationList[idx].margin = baseOffset;
notificationList[idx].elem.css('marginBottom', notificationList[idx].margin + 'px');
baseOffset += notificationList[idx].height + 24;
}
}
|
[
"function",
"reComputeElementsPosition",
"(",
")",
"{",
"var",
"baseOffset",
"=",
"0",
";",
"for",
"(",
"var",
"idx",
"=",
"notificationList",
".",
"length",
"-",
"1",
";",
"idx",
">=",
"0",
";",
"idx",
"--",
")",
"{",
"notificationList",
"[",
"idx",
"]",
".",
"height",
"=",
"getElementHeight",
"(",
"notificationList",
"[",
"idx",
"]",
".",
"elem",
"[",
"0",
"]",
")",
";",
"notificationList",
"[",
"idx",
"]",
".",
"margin",
"=",
"baseOffset",
";",
"notificationList",
"[",
"idx",
"]",
".",
"elem",
".",
"css",
"(",
"'marginBottom'",
",",
"notificationList",
"[",
"idx",
"]",
".",
"margin",
"+",
"'px'",
")",
";",
"baseOffset",
"+=",
"notificationList",
"[",
"idx",
"]",
".",
"height",
"+",
"24",
";",
"}",
"}"
] |
Compute the notification list element new position.
Usefull when the height change programmatically and you need other notifications to fit.
|
[
"Compute",
"the",
"notification",
"list",
"element",
"new",
"position",
".",
"Usefull",
"when",
"the",
"height",
"change",
"programmatically",
"and",
"you",
"need",
"other",
"notifications",
"to",
"fit",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/modules/notification/js/notification_service.js#L102-L115
|
9,729
|
lumapps/lumX
|
modules/notification/js/notification_service.js
|
buildDialogActions
|
function buildDialogActions(_buttons, _callback, _unbind)
{
var $compile = $injector.get('$compile');
var dialogActions = angular.element('<div/>',
{
class: 'dialog__footer'
});
var dialogLastBtn = angular.element('<button/>',
{
class: 'btn btn--m btn--blue btn--flat',
text: _buttons.ok
});
if (angular.isDefined(_buttons.cancel))
{
var dialogFirstBtn = angular.element('<button/>',
{
class: 'btn btn--m btn--red btn--flat',
text: _buttons.cancel
});
dialogFirstBtn.attr('lx-ripple', '');
$compile(dialogFirstBtn)($rootScope);
dialogActions.append(dialogFirstBtn);
dialogFirstBtn.bind('click', function()
{
_callback(false);
closeDialog();
});
}
dialogLastBtn.attr('lx-ripple', '');
$compile(dialogLastBtn)($rootScope);
dialogActions.append(dialogLastBtn);
dialogLastBtn.bind('click', function()
{
_callback(true);
closeDialog();
});
if (!_unbind)
{
idEventScheduler = LxEventSchedulerService.register('keyup', function(event)
{
if (event.keyCode == 13)
{
_callback(true);
closeDialog();
}
else if (event.keyCode == 27)
{
_callback(angular.isUndefined(_buttons.cancel));
closeDialog();
}
event.stopPropagation();
});
}
return dialogActions;
}
|
javascript
|
function buildDialogActions(_buttons, _callback, _unbind)
{
var $compile = $injector.get('$compile');
var dialogActions = angular.element('<div/>',
{
class: 'dialog__footer'
});
var dialogLastBtn = angular.element('<button/>',
{
class: 'btn btn--m btn--blue btn--flat',
text: _buttons.ok
});
if (angular.isDefined(_buttons.cancel))
{
var dialogFirstBtn = angular.element('<button/>',
{
class: 'btn btn--m btn--red btn--flat',
text: _buttons.cancel
});
dialogFirstBtn.attr('lx-ripple', '');
$compile(dialogFirstBtn)($rootScope);
dialogActions.append(dialogFirstBtn);
dialogFirstBtn.bind('click', function()
{
_callback(false);
closeDialog();
});
}
dialogLastBtn.attr('lx-ripple', '');
$compile(dialogLastBtn)($rootScope);
dialogActions.append(dialogLastBtn);
dialogLastBtn.bind('click', function()
{
_callback(true);
closeDialog();
});
if (!_unbind)
{
idEventScheduler = LxEventSchedulerService.register('keyup', function(event)
{
if (event.keyCode == 13)
{
_callback(true);
closeDialog();
}
else if (event.keyCode == 27)
{
_callback(angular.isUndefined(_buttons.cancel));
closeDialog();
}
event.stopPropagation();
});
}
return dialogActions;
}
|
[
"function",
"buildDialogActions",
"(",
"_buttons",
",",
"_callback",
",",
"_unbind",
")",
"{",
"var",
"$compile",
"=",
"$injector",
".",
"get",
"(",
"'$compile'",
")",
";",
"var",
"dialogActions",
"=",
"angular",
".",
"element",
"(",
"'<div/>'",
",",
"{",
"class",
":",
"'dialog__footer'",
"}",
")",
";",
"var",
"dialogLastBtn",
"=",
"angular",
".",
"element",
"(",
"'<button/>'",
",",
"{",
"class",
":",
"'btn btn--m btn--blue btn--flat'",
",",
"text",
":",
"_buttons",
".",
"ok",
"}",
")",
";",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"_buttons",
".",
"cancel",
")",
")",
"{",
"var",
"dialogFirstBtn",
"=",
"angular",
".",
"element",
"(",
"'<button/>'",
",",
"{",
"class",
":",
"'btn btn--m btn--red btn--flat'",
",",
"text",
":",
"_buttons",
".",
"cancel",
"}",
")",
";",
"dialogFirstBtn",
".",
"attr",
"(",
"'lx-ripple'",
",",
"''",
")",
";",
"$compile",
"(",
"dialogFirstBtn",
")",
"(",
"$rootScope",
")",
";",
"dialogActions",
".",
"append",
"(",
"dialogFirstBtn",
")",
";",
"dialogFirstBtn",
".",
"bind",
"(",
"'click'",
",",
"function",
"(",
")",
"{",
"_callback",
"(",
"false",
")",
";",
"closeDialog",
"(",
")",
";",
"}",
")",
";",
"}",
"dialogLastBtn",
".",
"attr",
"(",
"'lx-ripple'",
",",
"''",
")",
";",
"$compile",
"(",
"dialogLastBtn",
")",
"(",
"$rootScope",
")",
";",
"dialogActions",
".",
"append",
"(",
"dialogLastBtn",
")",
";",
"dialogLastBtn",
".",
"bind",
"(",
"'click'",
",",
"function",
"(",
")",
"{",
"_callback",
"(",
"true",
")",
";",
"closeDialog",
"(",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"_unbind",
")",
"{",
"idEventScheduler",
"=",
"LxEventSchedulerService",
".",
"register",
"(",
"'keyup'",
",",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"keyCode",
"==",
"13",
")",
"{",
"_callback",
"(",
"true",
")",
";",
"closeDialog",
"(",
")",
";",
"}",
"else",
"if",
"(",
"event",
".",
"keyCode",
"==",
"27",
")",
"{",
"_callback",
"(",
"angular",
".",
"isUndefined",
"(",
"_buttons",
".",
"cancel",
")",
")",
";",
"closeDialog",
"(",
")",
";",
"}",
"event",
".",
"stopPropagation",
"(",
")",
";",
"}",
")",
";",
"}",
"return",
"dialogActions",
";",
"}"
] |
ALERT & CONFIRM
|
[
"ALERT",
"&",
"CONFIRM"
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/modules/notification/js/notification_service.js#L254-L320
|
9,730
|
lumapps/lumX
|
dist/lumx.js
|
_closePanes
|
function _closePanes() {
toggledPanes = {};
if (lxSelect.choicesViewSize === 'large') {
if (angular.isDefined(lxSelect.choices) && lxSelect.choices !== null) {
lxSelect.panes = [lxSelect.choices];
} else {
lxSelect.panes = [];
}
} else {
if (angular.isDefined(lxSelect.choices) && lxSelect.choices !== null) {
lxSelect.openedPanes = [lxSelect.choices];
} else {
lxSelect.openedPanes = [];
}
}
}
|
javascript
|
function _closePanes() {
toggledPanes = {};
if (lxSelect.choicesViewSize === 'large') {
if (angular.isDefined(lxSelect.choices) && lxSelect.choices !== null) {
lxSelect.panes = [lxSelect.choices];
} else {
lxSelect.panes = [];
}
} else {
if (angular.isDefined(lxSelect.choices) && lxSelect.choices !== null) {
lxSelect.openedPanes = [lxSelect.choices];
} else {
lxSelect.openedPanes = [];
}
}
}
|
[
"function",
"_closePanes",
"(",
")",
"{",
"toggledPanes",
"=",
"{",
"}",
";",
"if",
"(",
"lxSelect",
".",
"choicesViewSize",
"===",
"'large'",
")",
"{",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"lxSelect",
".",
"choices",
")",
"&&",
"lxSelect",
".",
"choices",
"!==",
"null",
")",
"{",
"lxSelect",
".",
"panes",
"=",
"[",
"lxSelect",
".",
"choices",
"]",
";",
"}",
"else",
"{",
"lxSelect",
".",
"panes",
"=",
"[",
"]",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"lxSelect",
".",
"choices",
")",
"&&",
"lxSelect",
".",
"choices",
"!==",
"null",
")",
"{",
"lxSelect",
".",
"openedPanes",
"=",
"[",
"lxSelect",
".",
"choices",
"]",
";",
"}",
"else",
"{",
"lxSelect",
".",
"openedPanes",
"=",
"[",
"]",
";",
"}",
"}",
"}"
] |
Close all panes.
|
[
"Close",
"all",
"panes",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4436-L4452
|
9,731
|
lumapps/lumX
|
dist/lumx.js
|
_findIndex
|
function _findIndex(haystack, needle) {
if (angular.isUndefined(haystack) || haystack.length === 0) {
return -1;
}
for (var i = 0, len = haystack.length; i < len; i++) {
if (haystack[i] === needle) {
return i;
}
}
return -1;
}
|
javascript
|
function _findIndex(haystack, needle) {
if (angular.isUndefined(haystack) || haystack.length === 0) {
return -1;
}
for (var i = 0, len = haystack.length; i < len; i++) {
if (haystack[i] === needle) {
return i;
}
}
return -1;
}
|
[
"function",
"_findIndex",
"(",
"haystack",
",",
"needle",
")",
"{",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"haystack",
")",
"||",
"haystack",
".",
"length",
"===",
"0",
")",
"{",
"return",
"-",
"1",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"haystack",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"haystack",
"[",
"i",
"]",
"===",
"needle",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] |
Find the index of an element in an array.
@param {Array} haystack The array in which to search for the value.
@param {*} needle The value to search in the array.
@return {number} The index of the value of the array, or -1 if not found.
|
[
"Find",
"the",
"index",
"of",
"an",
"element",
"in",
"an",
"array",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4461-L4473
|
9,732
|
lumapps/lumX
|
dist/lumx.js
|
_getLongestMatchingPath
|
function _getLongestMatchingPath(containing) {
if (angular.isUndefined(lxSelect.matchingPaths) || lxSelect.matchingPaths.length === 0) {
return undefined;
}
containing = containing || lxSelect.matchingPaths[0];
var longest = lxSelect.matchingPaths[0];
var longestSize = longest.split('.').length;
for (var i = 1, len = lxSelect.matchingPaths.length; i < len; i++) {
var matchingPath = lxSelect.matchingPaths[i];
if (!matchingPath) {
continue;
}
if (matchingPath.indexOf(containing) === -1) {
break;
}
var size = matchingPath.split('.').length;
if (size > longestSize) {
longest = matchingPath;
longestSize = size;
}
}
return longest;
}
|
javascript
|
function _getLongestMatchingPath(containing) {
if (angular.isUndefined(lxSelect.matchingPaths) || lxSelect.matchingPaths.length === 0) {
return undefined;
}
containing = containing || lxSelect.matchingPaths[0];
var longest = lxSelect.matchingPaths[0];
var longestSize = longest.split('.').length;
for (var i = 1, len = lxSelect.matchingPaths.length; i < len; i++) {
var matchingPath = lxSelect.matchingPaths[i];
if (!matchingPath) {
continue;
}
if (matchingPath.indexOf(containing) === -1) {
break;
}
var size = matchingPath.split('.').length;
if (size > longestSize) {
longest = matchingPath;
longestSize = size;
}
}
return longest;
}
|
[
"function",
"_getLongestMatchingPath",
"(",
"containing",
")",
"{",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"lxSelect",
".",
"matchingPaths",
")",
"||",
"lxSelect",
".",
"matchingPaths",
".",
"length",
"===",
"0",
")",
"{",
"return",
"undefined",
";",
"}",
"containing",
"=",
"containing",
"||",
"lxSelect",
".",
"matchingPaths",
"[",
"0",
"]",
";",
"var",
"longest",
"=",
"lxSelect",
".",
"matchingPaths",
"[",
"0",
"]",
";",
"var",
"longestSize",
"=",
"longest",
".",
"split",
"(",
"'.'",
")",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"1",
",",
"len",
"=",
"lxSelect",
".",
"matchingPaths",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"matchingPath",
"=",
"lxSelect",
".",
"matchingPaths",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"matchingPath",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"matchingPath",
".",
"indexOf",
"(",
"containing",
")",
"===",
"-",
"1",
")",
"{",
"break",
";",
"}",
"var",
"size",
"=",
"matchingPath",
".",
"split",
"(",
"'.'",
")",
".",
"length",
";",
"if",
"(",
"size",
">",
"longestSize",
")",
"{",
"longest",
"=",
"matchingPath",
";",
"longestSize",
"=",
"size",
";",
"}",
"}",
"return",
"longest",
";",
"}"
] |
Get the longest matching path containing the given string.
@param {string} [containing] The string we want the matching path to contain.
If none given, just take the longest matching path of the first matching path.
|
[
"Get",
"the",
"longest",
"matching",
"path",
"containing",
"the",
"given",
"string",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4481-L4508
|
9,733
|
lumapps/lumX
|
dist/lumx.js
|
_keyLeft
|
function _keyLeft() {
if (lxSelect.choicesViewMode !== 'panes' || lxSelect.panes.length < 2) {
return;
}
var previousPaneIndex = lxSelect.panes.length - 2;
lxSelect.activeChoiceIndex = (
Object.keys(lxSelect.panes[previousPaneIndex]) || []
).indexOf(
(toggledPanes[previousPaneIndex] || {}).key
);
_closePane(previousPaneIndex);
}
|
javascript
|
function _keyLeft() {
if (lxSelect.choicesViewMode !== 'panes' || lxSelect.panes.length < 2) {
return;
}
var previousPaneIndex = lxSelect.panes.length - 2;
lxSelect.activeChoiceIndex = (
Object.keys(lxSelect.panes[previousPaneIndex]) || []
).indexOf(
(toggledPanes[previousPaneIndex] || {}).key
);
_closePane(previousPaneIndex);
}
|
[
"function",
"_keyLeft",
"(",
")",
"{",
"if",
"(",
"lxSelect",
".",
"choicesViewMode",
"!==",
"'panes'",
"||",
"lxSelect",
".",
"panes",
".",
"length",
"<",
"2",
")",
"{",
"return",
";",
"}",
"var",
"previousPaneIndex",
"=",
"lxSelect",
".",
"panes",
".",
"length",
"-",
"2",
";",
"lxSelect",
".",
"activeChoiceIndex",
"=",
"(",
"Object",
".",
"keys",
"(",
"lxSelect",
".",
"panes",
"[",
"previousPaneIndex",
"]",
")",
"||",
"[",
"]",
")",
".",
"indexOf",
"(",
"(",
"toggledPanes",
"[",
"previousPaneIndex",
"]",
"||",
"{",
"}",
")",
".",
"key",
")",
";",
"_closePane",
"(",
"previousPaneIndex",
")",
";",
"}"
] |
When the left key is pressed and we are displaying the choices in pane mode, close the most right opened
pane.
|
[
"When",
"the",
"left",
"key",
"is",
"pressed",
"and",
"we",
"are",
"displaying",
"the",
"choices",
"in",
"pane",
"mode",
"close",
"the",
"most",
"right",
"opened",
"pane",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4544-L4558
|
9,734
|
lumapps/lumX
|
dist/lumx.js
|
_keyRight
|
function _keyRight() {
if (lxSelect.choicesViewMode !== 'panes' || lxSelect.activeChoiceIndex === -1) {
return;
}
var paneOpened = _openPane((lxSelect.panes.length - 1), lxSelect.activeChoiceIndex, true);
if (paneOpened) {
lxSelect.activeChoiceIndex = 0;
} else {
_keySelect();
}
}
|
javascript
|
function _keyRight() {
if (lxSelect.choicesViewMode !== 'panes' || lxSelect.activeChoiceIndex === -1) {
return;
}
var paneOpened = _openPane((lxSelect.panes.length - 1), lxSelect.activeChoiceIndex, true);
if (paneOpened) {
lxSelect.activeChoiceIndex = 0;
} else {
_keySelect();
}
}
|
[
"function",
"_keyRight",
"(",
")",
"{",
"if",
"(",
"lxSelect",
".",
"choicesViewMode",
"!==",
"'panes'",
"||",
"lxSelect",
".",
"activeChoiceIndex",
"===",
"-",
"1",
")",
"{",
"return",
";",
"}",
"var",
"paneOpened",
"=",
"_openPane",
"(",
"(",
"lxSelect",
".",
"panes",
".",
"length",
"-",
"1",
")",
",",
"lxSelect",
".",
"activeChoiceIndex",
",",
"true",
")",
";",
"if",
"(",
"paneOpened",
")",
"{",
"lxSelect",
".",
"activeChoiceIndex",
"=",
"0",
";",
"}",
"else",
"{",
"_keySelect",
"(",
")",
";",
"}",
"}"
] |
When the right key is pressed and we are displaying the choices in pane mode, open the currently selected
pane.
|
[
"When",
"the",
"right",
"key",
"is",
"pressed",
"and",
"we",
"are",
"displaying",
"the",
"choices",
"in",
"pane",
"mode",
"open",
"the",
"currently",
"selected",
"pane",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4581-L4593
|
9,735
|
lumapps/lumX
|
dist/lumx.js
|
_keySelect
|
function _keySelect() {
var filteredChoices;
if (lxSelect.choicesViewMode === 'panes') {
filteredChoices = lxSelect.panes[(lxSelect.panes.length - 1)];
if (!lxSelect.isLeaf(filteredChoices[lxSelect.activeChoiceIndex])) {
return;
}
} else {
filteredChoices = $filter('filterChoices')(lxSelect.choices, lxSelect.filter, lxSelect.filterModel);
}
if (filteredChoices.length && filteredChoices[lxSelect.activeChoiceIndex]) {
lxSelect.toggleChoice(filteredChoices[lxSelect.activeChoiceIndex]);
} else if (lxSelect.filterModel && lxSelect.allowNewValue) {
if (angular.isArray(getSelectedModel())) {
var value = angular.isFunction(lxSelect.newValueTransform) ? lxSelect.newValueTransform(lxSelect.filterModel) : lxSelect.filterModel;
var identical = getSelectedModel().some(function (item) {
return angular.equals(item, value);
});
if (!identical) {
lxSelect.getSelectedModel().push(value);
}
}
lxSelect.filterModel = undefined;
LxDropdownService.close('dropdown-' + lxSelect.uuid);
}
}
|
javascript
|
function _keySelect() {
var filteredChoices;
if (lxSelect.choicesViewMode === 'panes') {
filteredChoices = lxSelect.panes[(lxSelect.panes.length - 1)];
if (!lxSelect.isLeaf(filteredChoices[lxSelect.activeChoiceIndex])) {
return;
}
} else {
filteredChoices = $filter('filterChoices')(lxSelect.choices, lxSelect.filter, lxSelect.filterModel);
}
if (filteredChoices.length && filteredChoices[lxSelect.activeChoiceIndex]) {
lxSelect.toggleChoice(filteredChoices[lxSelect.activeChoiceIndex]);
} else if (lxSelect.filterModel && lxSelect.allowNewValue) {
if (angular.isArray(getSelectedModel())) {
var value = angular.isFunction(lxSelect.newValueTransform) ? lxSelect.newValueTransform(lxSelect.filterModel) : lxSelect.filterModel;
var identical = getSelectedModel().some(function (item) {
return angular.equals(item, value);
});
if (!identical) {
lxSelect.getSelectedModel().push(value);
}
}
lxSelect.filterModel = undefined;
LxDropdownService.close('dropdown-' + lxSelect.uuid);
}
}
|
[
"function",
"_keySelect",
"(",
")",
"{",
"var",
"filteredChoices",
";",
"if",
"(",
"lxSelect",
".",
"choicesViewMode",
"===",
"'panes'",
")",
"{",
"filteredChoices",
"=",
"lxSelect",
".",
"panes",
"[",
"(",
"lxSelect",
".",
"panes",
".",
"length",
"-",
"1",
")",
"]",
";",
"if",
"(",
"!",
"lxSelect",
".",
"isLeaf",
"(",
"filteredChoices",
"[",
"lxSelect",
".",
"activeChoiceIndex",
"]",
")",
")",
"{",
"return",
";",
"}",
"}",
"else",
"{",
"filteredChoices",
"=",
"$filter",
"(",
"'filterChoices'",
")",
"(",
"lxSelect",
".",
"choices",
",",
"lxSelect",
".",
"filter",
",",
"lxSelect",
".",
"filterModel",
")",
";",
"}",
"if",
"(",
"filteredChoices",
".",
"length",
"&&",
"filteredChoices",
"[",
"lxSelect",
".",
"activeChoiceIndex",
"]",
")",
"{",
"lxSelect",
".",
"toggleChoice",
"(",
"filteredChoices",
"[",
"lxSelect",
".",
"activeChoiceIndex",
"]",
")",
";",
"}",
"else",
"if",
"(",
"lxSelect",
".",
"filterModel",
"&&",
"lxSelect",
".",
"allowNewValue",
")",
"{",
"if",
"(",
"angular",
".",
"isArray",
"(",
"getSelectedModel",
"(",
")",
")",
")",
"{",
"var",
"value",
"=",
"angular",
".",
"isFunction",
"(",
"lxSelect",
".",
"newValueTransform",
")",
"?",
"lxSelect",
".",
"newValueTransform",
"(",
"lxSelect",
".",
"filterModel",
")",
":",
"lxSelect",
".",
"filterModel",
";",
"var",
"identical",
"=",
"getSelectedModel",
"(",
")",
".",
"some",
"(",
"function",
"(",
"item",
")",
"{",
"return",
"angular",
".",
"equals",
"(",
"item",
",",
"value",
")",
";",
"}",
")",
";",
"if",
"(",
"!",
"identical",
")",
"{",
"lxSelect",
".",
"getSelectedModel",
"(",
")",
".",
"push",
"(",
"value",
")",
";",
"}",
"}",
"lxSelect",
".",
"filterModel",
"=",
"undefined",
";",
"LxDropdownService",
".",
"close",
"(",
"'dropdown-'",
"+",
"lxSelect",
".",
"uuid",
")",
";",
"}",
"}"
] |
When the enter key is pressed, select the currently active choice.
|
[
"When",
"the",
"enter",
"key",
"is",
"pressed",
"select",
"the",
"currently",
"active",
"choice",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4598-L4628
|
9,736
|
lumapps/lumX
|
dist/lumx.js
|
_openPane
|
function _openPane(parentIndex, indexOrKey, checkIsLeaf) {
if (angular.isDefined(toggledPanes[parentIndex])) {
return false;
}
var pane = pane || lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex];
if (angular.isUndefined(pane)) {
return false;
}
var key = indexOrKey;
if (angular.isObject(pane) && angular.isNumber(key)) {
key = (Object.keys(pane) || [])[key];
}
if (checkIsLeaf && lxSelect.isLeaf(pane[key])) {
return false;
}
if (lxSelect.choicesViewSize === 'large') {
lxSelect.panes.push(pane[key]);
} else {
lxSelect.openedPanes.push(pane[key]);
}
toggledPanes[parentIndex] = {
key: key,
position: lxSelect.choicesViewSize === 'large' ? lxSelect.panes.length - 1 : lxSelect.openedPanes.length - 1,
path: (parentIndex === 0) ? key : toggledPanes[parentIndex - 1].path + '.' + key,
};
return true;
}
|
javascript
|
function _openPane(parentIndex, indexOrKey, checkIsLeaf) {
if (angular.isDefined(toggledPanes[parentIndex])) {
return false;
}
var pane = pane || lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex];
if (angular.isUndefined(pane)) {
return false;
}
var key = indexOrKey;
if (angular.isObject(pane) && angular.isNumber(key)) {
key = (Object.keys(pane) || [])[key];
}
if (checkIsLeaf && lxSelect.isLeaf(pane[key])) {
return false;
}
if (lxSelect.choicesViewSize === 'large') {
lxSelect.panes.push(pane[key]);
} else {
lxSelect.openedPanes.push(pane[key]);
}
toggledPanes[parentIndex] = {
key: key,
position: lxSelect.choicesViewSize === 'large' ? lxSelect.panes.length - 1 : lxSelect.openedPanes.length - 1,
path: (parentIndex === 0) ? key : toggledPanes[parentIndex - 1].path + '.' + key,
};
return true;
}
|
[
"function",
"_openPane",
"(",
"parentIndex",
",",
"indexOrKey",
",",
"checkIsLeaf",
")",
"{",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"toggledPanes",
"[",
"parentIndex",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"pane",
"=",
"pane",
"||",
"lxSelect",
".",
"choicesViewSize",
"===",
"'large'",
"?",
"lxSelect",
".",
"panes",
"[",
"parentIndex",
"]",
":",
"lxSelect",
".",
"openedPanes",
"[",
"parentIndex",
"]",
";",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"pane",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"key",
"=",
"indexOrKey",
";",
"if",
"(",
"angular",
".",
"isObject",
"(",
"pane",
")",
"&&",
"angular",
".",
"isNumber",
"(",
"key",
")",
")",
"{",
"key",
"=",
"(",
"Object",
".",
"keys",
"(",
"pane",
")",
"||",
"[",
"]",
")",
"[",
"key",
"]",
";",
"}",
"if",
"(",
"checkIsLeaf",
"&&",
"lxSelect",
".",
"isLeaf",
"(",
"pane",
"[",
"key",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"lxSelect",
".",
"choicesViewSize",
"===",
"'large'",
")",
"{",
"lxSelect",
".",
"panes",
".",
"push",
"(",
"pane",
"[",
"key",
"]",
")",
";",
"}",
"else",
"{",
"lxSelect",
".",
"openedPanes",
".",
"push",
"(",
"pane",
"[",
"key",
"]",
")",
";",
"}",
"toggledPanes",
"[",
"parentIndex",
"]",
"=",
"{",
"key",
":",
"key",
",",
"position",
":",
"lxSelect",
".",
"choicesViewSize",
"===",
"'large'",
"?",
"lxSelect",
".",
"panes",
".",
"length",
"-",
"1",
":",
"lxSelect",
".",
"openedPanes",
".",
"length",
"-",
"1",
",",
"path",
":",
"(",
"parentIndex",
"===",
"0",
")",
"?",
"key",
":",
"toggledPanes",
"[",
"parentIndex",
"-",
"1",
"]",
".",
"path",
"+",
"'.'",
"+",
"key",
",",
"}",
";",
"return",
"true",
";",
"}"
] |
Open a pane.
If the pane is already opened, don't do anything.
@param {number} parentIndex The index of the parent of the pane to open.
@param {number|string} indexOrKey The index or the name of the pane to open.
@param {boolean} [checkIsLeaf=false] Check if the pane we want to open is in fact a leaf.
In the case of a leaf, don't open it.
@return {boolean} Indicates if the panel has been opened or not.
|
[
"Open",
"a",
"pane",
".",
"If",
"the",
"pane",
"is",
"already",
"opened",
"don",
"t",
"do",
"anything",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4677-L4710
|
9,737
|
lumapps/lumX
|
dist/lumx.js
|
_searchPath
|
function _searchPath(container, regexp, previousKey, limitToFields) {
limitToFields = limitToFields || [];
limitToFields = (angular.isArray(limitToFields)) ? limitToFields : [limitToFields];
var results = [];
angular.forEach(container, function forEachItemsInContainer(items, key) {
if (limitToFields.length > 0 && limitToFields.indexOf(key) === -1) {
return;
}
var pathToMatching = (previousKey) ? previousKey + '.' + key : key;
var previousKeyAdded = false;
var isLeaf = lxSelect.isLeaf(items);
if ((!isLeaf && angular.isString(key) && regexp.test(key)) || (angular.isString(items) && regexp.test(items))) {
if (!previousKeyAdded && previousKey) {
results.push(previousKey);
}
if (!isLeaf) {
results.push(pathToMatching);
}
}
if (angular.isArray(items) || angular.isObject(items)) {
var newPaths = _searchPath(items, regexp, pathToMatching, (isLeaf) ? lxSelect.filterFields : []);
if (angular.isDefined(newPaths) && newPaths.length > 0) {
if (previousKey) {
results.push(previousKey);
previousKeyAdded = true;
}
results = results.concat(newPaths);
}
}
});
return results;
}
|
javascript
|
function _searchPath(container, regexp, previousKey, limitToFields) {
limitToFields = limitToFields || [];
limitToFields = (angular.isArray(limitToFields)) ? limitToFields : [limitToFields];
var results = [];
angular.forEach(container, function forEachItemsInContainer(items, key) {
if (limitToFields.length > 0 && limitToFields.indexOf(key) === -1) {
return;
}
var pathToMatching = (previousKey) ? previousKey + '.' + key : key;
var previousKeyAdded = false;
var isLeaf = lxSelect.isLeaf(items);
if ((!isLeaf && angular.isString(key) && regexp.test(key)) || (angular.isString(items) && regexp.test(items))) {
if (!previousKeyAdded && previousKey) {
results.push(previousKey);
}
if (!isLeaf) {
results.push(pathToMatching);
}
}
if (angular.isArray(items) || angular.isObject(items)) {
var newPaths = _searchPath(items, regexp, pathToMatching, (isLeaf) ? lxSelect.filterFields : []);
if (angular.isDefined(newPaths) && newPaths.length > 0) {
if (previousKey) {
results.push(previousKey);
previousKeyAdded = true;
}
results = results.concat(newPaths);
}
}
});
return results;
}
|
[
"function",
"_searchPath",
"(",
"container",
",",
"regexp",
",",
"previousKey",
",",
"limitToFields",
")",
"{",
"limitToFields",
"=",
"limitToFields",
"||",
"[",
"]",
";",
"limitToFields",
"=",
"(",
"angular",
".",
"isArray",
"(",
"limitToFields",
")",
")",
"?",
"limitToFields",
":",
"[",
"limitToFields",
"]",
";",
"var",
"results",
"=",
"[",
"]",
";",
"angular",
".",
"forEach",
"(",
"container",
",",
"function",
"forEachItemsInContainer",
"(",
"items",
",",
"key",
")",
"{",
"if",
"(",
"limitToFields",
".",
"length",
">",
"0",
"&&",
"limitToFields",
".",
"indexOf",
"(",
"key",
")",
"===",
"-",
"1",
")",
"{",
"return",
";",
"}",
"var",
"pathToMatching",
"=",
"(",
"previousKey",
")",
"?",
"previousKey",
"+",
"'.'",
"+",
"key",
":",
"key",
";",
"var",
"previousKeyAdded",
"=",
"false",
";",
"var",
"isLeaf",
"=",
"lxSelect",
".",
"isLeaf",
"(",
"items",
")",
";",
"if",
"(",
"(",
"!",
"isLeaf",
"&&",
"angular",
".",
"isString",
"(",
"key",
")",
"&&",
"regexp",
".",
"test",
"(",
"key",
")",
")",
"||",
"(",
"angular",
".",
"isString",
"(",
"items",
")",
"&&",
"regexp",
".",
"test",
"(",
"items",
")",
")",
")",
"{",
"if",
"(",
"!",
"previousKeyAdded",
"&&",
"previousKey",
")",
"{",
"results",
".",
"push",
"(",
"previousKey",
")",
";",
"}",
"if",
"(",
"!",
"isLeaf",
")",
"{",
"results",
".",
"push",
"(",
"pathToMatching",
")",
";",
"}",
"}",
"if",
"(",
"angular",
".",
"isArray",
"(",
"items",
")",
"||",
"angular",
".",
"isObject",
"(",
"items",
")",
")",
"{",
"var",
"newPaths",
"=",
"_searchPath",
"(",
"items",
",",
"regexp",
",",
"pathToMatching",
",",
"(",
"isLeaf",
")",
"?",
"lxSelect",
".",
"filterFields",
":",
"[",
"]",
")",
";",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"newPaths",
")",
"&&",
"newPaths",
".",
"length",
">",
"0",
")",
"{",
"if",
"(",
"previousKey",
")",
"{",
"results",
".",
"push",
"(",
"previousKey",
")",
";",
"previousKeyAdded",
"=",
"true",
";",
"}",
"results",
"=",
"results",
".",
"concat",
"(",
"newPaths",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"results",
";",
"}"
] |
Search for any path in an object containing the given regexp as a key or as a value.
@param {*} container The container in which to search for the regexp.
@param {RegExp} regexp The regular expression to search in keys or values of the object (nested)
@param {string} previousKey The path to the current object.
@param {Array} [limitToFields=Array()] The fields in which we want to look for the filter.
If none give, then use all the fields of the object.
@return {Array} The list of paths that have matching key or value.
|
[
"Search",
"for",
"any",
"path",
"in",
"an",
"object",
"containing",
"the",
"given",
"regexp",
"as",
"a",
"key",
"or",
"as",
"a",
"value",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4722-L4763
|
9,738
|
lumapps/lumX
|
dist/lumx.js
|
isLeaf
|
function isLeaf(obj) {
if (angular.isUndefined(obj)) {
return false;
}
if (angular.isArray(obj)) {
return false;
}
if (!angular.isObject(obj)) {
return true;
}
if (obj.isLeaf) {
return true;
}
var isLeaf = false;
var keys = Object.keys(obj);
for (var i = 0, len = keys.length; i < len; i++) {
var property = keys[i];
if (property.charAt(0) === '$') {
continue;
}
if (!angular.isArray(obj[property]) && !angular.isObject(obj[property])) {
isLeaf = true;
break;
}
}
return isLeaf;
}
|
javascript
|
function isLeaf(obj) {
if (angular.isUndefined(obj)) {
return false;
}
if (angular.isArray(obj)) {
return false;
}
if (!angular.isObject(obj)) {
return true;
}
if (obj.isLeaf) {
return true;
}
var isLeaf = false;
var keys = Object.keys(obj);
for (var i = 0, len = keys.length; i < len; i++) {
var property = keys[i];
if (property.charAt(0) === '$') {
continue;
}
if (!angular.isArray(obj[property]) && !angular.isObject(obj[property])) {
isLeaf = true;
break;
}
}
return isLeaf;
}
|
[
"function",
"isLeaf",
"(",
"obj",
")",
"{",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"obj",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"angular",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"angular",
".",
"isObject",
"(",
"obj",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"obj",
".",
"isLeaf",
")",
"{",
"return",
"true",
";",
"}",
"var",
"isLeaf",
"=",
"false",
";",
"var",
"keys",
"=",
"Object",
".",
"keys",
"(",
"obj",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"keys",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"property",
"=",
"keys",
"[",
"i",
"]",
";",
"if",
"(",
"property",
".",
"charAt",
"(",
"0",
")",
"===",
"'$'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"angular",
".",
"isArray",
"(",
"obj",
"[",
"property",
"]",
")",
"&&",
"!",
"angular",
".",
"isObject",
"(",
"obj",
"[",
"property",
"]",
")",
")",
"{",
"isLeaf",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"isLeaf",
";",
"}"
] |
Check if an object is a leaf object.
A leaf object is an object that contains the `isLeaf` property or that has property that are anything else
than object or arrays.
@param {*} obj The object to check if it's a leaf
@return {boolean} If the object is a leaf object.
|
[
"Check",
"if",
"an",
"object",
"is",
"a",
"leaf",
"object",
".",
"A",
"leaf",
"object",
"is",
"an",
"object",
"that",
"contains",
"the",
"isLeaf",
"property",
"or",
"that",
"has",
"property",
"that",
"are",
"anything",
"else",
"than",
"object",
"or",
"arrays",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4882-L4914
|
9,739
|
lumapps/lumX
|
dist/lumx.js
|
isPaneToggled
|
function isPaneToggled(parentIndex, indexOrKey) {
var pane = lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex];
if (angular.isUndefined(pane)) {
return false;
}
var key = indexOrKey;
if (angular.isObject(pane) && angular.isNumber(indexOrKey)) {
key = (Object.keys(pane) || [])[indexOrKey];
}
return angular.isDefined(toggledPanes[parentIndex]) && toggledPanes[parentIndex].key === key;
}
|
javascript
|
function isPaneToggled(parentIndex, indexOrKey) {
var pane = lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex];
if (angular.isUndefined(pane)) {
return false;
}
var key = indexOrKey;
if (angular.isObject(pane) && angular.isNumber(indexOrKey)) {
key = (Object.keys(pane) || [])[indexOrKey];
}
return angular.isDefined(toggledPanes[parentIndex]) && toggledPanes[parentIndex].key === key;
}
|
[
"function",
"isPaneToggled",
"(",
"parentIndex",
",",
"indexOrKey",
")",
"{",
"var",
"pane",
"=",
"lxSelect",
".",
"choicesViewSize",
"===",
"'large'",
"?",
"lxSelect",
".",
"panes",
"[",
"parentIndex",
"]",
":",
"lxSelect",
".",
"openedPanes",
"[",
"parentIndex",
"]",
";",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"pane",
")",
")",
"{",
"return",
"false",
";",
"}",
"var",
"key",
"=",
"indexOrKey",
";",
"if",
"(",
"angular",
".",
"isObject",
"(",
"pane",
")",
"&&",
"angular",
".",
"isNumber",
"(",
"indexOrKey",
")",
")",
"{",
"key",
"=",
"(",
"Object",
".",
"keys",
"(",
"pane",
")",
"||",
"[",
"]",
")",
"[",
"indexOrKey",
"]",
";",
"}",
"return",
"angular",
".",
"isDefined",
"(",
"toggledPanes",
"[",
"parentIndex",
"]",
")",
"&&",
"toggledPanes",
"[",
"parentIndex",
"]",
".",
"key",
"===",
"key",
";",
"}"
] |
Check if a pane is toggled.
@param {number} parentIndex The parent index of the pane in which to check.
@param {number|string} indexOrKey The index or the name of the pane to check.
@return {boolean} If the pane is toggled or not.
|
[
"Check",
"if",
"a",
"pane",
"is",
"toggled",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4923-L4936
|
9,740
|
lumapps/lumX
|
dist/lumx.js
|
isMatchingPath
|
function isMatchingPath(parentIndex, indexOrKey) {
var pane = lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex];
if (angular.isUndefined(pane)) {
return;
}
var key = indexOrKey;
if (angular.isObject(pane) && angular.isNumber(indexOrKey)) {
key = (Object.keys(pane) || [])[indexOrKey];
}
if (parentIndex === 0) {
return _findIndex(lxSelect.matchingPaths, key) !== -1;
}
var previous = toggledPanes[parentIndex - 1];
if (angular.isUndefined(previous)) {
return false;
}
return _findIndex(lxSelect.matchingPaths, previous.path + '.' + key) !== -1;
}
|
javascript
|
function isMatchingPath(parentIndex, indexOrKey) {
var pane = lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex];
if (angular.isUndefined(pane)) {
return;
}
var key = indexOrKey;
if (angular.isObject(pane) && angular.isNumber(indexOrKey)) {
key = (Object.keys(pane) || [])[indexOrKey];
}
if (parentIndex === 0) {
return _findIndex(lxSelect.matchingPaths, key) !== -1;
}
var previous = toggledPanes[parentIndex - 1];
if (angular.isUndefined(previous)) {
return false;
}
return _findIndex(lxSelect.matchingPaths, previous.path + '.' + key) !== -1;
}
|
[
"function",
"isMatchingPath",
"(",
"parentIndex",
",",
"indexOrKey",
")",
"{",
"var",
"pane",
"=",
"lxSelect",
".",
"choicesViewSize",
"===",
"'large'",
"?",
"lxSelect",
".",
"panes",
"[",
"parentIndex",
"]",
":",
"lxSelect",
".",
"openedPanes",
"[",
"parentIndex",
"]",
";",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"pane",
")",
")",
"{",
"return",
";",
"}",
"var",
"key",
"=",
"indexOrKey",
";",
"if",
"(",
"angular",
".",
"isObject",
"(",
"pane",
")",
"&&",
"angular",
".",
"isNumber",
"(",
"indexOrKey",
")",
")",
"{",
"key",
"=",
"(",
"Object",
".",
"keys",
"(",
"pane",
")",
"||",
"[",
"]",
")",
"[",
"indexOrKey",
"]",
";",
"}",
"if",
"(",
"parentIndex",
"===",
"0",
")",
"{",
"return",
"_findIndex",
"(",
"lxSelect",
".",
"matchingPaths",
",",
"key",
")",
"!==",
"-",
"1",
";",
"}",
"var",
"previous",
"=",
"toggledPanes",
"[",
"parentIndex",
"-",
"1",
"]",
";",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"previous",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"_findIndex",
"(",
"lxSelect",
".",
"matchingPaths",
",",
"previous",
".",
"path",
"+",
"'.'",
"+",
"key",
")",
"!==",
"-",
"1",
";",
"}"
] |
Check if a path of a pane is matching the filter.
@param {number} parentIndex The index of the pane.
@param {number|string} indexOrKey The index or the name of the item to check.
|
[
"Check",
"if",
"a",
"path",
"of",
"a",
"pane",
"is",
"matching",
"the",
"filter",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4944-L4966
|
9,741
|
lumapps/lumX
|
dist/lumx.js
|
keyEvent
|
function keyEvent(evt) {
if (evt.keyCode !== 8) {
lxSelect.activeSelectedIndex = -1;
}
if (!LxDropdownService.isOpen('dropdown-' + lxSelect.uuid)) {
lxSelect.activeChoiceIndex = -1;
}
switch (evt.keyCode) {
case 8:
_keyRemove();
break;
case 13:
_keySelect();
evt.preventDefault();
break;
case 37:
if (lxSelect.activeChoiceIndex > -1) {
_keyLeft();
evt.preventDefault();
}
break;
case 38:
_keyUp();
evt.preventDefault();
break;
case 39:
if (lxSelect.activeChoiceIndex > -1) {
_keyRight();
evt.preventDefault();
}
break;
case 40:
_keyDown();
evt.preventDefault();
break;
default:
break;
}
}
|
javascript
|
function keyEvent(evt) {
if (evt.keyCode !== 8) {
lxSelect.activeSelectedIndex = -1;
}
if (!LxDropdownService.isOpen('dropdown-' + lxSelect.uuid)) {
lxSelect.activeChoiceIndex = -1;
}
switch (evt.keyCode) {
case 8:
_keyRemove();
break;
case 13:
_keySelect();
evt.preventDefault();
break;
case 37:
if (lxSelect.activeChoiceIndex > -1) {
_keyLeft();
evt.preventDefault();
}
break;
case 38:
_keyUp();
evt.preventDefault();
break;
case 39:
if (lxSelect.activeChoiceIndex > -1) {
_keyRight();
evt.preventDefault();
}
break;
case 40:
_keyDown();
evt.preventDefault();
break;
default:
break;
}
}
|
[
"function",
"keyEvent",
"(",
"evt",
")",
"{",
"if",
"(",
"evt",
".",
"keyCode",
"!==",
"8",
")",
"{",
"lxSelect",
".",
"activeSelectedIndex",
"=",
"-",
"1",
";",
"}",
"if",
"(",
"!",
"LxDropdownService",
".",
"isOpen",
"(",
"'dropdown-'",
"+",
"lxSelect",
".",
"uuid",
")",
")",
"{",
"lxSelect",
".",
"activeChoiceIndex",
"=",
"-",
"1",
";",
"}",
"switch",
"(",
"evt",
".",
"keyCode",
")",
"{",
"case",
"8",
":",
"_keyRemove",
"(",
")",
";",
"break",
";",
"case",
"13",
":",
"_keySelect",
"(",
")",
";",
"evt",
".",
"preventDefault",
"(",
")",
";",
"break",
";",
"case",
"37",
":",
"if",
"(",
"lxSelect",
".",
"activeChoiceIndex",
">",
"-",
"1",
")",
"{",
"_keyLeft",
"(",
")",
";",
"evt",
".",
"preventDefault",
"(",
")",
";",
"}",
"break",
";",
"case",
"38",
":",
"_keyUp",
"(",
")",
";",
"evt",
".",
"preventDefault",
"(",
")",
";",
"break",
";",
"case",
"39",
":",
"if",
"(",
"lxSelect",
".",
"activeChoiceIndex",
">",
"-",
"1",
")",
"{",
"_keyRight",
"(",
")",
";",
"evt",
".",
"preventDefault",
"(",
")",
";",
"}",
"break",
";",
"case",
"40",
":",
"_keyDown",
"(",
")",
";",
"evt",
".",
"preventDefault",
"(",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}"
] |
Handle a key press event
@param {Event} evt The key press event.
|
[
"Handle",
"a",
"key",
"press",
"event"
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L4994-L5041
|
9,742
|
lumapps/lumX
|
dist/lumx.js
|
toggleChoice
|
function toggleChoice(choice, evt) {
if (lxSelect.multiple && !lxSelect.autocomplete && angular.isDefined(evt)) {
evt.stopPropagation();
}
if (lxSelect.areChoicesOpened() && lxSelect.multiple) {
var dropdownElement = angular.element(angular.element(evt.target).closest('.dropdown-menu--is-open')[0]);
// If the dropdown element is scrollable, fix the content div height to keep the current scroll state.
if (dropdownElement.scrollTop() > 0) {
var dropdownContentElement = angular.element(dropdownElement.find('.dropdown-menu__content')[0]);
var dropdownFilterElement = angular.element(dropdownContentElement.find('.lx-select-choices__filter')[0]);
var newHeight = dropdownContentElement.height();
newHeight -= (dropdownFilterElement.length) ? dropdownFilterElement.outerHeight() : 0;
var dropdownListElement = angular.element(dropdownContentElement.find('ul > div')[0]);
dropdownListElement.css('height', newHeight + 'px');
// This function is called when the ng-change attached to the filter input is called.
lxSelect.resetDropdownSize = function() {
dropdownListElement.css('height', 'auto');
lxSelect.resetDropdownSize = undefined;
}
}
}
if (lxSelect.multiple && isSelected(choice)) {
lxSelect.unselect(choice);
} else {
lxSelect.select(choice);
}
if (lxSelect.autocomplete) {
lxSelect.activeChoiceIndex = -1;
lxSelect.filterModel = undefined;
}
if (lxSelect.autocomplete || (lxSelect.choicesViewMode === 'panes' && !lxSelect.multiple)) {
LxDropdownService.close('dropdown-' + lxSelect.uuid);
}
}
|
javascript
|
function toggleChoice(choice, evt) {
if (lxSelect.multiple && !lxSelect.autocomplete && angular.isDefined(evt)) {
evt.stopPropagation();
}
if (lxSelect.areChoicesOpened() && lxSelect.multiple) {
var dropdownElement = angular.element(angular.element(evt.target).closest('.dropdown-menu--is-open')[0]);
// If the dropdown element is scrollable, fix the content div height to keep the current scroll state.
if (dropdownElement.scrollTop() > 0) {
var dropdownContentElement = angular.element(dropdownElement.find('.dropdown-menu__content')[0]);
var dropdownFilterElement = angular.element(dropdownContentElement.find('.lx-select-choices__filter')[0]);
var newHeight = dropdownContentElement.height();
newHeight -= (dropdownFilterElement.length) ? dropdownFilterElement.outerHeight() : 0;
var dropdownListElement = angular.element(dropdownContentElement.find('ul > div')[0]);
dropdownListElement.css('height', newHeight + 'px');
// This function is called when the ng-change attached to the filter input is called.
lxSelect.resetDropdownSize = function() {
dropdownListElement.css('height', 'auto');
lxSelect.resetDropdownSize = undefined;
}
}
}
if (lxSelect.multiple && isSelected(choice)) {
lxSelect.unselect(choice);
} else {
lxSelect.select(choice);
}
if (lxSelect.autocomplete) {
lxSelect.activeChoiceIndex = -1;
lxSelect.filterModel = undefined;
}
if (lxSelect.autocomplete || (lxSelect.choicesViewMode === 'panes' && !lxSelect.multiple)) {
LxDropdownService.close('dropdown-' + lxSelect.uuid);
}
}
|
[
"function",
"toggleChoice",
"(",
"choice",
",",
"evt",
")",
"{",
"if",
"(",
"lxSelect",
".",
"multiple",
"&&",
"!",
"lxSelect",
".",
"autocomplete",
"&&",
"angular",
".",
"isDefined",
"(",
"evt",
")",
")",
"{",
"evt",
".",
"stopPropagation",
"(",
")",
";",
"}",
"if",
"(",
"lxSelect",
".",
"areChoicesOpened",
"(",
")",
"&&",
"lxSelect",
".",
"multiple",
")",
"{",
"var",
"dropdownElement",
"=",
"angular",
".",
"element",
"(",
"angular",
".",
"element",
"(",
"evt",
".",
"target",
")",
".",
"closest",
"(",
"'.dropdown-menu--is-open'",
")",
"[",
"0",
"]",
")",
";",
"// If the dropdown element is scrollable, fix the content div height to keep the current scroll state.",
"if",
"(",
"dropdownElement",
".",
"scrollTop",
"(",
")",
">",
"0",
")",
"{",
"var",
"dropdownContentElement",
"=",
"angular",
".",
"element",
"(",
"dropdownElement",
".",
"find",
"(",
"'.dropdown-menu__content'",
")",
"[",
"0",
"]",
")",
";",
"var",
"dropdownFilterElement",
"=",
"angular",
".",
"element",
"(",
"dropdownContentElement",
".",
"find",
"(",
"'.lx-select-choices__filter'",
")",
"[",
"0",
"]",
")",
";",
"var",
"newHeight",
"=",
"dropdownContentElement",
".",
"height",
"(",
")",
";",
"newHeight",
"-=",
"(",
"dropdownFilterElement",
".",
"length",
")",
"?",
"dropdownFilterElement",
".",
"outerHeight",
"(",
")",
":",
"0",
";",
"var",
"dropdownListElement",
"=",
"angular",
".",
"element",
"(",
"dropdownContentElement",
".",
"find",
"(",
"'ul > div'",
")",
"[",
"0",
"]",
")",
";",
"dropdownListElement",
".",
"css",
"(",
"'height'",
",",
"newHeight",
"+",
"'px'",
")",
";",
"// This function is called when the ng-change attached to the filter input is called.",
"lxSelect",
".",
"resetDropdownSize",
"=",
"function",
"(",
")",
"{",
"dropdownListElement",
".",
"css",
"(",
"'height'",
",",
"'auto'",
")",
";",
"lxSelect",
".",
"resetDropdownSize",
"=",
"undefined",
";",
"}",
"}",
"}",
"if",
"(",
"lxSelect",
".",
"multiple",
"&&",
"isSelected",
"(",
"choice",
")",
")",
"{",
"lxSelect",
".",
"unselect",
"(",
"choice",
")",
";",
"}",
"else",
"{",
"lxSelect",
".",
"select",
"(",
"choice",
")",
";",
"}",
"if",
"(",
"lxSelect",
".",
"autocomplete",
")",
"{",
"lxSelect",
".",
"activeChoiceIndex",
"=",
"-",
"1",
";",
"lxSelect",
".",
"filterModel",
"=",
"undefined",
";",
"}",
"if",
"(",
"lxSelect",
".",
"autocomplete",
"||",
"(",
"lxSelect",
".",
"choicesViewMode",
"===",
"'panes'",
"&&",
"!",
"lxSelect",
".",
"multiple",
")",
")",
"{",
"LxDropdownService",
".",
"close",
"(",
"'dropdown-'",
"+",
"lxSelect",
".",
"uuid",
")",
";",
"}",
"}"
] |
Toggle the given choice. If it was selected, unselect it. If it wasn't selected, select it.
@param {Object} choice The choice to toggle.
@param {Event} [evt] The event that triggered the function.
|
[
"Toggle",
"the",
"given",
"choice",
".",
"If",
"it",
"was",
"selected",
"unselect",
"it",
".",
"If",
"it",
"wasn",
"t",
"selected",
"select",
"it",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L5133-L5173
|
9,743
|
lumapps/lumX
|
dist/lumx.js
|
togglePane
|
function togglePane(evt, parentIndex, indexOrKey, selectLeaf) {
selectLeaf = (angular.isUndefined(selectLeaf)) ? true : selectLeaf;
var pane = lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex];
if (angular.isUndefined(pane)) {
return;
}
var key = indexOrKey;
if (angular.isObject(pane) && angular.isNumber(indexOrKey)) {
key = (Object.keys(pane) || [])[indexOrKey];
}
if (angular.isDefined(toggledPanes[parentIndex])) {
var previousKey = toggledPanes[parentIndex].key;
_closePane(parentIndex);
if (previousKey === key) {
return;
}
}
var isLeaf = lxSelect.isLeaf(pane[key]);
if (isLeaf) {
if (selectLeaf) {
lxSelect.toggleChoice(pane[key], evt);
}
return;
}
_openPane(parentIndex, key, false);
}
|
javascript
|
function togglePane(evt, parentIndex, indexOrKey, selectLeaf) {
selectLeaf = (angular.isUndefined(selectLeaf)) ? true : selectLeaf;
var pane = lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex];
if (angular.isUndefined(pane)) {
return;
}
var key = indexOrKey;
if (angular.isObject(pane) && angular.isNumber(indexOrKey)) {
key = (Object.keys(pane) || [])[indexOrKey];
}
if (angular.isDefined(toggledPanes[parentIndex])) {
var previousKey = toggledPanes[parentIndex].key;
_closePane(parentIndex);
if (previousKey === key) {
return;
}
}
var isLeaf = lxSelect.isLeaf(pane[key]);
if (isLeaf) {
if (selectLeaf) {
lxSelect.toggleChoice(pane[key], evt);
}
return;
}
_openPane(parentIndex, key, false);
}
|
[
"function",
"togglePane",
"(",
"evt",
",",
"parentIndex",
",",
"indexOrKey",
",",
"selectLeaf",
")",
"{",
"selectLeaf",
"=",
"(",
"angular",
".",
"isUndefined",
"(",
"selectLeaf",
")",
")",
"?",
"true",
":",
"selectLeaf",
";",
"var",
"pane",
"=",
"lxSelect",
".",
"choicesViewSize",
"===",
"'large'",
"?",
"lxSelect",
".",
"panes",
"[",
"parentIndex",
"]",
":",
"lxSelect",
".",
"openedPanes",
"[",
"parentIndex",
"]",
";",
"if",
"(",
"angular",
".",
"isUndefined",
"(",
"pane",
")",
")",
"{",
"return",
";",
"}",
"var",
"key",
"=",
"indexOrKey",
";",
"if",
"(",
"angular",
".",
"isObject",
"(",
"pane",
")",
"&&",
"angular",
".",
"isNumber",
"(",
"indexOrKey",
")",
")",
"{",
"key",
"=",
"(",
"Object",
".",
"keys",
"(",
"pane",
")",
"||",
"[",
"]",
")",
"[",
"indexOrKey",
"]",
";",
"}",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"toggledPanes",
"[",
"parentIndex",
"]",
")",
")",
"{",
"var",
"previousKey",
"=",
"toggledPanes",
"[",
"parentIndex",
"]",
".",
"key",
";",
"_closePane",
"(",
"parentIndex",
")",
";",
"if",
"(",
"previousKey",
"===",
"key",
")",
"{",
"return",
";",
"}",
"}",
"var",
"isLeaf",
"=",
"lxSelect",
".",
"isLeaf",
"(",
"pane",
"[",
"key",
"]",
")",
";",
"if",
"(",
"isLeaf",
")",
"{",
"if",
"(",
"selectLeaf",
")",
"{",
"lxSelect",
".",
"toggleChoice",
"(",
"pane",
"[",
"key",
"]",
",",
"evt",
")",
";",
"}",
"return",
";",
"}",
"_openPane",
"(",
"parentIndex",
",",
"key",
",",
"false",
")",
";",
"}"
] |
Toggle a pane.
@param {Event} evt The click event that led to toggle the pane.
@param {number} parentIndex The index of the containing pane.
@param {number|string} indexOrKey The index or the name of the pane to toggle.
@param {boolean} [selectLeaf=true] Indicates if we want to select the choice if the pane to toggle is
in fact a leaf.
|
[
"Toggle",
"a",
"pane",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L5184-L5217
|
9,744
|
lumapps/lumX
|
dist/lumx.js
|
updateFilter
|
function updateFilter() {
if (angular.isFunction(lxSelect.resetDropdownSize)) {
lxSelect.resetDropdownSize();
}
if (angular.isDefined(lxSelect.filter)) {
lxSelect.matchingPaths = lxSelect.filter({
newValue: lxSelect.filterModel
});
} else if (lxSelect.choicesViewMode === 'panes') {
lxSelect.matchingPaths = lxSelect.searchPath(lxSelect.filterModel);
_closePanes();
}
if (lxSelect.autocomplete) {
lxSelect.activeChoiceIndex = -1;
if (lxSelect.filterModel) {
LxDropdownService.open('dropdown-' + lxSelect.uuid, '#lx-select-selected-wrapper-' + lxSelect.uuid);
} else {
LxDropdownService.close('dropdown-' + lxSelect.uuid);
}
}
if (lxSelect.choicesViewMode === 'panes' && angular.isDefined(lxSelect.matchingPaths) && lxSelect.matchingPaths.length > 0) {
var longest = _getLongestMatchingPath();
if (!longest) {
return;
}
var longestPath = longest.split('.');
if (longestPath.length === 0) {
return;
}
angular.forEach(longestPath, function forEachPartOfTheLongestPath(part, index) {
_openPane(index, part, index === (longestPath.length - 1));
});
}
}
|
javascript
|
function updateFilter() {
if (angular.isFunction(lxSelect.resetDropdownSize)) {
lxSelect.resetDropdownSize();
}
if (angular.isDefined(lxSelect.filter)) {
lxSelect.matchingPaths = lxSelect.filter({
newValue: lxSelect.filterModel
});
} else if (lxSelect.choicesViewMode === 'panes') {
lxSelect.matchingPaths = lxSelect.searchPath(lxSelect.filterModel);
_closePanes();
}
if (lxSelect.autocomplete) {
lxSelect.activeChoiceIndex = -1;
if (lxSelect.filterModel) {
LxDropdownService.open('dropdown-' + lxSelect.uuid, '#lx-select-selected-wrapper-' + lxSelect.uuid);
} else {
LxDropdownService.close('dropdown-' + lxSelect.uuid);
}
}
if (lxSelect.choicesViewMode === 'panes' && angular.isDefined(lxSelect.matchingPaths) && lxSelect.matchingPaths.length > 0) {
var longest = _getLongestMatchingPath();
if (!longest) {
return;
}
var longestPath = longest.split('.');
if (longestPath.length === 0) {
return;
}
angular.forEach(longestPath, function forEachPartOfTheLongestPath(part, index) {
_openPane(index, part, index === (longestPath.length - 1));
});
}
}
|
[
"function",
"updateFilter",
"(",
")",
"{",
"if",
"(",
"angular",
".",
"isFunction",
"(",
"lxSelect",
".",
"resetDropdownSize",
")",
")",
"{",
"lxSelect",
".",
"resetDropdownSize",
"(",
")",
";",
"}",
"if",
"(",
"angular",
".",
"isDefined",
"(",
"lxSelect",
".",
"filter",
")",
")",
"{",
"lxSelect",
".",
"matchingPaths",
"=",
"lxSelect",
".",
"filter",
"(",
"{",
"newValue",
":",
"lxSelect",
".",
"filterModel",
"}",
")",
";",
"}",
"else",
"if",
"(",
"lxSelect",
".",
"choicesViewMode",
"===",
"'panes'",
")",
"{",
"lxSelect",
".",
"matchingPaths",
"=",
"lxSelect",
".",
"searchPath",
"(",
"lxSelect",
".",
"filterModel",
")",
";",
"_closePanes",
"(",
")",
";",
"}",
"if",
"(",
"lxSelect",
".",
"autocomplete",
")",
"{",
"lxSelect",
".",
"activeChoiceIndex",
"=",
"-",
"1",
";",
"if",
"(",
"lxSelect",
".",
"filterModel",
")",
"{",
"LxDropdownService",
".",
"open",
"(",
"'dropdown-'",
"+",
"lxSelect",
".",
"uuid",
",",
"'#lx-select-selected-wrapper-'",
"+",
"lxSelect",
".",
"uuid",
")",
";",
"}",
"else",
"{",
"LxDropdownService",
".",
"close",
"(",
"'dropdown-'",
"+",
"lxSelect",
".",
"uuid",
")",
";",
"}",
"}",
"if",
"(",
"lxSelect",
".",
"choicesViewMode",
"===",
"'panes'",
"&&",
"angular",
".",
"isDefined",
"(",
"lxSelect",
".",
"matchingPaths",
")",
"&&",
"lxSelect",
".",
"matchingPaths",
".",
"length",
">",
"0",
")",
"{",
"var",
"longest",
"=",
"_getLongestMatchingPath",
"(",
")",
";",
"if",
"(",
"!",
"longest",
")",
"{",
"return",
";",
"}",
"var",
"longestPath",
"=",
"longest",
".",
"split",
"(",
"'.'",
")",
";",
"if",
"(",
"longestPath",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"angular",
".",
"forEach",
"(",
"longestPath",
",",
"function",
"forEachPartOfTheLongestPath",
"(",
"part",
",",
"index",
")",
"{",
"_openPane",
"(",
"index",
",",
"part",
",",
"index",
"===",
"(",
"longestPath",
".",
"length",
"-",
"1",
")",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Update the filter.
Either filter the choices available or highlight the path to the matching elements.
|
[
"Update",
"the",
"filter",
".",
"Either",
"filter",
"the",
"choices",
"available",
"or",
"highlight",
"the",
"path",
"to",
"the",
"matching",
"elements",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L5276-L5315
|
9,745
|
lumapps/lumX
|
dist/lumx.js
|
searchPath
|
function searchPath(newValue) {
if (!newValue || newValue.length < 2) {
return undefined;
}
var regexp = new RegExp(LxUtils.escapeRegexp(newValue), 'ig');
return _searchPath(lxSelect.choices, regexp);
}
|
javascript
|
function searchPath(newValue) {
if (!newValue || newValue.length < 2) {
return undefined;
}
var regexp = new RegExp(LxUtils.escapeRegexp(newValue), 'ig');
return _searchPath(lxSelect.choices, regexp);
}
|
[
"function",
"searchPath",
"(",
"newValue",
")",
"{",
"if",
"(",
"!",
"newValue",
"||",
"newValue",
".",
"length",
"<",
"2",
")",
"{",
"return",
"undefined",
";",
"}",
"var",
"regexp",
"=",
"new",
"RegExp",
"(",
"LxUtils",
".",
"escapeRegexp",
"(",
"newValue",
")",
",",
"'ig'",
")",
";",
"return",
"_searchPath",
"(",
"lxSelect",
".",
"choices",
",",
"regexp",
")",
";",
"}"
] |
Search in the multipane select for the paths matching the search.
@param {string} newValue The filter string.
|
[
"Search",
"in",
"the",
"multipane",
"select",
"for",
"the",
"paths",
"matching",
"the",
"search",
"."
] |
50bfa6202261c5b311a59e8a2cc0d5eea6db1655
|
https://github.com/lumapps/lumX/blob/50bfa6202261c5b311a59e8a2cc0d5eea6db1655/dist/lumx.js#L5368-L5376
|
9,746
|
mozilla/aframe-xr
|
src/components/ar-mode-ui.js
|
createEnterARButton
|
function createEnterARButton (clickHandler) {
var arButton;
// Create elements.
arButton = document.createElement('button');
arButton.className = ENTER_AR_BTN_CLASS;
arButton.setAttribute('title', 'Enter AR mode.');
arButton.setAttribute('aframe-injected', '');
arButton.addEventListener('click', function (evt) {
document.getElementsByClassName(ENTER_AR_BTN_CLASS)[0].style.display = 'none';
document.getElementsByClassName(EXIT_AR_BTN_CLASS)[0].style.display = 'inline-block';
clickHandler();
});
return arButton;
}
|
javascript
|
function createEnterARButton (clickHandler) {
var arButton;
// Create elements.
arButton = document.createElement('button');
arButton.className = ENTER_AR_BTN_CLASS;
arButton.setAttribute('title', 'Enter AR mode.');
arButton.setAttribute('aframe-injected', '');
arButton.addEventListener('click', function (evt) {
document.getElementsByClassName(ENTER_AR_BTN_CLASS)[0].style.display = 'none';
document.getElementsByClassName(EXIT_AR_BTN_CLASS)[0].style.display = 'inline-block';
clickHandler();
});
return arButton;
}
|
[
"function",
"createEnterARButton",
"(",
"clickHandler",
")",
"{",
"var",
"arButton",
";",
"// Create elements.",
"arButton",
"=",
"document",
".",
"createElement",
"(",
"'button'",
")",
";",
"arButton",
".",
"className",
"=",
"ENTER_AR_BTN_CLASS",
";",
"arButton",
".",
"setAttribute",
"(",
"'title'",
",",
"'Enter AR mode.'",
")",
";",
"arButton",
".",
"setAttribute",
"(",
"'aframe-injected'",
",",
"''",
")",
";",
"arButton",
".",
"addEventListener",
"(",
"'click'",
",",
"function",
"(",
"evt",
")",
"{",
"document",
".",
"getElementsByClassName",
"(",
"ENTER_AR_BTN_CLASS",
")",
"[",
"0",
"]",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"document",
".",
"getElementsByClassName",
"(",
"EXIT_AR_BTN_CLASS",
")",
"[",
"0",
"]",
".",
"style",
".",
"display",
"=",
"'inline-block'",
";",
"clickHandler",
"(",
")",
";",
"}",
")",
";",
"return",
"arButton",
";",
"}"
] |
Creates a button that when clicked will enter into stereo-rendering mode for AR.
Structure: <div><button></div>
@param {function} enterARHandler
@returns {Element} Wrapper <div>.
|
[
"Creates",
"a",
"button",
"that",
"when",
"clicked",
"will",
"enter",
"into",
"stereo",
"-",
"rendering",
"mode",
"for",
"AR",
"."
] |
7ec17af3e65325b62fd2112e8158eb2e4310c0e0
|
https://github.com/mozilla/aframe-xr/blob/7ec17af3e65325b62fd2112e8158eb2e4310c0e0/src/components/ar-mode-ui.js#L135-L150
|
9,747
|
ryanhugh/searchneu
|
frontend/components/panels/LocationLinks.js
|
LocationLinks
|
function LocationLinks(props) {
const elements = props.locations.map((location, index, locations) => {
let buildingName;
if (location.match(/\d+\s*$/i)) {
buildingName = location.replace(/\d+\s*$/i, '');
} else {
buildingName = location;
}
let optionalComma = null;
if (index !== locations.length - 1) {
optionalComma = ', ';
}
if (location.toUpperCase() === 'TBA' || location.toUpperCase() === 'LOCATION TBA') {
if (locations.length > 1) {
return null;
}
return location;
}
if (location.toUpperCase() === 'BOSTON DEPT') {
return (
<span key='Boston DEPT'>
TBA (Boston Campus)
</span>
);
}
// The <a> tag needs to be on one line, or else react will insert spaces in the generated HTML.
// And we only want spaces between these span elements, and not after the location and the comma.
// eg YMCA, Hurting Hall and not YMCA , Hurting Hall
return (
<span key={ location }>
<a target='_blank' rel='noopener noreferrer' href={ `https://maps.google.com/?q=${macros.collegeName} ${buildingName}` }>
{location}
</a>
{optionalComma}
</span>
);
});
return (
<span>
{elements}
</span>
);
}
|
javascript
|
function LocationLinks(props) {
const elements = props.locations.map((location, index, locations) => {
let buildingName;
if (location.match(/\d+\s*$/i)) {
buildingName = location.replace(/\d+\s*$/i, '');
} else {
buildingName = location;
}
let optionalComma = null;
if (index !== locations.length - 1) {
optionalComma = ', ';
}
if (location.toUpperCase() === 'TBA' || location.toUpperCase() === 'LOCATION TBA') {
if (locations.length > 1) {
return null;
}
return location;
}
if (location.toUpperCase() === 'BOSTON DEPT') {
return (
<span key='Boston DEPT'>
TBA (Boston Campus)
</span>
);
}
// The <a> tag needs to be on one line, or else react will insert spaces in the generated HTML.
// And we only want spaces between these span elements, and not after the location and the comma.
// eg YMCA, Hurting Hall and not YMCA , Hurting Hall
return (
<span key={ location }>
<a target='_blank' rel='noopener noreferrer' href={ `https://maps.google.com/?q=${macros.collegeName} ${buildingName}` }>
{location}
</a>
{optionalComma}
</span>
);
});
return (
<span>
{elements}
</span>
);
}
|
[
"function",
"LocationLinks",
"(",
"props",
")",
"{",
"const",
"elements",
"=",
"props",
".",
"locations",
".",
"map",
"(",
"(",
"location",
",",
"index",
",",
"locations",
")",
"=>",
"{",
"let",
"buildingName",
";",
"if",
"(",
"location",
".",
"match",
"(",
"/",
"\\d+\\s*$",
"/",
"i",
")",
")",
"{",
"buildingName",
"=",
"location",
".",
"replace",
"(",
"/",
"\\d+\\s*$",
"/",
"i",
",",
"''",
")",
";",
"}",
"else",
"{",
"buildingName",
"=",
"location",
";",
"}",
"let",
"optionalComma",
"=",
"null",
";",
"if",
"(",
"index",
"!==",
"locations",
".",
"length",
"-",
"1",
")",
"{",
"optionalComma",
"=",
"', '",
";",
"}",
"if",
"(",
"location",
".",
"toUpperCase",
"(",
")",
"===",
"'TBA'",
"||",
"location",
".",
"toUpperCase",
"(",
")",
"===",
"'LOCATION TBA'",
")",
"{",
"if",
"(",
"locations",
".",
"length",
">",
"1",
")",
"{",
"return",
"null",
";",
"}",
"return",
"location",
";",
"}",
"if",
"(",
"location",
".",
"toUpperCase",
"(",
")",
"===",
"'BOSTON DEPT'",
")",
"{",
"return",
"(",
"<",
"span",
"key",
"=",
"'Boston DEPT'",
">",
"\n TBA (Boston Campus)\n ",
"<",
"/",
"span",
">",
")",
";",
"}",
"// The <a> tag needs to be on one line, or else react will insert spaces in the generated HTML.",
"// And we only want spaces between these span elements, and not after the location and the comma.",
"// eg YMCA, Hurting Hall and not YMCA , Hurting Hall",
"return",
"(",
"<",
"span",
"key",
"=",
"{",
"location",
"}",
">",
"\n ",
"<",
"a",
"target",
"=",
"'_blank'",
"rel",
"=",
"'noopener noreferrer'",
"href",
"=",
"{",
"`",
"${",
"macros",
".",
"collegeName",
"}",
"${",
"buildingName",
"}",
"`",
"}",
">",
"\n ",
"{",
"location",
"}",
"\n ",
"<",
"/",
"a",
">",
"\n ",
"{",
"optionalComma",
"}",
"\n ",
"<",
"/",
"span",
">",
")",
";",
"}",
")",
";",
"return",
"(",
"<",
"span",
">",
"\n ",
"{",
"elements",
"}",
"\n ",
"<",
"/",
"span",
">",
")",
";",
"}"
] |
Calculate the Google Maps links from a given section. This is used in both the mobile section panel and the desktop section panel.
|
[
"Calculate",
"the",
"Google",
"Maps",
"links",
"from",
"a",
"given",
"section",
".",
"This",
"is",
"used",
"in",
"both",
"the",
"mobile",
"section",
"panel",
"and",
"the",
"desktop",
"section",
"panel",
"."
] |
9ede451e45924a86611fbbc252087ee3cccb4c63
|
https://github.com/ryanhugh/searchneu/blob/9ede451e45924a86611fbbc252087ee3cccb4c63/frontend/components/panels/LocationLinks.js#L15-L63
|
9,748
|
crazychicken/t-scroll
|
theme/js/custom.js
|
setCookie
|
function setCookie(pr_name, exdays) {
var d = new Date();
d = (d.getTime() + (exdays*24*60*60*1000));
document.cookie = pr_name+"="+d + ";" + ";path=/";
}
|
javascript
|
function setCookie(pr_name, exdays) {
var d = new Date();
d = (d.getTime() + (exdays*24*60*60*1000));
document.cookie = pr_name+"="+d + ";" + ";path=/";
}
|
[
"function",
"setCookie",
"(",
"pr_name",
",",
"exdays",
")",
"{",
"var",
"d",
"=",
"new",
"Date",
"(",
")",
";",
"d",
"=",
"(",
"d",
".",
"getTime",
"(",
")",
"+",
"(",
"exdays",
"*",
"24",
"*",
"60",
"*",
"60",
"*",
"1000",
")",
")",
";",
"document",
".",
"cookie",
"=",
"pr_name",
"+",
"\"=\"",
"+",
"d",
"+",
"\";\"",
"+",
"\";path=/\"",
";",
"}"
] |
set the value, save data browser
|
[
"set",
"the",
"value",
"save",
"data",
"browser"
] |
a0e721f2e641fcae3f22b242e384d892fdd0d6e6
|
https://github.com/crazychicken/t-scroll/blob/a0e721f2e641fcae3f22b242e384d892fdd0d6e6/theme/js/custom.js#L47-L51
|
9,749
|
crazychicken/t-scroll
|
theme/js/custom.js
|
getCookie
|
function getCookie(pr_name) {
var name = pr_name + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
c = c.trim();
if (c.indexOf(pr_name+"=") === 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
|
javascript
|
function getCookie(pr_name) {
var name = pr_name + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
c = c.trim();
if (c.indexOf(pr_name+"=") === 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
|
[
"function",
"getCookie",
"(",
"pr_name",
")",
"{",
"var",
"name",
"=",
"pr_name",
"+",
"\"=\"",
";",
"var",
"ca",
"=",
"document",
".",
"cookie",
".",
"split",
"(",
"';'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ca",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"c",
"=",
"ca",
"[",
"i",
"]",
";",
"c",
"=",
"c",
".",
"trim",
"(",
")",
";",
"if",
"(",
"c",
".",
"indexOf",
"(",
"pr_name",
"+",
"\"=\"",
")",
"===",
"0",
")",
"{",
"return",
"c",
".",
"substring",
"(",
"name",
".",
"length",
",",
"c",
".",
"length",
")",
";",
"}",
"}",
"return",
"\"\"",
";",
"}"
] |
get the cookie and check value
|
[
"get",
"the",
"cookie",
"and",
"check",
"value"
] |
a0e721f2e641fcae3f22b242e384d892fdd0d6e6
|
https://github.com/crazychicken/t-scroll/blob/a0e721f2e641fcae3f22b242e384d892fdd0d6e6/theme/js/custom.js#L53-L65
|
9,750
|
Asana/node-asana
|
lib/auth/app.js
|
App
|
function App(options) {
this.clientId = options.clientId;
this.clientSecret = options.clientSecret || null;
this.redirectUri = options.redirectUri || null;
this.scope = options.scope || 'default';
this.asanaBaseUrl = options.asanaBaseUrl || 'https://app.asana.com/';
}
|
javascript
|
function App(options) {
this.clientId = options.clientId;
this.clientSecret = options.clientSecret || null;
this.redirectUri = options.redirectUri || null;
this.scope = options.scope || 'default';
this.asanaBaseUrl = options.asanaBaseUrl || 'https://app.asana.com/';
}
|
[
"function",
"App",
"(",
"options",
")",
"{",
"this",
".",
"clientId",
"=",
"options",
".",
"clientId",
";",
"this",
".",
"clientSecret",
"=",
"options",
".",
"clientSecret",
"||",
"null",
";",
"this",
".",
"redirectUri",
"=",
"options",
".",
"redirectUri",
"||",
"null",
";",
"this",
".",
"scope",
"=",
"options",
".",
"scope",
"||",
"'default'",
";",
"this",
".",
"asanaBaseUrl",
"=",
"options",
".",
"asanaBaseUrl",
"||",
"'https://app.asana.com/'",
";",
"}"
] |
An abstraction around an App used with Asana.
@options {Object} Options to construct the app
@option {String} clientId The ID of the app
@option {String} [clientSecret] The secret key, if available here
@option {String} [redirectUri] The default redirect URI
@option {String} [scope] Scope to use, supports `default` and `scim`
@option {String} [asanaBaseUrl] Base URL to use for Asana, for debugging
@constructor
|
[
"An",
"abstraction",
"around",
"an",
"App",
"used",
"with",
"Asana",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/auth/app.js#L41-L47
|
9,751
|
Asana/node-asana
|
lib/auth/chrome_extension_flow.js
|
ChromeExtensionFlow
|
function ChromeExtensionFlow(options) {
BaseBrowserFlow.call(this, options);
this._authorizationPromise = null;
this._receiverUrl = chrome.runtime.getURL(
options.receiverPath || 'asana_oauth_receiver.html');
}
|
javascript
|
function ChromeExtensionFlow(options) {
BaseBrowserFlow.call(this, options);
this._authorizationPromise = null;
this._receiverUrl = chrome.runtime.getURL(
options.receiverPath || 'asana_oauth_receiver.html');
}
|
[
"function",
"ChromeExtensionFlow",
"(",
"options",
")",
"{",
"BaseBrowserFlow",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"this",
".",
"_authorizationPromise",
"=",
"null",
";",
"this",
".",
"_receiverUrl",
"=",
"chrome",
".",
"runtime",
".",
"getURL",
"(",
"options",
".",
"receiverPath",
"||",
"'asana_oauth_receiver.html'",
")",
";",
"}"
] |
An Oauth flow that runs in a Chrome browser extension and requests user
authorization by opening a temporary tab to prompt the user.
@param {Object} options See `BaseBrowserFlow` for options, plus the below:
@options {String} [receiverPath] Full path and filename from the base
directory of the extension to the receiver page. This is an HTML file
that has been made web-accessible, and that calls the receiver method
`Asana.auth.ChromeExtensionFlow.runReceiver();`.
@constructor
|
[
"An",
"Oauth",
"flow",
"that",
"runs",
"in",
"a",
"Chrome",
"browser",
"extension",
"and",
"requests",
"user",
"authorization",
"by",
"opening",
"a",
"temporary",
"tab",
"to",
"prompt",
"the",
"user",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/auth/chrome_extension_flow.js#L19-L24
|
9,752
|
Asana/node-asana
|
lib/auth/native_flow.js
|
NativeFlow
|
function NativeFlow(options) {
this.app = options.app;
this.instructions = options.instructions || defaultInstructions;
this.prompt = options.prompt || defaultPrompt;
this.redirectUri = oauthUtil.NATIVE_REDIRECT_URI;
}
|
javascript
|
function NativeFlow(options) {
this.app = options.app;
this.instructions = options.instructions || defaultInstructions;
this.prompt = options.prompt || defaultPrompt;
this.redirectUri = oauthUtil.NATIVE_REDIRECT_URI;
}
|
[
"function",
"NativeFlow",
"(",
"options",
")",
"{",
"this",
".",
"app",
"=",
"options",
".",
"app",
";",
"this",
".",
"instructions",
"=",
"options",
".",
"instructions",
"||",
"defaultInstructions",
";",
"this",
".",
"prompt",
"=",
"options",
".",
"prompt",
"||",
"defaultPrompt",
";",
"this",
".",
"redirectUri",
"=",
"oauthUtil",
".",
"NATIVE_REDIRECT_URI",
";",
"}"
] |
An Oauth flow that can be run from the console or an app that does
not have the ability to open and manage a browser on its own.
@param {Object} options
@option {App} app App to authenticate for
@option {String function(String)} [instructions] Function returning the
instructions to output to the user. Passed the authorize url.
@option {String function()} [prompt] String to output immediately before
waiting for a line from stdin.
@constructor
|
[
"An",
"Oauth",
"flow",
"that",
"can",
"be",
"run",
"from",
"the",
"console",
"or",
"an",
"app",
"that",
"does",
"not",
"have",
"the",
"ability",
"to",
"open",
"and",
"manage",
"a",
"browser",
"on",
"its",
"own",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/auth/native_flow.js#L44-L49
|
9,753
|
Asana/node-asana
|
lib/util/collection.js
|
Collection
|
function Collection(response, dispatcher, dispatchOptions) {
if (!Collection.isCollectionResponse(response)) {
throw new Error(
'Cannot create Collection from response that does not have resources');
}
this.data = response.data;
this._response = response;
this._dispatcher = dispatcher;
this._dispatchOptions = dispatchOptions;
}
|
javascript
|
function Collection(response, dispatcher, dispatchOptions) {
if (!Collection.isCollectionResponse(response)) {
throw new Error(
'Cannot create Collection from response that does not have resources');
}
this.data = response.data;
this._response = response;
this._dispatcher = dispatcher;
this._dispatchOptions = dispatchOptions;
}
|
[
"function",
"Collection",
"(",
"response",
",",
"dispatcher",
",",
"dispatchOptions",
")",
"{",
"if",
"(",
"!",
"Collection",
".",
"isCollectionResponse",
"(",
"response",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Cannot create Collection from response that does not have resources'",
")",
";",
"}",
"this",
".",
"data",
"=",
"response",
".",
"data",
";",
"this",
".",
"_response",
"=",
"response",
";",
"this",
".",
"_dispatcher",
"=",
"dispatcher",
";",
"this",
".",
"_dispatchOptions",
"=",
"dispatchOptions",
";",
"}"
] |
Create a Collection object from a response containing a list of resources.
@param {Object} response Full payload from a response to a
collection request.
@param {Dispatcher} dispatcher
@param {Object} [dispatchOptions]
@returns {Object} Collection
|
[
"Create",
"a",
"Collection",
"object",
"from",
"a",
"response",
"containing",
"a",
"list",
"of",
"resources",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/util/collection.js#L21-L31
|
9,754
|
Asana/node-asana
|
lib/util/resource_stream.js
|
ResourceStream
|
function ResourceStream(collection) {
var me = this;
BufferedReadable.call(me, {
objectMode: true
});
// @type {Collection} The collection whose data was last pushed into the
// stream, such that if we have to go back for more, we should fetch
// its `nextPage`.
me._collection = collection;
// @type {boolean} True iff a request for more items is in flight.
me._fetching = false;
// Ensure the initial collection's data is in the stream.
me._pushCollection();
}
|
javascript
|
function ResourceStream(collection) {
var me = this;
BufferedReadable.call(me, {
objectMode: true
});
// @type {Collection} The collection whose data was last pushed into the
// stream, such that if we have to go back for more, we should fetch
// its `nextPage`.
me._collection = collection;
// @type {boolean} True iff a request for more items is in flight.
me._fetching = false;
// Ensure the initial collection's data is in the stream.
me._pushCollection();
}
|
[
"function",
"ResourceStream",
"(",
"collection",
")",
"{",
"var",
"me",
"=",
"this",
";",
"BufferedReadable",
".",
"call",
"(",
"me",
",",
"{",
"objectMode",
":",
"true",
"}",
")",
";",
"// @type {Collection} The collection whose data was last pushed into the",
"// stream, such that if we have to go back for more, we should fetch",
"// its `nextPage`.",
"me",
".",
"_collection",
"=",
"collection",
";",
"// @type {boolean} True iff a request for more items is in flight.",
"me",
".",
"_fetching",
"=",
"false",
";",
"// Ensure the initial collection's data is in the stream.",
"me",
".",
"_pushCollection",
"(",
")",
";",
"}"
] |
A ResourceStream is a Node stream implementation for objects that are
fetched from the API. Basically, any Collection of resources from the
API can be wrapped in this stream, and the stream will fetch new pages
of items as needed.
@param {Collection} collection Response from initial collection request.
@constructor
|
[
"A",
"ResourceStream",
"is",
"a",
"Node",
"stream",
"implementation",
"for",
"objects",
"that",
"are",
"fetched",
"from",
"the",
"API",
".",
"Basically",
"any",
"Collection",
"of",
"resources",
"from",
"the",
"API",
"can",
"be",
"wrapped",
"in",
"this",
"stream",
"and",
"the",
"stream",
"will",
"fetch",
"new",
"pages",
"of",
"items",
"as",
"needed",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/util/resource_stream.js#L14-L30
|
9,755
|
Asana/node-asana
|
lib/auth/oauth_authenticator.js
|
OauthAuthenticator
|
function OauthAuthenticator(options) {
Authenticator.call(this);
if (typeof(options.credentials) === 'string') {
this.credentials = {
'access_token': options.credentials
};
} else {
this.credentials = options.credentials || null;
}
this.flow = options.flow || null;
this.app = options.app;
}
|
javascript
|
function OauthAuthenticator(options) {
Authenticator.call(this);
if (typeof(options.credentials) === 'string') {
this.credentials = {
'access_token': options.credentials
};
} else {
this.credentials = options.credentials || null;
}
this.flow = options.flow || null;
this.app = options.app;
}
|
[
"function",
"OauthAuthenticator",
"(",
"options",
")",
"{",
"Authenticator",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"typeof",
"(",
"options",
".",
"credentials",
")",
"===",
"'string'",
")",
"{",
"this",
".",
"credentials",
"=",
"{",
"'access_token'",
":",
"options",
".",
"credentials",
"}",
";",
"}",
"else",
"{",
"this",
".",
"credentials",
"=",
"options",
".",
"credentials",
"||",
"null",
";",
"}",
"this",
".",
"flow",
"=",
"options",
".",
"flow",
"||",
"null",
";",
"this",
".",
"app",
"=",
"options",
".",
"app",
";",
"}"
] |
Creates an authenticator that uses Oauth for authentication.
@param {Object} options Configure the authenticator; must specify one
of `flow` or `credentials`.
@option {App} app The app being authenticated for.
@option {OauthFlow} [flow] The flow to use to get credentials
when needed.
@option {String|Object} [credentials] Initial credentials to use. This can
be either the object returned from an access token request (which
contains the token and some other metadata) or just the `access_token`
field.
@constructor
|
[
"Creates",
"an",
"authenticator",
"that",
"uses",
"Oauth",
"for",
"authentication",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/auth/oauth_authenticator.js#L19-L30
|
9,756
|
Asana/node-asana
|
lib/client.js
|
Client
|
function Client(dispatcher, options) {
options = options || {};
/**
* The internal dispatcher. This is mostly used by the resources but provided
* for custom requests to the API or API features that have not yet been added
* to the client.
* @type {Dispatcher}
*/
this.dispatcher = dispatcher;
/**
* An instance of the Attachments resource.
* @type {Attachments}
*/
this.attachments = new resources.Attachments(this.dispatcher);
/**
* An instance of the CustomFieldSettings resource.
* @type {CustomFieldSettings}
*/
this.customFieldSettings = new resources.CustomFieldSettings(this.dispatcher);
/**
* An instance of the CustomFields resource.
* @type {CustomFields}
*/
this.customFields = new resources.CustomFields(this.dispatcher);
/**
* An instance of the Events resource.
* @type {Events}
*/
this.events = new resources.Events(this.dispatcher);
/**
* An instance of the OrganizationExports resource.
* @type {Events}
*/
this.organizationExports = new resources.OrganizationExports(this.dispatcher);
/**
* An instance of the Projects resource.
* @type {Projects}
*/
this.projects = new resources.Projects(this.dispatcher);
/**
* An instance of the ProjectMemberships resource.
* @type {ProjectMemberships}
*/
this.projectMemberships = new resources.ProjectMemberships(this.dispatcher);
/**
* An instance of the ProjectStatuses resource.
* @type {ProjectStatuses}
*/
this.projectStatuses = new resources.ProjectStatuses(this.dispatcher);
/**
* An instance of the Sections resource.
* @type {Sections}
*/
this.sections = new resources.Sections(this.dispatcher);
/**
* An instance of the Stories resource.
* @type {Stories}
*/
this.stories = new resources.Stories(this.dispatcher);
/**
* An instance of the Tags resource.
* @type {Tags}
*/
this.tags = new resources.Tags(this.dispatcher);
/**
* An instance of the Tasks resource.
* @type {Tasks}
*/
this.tasks = new resources.Tasks(this.dispatcher);
/**
* An instance of the Teams resource.
* @type {Teams}
*/
this.teams = new resources.Teams(this.dispatcher);
/**
* An instance of the Users resource.
* @type {Users}
*/
this.users = new resources.Users(this.dispatcher);
/**
* An instance of the Workspaces resource.
* @type {Workspaces}
*/
this.workspaces = new resources.Workspaces(this.dispatcher);
/**
* An instance of the Webhooks resource.
* @type {Webhooks}
*/
this.webhooks = new resources.Webhooks(this.dispatcher);
// Store off Oauth info.
this.app = new App(options);
}
|
javascript
|
function Client(dispatcher, options) {
options = options || {};
/**
* The internal dispatcher. This is mostly used by the resources but provided
* for custom requests to the API or API features that have not yet been added
* to the client.
* @type {Dispatcher}
*/
this.dispatcher = dispatcher;
/**
* An instance of the Attachments resource.
* @type {Attachments}
*/
this.attachments = new resources.Attachments(this.dispatcher);
/**
* An instance of the CustomFieldSettings resource.
* @type {CustomFieldSettings}
*/
this.customFieldSettings = new resources.CustomFieldSettings(this.dispatcher);
/**
* An instance of the CustomFields resource.
* @type {CustomFields}
*/
this.customFields = new resources.CustomFields(this.dispatcher);
/**
* An instance of the Events resource.
* @type {Events}
*/
this.events = new resources.Events(this.dispatcher);
/**
* An instance of the OrganizationExports resource.
* @type {Events}
*/
this.organizationExports = new resources.OrganizationExports(this.dispatcher);
/**
* An instance of the Projects resource.
* @type {Projects}
*/
this.projects = new resources.Projects(this.dispatcher);
/**
* An instance of the ProjectMemberships resource.
* @type {ProjectMemberships}
*/
this.projectMemberships = new resources.ProjectMemberships(this.dispatcher);
/**
* An instance of the ProjectStatuses resource.
* @type {ProjectStatuses}
*/
this.projectStatuses = new resources.ProjectStatuses(this.dispatcher);
/**
* An instance of the Sections resource.
* @type {Sections}
*/
this.sections = new resources.Sections(this.dispatcher);
/**
* An instance of the Stories resource.
* @type {Stories}
*/
this.stories = new resources.Stories(this.dispatcher);
/**
* An instance of the Tags resource.
* @type {Tags}
*/
this.tags = new resources.Tags(this.dispatcher);
/**
* An instance of the Tasks resource.
* @type {Tasks}
*/
this.tasks = new resources.Tasks(this.dispatcher);
/**
* An instance of the Teams resource.
* @type {Teams}
*/
this.teams = new resources.Teams(this.dispatcher);
/**
* An instance of the Users resource.
* @type {Users}
*/
this.users = new resources.Users(this.dispatcher);
/**
* An instance of the Workspaces resource.
* @type {Workspaces}
*/
this.workspaces = new resources.Workspaces(this.dispatcher);
/**
* An instance of the Webhooks resource.
* @type {Webhooks}
*/
this.webhooks = new resources.Webhooks(this.dispatcher);
// Store off Oauth info.
this.app = new App(options);
}
|
[
"function",
"Client",
"(",
"dispatcher",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"/**\n * The internal dispatcher. This is mostly used by the resources but provided\n * for custom requests to the API or API features that have not yet been added\n * to the client.\n * @type {Dispatcher}\n */",
"this",
".",
"dispatcher",
"=",
"dispatcher",
";",
"/**\n * An instance of the Attachments resource.\n * @type {Attachments}\n */",
"this",
".",
"attachments",
"=",
"new",
"resources",
".",
"Attachments",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the CustomFieldSettings resource.\n * @type {CustomFieldSettings}\n */",
"this",
".",
"customFieldSettings",
"=",
"new",
"resources",
".",
"CustomFieldSettings",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the CustomFields resource.\n * @type {CustomFields}\n */",
"this",
".",
"customFields",
"=",
"new",
"resources",
".",
"CustomFields",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Events resource.\n * @type {Events}\n */",
"this",
".",
"events",
"=",
"new",
"resources",
".",
"Events",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the OrganizationExports resource.\n * @type {Events}\n */",
"this",
".",
"organizationExports",
"=",
"new",
"resources",
".",
"OrganizationExports",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Projects resource.\n * @type {Projects}\n */",
"this",
".",
"projects",
"=",
"new",
"resources",
".",
"Projects",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the ProjectMemberships resource.\n * @type {ProjectMemberships}\n */",
"this",
".",
"projectMemberships",
"=",
"new",
"resources",
".",
"ProjectMemberships",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the ProjectStatuses resource.\n * @type {ProjectStatuses}\n */",
"this",
".",
"projectStatuses",
"=",
"new",
"resources",
".",
"ProjectStatuses",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Sections resource.\n * @type {Sections}\n */",
"this",
".",
"sections",
"=",
"new",
"resources",
".",
"Sections",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Stories resource.\n * @type {Stories}\n */",
"this",
".",
"stories",
"=",
"new",
"resources",
".",
"Stories",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Tags resource.\n * @type {Tags}\n */",
"this",
".",
"tags",
"=",
"new",
"resources",
".",
"Tags",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Tasks resource.\n * @type {Tasks}\n */",
"this",
".",
"tasks",
"=",
"new",
"resources",
".",
"Tasks",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Teams resource.\n * @type {Teams}\n */",
"this",
".",
"teams",
"=",
"new",
"resources",
".",
"Teams",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Users resource.\n * @type {Users}\n */",
"this",
".",
"users",
"=",
"new",
"resources",
".",
"Users",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Workspaces resource.\n * @type {Workspaces}\n */",
"this",
".",
"workspaces",
"=",
"new",
"resources",
".",
"Workspaces",
"(",
"this",
".",
"dispatcher",
")",
";",
"/**\n * An instance of the Webhooks resource.\n * @type {Webhooks}\n */",
"this",
".",
"webhooks",
"=",
"new",
"resources",
".",
"Webhooks",
"(",
"this",
".",
"dispatcher",
")",
";",
"// Store off Oauth info.",
"this",
".",
"app",
"=",
"new",
"App",
"(",
"options",
")",
";",
"}"
] |
Constructs a Client with instances of all the resources using the dispatcher.
It also keeps a reference to the dispatcher so that way the end user can have
access to it.
@class
@classdesc A wrapper for the Asana API which is authenticated for one user
@param {Dispatcher} dispatcher The request dispatcher to use
@param {Object} options Options to configure the client
@param {String} [clientId] ID of the client, required for Oauth
@param {String} [clientSecret] Secret key, for some Oauth flows
@param {String} [redirectUri] Default redirect URI for this client
@param {String} [asanaBaseUrl] Base URL for Asana, for debugging
|
[
"Constructs",
"a",
"Client",
"with",
"instances",
"of",
"all",
"the",
"resources",
"using",
"the",
"dispatcher",
".",
"It",
"also",
"keeps",
"a",
"reference",
"to",
"the",
"dispatcher",
"so",
"that",
"way",
"the",
"end",
"user",
"can",
"have",
"access",
"to",
"it",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/client.js#L21-L113
|
9,757
|
Asana/node-asana
|
gulpfile.js
|
browserTask
|
function browserTask(minify) {
return function() {
var task = browserify(
{
entries: [index],
standalone: 'Asana'
})
.bundle()
.pipe(vinylSourceStream('asana' + (minify ? '-min' : '') + '.js'));
if (minify) {
task = task
.pipe(vinylBuffer())
.pipe(uglify());
}
return task.pipe(gulp.dest('dist'));
};
}
|
javascript
|
function browserTask(minify) {
return function() {
var task = browserify(
{
entries: [index],
standalone: 'Asana'
})
.bundle()
.pipe(vinylSourceStream('asana' + (minify ? '-min' : '') + '.js'));
if (minify) {
task = task
.pipe(vinylBuffer())
.pipe(uglify());
}
return task.pipe(gulp.dest('dist'));
};
}
|
[
"function",
"browserTask",
"(",
"minify",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"task",
"=",
"browserify",
"(",
"{",
"entries",
":",
"[",
"index",
"]",
",",
"standalone",
":",
"'Asana'",
"}",
")",
".",
"bundle",
"(",
")",
".",
"pipe",
"(",
"vinylSourceStream",
"(",
"'asana'",
"+",
"(",
"minify",
"?",
"'-min'",
":",
"''",
")",
"+",
"'.js'",
")",
")",
";",
"if",
"(",
"minify",
")",
"{",
"task",
"=",
"task",
".",
"pipe",
"(",
"vinylBuffer",
"(",
")",
")",
".",
"pipe",
"(",
"uglify",
"(",
")",
")",
";",
"}",
"return",
"task",
".",
"pipe",
"(",
"gulp",
".",
"dest",
"(",
"'dist'",
")",
")",
";",
"}",
";",
"}"
] |
Bundles the code, full version to `asana.js` and minified to `asana-min.js`
|
[
"Bundles",
"the",
"code",
"full",
"version",
"to",
"asana",
".",
"js",
"and",
"minified",
"to",
"asana",
"-",
"min",
".",
"js"
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/gulpfile.js#L31-L47
|
9,758
|
Asana/node-asana
|
lib/auth/auto_detect.js
|
autoDetect
|
function autoDetect(env) {
env = env || defaultEnvironment();
if (typeof(env.chrome) !== 'undefined' &&
env.chrome.runtime && env.chrome.runtime.id) {
if (env.chrome.tabs && env.chrome.tabs.create) {
return ChromeExtensionFlow;
} else {
// Chrome packaged app, not supported yet.
return null;
}
}
if (typeof(env.window) !== 'undefined' && env.window.navigator) {
// Browser
return RedirectFlow;
}
if (typeof(env.process) !== 'undefined' && env.process.env) {
// NodeJS script
return NativeFlow;
}
return null;
}
|
javascript
|
function autoDetect(env) {
env = env || defaultEnvironment();
if (typeof(env.chrome) !== 'undefined' &&
env.chrome.runtime && env.chrome.runtime.id) {
if (env.chrome.tabs && env.chrome.tabs.create) {
return ChromeExtensionFlow;
} else {
// Chrome packaged app, not supported yet.
return null;
}
}
if (typeof(env.window) !== 'undefined' && env.window.navigator) {
// Browser
return RedirectFlow;
}
if (typeof(env.process) !== 'undefined' && env.process.env) {
// NodeJS script
return NativeFlow;
}
return null;
}
|
[
"function",
"autoDetect",
"(",
"env",
")",
"{",
"env",
"=",
"env",
"||",
"defaultEnvironment",
"(",
")",
";",
"if",
"(",
"typeof",
"(",
"env",
".",
"chrome",
")",
"!==",
"'undefined'",
"&&",
"env",
".",
"chrome",
".",
"runtime",
"&&",
"env",
".",
"chrome",
".",
"runtime",
".",
"id",
")",
"{",
"if",
"(",
"env",
".",
"chrome",
".",
"tabs",
"&&",
"env",
".",
"chrome",
".",
"tabs",
".",
"create",
")",
"{",
"return",
"ChromeExtensionFlow",
";",
"}",
"else",
"{",
"// Chrome packaged app, not supported yet.",
"return",
"null",
";",
"}",
"}",
"if",
"(",
"typeof",
"(",
"env",
".",
"window",
")",
"!==",
"'undefined'",
"&&",
"env",
".",
"window",
".",
"navigator",
")",
"{",
"// Browser",
"return",
"RedirectFlow",
";",
"}",
"if",
"(",
"typeof",
"(",
"env",
".",
"process",
")",
"!==",
"'undefined'",
"&&",
"env",
".",
"process",
".",
"env",
")",
"{",
"// NodeJS script",
"return",
"NativeFlow",
";",
"}",
"return",
"null",
";",
"}"
] |
Auto-detects the type of Oauth flow to use that's appropriate to the
environment.
@returns {Function|null} The type of Oauth flow to use, or null if no
appropriate type could be determined.
|
[
"Auto",
"-",
"detects",
"the",
"type",
"of",
"Oauth",
"flow",
"to",
"use",
"that",
"s",
"appropriate",
"to",
"the",
"environment",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/auth/auto_detect.js#L14-L34
|
9,759
|
Asana/node-asana
|
examples/oauth/webserver/oauth_webserver.js
|
createClient
|
function createClient() {
return Asana.Client.create({
clientId: clientId,
clientSecret: clientSecret,
redirectUri: 'http://localhost:' + port + '/oauth_callback'
});
}
|
javascript
|
function createClient() {
return Asana.Client.create({
clientId: clientId,
clientSecret: clientSecret,
redirectUri: 'http://localhost:' + port + '/oauth_callback'
});
}
|
[
"function",
"createClient",
"(",
")",
"{",
"return",
"Asana",
".",
"Client",
".",
"create",
"(",
"{",
"clientId",
":",
"clientId",
",",
"clientSecret",
":",
"clientSecret",
",",
"redirectUri",
":",
"'http://localhost:'",
"+",
"port",
"+",
"'/oauth_callback'",
"}",
")",
";",
"}"
] |
Create an Asana client. Do this per request since it keeps state that shouldn't be shared across requests.
|
[
"Create",
"an",
"Asana",
"client",
".",
"Do",
"this",
"per",
"request",
"since",
"it",
"keeps",
"state",
"that",
"shouldn",
"t",
"be",
"shared",
"across",
"requests",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/examples/oauth/webserver/oauth_webserver.js#L28-L34
|
9,760
|
Asana/node-asana
|
lib/auth/oauth_util.js
|
parseOauthResultFromUrl
|
function parseOauthResultFromUrl(currentUrl) {
var oauthUrl = url.parse(currentUrl);
return oauthUrl.hash ? querystring.parse(oauthUrl.hash.substr(1)) : null;
}
|
javascript
|
function parseOauthResultFromUrl(currentUrl) {
var oauthUrl = url.parse(currentUrl);
return oauthUrl.hash ? querystring.parse(oauthUrl.hash.substr(1)) : null;
}
|
[
"function",
"parseOauthResultFromUrl",
"(",
"currentUrl",
")",
"{",
"var",
"oauthUrl",
"=",
"url",
".",
"parse",
"(",
"currentUrl",
")",
";",
"return",
"oauthUrl",
".",
"hash",
"?",
"querystring",
".",
"parse",
"(",
"oauthUrl",
".",
"hash",
".",
"substr",
"(",
"1",
")",
")",
":",
"null",
";",
"}"
] |
Parses a URL and returns any Oauth result that may be encoded therein.
@param currentUrl {String} Complete URL of a page.
@returns {Object|null} Oauth fields found in the hash of the URL, or null
if the URL does not contain a valid hash.
|
[
"Parses",
"a",
"URL",
"and",
"returns",
"any",
"Oauth",
"result",
"that",
"may",
"be",
"encoded",
"therein",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/auth/oauth_util.js#L24-L27
|
9,761
|
Asana/node-asana
|
lib/auth/oauth_util.js
|
removeOauthResultFromCurrentUrl
|
function removeOauthResultFromCurrentUrl() {
if (window.history && window.history.replaceState) {
var url = window.location.href;
var hashIndex = url.indexOf('#');
window.history.replaceState({},
document.title, url.substring(0, hashIndex));
} else {
window.location.hash = '';
}
}
|
javascript
|
function removeOauthResultFromCurrentUrl() {
if (window.history && window.history.replaceState) {
var url = window.location.href;
var hashIndex = url.indexOf('#');
window.history.replaceState({},
document.title, url.substring(0, hashIndex));
} else {
window.location.hash = '';
}
}
|
[
"function",
"removeOauthResultFromCurrentUrl",
"(",
")",
"{",
"if",
"(",
"window",
".",
"history",
"&&",
"window",
".",
"history",
".",
"replaceState",
")",
"{",
"var",
"url",
"=",
"window",
".",
"location",
".",
"href",
";",
"var",
"hashIndex",
"=",
"url",
".",
"indexOf",
"(",
"'#'",
")",
";",
"window",
".",
"history",
".",
"replaceState",
"(",
"{",
"}",
",",
"document",
".",
"title",
",",
"url",
".",
"substring",
"(",
"0",
",",
"hashIndex",
")",
")",
";",
"}",
"else",
"{",
"window",
".",
"location",
".",
"hash",
"=",
"''",
";",
"}",
"}"
] |
Clean Oauth results out of the current browser URL, for security and
cleanliness purposes.
@returns {Object|null} Oauth fields found in the hash of the URL, or null
if the URL does not contain a valid hash.
|
[
"Clean",
"Oauth",
"results",
"out",
"of",
"the",
"current",
"browser",
"URL",
"for",
"security",
"and",
"cleanliness",
"purposes",
"."
] |
afcc41fedba997654f0e52a1652da128d5961486
|
https://github.com/Asana/node-asana/blob/afcc41fedba997654f0e52a1652da128d5961486/lib/auth/oauth_util.js#L35-L44
|
9,762
|
protobufjs/bytebuffer.js
|
dist/bytebuffer-node.js
|
stringSource
|
function stringSource(s) {
var i=0; return function() {
return i < s.length ? s.charCodeAt(i++) : null;
};
}
|
javascript
|
function stringSource(s) {
var i=0; return function() {
return i < s.length ? s.charCodeAt(i++) : null;
};
}
|
[
"function",
"stringSource",
"(",
"s",
")",
"{",
"var",
"i",
"=",
"0",
";",
"return",
"function",
"(",
")",
"{",
"return",
"i",
"<",
"s",
".",
"length",
"?",
"s",
".",
"charCodeAt",
"(",
"i",
"++",
")",
":",
"null",
";",
"}",
";",
"}"
] |
Creates a source function for a string.
@param {string} s String to read from
@returns {function():number|null} Source function returning the next char code respectively `null` if there are
no more characters left.
@throws {TypeError} If the argument is invalid
@inner
|
[
"Creates",
"a",
"source",
"function",
"for",
"a",
"string",
"."
] |
4144951c7f583d9394d18487ff0b2b7474b1e775
|
https://github.com/protobufjs/bytebuffer.js/blob/4144951c7f583d9394d18487ff0b2b7474b1e775/dist/bytebuffer-node.js#L205-L209
|
9,763
|
protobufjs/bytebuffer.js
|
dist/bytebuffer-node.js
|
stringDestination
|
function stringDestination() {
var cs = [], ps = []; return function() {
if (arguments.length === 0)
return ps.join('')+stringFromCharCode.apply(String, cs);
if (cs.length + arguments.length > 1024)
ps.push(stringFromCharCode.apply(String, cs)),
cs.length = 0;
Array.prototype.push.apply(cs, arguments);
};
}
|
javascript
|
function stringDestination() {
var cs = [], ps = []; return function() {
if (arguments.length === 0)
return ps.join('')+stringFromCharCode.apply(String, cs);
if (cs.length + arguments.length > 1024)
ps.push(stringFromCharCode.apply(String, cs)),
cs.length = 0;
Array.prototype.push.apply(cs, arguments);
};
}
|
[
"function",
"stringDestination",
"(",
")",
"{",
"var",
"cs",
"=",
"[",
"]",
",",
"ps",
"=",
"[",
"]",
";",
"return",
"function",
"(",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"return",
"ps",
".",
"join",
"(",
"''",
")",
"+",
"stringFromCharCode",
".",
"apply",
"(",
"String",
",",
"cs",
")",
";",
"if",
"(",
"cs",
".",
"length",
"+",
"arguments",
".",
"length",
">",
"1024",
")",
"ps",
".",
"push",
"(",
"stringFromCharCode",
".",
"apply",
"(",
"String",
",",
"cs",
")",
")",
",",
"cs",
".",
"length",
"=",
"0",
";",
"Array",
".",
"prototype",
".",
"push",
".",
"apply",
"(",
"cs",
",",
"arguments",
")",
";",
"}",
";",
"}"
] |
Creates a destination function for a string.
@returns {function(number=):undefined|string} Destination function successively called with the next char code.
Returns the final string when called without arguments.
@inner
|
[
"Creates",
"a",
"destination",
"function",
"for",
"a",
"string",
"."
] |
4144951c7f583d9394d18487ff0b2b7474b1e775
|
https://github.com/protobufjs/bytebuffer.js/blob/4144951c7f583d9394d18487ff0b2b7474b1e775/dist/bytebuffer-node.js#L217-L226
|
9,764
|
protobufjs/bytebuffer.js
|
src/helpers.js
|
assertLong
|
function assertLong(value, unsigned) {
if (typeof value === 'number') {
return Long.fromNumber(value, unsigned);
} else if (typeof value === 'string') {
return Long.fromString(value, unsigned);
} else if (value && value instanceof Long) {
if (typeof unsigned !== 'undefined') {
if (unsigned && !value.unsigned) return value.toUnsigned();
if (!unsigned && value.unsigned) return value.toSigned();
}
return value;
} else
throw TypeError("Illegal value: "+value+" (not an integer or Long)");
}
|
javascript
|
function assertLong(value, unsigned) {
if (typeof value === 'number') {
return Long.fromNumber(value, unsigned);
} else if (typeof value === 'string') {
return Long.fromString(value, unsigned);
} else if (value && value instanceof Long) {
if (typeof unsigned !== 'undefined') {
if (unsigned && !value.unsigned) return value.toUnsigned();
if (!unsigned && value.unsigned) return value.toSigned();
}
return value;
} else
throw TypeError("Illegal value: "+value+" (not an integer or Long)");
}
|
[
"function",
"assertLong",
"(",
"value",
",",
"unsigned",
")",
"{",
"if",
"(",
"typeof",
"value",
"===",
"'number'",
")",
"{",
"return",
"Long",
".",
"fromNumber",
"(",
"value",
",",
"unsigned",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"value",
"===",
"'string'",
")",
"{",
"return",
"Long",
".",
"fromString",
"(",
"value",
",",
"unsigned",
")",
";",
"}",
"else",
"if",
"(",
"value",
"&&",
"value",
"instanceof",
"Long",
")",
"{",
"if",
"(",
"typeof",
"unsigned",
"!==",
"'undefined'",
")",
"{",
"if",
"(",
"unsigned",
"&&",
"!",
"value",
".",
"unsigned",
")",
"return",
"value",
".",
"toUnsigned",
"(",
")",
";",
"if",
"(",
"!",
"unsigned",
"&&",
"value",
".",
"unsigned",
")",
"return",
"value",
".",
"toSigned",
"(",
")",
";",
"}",
"return",
"value",
";",
"}",
"else",
"throw",
"TypeError",
"(",
"\"Illegal value: \"",
"+",
"value",
"+",
"\" (not an integer or Long)\"",
")",
";",
"}"
] |
Asserts that a value is an integer or Long.
@param {number|!Long} value Value to assert
@param {boolean=} unsigned Whether explicitly unsigned
@returns {number|!Long} Type-safe value
@throws {TypeError} If `value` is not an integer or Long
@inner
|
[
"Asserts",
"that",
"a",
"value",
"is",
"an",
"integer",
"or",
"Long",
"."
] |
4144951c7f583d9394d18487ff0b2b7474b1e775
|
https://github.com/protobufjs/bytebuffer.js/blob/4144951c7f583d9394d18487ff0b2b7474b1e775/src/helpers.js#L41-L54
|
9,765
|
protobufjs/bytebuffer.js
|
src/helpers.js
|
assertOffset
|
function assertOffset(offset, min, cap, size) {
if (typeof offset !== 'number' || offset % 1 !== 0)
throw TypeError("Illegal offset: "+offset+" (not an integer)");
offset = offset | 0;
if (offset < min || offset > cap-size)
throw RangeError("Illegal offset: "+min+" <= "+value+" <= "+cap+"-"+size);
return offset;
}
|
javascript
|
function assertOffset(offset, min, cap, size) {
if (typeof offset !== 'number' || offset % 1 !== 0)
throw TypeError("Illegal offset: "+offset+" (not an integer)");
offset = offset | 0;
if (offset < min || offset > cap-size)
throw RangeError("Illegal offset: "+min+" <= "+value+" <= "+cap+"-"+size);
return offset;
}
|
[
"function",
"assertOffset",
"(",
"offset",
",",
"min",
",",
"cap",
",",
"size",
")",
"{",
"if",
"(",
"typeof",
"offset",
"!==",
"'number'",
"||",
"offset",
"%",
"1",
"!==",
"0",
")",
"throw",
"TypeError",
"(",
"\"Illegal offset: \"",
"+",
"offset",
"+",
"\" (not an integer)\"",
")",
";",
"offset",
"=",
"offset",
"|",
"0",
";",
"if",
"(",
"offset",
"<",
"min",
"||",
"offset",
">",
"cap",
"-",
"size",
")",
"throw",
"RangeError",
"(",
"\"Illegal offset: \"",
"+",
"min",
"+",
"\" <= \"",
"+",
"value",
"+",
"\" <= \"",
"+",
"cap",
"+",
"\"-\"",
"+",
"size",
")",
";",
"return",
"offset",
";",
"}"
] |
Asserts that `min <= offset <= cap-size` and returns the type-safe offset.
@param {number} offset Offset to assert
@param {number} min Minimum offset
@param {number} cap Cap offset
@param {number} size Required size in bytes
@returns {number} Type-safe offset
@throws {TypeError} If `offset` is not an integer
@throws {RangeError} If `offset < min || offset > cap-size`
@inner
|
[
"Asserts",
"that",
"min",
"<",
"=",
"offset",
"<",
"=",
"cap",
"-",
"size",
"and",
"returns",
"the",
"type",
"-",
"safe",
"offset",
"."
] |
4144951c7f583d9394d18487ff0b2b7474b1e775
|
https://github.com/protobufjs/bytebuffer.js/blob/4144951c7f583d9394d18487ff0b2b7474b1e775/src/helpers.js#L67-L74
|
9,766
|
protobufjs/bytebuffer.js
|
src/helpers.js
|
assertRange
|
function assertRange(begin, end, min, cap) {
if (typeof begin !== 'number' || begin % 1 !== 0)
throw TypeError("Illegal begin: "+begin+" (not a number)");
begin = begin | 0;
if (typeof end !== 'number' || end % 1 !== 0)
throw TypeError("Illegal end: "+range[1]+" (not a number)");
end = end | 0;
if (begin < min || begin > end || end > cap)
throw RangeError("Illegal range: "+min+" <= "+begin+" <= "+end+" <= "+cap);
rangeVal[0] = begin; rangeVal[1] = end;
}
|
javascript
|
function assertRange(begin, end, min, cap) {
if (typeof begin !== 'number' || begin % 1 !== 0)
throw TypeError("Illegal begin: "+begin+" (not a number)");
begin = begin | 0;
if (typeof end !== 'number' || end % 1 !== 0)
throw TypeError("Illegal end: "+range[1]+" (not a number)");
end = end | 0;
if (begin < min || begin > end || end > cap)
throw RangeError("Illegal range: "+min+" <= "+begin+" <= "+end+" <= "+cap);
rangeVal[0] = begin; rangeVal[1] = end;
}
|
[
"function",
"assertRange",
"(",
"begin",
",",
"end",
",",
"min",
",",
"cap",
")",
"{",
"if",
"(",
"typeof",
"begin",
"!==",
"'number'",
"||",
"begin",
"%",
"1",
"!==",
"0",
")",
"throw",
"TypeError",
"(",
"\"Illegal begin: \"",
"+",
"begin",
"+",
"\" (not a number)\"",
")",
";",
"begin",
"=",
"begin",
"|",
"0",
";",
"if",
"(",
"typeof",
"end",
"!==",
"'number'",
"||",
"end",
"%",
"1",
"!==",
"0",
")",
"throw",
"TypeError",
"(",
"\"Illegal end: \"",
"+",
"range",
"[",
"1",
"]",
"+",
"\" (not a number)\"",
")",
";",
"end",
"=",
"end",
"|",
"0",
";",
"if",
"(",
"begin",
"<",
"min",
"||",
"begin",
">",
"end",
"||",
"end",
">",
"cap",
")",
"throw",
"RangeError",
"(",
"\"Illegal range: \"",
"+",
"min",
"+",
"\" <= \"",
"+",
"begin",
"+",
"\" <= \"",
"+",
"end",
"+",
"\" <= \"",
"+",
"cap",
")",
";",
"rangeVal",
"[",
"0",
"]",
"=",
"begin",
";",
"rangeVal",
"[",
"1",
"]",
"=",
"end",
";",
"}"
] |
Asserts that `min <= begin <= end <= cap`. Updates `rangeVal` with the type-safe range.
@param {number} begin Begin offset
@param {number} end End offset
@param {number} min Minimum offset
@param {number} cap Cap offset
@throws {TypeError} If `begin` or `end` is not an integer
@throws {RangeError} If `begin < min || begin > end || end > cap`
@inner
|
[
"Asserts",
"that",
"min",
"<",
"=",
"begin",
"<",
"=",
"end",
"<",
"=",
"cap",
".",
"Updates",
"rangeVal",
"with",
"the",
"type",
"-",
"safe",
"range",
"."
] |
4144951c7f583d9394d18487ff0b2b7474b1e775
|
https://github.com/protobufjs/bytebuffer.js/blob/4144951c7f583d9394d18487ff0b2b7474b1e775/src/helpers.js#L92-L102
|
9,767
|
googleads/videojs-ima
|
src/sdk-impl.js
|
function(controller) {
/**
* Plugin controller.
*/
this.controller = controller;
/**
* IMA SDK AdDisplayContainer.
*/
this.adDisplayContainer = null;
/**
* True if the AdDisplayContainer has been initialized. False otherwise.
*/
this.adDisplayContainerInitialized = false;
/**
* IMA SDK AdsLoader
*/
this.adsLoader = null;
/**
* IMA SDK AdsManager
*/
this.adsManager = null;
/**
* IMA SDK AdsRenderingSettings.
*/
this.adsRenderingSettings = null;
/**
* VAST, VMAP, or ad rules response. Used in lieu of fetching a response
* from an ad tag URL.
*/
this.adsResponse = null;
/**
* Current IMA SDK Ad.
*/
this.currentAd = null;
/**
* Timer used to track ad progress.
*/
this.adTrackingTimer = null;
/**
* True if ALL_ADS_COMPLETED has fired, false until then.
*/
this.allAdsCompleted = false;
/**
* True if ads are currently displayed, false otherwise.
* True regardless of ad pause state if an ad is currently being displayed.
*/
this.adsActive = false;
/**
* True if ad is currently playing, false if ad is paused or ads are not
* currently displayed.
*/
this.adPlaying = false;
/**
* True if the ad is muted, false otherwise.
*/
this.adMuted = false;
/**
* Listener to be called to trigger manual ad break playback.
*/
this.adBreakReadyListener = undefined;
/**
* Tracks whether or not we have already called adsLoader.contentComplete().
*/
this.contentCompleteCalled = false;
/**
* Stores the dimensions for the ads manager.
*/
this.adsManagerDimensions = {
width: 0,
height: 0,
};
/**
* Boolean flag to enable manual ad break playback.
*/
this.autoPlayAdBreaks = true;
if (this.controller.getSettings().autoPlayAdBreaks === false) {
this.autoPlayAdBreaks = false;
}
// Set SDK settings from plugin settings.
if (this.controller.getSettings().locale) {
/* eslint no-undef: 'error' */
/* global google */
google.ima.settings.setLocale(this.controller.getSettings().locale);
}
if (this.controller.getSettings().disableFlashAds) {
google.ima.settings.setDisableFlashAds(
this.controller.getSettings().disableFlashAds);
}
if (this.controller.getSettings().disableCustomPlaybackForIOS10Plus) {
google.ima.settings.setDisableCustomPlaybackForIOS10Plus(
this.controller.getSettings().disableCustomPlaybackForIOS10Plus);
}
}
|
javascript
|
function(controller) {
/**
* Plugin controller.
*/
this.controller = controller;
/**
* IMA SDK AdDisplayContainer.
*/
this.adDisplayContainer = null;
/**
* True if the AdDisplayContainer has been initialized. False otherwise.
*/
this.adDisplayContainerInitialized = false;
/**
* IMA SDK AdsLoader
*/
this.adsLoader = null;
/**
* IMA SDK AdsManager
*/
this.adsManager = null;
/**
* IMA SDK AdsRenderingSettings.
*/
this.adsRenderingSettings = null;
/**
* VAST, VMAP, or ad rules response. Used in lieu of fetching a response
* from an ad tag URL.
*/
this.adsResponse = null;
/**
* Current IMA SDK Ad.
*/
this.currentAd = null;
/**
* Timer used to track ad progress.
*/
this.adTrackingTimer = null;
/**
* True if ALL_ADS_COMPLETED has fired, false until then.
*/
this.allAdsCompleted = false;
/**
* True if ads are currently displayed, false otherwise.
* True regardless of ad pause state if an ad is currently being displayed.
*/
this.adsActive = false;
/**
* True if ad is currently playing, false if ad is paused or ads are not
* currently displayed.
*/
this.adPlaying = false;
/**
* True if the ad is muted, false otherwise.
*/
this.adMuted = false;
/**
* Listener to be called to trigger manual ad break playback.
*/
this.adBreakReadyListener = undefined;
/**
* Tracks whether or not we have already called adsLoader.contentComplete().
*/
this.contentCompleteCalled = false;
/**
* Stores the dimensions for the ads manager.
*/
this.adsManagerDimensions = {
width: 0,
height: 0,
};
/**
* Boolean flag to enable manual ad break playback.
*/
this.autoPlayAdBreaks = true;
if (this.controller.getSettings().autoPlayAdBreaks === false) {
this.autoPlayAdBreaks = false;
}
// Set SDK settings from plugin settings.
if (this.controller.getSettings().locale) {
/* eslint no-undef: 'error' */
/* global google */
google.ima.settings.setLocale(this.controller.getSettings().locale);
}
if (this.controller.getSettings().disableFlashAds) {
google.ima.settings.setDisableFlashAds(
this.controller.getSettings().disableFlashAds);
}
if (this.controller.getSettings().disableCustomPlaybackForIOS10Plus) {
google.ima.settings.setDisableCustomPlaybackForIOS10Plus(
this.controller.getSettings().disableCustomPlaybackForIOS10Plus);
}
}
|
[
"function",
"(",
"controller",
")",
"{",
"/**\n * Plugin controller.\n */",
"this",
".",
"controller",
"=",
"controller",
";",
"/**\n * IMA SDK AdDisplayContainer.\n */",
"this",
".",
"adDisplayContainer",
"=",
"null",
";",
"/**\n * True if the AdDisplayContainer has been initialized. False otherwise.\n */",
"this",
".",
"adDisplayContainerInitialized",
"=",
"false",
";",
"/**\n * IMA SDK AdsLoader\n */",
"this",
".",
"adsLoader",
"=",
"null",
";",
"/**\n * IMA SDK AdsManager\n */",
"this",
".",
"adsManager",
"=",
"null",
";",
"/**\n * IMA SDK AdsRenderingSettings.\n */",
"this",
".",
"adsRenderingSettings",
"=",
"null",
";",
"/**\n * VAST, VMAP, or ad rules response. Used in lieu of fetching a response\n * from an ad tag URL.\n */",
"this",
".",
"adsResponse",
"=",
"null",
";",
"/**\n * Current IMA SDK Ad.\n */",
"this",
".",
"currentAd",
"=",
"null",
";",
"/**\n * Timer used to track ad progress.\n */",
"this",
".",
"adTrackingTimer",
"=",
"null",
";",
"/**\n * True if ALL_ADS_COMPLETED has fired, false until then.\n */",
"this",
".",
"allAdsCompleted",
"=",
"false",
";",
"/**\n * True if ads are currently displayed, false otherwise.\n * True regardless of ad pause state if an ad is currently being displayed.\n */",
"this",
".",
"adsActive",
"=",
"false",
";",
"/**\n * True if ad is currently playing, false if ad is paused or ads are not\n * currently displayed.\n */",
"this",
".",
"adPlaying",
"=",
"false",
";",
"/**\n * True if the ad is muted, false otherwise.\n */",
"this",
".",
"adMuted",
"=",
"false",
";",
"/**\n * Listener to be called to trigger manual ad break playback.\n */",
"this",
".",
"adBreakReadyListener",
"=",
"undefined",
";",
"/**\n * Tracks whether or not we have already called adsLoader.contentComplete().\n */",
"this",
".",
"contentCompleteCalled",
"=",
"false",
";",
"/**\n * Stores the dimensions for the ads manager.\n */",
"this",
".",
"adsManagerDimensions",
"=",
"{",
"width",
":",
"0",
",",
"height",
":",
"0",
",",
"}",
";",
"/**\n * Boolean flag to enable manual ad break playback.\n */",
"this",
".",
"autoPlayAdBreaks",
"=",
"true",
";",
"if",
"(",
"this",
".",
"controller",
".",
"getSettings",
"(",
")",
".",
"autoPlayAdBreaks",
"===",
"false",
")",
"{",
"this",
".",
"autoPlayAdBreaks",
"=",
"false",
";",
"}",
"// Set SDK settings from plugin settings.",
"if",
"(",
"this",
".",
"controller",
".",
"getSettings",
"(",
")",
".",
"locale",
")",
"{",
"/* eslint no-undef: 'error' */",
"/* global google */",
"google",
".",
"ima",
".",
"settings",
".",
"setLocale",
"(",
"this",
".",
"controller",
".",
"getSettings",
"(",
")",
".",
"locale",
")",
";",
"}",
"if",
"(",
"this",
".",
"controller",
".",
"getSettings",
"(",
")",
".",
"disableFlashAds",
")",
"{",
"google",
".",
"ima",
".",
"settings",
".",
"setDisableFlashAds",
"(",
"this",
".",
"controller",
".",
"getSettings",
"(",
")",
".",
"disableFlashAds",
")",
";",
"}",
"if",
"(",
"this",
".",
"controller",
".",
"getSettings",
"(",
")",
".",
"disableCustomPlaybackForIOS10Plus",
")",
"{",
"google",
".",
"ima",
".",
"settings",
".",
"setDisableCustomPlaybackForIOS10Plus",
"(",
"this",
".",
"controller",
".",
"getSettings",
"(",
")",
".",
"disableCustomPlaybackForIOS10Plus",
")",
";",
"}",
"}"
] |
Implementation of the IMA SDK for the plugin.
@param {Object} controller Reference to the parent controller.
@constructor
@struct
@final
|
[
"Implementation",
"of",
"the",
"IMA",
"SDK",
"for",
"the",
"plugin",
"."
] |
e0d59f5a479467d954b3f31431f6535c6b8deb66
|
https://github.com/googleads/videojs-ima/blob/e0d59f5a479467d954b3f31431f6535c6b8deb66/src/sdk-impl.js#L31-L140
|
|
9,768
|
googleads/videojs-ima
|
src/controller.js
|
function(player, options) {
/**
* Stores user-provided settings.
* @type {Object}
*/
this.settings = {};
/**
* Content and ads ended listeners passed by the publisher to the plugin.
* These will be called when the plugin detects that content *and all
* ads* have completed. This differs from the contentEndedListeners in that
* contentEndedListeners will fire between content ending and a post-roll
* playing, whereas the contentAndAdsEndedListeners will fire after the
* post-roll completes.
*/
this.contentAndAdsEndedListeners = [];
/**
* Whether or not we are running on a mobile platform.
*/
this.isMobile = (navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/Android/i));
/**
* Whether or not we are running on an iOS platform.
*/
this.isIos = (navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i));
this.initWithSettings(options);
/**
* Stores contrib-ads default settings.
*/
const contribAdsDefaults = {
debug: this.settings.debug,
timeout: this.settings.timeout,
prerollTimeout: this.settings.prerollTimeout,
};
const adsPluginSettings = this.extend(
{}, contribAdsDefaults, options.contribAdsSettings || {});
this.playerWrapper = new PlayerWrapper(player, adsPluginSettings, this);
this.adUi = new AdUi(this);
this.sdkImpl = new SdkImpl(this);
}
|
javascript
|
function(player, options) {
/**
* Stores user-provided settings.
* @type {Object}
*/
this.settings = {};
/**
* Content and ads ended listeners passed by the publisher to the plugin.
* These will be called when the plugin detects that content *and all
* ads* have completed. This differs from the contentEndedListeners in that
* contentEndedListeners will fire between content ending and a post-roll
* playing, whereas the contentAndAdsEndedListeners will fire after the
* post-roll completes.
*/
this.contentAndAdsEndedListeners = [];
/**
* Whether or not we are running on a mobile platform.
*/
this.isMobile = (navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/Android/i));
/**
* Whether or not we are running on an iOS platform.
*/
this.isIos = (navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i));
this.initWithSettings(options);
/**
* Stores contrib-ads default settings.
*/
const contribAdsDefaults = {
debug: this.settings.debug,
timeout: this.settings.timeout,
prerollTimeout: this.settings.prerollTimeout,
};
const adsPluginSettings = this.extend(
{}, contribAdsDefaults, options.contribAdsSettings || {});
this.playerWrapper = new PlayerWrapper(player, adsPluginSettings, this);
this.adUi = new AdUi(this);
this.sdkImpl = new SdkImpl(this);
}
|
[
"function",
"(",
"player",
",",
"options",
")",
"{",
"/**\n * Stores user-provided settings.\n * @type {Object}\n */",
"this",
".",
"settings",
"=",
"{",
"}",
";",
"/**\n * Content and ads ended listeners passed by the publisher to the plugin.\n * These will be called when the plugin detects that content *and all\n * ads* have completed. This differs from the contentEndedListeners in that\n * contentEndedListeners will fire between content ending and a post-roll\n * playing, whereas the contentAndAdsEndedListeners will fire after the\n * post-roll completes.\n */",
"this",
".",
"contentAndAdsEndedListeners",
"=",
"[",
"]",
";",
"/**\n * Whether or not we are running on a mobile platform.\n */",
"this",
".",
"isMobile",
"=",
"(",
"navigator",
".",
"userAgent",
".",
"match",
"(",
"/",
"iPhone",
"/",
"i",
")",
"||",
"navigator",
".",
"userAgent",
".",
"match",
"(",
"/",
"iPad",
"/",
"i",
")",
"||",
"navigator",
".",
"userAgent",
".",
"match",
"(",
"/",
"Android",
"/",
"i",
")",
")",
";",
"/**\n * Whether or not we are running on an iOS platform.\n */",
"this",
".",
"isIos",
"=",
"(",
"navigator",
".",
"userAgent",
".",
"match",
"(",
"/",
"iPhone",
"/",
"i",
")",
"||",
"navigator",
".",
"userAgent",
".",
"match",
"(",
"/",
"iPad",
"/",
"i",
")",
")",
";",
"this",
".",
"initWithSettings",
"(",
"options",
")",
";",
"/**\n * Stores contrib-ads default settings.\n */",
"const",
"contribAdsDefaults",
"=",
"{",
"debug",
":",
"this",
".",
"settings",
".",
"debug",
",",
"timeout",
":",
"this",
".",
"settings",
".",
"timeout",
",",
"prerollTimeout",
":",
"this",
".",
"settings",
".",
"prerollTimeout",
",",
"}",
";",
"const",
"adsPluginSettings",
"=",
"this",
".",
"extend",
"(",
"{",
"}",
",",
"contribAdsDefaults",
",",
"options",
".",
"contribAdsSettings",
"||",
"{",
"}",
")",
";",
"this",
".",
"playerWrapper",
"=",
"new",
"PlayerWrapper",
"(",
"player",
",",
"adsPluginSettings",
",",
"this",
")",
";",
"this",
".",
"adUi",
"=",
"new",
"AdUi",
"(",
"this",
")",
";",
"this",
".",
"sdkImpl",
"=",
"new",
"SdkImpl",
"(",
"this",
")",
";",
"}"
] |
The grand coordinator of the plugin. Facilitates communication between all
other plugin classes.
@param {Object} player Instance of the video.js player.
@param {Object} options Options provided by the implementation.
@constructor
@struct
@final
|
[
"The",
"grand",
"coordinator",
"of",
"the",
"plugin",
".",
"Facilitates",
"communication",
"between",
"all",
"other",
"plugin",
"classes",
"."
] |
e0d59f5a479467d954b3f31431f6535c6b8deb66
|
https://github.com/googleads/videojs-ima/blob/e0d59f5a479467d954b3f31431f6535c6b8deb66/src/controller.js#L33-L79
|
|
9,769
|
cowbell/cordova-plugin-geofence
|
www/geofence.js
|
function (geofences, success, error) {
if (!Array.isArray(geofences)) {
geofences = [geofences];
}
geofences.forEach(coerceProperties);
if (isIOS) {
return addOrUpdateIOS(geofences, success, error);
}
return execPromise(success, error, "GeofencePlugin", "addOrUpdate", geofences);
}
|
javascript
|
function (geofences, success, error) {
if (!Array.isArray(geofences)) {
geofences = [geofences];
}
geofences.forEach(coerceProperties);
if (isIOS) {
return addOrUpdateIOS(geofences, success, error);
}
return execPromise(success, error, "GeofencePlugin", "addOrUpdate", geofences);
}
|
[
"function",
"(",
"geofences",
",",
"success",
",",
"error",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"geofences",
")",
")",
"{",
"geofences",
"=",
"[",
"geofences",
"]",
";",
"}",
"geofences",
".",
"forEach",
"(",
"coerceProperties",
")",
";",
"if",
"(",
"isIOS",
")",
"{",
"return",
"addOrUpdateIOS",
"(",
"geofences",
",",
"success",
",",
"error",
")",
";",
"}",
"return",
"execPromise",
"(",
"success",
",",
"error",
",",
"\"GeofencePlugin\"",
",",
"\"addOrUpdate\"",
",",
"geofences",
")",
";",
"}"
] |
Adding new geofence to monitor.
Geofence could override the previously one with the same id.
@name addOrUpdate
@param {Geofence|Array} geofences
@param {Function} success callback
@param {Function} error callback
@return {Promise}
|
[
"Adding",
"new",
"geofence",
"to",
"monitor",
".",
"Geofence",
"could",
"override",
"the",
"previously",
"one",
"with",
"the",
"same",
"id",
"."
] |
091907de34304202dc461f8787b292294ee6d1b0
|
https://github.com/cowbell/cordova-plugin-geofence/blob/091907de34304202dc461f8787b292294ee6d1b0/www/geofence.js#L51-L63
|
|
9,770
|
cowbell/cordova-plugin-geofence
|
www/geofence.js
|
function (ids, success, error) {
if (!Array.isArray(ids)) {
ids = [ids];
}
return execPromise(success, error, "GeofencePlugin", "remove", ids);
}
|
javascript
|
function (ids, success, error) {
if (!Array.isArray(ids)) {
ids = [ids];
}
return execPromise(success, error, "GeofencePlugin", "remove", ids);
}
|
[
"function",
"(",
"ids",
",",
"success",
",",
"error",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"ids",
")",
")",
"{",
"ids",
"=",
"[",
"ids",
"]",
";",
"}",
"return",
"execPromise",
"(",
"success",
",",
"error",
",",
"\"GeofencePlugin\"",
",",
"\"remove\"",
",",
"ids",
")",
";",
"}"
] |
Removing geofences with given ids
@name remove
@param {Number|Array} ids
@param {Function} success callback
@param {Function} error callback
@return {Promise}
|
[
"Removing",
"geofences",
"with",
"given",
"ids"
] |
091907de34304202dc461f8787b292294ee6d1b0
|
https://github.com/cowbell/cordova-plugin-geofence/blob/091907de34304202dc461f8787b292294ee6d1b0/www/geofence.js#L73-L78
|
|
9,771
|
dgraph-io/dgraph-js
|
examples/tls/index.js
|
newClientStub
|
function newClientStub() {
// First create the appropriate TLS certs with dgraph cert:
// $ dgraph cert
// $ dgraph cert -n localhost
// $ dgraph cert -c user
const rootCaCert = fs.readFileSync(path.join(__dirname, 'tls', 'ca.crt'));
const clientCertKey = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.key'));
const clientCert = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.crt'));
return new dgraph.DgraphClientStub(
"localhost:9080",
grpc.credentials.createSsl(rootCaCert, clientCertKey, clientCert));
}
|
javascript
|
function newClientStub() {
// First create the appropriate TLS certs with dgraph cert:
// $ dgraph cert
// $ dgraph cert -n localhost
// $ dgraph cert -c user
const rootCaCert = fs.readFileSync(path.join(__dirname, 'tls', 'ca.crt'));
const clientCertKey = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.key'));
const clientCert = fs.readFileSync(path.join(__dirname, 'tls', 'client.user.crt'));
return new dgraph.DgraphClientStub(
"localhost:9080",
grpc.credentials.createSsl(rootCaCert, clientCertKey, clientCert));
}
|
[
"function",
"newClientStub",
"(",
")",
"{",
"// First create the appropriate TLS certs with dgraph cert:",
"// $ dgraph cert",
"// $ dgraph cert -n localhost",
"// $ dgraph cert -c user",
"const",
"rootCaCert",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"'tls'",
",",
"'ca.crt'",
")",
")",
";",
"const",
"clientCertKey",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"'tls'",
",",
"'client.user.key'",
")",
")",
";",
"const",
"clientCert",
"=",
"fs",
".",
"readFileSync",
"(",
"path",
".",
"join",
"(",
"__dirname",
",",
"'tls'",
",",
"'client.user.crt'",
")",
")",
";",
"return",
"new",
"dgraph",
".",
"DgraphClientStub",
"(",
"\"localhost:9080\"",
",",
"grpc",
".",
"credentials",
".",
"createSsl",
"(",
"rootCaCert",
",",
"clientCertKey",
",",
"clientCert",
")",
")",
";",
"}"
] |
Create a client stub.
|
[
"Create",
"a",
"client",
"stub",
"."
] |
c32c1af2c3d536bf0d14252be604a863556920a7
|
https://github.com/dgraph-io/dgraph-js/blob/c32c1af2c3d536bf0d14252be604a863556920a7/examples/tls/index.js#L8-L19
|
9,772
|
dgraph-io/dgraph-js
|
examples/tls/index.js
|
dropAll
|
async function dropAll(dgraphClient) {
const op = new dgraph.Operation();
op.setDropAll(true);
await dgraphClient.alter(op);
}
|
javascript
|
async function dropAll(dgraphClient) {
const op = new dgraph.Operation();
op.setDropAll(true);
await dgraphClient.alter(op);
}
|
[
"async",
"function",
"dropAll",
"(",
"dgraphClient",
")",
"{",
"const",
"op",
"=",
"new",
"dgraph",
".",
"Operation",
"(",
")",
";",
"op",
".",
"setDropAll",
"(",
"true",
")",
";",
"await",
"dgraphClient",
".",
"alter",
"(",
"op",
")",
";",
"}"
] |
Drop All - discard all data and start from a clean slate.
|
[
"Drop",
"All",
"-",
"discard",
"all",
"data",
"and",
"start",
"from",
"a",
"clean",
"slate",
"."
] |
c32c1af2c3d536bf0d14252be604a863556920a7
|
https://github.com/dgraph-io/dgraph-js/blob/c32c1af2c3d536bf0d14252be604a863556920a7/examples/tls/index.js#L27-L31
|
9,773
|
dgraph-io/dgraph-js
|
examples/tls/index.js
|
createData
|
async function createData(dgraphClient) {
// Create a new transaction.
const txn = dgraphClient.newTxn();
try {
// Create data.
const p = {
name: "Alice",
age: 26,
married: true,
loc: {
type: "Point",
coordinates: [1.1, 2],
},
dob: new Date(1980, 1, 1, 23, 0, 0, 0),
friend: [
{
name: "Bob",
age: 24,
},
{
name: "Charlie",
age: 29,
}
],
school: [
{
name: "Crown Public School",
}
]
};
// Run mutation.
const mu = new dgraph.Mutation();
mu.setSetJson(p);
const assigned = await txn.mutate(mu);
// Commit transaction.
await txn.commit();
// Get uid of the outermost object (person named "Alice").
// Assigned#getUidsMap() returns a map from blank node names to uids.
// For a json mutation, blank node names "blank-0", "blank-1", ... are used
// for all the created nodes.
console.log(`Created person named "Alice" with uid = ${assigned.getUidsMap().get("blank-0")}\n`);
console.log("All created nodes (map from blank node names to uids):");
assigned.getUidsMap().forEach((uid, key) => console.log(`${key} => ${uid}`));
console.log();
} finally {
// Clean up. Calling this after txn.commit() is a no-op
// and hence safe.
await txn.discard();
}
}
|
javascript
|
async function createData(dgraphClient) {
// Create a new transaction.
const txn = dgraphClient.newTxn();
try {
// Create data.
const p = {
name: "Alice",
age: 26,
married: true,
loc: {
type: "Point",
coordinates: [1.1, 2],
},
dob: new Date(1980, 1, 1, 23, 0, 0, 0),
friend: [
{
name: "Bob",
age: 24,
},
{
name: "Charlie",
age: 29,
}
],
school: [
{
name: "Crown Public School",
}
]
};
// Run mutation.
const mu = new dgraph.Mutation();
mu.setSetJson(p);
const assigned = await txn.mutate(mu);
// Commit transaction.
await txn.commit();
// Get uid of the outermost object (person named "Alice").
// Assigned#getUidsMap() returns a map from blank node names to uids.
// For a json mutation, blank node names "blank-0", "blank-1", ... are used
// for all the created nodes.
console.log(`Created person named "Alice" with uid = ${assigned.getUidsMap().get("blank-0")}\n`);
console.log("All created nodes (map from blank node names to uids):");
assigned.getUidsMap().forEach((uid, key) => console.log(`${key} => ${uid}`));
console.log();
} finally {
// Clean up. Calling this after txn.commit() is a no-op
// and hence safe.
await txn.discard();
}
}
|
[
"async",
"function",
"createData",
"(",
"dgraphClient",
")",
"{",
"// Create a new transaction.",
"const",
"txn",
"=",
"dgraphClient",
".",
"newTxn",
"(",
")",
";",
"try",
"{",
"// Create data.",
"const",
"p",
"=",
"{",
"name",
":",
"\"Alice\"",
",",
"age",
":",
"26",
",",
"married",
":",
"true",
",",
"loc",
":",
"{",
"type",
":",
"\"Point\"",
",",
"coordinates",
":",
"[",
"1.1",
",",
"2",
"]",
",",
"}",
",",
"dob",
":",
"new",
"Date",
"(",
"1980",
",",
"1",
",",
"1",
",",
"23",
",",
"0",
",",
"0",
",",
"0",
")",
",",
"friend",
":",
"[",
"{",
"name",
":",
"\"Bob\"",
",",
"age",
":",
"24",
",",
"}",
",",
"{",
"name",
":",
"\"Charlie\"",
",",
"age",
":",
"29",
",",
"}",
"]",
",",
"school",
":",
"[",
"{",
"name",
":",
"\"Crown Public School\"",
",",
"}",
"]",
"}",
";",
"// Run mutation.",
"const",
"mu",
"=",
"new",
"dgraph",
".",
"Mutation",
"(",
")",
";",
"mu",
".",
"setSetJson",
"(",
"p",
")",
";",
"const",
"assigned",
"=",
"await",
"txn",
".",
"mutate",
"(",
"mu",
")",
";",
"// Commit transaction.",
"await",
"txn",
".",
"commit",
"(",
")",
";",
"// Get uid of the outermost object (person named \"Alice\").",
"// Assigned#getUidsMap() returns a map from blank node names to uids.",
"// For a json mutation, blank node names \"blank-0\", \"blank-1\", ... are used",
"// for all the created nodes.",
"console",
".",
"log",
"(",
"`",
"${",
"assigned",
".",
"getUidsMap",
"(",
")",
".",
"get",
"(",
"\"blank-0\"",
")",
"}",
"\\n",
"`",
")",
";",
"console",
".",
"log",
"(",
"\"All created nodes (map from blank node names to uids):\"",
")",
";",
"assigned",
".",
"getUidsMap",
"(",
")",
".",
"forEach",
"(",
"(",
"uid",
",",
"key",
")",
"=>",
"console",
".",
"log",
"(",
"`",
"${",
"key",
"}",
"${",
"uid",
"}",
"`",
")",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"}",
"finally",
"{",
"// Clean up. Calling this after txn.commit() is a no-op",
"// and hence safe.",
"await",
"txn",
".",
"discard",
"(",
")",
";",
"}",
"}"
] |
Create data using JSON.
|
[
"Create",
"data",
"using",
"JSON",
"."
] |
c32c1af2c3d536bf0d14252be604a863556920a7
|
https://github.com/dgraph-io/dgraph-js/blob/c32c1af2c3d536bf0d14252be604a863556920a7/examples/tls/index.js#L48-L101
|
9,774
|
darthbatman/billboard-top-100
|
billboard-top-100.js
|
yyyymmddDateFromMonthDayYearDate
|
function yyyymmddDateFromMonthDayYearDate(monthDayYearDate) {
var yyyy = monthDayYearDate.split(',')[1].trim();
var dd = monthDayYearDate.split(' ')[1].split(',')[0];
var mm = '';
switch (monthDayYearDate.split(' ')[0]) {
case 'January':
mm = '01';
break;
case 'February':
mm = '02';
break;
case 'March':
mm = '03';
break;
case 'April':
mm = '04';
break;
case 'May':
mm = '05';
break;
case 'June':
mm = '06';
break;
case 'July':
mm = '07';
break;
case 'August':
mm = '08';
break;
case 'September':
mm = '09';
break;
case 'October':
mm = '10';
break;
case 'November':
mm = '11';
break;
case 'December':
mm = '12';
break;
}
return yyyy + '-' + mm + '-' + dd;
}
|
javascript
|
function yyyymmddDateFromMonthDayYearDate(monthDayYearDate) {
var yyyy = monthDayYearDate.split(',')[1].trim();
var dd = monthDayYearDate.split(' ')[1].split(',')[0];
var mm = '';
switch (monthDayYearDate.split(' ')[0]) {
case 'January':
mm = '01';
break;
case 'February':
mm = '02';
break;
case 'March':
mm = '03';
break;
case 'April':
mm = '04';
break;
case 'May':
mm = '05';
break;
case 'June':
mm = '06';
break;
case 'July':
mm = '07';
break;
case 'August':
mm = '08';
break;
case 'September':
mm = '09';
break;
case 'October':
mm = '10';
break;
case 'November':
mm = '11';
break;
case 'December':
mm = '12';
break;
}
return yyyy + '-' + mm + '-' + dd;
}
|
[
"function",
"yyyymmddDateFromMonthDayYearDate",
"(",
"monthDayYearDate",
")",
"{",
"var",
"yyyy",
"=",
"monthDayYearDate",
".",
"split",
"(",
"','",
")",
"[",
"1",
"]",
".",
"trim",
"(",
")",
";",
"var",
"dd",
"=",
"monthDayYearDate",
".",
"split",
"(",
"' '",
")",
"[",
"1",
"]",
".",
"split",
"(",
"','",
")",
"[",
"0",
"]",
";",
"var",
"mm",
"=",
"''",
";",
"switch",
"(",
"monthDayYearDate",
".",
"split",
"(",
"' '",
")",
"[",
"0",
"]",
")",
"{",
"case",
"'January'",
":",
"mm",
"=",
"'01'",
";",
"break",
";",
"case",
"'February'",
":",
"mm",
"=",
"'02'",
";",
"break",
";",
"case",
"'March'",
":",
"mm",
"=",
"'03'",
";",
"break",
";",
"case",
"'April'",
":",
"mm",
"=",
"'04'",
";",
"break",
";",
"case",
"'May'",
":",
"mm",
"=",
"'05'",
";",
"break",
";",
"case",
"'June'",
":",
"mm",
"=",
"'06'",
";",
"break",
";",
"case",
"'July'",
":",
"mm",
"=",
"'07'",
";",
"break",
";",
"case",
"'August'",
":",
"mm",
"=",
"'08'",
";",
"break",
";",
"case",
"'September'",
":",
"mm",
"=",
"'09'",
";",
"break",
";",
"case",
"'October'",
":",
"mm",
"=",
"'10'",
";",
"break",
";",
"case",
"'November'",
":",
"mm",
"=",
"'11'",
";",
"break",
";",
"case",
"'December'",
":",
"mm",
"=",
"'12'",
";",
"break",
";",
"}",
"return",
"yyyy",
"+",
"'-'",
"+",
"mm",
"+",
"'-'",
"+",
"dd",
";",
"}"
] |
Converts Month Day, Year date to YYYY-MM-DD date
@param {string} monthDayYearDate - The Month Day, Year date
@return {string} The YYYY-MM-DD date
@example
yyyymmddDateFromMonthDayYearDate("November 19, 2016") // 2016-11-19
|
[
"Converts",
"Month",
"Day",
"Year",
"date",
"to",
"YYYY",
"-",
"MM",
"-",
"DD",
"date"
] |
6169e74bda974c004575dd71f28d50eb07aa1dcf
|
https://github.com/darthbatman/billboard-top-100/blob/6169e74bda974c004575dd71f28d50eb07aa1dcf/billboard-top-100.js#L53-L96
|
9,775
|
darthbatman/billboard-top-100
|
billboard-top-100.js
|
getTitleFromChartItem
|
function getTitleFromChartItem(chartItem) {
var title;
try {
title = chartItem.children[1].children[5].children[1].children[1].children[1].children[0].data.replace(/\n/g, '');
} catch (e) {
title = '';
}
return title;
}
|
javascript
|
function getTitleFromChartItem(chartItem) {
var title;
try {
title = chartItem.children[1].children[5].children[1].children[1].children[1].children[0].data.replace(/\n/g, '');
} catch (e) {
title = '';
}
return title;
}
|
[
"function",
"getTitleFromChartItem",
"(",
"chartItem",
")",
"{",
"var",
"title",
";",
"try",
"{",
"title",
"=",
"chartItem",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"5",
"]",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"''",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"title",
"=",
"''",
";",
"}",
"return",
"title",
";",
"}"
] |
IMPLEMENTATION FUNCTIONS
Gets the title from the specified chart item
@param {HTMLElement} chartItem - The chart item
@return {string} The title
@example
getTitleFromChartItem(<div class="chart-list-item">...</div>) // 'The Real Slim Shady'
|
[
"IMPLEMENTATION",
"FUNCTIONS",
"Gets",
"the",
"title",
"from",
"the",
"specified",
"chart",
"item"
] |
6169e74bda974c004575dd71f28d50eb07aa1dcf
|
https://github.com/darthbatman/billboard-top-100/blob/6169e74bda974c004575dd71f28d50eb07aa1dcf/billboard-top-100.js#L110-L118
|
9,776
|
darthbatman/billboard-top-100
|
billboard-top-100.js
|
getArtistFromChartItem
|
function getArtistFromChartItem(chartItem) {
var artist;
try {
artist = chartItem.children[1].children[5].children[1].children[3].children[0].data.replace(/\n/g, '');
} catch (e) {
artist = '';
}
if (artist.trim().length < 1) {
try {
artist = chartItem.children[1].children[5].children[1].children[3].children[1].children[0].data.replace(/\n/g, '');
} catch (e) {
artist = '';
}
}
return artist;
}
|
javascript
|
function getArtistFromChartItem(chartItem) {
var artist;
try {
artist = chartItem.children[1].children[5].children[1].children[3].children[0].data.replace(/\n/g, '');
} catch (e) {
artist = '';
}
if (artist.trim().length < 1) {
try {
artist = chartItem.children[1].children[5].children[1].children[3].children[1].children[0].data.replace(/\n/g, '');
} catch (e) {
artist = '';
}
}
return artist;
}
|
[
"function",
"getArtistFromChartItem",
"(",
"chartItem",
")",
"{",
"var",
"artist",
";",
"try",
"{",
"artist",
"=",
"chartItem",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"5",
"]",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"''",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"artist",
"=",
"''",
";",
"}",
"if",
"(",
"artist",
".",
"trim",
"(",
")",
".",
"length",
"<",
"1",
")",
"{",
"try",
"{",
"artist",
"=",
"chartItem",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"5",
"]",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"''",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"artist",
"=",
"''",
";",
"}",
"}",
"return",
"artist",
";",
"}"
] |
Gets the artist from the specified chart item
@param {HTMLElement} chartItem - The chart item
@return {string} The artist
@example
getArtistFromChartItem(<div class="chart-list-item">...</div>) // 'Eminem'
|
[
"Gets",
"the",
"artist",
"from",
"the",
"specified",
"chart",
"item"
] |
6169e74bda974c004575dd71f28d50eb07aa1dcf
|
https://github.com/darthbatman/billboard-top-100/blob/6169e74bda974c004575dd71f28d50eb07aa1dcf/billboard-top-100.js#L130-L145
|
9,777
|
darthbatman/billboard-top-100
|
billboard-top-100.js
|
getPositionLastWeekFromChartItem
|
function getPositionLastWeekFromChartItem(chartItem) {
var positionLastWeek;
try {
if (chartItem.children[3].children.length > 5) {
positionLastWeek = chartItem.children[3].children[5].children[3].children[3].children[0].data
} else {
positionLastWeek = chartItem.children[3].children[3].children[1].children[3].children[0].data;
}
} catch (e) {
positionLastWeek = '';
}
return parseInt(positionLastWeek);
}
|
javascript
|
function getPositionLastWeekFromChartItem(chartItem) {
var positionLastWeek;
try {
if (chartItem.children[3].children.length > 5) {
positionLastWeek = chartItem.children[3].children[5].children[3].children[3].children[0].data
} else {
positionLastWeek = chartItem.children[3].children[3].children[1].children[3].children[0].data;
}
} catch (e) {
positionLastWeek = '';
}
return parseInt(positionLastWeek);
}
|
[
"function",
"getPositionLastWeekFromChartItem",
"(",
"chartItem",
")",
"{",
"var",
"positionLastWeek",
";",
"try",
"{",
"if",
"(",
"chartItem",
".",
"children",
"[",
"3",
"]",
".",
"children",
".",
"length",
">",
"5",
")",
"{",
"positionLastWeek",
"=",
"chartItem",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"5",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
"}",
"else",
"{",
"positionLastWeek",
"=",
"chartItem",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"1",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"positionLastWeek",
"=",
"''",
";",
"}",
"return",
"parseInt",
"(",
"positionLastWeek",
")",
";",
"}"
] |
Gets the position last week from the specified chart item
@param {HTMLElement} chartItem - The chart item
@return {number} The position last week
@example
getPositionLastWeekFromChartItem(<div class="chart-list-item">...</div>) // 4
|
[
"Gets",
"the",
"position",
"last",
"week",
"from",
"the",
"specified",
"chart",
"item"
] |
6169e74bda974c004575dd71f28d50eb07aa1dcf
|
https://github.com/darthbatman/billboard-top-100/blob/6169e74bda974c004575dd71f28d50eb07aa1dcf/billboard-top-100.js#L201-L213
|
9,778
|
darthbatman/billboard-top-100
|
billboard-top-100.js
|
getPeakPositionFromChartItem
|
function getPeakPositionFromChartItem(chartItem) {
var peakPosition;
try {
if (chartItem.children[3].children.length > 5) {
peakPosition = chartItem.children[3].children[5].children[5].children[3].children[0].data;
} else {
peakPosition = chartItem.children[3].children[3].children[3].children[3].children[0].data;
}
} catch (e) {
peakPosition = chartItem.attribs['data-rank'];
}
return parseInt(peakPosition);
}
|
javascript
|
function getPeakPositionFromChartItem(chartItem) {
var peakPosition;
try {
if (chartItem.children[3].children.length > 5) {
peakPosition = chartItem.children[3].children[5].children[5].children[3].children[0].data;
} else {
peakPosition = chartItem.children[3].children[3].children[3].children[3].children[0].data;
}
} catch (e) {
peakPosition = chartItem.attribs['data-rank'];
}
return parseInt(peakPosition);
}
|
[
"function",
"getPeakPositionFromChartItem",
"(",
"chartItem",
")",
"{",
"var",
"peakPosition",
";",
"try",
"{",
"if",
"(",
"chartItem",
".",
"children",
"[",
"3",
"]",
".",
"children",
".",
"length",
">",
"5",
")",
"{",
"peakPosition",
"=",
"chartItem",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"5",
"]",
".",
"children",
"[",
"5",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
";",
"}",
"else",
"{",
"peakPosition",
"=",
"chartItem",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"peakPosition",
"=",
"chartItem",
".",
"attribs",
"[",
"'data-rank'",
"]",
";",
"}",
"return",
"parseInt",
"(",
"peakPosition",
")",
";",
"}"
] |
Gets the peak position from the specified chart item
@param {HTMLElement} chartItem - The chart item
@return {number} The peak position
@example
getPeakPositionFromChartItem(<div class="chart-list-item">...</div>) // 4
|
[
"Gets",
"the",
"peak",
"position",
"from",
"the",
"specified",
"chart",
"item"
] |
6169e74bda974c004575dd71f28d50eb07aa1dcf
|
https://github.com/darthbatman/billboard-top-100/blob/6169e74bda974c004575dd71f28d50eb07aa1dcf/billboard-top-100.js#L225-L237
|
9,779
|
darthbatman/billboard-top-100
|
billboard-top-100.js
|
getWeeksOnChartFromChartItem
|
function getWeeksOnChartFromChartItem(chartItem) {
var weeksOnChart;
try {
if (chartItem.children[3].children.length > 5) {
weeksOnChart = chartItem.children[3].children[5].children[7].children[3].children[0].data;
} else {
weeksOnChart = chartItem.children[3].children[3].children[5].children[3].children[0].data;
}
} catch (e) {
weeksOnChart = '1';
}
return parseInt(weeksOnChart);
}
|
javascript
|
function getWeeksOnChartFromChartItem(chartItem) {
var weeksOnChart;
try {
if (chartItem.children[3].children.length > 5) {
weeksOnChart = chartItem.children[3].children[5].children[7].children[3].children[0].data;
} else {
weeksOnChart = chartItem.children[3].children[3].children[5].children[3].children[0].data;
}
} catch (e) {
weeksOnChart = '1';
}
return parseInt(weeksOnChart);
}
|
[
"function",
"getWeeksOnChartFromChartItem",
"(",
"chartItem",
")",
"{",
"var",
"weeksOnChart",
";",
"try",
"{",
"if",
"(",
"chartItem",
".",
"children",
"[",
"3",
"]",
".",
"children",
".",
"length",
">",
"5",
")",
"{",
"weeksOnChart",
"=",
"chartItem",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"5",
"]",
".",
"children",
"[",
"7",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
";",
"}",
"else",
"{",
"weeksOnChart",
"=",
"chartItem",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"5",
"]",
".",
"children",
"[",
"3",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
";",
"}",
"}",
"catch",
"(",
"e",
")",
"{",
"weeksOnChart",
"=",
"'1'",
";",
"}",
"return",
"parseInt",
"(",
"weeksOnChart",
")",
";",
"}"
] |
Gets the weeks on chart last week from the specified chart item
@param {HTMLElement} chartItem - The chart item
@return {number} The weeks on chart
@example
getWeeksOnChartFromChartItem(<div class="chart-list-item">...</div>) // 4
|
[
"Gets",
"the",
"weeks",
"on",
"chart",
"last",
"week",
"from",
"the",
"specified",
"chart",
"item"
] |
6169e74bda974c004575dd71f28d50eb07aa1dcf
|
https://github.com/darthbatman/billboard-top-100/blob/6169e74bda974c004575dd71f28d50eb07aa1dcf/billboard-top-100.js#L249-L261
|
9,780
|
darthbatman/billboard-top-100
|
billboard-top-100.js
|
getNeighboringChart
|
function getNeighboringChart(chartItem, neighboringWeek) {
if (neighboringWeek == NeighboringWeek.Previous) {
if (chartItem[0].attribs.class.indexOf('dropdown__date-selector-option--disabled') == -1) {
return {
url: BILLBOARD_BASE_URL + chartItem[0].children[1].attribs.href,
date: chartItem[0].children[1].attribs.href.split('/')[3]
};
}
} else {
if (chartItem[1].attribs.class.indexOf('dropdown__date-selector-option--disabled') == -1) {
return {
url: BILLBOARD_BASE_URL + chartItem[1].children[1].attribs.href,
date: chartItem[1].children[1].attribs.href.split('/')[3]
};
}
}
return {
url: '',
date: ''
}
}
|
javascript
|
function getNeighboringChart(chartItem, neighboringWeek) {
if (neighboringWeek == NeighboringWeek.Previous) {
if (chartItem[0].attribs.class.indexOf('dropdown__date-selector-option--disabled') == -1) {
return {
url: BILLBOARD_BASE_URL + chartItem[0].children[1].attribs.href,
date: chartItem[0].children[1].attribs.href.split('/')[3]
};
}
} else {
if (chartItem[1].attribs.class.indexOf('dropdown__date-selector-option--disabled') == -1) {
return {
url: BILLBOARD_BASE_URL + chartItem[1].children[1].attribs.href,
date: chartItem[1].children[1].attribs.href.split('/')[3]
};
}
}
return {
url: '',
date: ''
}
}
|
[
"function",
"getNeighboringChart",
"(",
"chartItem",
",",
"neighboringWeek",
")",
"{",
"if",
"(",
"neighboringWeek",
"==",
"NeighboringWeek",
".",
"Previous",
")",
"{",
"if",
"(",
"chartItem",
"[",
"0",
"]",
".",
"attribs",
".",
"class",
".",
"indexOf",
"(",
"'dropdown__date-selector-option--disabled'",
")",
"==",
"-",
"1",
")",
"{",
"return",
"{",
"url",
":",
"BILLBOARD_BASE_URL",
"+",
"chartItem",
"[",
"0",
"]",
".",
"children",
"[",
"1",
"]",
".",
"attribs",
".",
"href",
",",
"date",
":",
"chartItem",
"[",
"0",
"]",
".",
"children",
"[",
"1",
"]",
".",
"attribs",
".",
"href",
".",
"split",
"(",
"'/'",
")",
"[",
"3",
"]",
"}",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"chartItem",
"[",
"1",
"]",
".",
"attribs",
".",
"class",
".",
"indexOf",
"(",
"'dropdown__date-selector-option--disabled'",
")",
"==",
"-",
"1",
")",
"{",
"return",
"{",
"url",
":",
"BILLBOARD_BASE_URL",
"+",
"chartItem",
"[",
"1",
"]",
".",
"children",
"[",
"1",
"]",
".",
"attribs",
".",
"href",
",",
"date",
":",
"chartItem",
"[",
"1",
"]",
".",
"children",
"[",
"1",
"]",
".",
"attribs",
".",
"href",
".",
"split",
"(",
"'/'",
")",
"[",
"3",
"]",
"}",
";",
"}",
"}",
"return",
"{",
"url",
":",
"''",
",",
"date",
":",
"''",
"}",
"}"
] |
Gets the neighboring chart for a given chart item and neighboring week type.
@param {HTMLElement} chartItem - The chart item
@param {enum} neighboringWeek - The type of neighboring week
@return {object} The neighboring chart with url and week
@example
getNeighboringChart(<div class="dropdown__date-selector-option">...</div>) // { url: 'http://www.billboard.com/charts/hot-100/2016-11-12', date: '2016-11-12' }
|
[
"Gets",
"the",
"neighboring",
"chart",
"for",
"a",
"given",
"chart",
"item",
"and",
"neighboring",
"week",
"type",
"."
] |
6169e74bda974c004575dd71f28d50eb07aa1dcf
|
https://github.com/darthbatman/billboard-top-100/blob/6169e74bda974c004575dd71f28d50eb07aa1dcf/billboard-top-100.js#L274-L294
|
9,781
|
darthbatman/billboard-top-100
|
billboard-top-100.js
|
getChart
|
function getChart(chartName, date, cb) {
// check if chart was specified
if (typeof chartName === 'function') {
// if chartName not specified, default to hot-100 chart for current week,
// and set callback method accordingly
cb = chartName;
chartName = 'hot-100';
date = '';
}
// check if date was specified
if (typeof date === 'function') {
// if date not specified, default to specified chart for current week,
// and set callback method accordingly
cb = date;
date = '';
}
var chart = {};
/**
* A song
* @typedef {Object} Song
* @property {string} title - The title of the song
* @property {string} artist - The song's artist
*/
/**
* Array of songs
*/
chart.songs = [];
// build request URL string for specified chart and date
var requestURL = BILLBOARD_CHARTS_URL + chartName + '/' + date;
request(requestURL, function completedRequest(error, response, html) {
if (error) {
cb(error, null);
return;
}
var $ = cheerio.load(html);
// get chart week
chart.week = yyyymmddDateFromMonthDayYearDate($('.chart-detail-header__date-selector-button')[0].children[0].data.replace(/\n/g, ''));
// get previous and next charts
chart.previousWeek = getNeighboringChart($('.dropdown__date-selector-option '), NeighboringWeek.Previous);
chart.nextWeek = getNeighboringChart($('.dropdown__date-selector-option '), NeighboringWeek.Next);
// push remaining ranked songs into chart.songs array
$('.chart-list-item').each(function(index, item) {
var rank = index + 1;
chart.songs.push({
"rank": rank,
"title": getTitleFromChartItem(item),
"artist": getArtistFromChartItem(item),
"cover": getCoverFromChartItem(item, rank),
"position" : {
"positionLastWeek": getPositionLastWeekFromChartItem(item),
"peakPosition": getPeakPositionFromChartItem(item),
"weeksOnChart": getWeeksOnChartFromChartItem(item)
}
});
});
// callback with chart if chart.songs array was populated
if (chart.songs.length > 1){
cb(null, chart);
return;
} else {
cb("Songs not found.", null);
return;
}
});
}
|
javascript
|
function getChart(chartName, date, cb) {
// check if chart was specified
if (typeof chartName === 'function') {
// if chartName not specified, default to hot-100 chart for current week,
// and set callback method accordingly
cb = chartName;
chartName = 'hot-100';
date = '';
}
// check if date was specified
if (typeof date === 'function') {
// if date not specified, default to specified chart for current week,
// and set callback method accordingly
cb = date;
date = '';
}
var chart = {};
/**
* A song
* @typedef {Object} Song
* @property {string} title - The title of the song
* @property {string} artist - The song's artist
*/
/**
* Array of songs
*/
chart.songs = [];
// build request URL string for specified chart and date
var requestURL = BILLBOARD_CHARTS_URL + chartName + '/' + date;
request(requestURL, function completedRequest(error, response, html) {
if (error) {
cb(error, null);
return;
}
var $ = cheerio.load(html);
// get chart week
chart.week = yyyymmddDateFromMonthDayYearDate($('.chart-detail-header__date-selector-button')[0].children[0].data.replace(/\n/g, ''));
// get previous and next charts
chart.previousWeek = getNeighboringChart($('.dropdown__date-selector-option '), NeighboringWeek.Previous);
chart.nextWeek = getNeighboringChart($('.dropdown__date-selector-option '), NeighboringWeek.Next);
// push remaining ranked songs into chart.songs array
$('.chart-list-item').each(function(index, item) {
var rank = index + 1;
chart.songs.push({
"rank": rank,
"title": getTitleFromChartItem(item),
"artist": getArtistFromChartItem(item),
"cover": getCoverFromChartItem(item, rank),
"position" : {
"positionLastWeek": getPositionLastWeekFromChartItem(item),
"peakPosition": getPeakPositionFromChartItem(item),
"weeksOnChart": getWeeksOnChartFromChartItem(item)
}
});
});
// callback with chart if chart.songs array was populated
if (chart.songs.length > 1){
cb(null, chart);
return;
} else {
cb("Songs not found.", null);
return;
}
});
}
|
[
"function",
"getChart",
"(",
"chartName",
",",
"date",
",",
"cb",
")",
"{",
"// check if chart was specified",
"if",
"(",
"typeof",
"chartName",
"===",
"'function'",
")",
"{",
"// if chartName not specified, default to hot-100 chart for current week, ",
"// and set callback method accordingly",
"cb",
"=",
"chartName",
";",
"chartName",
"=",
"'hot-100'",
";",
"date",
"=",
"''",
";",
"}",
"// check if date was specified",
"if",
"(",
"typeof",
"date",
"===",
"'function'",
")",
"{",
"// if date not specified, default to specified chart for current week, ",
"// and set callback method accordingly",
"cb",
"=",
"date",
";",
"date",
"=",
"''",
";",
"}",
"var",
"chart",
"=",
"{",
"}",
";",
"/**\n\t * A song\n\t * @typedef {Object} Song\n\t * @property {string} title - The title of the song\n\t * @property {string} artist - The song's artist\n\t */",
"/**\n\t * Array of songs\n\t */",
"chart",
".",
"songs",
"=",
"[",
"]",
";",
"// build request URL string for specified chart and date",
"var",
"requestURL",
"=",
"BILLBOARD_CHARTS_URL",
"+",
"chartName",
"+",
"'/'",
"+",
"date",
";",
"request",
"(",
"requestURL",
",",
"function",
"completedRequest",
"(",
"error",
",",
"response",
",",
"html",
")",
"{",
"if",
"(",
"error",
")",
"{",
"cb",
"(",
"error",
",",
"null",
")",
";",
"return",
";",
"}",
"var",
"$",
"=",
"cheerio",
".",
"load",
"(",
"html",
")",
";",
"// get chart week",
"chart",
".",
"week",
"=",
"yyyymmddDateFromMonthDayYearDate",
"(",
"$",
"(",
"'.chart-detail-header__date-selector-button'",
")",
"[",
"0",
"]",
".",
"children",
"[",
"0",
"]",
".",
"data",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"''",
")",
")",
";",
"// get previous and next charts",
"chart",
".",
"previousWeek",
"=",
"getNeighboringChart",
"(",
"$",
"(",
"'.dropdown__date-selector-option '",
")",
",",
"NeighboringWeek",
".",
"Previous",
")",
";",
"chart",
".",
"nextWeek",
"=",
"getNeighboringChart",
"(",
"$",
"(",
"'.dropdown__date-selector-option '",
")",
",",
"NeighboringWeek",
".",
"Next",
")",
";",
"// push remaining ranked songs into chart.songs array",
"$",
"(",
"'.chart-list-item'",
")",
".",
"each",
"(",
"function",
"(",
"index",
",",
"item",
")",
"{",
"var",
"rank",
"=",
"index",
"+",
"1",
";",
"chart",
".",
"songs",
".",
"push",
"(",
"{",
"\"rank\"",
":",
"rank",
",",
"\"title\"",
":",
"getTitleFromChartItem",
"(",
"item",
")",
",",
"\"artist\"",
":",
"getArtistFromChartItem",
"(",
"item",
")",
",",
"\"cover\"",
":",
"getCoverFromChartItem",
"(",
"item",
",",
"rank",
")",
",",
"\"position\"",
":",
"{",
"\"positionLastWeek\"",
":",
"getPositionLastWeekFromChartItem",
"(",
"item",
")",
",",
"\"peakPosition\"",
":",
"getPeakPositionFromChartItem",
"(",
"item",
")",
",",
"\"weeksOnChart\"",
":",
"getWeeksOnChartFromChartItem",
"(",
"item",
")",
"}",
"}",
")",
";",
"}",
")",
";",
"// callback with chart if chart.songs array was populated",
"if",
"(",
"chart",
".",
"songs",
".",
"length",
">",
"1",
")",
"{",
"cb",
"(",
"null",
",",
"chart",
")",
";",
"return",
";",
"}",
"else",
"{",
"cb",
"(",
"\"Songs not found.\"",
",",
"null",
")",
";",
"return",
";",
"}",
"}",
")",
";",
"}"
] |
Gets information for specified chart and date
@param {string} chartName - The specified chart
@param {string} date - Date represented as string in format 'YYYY-MM-DD'
@param {function} cb - The specified callback method
@example
getChart('hot-100', '2016-08-27', function(err, chart) {...})
|
[
"Gets",
"information",
"for",
"specified",
"chart",
"and",
"date"
] |
6169e74bda974c004575dd71f28d50eb07aa1dcf
|
https://github.com/darthbatman/billboard-top-100/blob/6169e74bda974c004575dd71f28d50eb07aa1dcf/billboard-top-100.js#L307-L373
|
9,782
|
darthbatman/billboard-top-100
|
billboard-top-100.js
|
listCharts
|
function listCharts(cb) {
if (typeof cb !== 'function') {
cb('Specified callback is not a function.', null);
return;
}
request(BILLBOARD_CHARTS_URL, function completedRequest(error, response, html) {
if (error) {
cb(error, null);
return;
}
var $ = cheerio.load(html);
/**
* A chart
* @typedef {Object} Chart
* @property {string} name - The name of the chart
* @property {string} url - The url of the chat
*/
/**
* Array of charts
*/
var charts = [];
// push charts into charts array
$('.chart-panel__link').each(function(index, item) {
var chart = {};
chart.name = toTitleCase($(this)[0].attribs.href.replace('/charts/', '').replace(/-/g, ' '));
chart.url = "https://www.billboard.com" + $(this)[0].attribs.href;
charts.push(chart);
});
// callback with charts if charts array was populated
if (charts.length > 0){
cb(null, charts);
return;
} else {
cb("No charts found.", null);
return;
}
});
}
|
javascript
|
function listCharts(cb) {
if (typeof cb !== 'function') {
cb('Specified callback is not a function.', null);
return;
}
request(BILLBOARD_CHARTS_URL, function completedRequest(error, response, html) {
if (error) {
cb(error, null);
return;
}
var $ = cheerio.load(html);
/**
* A chart
* @typedef {Object} Chart
* @property {string} name - The name of the chart
* @property {string} url - The url of the chat
*/
/**
* Array of charts
*/
var charts = [];
// push charts into charts array
$('.chart-panel__link').each(function(index, item) {
var chart = {};
chart.name = toTitleCase($(this)[0].attribs.href.replace('/charts/', '').replace(/-/g, ' '));
chart.url = "https://www.billboard.com" + $(this)[0].attribs.href;
charts.push(chart);
});
// callback with charts if charts array was populated
if (charts.length > 0){
cb(null, charts);
return;
} else {
cb("No charts found.", null);
return;
}
});
}
|
[
"function",
"listCharts",
"(",
"cb",
")",
"{",
"if",
"(",
"typeof",
"cb",
"!==",
"'function'",
")",
"{",
"cb",
"(",
"'Specified callback is not a function.'",
",",
"null",
")",
";",
"return",
";",
"}",
"request",
"(",
"BILLBOARD_CHARTS_URL",
",",
"function",
"completedRequest",
"(",
"error",
",",
"response",
",",
"html",
")",
"{",
"if",
"(",
"error",
")",
"{",
"cb",
"(",
"error",
",",
"null",
")",
";",
"return",
";",
"}",
"var",
"$",
"=",
"cheerio",
".",
"load",
"(",
"html",
")",
";",
"/**\n\t\t * A chart\n\t\t * @typedef {Object} Chart\n\t\t * @property {string} name - The name of the chart\n\t\t * @property {string} url - The url of the chat\n\t\t */",
"/**\n\t\t * Array of charts\n\t\t */",
"var",
"charts",
"=",
"[",
"]",
";",
"// push charts into charts array",
"$",
"(",
"'.chart-panel__link'",
")",
".",
"each",
"(",
"function",
"(",
"index",
",",
"item",
")",
"{",
"var",
"chart",
"=",
"{",
"}",
";",
"chart",
".",
"name",
"=",
"toTitleCase",
"(",
"$",
"(",
"this",
")",
"[",
"0",
"]",
".",
"attribs",
".",
"href",
".",
"replace",
"(",
"'/charts/'",
",",
"''",
")",
".",
"replace",
"(",
"/",
"-",
"/",
"g",
",",
"' '",
")",
")",
";",
"chart",
".",
"url",
"=",
"\"https://www.billboard.com\"",
"+",
"$",
"(",
"this",
")",
"[",
"0",
"]",
".",
"attribs",
".",
"href",
";",
"charts",
".",
"push",
"(",
"chart",
")",
";",
"}",
")",
";",
"// callback with charts if charts array was populated",
"if",
"(",
"charts",
".",
"length",
">",
"0",
")",
"{",
"cb",
"(",
"null",
",",
"charts",
")",
";",
"return",
";",
"}",
"else",
"{",
"cb",
"(",
"\"No charts found.\"",
",",
"null",
")",
";",
"return",
";",
"}",
"}",
")",
";",
"}"
] |
Gets all charts available via Billboard
@param {string} chart - The specified chart
@param {string} date - Date represented as string in format 'YYYY-MM-DD'
@param {function} cb - The specified callback method
@example
listCharts(function(err, charts) {...})
|
[
"Gets",
"all",
"charts",
"available",
"via",
"Billboard"
] |
6169e74bda974c004575dd71f28d50eb07aa1dcf
|
https://github.com/darthbatman/billboard-top-100/blob/6169e74bda974c004575dd71f28d50eb07aa1dcf/billboard-top-100.js#L386-L424
|
9,783
|
woocommerce/wc-api-node
|
index.js
|
WooCommerceAPI
|
function WooCommerceAPI(opt) {
if (!(this instanceof WooCommerceAPI)) {
return new WooCommerceAPI(opt);
}
opt = opt || {};
if (!(opt.url)) {
throw new Error('url is required');
}
if (!(opt.consumerKey)) {
throw new Error('consumerKey is required');
}
if (!(opt.consumerSecret)) {
throw new Error('consumerSecret is required');
}
this.classVersion = '1.4.2';
this._setDefaultsOptions(opt);
}
|
javascript
|
function WooCommerceAPI(opt) {
if (!(this instanceof WooCommerceAPI)) {
return new WooCommerceAPI(opt);
}
opt = opt || {};
if (!(opt.url)) {
throw new Error('url is required');
}
if (!(opt.consumerKey)) {
throw new Error('consumerKey is required');
}
if (!(opt.consumerSecret)) {
throw new Error('consumerSecret is required');
}
this.classVersion = '1.4.2';
this._setDefaultsOptions(opt);
}
|
[
"function",
"WooCommerceAPI",
"(",
"opt",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"WooCommerceAPI",
")",
")",
"{",
"return",
"new",
"WooCommerceAPI",
"(",
"opt",
")",
";",
"}",
"opt",
"=",
"opt",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"(",
"opt",
".",
"url",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'url is required'",
")",
";",
"}",
"if",
"(",
"!",
"(",
"opt",
".",
"consumerKey",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'consumerKey is required'",
")",
";",
"}",
"if",
"(",
"!",
"(",
"opt",
".",
"consumerSecret",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'consumerSecret is required'",
")",
";",
"}",
"this",
".",
"classVersion",
"=",
"'1.4.2'",
";",
"this",
".",
"_setDefaultsOptions",
"(",
"opt",
")",
";",
"}"
] |
WooCommerce REST API wrapper
@param {Object} opt
|
[
"WooCommerce",
"REST",
"API",
"wrapper"
] |
0844e882ffd675bcae489d89621fb39350eec483
|
https://github.com/woocommerce/wc-api-node/blob/0844e882ffd675bcae489d89621fb39350eec483/index.js#L16-L37
|
9,784
|
salsify/ember-css-modules
|
lib/resolve-path.js
|
resolveExternalPath
|
function resolveExternalPath(importPath, options) {
let baseIndex = importPath[0] === '@' ? importPath.indexOf('/') + 1 : 0;
let addonName = importPath.substring(0, importPath.indexOf('/', baseIndex));
let addon = options.parent.addons.find(addon => addon.name === addonName);
if (!addon) {
throw new Error(`Unable to resolve styles from addon ${addonName}; is it installed?`);
}
let pathWithinAddon = importPath.substring(addonName.length + 1);
let addonTreePath = path.join(addon.root, addon.treePaths.addon);
let absolutePath = ensurePosixPath(path.resolve(addonTreePath, pathWithinAddon));
let keyPath = options.addonModulesRoot + addonName + '/' + pathWithinAddon;
return new DependencyPath('external', absolutePath, keyPath);
}
|
javascript
|
function resolveExternalPath(importPath, options) {
let baseIndex = importPath[0] === '@' ? importPath.indexOf('/') + 1 : 0;
let addonName = importPath.substring(0, importPath.indexOf('/', baseIndex));
let addon = options.parent.addons.find(addon => addon.name === addonName);
if (!addon) {
throw new Error(`Unable to resolve styles from addon ${addonName}; is it installed?`);
}
let pathWithinAddon = importPath.substring(addonName.length + 1);
let addonTreePath = path.join(addon.root, addon.treePaths.addon);
let absolutePath = ensurePosixPath(path.resolve(addonTreePath, pathWithinAddon));
let keyPath = options.addonModulesRoot + addonName + '/' + pathWithinAddon;
return new DependencyPath('external', absolutePath, keyPath);
}
|
[
"function",
"resolveExternalPath",
"(",
"importPath",
",",
"options",
")",
"{",
"let",
"baseIndex",
"=",
"importPath",
"[",
"0",
"]",
"===",
"'@'",
"?",
"importPath",
".",
"indexOf",
"(",
"'/'",
")",
"+",
"1",
":",
"0",
";",
"let",
"addonName",
"=",
"importPath",
".",
"substring",
"(",
"0",
",",
"importPath",
".",
"indexOf",
"(",
"'/'",
",",
"baseIndex",
")",
")",
";",
"let",
"addon",
"=",
"options",
".",
"parent",
".",
"addons",
".",
"find",
"(",
"addon",
"=>",
"addon",
".",
"name",
"===",
"addonName",
")",
";",
"if",
"(",
"!",
"addon",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"addonName",
"}",
"`",
")",
";",
"}",
"let",
"pathWithinAddon",
"=",
"importPath",
".",
"substring",
"(",
"addonName",
".",
"length",
"+",
"1",
")",
";",
"let",
"addonTreePath",
"=",
"path",
".",
"join",
"(",
"addon",
".",
"root",
",",
"addon",
".",
"treePaths",
".",
"addon",
")",
";",
"let",
"absolutePath",
"=",
"ensurePosixPath",
"(",
"path",
".",
"resolve",
"(",
"addonTreePath",
",",
"pathWithinAddon",
")",
")",
";",
"let",
"keyPath",
"=",
"options",
".",
"addonModulesRoot",
"+",
"addonName",
"+",
"'/'",
"+",
"pathWithinAddon",
";",
"return",
"new",
"DependencyPath",
"(",
"'external'",
",",
"absolutePath",
",",
"keyPath",
")",
";",
"}"
] |
Resolve absolute paths pointing to external addons
|
[
"Resolve",
"absolute",
"paths",
"pointing",
"to",
"external",
"addons"
] |
cb6b2bf03eb6512f7fa3f66bf886540a16fdbfdc
|
https://github.com/salsify/ember-css-modules/blob/cb6b2bf03eb6512f7fa3f66bf886540a16fdbfdc/lib/resolve-path.js#L40-L55
|
9,785
|
salsify/ember-css-modules
|
addon/decorators.js
|
isStage1ClassDescriptor
|
function isStage1ClassDescriptor(possibleDesc) {
let [target] = possibleDesc;
return (
possibleDesc.length === 1 &&
typeof target === 'function' &&
'prototype' in target &&
!target.__isComputedDecorator
);
}
|
javascript
|
function isStage1ClassDescriptor(possibleDesc) {
let [target] = possibleDesc;
return (
possibleDesc.length === 1 &&
typeof target === 'function' &&
'prototype' in target &&
!target.__isComputedDecorator
);
}
|
[
"function",
"isStage1ClassDescriptor",
"(",
"possibleDesc",
")",
"{",
"let",
"[",
"target",
"]",
"=",
"possibleDesc",
";",
"return",
"(",
"possibleDesc",
".",
"length",
"===",
"1",
"&&",
"typeof",
"target",
"===",
"'function'",
"&&",
"'prototype'",
"in",
"target",
"&&",
"!",
"target",
".",
"__isComputedDecorator",
")",
";",
"}"
] |
These utilities are from @ember-decorators/utils https://github.com/ember-decorators/ember-decorators/blob/f3e3d636a38d99992af326a1012d69bf10a2cb4c/packages/utils/addon/-private/class-field-descriptor.js
|
[
"These",
"utilities",
"are",
"from"
] |
cb6b2bf03eb6512f7fa3f66bf886540a16fdbfdc
|
https://github.com/salsify/ember-css-modules/blob/cb6b2bf03eb6512f7fa3f66bf886540a16fdbfdc/addon/decorators.js#L126-L135
|
9,786
|
madebymany/sir-trevor-js
|
src/block_mixins/droppable.js
|
function() {
this.inner.setAttribute('tabindex', 0);
this.inner.addEventListener('keyup', (e) => {
if (e.target !== this.inner) { return; }
switch(e.keyCode) {
case 13:
this.mediator.trigger("block:create", 'Text', null, this.el, { autoFocus: true });
break;
case 8:
this.onDeleteClick.call(this, new CustomEvent('click'));
return;
}
});
}
|
javascript
|
function() {
this.inner.setAttribute('tabindex', 0);
this.inner.addEventListener('keyup', (e) => {
if (e.target !== this.inner) { return; }
switch(e.keyCode) {
case 13:
this.mediator.trigger("block:create", 'Text', null, this.el, { autoFocus: true });
break;
case 8:
this.onDeleteClick.call(this, new CustomEvent('click'));
return;
}
});
}
|
[
"function",
"(",
")",
"{",
"this",
".",
"inner",
".",
"setAttribute",
"(",
"'tabindex'",
",",
"0",
")",
";",
"this",
".",
"inner",
".",
"addEventListener",
"(",
"'keyup'",
",",
"(",
"e",
")",
"=>",
"{",
"if",
"(",
"e",
".",
"target",
"!==",
"this",
".",
"inner",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"e",
".",
"keyCode",
")",
"{",
"case",
"13",
":",
"this",
".",
"mediator",
".",
"trigger",
"(",
"\"block:create\"",
",",
"'Text'",
",",
"null",
",",
"this",
".",
"el",
",",
"{",
"autoFocus",
":",
"true",
"}",
")",
";",
"break",
";",
"case",
"8",
":",
"this",
".",
"onDeleteClick",
".",
"call",
"(",
"this",
",",
"new",
"CustomEvent",
"(",
"'click'",
")",
")",
";",
"return",
";",
"}",
"}",
")",
";",
"}"
] |
Allow this block to be managed with the keyboard
|
[
"Allow",
"this",
"block",
"to",
"be",
"managed",
"with",
"the",
"keyboard"
] |
1e604eb0715ba4b78ed20e8a0eef0abb76985edb
|
https://github.com/madebymany/sir-trevor-js/blob/1e604eb0715ba4b78ed20e8a0eef0abb76985edb/src/block_mixins/droppable.js#L73-L87
|
|
9,787
|
madebymany/sir-trevor-js
|
examples/javascript/example_block.js
|
function(){
var dataObj = {};
var content = this.getTextBlock().html();
if (content.length > 0) {
dataObj.text = SirTrevor.toMarkdown(content, this.type);
}
this.setData(dataObj);
}
|
javascript
|
function(){
var dataObj = {};
var content = this.getTextBlock().html();
if (content.length > 0) {
dataObj.text = SirTrevor.toMarkdown(content, this.type);
}
this.setData(dataObj);
}
|
[
"function",
"(",
")",
"{",
"var",
"dataObj",
"=",
"{",
"}",
";",
"var",
"content",
"=",
"this",
".",
"getTextBlock",
"(",
")",
".",
"html",
"(",
")",
";",
"if",
"(",
"content",
".",
"length",
">",
"0",
")",
"{",
"dataObj",
".",
"text",
"=",
"SirTrevor",
".",
"toMarkdown",
"(",
"content",
",",
"this",
".",
"type",
")",
";",
"}",
"this",
".",
"setData",
"(",
"dataObj",
")",
";",
"}"
] |
Function; Executed on save of the block, once the block is validated toData expects a way for the block to be transformed from inputs into structured data The default toData function provides a pretty comprehensive way of turning data into JSON In this example we take the text data and save it to the data object on the block
|
[
"Function",
";",
"Executed",
"on",
"save",
"of",
"the",
"block",
"once",
"the",
"block",
"is",
"validated",
"toData",
"expects",
"a",
"way",
"for",
"the",
"block",
"to",
"be",
"transformed",
"from",
"inputs",
"into",
"structured",
"data",
"The",
"default",
"toData",
"function",
"provides",
"a",
"pretty",
"comprehensive",
"way",
"of",
"turning",
"data",
"into",
"JSON",
"In",
"this",
"example",
"we",
"take",
"the",
"text",
"data",
"and",
"save",
"it",
"to",
"the",
"data",
"object",
"on",
"the",
"block"
] |
1e604eb0715ba4b78ed20e8a0eef0abb76985edb
|
https://github.com/madebymany/sir-trevor-js/blob/1e604eb0715ba4b78ed20e8a0eef0abb76985edb/examples/javascript/example_block.js#L126-L135
|
|
9,788
|
madebymany/sir-trevor-js
|
src/blocks/scribe-plugins/scribe-paste-plugin.js
|
removeWrappingParagraphForFirefox
|
function removeWrappingParagraphForFirefox(value) {
var fakeContent = document.createElement('div');
fakeContent.innerHTML = value;
if (fakeContent.childNodes.length === 1) {
var node = [].slice.call(fakeContent.childNodes)[0];
if (node && node.nodeName === "P") {
value = node.innerHTML;
}
}
return value;
}
|
javascript
|
function removeWrappingParagraphForFirefox(value) {
var fakeContent = document.createElement('div');
fakeContent.innerHTML = value;
if (fakeContent.childNodes.length === 1) {
var node = [].slice.call(fakeContent.childNodes)[0];
if (node && node.nodeName === "P") {
value = node.innerHTML;
}
}
return value;
}
|
[
"function",
"removeWrappingParagraphForFirefox",
"(",
"value",
")",
"{",
"var",
"fakeContent",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"fakeContent",
".",
"innerHTML",
"=",
"value",
";",
"if",
"(",
"fakeContent",
".",
"childNodes",
".",
"length",
"===",
"1",
")",
"{",
"var",
"node",
"=",
"[",
"]",
".",
"slice",
".",
"call",
"(",
"fakeContent",
".",
"childNodes",
")",
"[",
"0",
"]",
";",
"if",
"(",
"node",
"&&",
"node",
".",
"nodeName",
"===",
"\"P\"",
")",
"{",
"value",
"=",
"node",
".",
"innerHTML",
";",
"}",
"}",
"return",
"value",
";",
"}"
] |
In firefox when you paste any text is wraps in a paragraph block which we don't want.
|
[
"In",
"firefox",
"when",
"you",
"paste",
"any",
"text",
"is",
"wraps",
"in",
"a",
"paragraph",
"block",
"which",
"we",
"don",
"t",
"want",
"."
] |
1e604eb0715ba4b78ed20e8a0eef0abb76985edb
|
https://github.com/madebymany/sir-trevor-js/blob/1e604eb0715ba4b78ed20e8a0eef0abb76985edb/src/blocks/scribe-plugins/scribe-paste-plugin.js#L28-L40
|
9,789
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
eachObj
|
function eachObj(obj, iteratee, context) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
iteratee.call(context || obj, key, obj[key]);
}
}
}
|
javascript
|
function eachObj(obj, iteratee, context) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
iteratee.call(context || obj, key, obj[key]);
}
}
}
|
[
"function",
"eachObj",
"(",
"obj",
",",
"iteratee",
",",
"context",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"iteratee",
".",
"call",
"(",
"context",
"||",
"obj",
",",
"key",
",",
"obj",
"[",
"key",
"]",
")",
";",
"}",
"}",
"}"
] |
Iterates over elements of object invokes iteratee for each element
@param {object} obj Collection object
@param {function} iteratee Callback function called in iterative processing
@param {any} context This arg (aka Context)
|
[
"Iterates",
"over",
"elements",
"of",
"object",
"invokes",
"iteratee",
"for",
"each",
"element"
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L146-L152
|
9,790
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
jsxTagName
|
function jsxTagName(tagName) {
var name = tagName.toLowerCase();
if (ELEMENT_TAG_NAME_MAPPING.hasOwnProperty(name)) {
name = ELEMENT_TAG_NAME_MAPPING[name];
}
return name;
}
|
javascript
|
function jsxTagName(tagName) {
var name = tagName.toLowerCase();
if (ELEMENT_TAG_NAME_MAPPING.hasOwnProperty(name)) {
name = ELEMENT_TAG_NAME_MAPPING[name];
}
return name;
}
|
[
"function",
"jsxTagName",
"(",
"tagName",
")",
"{",
"var",
"name",
"=",
"tagName",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"ELEMENT_TAG_NAME_MAPPING",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"name",
"=",
"ELEMENT_TAG_NAME_MAPPING",
"[",
"name",
"]",
";",
"}",
"return",
"name",
";",
"}"
] |
Convert tag name to tag name suitable for JSX.
@param {string} tagName String of tag name
@return {string}
|
[
"Convert",
"tag",
"name",
"to",
"tag",
"name",
"suitable",
"for",
"JSX",
"."
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L174-L182
|
9,791
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
trimEnd
|
function trimEnd(haystack, needle) {
return endsWith(haystack, needle)
? haystack.slice(0, -needle.length)
: haystack;
}
|
javascript
|
function trimEnd(haystack, needle) {
return endsWith(haystack, needle)
? haystack.slice(0, -needle.length)
: haystack;
}
|
[
"function",
"trimEnd",
"(",
"haystack",
",",
"needle",
")",
"{",
"return",
"endsWith",
"(",
"haystack",
",",
"needle",
")",
"?",
"haystack",
".",
"slice",
"(",
"0",
",",
"-",
"needle",
".",
"length",
")",
":",
"haystack",
";",
"}"
] |
Trim the specified substring off the string. If the string does not end
with the specified substring, this is a no-op.
@param {string} haystack String to search in
@param {string} needle String to search for
@return {string}
|
[
"Trim",
"the",
"specified",
"substring",
"off",
"the",
"string",
".",
"If",
"the",
"string",
"does",
"not",
"end",
"with",
"the",
"specified",
"substring",
"this",
"is",
"a",
"no",
"-",
"op",
"."
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L229-L233
|
9,792
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
isNumeric
|
function isNumeric(input) {
return input !== undefined
&& input !== null
&& (typeof input === 'number' || parseInt(input, 10) == input);
}
|
javascript
|
function isNumeric(input) {
return input !== undefined
&& input !== null
&& (typeof input === 'number' || parseInt(input, 10) == input);
}
|
[
"function",
"isNumeric",
"(",
"input",
")",
"{",
"return",
"input",
"!==",
"undefined",
"&&",
"input",
"!==",
"null",
"&&",
"(",
"typeof",
"input",
"===",
"'number'",
"||",
"parseInt",
"(",
"input",
",",
"10",
")",
"==",
"input",
")",
";",
"}"
] |
Determines if the specified string consists entirely of numeric characters.
|
[
"Determines",
"if",
"the",
"specified",
"string",
"consists",
"entirely",
"of",
"numeric",
"characters",
"."
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L265-L269
|
9,793
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
function (html) {
this.reset();
var containerEl = createElement('div');
containerEl.innerHTML = '\n' + this._cleanInput(html) + '\n';
if (this.config.createClass) {
if (this.config.outputClassName) {
this.output = 'var ' + this.config.outputClassName + ' = React.createClass({\n';
} else {
this.output = 'React.createClass({\n';
}
this.output += this.config.indent + 'render: function() {' + "\n";
this.output += this.config.indent + this.config.indent + 'return (\n';
}
if (this._onlyOneTopLevel(containerEl)) {
// Only one top-level element, the component can return it directly
// No need to actually visit the container element
this._traverse(containerEl);
} else {
// More than one top-level element, need to wrap the whole thing in a
// container.
this.output += this.config.indent + this.config.indent + this.config.indent;
this.level++;
this._visit(containerEl);
}
this.output = this.output.trim() + '\n';
if (this.config.createClass) {
this.output += this.config.indent + this.config.indent + ');\n';
this.output += this.config.indent + '}\n';
this.output += '});';
} else {
this.output = this._removeJSXClassIndention(this.output, this.config.indent);
}
return this.output;
}
|
javascript
|
function (html) {
this.reset();
var containerEl = createElement('div');
containerEl.innerHTML = '\n' + this._cleanInput(html) + '\n';
if (this.config.createClass) {
if (this.config.outputClassName) {
this.output = 'var ' + this.config.outputClassName + ' = React.createClass({\n';
} else {
this.output = 'React.createClass({\n';
}
this.output += this.config.indent + 'render: function() {' + "\n";
this.output += this.config.indent + this.config.indent + 'return (\n';
}
if (this._onlyOneTopLevel(containerEl)) {
// Only one top-level element, the component can return it directly
// No need to actually visit the container element
this._traverse(containerEl);
} else {
// More than one top-level element, need to wrap the whole thing in a
// container.
this.output += this.config.indent + this.config.indent + this.config.indent;
this.level++;
this._visit(containerEl);
}
this.output = this.output.trim() + '\n';
if (this.config.createClass) {
this.output += this.config.indent + this.config.indent + ');\n';
this.output += this.config.indent + '}\n';
this.output += '});';
} else {
this.output = this._removeJSXClassIndention(this.output, this.config.indent);
}
return this.output;
}
|
[
"function",
"(",
"html",
")",
"{",
"this",
".",
"reset",
"(",
")",
";",
"var",
"containerEl",
"=",
"createElement",
"(",
"'div'",
")",
";",
"containerEl",
".",
"innerHTML",
"=",
"'\\n'",
"+",
"this",
".",
"_cleanInput",
"(",
"html",
")",
"+",
"'\\n'",
";",
"if",
"(",
"this",
".",
"config",
".",
"createClass",
")",
"{",
"if",
"(",
"this",
".",
"config",
".",
"outputClassName",
")",
"{",
"this",
".",
"output",
"=",
"'var '",
"+",
"this",
".",
"config",
".",
"outputClassName",
"+",
"' = React.createClass({\\n'",
";",
"}",
"else",
"{",
"this",
".",
"output",
"=",
"'React.createClass({\\n'",
";",
"}",
"this",
".",
"output",
"+=",
"this",
".",
"config",
".",
"indent",
"+",
"'render: function() {'",
"+",
"\"\\n\"",
";",
"this",
".",
"output",
"+=",
"this",
".",
"config",
".",
"indent",
"+",
"this",
".",
"config",
".",
"indent",
"+",
"'return (\\n'",
";",
"}",
"if",
"(",
"this",
".",
"_onlyOneTopLevel",
"(",
"containerEl",
")",
")",
"{",
"// Only one top-level element, the component can return it directly",
"// No need to actually visit the container element",
"this",
".",
"_traverse",
"(",
"containerEl",
")",
";",
"}",
"else",
"{",
"// More than one top-level element, need to wrap the whole thing in a",
"// container.",
"this",
".",
"output",
"+=",
"this",
".",
"config",
".",
"indent",
"+",
"this",
".",
"config",
".",
"indent",
"+",
"this",
".",
"config",
".",
"indent",
";",
"this",
".",
"level",
"++",
";",
"this",
".",
"_visit",
"(",
"containerEl",
")",
";",
"}",
"this",
".",
"output",
"=",
"this",
".",
"output",
".",
"trim",
"(",
")",
"+",
"'\\n'",
";",
"if",
"(",
"this",
".",
"config",
".",
"createClass",
")",
"{",
"this",
".",
"output",
"+=",
"this",
".",
"config",
".",
"indent",
"+",
"this",
".",
"config",
".",
"indent",
"+",
"');\\n'",
";",
"this",
".",
"output",
"+=",
"this",
".",
"config",
".",
"indent",
"+",
"'}\\n'",
";",
"this",
".",
"output",
"+=",
"'});'",
";",
"}",
"else",
"{",
"this",
".",
"output",
"=",
"this",
".",
"_removeJSXClassIndention",
"(",
"this",
".",
"output",
",",
"this",
".",
"config",
".",
"indent",
")",
";",
"}",
"return",
"this",
".",
"output",
";",
"}"
] |
Main entry point to the converter. Given the specified HTML, returns a
JSX object representing it.
@param {string} html HTML to convert
@return {string} JSX
|
[
"Main",
"entry",
"point",
"to",
"the",
"converter",
".",
"Given",
"the",
"specified",
"HTML",
"returns",
"a",
"JSX",
"object",
"representing",
"it",
"."
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L326-L362
|
|
9,794
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
function (containerEl) {
// Only a single child element
if (
containerEl.childNodes.length === 1
&& containerEl.childNodes[0].nodeType === NODE_TYPE.ELEMENT
) {
return true;
}
// Only one element, and all other children are whitespace
var foundElement = false;
for (var i = 0, count = containerEl.childNodes.length; i < count; i++) {
var child = containerEl.childNodes[i];
if (child.nodeType === NODE_TYPE.ELEMENT) {
if (foundElement) {
// Encountered an element after already encountering another one
// Therefore, more than one element at root level
return false;
} else {
foundElement = true;
}
} else if (child.nodeType === NODE_TYPE.TEXT && !isEmpty(child.textContent)) {
// Contains text content
return false;
}
}
return true;
}
|
javascript
|
function (containerEl) {
// Only a single child element
if (
containerEl.childNodes.length === 1
&& containerEl.childNodes[0].nodeType === NODE_TYPE.ELEMENT
) {
return true;
}
// Only one element, and all other children are whitespace
var foundElement = false;
for (var i = 0, count = containerEl.childNodes.length; i < count; i++) {
var child = containerEl.childNodes[i];
if (child.nodeType === NODE_TYPE.ELEMENT) {
if (foundElement) {
// Encountered an element after already encountering another one
// Therefore, more than one element at root level
return false;
} else {
foundElement = true;
}
} else if (child.nodeType === NODE_TYPE.TEXT && !isEmpty(child.textContent)) {
// Contains text content
return false;
}
}
return true;
}
|
[
"function",
"(",
"containerEl",
")",
"{",
"// Only a single child element",
"if",
"(",
"containerEl",
".",
"childNodes",
".",
"length",
"===",
"1",
"&&",
"containerEl",
".",
"childNodes",
"[",
"0",
"]",
".",
"nodeType",
"===",
"NODE_TYPE",
".",
"ELEMENT",
")",
"{",
"return",
"true",
";",
"}",
"// Only one element, and all other children are whitespace",
"var",
"foundElement",
"=",
"false",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"count",
"=",
"containerEl",
".",
"childNodes",
".",
"length",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"var",
"child",
"=",
"containerEl",
".",
"childNodes",
"[",
"i",
"]",
";",
"if",
"(",
"child",
".",
"nodeType",
"===",
"NODE_TYPE",
".",
"ELEMENT",
")",
"{",
"if",
"(",
"foundElement",
")",
"{",
"// Encountered an element after already encountering another one",
"// Therefore, more than one element at root level",
"return",
"false",
";",
"}",
"else",
"{",
"foundElement",
"=",
"true",
";",
"}",
"}",
"else",
"if",
"(",
"child",
".",
"nodeType",
"===",
"NODE_TYPE",
".",
"TEXT",
"&&",
"!",
"isEmpty",
"(",
"child",
".",
"textContent",
")",
")",
"{",
"// Contains text content",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Determines if there's only one top-level node in the DOM tree. That is,
all the HTML is wrapped by a single HTML tag.
@param {DOMElement} containerEl Container element
@return {boolean}
|
[
"Determines",
"if",
"there",
"s",
"only",
"one",
"top",
"-",
"level",
"node",
"in",
"the",
"DOM",
"tree",
".",
"That",
"is",
"all",
"the",
"HTML",
"is",
"wrapped",
"by",
"a",
"single",
"HTML",
"tag",
"."
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L387-L413
|
|
9,795
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
function (node) {
this.level++;
for (var i = 0, count = node.childNodes.length; i < count; i++) {
this._visit(node.childNodes[i]);
}
this.level--;
}
|
javascript
|
function (node) {
this.level++;
for (var i = 0, count = node.childNodes.length; i < count; i++) {
this._visit(node.childNodes[i]);
}
this.level--;
}
|
[
"function",
"(",
"node",
")",
"{",
"this",
".",
"level",
"++",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"count",
"=",
"node",
".",
"childNodes",
".",
"length",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"this",
".",
"_visit",
"(",
"node",
".",
"childNodes",
"[",
"i",
"]",
")",
";",
"}",
"this",
".",
"level",
"--",
";",
"}"
] |
Traverses all the children of the specified node
@param {Node} node
|
[
"Traverses",
"all",
"the",
"children",
"of",
"the",
"specified",
"node"
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L441-L447
|
|
9,796
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
function (node) {
switch (node.nodeType) {
case NODE_TYPE.ELEMENT:
this._beginVisitElement(node);
break;
case NODE_TYPE.TEXT:
this._visitText(node);
break;
case NODE_TYPE.COMMENT:
this._visitComment(node);
break;
default:
console.warn('Unrecognised node type: ' + node.nodeType);
}
}
|
javascript
|
function (node) {
switch (node.nodeType) {
case NODE_TYPE.ELEMENT:
this._beginVisitElement(node);
break;
case NODE_TYPE.TEXT:
this._visitText(node);
break;
case NODE_TYPE.COMMENT:
this._visitComment(node);
break;
default:
console.warn('Unrecognised node type: ' + node.nodeType);
}
}
|
[
"function",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"nodeType",
")",
"{",
"case",
"NODE_TYPE",
".",
"ELEMENT",
":",
"this",
".",
"_beginVisitElement",
"(",
"node",
")",
";",
"break",
";",
"case",
"NODE_TYPE",
".",
"TEXT",
":",
"this",
".",
"_visitText",
"(",
"node",
")",
";",
"break",
";",
"case",
"NODE_TYPE",
".",
"COMMENT",
":",
"this",
".",
"_visitComment",
"(",
"node",
")",
";",
"break",
";",
"default",
":",
"console",
".",
"warn",
"(",
"'Unrecognised node type: '",
"+",
"node",
".",
"nodeType",
")",
";",
"}",
"}"
] |
Handle pre-visit behaviour for the specified node.
@param {Node} node
|
[
"Handle",
"pre",
"-",
"visit",
"behaviour",
"for",
"the",
"specified",
"node",
"."
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L454-L471
|
|
9,797
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
function (node) {
switch (node.nodeType) {
case NODE_TYPE.ELEMENT:
this._endVisitElement(node);
break;
// No ending tags required for these types
case NODE_TYPE.TEXT:
case NODE_TYPE.COMMENT:
break;
}
}
|
javascript
|
function (node) {
switch (node.nodeType) {
case NODE_TYPE.ELEMENT:
this._endVisitElement(node);
break;
// No ending tags required for these types
case NODE_TYPE.TEXT:
case NODE_TYPE.COMMENT:
break;
}
}
|
[
"function",
"(",
"node",
")",
"{",
"switch",
"(",
"node",
".",
"nodeType",
")",
"{",
"case",
"NODE_TYPE",
".",
"ELEMENT",
":",
"this",
".",
"_endVisitElement",
"(",
"node",
")",
";",
"break",
";",
"// No ending tags required for these types",
"case",
"NODE_TYPE",
".",
"TEXT",
":",
"case",
"NODE_TYPE",
".",
"COMMENT",
":",
"break",
";",
"}",
"}"
] |
Handles post-visit behaviour for the specified node.
@param {Node} node
|
[
"Handles",
"post",
"-",
"visit",
"behaviour",
"for",
"the",
"specified",
"node",
"."
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L478-L488
|
|
9,798
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
function (node) {
var tagName = jsxTagName(node.tagName);
var attributes = [];
for (var i = 0, count = node.attributes.length; i < count; i++) {
attributes.push(this._getElementAttribute(node, node.attributes[i]));
}
if (tagName === 'textarea') {
// Hax: textareas need their inner text moved to a "defaultValue" attribute.
attributes.push('defaultValue={' + JSON.stringify(node.value) + '}');
}
if (tagName === 'style') {
// Hax: style tag contents need to be dangerously set due to liberal curly brace usage
attributes.push('dangerouslySetInnerHTML={{__html: ' + JSON.stringify(node.textContent) + ' }}');
}
if (tagName === 'pre') {
this._inPreTag = true;
}
this.output += '<' + tagName;
if (attributes.length > 0) {
this.output += ' ' + attributes.join(' ');
}
if (!this._isSelfClosing(node)) {
this.output += '>';
}
}
|
javascript
|
function (node) {
var tagName = jsxTagName(node.tagName);
var attributes = [];
for (var i = 0, count = node.attributes.length; i < count; i++) {
attributes.push(this._getElementAttribute(node, node.attributes[i]));
}
if (tagName === 'textarea') {
// Hax: textareas need their inner text moved to a "defaultValue" attribute.
attributes.push('defaultValue={' + JSON.stringify(node.value) + '}');
}
if (tagName === 'style') {
// Hax: style tag contents need to be dangerously set due to liberal curly brace usage
attributes.push('dangerouslySetInnerHTML={{__html: ' + JSON.stringify(node.textContent) + ' }}');
}
if (tagName === 'pre') {
this._inPreTag = true;
}
this.output += '<' + tagName;
if (attributes.length > 0) {
this.output += ' ' + attributes.join(' ');
}
if (!this._isSelfClosing(node)) {
this.output += '>';
}
}
|
[
"function",
"(",
"node",
")",
"{",
"var",
"tagName",
"=",
"jsxTagName",
"(",
"node",
".",
"tagName",
")",
";",
"var",
"attributes",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"count",
"=",
"node",
".",
"attributes",
".",
"length",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"attributes",
".",
"push",
"(",
"this",
".",
"_getElementAttribute",
"(",
"node",
",",
"node",
".",
"attributes",
"[",
"i",
"]",
")",
")",
";",
"}",
"if",
"(",
"tagName",
"===",
"'textarea'",
")",
"{",
"// Hax: textareas need their inner text moved to a \"defaultValue\" attribute.",
"attributes",
".",
"push",
"(",
"'defaultValue={'",
"+",
"JSON",
".",
"stringify",
"(",
"node",
".",
"value",
")",
"+",
"'}'",
")",
";",
"}",
"if",
"(",
"tagName",
"===",
"'style'",
")",
"{",
"// Hax: style tag contents need to be dangerously set due to liberal curly brace usage",
"attributes",
".",
"push",
"(",
"'dangerouslySetInnerHTML={{__html: '",
"+",
"JSON",
".",
"stringify",
"(",
"node",
".",
"textContent",
")",
"+",
"' }}'",
")",
";",
"}",
"if",
"(",
"tagName",
"===",
"'pre'",
")",
"{",
"this",
".",
"_inPreTag",
"=",
"true",
";",
"}",
"this",
".",
"output",
"+=",
"'<'",
"+",
"tagName",
";",
"if",
"(",
"attributes",
".",
"length",
">",
"0",
")",
"{",
"this",
".",
"output",
"+=",
"' '",
"+",
"attributes",
".",
"join",
"(",
"' '",
")",
";",
"}",
"if",
"(",
"!",
"this",
".",
"_isSelfClosing",
"(",
"node",
")",
")",
"{",
"this",
".",
"output",
"+=",
"'>'",
";",
"}",
"}"
] |
Handles pre-visit behaviour for the specified element node
@param {DOMElement} node
|
[
"Handles",
"pre",
"-",
"visit",
"behaviour",
"for",
"the",
"specified",
"element",
"node"
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L495-L521
|
|
9,799
|
roman01la/html-to-react-components
|
lib/html2jsx.js
|
function (node) {
var tagName = jsxTagName(node.tagName);
// De-indent a bit
// TODO: It's inefficient to do it this way :/
this.output = trimEnd(this.output, this.config.indent);
if (this._isSelfClosing(node)) {
this.output += ' />';
} else {
this.output += '</' + tagName + '>';
}
if (tagName === 'pre') {
this._inPreTag = false;
}
}
|
javascript
|
function (node) {
var tagName = jsxTagName(node.tagName);
// De-indent a bit
// TODO: It's inefficient to do it this way :/
this.output = trimEnd(this.output, this.config.indent);
if (this._isSelfClosing(node)) {
this.output += ' />';
} else {
this.output += '</' + tagName + '>';
}
if (tagName === 'pre') {
this._inPreTag = false;
}
}
|
[
"function",
"(",
"node",
")",
"{",
"var",
"tagName",
"=",
"jsxTagName",
"(",
"node",
".",
"tagName",
")",
";",
"// De-indent a bit",
"// TODO: It's inefficient to do it this way :/",
"this",
".",
"output",
"=",
"trimEnd",
"(",
"this",
".",
"output",
",",
"this",
".",
"config",
".",
"indent",
")",
";",
"if",
"(",
"this",
".",
"_isSelfClosing",
"(",
"node",
")",
")",
"{",
"this",
".",
"output",
"+=",
"' />'",
";",
"}",
"else",
"{",
"this",
".",
"output",
"+=",
"'</'",
"+",
"tagName",
"+",
"'>'",
";",
"}",
"if",
"(",
"tagName",
"===",
"'pre'",
")",
"{",
"this",
".",
"_inPreTag",
"=",
"false",
";",
"}",
"}"
] |
Handles post-visit behaviour for the specified element node
@param {Node} node
|
[
"Handles",
"post",
"-",
"visit",
"behaviour",
"for",
"the",
"specified",
"element",
"node"
] |
74b76fafbd0728f77c2bbe32a0b26a94e604442b
|
https://github.com/roman01la/html-to-react-components/blob/74b76fafbd0728f77c2bbe32a0b26a94e604442b/lib/html2jsx.js#L528-L542
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.