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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
19,700
|
conveyal/transitive.js
|
lib/display/tile-layer.js
|
prefixMatch
|
function prefixMatch (p) {
var i = -1
var n = p.length
var s = document.body.style
while (++i < n) {
if (p[i] + 'Transform' in s) return '-' + p[i].toLowerCase() + '-'
}
return ''
}
|
javascript
|
function prefixMatch (p) {
var i = -1
var n = p.length
var s = document.body.style
while (++i < n) {
if (p[i] + 'Transform' in s) return '-' + p[i].toLowerCase() + '-'
}
return ''
}
|
[
"function",
"prefixMatch",
"(",
"p",
")",
"{",
"var",
"i",
"=",
"-",
"1",
"var",
"n",
"=",
"p",
".",
"length",
"var",
"s",
"=",
"document",
".",
"body",
".",
"style",
"while",
"(",
"++",
"i",
"<",
"n",
")",
"{",
"if",
"(",
"p",
"[",
"i",
"]",
"+",
"'Transform'",
"in",
"s",
")",
"return",
"'-'",
"+",
"p",
"[",
"i",
"]",
".",
"toLowerCase",
"(",
")",
"+",
"'-'",
"}",
"return",
"''",
"}"
] |
Match the transform prefix
|
[
"Match",
"the",
"transform",
"prefix"
] |
4ba541f40f2dcbfd77f11028da07bd3cec9f2b0b
|
https://github.com/conveyal/transitive.js/blob/4ba541f40f2dcbfd77f11028da07bd3cec9f2b0b/lib/display/tile-layer.js#L127-L135
|
19,701
|
lukasmartinelli/mapbox-gl-inspect
|
lib/stylegen.js
|
generateInspectStyle
|
function generateInspectStyle(originalMapStyle, coloredLayers, opts) {
opts = Object.assign({
backgroundColor: '#fff'
}, opts);
var backgroundLayer = {
'id': 'background',
'type': 'background',
'paint': {
'background-color': opts.backgroundColor
}
};
var sources = {};
Object.keys(originalMapStyle.sources).forEach(function (sourceId) {
var source = originalMapStyle.sources[sourceId];
if (source.type === 'vector' || source.type === 'geojson') {
sources[sourceId] = source;
}
});
return Object.assign(originalMapStyle, {
layers: [backgroundLayer].concat(coloredLayers),
soources: sources
});
}
|
javascript
|
function generateInspectStyle(originalMapStyle, coloredLayers, opts) {
opts = Object.assign({
backgroundColor: '#fff'
}, opts);
var backgroundLayer = {
'id': 'background',
'type': 'background',
'paint': {
'background-color': opts.backgroundColor
}
};
var sources = {};
Object.keys(originalMapStyle.sources).forEach(function (sourceId) {
var source = originalMapStyle.sources[sourceId];
if (source.type === 'vector' || source.type === 'geojson') {
sources[sourceId] = source;
}
});
return Object.assign(originalMapStyle, {
layers: [backgroundLayer].concat(coloredLayers),
soources: sources
});
}
|
[
"function",
"generateInspectStyle",
"(",
"originalMapStyle",
",",
"coloredLayers",
",",
"opts",
")",
"{",
"opts",
"=",
"Object",
".",
"assign",
"(",
"{",
"backgroundColor",
":",
"'#fff'",
"}",
",",
"opts",
")",
";",
"var",
"backgroundLayer",
"=",
"{",
"'id'",
":",
"'background'",
",",
"'type'",
":",
"'background'",
",",
"'paint'",
":",
"{",
"'background-color'",
":",
"opts",
".",
"backgroundColor",
"}",
"}",
";",
"var",
"sources",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"originalMapStyle",
".",
"sources",
")",
".",
"forEach",
"(",
"function",
"(",
"sourceId",
")",
"{",
"var",
"source",
"=",
"originalMapStyle",
".",
"sources",
"[",
"sourceId",
"]",
";",
"if",
"(",
"source",
".",
"type",
"===",
"'vector'",
"||",
"source",
".",
"type",
"===",
"'geojson'",
")",
"{",
"sources",
"[",
"sourceId",
"]",
"=",
"source",
";",
"}",
"}",
")",
";",
"return",
"Object",
".",
"assign",
"(",
"originalMapStyle",
",",
"{",
"layers",
":",
"[",
"backgroundLayer",
"]",
".",
"concat",
"(",
"coloredLayers",
")",
",",
"soources",
":",
"sources",
"}",
")",
";",
"}"
] |
Create inspection style out of the original style and the new colored layers
@param {Object} Original map styles
@param {array} Array of colored Mapbox GL layers
@return {Object} Colored inspect style
|
[
"Create",
"inspection",
"style",
"out",
"of",
"the",
"original",
"style",
"and",
"the",
"new",
"colored",
"layers"
] |
19dd99ebf3e0ea639ba7044d2e52563706614a93
|
https://github.com/lukasmartinelli/mapbox-gl-inspect/blob/19dd99ebf3e0ea639ba7044d2e52563706614a93/lib/stylegen.js#L108-L133
|
19,702
|
lukasmartinelli/mapbox-gl-inspect
|
lib/colors.js
|
brightColor
|
function brightColor(layerId, alpha) {
var luminosity = 'bright';
var hue = null;
if (/water|ocean|lake|sea|river/.test(layerId)) {
hue = 'blue';
}
if (/state|country|place/.test(layerId)) {
hue = 'pink';
}
if (/road|highway|transport/.test(layerId)) {
hue = 'orange';
}
if (/contour|building/.test(layerId)) {
hue = 'monochrome';
}
if (/building/.test(layerId)) {
luminosity = 'dark';
}
if (/contour|landuse/.test(layerId)) {
hue = 'yellow';
}
if (/wood|forest|park|landcover/.test(layerId)) {
hue = 'green';
}
var rgb = randomColor({
luminosity: luminosity,
hue: hue,
seed: layerId,
format: 'rgbArray'
});
var rgba = rgb.concat([alpha || 1]);
return 'rgba(' + rgba.join(', ') + ')';
}
|
javascript
|
function brightColor(layerId, alpha) {
var luminosity = 'bright';
var hue = null;
if (/water|ocean|lake|sea|river/.test(layerId)) {
hue = 'blue';
}
if (/state|country|place/.test(layerId)) {
hue = 'pink';
}
if (/road|highway|transport/.test(layerId)) {
hue = 'orange';
}
if (/contour|building/.test(layerId)) {
hue = 'monochrome';
}
if (/building/.test(layerId)) {
luminosity = 'dark';
}
if (/contour|landuse/.test(layerId)) {
hue = 'yellow';
}
if (/wood|forest|park|landcover/.test(layerId)) {
hue = 'green';
}
var rgb = randomColor({
luminosity: luminosity,
hue: hue,
seed: layerId,
format: 'rgbArray'
});
var rgba = rgb.concat([alpha || 1]);
return 'rgba(' + rgba.join(', ') + ')';
}
|
[
"function",
"brightColor",
"(",
"layerId",
",",
"alpha",
")",
"{",
"var",
"luminosity",
"=",
"'bright'",
";",
"var",
"hue",
"=",
"null",
";",
"if",
"(",
"/",
"water|ocean|lake|sea|river",
"/",
".",
"test",
"(",
"layerId",
")",
")",
"{",
"hue",
"=",
"'blue'",
";",
"}",
"if",
"(",
"/",
"state|country|place",
"/",
".",
"test",
"(",
"layerId",
")",
")",
"{",
"hue",
"=",
"'pink'",
";",
"}",
"if",
"(",
"/",
"road|highway|transport",
"/",
".",
"test",
"(",
"layerId",
")",
")",
"{",
"hue",
"=",
"'orange'",
";",
"}",
"if",
"(",
"/",
"contour|building",
"/",
".",
"test",
"(",
"layerId",
")",
")",
"{",
"hue",
"=",
"'monochrome'",
";",
"}",
"if",
"(",
"/",
"building",
"/",
".",
"test",
"(",
"layerId",
")",
")",
"{",
"luminosity",
"=",
"'dark'",
";",
"}",
"if",
"(",
"/",
"contour|landuse",
"/",
".",
"test",
"(",
"layerId",
")",
")",
"{",
"hue",
"=",
"'yellow'",
";",
"}",
"if",
"(",
"/",
"wood|forest|park|landcover",
"/",
".",
"test",
"(",
"layerId",
")",
")",
"{",
"hue",
"=",
"'green'",
";",
"}",
"var",
"rgb",
"=",
"randomColor",
"(",
"{",
"luminosity",
":",
"luminosity",
",",
"hue",
":",
"hue",
",",
"seed",
":",
"layerId",
",",
"format",
":",
"'rgbArray'",
"}",
")",
";",
"var",
"rgba",
"=",
"rgb",
".",
"concat",
"(",
"[",
"alpha",
"||",
"1",
"]",
")",
";",
"return",
"'rgba('",
"+",
"rgba",
".",
"join",
"(",
"', '",
")",
"+",
"')'",
";",
"}"
] |
Assign a color to a unique layer ID and also considering
common layer names such as water or wood.
@param {string} layerId
@return {string} Unique random for the layer ID
|
[
"Assign",
"a",
"color",
"to",
"a",
"unique",
"layer",
"ID",
"and",
"also",
"considering",
"common",
"layer",
"names",
"such",
"as",
"water",
"or",
"wood",
"."
] |
19dd99ebf3e0ea639ba7044d2e52563706614a93
|
https://github.com/lukasmartinelli/mapbox-gl-inspect/blob/19dd99ebf3e0ea639ba7044d2e52563706614a93/lib/colors.js#L9-L50
|
19,703
|
larrymyers/jasmine-reporters
|
src/appveyor_reporter.js
|
setApi
|
function setApi() {
self.api = {};
if(process && process.env && process.env.APPVEYOR_API_URL) {
var fullUrl = process.env.APPVEYOR_API_URL;
var urlParts = fullUrl.split("/")[2].split(":");
self.api = {
host: urlParts[0],
port: urlParts[1],
endpoint: "/api/tests/batch"
};
}
else {
throw Error("Not running in AppVeyor environment");
}
}
|
javascript
|
function setApi() {
self.api = {};
if(process && process.env && process.env.APPVEYOR_API_URL) {
var fullUrl = process.env.APPVEYOR_API_URL;
var urlParts = fullUrl.split("/")[2].split(":");
self.api = {
host: urlParts[0],
port: urlParts[1],
endpoint: "/api/tests/batch"
};
}
else {
throw Error("Not running in AppVeyor environment");
}
}
|
[
"function",
"setApi",
"(",
")",
"{",
"self",
".",
"api",
"=",
"{",
"}",
";",
"if",
"(",
"process",
"&&",
"process",
".",
"env",
"&&",
"process",
".",
"env",
".",
"APPVEYOR_API_URL",
")",
"{",
"var",
"fullUrl",
"=",
"process",
".",
"env",
".",
"APPVEYOR_API_URL",
";",
"var",
"urlParts",
"=",
"fullUrl",
".",
"split",
"(",
"\"/\"",
")",
"[",
"2",
"]",
".",
"split",
"(",
"\":\"",
")",
";",
"self",
".",
"api",
"=",
"{",
"host",
":",
"urlParts",
"[",
"0",
"]",
",",
"port",
":",
"urlParts",
"[",
"1",
"]",
",",
"endpoint",
":",
"\"/api/tests/batch\"",
"}",
";",
"}",
"else",
"{",
"throw",
"Error",
"(",
"\"Not running in AppVeyor environment\"",
")",
";",
"}",
"}"
] |
set API host information
|
[
"set",
"API",
"host",
"information"
] |
4487b61e0681ae81015795738c4c2ef138b2d3ba
|
https://github.com/larrymyers/jasmine-reporters/blob/4487b61e0681ae81015795738c4c2ef138b2d3ba/src/appveyor_reporter.js#L71-L86
|
19,704
|
larrymyers/jasmine-reporters
|
src/appveyor_reporter.js
|
postSpecsToAppVeyor
|
function postSpecsToAppVeyor() {
log.info(inColor("Posting spec batch to AppVeyor API", "magenta"));
var postData = JSON.stringify(self.unreportedSpecs);
var options = {
host: self.api.host,
path: self.api.endpoint,
port: self.api.port,
method: "POST",
headers: {
"Content-Type": "application/json"
}
};
var http = require("http");
var req = http.request(options, function(res) {
log.debug(inColor(" STATUS: " + res.statusCode, "yellow"));
log.debug(inColor(" HEADERS: " + JSON.stringify(res.headers), "yellow"));
res.setEncoding("utf8");
res.on("data", function (chunk) {
log.debug(inColor(" BODY: " + chunk, "yellow"));
});
res.on("end", function() {
log.debug(inColor(" RESPONSE END", "yellow"));
});
});
req.on("error", function(e) {
log.debug(inColor("API request error: " + e.message, "red"));
});
req.write(postData);
req.end();
self.unreportedSpecs = [];
}
|
javascript
|
function postSpecsToAppVeyor() {
log.info(inColor("Posting spec batch to AppVeyor API", "magenta"));
var postData = JSON.stringify(self.unreportedSpecs);
var options = {
host: self.api.host,
path: self.api.endpoint,
port: self.api.port,
method: "POST",
headers: {
"Content-Type": "application/json"
}
};
var http = require("http");
var req = http.request(options, function(res) {
log.debug(inColor(" STATUS: " + res.statusCode, "yellow"));
log.debug(inColor(" HEADERS: " + JSON.stringify(res.headers), "yellow"));
res.setEncoding("utf8");
res.on("data", function (chunk) {
log.debug(inColor(" BODY: " + chunk, "yellow"));
});
res.on("end", function() {
log.debug(inColor(" RESPONSE END", "yellow"));
});
});
req.on("error", function(e) {
log.debug(inColor("API request error: " + e.message, "red"));
});
req.write(postData);
req.end();
self.unreportedSpecs = [];
}
|
[
"function",
"postSpecsToAppVeyor",
"(",
")",
"{",
"log",
".",
"info",
"(",
"inColor",
"(",
"\"Posting spec batch to AppVeyor API\"",
",",
"\"magenta\"",
")",
")",
";",
"var",
"postData",
"=",
"JSON",
".",
"stringify",
"(",
"self",
".",
"unreportedSpecs",
")",
";",
"var",
"options",
"=",
"{",
"host",
":",
"self",
".",
"api",
".",
"host",
",",
"path",
":",
"self",
".",
"api",
".",
"endpoint",
",",
"port",
":",
"self",
".",
"api",
".",
"port",
",",
"method",
":",
"\"POST\"",
",",
"headers",
":",
"{",
"\"Content-Type\"",
":",
"\"application/json\"",
"}",
"}",
";",
"var",
"http",
"=",
"require",
"(",
"\"http\"",
")",
";",
"var",
"req",
"=",
"http",
".",
"request",
"(",
"options",
",",
"function",
"(",
"res",
")",
"{",
"log",
".",
"debug",
"(",
"inColor",
"(",
"\" STATUS: \"",
"+",
"res",
".",
"statusCode",
",",
"\"yellow\"",
")",
")",
";",
"log",
".",
"debug",
"(",
"inColor",
"(",
"\" HEADERS: \"",
"+",
"JSON",
".",
"stringify",
"(",
"res",
".",
"headers",
")",
",",
"\"yellow\"",
")",
")",
";",
"res",
".",
"setEncoding",
"(",
"\"utf8\"",
")",
";",
"res",
".",
"on",
"(",
"\"data\"",
",",
"function",
"(",
"chunk",
")",
"{",
"log",
".",
"debug",
"(",
"inColor",
"(",
"\" BODY: \"",
"+",
"chunk",
",",
"\"yellow\"",
")",
")",
";",
"}",
")",
";",
"res",
".",
"on",
"(",
"\"end\"",
",",
"function",
"(",
")",
"{",
"log",
".",
"debug",
"(",
"inColor",
"(",
"\" RESPONSE END\"",
",",
"\"yellow\"",
")",
")",
";",
"}",
")",
";",
"}",
")",
";",
"req",
".",
"on",
"(",
"\"error\"",
",",
"function",
"(",
"e",
")",
"{",
"log",
".",
"debug",
"(",
"inColor",
"(",
"\"API request error: \"",
"+",
"e",
".",
"message",
",",
"\"red\"",
")",
")",
";",
"}",
")",
";",
"req",
".",
"write",
"(",
"postData",
")",
";",
"req",
".",
"end",
"(",
")",
";",
"self",
".",
"unreportedSpecs",
"=",
"[",
"]",
";",
"}"
] |
post batch to AppVeyor API
|
[
"post",
"batch",
"to",
"AppVeyor",
"API"
] |
4487b61e0681ae81015795738c4c2ef138b2d3ba
|
https://github.com/larrymyers/jasmine-reporters/blob/4487b61e0681ae81015795738c4c2ef138b2d3ba/src/appveyor_reporter.js#L130-L168
|
19,705
|
larrymyers/jasmine-reporters
|
src/appveyor_reporter.js
|
getOutcome
|
function getOutcome(spec) {
var outcome = "None";
if(isFailed(spec)) {
outcome = "Failed";
}
if(isDisabled(spec)) {
outcome = "Ignored";
}
if(isSkipped(spec)) {
outcome = "Skipped";
}
if(isPassed(spec)) {
outcome = "Passed";
}
return outcome;
}
|
javascript
|
function getOutcome(spec) {
var outcome = "None";
if(isFailed(spec)) {
outcome = "Failed";
}
if(isDisabled(spec)) {
outcome = "Ignored";
}
if(isSkipped(spec)) {
outcome = "Skipped";
}
if(isPassed(spec)) {
outcome = "Passed";
}
return outcome;
}
|
[
"function",
"getOutcome",
"(",
"spec",
")",
"{",
"var",
"outcome",
"=",
"\"None\"",
";",
"if",
"(",
"isFailed",
"(",
"spec",
")",
")",
"{",
"outcome",
"=",
"\"Failed\"",
";",
"}",
"if",
"(",
"isDisabled",
"(",
"spec",
")",
")",
"{",
"outcome",
"=",
"\"Ignored\"",
";",
"}",
"if",
"(",
"isSkipped",
"(",
"spec",
")",
")",
"{",
"outcome",
"=",
"\"Skipped\"",
";",
"}",
"if",
"(",
"isPassed",
"(",
"spec",
")",
")",
"{",
"outcome",
"=",
"\"Passed\"",
";",
"}",
"return",
"outcome",
";",
"}"
] |
detect spec outcome and return AppVeyor literals
|
[
"detect",
"spec",
"outcome",
"and",
"return",
"AppVeyor",
"literals"
] |
4487b61e0681ae81015795738c4c2ef138b2d3ba
|
https://github.com/larrymyers/jasmine-reporters/blob/4487b61e0681ae81015795738c4c2ef138b2d3ba/src/appveyor_reporter.js#L171-L191
|
19,706
|
larrymyers/jasmine-reporters
|
src/appveyor_reporter.js
|
mapSpecToResult
|
function mapSpecToResult(spec) {
var firstFailedExpectation = spec.failedExpectations[0] || {};
var result = {
testName: spec.fullName,
testFramework: "jasmine2",
durationMilliseconds: elapsed(spec.__startTime, spec.__endTime),
outcome: getOutcome(spec),
ErrorMessage: firstFailedExpectation.message,
ErrorStackTrace: firstFailedExpectation.stack
};
return result;
}
|
javascript
|
function mapSpecToResult(spec) {
var firstFailedExpectation = spec.failedExpectations[0] || {};
var result = {
testName: spec.fullName,
testFramework: "jasmine2",
durationMilliseconds: elapsed(spec.__startTime, spec.__endTime),
outcome: getOutcome(spec),
ErrorMessage: firstFailedExpectation.message,
ErrorStackTrace: firstFailedExpectation.stack
};
return result;
}
|
[
"function",
"mapSpecToResult",
"(",
"spec",
")",
"{",
"var",
"firstFailedExpectation",
"=",
"spec",
".",
"failedExpectations",
"[",
"0",
"]",
"||",
"{",
"}",
";",
"var",
"result",
"=",
"{",
"testName",
":",
"spec",
".",
"fullName",
",",
"testFramework",
":",
"\"jasmine2\"",
",",
"durationMilliseconds",
":",
"elapsed",
"(",
"spec",
".",
"__startTime",
",",
"spec",
".",
"__endTime",
")",
",",
"outcome",
":",
"getOutcome",
"(",
"spec",
")",
",",
"ErrorMessage",
":",
"firstFailedExpectation",
".",
"message",
",",
"ErrorStackTrace",
":",
"firstFailedExpectation",
".",
"stack",
"}",
";",
"return",
"result",
";",
"}"
] |
map jasmine spec to AppVeyor test result
|
[
"map",
"jasmine",
"spec",
"to",
"AppVeyor",
"test",
"result"
] |
4487b61e0681ae81015795738c4c2ef138b2d3ba
|
https://github.com/larrymyers/jasmine-reporters/blob/4487b61e0681ae81015795738c4c2ef138b2d3ba/src/appveyor_reporter.js#L194-L208
|
19,707
|
larrymyers/jasmine-reporters
|
src/teamcity_reporter.js
|
tclog
|
function tclog(message, attrs) {
var str = "##teamcity[" + message;
if (typeof(attrs) === "object") {
if (!("timestamp" in attrs)) {
attrs.timestamp = new Date();
}
for (var prop in attrs) {
if (attrs.hasOwnProperty(prop)) {
if(delegates.modifySuiteName && message.indexOf("testSuite") === 0 && prop === "name") {
attrs[prop] = delegates.modifySuiteName(attrs[prop]);
}
str += " " + prop + "='" + escapeTeamCityString(attrs[prop]) + "'";
}
}
}
str += "]";
log(str);
}
|
javascript
|
function tclog(message, attrs) {
var str = "##teamcity[" + message;
if (typeof(attrs) === "object") {
if (!("timestamp" in attrs)) {
attrs.timestamp = new Date();
}
for (var prop in attrs) {
if (attrs.hasOwnProperty(prop)) {
if(delegates.modifySuiteName && message.indexOf("testSuite") === 0 && prop === "name") {
attrs[prop] = delegates.modifySuiteName(attrs[prop]);
}
str += " " + prop + "='" + escapeTeamCityString(attrs[prop]) + "'";
}
}
}
str += "]";
log(str);
}
|
[
"function",
"tclog",
"(",
"message",
",",
"attrs",
")",
"{",
"var",
"str",
"=",
"\"##teamcity[\"",
"+",
"message",
";",
"if",
"(",
"typeof",
"(",
"attrs",
")",
"===",
"\"object\"",
")",
"{",
"if",
"(",
"!",
"(",
"\"timestamp\"",
"in",
"attrs",
")",
")",
"{",
"attrs",
".",
"timestamp",
"=",
"new",
"Date",
"(",
")",
";",
"}",
"for",
"(",
"var",
"prop",
"in",
"attrs",
")",
"{",
"if",
"(",
"attrs",
".",
"hasOwnProperty",
"(",
"prop",
")",
")",
"{",
"if",
"(",
"delegates",
".",
"modifySuiteName",
"&&",
"message",
".",
"indexOf",
"(",
"\"testSuite\"",
")",
"===",
"0",
"&&",
"prop",
"===",
"\"name\"",
")",
"{",
"attrs",
"[",
"prop",
"]",
"=",
"delegates",
".",
"modifySuiteName",
"(",
"attrs",
"[",
"prop",
"]",
")",
";",
"}",
"str",
"+=",
"\" \"",
"+",
"prop",
"+",
"\"='\"",
"+",
"escapeTeamCityString",
"(",
"attrs",
"[",
"prop",
"]",
")",
"+",
"\"'\"",
";",
"}",
"}",
"}",
"str",
"+=",
"\"]\"",
";",
"log",
"(",
"str",
")",
";",
"}"
] |
shorthand for logging TeamCity messages defined here because it needs access to the `delegates` closure variable
|
[
"shorthand",
"for",
"logging",
"TeamCity",
"messages",
"defined",
"here",
"because",
"it",
"needs",
"access",
"to",
"the",
"delegates",
"closure",
"variable"
] |
4487b61e0681ae81015795738c4c2ef138b2d3ba
|
https://github.com/larrymyers/jasmine-reporters/blob/4487b61e0681ae81015795738c4c2ef138b2d3ba/src/teamcity_reporter.js#L150-L167
|
19,708
|
svgdotjs/svg.select.js
|
src/svg.select.js
|
function (value, options) {
// Check the parameters and reassign if needed
if (typeof value === 'object') {
options = value;
value = true;
}
var selectHandler = this.remember('_selectHandler') || new SelectHandler(this);
selectHandler.init(value === undefined ? true : value, options || {});
return this;
}
|
javascript
|
function (value, options) {
// Check the parameters and reassign if needed
if (typeof value === 'object') {
options = value;
value = true;
}
var selectHandler = this.remember('_selectHandler') || new SelectHandler(this);
selectHandler.init(value === undefined ? true : value, options || {});
return this;
}
|
[
"function",
"(",
"value",
",",
"options",
")",
"{",
"// Check the parameters and reassign if needed",
"if",
"(",
"typeof",
"value",
"===",
"'object'",
")",
"{",
"options",
"=",
"value",
";",
"value",
"=",
"true",
";",
"}",
"var",
"selectHandler",
"=",
"this",
".",
"remember",
"(",
"'_selectHandler'",
")",
"||",
"new",
"SelectHandler",
"(",
"this",
")",
";",
"selectHandler",
".",
"init",
"(",
"value",
"===",
"undefined",
"?",
"true",
":",
"value",
",",
"options",
"||",
"{",
"}",
")",
";",
"return",
"this",
";",
"}"
] |
Select element with mouse
|
[
"Select",
"element",
"with",
"mouse"
] |
28996aeea6de8bd86fb4eda2ef423121aaa6980a
|
https://github.com/svgdotjs/svg.select.js/blob/28996aeea6de8bd86fb4eda2ef423121aaa6980a/src/svg.select.js#L385-L399
|
|
19,709
|
jonschlinkert/en-route
|
lib/route.js
|
handle
|
function handle(route, file) {
route.status = 'starting';
route.emit('handle', file);
for (let layer of route.stack) {
route.emit('layer', layer, file);
layer.handle(file);
}
route.status = 'finished';
route.emit('handle', file);
return file;
}
|
javascript
|
function handle(route, file) {
route.status = 'starting';
route.emit('handle', file);
for (let layer of route.stack) {
route.emit('layer', layer, file);
layer.handle(file);
}
route.status = 'finished';
route.emit('handle', file);
return file;
}
|
[
"function",
"handle",
"(",
"route",
",",
"file",
")",
"{",
"route",
".",
"status",
"=",
"'starting'",
";",
"route",
".",
"emit",
"(",
"'handle'",
",",
"file",
")",
";",
"for",
"(",
"let",
"layer",
"of",
"route",
".",
"stack",
")",
"{",
"route",
".",
"emit",
"(",
"'layer'",
",",
"layer",
",",
"file",
")",
";",
"layer",
".",
"handle",
"(",
"file",
")",
";",
"}",
"route",
".",
"status",
"=",
"'finished'",
";",
"route",
".",
"emit",
"(",
"'handle'",
",",
"file",
")",
";",
"return",
"file",
";",
"}"
] |
Sync method, used when options.sync is true
|
[
"Sync",
"method",
"used",
"when",
"options",
".",
"sync",
"is",
"true"
] |
e556b051a68a79ea08bb15925a2bb32850a4d98a
|
https://github.com/jonschlinkert/en-route/blob/e556b051a68a79ea08bb15925a2bb32850a4d98a/lib/route.js#L144-L156
|
19,710
|
jonschlinkert/en-route
|
lib/to-regex.js
|
toRegexpSource
|
function toRegexpSource(val, keys, options) {
if (Array.isArray(val)) {
return arrayToRegexp(val, keys, options);
}
if (val instanceof RegExp) {
return regexpToRegexp(val, keys, options);
}
return stringToRegexp(val, keys, options);
}
|
javascript
|
function toRegexpSource(val, keys, options) {
if (Array.isArray(val)) {
return arrayToRegexp(val, keys, options);
}
if (val instanceof RegExp) {
return regexpToRegexp(val, keys, options);
}
return stringToRegexp(val, keys, options);
}
|
[
"function",
"toRegexpSource",
"(",
"val",
",",
"keys",
",",
"options",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"val",
")",
")",
"{",
"return",
"arrayToRegexp",
"(",
"val",
",",
"keys",
",",
"options",
")",
";",
"}",
"if",
"(",
"val",
"instanceof",
"RegExp",
")",
"{",
"return",
"regexpToRegexp",
"(",
"val",
",",
"keys",
",",
"options",
")",
";",
"}",
"return",
"stringToRegexp",
"(",
"val",
",",
"keys",
",",
"options",
")",
";",
"}"
] |
Create a regexp source string from the given value.
@param {string|array|regexp} val
@param {array} keys
@param {object} options
@return {regexp}
@api public
|
[
"Create",
"a",
"regexp",
"source",
"string",
"from",
"the",
"given",
"value",
"."
] |
e556b051a68a79ea08bb15925a2bb32850a4d98a
|
https://github.com/jonschlinkert/en-route/blob/e556b051a68a79ea08bb15925a2bb32850a4d98a/lib/to-regex.js#L34-L44
|
19,711
|
jonschlinkert/en-route
|
lib/to-regex.js
|
stringToRegexp
|
function stringToRegexp(str, keys, options = {}) {
let tokens = parse(str, options);
let end = options.end !== false;
let strict = options.strict;
let delimiter = options.delimiter ? escapeString(options.delimiter) : '\\/';
let delimiters = options.delimiters || './';
let endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|');
let isEndDelimited = false;
let route = '';
// Iterate over the tokens and create our regexp string.
for (let i = 0; i < tokens.length; i++) {
let token = tokens[i];
if (typeof token === 'string') {
route += escapeString(token);
isEndDelimited = i === tokens.length - 1 && delimiters.includes(token[token.length - 1]);
continue;
}
let prefix = escapeString(token.prefix);
let capture = token.repeat
? `(?:${token.pattern})(?:${prefix}(?:${token.pattern}))*`
: token.pattern;
if (keys) keys.push(token);
if (token.optional) {
if (token.partial) {
route += prefix + `(${capture})?`;
} else {
route += `(?:${prefix}(${capture}))?`;
}
} else {
route += `${prefix}(${capture})`;
}
}
if (end) {
if (!strict) route += `(?:${delimiter})?`;
route += endsWith === '$' ? '$' : `(?=${endsWith})`;
} else {
if (!strict) route += `(?:${delimiter}(?=${endsWith}))?`;
if (!isEndDelimited) route += `(?=${delimiter}|${endsWith})`;
}
return `^${route}`;
}
|
javascript
|
function stringToRegexp(str, keys, options = {}) {
let tokens = parse(str, options);
let end = options.end !== false;
let strict = options.strict;
let delimiter = options.delimiter ? escapeString(options.delimiter) : '\\/';
let delimiters = options.delimiters || './';
let endsWith = [].concat(options.endsWith || []).map(escapeString).concat('$').join('|');
let isEndDelimited = false;
let route = '';
// Iterate over the tokens and create our regexp string.
for (let i = 0; i < tokens.length; i++) {
let token = tokens[i];
if (typeof token === 'string') {
route += escapeString(token);
isEndDelimited = i === tokens.length - 1 && delimiters.includes(token[token.length - 1]);
continue;
}
let prefix = escapeString(token.prefix);
let capture = token.repeat
? `(?:${token.pattern})(?:${prefix}(?:${token.pattern}))*`
: token.pattern;
if (keys) keys.push(token);
if (token.optional) {
if (token.partial) {
route += prefix + `(${capture})?`;
} else {
route += `(?:${prefix}(${capture}))?`;
}
} else {
route += `${prefix}(${capture})`;
}
}
if (end) {
if (!strict) route += `(?:${delimiter})?`;
route += endsWith === '$' ? '$' : `(?=${endsWith})`;
} else {
if (!strict) route += `(?:${delimiter}(?=${endsWith}))?`;
if (!isEndDelimited) route += `(?=${delimiter}|${endsWith})`;
}
return `^${route}`;
}
|
[
"function",
"stringToRegexp",
"(",
"str",
",",
"keys",
",",
"options",
"=",
"{",
"}",
")",
"{",
"let",
"tokens",
"=",
"parse",
"(",
"str",
",",
"options",
")",
";",
"let",
"end",
"=",
"options",
".",
"end",
"!==",
"false",
";",
"let",
"strict",
"=",
"options",
".",
"strict",
";",
"let",
"delimiter",
"=",
"options",
".",
"delimiter",
"?",
"escapeString",
"(",
"options",
".",
"delimiter",
")",
":",
"'\\\\/'",
";",
"let",
"delimiters",
"=",
"options",
".",
"delimiters",
"||",
"'./'",
";",
"let",
"endsWith",
"=",
"[",
"]",
".",
"concat",
"(",
"options",
".",
"endsWith",
"||",
"[",
"]",
")",
".",
"map",
"(",
"escapeString",
")",
".",
"concat",
"(",
"'$'",
")",
".",
"join",
"(",
"'|'",
")",
";",
"let",
"isEndDelimited",
"=",
"false",
";",
"let",
"route",
"=",
"''",
";",
"// Iterate over the tokens and create our regexp string.",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"i",
"++",
")",
"{",
"let",
"token",
"=",
"tokens",
"[",
"i",
"]",
";",
"if",
"(",
"typeof",
"token",
"===",
"'string'",
")",
"{",
"route",
"+=",
"escapeString",
"(",
"token",
")",
";",
"isEndDelimited",
"=",
"i",
"===",
"tokens",
".",
"length",
"-",
"1",
"&&",
"delimiters",
".",
"includes",
"(",
"token",
"[",
"token",
".",
"length",
"-",
"1",
"]",
")",
";",
"continue",
";",
"}",
"let",
"prefix",
"=",
"escapeString",
"(",
"token",
".",
"prefix",
")",
";",
"let",
"capture",
"=",
"token",
".",
"repeat",
"?",
"`",
"${",
"token",
".",
"pattern",
"}",
"${",
"prefix",
"}",
"${",
"token",
".",
"pattern",
"}",
"`",
":",
"token",
".",
"pattern",
";",
"if",
"(",
"keys",
")",
"keys",
".",
"push",
"(",
"token",
")",
";",
"if",
"(",
"token",
".",
"optional",
")",
"{",
"if",
"(",
"token",
".",
"partial",
")",
"{",
"route",
"+=",
"prefix",
"+",
"`",
"${",
"capture",
"}",
"`",
";",
"}",
"else",
"{",
"route",
"+=",
"`",
"${",
"prefix",
"}",
"${",
"capture",
"}",
"`",
";",
"}",
"}",
"else",
"{",
"route",
"+=",
"`",
"${",
"prefix",
"}",
"${",
"capture",
"}",
"`",
";",
"}",
"}",
"if",
"(",
"end",
")",
"{",
"if",
"(",
"!",
"strict",
")",
"route",
"+=",
"`",
"${",
"delimiter",
"}",
"`",
";",
"route",
"+=",
"endsWith",
"===",
"'$'",
"?",
"'$'",
":",
"`",
"${",
"endsWith",
"}",
"`",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"strict",
")",
"route",
"+=",
"`",
"${",
"delimiter",
"}",
"${",
"endsWith",
"}",
"`",
";",
"if",
"(",
"!",
"isEndDelimited",
")",
"route",
"+=",
"`",
"${",
"delimiter",
"}",
"${",
"endsWith",
"}",
"`",
";",
"}",
"return",
"`",
"${",
"route",
"}",
"`",
";",
"}"
] |
Create a regular expression from the given string.
@param {string} str
@param {Array=} keys
@param {Object=} options
@return {!RegExp}
|
[
"Create",
"a",
"regular",
"expression",
"from",
"the",
"given",
"string",
"."
] |
e556b051a68a79ea08bb15925a2bb32850a4d98a
|
https://github.com/jonschlinkert/en-route/blob/e556b051a68a79ea08bb15925a2bb32850a4d98a/lib/to-regex.js#L55-L103
|
19,712
|
jonschlinkert/en-route
|
lib/to-regex.js
|
arrayToRegexp
|
function arrayToRegexp(arr, keys, options) {
let parts = [];
arr.forEach(ele => parts.push(toRegexpSource(ele, keys, options)));
return new RegExp(`(?:${parts.join('|')})`, flags(options));
}
|
javascript
|
function arrayToRegexp(arr, keys, options) {
let parts = [];
arr.forEach(ele => parts.push(toRegexpSource(ele, keys, options)));
return new RegExp(`(?:${parts.join('|')})`, flags(options));
}
|
[
"function",
"arrayToRegexp",
"(",
"arr",
",",
"keys",
",",
"options",
")",
"{",
"let",
"parts",
"=",
"[",
"]",
";",
"arr",
".",
"forEach",
"(",
"ele",
"=>",
"parts",
".",
"push",
"(",
"toRegexpSource",
"(",
"ele",
",",
"keys",
",",
"options",
")",
")",
")",
";",
"return",
"new",
"RegExp",
"(",
"`",
"${",
"parts",
".",
"join",
"(",
"'|'",
")",
"}",
"`",
",",
"flags",
"(",
"options",
")",
")",
";",
"}"
] |
Transform an array into a regular expression.
@param {!Array} arr
@param {Array=} keys
@param {Object=} options
@return {!RegExp}
|
[
"Transform",
"an",
"array",
"into",
"a",
"regular",
"expression",
"."
] |
e556b051a68a79ea08bb15925a2bb32850a4d98a
|
https://github.com/jonschlinkert/en-route/blob/e556b051a68a79ea08bb15925a2bb32850a4d98a/lib/to-regex.js#L114-L118
|
19,713
|
jonschlinkert/en-route
|
lib/to-regex.js
|
regexpToRegexp
|
function regexpToRegexp(regex, keys, options) {
if (!Array.isArray(keys)) return regex.source;
let groups = regex.source.match(/\((?!\?)/g);
if (!groups) return regex.source;
let i = 0;
let group = () => ({
name: i++,
prefix: null,
delimiter: null,
optional: false,
repeat: false,
partial: false,
pattern: null
});
groups.forEach(() => keys.push(group()));
return regex.source;
}
|
javascript
|
function regexpToRegexp(regex, keys, options) {
if (!Array.isArray(keys)) return regex.source;
let groups = regex.source.match(/\((?!\?)/g);
if (!groups) return regex.source;
let i = 0;
let group = () => ({
name: i++,
prefix: null,
delimiter: null,
optional: false,
repeat: false,
partial: false,
pattern: null
});
groups.forEach(() => keys.push(group()));
return regex.source;
}
|
[
"function",
"regexpToRegexp",
"(",
"regex",
",",
"keys",
",",
"options",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"keys",
")",
")",
"return",
"regex",
".",
"source",
";",
"let",
"groups",
"=",
"regex",
".",
"source",
".",
"match",
"(",
"/",
"\\((?!\\?)",
"/",
"g",
")",
";",
"if",
"(",
"!",
"groups",
")",
"return",
"regex",
".",
"source",
";",
"let",
"i",
"=",
"0",
";",
"let",
"group",
"=",
"(",
")",
"=>",
"(",
"{",
"name",
":",
"i",
"++",
",",
"prefix",
":",
"null",
",",
"delimiter",
":",
"null",
",",
"optional",
":",
"false",
",",
"repeat",
":",
"false",
",",
"partial",
":",
"false",
",",
"pattern",
":",
"null",
"}",
")",
";",
"groups",
".",
"forEach",
"(",
"(",
")",
"=>",
"keys",
".",
"push",
"(",
"group",
"(",
")",
")",
")",
";",
"return",
"regex",
".",
"source",
";",
"}"
] |
Create keys from match groups in the given regex
@param {!RegExp} path
@param {Array=} keys
@return {!RegExp}
|
[
"Create",
"keys",
"from",
"match",
"groups",
"in",
"the",
"given",
"regex"
] |
e556b051a68a79ea08bb15925a2bb32850a4d98a
|
https://github.com/jonschlinkert/en-route/blob/e556b051a68a79ea08bb15925a2bb32850a4d98a/lib/to-regex.js#L127-L146
|
19,714
|
jeromegn/Backbone.localStorage
|
src/driver.js
|
getSyncMethod
|
function getSyncMethod(model, options = {}) {
const forceAjaxSync = options.ajaxSync;
const hasLocalStorage = getLocalStorage(model);
return !forceAjaxSync && hasLocalStorage ? localSync : ajaxSync;
}
|
javascript
|
function getSyncMethod(model, options = {}) {
const forceAjaxSync = options.ajaxSync;
const hasLocalStorage = getLocalStorage(model);
return !forceAjaxSync && hasLocalStorage ? localSync : ajaxSync;
}
|
[
"function",
"getSyncMethod",
"(",
"model",
",",
"options",
"=",
"{",
"}",
")",
"{",
"const",
"forceAjaxSync",
"=",
"options",
".",
"ajaxSync",
";",
"const",
"hasLocalStorage",
"=",
"getLocalStorage",
"(",
"model",
")",
";",
"return",
"!",
"forceAjaxSync",
"&&",
"hasLocalStorage",
"?",
"localSync",
":",
"ajaxSync",
";",
"}"
] |
Get the local or ajax sync call
@param {Model} model - Model to sync
@param {object} options - Options to pass, takes ajaxSync
@returns {function} The sync method that will be called
|
[
"Get",
"the",
"local",
"or",
"ajax",
"sync",
"call"
] |
560df91a82630e491cc225cb2c7e68ec77ef697e
|
https://github.com/jeromegn/Backbone.localStorage/blob/560df91a82630e491cc225cb2c7e68ec77ef697e/src/driver.js#L16-L21
|
19,715
|
CartoDB/carto.js
|
src/geo/geocoder/mapbox-geocoder.js
|
_formatResponse
|
function _formatResponse (rawMapboxResponse) {
if (!rawMapboxResponse.features.length) {
return [];
}
return [{
boundingbox: _getBoundingBox(rawMapboxResponse.features[0]),
center: _getCenter(rawMapboxResponse.features[0]),
type: _getType(rawMapboxResponse.features[0])
}];
}
|
javascript
|
function _formatResponse (rawMapboxResponse) {
if (!rawMapboxResponse.features.length) {
return [];
}
return [{
boundingbox: _getBoundingBox(rawMapboxResponse.features[0]),
center: _getCenter(rawMapboxResponse.features[0]),
type: _getType(rawMapboxResponse.features[0])
}];
}
|
[
"function",
"_formatResponse",
"(",
"rawMapboxResponse",
")",
"{",
"if",
"(",
"!",
"rawMapboxResponse",
".",
"features",
".",
"length",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"[",
"{",
"boundingbox",
":",
"_getBoundingBox",
"(",
"rawMapboxResponse",
".",
"features",
"[",
"0",
"]",
")",
",",
"center",
":",
"_getCenter",
"(",
"rawMapboxResponse",
".",
"features",
"[",
"0",
"]",
")",
",",
"type",
":",
"_getType",
"(",
"rawMapboxResponse",
".",
"features",
"[",
"0",
"]",
")",
"}",
"]",
";",
"}"
] |
Transform a mapbox geocoder response on a object friendly with our search widget.
@param {object} rawMapboxResponse - The raw mapbox geocoding response, {@see https://www.mapbox.com/api-documentation/?language=JavaScript#response-object}
|
[
"Transform",
"a",
"mapbox",
"geocoder",
"response",
"on",
"a",
"object",
"friendly",
"with",
"our",
"search",
"widget",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/geo/geocoder/mapbox-geocoder.js#L38-L47
|
19,716
|
CartoDB/carto.js
|
src/api/v4/layer/layer.js
|
Layer
|
function Layer (source, style, options = {}) {
Base.apply(this, arguments);
_checkSource(source);
_checkStyle(style);
this._client = undefined;
this._engine = undefined;
this._internalModel = undefined;
this._source = source;
this._style = style;
this._visible = _.isBoolean(options.visible) ? options.visible : true;
this._featureClickColumns = options.featureClickColumns || [];
this._featureOverColumns = options.featureOverColumns || [];
this._minzoom = options.minzoom || 0;
this._maxzoom = options.maxzoom || undefined;
this._aggregation = options.aggregation || {};
_validateAggregationColumnsAndInteractivity(this._aggregation.columns, this._featureClickColumns, this._featureOverColumns);
}
|
javascript
|
function Layer (source, style, options = {}) {
Base.apply(this, arguments);
_checkSource(source);
_checkStyle(style);
this._client = undefined;
this._engine = undefined;
this._internalModel = undefined;
this._source = source;
this._style = style;
this._visible = _.isBoolean(options.visible) ? options.visible : true;
this._featureClickColumns = options.featureClickColumns || [];
this._featureOverColumns = options.featureOverColumns || [];
this._minzoom = options.minzoom || 0;
this._maxzoom = options.maxzoom || undefined;
this._aggregation = options.aggregation || {};
_validateAggregationColumnsAndInteractivity(this._aggregation.columns, this._featureClickColumns, this._featureOverColumns);
}
|
[
"function",
"Layer",
"(",
"source",
",",
"style",
",",
"options",
"=",
"{",
"}",
")",
"{",
"Base",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"_checkSource",
"(",
"source",
")",
";",
"_checkStyle",
"(",
"style",
")",
";",
"this",
".",
"_client",
"=",
"undefined",
";",
"this",
".",
"_engine",
"=",
"undefined",
";",
"this",
".",
"_internalModel",
"=",
"undefined",
";",
"this",
".",
"_source",
"=",
"source",
";",
"this",
".",
"_style",
"=",
"style",
";",
"this",
".",
"_visible",
"=",
"_",
".",
"isBoolean",
"(",
"options",
".",
"visible",
")",
"?",
"options",
".",
"visible",
":",
"true",
";",
"this",
".",
"_featureClickColumns",
"=",
"options",
".",
"featureClickColumns",
"||",
"[",
"]",
";",
"this",
".",
"_featureOverColumns",
"=",
"options",
".",
"featureOverColumns",
"||",
"[",
"]",
";",
"this",
".",
"_minzoom",
"=",
"options",
".",
"minzoom",
"||",
"0",
";",
"this",
".",
"_maxzoom",
"=",
"options",
".",
"maxzoom",
"||",
"undefined",
";",
"this",
".",
"_aggregation",
"=",
"options",
".",
"aggregation",
"||",
"{",
"}",
";",
"_validateAggregationColumnsAndInteractivity",
"(",
"this",
".",
"_aggregation",
".",
"columns",
",",
"this",
".",
"_featureClickColumns",
",",
"this",
".",
"_featureOverColumns",
")",
";",
"}"
] |
Represents a layer Object.
A layer is the primary way to visualize geospatial data.
To create a layer a {@link carto.source.Base|source} and {@link carto.style.Base|styles}
are required:
- The {@link carto.source.Base|source} is used to know **what** data will be displayed in the Layer.
- The {@link carto.style.Base|style} is used to know **how** to draw the data in the Layer.
A layer alone won't do too much. In order to get data from the CARTO server you must add the Layer to a {@link carto.Client|client}.
```
// Create a layer. Remember this won't do anything unless the layer is added to a client.
const layer = new carto.layer.Layer(source, style);
```
@param {carto.source.Base} source - The source where the layer will fetch the data
@param {carto.style.CartoCSS} style - A CartoCSS object with the layer styling
@param {object} [options]
@param {Array<string>} [options.featureClickColumns=[]] - Columns that will be available for `featureClick` events
@param {boolean} [options.visible=true] - A boolean value indicating the layer's visibility
@param {Array<string>} [options.featureOverColumns=[]] - Columns that will be available for `featureOver` events
@param {carto.layer.Aggregation} [options.aggregation={}] - Specify {@link carto.layer.Aggregation|aggregation } options
@param {string} [options.id] - An unique identifier for the layer
@fires metadataChanged
@fires featureClicked
@fires featureOut
@fires featureOver
@fires error
@example
const citiesSource = new carto.source.SQL('SELECT * FROM cities');
const citiesStyle = new carto.style.CartoCSS(`
#layer {
marker-fill: #FABADA;
marker-width: 10;
}
`);
// Create a layer with no options
new carto.layer.Layer(citiesSource, citiesStyle);
@example
const citiesSource = new carto.source.SQL('SELECT * FROM cities');
const citiesStyle = new carto.style.CartoCSS(`
#layer {
marker-fill: #FABADA;
marker-width: 10;
}
`);
// Create a layer indicating what columns will be included in the featureOver event.
new carto.layer.Layer(citiesSource, citiesStyle, {
featureOverColumns: [ 'name' ]
});
@example
const citiesSource = new carto.source.SQL('SELECT * FROM cities');
const citiesStyle = new carto.style.CartoCSS(`
#layer {
marker-fill: #FABADA;
marker-width: 10;
}
`);
// Create a hidden layer
new carto.layer.Layer(citiesSource, citiesStyle, { visible: false });
@example
// Listen to the event thrown when the mouse is over a feature
layer.on('featureOver', featureEvent => {
console.log(`Mouse over city with name: ${featureEvent.data.name}`);
});
@constructor
@extends carto.layer.Base
@memberof carto.layer
@api
|
[
"Represents",
"a",
"layer",
"Object",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/layer/layer.js#L84-L104
|
19,717
|
CartoDB/carto.js
|
src/api/v4/layer/layer.js
|
_getInteractivityFields
|
function _getInteractivityFields (columns) {
var fields = columns.map(function (column, index) {
return {
name: column,
title: true,
position: index
};
});
return {
fields: fields
};
}
|
javascript
|
function _getInteractivityFields (columns) {
var fields = columns.map(function (column, index) {
return {
name: column,
title: true,
position: index
};
});
return {
fields: fields
};
}
|
[
"function",
"_getInteractivityFields",
"(",
"columns",
")",
"{",
"var",
"fields",
"=",
"columns",
".",
"map",
"(",
"function",
"(",
"column",
",",
"index",
")",
"{",
"return",
"{",
"name",
":",
"column",
",",
"title",
":",
"true",
",",
"position",
":",
"index",
"}",
";",
"}",
")",
";",
"return",
"{",
"fields",
":",
"fields",
"}",
";",
"}"
] |
Scope functions
Transform the columns array into the format expected by the CartoDBLayer.
|
[
"Scope",
"functions",
"Transform",
"the",
"columns",
"array",
"into",
"the",
"format",
"expected",
"by",
"the",
"CartoDBLayer",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/layer/layer.js#L474-L486
|
19,718
|
CartoDB/carto.js
|
src/api/v4/layer/layer.js
|
_validateAggregationColumnsAndInteractivity
|
function _validateAggregationColumnsAndInteractivity (aggregationColumns, clickColumns, overColumns) {
var aggColumns = (aggregationColumns && Object.keys(aggregationColumns)) || [];
_validateColumnsConcordance(aggColumns, clickColumns, 'featureClick');
_validateColumnsConcordance(aggColumns, overColumns, 'featureOver');
}
|
javascript
|
function _validateAggregationColumnsAndInteractivity (aggregationColumns, clickColumns, overColumns) {
var aggColumns = (aggregationColumns && Object.keys(aggregationColumns)) || [];
_validateColumnsConcordance(aggColumns, clickColumns, 'featureClick');
_validateColumnsConcordance(aggColumns, overColumns, 'featureOver');
}
|
[
"function",
"_validateAggregationColumnsAndInteractivity",
"(",
"aggregationColumns",
",",
"clickColumns",
",",
"overColumns",
")",
"{",
"var",
"aggColumns",
"=",
"(",
"aggregationColumns",
"&&",
"Object",
".",
"keys",
"(",
"aggregationColumns",
")",
")",
"||",
"[",
"]",
";",
"_validateColumnsConcordance",
"(",
"aggColumns",
",",
"clickColumns",
",",
"'featureClick'",
")",
";",
"_validateColumnsConcordance",
"(",
"aggColumns",
",",
"overColumns",
",",
"'featureOver'",
")",
";",
"}"
] |
When there are aggregated columns and interactivity columns they must agree
|
[
"When",
"there",
"are",
"aggregated",
"columns",
"and",
"interactivity",
"columns",
"they",
"must",
"agree"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/layer/layer.js#L526-L531
|
19,719
|
CartoDB/carto.js
|
src/api/v4/dataview/category/parse-data.js
|
parseCategoryData
|
function parseCategoryData (data, count, max, min, nulls, operation) {
if (!data) {
return null;
}
/**
* @typedef {object} carto.dataview.CategoryData
* @property {number} count - The total number of categories
* @property {number} max - Maximum category value
* @property {number} min - Minimum category value
* @property {number} nulls - Number of null categories
* @property {string} operation - Operation used
* @property {carto.dataview.CategoryItem[]} categories
* @api
*/
return {
count: count,
max: max,
min: min,
nulls: nulls,
operation: operation,
categories: _createCategories(data)
};
}
|
javascript
|
function parseCategoryData (data, count, max, min, nulls, operation) {
if (!data) {
return null;
}
/**
* @typedef {object} carto.dataview.CategoryData
* @property {number} count - The total number of categories
* @property {number} max - Maximum category value
* @property {number} min - Minimum category value
* @property {number} nulls - Number of null categories
* @property {string} operation - Operation used
* @property {carto.dataview.CategoryItem[]} categories
* @api
*/
return {
count: count,
max: max,
min: min,
nulls: nulls,
operation: operation,
categories: _createCategories(data)
};
}
|
[
"function",
"parseCategoryData",
"(",
"data",
",",
"count",
",",
"max",
",",
"min",
",",
"nulls",
",",
"operation",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"return",
"null",
";",
"}",
"/**\n * @typedef {object} carto.dataview.CategoryData\n * @property {number} count - The total number of categories\n * @property {number} max - Maximum category value\n * @property {number} min - Minimum category value\n * @property {number} nulls - Number of null categories\n * @property {string} operation - Operation used\n * @property {carto.dataview.CategoryItem[]} categories\n * @api\n */",
"return",
"{",
"count",
":",
"count",
",",
"max",
":",
"max",
",",
"min",
":",
"min",
",",
"nulls",
":",
"nulls",
",",
"operation",
":",
"operation",
",",
"categories",
":",
"_createCategories",
"(",
"data",
")",
"}",
";",
"}"
] |
Transform the data obtained from an internal category dataview into a
public object.
@param {object[]} data
@param {number} count
@param {number} max
@param {number} min
@param {number} nulls
@param {string} operation
@return {carto.dataview.CategoryData} - The parsed and formatted data for the given parameters
|
[
"Transform",
"the",
"data",
"obtained",
"from",
"an",
"internal",
"category",
"dataview",
"into",
"a",
"public",
"object",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/dataview/category/parse-data.js#L16-L38
|
19,720
|
CartoDB/carto.js
|
src/api/v4/client.js
|
Client
|
function Client (settings) {
settings.serverUrl = (settings.serverUrl || DEFAULT_SERVER_URL).replace(/{username}/, settings.username || '');
_checkSettings(settings);
this._layers = new Layers();
this._dataviews = [];
this._engine = new Engine({
apiKey: settings.apiKey,
username: settings.username,
serverUrl: settings.serverUrl,
client: 'js-' + VERSION
});
this._bindEngine(this._engine);
}
|
javascript
|
function Client (settings) {
settings.serverUrl = (settings.serverUrl || DEFAULT_SERVER_URL).replace(/{username}/, settings.username || '');
_checkSettings(settings);
this._layers = new Layers();
this._dataviews = [];
this._engine = new Engine({
apiKey: settings.apiKey,
username: settings.username,
serverUrl: settings.serverUrl,
client: 'js-' + VERSION
});
this._bindEngine(this._engine);
}
|
[
"function",
"Client",
"(",
"settings",
")",
"{",
"settings",
".",
"serverUrl",
"=",
"(",
"settings",
".",
"serverUrl",
"||",
"DEFAULT_SERVER_URL",
")",
".",
"replace",
"(",
"/",
"{username}",
"/",
",",
"settings",
".",
"username",
"||",
"''",
")",
";",
"_checkSettings",
"(",
"settings",
")",
";",
"this",
".",
"_layers",
"=",
"new",
"Layers",
"(",
")",
";",
"this",
".",
"_dataviews",
"=",
"[",
"]",
";",
"this",
".",
"_engine",
"=",
"new",
"Engine",
"(",
"{",
"apiKey",
":",
"settings",
".",
"apiKey",
",",
"username",
":",
"settings",
".",
"username",
",",
"serverUrl",
":",
"settings",
".",
"serverUrl",
",",
"client",
":",
"'js-'",
"+",
"VERSION",
"}",
")",
";",
"this",
".",
"_bindEngine",
"(",
"this",
".",
"_engine",
")",
";",
"}"
] |
This is the entry point for a CARTO.js application.
A CARTO client allows managing layers and dataviews. Some operations like addding a layer or a dataview are asynchronous.
The client takes care of the communication between CARTO.js and the server for you.
To create a new client you need a CARTO account, where you will be able to get
your API key and username.
If you want to learn more about authorization and authentication, please read the authorization fundamentals section of our Developer Center.
@param {object} settings
@param {string} settings.apiKey - API key used to authenticate against CARTO
@param {string} settings.username - Name of the user
@param {string} [settings.serverUrl='https://{username}.carto.com'] - URL of the windshaft server. Only needed in custom installations. Pattern: `http(s)://{username}.your.carto.instance` or `http(s)://your.carto.instance/user/{username}` (only for On-Premises environments).
@example
var client = new carto.Client({
apiKey: 'YOUR_API_KEY_HERE',
username: 'YOUR_USERNAME_HERE'
});
var client = new carto.Client({
apiKey: 'YOUR_API_KEY_HERE',
username: 'YOUR_USERNAME_HERE',
serverUrl: 'http://{username}.your.carto.instance'
});
@constructor
@memberof carto
@api
@fires error
@fires success
|
[
"This",
"is",
"the",
"entry",
"point",
"for",
"a",
"CARTO",
".",
"js",
"application",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/client.js#L53-L65
|
19,721
|
CartoDB/carto.js
|
src/vis/tooltip-manager.js
|
function (deps) {
if (!deps.mapModel) throw new Error('mapModel is required');
if (!deps.tooltipModel) throw new Error('tooltipModel is required');
if (!deps.infowindowModel) throw new Error('infowindowModel is required');
this._mapModel = deps.mapModel;
this._tooltipModel = deps.tooltipModel;
this._infowindowModel = deps.infowindowModel;
this._layersBeingFeaturedOvered = {};
}
|
javascript
|
function (deps) {
if (!deps.mapModel) throw new Error('mapModel is required');
if (!deps.tooltipModel) throw new Error('tooltipModel is required');
if (!deps.infowindowModel) throw new Error('infowindowModel is required');
this._mapModel = deps.mapModel;
this._tooltipModel = deps.tooltipModel;
this._infowindowModel = deps.infowindowModel;
this._layersBeingFeaturedOvered = {};
}
|
[
"function",
"(",
"deps",
")",
"{",
"if",
"(",
"!",
"deps",
".",
"mapModel",
")",
"throw",
"new",
"Error",
"(",
"'mapModel is required'",
")",
";",
"if",
"(",
"!",
"deps",
".",
"tooltipModel",
")",
"throw",
"new",
"Error",
"(",
"'tooltipModel is required'",
")",
";",
"if",
"(",
"!",
"deps",
".",
"infowindowModel",
")",
"throw",
"new",
"Error",
"(",
"'infowindowModel is required'",
")",
";",
"this",
".",
"_mapModel",
"=",
"deps",
".",
"mapModel",
";",
"this",
".",
"_tooltipModel",
"=",
"deps",
".",
"tooltipModel",
";",
"this",
".",
"_infowindowModel",
"=",
"deps",
".",
"infowindowModel",
";",
"this",
".",
"_layersBeingFeaturedOvered",
"=",
"{",
"}",
";",
"}"
] |
Manages the tooltips for a map. It listens to events triggered by a
CartoDBLayerGroupView and updates models accordingly
|
[
"Manages",
"the",
"tooltips",
"for",
"a",
"map",
".",
"It",
"listens",
"to",
"events",
"triggered",
"by",
"a",
"CartoDBLayerGroupView",
"and",
"updates",
"models",
"accordingly"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/vis/tooltip-manager.js#L7-L17
|
|
19,722
|
CartoDB/carto.js
|
src/api/v4/layer/metadata/categories.js
|
Categories
|
function Categories (rule) {
var categoryBuckets = rule.getBucketsWithCategoryFilter();
var defaultBuckets = rule.getBucketsWithDefaultFilter();
/**
* @typedef {object} carto.layer.metadata.Category
* @property {number|string} name - The name of the category
* @property {string} value - The value of the category
* @api
*/
this._categories = categoryBuckets.map(function (bucket) {
return {
name: bucket.filter.name,
value: bucket.value
};
});
this._defaultValue = defaultBuckets.length > 0 ? defaultBuckets[0].value : undefined;
Base.call(this, 'categories', rule);
}
|
javascript
|
function Categories (rule) {
var categoryBuckets = rule.getBucketsWithCategoryFilter();
var defaultBuckets = rule.getBucketsWithDefaultFilter();
/**
* @typedef {object} carto.layer.metadata.Category
* @property {number|string} name - The name of the category
* @property {string} value - The value of the category
* @api
*/
this._categories = categoryBuckets.map(function (bucket) {
return {
name: bucket.filter.name,
value: bucket.value
};
});
this._defaultValue = defaultBuckets.length > 0 ? defaultBuckets[0].value : undefined;
Base.call(this, 'categories', rule);
}
|
[
"function",
"Categories",
"(",
"rule",
")",
"{",
"var",
"categoryBuckets",
"=",
"rule",
".",
"getBucketsWithCategoryFilter",
"(",
")",
";",
"var",
"defaultBuckets",
"=",
"rule",
".",
"getBucketsWithDefaultFilter",
"(",
")",
";",
"/**\n * @typedef {object} carto.layer.metadata.Category\n * @property {number|string} name - The name of the category\n * @property {string} value - The value of the category\n * @api\n */",
"this",
".",
"_categories",
"=",
"categoryBuckets",
".",
"map",
"(",
"function",
"(",
"bucket",
")",
"{",
"return",
"{",
"name",
":",
"bucket",
".",
"filter",
".",
"name",
",",
"value",
":",
"bucket",
".",
"value",
"}",
";",
"}",
")",
";",
"this",
".",
"_defaultValue",
"=",
"defaultBuckets",
".",
"length",
">",
"0",
"?",
"defaultBuckets",
"[",
"0",
"]",
".",
"value",
":",
"undefined",
";",
"Base",
".",
"call",
"(",
"this",
",",
"'categories'",
",",
"rule",
")",
";",
"}"
] |
Metadata type categories
Adding a Turbocarto ramp (with categories) in the style generates a response
from the server with the resulting information after computing the ramp.
This information is wrapped in a metadata object of type 'categories', that
contains a list of categories with the name of the category and the value. And
also the default value if it has been defined in the ramp.
For example, the following ramp will generate a metadata of type 'categories'
with string values (the color) in its categories. The #CCCCCC is the default
value in this case:
marker-fill: ramp([scalerank], (#F54690, #D16996, #CCCCCC), (1, 2), "=", category);
@param {object} rule - Rule with the cartocss metadata
@constructor
@hideconstructor
@extends carto.layer.metadata.Base
@memberof carto.layer.metadata
@api
|
[
"Metadata",
"type",
"categories"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/layer/metadata/categories.js#L25-L44
|
19,723
|
CartoDB/carto.js
|
src/windshaft/response.js
|
Response
|
function Response (windshaftSettings, serverResponse) {
this._windshaftSettings = windshaftSettings;
this._layerGroupId = serverResponse.layergroupid;
this._layers = serverResponse.metadata.layers;
this._dataviews = serverResponse.metadata.dataviews;
this._analyses = serverResponse.metadata.analyses;
this._cdnUrl = serverResponse.cdn_url;
}
|
javascript
|
function Response (windshaftSettings, serverResponse) {
this._windshaftSettings = windshaftSettings;
this._layerGroupId = serverResponse.layergroupid;
this._layers = serverResponse.metadata.layers;
this._dataviews = serverResponse.metadata.dataviews;
this._analyses = serverResponse.metadata.analyses;
this._cdnUrl = serverResponse.cdn_url;
}
|
[
"function",
"Response",
"(",
"windshaftSettings",
",",
"serverResponse",
")",
"{",
"this",
".",
"_windshaftSettings",
"=",
"windshaftSettings",
";",
"this",
".",
"_layerGroupId",
"=",
"serverResponse",
".",
"layergroupid",
";",
"this",
".",
"_layers",
"=",
"serverResponse",
".",
"metadata",
".",
"layers",
";",
"this",
".",
"_dataviews",
"=",
"serverResponse",
".",
"metadata",
".",
"dataviews",
";",
"this",
".",
"_analyses",
"=",
"serverResponse",
".",
"metadata",
".",
"analyses",
";",
"this",
".",
"_cdnUrl",
"=",
"serverResponse",
".",
"cdn_url",
";",
"}"
] |
Wrapper over a server response to a map instantiation giving some utility methods.
@constructor
@param {object} windshaftSettings - Object containing the request options.
@param {string} serverResponse - The json string representing a windshaft response to a map instantiation.
|
[
"Wrapper",
"over",
"a",
"server",
"response",
"to",
"a",
"map",
"instantiation",
"giving",
"some",
"utility",
"methods",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/windshaft/response.js#L10-L17
|
19,724
|
CartoDB/carto.js
|
src/geo/geocoder/tomtom-geocoder.js
|
_formatResponse
|
function _formatResponse (rawTomTomResponse) {
if (!rawTomTomResponse.results.length) {
return [];
}
const bestCandidate = rawTomTomResponse.results[0];
return [{
boundingbox: _getBoundingBox(bestCandidate),
center: _getCenter(bestCandidate),
type: _getType(bestCandidate)
}];
}
|
javascript
|
function _formatResponse (rawTomTomResponse) {
if (!rawTomTomResponse.results.length) {
return [];
}
const bestCandidate = rawTomTomResponse.results[0];
return [{
boundingbox: _getBoundingBox(bestCandidate),
center: _getCenter(bestCandidate),
type: _getType(bestCandidate)
}];
}
|
[
"function",
"_formatResponse",
"(",
"rawTomTomResponse",
")",
"{",
"if",
"(",
"!",
"rawTomTomResponse",
".",
"results",
".",
"length",
")",
"{",
"return",
"[",
"]",
";",
"}",
"const",
"bestCandidate",
"=",
"rawTomTomResponse",
".",
"results",
"[",
"0",
"]",
";",
"return",
"[",
"{",
"boundingbox",
":",
"_getBoundingBox",
"(",
"bestCandidate",
")",
",",
"center",
":",
"_getCenter",
"(",
"bestCandidate",
")",
",",
"type",
":",
"_getType",
"(",
"bestCandidate",
")",
"}",
"]",
";",
"}"
] |
Transform a tomtom geocoder response into an object more friendly for our search widget.
@param {object} rawTomTomResponse - The raw tomtom geocoding response, {@see https://developer.tomtom.com/search-api/search-api-documentation-geocoding/geocode}
|
[
"Transform",
"a",
"tomtom",
"geocoder",
"response",
"into",
"an",
"object",
"more",
"friendly",
"for",
"our",
"search",
"widget",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/geo/geocoder/tomtom-geocoder.js#L42-L53
|
19,725
|
CartoDB/carto.js
|
src/geo/geocoder/tomtom-geocoder.js
|
_getType
|
function _getType (result) {
let type = result.type;
if (TYPES[type]) {
if (type === 'Geography' && result.entityType) {
type = type + ':' + result.entityType;
}
return TYPES[type];
}
return 'default';
}
|
javascript
|
function _getType (result) {
let type = result.type;
if (TYPES[type]) {
if (type === 'Geography' && result.entityType) {
type = type + ':' + result.entityType;
}
return TYPES[type];
}
return 'default';
}
|
[
"function",
"_getType",
"(",
"result",
")",
"{",
"let",
"type",
"=",
"result",
".",
"type",
";",
"if",
"(",
"TYPES",
"[",
"type",
"]",
")",
"{",
"if",
"(",
"type",
"===",
"'Geography'",
"&&",
"result",
".",
"entityType",
")",
"{",
"type",
"=",
"type",
"+",
"':'",
"+",
"result",
".",
"entityType",
";",
"}",
"return",
"TYPES",
"[",
"type",
"]",
";",
"}",
"return",
"'default'",
";",
"}"
] |
Transform the feature type into a well known enum.
|
[
"Transform",
"the",
"feature",
"type",
"into",
"a",
"well",
"known",
"enum",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/geo/geocoder/tomtom-geocoder.js#L65-L75
|
19,726
|
CartoDB/carto.js
|
src/api/v4/layer/base.js
|
Base
|
function Base (source, layer, options) {
options = options || {};
this._id = options.id || Base.$generateId();
}
|
javascript
|
function Base (source, layer, options) {
options = options || {};
this._id = options.id || Base.$generateId();
}
|
[
"function",
"Base",
"(",
"source",
",",
"layer",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"_id",
"=",
"options",
".",
"id",
"||",
"Base",
".",
"$generateId",
"(",
")",
";",
"}"
] |
Base layer object.
This object should not be used directly! use {@link carto.layer.Layer} instead.
@constructor
@abstract
@fires error
@memberof carto.layer
@api
|
[
"Base",
"layer",
"object",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/layer/base.js#L15-L18
|
19,727
|
CartoDB/carto.js
|
src/api/v4/dataview/histogram/parse-data.js
|
parseHistogramData
|
function parseHistogramData (data, nulls, totalAmount) {
if (!data) {
return null;
}
var compactData = _.compact(data);
var maxBin = _.max(compactData, function (bin) { return bin.freq || 0; });
var maxFreq = _.isFinite(maxBin.freq) && maxBin.freq !== 0
? maxBin.freq
: null;
/**
* @description
* Object containing histogram data.
*
* @typedef {object} carto.dataview.HistogramData
* @property {number} nulls - The number of items with null value
* @property {number} totalAmount - The number of elements returned
* @property {carto.dataview.BinItem[]} bins - Array containing the {@link carto.dataview.BinItem|data bins} for the histogram
* @property {string} type - String with value: **histogram**
* @api
*/
return {
bins: _createBins(compactData, maxFreq),
nulls: nulls || 0,
totalAmount: totalAmount
};
}
|
javascript
|
function parseHistogramData (data, nulls, totalAmount) {
if (!data) {
return null;
}
var compactData = _.compact(data);
var maxBin = _.max(compactData, function (bin) { return bin.freq || 0; });
var maxFreq = _.isFinite(maxBin.freq) && maxBin.freq !== 0
? maxBin.freq
: null;
/**
* @description
* Object containing histogram data.
*
* @typedef {object} carto.dataview.HistogramData
* @property {number} nulls - The number of items with null value
* @property {number} totalAmount - The number of elements returned
* @property {carto.dataview.BinItem[]} bins - Array containing the {@link carto.dataview.BinItem|data bins} for the histogram
* @property {string} type - String with value: **histogram**
* @api
*/
return {
bins: _createBins(compactData, maxFreq),
nulls: nulls || 0,
totalAmount: totalAmount
};
}
|
[
"function",
"parseHistogramData",
"(",
"data",
",",
"nulls",
",",
"totalAmount",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"return",
"null",
";",
"}",
"var",
"compactData",
"=",
"_",
".",
"compact",
"(",
"data",
")",
";",
"var",
"maxBin",
"=",
"_",
".",
"max",
"(",
"compactData",
",",
"function",
"(",
"bin",
")",
"{",
"return",
"bin",
".",
"freq",
"||",
"0",
";",
"}",
")",
";",
"var",
"maxFreq",
"=",
"_",
".",
"isFinite",
"(",
"maxBin",
".",
"freq",
")",
"&&",
"maxBin",
".",
"freq",
"!==",
"0",
"?",
"maxBin",
".",
"freq",
":",
"null",
";",
"/**\n * @description\n * Object containing histogram data.\n *\n * @typedef {object} carto.dataview.HistogramData\n * @property {number} nulls - The number of items with null value\n * @property {number} totalAmount - The number of elements returned\n * @property {carto.dataview.BinItem[]} bins - Array containing the {@link carto.dataview.BinItem|data bins} for the histogram\n * @property {string} type - String with value: **histogram**\n * @api\n */",
"return",
"{",
"bins",
":",
"_createBins",
"(",
"compactData",
",",
"maxFreq",
")",
",",
"nulls",
":",
"nulls",
"||",
"0",
",",
"totalAmount",
":",
"totalAmount",
"}",
";",
"}"
] |
Transform the data obtained from an internal histogram dataview into a
public object.
@param {object[]} data - The raw histogram data
@param {number} nulls - Number of data with a null
@param {number} totalAmount - Total number of data in the histogram
@return {carto.dataview.HistogramData} - The parsed and formatted data for the given parameters
|
[
"Transform",
"the",
"data",
"obtained",
"from",
"an",
"internal",
"histogram",
"dataview",
"into",
"a",
"public",
"object",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/dataview/histogram/parse-data.js#L13-L39
|
19,728
|
CartoDB/carto.js
|
src/api/v4/layer/metadata/base.js
|
Base
|
function Base (type, rule) {
this._type = type || '';
this._column = rule.getColumn();
this._mapping = rule.getMapping();
this._property = rule.getProperty();
}
|
javascript
|
function Base (type, rule) {
this._type = type || '';
this._column = rule.getColumn();
this._mapping = rule.getMapping();
this._property = rule.getProperty();
}
|
[
"function",
"Base",
"(",
"type",
",",
"rule",
")",
"{",
"this",
".",
"_type",
"=",
"type",
"||",
"''",
";",
"this",
".",
"_column",
"=",
"rule",
".",
"getColumn",
"(",
")",
";",
"this",
".",
"_mapping",
"=",
"rule",
".",
"getMapping",
"(",
")",
";",
"this",
".",
"_property",
"=",
"rule",
".",
"getProperty",
"(",
")",
";",
"}"
] |
Base metadata object
@constructor
@abstract
@memberof carto.layer.metadata
@api
|
[
"Base",
"metadata",
"object"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/layer/metadata/base.js#L9-L14
|
19,729
|
CartoDB/carto.js
|
src/windshaft/map-serializer/anonymous-map-serializer/analysis-serializer.js
|
serialize
|
function serialize (layersCollection, dataviewsCollection) {
var analysisList = AnalysisService.getAnalysisList(layersCollection, dataviewsCollection);
return _generateUniqueAnalysisList(analysisList);
}
|
javascript
|
function serialize (layersCollection, dataviewsCollection) {
var analysisList = AnalysisService.getAnalysisList(layersCollection, dataviewsCollection);
return _generateUniqueAnalysisList(analysisList);
}
|
[
"function",
"serialize",
"(",
"layersCollection",
",",
"dataviewsCollection",
")",
"{",
"var",
"analysisList",
"=",
"AnalysisService",
".",
"getAnalysisList",
"(",
"layersCollection",
",",
"dataviewsCollection",
")",
";",
"return",
"_generateUniqueAnalysisList",
"(",
"analysisList",
")",
";",
"}"
] |
Return a payload with the serialization of all the analyses in the
layersCollection and the dataviewsCollection.
|
[
"Return",
"a",
"payload",
"with",
"the",
"serialization",
"of",
"all",
"the",
"analyses",
"in",
"the",
"layersCollection",
"and",
"the",
"dataviewsCollection",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/windshaft/map-serializer/anonymous-map-serializer/analysis-serializer.js#L8-L11
|
19,730
|
CartoDB/carto.js
|
src/windshaft/map-serializer/anonymous-map-serializer/analysis-serializer.js
|
_generateUniqueAnalysisList
|
function _generateUniqueAnalysisList (analysisList) {
var analysisIds = {};
return _.reduce(analysisList, function (list, analysis) {
if (!analysisIds[analysis.get('id')] && !_isAnalysisPartOfOtherAnalyses(analysis, analysisList)) {
analysisIds[analysis.get('id')] = true; // keep a set of already added analysis.
list.push(analysis.toJSON());
}
return list;
}, []);
}
|
javascript
|
function _generateUniqueAnalysisList (analysisList) {
var analysisIds = {};
return _.reduce(analysisList, function (list, analysis) {
if (!analysisIds[analysis.get('id')] && !_isAnalysisPartOfOtherAnalyses(analysis, analysisList)) {
analysisIds[analysis.get('id')] = true; // keep a set of already added analysis.
list.push(analysis.toJSON());
}
return list;
}, []);
}
|
[
"function",
"_generateUniqueAnalysisList",
"(",
"analysisList",
")",
"{",
"var",
"analysisIds",
"=",
"{",
"}",
";",
"return",
"_",
".",
"reduce",
"(",
"analysisList",
",",
"function",
"(",
"list",
",",
"analysis",
")",
"{",
"if",
"(",
"!",
"analysisIds",
"[",
"analysis",
".",
"get",
"(",
"'id'",
")",
"]",
"&&",
"!",
"_isAnalysisPartOfOtherAnalyses",
"(",
"analysis",
",",
"analysisList",
")",
")",
"{",
"analysisIds",
"[",
"analysis",
".",
"get",
"(",
"'id'",
")",
"]",
"=",
"true",
";",
"// keep a set of already added analysis.",
"list",
".",
"push",
"(",
"analysis",
".",
"toJSON",
"(",
")",
")",
";",
"}",
"return",
"list",
";",
"}",
",",
"[",
"]",
")",
";",
"}"
] |
Return an analysis list without duplicated or nested analyses
|
[
"Return",
"an",
"analysis",
"list",
"without",
"duplicated",
"or",
"nested",
"analyses"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/windshaft/map-serializer/anonymous-map-serializer/analysis-serializer.js#L16-L25
|
19,731
|
CartoDB/carto.js
|
src/windshaft/map-serializer/anonymous-map-serializer/analysis-serializer.js
|
_isAnalysisPartOfOtherAnalyses
|
function _isAnalysisPartOfOtherAnalyses (analysis, analysisList) {
return _.any(analysisList, function (otherAnalysisModel) {
if (!analysis.equals(otherAnalysisModel)) {
return otherAnalysisModel.findAnalysisById(analysis.get('id'));
}
return false;
});
}
|
javascript
|
function _isAnalysisPartOfOtherAnalyses (analysis, analysisList) {
return _.any(analysisList, function (otherAnalysisModel) {
if (!analysis.equals(otherAnalysisModel)) {
return otherAnalysisModel.findAnalysisById(analysis.get('id'));
}
return false;
});
}
|
[
"function",
"_isAnalysisPartOfOtherAnalyses",
"(",
"analysis",
",",
"analysisList",
")",
"{",
"return",
"_",
".",
"any",
"(",
"analysisList",
",",
"function",
"(",
"otherAnalysisModel",
")",
"{",
"if",
"(",
"!",
"analysis",
".",
"equals",
"(",
"otherAnalysisModel",
")",
")",
"{",
"return",
"otherAnalysisModel",
".",
"findAnalysisById",
"(",
"analysis",
".",
"get",
"(",
"'id'",
")",
")",
";",
"}",
"return",
"false",
";",
"}",
")",
";",
"}"
] |
Check if an analysis is referenced by other anylisis in the given
analysis collection.
|
[
"Check",
"if",
"an",
"analysis",
"is",
"referenced",
"by",
"other",
"anylisis",
"in",
"the",
"given",
"analysis",
"collection",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/windshaft/map-serializer/anonymous-map-serializer/analysis-serializer.js#L31-L38
|
19,732
|
CartoDB/carto.js
|
src/core/profiler.js
|
function (defer) {
if (this.t0 !== null) {
Profiler.new_value(this.name, this._elapsed(), 't', defer);
this.t0 = null;
}
}
|
javascript
|
function (defer) {
if (this.t0 !== null) {
Profiler.new_value(this.name, this._elapsed(), 't', defer);
this.t0 = null;
}
}
|
[
"function",
"(",
"defer",
")",
"{",
"if",
"(",
"this",
".",
"t0",
"!==",
"null",
")",
"{",
"Profiler",
".",
"new_value",
"(",
"this",
".",
"name",
",",
"this",
".",
"_elapsed",
"(",
")",
",",
"'t'",
",",
"defer",
")",
";",
"this",
".",
"t0",
"=",
"null",
";",
"}",
"}"
] |
finish a time measurement and register it ``start`` should be called first, if not this function does not take effect
|
[
"finish",
"a",
"time",
"measurement",
"and",
"register",
"it",
"start",
"should",
"be",
"called",
"first",
"if",
"not",
"this",
"function",
"does",
"not",
"take",
"effect"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/core/profiler.js#L113-L118
|
|
19,733
|
CartoDB/carto.js
|
src/core/profiler.js
|
function () {
++this.count;
if (this.t0 === null) {
this.start();
return;
}
var elapsed = this._elapsed();
if (elapsed > 1) {
Profiler.new_value(this.name, this.count);
this.count = 0;
this.start();
}
}
|
javascript
|
function () {
++this.count;
if (this.t0 === null) {
this.start();
return;
}
var elapsed = this._elapsed();
if (elapsed > 1) {
Profiler.new_value(this.name, this.count);
this.count = 0;
this.start();
}
}
|
[
"function",
"(",
")",
"{",
"++",
"this",
".",
"count",
";",
"if",
"(",
"this",
".",
"t0",
"===",
"null",
")",
"{",
"this",
".",
"start",
"(",
")",
";",
"return",
";",
"}",
"var",
"elapsed",
"=",
"this",
".",
"_elapsed",
"(",
")",
";",
"if",
"(",
"elapsed",
">",
"1",
")",
"{",
"Profiler",
".",
"new_value",
"(",
"this",
".",
"name",
",",
"this",
".",
"count",
")",
";",
"this",
".",
"count",
"=",
"0",
";",
"this",
".",
"start",
"(",
")",
";",
"}",
"}"
] |
measures how many times per second this function is called
|
[
"measures",
"how",
"many",
"times",
"per",
"second",
"this",
"function",
"is",
"called"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/core/profiler.js#L141-L153
|
|
19,734
|
CartoDB/carto.js
|
src/geo/gmaps/gmaps-cartodb-layer-group-view.js
|
function (coord, zoom, ownerDocument) {
var key = zoom + '/' + coord.x + '/' + coord.y;
if (!this.cache[key]) {
var img = this.cache[key] = new Image(256, 256);
this.cache[key].src = this._getTileUrl(coord, zoom);
this.cache[key].setAttribute('gTileKey', key);
this.cache[key].onerror = function () { img.style.display = 'none'; };
}
return this.cache[key];
}
|
javascript
|
function (coord, zoom, ownerDocument) {
var key = zoom + '/' + coord.x + '/' + coord.y;
if (!this.cache[key]) {
var img = this.cache[key] = new Image(256, 256);
this.cache[key].src = this._getTileUrl(coord, zoom);
this.cache[key].setAttribute('gTileKey', key);
this.cache[key].onerror = function () { img.style.display = 'none'; };
}
return this.cache[key];
}
|
[
"function",
"(",
"coord",
",",
"zoom",
",",
"ownerDocument",
")",
"{",
"var",
"key",
"=",
"zoom",
"+",
"'/'",
"+",
"coord",
".",
"x",
"+",
"'/'",
"+",
"coord",
".",
"y",
";",
"if",
"(",
"!",
"this",
".",
"cache",
"[",
"key",
"]",
")",
"{",
"var",
"img",
"=",
"this",
".",
"cache",
"[",
"key",
"]",
"=",
"new",
"Image",
"(",
"256",
",",
"256",
")",
";",
"this",
".",
"cache",
"[",
"key",
"]",
".",
"src",
"=",
"this",
".",
"_getTileUrl",
"(",
"coord",
",",
"zoom",
")",
";",
"this",
".",
"cache",
"[",
"key",
"]",
".",
"setAttribute",
"(",
"'gTileKey'",
",",
"key",
")",
";",
"this",
".",
"cache",
"[",
"key",
"]",
".",
"onerror",
"=",
"function",
"(",
")",
"{",
"img",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"}",
";",
"}",
"return",
"this",
".",
"cache",
"[",
"key",
"]",
";",
"}"
] |
Get a tile element from a coordinate, zoom level, and an ownerDocument.
|
[
"Get",
"a",
"tile",
"element",
"from",
"a",
"coordinate",
"zoom",
"level",
"and",
"an",
"ownerDocument",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/geo/gmaps/gmaps-cartodb-layer-group-view.js#L252-L261
|
|
19,735
|
CartoDB/carto.js
|
src/api/v4/source/sql.js
|
SQL
|
function SQL (query) {
_checkQuery(query);
this._query = query;
Base.apply(this, arguments);
this._appliedFilters.on('change:filters', () => this._updateInternalModelQuery(this._getQueryToApply()));
}
|
javascript
|
function SQL (query) {
_checkQuery(query);
this._query = query;
Base.apply(this, arguments);
this._appliedFilters.on('change:filters', () => this._updateInternalModelQuery(this._getQueryToApply()));
}
|
[
"function",
"SQL",
"(",
"query",
")",
"{",
"_checkQuery",
"(",
"query",
")",
";",
"this",
".",
"_query",
"=",
"query",
";",
"Base",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"_appliedFilters",
".",
"on",
"(",
"'change:filters'",
",",
"(",
")",
"=>",
"this",
".",
"_updateInternalModelQuery",
"(",
"this",
".",
"_getQueryToApply",
"(",
")",
")",
")",
";",
"}"
] |
A SQL Query that can be used as the data source for layers and dataviews.
@param {string} query A SQL query containing a SELECT statement
@fires error
@example
new carto.source.SQL('SELECT * FROM european_cities');
@constructor
@extends carto.source.Base
@memberof carto.source
@fires queryChanged
@api
|
[
"A",
"SQL",
"Query",
"that",
"can",
"be",
"used",
"as",
"the",
"data",
"source",
"for",
"layers",
"and",
"dataviews",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/source/sql.js#L21-L28
|
19,736
|
CartoDB/carto.js
|
src/windshaft/client.js
|
function (settings) {
validatePresenceOfOptions(settings, ['urlTemplate', 'userName']);
if (settings.templateName) {
this.endpoints = {
get: [WindshaftConfig.MAPS_API_BASE_URL, 'named', settings.templateName, 'jsonp'].join('/'),
post: [WindshaftConfig.MAPS_API_BASE_URL, 'named', settings.templateName].join('/')
};
} else {
this.endpoints = {
get: WindshaftConfig.MAPS_API_BASE_URL,
post: WindshaftConfig.MAPS_API_BASE_URL
};
}
this.url = settings.urlTemplate.replace('{user}', settings.userName);
this._requestTracker = new RequestTracker(MAP_INSTANTIATION_LIMIT);
}
|
javascript
|
function (settings) {
validatePresenceOfOptions(settings, ['urlTemplate', 'userName']);
if (settings.templateName) {
this.endpoints = {
get: [WindshaftConfig.MAPS_API_BASE_URL, 'named', settings.templateName, 'jsonp'].join('/'),
post: [WindshaftConfig.MAPS_API_BASE_URL, 'named', settings.templateName].join('/')
};
} else {
this.endpoints = {
get: WindshaftConfig.MAPS_API_BASE_URL,
post: WindshaftConfig.MAPS_API_BASE_URL
};
}
this.url = settings.urlTemplate.replace('{user}', settings.userName);
this._requestTracker = new RequestTracker(MAP_INSTANTIATION_LIMIT);
}
|
[
"function",
"(",
"settings",
")",
"{",
"validatePresenceOfOptions",
"(",
"settings",
",",
"[",
"'urlTemplate'",
",",
"'userName'",
"]",
")",
";",
"if",
"(",
"settings",
".",
"templateName",
")",
"{",
"this",
".",
"endpoints",
"=",
"{",
"get",
":",
"[",
"WindshaftConfig",
".",
"MAPS_API_BASE_URL",
",",
"'named'",
",",
"settings",
".",
"templateName",
",",
"'jsonp'",
"]",
".",
"join",
"(",
"'/'",
")",
",",
"post",
":",
"[",
"WindshaftConfig",
".",
"MAPS_API_BASE_URL",
",",
"'named'",
",",
"settings",
".",
"templateName",
"]",
".",
"join",
"(",
"'/'",
")",
"}",
";",
"}",
"else",
"{",
"this",
".",
"endpoints",
"=",
"{",
"get",
":",
"WindshaftConfig",
".",
"MAPS_API_BASE_URL",
",",
"post",
":",
"WindshaftConfig",
".",
"MAPS_API_BASE_URL",
"}",
";",
"}",
"this",
".",
"url",
"=",
"settings",
".",
"urlTemplate",
".",
"replace",
"(",
"'{user}'",
",",
"settings",
".",
"userName",
")",
";",
"this",
".",
"_requestTracker",
"=",
"new",
"RequestTracker",
"(",
"MAP_INSTANTIATION_LIMIT",
")",
";",
"}"
] |
Windshaft client. It provides a method to create instances of maps in Windshaft.
@param {object} options Options to set up the client
|
[
"Windshaft",
"client",
".",
"It",
"provides",
"a",
"method",
"to",
"create",
"instances",
"of",
"maps",
"in",
"Windshaft",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/windshaft/client.js#L28-L45
|
|
19,737
|
CartoDB/carto.js
|
src/api/v4/layer/metadata/buckets.js
|
Buckets
|
function Buckets (rule) {
var rangeBuckets = rule.getBucketsWithRangeFilter();
/**
* @typedef {object} carto.layer.metadata.Bucket
* @property {number} min - The minimum range value
* @property {number} max - The maximum range value
* @property {number|string} value - The value of the bucket
* @api
*/
this._buckets = rangeBuckets.map(function (bucket) {
return {
min: bucket.filter.start,
max: bucket.filter.end,
value: bucket.value
};
});
this._avg = rule.getFilterAvg();
this._min = rangeBuckets.length > 0 ? rangeBuckets[0].filter.start : undefined;
this._max = rangeBuckets.length > 0 ? rangeBuckets[rangeBuckets.length - 1].filter.end : undefined;
Base.call(this, 'buckets', rule);
}
|
javascript
|
function Buckets (rule) {
var rangeBuckets = rule.getBucketsWithRangeFilter();
/**
* @typedef {object} carto.layer.metadata.Bucket
* @property {number} min - The minimum range value
* @property {number} max - The maximum range value
* @property {number|string} value - The value of the bucket
* @api
*/
this._buckets = rangeBuckets.map(function (bucket) {
return {
min: bucket.filter.start,
max: bucket.filter.end,
value: bucket.value
};
});
this._avg = rule.getFilterAvg();
this._min = rangeBuckets.length > 0 ? rangeBuckets[0].filter.start : undefined;
this._max = rangeBuckets.length > 0 ? rangeBuckets[rangeBuckets.length - 1].filter.end : undefined;
Base.call(this, 'buckets', rule);
}
|
[
"function",
"Buckets",
"(",
"rule",
")",
"{",
"var",
"rangeBuckets",
"=",
"rule",
".",
"getBucketsWithRangeFilter",
"(",
")",
";",
"/**\n * @typedef {object} carto.layer.metadata.Bucket\n * @property {number} min - The minimum range value\n * @property {number} max - The maximum range value\n * @property {number|string} value - The value of the bucket\n * @api\n */",
"this",
".",
"_buckets",
"=",
"rangeBuckets",
".",
"map",
"(",
"function",
"(",
"bucket",
")",
"{",
"return",
"{",
"min",
":",
"bucket",
".",
"filter",
".",
"start",
",",
"max",
":",
"bucket",
".",
"filter",
".",
"end",
",",
"value",
":",
"bucket",
".",
"value",
"}",
";",
"}",
")",
";",
"this",
".",
"_avg",
"=",
"rule",
".",
"getFilterAvg",
"(",
")",
";",
"this",
".",
"_min",
"=",
"rangeBuckets",
".",
"length",
">",
"0",
"?",
"rangeBuckets",
"[",
"0",
"]",
".",
"filter",
".",
"start",
":",
"undefined",
";",
"this",
".",
"_max",
"=",
"rangeBuckets",
".",
"length",
">",
"0",
"?",
"rangeBuckets",
"[",
"rangeBuckets",
".",
"length",
"-",
"1",
"]",
".",
"filter",
".",
"end",
":",
"undefined",
";",
"Base",
".",
"call",
"(",
"this",
",",
"'buckets'",
",",
"rule",
")",
";",
"}"
] |
Metadata type buckets
Adding a Turbocarto ramp (with ranges) in the style generates a response
from the server with the resulting information, after computing the ramp.
This information is wrapped in a metadata object of type 'buckets', that
contains a list of buckets with the range (min, max) and the value. And
also the total min, max range and the average of the total values.
For example, the following ramp will generate a metadata of type 'buckets'
with numeric values (the size) in its buckets:
marker-width: ramp([scalerank], range(5, 20), quantiles(5));
In another example, this ramp will generate a metadata of type 'buckets'
with string values (the color) in its buckets:
marker-fill: ramp([scalerank], (#FFC6C4, #EE919B, #CC607D), quantiles);
@param {object} rule - Rule with the cartocss metadata
@constructor
@hideconstructor
@extends carto.layer.metadata.Base
@memberof carto.layer.metadata
@api
|
[
"Metadata",
"type",
"buckets"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/layer/metadata/buckets.js#L29-L51
|
19,738
|
CartoDB/carto.js
|
src/api/v4/dataview/formula/parse-data.js
|
parseFormulaData
|
function parseFormulaData (nulls, operation, result) {
/**
* @description
* Object containing formula data
*
* @typedef {object} carto.dataview.FormulaData
* @property {number} nulls - Number of null values in the column
* @property {string} operation - Operation used
* @property {number} result - Result of the operation
* @api
*/
return {
nulls: nulls,
operation: operation,
result: result
};
}
|
javascript
|
function parseFormulaData (nulls, operation, result) {
/**
* @description
* Object containing formula data
*
* @typedef {object} carto.dataview.FormulaData
* @property {number} nulls - Number of null values in the column
* @property {string} operation - Operation used
* @property {number} result - Result of the operation
* @api
*/
return {
nulls: nulls,
operation: operation,
result: result
};
}
|
[
"function",
"parseFormulaData",
"(",
"nulls",
",",
"operation",
",",
"result",
")",
"{",
"/**\n * @description\n * Object containing formula data\n *\n * @typedef {object} carto.dataview.FormulaData\n * @property {number} nulls - Number of null values in the column\n * @property {string} operation - Operation used\n * @property {number} result - Result of the operation\n * @api\n */",
"return",
"{",
"nulls",
":",
"nulls",
",",
"operation",
":",
"operation",
",",
"result",
":",
"result",
"}",
";",
"}"
] |
Transform the data obtained from an internal formula dataview into a
public object.
@param {number} nulls
@param {string} operation
@param {number} result
@return {carto.dataview.FormulaData} - The parsed and formatted data for the given parameters
|
[
"Transform",
"the",
"data",
"obtained",
"from",
"an",
"internal",
"formula",
"dataview",
"into",
"a",
"public",
"object",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/dataview/formula/parse-data.js#L11-L27
|
19,739
|
CartoDB/carto.js
|
src/api/v4/native/google-maps-map-type.js
|
GoogleMapsMapType
|
function GoogleMapsMapType (layers, engine, map) {
this._layers = layers;
this._engine = engine;
this._map = map;
this._hoveredLayers = [];
this.tileSize = new google.maps.Size(256, 256);
this._internalView = new GMapsCartoDBLayerGroupView(this._engine._cartoLayerGroup, {
nativeMap: map
});
this._id = this._internalView._id;
this._internalView.on('featureClick', this._onFeatureClick, this);
this._internalView.on('featureOver', this._onFeatureOver, this);
this._internalView.on('featureOut', this._onFeatureOut, this);
this._internalView.on('featureError', this._onFeatureError, this);
}
|
javascript
|
function GoogleMapsMapType (layers, engine, map) {
this._layers = layers;
this._engine = engine;
this._map = map;
this._hoveredLayers = [];
this.tileSize = new google.maps.Size(256, 256);
this._internalView = new GMapsCartoDBLayerGroupView(this._engine._cartoLayerGroup, {
nativeMap: map
});
this._id = this._internalView._id;
this._internalView.on('featureClick', this._onFeatureClick, this);
this._internalView.on('featureOver', this._onFeatureOver, this);
this._internalView.on('featureOut', this._onFeatureOut, this);
this._internalView.on('featureError', this._onFeatureError, this);
}
|
[
"function",
"GoogleMapsMapType",
"(",
"layers",
",",
"engine",
",",
"map",
")",
"{",
"this",
".",
"_layers",
"=",
"layers",
";",
"this",
".",
"_engine",
"=",
"engine",
";",
"this",
".",
"_map",
"=",
"map",
";",
"this",
".",
"_hoveredLayers",
"=",
"[",
"]",
";",
"this",
".",
"tileSize",
"=",
"new",
"google",
".",
"maps",
".",
"Size",
"(",
"256",
",",
"256",
")",
";",
"this",
".",
"_internalView",
"=",
"new",
"GMapsCartoDBLayerGroupView",
"(",
"this",
".",
"_engine",
".",
"_cartoLayerGroup",
",",
"{",
"nativeMap",
":",
"map",
"}",
")",
";",
"this",
".",
"_id",
"=",
"this",
".",
"_internalView",
".",
"_id",
";",
"this",
".",
"_internalView",
".",
"on",
"(",
"'featureClick'",
",",
"this",
".",
"_onFeatureClick",
",",
"this",
")",
";",
"this",
".",
"_internalView",
".",
"on",
"(",
"'featureOver'",
",",
"this",
".",
"_onFeatureOver",
",",
"this",
")",
";",
"this",
".",
"_internalView",
".",
"on",
"(",
"'featureOut'",
",",
"this",
".",
"_onFeatureOut",
",",
"this",
")",
";",
"this",
".",
"_internalView",
".",
"on",
"(",
"'featureError'",
",",
"this",
".",
"_onFeatureError",
",",
"this",
")",
";",
"}"
] |
This object is a custom Google Maps MapType to enable feature interactivity
using an internal GMapsCartoDBLayerGroupView instance.
NOTE: It also contains the feature events handlers. That's why it requires the carto layers array.
|
[
"This",
"object",
"is",
"a",
"custom",
"Google",
"Maps",
"MapType",
"to",
"enable",
"feature",
"interactivity",
"using",
"an",
"internal",
"GMapsCartoDBLayerGroupView",
"instance",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/native/google-maps-map-type.js#L14-L30
|
19,740
|
CartoDB/carto.js
|
src/api/v4/layer/aggregation.js
|
_checkAndTransformColumns
|
function _checkAndTransformColumns (columns) {
var returnValue = null;
if (columns) {
_checkColumns(columns);
returnValue = {};
Object.keys(columns).forEach(function (key) {
returnValue[key] = _columnToSnakeCase(columns[key]);
});
}
return returnValue;
}
|
javascript
|
function _checkAndTransformColumns (columns) {
var returnValue = null;
if (columns) {
_checkColumns(columns);
returnValue = {};
Object.keys(columns).forEach(function (key) {
returnValue[key] = _columnToSnakeCase(columns[key]);
});
}
return returnValue;
}
|
[
"function",
"_checkAndTransformColumns",
"(",
"columns",
")",
"{",
"var",
"returnValue",
"=",
"null",
";",
"if",
"(",
"columns",
")",
"{",
"_checkColumns",
"(",
"columns",
")",
";",
"returnValue",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"columns",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"returnValue",
"[",
"key",
"]",
"=",
"_columnToSnakeCase",
"(",
"columns",
"[",
"key",
"]",
")",
";",
"}",
")",
";",
"}",
"return",
"returnValue",
";",
"}"
] |
Windshaft uses snake_case for column parameters
|
[
"Windshaft",
"uses",
"snake_case",
"for",
"column",
"parameters"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/layer/aggregation.js#L150-L162
|
19,741
|
CartoDB/carto.js
|
src/api/v4/error-handling/carto-error-extender.js
|
_getListedError
|
function _getListedError (cartoError, errorList) {
var errorListkeys = _.keys(errorList);
var key;
for (var i = 0; i < errorListkeys.length; i++) {
key = errorListkeys[i];
if (!(errorList[key].messageRegex instanceof RegExp)) {
throw new Error('MessageRegex on ' + key + ' is not a RegExp.');
}
if (errorList[key].messageRegex.test(cartoError.message)) {
return {
friendlyMessage: _replaceRegex(cartoError, errorList[key]),
errorCode: _buildErrorCode(cartoError, key)
};
}
}
// When cartoError not found return generic values
return {
friendlyMessage: cartoError.message || '',
errorCode: _buildErrorCode(cartoError, 'unknown-error')
};
}
|
javascript
|
function _getListedError (cartoError, errorList) {
var errorListkeys = _.keys(errorList);
var key;
for (var i = 0; i < errorListkeys.length; i++) {
key = errorListkeys[i];
if (!(errorList[key].messageRegex instanceof RegExp)) {
throw new Error('MessageRegex on ' + key + ' is not a RegExp.');
}
if (errorList[key].messageRegex.test(cartoError.message)) {
return {
friendlyMessage: _replaceRegex(cartoError, errorList[key]),
errorCode: _buildErrorCode(cartoError, key)
};
}
}
// When cartoError not found return generic values
return {
friendlyMessage: cartoError.message || '',
errorCode: _buildErrorCode(cartoError, 'unknown-error')
};
}
|
[
"function",
"_getListedError",
"(",
"cartoError",
",",
"errorList",
")",
"{",
"var",
"errorListkeys",
"=",
"_",
".",
"keys",
"(",
"errorList",
")",
";",
"var",
"key",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"errorListkeys",
".",
"length",
";",
"i",
"++",
")",
"{",
"key",
"=",
"errorListkeys",
"[",
"i",
"]",
";",
"if",
"(",
"!",
"(",
"errorList",
"[",
"key",
"]",
".",
"messageRegex",
"instanceof",
"RegExp",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'MessageRegex on '",
"+",
"key",
"+",
"' is not a RegExp.'",
")",
";",
"}",
"if",
"(",
"errorList",
"[",
"key",
"]",
".",
"messageRegex",
".",
"test",
"(",
"cartoError",
".",
"message",
")",
")",
"{",
"return",
"{",
"friendlyMessage",
":",
"_replaceRegex",
"(",
"cartoError",
",",
"errorList",
"[",
"key",
"]",
")",
",",
"errorCode",
":",
"_buildErrorCode",
"(",
"cartoError",
",",
"key",
")",
"}",
";",
"}",
"}",
"// When cartoError not found return generic values",
"return",
"{",
"friendlyMessage",
":",
"cartoError",
".",
"message",
"||",
"''",
",",
"errorCode",
":",
"_buildErrorCode",
"(",
"cartoError",
",",
"'unknown-error'",
")",
"}",
";",
"}"
] |
Get the listed error from a cartoError, if no listedError is found return a generic
unknown error.
@param {CartoError} cartoError
|
[
"Get",
"the",
"listed",
"error",
"from",
"a",
"cartoError",
"if",
"no",
"listedError",
"is",
"found",
"return",
"a",
"generic",
"unknown",
"error",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/error-handling/carto-error-extender.js#L36-L57
|
19,742
|
CartoDB/carto.js
|
src/api/v4/error-handling/carto-error-extender.js
|
_buildErrorCode
|
function _buildErrorCode (cartoError, key) {
var fragments = [];
fragments.push(cartoError && cartoError.origin);
fragments.push(cartoError && cartoError.type);
fragments.push(key);
fragments = _.compact(fragments);
return fragments.join(':');
}
|
javascript
|
function _buildErrorCode (cartoError, key) {
var fragments = [];
fragments.push(cartoError && cartoError.origin);
fragments.push(cartoError && cartoError.type);
fragments.push(key);
fragments = _.compact(fragments);
return fragments.join(':');
}
|
[
"function",
"_buildErrorCode",
"(",
"cartoError",
",",
"key",
")",
"{",
"var",
"fragments",
"=",
"[",
"]",
";",
"fragments",
".",
"push",
"(",
"cartoError",
"&&",
"cartoError",
".",
"origin",
")",
";",
"fragments",
".",
"push",
"(",
"cartoError",
"&&",
"cartoError",
".",
"type",
")",
";",
"fragments",
".",
"push",
"(",
"key",
")",
";",
"fragments",
"=",
"_",
".",
"compact",
"(",
"fragments",
")",
";",
"return",
"fragments",
".",
"join",
"(",
"':'",
")",
";",
"}"
] |
Generate an unique string that represents a cartoError
@param {cartoError} cartoError
@param {string} key
|
[
"Generate",
"an",
"unique",
"string",
"that",
"represents",
"a",
"cartoError"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/error-handling/carto-error-extender.js#L82-L90
|
19,743
|
CartoDB/carto.js
|
src/vis/map-cursor-manager.js
|
function (deps) {
if (!deps.mapView) throw new Error('mapView is required');
if (!deps.mapModel) throw new Error('mapModel is required');
this._mapView = deps.mapView;
this._mapModel = deps.mapModel;
// Map to keep track of clickable layers that are being feature overed
this._clickableLayersBeingFeatureOvered = {};
}
|
javascript
|
function (deps) {
if (!deps.mapView) throw new Error('mapView is required');
if (!deps.mapModel) throw new Error('mapModel is required');
this._mapView = deps.mapView;
this._mapModel = deps.mapModel;
// Map to keep track of clickable layers that are being feature overed
this._clickableLayersBeingFeatureOvered = {};
}
|
[
"function",
"(",
"deps",
")",
"{",
"if",
"(",
"!",
"deps",
".",
"mapView",
")",
"throw",
"new",
"Error",
"(",
"'mapView is required'",
")",
";",
"if",
"(",
"!",
"deps",
".",
"mapModel",
")",
"throw",
"new",
"Error",
"(",
"'mapModel is required'",
")",
";",
"this",
".",
"_mapView",
"=",
"deps",
".",
"mapView",
";",
"this",
".",
"_mapModel",
"=",
"deps",
".",
"mapModel",
";",
"// Map to keep track of clickable layers that are being feature overed",
"this",
".",
"_clickableLayersBeingFeatureOvered",
"=",
"{",
"}",
";",
"}"
] |
Changes the mouse pointer based on feature events and status
of map's interactivity.
@param {Object} deps Dependencies
|
[
"Changes",
"the",
"mouse",
"pointer",
"based",
"on",
"feature",
"events",
"and",
"status",
"of",
"map",
"s",
"interactivity",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/vis/map-cursor-manager.js#L8-L17
|
|
19,744
|
CartoDB/carto.js
|
src/api/v4/filter/bounding-box-gmaps.js
|
BoundingBoxGoogleMaps
|
function BoundingBoxGoogleMaps (map) {
if (!_isGoogleMap(map)) {
throw new Error('Bounding box requires a Google Maps map but got: ' + map);
}
// Adapt the Google Maps map to offer unique:
// - getBounds() function
// - 'boundsChanged' event
var mapAdapter = new GoogleMapsBoundingBoxAdapter(map);
// Use the adapter for the internal BoundingBoxFilter model
this._internalModel = new BoundingBoxFilterModel(mapAdapter);
this.listenTo(this._internalModel, 'boundsChanged', this._onBoundsChanged);
}
|
javascript
|
function BoundingBoxGoogleMaps (map) {
if (!_isGoogleMap(map)) {
throw new Error('Bounding box requires a Google Maps map but got: ' + map);
}
// Adapt the Google Maps map to offer unique:
// - getBounds() function
// - 'boundsChanged' event
var mapAdapter = new GoogleMapsBoundingBoxAdapter(map);
// Use the adapter for the internal BoundingBoxFilter model
this._internalModel = new BoundingBoxFilterModel(mapAdapter);
this.listenTo(this._internalModel, 'boundsChanged', this._onBoundsChanged);
}
|
[
"function",
"BoundingBoxGoogleMaps",
"(",
"map",
")",
"{",
"if",
"(",
"!",
"_isGoogleMap",
"(",
"map",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Bounding box requires a Google Maps map but got: '",
"+",
"map",
")",
";",
"}",
"// Adapt the Google Maps map to offer unique:",
"// - getBounds() function",
"// - 'boundsChanged' event",
"var",
"mapAdapter",
"=",
"new",
"GoogleMapsBoundingBoxAdapter",
"(",
"map",
")",
";",
"// Use the adapter for the internal BoundingBoxFilter model",
"this",
".",
"_internalModel",
"=",
"new",
"BoundingBoxFilterModel",
"(",
"mapAdapter",
")",
";",
"this",
".",
"listenTo",
"(",
"this",
".",
"_internalModel",
",",
"'boundsChanged'",
",",
"this",
".",
"_onBoundsChanged",
")",
";",
"}"
] |
Bounding box filter for Google Maps maps.
When this filter is included into a dataview only the data inside the {@link https://developers.google.com/maps/documentation/javascript/3.exp/reference#Map|googleMap}
bounds will be taken into account.
@param {google.maps.map} map - The google map to track the bounds
@fires boundsChanged
@constructor
@extends carto.filter.Base
@memberof carto.filter
@api
@example
// Create a bonding box attached to a google map.
const bboxFilter = new carto.filter.BoundingBoxGoogleMaps(googleMap);
// Add the filter to a dataview. Generating new data when the map bounds are changed.
dataview.addFilter(bboxFilter);
|
[
"Bounding",
"box",
"filter",
"for",
"Google",
"Maps",
"maps",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/filter/bounding-box-gmaps.js#L29-L40
|
19,745
|
CartoDB/carto.js
|
vendor/html-css-sanitizer-bundle.js
|
parse
|
function parse(uriStr) {
var m = ('' + uriStr).match(URI_RE_);
if (!m) { return null; }
return new URI(
nullIfAbsent(m[1]),
nullIfAbsent(m[2]),
nullIfAbsent(m[3]),
nullIfAbsent(m[4]),
nullIfAbsent(m[5]),
nullIfAbsent(m[6]),
nullIfAbsent(m[7]));
}
|
javascript
|
function parse(uriStr) {
var m = ('' + uriStr).match(URI_RE_);
if (!m) { return null; }
return new URI(
nullIfAbsent(m[1]),
nullIfAbsent(m[2]),
nullIfAbsent(m[3]),
nullIfAbsent(m[4]),
nullIfAbsent(m[5]),
nullIfAbsent(m[6]),
nullIfAbsent(m[7]));
}
|
[
"function",
"parse",
"(",
"uriStr",
")",
"{",
"var",
"m",
"=",
"(",
"''",
"+",
"uriStr",
")",
".",
"match",
"(",
"URI_RE_",
")",
";",
"if",
"(",
"!",
"m",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"URI",
"(",
"nullIfAbsent",
"(",
"m",
"[",
"1",
"]",
")",
",",
"nullIfAbsent",
"(",
"m",
"[",
"2",
"]",
")",
",",
"nullIfAbsent",
"(",
"m",
"[",
"3",
"]",
")",
",",
"nullIfAbsent",
"(",
"m",
"[",
"4",
"]",
")",
",",
"nullIfAbsent",
"(",
"m",
"[",
"5",
"]",
")",
",",
"nullIfAbsent",
"(",
"m",
"[",
"6",
"]",
")",
",",
"nullIfAbsent",
"(",
"m",
"[",
"7",
"]",
")",
")",
";",
"}"
] |
creates a uri from the string form. The parser is relaxed, so special
characters that aren't escaped but don't cause ambiguities will not cause
parse failures.
@return {URI|null}
|
[
"creates",
"a",
"uri",
"from",
"the",
"string",
"form",
".",
"The",
"parser",
"is",
"relaxed",
"so",
"special",
"characters",
"that",
"aren",
"t",
"escaped",
"but",
"don",
"t",
"cause",
"ambiguities",
"will",
"not",
"cause",
"parse",
"failures",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/vendor/html-css-sanitizer-bundle.js#L1086-L1097
|
19,746
|
CartoDB/carto.js
|
vendor/html-css-sanitizer-bundle.js
|
create
|
function create(scheme, credentials, domain, port, path, query, fragment) {
var uri = new URI(
encodeIfExists2(scheme, URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_),
encodeIfExists2(
credentials, URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_),
encodeIfExists(domain),
port > 0 ? port.toString() : null,
encodeIfExists2(path, URI_DISALLOWED_IN_PATH_),
null,
encodeIfExists(fragment));
if (query) {
if ('string' === typeof query) {
uri.setRawQuery(query.replace(/[^?&=0-9A-Za-z_\-~.%]/g, encodeOne));
} else {
uri.setAllParameters(query);
}
}
return uri;
}
|
javascript
|
function create(scheme, credentials, domain, port, path, query, fragment) {
var uri = new URI(
encodeIfExists2(scheme, URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_),
encodeIfExists2(
credentials, URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_),
encodeIfExists(domain),
port > 0 ? port.toString() : null,
encodeIfExists2(path, URI_DISALLOWED_IN_PATH_),
null,
encodeIfExists(fragment));
if (query) {
if ('string' === typeof query) {
uri.setRawQuery(query.replace(/[^?&=0-9A-Za-z_\-~.%]/g, encodeOne));
} else {
uri.setAllParameters(query);
}
}
return uri;
}
|
[
"function",
"create",
"(",
"scheme",
",",
"credentials",
",",
"domain",
",",
"port",
",",
"path",
",",
"query",
",",
"fragment",
")",
"{",
"var",
"uri",
"=",
"new",
"URI",
"(",
"encodeIfExists2",
"(",
"scheme",
",",
"URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_",
")",
",",
"encodeIfExists2",
"(",
"credentials",
",",
"URI_DISALLOWED_IN_SCHEME_OR_CREDENTIALS_",
")",
",",
"encodeIfExists",
"(",
"domain",
")",
",",
"port",
">",
"0",
"?",
"port",
".",
"toString",
"(",
")",
":",
"null",
",",
"encodeIfExists2",
"(",
"path",
",",
"URI_DISALLOWED_IN_PATH_",
")",
",",
"null",
",",
"encodeIfExists",
"(",
"fragment",
")",
")",
";",
"if",
"(",
"query",
")",
"{",
"if",
"(",
"'string'",
"===",
"typeof",
"query",
")",
"{",
"uri",
".",
"setRawQuery",
"(",
"query",
".",
"replace",
"(",
"/",
"[^?&=0-9A-Za-z_\\-~.%]",
"/",
"g",
",",
"encodeOne",
")",
")",
";",
"}",
"else",
"{",
"uri",
".",
"setAllParameters",
"(",
"query",
")",
";",
"}",
"}",
"return",
"uri",
";",
"}"
] |
creates a uri from the given parts.
@param scheme {string} an unencoded scheme such as "http" or null
@param credentials {string} unencoded user credentials or null
@param domain {string} an unencoded domain name or null
@param port {number} a port number in [1, 32768].
-1 indicates no port, as does null.
@param path {string} an unencoded path
@param query {Array.<string>|string|null} a list of unencoded cgi
parameters where even values are keys and odds the corresponding values
or an unencoded query.
@param fragment {string} an unencoded fragment without the "#" or null.
@return {URI}
|
[
"creates",
"a",
"uri",
"from",
"the",
"given",
"parts",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/vendor/html-css-sanitizer-bundle.js#L1115-L1133
|
19,747
|
CartoDB/carto.js
|
vendor/html-css-sanitizer-bundle.js
|
encodeIfExists2
|
function encodeIfExists2(unescapedPart, extra) {
if ('string' == typeof unescapedPart) {
return encodeURI(unescapedPart).replace(extra, encodeOne);
}
return null;
}
|
javascript
|
function encodeIfExists2(unescapedPart, extra) {
if ('string' == typeof unescapedPart) {
return encodeURI(unescapedPart).replace(extra, encodeOne);
}
return null;
}
|
[
"function",
"encodeIfExists2",
"(",
"unescapedPart",
",",
"extra",
")",
"{",
"if",
"(",
"'string'",
"==",
"typeof",
"unescapedPart",
")",
"{",
"return",
"encodeURI",
"(",
"unescapedPart",
")",
".",
"replace",
"(",
"extra",
",",
"encodeOne",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
if unescapedPart is non null, then escapes any characters in it that aren't
valid characters in a url and also escapes any special characters that
appear in extra.
@param unescapedPart {string}
@param extra {RegExp} a character set of characters in [\01-\177].
@return {string|null} null iff unescapedPart == null.
|
[
"if",
"unescapedPart",
"is",
"non",
"null",
"then",
"escapes",
"any",
"characters",
"in",
"it",
"that",
"aren",
"t",
"valid",
"characters",
"in",
"a",
"url",
"and",
"also",
"escapes",
"any",
"special",
"characters",
"that",
"appear",
"in",
"extra",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/vendor/html-css-sanitizer-bundle.js#L1149-L1154
|
19,748
|
CartoDB/carto.js
|
vendor/html-css-sanitizer-bundle.js
|
resolve
|
function resolve(baseUri, relativeUri) {
// there are several kinds of relative urls:
// 1. //foo - replaces everything from the domain on. foo is a domain name
// 2. foo - replaces the last part of the path, the whole query and fragment
// 3. /foo - replaces the the path, the query and fragment
// 4. ?foo - replace the query and fragment
// 5. #foo - replace the fragment only
var absoluteUri = baseUri.clone();
// we satisfy these conditions by looking for the first part of relativeUri
// that is not blank and applying defaults to the rest
var overridden = relativeUri.hasScheme();
if (overridden) {
absoluteUri.setRawScheme(relativeUri.getRawScheme());
} else {
overridden = relativeUri.hasCredentials();
}
if (overridden) {
absoluteUri.setRawCredentials(relativeUri.getRawCredentials());
} else {
overridden = relativeUri.hasDomain();
}
if (overridden) {
absoluteUri.setRawDomain(relativeUri.getRawDomain());
} else {
overridden = relativeUri.hasPort();
}
var rawPath = relativeUri.getRawPath();
var simplifiedPath = collapse_dots(rawPath);
if (overridden) {
absoluteUri.setPort(relativeUri.getPort());
simplifiedPath = simplifiedPath
&& simplifiedPath.replace(EXTRA_PARENT_PATHS_RE, '');
} else {
overridden = !!rawPath;
if (overridden) {
// resolve path properly
if (simplifiedPath.charCodeAt(0) !== 0x2f /* / */) { // path is relative
var absRawPath = collapse_dots(absoluteUri.getRawPath() || '')
.replace(EXTRA_PARENT_PATHS_RE, '');
var slash = absRawPath.lastIndexOf('/') + 1;
simplifiedPath = collapse_dots(
(slash ? absRawPath.substring(0, slash) : '')
+ collapse_dots(rawPath))
.replace(EXTRA_PARENT_PATHS_RE, '');
}
} else {
simplifiedPath = simplifiedPath
&& simplifiedPath.replace(EXTRA_PARENT_PATHS_RE, '');
if (simplifiedPath !== rawPath) {
absoluteUri.setRawPath(simplifiedPath);
}
}
}
if (overridden) {
absoluteUri.setRawPath(simplifiedPath);
} else {
overridden = relativeUri.hasQuery();
}
if (overridden) {
absoluteUri.setRawQuery(relativeUri.getRawQuery());
} else {
overridden = relativeUri.hasFragment();
}
if (overridden) {
absoluteUri.setRawFragment(relativeUri.getRawFragment());
}
return absoluteUri;
}
|
javascript
|
function resolve(baseUri, relativeUri) {
// there are several kinds of relative urls:
// 1. //foo - replaces everything from the domain on. foo is a domain name
// 2. foo - replaces the last part of the path, the whole query and fragment
// 3. /foo - replaces the the path, the query and fragment
// 4. ?foo - replace the query and fragment
// 5. #foo - replace the fragment only
var absoluteUri = baseUri.clone();
// we satisfy these conditions by looking for the first part of relativeUri
// that is not blank and applying defaults to the rest
var overridden = relativeUri.hasScheme();
if (overridden) {
absoluteUri.setRawScheme(relativeUri.getRawScheme());
} else {
overridden = relativeUri.hasCredentials();
}
if (overridden) {
absoluteUri.setRawCredentials(relativeUri.getRawCredentials());
} else {
overridden = relativeUri.hasDomain();
}
if (overridden) {
absoluteUri.setRawDomain(relativeUri.getRawDomain());
} else {
overridden = relativeUri.hasPort();
}
var rawPath = relativeUri.getRawPath();
var simplifiedPath = collapse_dots(rawPath);
if (overridden) {
absoluteUri.setPort(relativeUri.getPort());
simplifiedPath = simplifiedPath
&& simplifiedPath.replace(EXTRA_PARENT_PATHS_RE, '');
} else {
overridden = !!rawPath;
if (overridden) {
// resolve path properly
if (simplifiedPath.charCodeAt(0) !== 0x2f /* / */) { // path is relative
var absRawPath = collapse_dots(absoluteUri.getRawPath() || '')
.replace(EXTRA_PARENT_PATHS_RE, '');
var slash = absRawPath.lastIndexOf('/') + 1;
simplifiedPath = collapse_dots(
(slash ? absRawPath.substring(0, slash) : '')
+ collapse_dots(rawPath))
.replace(EXTRA_PARENT_PATHS_RE, '');
}
} else {
simplifiedPath = simplifiedPath
&& simplifiedPath.replace(EXTRA_PARENT_PATHS_RE, '');
if (simplifiedPath !== rawPath) {
absoluteUri.setRawPath(simplifiedPath);
}
}
}
if (overridden) {
absoluteUri.setRawPath(simplifiedPath);
} else {
overridden = relativeUri.hasQuery();
}
if (overridden) {
absoluteUri.setRawQuery(relativeUri.getRawQuery());
} else {
overridden = relativeUri.hasFragment();
}
if (overridden) {
absoluteUri.setRawFragment(relativeUri.getRawFragment());
}
return absoluteUri;
}
|
[
"function",
"resolve",
"(",
"baseUri",
",",
"relativeUri",
")",
"{",
"// there are several kinds of relative urls:",
"// 1. //foo - replaces everything from the domain on. foo is a domain name",
"// 2. foo - replaces the last part of the path, the whole query and fragment",
"// 3. /foo - replaces the the path, the query and fragment",
"// 4. ?foo - replace the query and fragment",
"// 5. #foo - replace the fragment only",
"var",
"absoluteUri",
"=",
"baseUri",
".",
"clone",
"(",
")",
";",
"// we satisfy these conditions by looking for the first part of relativeUri",
"// that is not blank and applying defaults to the rest",
"var",
"overridden",
"=",
"relativeUri",
".",
"hasScheme",
"(",
")",
";",
"if",
"(",
"overridden",
")",
"{",
"absoluteUri",
".",
"setRawScheme",
"(",
"relativeUri",
".",
"getRawScheme",
"(",
")",
")",
";",
"}",
"else",
"{",
"overridden",
"=",
"relativeUri",
".",
"hasCredentials",
"(",
")",
";",
"}",
"if",
"(",
"overridden",
")",
"{",
"absoluteUri",
".",
"setRawCredentials",
"(",
"relativeUri",
".",
"getRawCredentials",
"(",
")",
")",
";",
"}",
"else",
"{",
"overridden",
"=",
"relativeUri",
".",
"hasDomain",
"(",
")",
";",
"}",
"if",
"(",
"overridden",
")",
"{",
"absoluteUri",
".",
"setRawDomain",
"(",
"relativeUri",
".",
"getRawDomain",
"(",
")",
")",
";",
"}",
"else",
"{",
"overridden",
"=",
"relativeUri",
".",
"hasPort",
"(",
")",
";",
"}",
"var",
"rawPath",
"=",
"relativeUri",
".",
"getRawPath",
"(",
")",
";",
"var",
"simplifiedPath",
"=",
"collapse_dots",
"(",
"rawPath",
")",
";",
"if",
"(",
"overridden",
")",
"{",
"absoluteUri",
".",
"setPort",
"(",
"relativeUri",
".",
"getPort",
"(",
")",
")",
";",
"simplifiedPath",
"=",
"simplifiedPath",
"&&",
"simplifiedPath",
".",
"replace",
"(",
"EXTRA_PARENT_PATHS_RE",
",",
"''",
")",
";",
"}",
"else",
"{",
"overridden",
"=",
"!",
"!",
"rawPath",
";",
"if",
"(",
"overridden",
")",
"{",
"// resolve path properly",
"if",
"(",
"simplifiedPath",
".",
"charCodeAt",
"(",
"0",
")",
"!==",
"0x2f",
"/* / */",
")",
"{",
"// path is relative",
"var",
"absRawPath",
"=",
"collapse_dots",
"(",
"absoluteUri",
".",
"getRawPath",
"(",
")",
"||",
"''",
")",
".",
"replace",
"(",
"EXTRA_PARENT_PATHS_RE",
",",
"''",
")",
";",
"var",
"slash",
"=",
"absRawPath",
".",
"lastIndexOf",
"(",
"'/'",
")",
"+",
"1",
";",
"simplifiedPath",
"=",
"collapse_dots",
"(",
"(",
"slash",
"?",
"absRawPath",
".",
"substring",
"(",
"0",
",",
"slash",
")",
":",
"''",
")",
"+",
"collapse_dots",
"(",
"rawPath",
")",
")",
".",
"replace",
"(",
"EXTRA_PARENT_PATHS_RE",
",",
"''",
")",
";",
"}",
"}",
"else",
"{",
"simplifiedPath",
"=",
"simplifiedPath",
"&&",
"simplifiedPath",
".",
"replace",
"(",
"EXTRA_PARENT_PATHS_RE",
",",
"''",
")",
";",
"if",
"(",
"simplifiedPath",
"!==",
"rawPath",
")",
"{",
"absoluteUri",
".",
"setRawPath",
"(",
"simplifiedPath",
")",
";",
"}",
"}",
"}",
"if",
"(",
"overridden",
")",
"{",
"absoluteUri",
".",
"setRawPath",
"(",
"simplifiedPath",
")",
";",
"}",
"else",
"{",
"overridden",
"=",
"relativeUri",
".",
"hasQuery",
"(",
")",
";",
"}",
"if",
"(",
"overridden",
")",
"{",
"absoluteUri",
".",
"setRawQuery",
"(",
"relativeUri",
".",
"getRawQuery",
"(",
")",
")",
";",
"}",
"else",
"{",
"overridden",
"=",
"relativeUri",
".",
"hasFragment",
"(",
")",
";",
"}",
"if",
"(",
"overridden",
")",
"{",
"absoluteUri",
".",
"setRawFragment",
"(",
"relativeUri",
".",
"getRawFragment",
"(",
")",
")",
";",
"}",
"return",
"absoluteUri",
";",
"}"
] |
resolves a relative url string to a base uri.
@return {URI}
|
[
"resolves",
"a",
"relative",
"url",
"string",
"to",
"a",
"base",
"uri",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/vendor/html-css-sanitizer-bundle.js#L1227-L1304
|
19,749
|
CartoDB/carto.js
|
vendor/html-css-sanitizer-bundle.js
|
URI
|
function URI(
rawScheme,
rawCredentials, rawDomain, port,
rawPath, rawQuery, rawFragment) {
this.scheme_ = rawScheme;
this.credentials_ = rawCredentials;
this.domain_ = rawDomain;
this.port_ = port;
this.path_ = rawPath;
this.query_ = rawQuery;
this.fragment_ = rawFragment;
/**
* @type {Array|null}
*/
this.paramCache_ = null;
}
|
javascript
|
function URI(
rawScheme,
rawCredentials, rawDomain, port,
rawPath, rawQuery, rawFragment) {
this.scheme_ = rawScheme;
this.credentials_ = rawCredentials;
this.domain_ = rawDomain;
this.port_ = port;
this.path_ = rawPath;
this.query_ = rawQuery;
this.fragment_ = rawFragment;
/**
* @type {Array|null}
*/
this.paramCache_ = null;
}
|
[
"function",
"URI",
"(",
"rawScheme",
",",
"rawCredentials",
",",
"rawDomain",
",",
"port",
",",
"rawPath",
",",
"rawQuery",
",",
"rawFragment",
")",
"{",
"this",
".",
"scheme_",
"=",
"rawScheme",
";",
"this",
".",
"credentials_",
"=",
"rawCredentials",
";",
"this",
".",
"domain_",
"=",
"rawDomain",
";",
"this",
".",
"port_",
"=",
"port",
";",
"this",
".",
"path_",
"=",
"rawPath",
";",
"this",
".",
"query_",
"=",
"rawQuery",
";",
"this",
".",
"fragment_",
"=",
"rawFragment",
";",
"/**\n * @type {Array|null}\n */",
"this",
".",
"paramCache_",
"=",
"null",
";",
"}"
] |
a mutable URI.
This class contains setters and getters for the parts of the URI.
The <tt>getXYZ</tt>/<tt>setXYZ</tt> methods return the decoded part -- so
<code>uri.parse('/foo%20bar').getPath()</code> will return the decoded path,
<tt>/foo bar</tt>.
<p>The raw versions of fields are available too.
<code>uri.parse('/foo%20bar').getRawPath()</code> will return the raw path,
<tt>/foo%20bar</tt>. Use the raw setters with care, since
<code>URI::toString</code> is not guaranteed to return a valid url if a
raw setter was used.
<p>All setters return <tt>this</tt> and so may be chained, a la
<code>uri.parse('/foo').setFragment('part').toString()</code>.
<p>You should not use this constructor directly -- please prefer the factory
functions {@link uri.parse}, {@link uri.create}, {@link uri.resolve}
instead.</p>
<p>The parameters are all raw (assumed to be properly escaped) parts, and
any (but not all) may be null. Undefined is not allowed.</p>
@constructor
|
[
"a",
"mutable",
"URI",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/vendor/html-css-sanitizer-bundle.js#L1332-L1347
|
19,750
|
CartoDB/carto.js
|
vendor/html-css-sanitizer-bundle.js
|
lookupEntity
|
function lookupEntity(name) {
// TODO: entity lookup as specified by HTML5 actually depends on the
// presence of the ";".
if (ENTITIES.hasOwnProperty(name)) { return ENTITIES[name]; }
var m = name.match(decimalEscapeRe);
if (m) {
return String.fromCharCode(parseInt(m[1], 10));
} else if (!!(m = name.match(hexEscapeRe))) {
return String.fromCharCode(parseInt(m[1], 16));
} else if (entityLookupElement && safeEntityNameRe.test(name)) {
entityLookupElement.innerHTML = '&' + name + ';';
var text = entityLookupElement.textContent;
ENTITIES[name] = text;
return text;
} else {
return '&' + name + ';';
}
}
|
javascript
|
function lookupEntity(name) {
// TODO: entity lookup as specified by HTML5 actually depends on the
// presence of the ";".
if (ENTITIES.hasOwnProperty(name)) { return ENTITIES[name]; }
var m = name.match(decimalEscapeRe);
if (m) {
return String.fromCharCode(parseInt(m[1], 10));
} else if (!!(m = name.match(hexEscapeRe))) {
return String.fromCharCode(parseInt(m[1], 16));
} else if (entityLookupElement && safeEntityNameRe.test(name)) {
entityLookupElement.innerHTML = '&' + name + ';';
var text = entityLookupElement.textContent;
ENTITIES[name] = text;
return text;
} else {
return '&' + name + ';';
}
}
|
[
"function",
"lookupEntity",
"(",
"name",
")",
"{",
"// TODO: entity lookup as specified by HTML5 actually depends on the",
"// presence of the \";\".",
"if",
"(",
"ENTITIES",
".",
"hasOwnProperty",
"(",
"name",
")",
")",
"{",
"return",
"ENTITIES",
"[",
"name",
"]",
";",
"}",
"var",
"m",
"=",
"name",
".",
"match",
"(",
"decimalEscapeRe",
")",
";",
"if",
"(",
"m",
")",
"{",
"return",
"String",
".",
"fromCharCode",
"(",
"parseInt",
"(",
"m",
"[",
"1",
"]",
",",
"10",
")",
")",
";",
"}",
"else",
"if",
"(",
"!",
"!",
"(",
"m",
"=",
"name",
".",
"match",
"(",
"hexEscapeRe",
")",
")",
")",
"{",
"return",
"String",
".",
"fromCharCode",
"(",
"parseInt",
"(",
"m",
"[",
"1",
"]",
",",
"16",
")",
")",
";",
"}",
"else",
"if",
"(",
"entityLookupElement",
"&&",
"safeEntityNameRe",
".",
"test",
"(",
"name",
")",
")",
"{",
"entityLookupElement",
".",
"innerHTML",
"=",
"'&'",
"+",
"name",
"+",
"';'",
";",
"var",
"text",
"=",
"entityLookupElement",
".",
"textContent",
";",
"ENTITIES",
"[",
"name",
"]",
"=",
"text",
";",
"return",
"text",
";",
"}",
"else",
"{",
"return",
"'&'",
"+",
"name",
"+",
"';'",
";",
"}",
"}"
] |
Decodes an HTML entity.
{\@updoc
$ lookupEntity('lt')
# '<'
$ lookupEntity('GT')
# '>'
$ lookupEntity('amp')
# '&'
$ lookupEntity('nbsp')
# '\xA0'
$ lookupEntity('apos')
# "'"
$ lookupEntity('quot')
# '"'
$ lookupEntity('#xa')
# '\n'
$ lookupEntity('#10')
# '\n'
$ lookupEntity('#x0a')
# '\n'
$ lookupEntity('#010')
# '\n'
$ lookupEntity('#x00A')
# '\n'
$ lookupEntity('Pi') // Known failure
# '\u03A0'
$ lookupEntity('pi') // Known failure
# '\u03C0'
}
@param {string} name the content between the '&' and the ';'.
@return {string} a single unicode code-point as a string.
|
[
"Decodes",
"an",
"HTML",
"entity",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/vendor/html-css-sanitizer-bundle.js#L3895-L3912
|
19,751
|
CartoDB/carto.js
|
vendor/html-css-sanitizer-bundle.js
|
makeSaxParser
|
function makeSaxParser(handler) {
// Accept quoted or unquoted keys (Closure compat)
var hcopy = {
cdata: handler.cdata || handler['cdata'],
comment: handler.comment || handler['comment'],
endDoc: handler.endDoc || handler['endDoc'],
endTag: handler.endTag || handler['endTag'],
pcdata: handler.pcdata || handler['pcdata'],
rcdata: handler.rcdata || handler['rcdata'],
startDoc: handler.startDoc || handler['startDoc'],
startTag: handler.startTag || handler['startTag']
};
return function(htmlText, param) {
return parse(htmlText, hcopy, param);
};
}
|
javascript
|
function makeSaxParser(handler) {
// Accept quoted or unquoted keys (Closure compat)
var hcopy = {
cdata: handler.cdata || handler['cdata'],
comment: handler.comment || handler['comment'],
endDoc: handler.endDoc || handler['endDoc'],
endTag: handler.endTag || handler['endTag'],
pcdata: handler.pcdata || handler['pcdata'],
rcdata: handler.rcdata || handler['rcdata'],
startDoc: handler.startDoc || handler['startDoc'],
startTag: handler.startTag || handler['startTag']
};
return function(htmlText, param) {
return parse(htmlText, hcopy, param);
};
}
|
[
"function",
"makeSaxParser",
"(",
"handler",
")",
"{",
"// Accept quoted or unquoted keys (Closure compat)",
"var",
"hcopy",
"=",
"{",
"cdata",
":",
"handler",
".",
"cdata",
"||",
"handler",
"[",
"'cdata'",
"]",
",",
"comment",
":",
"handler",
".",
"comment",
"||",
"handler",
"[",
"'comment'",
"]",
",",
"endDoc",
":",
"handler",
".",
"endDoc",
"||",
"handler",
"[",
"'endDoc'",
"]",
",",
"endTag",
":",
"handler",
".",
"endTag",
"||",
"handler",
"[",
"'endTag'",
"]",
",",
"pcdata",
":",
"handler",
".",
"pcdata",
"||",
"handler",
"[",
"'pcdata'",
"]",
",",
"rcdata",
":",
"handler",
".",
"rcdata",
"||",
"handler",
"[",
"'rcdata'",
"]",
",",
"startDoc",
":",
"handler",
".",
"startDoc",
"||",
"handler",
"[",
"'startDoc'",
"]",
",",
"startTag",
":",
"handler",
".",
"startTag",
"||",
"handler",
"[",
"'startTag'",
"]",
"}",
";",
"return",
"function",
"(",
"htmlText",
",",
"param",
")",
"{",
"return",
"parse",
"(",
"htmlText",
",",
"hcopy",
",",
"param",
")",
";",
"}",
";",
"}"
] |
Given a SAX-like event handler, produce a function that feeds those
events and a parameter to the event handler.
The event handler has the form:{@code
{
// Name is an upper-case HTML tag name. Attribs is an array of
// alternating upper-case attribute names, and attribute values. The
// attribs array is reused by the parser. Param is the value passed to
// the saxParser.
startTag: function (name, attribs, param) { ... },
endTag: function (name, param) { ... },
pcdata: function (text, param) { ... },
rcdata: function (text, param) { ... },
cdata: function (text, param) { ... },
startDoc: function (param) { ... },
endDoc: function (param) { ... }
}}
@param {Object} handler a record containing event handlers.
@return {function(string, Object)} A function that takes a chunk of HTML
and a parameter. The parameter is passed on to the handler methods.
|
[
"Given",
"a",
"SAX",
"-",
"like",
"event",
"handler",
"produce",
"a",
"function",
"that",
"feeds",
"those",
"events",
"and",
"a",
"parameter",
"to",
"the",
"event",
"handler",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/vendor/html-css-sanitizer-bundle.js#L4053-L4068
|
19,752
|
CartoDB/carto.js
|
src/api/v4/dataview/time-series/parse-data.js
|
parseTimeSeriesData
|
function parseTimeSeriesData (data, nulls, totalAmount, offset) {
if (!data) {
return null;
}
var compactData = _.compact(data);
var maxBin = _.max(compactData, function (bin) { return bin.freq || 0; });
var maxFreq = _.isFinite(maxBin.freq) && maxBin.freq !== 0
? maxBin.freq
: null;
/**
* @description
* Object containing time series data.
*
* @typedef {object} carto.dataview.TimeSeriesData
* @property {number} nulls - The number of items with null value
* @property {number} totalAmount - The number of elements returned
* @property {number} offset - The time offset in hours. Needed to format UTC timestamps into the proper timezone format
* @property {carto.dataview.TimeSeriesBinItem[]} bins - Array containing the {@link carto.dataview.TimeSeriesBinItem|data bins} for the time series
* @api
*/
return {
bins: _createBins(compactData, maxFreq),
nulls: nulls || 0,
offset: secondsToHours(offset),
totalAmount: totalAmount
};
}
|
javascript
|
function parseTimeSeriesData (data, nulls, totalAmount, offset) {
if (!data) {
return null;
}
var compactData = _.compact(data);
var maxBin = _.max(compactData, function (bin) { return bin.freq || 0; });
var maxFreq = _.isFinite(maxBin.freq) && maxBin.freq !== 0
? maxBin.freq
: null;
/**
* @description
* Object containing time series data.
*
* @typedef {object} carto.dataview.TimeSeriesData
* @property {number} nulls - The number of items with null value
* @property {number} totalAmount - The number of elements returned
* @property {number} offset - The time offset in hours. Needed to format UTC timestamps into the proper timezone format
* @property {carto.dataview.TimeSeriesBinItem[]} bins - Array containing the {@link carto.dataview.TimeSeriesBinItem|data bins} for the time series
* @api
*/
return {
bins: _createBins(compactData, maxFreq),
nulls: nulls || 0,
offset: secondsToHours(offset),
totalAmount: totalAmount
};
}
|
[
"function",
"parseTimeSeriesData",
"(",
"data",
",",
"nulls",
",",
"totalAmount",
",",
"offset",
")",
"{",
"if",
"(",
"!",
"data",
")",
"{",
"return",
"null",
";",
"}",
"var",
"compactData",
"=",
"_",
".",
"compact",
"(",
"data",
")",
";",
"var",
"maxBin",
"=",
"_",
".",
"max",
"(",
"compactData",
",",
"function",
"(",
"bin",
")",
"{",
"return",
"bin",
".",
"freq",
"||",
"0",
";",
"}",
")",
";",
"var",
"maxFreq",
"=",
"_",
".",
"isFinite",
"(",
"maxBin",
".",
"freq",
")",
"&&",
"maxBin",
".",
"freq",
"!==",
"0",
"?",
"maxBin",
".",
"freq",
":",
"null",
";",
"/**\n * @description\n * Object containing time series data.\n *\n * @typedef {object} carto.dataview.TimeSeriesData\n * @property {number} nulls - The number of items with null value\n * @property {number} totalAmount - The number of elements returned\n * @property {number} offset - The time offset in hours. Needed to format UTC timestamps into the proper timezone format\n * @property {carto.dataview.TimeSeriesBinItem[]} bins - Array containing the {@link carto.dataview.TimeSeriesBinItem|data bins} for the time series\n * @api\n */",
"return",
"{",
"bins",
":",
"_createBins",
"(",
"compactData",
",",
"maxFreq",
")",
",",
"nulls",
":",
"nulls",
"||",
"0",
",",
"offset",
":",
"secondsToHours",
"(",
"offset",
")",
",",
"totalAmount",
":",
"totalAmount",
"}",
";",
"}"
] |
Transform the data obtained from an internal timeseries dataview into a public object.
@param {object[]} data - The raw time series data
@param {number} nulls - Number of data with a null
@param {number} totalAmount - Total number of data in the histogram
@return {TimeSeriesData} - The parsed and formatted data for the given parameters
|
[
"Transform",
"the",
"data",
"obtained",
"from",
"an",
"internal",
"timeseries",
"dataview",
"into",
"a",
"public",
"object",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/dataview/time-series/parse-data.js#L16-L43
|
19,753
|
CartoDB/carto.js
|
src/api/v4/source/dataset.js
|
Dataset
|
function Dataset (tableName) {
_checkTableName(tableName);
this._tableName = tableName;
Base.apply(this, arguments);
this._appliedFilters.on('change:filters', () => this._updateInternalModelQuery(this._getQueryToApply()));
}
|
javascript
|
function Dataset (tableName) {
_checkTableName(tableName);
this._tableName = tableName;
Base.apply(this, arguments);
this._appliedFilters.on('change:filters', () => this._updateInternalModelQuery(this._getQueryToApply()));
}
|
[
"function",
"Dataset",
"(",
"tableName",
")",
"{",
"_checkTableName",
"(",
"tableName",
")",
";",
"this",
".",
"_tableName",
"=",
"tableName",
";",
"Base",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"this",
".",
"_appliedFilters",
".",
"on",
"(",
"'change:filters'",
",",
"(",
")",
"=>",
"this",
".",
"_updateInternalModelQuery",
"(",
"this",
".",
"_getQueryToApply",
"(",
")",
")",
")",
";",
"}"
] |
A Dataset that can be used as the data source for layers and dataviews.
@param {string} tableName The name of an existing table
@example
new carto.source.Dataset('european_cities');
@constructor
@fires error
@extends carto.source.Base
@memberof carto.source
@api
|
[
"A",
"Dataset",
"that",
"can",
"be",
"used",
"as",
"the",
"data",
"source",
"for",
"layers",
"and",
"dataviews",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/source/dataset.js#L20-L27
|
19,754
|
CartoDB/carto.js
|
src/api/v4/dataview/histogram/index.js
|
Histogram
|
function Histogram (source, column, options) {
this._initialize(source, column, options);
this._bins = this._options.bins;
this._start = this._options.start;
this._end = this._options.end;
}
|
javascript
|
function Histogram (source, column, options) {
this._initialize(source, column, options);
this._bins = this._options.bins;
this._start = this._options.start;
this._end = this._options.end;
}
|
[
"function",
"Histogram",
"(",
"source",
",",
"column",
",",
"options",
")",
"{",
"this",
".",
"_initialize",
"(",
"source",
",",
"column",
",",
"options",
")",
";",
"this",
".",
"_bins",
"=",
"this",
".",
"_options",
".",
"bins",
";",
"this",
".",
"_start",
"=",
"this",
".",
"_options",
".",
"start",
";",
"this",
".",
"_end",
"=",
"this",
".",
"_options",
".",
"end",
";",
"}"
] |
A histogram is used to represent the distribution of numerical data.
See {@link https://en.wikipedia.org/wiki/Histogram}.
@param {carto.source.Base} source - The source where the dataview will fetch the data
@param {string} column - The column name to get the data
@param {object} [options]
@param {number} [options.bins=10] - Number of bins to aggregate the data range into
@param {number} [options.start] - Lower limit of the data range, if not present, the lower limit of the actual data will be used. Start and end values must be used together.
@param {number} [options.end] - Upper limit of the data range, if not present, the upper limit of the actual data will be used. Start and end values must be used together.
@fires dataChanged
@fires columnChanged
@fires statusChanged
@fires error
@fires binsChanged
@constructor
@extends carto.dataview.Base
@memberof carto.dataview
@api
@example
// Create a cities population histogram.
var histogram = new carto.dataview.Histogram(citiesSource, 'population');
// Set up a callback to render the histogram data every time new data is obtained.
histogram.on('dataChanged', renderData);
// Add the histogram to the client
client.addDataview(histogram);
@example
// Create a cities population histogram with only 4 bins
var histogram = new carto.dataview.Histogram(citiesSource, 'population', {bins: 4});
// Add a bounding box filter, so the data will change when the map is moved.
var bboxFilter = new carto.filter.BoundingBoxLeaflet(map);
// Set up a callback to render the histogram data every time new data is obtained.
histogram.on('dataChanged', histogramData => {
console.log(histogramData);
});
// Add the histogram to the client
client.addDataview(histogram);
@example
// Create a cities population histogram with a range
var histogram = new carto.dataview.Histogram(citiesSource, 'population', { start: 100000, end: 5000000 });
// Set up a callback to render the histogram data every time new data is obtained.
histogram.on('dataChanged', histogramData => {
console.log(histogramData);
});
// Add the histogram to the client
client.addDataview(histogram);
@example
// The histogram is an async object so it can be on different states: LOADING, ERROR...
// Listen to state events
histogram.on('statusChanged', (newStatus, error) => { });
// Listen to histogram errors
histogram.on('error', error => { });
|
[
"A",
"histogram",
"is",
"used",
"to",
"represent",
"the",
"distribution",
"of",
"numerical",
"data",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/dataview/histogram/index.js#L63-L68
|
19,755
|
CartoDB/carto.js
|
src/vis/infowindow-manager.js
|
function (deps, options) {
deps = deps || {};
options = options || {};
if (!deps.engine) throw new Error('engine is required');
if (!deps.mapModel) throw new Error('mapModel is required');
if (!deps.infowindowModel) throw new Error('infowindowModel is required');
if (!deps.tooltipModel) throw new Error('tooltipModel is required');
this._engine = deps.engine;
this._mapModel = deps.mapModel;
this._infowindowModel = deps.infowindowModel;
this._tooltipModel = deps.tooltipModel;
this._showEmptyFields = !!options.showEmptyFields;
this._cartoDBLayerGroupView = null;
this._cartoDBLayerModel = null;
this.currentFeatureUniqueId = null;
this._mapModel.on('change:popupsEnabled', this._onPopupsEnabledChanged, this);
}
|
javascript
|
function (deps, options) {
deps = deps || {};
options = options || {};
if (!deps.engine) throw new Error('engine is required');
if (!deps.mapModel) throw new Error('mapModel is required');
if (!deps.infowindowModel) throw new Error('infowindowModel is required');
if (!deps.tooltipModel) throw new Error('tooltipModel is required');
this._engine = deps.engine;
this._mapModel = deps.mapModel;
this._infowindowModel = deps.infowindowModel;
this._tooltipModel = deps.tooltipModel;
this._showEmptyFields = !!options.showEmptyFields;
this._cartoDBLayerGroupView = null;
this._cartoDBLayerModel = null;
this.currentFeatureUniqueId = null;
this._mapModel.on('change:popupsEnabled', this._onPopupsEnabledChanged, this);
}
|
[
"function",
"(",
"deps",
",",
"options",
")",
"{",
"deps",
"=",
"deps",
"||",
"{",
"}",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"!",
"deps",
".",
"engine",
")",
"throw",
"new",
"Error",
"(",
"'engine is required'",
")",
";",
"if",
"(",
"!",
"deps",
".",
"mapModel",
")",
"throw",
"new",
"Error",
"(",
"'mapModel is required'",
")",
";",
"if",
"(",
"!",
"deps",
".",
"infowindowModel",
")",
"throw",
"new",
"Error",
"(",
"'infowindowModel is required'",
")",
";",
"if",
"(",
"!",
"deps",
".",
"tooltipModel",
")",
"throw",
"new",
"Error",
"(",
"'tooltipModel is required'",
")",
";",
"this",
".",
"_engine",
"=",
"deps",
".",
"engine",
";",
"this",
".",
"_mapModel",
"=",
"deps",
".",
"mapModel",
";",
"this",
".",
"_infowindowModel",
"=",
"deps",
".",
"infowindowModel",
";",
"this",
".",
"_tooltipModel",
"=",
"deps",
".",
"tooltipModel",
";",
"this",
".",
"_showEmptyFields",
"=",
"!",
"!",
"options",
".",
"showEmptyFields",
";",
"this",
".",
"_cartoDBLayerGroupView",
"=",
"null",
";",
"this",
".",
"_cartoDBLayerModel",
"=",
"null",
";",
"this",
".",
"currentFeatureUniqueId",
"=",
"null",
";",
"this",
".",
"_mapModel",
".",
"on",
"(",
"'change:popupsEnabled'",
",",
"this",
".",
"_onPopupsEnabledChanged",
",",
"this",
")",
";",
"}"
] |
Manages the infowindows for a map. It listens to events triggered by a
CartoDBLayerGroupView and updates models accordingly
|
[
"Manages",
"the",
"infowindows",
"for",
"a",
"map",
".",
"It",
"listens",
"to",
"events",
"triggered",
"by",
"a",
"CartoDBLayerGroupView",
"and",
"updates",
"models",
"accordingly"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/vis/infowindow-manager.js#L7-L26
|
|
19,756
|
CartoDB/carto.js
|
src/api/v4/filter/bounding-box-leaflet.js
|
BoundingBoxLeaflet
|
function BoundingBoxLeaflet (map) {
if (!_isLeafletMap(map)) {
throw new Error('Bounding box requires a Leaflet map but got: ' + map);
}
// Adapt the Leaflet map to offer unique:
// - getBounds() function
// - 'boundsChanged' event
var mapAdapter = new LeafletBoundingBoxAdapter(map);
// Use the adapter for the internal BoundingBoxFilter model
this._internalModel = new BoundingBoxFilterModel(mapAdapter);
this.listenTo(this._internalModel, 'boundsChanged', this._onBoundsChanged);
}
|
javascript
|
function BoundingBoxLeaflet (map) {
if (!_isLeafletMap(map)) {
throw new Error('Bounding box requires a Leaflet map but got: ' + map);
}
// Adapt the Leaflet map to offer unique:
// - getBounds() function
// - 'boundsChanged' event
var mapAdapter = new LeafletBoundingBoxAdapter(map);
// Use the adapter for the internal BoundingBoxFilter model
this._internalModel = new BoundingBoxFilterModel(mapAdapter);
this.listenTo(this._internalModel, 'boundsChanged', this._onBoundsChanged);
}
|
[
"function",
"BoundingBoxLeaflet",
"(",
"map",
")",
"{",
"if",
"(",
"!",
"_isLeafletMap",
"(",
"map",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Bounding box requires a Leaflet map but got: '",
"+",
"map",
")",
";",
"}",
"// Adapt the Leaflet map to offer unique:",
"// - getBounds() function",
"// - 'boundsChanged' event",
"var",
"mapAdapter",
"=",
"new",
"LeafletBoundingBoxAdapter",
"(",
"map",
")",
";",
"// Use the adapter for the internal BoundingBoxFilter model",
"this",
".",
"_internalModel",
"=",
"new",
"BoundingBoxFilterModel",
"(",
"mapAdapter",
")",
";",
"this",
".",
"listenTo",
"(",
"this",
".",
"_internalModel",
",",
"'boundsChanged'",
",",
"this",
".",
"_onBoundsChanged",
")",
";",
"}"
] |
Bounding box filter for Leaflet maps.
When this filter is included into a dataview only the data inside the {@link http://leafletjs.com/reference-1.3.1.html#map|leafletMap}
bounds will be taken into account.
@param {L.Map} map - The leaflet map view
@fires boundsChanged
@constructor
@extends carto.filter.Base
@memberof carto.filter
@api
@example
// Create a bonding box attached to a leaflet map.
const bboxFilter = new carto.filter.BoundingBoxLeaflet(leafletMap);
// Add the filter to a dataview. Generating new data when the map bounds are changed.
dataview.addFilter(bboxFilter);
|
[
"Bounding",
"box",
"filter",
"for",
"Leaflet",
"maps",
"."
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/filter/bounding-box-leaflet.js#L28-L39
|
19,757
|
CartoDB/carto.js
|
src/api/v4/layer/metadata/parser.js
|
getMetadataFromRules
|
function getMetadataFromRules (rulesData) {
var metadata = [];
rulesData.forEach(function (ruleData) {
var rule = new Rule(ruleData);
if (_isBucketsMetadata(rule)) {
metadata.push(new BucketsMetadata(rule));
} else if (_isCategoriesMetadata(rule)) {
metadata.push(new CategoriesMetadata(rule));
}
});
return metadata;
}
|
javascript
|
function getMetadataFromRules (rulesData) {
var metadata = [];
rulesData.forEach(function (ruleData) {
var rule = new Rule(ruleData);
if (_isBucketsMetadata(rule)) {
metadata.push(new BucketsMetadata(rule));
} else if (_isCategoriesMetadata(rule)) {
metadata.push(new CategoriesMetadata(rule));
}
});
return metadata;
}
|
[
"function",
"getMetadataFromRules",
"(",
"rulesData",
")",
"{",
"var",
"metadata",
"=",
"[",
"]",
";",
"rulesData",
".",
"forEach",
"(",
"function",
"(",
"ruleData",
")",
"{",
"var",
"rule",
"=",
"new",
"Rule",
"(",
"ruleData",
")",
";",
"if",
"(",
"_isBucketsMetadata",
"(",
"rule",
")",
")",
"{",
"metadata",
".",
"push",
"(",
"new",
"BucketsMetadata",
"(",
"rule",
")",
")",
";",
"}",
"else",
"if",
"(",
"_isCategoriesMetadata",
"(",
"rule",
")",
")",
"{",
"metadata",
".",
"push",
"(",
"new",
"CategoriesMetadata",
"(",
"rule",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"metadata",
";",
"}"
] |
Generates a list of Metadata objects from the original cartocss_meta rules
@param {Rules} rulesData
@return {metadata.Base[]}
|
[
"Generates",
"a",
"list",
"of",
"Metadata",
"objects",
"from",
"the",
"original",
"cartocss_meta",
"rules"
] |
0b7ca24d7066354de265d07f717ef8b336c7e0ce
|
https://github.com/CartoDB/carto.js/blob/0b7ca24d7066354de265d07f717ef8b336c7e0ce/src/api/v4/layer/metadata/parser.js#L11-L25
|
19,758
|
ma-ha/rest-web-ui
|
html/modules/pong-histogram/pong-histogram.js
|
pongHistogram_UpdateBars
|
function pongHistogram_UpdateBars( divId, dta, xMin, xMax ) {
log( "pongHistogram", "UpdateBars "+divId);
var pmd = moduleConfig[ divId ];
var cnt = ( pmd.blockCount ? pmd.blockCount : 10 );
// get y-axis scaling
var yMax = pmd.yAxisMax;
if ( !yMax || yMax == 'auto' ) {
yMax = 0;
for ( var i = 0; i < cnt; i++ ) {
if ( parseFloat( dta[i][ pmd.dataY ] ) > yMax ) {
yMax = parseFloat( dta[i][ pmd.dataY ] );
}
}
}
var yH = $( '.HistogramBlockContainer' ).height();
log( "pongHistogram", 'yH='+yH);
// scale bars in % height
for ( var i = 0; i < cnt; i++ ) {
//var bar = pongHistogram[ divId ][i];
var h = parseFloat( dta[i][ pmd.dataY ] ) / parseFloat( yMax ) * yH;
h = ( h > 100 ? 100 : h );
log( "pongHistogram", ' bar '+i+' '+ JSON.stringify( dta[i]) + ' '+ pmd.dataY+' '+ pmd.xAxisMax + ' h='+h );
$( '#'+divId+'bar'+i ).height( h+'px' ); // set height of bar
$( '#'+divId+'bar'+i ).attr( 'title', dta[i][ pmd.dataY ]+'#' );
if ( dta[i][ pmd.dataX ] ) { // update label
$( '#'+divId+'xLabel'+i ).html( dta[i][ pmd.dataX ] );
}
}
log( "pongHistogram", 'UpdateBars end' );
return true;
}
|
javascript
|
function pongHistogram_UpdateBars( divId, dta, xMin, xMax ) {
log( "pongHistogram", "UpdateBars "+divId);
var pmd = moduleConfig[ divId ];
var cnt = ( pmd.blockCount ? pmd.blockCount : 10 );
// get y-axis scaling
var yMax = pmd.yAxisMax;
if ( !yMax || yMax == 'auto' ) {
yMax = 0;
for ( var i = 0; i < cnt; i++ ) {
if ( parseFloat( dta[i][ pmd.dataY ] ) > yMax ) {
yMax = parseFloat( dta[i][ pmd.dataY ] );
}
}
}
var yH = $( '.HistogramBlockContainer' ).height();
log( "pongHistogram", 'yH='+yH);
// scale bars in % height
for ( var i = 0; i < cnt; i++ ) {
//var bar = pongHistogram[ divId ][i];
var h = parseFloat( dta[i][ pmd.dataY ] ) / parseFloat( yMax ) * yH;
h = ( h > 100 ? 100 : h );
log( "pongHistogram", ' bar '+i+' '+ JSON.stringify( dta[i]) + ' '+ pmd.dataY+' '+ pmd.xAxisMax + ' h='+h );
$( '#'+divId+'bar'+i ).height( h+'px' ); // set height of bar
$( '#'+divId+'bar'+i ).attr( 'title', dta[i][ pmd.dataY ]+'#' );
if ( dta[i][ pmd.dataX ] ) { // update label
$( '#'+divId+'xLabel'+i ).html( dta[i][ pmd.dataX ] );
}
}
log( "pongHistogram", 'UpdateBars end' );
return true;
}
|
[
"function",
"pongHistogram_UpdateBars",
"(",
"divId",
",",
"dta",
",",
"xMin",
",",
"xMax",
")",
"{",
"log",
"(",
"\"pongHistogram\"",
",",
"\"UpdateBars \"",
"+",
"divId",
")",
";",
"var",
"pmd",
"=",
"moduleConfig",
"[",
"divId",
"]",
";",
"var",
"cnt",
"=",
"(",
"pmd",
".",
"blockCount",
"?",
"pmd",
".",
"blockCount",
":",
"10",
")",
";",
"// get y-axis scaling",
"var",
"yMax",
"=",
"pmd",
".",
"yAxisMax",
";",
"if",
"(",
"!",
"yMax",
"||",
"yMax",
"==",
"'auto'",
")",
"{",
"yMax",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cnt",
";",
"i",
"++",
")",
"{",
"if",
"(",
"parseFloat",
"(",
"dta",
"[",
"i",
"]",
"[",
"pmd",
".",
"dataY",
"]",
")",
">",
"yMax",
")",
"{",
"yMax",
"=",
"parseFloat",
"(",
"dta",
"[",
"i",
"]",
"[",
"pmd",
".",
"dataY",
"]",
")",
";",
"}",
"}",
"}",
"var",
"yH",
"=",
"$",
"(",
"'.HistogramBlockContainer'",
")",
".",
"height",
"(",
")",
";",
"log",
"(",
"\"pongHistogram\"",
",",
"'yH='",
"+",
"yH",
")",
";",
"// scale bars in % height",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cnt",
";",
"i",
"++",
")",
"{",
"//var bar = pongHistogram[ divId ][i];",
"var",
"h",
"=",
"parseFloat",
"(",
"dta",
"[",
"i",
"]",
"[",
"pmd",
".",
"dataY",
"]",
")",
"/",
"parseFloat",
"(",
"yMax",
")",
"*",
"yH",
";",
"h",
"=",
"(",
"h",
">",
"100",
"?",
"100",
":",
"h",
")",
";",
"log",
"(",
"\"pongHistogram\"",
",",
"' bar '",
"+",
"i",
"+",
"' '",
"+",
"JSON",
".",
"stringify",
"(",
"dta",
"[",
"i",
"]",
")",
"+",
"' '",
"+",
"pmd",
".",
"dataY",
"+",
"' '",
"+",
"pmd",
".",
"xAxisMax",
"+",
"' h='",
"+",
"h",
")",
";",
"$",
"(",
"'#'",
"+",
"divId",
"+",
"'bar'",
"+",
"i",
")",
".",
"height",
"(",
"h",
"+",
"'px'",
")",
";",
"// set height of bar",
"$",
"(",
"'#'",
"+",
"divId",
"+",
"'bar'",
"+",
"i",
")",
".",
"attr",
"(",
"'title'",
",",
"dta",
"[",
"i",
"]",
"[",
"pmd",
".",
"dataY",
"]",
"+",
"'#'",
")",
";",
"if",
"(",
"dta",
"[",
"i",
"]",
"[",
"pmd",
".",
"dataX",
"]",
")",
"{",
"// update label",
"$",
"(",
"'#'",
"+",
"divId",
"+",
"'xLabel'",
"+",
"i",
")",
".",
"html",
"(",
"dta",
"[",
"i",
"]",
"[",
"pmd",
".",
"dataX",
"]",
")",
";",
"}",
"}",
"log",
"(",
"\"pongHistogram\"",
",",
"'UpdateBars end'",
")",
";",
"return",
"true",
";",
"}"
] |
Change labels an height of histogram bars
|
[
"Change",
"labels",
"an",
"height",
"of",
"histogram",
"bars"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-histogram/pong-histogram.js#L110-L143
|
19,759
|
ma-ha/rest-web-ui
|
html/js/portal-ng.js
|
loadIncludes
|
function loadIncludes() {
for ( var module in reqModules ) {
if ( module && module != 'pong-tableXX' ) { // just to exclude modules, for debugging it's better to include them hardcoded in index.html
// extra CSS files
if ( moduleMap[ module ] ) {
if ( moduleMap[ module ].css ) {
for ( var i = 0; i < moduleMap[ module ].css.length; i++ ) {
log( 'loadModules', module+' add extra CSS: '+modulesPath+module+'/'+moduleMap[ module ].css[i] );
jQuery('head').append('<link rel="stylesheet" rel="nofollow" href="'+modulesPath+module+'/'+moduleMap[ module ].css[i] +'" type="text/css" />');
}
}
// include files
if ( moduleMap[ module ].include ) {
for ( var i = 0; i < moduleMap[ module ].include.length; i++ ) {
//for ( var includeJS in moduleMap[ module ].include ) {
var includeJS = moduleMap[ module ].include[i];
log( 'loadModules', module+' load include: '+modulesPath+module+'/'+includeJS );
ajaxOngoing++;
$.getScript( modulesPath+module+'/'+includeJS )
.done( function( script, textStatus, jqxhr ) {
log( 'loadModules', this.url+' '+textStatus ); ajaxOngoing--; } )
.fail( function( jqxhr, settings, exception ) {
log( 'loadModules', this.url+' '+exception ); ajaxOngoing--; } );
}
}
}
}
}
ajaxOngoing--;
}
|
javascript
|
function loadIncludes() {
for ( var module in reqModules ) {
if ( module && module != 'pong-tableXX' ) { // just to exclude modules, for debugging it's better to include them hardcoded in index.html
// extra CSS files
if ( moduleMap[ module ] ) {
if ( moduleMap[ module ].css ) {
for ( var i = 0; i < moduleMap[ module ].css.length; i++ ) {
log( 'loadModules', module+' add extra CSS: '+modulesPath+module+'/'+moduleMap[ module ].css[i] );
jQuery('head').append('<link rel="stylesheet" rel="nofollow" href="'+modulesPath+module+'/'+moduleMap[ module ].css[i] +'" type="text/css" />');
}
}
// include files
if ( moduleMap[ module ].include ) {
for ( var i = 0; i < moduleMap[ module ].include.length; i++ ) {
//for ( var includeJS in moduleMap[ module ].include ) {
var includeJS = moduleMap[ module ].include[i];
log( 'loadModules', module+' load include: '+modulesPath+module+'/'+includeJS );
ajaxOngoing++;
$.getScript( modulesPath+module+'/'+includeJS )
.done( function( script, textStatus, jqxhr ) {
log( 'loadModules', this.url+' '+textStatus ); ajaxOngoing--; } )
.fail( function( jqxhr, settings, exception ) {
log( 'loadModules', this.url+' '+exception ); ajaxOngoing--; } );
}
}
}
}
}
ajaxOngoing--;
}
|
[
"function",
"loadIncludes",
"(",
")",
"{",
"for",
"(",
"var",
"module",
"in",
"reqModules",
")",
"{",
"if",
"(",
"module",
"&&",
"module",
"!=",
"'pong-tableXX'",
")",
"{",
"// just to exclude modules, for debugging it's better to include them hardcoded in index.html",
"// extra CSS files",
"if",
"(",
"moduleMap",
"[",
"module",
"]",
")",
"{",
"if",
"(",
"moduleMap",
"[",
"module",
"]",
".",
"css",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"moduleMap",
"[",
"module",
"]",
".",
"css",
".",
"length",
";",
"i",
"++",
")",
"{",
"log",
"(",
"'loadModules'",
",",
"module",
"+",
"' add extra CSS: '",
"+",
"modulesPath",
"+",
"module",
"+",
"'/'",
"+",
"moduleMap",
"[",
"module",
"]",
".",
"css",
"[",
"i",
"]",
")",
";",
"jQuery",
"(",
"'head'",
")",
".",
"append",
"(",
"'<link rel=\"stylesheet\" rel=\"nofollow\" href=\"'",
"+",
"modulesPath",
"+",
"module",
"+",
"'/'",
"+",
"moduleMap",
"[",
"module",
"]",
".",
"css",
"[",
"i",
"]",
"+",
"'\" type=\"text/css\" />'",
")",
";",
"}",
"}",
"// include files",
"if",
"(",
"moduleMap",
"[",
"module",
"]",
".",
"include",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"moduleMap",
"[",
"module",
"]",
".",
"include",
".",
"length",
";",
"i",
"++",
")",
"{",
"//for ( var includeJS in moduleMap[ module ].include ) {",
"var",
"includeJS",
"=",
"moduleMap",
"[",
"module",
"]",
".",
"include",
"[",
"i",
"]",
";",
"log",
"(",
"'loadModules'",
",",
"module",
"+",
"' load include: '",
"+",
"modulesPath",
"+",
"module",
"+",
"'/'",
"+",
"includeJS",
")",
";",
"ajaxOngoing",
"++",
";",
"$",
".",
"getScript",
"(",
"modulesPath",
"+",
"module",
"+",
"'/'",
"+",
"includeJS",
")",
".",
"done",
"(",
"function",
"(",
"script",
",",
"textStatus",
",",
"jqxhr",
")",
"{",
"log",
"(",
"'loadModules'",
",",
"this",
".",
"url",
"+",
"' '",
"+",
"textStatus",
")",
";",
"ajaxOngoing",
"--",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
"jqxhr",
",",
"settings",
",",
"exception",
")",
"{",
"log",
"(",
"'loadModules'",
",",
"this",
".",
"url",
"+",
"' '",
"+",
"exception",
")",
";",
"ajaxOngoing",
"--",
";",
"}",
")",
";",
"}",
"}",
"}",
"}",
"}",
"ajaxOngoing",
"--",
";",
"}"
] |
load includes for modules
|
[
"load",
"includes",
"for",
"modules"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/portal-ng.js#L506-L537
|
19,760
|
ma-ha/rest-web-ui
|
html/js/portal-ng.js
|
getUrlGETparams
|
function getUrlGETparams() {
var vars = {}, hash;
var hashes = window.location.href.slice( window.location.href.indexOf('?') + 1 ).split('&');
for( var i = 0; i < hashes.length; i++ ) {
hash = hashes[i].split('=');
vars[ hash[0] ] = hash[1];
// switch on console logging
if ( hash[0] == 'info') { logInfo = true }
if ( hash[0] == 'info' && hash[1] && hash[1] != '') { logInfoStr = hash[1] }
}
//alert( JSON.stringify( vars ) );
return vars;
}
|
javascript
|
function getUrlGETparams() {
var vars = {}, hash;
var hashes = window.location.href.slice( window.location.href.indexOf('?') + 1 ).split('&');
for( var i = 0; i < hashes.length; i++ ) {
hash = hashes[i].split('=');
vars[ hash[0] ] = hash[1];
// switch on console logging
if ( hash[0] == 'info') { logInfo = true }
if ( hash[0] == 'info' && hash[1] && hash[1] != '') { logInfoStr = hash[1] }
}
//alert( JSON.stringify( vars ) );
return vars;
}
|
[
"function",
"getUrlGETparams",
"(",
")",
"{",
"var",
"vars",
"=",
"{",
"}",
",",
"hash",
";",
"var",
"hashes",
"=",
"window",
".",
"location",
".",
"href",
".",
"slice",
"(",
"window",
".",
"location",
".",
"href",
".",
"indexOf",
"(",
"'?'",
")",
"+",
"1",
")",
".",
"split",
"(",
"'&'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"hashes",
".",
"length",
";",
"i",
"++",
")",
"{",
"hash",
"=",
"hashes",
"[",
"i",
"]",
".",
"split",
"(",
"'='",
")",
";",
"vars",
"[",
"hash",
"[",
"0",
"]",
"]",
"=",
"hash",
"[",
"1",
"]",
";",
"// switch on console logging",
"if",
"(",
"hash",
"[",
"0",
"]",
"==",
"'info'",
")",
"{",
"logInfo",
"=",
"true",
"}",
"if",
"(",
"hash",
"[",
"0",
"]",
"==",
"'info'",
"&&",
"hash",
"[",
"1",
"]",
"&&",
"hash",
"[",
"1",
"]",
"!=",
"''",
")",
"{",
"logInfoStr",
"=",
"hash",
"[",
"1",
"]",
"}",
"}",
"//alert( JSON.stringify( vars ) );",
"return",
"vars",
";",
"}"
] |
Read a page's GET URL variables and return them as an object.
|
[
"Read",
"a",
"page",
"s",
"GET",
"URL",
"variables",
"and",
"return",
"them",
"as",
"an",
"object",
"."
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/portal-ng.js#L1463-L1475
|
19,761
|
ma-ha/rest-web-ui
|
html/js/portal-ng.js
|
publishEvent
|
function publishEvent( channelName, eventObj ) {
var broker = getEventBroker( 'main' )
eventObj.channel = channelName
broker.publish( eventObj );
}
|
javascript
|
function publishEvent( channelName, eventObj ) {
var broker = getEventBroker( 'main' )
eventObj.channel = channelName
broker.publish( eventObj );
}
|
[
"function",
"publishEvent",
"(",
"channelName",
",",
"eventObj",
")",
"{",
"var",
"broker",
"=",
"getEventBroker",
"(",
"'main'",
")",
"eventObj",
".",
"channel",
"=",
"channelName",
"broker",
".",
"publish",
"(",
"eventObj",
")",
";",
"}"
] |
short cut function
|
[
"short",
"cut",
"function"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/portal-ng.js#L1600-L1604
|
19,762
|
ma-ha/rest-web-ui
|
html/modules/pong-feedback/pong-feedback.js
|
feedbackEvtCallback
|
function feedbackEvtCallback( evt ) {
log( "pong-feedback", "feedbackEvtCallback" )
if ( evt && evt.text ) {
log( "pong-feedback", "feedbackEvtCallback "+evt.text )
if ( pongLastFeedbackTxt.indexOf( evt.text ) >= 0 ) {
if ( evt.text.length > 0 ) {
var feedbackTxt = $.i18n( evt.text )
var evtNo = pongLastFeedbackTxt.indexOf( feedbackTxt )
pongLastFeedbackCnt[evtNo] = pongLastFeedbackCnt[evtNo] + 1
pongLastFeedbackTim[evtNo] = new Date()
moveToLastFeetback( evtNo )
}
} else {
if ( evt.text.length > 0 ) {
var feedbackTxt = $.i18n( evt.text )
pongLastFeedbackTxt.shift()
pongLastFeedbackTxt.push( feedbackTxt )
pongLastFeedbackCnt.shift()
pongLastFeedbackCnt.push( 1 )
pongLastFeedbackTim.shift()
pongLastFeedbackTim.push( new Date() )
}
}
}
updateFeedback()
}
|
javascript
|
function feedbackEvtCallback( evt ) {
log( "pong-feedback", "feedbackEvtCallback" )
if ( evt && evt.text ) {
log( "pong-feedback", "feedbackEvtCallback "+evt.text )
if ( pongLastFeedbackTxt.indexOf( evt.text ) >= 0 ) {
if ( evt.text.length > 0 ) {
var feedbackTxt = $.i18n( evt.text )
var evtNo = pongLastFeedbackTxt.indexOf( feedbackTxt )
pongLastFeedbackCnt[evtNo] = pongLastFeedbackCnt[evtNo] + 1
pongLastFeedbackTim[evtNo] = new Date()
moveToLastFeetback( evtNo )
}
} else {
if ( evt.text.length > 0 ) {
var feedbackTxt = $.i18n( evt.text )
pongLastFeedbackTxt.shift()
pongLastFeedbackTxt.push( feedbackTxt )
pongLastFeedbackCnt.shift()
pongLastFeedbackCnt.push( 1 )
pongLastFeedbackTim.shift()
pongLastFeedbackTim.push( new Date() )
}
}
}
updateFeedback()
}
|
[
"function",
"feedbackEvtCallback",
"(",
"evt",
")",
"{",
"log",
"(",
"\"pong-feedback\"",
",",
"\"feedbackEvtCallback\"",
")",
"if",
"(",
"evt",
"&&",
"evt",
".",
"text",
")",
"{",
"log",
"(",
"\"pong-feedback\"",
",",
"\"feedbackEvtCallback \"",
"+",
"evt",
".",
"text",
")",
"if",
"(",
"pongLastFeedbackTxt",
".",
"indexOf",
"(",
"evt",
".",
"text",
")",
">=",
"0",
")",
"{",
"if",
"(",
"evt",
".",
"text",
".",
"length",
">",
"0",
")",
"{",
"var",
"feedbackTxt",
"=",
"$",
".",
"i18n",
"(",
"evt",
".",
"text",
")",
"var",
"evtNo",
"=",
"pongLastFeedbackTxt",
".",
"indexOf",
"(",
"feedbackTxt",
")",
"pongLastFeedbackCnt",
"[",
"evtNo",
"]",
"=",
"pongLastFeedbackCnt",
"[",
"evtNo",
"]",
"+",
"1",
"pongLastFeedbackTim",
"[",
"evtNo",
"]",
"=",
"new",
"Date",
"(",
")",
"moveToLastFeetback",
"(",
"evtNo",
")",
"}",
"}",
"else",
"{",
"if",
"(",
"evt",
".",
"text",
".",
"length",
">",
"0",
")",
"{",
"var",
"feedbackTxt",
"=",
"$",
".",
"i18n",
"(",
"evt",
".",
"text",
")",
"pongLastFeedbackTxt",
".",
"shift",
"(",
")",
"pongLastFeedbackTxt",
".",
"push",
"(",
"feedbackTxt",
")",
"pongLastFeedbackCnt",
".",
"shift",
"(",
")",
"pongLastFeedbackCnt",
".",
"push",
"(",
"1",
")",
"pongLastFeedbackTim",
".",
"shift",
"(",
")",
"pongLastFeedbackTim",
".",
"push",
"(",
"new",
"Date",
"(",
")",
")",
"}",
"}",
"}",
"updateFeedback",
"(",
")",
"}"
] |
The callback is subscribed for feedback events
|
[
"The",
"callback",
"is",
"subscribed",
"for",
"feedback",
"events"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-feedback/pong-feedback.js#L51-L79
|
19,763
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.language.js
|
function ( count, forms ) {
var pluralRules,
pluralFormIndex,
index,
explicitPluralPattern = new RegExp('\\d+=', 'i'),
formCount,
form;
if ( !forms || forms.length === 0 ) {
return '';
}
// Handle for Explicit 0= & 1= values
for ( index = 0; index < forms.length; index++ ) {
form = forms[index];
if ( explicitPluralPattern.test( form ) ) {
formCount = parseInt( form.substring( 0, form.indexOf( '=' ) ), 10 );
if ( formCount === count ) {
return ( form.substr( form.indexOf( '=' ) + 1 ) );
}
forms[index] = undefined;
}
}
forms = $.map( forms, function ( form ) {
if ( form !== undefined ) {
return form;
}
} );
pluralRules = this.pluralRules[$.i18n().locale];
if ( !pluralRules ) {
// default fallback.
return ( count === 1 ) ? forms[0] : forms[1];
}
pluralFormIndex = this.getPluralForm( count, pluralRules );
pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 );
return forms[pluralFormIndex];
}
|
javascript
|
function ( count, forms ) {
var pluralRules,
pluralFormIndex,
index,
explicitPluralPattern = new RegExp('\\d+=', 'i'),
formCount,
form;
if ( !forms || forms.length === 0 ) {
return '';
}
// Handle for Explicit 0= & 1= values
for ( index = 0; index < forms.length; index++ ) {
form = forms[index];
if ( explicitPluralPattern.test( form ) ) {
formCount = parseInt( form.substring( 0, form.indexOf( '=' ) ), 10 );
if ( formCount === count ) {
return ( form.substr( form.indexOf( '=' ) + 1 ) );
}
forms[index] = undefined;
}
}
forms = $.map( forms, function ( form ) {
if ( form !== undefined ) {
return form;
}
} );
pluralRules = this.pluralRules[$.i18n().locale];
if ( !pluralRules ) {
// default fallback.
return ( count === 1 ) ? forms[0] : forms[1];
}
pluralFormIndex = this.getPluralForm( count, pluralRules );
pluralFormIndex = Math.min( pluralFormIndex, forms.length - 1 );
return forms[pluralFormIndex];
}
|
[
"function",
"(",
"count",
",",
"forms",
")",
"{",
"var",
"pluralRules",
",",
"pluralFormIndex",
",",
"index",
",",
"explicitPluralPattern",
"=",
"new",
"RegExp",
"(",
"'\\\\d+='",
",",
"'i'",
")",
",",
"formCount",
",",
"form",
";",
"if",
"(",
"!",
"forms",
"||",
"forms",
".",
"length",
"===",
"0",
")",
"{",
"return",
"''",
";",
"}",
"// Handle for Explicit 0= & 1= values",
"for",
"(",
"index",
"=",
"0",
";",
"index",
"<",
"forms",
".",
"length",
";",
"index",
"++",
")",
"{",
"form",
"=",
"forms",
"[",
"index",
"]",
";",
"if",
"(",
"explicitPluralPattern",
".",
"test",
"(",
"form",
")",
")",
"{",
"formCount",
"=",
"parseInt",
"(",
"form",
".",
"substring",
"(",
"0",
",",
"form",
".",
"indexOf",
"(",
"'='",
")",
")",
",",
"10",
")",
";",
"if",
"(",
"formCount",
"===",
"count",
")",
"{",
"return",
"(",
"form",
".",
"substr",
"(",
"form",
".",
"indexOf",
"(",
"'='",
")",
"+",
"1",
")",
")",
";",
"}",
"forms",
"[",
"index",
"]",
"=",
"undefined",
";",
"}",
"}",
"forms",
"=",
"$",
".",
"map",
"(",
"forms",
",",
"function",
"(",
"form",
")",
"{",
"if",
"(",
"form",
"!==",
"undefined",
")",
"{",
"return",
"form",
";",
"}",
"}",
")",
";",
"pluralRules",
"=",
"this",
".",
"pluralRules",
"[",
"$",
".",
"i18n",
"(",
")",
".",
"locale",
"]",
";",
"if",
"(",
"!",
"pluralRules",
")",
"{",
"// default fallback.",
"return",
"(",
"count",
"===",
"1",
")",
"?",
"forms",
"[",
"0",
"]",
":",
"forms",
"[",
"1",
"]",
";",
"}",
"pluralFormIndex",
"=",
"this",
".",
"getPluralForm",
"(",
"count",
",",
"pluralRules",
")",
";",
"pluralFormIndex",
"=",
"Math",
".",
"min",
"(",
"pluralFormIndex",
",",
"forms",
".",
"length",
"-",
"1",
")",
";",
"return",
"forms",
"[",
"pluralFormIndex",
"]",
";",
"}"
] |
Plural form transformations, needed for some languages.
@param count
integer Non-localized quantifier
@param forms
array List of plural forms
@return string Correct form for quantifier in this language
|
[
"Plural",
"form",
"transformations",
"needed",
"for",
"some",
"languages",
"."
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.language.js#L273-L314
|
|
19,764
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.language.js
|
function ( number, pluralRules ) {
var i,
pluralForms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ],
pluralFormIndex = 0;
for ( i = 0; i < pluralForms.length; i++ ) {
if ( pluralRules[pluralForms[i]] ) {
if ( pluralRuleParser( pluralRules[pluralForms[i]], number ) ) {
return pluralFormIndex;
}
pluralFormIndex++;
}
}
return pluralFormIndex;
}
|
javascript
|
function ( number, pluralRules ) {
var i,
pluralForms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ],
pluralFormIndex = 0;
for ( i = 0; i < pluralForms.length; i++ ) {
if ( pluralRules[pluralForms[i]] ) {
if ( pluralRuleParser( pluralRules[pluralForms[i]], number ) ) {
return pluralFormIndex;
}
pluralFormIndex++;
}
}
return pluralFormIndex;
}
|
[
"function",
"(",
"number",
",",
"pluralRules",
")",
"{",
"var",
"i",
",",
"pluralForms",
"=",
"[",
"'zero'",
",",
"'one'",
",",
"'two'",
",",
"'few'",
",",
"'many'",
",",
"'other'",
"]",
",",
"pluralFormIndex",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"pluralForms",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pluralRules",
"[",
"pluralForms",
"[",
"i",
"]",
"]",
")",
"{",
"if",
"(",
"pluralRuleParser",
"(",
"pluralRules",
"[",
"pluralForms",
"[",
"i",
"]",
"]",
",",
"number",
")",
")",
"{",
"return",
"pluralFormIndex",
";",
"}",
"pluralFormIndex",
"++",
";",
"}",
"}",
"return",
"pluralFormIndex",
";",
"}"
] |
For the number, get the plural for index
@param number
@param pluralRules
@return plural form index
|
[
"For",
"the",
"number",
"get",
"the",
"plural",
"for",
"index"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.language.js#L323-L339
|
|
19,765
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.language.js
|
function ( num, integer ) {
var tmp, item, i,
transformTable, numberString, convertedNumber;
// Set the target Transform table:
transformTable = this.digitTransformTable( $.i18n().locale );
numberString = '' + num;
convertedNumber = '';
if ( !transformTable ) {
return num;
}
// Check if the restore to Latin number flag is set:
if ( integer ) {
if ( parseFloat( num, 10 ) === num ) {
return num;
}
tmp = [];
for ( item in transformTable ) {
tmp[transformTable[item]] = item;
}
transformTable = tmp;
}
for ( i = 0; i < numberString.length; i++ ) {
if ( transformTable[numberString[i]] ) {
convertedNumber += transformTable[numberString[i]];
} else {
convertedNumber += numberString[i];
}
}
return integer ? parseFloat( convertedNumber, 10 ) : convertedNumber;
}
|
javascript
|
function ( num, integer ) {
var tmp, item, i,
transformTable, numberString, convertedNumber;
// Set the target Transform table:
transformTable = this.digitTransformTable( $.i18n().locale );
numberString = '' + num;
convertedNumber = '';
if ( !transformTable ) {
return num;
}
// Check if the restore to Latin number flag is set:
if ( integer ) {
if ( parseFloat( num, 10 ) === num ) {
return num;
}
tmp = [];
for ( item in transformTable ) {
tmp[transformTable[item]] = item;
}
transformTable = tmp;
}
for ( i = 0; i < numberString.length; i++ ) {
if ( transformTable[numberString[i]] ) {
convertedNumber += transformTable[numberString[i]];
} else {
convertedNumber += numberString[i];
}
}
return integer ? parseFloat( convertedNumber, 10 ) : convertedNumber;
}
|
[
"function",
"(",
"num",
",",
"integer",
")",
"{",
"var",
"tmp",
",",
"item",
",",
"i",
",",
"transformTable",
",",
"numberString",
",",
"convertedNumber",
";",
"// Set the target Transform table:",
"transformTable",
"=",
"this",
".",
"digitTransformTable",
"(",
"$",
".",
"i18n",
"(",
")",
".",
"locale",
")",
";",
"numberString",
"=",
"''",
"+",
"num",
";",
"convertedNumber",
"=",
"''",
";",
"if",
"(",
"!",
"transformTable",
")",
"{",
"return",
"num",
";",
"}",
"// Check if the restore to Latin number flag is set:",
"if",
"(",
"integer",
")",
"{",
"if",
"(",
"parseFloat",
"(",
"num",
",",
"10",
")",
"===",
"num",
")",
"{",
"return",
"num",
";",
"}",
"tmp",
"=",
"[",
"]",
";",
"for",
"(",
"item",
"in",
"transformTable",
")",
"{",
"tmp",
"[",
"transformTable",
"[",
"item",
"]",
"]",
"=",
"item",
";",
"}",
"transformTable",
"=",
"tmp",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"numberString",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"transformTable",
"[",
"numberString",
"[",
"i",
"]",
"]",
")",
"{",
"convertedNumber",
"+=",
"transformTable",
"[",
"numberString",
"[",
"i",
"]",
"]",
";",
"}",
"else",
"{",
"convertedNumber",
"+=",
"numberString",
"[",
"i",
"]",
";",
"}",
"}",
"return",
"integer",
"?",
"parseFloat",
"(",
"convertedNumber",
",",
"10",
")",
":",
"convertedNumber",
";",
"}"
] |
Converts a number using digitTransformTable.
@param {number} num Value to be converted
@param {boolean} integer Convert the return value to an integer
|
[
"Converts",
"a",
"number",
"using",
"digitTransformTable",
"."
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.language.js#L347-L384
|
|
19,766
|
ma-ha/rest-web-ui
|
html/modules/pong-search/pong-search.js
|
initializeTheSearch
|
function initializeTheSearch( divId, type , params ) {
if ( params && params.get && params.get.search ) {
//alert( JSON.stringify( moduleConfig[ divId ] ) )
var cfg = moduleConfig[ divId ];
if ( cfg.update ) {
for ( var i= 0; i < cfg.update.length; i++ ) {
var p = {}
p[ cfg.update[i].param ] = params.get.search
//alert( cfg.update[i].id + ' ' +JSON.stringify(p) )
udateModuleData( cfg.update[i].id+'Content', p )
}
}
}
}
|
javascript
|
function initializeTheSearch( divId, type , params ) {
if ( params && params.get && params.get.search ) {
//alert( JSON.stringify( moduleConfig[ divId ] ) )
var cfg = moduleConfig[ divId ];
if ( cfg.update ) {
for ( var i= 0; i < cfg.update.length; i++ ) {
var p = {}
p[ cfg.update[i].param ] = params.get.search
//alert( cfg.update[i].id + ' ' +JSON.stringify(p) )
udateModuleData( cfg.update[i].id+'Content', p )
}
}
}
}
|
[
"function",
"initializeTheSearch",
"(",
"divId",
",",
"type",
",",
"params",
")",
"{",
"if",
"(",
"params",
"&&",
"params",
".",
"get",
"&&",
"params",
".",
"get",
".",
"search",
")",
"{",
"//alert( JSON.stringify( moduleConfig[ divId ] ) )",
"var",
"cfg",
"=",
"moduleConfig",
"[",
"divId",
"]",
";",
"if",
"(",
"cfg",
".",
"update",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cfg",
".",
"update",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"p",
"=",
"{",
"}",
"p",
"[",
"cfg",
".",
"update",
"[",
"i",
"]",
".",
"param",
"]",
"=",
"params",
".",
"get",
".",
"search",
"//alert( cfg.update[i].id + ' ' +JSON.stringify(p) )",
"udateModuleData",
"(",
"cfg",
".",
"update",
"[",
"i",
"]",
".",
"id",
"+",
"'Content'",
",",
"p",
")",
"}",
"}",
"}",
"}"
] |
do the search
|
[
"do",
"the",
"search"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-search/pong-search.js#L46-L59
|
19,767
|
ma-ha/rest-web-ui
|
html/modules/pong-search/pong-search.js
|
addSearchHeaderRenderHtml
|
function addSearchHeaderRenderHtml( divId, type , params, config ) {
log( "PoNG-Search", "add content " );
if ( ! config.page ) return;
var html = [];
var lang = '';
html.push( '<div class="pongSearch" id="'+divId+'">' );
html.push( '<form id="'+divId+'Form">' );
html.push( '<input type="hidden" name="layout" value="'+ config.page + '"/>' );
if ( getParam( 'lang' ) != '' ) {
html.push( '<input type="hidden" name="lang" value="'+ getParam( 'lang' ) + '"/>' );
}
var role = '';
if ( userRole != '' ) {
html.push( '<input type="hidden" name="role" value="'+ getParam( 'role' ) + '"/>' );
}
var title = ( config.title ? config.title : '' );
var name = ( config.name ? config.name : 'search' );
if ( config.label ) {
html.push( '<label class="pongSearchLabel" for="'+divId+'Input">'+$.i18n( config.label )+'</label>' )
}
html.push( '<input id="'+divId+'Input" class="pongSearchInput" title="'+title+'" name="'+name+'" accessKey="s"></input>' )
html.push( '</form>' )
html.push( '<script>' )
//html.push( ' $( function(){ alert("yepp") } );' )
html.push( ' $( "#'+divId+'Form" ).submit( function(event){ } );' )
html.push( '</script>' )
html.push( '</div>' )
$( "#"+divId ).html( html.join( "\n" ) );
}
|
javascript
|
function addSearchHeaderRenderHtml( divId, type , params, config ) {
log( "PoNG-Search", "add content " );
if ( ! config.page ) return;
var html = [];
var lang = '';
html.push( '<div class="pongSearch" id="'+divId+'">' );
html.push( '<form id="'+divId+'Form">' );
html.push( '<input type="hidden" name="layout" value="'+ config.page + '"/>' );
if ( getParam( 'lang' ) != '' ) {
html.push( '<input type="hidden" name="lang" value="'+ getParam( 'lang' ) + '"/>' );
}
var role = '';
if ( userRole != '' ) {
html.push( '<input type="hidden" name="role" value="'+ getParam( 'role' ) + '"/>' );
}
var title = ( config.title ? config.title : '' );
var name = ( config.name ? config.name : 'search' );
if ( config.label ) {
html.push( '<label class="pongSearchLabel" for="'+divId+'Input">'+$.i18n( config.label )+'</label>' )
}
html.push( '<input id="'+divId+'Input" class="pongSearchInput" title="'+title+'" name="'+name+'" accessKey="s"></input>' )
html.push( '</form>' )
html.push( '<script>' )
//html.push( ' $( function(){ alert("yepp") } );' )
html.push( ' $( "#'+divId+'Form" ).submit( function(event){ } );' )
html.push( '</script>' )
html.push( '</div>' )
$( "#"+divId ).html( html.join( "\n" ) );
}
|
[
"function",
"addSearchHeaderRenderHtml",
"(",
"divId",
",",
"type",
",",
"params",
",",
"config",
")",
"{",
"log",
"(",
"\"PoNG-Search\"",
",",
"\"add content \"",
")",
";",
"if",
"(",
"!",
"config",
".",
"page",
")",
"return",
";",
"var",
"html",
"=",
"[",
"]",
";",
"var",
"lang",
"=",
"''",
";",
"html",
".",
"push",
"(",
"'<div class=\"pongSearch\" id=\"'",
"+",
"divId",
"+",
"'\">'",
")",
";",
"html",
".",
"push",
"(",
"'<form id=\"'",
"+",
"divId",
"+",
"'Form\">'",
")",
";",
"html",
".",
"push",
"(",
"'<input type=\"hidden\" name=\"layout\" value=\"'",
"+",
"config",
".",
"page",
"+",
"'\"/>'",
")",
";",
"if",
"(",
"getParam",
"(",
"'lang'",
")",
"!=",
"''",
")",
"{",
"html",
".",
"push",
"(",
"'<input type=\"hidden\" name=\"lang\" value=\"'",
"+",
"getParam",
"(",
"'lang'",
")",
"+",
"'\"/>'",
")",
";",
"}",
"var",
"role",
"=",
"''",
";",
"if",
"(",
"userRole",
"!=",
"''",
")",
"{",
"html",
".",
"push",
"(",
"'<input type=\"hidden\" name=\"role\" value=\"'",
"+",
"getParam",
"(",
"'role'",
")",
"+",
"'\"/>'",
")",
";",
"}",
"var",
"title",
"=",
"(",
"config",
".",
"title",
"?",
"config",
".",
"title",
":",
"''",
")",
";",
"var",
"name",
"=",
"(",
"config",
".",
"name",
"?",
"config",
".",
"name",
":",
"'search'",
")",
";",
"if",
"(",
"config",
".",
"label",
")",
"{",
"html",
".",
"push",
"(",
"'<label class=\"pongSearchLabel\" for=\"'",
"+",
"divId",
"+",
"'Input\">'",
"+",
"$",
".",
"i18n",
"(",
"config",
".",
"label",
")",
"+",
"'</label>'",
")",
"}",
"html",
".",
"push",
"(",
"'<input id=\"'",
"+",
"divId",
"+",
"'Input\" class=\"pongSearchInput\" title=\"'",
"+",
"title",
"+",
"'\" name=\"'",
"+",
"name",
"+",
"'\" accessKey=\"s\"></input>'",
")",
"html",
".",
"push",
"(",
"'</form>'",
")",
"html",
".",
"push",
"(",
"'<script>'",
")",
"//html.push( ' $( function(){ alert(\"yepp\") } );' )",
"html",
".",
"push",
"(",
"' $( \"#'",
"+",
"divId",
"+",
"'Form\" ).submit( function(event){ } );'",
")",
"html",
".",
"push",
"(",
"'</script>'",
")",
"html",
".",
"push",
"(",
"'</div>'",
")",
"$",
"(",
"\"#\"",
"+",
"divId",
")",
".",
"html",
"(",
"html",
".",
"join",
"(",
"\"\\n\"",
")",
")",
";",
"}"
] |
search header html rendering
|
[
"search",
"header",
"html",
"rendering"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-search/pong-search.js#L62-L90
|
19,768
|
ma-ha/rest-web-ui
|
html/modules/pong-sourcecode/pong-sourcecode.js
|
pongSrcCodeDivRenderHTML
|
function pongSrcCodeDivRenderHTML( divId, resourceURL, params, cfg ) {
log( "Pong-SrcCode", "load source code" );
if ( ! cfg.type ) { cfg.type = "plain"; }
$.get( resourceURL, params )
.done(
function ( srcData ) {
jQuerySyntaxInsertCode( divId, srcData, cfg.type, cfg.options||{} );
}
).fail( function() { alert( "Failed to load source code." ) } );
}
|
javascript
|
function pongSrcCodeDivRenderHTML( divId, resourceURL, params, cfg ) {
log( "Pong-SrcCode", "load source code" );
if ( ! cfg.type ) { cfg.type = "plain"; }
$.get( resourceURL, params )
.done(
function ( srcData ) {
jQuerySyntaxInsertCode( divId, srcData, cfg.type, cfg.options||{} );
}
).fail( function() { alert( "Failed to load source code." ) } );
}
|
[
"function",
"pongSrcCodeDivRenderHTML",
"(",
"divId",
",",
"resourceURL",
",",
"params",
",",
"cfg",
")",
"{",
"log",
"(",
"\"Pong-SrcCode\"",
",",
"\"load source code\"",
")",
";",
"if",
"(",
"!",
"cfg",
".",
"type",
")",
"{",
"cfg",
".",
"type",
"=",
"\"plain\"",
";",
"}",
"$",
".",
"get",
"(",
"resourceURL",
",",
"params",
")",
".",
"done",
"(",
"function",
"(",
"srcData",
")",
"{",
"jQuerySyntaxInsertCode",
"(",
"divId",
",",
"srcData",
",",
"cfg",
".",
"type",
",",
"cfg",
".",
"options",
"||",
"{",
"}",
")",
";",
"}",
")",
".",
"fail",
"(",
"function",
"(",
")",
"{",
"alert",
"(",
"\"Failed to load source code.\"",
")",
"}",
")",
";",
"}"
] |
load source code from resourceURL and render view
|
[
"load",
"source",
"code",
"from",
"resourceURL",
"and",
"render",
"view"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-sourcecode/pong-sourcecode.js#L74-L83
|
19,769
|
ma-ha/rest-web-ui
|
html/modules/pong-list/pong-list.js
|
pongListDivHTML
|
function pongListDivHTML( divId, resourceURL, params ) {
log( "PoNG-List", "divId="+divId+" resourceURL="+resourceURL );
pongTableInit( divId, "PongList" );
if ( moduleConfig[ divId ] != null ) {
renderPongListDivHTML( divId, resourceURL, params, moduleConfig[ divId ] );
} else {
$.getJSON(
resourceURL+"/pong-list",
function( tbl ) {
renderPongListDivHTML( divId, resourceURL, params, tbl );
}
);
}
}
|
javascript
|
function pongListDivHTML( divId, resourceURL, params ) {
log( "PoNG-List", "divId="+divId+" resourceURL="+resourceURL );
pongTableInit( divId, "PongList" );
if ( moduleConfig[ divId ] != null ) {
renderPongListDivHTML( divId, resourceURL, params, moduleConfig[ divId ] );
} else {
$.getJSON(
resourceURL+"/pong-list",
function( tbl ) {
renderPongListDivHTML( divId, resourceURL, params, tbl );
}
);
}
}
|
[
"function",
"pongListDivHTML",
"(",
"divId",
",",
"resourceURL",
",",
"params",
")",
"{",
"log",
"(",
"\"PoNG-List\"",
",",
"\"divId=\"",
"+",
"divId",
"+",
"\" resourceURL=\"",
"+",
"resourceURL",
")",
";",
"pongTableInit",
"(",
"divId",
",",
"\"PongList\"",
")",
";",
"if",
"(",
"moduleConfig",
"[",
"divId",
"]",
"!=",
"null",
")",
"{",
"renderPongListDivHTML",
"(",
"divId",
",",
"resourceURL",
",",
"params",
",",
"moduleConfig",
"[",
"divId",
"]",
")",
";",
"}",
"else",
"{",
"$",
".",
"getJSON",
"(",
"resourceURL",
"+",
"\"/pong-list\"",
",",
"function",
"(",
"tbl",
")",
"{",
"renderPongListDivHTML",
"(",
"divId",
",",
"resourceURL",
",",
"params",
",",
"tbl",
")",
";",
"}",
")",
";",
"}",
"}"
] |
This uses heavily pong-table.js functions!!
|
[
"This",
"uses",
"heavily",
"pong",
"-",
"table",
".",
"js",
"functions!!"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-list/pong-list.js#L28-L43
|
19,770
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.messagestore.js
|
function( locale, messages ) {
if ( !this.messages[locale] ) {
this.messages[locale] = messages;
} else {
this.messages[locale] = $.extend( this.messages[locale], messages );
}
}
|
javascript
|
function( locale, messages ) {
if ( !this.messages[locale] ) {
this.messages[locale] = messages;
} else {
this.messages[locale] = $.extend( this.messages[locale], messages );
}
}
|
[
"function",
"(",
"locale",
",",
"messages",
")",
"{",
"if",
"(",
"!",
"this",
".",
"messages",
"[",
"locale",
"]",
")",
"{",
"this",
".",
"messages",
"[",
"locale",
"]",
"=",
"messages",
";",
"}",
"else",
"{",
"this",
".",
"messages",
"[",
"locale",
"]",
"=",
"$",
".",
"extend",
"(",
"this",
".",
"messages",
"[",
"locale",
"]",
",",
"messages",
")",
";",
"}",
"}"
] |
Set messages to the given locale.
If locale exists, add messages to the locale.
@param locale
@param messages
|
[
"Set",
"messages",
"to",
"the",
"given",
"locale",
".",
"If",
"locale",
"exists",
"add",
"messages",
"to",
"the",
"locale",
"."
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.messagestore.js#L91-L97
|
|
19,771
|
ma-ha/rest-web-ui
|
html/modules/pong-on-the-fly/pong-on-the-fly.js
|
pongOnTheFlyAddActionBtn
|
function pongOnTheFlyAddActionBtn(id, modalName, resourceURL, params) {
log( "PoNG-OnTheFly", "modalFormAddActionBtn " + id );
if ( !modalName ) {
modalName = "OnTheFly";
}
var buttonLbl = modalName;
if ( params && params.showConfig ) {
buttonLbl = 'Show the configruation of this view...';
}
var html = "";
log( "PoNG-OnTheFly", "Std Config Dlg: " + modalName );
var icon = "ui-icon-pencil";
var paramsStr = 'null';
if ( params ) {
paramsStr = JSON.stringify( params )
}
var jscall = 'pongOnTheFlyOpenDlg( "' + id + '", "' + modalName + '", "'
+ resourceURL + '",' + paramsStr + ' );'
var width = "600";
if ( params && params.width ) {
width = params.width;
}
var height = "600";
if ( params && params.height ) {
height = params.height;
}
html += '<div id="' + id + modalName + 'Dialog">' + resourceURL + " "
+ modalName + "</div>";
log( "PoNG-OnTheFly", " cfg: height: " + height + ", width: " + width );
html += '<script>'
+ '$(function() { '
+ ' $( "#' + id + modalName + 'Dialog" ).dialog( '
+ ' { autoOpen: false, modal: true, height: '+height+', width: '+width+','
+ ' buttons: { "' + $.i18n( 'Save Configuration' ) + '": '
+ ' function() { '
+ ' pongOnTheFlySave( "'+id+'", "'+modalName+'", "'+resourceURL+'" );'
+ ' $( this ).dialog( "close" ); '
+ ' } } '
+ ' } ); '
+ '} );</script>';
html += '<button id="' + id + modalName + 'Bt">' + $.i18n( buttonLbl )
+ '</button>';
html += '<script> '
+ ' $(function() { '
+ ' $( "#' + id + modalName + 'Bt" ).button( '
+' { icons:{primary: "' + icon + '"}, text: false } '
+' ).click( function() { ' + jscall + ' } ); } ); '
+'</script>';
return html;
}
|
javascript
|
function pongOnTheFlyAddActionBtn(id, modalName, resourceURL, params) {
log( "PoNG-OnTheFly", "modalFormAddActionBtn " + id );
if ( !modalName ) {
modalName = "OnTheFly";
}
var buttonLbl = modalName;
if ( params && params.showConfig ) {
buttonLbl = 'Show the configruation of this view...';
}
var html = "";
log( "PoNG-OnTheFly", "Std Config Dlg: " + modalName );
var icon = "ui-icon-pencil";
var paramsStr = 'null';
if ( params ) {
paramsStr = JSON.stringify( params )
}
var jscall = 'pongOnTheFlyOpenDlg( "' + id + '", "' + modalName + '", "'
+ resourceURL + '",' + paramsStr + ' );'
var width = "600";
if ( params && params.width ) {
width = params.width;
}
var height = "600";
if ( params && params.height ) {
height = params.height;
}
html += '<div id="' + id + modalName + 'Dialog">' + resourceURL + " "
+ modalName + "</div>";
log( "PoNG-OnTheFly", " cfg: height: " + height + ", width: " + width );
html += '<script>'
+ '$(function() { '
+ ' $( "#' + id + modalName + 'Dialog" ).dialog( '
+ ' { autoOpen: false, modal: true, height: '+height+', width: '+width+','
+ ' buttons: { "' + $.i18n( 'Save Configuration' ) + '": '
+ ' function() { '
+ ' pongOnTheFlySave( "'+id+'", "'+modalName+'", "'+resourceURL+'" );'
+ ' $( this ).dialog( "close" ); '
+ ' } } '
+ ' } ); '
+ '} );</script>';
html += '<button id="' + id + modalName + 'Bt">' + $.i18n( buttonLbl )
+ '</button>';
html += '<script> '
+ ' $(function() { '
+ ' $( "#' + id + modalName + 'Bt" ).button( '
+' { icons:{primary: "' + icon + '"}, text: false } '
+' ).click( function() { ' + jscall + ' } ); } ); '
+'</script>';
return html;
}
|
[
"function",
"pongOnTheFlyAddActionBtn",
"(",
"id",
",",
"modalName",
",",
"resourceURL",
",",
"params",
")",
"{",
"log",
"(",
"\"PoNG-OnTheFly\"",
",",
"\"modalFormAddActionBtn \"",
"+",
"id",
")",
";",
"if",
"(",
"!",
"modalName",
")",
"{",
"modalName",
"=",
"\"OnTheFly\"",
";",
"}",
"var",
"buttonLbl",
"=",
"modalName",
";",
"if",
"(",
"params",
"&&",
"params",
".",
"showConfig",
")",
"{",
"buttonLbl",
"=",
"'Show the configruation of this view...'",
";",
"}",
"var",
"html",
"=",
"\"\"",
";",
"log",
"(",
"\"PoNG-OnTheFly\"",
",",
"\"Std Config Dlg: \"",
"+",
"modalName",
")",
";",
"var",
"icon",
"=",
"\"ui-icon-pencil\"",
";",
"var",
"paramsStr",
"=",
"'null'",
";",
"if",
"(",
"params",
")",
"{",
"paramsStr",
"=",
"JSON",
".",
"stringify",
"(",
"params",
")",
"}",
"var",
"jscall",
"=",
"'pongOnTheFlyOpenDlg( \"'",
"+",
"id",
"+",
"'\", \"'",
"+",
"modalName",
"+",
"'\", \"'",
"+",
"resourceURL",
"+",
"'\",'",
"+",
"paramsStr",
"+",
"' );'",
"var",
"width",
"=",
"\"600\"",
";",
"if",
"(",
"params",
"&&",
"params",
".",
"width",
")",
"{",
"width",
"=",
"params",
".",
"width",
";",
"}",
"var",
"height",
"=",
"\"600\"",
";",
"if",
"(",
"params",
"&&",
"params",
".",
"height",
")",
"{",
"height",
"=",
"params",
".",
"height",
";",
"}",
"html",
"+=",
"'<div id=\"'",
"+",
"id",
"+",
"modalName",
"+",
"'Dialog\">'",
"+",
"resourceURL",
"+",
"\" \"",
"+",
"modalName",
"+",
"\"</div>\"",
";",
"log",
"(",
"\"PoNG-OnTheFly\"",
",",
"\" cfg: height: \"",
"+",
"height",
"+",
"\", width: \"",
"+",
"width",
")",
";",
"html",
"+=",
"'<script>'",
"+",
"'$(function() { '",
"+",
"' $( \"#'",
"+",
"id",
"+",
"modalName",
"+",
"'Dialog\" ).dialog( '",
"+",
"' { autoOpen: false, modal: true, height: '",
"+",
"height",
"+",
"', width: '",
"+",
"width",
"+",
"','",
"+",
"' buttons: { \"'",
"+",
"$",
".",
"i18n",
"(",
"'Save Configuration'",
")",
"+",
"'\": '",
"+",
"' function() { '",
"+",
"' pongOnTheFlySave( \"'",
"+",
"id",
"+",
"'\", \"'",
"+",
"modalName",
"+",
"'\", \"'",
"+",
"resourceURL",
"+",
"'\" );'",
"+",
"' $( this ).dialog( \"close\" ); '",
"+",
"' } } '",
"+",
"' } ); '",
"+",
"'} );</script>'",
";",
"html",
"+=",
"'<button id=\"'",
"+",
"id",
"+",
"modalName",
"+",
"'Bt\">'",
"+",
"$",
".",
"i18n",
"(",
"buttonLbl",
")",
"+",
"'</button>'",
";",
"html",
"+=",
"'<script> '",
"+",
"' $(function() { '",
"+",
"' $( \"#'",
"+",
"id",
"+",
"modalName",
"+",
"'Bt\" ).button( '",
"+",
"' { icons:{primary: \"'",
"+",
"icon",
"+",
"'\"}, text: false } '",
"+",
"' ).click( function() { '",
"+",
"jscall",
"+",
"' } ); } ); '",
"+",
"'</script>'",
";",
"return",
"html",
";",
"}"
] |
Init HTML and JS
|
[
"Init",
"HTML",
"and",
"JS"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-on-the-fly/pong-on-the-fly.js#L28-L78
|
19,772
|
ma-ha/rest-web-ui
|
html/modules/pong-on-the-fly/pong-on-the-fly.js
|
pongOnTheFlyCreModalFromMeta
|
function pongOnTheFlyCreModalFromMeta(id, modalName, resourceURL) {
log( "PoNG-OnTheFly", "Create modal view content " + resourceURL );
if ( !modalName ) {
modalName = "OnTheFly";
}
if ( resourceURL ) {
log( "PoNG-OnTheFly", "Get JSON for " + id );
// var jsonCfg = pongOnTheFlyFindSubJSON( layoutOrig, "", sessionInfo[
// id+"OnTheFly" ].resID );
var editName = id + modalName + 'DialogConfig';
var tmplName = id + modalName + 'DialogAssist';
log( "PoNG-OnTheFly", "Add JSON to #" + id + modalName + "Dialog" );
$( '#' + id + modalName + 'Dialog' ).html(
'<form>'
+'<label for="' +editName+ '">View Configuration Editor:</label>'
+'<textarea id="' +editName+ '" class="OnTheFly-ConfField"/>'
+'<label for="' +tmplName + '">Config Copy-Paste Template</label>'
+'<textarea id="' +tmplName+ '" class="OnTheFly-AssistField"/>'
+'</form>' );
$( '#' + id + modalName + 'DialogConfig' ).val(
$.i18n( 'Could not load configuration from' )
+ ' "' + resourceURL + '"' );
$( '#' + id + modalName + 'DialogAssist' ).val(
$.i18n( 'No help available.' ) );
} else {
log( "PoNG-OnTheFly", "WARNING: Configuration issue!" );
}
log( "PoNG-OnTheFly", "Done." );
}
|
javascript
|
function pongOnTheFlyCreModalFromMeta(id, modalName, resourceURL) {
log( "PoNG-OnTheFly", "Create modal view content " + resourceURL );
if ( !modalName ) {
modalName = "OnTheFly";
}
if ( resourceURL ) {
log( "PoNG-OnTheFly", "Get JSON for " + id );
// var jsonCfg = pongOnTheFlyFindSubJSON( layoutOrig, "", sessionInfo[
// id+"OnTheFly" ].resID );
var editName = id + modalName + 'DialogConfig';
var tmplName = id + modalName + 'DialogAssist';
log( "PoNG-OnTheFly", "Add JSON to #" + id + modalName + "Dialog" );
$( '#' + id + modalName + 'Dialog' ).html(
'<form>'
+'<label for="' +editName+ '">View Configuration Editor:</label>'
+'<textarea id="' +editName+ '" class="OnTheFly-ConfField"/>'
+'<label for="' +tmplName + '">Config Copy-Paste Template</label>'
+'<textarea id="' +tmplName+ '" class="OnTheFly-AssistField"/>'
+'</form>' );
$( '#' + id + modalName + 'DialogConfig' ).val(
$.i18n( 'Could not load configuration from' )
+ ' "' + resourceURL + '"' );
$( '#' + id + modalName + 'DialogAssist' ).val(
$.i18n( 'No help available.' ) );
} else {
log( "PoNG-OnTheFly", "WARNING: Configuration issue!" );
}
log( "PoNG-OnTheFly", "Done." );
}
|
[
"function",
"pongOnTheFlyCreModalFromMeta",
"(",
"id",
",",
"modalName",
",",
"resourceURL",
")",
"{",
"log",
"(",
"\"PoNG-OnTheFly\"",
",",
"\"Create modal view content \"",
"+",
"resourceURL",
")",
";",
"if",
"(",
"!",
"modalName",
")",
"{",
"modalName",
"=",
"\"OnTheFly\"",
";",
"}",
"if",
"(",
"resourceURL",
")",
"{",
"log",
"(",
"\"PoNG-OnTheFly\"",
",",
"\"Get JSON for \"",
"+",
"id",
")",
";",
"// var jsonCfg = pongOnTheFlyFindSubJSON( layoutOrig, \"\", sessionInfo[",
"// id+\"OnTheFly\" ].resID );",
"var",
"editName",
"=",
"id",
"+",
"modalName",
"+",
"'DialogConfig'",
";",
"var",
"tmplName",
"=",
"id",
"+",
"modalName",
"+",
"'DialogAssist'",
";",
"log",
"(",
"\"PoNG-OnTheFly\"",
",",
"\"Add JSON to #\"",
"+",
"id",
"+",
"modalName",
"+",
"\"Dialog\"",
")",
";",
"$",
"(",
"'#'",
"+",
"id",
"+",
"modalName",
"+",
"'Dialog'",
")",
".",
"html",
"(",
"'<form>'",
"+",
"'<label for=\"'",
"+",
"editName",
"+",
"'\">View Configuration Editor:</label>'",
"+",
"'<textarea id=\"'",
"+",
"editName",
"+",
"'\" class=\"OnTheFly-ConfField\"/>'",
"+",
"'<label for=\"'",
"+",
"tmplName",
"+",
"'\">Config Copy-Paste Template</label>'",
"+",
"'<textarea id=\"'",
"+",
"tmplName",
"+",
"'\" class=\"OnTheFly-AssistField\"/>'",
"+",
"'</form>'",
")",
";",
"$",
"(",
"'#'",
"+",
"id",
"+",
"modalName",
"+",
"'DialogConfig'",
")",
".",
"val",
"(",
"$",
".",
"i18n",
"(",
"'Could not load configuration from'",
")",
"+",
"' \"'",
"+",
"resourceURL",
"+",
"'\"'",
")",
";",
"$",
"(",
"'#'",
"+",
"id",
"+",
"modalName",
"+",
"'DialogAssist'",
")",
".",
"val",
"(",
"$",
".",
"i18n",
"(",
"'No help available.'",
")",
")",
";",
"}",
"else",
"{",
"log",
"(",
"\"PoNG-OnTheFly\"",
",",
"\"WARNING: Configuration issue!\"",
")",
";",
"}",
"log",
"(",
"\"PoNG-OnTheFly\"",
",",
"\"Done.\"",
")",
";",
"}"
] |
creae modal dialog from
|
[
"creae",
"modal",
"dialog",
"from"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-on-the-fly/pong-on-the-fly.js#L127-L157
|
19,773
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.js
|
function () {
var i18n = this;
// Set locale of String environment
String.locale = i18n.locale;
// Override String.localeString method
String.prototype.toLocaleString = function () {
var localeParts, localePartIndex, value, locale, fallbackIndex,
tryingLocale, message;
value = this.valueOf();
locale = i18n.locale;
fallbackIndex = 0;
while ( locale ) {
// Iterate through locales starting at most-specific until
// localization is found. As in fi-Latn-FI, fi-Latn and fi.
localeParts = locale.split( '-' );
localePartIndex = localeParts.length;
do {
tryingLocale = localeParts.slice( 0, localePartIndex ).join( '-' );
message = i18n.messageStore.get( tryingLocale, value );
if ( message ) {
return message;
}
localePartIndex--;
} while ( localePartIndex );
if ( locale === 'en' ) {
break;
}
locale = ( $.i18n.fallbacks[i18n.locale] && $.i18n.fallbacks[i18n.locale][fallbackIndex] ) ||
i18n.options.fallbackLocale;
$.i18n.log( 'Trying fallback locale for ' + i18n.locale + ': ' + locale );
fallbackIndex++;
}
// key not found
return '';
};
}
|
javascript
|
function () {
var i18n = this;
// Set locale of String environment
String.locale = i18n.locale;
// Override String.localeString method
String.prototype.toLocaleString = function () {
var localeParts, localePartIndex, value, locale, fallbackIndex,
tryingLocale, message;
value = this.valueOf();
locale = i18n.locale;
fallbackIndex = 0;
while ( locale ) {
// Iterate through locales starting at most-specific until
// localization is found. As in fi-Latn-FI, fi-Latn and fi.
localeParts = locale.split( '-' );
localePartIndex = localeParts.length;
do {
tryingLocale = localeParts.slice( 0, localePartIndex ).join( '-' );
message = i18n.messageStore.get( tryingLocale, value );
if ( message ) {
return message;
}
localePartIndex--;
} while ( localePartIndex );
if ( locale === 'en' ) {
break;
}
locale = ( $.i18n.fallbacks[i18n.locale] && $.i18n.fallbacks[i18n.locale][fallbackIndex] ) ||
i18n.options.fallbackLocale;
$.i18n.log( 'Trying fallback locale for ' + i18n.locale + ': ' + locale );
fallbackIndex++;
}
// key not found
return '';
};
}
|
[
"function",
"(",
")",
"{",
"var",
"i18n",
"=",
"this",
";",
"// Set locale of String environment",
"String",
".",
"locale",
"=",
"i18n",
".",
"locale",
";",
"// Override String.localeString method",
"String",
".",
"prototype",
".",
"toLocaleString",
"=",
"function",
"(",
")",
"{",
"var",
"localeParts",
",",
"localePartIndex",
",",
"value",
",",
"locale",
",",
"fallbackIndex",
",",
"tryingLocale",
",",
"message",
";",
"value",
"=",
"this",
".",
"valueOf",
"(",
")",
";",
"locale",
"=",
"i18n",
".",
"locale",
";",
"fallbackIndex",
"=",
"0",
";",
"while",
"(",
"locale",
")",
"{",
"// Iterate through locales starting at most-specific until",
"// localization is found. As in fi-Latn-FI, fi-Latn and fi.",
"localeParts",
"=",
"locale",
".",
"split",
"(",
"'-'",
")",
";",
"localePartIndex",
"=",
"localeParts",
".",
"length",
";",
"do",
"{",
"tryingLocale",
"=",
"localeParts",
".",
"slice",
"(",
"0",
",",
"localePartIndex",
")",
".",
"join",
"(",
"'-'",
")",
";",
"message",
"=",
"i18n",
".",
"messageStore",
".",
"get",
"(",
"tryingLocale",
",",
"value",
")",
";",
"if",
"(",
"message",
")",
"{",
"return",
"message",
";",
"}",
"localePartIndex",
"--",
";",
"}",
"while",
"(",
"localePartIndex",
")",
";",
"if",
"(",
"locale",
"===",
"'en'",
")",
"{",
"break",
";",
"}",
"locale",
"=",
"(",
"$",
".",
"i18n",
".",
"fallbacks",
"[",
"i18n",
".",
"locale",
"]",
"&&",
"$",
".",
"i18n",
".",
"fallbacks",
"[",
"i18n",
".",
"locale",
"]",
"[",
"fallbackIndex",
"]",
")",
"||",
"i18n",
".",
"options",
".",
"fallbackLocale",
";",
"$",
".",
"i18n",
".",
"log",
"(",
"'Trying fallback locale for '",
"+",
"i18n",
".",
"locale",
"+",
"': '",
"+",
"locale",
")",
";",
"fallbackIndex",
"++",
";",
"}",
"// key not found",
"return",
"''",
";",
"}",
";",
"}"
] |
Initialize by loading locales and setting up
String.prototype.toLocaleString and String.locale.
|
[
"Initialize",
"by",
"loading",
"locales",
"and",
"setting",
"up",
"String",
".",
"prototype",
".",
"toLocaleString",
"and",
"String",
".",
"locale",
"."
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.js#L42-L88
|
|
19,774
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.js
|
function ( key, parameters ) {
var message = key.toLocaleString();
// FIXME: This changes the state of the I18N object,
// should probably not change the 'this.parser' but just
// pass it to the parser.
this.parser.language = $.i18n.languages[$.i18n().locale] || $.i18n.languages['default'];
if( message === '' || message === '*' ) {
if ( ( mode == "php" ) && ( message != '*' ) ) {
$.post( "svc/backend/i18n/", { missing: key, lang : $.i18n().locale , layout : pageInfo["layout"] } );
}
message = key;
}
var result = this.parser.parse( message, parameters );
if ( result.substr(0,6) == 'UTF8: ') result = result.substr(6)
return result;
}
|
javascript
|
function ( key, parameters ) {
var message = key.toLocaleString();
// FIXME: This changes the state of the I18N object,
// should probably not change the 'this.parser' but just
// pass it to the parser.
this.parser.language = $.i18n.languages[$.i18n().locale] || $.i18n.languages['default'];
if( message === '' || message === '*' ) {
if ( ( mode == "php" ) && ( message != '*' ) ) {
$.post( "svc/backend/i18n/", { missing: key, lang : $.i18n().locale , layout : pageInfo["layout"] } );
}
message = key;
}
var result = this.parser.parse( message, parameters );
if ( result.substr(0,6) == 'UTF8: ') result = result.substr(6)
return result;
}
|
[
"function",
"(",
"key",
",",
"parameters",
")",
"{",
"var",
"message",
"=",
"key",
".",
"toLocaleString",
"(",
")",
";",
"// FIXME: This changes the state of the I18N object,",
"// should probably not change the 'this.parser' but just",
"// pass it to the parser.",
"this",
".",
"parser",
".",
"language",
"=",
"$",
".",
"i18n",
".",
"languages",
"[",
"$",
".",
"i18n",
"(",
")",
".",
"locale",
"]",
"||",
"$",
".",
"i18n",
".",
"languages",
"[",
"'default'",
"]",
";",
"if",
"(",
"message",
"===",
"''",
"||",
"message",
"===",
"'*'",
")",
"{",
"if",
"(",
"(",
"mode",
"==",
"\"php\"",
")",
"&&",
"(",
"message",
"!=",
"'*'",
")",
")",
"{",
"$",
".",
"post",
"(",
"\"svc/backend/i18n/\"",
",",
"{",
"missing",
":",
"key",
",",
"lang",
":",
"$",
".",
"i18n",
"(",
")",
".",
"locale",
",",
"layout",
":",
"pageInfo",
"[",
"\"layout\"",
"]",
"}",
")",
";",
"}",
"message",
"=",
"key",
";",
"}",
"var",
"result",
"=",
"this",
".",
"parser",
".",
"parse",
"(",
"message",
",",
"parameters",
")",
";",
"if",
"(",
"result",
".",
"substr",
"(",
"0",
",",
"6",
")",
"==",
"'UTF8: '",
")",
"result",
"=",
"result",
".",
"substr",
"(",
"6",
")",
"return",
"result",
";",
"}"
] |
Does parameter and magic word substitution.
@param {string} key Message key
@param {Array} parameters Message parameters
@return {string}
|
[
"Does",
"parameter",
"and",
"magic",
"word",
"substitution",
"."
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.js#L165-L183
|
|
19,775
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.js
|
function ( message, parameters ) {
return message.replace( /\$(\d+)/g, function ( str, match ) {
var index = parseInt( match, 10 ) - 1;
return parameters[index] !== undefined ? parameters[index] : '$' + match;
} );
}
|
javascript
|
function ( message, parameters ) {
return message.replace( /\$(\d+)/g, function ( str, match ) {
var index = parseInt( match, 10 ) - 1;
return parameters[index] !== undefined ? parameters[index] : '$' + match;
} );
}
|
[
"function",
"(",
"message",
",",
"parameters",
")",
"{",
"return",
"message",
".",
"replace",
"(",
"/",
"\\$(\\d+)",
"/",
"g",
",",
"function",
"(",
"str",
",",
"match",
")",
"{",
"var",
"index",
"=",
"parseInt",
"(",
"match",
",",
"10",
")",
"-",
"1",
";",
"return",
"parameters",
"[",
"index",
"]",
"!==",
"undefined",
"?",
"parameters",
"[",
"index",
"]",
":",
"'$'",
"+",
"match",
";",
"}",
")",
";",
"}"
] |
The default parser only handles variable substitution
|
[
"The",
"default",
"parser",
"only",
"handles",
"variable",
"substitution"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.js#L265-L270
|
|
19,776
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.parser.js
|
choice
|
function choice ( parserSyntax ) {
return function () {
var i, result;
for ( i = 0; i < parserSyntax.length; i++ ) {
result = parserSyntax[i]();
if ( result !== null ) {
return result;
}
}
return null;
};
}
|
javascript
|
function choice ( parserSyntax ) {
return function () {
var i, result;
for ( i = 0; i < parserSyntax.length; i++ ) {
result = parserSyntax[i]();
if ( result !== null ) {
return result;
}
}
return null;
};
}
|
[
"function",
"choice",
"(",
"parserSyntax",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"i",
",",
"result",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"parserSyntax",
".",
"length",
";",
"i",
"++",
")",
"{",
"result",
"=",
"parserSyntax",
"[",
"i",
"]",
"(",
")",
";",
"if",
"(",
"result",
"!==",
"null",
")",
"{",
"return",
"result",
";",
"}",
"}",
"return",
"null",
";",
"}",
";",
"}"
] |
Try parsers until one works, if none work return null
|
[
"Try",
"parsers",
"until",
"one",
"works",
"if",
"none",
"work",
"return",
"null"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.parser.js#L56-L70
|
19,777
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.parser.js
|
sequence
|
function sequence ( parserSyntax ) {
var i, res,
originalPos = pos,
result = [];
for ( i = 0; i < parserSyntax.length; i++ ) {
res = parserSyntax[i]();
if ( res === null ) {
pos = originalPos;
return null;
}
result.push( res );
}
return result;
}
|
javascript
|
function sequence ( parserSyntax ) {
var i, res,
originalPos = pos,
result = [];
for ( i = 0; i < parserSyntax.length; i++ ) {
res = parserSyntax[i]();
if ( res === null ) {
pos = originalPos;
return null;
}
result.push( res );
}
return result;
}
|
[
"function",
"sequence",
"(",
"parserSyntax",
")",
"{",
"var",
"i",
",",
"res",
",",
"originalPos",
"=",
"pos",
",",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"parserSyntax",
".",
"length",
";",
"i",
"++",
")",
"{",
"res",
"=",
"parserSyntax",
"[",
"i",
"]",
"(",
")",
";",
"if",
"(",
"res",
"===",
"null",
")",
"{",
"pos",
"=",
"originalPos",
";",
"return",
"null",
";",
"}",
"result",
".",
"push",
"(",
"res",
")",
";",
"}",
"return",
"result",
";",
"}"
] |
Try several parserSyntax-es in a row. All must succeed; otherwise, return null. This is the only eager one.
|
[
"Try",
"several",
"parserSyntax",
"-",
"es",
"in",
"a",
"row",
".",
"All",
"must",
"succeed",
";",
"otherwise",
"return",
"null",
".",
"This",
"is",
"the",
"only",
"eager",
"one",
"."
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.parser.js#L75-L93
|
19,778
|
ma-ha/rest-web-ui
|
html/js/i18n/jquery.i18n.parser.js
|
nOrMore
|
function nOrMore ( n, p ) {
return function () {
var originalPos = pos,
result = [],
parsed = p();
while ( parsed !== null ) {
result.push( parsed );
parsed = p();
}
if ( result.length < n ) {
pos = originalPos;
return null;
}
return result;
};
}
|
javascript
|
function nOrMore ( n, p ) {
return function () {
var originalPos = pos,
result = [],
parsed = p();
while ( parsed !== null ) {
result.push( parsed );
parsed = p();
}
if ( result.length < n ) {
pos = originalPos;
return null;
}
return result;
};
}
|
[
"function",
"nOrMore",
"(",
"n",
",",
"p",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"originalPos",
"=",
"pos",
",",
"result",
"=",
"[",
"]",
",",
"parsed",
"=",
"p",
"(",
")",
";",
"while",
"(",
"parsed",
"!==",
"null",
")",
"{",
"result",
".",
"push",
"(",
"parsed",
")",
";",
"parsed",
"=",
"p",
"(",
")",
";",
"}",
"if",
"(",
"result",
".",
"length",
"<",
"n",
")",
"{",
"pos",
"=",
"originalPos",
";",
"return",
"null",
";",
"}",
"return",
"result",
";",
"}",
";",
"}"
] |
Run the same parser over and over until it fails. Must succeed a minimum of n times; otherwise, return null.
|
[
"Run",
"the",
"same",
"parser",
"over",
"and",
"over",
"until",
"it",
"fails",
".",
"Must",
"succeed",
"a",
"minimum",
"of",
"n",
"times",
";",
"otherwise",
"return",
"null",
"."
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/js/i18n/jquery.i18n.parser.js#L97-L116
|
19,779
|
ma-ha/rest-web-ui
|
html/modules/pong-table/pong-table.js
|
pongTableCmpFields
|
function pongTableCmpFields( a, b ) {
var cellValA = getSubData( a, pongTable_sc );
var cellValB = getSubData( b, pongTable_sc );
log( "Pong-Table", 'Sort: '+pongTable_sc+" "+cellValA+" "+cellValB );
if ( Number( cellValA ) && Number( cellValB ) ) {
if ( ! isNaN( parseFloat( cellValA ) ) && ! isNaN( parseFloat( cellValB ) ) ) {
cellValA = parseFloat( cellValA );
cellValB = parseFloat( cellValB );
log( "Pong-Table", "parseFloat" );
} else {
if ( ! isNaN( parseInt( cellValA ) ) && ! isNaN( parseInt( cellValB ) ) ) {
cellValA = parseInt( cellValA );
cellValB = parseInt( cellValB );
log( "Pong-Table", "parseInt" );
}
}
}
if ( cellValA > cellValB ) {
return ( pongTable_sort_up ? 1 : -1)
}
if ( cellValA < cellValB ) {
return ( pongTable_sort_up ? -1 : 1)
}
return 0;
}
|
javascript
|
function pongTableCmpFields( a, b ) {
var cellValA = getSubData( a, pongTable_sc );
var cellValB = getSubData( b, pongTable_sc );
log( "Pong-Table", 'Sort: '+pongTable_sc+" "+cellValA+" "+cellValB );
if ( Number( cellValA ) && Number( cellValB ) ) {
if ( ! isNaN( parseFloat( cellValA ) ) && ! isNaN( parseFloat( cellValB ) ) ) {
cellValA = parseFloat( cellValA );
cellValB = parseFloat( cellValB );
log( "Pong-Table", "parseFloat" );
} else {
if ( ! isNaN( parseInt( cellValA ) ) && ! isNaN( parseInt( cellValB ) ) ) {
cellValA = parseInt( cellValA );
cellValB = parseInt( cellValB );
log( "Pong-Table", "parseInt" );
}
}
}
if ( cellValA > cellValB ) {
return ( pongTable_sort_up ? 1 : -1)
}
if ( cellValA < cellValB ) {
return ( pongTable_sort_up ? -1 : 1)
}
return 0;
}
|
[
"function",
"pongTableCmpFields",
"(",
"a",
",",
"b",
")",
"{",
"var",
"cellValA",
"=",
"getSubData",
"(",
"a",
",",
"pongTable_sc",
")",
";",
"var",
"cellValB",
"=",
"getSubData",
"(",
"b",
",",
"pongTable_sc",
")",
";",
"log",
"(",
"\"Pong-Table\"",
",",
"'Sort: '",
"+",
"pongTable_sc",
"+",
"\" \"",
"+",
"cellValA",
"+",
"\" \"",
"+",
"cellValB",
")",
";",
"if",
"(",
"Number",
"(",
"cellValA",
")",
"&&",
"Number",
"(",
"cellValB",
")",
")",
"{",
"if",
"(",
"!",
"isNaN",
"(",
"parseFloat",
"(",
"cellValA",
")",
")",
"&&",
"!",
"isNaN",
"(",
"parseFloat",
"(",
"cellValB",
")",
")",
")",
"{",
"cellValA",
"=",
"parseFloat",
"(",
"cellValA",
")",
";",
"cellValB",
"=",
"parseFloat",
"(",
"cellValB",
")",
";",
"log",
"(",
"\"Pong-Table\"",
",",
"\"parseFloat\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isNaN",
"(",
"parseInt",
"(",
"cellValA",
")",
")",
"&&",
"!",
"isNaN",
"(",
"parseInt",
"(",
"cellValB",
")",
")",
")",
"{",
"cellValA",
"=",
"parseInt",
"(",
"cellValA",
")",
";",
"cellValB",
"=",
"parseInt",
"(",
"cellValB",
")",
";",
"log",
"(",
"\"Pong-Table\"",
",",
"\"parseInt\"",
")",
";",
"}",
"}",
"}",
"if",
"(",
"cellValA",
">",
"cellValB",
")",
"{",
"return",
"(",
"pongTable_sort_up",
"?",
"1",
":",
"-",
"1",
")",
"}",
"if",
"(",
"cellValA",
"<",
"cellValB",
")",
"{",
"return",
"(",
"pongTable_sort_up",
"?",
"-",
"1",
":",
"1",
")",
"}",
"return",
"0",
";",
"}"
] |
little dirty, but works well
|
[
"little",
"dirty",
"but",
"works",
"well"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-table/pong-table.js#L907-L931
|
19,780
|
ma-ha/rest-web-ui
|
html/modules/pong-table/pong-table.js
|
pongListUpdateRow
|
function pongListUpdateRow( divId, divs, rowDta, r, cx, i, tblDiv ) {
log( "PoNG-List", 'upd-div row='+r+'/'+cx );
for ( var c = 0; c < divs.length; c ++ ) {
log( "PoNG-List", 'upd-div '+cx+'/'+c );
if ( divs[c].cellType == 'div' ) {
log( "PoNG-List", 'upd-div-x '+divs[c].id );
if ( divs[c].divs ) {
pongListUpdateRow( divId, divs[c].divs, rowDta, r, cx+c, i, tblDiv );
}
} else {
var cellId = '#'+divId+'R'+i+'X'+cx+'C'+c;
log( "PoNG-List", 'upd-div-n '+cellId );
var dtaArr = poTbl[ tblDiv ].pongTableData;
var rowIdVal = dtaArr[r][ poTbl[ tblDiv ].pongTableDef.rowId ];
tblUpdateCell( divId, divs[c], r, c, i, rowDta, cellId, rowIdVal, tblDiv );
}
}
}
|
javascript
|
function pongListUpdateRow( divId, divs, rowDta, r, cx, i, tblDiv ) {
log( "PoNG-List", 'upd-div row='+r+'/'+cx );
for ( var c = 0; c < divs.length; c ++ ) {
log( "PoNG-List", 'upd-div '+cx+'/'+c );
if ( divs[c].cellType == 'div' ) {
log( "PoNG-List", 'upd-div-x '+divs[c].id );
if ( divs[c].divs ) {
pongListUpdateRow( divId, divs[c].divs, rowDta, r, cx+c, i, tblDiv );
}
} else {
var cellId = '#'+divId+'R'+i+'X'+cx+'C'+c;
log( "PoNG-List", 'upd-div-n '+cellId );
var dtaArr = poTbl[ tblDiv ].pongTableData;
var rowIdVal = dtaArr[r][ poTbl[ tblDiv ].pongTableDef.rowId ];
tblUpdateCell( divId, divs[c], r, c, i, rowDta, cellId, rowIdVal, tblDiv );
}
}
}
|
[
"function",
"pongListUpdateRow",
"(",
"divId",
",",
"divs",
",",
"rowDta",
",",
"r",
",",
"cx",
",",
"i",
",",
"tblDiv",
")",
"{",
"log",
"(",
"\"PoNG-List\"",
",",
"'upd-div row='",
"+",
"r",
"+",
"'/'",
"+",
"cx",
")",
";",
"for",
"(",
"var",
"c",
"=",
"0",
";",
"c",
"<",
"divs",
".",
"length",
";",
"c",
"++",
")",
"{",
"log",
"(",
"\"PoNG-List\"",
",",
"'upd-div '",
"+",
"cx",
"+",
"'/'",
"+",
"c",
")",
";",
"if",
"(",
"divs",
"[",
"c",
"]",
".",
"cellType",
"==",
"'div'",
")",
"{",
"log",
"(",
"\"PoNG-List\"",
",",
"'upd-div-x '",
"+",
"divs",
"[",
"c",
"]",
".",
"id",
")",
";",
"if",
"(",
"divs",
"[",
"c",
"]",
".",
"divs",
")",
"{",
"pongListUpdateRow",
"(",
"divId",
",",
"divs",
"[",
"c",
"]",
".",
"divs",
",",
"rowDta",
",",
"r",
",",
"cx",
"+",
"c",
",",
"i",
",",
"tblDiv",
")",
";",
"}",
"}",
"else",
"{",
"var",
"cellId",
"=",
"'#'",
"+",
"divId",
"+",
"'R'",
"+",
"i",
"+",
"'X'",
"+",
"cx",
"+",
"'C'",
"+",
"c",
";",
"log",
"(",
"\"PoNG-List\"",
",",
"'upd-div-n '",
"+",
"cellId",
")",
";",
"var",
"dtaArr",
"=",
"poTbl",
"[",
"tblDiv",
"]",
".",
"pongTableData",
";",
"var",
"rowIdVal",
"=",
"dtaArr",
"[",
"r",
"]",
"[",
"poTbl",
"[",
"tblDiv",
"]",
".",
"pongTableDef",
".",
"rowId",
"]",
";",
"tblUpdateCell",
"(",
"divId",
",",
"divs",
"[",
"c",
"]",
",",
"r",
",",
"c",
",",
"i",
",",
"rowDta",
",",
"cellId",
",",
"rowIdVal",
",",
"tblDiv",
")",
";",
"}",
"}",
"}"
] |
fill recursively empty cells of one row with data
|
[
"fill",
"recursively",
"empty",
"cells",
"of",
"one",
"row",
"with",
"data"
] |
e2db0d55bb31a4f16fd07609ecae79156cb38378
|
https://github.com/ma-ha/rest-web-ui/blob/e2db0d55bb31a4f16fd07609ecae79156cb38378/html/modules/pong-table/pong-table.js#L1836-L1853
|
19,781
|
sqlectron/sqlectron-core
|
src/servers.js
|
encryptSecrects
|
function encryptSecrects(server, cryptoSecret, oldSever) {
const updatedServer = { ...server };
/* eslint no-param-reassign:0 */
if (server.password) {
const isPassDiff = (oldSever && server.password !== oldSever.password);
if (!oldSever || isPassDiff) {
updatedServer.password = crypto.encrypt(server.password, cryptoSecret);
}
}
if (server.ssh && server.ssh.password) {
const isPassDiff = (oldSever && server.ssh.password !== oldSever.ssh.password);
if (!oldSever || isPassDiff) {
updatedServer.ssh.password = crypto.encrypt(server.ssh.password, cryptoSecret);
}
}
updatedServer.encrypted = true;
return updatedServer;
}
|
javascript
|
function encryptSecrects(server, cryptoSecret, oldSever) {
const updatedServer = { ...server };
/* eslint no-param-reassign:0 */
if (server.password) {
const isPassDiff = (oldSever && server.password !== oldSever.password);
if (!oldSever || isPassDiff) {
updatedServer.password = crypto.encrypt(server.password, cryptoSecret);
}
}
if (server.ssh && server.ssh.password) {
const isPassDiff = (oldSever && server.ssh.password !== oldSever.ssh.password);
if (!oldSever || isPassDiff) {
updatedServer.ssh.password = crypto.encrypt(server.ssh.password, cryptoSecret);
}
}
updatedServer.encrypted = true;
return updatedServer;
}
|
[
"function",
"encryptSecrects",
"(",
"server",
",",
"cryptoSecret",
",",
"oldSever",
")",
"{",
"const",
"updatedServer",
"=",
"{",
"...",
"server",
"}",
";",
"/* eslint no-param-reassign:0 */",
"if",
"(",
"server",
".",
"password",
")",
"{",
"const",
"isPassDiff",
"=",
"(",
"oldSever",
"&&",
"server",
".",
"password",
"!==",
"oldSever",
".",
"password",
")",
";",
"if",
"(",
"!",
"oldSever",
"||",
"isPassDiff",
")",
"{",
"updatedServer",
".",
"password",
"=",
"crypto",
".",
"encrypt",
"(",
"server",
".",
"password",
",",
"cryptoSecret",
")",
";",
"}",
"}",
"if",
"(",
"server",
".",
"ssh",
"&&",
"server",
".",
"ssh",
".",
"password",
")",
"{",
"const",
"isPassDiff",
"=",
"(",
"oldSever",
"&&",
"server",
".",
"ssh",
".",
"password",
"!==",
"oldSever",
".",
"ssh",
".",
"password",
")",
";",
"if",
"(",
"!",
"oldSever",
"||",
"isPassDiff",
")",
"{",
"updatedServer",
".",
"ssh",
".",
"password",
"=",
"crypto",
".",
"encrypt",
"(",
"server",
".",
"ssh",
".",
"password",
",",
"cryptoSecret",
")",
";",
"}",
"}",
"updatedServer",
".",
"encrypted",
"=",
"true",
";",
"return",
"updatedServer",
";",
"}"
] |
ensure all secret fields are encrypted
|
[
"ensure",
"all",
"secret",
"fields",
"are",
"encrypted"
] |
87094c7becf49f9f2ff18bc26c999f9ab60fe129
|
https://github.com/sqlectron/sqlectron-core/blob/87094c7becf49f9f2ff18bc26c999f9ab60fe129/src/servers.js#L73-L95
|
19,782
|
nikku/karma-browserify
|
lib/bundle-file.js
|
BundleFile
|
function BundleFile() {
var location = getTempFileName('.browserify.js');
function write(content) {
fs.writeFileSync(location, content);
}
function exists() {
return fs.existsSync(location);
}
function remove() {
if (exists()) {
fs.unlinkSync(location);
}
}
function touch() {
if (!exists()) {
write('');
}
}
// API
this.touch = touch;
this.update = write;
this.remove = remove;
this.location = location;
}
|
javascript
|
function BundleFile() {
var location = getTempFileName('.browserify.js');
function write(content) {
fs.writeFileSync(location, content);
}
function exists() {
return fs.existsSync(location);
}
function remove() {
if (exists()) {
fs.unlinkSync(location);
}
}
function touch() {
if (!exists()) {
write('');
}
}
// API
this.touch = touch;
this.update = write;
this.remove = remove;
this.location = location;
}
|
[
"function",
"BundleFile",
"(",
")",
"{",
"var",
"location",
"=",
"getTempFileName",
"(",
"'.browserify.js'",
")",
";",
"function",
"write",
"(",
"content",
")",
"{",
"fs",
".",
"writeFileSync",
"(",
"location",
",",
"content",
")",
";",
"}",
"function",
"exists",
"(",
")",
"{",
"return",
"fs",
".",
"existsSync",
"(",
"location",
")",
";",
"}",
"function",
"remove",
"(",
")",
"{",
"if",
"(",
"exists",
"(",
")",
")",
"{",
"fs",
".",
"unlinkSync",
"(",
"location",
")",
";",
"}",
"}",
"function",
"touch",
"(",
")",
"{",
"if",
"(",
"!",
"exists",
"(",
")",
")",
"{",
"write",
"(",
"''",
")",
";",
"}",
"}",
"// API",
"this",
".",
"touch",
"=",
"touch",
";",
"this",
".",
"update",
"=",
"write",
";",
"this",
".",
"remove",
"=",
"remove",
";",
"this",
".",
"location",
"=",
"location",
";",
"}"
] |
A instance of a bundle file
|
[
"A",
"instance",
"of",
"a",
"bundle",
"file"
] |
b2709c3d4945744ebb8fea92fa3b12d433d5729f
|
https://github.com/nikku/karma-browserify/blob/b2709c3d4945744ebb8fea92fa3b12d433d5729f/lib/bundle-file.js#L18-L51
|
19,783
|
nikku/karma-browserify
|
lib/bro.js
|
extractSourceMap
|
function extractSourceMap(bundleContents) {
var start = bundleContents.lastIndexOf('//# sourceMappingURL');
var sourceMapComment = start !== -1 ? bundleContents.substring(start) : '';
return sourceMapComment && convert.fromComment(sourceMapComment);
}
|
javascript
|
function extractSourceMap(bundleContents) {
var start = bundleContents.lastIndexOf('//# sourceMappingURL');
var sourceMapComment = start !== -1 ? bundleContents.substring(start) : '';
return sourceMapComment && convert.fromComment(sourceMapComment);
}
|
[
"function",
"extractSourceMap",
"(",
"bundleContents",
")",
"{",
"var",
"start",
"=",
"bundleContents",
".",
"lastIndexOf",
"(",
"'//# sourceMappingURL'",
")",
";",
"var",
"sourceMapComment",
"=",
"start",
"!==",
"-",
"1",
"?",
"bundleContents",
".",
"substring",
"(",
"start",
")",
":",
"''",
";",
"return",
"sourceMapComment",
"&&",
"convert",
".",
"fromComment",
"(",
"sourceMapComment",
")",
";",
"}"
] |
Extract the source map from the given bundle contents
@param {String} source
@return {SourceMap} if it could be parsed
|
[
"Extract",
"the",
"source",
"map",
"from",
"the",
"given",
"bundle",
"contents"
] |
b2709c3d4945744ebb8fea92fa3b12d433d5729f
|
https://github.com/nikku/karma-browserify/blob/b2709c3d4945744ebb8fea92fa3b12d433d5729f/lib/bro.js#L56-L61
|
19,784
|
nikku/karma-browserify
|
lib/bro.js
|
addBundleFile
|
function addBundleFile(bundleFile, config) {
var files = config.files,
preprocessors = config.preprocessors;
// list of patterns using our preprocessor
var patterns = reduce(preprocessors, function(matched, val, key) {
if (val.indexOf('browserify') !== -1) {
matched.push(key);
}
return matched;
}, []);
// first file being preprocessed
var file = find(files, function(f) {
return some(patterns, function(p) {
return minimatch(f.pattern, p);
});
});
var idx = 0;
if (file) {
idx = files.indexOf(file);
} else {
log.debug('no matching preprocessed file was found, defaulting to prepend');
}
log.debug('add bundle to config.files at position', idx);
// insert bundle on the correct spot
files.splice(idx, 0, {
pattern: bundleFile.location,
served: true,
included: true,
watched: true
});
}
|
javascript
|
function addBundleFile(bundleFile, config) {
var files = config.files,
preprocessors = config.preprocessors;
// list of patterns using our preprocessor
var patterns = reduce(preprocessors, function(matched, val, key) {
if (val.indexOf('browserify') !== -1) {
matched.push(key);
}
return matched;
}, []);
// first file being preprocessed
var file = find(files, function(f) {
return some(patterns, function(p) {
return minimatch(f.pattern, p);
});
});
var idx = 0;
if (file) {
idx = files.indexOf(file);
} else {
log.debug('no matching preprocessed file was found, defaulting to prepend');
}
log.debug('add bundle to config.files at position', idx);
// insert bundle on the correct spot
files.splice(idx, 0, {
pattern: bundleFile.location,
served: true,
included: true,
watched: true
});
}
|
[
"function",
"addBundleFile",
"(",
"bundleFile",
",",
"config",
")",
"{",
"var",
"files",
"=",
"config",
".",
"files",
",",
"preprocessors",
"=",
"config",
".",
"preprocessors",
";",
"// list of patterns using our preprocessor",
"var",
"patterns",
"=",
"reduce",
"(",
"preprocessors",
",",
"function",
"(",
"matched",
",",
"val",
",",
"key",
")",
"{",
"if",
"(",
"val",
".",
"indexOf",
"(",
"'browserify'",
")",
"!==",
"-",
"1",
")",
"{",
"matched",
".",
"push",
"(",
"key",
")",
";",
"}",
"return",
"matched",
";",
"}",
",",
"[",
"]",
")",
";",
"// first file being preprocessed",
"var",
"file",
"=",
"find",
"(",
"files",
",",
"function",
"(",
"f",
")",
"{",
"return",
"some",
"(",
"patterns",
",",
"function",
"(",
"p",
")",
"{",
"return",
"minimatch",
"(",
"f",
".",
"pattern",
",",
"p",
")",
";",
"}",
")",
";",
"}",
")",
";",
"var",
"idx",
"=",
"0",
";",
"if",
"(",
"file",
")",
"{",
"idx",
"=",
"files",
".",
"indexOf",
"(",
"file",
")",
";",
"}",
"else",
"{",
"log",
".",
"debug",
"(",
"'no matching preprocessed file was found, defaulting to prepend'",
")",
";",
"}",
"log",
".",
"debug",
"(",
"'add bundle to config.files at position'",
",",
"idx",
")",
";",
"// insert bundle on the correct spot",
"files",
".",
"splice",
"(",
"idx",
",",
"0",
",",
"{",
"pattern",
":",
"bundleFile",
".",
"location",
",",
"served",
":",
"true",
",",
"included",
":",
"true",
",",
"watched",
":",
"true",
"}",
")",
";",
"}"
] |
Add bundle file to the list of files in the
configuration, right before the first browserified
test file and after everything else.
That makes sure users can include non-commonJS files
prior to the browserified bundle.
@param {BundleFile} bundleFile the file containing the browserify bundle
@param {Object} config the karma configuration to be updated
|
[
"Add",
"bundle",
"file",
"to",
"the",
"list",
"of",
"files",
"in",
"the",
"configuration",
"right",
"before",
"the",
"first",
"browserified",
"test",
"file",
"and",
"after",
"everything",
"else",
"."
] |
b2709c3d4945744ebb8fea92fa3b12d433d5729f
|
https://github.com/nikku/karma-browserify/blob/b2709c3d4945744ebb8fea92fa3b12d433d5729f/lib/bro.js#L84-L121
|
19,785
|
nikku/karma-browserify
|
lib/bro.js
|
framework
|
function framework(emitter, config, logger) {
log = logger.create('framework.browserify');
if (!bundleFile) {
bundleFile = new BundleFile();
}
bundleFile.touch();
log.debug('created browserify bundle: %s', bundleFile.location);
b = createBundle(config);
// TODO(Nikku): hook into karma karmas file update facilities
// to remove files from the bundle once karma detects the deletion
// hook into exit for cleanup
emitter.on('exit', function(done) {
log.debug('cleaning up');
if (b.close) {
b.close();
}
bundleFile.remove();
done();
});
// add bundle file to the list of files defined in the
// configuration. be smart by doing so.
addBundleFile(bundleFile, config);
return b;
}
|
javascript
|
function framework(emitter, config, logger) {
log = logger.create('framework.browserify');
if (!bundleFile) {
bundleFile = new BundleFile();
}
bundleFile.touch();
log.debug('created browserify bundle: %s', bundleFile.location);
b = createBundle(config);
// TODO(Nikku): hook into karma karmas file update facilities
// to remove files from the bundle once karma detects the deletion
// hook into exit for cleanup
emitter.on('exit', function(done) {
log.debug('cleaning up');
if (b.close) {
b.close();
}
bundleFile.remove();
done();
});
// add bundle file to the list of files defined in the
// configuration. be smart by doing so.
addBundleFile(bundleFile, config);
return b;
}
|
[
"function",
"framework",
"(",
"emitter",
",",
"config",
",",
"logger",
")",
"{",
"log",
"=",
"logger",
".",
"create",
"(",
"'framework.browserify'",
")",
";",
"if",
"(",
"!",
"bundleFile",
")",
"{",
"bundleFile",
"=",
"new",
"BundleFile",
"(",
")",
";",
"}",
"bundleFile",
".",
"touch",
"(",
")",
";",
"log",
".",
"debug",
"(",
"'created browserify bundle: %s'",
",",
"bundleFile",
".",
"location",
")",
";",
"b",
"=",
"createBundle",
"(",
"config",
")",
";",
"// TODO(Nikku): hook into karma karmas file update facilities",
"// to remove files from the bundle once karma detects the deletion",
"// hook into exit for cleanup",
"emitter",
".",
"on",
"(",
"'exit'",
",",
"function",
"(",
"done",
")",
"{",
"log",
".",
"debug",
"(",
"'cleaning up'",
")",
";",
"if",
"(",
"b",
".",
"close",
")",
"{",
"b",
".",
"close",
"(",
")",
";",
"}",
"bundleFile",
".",
"remove",
"(",
")",
";",
"done",
"(",
")",
";",
"}",
")",
";",
"// add bundle file to the list of files defined in the",
"// configuration. be smart by doing so.",
"addBundleFile",
"(",
"bundleFile",
",",
"config",
")",
";",
"return",
"b",
";",
"}"
] |
The browserify framework that creates the initial logger and bundle file
as well as prepends the bundle file to the karma file configuration.
|
[
"The",
"browserify",
"framework",
"that",
"creates",
"the",
"initial",
"logger",
"and",
"bundle",
"file",
"as",
"well",
"as",
"prepends",
"the",
"bundle",
"file",
"to",
"the",
"karma",
"file",
"configuration",
"."
] |
b2709c3d4945744ebb8fea92fa3b12d433d5729f
|
https://github.com/nikku/karma-browserify/blob/b2709c3d4945744ebb8fea92fa3b12d433d5729f/lib/bro.js#L135-L169
|
19,786
|
nikku/karma-browserify
|
lib/bro.js
|
bundlePreprocessor
|
function bundlePreprocessor(config) {
var debug = config.browserify && config.browserify.debug;
function updateSourceMap(file, content) {
var map;
if (debug) {
map = extractSourceMap(content);
file.sourceMap = map && map.sourcemap;
}
}
return function(content, file, done) {
if (b._builtOnce) {
updateSourceMap(file, content);
return done(content);
}
log.debug('building bundle');
// wait for the initial bundle to be created
b.deferredBundle(function(err, content) {
b._builtOnce = config.autoWatch;
if (err) {
return done(BUNDLE_ERROR_TPL);
}
content = content.toString('utf-8');
updateSourceMap(file, content);
log.info('bundle built');
done(content);
});
};
}
|
javascript
|
function bundlePreprocessor(config) {
var debug = config.browserify && config.browserify.debug;
function updateSourceMap(file, content) {
var map;
if (debug) {
map = extractSourceMap(content);
file.sourceMap = map && map.sourcemap;
}
}
return function(content, file, done) {
if (b._builtOnce) {
updateSourceMap(file, content);
return done(content);
}
log.debug('building bundle');
// wait for the initial bundle to be created
b.deferredBundle(function(err, content) {
b._builtOnce = config.autoWatch;
if (err) {
return done(BUNDLE_ERROR_TPL);
}
content = content.toString('utf-8');
updateSourceMap(file, content);
log.info('bundle built');
done(content);
});
};
}
|
[
"function",
"bundlePreprocessor",
"(",
"config",
")",
"{",
"var",
"debug",
"=",
"config",
".",
"browserify",
"&&",
"config",
".",
"browserify",
".",
"debug",
";",
"function",
"updateSourceMap",
"(",
"file",
",",
"content",
")",
"{",
"var",
"map",
";",
"if",
"(",
"debug",
")",
"{",
"map",
"=",
"extractSourceMap",
"(",
"content",
")",
";",
"file",
".",
"sourceMap",
"=",
"map",
"&&",
"map",
".",
"sourcemap",
";",
"}",
"}",
"return",
"function",
"(",
"content",
",",
"file",
",",
"done",
")",
"{",
"if",
"(",
"b",
".",
"_builtOnce",
")",
"{",
"updateSourceMap",
"(",
"file",
",",
"content",
")",
";",
"return",
"done",
"(",
"content",
")",
";",
"}",
"log",
".",
"debug",
"(",
"'building bundle'",
")",
";",
"// wait for the initial bundle to be created",
"b",
".",
"deferredBundle",
"(",
"function",
"(",
"err",
",",
"content",
")",
"{",
"b",
".",
"_builtOnce",
"=",
"config",
".",
"autoWatch",
";",
"if",
"(",
"err",
")",
"{",
"return",
"done",
"(",
"BUNDLE_ERROR_TPL",
")",
";",
"}",
"content",
"=",
"content",
".",
"toString",
"(",
"'utf-8'",
")",
";",
"updateSourceMap",
"(",
"file",
",",
"content",
")",
";",
"log",
".",
"info",
"(",
"'bundle built'",
")",
";",
"done",
"(",
"content",
")",
";",
"}",
")",
";",
"}",
";",
"}"
] |
A special preprocessor that builds the main browserify bundle once and
passes the bundle contents through on all later preprocessing request.
|
[
"A",
"special",
"preprocessor",
"that",
"builds",
"the",
"main",
"browserify",
"bundle",
"once",
"and",
"passes",
"the",
"bundle",
"contents",
"through",
"on",
"all",
"later",
"preprocessing",
"request",
"."
] |
b2709c3d4945744ebb8fea92fa3b12d433d5729f
|
https://github.com/nikku/karma-browserify/blob/b2709c3d4945744ebb8fea92fa3b12d433d5729f/lib/bro.js#L370-L411
|
19,787
|
yuku/jquery-textcomplete
|
src/dropdown.js
|
Dropdown
|
function Dropdown(element, completer, option) {
this.$el = Dropdown.createElement(option);
this.completer = completer;
this.id = completer.id + 'dropdown';
this._data = []; // zipped data.
this.$inputEl = $(element);
this.option = option;
// Override setPosition method.
if (option.listPosition) { this.setPosition = option.listPosition; }
if (option.height) { this.$el.height(option.height); }
var self = this;
$.each(['maxCount', 'placement', 'footer', 'header', 'noResultsMessage', 'className'], function (_i, name) {
if (option[name] != null) { self[name] = option[name]; }
});
this._bindEvents(element);
dropdownViews[this.id] = this;
}
|
javascript
|
function Dropdown(element, completer, option) {
this.$el = Dropdown.createElement(option);
this.completer = completer;
this.id = completer.id + 'dropdown';
this._data = []; // zipped data.
this.$inputEl = $(element);
this.option = option;
// Override setPosition method.
if (option.listPosition) { this.setPosition = option.listPosition; }
if (option.height) { this.$el.height(option.height); }
var self = this;
$.each(['maxCount', 'placement', 'footer', 'header', 'noResultsMessage', 'className'], function (_i, name) {
if (option[name] != null) { self[name] = option[name]; }
});
this._bindEvents(element);
dropdownViews[this.id] = this;
}
|
[
"function",
"Dropdown",
"(",
"element",
",",
"completer",
",",
"option",
")",
"{",
"this",
".",
"$el",
"=",
"Dropdown",
".",
"createElement",
"(",
"option",
")",
";",
"this",
".",
"completer",
"=",
"completer",
";",
"this",
".",
"id",
"=",
"completer",
".",
"id",
"+",
"'dropdown'",
";",
"this",
".",
"_data",
"=",
"[",
"]",
";",
"// zipped data.",
"this",
".",
"$inputEl",
"=",
"$",
"(",
"element",
")",
";",
"this",
".",
"option",
"=",
"option",
";",
"// Override setPosition method.",
"if",
"(",
"option",
".",
"listPosition",
")",
"{",
"this",
".",
"setPosition",
"=",
"option",
".",
"listPosition",
";",
"}",
"if",
"(",
"option",
".",
"height",
")",
"{",
"this",
".",
"$el",
".",
"height",
"(",
"option",
".",
"height",
")",
";",
"}",
"var",
"self",
"=",
"this",
";",
"$",
".",
"each",
"(",
"[",
"'maxCount'",
",",
"'placement'",
",",
"'footer'",
",",
"'header'",
",",
"'noResultsMessage'",
",",
"'className'",
"]",
",",
"function",
"(",
"_i",
",",
"name",
")",
"{",
"if",
"(",
"option",
"[",
"name",
"]",
"!=",
"null",
")",
"{",
"self",
"[",
"name",
"]",
"=",
"option",
"[",
"name",
"]",
";",
"}",
"}",
")",
";",
"this",
".",
"_bindEvents",
"(",
"element",
")",
";",
"dropdownViews",
"[",
"this",
".",
"id",
"]",
"=",
"this",
";",
"}"
] |
Construct Dropdown object. element - Textarea or contenteditable element.
|
[
"Construct",
"Dropdown",
"object",
".",
"element",
"-",
"Textarea",
"or",
"contenteditable",
"element",
"."
] |
3aa8a1b2e74a451f0017ce700ebcf2c405a25184
|
https://github.com/yuku/jquery-textcomplete/blob/3aa8a1b2e74a451f0017ce700ebcf2c405a25184/src/dropdown.js#L45-L62
|
19,788
|
yuku/jquery-textcomplete
|
src/dropdown.js
|
function (e) {
var $el = $(e.target);
e.preventDefault();
if (!$el.hasClass('textcomplete-item')) {
$el = $el.closest('.textcomplete-item');
}
this._index = parseInt($el.data('index'), 10);
this._activateIndexedItem();
}
|
javascript
|
function (e) {
var $el = $(e.target);
e.preventDefault();
if (!$el.hasClass('textcomplete-item')) {
$el = $el.closest('.textcomplete-item');
}
this._index = parseInt($el.data('index'), 10);
this._activateIndexedItem();
}
|
[
"function",
"(",
"e",
")",
"{",
"var",
"$el",
"=",
"$",
"(",
"e",
".",
"target",
")",
";",
"e",
".",
"preventDefault",
"(",
")",
";",
"if",
"(",
"!",
"$el",
".",
"hasClass",
"(",
"'textcomplete-item'",
")",
")",
"{",
"$el",
"=",
"$el",
".",
"closest",
"(",
"'.textcomplete-item'",
")",
";",
"}",
"this",
".",
"_index",
"=",
"parseInt",
"(",
"$el",
".",
"data",
"(",
"'index'",
")",
",",
"10",
")",
";",
"this",
".",
"_activateIndexedItem",
"(",
")",
";",
"}"
] |
Activate hovered item.
|
[
"Activate",
"hovered",
"item",
"."
] |
3aa8a1b2e74a451f0017ce700ebcf2c405a25184
|
https://github.com/yuku/jquery-textcomplete/blob/3aa8a1b2e74a451f0017ce700ebcf2c405a25184/src/dropdown.js#L257-L265
|
|
19,789
|
yuku/jquery-textcomplete
|
src/strategy.js
|
function (func) {
var memo = {};
return function (term, callback) {
if (memo[term]) {
callback(memo[term]);
} else {
func.call(this, term, function (data) {
memo[term] = (memo[term] || []).concat(data);
callback.apply(null, arguments);
});
}
};
}
|
javascript
|
function (func) {
var memo = {};
return function (term, callback) {
if (memo[term]) {
callback(memo[term]);
} else {
func.call(this, term, function (data) {
memo[term] = (memo[term] || []).concat(data);
callback.apply(null, arguments);
});
}
};
}
|
[
"function",
"(",
"func",
")",
"{",
"var",
"memo",
"=",
"{",
"}",
";",
"return",
"function",
"(",
"term",
",",
"callback",
")",
"{",
"if",
"(",
"memo",
"[",
"term",
"]",
")",
"{",
"callback",
"(",
"memo",
"[",
"term",
"]",
")",
";",
"}",
"else",
"{",
"func",
".",
"call",
"(",
"this",
",",
"term",
",",
"function",
"(",
"data",
")",
"{",
"memo",
"[",
"term",
"]",
"=",
"(",
"memo",
"[",
"term",
"]",
"||",
"[",
"]",
")",
".",
"concat",
"(",
"data",
")",
";",
"callback",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
";",
"}",
")",
";",
"}",
"}",
";",
"}"
] |
Memoize a search function.
|
[
"Memoize",
"a",
"search",
"function",
"."
] |
3aa8a1b2e74a451f0017ce700ebcf2c405a25184
|
https://github.com/yuku/jquery-textcomplete/blob/3aa8a1b2e74a451f0017ce700ebcf2c405a25184/src/strategy.js#L5-L17
|
|
19,790
|
yuku/jquery-textcomplete
|
src/content_editable.js
|
function (value, strategy, e) {
var pre = this.getTextFromHeadToCaret();
// use ownerDocument instead of window to support iframes
var sel = this.el.ownerDocument.getSelection();
var range = sel.getRangeAt(0);
var selection = range.cloneRange();
selection.selectNodeContents(range.startContainer);
var content = selection.toString();
var post = content.substring(range.startOffset);
var newSubstr = strategy.replace(value, e);
var regExp;
if (typeof newSubstr !== 'undefined') {
if ($.isArray(newSubstr)) {
post = newSubstr[1] + post;
newSubstr = newSubstr[0];
}
regExp = $.isFunction(strategy.match) ? strategy.match(pre) : strategy.match;
pre = pre.replace(regExp, newSubstr)
.replace(/ $/, " "); //   necessary at least for CKeditor to not eat spaces
range.selectNodeContents(range.startContainer);
range.deleteContents();
// create temporary elements
var preWrapper = this.el.ownerDocument.createElement("div");
preWrapper.innerHTML = pre;
var postWrapper = this.el.ownerDocument.createElement("div");
postWrapper.innerHTML = post;
// create the fragment thats inserted
var fragment = this.el.ownerDocument.createDocumentFragment();
var childNode;
var lastOfPre;
while (childNode = preWrapper.firstChild) {
lastOfPre = fragment.appendChild(childNode);
}
while (childNode = postWrapper.firstChild) {
fragment.appendChild(childNode);
}
// insert the fragment & jump behind the last node in "pre"
range.insertNode(fragment);
range.setStartAfter(lastOfPre);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
}
}
|
javascript
|
function (value, strategy, e) {
var pre = this.getTextFromHeadToCaret();
// use ownerDocument instead of window to support iframes
var sel = this.el.ownerDocument.getSelection();
var range = sel.getRangeAt(0);
var selection = range.cloneRange();
selection.selectNodeContents(range.startContainer);
var content = selection.toString();
var post = content.substring(range.startOffset);
var newSubstr = strategy.replace(value, e);
var regExp;
if (typeof newSubstr !== 'undefined') {
if ($.isArray(newSubstr)) {
post = newSubstr[1] + post;
newSubstr = newSubstr[0];
}
regExp = $.isFunction(strategy.match) ? strategy.match(pre) : strategy.match;
pre = pre.replace(regExp, newSubstr)
.replace(/ $/, " "); //   necessary at least for CKeditor to not eat spaces
range.selectNodeContents(range.startContainer);
range.deleteContents();
// create temporary elements
var preWrapper = this.el.ownerDocument.createElement("div");
preWrapper.innerHTML = pre;
var postWrapper = this.el.ownerDocument.createElement("div");
postWrapper.innerHTML = post;
// create the fragment thats inserted
var fragment = this.el.ownerDocument.createDocumentFragment();
var childNode;
var lastOfPre;
while (childNode = preWrapper.firstChild) {
lastOfPre = fragment.appendChild(childNode);
}
while (childNode = postWrapper.firstChild) {
fragment.appendChild(childNode);
}
// insert the fragment & jump behind the last node in "pre"
range.insertNode(fragment);
range.setStartAfter(lastOfPre);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
}
}
|
[
"function",
"(",
"value",
",",
"strategy",
",",
"e",
")",
"{",
"var",
"pre",
"=",
"this",
".",
"getTextFromHeadToCaret",
"(",
")",
";",
"// use ownerDocument instead of window to support iframes",
"var",
"sel",
"=",
"this",
".",
"el",
".",
"ownerDocument",
".",
"getSelection",
"(",
")",
";",
"var",
"range",
"=",
"sel",
".",
"getRangeAt",
"(",
"0",
")",
";",
"var",
"selection",
"=",
"range",
".",
"cloneRange",
"(",
")",
";",
"selection",
".",
"selectNodeContents",
"(",
"range",
".",
"startContainer",
")",
";",
"var",
"content",
"=",
"selection",
".",
"toString",
"(",
")",
";",
"var",
"post",
"=",
"content",
".",
"substring",
"(",
"range",
".",
"startOffset",
")",
";",
"var",
"newSubstr",
"=",
"strategy",
".",
"replace",
"(",
"value",
",",
"e",
")",
";",
"var",
"regExp",
";",
"if",
"(",
"typeof",
"newSubstr",
"!==",
"'undefined'",
")",
"{",
"if",
"(",
"$",
".",
"isArray",
"(",
"newSubstr",
")",
")",
"{",
"post",
"=",
"newSubstr",
"[",
"1",
"]",
"+",
"post",
";",
"newSubstr",
"=",
"newSubstr",
"[",
"0",
"]",
";",
"}",
"regExp",
"=",
"$",
".",
"isFunction",
"(",
"strategy",
".",
"match",
")",
"?",
"strategy",
".",
"match",
"(",
"pre",
")",
":",
"strategy",
".",
"match",
";",
"pre",
"=",
"pre",
".",
"replace",
"(",
"regExp",
",",
"newSubstr",
")",
".",
"replace",
"(",
"/",
" $",
"/",
",",
"\" \"",
")",
";",
"//   necessary at least for CKeditor to not eat spaces",
"range",
".",
"selectNodeContents",
"(",
"range",
".",
"startContainer",
")",
";",
"range",
".",
"deleteContents",
"(",
")",
";",
"// create temporary elements",
"var",
"preWrapper",
"=",
"this",
".",
"el",
".",
"ownerDocument",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"preWrapper",
".",
"innerHTML",
"=",
"pre",
";",
"var",
"postWrapper",
"=",
"this",
".",
"el",
".",
"ownerDocument",
".",
"createElement",
"(",
"\"div\"",
")",
";",
"postWrapper",
".",
"innerHTML",
"=",
"post",
";",
"// create the fragment thats inserted",
"var",
"fragment",
"=",
"this",
".",
"el",
".",
"ownerDocument",
".",
"createDocumentFragment",
"(",
")",
";",
"var",
"childNode",
";",
"var",
"lastOfPre",
";",
"while",
"(",
"childNode",
"=",
"preWrapper",
".",
"firstChild",
")",
"{",
"lastOfPre",
"=",
"fragment",
".",
"appendChild",
"(",
"childNode",
")",
";",
"}",
"while",
"(",
"childNode",
"=",
"postWrapper",
".",
"firstChild",
")",
"{",
"fragment",
".",
"appendChild",
"(",
"childNode",
")",
";",
"}",
"// insert the fragment & jump behind the last node in \"pre\"",
"range",
".",
"insertNode",
"(",
"fragment",
")",
";",
"range",
".",
"setStartAfter",
"(",
"lastOfPre",
")",
";",
"range",
".",
"collapse",
"(",
"true",
")",
";",
"sel",
".",
"removeAllRanges",
"(",
")",
";",
"sel",
".",
"addRange",
"(",
"range",
")",
";",
"}",
"}"
] |
Update the content with the given value and strategy. When an dropdown item is selected, it is executed.
|
[
"Update",
"the",
"content",
"with",
"the",
"given",
"value",
"and",
"strategy",
".",
"When",
"an",
"dropdown",
"item",
"is",
"selected",
"it",
"is",
"executed",
"."
] |
3aa8a1b2e74a451f0017ce700ebcf2c405a25184
|
https://github.com/yuku/jquery-textcomplete/blob/3aa8a1b2e74a451f0017ce700ebcf2c405a25184/src/content_editable.js#L22-L70
|
|
19,791
|
yuku/jquery-textcomplete
|
src/adapter.js
|
function () {
var position = this._getCaretRelativePosition();
var offset = this.$el.offset();
// Calculate the left top corner of `this.option.appendTo` element.
var $parent = this.option.appendTo;
if ($parent) {
if (!($parent instanceof $)) { $parent = $($parent); }
var parentOffset = $parent.offsetParent().offset();
offset.top -= parentOffset.top;
offset.left -= parentOffset.left;
}
position.top += offset.top;
position.left += offset.left;
return position;
}
|
javascript
|
function () {
var position = this._getCaretRelativePosition();
var offset = this.$el.offset();
// Calculate the left top corner of `this.option.appendTo` element.
var $parent = this.option.appendTo;
if ($parent) {
if (!($parent instanceof $)) { $parent = $($parent); }
var parentOffset = $parent.offsetParent().offset();
offset.top -= parentOffset.top;
offset.left -= parentOffset.left;
}
position.top += offset.top;
position.left += offset.left;
return position;
}
|
[
"function",
"(",
")",
"{",
"var",
"position",
"=",
"this",
".",
"_getCaretRelativePosition",
"(",
")",
";",
"var",
"offset",
"=",
"this",
".",
"$el",
".",
"offset",
"(",
")",
";",
"// Calculate the left top corner of `this.option.appendTo` element.",
"var",
"$parent",
"=",
"this",
".",
"option",
".",
"appendTo",
";",
"if",
"(",
"$parent",
")",
"{",
"if",
"(",
"!",
"(",
"$parent",
"instanceof",
"$",
")",
")",
"{",
"$parent",
"=",
"$",
"(",
"$parent",
")",
";",
"}",
"var",
"parentOffset",
"=",
"$parent",
".",
"offsetParent",
"(",
")",
".",
"offset",
"(",
")",
";",
"offset",
".",
"top",
"-=",
"parentOffset",
".",
"top",
";",
"offset",
".",
"left",
"-=",
"parentOffset",
".",
"left",
";",
"}",
"position",
".",
"top",
"+=",
"offset",
".",
"top",
";",
"position",
".",
"left",
"+=",
"offset",
".",
"left",
";",
"return",
"position",
";",
"}"
] |
Returns the caret's relative coordinates from body's left top corner.
|
[
"Returns",
"the",
"caret",
"s",
"relative",
"coordinates",
"from",
"body",
"s",
"left",
"top",
"corner",
"."
] |
3aa8a1b2e74a451f0017ce700ebcf2c405a25184
|
https://github.com/yuku/jquery-textcomplete/blob/3aa8a1b2e74a451f0017ce700ebcf2c405a25184/src/adapter.js#L79-L95
|
|
19,792
|
yuku/jquery-textcomplete
|
src/completer.js
|
function (text, skipUnchangedTerm) {
if (!this.dropdown) { this.initialize(); }
text != null || (text = this.adapter.getTextFromHeadToCaret());
var searchQuery = this._extractSearchQuery(text);
if (searchQuery.length) {
var term = searchQuery[1];
// Ignore shift-key, ctrl-key and so on.
if (skipUnchangedTerm && this._term === term && term !== "") { return; }
this._term = term;
this._search.apply(this, searchQuery);
} else {
this._term = null;
this.dropdown.deactivate();
}
}
|
javascript
|
function (text, skipUnchangedTerm) {
if (!this.dropdown) { this.initialize(); }
text != null || (text = this.adapter.getTextFromHeadToCaret());
var searchQuery = this._extractSearchQuery(text);
if (searchQuery.length) {
var term = searchQuery[1];
// Ignore shift-key, ctrl-key and so on.
if (skipUnchangedTerm && this._term === term && term !== "") { return; }
this._term = term;
this._search.apply(this, searchQuery);
} else {
this._term = null;
this.dropdown.deactivate();
}
}
|
[
"function",
"(",
"text",
",",
"skipUnchangedTerm",
")",
"{",
"if",
"(",
"!",
"this",
".",
"dropdown",
")",
"{",
"this",
".",
"initialize",
"(",
")",
";",
"}",
"text",
"!=",
"null",
"||",
"(",
"text",
"=",
"this",
".",
"adapter",
".",
"getTextFromHeadToCaret",
"(",
")",
")",
";",
"var",
"searchQuery",
"=",
"this",
".",
"_extractSearchQuery",
"(",
"text",
")",
";",
"if",
"(",
"searchQuery",
".",
"length",
")",
"{",
"var",
"term",
"=",
"searchQuery",
"[",
"1",
"]",
";",
"// Ignore shift-key, ctrl-key and so on.",
"if",
"(",
"skipUnchangedTerm",
"&&",
"this",
".",
"_term",
"===",
"term",
"&&",
"term",
"!==",
"\"\"",
")",
"{",
"return",
";",
"}",
"this",
".",
"_term",
"=",
"term",
";",
"this",
".",
"_search",
".",
"apply",
"(",
"this",
",",
"searchQuery",
")",
";",
"}",
"else",
"{",
"this",
".",
"_term",
"=",
"null",
";",
"this",
".",
"dropdown",
".",
"deactivate",
"(",
")",
";",
"}",
"}"
] |
Invoke textcomplete.
|
[
"Invoke",
"textcomplete",
"."
] |
3aa8a1b2e74a451f0017ce700ebcf2c405a25184
|
https://github.com/yuku/jquery-textcomplete/blob/3aa8a1b2e74a451f0017ce700ebcf2c405a25184/src/completer.js#L182-L196
|
|
19,793
|
yuku/jquery-textcomplete
|
src/completer.js
|
function (value, strategy, e) {
this._term = null;
this.adapter.select(value, strategy, e);
this.fire('change').fire('textComplete:select', value, strategy);
this.adapter.focus();
}
|
javascript
|
function (value, strategy, e) {
this._term = null;
this.adapter.select(value, strategy, e);
this.fire('change').fire('textComplete:select', value, strategy);
this.adapter.focus();
}
|
[
"function",
"(",
"value",
",",
"strategy",
",",
"e",
")",
"{",
"this",
".",
"_term",
"=",
"null",
";",
"this",
".",
"adapter",
".",
"select",
"(",
"value",
",",
"strategy",
",",
"e",
")",
";",
"this",
".",
"fire",
"(",
"'change'",
")",
".",
"fire",
"(",
"'textComplete:select'",
",",
"value",
",",
"strategy",
")",
";",
"this",
".",
"adapter",
".",
"focus",
"(",
")",
";",
"}"
] |
Insert the value into adapter view. It is called when the dropdown is clicked or selected. value - The selected element of the array callbacked from search func. strategy - The Strategy object. e - Click or keydown event object.
|
[
"Insert",
"the",
"value",
"into",
"adapter",
"view",
".",
"It",
"is",
"called",
"when",
"the",
"dropdown",
"is",
"clicked",
"or",
"selected",
".",
"value",
"-",
"The",
"selected",
"element",
"of",
"the",
"array",
"callbacked",
"from",
"search",
"func",
".",
"strategy",
"-",
"The",
"Strategy",
"object",
".",
"e",
"-",
"Click",
"or",
"keydown",
"event",
"object",
"."
] |
3aa8a1b2e74a451f0017ce700ebcf2c405a25184
|
https://github.com/yuku/jquery-textcomplete/blob/3aa8a1b2e74a451f0017ce700ebcf2c405a25184/src/completer.js#L214-L219
|
|
19,794
|
yuku/jquery-textcomplete
|
src/completer.js
|
function (text) {
for (var i = 0; i < this.strategies.length; i++) {
var strategy = this.strategies[i];
var context = strategy.context(text);
if (context || context === '') {
var matchRegexp = $.isFunction(strategy.match) ? strategy.match(text) : strategy.match;
if (isString(context)) { text = context; }
var match = text.match(matchRegexp);
if (match) { return [strategy, match[strategy.index], match]; }
}
}
return []
}
|
javascript
|
function (text) {
for (var i = 0; i < this.strategies.length; i++) {
var strategy = this.strategies[i];
var context = strategy.context(text);
if (context || context === '') {
var matchRegexp = $.isFunction(strategy.match) ? strategy.match(text) : strategy.match;
if (isString(context)) { text = context; }
var match = text.match(matchRegexp);
if (match) { return [strategy, match[strategy.index], match]; }
}
}
return []
}
|
[
"function",
"(",
"text",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"strategies",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"strategy",
"=",
"this",
".",
"strategies",
"[",
"i",
"]",
";",
"var",
"context",
"=",
"strategy",
".",
"context",
"(",
"text",
")",
";",
"if",
"(",
"context",
"||",
"context",
"===",
"''",
")",
"{",
"var",
"matchRegexp",
"=",
"$",
".",
"isFunction",
"(",
"strategy",
".",
"match",
")",
"?",
"strategy",
".",
"match",
"(",
"text",
")",
":",
"strategy",
".",
"match",
";",
"if",
"(",
"isString",
"(",
"context",
")",
")",
"{",
"text",
"=",
"context",
";",
"}",
"var",
"match",
"=",
"text",
".",
"match",
"(",
"matchRegexp",
")",
";",
"if",
"(",
"match",
")",
"{",
"return",
"[",
"strategy",
",",
"match",
"[",
"strategy",
".",
"index",
"]",
",",
"match",
"]",
";",
"}",
"}",
"}",
"return",
"[",
"]",
"}"
] |
Parse the given text and extract the first matching strategy. Returns an array including the strategy, the query term and the match object if the text matches an strategy; otherwise returns an empty array.
|
[
"Parse",
"the",
"given",
"text",
"and",
"extract",
"the",
"first",
"matching",
"strategy",
".",
"Returns",
"an",
"array",
"including",
"the",
"strategy",
"the",
"query",
"term",
"and",
"the",
"match",
"object",
"if",
"the",
"text",
"matches",
"an",
"strategy",
";",
"otherwise",
"returns",
"an",
"empty",
"array",
"."
] |
3aa8a1b2e74a451f0017ce700ebcf2c405a25184
|
https://github.com/yuku/jquery-textcomplete/blob/3aa8a1b2e74a451f0017ce700ebcf2c405a25184/src/completer.js#L234-L246
|
|
19,795
|
yeoman/environment
|
lib/environment.js
|
splitArgsFromString
|
function splitArgsFromString(argsString) {
let result = [];
const quoteSeparatedArgs = argsString.split(/(\x22[^\x22]*\x22)/).filter(x => x);
quoteSeparatedArgs.forEach(arg => {
if (arg.match('\x22')) {
result.push(arg.replace(/\x22/g, ''));
} else {
result = result.concat(arg.trim().split(' '));
}
});
return result;
}
|
javascript
|
function splitArgsFromString(argsString) {
let result = [];
const quoteSeparatedArgs = argsString.split(/(\x22[^\x22]*\x22)/).filter(x => x);
quoteSeparatedArgs.forEach(arg => {
if (arg.match('\x22')) {
result.push(arg.replace(/\x22/g, ''));
} else {
result = result.concat(arg.trim().split(' '));
}
});
return result;
}
|
[
"function",
"splitArgsFromString",
"(",
"argsString",
")",
"{",
"let",
"result",
"=",
"[",
"]",
";",
"const",
"quoteSeparatedArgs",
"=",
"argsString",
".",
"split",
"(",
"/",
"(\\x22[^\\x22]*\\x22)",
"/",
")",
".",
"filter",
"(",
"x",
"=>",
"x",
")",
";",
"quoteSeparatedArgs",
".",
"forEach",
"(",
"arg",
"=>",
"{",
"if",
"(",
"arg",
".",
"match",
"(",
"'\\x22'",
")",
")",
"{",
"result",
".",
"push",
"(",
"arg",
".",
"replace",
"(",
"/",
"\\x22",
"/",
"g",
",",
"''",
")",
")",
";",
"}",
"else",
"{",
"result",
"=",
"result",
".",
"concat",
"(",
"arg",
".",
"trim",
"(",
")",
".",
"split",
"(",
"' '",
")",
")",
";",
"}",
"}",
")",
";",
"return",
"result",
";",
"}"
] |
Two-step argument splitting function that first splits arguments in quotes,
and then splits up the remaining arguments if they are not part of a quote.
|
[
"Two",
"-",
"step",
"argument",
"splitting",
"function",
"that",
"first",
"splits",
"arguments",
"in",
"quotes",
"and",
"then",
"splits",
"up",
"the",
"remaining",
"arguments",
"if",
"they",
"are",
"not",
"part",
"of",
"a",
"quote",
"."
] |
c2143b40209b5358b709eb07698ba0b98de59da2
|
https://github.com/yeoman/environment/blob/c2143b40209b5358b709eb07698ba0b98de59da2/lib/environment.js#L21-L32
|
19,796
|
eggjs/egg-mock
|
lib/mock_httpclient.js
|
_request
|
function _request(url, opt) {
opt = opt || {};
opt.method = (opt.method || 'GET').toUpperCase();
opt.headers = opt.headers || {};
if (matchUrl(url) && matchMethod(opt.method)) {
const result = extend(true, {}, mockResult);
const response = {
status: result.status,
statusCode: result.status,
headers: result.headers,
size: result.responseSize,
aborted: false,
rt: 1,
keepAliveSocket: result.keepAliveSocket || false,
};
httpclient.emit('response', {
error: null,
ctx: opt.ctx,
req: {
url,
options: opt,
size: result.requestSize,
},
res: response,
});
if (opt.dataType === 'json') {
try {
result.data = JSON.parse(result.data);
} catch (err) {
err.name = 'JSONResponseFormatError';
throw err;
}
} else if (opt.dataType === 'text') {
result.data = result.data.toString();
}
return Promise.resolve(result);
}
return rawRequest.call(httpclient, url, opt);
}
|
javascript
|
function _request(url, opt) {
opt = opt || {};
opt.method = (opt.method || 'GET').toUpperCase();
opt.headers = opt.headers || {};
if (matchUrl(url) && matchMethod(opt.method)) {
const result = extend(true, {}, mockResult);
const response = {
status: result.status,
statusCode: result.status,
headers: result.headers,
size: result.responseSize,
aborted: false,
rt: 1,
keepAliveSocket: result.keepAliveSocket || false,
};
httpclient.emit('response', {
error: null,
ctx: opt.ctx,
req: {
url,
options: opt,
size: result.requestSize,
},
res: response,
});
if (opt.dataType === 'json') {
try {
result.data = JSON.parse(result.data);
} catch (err) {
err.name = 'JSONResponseFormatError';
throw err;
}
} else if (opt.dataType === 'text') {
result.data = result.data.toString();
}
return Promise.resolve(result);
}
return rawRequest.call(httpclient, url, opt);
}
|
[
"function",
"_request",
"(",
"url",
",",
"opt",
")",
"{",
"opt",
"=",
"opt",
"||",
"{",
"}",
";",
"opt",
".",
"method",
"=",
"(",
"opt",
".",
"method",
"||",
"'GET'",
")",
".",
"toUpperCase",
"(",
")",
";",
"opt",
".",
"headers",
"=",
"opt",
".",
"headers",
"||",
"{",
"}",
";",
"if",
"(",
"matchUrl",
"(",
"url",
")",
"&&",
"matchMethod",
"(",
"opt",
".",
"method",
")",
")",
"{",
"const",
"result",
"=",
"extend",
"(",
"true",
",",
"{",
"}",
",",
"mockResult",
")",
";",
"const",
"response",
"=",
"{",
"status",
":",
"result",
".",
"status",
",",
"statusCode",
":",
"result",
".",
"status",
",",
"headers",
":",
"result",
".",
"headers",
",",
"size",
":",
"result",
".",
"responseSize",
",",
"aborted",
":",
"false",
",",
"rt",
":",
"1",
",",
"keepAliveSocket",
":",
"result",
".",
"keepAliveSocket",
"||",
"false",
",",
"}",
";",
"httpclient",
".",
"emit",
"(",
"'response'",
",",
"{",
"error",
":",
"null",
",",
"ctx",
":",
"opt",
".",
"ctx",
",",
"req",
":",
"{",
"url",
",",
"options",
":",
"opt",
",",
"size",
":",
"result",
".",
"requestSize",
",",
"}",
",",
"res",
":",
"response",
",",
"}",
")",
";",
"if",
"(",
"opt",
".",
"dataType",
"===",
"'json'",
")",
"{",
"try",
"{",
"result",
".",
"data",
"=",
"JSON",
".",
"parse",
"(",
"result",
".",
"data",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"err",
".",
"name",
"=",
"'JSONResponseFormatError'",
";",
"throw",
"err",
";",
"}",
"}",
"else",
"if",
"(",
"opt",
".",
"dataType",
"===",
"'text'",
")",
"{",
"result",
".",
"data",
"=",
"result",
".",
"data",
".",
"toString",
"(",
")",
";",
"}",
"return",
"Promise",
".",
"resolve",
"(",
"result",
")",
";",
"}",
"return",
"rawRequest",
".",
"call",
"(",
"httpclient",
",",
"url",
",",
"opt",
")",
";",
"}"
] |
support generator rather than callback and promise
|
[
"support",
"generator",
"rather",
"than",
"callback",
"and",
"promise"
] |
b6549fa3e0bcf6d90cf6e2132734d6c1b03ddae3
|
https://github.com/eggjs/egg-mock/blob/b6549fa3e0bcf6d90cf6e2132734d6c1b03ddae3/lib/mock_httpclient.js#L74-L113
|
19,797
|
wilzbach/msa
|
src/views/canvas/CanvasSelection.js
|
function(data) {
const seq = data.model.get("seq");
const selection = this._getSelection(data.model);
// get the status of the upper and lower row
const getNextPrev= this._getPrevNextSelection(data.model);
const mPrevSel = getNextPrev[0];
const mNextSel = getNextPrev[1];
const boxWidth = this.g.zoomer.get("columnWidth");
const boxHeight = this.g.zoomer.get("rowHeight");
// avoid unnecessary loops
if (selection.length === 0) { return; }
let hiddenOffset = 0;
return (() => {
const result = [];
const end = seq.length - 1;
for (let n = 0; n <= end; n++) {
result.push((() => {
if (data.hidden.indexOf(n) >= 0) {
return hiddenOffset++;
} else {
const k = n - hiddenOffset;
// only if its a new selection
if (selection.indexOf(n) >= 0 && (k === 0 || selection.indexOf(n - 1) < 0 )) {
return this._renderSelection({n:n,
k:k,
selection: selection,
mPrevSel: mPrevSel,
mNextSel:mNextSel,
xZero: data.xZero,
yZero: data.yZero,
model: data.model});
}
}
})());
}
return result;
})();
}
|
javascript
|
function(data) {
const seq = data.model.get("seq");
const selection = this._getSelection(data.model);
// get the status of the upper and lower row
const getNextPrev= this._getPrevNextSelection(data.model);
const mPrevSel = getNextPrev[0];
const mNextSel = getNextPrev[1];
const boxWidth = this.g.zoomer.get("columnWidth");
const boxHeight = this.g.zoomer.get("rowHeight");
// avoid unnecessary loops
if (selection.length === 0) { return; }
let hiddenOffset = 0;
return (() => {
const result = [];
const end = seq.length - 1;
for (let n = 0; n <= end; n++) {
result.push((() => {
if (data.hidden.indexOf(n) >= 0) {
return hiddenOffset++;
} else {
const k = n - hiddenOffset;
// only if its a new selection
if (selection.indexOf(n) >= 0 && (k === 0 || selection.indexOf(n - 1) < 0 )) {
return this._renderSelection({n:n,
k:k,
selection: selection,
mPrevSel: mPrevSel,
mNextSel:mNextSel,
xZero: data.xZero,
yZero: data.yZero,
model: data.model});
}
}
})());
}
return result;
})();
}
|
[
"function",
"(",
"data",
")",
"{",
"const",
"seq",
"=",
"data",
".",
"model",
".",
"get",
"(",
"\"seq\"",
")",
";",
"const",
"selection",
"=",
"this",
".",
"_getSelection",
"(",
"data",
".",
"model",
")",
";",
"// get the status of the upper and lower row",
"const",
"getNextPrev",
"=",
"this",
".",
"_getPrevNextSelection",
"(",
"data",
".",
"model",
")",
";",
"const",
"mPrevSel",
"=",
"getNextPrev",
"[",
"0",
"]",
";",
"const",
"mNextSel",
"=",
"getNextPrev",
"[",
"1",
"]",
";",
"const",
"boxWidth",
"=",
"this",
".",
"g",
".",
"zoomer",
".",
"get",
"(",
"\"columnWidth\"",
")",
";",
"const",
"boxHeight",
"=",
"this",
".",
"g",
".",
"zoomer",
".",
"get",
"(",
"\"rowHeight\"",
")",
";",
"// avoid unnecessary loops",
"if",
"(",
"selection",
".",
"length",
"===",
"0",
")",
"{",
"return",
";",
"}",
"let",
"hiddenOffset",
"=",
"0",
";",
"return",
"(",
"(",
")",
"=>",
"{",
"const",
"result",
"=",
"[",
"]",
";",
"const",
"end",
"=",
"seq",
".",
"length",
"-",
"1",
";",
"for",
"(",
"let",
"n",
"=",
"0",
";",
"n",
"<=",
"end",
";",
"n",
"++",
")",
"{",
"result",
".",
"push",
"(",
"(",
"(",
")",
"=>",
"{",
"if",
"(",
"data",
".",
"hidden",
".",
"indexOf",
"(",
"n",
")",
">=",
"0",
")",
"{",
"return",
"hiddenOffset",
"++",
";",
"}",
"else",
"{",
"const",
"k",
"=",
"n",
"-",
"hiddenOffset",
";",
"// only if its a new selection",
"if",
"(",
"selection",
".",
"indexOf",
"(",
"n",
")",
">=",
"0",
"&&",
"(",
"k",
"===",
"0",
"||",
"selection",
".",
"indexOf",
"(",
"n",
"-",
"1",
")",
"<",
"0",
")",
")",
"{",
"return",
"this",
".",
"_renderSelection",
"(",
"{",
"n",
":",
"n",
",",
"k",
":",
"k",
",",
"selection",
":",
"selection",
",",
"mPrevSel",
":",
"mPrevSel",
",",
"mNextSel",
":",
"mNextSel",
",",
"xZero",
":",
"data",
".",
"xZero",
",",
"yZero",
":",
"data",
".",
"yZero",
",",
"model",
":",
"data",
".",
"model",
"}",
")",
";",
"}",
"}",
"}",
")",
"(",
")",
")",
";",
"}",
"return",
"result",
";",
"}",
")",
"(",
")",
";",
"}"
] |
loops over all selection and calls the render method
|
[
"loops",
"over",
"all",
"selection",
"and",
"calls",
"the",
"render",
"method"
] |
47042e8c3574fb62fad3b94de04183e5a0b09a97
|
https://github.com/wilzbach/msa/blob/47042e8c3574fb62fad3b94de04183e5a0b09a97/src/views/canvas/CanvasSelection.js#L41-L81
|
|
19,798
|
wilzbach/msa
|
src/views/canvas/CanvasSelection.js
|
function(data) {
let xZero = data.xZero;
const yZero = data.yZero;
const n = data.n;
const k = data.k;
const selection = data.selection;
// and checks the prev and next row for selection -> no borders in a selection
const mPrevSel= data.mPrevSel;
const mNextSel = data.mNextSel;
// get the length of this selection
let selectionLength = 0;
const end = data.model.get("seq").length - 1;
for (let i = n; i <= end; i++) {
if (selection.indexOf(i) >= 0) {
selectionLength++;
} else {
break;
}
}
// TODO: ugly!
const boxWidth = this.g.zoomer.get("columnWidth");
const boxHeight = this.g.zoomer.get("rowHeight");
const totalWidth = (boxWidth * selectionLength) + 1;
const hidden = this.g.columns.get('hidden');
this.ctx.beginPath();
const beforeWidth = this.ctx.lineWidth;
this.ctx.lineWidth = 3;
const beforeStyle = this.ctx.strokeStyle;
this.ctx.strokeStyle = "#FF0000";
xZero += k * boxWidth;
// split up the selection into single cells
let xPart = 0;
const end1 = selectionLength - 1;
for (let i = 0; i <= end1; i++) {
let xPos = n + i;
if (hidden.indexOf(xPos) >= 0) {
continue;
}
// upper line
if (!((typeof mPrevSel !== "undefined" && mPrevSel !== null) && mPrevSel.indexOf(xPos) >= 0)) {
this.ctx.moveTo(xZero + xPart, yZero);
this.ctx.lineTo(xPart + boxWidth + xZero, yZero);
}
// lower line
if (!((typeof mNextSel !== "undefined" && mNextSel !== null) && mNextSel.indexOf(xPos) >= 0)) {
this.ctx.moveTo(xPart + xZero, boxHeight + yZero);
this.ctx.lineTo(xPart + boxWidth + xZero, boxHeight + yZero);
}
xPart += boxWidth;
}
// left
this.ctx.moveTo(xZero,yZero);
this.ctx.lineTo(xZero, boxHeight + yZero);
// right
this.ctx.moveTo(xZero + totalWidth,yZero);
this.ctx.lineTo(xZero + totalWidth, boxHeight + yZero);
this.ctx.stroke();
this.ctx.strokeStyle = beforeStyle;
return this.ctx.lineWidth = beforeWidth;
}
|
javascript
|
function(data) {
let xZero = data.xZero;
const yZero = data.yZero;
const n = data.n;
const k = data.k;
const selection = data.selection;
// and checks the prev and next row for selection -> no borders in a selection
const mPrevSel= data.mPrevSel;
const mNextSel = data.mNextSel;
// get the length of this selection
let selectionLength = 0;
const end = data.model.get("seq").length - 1;
for (let i = n; i <= end; i++) {
if (selection.indexOf(i) >= 0) {
selectionLength++;
} else {
break;
}
}
// TODO: ugly!
const boxWidth = this.g.zoomer.get("columnWidth");
const boxHeight = this.g.zoomer.get("rowHeight");
const totalWidth = (boxWidth * selectionLength) + 1;
const hidden = this.g.columns.get('hidden');
this.ctx.beginPath();
const beforeWidth = this.ctx.lineWidth;
this.ctx.lineWidth = 3;
const beforeStyle = this.ctx.strokeStyle;
this.ctx.strokeStyle = "#FF0000";
xZero += k * boxWidth;
// split up the selection into single cells
let xPart = 0;
const end1 = selectionLength - 1;
for (let i = 0; i <= end1; i++) {
let xPos = n + i;
if (hidden.indexOf(xPos) >= 0) {
continue;
}
// upper line
if (!((typeof mPrevSel !== "undefined" && mPrevSel !== null) && mPrevSel.indexOf(xPos) >= 0)) {
this.ctx.moveTo(xZero + xPart, yZero);
this.ctx.lineTo(xPart + boxWidth + xZero, yZero);
}
// lower line
if (!((typeof mNextSel !== "undefined" && mNextSel !== null) && mNextSel.indexOf(xPos) >= 0)) {
this.ctx.moveTo(xPart + xZero, boxHeight + yZero);
this.ctx.lineTo(xPart + boxWidth + xZero, boxHeight + yZero);
}
xPart += boxWidth;
}
// left
this.ctx.moveTo(xZero,yZero);
this.ctx.lineTo(xZero, boxHeight + yZero);
// right
this.ctx.moveTo(xZero + totalWidth,yZero);
this.ctx.lineTo(xZero + totalWidth, boxHeight + yZero);
this.ctx.stroke();
this.ctx.strokeStyle = beforeStyle;
return this.ctx.lineWidth = beforeWidth;
}
|
[
"function",
"(",
"data",
")",
"{",
"let",
"xZero",
"=",
"data",
".",
"xZero",
";",
"const",
"yZero",
"=",
"data",
".",
"yZero",
";",
"const",
"n",
"=",
"data",
".",
"n",
";",
"const",
"k",
"=",
"data",
".",
"k",
";",
"const",
"selection",
"=",
"data",
".",
"selection",
";",
"// and checks the prev and next row for selection -> no borders in a selection",
"const",
"mPrevSel",
"=",
"data",
".",
"mPrevSel",
";",
"const",
"mNextSel",
"=",
"data",
".",
"mNextSel",
";",
"// get the length of this selection",
"let",
"selectionLength",
"=",
"0",
";",
"const",
"end",
"=",
"data",
".",
"model",
".",
"get",
"(",
"\"seq\"",
")",
".",
"length",
"-",
"1",
";",
"for",
"(",
"let",
"i",
"=",
"n",
";",
"i",
"<=",
"end",
";",
"i",
"++",
")",
"{",
"if",
"(",
"selection",
".",
"indexOf",
"(",
"i",
")",
">=",
"0",
")",
"{",
"selectionLength",
"++",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"// TODO: ugly!",
"const",
"boxWidth",
"=",
"this",
".",
"g",
".",
"zoomer",
".",
"get",
"(",
"\"columnWidth\"",
")",
";",
"const",
"boxHeight",
"=",
"this",
".",
"g",
".",
"zoomer",
".",
"get",
"(",
"\"rowHeight\"",
")",
";",
"const",
"totalWidth",
"=",
"(",
"boxWidth",
"*",
"selectionLength",
")",
"+",
"1",
";",
"const",
"hidden",
"=",
"this",
".",
"g",
".",
"columns",
".",
"get",
"(",
"'hidden'",
")",
";",
"this",
".",
"ctx",
".",
"beginPath",
"(",
")",
";",
"const",
"beforeWidth",
"=",
"this",
".",
"ctx",
".",
"lineWidth",
";",
"this",
".",
"ctx",
".",
"lineWidth",
"=",
"3",
";",
"const",
"beforeStyle",
"=",
"this",
".",
"ctx",
".",
"strokeStyle",
";",
"this",
".",
"ctx",
".",
"strokeStyle",
"=",
"\"#FF0000\"",
";",
"xZero",
"+=",
"k",
"*",
"boxWidth",
";",
"// split up the selection into single cells",
"let",
"xPart",
"=",
"0",
";",
"const",
"end1",
"=",
"selectionLength",
"-",
"1",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<=",
"end1",
";",
"i",
"++",
")",
"{",
"let",
"xPos",
"=",
"n",
"+",
"i",
";",
"if",
"(",
"hidden",
".",
"indexOf",
"(",
"xPos",
")",
">=",
"0",
")",
"{",
"continue",
";",
"}",
"// upper line",
"if",
"(",
"!",
"(",
"(",
"typeof",
"mPrevSel",
"!==",
"\"undefined\"",
"&&",
"mPrevSel",
"!==",
"null",
")",
"&&",
"mPrevSel",
".",
"indexOf",
"(",
"xPos",
")",
">=",
"0",
")",
")",
"{",
"this",
".",
"ctx",
".",
"moveTo",
"(",
"xZero",
"+",
"xPart",
",",
"yZero",
")",
";",
"this",
".",
"ctx",
".",
"lineTo",
"(",
"xPart",
"+",
"boxWidth",
"+",
"xZero",
",",
"yZero",
")",
";",
"}",
"// lower line",
"if",
"(",
"!",
"(",
"(",
"typeof",
"mNextSel",
"!==",
"\"undefined\"",
"&&",
"mNextSel",
"!==",
"null",
")",
"&&",
"mNextSel",
".",
"indexOf",
"(",
"xPos",
")",
">=",
"0",
")",
")",
"{",
"this",
".",
"ctx",
".",
"moveTo",
"(",
"xPart",
"+",
"xZero",
",",
"boxHeight",
"+",
"yZero",
")",
";",
"this",
".",
"ctx",
".",
"lineTo",
"(",
"xPart",
"+",
"boxWidth",
"+",
"xZero",
",",
"boxHeight",
"+",
"yZero",
")",
";",
"}",
"xPart",
"+=",
"boxWidth",
";",
"}",
"// left",
"this",
".",
"ctx",
".",
"moveTo",
"(",
"xZero",
",",
"yZero",
")",
";",
"this",
".",
"ctx",
".",
"lineTo",
"(",
"xZero",
",",
"boxHeight",
"+",
"yZero",
")",
";",
"// right",
"this",
".",
"ctx",
".",
"moveTo",
"(",
"xZero",
"+",
"totalWidth",
",",
"yZero",
")",
";",
"this",
".",
"ctx",
".",
"lineTo",
"(",
"xZero",
"+",
"totalWidth",
",",
"boxHeight",
"+",
"yZero",
")",
";",
"this",
".",
"ctx",
".",
"stroke",
"(",
")",
";",
"this",
".",
"ctx",
".",
"strokeStyle",
"=",
"beforeStyle",
";",
"return",
"this",
".",
"ctx",
".",
"lineWidth",
"=",
"beforeWidth",
";",
"}"
] |
draws a single user selection
|
[
"draws",
"a",
"single",
"user",
"selection"
] |
47042e8c3574fb62fad3b94de04183e5a0b09a97
|
https://github.com/wilzbach/msa/blob/47042e8c3574fb62fad3b94de04183e5a0b09a97/src/views/canvas/CanvasSelection.js#L84-L154
|
|
19,799
|
wilzbach/msa
|
src/g/zoomer.js
|
function(model) {
var maxLen = model.getMaxLength();
if (maxLen < 200 && model.length < 30) {
this.defaults.boxRectWidth = this.defaults.boxRectHeight = 5;
}
return this;
}
|
javascript
|
function(model) {
var maxLen = model.getMaxLength();
if (maxLen < 200 && model.length < 30) {
this.defaults.boxRectWidth = this.defaults.boxRectHeight = 5;
}
return this;
}
|
[
"function",
"(",
"model",
")",
"{",
"var",
"maxLen",
"=",
"model",
".",
"getMaxLength",
"(",
")",
";",
"if",
"(",
"maxLen",
"<",
"200",
"&&",
"model",
".",
"length",
"<",
"30",
")",
"{",
"this",
".",
"defaults",
".",
"boxRectWidth",
"=",
"this",
".",
"defaults",
".",
"boxRectHeight",
"=",
"5",
";",
"}",
"return",
"this",
";",
"}"
] |
sets some defaults, depending on the model
|
[
"sets",
"some",
"defaults",
"depending",
"on",
"the",
"model"
] |
47042e8c3574fb62fad3b94de04183e5a0b09a97
|
https://github.com/wilzbach/msa/blob/47042e8c3574fb62fad3b94de04183e5a0b09a97/src/g/zoomer.js#L70-L76
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.