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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
13,600
|
bolt-design-system/bolt
|
packages/build-tools/plugins/postcss-themify/src/index.js
|
getSelectorName
|
function getSelectorName(rule, variationName, isFallbackSelector = false) {
const selectorPrefix = `.${options.classPrefix || ''}${variationName}`;
// console.log(variationName);
if (isFallbackSelector) {
return rule.selectors
.map(selector => {
let selectors = [];
let initialSelector = `${selectorPrefix} ${selector}`;
if (variationName === 'xlight') {
selectors.push(selector);
}
selectors.push(initialSelector);
selectors.push(`[class*="t-bolt-"] ${initialSelector}`);
return selectors.join(',');
})
.join(',');
} else {
return rule.selectors
.map(selector => {
return `${selectorPrefix} ${selector}`;
})
.join(',');
}
}
|
javascript
|
function getSelectorName(rule, variationName, isFallbackSelector = false) {
const selectorPrefix = `.${options.classPrefix || ''}${variationName}`;
// console.log(variationName);
if (isFallbackSelector) {
return rule.selectors
.map(selector => {
let selectors = [];
let initialSelector = `${selectorPrefix} ${selector}`;
if (variationName === 'xlight') {
selectors.push(selector);
}
selectors.push(initialSelector);
selectors.push(`[class*="t-bolt-"] ${initialSelector}`);
return selectors.join(',');
})
.join(',');
} else {
return rule.selectors
.map(selector => {
return `${selectorPrefix} ${selector}`;
})
.join(',');
}
}
|
[
"function",
"getSelectorName",
"(",
"rule",
",",
"variationName",
",",
"isFallbackSelector",
"=",
"false",
")",
"{",
"const",
"selectorPrefix",
"=",
"`",
"${",
"options",
".",
"classPrefix",
"||",
"''",
"}",
"${",
"variationName",
"}",
"`",
";",
"// console.log(variationName);",
"if",
"(",
"isFallbackSelector",
")",
"{",
"return",
"rule",
".",
"selectors",
".",
"map",
"(",
"selector",
"=>",
"{",
"let",
"selectors",
"=",
"[",
"]",
";",
"let",
"initialSelector",
"=",
"`",
"${",
"selectorPrefix",
"}",
"${",
"selector",
"}",
"`",
";",
"if",
"(",
"variationName",
"===",
"'xlight'",
")",
"{",
"selectors",
".",
"push",
"(",
"selector",
")",
";",
"}",
"selectors",
".",
"push",
"(",
"initialSelector",
")",
";",
"selectors",
".",
"push",
"(",
"`",
"${",
"initialSelector",
"}",
"`",
")",
";",
"return",
"selectors",
".",
"join",
"(",
"','",
")",
";",
"}",
")",
".",
"join",
"(",
"','",
")",
";",
"}",
"else",
"{",
"return",
"rule",
".",
"selectors",
".",
"map",
"(",
"selector",
"=>",
"{",
"return",
"`",
"${",
"selectorPrefix",
"}",
"${",
"selector",
"}",
"`",
";",
"}",
")",
".",
"join",
"(",
"','",
")",
";",
"}",
"}"
] |
Get a selector name for the given rule and variation, deliberately increasing
the CSS class's specificity when generating CSS selectors for IE 11 so we can
account for specificity conflicts when nesting themed components inside other
themes.
@param rule
@param variationName
@param isFallbackSelector
|
[
"Get",
"a",
"selector",
"name",
"for",
"the",
"given",
"rule",
"and",
"variation",
"deliberately",
"increasing",
"the",
"CSS",
"class",
"s",
"specificity",
"when",
"generating",
"CSS",
"selectors",
"for",
"IE",
"11",
"so",
"we",
"can",
"account",
"for",
"specificity",
"conflicts",
"when",
"nesting",
"themed",
"components",
"inside",
"other",
"themes",
"."
] |
c63ab37dbee8f35aa5472be2d9688f989b20fd21
|
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/plugins/postcss-themify/src/index.js#L505-L533
|
13,601
|
bolt-design-system/bolt
|
packages/build-tools/utils/log.js
|
errorAndExit
|
function errorAndExit(msg, logMe) {
// @todo Only trigger if `verbosity > 1`
if (logMe) {
// Adding some empty lines before error message for readability
console.log();
console.log();
console.log(logMe);
}
error(`Error: ${msg}`);
// There's a few ways to handle exiting
// This is suggested and it's nice b/c it let's I/O finish up, but if an error happens on a watch task, it doesn't exit, b/c this will exit once the event loop is empty.
// process.exitCode = 1;
// This stops everything instantly and guarantees a killed program, but there's comments on the InterWebs about how it can be bad b/c I/O (like file writes) might not be done yet. I also have suspicions that this can lead to child processes never getting killed and running indefinitely - perhaps what leads to ports not being available
// process.exit(1);
// From docs for `process.nextTick` : "Once the current turn of the event loop turn runs to completion, all callbacks currently in the next tick queue will be called. This is not a simple alias to setTimeout(fn, 0). It is much more efficient. It runs before any additional I/O events (including timers) fire in subsequent ticks of the event loop."
// This exits during watches correctly, and I *think* it'll let the I/O finish, but I'm not 100%
process.nextTick(() => {
process.exit(1);
});
}
|
javascript
|
function errorAndExit(msg, logMe) {
// @todo Only trigger if `verbosity > 1`
if (logMe) {
// Adding some empty lines before error message for readability
console.log();
console.log();
console.log(logMe);
}
error(`Error: ${msg}`);
// There's a few ways to handle exiting
// This is suggested and it's nice b/c it let's I/O finish up, but if an error happens on a watch task, it doesn't exit, b/c this will exit once the event loop is empty.
// process.exitCode = 1;
// This stops everything instantly and guarantees a killed program, but there's comments on the InterWebs about how it can be bad b/c I/O (like file writes) might not be done yet. I also have suspicions that this can lead to child processes never getting killed and running indefinitely - perhaps what leads to ports not being available
// process.exit(1);
// From docs for `process.nextTick` : "Once the current turn of the event loop turn runs to completion, all callbacks currently in the next tick queue will be called. This is not a simple alias to setTimeout(fn, 0). It is much more efficient. It runs before any additional I/O events (including timers) fire in subsequent ticks of the event loop."
// This exits during watches correctly, and I *think* it'll let the I/O finish, but I'm not 100%
process.nextTick(() => {
process.exit(1);
});
}
|
[
"function",
"errorAndExit",
"(",
"msg",
",",
"logMe",
")",
"{",
"// @todo Only trigger if `verbosity > 1`",
"if",
"(",
"logMe",
")",
"{",
"// Adding some empty lines before error message for readability",
"console",
".",
"log",
"(",
")",
";",
"console",
".",
"log",
"(",
")",
";",
"console",
".",
"log",
"(",
"logMe",
")",
";",
"}",
"error",
"(",
"`",
"${",
"msg",
"}",
"`",
")",
";",
"// There's a few ways to handle exiting",
"// This is suggested and it's nice b/c it let's I/O finish up, but if an error happens on a watch task, it doesn't exit, b/c this will exit once the event loop is empty.",
"// process.exitCode = 1;",
"// This stops everything instantly and guarantees a killed program, but there's comments on the InterWebs about how it can be bad b/c I/O (like file writes) might not be done yet. I also have suspicions that this can lead to child processes never getting killed and running indefinitely - perhaps what leads to ports not being available",
"// process.exit(1);",
"// From docs for `process.nextTick` : \"Once the current turn of the event loop turn runs to completion, all callbacks currently in the next tick queue will be called. This is not a simple alias to setTimeout(fn, 0). It is much more efficient. It runs before any additional I/O events (including timers) fire in subsequent ticks of the event loop.\"",
"// This exits during watches correctly, and I *think* it'll let the I/O finish, but I'm not 100%",
"process",
".",
"nextTick",
"(",
"(",
")",
"=>",
"{",
"process",
".",
"exit",
"(",
"1",
")",
";",
"}",
")",
";",
"}"
] |
Displays info, an error message, and then exits the cli
@param {string} msg - Message
@param {*} logMe - Passed to `console.log`
|
[
"Displays",
"info",
"an",
"error",
"message",
"and",
"then",
"exits",
"the",
"cli"
] |
c63ab37dbee8f35aa5472be2d9688f989b20fd21
|
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/log.js#L50-L73
|
13,602
|
bolt-design-system/bolt
|
packages/components/bolt-nav-indicator/nav-indicator.js
|
activateGumshoeLink
|
function activateGumshoeLink() {
const originalTarget = nav.nav;
let originalTargetHref;
let normalizedTarget;
if (originalTarget) {
originalTargetHref = originalTarget.getAttribute('href');
} else {
originalTargetHref = nav.nav.getAttribute('href');
}
// Need to target via document vs this custom element reference since only one gumshoe instance is shared across every component instance to better optimize for performance
const matchedTargetLinks = document.querySelectorAll(
`bolt-navlink > [href*="${originalTargetHref}"]`,
);
for (var i = 0, len = matchedTargetLinks.length; i < len; i++) {
const linkInstance = matchedTargetLinks[i];
// Stop if normalizedTarget already set.
if (normalizedTarget) {
break;
}
// Prefer visible links over hidden links
if (isVisible(linkInstance)) {
normalizedTarget = linkInstance;
// Prefer dropdown links over non-dropdown links if the link is hidden
} else if (linkInstance.parentNode.isDropdownLink) {
normalizedTarget = linkInstance;
// otherwise default to what was originally selected.
} else if (i === len - 1) {
normalizedTarget = originalTarget;
}
}
const normalizedParent = normalizedTarget.parentNode;
normalizedParent.activate();
}
|
javascript
|
function activateGumshoeLink() {
const originalTarget = nav.nav;
let originalTargetHref;
let normalizedTarget;
if (originalTarget) {
originalTargetHref = originalTarget.getAttribute('href');
} else {
originalTargetHref = nav.nav.getAttribute('href');
}
// Need to target via document vs this custom element reference since only one gumshoe instance is shared across every component instance to better optimize for performance
const matchedTargetLinks = document.querySelectorAll(
`bolt-navlink > [href*="${originalTargetHref}"]`,
);
for (var i = 0, len = matchedTargetLinks.length; i < len; i++) {
const linkInstance = matchedTargetLinks[i];
// Stop if normalizedTarget already set.
if (normalizedTarget) {
break;
}
// Prefer visible links over hidden links
if (isVisible(linkInstance)) {
normalizedTarget = linkInstance;
// Prefer dropdown links over non-dropdown links if the link is hidden
} else if (linkInstance.parentNode.isDropdownLink) {
normalizedTarget = linkInstance;
// otherwise default to what was originally selected.
} else if (i === len - 1) {
normalizedTarget = originalTarget;
}
}
const normalizedParent = normalizedTarget.parentNode;
normalizedParent.activate();
}
|
[
"function",
"activateGumshoeLink",
"(",
")",
"{",
"const",
"originalTarget",
"=",
"nav",
".",
"nav",
";",
"let",
"originalTargetHref",
";",
"let",
"normalizedTarget",
";",
"if",
"(",
"originalTarget",
")",
"{",
"originalTargetHref",
"=",
"originalTarget",
".",
"getAttribute",
"(",
"'href'",
")",
";",
"}",
"else",
"{",
"originalTargetHref",
"=",
"nav",
".",
"nav",
".",
"getAttribute",
"(",
"'href'",
")",
";",
"}",
"// Need to target via document vs this custom element reference since only one gumshoe instance is shared across every component instance to better optimize for performance",
"const",
"matchedTargetLinks",
"=",
"document",
".",
"querySelectorAll",
"(",
"`",
"${",
"originalTargetHref",
"}",
"`",
",",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"matchedTargetLinks",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"const",
"linkInstance",
"=",
"matchedTargetLinks",
"[",
"i",
"]",
";",
"// Stop if normalizedTarget already set.",
"if",
"(",
"normalizedTarget",
")",
"{",
"break",
";",
"}",
"// Prefer visible links over hidden links",
"if",
"(",
"isVisible",
"(",
"linkInstance",
")",
")",
"{",
"normalizedTarget",
"=",
"linkInstance",
";",
"// Prefer dropdown links over non-dropdown links if the link is hidden",
"}",
"else",
"if",
"(",
"linkInstance",
".",
"parentNode",
".",
"isDropdownLink",
")",
"{",
"normalizedTarget",
"=",
"linkInstance",
";",
"// otherwise default to what was originally selected.",
"}",
"else",
"if",
"(",
"i",
"===",
"len",
"-",
"1",
")",
"{",
"normalizedTarget",
"=",
"originalTarget",
";",
"}",
"}",
"const",
"normalizedParent",
"=",
"normalizedTarget",
".",
"parentNode",
";",
"normalizedParent",
".",
"activate",
"(",
")",
";",
"}"
] |
logic once we know we should try to animate in a gumshoe-activated link
|
[
"logic",
"once",
"we",
"know",
"we",
"should",
"try",
"to",
"animate",
"in",
"a",
"gumshoe",
"-",
"activated",
"link"
] |
c63ab37dbee8f35aa5472be2d9688f989b20fd21
|
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/components/bolt-nav-indicator/nav-indicator.js#L82-L123
|
13,603
|
bolt-design-system/bolt
|
packages/build-tools/utils/manifest.js
|
flattenDeep
|
function flattenDeep(arr1) {
return arr1.reduce(
(acc, val) =>
Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val),
[],
);
}
|
javascript
|
function flattenDeep(arr1) {
return arr1.reduce(
(acc, val) =>
Array.isArray(val) ? acc.concat(flattenDeep(val)) : acc.concat(val),
[],
);
}
|
[
"function",
"flattenDeep",
"(",
"arr1",
")",
"{",
"return",
"arr1",
".",
"reduce",
"(",
"(",
"acc",
",",
"val",
")",
"=>",
"Array",
".",
"isArray",
"(",
"val",
")",
"?",
"acc",
".",
"concat",
"(",
"flattenDeep",
"(",
"val",
")",
")",
":",
"acc",
".",
"concat",
"(",
"val",
")",
",",
"[",
"]",
",",
")",
";",
"}"
] |
recursively flatten heavily nested arrays
|
[
"recursively",
"flatten",
"heavily",
"nested",
"arrays"
] |
c63ab37dbee8f35aa5472be2d9688f989b20fd21
|
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/manifest.js#L13-L19
|
13,604
|
bolt-design-system/bolt
|
packages/build-tools/utils/manifest.js
|
aggregateBoltDependencies
|
async function aggregateBoltDependencies(data) {
let componentDependencies = [];
let componentsWithoutDeps = data;
componentsWithoutDeps.forEach(item => {
if (item.deps) {
componentDependencies.push([...item.deps]);
}
});
componentDependencies = flattenDeep(componentDependencies);
componentDependencies = componentDependencies.filter(function(x, i, a) {
if (x !== '@bolt/build-tools' && a.indexOf(x) === i) {
return x;
}
});
let globalDepsSrc = await Promise.all(componentDependencies.map(getPkgInfo));
componentsWithoutDeps = componentsWithoutDeps.concat(globalDepsSrc);
var uniqueComponentsWithDeps = removeDuplicateObjectsFromArray(
componentsWithoutDeps,
'name',
);
return uniqueComponentsWithDeps;
}
|
javascript
|
async function aggregateBoltDependencies(data) {
let componentDependencies = [];
let componentsWithoutDeps = data;
componentsWithoutDeps.forEach(item => {
if (item.deps) {
componentDependencies.push([...item.deps]);
}
});
componentDependencies = flattenDeep(componentDependencies);
componentDependencies = componentDependencies.filter(function(x, i, a) {
if (x !== '@bolt/build-tools' && a.indexOf(x) === i) {
return x;
}
});
let globalDepsSrc = await Promise.all(componentDependencies.map(getPkgInfo));
componentsWithoutDeps = componentsWithoutDeps.concat(globalDepsSrc);
var uniqueComponentsWithDeps = removeDuplicateObjectsFromArray(
componentsWithoutDeps,
'name',
);
return uniqueComponentsWithDeps;
}
|
[
"async",
"function",
"aggregateBoltDependencies",
"(",
"data",
")",
"{",
"let",
"componentDependencies",
"=",
"[",
"]",
";",
"let",
"componentsWithoutDeps",
"=",
"data",
";",
"componentsWithoutDeps",
".",
"forEach",
"(",
"item",
"=>",
"{",
"if",
"(",
"item",
".",
"deps",
")",
"{",
"componentDependencies",
".",
"push",
"(",
"[",
"...",
"item",
".",
"deps",
"]",
")",
";",
"}",
"}",
")",
";",
"componentDependencies",
"=",
"flattenDeep",
"(",
"componentDependencies",
")",
";",
"componentDependencies",
"=",
"componentDependencies",
".",
"filter",
"(",
"function",
"(",
"x",
",",
"i",
",",
"a",
")",
"{",
"if",
"(",
"x",
"!==",
"'@bolt/build-tools'",
"&&",
"a",
".",
"indexOf",
"(",
"x",
")",
"===",
"i",
")",
"{",
"return",
"x",
";",
"}",
"}",
")",
";",
"let",
"globalDepsSrc",
"=",
"await",
"Promise",
".",
"all",
"(",
"componentDependencies",
".",
"map",
"(",
"getPkgInfo",
")",
")",
";",
"componentsWithoutDeps",
"=",
"componentsWithoutDeps",
".",
"concat",
"(",
"globalDepsSrc",
")",
";",
"var",
"uniqueComponentsWithDeps",
"=",
"removeDuplicateObjectsFromArray",
"(",
"componentsWithoutDeps",
",",
"'name'",
",",
")",
";",
"return",
"uniqueComponentsWithDeps",
";",
"}"
] |
loop through package-specific dependencies to merge and dedupe
|
[
"loop",
"through",
"package",
"-",
"specific",
"dependencies",
"to",
"merge",
"and",
"dedupe"
] |
c63ab37dbee8f35aa5472be2d9688f989b20fd21
|
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/manifest.js#L177-L205
|
13,605
|
bolt-design-system/bolt
|
packages/build-tools/utils/manifest.js
|
getAllDirs
|
async function getAllDirs(relativeFrom) {
const dirs = [];
const manifest = await getBoltManifest();
[manifest.components.global, manifest.components.individual].forEach(
componentList => {
componentList.forEach(component => {
dirs.push(
relativeFrom
? path.relative(relativeFrom, component.dir)
: component.dir,
);
});
},
);
return dirs;
}
|
javascript
|
async function getAllDirs(relativeFrom) {
const dirs = [];
const manifest = await getBoltManifest();
[manifest.components.global, manifest.components.individual].forEach(
componentList => {
componentList.forEach(component => {
dirs.push(
relativeFrom
? path.relative(relativeFrom, component.dir)
: component.dir,
);
});
},
);
return dirs;
}
|
[
"async",
"function",
"getAllDirs",
"(",
"relativeFrom",
")",
"{",
"const",
"dirs",
"=",
"[",
"]",
";",
"const",
"manifest",
"=",
"await",
"getBoltManifest",
"(",
")",
";",
"[",
"manifest",
".",
"components",
".",
"global",
",",
"manifest",
".",
"components",
".",
"individual",
"]",
".",
"forEach",
"(",
"componentList",
"=>",
"{",
"componentList",
".",
"forEach",
"(",
"component",
"=>",
"{",
"dirs",
".",
"push",
"(",
"relativeFrom",
"?",
"path",
".",
"relative",
"(",
"relativeFrom",
",",
"component",
".",
"dir",
")",
":",
"component",
".",
"dir",
",",
")",
";",
"}",
")",
";",
"}",
",",
")",
";",
"return",
"dirs",
";",
"}"
] |
Get all directories for components in Bolt Manifest
@param relativeFrom {string} - If present, the path will be relative from this, else it will be absolute.
@returns {Array<String>} {dirs} - List of all component/package paths in Bolt Manifest
|
[
"Get",
"all",
"directories",
"for",
"components",
"in",
"Bolt",
"Manifest"
] |
c63ab37dbee8f35aa5472be2d9688f989b20fd21
|
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/manifest.js#L242-L258
|
13,606
|
bolt-design-system/bolt
|
packages/build-tools/utils/manifest.js
|
getTwigNamespaceConfig
|
async function getTwigNamespaceConfig(relativeFrom, extraNamespaces = {}) {
const config = await getConfig();
const namespaces = {};
const allDirs = [];
const manifest = await getBoltManifest();
const global = manifest.components.global;
const individual = manifest.components.individual;
[global, individual].forEach(componentList => {
componentList.forEach(component => {
if (!component.twigNamespace) {
return;
}
const dir = relativeFrom
? path.relative(relativeFrom, component.dir)
: component.dir;
namespaces[component.basicName] = {
recursive: true,
paths: [dir],
};
allDirs.push(dir);
});
});
const namespaceConfigFile = Object.assign(
{
// Can hit anything with `@bolt`
bolt: {
recursive: true,
paths: [...allDirs],
},
'bolt-data': {
recursive: true,
paths: [config.dataDir],
},
},
namespaces,
);
// `extraNamespaces` serves two purposes:
// 1. To add extra namespaces that have not been declared
// 2. To add extra paths to previously declared namespaces
// Assuming we've already declared the `foo` namespaces to look in `~/my-dir1`
// Then someone uses `extraNamespaces` to declare that `foo` will look in `~/my-dir2`
// This will not overwrite it, but *prepend* to the paths, resulting in a namespace setting like this:
// 'foo': {
// paths: ['~/my-dir2', '~/my-dir1']
// }
// This causes the folder declared in `extraNamespaces` to be looked in first for templates, before our default;
// allowing end user developers to selectively overwrite some templates.
if (extraNamespaces) {
Object.keys(extraNamespaces).forEach(namespace => {
const settings = extraNamespaces[namespace];
if (
namespaceConfigFile[namespace] &&
settings.paths !== undefined // make sure the paths config is defined before trying to merge
) {
// merging the two, making sure the paths from `extraNamespaces` go first
namespaceConfigFile[namespace].paths = [
...settings.paths,
...namespaceConfigFile[namespace].paths,
];
// don't add a new namespace key if the paths config option wasn't defined. prevents PHP errors if a namespace key was defined but no paths specified.
} else if (settings.paths !== undefined) {
namespaceConfigFile[namespace] = settings;
}
});
}
return namespaceConfigFile;
}
|
javascript
|
async function getTwigNamespaceConfig(relativeFrom, extraNamespaces = {}) {
const config = await getConfig();
const namespaces = {};
const allDirs = [];
const manifest = await getBoltManifest();
const global = manifest.components.global;
const individual = manifest.components.individual;
[global, individual].forEach(componentList => {
componentList.forEach(component => {
if (!component.twigNamespace) {
return;
}
const dir = relativeFrom
? path.relative(relativeFrom, component.dir)
: component.dir;
namespaces[component.basicName] = {
recursive: true,
paths: [dir],
};
allDirs.push(dir);
});
});
const namespaceConfigFile = Object.assign(
{
// Can hit anything with `@bolt`
bolt: {
recursive: true,
paths: [...allDirs],
},
'bolt-data': {
recursive: true,
paths: [config.dataDir],
},
},
namespaces,
);
// `extraNamespaces` serves two purposes:
// 1. To add extra namespaces that have not been declared
// 2. To add extra paths to previously declared namespaces
// Assuming we've already declared the `foo` namespaces to look in `~/my-dir1`
// Then someone uses `extraNamespaces` to declare that `foo` will look in `~/my-dir2`
// This will not overwrite it, but *prepend* to the paths, resulting in a namespace setting like this:
// 'foo': {
// paths: ['~/my-dir2', '~/my-dir1']
// }
// This causes the folder declared in `extraNamespaces` to be looked in first for templates, before our default;
// allowing end user developers to selectively overwrite some templates.
if (extraNamespaces) {
Object.keys(extraNamespaces).forEach(namespace => {
const settings = extraNamespaces[namespace];
if (
namespaceConfigFile[namespace] &&
settings.paths !== undefined // make sure the paths config is defined before trying to merge
) {
// merging the two, making sure the paths from `extraNamespaces` go first
namespaceConfigFile[namespace].paths = [
...settings.paths,
...namespaceConfigFile[namespace].paths,
];
// don't add a new namespace key if the paths config option wasn't defined. prevents PHP errors if a namespace key was defined but no paths specified.
} else if (settings.paths !== undefined) {
namespaceConfigFile[namespace] = settings;
}
});
}
return namespaceConfigFile;
}
|
[
"async",
"function",
"getTwigNamespaceConfig",
"(",
"relativeFrom",
",",
"extraNamespaces",
"=",
"{",
"}",
")",
"{",
"const",
"config",
"=",
"await",
"getConfig",
"(",
")",
";",
"const",
"namespaces",
"=",
"{",
"}",
";",
"const",
"allDirs",
"=",
"[",
"]",
";",
"const",
"manifest",
"=",
"await",
"getBoltManifest",
"(",
")",
";",
"const",
"global",
"=",
"manifest",
".",
"components",
".",
"global",
";",
"const",
"individual",
"=",
"manifest",
".",
"components",
".",
"individual",
";",
"[",
"global",
",",
"individual",
"]",
".",
"forEach",
"(",
"componentList",
"=>",
"{",
"componentList",
".",
"forEach",
"(",
"component",
"=>",
"{",
"if",
"(",
"!",
"component",
".",
"twigNamespace",
")",
"{",
"return",
";",
"}",
"const",
"dir",
"=",
"relativeFrom",
"?",
"path",
".",
"relative",
"(",
"relativeFrom",
",",
"component",
".",
"dir",
")",
":",
"component",
".",
"dir",
";",
"namespaces",
"[",
"component",
".",
"basicName",
"]",
"=",
"{",
"recursive",
":",
"true",
",",
"paths",
":",
"[",
"dir",
"]",
",",
"}",
";",
"allDirs",
".",
"push",
"(",
"dir",
")",
";",
"}",
")",
";",
"}",
")",
";",
"const",
"namespaceConfigFile",
"=",
"Object",
".",
"assign",
"(",
"{",
"// Can hit anything with `@bolt`",
"bolt",
":",
"{",
"recursive",
":",
"true",
",",
"paths",
":",
"[",
"...",
"allDirs",
"]",
",",
"}",
",",
"'bolt-data'",
":",
"{",
"recursive",
":",
"true",
",",
"paths",
":",
"[",
"config",
".",
"dataDir",
"]",
",",
"}",
",",
"}",
",",
"namespaces",
",",
")",
";",
"// `extraNamespaces` serves two purposes:",
"// 1. To add extra namespaces that have not been declared",
"// 2. To add extra paths to previously declared namespaces",
"// Assuming we've already declared the `foo` namespaces to look in `~/my-dir1`",
"// Then someone uses `extraNamespaces` to declare that `foo` will look in `~/my-dir2`",
"// This will not overwrite it, but *prepend* to the paths, resulting in a namespace setting like this:",
"// 'foo': {",
"// paths: ['~/my-dir2', '~/my-dir1']",
"// }",
"// This causes the folder declared in `extraNamespaces` to be looked in first for templates, before our default;",
"// allowing end user developers to selectively overwrite some templates.",
"if",
"(",
"extraNamespaces",
")",
"{",
"Object",
".",
"keys",
"(",
"extraNamespaces",
")",
".",
"forEach",
"(",
"namespace",
"=>",
"{",
"const",
"settings",
"=",
"extraNamespaces",
"[",
"namespace",
"]",
";",
"if",
"(",
"namespaceConfigFile",
"[",
"namespace",
"]",
"&&",
"settings",
".",
"paths",
"!==",
"undefined",
"// make sure the paths config is defined before trying to merge",
")",
"{",
"// merging the two, making sure the paths from `extraNamespaces` go first",
"namespaceConfigFile",
"[",
"namespace",
"]",
".",
"paths",
"=",
"[",
"...",
"settings",
".",
"paths",
",",
"...",
"namespaceConfigFile",
"[",
"namespace",
"]",
".",
"paths",
",",
"]",
";",
"// don't add a new namespace key if the paths config option wasn't defined. prevents PHP errors if a namespace key was defined but no paths specified.",
"}",
"else",
"if",
"(",
"settings",
".",
"paths",
"!==",
"undefined",
")",
"{",
"namespaceConfigFile",
"[",
"namespace",
"]",
"=",
"settings",
";",
"}",
"}",
")",
";",
"}",
"return",
"namespaceConfigFile",
";",
"}"
] |
Builds config for Twig Namespaces
@param relativeFrom {string} - If present, the path will be relative from this, else it will be absolute.
@param extraNamespaces {object} - Extra namespaces to add to file in [this format](https://packagist.org/packages/evanlovely/plugin-twig-namespaces)
@async
@see writeTwigNamespaceFile
@returns {Promise<object>}
|
[
"Builds",
"config",
"for",
"Twig",
"Namespaces"
] |
c63ab37dbee8f35aa5472be2d9688f989b20fd21
|
https://github.com/bolt-design-system/bolt/blob/c63ab37dbee8f35aa5472be2d9688f989b20fd21/packages/build-tools/utils/manifest.js#L322-L396
|
13,607
|
chjj/pty.js
|
lib/pty.js
|
Socket
|
function Socket(options) {
if (!(this instanceof Socket)) {
return new Socket(options);
}
var tty = process.binding('tty_wrap');
var guessHandleType = tty.guessHandleType;
tty.guessHandleType = function() {
return 'PIPE';
};
net.Socket.call(this, options);
tty.guessHandleType = guessHandleType;
}
|
javascript
|
function Socket(options) {
if (!(this instanceof Socket)) {
return new Socket(options);
}
var tty = process.binding('tty_wrap');
var guessHandleType = tty.guessHandleType;
tty.guessHandleType = function() {
return 'PIPE';
};
net.Socket.call(this, options);
tty.guessHandleType = guessHandleType;
}
|
[
"function",
"Socket",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Socket",
")",
")",
"{",
"return",
"new",
"Socket",
"(",
"options",
")",
";",
"}",
"var",
"tty",
"=",
"process",
".",
"binding",
"(",
"'tty_wrap'",
")",
";",
"var",
"guessHandleType",
"=",
"tty",
".",
"guessHandleType",
";",
"tty",
".",
"guessHandleType",
"=",
"function",
"(",
")",
"{",
"return",
"'PIPE'",
";",
"}",
";",
"net",
".",
"Socket",
".",
"call",
"(",
"this",
",",
"options",
")",
";",
"tty",
".",
"guessHandleType",
"=",
"guessHandleType",
";",
"}"
] |
Wrap net.Socket for a workaround
|
[
"Wrap",
"net",
".",
"Socket",
"for",
"a",
"workaround"
] |
fe63a412574f45ee6bb6d8fab4a5c102107b5201
|
https://github.com/chjj/pty.js/blob/fe63a412574f45ee6bb6d8fab4a5c102107b5201/lib/pty.js#L430-L441
|
13,608
|
chjj/pty.js
|
lib/pty_win.js
|
Agent
|
function Agent(file, args, env, cwd, cols, rows, debug) {
var self = this;
// Increment the number of pipes created.
pipeIncr++;
// Unique identifier per pipe created.
var timestamp = Date.now();
// The data pipe is the direct connection to the forked terminal.
this.dataPipe = '\\\\.\\pipe\\winpty-data-' + pipeIncr + '' + timestamp;
// Dummy socket for awaiting `ready` event.
this.ptySocket = new net.Socket();
// Create terminal pipe IPC channel and forward
// to a local unix socket.
this.ptyDataPipe = net.createServer(function (socket) {
// Default socket encoding.
socket.setEncoding('utf8');
// Pause until `ready` event is emitted.
socket.pause();
// Sanitize input variable.
file = file;
args = args.join(' ');
cwd = path.resolve(cwd);
// Start terminal session.
pty.startProcess(self.pid, file, args, env, cwd);
// Emit ready event.
self.ptySocket.emit('ready_datapipe', socket);
}).listen(this.dataPipe);
// Open pty session.
var term = pty.open(self.dataPipe, cols, rows, debug);
// Terminal pid.
this.pid = term.pid;
// Not available on windows.
this.fd = term.fd;
// Generated incremental number that has no real purpose besides
// using it as a terminal id.
this.pty = term.pty;
}
|
javascript
|
function Agent(file, args, env, cwd, cols, rows, debug) {
var self = this;
// Increment the number of pipes created.
pipeIncr++;
// Unique identifier per pipe created.
var timestamp = Date.now();
// The data pipe is the direct connection to the forked terminal.
this.dataPipe = '\\\\.\\pipe\\winpty-data-' + pipeIncr + '' + timestamp;
// Dummy socket for awaiting `ready` event.
this.ptySocket = new net.Socket();
// Create terminal pipe IPC channel and forward
// to a local unix socket.
this.ptyDataPipe = net.createServer(function (socket) {
// Default socket encoding.
socket.setEncoding('utf8');
// Pause until `ready` event is emitted.
socket.pause();
// Sanitize input variable.
file = file;
args = args.join(' ');
cwd = path.resolve(cwd);
// Start terminal session.
pty.startProcess(self.pid, file, args, env, cwd);
// Emit ready event.
self.ptySocket.emit('ready_datapipe', socket);
}).listen(this.dataPipe);
// Open pty session.
var term = pty.open(self.dataPipe, cols, rows, debug);
// Terminal pid.
this.pid = term.pid;
// Not available on windows.
this.fd = term.fd;
// Generated incremental number that has no real purpose besides
// using it as a terminal id.
this.pty = term.pty;
}
|
[
"function",
"Agent",
"(",
"file",
",",
"args",
",",
"env",
",",
"cwd",
",",
"cols",
",",
"rows",
",",
"debug",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// Increment the number of pipes created.",
"pipeIncr",
"++",
";",
"// Unique identifier per pipe created.",
"var",
"timestamp",
"=",
"Date",
".",
"now",
"(",
")",
";",
"// The data pipe is the direct connection to the forked terminal.",
"this",
".",
"dataPipe",
"=",
"'\\\\\\\\.\\\\pipe\\\\winpty-data-'",
"+",
"pipeIncr",
"+",
"''",
"+",
"timestamp",
";",
"// Dummy socket for awaiting `ready` event.",
"this",
".",
"ptySocket",
"=",
"new",
"net",
".",
"Socket",
"(",
")",
";",
"// Create terminal pipe IPC channel and forward",
"// to a local unix socket.",
"this",
".",
"ptyDataPipe",
"=",
"net",
".",
"createServer",
"(",
"function",
"(",
"socket",
")",
"{",
"// Default socket encoding.",
"socket",
".",
"setEncoding",
"(",
"'utf8'",
")",
";",
"// Pause until `ready` event is emitted.",
"socket",
".",
"pause",
"(",
")",
";",
"// Sanitize input variable.",
"file",
"=",
"file",
";",
"args",
"=",
"args",
".",
"join",
"(",
"' '",
")",
";",
"cwd",
"=",
"path",
".",
"resolve",
"(",
"cwd",
")",
";",
"// Start terminal session.",
"pty",
".",
"startProcess",
"(",
"self",
".",
"pid",
",",
"file",
",",
"args",
",",
"env",
",",
"cwd",
")",
";",
"// Emit ready event.",
"self",
".",
"ptySocket",
".",
"emit",
"(",
"'ready_datapipe'",
",",
"socket",
")",
";",
"}",
")",
".",
"listen",
"(",
"this",
".",
"dataPipe",
")",
";",
"// Open pty session.",
"var",
"term",
"=",
"pty",
".",
"open",
"(",
"self",
".",
"dataPipe",
",",
"cols",
",",
"rows",
",",
"debug",
")",
";",
"// Terminal pid.",
"this",
".",
"pid",
"=",
"term",
".",
"pid",
";",
"// Not available on windows.",
"this",
".",
"fd",
"=",
"term",
".",
"fd",
";",
"// Generated incremental number that has no real purpose besides",
"// using it as a terminal id.",
"this",
".",
"pty",
"=",
"term",
".",
"pty",
";",
"}"
] |
Agent. Internal class.
Everytime a new pseudo terminal is created it is contained
within agent.exe. When this process is started there are two
available named pipes (control and data socket).
|
[
"Agent",
".",
"Internal",
"class",
"."
] |
fe63a412574f45ee6bb6d8fab4a5c102107b5201
|
https://github.com/chjj/pty.js/blob/fe63a412574f45ee6bb6d8fab4a5c102107b5201/lib/pty_win.js#L24-L74
|
13,609
|
harrisiirak/cron-parser
|
lib/expression.js
|
isWildcardRange
|
function isWildcardRange(range, constraints) {
if (range instanceof Array && !range.length) {
return false;
}
if (constraints.length !== 2) {
return false;
}
return range.length === (constraints[1] - (constraints[0] < 1 ? - 1 : 0));
}
|
javascript
|
function isWildcardRange(range, constraints) {
if (range instanceof Array && !range.length) {
return false;
}
if (constraints.length !== 2) {
return false;
}
return range.length === (constraints[1] - (constraints[0] < 1 ? - 1 : 0));
}
|
[
"function",
"isWildcardRange",
"(",
"range",
",",
"constraints",
")",
"{",
"if",
"(",
"range",
"instanceof",
"Array",
"&&",
"!",
"range",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"constraints",
".",
"length",
"!==",
"2",
")",
"{",
"return",
"false",
";",
"}",
"return",
"range",
".",
"length",
"===",
"(",
"constraints",
"[",
"1",
"]",
"-",
"(",
"constraints",
"[",
"0",
"]",
"<",
"1",
"?",
"-",
"1",
":",
"0",
")",
")",
";",
"}"
] |
Detect if input range fully matches constraint bounds
@param {Array} range Input range
@param {Array} constraints Input constraints
@returns {Boolean}
@private
|
[
"Detect",
"if",
"input",
"range",
"fully",
"matches",
"constraint",
"bounds"
] |
b6cfece825f0894194f5d002c0051b9a7f09ce12
|
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L21-L31
|
13,610
|
harrisiirak/cron-parser
|
lib/expression.js
|
CronExpression
|
function CronExpression (fields, options) {
this._options = options;
this._utc = options.utc || false;
this._tz = this._utc ? 'UTC' : options.tz;
this._currentDate = new CronDate(options.currentDate, this._tz);
this._startDate = options.startDate ? new CronDate(options.startDate, this._tz) : null;
this._endDate = options.endDate ? new CronDate(options.endDate, this._tz) : null;
this._fields = fields;
this._isIterator = options.iterator || false;
this._hasIterated = false;
this._nthDayOfWeek = options.nthDayOfWeek || 0;
}
|
javascript
|
function CronExpression (fields, options) {
this._options = options;
this._utc = options.utc || false;
this._tz = this._utc ? 'UTC' : options.tz;
this._currentDate = new CronDate(options.currentDate, this._tz);
this._startDate = options.startDate ? new CronDate(options.startDate, this._tz) : null;
this._endDate = options.endDate ? new CronDate(options.endDate, this._tz) : null;
this._fields = fields;
this._isIterator = options.iterator || false;
this._hasIterated = false;
this._nthDayOfWeek = options.nthDayOfWeek || 0;
}
|
[
"function",
"CronExpression",
"(",
"fields",
",",
"options",
")",
"{",
"this",
".",
"_options",
"=",
"options",
";",
"this",
".",
"_utc",
"=",
"options",
".",
"utc",
"||",
"false",
";",
"this",
".",
"_tz",
"=",
"this",
".",
"_utc",
"?",
"'UTC'",
":",
"options",
".",
"tz",
";",
"this",
".",
"_currentDate",
"=",
"new",
"CronDate",
"(",
"options",
".",
"currentDate",
",",
"this",
".",
"_tz",
")",
";",
"this",
".",
"_startDate",
"=",
"options",
".",
"startDate",
"?",
"new",
"CronDate",
"(",
"options",
".",
"startDate",
",",
"this",
".",
"_tz",
")",
":",
"null",
";",
"this",
".",
"_endDate",
"=",
"options",
".",
"endDate",
"?",
"new",
"CronDate",
"(",
"options",
".",
"endDate",
",",
"this",
".",
"_tz",
")",
":",
"null",
";",
"this",
".",
"_fields",
"=",
"fields",
";",
"this",
".",
"_isIterator",
"=",
"options",
".",
"iterator",
"||",
"false",
";",
"this",
".",
"_hasIterated",
"=",
"false",
";",
"this",
".",
"_nthDayOfWeek",
"=",
"options",
".",
"nthDayOfWeek",
"||",
"0",
";",
"}"
] |
Construct a new expression parser
Options:
currentDate: iterator start date
endDate: iterator end date
@constructor
@private
@param {Object} fields Expression fields parsed values
@param {Object} options Parser options
|
[
"Construct",
"a",
"new",
"expression",
"parser"
] |
b6cfece825f0894194f5d002c0051b9a7f09ce12
|
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L45-L56
|
13,611
|
harrisiirak/cron-parser
|
lib/expression.js
|
parseRepeat
|
function parseRepeat (val) {
var repeatInterval = 1;
var atoms = val.split('/');
if (atoms.length > 1) {
return parseRange(atoms[0], atoms[atoms.length - 1]);
}
return parseRange(val, repeatInterval);
}
|
javascript
|
function parseRepeat (val) {
var repeatInterval = 1;
var atoms = val.split('/');
if (atoms.length > 1) {
return parseRange(atoms[0], atoms[atoms.length - 1]);
}
return parseRange(val, repeatInterval);
}
|
[
"function",
"parseRepeat",
"(",
"val",
")",
"{",
"var",
"repeatInterval",
"=",
"1",
";",
"var",
"atoms",
"=",
"val",
".",
"split",
"(",
"'/'",
")",
";",
"if",
"(",
"atoms",
".",
"length",
">",
"1",
")",
"{",
"return",
"parseRange",
"(",
"atoms",
"[",
"0",
"]",
",",
"atoms",
"[",
"atoms",
".",
"length",
"-",
"1",
"]",
")",
";",
"}",
"return",
"parseRange",
"(",
"val",
",",
"repeatInterval",
")",
";",
"}"
] |
Parse repetition interval
@param {String} val
@return {Array}
|
[
"Parse",
"repetition",
"interval"
] |
b6cfece825f0894194f5d002c0051b9a7f09ce12
|
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L276-L285
|
13,612
|
harrisiirak/cron-parser
|
lib/expression.js
|
matchSchedule
|
function matchSchedule (value, sequence) {
for (var i = 0, c = sequence.length; i < c; i++) {
if (sequence[i] >= value) {
return sequence[i] === value;
}
}
return sequence[0] === value;
}
|
javascript
|
function matchSchedule (value, sequence) {
for (var i = 0, c = sequence.length; i < c; i++) {
if (sequence[i] >= value) {
return sequence[i] === value;
}
}
return sequence[0] === value;
}
|
[
"function",
"matchSchedule",
"(",
"value",
",",
"sequence",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"c",
"=",
"sequence",
".",
"length",
";",
"i",
"<",
"c",
";",
"i",
"++",
")",
"{",
"if",
"(",
"sequence",
"[",
"i",
"]",
">=",
"value",
")",
"{",
"return",
"sequence",
"[",
"i",
"]",
"===",
"value",
";",
"}",
"}",
"return",
"sequence",
"[",
"0",
"]",
"===",
"value",
";",
"}"
] |
Match field value
@param {String} value
@param {Array} sequence
@return {Boolean}
@private
|
[
"Match",
"field",
"value"
] |
b6cfece825f0894194f5d002c0051b9a7f09ce12
|
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L409-L417
|
13,613
|
harrisiirak/cron-parser
|
lib/expression.js
|
isNthDayMatch
|
function isNthDayMatch(date, nthDayOfWeek) {
if (nthDayOfWeek < 6) {
if (
date.getDate() < 8 &&
nthDayOfWeek === 1 // First occurence has to happen in first 7 days of the month
) {
return true;
}
var offset = date.getDate() % 7 ? 1 : 0; // Math is off by 1 when dayOfWeek isn't divisible by 7
var adjustedDate = date.getDate() - (date.getDate() % 7); // find the first occurance
var occurrence = Math.floor(adjustedDate / 7) + offset;
return occurrence === nthDayOfWeek;
}
return false;
}
|
javascript
|
function isNthDayMatch(date, nthDayOfWeek) {
if (nthDayOfWeek < 6) {
if (
date.getDate() < 8 &&
nthDayOfWeek === 1 // First occurence has to happen in first 7 days of the month
) {
return true;
}
var offset = date.getDate() % 7 ? 1 : 0; // Math is off by 1 when dayOfWeek isn't divisible by 7
var adjustedDate = date.getDate() - (date.getDate() % 7); // find the first occurance
var occurrence = Math.floor(adjustedDate / 7) + offset;
return occurrence === nthDayOfWeek;
}
return false;
}
|
[
"function",
"isNthDayMatch",
"(",
"date",
",",
"nthDayOfWeek",
")",
"{",
"if",
"(",
"nthDayOfWeek",
"<",
"6",
")",
"{",
"if",
"(",
"date",
".",
"getDate",
"(",
")",
"<",
"8",
"&&",
"nthDayOfWeek",
"===",
"1",
"// First occurence has to happen in first 7 days of the month",
")",
"{",
"return",
"true",
";",
"}",
"var",
"offset",
"=",
"date",
".",
"getDate",
"(",
")",
"%",
"7",
"?",
"1",
":",
"0",
";",
"// Math is off by 1 when dayOfWeek isn't divisible by 7",
"var",
"adjustedDate",
"=",
"date",
".",
"getDate",
"(",
")",
"-",
"(",
"date",
".",
"getDate",
"(",
")",
"%",
"7",
")",
";",
"// find the first occurance",
"var",
"occurrence",
"=",
"Math",
".",
"floor",
"(",
"adjustedDate",
"/",
"7",
")",
"+",
"offset",
";",
"return",
"occurrence",
"===",
"nthDayOfWeek",
";",
"}",
"return",
"false",
";",
"}"
] |
Helps determine if the provided date is the correct nth occurence of the
desired day of week.
@param {CronDate} date
@param {Number} nthDayOfWeek
@return {Boolean}
@private
|
[
"Helps",
"determine",
"if",
"the",
"provided",
"date",
"is",
"the",
"correct",
"nth",
"occurence",
"of",
"the",
"desired",
"day",
"of",
"week",
"."
] |
b6cfece825f0894194f5d002c0051b9a7f09ce12
|
https://github.com/harrisiirak/cron-parser/blob/b6cfece825f0894194f5d002c0051b9a7f09ce12/lib/expression.js#L428-L445
|
13,614
|
pixijs/pixi-particles
|
docs/examples/js/ParticleExample.js
|
function(){
// Update the next frame
updateId = requestAnimationFrame(update);
var now = Date.now();
if (emitter)
emitter.update((now - elapsed) * 0.001);
framerate.innerHTML = (1000 / (now - elapsed)).toFixed(2);
elapsed = now;
if(emitter && particleCount)
particleCount.innerHTML = emitter.particleCount;
// render the stage
renderer.render(stage);
}
|
javascript
|
function(){
// Update the next frame
updateId = requestAnimationFrame(update);
var now = Date.now();
if (emitter)
emitter.update((now - elapsed) * 0.001);
framerate.innerHTML = (1000 / (now - elapsed)).toFixed(2);
elapsed = now;
if(emitter && particleCount)
particleCount.innerHTML = emitter.particleCount;
// render the stage
renderer.render(stage);
}
|
[
"function",
"(",
")",
"{",
"// Update the next frame",
"updateId",
"=",
"requestAnimationFrame",
"(",
"update",
")",
";",
"var",
"now",
"=",
"Date",
".",
"now",
"(",
")",
";",
"if",
"(",
"emitter",
")",
"emitter",
".",
"update",
"(",
"(",
"now",
"-",
"elapsed",
")",
"*",
"0.001",
")",
";",
"framerate",
".",
"innerHTML",
"=",
"(",
"1000",
"/",
"(",
"now",
"-",
"elapsed",
")",
")",
".",
"toFixed",
"(",
"2",
")",
";",
"elapsed",
"=",
"now",
";",
"if",
"(",
"emitter",
"&&",
"particleCount",
")",
"particleCount",
".",
"innerHTML",
"=",
"emitter",
".",
"particleCount",
";",
"// render the stage",
"renderer",
".",
"render",
"(",
"stage",
")",
";",
"}"
] |
Update function every frame
|
[
"Update",
"function",
"every",
"frame"
] |
163262fe65ac8ebe4e8c5c4d485610571a54291b
|
https://github.com/pixijs/pixi-particles/blob/163262fe65ac8ebe4e8c5c4d485610571a54291b/docs/examples/js/ParticleExample.js#L38-L56
|
|
13,615
|
tristen/tablesort
|
src/tablesort.js
|
function(a, b) {
a = a.trim().toLowerCase();
b = b.trim().toLowerCase();
if (a === b) return 0;
if (a < b) return 1;
return -1;
}
|
javascript
|
function(a, b) {
a = a.trim().toLowerCase();
b = b.trim().toLowerCase();
if (a === b) return 0;
if (a < b) return 1;
return -1;
}
|
[
"function",
"(",
"a",
",",
"b",
")",
"{",
"a",
"=",
"a",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"b",
"=",
"b",
".",
"trim",
"(",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"a",
"===",
"b",
")",
"return",
"0",
";",
"if",
"(",
"a",
"<",
"b",
")",
"return",
"1",
";",
"return",
"-",
"1",
";",
"}"
] |
Default sort method if no better sort method is found
|
[
"Default",
"sort",
"method",
"if",
"no",
"better",
"sort",
"method",
"is",
"found"
] |
3f9153b3e5f6d87ec8f9d83bb0c986d705661402
|
https://github.com/tristen/tablesort/blob/3f9153b3e5f6d87ec8f9d83bb0c986d705661402/src/tablesort.js#L31-L39
|
|
13,616
|
tristen/tablesort
|
src/tablesort.js
|
function(sort, antiStabilize) {
return function(a, b) {
var unstableResult = sort(a.td, b.td);
if (unstableResult === 0) {
if (antiStabilize) return b.index - a.index;
return a.index - b.index;
}
return unstableResult;
};
}
|
javascript
|
function(sort, antiStabilize) {
return function(a, b) {
var unstableResult = sort(a.td, b.td);
if (unstableResult === 0) {
if (antiStabilize) return b.index - a.index;
return a.index - b.index;
}
return unstableResult;
};
}
|
[
"function",
"(",
"sort",
",",
"antiStabilize",
")",
"{",
"return",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"unstableResult",
"=",
"sort",
"(",
"a",
".",
"td",
",",
"b",
".",
"td",
")",
";",
"if",
"(",
"unstableResult",
"===",
"0",
")",
"{",
"if",
"(",
"antiStabilize",
")",
"return",
"b",
".",
"index",
"-",
"a",
".",
"index",
";",
"return",
"a",
".",
"index",
"-",
"b",
".",
"index",
";",
"}",
"return",
"unstableResult",
";",
"}",
";",
"}"
] |
Stable sort function If two elements are equal under the original sort function, then there relative order is reversed
|
[
"Stable",
"sort",
"function",
"If",
"two",
"elements",
"are",
"equal",
"under",
"the",
"original",
"sort",
"function",
"then",
"there",
"relative",
"order",
"is",
"reversed"
] |
3f9153b3e5f6d87ec8f9d83bb0c986d705661402
|
https://github.com/tristen/tablesort/blob/3f9153b3e5f6d87ec8f9d83bb0c986d705661402/src/tablesort.js#L44-L55
|
|
13,617
|
xiongwilee/Gracejs
|
middleware/session/index.js
|
extendContext
|
function extendContext(context, opts) {
Object.defineProperties(context, {
[CONTEXT_SESSION]: {
get() {
if (this[_CONTEXT_SESSION]) return this[_CONTEXT_SESSION];
this[_CONTEXT_SESSION] = new ContextSession(this, opts);
return this[_CONTEXT_SESSION];
},
enumerable: true
},
session: {
get() {
return this[CONTEXT_SESSION].get();
},
set(val) {
this[CONTEXT_SESSION].set(val);
},
configurable: true,
enumerable: true
},
sessionOptions: {
get() {
return this[CONTEXT_SESSION].opts;
},
enumerable: true
},
});
}
|
javascript
|
function extendContext(context, opts) {
Object.defineProperties(context, {
[CONTEXT_SESSION]: {
get() {
if (this[_CONTEXT_SESSION]) return this[_CONTEXT_SESSION];
this[_CONTEXT_SESSION] = new ContextSession(this, opts);
return this[_CONTEXT_SESSION];
},
enumerable: true
},
session: {
get() {
return this[CONTEXT_SESSION].get();
},
set(val) {
this[CONTEXT_SESSION].set(val);
},
configurable: true,
enumerable: true
},
sessionOptions: {
get() {
return this[CONTEXT_SESSION].opts;
},
enumerable: true
},
});
}
|
[
"function",
"extendContext",
"(",
"context",
",",
"opts",
")",
"{",
"Object",
".",
"defineProperties",
"(",
"context",
",",
"{",
"[",
"CONTEXT_SESSION",
"]",
":",
"{",
"get",
"(",
")",
"{",
"if",
"(",
"this",
"[",
"_CONTEXT_SESSION",
"]",
")",
"return",
"this",
"[",
"_CONTEXT_SESSION",
"]",
";",
"this",
"[",
"_CONTEXT_SESSION",
"]",
"=",
"new",
"ContextSession",
"(",
"this",
",",
"opts",
")",
";",
"return",
"this",
"[",
"_CONTEXT_SESSION",
"]",
";",
"}",
",",
"enumerable",
":",
"true",
"}",
",",
"session",
":",
"{",
"get",
"(",
")",
"{",
"return",
"this",
"[",
"CONTEXT_SESSION",
"]",
".",
"get",
"(",
")",
";",
"}",
",",
"set",
"(",
"val",
")",
"{",
"this",
"[",
"CONTEXT_SESSION",
"]",
".",
"set",
"(",
"val",
")",
";",
"}",
",",
"configurable",
":",
"true",
",",
"enumerable",
":",
"true",
"}",
",",
"sessionOptions",
":",
"{",
"get",
"(",
")",
"{",
"return",
"this",
"[",
"CONTEXT_SESSION",
"]",
".",
"opts",
";",
"}",
",",
"enumerable",
":",
"true",
"}",
",",
"}",
")",
";",
"}"
] |
extend context prototype, add session properties
@param {Object} context koa's context prototype
@param {Object} opts session options
@api private
|
[
"extend",
"context",
"prototype",
"add",
"session",
"properties"
] |
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
|
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/middleware/session/index.js#L103-L130
|
13,618
|
xiongwilee/Gracejs
|
middleware/router/lib/router.js
|
Router
|
function Router(opts) {
if (!(this instanceof Router)) {
return new Router(opts);
}
this.opts = opts || {};
this.methods = this.opts.methods || [
'HEAD',
'OPTIONS',
'GET',
'PUT',
'PATCH',
'POST',
'DELETE'
];
this.params = {};
this.stack = [];
this.MATCHS = {};
}
|
javascript
|
function Router(opts) {
if (!(this instanceof Router)) {
return new Router(opts);
}
this.opts = opts || {};
this.methods = this.opts.methods || [
'HEAD',
'OPTIONS',
'GET',
'PUT',
'PATCH',
'POST',
'DELETE'
];
this.params = {};
this.stack = [];
this.MATCHS = {};
}
|
[
"function",
"Router",
"(",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Router",
")",
")",
"{",
"return",
"new",
"Router",
"(",
"opts",
")",
";",
"}",
"this",
".",
"opts",
"=",
"opts",
"||",
"{",
"}",
";",
"this",
".",
"methods",
"=",
"this",
".",
"opts",
".",
"methods",
"||",
"[",
"'HEAD'",
",",
"'OPTIONS'",
",",
"'GET'",
",",
"'PUT'",
",",
"'PATCH'",
",",
"'POST'",
",",
"'DELETE'",
"]",
";",
"this",
".",
"params",
"=",
"{",
"}",
";",
"this",
".",
"stack",
"=",
"[",
"]",
";",
"this",
".",
"MATCHS",
"=",
"{",
"}",
";",
"}"
] |
Create a new router.
@example
Basic usage:
```javascript
var app = require('koa')();
var router = require('koa-router')();
router.get('/', function *(next) {...});
app
.use(router.routes())
.use(router.allowedMethods());
```
@alias module:koa-router
@param {Object=} opts
@param {String=} opts.prefix prefix router paths
@constructor
|
[
"Create",
"a",
"new",
"router",
"."
] |
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
|
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/middleware/router/lib/router.js#L47-L66
|
13,619
|
xiongwilee/Gracejs
|
app/blog/static/js/common/reveal/markdown.js
|
getForwardedAttributes
|
function getForwardedAttributes( section ) {
var attributes = section.attributes;
var result = [];
for( var i = 0, len = attributes.length; i < len; i++ ) {
var name = attributes[i].name,
value = attributes[i].value;
// disregard attributes that are used for markdown loading/parsing
if( /data\-(markdown|separator|vertical|notes)/gi.test( name ) ) continue;
if( value ) {
result.push( name + '="' + value + '"' );
}
else {
result.push( name );
}
}
return result.join( ' ' );
}
|
javascript
|
function getForwardedAttributes( section ) {
var attributes = section.attributes;
var result = [];
for( var i = 0, len = attributes.length; i < len; i++ ) {
var name = attributes[i].name,
value = attributes[i].value;
// disregard attributes that are used for markdown loading/parsing
if( /data\-(markdown|separator|vertical|notes)/gi.test( name ) ) continue;
if( value ) {
result.push( name + '="' + value + '"' );
}
else {
result.push( name );
}
}
return result.join( ' ' );
}
|
[
"function",
"getForwardedAttributes",
"(",
"section",
")",
"{",
"var",
"attributes",
"=",
"section",
".",
"attributes",
";",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"attributes",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"name",
"=",
"attributes",
"[",
"i",
"]",
".",
"name",
",",
"value",
"=",
"attributes",
"[",
"i",
"]",
".",
"value",
";",
"// disregard attributes that are used for markdown loading/parsing",
"if",
"(",
"/",
"data\\-(markdown|separator|vertical|notes)",
"/",
"gi",
".",
"test",
"(",
"name",
")",
")",
"continue",
";",
"if",
"(",
"value",
")",
"{",
"result",
".",
"push",
"(",
"name",
"+",
"'=\"'",
"+",
"value",
"+",
"'\"'",
")",
";",
"}",
"else",
"{",
"result",
".",
"push",
"(",
"name",
")",
";",
"}",
"}",
"return",
"result",
".",
"join",
"(",
"' '",
")",
";",
"}"
] |
Given a markdown slide section element, this will
return all arguments that aren't related to markdown
parsing. Used to forward any other user-defined arguments
to the output markdown slide.
|
[
"Given",
"a",
"markdown",
"slide",
"section",
"element",
"this",
"will",
"return",
"all",
"arguments",
"that",
"aren",
"t",
"related",
"to",
"markdown",
"parsing",
".",
"Used",
"to",
"forward",
"any",
"other",
"user",
"-",
"defined",
"arguments",
"to",
"the",
"output",
"markdown",
"slide",
"."
] |
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
|
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/app/blog/static/js/common/reveal/markdown.js#L74-L96
|
13,620
|
xiongwilee/Gracejs
|
app/blog/static/js/common/reveal/markdown.js
|
getSlidifyOptions
|
function getSlidifyOptions( options ) {
options = options || {};
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
options.attributes = options.attributes || '';
return options;
}
|
javascript
|
function getSlidifyOptions( options ) {
options = options || {};
options.separator = options.separator || DEFAULT_SLIDE_SEPARATOR;
options.notesSeparator = options.notesSeparator || DEFAULT_NOTES_SEPARATOR;
options.attributes = options.attributes || '';
return options;
}
|
[
"function",
"getSlidifyOptions",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
".",
"separator",
"=",
"options",
".",
"separator",
"||",
"DEFAULT_SLIDE_SEPARATOR",
";",
"options",
".",
"notesSeparator",
"=",
"options",
".",
"notesSeparator",
"||",
"DEFAULT_NOTES_SEPARATOR",
";",
"options",
".",
"attributes",
"=",
"options",
".",
"attributes",
"||",
"''",
";",
"return",
"options",
";",
"}"
] |
Inspects the given options and fills out default
values for what's not defined.
|
[
"Inspects",
"the",
"given",
"options",
"and",
"fills",
"out",
"default",
"values",
"for",
"what",
"s",
"not",
"defined",
"."
] |
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
|
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/app/blog/static/js/common/reveal/markdown.js#L102-L111
|
13,621
|
xiongwilee/Gracejs
|
app/blog/static/js/common/reveal/markdown.js
|
slidify
|
function slidify( markdown, options ) {
options = getSlidifyOptions( options );
var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
horizontalSeparatorRegex = new RegExp( options.separator );
var matches,
lastIndex = 0,
isHorizontal,
wasHorizontal = true,
content,
sectionStack = [];
// iterate until all blocks between separators are stacked up
while( matches = separatorRegex.exec( markdown ) ) {
notes = null;
// determine direction (horizontal by default)
isHorizontal = horizontalSeparatorRegex.test( matches[0] );
if( !isHorizontal && wasHorizontal ) {
// create vertical stack
sectionStack.push( [] );
}
// pluck slide content from markdown input
content = markdown.substring( lastIndex, matches.index );
if( isHorizontal && wasHorizontal ) {
// add to horizontal stack
sectionStack.push( content );
}
else {
// add to vertical stack
sectionStack[sectionStack.length-1].push( content );
}
lastIndex = separatorRegex.lastIndex;
wasHorizontal = isHorizontal;
}
// add the remaining slide
( wasHorizontal ? sectionStack : sectionStack[sectionStack.length-1] ).push( markdown.substring( lastIndex ) );
var markdownSections = '';
// flatten the hierarchical stack, and insert <section data-markdown> tags
for( var i = 0, len = sectionStack.length; i < len; i++ ) {
// vertical
if( sectionStack[i] instanceof Array ) {
markdownSections += '<section '+ options.attributes +'>';
sectionStack[i].forEach( function( child ) {
markdownSections += '<section data-markdown>' + createMarkdownSlide( child, options ) + '</section>';
} );
markdownSections += '</section>';
}
else {
markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide( sectionStack[i], options ) + '</section>';
}
}
return markdownSections;
}
|
javascript
|
function slidify( markdown, options ) {
options = getSlidifyOptions( options );
var separatorRegex = new RegExp( options.separator + ( options.verticalSeparator ? '|' + options.verticalSeparator : '' ), 'mg' ),
horizontalSeparatorRegex = new RegExp( options.separator );
var matches,
lastIndex = 0,
isHorizontal,
wasHorizontal = true,
content,
sectionStack = [];
// iterate until all blocks between separators are stacked up
while( matches = separatorRegex.exec( markdown ) ) {
notes = null;
// determine direction (horizontal by default)
isHorizontal = horizontalSeparatorRegex.test( matches[0] );
if( !isHorizontal && wasHorizontal ) {
// create vertical stack
sectionStack.push( [] );
}
// pluck slide content from markdown input
content = markdown.substring( lastIndex, matches.index );
if( isHorizontal && wasHorizontal ) {
// add to horizontal stack
sectionStack.push( content );
}
else {
// add to vertical stack
sectionStack[sectionStack.length-1].push( content );
}
lastIndex = separatorRegex.lastIndex;
wasHorizontal = isHorizontal;
}
// add the remaining slide
( wasHorizontal ? sectionStack : sectionStack[sectionStack.length-1] ).push( markdown.substring( lastIndex ) );
var markdownSections = '';
// flatten the hierarchical stack, and insert <section data-markdown> tags
for( var i = 0, len = sectionStack.length; i < len; i++ ) {
// vertical
if( sectionStack[i] instanceof Array ) {
markdownSections += '<section '+ options.attributes +'>';
sectionStack[i].forEach( function( child ) {
markdownSections += '<section data-markdown>' + createMarkdownSlide( child, options ) + '</section>';
} );
markdownSections += '</section>';
}
else {
markdownSections += '<section '+ options.attributes +' data-markdown>' + createMarkdownSlide( sectionStack[i], options ) + '</section>';
}
}
return markdownSections;
}
|
[
"function",
"slidify",
"(",
"markdown",
",",
"options",
")",
"{",
"options",
"=",
"getSlidifyOptions",
"(",
"options",
")",
";",
"var",
"separatorRegex",
"=",
"new",
"RegExp",
"(",
"options",
".",
"separator",
"+",
"(",
"options",
".",
"verticalSeparator",
"?",
"'|'",
"+",
"options",
".",
"verticalSeparator",
":",
"''",
")",
",",
"'mg'",
")",
",",
"horizontalSeparatorRegex",
"=",
"new",
"RegExp",
"(",
"options",
".",
"separator",
")",
";",
"var",
"matches",
",",
"lastIndex",
"=",
"0",
",",
"isHorizontal",
",",
"wasHorizontal",
"=",
"true",
",",
"content",
",",
"sectionStack",
"=",
"[",
"]",
";",
"// iterate until all blocks between separators are stacked up",
"while",
"(",
"matches",
"=",
"separatorRegex",
".",
"exec",
"(",
"markdown",
")",
")",
"{",
"notes",
"=",
"null",
";",
"// determine direction (horizontal by default)",
"isHorizontal",
"=",
"horizontalSeparatorRegex",
".",
"test",
"(",
"matches",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"isHorizontal",
"&&",
"wasHorizontal",
")",
"{",
"// create vertical stack",
"sectionStack",
".",
"push",
"(",
"[",
"]",
")",
";",
"}",
"// pluck slide content from markdown input",
"content",
"=",
"markdown",
".",
"substring",
"(",
"lastIndex",
",",
"matches",
".",
"index",
")",
";",
"if",
"(",
"isHorizontal",
"&&",
"wasHorizontal",
")",
"{",
"// add to horizontal stack",
"sectionStack",
".",
"push",
"(",
"content",
")",
";",
"}",
"else",
"{",
"// add to vertical stack",
"sectionStack",
"[",
"sectionStack",
".",
"length",
"-",
"1",
"]",
".",
"push",
"(",
"content",
")",
";",
"}",
"lastIndex",
"=",
"separatorRegex",
".",
"lastIndex",
";",
"wasHorizontal",
"=",
"isHorizontal",
";",
"}",
"// add the remaining slide",
"(",
"wasHorizontal",
"?",
"sectionStack",
":",
"sectionStack",
"[",
"sectionStack",
".",
"length",
"-",
"1",
"]",
")",
".",
"push",
"(",
"markdown",
".",
"substring",
"(",
"lastIndex",
")",
")",
";",
"var",
"markdownSections",
"=",
"''",
";",
"// flatten the hierarchical stack, and insert <section data-markdown> tags",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"sectionStack",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"// vertical",
"if",
"(",
"sectionStack",
"[",
"i",
"]",
"instanceof",
"Array",
")",
"{",
"markdownSections",
"+=",
"'<section '",
"+",
"options",
".",
"attributes",
"+",
"'>'",
";",
"sectionStack",
"[",
"i",
"]",
".",
"forEach",
"(",
"function",
"(",
"child",
")",
"{",
"markdownSections",
"+=",
"'<section data-markdown>'",
"+",
"createMarkdownSlide",
"(",
"child",
",",
"options",
")",
"+",
"'</section>'",
";",
"}",
")",
";",
"markdownSections",
"+=",
"'</section>'",
";",
"}",
"else",
"{",
"markdownSections",
"+=",
"'<section '",
"+",
"options",
".",
"attributes",
"+",
"' data-markdown>'",
"+",
"createMarkdownSlide",
"(",
"sectionStack",
"[",
"i",
"]",
",",
"options",
")",
"+",
"'</section>'",
";",
"}",
"}",
"return",
"markdownSections",
";",
"}"
] |
Parses a data string into multiple slides based
on the passed in separator arguments.
|
[
"Parses",
"a",
"data",
"string",
"into",
"multiple",
"slides",
"based",
"on",
"the",
"passed",
"in",
"separator",
"arguments",
"."
] |
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
|
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/app/blog/static/js/common/reveal/markdown.js#L138-L204
|
13,622
|
xiongwilee/Gracejs
|
app/blog/static/js/common/reveal/markdown.js
|
addAttributeInElement
|
function addAttributeInElement( node, elementTarget, separator ) {
var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
var nodeValue = node.nodeValue;
if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
var classes = matches[1];
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
node.nodeValue = nodeValue;
while( matchesClass = mardownClassRegex.exec( classes ) ) {
elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
}
return true;
}
return false;
}
|
javascript
|
function addAttributeInElement( node, elementTarget, separator ) {
var mardownClassesInElementsRegex = new RegExp( separator, 'mg' );
var mardownClassRegex = new RegExp( "([^\"= ]+?)=\"([^\"=]+?)\"", 'mg' );
var nodeValue = node.nodeValue;
if( matches = mardownClassesInElementsRegex.exec( nodeValue ) ) {
var classes = matches[1];
nodeValue = nodeValue.substring( 0, matches.index ) + nodeValue.substring( mardownClassesInElementsRegex.lastIndex );
node.nodeValue = nodeValue;
while( matchesClass = mardownClassRegex.exec( classes ) ) {
elementTarget.setAttribute( matchesClass[1], matchesClass[2] );
}
return true;
}
return false;
}
|
[
"function",
"addAttributeInElement",
"(",
"node",
",",
"elementTarget",
",",
"separator",
")",
"{",
"var",
"mardownClassesInElementsRegex",
"=",
"new",
"RegExp",
"(",
"separator",
",",
"'mg'",
")",
";",
"var",
"mardownClassRegex",
"=",
"new",
"RegExp",
"(",
"\"([^\\\"= ]+?)=\\\"([^\\\"=]+?)\\\"\"",
",",
"'mg'",
")",
";",
"var",
"nodeValue",
"=",
"node",
".",
"nodeValue",
";",
"if",
"(",
"matches",
"=",
"mardownClassesInElementsRegex",
".",
"exec",
"(",
"nodeValue",
")",
")",
"{",
"var",
"classes",
"=",
"matches",
"[",
"1",
"]",
";",
"nodeValue",
"=",
"nodeValue",
".",
"substring",
"(",
"0",
",",
"matches",
".",
"index",
")",
"+",
"nodeValue",
".",
"substring",
"(",
"mardownClassesInElementsRegex",
".",
"lastIndex",
")",
";",
"node",
".",
"nodeValue",
"=",
"nodeValue",
";",
"while",
"(",
"matchesClass",
"=",
"mardownClassRegex",
".",
"exec",
"(",
"classes",
")",
")",
"{",
"elementTarget",
".",
"setAttribute",
"(",
"matchesClass",
"[",
"1",
"]",
",",
"matchesClass",
"[",
"2",
"]",
")",
";",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if a node value has the attributes pattern.
If yes, extract it and add that value as one or several attributes
the the terget element.
You need Cache Killer on Chrome to see the effect on any FOM transformation
directly on refresh (F5)
http://stackoverflow.com/questions/5690269/disabling-chrome-cache-for-website-development/7000899#answer-11786277
|
[
"Check",
"if",
"a",
"node",
"value",
"has",
"the",
"attributes",
"pattern",
".",
"If",
"yes",
"extract",
"it",
"and",
"add",
"that",
"value",
"as",
"one",
"or",
"several",
"attributes",
"the",
"the",
"terget",
"element",
"."
] |
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
|
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/app/blog/static/js/common/reveal/markdown.js#L293-L309
|
13,623
|
xiongwilee/Gracejs
|
app/blog/static/js/common/reveal/markdown.js
|
addAttributes
|
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
previousParentElement = element;
for( var i = 0; i < element.childNodes.length; i++ ) {
childElement = element.childNodes[i];
if ( i > 0 ) {
j = i - 1;
while ( j >= 0 ) {
aPreviousChildElement = element.childNodes[j];
if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR" ) {
previousParentElement = aPreviousChildElement;
break;
}
j = j - 1;
}
}
parentSection = section;
if( childElement.nodeName == "section" ) {
parentSection = childElement ;
previousParentElement = childElement ;
}
if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) {
addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
}
}
}
if ( element.nodeType == Node.COMMENT_NODE ) {
if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) {
addAttributeInElement( element, section, separatorSectionAttributes );
}
}
}
|
javascript
|
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {
if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
previousParentElement = element;
for( var i = 0; i < element.childNodes.length; i++ ) {
childElement = element.childNodes[i];
if ( i > 0 ) {
j = i - 1;
while ( j >= 0 ) {
aPreviousChildElement = element.childNodes[j];
if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR" ) {
previousParentElement = aPreviousChildElement;
break;
}
j = j - 1;
}
}
parentSection = section;
if( childElement.nodeName == "section" ) {
parentSection = childElement ;
previousParentElement = childElement ;
}
if ( typeof childElement.setAttribute == 'function' || childElement.nodeType == Node.COMMENT_NODE ) {
addAttributes( parentSection, childElement, previousParentElement, separatorElementAttributes, separatorSectionAttributes );
}
}
}
if ( element.nodeType == Node.COMMENT_NODE ) {
if ( addAttributeInElement( element, previousElement, separatorElementAttributes ) == false ) {
addAttributeInElement( element, section, separatorSectionAttributes );
}
}
}
|
[
"function",
"addAttributes",
"(",
"section",
",",
"element",
",",
"previousElement",
",",
"separatorElementAttributes",
",",
"separatorSectionAttributes",
")",
"{",
"if",
"(",
"element",
"!=",
"null",
"&&",
"element",
".",
"childNodes",
"!=",
"undefined",
"&&",
"element",
".",
"childNodes",
".",
"length",
">",
"0",
")",
"{",
"previousParentElement",
"=",
"element",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"element",
".",
"childNodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"childElement",
"=",
"element",
".",
"childNodes",
"[",
"i",
"]",
";",
"if",
"(",
"i",
">",
"0",
")",
"{",
"j",
"=",
"i",
"-",
"1",
";",
"while",
"(",
"j",
">=",
"0",
")",
"{",
"aPreviousChildElement",
"=",
"element",
".",
"childNodes",
"[",
"j",
"]",
";",
"if",
"(",
"typeof",
"aPreviousChildElement",
".",
"setAttribute",
"==",
"'function'",
"&&",
"aPreviousChildElement",
".",
"tagName",
"!=",
"\"BR\"",
")",
"{",
"previousParentElement",
"=",
"aPreviousChildElement",
";",
"break",
";",
"}",
"j",
"=",
"j",
"-",
"1",
";",
"}",
"}",
"parentSection",
"=",
"section",
";",
"if",
"(",
"childElement",
".",
"nodeName",
"==",
"\"section\"",
")",
"{",
"parentSection",
"=",
"childElement",
";",
"previousParentElement",
"=",
"childElement",
";",
"}",
"if",
"(",
"typeof",
"childElement",
".",
"setAttribute",
"==",
"'function'",
"||",
"childElement",
".",
"nodeType",
"==",
"Node",
".",
"COMMENT_NODE",
")",
"{",
"addAttributes",
"(",
"parentSection",
",",
"childElement",
",",
"previousParentElement",
",",
"separatorElementAttributes",
",",
"separatorSectionAttributes",
")",
";",
"}",
"}",
"}",
"if",
"(",
"element",
".",
"nodeType",
"==",
"Node",
".",
"COMMENT_NODE",
")",
"{",
"if",
"(",
"addAttributeInElement",
"(",
"element",
",",
"previousElement",
",",
"separatorElementAttributes",
")",
"==",
"false",
")",
"{",
"addAttributeInElement",
"(",
"element",
",",
"section",
",",
"separatorSectionAttributes",
")",
";",
"}",
"}",
"}"
] |
Add attributes to the parent element of a text node,
or the element of an attribute node.
|
[
"Add",
"attributes",
"to",
"the",
"parent",
"element",
"of",
"a",
"text",
"node",
"or",
"the",
"element",
"of",
"an",
"attribute",
"node",
"."
] |
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
|
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/app/blog/static/js/common/reveal/markdown.js#L315-L348
|
13,624
|
xiongwilee/Gracejs
|
app/blog/static/js/common/reveal/markdown.js
|
convertSlides
|
function convertSlides() {
var sections = document.querySelectorAll( '[data-markdown]');
for( var i = 0, len = sections.length; i < len; i++ ) {
var section = sections[i];
// Only parse the same slide once
if( !section.getAttribute( 'data-markdown-parsed' ) ) {
section.setAttribute( 'data-markdown-parsed', true )
var notes = section.querySelector( 'aside.notes' );
var markdown = getMarkdownFromSlide( section );
section.innerHTML = marked( markdown );
addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) ||
section.parentNode.getAttribute( 'data-element-attributes' ) ||
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR,
section.getAttribute( 'data-attributes' ) ||
section.parentNode.getAttribute( 'data-attributes' ) ||
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR);
// If there were notes, we need to re-add them after
// having overwritten the section's HTML
if( notes ) {
section.appendChild( notes );
}
}
}
}
|
javascript
|
function convertSlides() {
var sections = document.querySelectorAll( '[data-markdown]');
for( var i = 0, len = sections.length; i < len; i++ ) {
var section = sections[i];
// Only parse the same slide once
if( !section.getAttribute( 'data-markdown-parsed' ) ) {
section.setAttribute( 'data-markdown-parsed', true )
var notes = section.querySelector( 'aside.notes' );
var markdown = getMarkdownFromSlide( section );
section.innerHTML = marked( markdown );
addAttributes( section, section, null, section.getAttribute( 'data-element-attributes' ) ||
section.parentNode.getAttribute( 'data-element-attributes' ) ||
DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR,
section.getAttribute( 'data-attributes' ) ||
section.parentNode.getAttribute( 'data-attributes' ) ||
DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR);
// If there were notes, we need to re-add them after
// having overwritten the section's HTML
if( notes ) {
section.appendChild( notes );
}
}
}
}
|
[
"function",
"convertSlides",
"(",
")",
"{",
"var",
"sections",
"=",
"document",
".",
"querySelectorAll",
"(",
"'[data-markdown]'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"sections",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"var",
"section",
"=",
"sections",
"[",
"i",
"]",
";",
"// Only parse the same slide once",
"if",
"(",
"!",
"section",
".",
"getAttribute",
"(",
"'data-markdown-parsed'",
")",
")",
"{",
"section",
".",
"setAttribute",
"(",
"'data-markdown-parsed'",
",",
"true",
")",
"var",
"notes",
"=",
"section",
".",
"querySelector",
"(",
"'aside.notes'",
")",
";",
"var",
"markdown",
"=",
"getMarkdownFromSlide",
"(",
"section",
")",
";",
"section",
".",
"innerHTML",
"=",
"marked",
"(",
"markdown",
")",
";",
"addAttributes",
"(",
"section",
",",
"section",
",",
"null",
",",
"section",
".",
"getAttribute",
"(",
"'data-element-attributes'",
")",
"||",
"section",
".",
"parentNode",
".",
"getAttribute",
"(",
"'data-element-attributes'",
")",
"||",
"DEFAULT_ELEMENT_ATTRIBUTES_SEPARATOR",
",",
"section",
".",
"getAttribute",
"(",
"'data-attributes'",
")",
"||",
"section",
".",
"parentNode",
".",
"getAttribute",
"(",
"'data-attributes'",
")",
"||",
"DEFAULT_SLIDE_ATTRIBUTES_SEPARATOR",
")",
";",
"// If there were notes, we need to re-add them after",
"// having overwritten the section's HTML",
"if",
"(",
"notes",
")",
"{",
"section",
".",
"appendChild",
"(",
"notes",
")",
";",
"}",
"}",
"}",
"}"
] |
Converts any current data-markdown slides in the
DOM to HTML.
|
[
"Converts",
"any",
"current",
"data",
"-",
"markdown",
"slides",
"in",
"the",
"DOM",
"to",
"HTML",
"."
] |
a4ca954d28ddcd1c39a0b3eefe16e79a390fb507
|
https://github.com/xiongwilee/Gracejs/blob/a4ca954d28ddcd1c39a0b3eefe16e79a390fb507/app/blog/static/js/common/reveal/markdown.js#L354-L388
|
13,625
|
Shopify/node-themekit
|
lib/run-executable.js
|
runExecutable
|
function runExecutable(args, cwd, logLevel) {
const logger = require('./logger')(logLevel);
return new Promise((resolve, reject) => {
logger.silly('Theme Kit command starting');
let errors = '';
const pathToExecutable = path.join(config.destination, config.binName);
fs.statSync(pathToExecutable);
const childProcess = spawn(pathToExecutable, args, {
cwd,
stdio: ['inherit', 'inherit', 'pipe']
});
childProcess.on('error', (err) => {
errors += err;
});
childProcess.stderr.on('data', (err) => {
errors += err;
});
childProcess.on('close', () => {
logger.silly('Theme Kit command finished');
if (errors) {
reject(errors);
}
resolve();
});
});
}
|
javascript
|
function runExecutable(args, cwd, logLevel) {
const logger = require('./logger')(logLevel);
return new Promise((resolve, reject) => {
logger.silly('Theme Kit command starting');
let errors = '';
const pathToExecutable = path.join(config.destination, config.binName);
fs.statSync(pathToExecutable);
const childProcess = spawn(pathToExecutable, args, {
cwd,
stdio: ['inherit', 'inherit', 'pipe']
});
childProcess.on('error', (err) => {
errors += err;
});
childProcess.stderr.on('data', (err) => {
errors += err;
});
childProcess.on('close', () => {
logger.silly('Theme Kit command finished');
if (errors) {
reject(errors);
}
resolve();
});
});
}
|
[
"function",
"runExecutable",
"(",
"args",
",",
"cwd",
",",
"logLevel",
")",
"{",
"const",
"logger",
"=",
"require",
"(",
"'./logger'",
")",
"(",
"logLevel",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"logger",
".",
"silly",
"(",
"'Theme Kit command starting'",
")",
";",
"let",
"errors",
"=",
"''",
";",
"const",
"pathToExecutable",
"=",
"path",
".",
"join",
"(",
"config",
".",
"destination",
",",
"config",
".",
"binName",
")",
";",
"fs",
".",
"statSync",
"(",
"pathToExecutable",
")",
";",
"const",
"childProcess",
"=",
"spawn",
"(",
"pathToExecutable",
",",
"args",
",",
"{",
"cwd",
",",
"stdio",
":",
"[",
"'inherit'",
",",
"'inherit'",
",",
"'pipe'",
"]",
"}",
")",
";",
"childProcess",
".",
"on",
"(",
"'error'",
",",
"(",
"err",
")",
"=>",
"{",
"errors",
"+=",
"err",
";",
"}",
")",
";",
"childProcess",
".",
"stderr",
".",
"on",
"(",
"'data'",
",",
"(",
"err",
")",
"=>",
"{",
"errors",
"+=",
"err",
";",
"}",
")",
";",
"childProcess",
".",
"on",
"(",
"'close'",
",",
"(",
")",
"=>",
"{",
"logger",
".",
"silly",
"(",
"'Theme Kit command finished'",
")",
";",
"if",
"(",
"errors",
")",
"{",
"reject",
"(",
"errors",
")",
";",
"}",
"resolve",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Spawns a child process to run the Theme Kit executable with given parameters
@param {string[]} args array to pass to the executable
@param {string} cwd directory to run command on
@param {string} logLevel level of logging required
|
[
"Spawns",
"a",
"child",
"process",
"to",
"run",
"the",
"Theme",
"Kit",
"executable",
"with",
"given",
"parameters"
] |
8f71a778b301dffda673181c651f58b368b25293
|
https://github.com/Shopify/node-themekit/blob/8f71a778b301dffda673181c651f58b368b25293/lib/run-executable.js#L13-L43
|
13,626
|
Shopify/node-themekit
|
lib/utils.js
|
cleanFile
|
function cleanFile(pathToFile) {
try {
fs.unlinkSync(pathToFile);
} catch (err) {
switch (err.code) {
case 'ENOENT':
return;
default:
throw new Error(err);
}
}
}
|
javascript
|
function cleanFile(pathToFile) {
try {
fs.unlinkSync(pathToFile);
} catch (err) {
switch (err.code) {
case 'ENOENT':
return;
default:
throw new Error(err);
}
}
}
|
[
"function",
"cleanFile",
"(",
"pathToFile",
")",
"{",
"try",
"{",
"fs",
".",
"unlinkSync",
"(",
"pathToFile",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"switch",
"(",
"err",
".",
"code",
")",
"{",
"case",
"'ENOENT'",
":",
"return",
";",
"default",
":",
"throw",
"new",
"Error",
"(",
"err",
")",
";",
"}",
"}",
"}"
] |
Deletes a file from the filesystem if it exists.
Does nothing if it doesn't do anything.
@param {string} pathToFile path to file to delete
|
[
"Deletes",
"a",
"file",
"from",
"the",
"filesystem",
"if",
"it",
"exists",
".",
"Does",
"nothing",
"if",
"it",
"doesn",
"t",
"do",
"anything",
"."
] |
8f71a778b301dffda673181c651f58b368b25293
|
https://github.com/Shopify/node-themekit/blob/8f71a778b301dffda673181c651f58b368b25293/lib/utils.js#L8-L19
|
13,627
|
splunk/splunk-sdk-javascript
|
contrib/dox/doc_builder.js
|
function () {
var module = "Global";
for(var i = 0; i < doc.tags.length; i++) {
var tag = doc.tags[i];
if (tag.type === "method") {
module = tag.content;
}
else if (tag.type === "function") {
module = tag.content;
}
}
return module.trim();
}
|
javascript
|
function () {
var module = "Global";
for(var i = 0; i < doc.tags.length; i++) {
var tag = doc.tags[i];
if (tag.type === "method") {
module = tag.content;
}
else if (tag.type === "function") {
module = tag.content;
}
}
return module.trim();
}
|
[
"function",
"(",
")",
"{",
"var",
"module",
"=",
"\"Global\"",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"doc",
".",
"tags",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"tag",
"=",
"doc",
".",
"tags",
"[",
"i",
"]",
";",
"if",
"(",
"tag",
".",
"type",
"===",
"\"method\"",
")",
"{",
"module",
"=",
"tag",
".",
"content",
";",
"}",
"else",
"if",
"(",
"tag",
".",
"type",
"===",
"\"function\"",
")",
"{",
"module",
"=",
"tag",
".",
"content",
";",
"}",
"}",
"return",
"module",
".",
"trim",
"(",
")",
";",
"}"
] |
Find the parent module and note the name
|
[
"Find",
"the",
"parent",
"module",
"and",
"note",
"the",
"name"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/contrib/dox/doc_builder.js#L67-L80
|
|
13,628
|
splunk/splunk-sdk-javascript
|
lib/http.js
|
function() {
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this.get = utils.bind(this, this.get);
this.del = utils.bind(this, this.del);
this.post = utils.bind(this, this.post);
this.request = utils.bind(this, this.request);
this._buildResponse = utils.bind(this, this._buildResponse);
// Set our default version to "none"
this._setSplunkVersion("none");
// Cookie store for cookie based authentication.
this._cookieStore = {};
}
|
javascript
|
function() {
// We perform the bindings so that every function works
// properly when it is passed as a callback.
this.get = utils.bind(this, this.get);
this.del = utils.bind(this, this.del);
this.post = utils.bind(this, this.post);
this.request = utils.bind(this, this.request);
this._buildResponse = utils.bind(this, this._buildResponse);
// Set our default version to "none"
this._setSplunkVersion("none");
// Cookie store for cookie based authentication.
this._cookieStore = {};
}
|
[
"function",
"(",
")",
"{",
"// We perform the bindings so that every function works",
"// properly when it is passed as a callback.",
"this",
".",
"get",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"get",
")",
";",
"this",
".",
"del",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"del",
")",
";",
"this",
".",
"post",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"post",
")",
";",
"this",
".",
"request",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"request",
")",
";",
"this",
".",
"_buildResponse",
"=",
"utils",
".",
"bind",
"(",
"this",
",",
"this",
".",
"_buildResponse",
")",
";",
"// Set our default version to \"none\"",
"this",
".",
"_setSplunkVersion",
"(",
"\"none\"",
")",
";",
"// Cookie store for cookie based authentication.",
"this",
".",
"_cookieStore",
"=",
"{",
"}",
";",
"}"
] |
Constructor for `splunkjs.Http`.
@constructor
@return {splunkjs.Http} A new `splunkjs.Http` instance.
@method splunkjs.Http
|
[
"Constructor",
"for",
"splunkjs",
".",
"Http",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/http.js#L72-L87
|
|
13,629
|
splunk/splunk-sdk-javascript
|
lib/http.js
|
function() {
var cookieString = "";
utils.forEach(this._cookieStore, function (cookieValue, cookieKey) {
cookieString += cookieKey;
cookieString += '=';
cookieString += cookieValue;
cookieString += '; ';
});
return cookieString;
}
|
javascript
|
function() {
var cookieString = "";
utils.forEach(this._cookieStore, function (cookieValue, cookieKey) {
cookieString += cookieKey;
cookieString += '=';
cookieString += cookieValue;
cookieString += '; ';
});
return cookieString;
}
|
[
"function",
"(",
")",
"{",
"var",
"cookieString",
"=",
"\"\"",
";",
"utils",
".",
"forEach",
"(",
"this",
".",
"_cookieStore",
",",
"function",
"(",
"cookieValue",
",",
"cookieKey",
")",
"{",
"cookieString",
"+=",
"cookieKey",
";",
"cookieString",
"+=",
"'='",
";",
"cookieString",
"+=",
"cookieValue",
";",
"cookieString",
"+=",
"'; '",
";",
"}",
")",
";",
"return",
"cookieString",
";",
"}"
] |
Returns all cookies formatted as a string to be put into the Cookie Header.
|
[
"Returns",
"all",
"cookies",
"formatted",
"as",
"a",
"string",
"to",
"be",
"put",
"into",
"the",
"Cookie",
"Header",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/http.js#L97-L109
|
|
13,630
|
splunk/splunk-sdk-javascript
|
lib/http.js
|
function(url, headers, params, timeout, callback) {
var message = {
method: "GET",
headers: headers,
timeout: timeout,
query: params
};
return this.request(url, message, callback);
}
|
javascript
|
function(url, headers, params, timeout, callback) {
var message = {
method: "GET",
headers: headers,
timeout: timeout,
query: params
};
return this.request(url, message, callback);
}
|
[
"function",
"(",
"url",
",",
"headers",
",",
"params",
",",
"timeout",
",",
"callback",
")",
"{",
"var",
"message",
"=",
"{",
"method",
":",
"\"GET\"",
",",
"headers",
":",
"headers",
",",
"timeout",
":",
"timeout",
",",
"query",
":",
"params",
"}",
";",
"return",
"this",
".",
"request",
"(",
"url",
",",
"message",
",",
"callback",
")",
";",
"}"
] |
Performs a GET request.
@param {String} url The URL of the GET request.
@param {Object} headers An object of headers for this request.
@param {Object} params Parameters for this request.
@param {Number} timeout A timeout period.
@param {Function} callback The function to call when the request is complete: `(err, response)`.
@method splunkjs.Http
|
[
"Performs",
"a",
"GET",
"request",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/http.js#L142-L151
|
|
13,631
|
splunk/splunk-sdk-javascript
|
lib/http.js
|
function(url, message, callback) {
var that = this;
var wrappedCallback = function(response) {
callback = callback || function() {};
// Handle cookies if 'set-cookie' header is in the response
var cookieHeaders = response.response.headers['set-cookie'];
if (cookieHeaders) {
utils.forEach(cookieHeaders, function (cookieHeader) {
var cookie = that._parseCookieHeader(cookieHeader);
that._cookieStore[cookie.key] = cookie.value;
});
}
// Handle callback
if (response.status < 400 && response.status !== "abort") {
callback(null, response);
}
else {
callback(response);
}
};
var query = utils.getWithVersion(this.version, queryBuilderMap)(message);
var post = message.post || {};
var encodedUrl = url + "?" + Http.encode(query);
var body = message.body ? message.body : Http.encode(post);
var cookieString = that._getCookieString();
if (cookieString.length !== 0) {
message.headers["Cookie"] = cookieString;
// Remove Authorization header
// Splunk will use Authorization header and ignore Cookies if Authorization header is sent
delete message.headers["Authorization"];
}
var options = {
method: message.method,
headers: message.headers,
timeout: message.timeout,
body: body
};
// Now we can invoke the user-provided HTTP class,
// passing in our "wrapped" callback
return this.makeRequest(encodedUrl, options, wrappedCallback);
}
|
javascript
|
function(url, message, callback) {
var that = this;
var wrappedCallback = function(response) {
callback = callback || function() {};
// Handle cookies if 'set-cookie' header is in the response
var cookieHeaders = response.response.headers['set-cookie'];
if (cookieHeaders) {
utils.forEach(cookieHeaders, function (cookieHeader) {
var cookie = that._parseCookieHeader(cookieHeader);
that._cookieStore[cookie.key] = cookie.value;
});
}
// Handle callback
if (response.status < 400 && response.status !== "abort") {
callback(null, response);
}
else {
callback(response);
}
};
var query = utils.getWithVersion(this.version, queryBuilderMap)(message);
var post = message.post || {};
var encodedUrl = url + "?" + Http.encode(query);
var body = message.body ? message.body : Http.encode(post);
var cookieString = that._getCookieString();
if (cookieString.length !== 0) {
message.headers["Cookie"] = cookieString;
// Remove Authorization header
// Splunk will use Authorization header and ignore Cookies if Authorization header is sent
delete message.headers["Authorization"];
}
var options = {
method: message.method,
headers: message.headers,
timeout: message.timeout,
body: body
};
// Now we can invoke the user-provided HTTP class,
// passing in our "wrapped" callback
return this.makeRequest(encodedUrl, options, wrappedCallback);
}
|
[
"function",
"(",
"url",
",",
"message",
",",
"callback",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"wrappedCallback",
"=",
"function",
"(",
"response",
")",
"{",
"callback",
"=",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
";",
"// Handle cookies if 'set-cookie' header is in the response",
"var",
"cookieHeaders",
"=",
"response",
".",
"response",
".",
"headers",
"[",
"'set-cookie'",
"]",
";",
"if",
"(",
"cookieHeaders",
")",
"{",
"utils",
".",
"forEach",
"(",
"cookieHeaders",
",",
"function",
"(",
"cookieHeader",
")",
"{",
"var",
"cookie",
"=",
"that",
".",
"_parseCookieHeader",
"(",
"cookieHeader",
")",
";",
"that",
".",
"_cookieStore",
"[",
"cookie",
".",
"key",
"]",
"=",
"cookie",
".",
"value",
";",
"}",
")",
";",
"}",
"// Handle callback",
"if",
"(",
"response",
".",
"status",
"<",
"400",
"&&",
"response",
".",
"status",
"!==",
"\"abort\"",
")",
"{",
"callback",
"(",
"null",
",",
"response",
")",
";",
"}",
"else",
"{",
"callback",
"(",
"response",
")",
";",
"}",
"}",
";",
"var",
"query",
"=",
"utils",
".",
"getWithVersion",
"(",
"this",
".",
"version",
",",
"queryBuilderMap",
")",
"(",
"message",
")",
";",
"var",
"post",
"=",
"message",
".",
"post",
"||",
"{",
"}",
";",
"var",
"encodedUrl",
"=",
"url",
"+",
"\"?\"",
"+",
"Http",
".",
"encode",
"(",
"query",
")",
";",
"var",
"body",
"=",
"message",
".",
"body",
"?",
"message",
".",
"body",
":",
"Http",
".",
"encode",
"(",
"post",
")",
";",
"var",
"cookieString",
"=",
"that",
".",
"_getCookieString",
"(",
")",
";",
"if",
"(",
"cookieString",
".",
"length",
"!==",
"0",
")",
"{",
"message",
".",
"headers",
"[",
"\"Cookie\"",
"]",
"=",
"cookieString",
";",
"// Remove Authorization header",
"// Splunk will use Authorization header and ignore Cookies if Authorization header is sent",
"delete",
"message",
".",
"headers",
"[",
"\"Authorization\"",
"]",
";",
"}",
"var",
"options",
"=",
"{",
"method",
":",
"message",
".",
"method",
",",
"headers",
":",
"message",
".",
"headers",
",",
"timeout",
":",
"message",
".",
"timeout",
",",
"body",
":",
"body",
"}",
";",
"// Now we can invoke the user-provided HTTP class,",
"// passing in our \"wrapped\" callback",
"return",
"this",
".",
"makeRequest",
"(",
"encodedUrl",
",",
"options",
",",
"wrappedCallback",
")",
";",
"}"
] |
Performs a request.
This function sets up how to handle a response from a request, but
delegates calling the request to the `makeRequest` subclass.
@param {String} url The encoded URL of the request.
@param {Object} message An object with values for method, headers, timeout, and encoded body.
@param {Function} callback The function to call when the request is complete: `(err, response)`.
@method splunkjs.Http
@see makeRequest
|
[
"Performs",
"a",
"request",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/http.js#L211-L262
|
|
13,632
|
splunk/splunk-sdk-javascript
|
lib/http.js
|
function(error, response, data) {
var complete_response, json = {};
var contentType = null;
if (response && response.headers) {
contentType = utils.trim(response.headers["content-type"] || response.headers["Content-Type"] || response.headers["Content-type"] || response.headers["contentType"]);
}
if (utils.startsWith(contentType, "application/json") && data) {
try {
json = this.parseJson(data) || {};
}
catch(e) {
logger.error("Error in parsing JSON:", data, e);
json = data;
}
}
else {
json = data;
}
if (json) {
logger.printMessages(json.messages);
}
complete_response = {
response: response,
status: (response ? response.statusCode : 0),
data: json,
error: error
};
return complete_response;
}
|
javascript
|
function(error, response, data) {
var complete_response, json = {};
var contentType = null;
if (response && response.headers) {
contentType = utils.trim(response.headers["content-type"] || response.headers["Content-Type"] || response.headers["Content-type"] || response.headers["contentType"]);
}
if (utils.startsWith(contentType, "application/json") && data) {
try {
json = this.parseJson(data) || {};
}
catch(e) {
logger.error("Error in parsing JSON:", data, e);
json = data;
}
}
else {
json = data;
}
if (json) {
logger.printMessages(json.messages);
}
complete_response = {
response: response,
status: (response ? response.statusCode : 0),
data: json,
error: error
};
return complete_response;
}
|
[
"function",
"(",
"error",
",",
"response",
",",
"data",
")",
"{",
"var",
"complete_response",
",",
"json",
"=",
"{",
"}",
";",
"var",
"contentType",
"=",
"null",
";",
"if",
"(",
"response",
"&&",
"response",
".",
"headers",
")",
"{",
"contentType",
"=",
"utils",
".",
"trim",
"(",
"response",
".",
"headers",
"[",
"\"content-type\"",
"]",
"||",
"response",
".",
"headers",
"[",
"\"Content-Type\"",
"]",
"||",
"response",
".",
"headers",
"[",
"\"Content-type\"",
"]",
"||",
"response",
".",
"headers",
"[",
"\"contentType\"",
"]",
")",
";",
"}",
"if",
"(",
"utils",
".",
"startsWith",
"(",
"contentType",
",",
"\"application/json\"",
")",
"&&",
"data",
")",
"{",
"try",
"{",
"json",
"=",
"this",
".",
"parseJson",
"(",
"data",
")",
"||",
"{",
"}",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"\"Error in parsing JSON:\"",
",",
"data",
",",
"e",
")",
";",
"json",
"=",
"data",
";",
"}",
"}",
"else",
"{",
"json",
"=",
"data",
";",
"}",
"if",
"(",
"json",
")",
"{",
"logger",
".",
"printMessages",
"(",
"json",
".",
"messages",
")",
";",
"}",
"complete_response",
"=",
"{",
"response",
":",
"response",
",",
"status",
":",
"(",
"response",
"?",
"response",
".",
"statusCode",
":",
"0",
")",
",",
"data",
":",
"json",
",",
"error",
":",
"error",
"}",
";",
"return",
"complete_response",
";",
"}"
] |
Generates a unified response with the given parameters.
@param {Object} error An error object, if one exists for the request.
@param {Object} response The response object.
@param {Object} data The response data.
@return {Object} A unified response object.
@method splunkjs.Http
|
[
"Generates",
"a",
"unified",
"response",
"with",
"the",
"given",
"parameters",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/http.js#L300-L333
|
|
13,633
|
splunk/splunk-sdk-javascript
|
examples/node/helloworld/search_oneshot.js
|
function(results, done) {
// Find the index of the fields we want
var rawIndex = results.fields.indexOf("_raw");
var sourcetypeIndex = results.fields.indexOf("sourcetype");
var userIndex = results.fields.indexOf("user");
// Print out each result and the key-value pairs we want
console.log("Results: ");
for(var i = 0; i < results.rows.length; i++) {
console.log(" Result " + i + ": ");
console.log(" sourcetype: " + results.rows[i][sourcetypeIndex]);
console.log(" user: " + results.rows[i][userIndex]);
console.log(" _raw: " + results.rows[i][rawIndex]);
}
done();
}
|
javascript
|
function(results, done) {
// Find the index of the fields we want
var rawIndex = results.fields.indexOf("_raw");
var sourcetypeIndex = results.fields.indexOf("sourcetype");
var userIndex = results.fields.indexOf("user");
// Print out each result and the key-value pairs we want
console.log("Results: ");
for(var i = 0; i < results.rows.length; i++) {
console.log(" Result " + i + ": ");
console.log(" sourcetype: " + results.rows[i][sourcetypeIndex]);
console.log(" user: " + results.rows[i][userIndex]);
console.log(" _raw: " + results.rows[i][rawIndex]);
}
done();
}
|
[
"function",
"(",
"results",
",",
"done",
")",
"{",
"// Find the index of the fields we want",
"var",
"rawIndex",
"=",
"results",
".",
"fields",
".",
"indexOf",
"(",
"\"_raw\"",
")",
";",
"var",
"sourcetypeIndex",
"=",
"results",
".",
"fields",
".",
"indexOf",
"(",
"\"sourcetype\"",
")",
";",
"var",
"userIndex",
"=",
"results",
".",
"fields",
".",
"indexOf",
"(",
"\"user\"",
")",
";",
"// Print out each result and the key-value pairs we want",
"console",
".",
"log",
"(",
"\"Results: \"",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"results",
".",
"rows",
".",
"length",
";",
"i",
"++",
")",
"{",
"console",
".",
"log",
"(",
"\" Result \"",
"+",
"i",
"+",
"\": \"",
")",
";",
"console",
".",
"log",
"(",
"\" sourcetype: \"",
"+",
"results",
".",
"rows",
"[",
"i",
"]",
"[",
"sourcetypeIndex",
"]",
")",
";",
"console",
".",
"log",
"(",
"\" user: \"",
"+",
"results",
".",
"rows",
"[",
"i",
"]",
"[",
"userIndex",
"]",
")",
";",
"console",
".",
"log",
"(",
"\" _raw: \"",
"+",
"results",
".",
"rows",
"[",
"i",
"]",
"[",
"rawIndex",
"]",
")",
";",
"}",
"done",
"(",
")",
";",
"}"
] |
The job is done, and the results are returned inline
|
[
"The",
"job",
"is",
"done",
"and",
"the",
"results",
"are",
"returned",
"inline"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/examples/node/helloworld/search_oneshot.js#L58-L74
|
|
13,634
|
splunk/splunk-sdk-javascript
|
examples/node/helloworld/search_realtime.js
|
function(job, done) {
var MAX_COUNT = 5;
var count = 0;
Async.whilst(
// Loop for N times
function() { return MAX_COUNT > count; },
// Every second, ask for preview results
function(iterationDone) {
Async.sleep(1000, function() {
job.preview({}, function(err, results) {
if (err) {
iterationDone(err);
return;
}
// Only do something if we have results
if (results && results.rows) {
// Up the iteration counter
count++;
console.log("========== Iteration " + count + " ==========");
var sourcetypeIndex = results.fields.indexOf("sourcetype");
var countIndex = results.fields.indexOf("count");
for(var i = 0; i < results.rows.length; i++) {
var row = results.rows[i];
// This is a hacky "padding" solution
var stat = (" " + row[sourcetypeIndex] + " ").slice(0, 30);
// Print out the sourcetype and the count of the sourcetype so far
console.log(stat + row[countIndex]);
}
console.log("=================================");
}
// And we're done with this iteration
iterationDone();
});
});
},
// When we're done looping, just cancel the job
function(err) {
job.cancel(done);
}
);
}
|
javascript
|
function(job, done) {
var MAX_COUNT = 5;
var count = 0;
Async.whilst(
// Loop for N times
function() { return MAX_COUNT > count; },
// Every second, ask for preview results
function(iterationDone) {
Async.sleep(1000, function() {
job.preview({}, function(err, results) {
if (err) {
iterationDone(err);
return;
}
// Only do something if we have results
if (results && results.rows) {
// Up the iteration counter
count++;
console.log("========== Iteration " + count + " ==========");
var sourcetypeIndex = results.fields.indexOf("sourcetype");
var countIndex = results.fields.indexOf("count");
for(var i = 0; i < results.rows.length; i++) {
var row = results.rows[i];
// This is a hacky "padding" solution
var stat = (" " + row[sourcetypeIndex] + " ").slice(0, 30);
// Print out the sourcetype and the count of the sourcetype so far
console.log(stat + row[countIndex]);
}
console.log("=================================");
}
// And we're done with this iteration
iterationDone();
});
});
},
// When we're done looping, just cancel the job
function(err) {
job.cancel(done);
}
);
}
|
[
"function",
"(",
"job",
",",
"done",
")",
"{",
"var",
"MAX_COUNT",
"=",
"5",
";",
"var",
"count",
"=",
"0",
";",
"Async",
".",
"whilst",
"(",
"// Loop for N times",
"function",
"(",
")",
"{",
"return",
"MAX_COUNT",
">",
"count",
";",
"}",
",",
"// Every second, ask for preview results",
"function",
"(",
"iterationDone",
")",
"{",
"Async",
".",
"sleep",
"(",
"1000",
",",
"function",
"(",
")",
"{",
"job",
".",
"preview",
"(",
"{",
"}",
",",
"function",
"(",
"err",
",",
"results",
")",
"{",
"if",
"(",
"err",
")",
"{",
"iterationDone",
"(",
"err",
")",
";",
"return",
";",
"}",
"// Only do something if we have results",
"if",
"(",
"results",
"&&",
"results",
".",
"rows",
")",
"{",
"// Up the iteration counter",
"count",
"++",
";",
"console",
".",
"log",
"(",
"\"========== Iteration \"",
"+",
"count",
"+",
"\" ==========\"",
")",
";",
"var",
"sourcetypeIndex",
"=",
"results",
".",
"fields",
".",
"indexOf",
"(",
"\"sourcetype\"",
")",
";",
"var",
"countIndex",
"=",
"results",
".",
"fields",
".",
"indexOf",
"(",
"\"count\"",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"results",
".",
"rows",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"row",
"=",
"results",
".",
"rows",
"[",
"i",
"]",
";",
"// This is a hacky \"padding\" solution",
"var",
"stat",
"=",
"(",
"\" \"",
"+",
"row",
"[",
"sourcetypeIndex",
"]",
"+",
"\" \"",
")",
".",
"slice",
"(",
"0",
",",
"30",
")",
";",
"// Print out the sourcetype and the count of the sourcetype so far",
"console",
".",
"log",
"(",
"stat",
"+",
"row",
"[",
"countIndex",
"]",
")",
";",
"}",
"console",
".",
"log",
"(",
"\"=================================\"",
")",
";",
"}",
"// And we're done with this iteration",
"iterationDone",
"(",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
",",
"// When we're done looping, just cancel the job",
"function",
"(",
"err",
")",
"{",
"job",
".",
"cancel",
"(",
"done",
")",
";",
"}",
")",
";",
"}"
] |
The search is never going to be done, so we simply poll it every second to get more results
|
[
"The",
"search",
"is",
"never",
"going",
"to",
"be",
"done",
"so",
"we",
"simply",
"poll",
"it",
"every",
"second",
"to",
"get",
"more",
"results"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/examples/node/helloworld/search_realtime.js#L61-L109
|
|
13,635
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.timeline.js
|
function(script)
{
// create local undefined vars so that script cannot access private vars
var _namespaces = undefined;
var _imported = undefined;
var _loading = undefined;
var _classPaths = undefined;
var _classInfo = undefined;
var _classDependencyList = undefined;
var _mixinCount = undefined;
var _mixinDependencies = undefined;
var _evalScript = undefined;
var _appendConstructor = undefined;
// set arguments to undefined so that script cannot access
arguments = undefined;
// eval script in context of window
eval.call(window, script);
}
|
javascript
|
function(script)
{
// create local undefined vars so that script cannot access private vars
var _namespaces = undefined;
var _imported = undefined;
var _loading = undefined;
var _classPaths = undefined;
var _classInfo = undefined;
var _classDependencyList = undefined;
var _mixinCount = undefined;
var _mixinDependencies = undefined;
var _evalScript = undefined;
var _appendConstructor = undefined;
// set arguments to undefined so that script cannot access
arguments = undefined;
// eval script in context of window
eval.call(window, script);
}
|
[
"function",
"(",
"script",
")",
"{",
"// create local undefined vars so that script cannot access private vars",
"var",
"_namespaces",
"=",
"undefined",
";",
"var",
"_imported",
"=",
"undefined",
";",
"var",
"_loading",
"=",
"undefined",
";",
"var",
"_classPaths",
"=",
"undefined",
";",
"var",
"_classInfo",
"=",
"undefined",
";",
"var",
"_classDependencyList",
"=",
"undefined",
";",
"var",
"_mixinCount",
"=",
"undefined",
";",
"var",
"_mixinDependencies",
"=",
"undefined",
";",
"var",
"_evalScript",
"=",
"undefined",
";",
"var",
"_appendConstructor",
"=",
"undefined",
";",
"// set arguments to undefined so that script cannot access",
"arguments",
"=",
"undefined",
";",
"// eval script in context of window",
"eval",
".",
"call",
"(",
"window",
",",
"script",
")",
";",
"}"
] |
Private Functions
Function for evaluating dynamically loaded scripts.
|
[
"Private",
"Functions",
"Function",
"for",
"evaluating",
"dynamically",
"loaded",
"scripts",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.timeline.js#L509-L528
|
|
13,636
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/i18n.js
|
ungettext
|
function ungettext(msgid1, msgid2, n) {
if (_i18n_locale.locale_name == 'en_DEBUG') return __debug_trans_str(msgid1);
var id = ''+_i18n_plural(n)+'-'+msgid1;
var entry = _i18n_catalog[id];
return entry == undefined ? (n==1 ? msgid1 : msgid2) : entry;
}
|
javascript
|
function ungettext(msgid1, msgid2, n) {
if (_i18n_locale.locale_name == 'en_DEBUG') return __debug_trans_str(msgid1);
var id = ''+_i18n_plural(n)+'-'+msgid1;
var entry = _i18n_catalog[id];
return entry == undefined ? (n==1 ? msgid1 : msgid2) : entry;
}
|
[
"function",
"ungettext",
"(",
"msgid1",
",",
"msgid2",
",",
"n",
")",
"{",
"if",
"(",
"_i18n_locale",
".",
"locale_name",
"==",
"'en_DEBUG'",
")",
"return",
"__debug_trans_str",
"(",
"msgid1",
")",
";",
"var",
"id",
"=",
"''",
"+",
"_i18n_plural",
"(",
"n",
")",
"+",
"'-'",
"+",
"msgid1",
";",
"var",
"entry",
"=",
"_i18n_catalog",
"[",
"id",
"]",
";",
"return",
"entry",
"==",
"undefined",
"?",
"(",
"n",
"==",
"1",
"?",
"msgid1",
":",
"msgid2",
")",
":",
"entry",
";",
"}"
] |
Translate a string containing a number
Eg. ungettext('Delete %(files)d file?', 'Delete %(files)d files?', files)
Use in conjuction with sprintf():
sprintf( ungettext('Delete %(files)d file?', 'Delete %(files)d files?', files), { files: 14 } )
|
[
"Translate",
"a",
"string",
"containing",
"a",
"number"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/i18n.js#L46-L51
|
13,637
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/i18n.js
|
Time
|
function Time(hour, minute, second, microsecond) {
if (_i18n_locale.locale_name == 'en_DEBUG') {
this.hour = 11;
this.minute = 22;
this.second = 33;
this.microsecond = 123000;
} else {
this.hour = hour;
this.minute = minute;
this.second = second;
this.microsecond = microsecond ? microsecond : 0;
}
}
|
javascript
|
function Time(hour, minute, second, microsecond) {
if (_i18n_locale.locale_name == 'en_DEBUG') {
this.hour = 11;
this.minute = 22;
this.second = 33;
this.microsecond = 123000;
} else {
this.hour = hour;
this.minute = minute;
this.second = second;
this.microsecond = microsecond ? microsecond : 0;
}
}
|
[
"function",
"Time",
"(",
"hour",
",",
"minute",
",",
"second",
",",
"microsecond",
")",
"{",
"if",
"(",
"_i18n_locale",
".",
"locale_name",
"==",
"'en_DEBUG'",
")",
"{",
"this",
".",
"hour",
"=",
"11",
";",
"this",
".",
"minute",
"=",
"22",
";",
"this",
".",
"second",
"=",
"33",
";",
"this",
".",
"microsecond",
"=",
"123000",
";",
"}",
"else",
"{",
"this",
".",
"hour",
"=",
"hour",
";",
"this",
".",
"minute",
"=",
"minute",
";",
"this",
".",
"second",
"=",
"second",
";",
"this",
".",
"microsecond",
"=",
"microsecond",
"?",
"microsecond",
":",
"0",
";",
"}",
"}"
] |
Class to hold time information in lieu of datetime.time
|
[
"Class",
"to",
"hold",
"time",
"information",
"in",
"lieu",
"of",
"datetime",
".",
"time"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/i18n.js#L294-L306
|
13,638
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/i18n.js
|
DateTime
|
function DateTime(date) {
if (date instanceof DateTime)
return date;
if (_i18n_locale.locale_name == 'en_DEBUG')
date = new Date(3333, 10, 22, 11, 22, 33, 123);
if (date instanceof Date) {
this.date = date;
this.hour = date.getHours();
this.minute = date.getMinutes();
this.second = date.getSeconds();
this.microsecond = 0;
this.year = date.getFullYear();
this.month = date.getMonth()+1;
this.day = date.getDate();
} else {
for(var k in date) {
this[k] = date[k];
}
}
}
|
javascript
|
function DateTime(date) {
if (date instanceof DateTime)
return date;
if (_i18n_locale.locale_name == 'en_DEBUG')
date = new Date(3333, 10, 22, 11, 22, 33, 123);
if (date instanceof Date) {
this.date = date;
this.hour = date.getHours();
this.minute = date.getMinutes();
this.second = date.getSeconds();
this.microsecond = 0;
this.year = date.getFullYear();
this.month = date.getMonth()+1;
this.day = date.getDate();
} else {
for(var k in date) {
this[k] = date[k];
}
}
}
|
[
"function",
"DateTime",
"(",
"date",
")",
"{",
"if",
"(",
"date",
"instanceof",
"DateTime",
")",
"return",
"date",
";",
"if",
"(",
"_i18n_locale",
".",
"locale_name",
"==",
"'en_DEBUG'",
")",
"date",
"=",
"new",
"Date",
"(",
"3333",
",",
"10",
",",
"22",
",",
"11",
",",
"22",
",",
"33",
",",
"123",
")",
";",
"if",
"(",
"date",
"instanceof",
"Date",
")",
"{",
"this",
".",
"date",
"=",
"date",
";",
"this",
".",
"hour",
"=",
"date",
".",
"getHours",
"(",
")",
";",
"this",
".",
"minute",
"=",
"date",
".",
"getMinutes",
"(",
")",
";",
"this",
".",
"second",
"=",
"date",
".",
"getSeconds",
"(",
")",
";",
"this",
".",
"microsecond",
"=",
"0",
";",
"this",
".",
"year",
"=",
"date",
".",
"getFullYear",
"(",
")",
";",
"this",
".",
"month",
"=",
"date",
".",
"getMonth",
"(",
")",
"+",
"1",
";",
"this",
".",
"day",
"=",
"date",
".",
"getDate",
"(",
")",
";",
"}",
"else",
"{",
"for",
"(",
"var",
"k",
"in",
"date",
")",
"{",
"this",
"[",
"k",
"]",
"=",
"date",
"[",
"k",
"]",
";",
"}",
"}",
"}"
] |
Wrapper object for JS Date objects
|
[
"Wrapper",
"object",
"for",
"JS",
"Date",
"objects"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/i18n.js#L311-L330
|
13,639
|
splunk/splunk-sdk-javascript
|
examples/node/helloworld/firedalerts_async.js
|
function(firedAlertGroups, done) {
// Get the list of all fired alert groups, including the all group (represented by "-").
var groups = firedAlertGroups.list();
console.log("Fired alert groups:");
Async.seriesEach(
groups,
function(firedAlertGroup, index, seriescallback) {
firedAlertGroup.list(function(err, firedAlerts){
// How many times was this alert fired?
console.log(firedAlertGroup.name, "(Count:", firedAlertGroup.count(), ")");
// Print the properties for each fired alert (default of 30 per alert group).
for(var i = 0; i < firedAlerts.length; i++) {
var firedAlert = firedAlerts[i];
for (var key in firedAlert.properties()) {
if (firedAlert.properties().hasOwnProperty(key)) {
console.log("\t", key, ":", firedAlert.properties()[key]);
}
}
console.log();
}
console.log("======================================");
});
seriescallback();
},
function(err) {
if (err) {
done(err);
}
done();
}
);
}
|
javascript
|
function(firedAlertGroups, done) {
// Get the list of all fired alert groups, including the all group (represented by "-").
var groups = firedAlertGroups.list();
console.log("Fired alert groups:");
Async.seriesEach(
groups,
function(firedAlertGroup, index, seriescallback) {
firedAlertGroup.list(function(err, firedAlerts){
// How many times was this alert fired?
console.log(firedAlertGroup.name, "(Count:", firedAlertGroup.count(), ")");
// Print the properties for each fired alert (default of 30 per alert group).
for(var i = 0; i < firedAlerts.length; i++) {
var firedAlert = firedAlerts[i];
for (var key in firedAlert.properties()) {
if (firedAlert.properties().hasOwnProperty(key)) {
console.log("\t", key, ":", firedAlert.properties()[key]);
}
}
console.log();
}
console.log("======================================");
});
seriescallback();
},
function(err) {
if (err) {
done(err);
}
done();
}
);
}
|
[
"function",
"(",
"firedAlertGroups",
",",
"done",
")",
"{",
"// Get the list of all fired alert groups, including the all group (represented by \"-\").",
"var",
"groups",
"=",
"firedAlertGroups",
".",
"list",
"(",
")",
";",
"console",
".",
"log",
"(",
"\"Fired alert groups:\"",
")",
";",
"Async",
".",
"seriesEach",
"(",
"groups",
",",
"function",
"(",
"firedAlertGroup",
",",
"index",
",",
"seriescallback",
")",
"{",
"firedAlertGroup",
".",
"list",
"(",
"function",
"(",
"err",
",",
"firedAlerts",
")",
"{",
"// How many times was this alert fired?",
"console",
".",
"log",
"(",
"firedAlertGroup",
".",
"name",
",",
"\"(Count:\"",
",",
"firedAlertGroup",
".",
"count",
"(",
")",
",",
"\")\"",
")",
";",
"// Print the properties for each fired alert (default of 30 per alert group).",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"firedAlerts",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"firedAlert",
"=",
"firedAlerts",
"[",
"i",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"firedAlert",
".",
"properties",
"(",
")",
")",
"{",
"if",
"(",
"firedAlert",
".",
"properties",
"(",
")",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"console",
".",
"log",
"(",
"\"\\t\"",
",",
"key",
",",
"\":\"",
",",
"firedAlert",
".",
"properties",
"(",
")",
"[",
"key",
"]",
")",
";",
"}",
"}",
"console",
".",
"log",
"(",
")",
";",
"}",
"console",
".",
"log",
"(",
"\"======================================\"",
")",
";",
"}",
")",
";",
"seriescallback",
"(",
")",
";",
"}",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"done",
"(",
"err",
")",
";",
"}",
"done",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Print them out.
|
[
"Print",
"them",
"out",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/examples/node/helloworld/firedalerts_async.js#L57-L89
|
|
13,640
|
splunk/splunk-sdk-javascript
|
contrib/commander.js
|
camelcase
|
function camelcase(flag) {
return flag.split('-').reduce(function(str, word){
return str + word[0].toUpperCase() + word.slice(1);
});
}
|
javascript
|
function camelcase(flag) {
return flag.split('-').reduce(function(str, word){
return str + word[0].toUpperCase() + word.slice(1);
});
}
|
[
"function",
"camelcase",
"(",
"flag",
")",
"{",
"return",
"flag",
".",
"split",
"(",
"'-'",
")",
".",
"reduce",
"(",
"function",
"(",
"str",
",",
"word",
")",
"{",
"return",
"str",
"+",
"word",
"[",
"0",
"]",
".",
"toUpperCase",
"(",
")",
"+",
"word",
".",
"slice",
"(",
"1",
")",
";",
"}",
")",
";",
"}"
] |
Camel-case the given `flag`
@param {String} flag
@return {String}
@api private
|
[
"Camel",
"-",
"case",
"the",
"given",
"flag"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/contrib/commander.js#L1054-L1058
|
13,641
|
splunk/splunk-sdk-javascript
|
contrib/commander.js
|
pad
|
function pad(str, width) {
var len = Math.max(0, width - str.length);
return str + Array(len + 1).join(' ');
}
|
javascript
|
function pad(str, width) {
var len = Math.max(0, width - str.length);
return str + Array(len + 1).join(' ');
}
|
[
"function",
"pad",
"(",
"str",
",",
"width",
")",
"{",
"var",
"len",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"width",
"-",
"str",
".",
"length",
")",
";",
"return",
"str",
"+",
"Array",
"(",
"len",
"+",
"1",
")",
".",
"join",
"(",
"' '",
")",
";",
"}"
] |
Pad `str` to `width`.
@param {String} str
@param {Number} width
@return {String}
@api private
|
[
"Pad",
"str",
"to",
"width",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/contrib/commander.js#L1081-L1084
|
13,642
|
splunk/splunk-sdk-javascript
|
examples/node/jobs.js
|
function(sids, options, callback) {
_check_sids('cancel', sids);
// For each of the supplied sids, cancel the job.
this._foreach(sids, function(job, idx, done) {
job.cancel(function (err) {
if (err) {
done(err);
return;
}
console.log(" Job " + job.sid + " cancelled");
done();
});
}, callback);
}
|
javascript
|
function(sids, options, callback) {
_check_sids('cancel', sids);
// For each of the supplied sids, cancel the job.
this._foreach(sids, function(job, idx, done) {
job.cancel(function (err) {
if (err) {
done(err);
return;
}
console.log(" Job " + job.sid + " cancelled");
done();
});
}, callback);
}
|
[
"function",
"(",
"sids",
",",
"options",
",",
"callback",
")",
"{",
"_check_sids",
"(",
"'cancel'",
",",
"sids",
")",
";",
"// For each of the supplied sids, cancel the job.",
"this",
".",
"_foreach",
"(",
"sids",
",",
"function",
"(",
"job",
",",
"idx",
",",
"done",
")",
"{",
"job",
".",
"cancel",
"(",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"done",
"(",
"err",
")",
";",
"return",
";",
"}",
"console",
".",
"log",
"(",
"\" Job \"",
"+",
"job",
".",
"sid",
"+",
"\" cancelled\"",
")",
";",
"done",
"(",
")",
";",
"}",
")",
";",
"}",
",",
"callback",
")",
";",
"}"
] |
Cancel the specified search jobs
|
[
"Cancel",
"the",
"specified",
"search",
"jobs"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/examples/node/jobs.js#L145-L160
|
|
13,643
|
splunk/splunk-sdk-javascript
|
examples/node/jobs.js
|
function(args, options, callback) {
// Get the query and parameters, and remove the extraneous
// search parameter
var query = options.search;
var params = options;
delete params.search;
// Create the job
this.service.jobs().create(query, params, function(err, job) {
if (err) {
callback(err);
return;
}
console.log("Created job " + job.sid);
callback(null, job);
});
}
|
javascript
|
function(args, options, callback) {
// Get the query and parameters, and remove the extraneous
// search parameter
var query = options.search;
var params = options;
delete params.search;
// Create the job
this.service.jobs().create(query, params, function(err, job) {
if (err) {
callback(err);
return;
}
console.log("Created job " + job.sid);
callback(null, job);
});
}
|
[
"function",
"(",
"args",
",",
"options",
",",
"callback",
")",
"{",
"// Get the query and parameters, and remove the extraneous",
"// search parameter",
"var",
"query",
"=",
"options",
".",
"search",
";",
"var",
"params",
"=",
"options",
";",
"delete",
"params",
".",
"search",
";",
"// Create the job",
"this",
".",
"service",
".",
"jobs",
"(",
")",
".",
"create",
"(",
"query",
",",
"params",
",",
"function",
"(",
"err",
",",
"job",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"console",
".",
"log",
"(",
"\"Created job \"",
"+",
"job",
".",
"sid",
")",
";",
"callback",
"(",
"null",
",",
"job",
")",
";",
"}",
")",
";",
"}"
] |
Create a search job
|
[
"Create",
"a",
"search",
"job"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/examples/node/jobs.js#L191-L208
|
|
13,644
|
splunk/splunk-sdk-javascript
|
examples/node/jobs.js
|
function(sids, options, callback) {
sids = sids || [];
if (sids.length === 0) {
// If no job SIDs are provided, we list all jobs.
var jobs = this.service.jobs();
jobs.fetch(function(err, jobs) {
if (err) {
callback(err);
return;
}
var list = jobs.list() || [];
for(var i = 0; i < list.length; i++) {
console.log(" Job " + (i + 1) + " sid: "+ list[i].sid);
}
callback(null, list);
});
}
else {
// If certain job SIDs are provided,
// then we simply read the properties of those jobs
this._foreach(sids, function(job, idx, done) {
job.fetch(function(err, job) {
if (err) {
done(err);
return;
}
console.log("Job " + job.sid + ": ");
var properties = job.properties();
for(var key in properties) {
// Skip some keys that make the output hard to read
if (utils.contains(["performance"], key)) {
continue;
}
console.log(" " + key + ": ", properties[key]);
}
done(null, properties);
});
}, callback);
}
}
|
javascript
|
function(sids, options, callback) {
sids = sids || [];
if (sids.length === 0) {
// If no job SIDs are provided, we list all jobs.
var jobs = this.service.jobs();
jobs.fetch(function(err, jobs) {
if (err) {
callback(err);
return;
}
var list = jobs.list() || [];
for(var i = 0; i < list.length; i++) {
console.log(" Job " + (i + 1) + " sid: "+ list[i].sid);
}
callback(null, list);
});
}
else {
// If certain job SIDs are provided,
// then we simply read the properties of those jobs
this._foreach(sids, function(job, idx, done) {
job.fetch(function(err, job) {
if (err) {
done(err);
return;
}
console.log("Job " + job.sid + ": ");
var properties = job.properties();
for(var key in properties) {
// Skip some keys that make the output hard to read
if (utils.contains(["performance"], key)) {
continue;
}
console.log(" " + key + ": ", properties[key]);
}
done(null, properties);
});
}, callback);
}
}
|
[
"function",
"(",
"sids",
",",
"options",
",",
"callback",
")",
"{",
"sids",
"=",
"sids",
"||",
"[",
"]",
";",
"if",
"(",
"sids",
".",
"length",
"===",
"0",
")",
"{",
"// If no job SIDs are provided, we list all jobs.",
"var",
"jobs",
"=",
"this",
".",
"service",
".",
"jobs",
"(",
")",
";",
"jobs",
".",
"fetch",
"(",
"function",
"(",
"err",
",",
"jobs",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"err",
")",
";",
"return",
";",
"}",
"var",
"list",
"=",
"jobs",
".",
"list",
"(",
")",
"||",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"i",
"++",
")",
"{",
"console",
".",
"log",
"(",
"\" Job \"",
"+",
"(",
"i",
"+",
"1",
")",
"+",
"\" sid: \"",
"+",
"list",
"[",
"i",
"]",
".",
"sid",
")",
";",
"}",
"callback",
"(",
"null",
",",
"list",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"// If certain job SIDs are provided,",
"// then we simply read the properties of those jobs",
"this",
".",
"_foreach",
"(",
"sids",
",",
"function",
"(",
"job",
",",
"idx",
",",
"done",
")",
"{",
"job",
".",
"fetch",
"(",
"function",
"(",
"err",
",",
"job",
")",
"{",
"if",
"(",
"err",
")",
"{",
"done",
"(",
"err",
")",
";",
"return",
";",
"}",
"console",
".",
"log",
"(",
"\"Job \"",
"+",
"job",
".",
"sid",
"+",
"\": \"",
")",
";",
"var",
"properties",
"=",
"job",
".",
"properties",
"(",
")",
";",
"for",
"(",
"var",
"key",
"in",
"properties",
")",
"{",
"// Skip some keys that make the output hard to read",
"if",
"(",
"utils",
".",
"contains",
"(",
"[",
"\"performance\"",
"]",
",",
"key",
")",
")",
"{",
"continue",
";",
"}",
"console",
".",
"log",
"(",
"\" \"",
"+",
"key",
"+",
"\": \"",
",",
"properties",
"[",
"key",
"]",
")",
";",
"}",
"done",
"(",
"null",
",",
"properties",
")",
";",
"}",
")",
";",
"}",
",",
"callback",
")",
";",
"}",
"}"
] |
List all current search jobs if no jobs specified, otherwise list the properties of the specified jobs.
|
[
"List",
"all",
"current",
"search",
"jobs",
"if",
"no",
"jobs",
"specified",
"otherwise",
"list",
"the",
"properties",
"of",
"the",
"specified",
"jobs",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/examples/node/jobs.js#L212-L257
|
|
13,645
|
splunk/splunk-sdk-javascript
|
examples/modularinputs/github_commits/bin/app/github_commits.js
|
getDisplayDate
|
function getDisplayDate(date) {
var monthStrings = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
date = new Date(date);
var hours = date.getHours();
if (hours < 10) {
hours = "0" + hours.toString();
}
var mins = date.getMinutes();
if (mins < 10) {
mins = "0" + mins.toString();
}
return monthStrings[date.getMonth()] + " " + date.getDate() + ", " + date.getFullYear() +
" - " + hours + ":" + mins + " " + (date.getUTCHours() < 12 ? "AM" : "PM");
}
|
javascript
|
function getDisplayDate(date) {
var monthStrings = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
date = new Date(date);
var hours = date.getHours();
if (hours < 10) {
hours = "0" + hours.toString();
}
var mins = date.getMinutes();
if (mins < 10) {
mins = "0" + mins.toString();
}
return monthStrings[date.getMonth()] + " " + date.getDate() + ", " + date.getFullYear() +
" - " + hours + ":" + mins + " " + (date.getUTCHours() < 12 ? "AM" : "PM");
}
|
[
"function",
"getDisplayDate",
"(",
"date",
")",
"{",
"var",
"monthStrings",
"=",
"[",
"\"Jan\"",
",",
"\"Feb\"",
",",
"\"Mar\"",
",",
"\"Apr\"",
",",
"\"May\"",
",",
"\"Jun\"",
",",
"\"Jul\"",
",",
"\"Aug\"",
",",
"\"Sep\"",
",",
"\"Oct\"",
",",
"\"Nov\"",
",",
"\"Dec\"",
"]",
";",
"date",
"=",
"new",
"Date",
"(",
"date",
")",
";",
"var",
"hours",
"=",
"date",
".",
"getHours",
"(",
")",
";",
"if",
"(",
"hours",
"<",
"10",
")",
"{",
"hours",
"=",
"\"0\"",
"+",
"hours",
".",
"toString",
"(",
")",
";",
"}",
"var",
"mins",
"=",
"date",
".",
"getMinutes",
"(",
")",
";",
"if",
"(",
"mins",
"<",
"10",
")",
"{",
"mins",
"=",
"\"0\"",
"+",
"mins",
".",
"toString",
"(",
")",
";",
"}",
"return",
"monthStrings",
"[",
"date",
".",
"getMonth",
"(",
")",
"]",
"+",
"\" \"",
"+",
"date",
".",
"getDate",
"(",
")",
"+",
"\", \"",
"+",
"date",
".",
"getFullYear",
"(",
")",
"+",
"\" - \"",
"+",
"hours",
"+",
"\":\"",
"+",
"mins",
"+",
"\" \"",
"+",
"(",
"date",
".",
"getUTCHours",
"(",
")",
"<",
"12",
"?",
"\"AM\"",
":",
"\"PM\"",
")",
";",
"}"
] |
Create easy to read date format.
|
[
"Create",
"easy",
"to",
"read",
"date",
"format",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/examples/modularinputs/github_commits/bin/app/github_commits.js#L32-L48
|
13,646
|
splunk/splunk-sdk-javascript
|
lib/log.js
|
function(allMessages) {
allMessages = allMessages || [];
for(var i = 0; i < allMessages.length; i++) {
var message = allMessages[i];
var type = message["type"];
var text = message["text"];
var msg = '[SPLUNKD] ' + text;
switch (type) {
case 'HTTP':
case 'FATAL':
case 'ERROR':
this.error(msg);
break;
case 'WARN':
this.warn(msg);
break;
case 'INFO':
this.info(msg);
break;
case 'HTTP':
this.error(msg);
break;
default:
this.info(msg);
break;
}
}
}
|
javascript
|
function(allMessages) {
allMessages = allMessages || [];
for(var i = 0; i < allMessages.length; i++) {
var message = allMessages[i];
var type = message["type"];
var text = message["text"];
var msg = '[SPLUNKD] ' + text;
switch (type) {
case 'HTTP':
case 'FATAL':
case 'ERROR':
this.error(msg);
break;
case 'WARN':
this.warn(msg);
break;
case 'INFO':
this.info(msg);
break;
case 'HTTP':
this.error(msg);
break;
default:
this.info(msg);
break;
}
}
}
|
[
"function",
"(",
"allMessages",
")",
"{",
"allMessages",
"=",
"allMessages",
"||",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"allMessages",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"message",
"=",
"allMessages",
"[",
"i",
"]",
";",
"var",
"type",
"=",
"message",
"[",
"\"type\"",
"]",
";",
"var",
"text",
"=",
"message",
"[",
"\"text\"",
"]",
";",
"var",
"msg",
"=",
"'[SPLUNKD] '",
"+",
"text",
";",
"switch",
"(",
"type",
")",
"{",
"case",
"'HTTP'",
":",
"case",
"'FATAL'",
":",
"case",
"'ERROR'",
":",
"this",
".",
"error",
"(",
"msg",
")",
";",
"break",
";",
"case",
"'WARN'",
":",
"this",
".",
"warn",
"(",
"msg",
")",
";",
"break",
";",
"case",
"'INFO'",
":",
"this",
".",
"info",
"(",
"msg",
")",
";",
"break",
";",
"case",
"'HTTP'",
":",
"this",
".",
"error",
"(",
"msg",
")",
";",
"break",
";",
"default",
":",
"this",
".",
"info",
"(",
"msg",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
Prints all messages that are retrieved from the splunkd server to the
console.
@function splunkjs.Logger
|
[
"Prints",
"all",
"messages",
"that",
"are",
"retrieved",
"from",
"the",
"splunkd",
"server",
"to",
"the",
"console",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/log.js#L139-L167
|
|
13,647
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(name, properties) {
// first respect the field hide list that came from the parent module
if(properties.fieldHideList && $.inArray(name, properties.fieldHideList) > -1) {
return false;
}
// next process the field visibility lists from the xml
if(this.fieldListMode === 'show_hide') {
if($.inArray(name, this.fieldHideList) > -1 && $.inArray(name, this.fieldShowList) < 0) {
return false;
}
}
else {
// assumes 'hide_show' mode
if($.inArray(name, this.fieldHideList) > -1) {
return false;
}
}
return true;
}
|
javascript
|
function(name, properties) {
// first respect the field hide list that came from the parent module
if(properties.fieldHideList && $.inArray(name, properties.fieldHideList) > -1) {
return false;
}
// next process the field visibility lists from the xml
if(this.fieldListMode === 'show_hide') {
if($.inArray(name, this.fieldHideList) > -1 && $.inArray(name, this.fieldShowList) < 0) {
return false;
}
}
else {
// assumes 'hide_show' mode
if($.inArray(name, this.fieldHideList) > -1) {
return false;
}
}
return true;
}
|
[
"function",
"(",
"name",
",",
"properties",
")",
"{",
"// first respect the field hide list that came from the parent module",
"if",
"(",
"properties",
".",
"fieldHideList",
"&&",
"$",
".",
"inArray",
"(",
"name",
",",
"properties",
".",
"fieldHideList",
")",
">",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"// next process the field visibility lists from the xml",
"if",
"(",
"this",
".",
"fieldListMode",
"===",
"'show_hide'",
")",
"{",
"if",
"(",
"$",
".",
"inArray",
"(",
"name",
",",
"this",
".",
"fieldHideList",
")",
">",
"-",
"1",
"&&",
"$",
".",
"inArray",
"(",
"name",
",",
"this",
".",
"fieldShowList",
")",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"// assumes 'hide_show' mode",
"if",
"(",
"$",
".",
"inArray",
"(",
"name",
",",
"this",
".",
"fieldHideList",
")",
">",
"-",
"1",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
returns false if series should not be added to the chart
|
[
"returns",
"false",
"if",
"series",
"should",
"not",
"be",
"added",
"to",
"the",
"chart"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L1434-L1452
|
|
13,648
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function($super, key, value, properties) {
var keysToIgnore = {
'chart.nullValueMode': true
};
if(key in keysToIgnore) {
return;
}
$super(key, value, properties);
}
|
javascript
|
function($super, key, value, properties) {
var keysToIgnore = {
'chart.nullValueMode': true
};
if(key in keysToIgnore) {
return;
}
$super(key, value, properties);
}
|
[
"function",
"(",
"$super",
",",
"key",
",",
"value",
",",
"properties",
")",
"{",
"var",
"keysToIgnore",
"=",
"{",
"'chart.nullValueMode'",
":",
"true",
"}",
";",
"if",
"(",
"key",
"in",
"keysToIgnore",
")",
"{",
"return",
";",
"}",
"$super",
"(",
"key",
",",
"value",
",",
"properties",
")",
";",
"}"
] |
override point-based charts need to defensively ignore null-value mode, since 'connect' will lead to unexpected results
|
[
"override",
"point",
"-",
"based",
"charts",
"need",
"to",
"defensively",
"ignore",
"null",
"-",
"value",
"mode",
"since",
"connect",
"will",
"lead",
"to",
"unexpected",
"results"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L1769-L1778
|
|
13,649
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(point, series) {
if(!point || !point.graphic) {
return;
}
point.graphic.attr({'fill': this.fadedElementColor, 'stroke-width': 1, 'stroke': this.fadedElementBorderColor});
}
|
javascript
|
function(point, series) {
if(!point || !point.graphic) {
return;
}
point.graphic.attr({'fill': this.fadedElementColor, 'stroke-width': 1, 'stroke': this.fadedElementBorderColor});
}
|
[
"function",
"(",
"point",
",",
"series",
")",
"{",
"if",
"(",
"!",
"point",
"||",
"!",
"point",
".",
"graphic",
")",
"{",
"return",
";",
"}",
"point",
".",
"graphic",
".",
"attr",
"(",
"{",
"'fill'",
":",
"this",
".",
"fadedElementColor",
",",
"'stroke-width'",
":",
"1",
",",
"'stroke'",
":",
"this",
".",
"fadedElementBorderColor",
"}",
")",
";",
"}"
] |
doing full overrides here to avoid a double-repaint, even though there is some duplicate code override
|
[
"doing",
"full",
"overrides",
"here",
"to",
"avoid",
"a",
"double",
"-",
"repaint",
"even",
"though",
"there",
"is",
"some",
"duplicate",
"code",
"override"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L1915-L1920
|
|
13,650
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(properties, data) {
var axisProperties = this.parseUtils.getXAxisProperties(properties),
orientation = (this.axesAreInverted) ? 'vertical' : 'horizontal',
colorScheme = this.getAxisColorScheme();
// add some extra info to the axisProperties as needed
if(axisProperties.hasOwnProperty('axisTitle.text')){
axisProperties['axisTitle.text'] = Splunk.JSCharting.ParsingUtils.escapeHtml(axisProperties['axisTitle.text']);
}
axisProperties.chartType = properties.chart;
axisProperties.axisLength = $(this.renderTo).width();
this.xAxis = new Splunk.JSCharting.NumericAxis(axisProperties, data, orientation, colorScheme);
this.hcConfig.xAxis = $.extend(true, this.xAxis.getConfig(), {
startOnTick: true,
endOnTick: true,
minPadding: 0,
maxPadding: 0
});
}
|
javascript
|
function(properties, data) {
var axisProperties = this.parseUtils.getXAxisProperties(properties),
orientation = (this.axesAreInverted) ? 'vertical' : 'horizontal',
colorScheme = this.getAxisColorScheme();
// add some extra info to the axisProperties as needed
if(axisProperties.hasOwnProperty('axisTitle.text')){
axisProperties['axisTitle.text'] = Splunk.JSCharting.ParsingUtils.escapeHtml(axisProperties['axisTitle.text']);
}
axisProperties.chartType = properties.chart;
axisProperties.axisLength = $(this.renderTo).width();
this.xAxis = new Splunk.JSCharting.NumericAxis(axisProperties, data, orientation, colorScheme);
this.hcConfig.xAxis = $.extend(true, this.xAxis.getConfig(), {
startOnTick: true,
endOnTick: true,
minPadding: 0,
maxPadding: 0
});
}
|
[
"function",
"(",
"properties",
",",
"data",
")",
"{",
"var",
"axisProperties",
"=",
"this",
".",
"parseUtils",
".",
"getXAxisProperties",
"(",
"properties",
")",
",",
"orientation",
"=",
"(",
"this",
".",
"axesAreInverted",
")",
"?",
"'vertical'",
":",
"'horizontal'",
",",
"colorScheme",
"=",
"this",
".",
"getAxisColorScheme",
"(",
")",
";",
"// add some extra info to the axisProperties as needed",
"if",
"(",
"axisProperties",
".",
"hasOwnProperty",
"(",
"'axisTitle.text'",
")",
")",
"{",
"axisProperties",
"[",
"'axisTitle.text'",
"]",
"=",
"Splunk",
".",
"JSCharting",
".",
"ParsingUtils",
".",
"escapeHtml",
"(",
"axisProperties",
"[",
"'axisTitle.text'",
"]",
")",
";",
"}",
"axisProperties",
".",
"chartType",
"=",
"properties",
".",
"chart",
";",
"axisProperties",
".",
"axisLength",
"=",
"$",
"(",
"this",
".",
"renderTo",
")",
".",
"width",
"(",
")",
";",
"this",
".",
"xAxis",
"=",
"new",
"Splunk",
".",
"JSCharting",
".",
"NumericAxis",
"(",
"axisProperties",
",",
"data",
",",
"orientation",
",",
"colorScheme",
")",
";",
"this",
".",
"hcConfig",
".",
"xAxis",
"=",
"$",
".",
"extend",
"(",
"true",
",",
"this",
".",
"xAxis",
".",
"getConfig",
"(",
")",
",",
"{",
"startOnTick",
":",
"true",
",",
"endOnTick",
":",
"true",
",",
"minPadding",
":",
"0",
",",
"maxPadding",
":",
"0",
"}",
")",
";",
"}"
] |
override force the x axis to be numeric
|
[
"override",
"force",
"the",
"x",
"axis",
"to",
"be",
"numeric"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L2345-L2364
|
|
13,651
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function($super) {
if(!this.hasSVG) {
$super();
return;
}
var i, loopSplit, loopKeyName, loopKeyElem, loopValElem,
$tooltip = $('.highcharts-tooltip', $(this.renderTo)),
tooltipElements = (this.hasSVG) ? $('tspan', $tooltip) :
$('span > span', $tooltip);
for(i = 0; i < tooltipElements.length; i += 3) {
loopKeyElem =tooltipElements[i];
if(tooltipElements.length < i + 2) {
break;
}
loopValElem = tooltipElements[i + 1];
loopSplit = (this.hasSVG) ? loopKeyElem.textContent.split(':') :
$(loopKeyElem).html().split(':');
loopKeyName = loopSplit[0];
this.addClassToElement(loopKeyElem, 'key');
this.addClassToElement(loopKeyElem, loopKeyName + '-key');
this.addClassToElement(loopValElem, 'value');
this.addClassToElement(loopValElem, loopKeyName + '-value');
}
}
|
javascript
|
function($super) {
if(!this.hasSVG) {
$super();
return;
}
var i, loopSplit, loopKeyName, loopKeyElem, loopValElem,
$tooltip = $('.highcharts-tooltip', $(this.renderTo)),
tooltipElements = (this.hasSVG) ? $('tspan', $tooltip) :
$('span > span', $tooltip);
for(i = 0; i < tooltipElements.length; i += 3) {
loopKeyElem =tooltipElements[i];
if(tooltipElements.length < i + 2) {
break;
}
loopValElem = tooltipElements[i + 1];
loopSplit = (this.hasSVG) ? loopKeyElem.textContent.split(':') :
$(loopKeyElem).html().split(':');
loopKeyName = loopSplit[0];
this.addClassToElement(loopKeyElem, 'key');
this.addClassToElement(loopKeyElem, loopKeyName + '-key');
this.addClassToElement(loopValElem, 'value');
this.addClassToElement(loopValElem, loopKeyName + '-value');
}
}
|
[
"function",
"(",
"$super",
")",
"{",
"if",
"(",
"!",
"this",
".",
"hasSVG",
")",
"{",
"$super",
"(",
")",
";",
"return",
";",
"}",
"var",
"i",
",",
"loopSplit",
",",
"loopKeyName",
",",
"loopKeyElem",
",",
"loopValElem",
",",
"$tooltip",
"=",
"$",
"(",
"'.highcharts-tooltip'",
",",
"$",
"(",
"this",
".",
"renderTo",
")",
")",
",",
"tooltipElements",
"=",
"(",
"this",
".",
"hasSVG",
")",
"?",
"$",
"(",
"'tspan'",
",",
"$tooltip",
")",
":",
"$",
"(",
"'span > span'",
",",
"$tooltip",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"tooltipElements",
".",
"length",
";",
"i",
"+=",
"3",
")",
"{",
"loopKeyElem",
"=",
"tooltipElements",
"[",
"i",
"]",
";",
"if",
"(",
"tooltipElements",
".",
"length",
"<",
"i",
"+",
"2",
")",
"{",
"break",
";",
"}",
"loopValElem",
"=",
"tooltipElements",
"[",
"i",
"+",
"1",
"]",
";",
"loopSplit",
"=",
"(",
"this",
".",
"hasSVG",
")",
"?",
"loopKeyElem",
".",
"textContent",
".",
"split",
"(",
"':'",
")",
":",
"$",
"(",
"loopKeyElem",
")",
".",
"html",
"(",
")",
".",
"split",
"(",
"':'",
")",
";",
"loopKeyName",
"=",
"loopSplit",
"[",
"0",
"]",
";",
"this",
".",
"addClassToElement",
"(",
"loopKeyElem",
",",
"'key'",
")",
";",
"this",
".",
"addClassToElement",
"(",
"loopKeyElem",
",",
"loopKeyName",
"+",
"'-key'",
")",
";",
"this",
".",
"addClassToElement",
"(",
"loopValElem",
",",
"'value'",
")",
";",
"this",
".",
"addClassToElement",
"(",
"loopValElem",
",",
"loopKeyName",
"+",
"'-value'",
")",
";",
"}",
"}"
] |
we have to override here because the tooltip structure is different
|
[
"we",
"have",
"to",
"override",
"here",
"because",
"the",
"tooltip",
"structure",
"is",
"different"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L2581-L2605
|
|
13,652
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(properties, data) {
var useTimeNames = (this.processedData.xAxisType === 'time'),
resolveLabel = this.getLabel.bind(this);
this.formatTooltip(properties, data);
$.extend(true, this.hcConfig, {
plotOptions: {
pie: {
dataLabels: {
formatter: function() {
return Splunk.JSCharting.ParsingUtils.escapeHtml(resolveLabel(this, useTimeNames));
}
}
}
}
});
}
|
javascript
|
function(properties, data) {
var useTimeNames = (this.processedData.xAxisType === 'time'),
resolveLabel = this.getLabel.bind(this);
this.formatTooltip(properties, data);
$.extend(true, this.hcConfig, {
plotOptions: {
pie: {
dataLabels: {
formatter: function() {
return Splunk.JSCharting.ParsingUtils.escapeHtml(resolveLabel(this, useTimeNames));
}
}
}
}
});
}
|
[
"function",
"(",
"properties",
",",
"data",
")",
"{",
"var",
"useTimeNames",
"=",
"(",
"this",
".",
"processedData",
".",
"xAxisType",
"===",
"'time'",
")",
",",
"resolveLabel",
"=",
"this",
".",
"getLabel",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"formatTooltip",
"(",
"properties",
",",
"data",
")",
";",
"$",
".",
"extend",
"(",
"true",
",",
"this",
".",
"hcConfig",
",",
"{",
"plotOptions",
":",
"{",
"pie",
":",
"{",
"dataLabels",
":",
"{",
"formatter",
":",
"function",
"(",
")",
"{",
"return",
"Splunk",
".",
"JSCharting",
".",
"ParsingUtils",
".",
"escapeHtml",
"(",
"resolveLabel",
"(",
"this",
",",
"useTimeNames",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
")",
";",
"}"
] |
override not calling super class method, pie charts don't have axes or legend
|
[
"override",
"not",
"calling",
"super",
"class",
"method",
"pie",
"charts",
"don",
"t",
"have",
"axes",
"or",
"legend"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L2798-L2813
|
|
13,653
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(list, map, legendSize) {
var hexColor;
this.colorList = [];
this.hcConfig.colors = [];
for(i = 0; i < list.length; i++) {
hexColor = this.colorPalette.getColor(list[i], map[list[i]], legendSize);
this.colorList.push(hexColor);
this.hcConfig.colors.push(this.colorUtils.addAlphaToColor(hexColor, 1.0));
}
}
|
javascript
|
function(list, map, legendSize) {
var hexColor;
this.colorList = [];
this.hcConfig.colors = [];
for(i = 0; i < list.length; i++) {
hexColor = this.colorPalette.getColor(list[i], map[list[i]], legendSize);
this.colorList.push(hexColor);
this.hcConfig.colors.push(this.colorUtils.addAlphaToColor(hexColor, 1.0));
}
}
|
[
"function",
"(",
"list",
",",
"map",
",",
"legendSize",
")",
"{",
"var",
"hexColor",
";",
"this",
".",
"colorList",
"=",
"[",
"]",
";",
"this",
".",
"hcConfig",
".",
"colors",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"i",
"++",
")",
"{",
"hexColor",
"=",
"this",
".",
"colorPalette",
".",
"getColor",
"(",
"list",
"[",
"i",
"]",
",",
"map",
"[",
"list",
"[",
"i",
"]",
"]",
",",
"legendSize",
")",
";",
"this",
".",
"colorList",
".",
"push",
"(",
"hexColor",
")",
";",
"this",
".",
"hcConfig",
".",
"colors",
".",
"push",
"(",
"this",
".",
"colorUtils",
".",
"addAlphaToColor",
"(",
"hexColor",
",",
"1.0",
")",
")",
";",
"}",
"}"
] |
override the inner charts will handle adding opacity to their color schemes
|
[
"override",
"the",
"inner",
"charts",
"will",
"handle",
"adding",
"opacity",
"to",
"their",
"color",
"schemes"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L3364-L3373
|
|
13,654
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(ticks) {
var key,
tickArray = [];
for(key in ticks) {
if(ticks.hasOwnProperty(key)) {
tickArray.push(ticks[key]);
}
}
tickArray.sort(function(t1, t2) {
return (t1.pos - t2.pos);
});
return tickArray;
}
|
javascript
|
function(ticks) {
var key,
tickArray = [];
for(key in ticks) {
if(ticks.hasOwnProperty(key)) {
tickArray.push(ticks[key]);
}
}
tickArray.sort(function(t1, t2) {
return (t1.pos - t2.pos);
});
return tickArray;
}
|
[
"function",
"(",
"ticks",
")",
"{",
"var",
"key",
",",
"tickArray",
"=",
"[",
"]",
";",
"for",
"(",
"key",
"in",
"ticks",
")",
"{",
"if",
"(",
"ticks",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"tickArray",
".",
"push",
"(",
"ticks",
"[",
"key",
"]",
")",
";",
"}",
"}",
"tickArray",
".",
"sort",
"(",
"function",
"(",
"t1",
",",
"t2",
")",
"{",
"return",
"(",
"t1",
".",
"pos",
"-",
"t2",
".",
"pos",
")",
";",
"}",
")",
";",
"return",
"tickArray",
";",
"}"
] |
returns the ticks in an array in ascending order by 'pos'
|
[
"returns",
"the",
"ticks",
"in",
"an",
"array",
"in",
"ascending",
"order",
"by",
"pos"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L3982-L3995
|
|
13,655
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(options, extremes) {
// if there are no extremes (i.e. no meaningful data was extracted), go with 0 to 100
if(!extremes.min && !extremes.max) {
options.min = 0;
options.max = 100;
return;
}
// if the min or max is such that no data makes it onto the chart, we hard-code some reasonable extremes
if(extremes.min > extremes.dataMax && extremes.min > 0 && this.userMax === Infinity) {
options.max = (this.logScale) ? extremes.min + 2 : extremes.min * 2;
return;
}
if(extremes.max < extremes.dataMin && extremes.max < 0 && this.userMin === -Infinity) {
options.min = (this.logScale) ? extremes.max - 2 : extremes.max * 2;
return;
}
// if either data extreme is exactly zero, remove the padding on that side so the axis doesn't extend beyond zero
if(extremes.dataMin === 0 && this.userMin === -Infinity) {
options.min = 0;
options.minPadding = 0;
}
if(extremes.dataMax === 0 && this.userMax === Infinity) {
options.max = 0;
options.maxPadding = 0;
}
}
|
javascript
|
function(options, extremes) {
// if there are no extremes (i.e. no meaningful data was extracted), go with 0 to 100
if(!extremes.min && !extremes.max) {
options.min = 0;
options.max = 100;
return;
}
// if the min or max is such that no data makes it onto the chart, we hard-code some reasonable extremes
if(extremes.min > extremes.dataMax && extremes.min > 0 && this.userMax === Infinity) {
options.max = (this.logScale) ? extremes.min + 2 : extremes.min * 2;
return;
}
if(extremes.max < extremes.dataMin && extremes.max < 0 && this.userMin === -Infinity) {
options.min = (this.logScale) ? extremes.max - 2 : extremes.max * 2;
return;
}
// if either data extreme is exactly zero, remove the padding on that side so the axis doesn't extend beyond zero
if(extremes.dataMin === 0 && this.userMin === -Infinity) {
options.min = 0;
options.minPadding = 0;
}
if(extremes.dataMax === 0 && this.userMax === Infinity) {
options.max = 0;
options.maxPadding = 0;
}
}
|
[
"function",
"(",
"options",
",",
"extremes",
")",
"{",
"// if there are no extremes (i.e. no meaningful data was extracted), go with 0 to 100",
"if",
"(",
"!",
"extremes",
".",
"min",
"&&",
"!",
"extremes",
".",
"max",
")",
"{",
"options",
".",
"min",
"=",
"0",
";",
"options",
".",
"max",
"=",
"100",
";",
"return",
";",
"}",
"// if the min or max is such that no data makes it onto the chart, we hard-code some reasonable extremes",
"if",
"(",
"extremes",
".",
"min",
">",
"extremes",
".",
"dataMax",
"&&",
"extremes",
".",
"min",
">",
"0",
"&&",
"this",
".",
"userMax",
"===",
"Infinity",
")",
"{",
"options",
".",
"max",
"=",
"(",
"this",
".",
"logScale",
")",
"?",
"extremes",
".",
"min",
"+",
"2",
":",
"extremes",
".",
"min",
"*",
"2",
";",
"return",
";",
"}",
"if",
"(",
"extremes",
".",
"max",
"<",
"extremes",
".",
"dataMin",
"&&",
"extremes",
".",
"max",
"<",
"0",
"&&",
"this",
".",
"userMin",
"===",
"-",
"Infinity",
")",
"{",
"options",
".",
"min",
"=",
"(",
"this",
".",
"logScale",
")",
"?",
"extremes",
".",
"max",
"-",
"2",
":",
"extremes",
".",
"max",
"*",
"2",
";",
"return",
";",
"}",
"// if either data extreme is exactly zero, remove the padding on that side so the axis doesn't extend beyond zero",
"if",
"(",
"extremes",
".",
"dataMin",
"===",
"0",
"&&",
"this",
".",
"userMin",
"===",
"-",
"Infinity",
")",
"{",
"options",
".",
"min",
"=",
"0",
";",
"options",
".",
"minPadding",
"=",
"0",
";",
"}",
"if",
"(",
"extremes",
".",
"dataMax",
"===",
"0",
"&&",
"this",
".",
"userMax",
"===",
"Infinity",
")",
"{",
"options",
".",
"max",
"=",
"0",
";",
"options",
".",
"maxPadding",
"=",
"0",
";",
"}",
"}"
] |
clean up various issues that can arise from the axis extremes
|
[
"clean",
"up",
"various",
"issues",
"that",
"can",
"arise",
"from",
"the",
"axis",
"extremes"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L4292-L4317
|
|
13,656
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(startVal, endVal, drawFn, finishCallback) {
var animationRange = endVal - startVal,
duration = 500,
animationProperties = {
duration: duration,
step: function(now, fx) {
drawFn(startVal + now);
this.nudgeChart();
}.bind(this)
};
if(finishCallback) {
animationProperties.complete = function() {
finishCallback(endVal);
};
}
// for the animation start and end values, use 0 and animationRange for consistency with the way jQuery handles
// css properties that it doesn't recognize
$(this.renderTo)
.stop(true, true)
.css({'animation-progress': 0})
.animate({'animation-progress': animationRange}, animationProperties);
}
|
javascript
|
function(startVal, endVal, drawFn, finishCallback) {
var animationRange = endVal - startVal,
duration = 500,
animationProperties = {
duration: duration,
step: function(now, fx) {
drawFn(startVal + now);
this.nudgeChart();
}.bind(this)
};
if(finishCallback) {
animationProperties.complete = function() {
finishCallback(endVal);
};
}
// for the animation start and end values, use 0 and animationRange for consistency with the way jQuery handles
// css properties that it doesn't recognize
$(this.renderTo)
.stop(true, true)
.css({'animation-progress': 0})
.animate({'animation-progress': animationRange}, animationProperties);
}
|
[
"function",
"(",
"startVal",
",",
"endVal",
",",
"drawFn",
",",
"finishCallback",
")",
"{",
"var",
"animationRange",
"=",
"endVal",
"-",
"startVal",
",",
"duration",
"=",
"500",
",",
"animationProperties",
"=",
"{",
"duration",
":",
"duration",
",",
"step",
":",
"function",
"(",
"now",
",",
"fx",
")",
"{",
"drawFn",
"(",
"startVal",
"+",
"now",
")",
";",
"this",
".",
"nudgeChart",
"(",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
"}",
";",
"if",
"(",
"finishCallback",
")",
"{",
"animationProperties",
".",
"complete",
"=",
"function",
"(",
")",
"{",
"finishCallback",
"(",
"endVal",
")",
";",
"}",
";",
"}",
"// for the animation start and end values, use 0 and animationRange for consistency with the way jQuery handles",
"// css properties that it doesn't recognize",
"$",
"(",
"this",
".",
"renderTo",
")",
".",
"stop",
"(",
"true",
",",
"true",
")",
".",
"css",
"(",
"{",
"'animation-progress'",
":",
"0",
"}",
")",
".",
"animate",
"(",
"{",
"'animation-progress'",
":",
"animationRange",
"}",
",",
"animationProperties",
")",
";",
"}"
] |
we can't use the jQuery animation library explicitly to perform complex SVG animations, but we can take advantage of their implementation using a meaningless css property and a custom step function
|
[
"we",
"can",
"t",
"use",
"the",
"jQuery",
"animation",
"library",
"explicitly",
"to",
"perform",
"complex",
"SVG",
"animations",
"but",
"we",
"can",
"take",
"advantage",
"of",
"their",
"implementation",
"using",
"a",
"meaningless",
"css",
"property",
"and",
"a",
"custom",
"step",
"function"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L5436-L5458
|
|
13,657
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function($super, oldValue, newValue) {
var oldPrecision = this.mathUtils.getDecimalPrecision(oldValue, 3),
newPrecision = this.mathUtils.getDecimalPrecision(newValue, 3);
this.valueAnimationPrecision = Math.max(oldPrecision, newPrecision);
$super(oldValue, newValue);
}
|
javascript
|
function($super, oldValue, newValue) {
var oldPrecision = this.mathUtils.getDecimalPrecision(oldValue, 3),
newPrecision = this.mathUtils.getDecimalPrecision(newValue, 3);
this.valueAnimationPrecision = Math.max(oldPrecision, newPrecision);
$super(oldValue, newValue);
}
|
[
"function",
"(",
"$super",
",",
"oldValue",
",",
"newValue",
")",
"{",
"var",
"oldPrecision",
"=",
"this",
".",
"mathUtils",
".",
"getDecimalPrecision",
"(",
"oldValue",
",",
"3",
")",
",",
"newPrecision",
"=",
"this",
".",
"mathUtils",
".",
"getDecimalPrecision",
"(",
"newValue",
",",
"3",
")",
";",
"this",
".",
"valueAnimationPrecision",
"=",
"Math",
".",
"max",
"(",
"oldPrecision",
",",
"newPrecision",
")",
";",
"$super",
"(",
"oldValue",
",",
"newValue",
")",
";",
"}"
] |
override use the decimal precision of the old and new values to set things up for a smooth animation
|
[
"override",
"use",
"the",
"decimal",
"precision",
"of",
"the",
"old",
"and",
"new",
"values",
"to",
"set",
"things",
"up",
"for",
"a",
"smooth",
"animation"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L6023-L6029
|
|
13,658
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(fillColor) {
var fillColorHex = this.colorUtils.hexFromColor(fillColor),
luminanceThreshold = 128,
darkColor = 'black',
lightColor = 'white',
fillLuminance = this.colorUtils.getLuminance(fillColorHex);
return (fillLuminance < luminanceThreshold) ? lightColor : darkColor;
}
|
javascript
|
function(fillColor) {
var fillColorHex = this.colorUtils.hexFromColor(fillColor),
luminanceThreshold = 128,
darkColor = 'black',
lightColor = 'white',
fillLuminance = this.colorUtils.getLuminance(fillColorHex);
return (fillLuminance < luminanceThreshold) ? lightColor : darkColor;
}
|
[
"function",
"(",
"fillColor",
")",
"{",
"var",
"fillColorHex",
"=",
"this",
".",
"colorUtils",
".",
"hexFromColor",
"(",
"fillColor",
")",
",",
"luminanceThreshold",
"=",
"128",
",",
"darkColor",
"=",
"'black'",
",",
"lightColor",
"=",
"'white'",
",",
"fillLuminance",
"=",
"this",
".",
"colorUtils",
".",
"getLuminance",
"(",
"fillColorHex",
")",
";",
"return",
"(",
"fillLuminance",
"<",
"luminanceThreshold",
")",
"?",
"lightColor",
":",
"darkColor",
";",
"}"
] |
use the value to determine the fill color, then use that color's luminance determine if a light or dark font color should be used
|
[
"use",
"the",
"value",
"to",
"determine",
"the",
"fill",
"color",
"then",
"use",
"that",
"color",
"s",
"luminance",
"determine",
"if",
"a",
"light",
"or",
"dark",
"font",
"color",
"should",
"be",
"used"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L6060-L6068
|
|
13,659
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(num) {
var result = Math.log(num) / Math.LN10;
return (Math.round(result * 10000) / 10000);
}
|
javascript
|
function(num) {
var result = Math.log(num) / Math.LN10;
return (Math.round(result * 10000) / 10000);
}
|
[
"function",
"(",
"num",
")",
"{",
"var",
"result",
"=",
"Math",
".",
"log",
"(",
"num",
")",
"/",
"Math",
".",
"LN10",
";",
"return",
"(",
"Math",
".",
"round",
"(",
"result",
"*",
"10000",
")",
"/",
"10000",
")",
";",
"}"
] |
shortcut for base-ten log, also rounds to four decimal points of precision to make pretty numbers
|
[
"shortcut",
"for",
"base",
"-",
"ten",
"log",
"also",
"rounds",
"to",
"four",
"decimal",
"points",
"of",
"precision",
"to",
"make",
"pretty",
"numbers"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L7272-L7275
|
|
13,660
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(num) {
if(typeof num !== "number") {
return NaN;
}
var isNegative = (num < 0),
result;
if(isNegative) {
num = -num;
}
if(num < 10) {
num += (10 - num) / 10;
}
result = this.logBaseTen(num);
return (isNegative) ? -result : result;
}
|
javascript
|
function(num) {
if(typeof num !== "number") {
return NaN;
}
var isNegative = (num < 0),
result;
if(isNegative) {
num = -num;
}
if(num < 10) {
num += (10 - num) / 10;
}
result = this.logBaseTen(num);
return (isNegative) ? -result : result;
}
|
[
"function",
"(",
"num",
")",
"{",
"if",
"(",
"typeof",
"num",
"!==",
"\"number\"",
")",
"{",
"return",
"NaN",
";",
"}",
"var",
"isNegative",
"=",
"(",
"num",
"<",
"0",
")",
",",
"result",
";",
"if",
"(",
"isNegative",
")",
"{",
"num",
"=",
"-",
"num",
";",
"}",
"if",
"(",
"num",
"<",
"10",
")",
"{",
"num",
"+=",
"(",
"10",
"-",
"num",
")",
"/",
"10",
";",
"}",
"result",
"=",
"this",
".",
"logBaseTen",
"(",
"num",
")",
";",
"return",
"(",
"isNegative",
")",
"?",
"-",
"result",
":",
"result",
";",
"}"
] |
transforms numbers to a normalized log scale that can handle negative numbers rounds to four decimal points of precision
|
[
"transforms",
"numbers",
"to",
"a",
"normalized",
"log",
"scale",
"that",
"can",
"handle",
"negative",
"numbers",
"rounds",
"to",
"four",
"decimal",
"points",
"of",
"precision"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L7279-L7294
|
|
13,661
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(num) {
if(typeof num !== "number") {
return NaN;
}
var isNegative = (num < 0),
result;
if(isNegative) {
num = -num;
}
result = Math.pow(10, num);
if(result < 10) {
result = 10 * (result - 1) / (10 - 1);
}
result = (isNegative) ? -result : result;
return (Math.round(result * 1000) / 1000);
}
|
javascript
|
function(num) {
if(typeof num !== "number") {
return NaN;
}
var isNegative = (num < 0),
result;
if(isNegative) {
num = -num;
}
result = Math.pow(10, num);
if(result < 10) {
result = 10 * (result - 1) / (10 - 1);
}
result = (isNegative) ? -result : result;
return (Math.round(result * 1000) / 1000);
}
|
[
"function",
"(",
"num",
")",
"{",
"if",
"(",
"typeof",
"num",
"!==",
"\"number\"",
")",
"{",
"return",
"NaN",
";",
"}",
"var",
"isNegative",
"=",
"(",
"num",
"<",
"0",
")",
",",
"result",
";",
"if",
"(",
"isNegative",
")",
"{",
"num",
"=",
"-",
"num",
";",
"}",
"result",
"=",
"Math",
".",
"pow",
"(",
"10",
",",
"num",
")",
";",
"if",
"(",
"result",
"<",
"10",
")",
"{",
"result",
"=",
"10",
"*",
"(",
"result",
"-",
"1",
")",
"/",
"(",
"10",
"-",
"1",
")",
";",
"}",
"result",
"=",
"(",
"isNegative",
")",
"?",
"-",
"result",
":",
"result",
";",
"return",
"(",
"Math",
".",
"round",
"(",
"result",
"*",
"1000",
")",
"/",
"1000",
")",
";",
"}"
] |
reverses the transformation made by absLogBaseTen above rounds to three decimal points of precision
|
[
"reverses",
"the",
"transformation",
"made",
"by",
"absLogBaseTen",
"above",
"rounds",
"to",
"three",
"decimal",
"points",
"of",
"precision"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L7298-L7314
|
|
13,662
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(num) {
if(typeof num !== "number") {
return NaN;
}
var isNegative = num < 0;
num = (isNegative) ? -num : num;
var log = this.logBaseTen(num),
result = Math.pow(10, Math.floor(log));
return (isNegative) ? -result: result;
}
|
javascript
|
function(num) {
if(typeof num !== "number") {
return NaN;
}
var isNegative = num < 0;
num = (isNegative) ? -num : num;
var log = this.logBaseTen(num),
result = Math.pow(10, Math.floor(log));
return (isNegative) ? -result: result;
}
|
[
"function",
"(",
"num",
")",
"{",
"if",
"(",
"typeof",
"num",
"!==",
"\"number\"",
")",
"{",
"return",
"NaN",
";",
"}",
"var",
"isNegative",
"=",
"num",
"<",
"0",
";",
"num",
"=",
"(",
"isNegative",
")",
"?",
"-",
"num",
":",
"num",
";",
"var",
"log",
"=",
"this",
".",
"logBaseTen",
"(",
"num",
")",
",",
"result",
"=",
"Math",
".",
"pow",
"(",
"10",
",",
"Math",
".",
"floor",
"(",
"log",
")",
")",
";",
"return",
"(",
"isNegative",
")",
"?",
"-",
"result",
":",
"result",
";",
"}"
] |
calculates the power of ten that is closest to but not greater than the number negative numbers are treated as their absolute value and the sign of the result is flipped before returning
|
[
"calculates",
"the",
"power",
"of",
"ten",
"that",
"is",
"closest",
"to",
"but",
"not",
"greater",
"than",
"the",
"number",
"negative",
"numbers",
"are",
"treated",
"as",
"their",
"absolute",
"value",
"and",
"the",
"sign",
"of",
"the",
"result",
"is",
"flipped",
"before",
"returning"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L7318-L7328
|
|
13,663
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(num, max) {
max = max || Infinity;
var precision = 0;
while(precision < max && num.toFixed(precision) !== num.toString()) {
precision += 1;
}
return precision;
}
|
javascript
|
function(num, max) {
max = max || Infinity;
var precision = 0;
while(precision < max && num.toFixed(precision) !== num.toString()) {
precision += 1;
}
return precision;
}
|
[
"function",
"(",
"num",
",",
"max",
")",
"{",
"max",
"=",
"max",
"||",
"Infinity",
";",
"var",
"precision",
"=",
"0",
";",
"while",
"(",
"precision",
"<",
"max",
"&&",
"num",
".",
"toFixed",
"(",
"precision",
")",
"!==",
"num",
".",
"toString",
"(",
")",
")",
"{",
"precision",
"+=",
"1",
";",
"}",
"return",
"precision",
";",
"}"
] |
returns the number of digits of precision after the decimal point optionally accepts a maximum number, after which point it will stop looking and return the max
|
[
"returns",
"the",
"number",
"of",
"digits",
"of",
"precision",
"after",
"the",
"decimal",
"point",
"optionally",
"accepts",
"a",
"maximum",
"number",
"after",
"which",
"point",
"it",
"will",
"stop",
"looking",
"and",
"return",
"the",
"max"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L7346-L7355
|
|
13,664
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(isoString, pointSpan) {
var i18n = Splunk.JSCharting.i18nUtils,
bdTime = this.extractBdTime(isoString),
dateObject;
if(bdTime.isInvalid) {
return null;
}
dateObject = this.bdTimeToDateObject(bdTime);
if (pointSpan >= this.MIN_SECS_PER_DAY) { // day or larger
return i18n.format_date(dateObject);
}
else if (pointSpan >= this.SECS_PER_MIN) { // minute or longer
return format_datetime(dateObject, 'medium', 'short');
}
return format_datetime(dateObject);
}
|
javascript
|
function(isoString, pointSpan) {
var i18n = Splunk.JSCharting.i18nUtils,
bdTime = this.extractBdTime(isoString),
dateObject;
if(bdTime.isInvalid) {
return null;
}
dateObject = this.bdTimeToDateObject(bdTime);
if (pointSpan >= this.MIN_SECS_PER_DAY) { // day or larger
return i18n.format_date(dateObject);
}
else if (pointSpan >= this.SECS_PER_MIN) { // minute or longer
return format_datetime(dateObject, 'medium', 'short');
}
return format_datetime(dateObject);
}
|
[
"function",
"(",
"isoString",
",",
"pointSpan",
")",
"{",
"var",
"i18n",
"=",
"Splunk",
".",
"JSCharting",
".",
"i18nUtils",
",",
"bdTime",
"=",
"this",
".",
"extractBdTime",
"(",
"isoString",
")",
",",
"dateObject",
";",
"if",
"(",
"bdTime",
".",
"isInvalid",
")",
"{",
"return",
"null",
";",
"}",
"dateObject",
"=",
"this",
".",
"bdTimeToDateObject",
"(",
"bdTime",
")",
";",
"if",
"(",
"pointSpan",
">=",
"this",
".",
"MIN_SECS_PER_DAY",
")",
"{",
"// day or larger",
"return",
"i18n",
".",
"format_date",
"(",
"dateObject",
")",
";",
"}",
"else",
"if",
"(",
"pointSpan",
">=",
"this",
".",
"SECS_PER_MIN",
")",
"{",
"// minute or longer",
"return",
"format_datetime",
"(",
"dateObject",
",",
"'medium'",
",",
"'short'",
")",
";",
"}",
"return",
"format_datetime",
"(",
"dateObject",
")",
";",
"}"
] |
returns null if string cannot be parsed
|
[
"returns",
"null",
"if",
"string",
"cannot",
"be",
"parsed"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L7886-L7903
|
|
13,665
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(hexNum, alpha) {
if(typeof hexNum !== "number") {
hexNum = parseInt(hexNum, 16);
}
if(isNaN(hexNum) || hexNum < 0x000000 || hexNum > 0xffffff) {
return undefined;
}
var r = (hexNum & 0xff0000) >> 16,
g = (hexNum & 0x00ff00) >> 8,
b = hexNum & 0x0000ff;
return ((alpha === undefined) ? ("rgb(" + r + "," + g + "," + b + ")") : ("rgba(" + r + "," + g + "," + b + "," + alpha + ")"));
}
|
javascript
|
function(hexNum, alpha) {
if(typeof hexNum !== "number") {
hexNum = parseInt(hexNum, 16);
}
if(isNaN(hexNum) || hexNum < 0x000000 || hexNum > 0xffffff) {
return undefined;
}
var r = (hexNum & 0xff0000) >> 16,
g = (hexNum & 0x00ff00) >> 8,
b = hexNum & 0x0000ff;
return ((alpha === undefined) ? ("rgb(" + r + "," + g + "," + b + ")") : ("rgba(" + r + "," + g + "," + b + "," + alpha + ")"));
}
|
[
"function",
"(",
"hexNum",
",",
"alpha",
")",
"{",
"if",
"(",
"typeof",
"hexNum",
"!==",
"\"number\"",
")",
"{",
"hexNum",
"=",
"parseInt",
"(",
"hexNum",
",",
"16",
")",
";",
"}",
"if",
"(",
"isNaN",
"(",
"hexNum",
")",
"||",
"hexNum",
"<",
"0x000000",
"||",
"hexNum",
">",
"0xffffff",
")",
"{",
"return",
"undefined",
";",
"}",
"var",
"r",
"=",
"(",
"hexNum",
"&",
"0xff0000",
")",
">>",
"16",
",",
"g",
"=",
"(",
"hexNum",
"&",
"0x00ff00",
")",
">>",
"8",
",",
"b",
"=",
"hexNum",
"&",
"0x0000ff",
";",
"return",
"(",
"(",
"alpha",
"===",
"undefined",
")",
"?",
"(",
"\"rgb(\"",
"+",
"r",
"+",
"\",\"",
"+",
"g",
"+",
"\",\"",
"+",
"b",
"+",
"\")\"",
")",
":",
"(",
"\"rgba(\"",
"+",
"r",
"+",
"\",\"",
"+",
"g",
"+",
"\",\"",
"+",
"b",
"+",
"\",\"",
"+",
"alpha",
"+",
"\")\"",
")",
")",
";",
"}"
] |
converts a hex number to its css-friendly counterpart, with optional alpha transparency field returns undefined if the input is cannot be parsed to a valid number or if the number is out of range
|
[
"converts",
"a",
"hex",
"number",
"to",
"its",
"css",
"-",
"friendly",
"counterpart",
"with",
"optional",
"alpha",
"transparency",
"field",
"returns",
"undefined",
"if",
"the",
"input",
"is",
"cannot",
"be",
"parsed",
"to",
"a",
"valid",
"number",
"or",
"if",
"the",
"number",
"is",
"out",
"of",
"range"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8009-L8021
|
|
13,666
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(color) {
var normalizedColor = Splunk.util.normalizeColor(color);
return (normalizedColor) ? parseInt(normalizedColor.replace("#", "0x"), 16) : 0;
}
|
javascript
|
function(color) {
var normalizedColor = Splunk.util.normalizeColor(color);
return (normalizedColor) ? parseInt(normalizedColor.replace("#", "0x"), 16) : 0;
}
|
[
"function",
"(",
"color",
")",
"{",
"var",
"normalizedColor",
"=",
"Splunk",
".",
"util",
".",
"normalizeColor",
"(",
"color",
")",
";",
"return",
"(",
"normalizedColor",
")",
"?",
"parseInt",
"(",
"normalizedColor",
".",
"replace",
"(",
"\"#\"",
",",
"\"0x\"",
")",
",",
"16",
")",
":",
"0",
";",
"}"
] |
coverts a color string in either hex or rgb format into its corresponding hex number returns zero if the color string can't be parsed as either format
|
[
"coverts",
"a",
"color",
"string",
"in",
"either",
"hex",
"or",
"rgb",
"format",
"into",
"its",
"corresponding",
"hex",
"number",
"returns",
"zero",
"if",
"the",
"color",
"string",
"can",
"t",
"be",
"parsed",
"as",
"either",
"format"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8025-L8029
|
|
13,667
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(rgbaStr) {
// lazy create the regex
if(!this.rgbaRegex) {
this.rgbaRegex = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,[\s\d.]+\)\s*$/;
}
var colorComponents = this.rgbaRegex.exec(rgbaStr);
if(!colorComponents) {
return rgbaStr;
}
return ("rgb(" + colorComponents[1] + ", " + colorComponents[2] + ", " + colorComponents[3] + ")");
}
|
javascript
|
function(rgbaStr) {
// lazy create the regex
if(!this.rgbaRegex) {
this.rgbaRegex = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,[\s\d.]+\)\s*$/;
}
var colorComponents = this.rgbaRegex.exec(rgbaStr);
if(!colorComponents) {
return rgbaStr;
}
return ("rgb(" + colorComponents[1] + ", " + colorComponents[2] + ", " + colorComponents[3] + ")");
}
|
[
"function",
"(",
"rgbaStr",
")",
"{",
"// lazy create the regex",
"if",
"(",
"!",
"this",
".",
"rgbaRegex",
")",
"{",
"this",
".",
"rgbaRegex",
"=",
"/",
"^rgba\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,[\\s\\d.]+\\)\\s*$",
"/",
";",
"}",
"var",
"colorComponents",
"=",
"this",
".",
"rgbaRegex",
".",
"exec",
"(",
"rgbaStr",
")",
";",
"if",
"(",
"!",
"colorComponents",
")",
"{",
"return",
"rgbaStr",
";",
"}",
"return",
"(",
"\"rgb(\"",
"+",
"colorComponents",
"[",
"1",
"]",
"+",
"\", \"",
"+",
"colorComponents",
"[",
"2",
"]",
"+",
"\", \"",
"+",
"colorComponents",
"[",
"3",
"]",
"+",
"\")\"",
")",
";",
"}"
] |
given a color string in rgba format, returns the equivalent color in rgb format if the color string is not in valid rgba format, returns the color string un-modified
|
[
"given",
"a",
"color",
"string",
"in",
"rgba",
"format",
"returns",
"the",
"equivalent",
"color",
"in",
"rgb",
"format",
"if",
"the",
"color",
"string",
"is",
"not",
"in",
"valid",
"rgba",
"format",
"returns",
"the",
"color",
"string",
"un",
"-",
"modified"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8039-L8049
|
|
13,668
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(properties) {
var key, newKey,
remapped = {},
axisProps = this.filterPropsByRegex(properties, /(axisX|primaryAxis|axisLabelsX|axisTitleX|gridLinesX)/);
for(key in axisProps) {
if(axisProps.hasOwnProperty(key)) {
if(!this.xAxisKeyIsTrumped(key, properties)) {
newKey = key.replace(/(axisX|primaryAxis)/, "axis");
newKey = newKey.replace(/axisLabelsX/, "axisLabels");
newKey = newKey.replace(/axisTitleX/, "axisTitle");
newKey = newKey.replace(/gridLinesX/, "gridLines");
remapped[newKey] = axisProps[key];
}
}
}
return remapped;
}
|
javascript
|
function(properties) {
var key, newKey,
remapped = {},
axisProps = this.filterPropsByRegex(properties, /(axisX|primaryAxis|axisLabelsX|axisTitleX|gridLinesX)/);
for(key in axisProps) {
if(axisProps.hasOwnProperty(key)) {
if(!this.xAxisKeyIsTrumped(key, properties)) {
newKey = key.replace(/(axisX|primaryAxis)/, "axis");
newKey = newKey.replace(/axisLabelsX/, "axisLabels");
newKey = newKey.replace(/axisTitleX/, "axisTitle");
newKey = newKey.replace(/gridLinesX/, "gridLines");
remapped[newKey] = axisProps[key];
}
}
}
return remapped;
}
|
[
"function",
"(",
"properties",
")",
"{",
"var",
"key",
",",
"newKey",
",",
"remapped",
"=",
"{",
"}",
",",
"axisProps",
"=",
"this",
".",
"filterPropsByRegex",
"(",
"properties",
",",
"/",
"(axisX|primaryAxis|axisLabelsX|axisTitleX|gridLinesX)",
"/",
")",
";",
"for",
"(",
"key",
"in",
"axisProps",
")",
"{",
"if",
"(",
"axisProps",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"if",
"(",
"!",
"this",
".",
"xAxisKeyIsTrumped",
"(",
"key",
",",
"properties",
")",
")",
"{",
"newKey",
"=",
"key",
".",
"replace",
"(",
"/",
"(axisX|primaryAxis)",
"/",
",",
"\"axis\"",
")",
";",
"newKey",
"=",
"newKey",
".",
"replace",
"(",
"/",
"axisLabelsX",
"/",
",",
"\"axisLabels\"",
")",
";",
"newKey",
"=",
"newKey",
".",
"replace",
"(",
"/",
"axisTitleX",
"/",
",",
"\"axisTitle\"",
")",
";",
"newKey",
"=",
"newKey",
".",
"replace",
"(",
"/",
"gridLinesX",
"/",
",",
"\"gridLines\"",
")",
";",
"remapped",
"[",
"newKey",
"]",
"=",
"axisProps",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"return",
"remapped",
";",
"}"
] |
returns a map of properties that apply either to the x-axis or to x-axis labels all axis-related keys are renamed to 'axis' and all axis-label-related keys are renamed to 'axisLabels'
|
[
"returns",
"a",
"map",
"of",
"properties",
"that",
"apply",
"either",
"to",
"the",
"x",
"-",
"axis",
"or",
"to",
"x",
"-",
"axis",
"labels",
"all",
"axis",
"-",
"related",
"keys",
"are",
"renamed",
"to",
"axis",
"and",
"all",
"axis",
"-",
"label",
"-",
"related",
"keys",
"are",
"renamed",
"to",
"axisLabels"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8077-L8093
|
|
13,669
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(key, properties) {
if(!(/primaryAxis/.test(key))) {
return false;
}
if(/primaryAxisTitle/.test(key)) {
return properties[key.replace(/primaryAxisTitle/, "axisTitleX")];
}
return properties[key.replace(/primaryAxis/, "axisX")];
}
|
javascript
|
function(key, properties) {
if(!(/primaryAxis/.test(key))) {
return false;
}
if(/primaryAxisTitle/.test(key)) {
return properties[key.replace(/primaryAxisTitle/, "axisTitleX")];
}
return properties[key.replace(/primaryAxis/, "axisX")];
}
|
[
"function",
"(",
"key",
",",
"properties",
")",
"{",
"if",
"(",
"!",
"(",
"/",
"primaryAxis",
"/",
".",
"test",
"(",
"key",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"/",
"primaryAxisTitle",
"/",
".",
"test",
"(",
"key",
")",
")",
"{",
"return",
"properties",
"[",
"key",
".",
"replace",
"(",
"/",
"primaryAxisTitle",
"/",
",",
"\"axisTitleX\"",
")",
"]",
";",
"}",
"return",
"properties",
"[",
"key",
".",
"replace",
"(",
"/",
"primaryAxis",
"/",
",",
"\"axisX\"",
")",
"]",
";",
"}"
] |
checks if the given x-axis key is deprecated, and if so returns true if that key's non-deprecated counterpart is set in the properties map, otherwise returns false
|
[
"checks",
"if",
"the",
"given",
"x",
"-",
"axis",
"key",
"is",
"deprecated",
"and",
"if",
"so",
"returns",
"true",
"if",
"that",
"key",
"s",
"non",
"-",
"deprecated",
"counterpart",
"is",
"set",
"in",
"the",
"properties",
"map",
"otherwise",
"returns",
"false"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8097-L8105
|
|
13,670
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(properties) {
var key, newKey,
remapped = {},
axisProps = this.filterPropsByRegex(properties, /(axisY|secondaryAxis|axisLabelsY|axisTitleY|gridLinesY)/);
for(key in axisProps) {
if(axisProps.hasOwnProperty(key)) {
if(!this.yAxisKeyIsTrumped(key, properties)) {
newKey = key.replace(/(axisY|secondaryAxis)/, "axis");
newKey = newKey.replace(/axisLabelsY/, "axisLabels");
newKey = newKey.replace(/axisTitleY/, "axisTitle");
newKey = newKey.replace(/gridLinesY/, "gridLines");
remapped[newKey] = axisProps[key];
}
}
}
return remapped;
}
|
javascript
|
function(properties) {
var key, newKey,
remapped = {},
axisProps = this.filterPropsByRegex(properties, /(axisY|secondaryAxis|axisLabelsY|axisTitleY|gridLinesY)/);
for(key in axisProps) {
if(axisProps.hasOwnProperty(key)) {
if(!this.yAxisKeyIsTrumped(key, properties)) {
newKey = key.replace(/(axisY|secondaryAxis)/, "axis");
newKey = newKey.replace(/axisLabelsY/, "axisLabels");
newKey = newKey.replace(/axisTitleY/, "axisTitle");
newKey = newKey.replace(/gridLinesY/, "gridLines");
remapped[newKey] = axisProps[key];
}
}
}
return remapped;
}
|
[
"function",
"(",
"properties",
")",
"{",
"var",
"key",
",",
"newKey",
",",
"remapped",
"=",
"{",
"}",
",",
"axisProps",
"=",
"this",
".",
"filterPropsByRegex",
"(",
"properties",
",",
"/",
"(axisY|secondaryAxis|axisLabelsY|axisTitleY|gridLinesY)",
"/",
")",
";",
"for",
"(",
"key",
"in",
"axisProps",
")",
"{",
"if",
"(",
"axisProps",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"if",
"(",
"!",
"this",
".",
"yAxisKeyIsTrumped",
"(",
"key",
",",
"properties",
")",
")",
"{",
"newKey",
"=",
"key",
".",
"replace",
"(",
"/",
"(axisY|secondaryAxis)",
"/",
",",
"\"axis\"",
")",
";",
"newKey",
"=",
"newKey",
".",
"replace",
"(",
"/",
"axisLabelsY",
"/",
",",
"\"axisLabels\"",
")",
";",
"newKey",
"=",
"newKey",
".",
"replace",
"(",
"/",
"axisTitleY",
"/",
",",
"\"axisTitle\"",
")",
";",
"newKey",
"=",
"newKey",
".",
"replace",
"(",
"/",
"gridLinesY",
"/",
",",
"\"gridLines\"",
")",
";",
"remapped",
"[",
"newKey",
"]",
"=",
"axisProps",
"[",
"key",
"]",
";",
"}",
"}",
"}",
"return",
"remapped",
";",
"}"
] |
returns a map of properties that apply either to the y-axis or to y-axis labels all axis-related keys are renamed to 'axis' and all axis-label-related keys are renamed to 'axisLabels'
|
[
"returns",
"a",
"map",
"of",
"properties",
"that",
"apply",
"either",
"to",
"the",
"y",
"-",
"axis",
"or",
"to",
"y",
"-",
"axis",
"labels",
"all",
"axis",
"-",
"related",
"keys",
"are",
"renamed",
"to",
"axis",
"and",
"all",
"axis",
"-",
"label",
"-",
"related",
"keys",
"are",
"renamed",
"to",
"axisLabels"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8109-L8125
|
|
13,671
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(key, properties) {
if(!(/secondaryAxis/.test(key))) {
return false;
}
if(/secondaryAxisTitle/.test(key)) {
return properties[key.replace(/secondaryAxisTitle/, "axisTitleY")];
}
return properties[key.replace(/secondaryAxis/, "axisY")];
}
|
javascript
|
function(key, properties) {
if(!(/secondaryAxis/.test(key))) {
return false;
}
if(/secondaryAxisTitle/.test(key)) {
return properties[key.replace(/secondaryAxisTitle/, "axisTitleY")];
}
return properties[key.replace(/secondaryAxis/, "axisY")];
}
|
[
"function",
"(",
"key",
",",
"properties",
")",
"{",
"if",
"(",
"!",
"(",
"/",
"secondaryAxis",
"/",
".",
"test",
"(",
"key",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"/",
"secondaryAxisTitle",
"/",
".",
"test",
"(",
"key",
")",
")",
"{",
"return",
"properties",
"[",
"key",
".",
"replace",
"(",
"/",
"secondaryAxisTitle",
"/",
",",
"\"axisTitleY\"",
")",
"]",
";",
"}",
"return",
"properties",
"[",
"key",
".",
"replace",
"(",
"/",
"secondaryAxis",
"/",
",",
"\"axisY\"",
")",
"]",
";",
"}"
] |
checks if the given y-axis key is deprecated, and if so returns true if that key's non-deprecated counterpart is set in the properties map, otherwise returns false
|
[
"checks",
"if",
"the",
"given",
"y",
"-",
"axis",
"key",
"is",
"deprecated",
"and",
"if",
"so",
"returns",
"true",
"if",
"that",
"key",
"s",
"non",
"-",
"deprecated",
"counterpart",
"is",
"set",
"in",
"the",
"properties",
"map",
"otherwise",
"returns",
"false"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8129-L8137
|
|
13,672
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(props, regex) {
if(!(regex instanceof RegExp)) {
return props;
}
var key,
filtered = {};
for(key in props) {
if(props.hasOwnProperty(key) && regex.test(key)) {
filtered[key] = props[key];
}
}
return filtered;
}
|
javascript
|
function(props, regex) {
if(!(regex instanceof RegExp)) {
return props;
}
var key,
filtered = {};
for(key in props) {
if(props.hasOwnProperty(key) && regex.test(key)) {
filtered[key] = props[key];
}
}
return filtered;
}
|
[
"function",
"(",
"props",
",",
"regex",
")",
"{",
"if",
"(",
"!",
"(",
"regex",
"instanceof",
"RegExp",
")",
")",
"{",
"return",
"props",
";",
"}",
"var",
"key",
",",
"filtered",
"=",
"{",
"}",
";",
"for",
"(",
"key",
"in",
"props",
")",
"{",
"if",
"(",
"props",
".",
"hasOwnProperty",
"(",
"key",
")",
"&&",
"regex",
".",
"test",
"(",
"key",
")",
")",
"{",
"filtered",
"[",
"key",
"]",
"=",
"props",
"[",
"key",
"]",
";",
"}",
"}",
"return",
"filtered",
";",
"}"
] |
uses the given regex to filter out any properties whose key doesn't match will return an empty object if the props input is not a map
|
[
"uses",
"the",
"given",
"regex",
"to",
"filter",
"out",
"any",
"properties",
"whose",
"key",
"doesn",
"t",
"match",
"will",
"return",
"an",
"empty",
"object",
"if",
"the",
"props",
"input",
"is",
"not",
"a",
"map"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8141-L8154
|
|
13,673
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(array1, array2) {
// make sure these are actually arrays
if(!(array1 instanceof Array) || !(array2 instanceof Array)) {
return false;
}
if(array1 === array2) {
// true if they are the same object
return true;
}
if(array1.length !== array2.length) {
// false if they are different lengths
return false;
}
// false if any of their elements don't match
for(var i = 0; i < array1.length; i++) {
if(array1[i] !== array2[i]) {
return false;
}
}
return true;
}
|
javascript
|
function(array1, array2) {
// make sure these are actually arrays
if(!(array1 instanceof Array) || !(array2 instanceof Array)) {
return false;
}
if(array1 === array2) {
// true if they are the same object
return true;
}
if(array1.length !== array2.length) {
// false if they are different lengths
return false;
}
// false if any of their elements don't match
for(var i = 0; i < array1.length; i++) {
if(array1[i] !== array2[i]) {
return false;
}
}
return true;
}
|
[
"function",
"(",
"array1",
",",
"array2",
")",
"{",
"// make sure these are actually arrays",
"if",
"(",
"!",
"(",
"array1",
"instanceof",
"Array",
")",
"||",
"!",
"(",
"array2",
"instanceof",
"Array",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"array1",
"===",
"array2",
")",
"{",
"// true if they are the same object",
"return",
"true",
";",
"}",
"if",
"(",
"array1",
".",
"length",
"!==",
"array2",
".",
"length",
")",
"{",
"// false if they are different lengths",
"return",
"false",
";",
"}",
"// false if any of their elements don't match",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array1",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"array1",
"[",
"i",
"]",
"!==",
"array2",
"[",
"i",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
a simple utility method for comparing arrays, assumes one-dimensional arrays of primitives, performs strict comparisons
|
[
"a",
"simple",
"utility",
"method",
"for",
"comparing",
"arrays",
"assumes",
"one",
"-",
"dimensional",
"arrays",
"of",
"primitives",
"performs",
"strict",
"comparisons"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8201-L8221
|
|
13,674
|
splunk/splunk-sdk-javascript
|
lib/ui/charting/js_charting.js
|
function(date, format) {
var i, replacements,
locale = locale_name();
if(format && locale_uses_day_before_month()) {
replacements = this.DAY_FIRST_FORMATS;
for(i = 0; i < replacements.length; i++) {
format = format.replace(replacements[i][0], replacements[i][1]);
}
}
if(format && locale in this.CUSTOM_LOCALE_FORMATS) {
replacements = this.CUSTOM_LOCALE_FORMATS[locale];
for(i = 0; i < replacements.length; i++) {
format = format.replace(replacements[i][0], replacements[i][1]);
}
}
return format_date(date, format);
}
|
javascript
|
function(date, format) {
var i, replacements,
locale = locale_name();
if(format && locale_uses_day_before_month()) {
replacements = this.DAY_FIRST_FORMATS;
for(i = 0; i < replacements.length; i++) {
format = format.replace(replacements[i][0], replacements[i][1]);
}
}
if(format && locale in this.CUSTOM_LOCALE_FORMATS) {
replacements = this.CUSTOM_LOCALE_FORMATS[locale];
for(i = 0; i < replacements.length; i++) {
format = format.replace(replacements[i][0], replacements[i][1]);
}
}
return format_date(date, format);
}
|
[
"function",
"(",
"date",
",",
"format",
")",
"{",
"var",
"i",
",",
"replacements",
",",
"locale",
"=",
"locale_name",
"(",
")",
";",
"if",
"(",
"format",
"&&",
"locale_uses_day_before_month",
"(",
")",
")",
"{",
"replacements",
"=",
"this",
".",
"DAY_FIRST_FORMATS",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"replacements",
".",
"length",
";",
"i",
"++",
")",
"{",
"format",
"=",
"format",
".",
"replace",
"(",
"replacements",
"[",
"i",
"]",
"[",
"0",
"]",
",",
"replacements",
"[",
"i",
"]",
"[",
"1",
"]",
")",
";",
"}",
"}",
"if",
"(",
"format",
"&&",
"locale",
"in",
"this",
".",
"CUSTOM_LOCALE_FORMATS",
")",
"{",
"replacements",
"=",
"this",
".",
"CUSTOM_LOCALE_FORMATS",
"[",
"locale",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"replacements",
".",
"length",
";",
"i",
"++",
")",
"{",
"format",
"=",
"format",
".",
"replace",
"(",
"replacements",
"[",
"i",
"]",
"[",
"0",
"]",
",",
"replacements",
"[",
"i",
"]",
"[",
"1",
"]",
")",
";",
"}",
"}",
"return",
"format_date",
"(",
"date",
",",
"format",
")",
";",
"}"
] |
a special-case hack to handle some i18n bugs, see SPL-42469
|
[
"a",
"special",
"-",
"case",
"hack",
"to",
"handle",
"some",
"i18n",
"bugs",
"see",
"SPL",
"-",
"42469"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/lib/ui/charting/js_charting.js#L8261-L8278
|
|
13,675
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(args) {
args = this.trim(args, '&\?#');
var parts = args.split('&');
var output = {};
var key;
var value;
var equalsSegments;
var lim = parts.length;
for (var i=0,l=lim; i<l; i++) {
equalsSegments = parts[i].split('=');
key = decodeURIComponent(equalsSegments.shift());
value = equalsSegments.join("=");
output[key] = decodeURIComponent(value);
}
return output;
}
|
javascript
|
function(args) {
args = this.trim(args, '&\?#');
var parts = args.split('&');
var output = {};
var key;
var value;
var equalsSegments;
var lim = parts.length;
for (var i=0,l=lim; i<l; i++) {
equalsSegments = parts[i].split('=');
key = decodeURIComponent(equalsSegments.shift());
value = equalsSegments.join("=");
output[key] = decodeURIComponent(value);
}
return output;
}
|
[
"function",
"(",
"args",
")",
"{",
"args",
"=",
"this",
".",
"trim",
"(",
"args",
",",
"'&\\?#'",
")",
";",
"var",
"parts",
"=",
"args",
".",
"split",
"(",
"'&'",
")",
";",
"var",
"output",
"=",
"{",
"}",
";",
"var",
"key",
";",
"var",
"value",
";",
"var",
"equalsSegments",
";",
"var",
"lim",
"=",
"parts",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"lim",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"equalsSegments",
"=",
"parts",
"[",
"i",
"]",
".",
"split",
"(",
"'='",
")",
";",
"key",
"=",
"decodeURIComponent",
"(",
"equalsSegments",
".",
"shift",
"(",
")",
")",
";",
"value",
"=",
"equalsSegments",
".",
"join",
"(",
"\"=\"",
")",
";",
"output",
"[",
"key",
"]",
"=",
"decodeURIComponent",
"(",
"value",
")",
";",
"}",
"return",
"output",
";",
"}"
] |
Converts a flat querystring into an object literal
|
[
"Converts",
"a",
"flat",
"querystring",
"into",
"an",
"object",
"literal"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L10790-L10807
|
|
13,676
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(){
var hashPos = window.location.href.indexOf('#');
if (hashPos == -1) {
return "";
}
var qPos = window.location.href.indexOf('?', hashPos);
if (qPos != -1)
return window.location.href.substr(qPos);
return window.location.href.substr(hashPos);
}
|
javascript
|
function(){
var hashPos = window.location.href.indexOf('#');
if (hashPos == -1) {
return "";
}
var qPos = window.location.href.indexOf('?', hashPos);
if (qPos != -1)
return window.location.href.substr(qPos);
return window.location.href.substr(hashPos);
}
|
[
"function",
"(",
")",
"{",
"var",
"hashPos",
"=",
"window",
".",
"location",
".",
"href",
".",
"indexOf",
"(",
"'#'",
")",
";",
"if",
"(",
"hashPos",
"==",
"-",
"1",
")",
"{",
"return",
"\"\"",
";",
"}",
"var",
"qPos",
"=",
"window",
".",
"location",
".",
"href",
".",
"indexOf",
"(",
"'?'",
",",
"hashPos",
")",
";",
"if",
"(",
"qPos",
"!=",
"-",
"1",
")",
"return",
"window",
".",
"location",
".",
"href",
".",
"substr",
"(",
"qPos",
")",
";",
"return",
"window",
".",
"location",
".",
"href",
".",
"substr",
"(",
"hashPos",
")",
";",
"}"
] |
Extracts the fragment identifier value.
|
[
"Extracts",
"the",
"fragment",
"identifier",
"value",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L10812-L10825
|
|
13,677
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(serverOffsetThen, d) {
if (!Splunk.util.isInt(serverOffsetThen)) {
return 0;
}
// what JS thinks the timezone offset is at the time given by d. This WILL INCLUDE DST
var clientOffsetThen = d.getTimezoneOffset() * 60;
// what splunkd told is the actual timezone offset.
serverOffsetThen = serverOffsetThen * -60;
return 1000 * (serverOffsetThen - clientOffsetThen);
}
|
javascript
|
function(serverOffsetThen, d) {
if (!Splunk.util.isInt(serverOffsetThen)) {
return 0;
}
// what JS thinks the timezone offset is at the time given by d. This WILL INCLUDE DST
var clientOffsetThen = d.getTimezoneOffset() * 60;
// what splunkd told is the actual timezone offset.
serverOffsetThen = serverOffsetThen * -60;
return 1000 * (serverOffsetThen - clientOffsetThen);
}
|
[
"function",
"(",
"serverOffsetThen",
",",
"d",
")",
"{",
"if",
"(",
"!",
"Splunk",
".",
"util",
".",
"isInt",
"(",
"serverOffsetThen",
")",
")",
"{",
"return",
"0",
";",
"}",
"// what JS thinks the timezone offset is at the time given by d. This WILL INCLUDE DST",
"var",
"clientOffsetThen",
"=",
"d",
".",
"getTimezoneOffset",
"(",
")",
"*",
"60",
";",
"// what splunkd told is the actual timezone offset.",
"serverOffsetThen",
"=",
"serverOffsetThen",
"*",
"-",
"60",
";",
"return",
"1000",
"*",
"(",
"serverOffsetThen",
"-",
"clientOffsetThen",
")",
";",
"}"
] |
Given a timezone offset in minutes, and a JS Date object,
returns the delta in milliseconds, of the two timezones.
Note that this will include the offset contributions from DST for both.
|
[
"Given",
"a",
"timezone",
"offset",
"in",
"minutes",
"and",
"a",
"JS",
"Date",
"object",
"returns",
"the",
"delta",
"in",
"milliseconds",
"of",
"the",
"two",
"timezones",
".",
"Note",
"that",
"this",
"will",
"include",
"the",
"offset",
"contributions",
"from",
"DST",
"for",
"both",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L10894-L10904
|
|
13,678
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function() {
var output = '', seg, len;
for (var i=0,l=arguments.length; i<l; i++) {
seg = arguments[i].toString();
len = seg.length;
if (len > 1 && seg.charAt(len-1) == '/') {
seg = seg.substring(0, len-1);
}
if (seg.charAt(0) != '/') {
output += '/' + seg;
} else {
output += seg;
}
}
// augment static dirs with build number
if (output!='/') {
var segments = output.split('/');
var firstseg = segments[1];
if (firstseg=='static' || firstseg=='modules') {
var postfix = output.substring(firstseg.length+2, output.length);
output = '/'+firstseg+'/@' + window.$C['BUILD_NUMBER'];
if (window.$C['BUILD_PUSH_NUMBER']) output += '.' + window.$C['BUILD_PUSH_NUMBER'];
if (segments[2] == 'app')
output += ':'+this.getConfigValue('APP_BUILD', 0);
output += '/' + postfix;
}
}
var root = Splunk.util.getConfigValue('MRSPARKLE_ROOT_PATH', '/');
var locale = Splunk.util.getConfigValue('LOCALE', 'en-US');
if (root == '' || root == '/') {
return '/' + locale + output;
} else {
return root + '/' + locale + output;
}
}
|
javascript
|
function() {
var output = '', seg, len;
for (var i=0,l=arguments.length; i<l; i++) {
seg = arguments[i].toString();
len = seg.length;
if (len > 1 && seg.charAt(len-1) == '/') {
seg = seg.substring(0, len-1);
}
if (seg.charAt(0) != '/') {
output += '/' + seg;
} else {
output += seg;
}
}
// augment static dirs with build number
if (output!='/') {
var segments = output.split('/');
var firstseg = segments[1];
if (firstseg=='static' || firstseg=='modules') {
var postfix = output.substring(firstseg.length+2, output.length);
output = '/'+firstseg+'/@' + window.$C['BUILD_NUMBER'];
if (window.$C['BUILD_PUSH_NUMBER']) output += '.' + window.$C['BUILD_PUSH_NUMBER'];
if (segments[2] == 'app')
output += ':'+this.getConfigValue('APP_BUILD', 0);
output += '/' + postfix;
}
}
var root = Splunk.util.getConfigValue('MRSPARKLE_ROOT_PATH', '/');
var locale = Splunk.util.getConfigValue('LOCALE', 'en-US');
if (root == '' || root == '/') {
return '/' + locale + output;
} else {
return root + '/' + locale + output;
}
}
|
[
"function",
"(",
")",
"{",
"var",
"output",
"=",
"''",
",",
"seg",
",",
"len",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"l",
"=",
"arguments",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"seg",
"=",
"arguments",
"[",
"i",
"]",
".",
"toString",
"(",
")",
";",
"len",
"=",
"seg",
".",
"length",
";",
"if",
"(",
"len",
">",
"1",
"&&",
"seg",
".",
"charAt",
"(",
"len",
"-",
"1",
")",
"==",
"'/'",
")",
"{",
"seg",
"=",
"seg",
".",
"substring",
"(",
"0",
",",
"len",
"-",
"1",
")",
";",
"}",
"if",
"(",
"seg",
".",
"charAt",
"(",
"0",
")",
"!=",
"'/'",
")",
"{",
"output",
"+=",
"'/'",
"+",
"seg",
";",
"}",
"else",
"{",
"output",
"+=",
"seg",
";",
"}",
"}",
"// augment static dirs with build number",
"if",
"(",
"output",
"!=",
"'/'",
")",
"{",
"var",
"segments",
"=",
"output",
".",
"split",
"(",
"'/'",
")",
";",
"var",
"firstseg",
"=",
"segments",
"[",
"1",
"]",
";",
"if",
"(",
"firstseg",
"==",
"'static'",
"||",
"firstseg",
"==",
"'modules'",
")",
"{",
"var",
"postfix",
"=",
"output",
".",
"substring",
"(",
"firstseg",
".",
"length",
"+",
"2",
",",
"output",
".",
"length",
")",
";",
"output",
"=",
"'/'",
"+",
"firstseg",
"+",
"'/@'",
"+",
"window",
".",
"$C",
"[",
"'BUILD_NUMBER'",
"]",
";",
"if",
"(",
"window",
".",
"$C",
"[",
"'BUILD_PUSH_NUMBER'",
"]",
")",
"output",
"+=",
"'.'",
"+",
"window",
".",
"$C",
"[",
"'BUILD_PUSH_NUMBER'",
"]",
";",
"if",
"(",
"segments",
"[",
"2",
"]",
"==",
"'app'",
")",
"output",
"+=",
"':'",
"+",
"this",
".",
"getConfigValue",
"(",
"'APP_BUILD'",
",",
"0",
")",
";",
"output",
"+=",
"'/'",
"+",
"postfix",
";",
"}",
"}",
"var",
"root",
"=",
"Splunk",
".",
"util",
".",
"getConfigValue",
"(",
"'MRSPARKLE_ROOT_PATH'",
",",
"'/'",
")",
";",
"var",
"locale",
"=",
"Splunk",
".",
"util",
".",
"getConfigValue",
"(",
"'LOCALE'",
",",
"'en-US'",
")",
";",
"if",
"(",
"root",
"==",
"''",
"||",
"root",
"==",
"'/'",
")",
"{",
"return",
"'/'",
"+",
"locale",
"+",
"output",
";",
"}",
"else",
"{",
"return",
"root",
"+",
"'/'",
"+",
"locale",
"+",
"output",
";",
"}",
"}"
] |
Returns a proper path that is relative to the current appserver location.
This is critical to ensure that we are proxy compatible. This method
takes 1 or more arguments, which will all be stiched together in sequence.
Ex: make_url('search/job'); // "/splunk/search/job"
Ex: make_url('/search/job'); // "/splunk/search/job"
Ex: make_url('/search', '/job'); // "/splunk/search/job"
Ex: make_url('/search', '/job', 1234); // "/splunk/search/job/1234"
Static paths are augmented with a cache defeater
Ex: make_url('/static/js/foo.js'); // "/splunk/static/@12345/js/foo.js"
Ex: make_url('/static/js/foo.js'); // "/splunk/static/@12345.1/js/foo.js"
@param path {String} The relative path to extend
TODO: lots of fancy URL munging
|
[
"Returns",
"a",
"proper",
"path",
"that",
"is",
"relative",
"to",
"the",
"current",
"appserver",
"location",
".",
"This",
"is",
"critical",
"to",
"ensure",
"that",
"we",
"are",
"proxy",
"compatible",
".",
"This",
"method",
"takes",
"1",
"or",
"more",
"arguments",
"which",
"will",
"all",
"be",
"stiched",
"together",
"in",
"sequence",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L10975-L11011
|
|
13,679
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(url, options) {
url = this.make_url(url);
if (options) url = url + '?' + this.propToQueryString(options);
return url;
}
|
javascript
|
function(url, options) {
url = this.make_url(url);
if (options) url = url + '?' + this.propToQueryString(options);
return url;
}
|
[
"function",
"(",
"url",
",",
"options",
")",
"{",
"url",
"=",
"this",
".",
"make_url",
"(",
"url",
")",
";",
"if",
"(",
"options",
")",
"url",
"=",
"url",
"+",
"'?'",
"+",
"this",
".",
"propToQueryString",
"(",
"options",
")",
";",
"return",
"url",
";",
"}"
] |
Given a path and a dictionary of options, builds a qualified query string.
@param uri {String} required; path to endpoint. eg. "search/jobs"
@param options {Object} key / value par of query params eg. {'foo': 'bar'}
|
[
"Given",
"a",
"path",
"and",
"a",
"dictionary",
"of",
"options",
"builds",
"a",
"qualified",
"query",
"string",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11019-L11023
|
|
13,680
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(uri, options, windowObj, focus) {
uri = this.make_full_url(uri, options);
if (!windowObj) windowObj = window;
windowObj.document.location = uri;
if (focus && windowObj.focus) windowObj.focus();
return;
}
|
javascript
|
function(uri, options, windowObj, focus) {
uri = this.make_full_url(uri, options);
if (!windowObj) windowObj = window;
windowObj.document.location = uri;
if (focus && windowObj.focus) windowObj.focus();
return;
}
|
[
"function",
"(",
"uri",
",",
"options",
",",
"windowObj",
",",
"focus",
")",
"{",
"uri",
"=",
"this",
".",
"make_full_url",
"(",
"uri",
",",
"options",
")",
";",
"if",
"(",
"!",
"windowObj",
")",
"windowObj",
"=",
"window",
";",
"windowObj",
".",
"document",
".",
"location",
"=",
"uri",
";",
"if",
"(",
"focus",
"&&",
"windowObj",
".",
"focus",
")",
"windowObj",
".",
"focus",
"(",
")",
";",
"return",
";",
"}"
] |
Redirects user to a new page.
@param uri {String} required
@param options {Object} containing parameters like:
sid => attaches optional sid in valid format
s => attaches optional saved search name
q => attaches optional search string in valid format
Example:
util.redirect_to('app/core/search', {
'sid' : 1234,
'foo' : 'bar'
});
redirects to 'splunk/app/core/search?sid=1234&foo=bar'
@param windowObj {Window Object} an optional window object to target the location change
@param focus {Boolean} if true, focus is called on windowObj
|
[
"Redirects",
"user",
"to",
"a",
"new",
"page",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11044-L11050
|
|
13,681
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(path) {
if (path === undefined) {
path = document.location.pathname;
}
var locale = this.getConfigValue('LOCALE').toString();
// if there is no way to figure out the locale, just return pathname
if (!this.getConfigValue('LOCALE') || path.indexOf(locale) == -1) {
return path;
}
var start = locale.length + path.indexOf(locale);
return path.slice(start);
}
|
javascript
|
function(path) {
if (path === undefined) {
path = document.location.pathname;
}
var locale = this.getConfigValue('LOCALE').toString();
// if there is no way to figure out the locale, just return pathname
if (!this.getConfigValue('LOCALE') || path.indexOf(locale) == -1) {
return path;
}
var start = locale.length + path.indexOf(locale);
return path.slice(start);
}
|
[
"function",
"(",
"path",
")",
"{",
"if",
"(",
"path",
"===",
"undefined",
")",
"{",
"path",
"=",
"document",
".",
"location",
".",
"pathname",
";",
"}",
"var",
"locale",
"=",
"this",
".",
"getConfigValue",
"(",
"'LOCALE'",
")",
".",
"toString",
"(",
")",
";",
"// if there is no way to figure out the locale, just return pathname",
"if",
"(",
"!",
"this",
".",
"getConfigValue",
"(",
"'LOCALE'",
")",
"||",
"path",
".",
"indexOf",
"(",
"locale",
")",
"==",
"-",
"1",
")",
"{",
"return",
"path",
";",
"}",
"var",
"start",
"=",
"locale",
".",
"length",
"+",
"path",
".",
"indexOf",
"(",
"locale",
")",
";",
"return",
"path",
".",
"slice",
"(",
"start",
")",
";",
"}"
] |
Return the path without the localization segment.
|
[
"Return",
"the",
"path",
"without",
"the",
"localization",
"segment",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11109-L11121
|
|
13,682
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(){
var pageYOffset = 0;
if(window.pageYOffset){
pageYOffset = window.pageYOffset;
}else if(document.documentElement && document.documentElement.scrollTop){
pageYOffset = document.documentElement.scrollTop;
}
return pageYOffset;
}
|
javascript
|
function(){
var pageYOffset = 0;
if(window.pageYOffset){
pageYOffset = window.pageYOffset;
}else if(document.documentElement && document.documentElement.scrollTop){
pageYOffset = document.documentElement.scrollTop;
}
return pageYOffset;
}
|
[
"function",
"(",
")",
"{",
"var",
"pageYOffset",
"=",
"0",
";",
"if",
"(",
"window",
".",
"pageYOffset",
")",
"{",
"pageYOffset",
"=",
"window",
".",
"pageYOffset",
";",
"}",
"else",
"if",
"(",
"document",
".",
"documentElement",
"&&",
"document",
".",
"documentElement",
".",
"scrollTop",
")",
"{",
"pageYOffset",
"=",
"document",
".",
"documentElement",
".",
"scrollTop",
";",
"}",
"return",
"pageYOffset",
";",
"}"
] |
Retrieve the amount of content that has been hidden by scrolling down.
@type Number
@return 0-n value.
|
[
"Retrieve",
"the",
"amount",
"of",
"content",
"that",
"has",
"been",
"hidden",
"by",
"scrolling",
"down",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11149-L11157
|
|
13,683
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(){
return {
width:(!isNaN(window.innerWidth))?window.innerWidth:document.documentElement.clientWidth||0,
height:(!isNaN(window.innerHeight))?window.innerHeight:document.documentElement.clientHeight||0
};
}
|
javascript
|
function(){
return {
width:(!isNaN(window.innerWidth))?window.innerWidth:document.documentElement.clientWidth||0,
height:(!isNaN(window.innerHeight))?window.innerHeight:document.documentElement.clientHeight||0
};
}
|
[
"function",
"(",
")",
"{",
"return",
"{",
"width",
":",
"(",
"!",
"isNaN",
"(",
"window",
".",
"innerWidth",
")",
")",
"?",
"window",
".",
"innerWidth",
":",
"document",
".",
"documentElement",
".",
"clientWidth",
"||",
"0",
",",
"height",
":",
"(",
"!",
"isNaN",
"(",
"window",
".",
"innerHeight",
")",
")",
"?",
"window",
".",
"innerHeight",
":",
"document",
".",
"documentElement",
".",
"clientHeight",
"||",
"0",
"}",
";",
"}"
] |
Retrieve the inner dimensions of the window. This does not work in jQuery.
@type Object
@return An object literal having width and height attributes.
|
[
"Retrieve",
"the",
"inner",
"dimensions",
"of",
"the",
"window",
".",
"This",
"does",
"not",
"work",
"in",
"jQuery",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11165-L11170
|
|
13,684
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(el, styleProperty){
if(el.currentStyle){
return el.currentStyle[styleProperty];
}else if(window.getComputedStyle){
var cssProperty = styleProperty.replace(/([A-Z])/g, "-$1").toLowerCase();
var computedStyle = window.getComputedStyle(el, "");
return computedStyle.getPropertyValue(cssProperty);
}else{
return "";
}
}
|
javascript
|
function(el, styleProperty){
if(el.currentStyle){
return el.currentStyle[styleProperty];
}else if(window.getComputedStyle){
var cssProperty = styleProperty.replace(/([A-Z])/g, "-$1").toLowerCase();
var computedStyle = window.getComputedStyle(el, "");
return computedStyle.getPropertyValue(cssProperty);
}else{
return "";
}
}
|
[
"function",
"(",
"el",
",",
"styleProperty",
")",
"{",
"if",
"(",
"el",
".",
"currentStyle",
")",
"{",
"return",
"el",
".",
"currentStyle",
"[",
"styleProperty",
"]",
";",
"}",
"else",
"if",
"(",
"window",
".",
"getComputedStyle",
")",
"{",
"var",
"cssProperty",
"=",
"styleProperty",
".",
"replace",
"(",
"/",
"([A-Z])",
"/",
"g",
",",
"\"-$1\"",
")",
".",
"toLowerCase",
"(",
")",
";",
"var",
"computedStyle",
"=",
"window",
".",
"getComputedStyle",
"(",
"el",
",",
"\"\"",
")",
";",
"return",
"computedStyle",
".",
"getPropertyValue",
"(",
"cssProperty",
")",
";",
"}",
"else",
"{",
"return",
"\"\"",
";",
"}",
"}"
] |
Retrieve the computed style from a specified element.
@param el
@param styleProperty
@return The computed style value.
@type String
|
[
"Retrieve",
"the",
"computed",
"style",
"from",
"a",
"specified",
"element",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11180-L11190
|
|
13,685
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(p, s){
s = s || window.location.search;
if(!s){
return null;
}
if(!(s.indexOf(p+'=')+1)){
return null;
}
return s.split(p+'=')[1].split('&')[0];
}
|
javascript
|
function(p, s){
s = s || window.location.search;
if(!s){
return null;
}
if(!(s.indexOf(p+'=')+1)){
return null;
}
return s.split(p+'=')[1].split('&')[0];
}
|
[
"function",
"(",
"p",
",",
"s",
")",
"{",
"s",
"=",
"s",
"||",
"window",
".",
"location",
".",
"search",
";",
"if",
"(",
"!",
"s",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"(",
"s",
".",
"indexOf",
"(",
"p",
"+",
"'='",
")",
"+",
"1",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"s",
".",
"split",
"(",
"p",
"+",
"'='",
")",
"[",
"1",
"]",
".",
"split",
"(",
"'&'",
")",
"[",
"0",
"]",
";",
"}"
] |
Retrieve a GET parameter from the window.location. Type casting is not performed.
@param {String} p The param value to retrieve.
@param {String} s Optional string to search through instead of window.location.search
@return {String || null} The string value or null if it does not exist.
|
[
"Retrieve",
"a",
"GET",
"parameter",
"from",
"the",
"window",
".",
"location",
".",
"Type",
"casting",
"is",
"not",
"performed",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11198-L11207
|
|
13,686
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(rgb){
var parts = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
var hex = (parts[1]<<16|parts[2]<<8|parts[3]).toString(16);
return "#"+Array(6-hex.length).concat([hex]).toString().replace(/,/g, 0);
}
|
javascript
|
function(rgb){
var parts = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
var hex = (parts[1]<<16|parts[2]<<8|parts[3]).toString(16);
return "#"+Array(6-hex.length).concat([hex]).toString().replace(/,/g, 0);
}
|
[
"function",
"(",
"rgb",
")",
"{",
"var",
"parts",
"=",
"rgb",
".",
"match",
"(",
"/",
"^rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)$",
"/",
")",
";",
"var",
"hex",
"=",
"(",
"parts",
"[",
"1",
"]",
"<<",
"16",
"|",
"parts",
"[",
"2",
"]",
"<<",
"8",
"|",
"parts",
"[",
"3",
"]",
")",
".",
"toString",
"(",
"16",
")",
";",
"return",
"\"#\"",
"+",
"Array",
"(",
"6",
"-",
"hex",
".",
"length",
")",
".",
"concat",
"(",
"[",
"hex",
"]",
")",
".",
"toString",
"(",
")",
".",
"replace",
"(",
"/",
",",
"/",
"g",
",",
"0",
")",
";",
"}"
] |
Take an RGB value and convert to HEX equivalent.
@param {String} rgb A RGB value following rgb(XXX, XXX, XXX) convention.
@type String
@return A HEX equivalent for a given RGB value with a leading '#' character.
|
[
"Take",
"an",
"RGB",
"value",
"and",
"convert",
"to",
"HEX",
"equivalent",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11216-L11220
|
|
13,687
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(target, innerHTML) {
/*@cc_on //innerHTML is faster for IE
target.innerHTML = innerHTML;
return target;
@*/
var targetClone = target.cloneNode(false);
targetClone.innerHTML = innerHTML;
target.parentNode.replaceChild(targetClone, target);
return targetClone;
}
|
javascript
|
function(target, innerHTML) {
/*@cc_on //innerHTML is faster for IE
target.innerHTML = innerHTML;
return target;
@*/
var targetClone = target.cloneNode(false);
targetClone.innerHTML = innerHTML;
target.parentNode.replaceChild(targetClone, target);
return targetClone;
}
|
[
"function",
"(",
"target",
",",
"innerHTML",
")",
"{",
"/*@cc_on //innerHTML is faster for IE\n target.innerHTML = innerHTML;\n return target;\n @*/",
"var",
"targetClone",
"=",
"target",
".",
"cloneNode",
"(",
"false",
")",
";",
"targetClone",
".",
"innerHTML",
"=",
"innerHTML",
";",
"target",
".",
"parentNode",
".",
"replaceChild",
"(",
"targetClone",
",",
"target",
")",
";",
"return",
"targetClone",
";",
"}"
] |
innerHTML substitute when it is not fast enough.
@param {HTMLObject} target The target DOM element to replace innerHTML content with.
@param {String} innerHTML The innerHTML string to add.
@return {HTMLObject} The reference to the target DOM element as it may have been cloned and removed.
|
[
"innerHTML",
"substitute",
"when",
"it",
"is",
"not",
"fast",
"enough",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11251-L11260
|
|
13,688
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(q, isUserEntered) {
var workingQ = '' + q;
workingQ = workingQ.replace(this.reLTrim, '').replace(this.reRNormalize, ' ');
if (workingQ.substring(0, 1) == '|') {
return q;
}
// this is specific to the case where searchstring = 'search ',
// which we conservatively assume does not constitute a search command
if (!isUserEntered
&& (workingQ.substring(0, 7) == 'search ' && workingQ.length > 7))
{
return q;
}
return 'search ' + workingQ;
}
|
javascript
|
function(q, isUserEntered) {
var workingQ = '' + q;
workingQ = workingQ.replace(this.reLTrim, '').replace(this.reRNormalize, ' ');
if (workingQ.substring(0, 1) == '|') {
return q;
}
// this is specific to the case where searchstring = 'search ',
// which we conservatively assume does not constitute a search command
if (!isUserEntered
&& (workingQ.substring(0, 7) == 'search ' && workingQ.length > 7))
{
return q;
}
return 'search ' + workingQ;
}
|
[
"function",
"(",
"q",
",",
"isUserEntered",
")",
"{",
"var",
"workingQ",
"=",
"''",
"+",
"q",
";",
"workingQ",
"=",
"workingQ",
".",
"replace",
"(",
"this",
".",
"reLTrim",
",",
"''",
")",
".",
"replace",
"(",
"this",
".",
"reRNormalize",
",",
"' '",
")",
";",
"if",
"(",
"workingQ",
".",
"substring",
"(",
"0",
",",
"1",
")",
"==",
"'|'",
")",
"{",
"return",
"q",
";",
"}",
"// this is specific to the case where searchstring = 'search ',",
"// which we conservatively assume does not constitute a search command",
"if",
"(",
"!",
"isUserEntered",
"&&",
"(",
"workingQ",
".",
"substring",
"(",
"0",
",",
"7",
")",
"==",
"'search '",
"&&",
"workingQ",
".",
"length",
">",
"7",
")",
")",
"{",
"return",
"q",
";",
"}",
"return",
"'search '",
"+",
"workingQ",
";",
"}"
] |
Returns a fully qualified search string by prepending the 'search'
command of unqualified searches. This method deems strings as unqualified
if it does not start with a | or 'search '
@param {boolean} isUserEntered Indicates if 'q' is expected to be unqualified
|
[
"Returns",
"a",
"fully",
"qualified",
"search",
"string",
"by",
"prepending",
"the",
"search",
"command",
"of",
"unqualified",
"searches",
".",
"This",
"method",
"deems",
"strings",
"as",
"unqualified",
"if",
"it",
"does",
"not",
"start",
"with",
"a",
"|",
"or",
"search"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11313-L11328
|
|
13,689
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(q) {
var workingQ = '' + q;
workingQ = workingQ.replace(this.reLTrimCommand, '');
if (workingQ.substring(0, 7) == 'search ') {
return workingQ.substring(7).replace(this.reLTrimCommand, '');
}
return q;
}
|
javascript
|
function(q) {
var workingQ = '' + q;
workingQ = workingQ.replace(this.reLTrimCommand, '');
if (workingQ.substring(0, 7) == 'search ') {
return workingQ.substring(7).replace(this.reLTrimCommand, '');
}
return q;
}
|
[
"function",
"(",
"q",
")",
"{",
"var",
"workingQ",
"=",
"''",
"+",
"q",
";",
"workingQ",
"=",
"workingQ",
".",
"replace",
"(",
"this",
".",
"reLTrimCommand",
",",
"''",
")",
";",
"if",
"(",
"workingQ",
".",
"substring",
"(",
"0",
",",
"7",
")",
"==",
"'search '",
")",
"{",
"return",
"workingQ",
".",
"substring",
"(",
"7",
")",
".",
"replace",
"(",
"this",
".",
"reLTrimCommand",
",",
"''",
")",
";",
"}",
"return",
"q",
";",
"}"
] |
Returns an unqualified search string by removing any leading 'search '
command. This method does a simple search at the beginning of the
search.
|
[
"Returns",
"an",
"unqualified",
"search",
"string",
"by",
"removing",
"any",
"leading",
"search",
"command",
".",
"This",
"method",
"does",
"a",
"simple",
"search",
"at",
"the",
"beginning",
"of",
"the",
"search",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11335-L11342
|
|
13,690
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(strList) {
if (typeof(strList) != 'string' || !strList) return [];
var items = [];
var field_name_buffer = [];
var inquote = false;
var str = $.trim(strList);
for (var i=0,j=str.length; i<j; i++) {
if (str.charAt(i) == '\\') {
var nextidx = i+1;
if (j > nextidx && (str.charAt(nextidx) == '\\' || str.charAt(nextidx) == '"')) {
field_name_buffer.push(str.charAt(nextidx));
i++;
continue;
} else {
field_name_buffer.push(str.charAt(i));
continue;
}
}
if (str.charAt(i) == '"') {
if (!inquote) {
inquote = true;
continue;
} else {
inquote = false;
items.push(field_name_buffer.join(''));
field_name_buffer = [];
continue;
}
}
if ((str.charAt(i) == ' ' || str.charAt(i) == ',') && !inquote) {
if (field_name_buffer.length > 0) {
items.push(field_name_buffer.join(''));
}
field_name_buffer = [];
continue;
}
field_name_buffer.push(str.charAt(i));
}
if (field_name_buffer.length > 0) items.push(field_name_buffer.join(''));
return items;
}
|
javascript
|
function(strList) {
if (typeof(strList) != 'string' || !strList) return [];
var items = [];
var field_name_buffer = [];
var inquote = false;
var str = $.trim(strList);
for (var i=0,j=str.length; i<j; i++) {
if (str.charAt(i) == '\\') {
var nextidx = i+1;
if (j > nextidx && (str.charAt(nextidx) == '\\' || str.charAt(nextidx) == '"')) {
field_name_buffer.push(str.charAt(nextidx));
i++;
continue;
} else {
field_name_buffer.push(str.charAt(i));
continue;
}
}
if (str.charAt(i) == '"') {
if (!inquote) {
inquote = true;
continue;
} else {
inquote = false;
items.push(field_name_buffer.join(''));
field_name_buffer = [];
continue;
}
}
if ((str.charAt(i) == ' ' || str.charAt(i) == ',') && !inquote) {
if (field_name_buffer.length > 0) {
items.push(field_name_buffer.join(''));
}
field_name_buffer = [];
continue;
}
field_name_buffer.push(str.charAt(i));
}
if (field_name_buffer.length > 0) items.push(field_name_buffer.join(''));
return items;
}
|
[
"function",
"(",
"strList",
")",
"{",
"if",
"(",
"typeof",
"(",
"strList",
")",
"!=",
"'string'",
"||",
"!",
"strList",
")",
"return",
"[",
"]",
";",
"var",
"items",
"=",
"[",
"]",
";",
"var",
"field_name_buffer",
"=",
"[",
"]",
";",
"var",
"inquote",
"=",
"false",
";",
"var",
"str",
"=",
"$",
".",
"trim",
"(",
"strList",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"j",
"=",
"str",
".",
"length",
";",
"i",
"<",
"j",
";",
"i",
"++",
")",
"{",
"if",
"(",
"str",
".",
"charAt",
"(",
"i",
")",
"==",
"'\\\\'",
")",
"{",
"var",
"nextidx",
"=",
"i",
"+",
"1",
";",
"if",
"(",
"j",
">",
"nextidx",
"&&",
"(",
"str",
".",
"charAt",
"(",
"nextidx",
")",
"==",
"'\\\\'",
"||",
"str",
".",
"charAt",
"(",
"nextidx",
")",
"==",
"'\"'",
")",
")",
"{",
"field_name_buffer",
".",
"push",
"(",
"str",
".",
"charAt",
"(",
"nextidx",
")",
")",
";",
"i",
"++",
";",
"continue",
";",
"}",
"else",
"{",
"field_name_buffer",
".",
"push",
"(",
"str",
".",
"charAt",
"(",
"i",
")",
")",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"str",
".",
"charAt",
"(",
"i",
")",
"==",
"'\"'",
")",
"{",
"if",
"(",
"!",
"inquote",
")",
"{",
"inquote",
"=",
"true",
";",
"continue",
";",
"}",
"else",
"{",
"inquote",
"=",
"false",
";",
"items",
".",
"push",
"(",
"field_name_buffer",
".",
"join",
"(",
"''",
")",
")",
";",
"field_name_buffer",
"=",
"[",
"]",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"(",
"str",
".",
"charAt",
"(",
"i",
")",
"==",
"' '",
"||",
"str",
".",
"charAt",
"(",
"i",
")",
"==",
"','",
")",
"&&",
"!",
"inquote",
")",
"{",
"if",
"(",
"field_name_buffer",
".",
"length",
">",
"0",
")",
"{",
"items",
".",
"push",
"(",
"field_name_buffer",
".",
"join",
"(",
"''",
")",
")",
";",
"}",
"field_name_buffer",
"=",
"[",
"]",
";",
"continue",
";",
"}",
"field_name_buffer",
".",
"push",
"(",
"str",
".",
"charAt",
"(",
"i",
")",
")",
";",
"}",
"if",
"(",
"field_name_buffer",
".",
"length",
">",
"0",
")",
"items",
".",
"push",
"(",
"field_name_buffer",
".",
"join",
"(",
"''",
")",
")",
";",
"return",
"items",
";",
"}"
] |
Deserializes a string into a field list.
|
[
"Deserializes",
"a",
"string",
"into",
"a",
"field",
"list",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11347-L11389
|
|
13,691
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(obj1, obj2){
if(obj1 instanceof Array && obj2 instanceof Array){
if(obj1.length!==obj2.length){
return false;
}else{
for(var i=0; i<obj1.length; i++){
if(!this.objectSimilarity(obj1[i], obj2[i])){
return false;
}
}
}
}else if(obj1 instanceof Object && obj2 instanceof Object){
if(obj1!=obj2){
for(var j in obj2){
if(!obj1.hasOwnProperty(j)){
return false;
}
}
for(var k in obj1){
if(obj1.hasOwnProperty(k)){
if(obj2.hasOwnProperty(k)){
if(!this.objectSimilarity(obj1[k], obj2[k])){
return false;
}
}else{
return false;
}
}
}
}
}else if(typeof(obj1)==="function" && typeof(obj2)==="function"){
if(obj1.toString()!==obj2.toString()){
return false;
}
}else if(obj1!==obj2){
return false;
}
return true;
}
|
javascript
|
function(obj1, obj2){
if(obj1 instanceof Array && obj2 instanceof Array){
if(obj1.length!==obj2.length){
return false;
}else{
for(var i=0; i<obj1.length; i++){
if(!this.objectSimilarity(obj1[i], obj2[i])){
return false;
}
}
}
}else if(obj1 instanceof Object && obj2 instanceof Object){
if(obj1!=obj2){
for(var j in obj2){
if(!obj1.hasOwnProperty(j)){
return false;
}
}
for(var k in obj1){
if(obj1.hasOwnProperty(k)){
if(obj2.hasOwnProperty(k)){
if(!this.objectSimilarity(obj1[k], obj2[k])){
return false;
}
}else{
return false;
}
}
}
}
}else if(typeof(obj1)==="function" && typeof(obj2)==="function"){
if(obj1.toString()!==obj2.toString()){
return false;
}
}else if(obj1!==obj2){
return false;
}
return true;
}
|
[
"function",
"(",
"obj1",
",",
"obj2",
")",
"{",
"if",
"(",
"obj1",
"instanceof",
"Array",
"&&",
"obj2",
"instanceof",
"Array",
")",
"{",
"if",
"(",
"obj1",
".",
"length",
"!==",
"obj2",
".",
"length",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"obj1",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"this",
".",
"objectSimilarity",
"(",
"obj1",
"[",
"i",
"]",
",",
"obj2",
"[",
"i",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"obj1",
"instanceof",
"Object",
"&&",
"obj2",
"instanceof",
"Object",
")",
"{",
"if",
"(",
"obj1",
"!=",
"obj2",
")",
"{",
"for",
"(",
"var",
"j",
"in",
"obj2",
")",
"{",
"if",
"(",
"!",
"obj1",
".",
"hasOwnProperty",
"(",
"j",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"for",
"(",
"var",
"k",
"in",
"obj1",
")",
"{",
"if",
"(",
"obj1",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"{",
"if",
"(",
"obj2",
".",
"hasOwnProperty",
"(",
"k",
")",
")",
"{",
"if",
"(",
"!",
"this",
".",
"objectSimilarity",
"(",
"obj1",
"[",
"k",
"]",
",",
"obj2",
"[",
"k",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"}",
"}",
"else",
"if",
"(",
"typeof",
"(",
"obj1",
")",
"===",
"\"function\"",
"&&",
"typeof",
"(",
"obj2",
")",
"===",
"\"function\"",
")",
"{",
"if",
"(",
"obj1",
".",
"toString",
"(",
")",
"!==",
"obj2",
".",
"toString",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"if",
"(",
"obj1",
"!==",
"obj2",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Compare the likeness of two objects. Please use with discretion.
|
[
"Compare",
"the",
"likeness",
"of",
"two",
"objects",
".",
"Please",
"use",
"with",
"discretion",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11429-L11467
|
|
13,692
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(){
var self = this,
startTime = null,
stopTime = null,
times = [];
var isSet = function(prop){
return (prop==null)?false:true;
};
var isStarted = function(){
return isSet(startTime);
};
var isStopped = function(){
return isSet(stopTime);
};
var softReset = function(){
startTime = null;
stopTime = null;
};
self.start = function(){
if(isStarted()){
throw new Error("cannot call start, start already invoked.");
}
startTime = new Date();
};
self.stop = function(){
if(!isStarted()){
throw new Error("cannot call stop, start not invoked.");
}
if(isStopped()){
throw new Error("cannot call stop, stop already invoked.");
}
stopTime = new Date();
time = stopTime - startTime;
times.push(time);
};
self.pause = function(){
if(!isStarted()){
throw new Error("cannot call pause, start not invoked.");
}
if(isStopped()){
throw new Error("cannot call pause, stop already invoked.");
}
self.stop();
softReset();
};
self.reset = function(){
softReset();
times = [];
};
self.time = function(){
var total = 0;
for(i=0; i<times.length; i++){
total += times[i];
}
if(isStarted() && !isStopped()){
total += (new Date() - startTime);
}
return total/1000;
};
}
|
javascript
|
function(){
var self = this,
startTime = null,
stopTime = null,
times = [];
var isSet = function(prop){
return (prop==null)?false:true;
};
var isStarted = function(){
return isSet(startTime);
};
var isStopped = function(){
return isSet(stopTime);
};
var softReset = function(){
startTime = null;
stopTime = null;
};
self.start = function(){
if(isStarted()){
throw new Error("cannot call start, start already invoked.");
}
startTime = new Date();
};
self.stop = function(){
if(!isStarted()){
throw new Error("cannot call stop, start not invoked.");
}
if(isStopped()){
throw new Error("cannot call stop, stop already invoked.");
}
stopTime = new Date();
time = stopTime - startTime;
times.push(time);
};
self.pause = function(){
if(!isStarted()){
throw new Error("cannot call pause, start not invoked.");
}
if(isStopped()){
throw new Error("cannot call pause, stop already invoked.");
}
self.stop();
softReset();
};
self.reset = function(){
softReset();
times = [];
};
self.time = function(){
var total = 0;
for(i=0; i<times.length; i++){
total += times[i];
}
if(isStarted() && !isStopped()){
total += (new Date() - startTime);
}
return total/1000;
};
}
|
[
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
",",
"startTime",
"=",
"null",
",",
"stopTime",
"=",
"null",
",",
"times",
"=",
"[",
"]",
";",
"var",
"isSet",
"=",
"function",
"(",
"prop",
")",
"{",
"return",
"(",
"prop",
"==",
"null",
")",
"?",
"false",
":",
"true",
";",
"}",
";",
"var",
"isStarted",
"=",
"function",
"(",
")",
"{",
"return",
"isSet",
"(",
"startTime",
")",
";",
"}",
";",
"var",
"isStopped",
"=",
"function",
"(",
")",
"{",
"return",
"isSet",
"(",
"stopTime",
")",
";",
"}",
";",
"var",
"softReset",
"=",
"function",
"(",
")",
"{",
"startTime",
"=",
"null",
";",
"stopTime",
"=",
"null",
";",
"}",
";",
"self",
".",
"start",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"isStarted",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"cannot call start, start already invoked.\"",
")",
";",
"}",
"startTime",
"=",
"new",
"Date",
"(",
")",
";",
"}",
";",
"self",
".",
"stop",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"isStarted",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"cannot call stop, start not invoked.\"",
")",
";",
"}",
"if",
"(",
"isStopped",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"cannot call stop, stop already invoked.\"",
")",
";",
"}",
"stopTime",
"=",
"new",
"Date",
"(",
")",
";",
"time",
"=",
"stopTime",
"-",
"startTime",
";",
"times",
".",
"push",
"(",
"time",
")",
";",
"}",
";",
"self",
".",
"pause",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"!",
"isStarted",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"cannot call pause, start not invoked.\"",
")",
";",
"}",
"if",
"(",
"isStopped",
"(",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"cannot call pause, stop already invoked.\"",
")",
";",
"}",
"self",
".",
"stop",
"(",
")",
";",
"softReset",
"(",
")",
";",
"}",
";",
"self",
".",
"reset",
"=",
"function",
"(",
")",
"{",
"softReset",
"(",
")",
";",
"times",
"=",
"[",
"]",
";",
"}",
";",
"self",
".",
"time",
"=",
"function",
"(",
")",
"{",
"var",
"total",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"times",
".",
"length",
";",
"i",
"++",
")",
"{",
"total",
"+=",
"times",
"[",
"i",
"]",
";",
"}",
"if",
"(",
"isStarted",
"(",
")",
"&&",
"!",
"isStopped",
"(",
")",
")",
"{",
"total",
"+=",
"(",
"new",
"Date",
"(",
")",
"-",
"startTime",
")",
";",
"}",
"return",
"total",
"/",
"1000",
";",
"}",
";",
"}"
] |
Stop watch class.
|
[
"Stop",
"watch",
"class",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11471-L11530
|
|
13,693
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(string, maxLength) {
if (!string) return string;
if (maxLength < 1) return string;
if (string.length <= maxLength) return string;
if (maxLength == 1) return string.substring(0,1) + '...';
var midpoint = Math.ceil(string.length / 2);
var toremove = string.length - maxLength;
var lstrip = Math.ceil(toremove/2);
var rstrip = toremove - lstrip;
return string.substring(0, midpoint-lstrip) + '...' + string.substring(midpoint+rstrip);
}
|
javascript
|
function(string, maxLength) {
if (!string) return string;
if (maxLength < 1) return string;
if (string.length <= maxLength) return string;
if (maxLength == 1) return string.substring(0,1) + '...';
var midpoint = Math.ceil(string.length / 2);
var toremove = string.length - maxLength;
var lstrip = Math.ceil(toremove/2);
var rstrip = toremove - lstrip;
return string.substring(0, midpoint-lstrip) + '...' + string.substring(midpoint+rstrip);
}
|
[
"function",
"(",
"string",
",",
"maxLength",
")",
"{",
"if",
"(",
"!",
"string",
")",
"return",
"string",
";",
"if",
"(",
"maxLength",
"<",
"1",
")",
"return",
"string",
";",
"if",
"(",
"string",
".",
"length",
"<=",
"maxLength",
")",
"return",
"string",
";",
"if",
"(",
"maxLength",
"==",
"1",
")",
"return",
"string",
".",
"substring",
"(",
"0",
",",
"1",
")",
"+",
"'...'",
";",
"var",
"midpoint",
"=",
"Math",
".",
"ceil",
"(",
"string",
".",
"length",
"/",
"2",
")",
";",
"var",
"toremove",
"=",
"string",
".",
"length",
"-",
"maxLength",
";",
"var",
"lstrip",
"=",
"Math",
".",
"ceil",
"(",
"toremove",
"/",
"2",
")",
";",
"var",
"rstrip",
"=",
"toremove",
"-",
"lstrip",
";",
"return",
"string",
".",
"substring",
"(",
"0",
",",
"midpoint",
"-",
"lstrip",
")",
"+",
"'...'",
"+",
"string",
".",
"substring",
"(",
"midpoint",
"+",
"rstrip",
")",
";",
"}"
] |
Returns a string trimmed to maxLength by removing characters from the
middle of the string and replacing with ellipses.
Ex: Splunk.util.smartTrim('1234567890', 5) ==> '12...890'
|
[
"Returns",
"a",
"string",
"trimmed",
"to",
"maxLength",
"by",
"removing",
"characters",
"from",
"the",
"middle",
"of",
"the",
"string",
"and",
"replacing",
"with",
"ellipses",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11543-L11554
|
|
13,694
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
function(fragment, reg, value) {
if (typeof fragment == 'string') {
if (fragment.match(reg)) {
fragment = fragment.replace(reg, value);
}
return fragment;
}
else if (typeof fragment == "function") {
return fragment;
}
// watch out for infinite loops. We make all changes to the array after iteration.
var keysToRename = {};
for (var key in fragment) {
// recurse
if (typeof fragment[key] == 'object') {
Splunk.util.replaceTokens(fragment[key], reg, value);
}
// we have hit a string value.
else if (typeof fragment[key] == 'string' && fragment[key].match(reg)) {
fragment[key] = fragment[key].replace(reg, value);
}
// now that the value is changed we check the key itself
if (key.match(reg)) {
// mark this to be changed after we're out of the iterator
keysToRename[key] = key.replace(reg, value);
}
}
for (oldKey in keysToRename) {
var newKey = keysToRename[oldKey];
fragment[newKey] = fragment[oldKey];
delete(fragment[oldKey]);
}
return fragment;
}
|
javascript
|
function(fragment, reg, value) {
if (typeof fragment == 'string') {
if (fragment.match(reg)) {
fragment = fragment.replace(reg, value);
}
return fragment;
}
else if (typeof fragment == "function") {
return fragment;
}
// watch out for infinite loops. We make all changes to the array after iteration.
var keysToRename = {};
for (var key in fragment) {
// recurse
if (typeof fragment[key] == 'object') {
Splunk.util.replaceTokens(fragment[key], reg, value);
}
// we have hit a string value.
else if (typeof fragment[key] == 'string' && fragment[key].match(reg)) {
fragment[key] = fragment[key].replace(reg, value);
}
// now that the value is changed we check the key itself
if (key.match(reg)) {
// mark this to be changed after we're out of the iterator
keysToRename[key] = key.replace(reg, value);
}
}
for (oldKey in keysToRename) {
var newKey = keysToRename[oldKey];
fragment[newKey] = fragment[oldKey];
delete(fragment[oldKey]);
}
return fragment;
}
|
[
"function",
"(",
"fragment",
",",
"reg",
",",
"value",
")",
"{",
"if",
"(",
"typeof",
"fragment",
"==",
"'string'",
")",
"{",
"if",
"(",
"fragment",
".",
"match",
"(",
"reg",
")",
")",
"{",
"fragment",
"=",
"fragment",
".",
"replace",
"(",
"reg",
",",
"value",
")",
";",
"}",
"return",
"fragment",
";",
"}",
"else",
"if",
"(",
"typeof",
"fragment",
"==",
"\"function\"",
")",
"{",
"return",
"fragment",
";",
"}",
"// watch out for infinite loops. We make all changes to the array after iteration.",
"var",
"keysToRename",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"fragment",
")",
"{",
"// recurse",
"if",
"(",
"typeof",
"fragment",
"[",
"key",
"]",
"==",
"'object'",
")",
"{",
"Splunk",
".",
"util",
".",
"replaceTokens",
"(",
"fragment",
"[",
"key",
"]",
",",
"reg",
",",
"value",
")",
";",
"}",
"// we have hit a string value.",
"else",
"if",
"(",
"typeof",
"fragment",
"[",
"key",
"]",
"==",
"'string'",
"&&",
"fragment",
"[",
"key",
"]",
".",
"match",
"(",
"reg",
")",
")",
"{",
"fragment",
"[",
"key",
"]",
"=",
"fragment",
"[",
"key",
"]",
".",
"replace",
"(",
"reg",
",",
"value",
")",
";",
"}",
"// now that the value is changed we check the key itself",
"if",
"(",
"key",
".",
"match",
"(",
"reg",
")",
")",
"{",
"// mark this to be changed after we're out of the iterator",
"keysToRename",
"[",
"key",
"]",
"=",
"key",
".",
"replace",
"(",
"reg",
",",
"value",
")",
";",
"}",
"}",
"for",
"(",
"oldKey",
"in",
"keysToRename",
")",
"{",
"var",
"newKey",
"=",
"keysToRename",
"[",
"oldKey",
"]",
";",
"fragment",
"[",
"newKey",
"]",
"=",
"fragment",
"[",
"oldKey",
"]",
";",
"delete",
"(",
"fragment",
"[",
"oldKey",
"]",
")",
";",
"}",
"return",
"fragment",
";",
"}"
] |
walked through the entirety of fragment to all levels of nesting
and will replace all matches of the given single regex with the given
single value.
replacement will occur in both keys and values.
|
[
"walked",
"through",
"the",
"entirety",
"of",
"fragment",
"to",
"all",
"levels",
"of",
"nesting",
"and",
"will",
"replace",
"all",
"matches",
"of",
"the",
"given",
"single",
"regex",
"with",
"the",
"given",
"single",
"value",
".",
"replacement",
"will",
"occur",
"in",
"both",
"keys",
"and",
"values",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L11611-L11645
|
|
13,695
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
extend
|
function extend(a, b) {
var n;
if (!a) {
a = {};
}
for (n in b) {
a[n] = b[n];
}
return a;
}
|
javascript
|
function extend(a, b) {
var n;
if (!a) {
a = {};
}
for (n in b) {
a[n] = b[n];
}
return a;
}
|
[
"function",
"extend",
"(",
"a",
",",
"b",
")",
"{",
"var",
"n",
";",
"if",
"(",
"!",
"a",
")",
"{",
"a",
"=",
"{",
"}",
";",
"}",
"for",
"(",
"n",
"in",
"b",
")",
"{",
"a",
"[",
"n",
"]",
"=",
"b",
"[",
"n",
"]",
";",
"}",
"return",
"a",
";",
"}"
] |
Extend an object with the members of another
@param {Object} a The object to be extended
@param {Object} b The object to add to the first one
|
[
"Extend",
"an",
"object",
"with",
"the",
"members",
"of",
"another"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L12123-L12132
|
13,696
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
erase
|
function erase(arr, item) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
arr.splice(i, 1);
break;
}
}
//return arr;
}
|
javascript
|
function erase(arr, item) {
var i = arr.length;
while (i--) {
if (arr[i] === item) {
arr.splice(i, 1);
break;
}
}
//return arr;
}
|
[
"function",
"erase",
"(",
"arr",
",",
"item",
")",
"{",
"var",
"i",
"=",
"arr",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"if",
"(",
"arr",
"[",
"i",
"]",
"===",
"item",
")",
"{",
"arr",
".",
"splice",
"(",
"i",
",",
"1",
")",
";",
"break",
";",
"}",
"}",
"//return arr;\r",
"}"
] |
Remove last occurence of an item from an array
@param {Array} arr
@param {Mixed} item
|
[
"Remove",
"last",
"occurence",
"of",
"an",
"item",
"from",
"an",
"array"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L12186-L12195
|
13,697
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
attr
|
function attr(elem, prop, value) {
var key,
setAttribute = 'setAttribute',
ret;
// if the prop is a string
if (isString(prop)) {
// set the value
if (defined(value)) {
elem[setAttribute](prop, value);
// get the value
} else if (elem && elem.getAttribute) { // elem not defined when printing pie demo...
ret = elem.getAttribute(prop);
}
// else if prop is defined, it is a hash of key/value pairs
} else if (defined(prop) && isObject(prop)) {
for (key in prop) {
elem[setAttribute](key, prop[key]);
}
}
return ret;
}
|
javascript
|
function attr(elem, prop, value) {
var key,
setAttribute = 'setAttribute',
ret;
// if the prop is a string
if (isString(prop)) {
// set the value
if (defined(value)) {
elem[setAttribute](prop, value);
// get the value
} else if (elem && elem.getAttribute) { // elem not defined when printing pie demo...
ret = elem.getAttribute(prop);
}
// else if prop is defined, it is a hash of key/value pairs
} else if (defined(prop) && isObject(prop)) {
for (key in prop) {
elem[setAttribute](key, prop[key]);
}
}
return ret;
}
|
[
"function",
"attr",
"(",
"elem",
",",
"prop",
",",
"value",
")",
"{",
"var",
"key",
",",
"setAttribute",
"=",
"'setAttribute'",
",",
"ret",
";",
"// if the prop is a string\r",
"if",
"(",
"isString",
"(",
"prop",
")",
")",
"{",
"// set the value\r",
"if",
"(",
"defined",
"(",
"value",
")",
")",
"{",
"elem",
"[",
"setAttribute",
"]",
"(",
"prop",
",",
"value",
")",
";",
"// get the value\r",
"}",
"else",
"if",
"(",
"elem",
"&&",
"elem",
".",
"getAttribute",
")",
"{",
"// elem not defined when printing pie demo...\r",
"ret",
"=",
"elem",
".",
"getAttribute",
"(",
"prop",
")",
";",
"}",
"// else if prop is defined, it is a hash of key/value pairs\r",
"}",
"else",
"if",
"(",
"defined",
"(",
"prop",
")",
"&&",
"isObject",
"(",
"prop",
")",
")",
"{",
"for",
"(",
"key",
"in",
"prop",
")",
"{",
"elem",
"[",
"setAttribute",
"]",
"(",
"key",
",",
"prop",
"[",
"key",
"]",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Set or get an attribute or an object of attributes. Can't use jQuery attr because
it attempts to set expando properties on the SVG element, which is not allowed.
@param {Object} elem The DOM element to receive the attribute(s)
@param {String|Object} prop The property or an abject of key-value pairs
@param {String} value The value if a single property is set
|
[
"Set",
"or",
"get",
"an",
"attribute",
"or",
"an",
"object",
"of",
"attributes",
".",
"Can",
"t",
"use",
"jQuery",
"attr",
"because",
"it",
"attempts",
"to",
"set",
"expando",
"properties",
"on",
"the",
"SVG",
"element",
"which",
"is",
"not",
"allowed",
"."
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L12213-L12237
|
13,698
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
css
|
function css(el, styles) {
if (isIE) {
if (styles && styles.opacity !== UNDEFINED) {
styles.filter = 'alpha(opacity=' + (styles.opacity * 100) + ')';
}
}
extend(el.style, styles);
}
|
javascript
|
function css(el, styles) {
if (isIE) {
if (styles && styles.opacity !== UNDEFINED) {
styles.filter = 'alpha(opacity=' + (styles.opacity * 100) + ')';
}
}
extend(el.style, styles);
}
|
[
"function",
"css",
"(",
"el",
",",
"styles",
")",
"{",
"if",
"(",
"isIE",
")",
"{",
"if",
"(",
"styles",
"&&",
"styles",
".",
"opacity",
"!==",
"UNDEFINED",
")",
"{",
"styles",
".",
"filter",
"=",
"'alpha(opacity='",
"+",
"(",
"styles",
".",
"opacity",
"*",
"100",
")",
"+",
"')'",
";",
"}",
"}",
"extend",
"(",
"el",
".",
"style",
",",
"styles",
")",
";",
"}"
] |
Set CSS on a given element
@param {Object} el
@param {Object} styles Style object with camel case property names
|
[
"Set",
"CSS",
"on",
"a",
"given",
"element"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L12268-L12275
|
13,699
|
splunk/splunk-sdk-javascript
|
client/splunk.ui.charting.js
|
createElement
|
function createElement(tag, attribs, styles, parent, nopad) {
var el = doc.createElement(tag);
if (attribs) {
extend(el, attribs);
}
if (nopad) {
css(el, {padding: 0, border: NONE, margin: 0});
}
if (styles) {
css(el, styles);
}
if (parent) {
parent.appendChild(el);
}
return el;
}
|
javascript
|
function createElement(tag, attribs, styles, parent, nopad) {
var el = doc.createElement(tag);
if (attribs) {
extend(el, attribs);
}
if (nopad) {
css(el, {padding: 0, border: NONE, margin: 0});
}
if (styles) {
css(el, styles);
}
if (parent) {
parent.appendChild(el);
}
return el;
}
|
[
"function",
"createElement",
"(",
"tag",
",",
"attribs",
",",
"styles",
",",
"parent",
",",
"nopad",
")",
"{",
"var",
"el",
"=",
"doc",
".",
"createElement",
"(",
"tag",
")",
";",
"if",
"(",
"attribs",
")",
"{",
"extend",
"(",
"el",
",",
"attribs",
")",
";",
"}",
"if",
"(",
"nopad",
")",
"{",
"css",
"(",
"el",
",",
"{",
"padding",
":",
"0",
",",
"border",
":",
"NONE",
",",
"margin",
":",
"0",
"}",
")",
";",
"}",
"if",
"(",
"styles",
")",
"{",
"css",
"(",
"el",
",",
"styles",
")",
";",
"}",
"if",
"(",
"parent",
")",
"{",
"parent",
".",
"appendChild",
"(",
"el",
")",
";",
"}",
"return",
"el",
";",
"}"
] |
Utility function to create element with attributes and styles
@param {Object} tag
@param {Object} attribs
@param {Object} styles
@param {Object} parent
@param {Object} nopad
|
[
"Utility",
"function",
"to",
"create",
"element",
"with",
"attributes",
"and",
"styles"
] |
9aec5443860926654c2ab8ee3bf198a407c53b07
|
https://github.com/splunk/splunk-sdk-javascript/blob/9aec5443860926654c2ab8ee3bf198a407c53b07/client/splunk.ui.charting.js#L12285-L12300
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.