language
stringclasses 6
values | original_string
stringlengths 25
887k
| text
stringlengths 25
887k
|
---|---|---|
JavaScript | function optionsRequestDataProcessing(){
if ($scope[list.name] !== undefined) {
$scope[list.name].forEach(function(item, item_idx) {
var itm = $scope[list.name][item_idx];
// Set the item type label
if (list.fields.scm_type && $scope.options &&
$scope.options.hasOwnProperty('scm_type')) {
$scope.options.scm_type.choices.forEach(function(choice) {
if (choice[0] === item.scm_type) {
itm.type_label = choice[1];
}
});
}
buildTooltips(itm);
});
}
} | function optionsRequestDataProcessing(){
if ($scope[list.name] !== undefined) {
$scope[list.name].forEach(function(item, item_idx) {
var itm = $scope[list.name][item_idx];
// Set the item type label
if (list.fields.scm_type && $scope.options &&
$scope.options.hasOwnProperty('scm_type')) {
$scope.options.scm_type.choices.forEach(function(choice) {
if (choice[0] === item.scm_type) {
itm.type_label = choice[1];
}
});
}
buildTooltips(itm);
});
}
} |
JavaScript | function optionsRequestDataProcessing(){
if(scope.list.name === 'projects'){
if (scope[list.name] !== undefined) {
scope[list.name].forEach(function(item, item_idx) {
var itm = scope[list.name][item_idx];
// Set the item type label
if (list.fields.scm_type && scope.options &&
scope.options.hasOwnProperty('scm_type')) {
scope.options.scm_type.choices.forEach(function(choice) {
if (choice[0] === item.scm_type) {
itm.type_label = choice[1];
}
});
}
});
}
}
else if(scope.list.name === 'inventories') {
if (scope[list.name] !== undefined) {
scope[list.name].forEach(function(item, item_idx) {
var itm = scope[list.name][item_idx];
if(itm.kind && itm.kind === "smart") {
itm.linkToDetails = `#/inventories/smart/${itm.id}`;
}
else {
itm.linkToDetails = `#/inventories/inventory/${itm.id}`;
}
});
}
}
} | function optionsRequestDataProcessing(){
if(scope.list.name === 'projects'){
if (scope[list.name] !== undefined) {
scope[list.name].forEach(function(item, item_idx) {
var itm = scope[list.name][item_idx];
// Set the item type label
if (list.fields.scm_type && scope.options &&
scope.options.hasOwnProperty('scm_type')) {
scope.options.scm_type.choices.forEach(function(choice) {
if (choice[0] === item.scm_type) {
itm.type_label = choice[1];
}
});
}
});
}
}
else if(scope.list.name === 'inventories') {
if (scope[list.name] !== undefined) {
scope[list.name].forEach(function(item, item_idx) {
var itm = scope[list.name][item_idx];
if(itm.kind && itm.kind === "smart") {
itm.linkToDetails = `#/inventories/smart/${itm.id}`;
}
else {
itm.linkToDetails = `#/inventories/inventory/${itm.id}`;
}
});
}
}
} |
JavaScript | function fetchOEmbed(url) {
return fetch(`${OEMBED_URL}?url=${encodeURIComponent(url)}`)
.then(checkStatus)
.then(response => response.json());
} | function fetchOEmbed(url) {
return fetch(`${OEMBED_URL}?url=${encodeURIComponent(url)}`)
.then(checkStatus)
.then(response => response.json());
} |
JavaScript | runJs(code) {
return new Promise((resolve, reject) => {
this.webview.executeScript({
code: `
;(function() {
${code}
})();
`,
}, (results) => {
if (chrome && chrome.runtime && chrome.runtime.lastError) {
return reject(new Error(`Chrome last error: ${chrome.runtime.lastError.message || 'undefined'}`));
}
return resolve(results && results[0]);
});
});
} | runJs(code) {
return new Promise((resolve, reject) => {
this.webview.executeScript({
code: `
;(function() {
${code}
})();
`,
}, (results) => {
if (chrome && chrome.runtime && chrome.runtime.lastError) {
return reject(new Error(`Chrome last error: ${chrome.runtime.lastError.message || 'undefined'}`));
}
return resolve(results && results[0]);
});
});
} |
JavaScript | length(selector) {
const _s = Webview.replaceWrongQuotes(selector);
return this.runJs(`
return document.querySelectorAll('${_s}').length;
`);
} | length(selector) {
const _s = Webview.replaceWrongQuotes(selector);
return this.runJs(`
return document.querySelectorAll('${_s}').length;
`);
} |
JavaScript | text(selector, value) {
const _s = Webview.replaceWrongQuotes(selector);
if (typeof value === 'undefined') {
return this.runJs(`
let _getText = el => {
if (!el) return '';
if ([Node.ELEMENT_NODE, Node.DOCUMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE].includes(el.nodeType)) {
if (typeof el.textContent === 'string') {
return el.textContent;
}
let result = [];
for (el = el.firstChild; el; el = el.nextSibling) {
result.push(_getText(el));
}
return result.join('');
}
if ([Node.TEXT_NODE, Node.CDATA_SECTION_NODE].includes(el.nodeType)) {
return el.nodeValue;
}
if (!el.nodeType) {
let node;
let i = 0;
let result =[];
while (node = el[i++]) {
result.push(_getText(node));
}
return result.join('');
}
};
return _getText(document.querySelectorAll('${_s}'));
`);
}
return this.runJs(`
document.querySelectorAll('${_s}')
.forEach(el => el.textContent = '${value}');
`);
} | text(selector, value) {
const _s = Webview.replaceWrongQuotes(selector);
if (typeof value === 'undefined') {
return this.runJs(`
let _getText = el => {
if (!el) return '';
if ([Node.ELEMENT_NODE, Node.DOCUMENT_NODE, Node.DOCUMENT_FRAGMENT_NODE].includes(el.nodeType)) {
if (typeof el.textContent === 'string') {
return el.textContent;
}
let result = [];
for (el = el.firstChild; el; el = el.nextSibling) {
result.push(_getText(el));
}
return result.join('');
}
if ([Node.TEXT_NODE, Node.CDATA_SECTION_NODE].includes(el.nodeType)) {
return el.nodeValue;
}
if (!el.nodeType) {
let node;
let i = 0;
let result =[];
while (node = el[i++]) {
result.push(_getText(node));
}
return result.join('');
}
};
return _getText(document.querySelectorAll('${_s}'));
`);
}
return this.runJs(`
document.querySelectorAll('${_s}')
.forEach(el => el.textContent = '${value}');
`);
} |
JavaScript | plot(rawData) {
var data = this.prePlot(rawData);
var obj = this;
this.canvas.selectAll("rect.bar")
.data(data)
.enter()
.append("rect")
.attr("class", "bar pub resizable")
.attr("height", 0)
.attr("y", obj.height)
.call(this.getAttr, this, ["x", "width", "fill"]);
// add the x Axis
this.canvas
.append("g")
.attr("class", "xAxis axis pub resizable")
.call(this.getXAxis, this);
// add the y Axis
this.canvas
.append("g")
.attr("class", "yAxis axis pub resizable")
.call(this.getYAxis, this, data);
this.makePubBtn();
this.postPlot(data);
} | plot(rawData) {
var data = this.prePlot(rawData);
var obj = this;
this.canvas.selectAll("rect.bar")
.data(data)
.enter()
.append("rect")
.attr("class", "bar pub resizable")
.attr("height", 0)
.attr("y", obj.height)
.call(this.getAttr, this, ["x", "width", "fill"]);
// add the x Axis
this.canvas
.append("g")
.attr("class", "xAxis axis pub resizable")
.call(this.getXAxis, this);
// add the y Axis
this.canvas
.append("g")
.attr("class", "yAxis axis pub resizable")
.call(this.getYAxis, this, data);
this.makePubBtn();
this.postPlot(data);
} |
JavaScript | attrTween(path, duration, attr, endRes) {
var dummy = {};
d3.select(dummy)
.transition()
.duration(duration)
.tween(attr, function() {
var lerp = d3.interpolate(path.attr(attr), endRes);
return function(t) {
path.attr(attr, lerp(t));
};
});
} | attrTween(path, duration, attr, endRes) {
var dummy = {};
d3.select(dummy)
.transition()
.duration(duration)
.tween(attr, function() {
var lerp = d3.interpolate(path.attr(attr), endRes);
return function(t) {
path.attr(attr, lerp(t));
};
});
} |
JavaScript | resetTween(path, duration, attr, endRes, peakRes) {
var dummy = {};
d3.select(dummy)
.transition()
.duration(duration)
.tween(attr, function() {
var lerp = d3.interpolate(path.attr(attr), peakRes);
return function(t) {
path.attr(attr, lerp(t));
};
})
.transition()
.duration(duration*3)
.tween(attr, function() {
var lerp = d3.interpolate(peakRes, endRes);
return function(t) {
path.attr(attr, lerp(t));
};
})
} | resetTween(path, duration, attr, endRes, peakRes) {
var dummy = {};
d3.select(dummy)
.transition()
.duration(duration)
.tween(attr, function() {
var lerp = d3.interpolate(path.attr(attr), peakRes);
return function(t) {
path.attr(attr, lerp(t));
};
})
.transition()
.duration(duration*3)
.tween(attr, function() {
var lerp = d3.interpolate(peakRes, endRes);
return function(t) {
path.attr(attr, lerp(t));
};
})
} |
JavaScript | makePubBtn() {
var obj = this;
var unit = 80;
var imagePadding = 2;
var alpha = "0.7";
var btnCol = this.setAlpha(this.colourTop, alpha);
this.canvas
.append("g")
.attr("class", "menu resizable")
.append("rect")
.attr("x", obj.width + obj.margin.right - (unit/2))
.attr("y", 0 - obj.margin.top - (unit/2))
.attr("width", unit)
.attr("height", unit)
.attr("transform", "rotate(45, " + (obj.width + obj.margin.right) + ", " + (0 - obj.margin.top) + ")")
.attr("fill", btnCol)
.style("cursor", "pointer")
.on("mouseover", function() {
d3.select(this).attr("fill", obj.setAlpha(btnCol, 1))
})
.on("mouseout", function() {
d3.select(this).attr("fill", btnCol)
})
.on("click", function() {
d3.select(this).attr("fill", obj.setAlpha(btnCol, 0))
saveSvgAsPng(
document.getElementById(obj.id),
obj.id + ".png",
{scale: 2, backgroundColor: "#FFFFFF"}
);
});
this.div
.append("img")
.attr("class", "picture resizable")
.attr("src", function(d) {
//this icon is licensed under the Creative Commons
//Attribution 4.0 International license
//find out more at https://fontawesome.com/license
return obj.basePath + "/images/file-image-regular.svg";
})
.on("error", function() {
console.log("error in retrieving image")
})
.style("width", unit/4 + "px")
.style("position", "absolute")
.style("left", function() {
var rtn = document
.getElementById(obj.id)
.getBoundingClientRect().right;
rtn -= unit/4;
rtn -= imagePadding;
return rtn.toString() + "px";
})
.style("top", function() {
var rtn = document
.getElementById(obj.id)
.getBoundingClientRect().top;
rtn += imagePadding;
return rtn.toString() + "px";
})
.style("pointer-events", "none");
} | makePubBtn() {
var obj = this;
var unit = 80;
var imagePadding = 2;
var alpha = "0.7";
var btnCol = this.setAlpha(this.colourTop, alpha);
this.canvas
.append("g")
.attr("class", "menu resizable")
.append("rect")
.attr("x", obj.width + obj.margin.right - (unit/2))
.attr("y", 0 - obj.margin.top - (unit/2))
.attr("width", unit)
.attr("height", unit)
.attr("transform", "rotate(45, " + (obj.width + obj.margin.right) + ", " + (0 - obj.margin.top) + ")")
.attr("fill", btnCol)
.style("cursor", "pointer")
.on("mouseover", function() {
d3.select(this).attr("fill", obj.setAlpha(btnCol, 1))
})
.on("mouseout", function() {
d3.select(this).attr("fill", btnCol)
})
.on("click", function() {
d3.select(this).attr("fill", obj.setAlpha(btnCol, 0))
saveSvgAsPng(
document.getElementById(obj.id),
obj.id + ".png",
{scale: 2, backgroundColor: "#FFFFFF"}
);
});
this.div
.append("img")
.attr("class", "picture resizable")
.attr("src", function(d) {
//this icon is licensed under the Creative Commons
//Attribution 4.0 International license
//find out more at https://fontawesome.com/license
return obj.basePath + "/images/file-image-regular.svg";
})
.on("error", function() {
console.log("error in retrieving image")
})
.style("width", unit/4 + "px")
.style("position", "absolute")
.style("left", function() {
var rtn = document
.getElementById(obj.id)
.getBoundingClientRect().right;
rtn -= unit/4;
rtn -= imagePadding;
return rtn.toString() + "px";
})
.style("top", function() {
var rtn = document
.getElementById(obj.id)
.getBoundingClientRect().top;
rtn += imagePadding;
return rtn.toString() + "px";
})
.style("pointer-events", "none");
} |
JavaScript | parseRawData_one(obj, rawData) {
return rawData.map(function(d, i) {
return parseFloat(d[obj.yLabel]);
});
} | parseRawData_one(obj, rawData) {
return rawData.map(function(d, i) {
return parseFloat(d[obj.yLabel]);
});
} |
JavaScript | parseRawData_two(obj, rawData) {
return rawData.map(function(d, i) {
return {
[obj.xLabel]: parseFloat(d[obj.xLabel]),
[obj.yLabel]: parseFloat(d[obj.yLabel])
};
});
} | parseRawData_two(obj, rawData) {
return rawData.map(function(d, i) {
return {
[obj.xLabel]: parseFloat(d[obj.xLabel]),
[obj.yLabel]: parseFloat(d[obj.yLabel])
};
});
} |
JavaScript | parseRawData_one(obj, rawData) {
return rawData.map(function(d, i) {
return obj._date.parseTime(d[obj.yLabel]);
});
} | parseRawData_one(obj, rawData) {
return rawData.map(function(d, i) {
return obj._date.parseTime(d[obj.yLabel]);
});
} |
JavaScript | parseRawData_two(obj, rawData) {
return rawData.map(function(d, i) {
return {
[obj.xLabel]: obj._date.parseTime(d[obj.xLabel]),
[obj.yLabel]: d[obj.yLabel]
};
});
} | parseRawData_two(obj, rawData) {
return rawData.map(function(d, i) {
return {
[obj.xLabel]: obj._date.parseTime(d[obj.xLabel]),
[obj.yLabel]: d[obj.yLabel]
};
});
} |
JavaScript | function isLastValueSameLinkEvent(lastValue, nextValue) {
return (isLinkEventObject(lastValue) &&
lastValue.event === nextValue.event &&
lastValue.data === nextValue.data);
} | function isLastValueSameLinkEvent(lastValue, nextValue) {
return (isLinkEventObject(lastValue) &&
lastValue.event === nextValue.event &&
lastValue.data === nextValue.data);
} |
JavaScript | function cloneFragment(vNodeToClone) {
var oldChildren = vNodeToClone.children;
var childFlags = vNodeToClone.childFlags;
return createFragment(childFlags === 2 /* HasVNodeChildren */ ? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key);
} | function cloneFragment(vNodeToClone) {
var oldChildren = vNodeToClone.children;
var childFlags = vNodeToClone.childFlags;
return createFragment(childFlags === 2 /* HasVNodeChildren */ ? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key);
} |
JavaScript | function patchStyle(lastAttrValue, nextAttrValue, dom) {
if (isNullOrUndef(nextAttrValue)) {
dom.removeAttribute('style');
return;
}
var domStyle = dom.style;
var style;
var value;
if (isString(nextAttrValue)) {
domStyle.cssText = nextAttrValue;
return;
}
if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) {
for (style in nextAttrValue) {
// do not add a hasOwnProperty check here, it affects performance
value = nextAttrValue[style];
if (value !== lastAttrValue[style]) {
domStyle.setProperty(style, value);
}
}
for (style in lastAttrValue) {
if (isNullOrUndef(nextAttrValue[style])) {
domStyle.removeProperty(style);
}
}
}
else {
for (style in nextAttrValue) {
value = nextAttrValue[style];
domStyle.setProperty(style, value);
}
}
} | function patchStyle(lastAttrValue, nextAttrValue, dom) {
if (isNullOrUndef(nextAttrValue)) {
dom.removeAttribute('style');
return;
}
var domStyle = dom.style;
var style;
var value;
if (isString(nextAttrValue)) {
domStyle.cssText = nextAttrValue;
return;
}
if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) {
for (style in nextAttrValue) {
// do not add a hasOwnProperty check here, it affects performance
value = nextAttrValue[style];
if (value !== lastAttrValue[style]) {
domStyle.setProperty(style, value);
}
}
for (style in lastAttrValue) {
if (isNullOrUndef(nextAttrValue[style])) {
domStyle.removeProperty(style);
}
}
}
else {
for (style in nextAttrValue) {
value = nextAttrValue[style];
domStyle.setProperty(style, value);
}
}
} |
JavaScript | function scheduleNextFrameTask(task) {
frameTasks.push(task);
if (rafId === -1) {
requestAnimationFrame(function (t) {
rafId = -1;
var tasks = frameTasks;
frameTasks = [];
for (var i = 0; i < tasks.length; i++) {
tasks[i]();
}
});
}
} | function scheduleNextFrameTask(task) {
frameTasks.push(task);
if (rafId === -1) {
requestAnimationFrame(function (t) {
rafId = -1;
var tasks = frameTasks;
frameTasks = [];
for (var i = 0; i < tasks.length; i++) {
tasks[i]();
}
});
}
} |
JavaScript | function checkInit() {
if (!container) {
container = document.createElement("div");
container.style.cssText = "position: fixed;" +
"opacity: 0.9;" +
"right: 0;" +
"bottom: 0";
document.body.appendChild(container);
}
} | function checkInit() {
if (!container) {
container = document.createElement("div");
container.style.cssText = "position: fixed;" +
"opacity: 0.9;" +
"right: 0;" +
"bottom: 0";
document.body.appendChild(container);
}
} |
JavaScript | function scheduleNextFrameTask(task) {
frameTasks.push(task);
if (rafId === -1) {
requestAnimationFrame(function (t) {
rafId = -1;
var tasks = frameTasks;
frameTasks = [];
for (var i = 0; i < tasks.length; i++) {
tasks[i]();
}
});
}
} | function scheduleNextFrameTask(task) {
frameTasks.push(task);
if (rafId === -1) {
requestAnimationFrame(function (t) {
rafId = -1;
var tasks = frameTasks;
frameTasks = [];
for (var i = 0; i < tasks.length; i++) {
tasks[i]();
}
});
}
} |
JavaScript | function checkInit() {
if (!container) {
container = document.createElement("div");
container.style.cssText = "position: fixed;" +
"opacity: 0.9;" +
"right: 0;" +
"bottom: 0";
document.body.appendChild(container);
}
} | function checkInit() {
if (!container) {
container = document.createElement("div");
container.style.cssText = "position: fixed;" +
"opacity: 0.9;" +
"right: 0;" +
"bottom: 0";
document.body.appendChild(container);
}
} |
JavaScript | function initProfiler(name, flags) {
if (flags === void 0) { flags = 0; }
checkInit();
var profiler = profilerInstances[name];
if (profiler === void 0) {
profilerInstances[name] = profiler = new ProfilerDetails(name, "ms", flags);
container.appendChild(profiler.widget.element);
}
} | function initProfiler(name, flags) {
if (flags === void 0) { flags = 0; }
checkInit();
var profiler = profilerInstances[name];
if (profiler === void 0) {
profilerInstances[name] = profiler = new ProfilerDetails(name, "ms", flags);
container.appendChild(profiler.widget.element);
}
} |
JavaScript | function cloneFragment(vNodeToClone) {
var oldChildren = vNodeToClone.children;
var childFlags = vNodeToClone.childFlags;
return createFragment(childFlags === 2 /* HasVNodeChildren */ ? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key);
} | function cloneFragment(vNodeToClone) {
var oldChildren = vNodeToClone.children;
var childFlags = vNodeToClone.childFlags;
return createFragment(childFlags === 2 /* HasVNodeChildren */ ? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key);
} |
JavaScript | function cloneFragment$1(vNodeToClone) {
var oldChildren = vNodeToClone.children;
var childFlags = vNodeToClone.childFlags;
return createFragment$1(childFlags === 2 /* HasVNodeChildren */ ? directClone$1(oldChildren) : oldChildren.map(directClone$1), childFlags, vNodeToClone.key);
} | function cloneFragment$1(vNodeToClone) {
var oldChildren = vNodeToClone.children;
var childFlags = vNodeToClone.childFlags;
return createFragment$1(childFlags === 2 /* HasVNodeChildren */ ? directClone$1(oldChildren) : oldChildren.map(directClone$1), childFlags, vNodeToClone.key);
} |
JavaScript | function cloneFragment(vNodeToClone) {
var oldChildren = vNodeToClone.children;
var childFlags = vNodeToClone.childFlags;
return createFragment(childFlags === 2
/* HasVNodeChildren */
? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key);
} | function cloneFragment(vNodeToClone) {
var oldChildren = vNodeToClone.children;
var childFlags = vNodeToClone.childFlags;
return createFragment(childFlags === 2
/* HasVNodeChildren */
? directClone(oldChildren) : oldChildren.map(directClone), childFlags, vNodeToClone.key);
} |
JavaScript | function patchStyle(lastAttrValue, nextAttrValue, dom) {
if (isNullOrUndef$3(nextAttrValue)) {
dom.removeAttribute('style');
return;
}
var domStyle = dom.style;
var style;
var value;
if (isString$2(nextAttrValue)) {
domStyle.cssText = nextAttrValue;
return;
}
if (!isNullOrUndef$3(lastAttrValue) && !isString$2(lastAttrValue)) {
for (style in nextAttrValue) {
// do not add a hasOwnProperty check here, it affects performance
value = nextAttrValue[style];
if (value !== lastAttrValue[style]) {
domStyle.setProperty(style, value);
}
}
for (style in lastAttrValue) {
if (isNullOrUndef$3(nextAttrValue[style])) {
domStyle.removeProperty(style);
}
}
} else {
for (style in nextAttrValue) {
value = nextAttrValue[style];
domStyle.setProperty(style, value);
}
}
} | function patchStyle(lastAttrValue, nextAttrValue, dom) {
if (isNullOrUndef$3(nextAttrValue)) {
dom.removeAttribute('style');
return;
}
var domStyle = dom.style;
var style;
var value;
if (isString$2(nextAttrValue)) {
domStyle.cssText = nextAttrValue;
return;
}
if (!isNullOrUndef$3(lastAttrValue) && !isString$2(lastAttrValue)) {
for (style in nextAttrValue) {
// do not add a hasOwnProperty check here, it affects performance
value = nextAttrValue[style];
if (value !== lastAttrValue[style]) {
domStyle.setProperty(style, value);
}
}
for (style in lastAttrValue) {
if (isNullOrUndef$3(nextAttrValue[style])) {
domStyle.removeProperty(style);
}
}
} else {
for (style in nextAttrValue) {
value = nextAttrValue[style];
domStyle.setProperty(style, value);
}
}
} |
JavaScript | function cloneVNode(vNodeToClone, props, _children) {
var arguments$1 = arguments;
var flags = vNodeToClone.flags;
var children = flags & 14
/* Component */
? vNodeToClone.props && vNodeToClone.props.children : vNodeToClone.children;
var childLen = arguments.length - 2;
var className = vNodeToClone.className;
var key = vNodeToClone.key;
var ref = vNodeToClone.ref;
if (props) {
if (props.className !== void 0) {
className = props.className;
}
if (props.ref !== void 0) {
ref = props.ref;
}
if (props.key !== void 0) {
key = props.key;
}
if (props.children !== void 0) {
children = props.children;
}
} else {
props = {};
}
if (childLen === 1) {
children = _children;
} else if (childLen > 1) {
children = [];
while (childLen-- > 0) {
children[childLen] = arguments$1[childLen + 2];
}
}
props.children = children;
if (flags & 14
/* Component */
) {
return createComponentVNode(flags, vNodeToClone.type, !vNodeToClone.props && !props ? EMPTY_OBJ : combineFrom(vNodeToClone.props, props), key, ref);
}
if (flags & 16
/* Text */
) {
return createTextVNode(children);
}
if (flags & 8192
/* Fragment */
) {
return createFragment(childLen === 1 ? [children] : children, 0
/* UnknownChildren */
, key);
}
return normalizeProps(createVNode(flags, vNodeToClone.type, className, null, 1
/* HasInvalidChildren */
, combineFrom(vNodeToClone.props, props), key, ref));
} | function cloneVNode(vNodeToClone, props, _children) {
var arguments$1 = arguments;
var flags = vNodeToClone.flags;
var children = flags & 14
/* Component */
? vNodeToClone.props && vNodeToClone.props.children : vNodeToClone.children;
var childLen = arguments.length - 2;
var className = vNodeToClone.className;
var key = vNodeToClone.key;
var ref = vNodeToClone.ref;
if (props) {
if (props.className !== void 0) {
className = props.className;
}
if (props.ref !== void 0) {
ref = props.ref;
}
if (props.key !== void 0) {
key = props.key;
}
if (props.children !== void 0) {
children = props.children;
}
} else {
props = {};
}
if (childLen === 1) {
children = _children;
} else if (childLen > 1) {
children = [];
while (childLen-- > 0) {
children[childLen] = arguments$1[childLen + 2];
}
}
props.children = children;
if (flags & 14
/* Component */
) {
return createComponentVNode(flags, vNodeToClone.type, !vNodeToClone.props && !props ? EMPTY_OBJ : combineFrom(vNodeToClone.props, props), key, ref);
}
if (flags & 16
/* Text */
) {
return createTextVNode(children);
}
if (flags & 8192
/* Fragment */
) {
return createFragment(childLen === 1 ? [children] : children, 0
/* UnknownChildren */
, key);
}
return normalizeProps(createVNode(flags, vNodeToClone.type, className, null, 1
/* HasInvalidChildren */
, combineFrom(vNodeToClone.props, props), key, ref));
} |
JavaScript | function formatState (state) {
if(state.id == 'cube-portfolio'){
var $state = $(
'<span>' + state.text + ' <span class="label label-success">Premium $16</span></span>'
);
}else if(state.id == 'glyphicons-pro'){
var $state = $(
'<span>' + state.text + ' <span class="label label-success">Premium $59</span></span>'
);
}else if(state.id == 'slider-revolution'){
var $state = $(
'<span>' + state.text + ' <span class="label label-success">Premium $14</span></span>'
);
}else{
return state.text;
}
return $state;
} | function formatState (state) {
if(state.id == 'cube-portfolio'){
var $state = $(
'<span>' + state.text + ' <span class="label label-success">Premium $16</span></span>'
);
}else if(state.id == 'glyphicons-pro'){
var $state = $(
'<span>' + state.text + ' <span class="label label-success">Premium $59</span></span>'
);
}else if(state.id == 'slider-revolution'){
var $state = $(
'<span>' + state.text + ' <span class="label label-success">Premium $14</span></span>'
);
}else{
return state.text;
}
return $state;
} |
JavaScript | function radioGroup1_change(event) {
let RadioValue = $w("#radioGroup1").value; //Number the values of the radio buttons to make it simpler
console.log("Radio Button Group Value: " + RadioValue);
//Call the hiding and showing image funciton
ImageHide(RadioValue, 3, 1);
} | function radioGroup1_change(event) {
let RadioValue = $w("#radioGroup1").value; //Number the values of the radio buttons to make it simpler
console.log("Radio Button Group Value: " + RadioValue);
//Call the hiding and showing image funciton
ImageHide(RadioValue, 3, 1);
} |
JavaScript | handleBlur(e) {
if (this.props.onBlurChange) {
if (_.isNil(this.props.value)) {
console.error('You try to use onBlurChange event on uncontrolled element. This has not been implemented yet. onBlurChange handler will be ignored');
} else if (
this.props.value !== this.lastBlurValue // checking if value really changed
&& (inputConfig.onBlurChangeFromEmpty || this.lastBlurValue !== '') // checking if previous blur value has been empty string
) {
this.props.onBlurChange(e);
}
}
if (this.props.onBlur) {
this.props.onBlur(e);
}
this.lastBlurValue = this.props.value;
} | handleBlur(e) {
if (this.props.onBlurChange) {
if (_.isNil(this.props.value)) {
console.error('You try to use onBlurChange event on uncontrolled element. This has not been implemented yet. onBlurChange handler will be ignored');
} else if (
this.props.value !== this.lastBlurValue // checking if value really changed
&& (inputConfig.onBlurChangeFromEmpty || this.lastBlurValue !== '') // checking if previous blur value has been empty string
) {
this.props.onBlurChange(e);
}
}
if (this.props.onBlur) {
this.props.onBlur(e);
}
this.lastBlurValue = this.props.value;
} |
JavaScript | handleChange(e) {
if (this.props.onChange) {
this.props.onChange(e);
}
} | handleChange(e) {
if (this.props.onChange) {
this.props.onChange(e);
}
} |
JavaScript | function BasicSourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
}
var version = util.getArg(sourceMap, 'version');
var sources = util.getArg(sourceMap, 'sources');
// Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
// requires the array) to play nice here.
var names = util.getArg(sourceMap, 'names', []);
var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
var mappings = util.getArg(sourceMap, 'mappings');
var file = util.getArg(sourceMap, 'file', null);
// Once again, Sass deviates from the spec and supplies the version as a
// string rather than a number, so we use loose equality checking here.
if (version != this._version) {
throw new Error('Unsupported version: ' + version);
}
sources = sources
.map(String)
// Some source maps produce relative source paths like "./foo.js" instead of
// "foo.js". Normalize these first so that future comparisons will succeed.
// See bugzil.la/1090768.
.map(util.normalize)
// Always ensure that absolute sources are internally stored relative to
// the source root, if the source root is absolute. Not doing this would
// be particularly problematic when the source root is a prefix of the
// source (valid, but why??). See github issue #199 and bugzil.la/1188982.
.map(function (source) {
return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
? util.relative(sourceRoot, source)
: source;
});
// Pass `true` below to allow duplicate names and sources. While source maps
// are intended to be compressed and deduplicated, the TypeScript compiler
// sometimes generates source maps with duplicates in them. See Github issue
// #72 and bugzil.la/889492.
this._names = ArraySet.fromArray(names.map(String), true);
this._sources = ArraySet.fromArray(sources, true);
this.sourceRoot = sourceRoot;
this.sourcesContent = sourcesContent;
this._mappings = mappings;
this.file = file;
} | function BasicSourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
}
var version = util.getArg(sourceMap, 'version');
var sources = util.getArg(sourceMap, 'sources');
// Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
// requires the array) to play nice here.
var names = util.getArg(sourceMap, 'names', []);
var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
var mappings = util.getArg(sourceMap, 'mappings');
var file = util.getArg(sourceMap, 'file', null);
// Once again, Sass deviates from the spec and supplies the version as a
// string rather than a number, so we use loose equality checking here.
if (version != this._version) {
throw new Error('Unsupported version: ' + version);
}
sources = sources
.map(String)
// Some source maps produce relative source paths like "./foo.js" instead of
// "foo.js". Normalize these first so that future comparisons will succeed.
// See bugzil.la/1090768.
.map(util.normalize)
// Always ensure that absolute sources are internally stored relative to
// the source root, if the source root is absolute. Not doing this would
// be particularly problematic when the source root is a prefix of the
// source (valid, but why??). See github issue #199 and bugzil.la/1188982.
.map(function (source) {
return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
? util.relative(sourceRoot, source)
: source;
});
// Pass `true` below to allow duplicate names and sources. While source maps
// are intended to be compressed and deduplicated, the TypeScript compiler
// sometimes generates source maps with duplicates in them. See Github issue
// #72 and bugzil.la/889492.
this._names = ArraySet.fromArray(names.map(String), true);
this._sources = ArraySet.fromArray(sources, true);
this.sourceRoot = sourceRoot;
this.sourcesContent = sourcesContent;
this._mappings = mappings;
this.file = file;
} |
JavaScript | function IndexedSourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
}
var version = util.getArg(sourceMap, 'version');
var sections = util.getArg(sourceMap, 'sections');
if (version != this._version) {
throw new Error('Unsupported version: ' + version);
}
this._sources = new ArraySet();
this._names = new ArraySet();
var lastOffset = {
line: -1,
column: 0
};
this._sections = sections.map(function (s) {
if (s.url) {
// The url field will require support for asynchronicity.
// See https://github.com/mozilla/source-map/issues/16
throw new Error('Support for url field in sections not implemented.');
}
var offset = util.getArg(s, 'offset');
var offsetLine = util.getArg(offset, 'line');
var offsetColumn = util.getArg(offset, 'column');
if (offsetLine < lastOffset.line ||
(offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
throw new Error('Section offsets must be ordered and non-overlapping.');
}
lastOffset = offset;
return {
generatedOffset: {
// The offset fields are 0-based, but we use 1-based indices when
// encoding/decoding from VLQ.
generatedLine: offsetLine + 1,
generatedColumn: offsetColumn + 1
},
consumer: new SourceMapConsumer(util.getArg(s, 'map'))
}
});
} | function IndexedSourceMapConsumer(aSourceMap) {
var sourceMap = aSourceMap;
if (typeof aSourceMap === 'string') {
sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
}
var version = util.getArg(sourceMap, 'version');
var sections = util.getArg(sourceMap, 'sections');
if (version != this._version) {
throw new Error('Unsupported version: ' + version);
}
this._sources = new ArraySet();
this._names = new ArraySet();
var lastOffset = {
line: -1,
column: 0
};
this._sections = sections.map(function (s) {
if (s.url) {
// The url field will require support for asynchronicity.
// See https://github.com/mozilla/source-map/issues/16
throw new Error('Support for url field in sections not implemented.');
}
var offset = util.getArg(s, 'offset');
var offsetLine = util.getArg(offset, 'line');
var offsetColumn = util.getArg(offset, 'column');
if (offsetLine < lastOffset.line ||
(offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
throw new Error('Section offsets must be ordered and non-overlapping.');
}
lastOffset = offset;
return {
generatedOffset: {
// The offset fields are 0-based, but we use 1-based indices when
// encoding/decoding from VLQ.
generatedLine: offsetLine + 1,
generatedColumn: offsetColumn + 1
},
consumer: new SourceMapConsumer(util.getArg(s, 'map'))
}
});
} |
JavaScript | function join(aRoot, aPath) {
if (aRoot === "") {
aRoot = ".";
}
if (aPath === "") {
aPath = ".";
}
var aPathUrl = urlParse(aPath);
var aRootUrl = urlParse(aRoot);
if (aRootUrl) {
aRoot = aRootUrl.path || '/';
}
// `join(foo, '//www.example.org')`
if (aPathUrl && !aPathUrl.scheme) {
if (aRootUrl) {
aPathUrl.scheme = aRootUrl.scheme;
}
return urlGenerate(aPathUrl);
}
if (aPathUrl || aPath.match(dataUrlRegexp)) {
return aPath;
}
// `join('http://', 'www.example.com')`
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
aRootUrl.host = aPath;
return urlGenerate(aRootUrl);
}
var joined = aPath.charAt(0) === '/'
? aPath
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
if (aRootUrl) {
aRootUrl.path = joined;
return urlGenerate(aRootUrl);
}
return joined;
} | function join(aRoot, aPath) {
if (aRoot === "") {
aRoot = ".";
}
if (aPath === "") {
aPath = ".";
}
var aPathUrl = urlParse(aPath);
var aRootUrl = urlParse(aRoot);
if (aRootUrl) {
aRoot = aRootUrl.path || '/';
}
// `join(foo, '//www.example.org')`
if (aPathUrl && !aPathUrl.scheme) {
if (aRootUrl) {
aPathUrl.scheme = aRootUrl.scheme;
}
return urlGenerate(aPathUrl);
}
if (aPathUrl || aPath.match(dataUrlRegexp)) {
return aPath;
}
// `join('http://', 'www.example.com')`
if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
aRootUrl.host = aPath;
return urlGenerate(aRootUrl);
}
var joined = aPath.charAt(0) === '/'
? aPath
: normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
if (aRootUrl) {
aRootUrl.path = joined;
return urlGenerate(aRootUrl);
}
return joined;
} |
JavaScript | function relative(aRoot, aPath) {
if (aRoot === "") {
aRoot = ".";
}
aRoot = aRoot.replace(/\/$/, '');
// It is possible for the path to be above the root. In this case, simply
// checking whether the root is a prefix of the path won't work. Instead, we
// need to remove components from the root one by one, until either we find
// a prefix that fits, or we run out of components to remove.
var level = 0;
while (aPath.indexOf(aRoot + '/') !== 0) {
var index = aRoot.lastIndexOf("/");
if (index < 0) {
return aPath;
}
// If the only part of the root that is left is the scheme (i.e. http://,
// file:///, etc.), one or more slashes (/), or simply nothing at all, we
// have exhausted all components, so the path is not relative to the root.
aRoot = aRoot.slice(0, index);
if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
return aPath;
}
++level;
}
// Make sure we add a "../" for each component we removed from the root.
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
} | function relative(aRoot, aPath) {
if (aRoot === "") {
aRoot = ".";
}
aRoot = aRoot.replace(/\/$/, '');
// It is possible for the path to be above the root. In this case, simply
// checking whether the root is a prefix of the path won't work. Instead, we
// need to remove components from the root one by one, until either we find
// a prefix that fits, or we run out of components to remove.
var level = 0;
while (aPath.indexOf(aRoot + '/') !== 0) {
var index = aRoot.lastIndexOf("/");
if (index < 0) {
return aPath;
}
// If the only part of the root that is left is the scheme (i.e. http://,
// file:///, etc.), one or more slashes (/), or simply nothing at all, we
// have exhausted all components, so the path is not relative to the root.
aRoot = aRoot.slice(0, index);
if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
return aPath;
}
++level;
}
// Make sure we add a "../" for each component we removed from the root.
return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
} |
JavaScript | function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
var cmp = mappingA.source - mappingB.source;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalLine - mappingB.originalLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalColumn - mappingB.originalColumn;
if (cmp !== 0 || onlyCompareOriginal) {
return cmp;
}
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.generatedLine - mappingB.generatedLine;
if (cmp !== 0) {
return cmp;
}
return mappingA.name - mappingB.name;
} | function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
var cmp = mappingA.source - mappingB.source;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalLine - mappingB.originalLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalColumn - mappingB.originalColumn;
if (cmp !== 0 || onlyCompareOriginal) {
return cmp;
}
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.generatedLine - mappingB.generatedLine;
if (cmp !== 0) {
return cmp;
}
return mappingA.name - mappingB.name;
} |
JavaScript | function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
var cmp = mappingA.generatedLine - mappingB.generatedLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
if (cmp !== 0 || onlyCompareGenerated) {
return cmp;
}
cmp = mappingA.source - mappingB.source;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalLine - mappingB.originalLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalColumn - mappingB.originalColumn;
if (cmp !== 0) {
return cmp;
}
return mappingA.name - mappingB.name;
} | function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
var cmp = mappingA.generatedLine - mappingB.generatedLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
if (cmp !== 0 || onlyCompareGenerated) {
return cmp;
}
cmp = mappingA.source - mappingB.source;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalLine - mappingB.originalLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalColumn - mappingB.originalColumn;
if (cmp !== 0) {
return cmp;
}
return mappingA.name - mappingB.name;
} |
JavaScript | function compareByGeneratedPositionsInflated(mappingA, mappingB) {
var cmp = mappingA.generatedLine - mappingB.generatedLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
if (cmp !== 0) {
return cmp;
}
cmp = strcmp(mappingA.source, mappingB.source);
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalLine - mappingB.originalLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalColumn - mappingB.originalColumn;
if (cmp !== 0) {
return cmp;
}
return strcmp(mappingA.name, mappingB.name);
} | function compareByGeneratedPositionsInflated(mappingA, mappingB) {
var cmp = mappingA.generatedLine - mappingB.generatedLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.generatedColumn - mappingB.generatedColumn;
if (cmp !== 0) {
return cmp;
}
cmp = strcmp(mappingA.source, mappingB.source);
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalLine - mappingB.originalLine;
if (cmp !== 0) {
return cmp;
}
cmp = mappingA.originalColumn - mappingB.originalColumn;
if (cmp !== 0) {
return cmp;
}
return strcmp(mappingA.name, mappingB.name);
} |
JavaScript | function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
// This function terminates when one of the following is true:
//
// 1. We find the exact element we are looking for.
//
// 2. We did not find the exact element, but we can return the index of
// the next-closest element.
//
// 3. We did not find the exact element, and there is no next-closest
// element than the one we are searching for, so we return -1.
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
var cmp = aCompare(aNeedle, aHaystack[mid], true);
if (cmp === 0) {
// Found the element we are looking for.
return mid;
}
else if (cmp > 0) {
// Our needle is greater than aHaystack[mid].
if (aHigh - mid > 1) {
// The element is in the upper half.
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
}
// The exact needle element was not found in this haystack. Determine if
// we are in termination case (3) or (2) and return the appropriate thing.
if (aBias == exports.LEAST_UPPER_BOUND) {
return aHigh < aHaystack.length ? aHigh : -1;
} else {
return mid;
}
}
else {
// Our needle is less than aHaystack[mid].
if (mid - aLow > 1) {
// The element is in the lower half.
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
}
// we are in termination case (3) or (2) and return the appropriate thing.
if (aBias == exports.LEAST_UPPER_BOUND) {
return mid;
} else {
return aLow < 0 ? -1 : aLow;
}
}
} | function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
// This function terminates when one of the following is true:
//
// 1. We find the exact element we are looking for.
//
// 2. We did not find the exact element, but we can return the index of
// the next-closest element.
//
// 3. We did not find the exact element, and there is no next-closest
// element than the one we are searching for, so we return -1.
var mid = Math.floor((aHigh - aLow) / 2) + aLow;
var cmp = aCompare(aNeedle, aHaystack[mid], true);
if (cmp === 0) {
// Found the element we are looking for.
return mid;
}
else if (cmp > 0) {
// Our needle is greater than aHaystack[mid].
if (aHigh - mid > 1) {
// The element is in the upper half.
return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
}
// The exact needle element was not found in this haystack. Determine if
// we are in termination case (3) or (2) and return the appropriate thing.
if (aBias == exports.LEAST_UPPER_BOUND) {
return aHigh < aHaystack.length ? aHigh : -1;
} else {
return mid;
}
}
else {
// Our needle is less than aHaystack[mid].
if (mid - aLow > 1) {
// The element is in the lower half.
return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
}
// we are in termination case (3) or (2) and return the appropriate thing.
if (aBias == exports.LEAST_UPPER_BOUND) {
return mid;
} else {
return aLow < 0 ? -1 : aLow;
}
}
} |
JavaScript | function toVLQSigned(aValue) {
return aValue < 0
? ((-aValue) << 1) + 1
: (aValue << 1) + 0;
} | function toVLQSigned(aValue) {
return aValue < 0
? ((-aValue) << 1) + 1
: (aValue << 1) + 0;
} |
JavaScript | function fromVLQSigned(aValue) {
var isNegative = (aValue & 1) === 1;
var shifted = aValue >> 1;
return isNegative
? -shifted
: shifted;
} | function fromVLQSigned(aValue) {
var isNegative = (aValue & 1) === 1;
var shifted = aValue >> 1;
return isNegative
? -shifted
: shifted;
} |
JavaScript | insertAfterPart(ref) {
ref._insert(this.startNode = createMarker());
this.endNode = ref.endNode;
ref.endNode = this.startNode;
} | insertAfterPart(ref) {
ref._insert(this.startNode = createMarker());
this.endNode = ref.endNode;
ref.endNode = this.startNode;
} |
JavaScript | function cleanup() {
if (navigator.platform.indexOf("Win") > -1) {
ps.destroy();
}
window.removeEventListener("resize", resizeFunction);
} | function cleanup() {
if (navigator.platform.indexOf("Win") > -1) {
ps.destroy();
}
window.removeEventListener("resize", resizeFunction);
} |
JavaScript | function addIcon(post) {
if(post) {
post.setAttribute("class", post.className + " with-icon");
var originalRemoveLink = post.querySelector("a[onclick^='feed.ignoreItem']");
if(originalRemoveLink) {
var onclickAction = originalRemoveLink.getAttribute("onclick");
var link = document.createElement("a");
link.innerHTML = "✕"; // cross sign
link.setAttribute("onclick", onclickAction);
link.setAttribute("class", "remove-post-icon");
post.querySelector(".post_header_info").appendChild(link);
}
}
} | function addIcon(post) {
if(post) {
post.setAttribute("class", post.className + " with-icon");
var originalRemoveLink = post.querySelector("a[onclick^='feed.ignoreItem']");
if(originalRemoveLink) {
var onclickAction = originalRemoveLink.getAttribute("onclick");
var link = document.createElement("a");
link.innerHTML = "✕"; // cross sign
link.setAttribute("onclick", onclickAction);
link.setAttribute("class", "remove-post-icon");
post.querySelector(".post_header_info").appendChild(link);
}
}
} |
JavaScript | function updatePosts() {
console.log("Update posts icons");
var posts = document.getElementsByClassName('feed_row');
for (var i = 0; i < posts.length; i++) {
if(!posts[i].querySelector(".remove-post-icon")) {
addIcon(posts[i]);
}
}
} | function updatePosts() {
console.log("Update posts icons");
var posts = document.getElementsByClassName('feed_row');
for (var i = 0; i < posts.length; i++) {
if(!posts[i].querySelector(".remove-post-icon")) {
addIcon(posts[i]);
}
}
} |
JavaScript | function inOrderTraverseArr(tree, array) {
if(tree) {
inOrderTraverseArr(tree.left, array);
array.push(tree.value);
inOrderTraverseArr(tree.right, array);
return array;
}
} | function inOrderTraverseArr(tree, array) {
if(tree) {
inOrderTraverseArr(tree.left, array);
array.push(tree.value);
inOrderTraverseArr(tree.right, array);
return array;
}
} |
JavaScript | function lock_mode(single_mad, multiple_mod){
if(single_mad == true)
$("#menu-single-descr-mode").removeClass('disabled');
if(multiple_mod == true)
$("#menu-multiple-descr-mode").removeClass('disabled');
} | function lock_mode(single_mad, multiple_mod){
if(single_mad == true)
$("#menu-single-descr-mode").removeClass('disabled');
if(multiple_mod == true)
$("#menu-multiple-descr-mode").removeClass('disabled');
} |
JavaScript | function addField(parent_div, div_class, label_class, inner_div_class, field_name, field_name_GUI, field_class, field_tag,
field_type, field_type_backend){
// create div
var i_div = document.createElement('div');
i_div.className = div_class;
// create inner div
var i_inner_div = document.createElement('div');
i_inner_div.className = inner_div_class;
// create label
var i_label = document.createElement('label');
i_label.className = label_class;
i_label.innerHTML = field_name_GUI
// create field
var i_field = document.createElement(field_tag);
i_field.id = field_name
i_field.name = field_name
if(field_type_backend == 'categorical'){
i_field.multiple="multiple"
var newScript = document.createElement("script");
newScript.async = false;
// jquery doesn't work with # and id with spaces
var inlineScript = document.createTextNode("document.addEventListener('DOMContentLoaded',"+ "function categorical(e){$(\"[id='"+field_name+"']\").select2({width:'100%'});}, false);");
newScript.appendChild(inlineScript);
var test = document.getElementById('loadDiv')
test.appendChild(newScript)
}
if(field_type_backend == 'text'){
i_field.type = field_type
i_field.pattern = "[A-Z]{1,10}[\-][0-9]{1,10}"
i_field.className = field_class[0]
}
if(field_type_backend == 'text2'){
i_field.type = field_type
i_field.className = field_class[0];
}
if(field_type_backend == 'text1'){
i_field.type = field_type
i_field.className = field_class[0];
}
if(field_type_backend == 'number'){
i_field.className = field_class[1];
i_field.pattern = "[0-9]+"
i_field.min = 0
i_field.placeholder = '>=0'
i_field.id = field_name + '1'
i_field.name = field_name + '1'
i_span = document.createElement('span')
i_span.innerHTML = '&'
i_field1 = i_field.cloneNode(false)
i_field1.className = field_class[0]
i_field1.id = field_name + '0'
i_field1.name = field_name + '0'
i_inner_div.appendChild(i_field1)
i_inner_div.appendChild(i_span)
}
if(field_type_backend == 'date'){
i_field.pattern = "^[0-9]{2}-[0-9]{2}-[0-9]{4}$"
i_field.type = 'text'
i_field.className = field_class[1]
i_field.autocomplete="on"
i_field.id = field_name + '1'
i_field.name = field_name + '1'
i_field.placeholder = 'to'
i_span = document.createElement('span')
i_span.innerHTML = '&'
i_field1 = i_field.cloneNode(false)
i_field1.id = field_name + '0'
i_field1.name = field_name + '0'
i_field1.placeholder = 'from'
i_field1.className = field_class[0]
i_inner_div.appendChild(i_field1)
i_inner_div.appendChild(i_span)
}
if(field_type_backend == 'bool'){
i_field.className = field_class[0];
var masVal = ['', 'Yes', 'No']
for (var i = 0; i<masVal.length; i++){
var i_option = document.createElement('option')
i_option.value = masVal[i]
i_option.innerHTML = masVal[i]
i_field.appendChild(i_option)
}
}
// add label to div
parent_div.appendChild(i_div)
i_div.appendChild(i_label)
i_div.appendChild(i_inner_div)
i_inner_div.appendChild(i_field)
} | function addField(parent_div, div_class, label_class, inner_div_class, field_name, field_name_GUI, field_class, field_tag,
field_type, field_type_backend){
// create div
var i_div = document.createElement('div');
i_div.className = div_class;
// create inner div
var i_inner_div = document.createElement('div');
i_inner_div.className = inner_div_class;
// create label
var i_label = document.createElement('label');
i_label.className = label_class;
i_label.innerHTML = field_name_GUI
// create field
var i_field = document.createElement(field_tag);
i_field.id = field_name
i_field.name = field_name
if(field_type_backend == 'categorical'){
i_field.multiple="multiple"
var newScript = document.createElement("script");
newScript.async = false;
// jquery doesn't work with # and id with spaces
var inlineScript = document.createTextNode("document.addEventListener('DOMContentLoaded',"+ "function categorical(e){$(\"[id='"+field_name+"']\").select2({width:'100%'});}, false);");
newScript.appendChild(inlineScript);
var test = document.getElementById('loadDiv')
test.appendChild(newScript)
}
if(field_type_backend == 'text'){
i_field.type = field_type
i_field.pattern = "[A-Z]{1,10}[\-][0-9]{1,10}"
i_field.className = field_class[0]
}
if(field_type_backend == 'text2'){
i_field.type = field_type
i_field.className = field_class[0];
}
if(field_type_backend == 'text1'){
i_field.type = field_type
i_field.className = field_class[0];
}
if(field_type_backend == 'number'){
i_field.className = field_class[1];
i_field.pattern = "[0-9]+"
i_field.min = 0
i_field.placeholder = '>=0'
i_field.id = field_name + '1'
i_field.name = field_name + '1'
i_span = document.createElement('span')
i_span.innerHTML = '&'
i_field1 = i_field.cloneNode(false)
i_field1.className = field_class[0]
i_field1.id = field_name + '0'
i_field1.name = field_name + '0'
i_inner_div.appendChild(i_field1)
i_inner_div.appendChild(i_span)
}
if(field_type_backend == 'date'){
i_field.pattern = "^[0-9]{2}-[0-9]{2}-[0-9]{4}$"
i_field.type = 'text'
i_field.className = field_class[1]
i_field.autocomplete="on"
i_field.id = field_name + '1'
i_field.name = field_name + '1'
i_field.placeholder = 'to'
i_span = document.createElement('span')
i_span.innerHTML = '&'
i_field1 = i_field.cloneNode(false)
i_field1.id = field_name + '0'
i_field1.name = field_name + '0'
i_field1.placeholder = 'from'
i_field1.className = field_class[0]
i_inner_div.appendChild(i_field1)
i_inner_div.appendChild(i_span)
}
if(field_type_backend == 'bool'){
i_field.className = field_class[0];
var masVal = ['', 'Yes', 'No']
for (var i = 0; i<masVal.length; i++){
var i_option = document.createElement('option')
i_option.value = masVal[i]
i_option.innerHTML = masVal[i]
i_field.appendChild(i_option)
}
}
// add label to div
parent_div.appendChild(i_div)
i_div.appendChild(i_label)
i_div.appendChild(i_inner_div)
i_inner_div.appendChild(i_field)
} |
JavaScript | function findMax(xLine, xHist, scale){
var finalX = xLine.concat(xHist);
var max = 0;
if(scale == ''){
for(index=0; index < finalX.length; index++){
if(finalX[index]>max){
max = finalX[index];
}
}
if(max > 1)
return max+1;
else return max+0.01;
}
else return parseInt(scale);
} | function findMax(xLine, xHist, scale){
var finalX = xLine.concat(xHist);
var max = 0;
if(scale == ''){
for(index=0; index < finalX.length; index++){
if(finalX[index]>max){
max = finalX[index];
}
}
if(max > 1)
return max+1;
else return max+0.01;
}
else return parseInt(scale);
} |
JavaScript | function from_bool(val){
if (typeof val === "boolean")
if (val==true)
return 'Yes'
else return 'No'
else
return val
} | function from_bool(val){
if (typeof val === "boolean")
if (val==true)
return 'Yes'
else return 'No'
else
return val
} |
JavaScript | function special_fields_table(data){
return new Tabulator('#special_fields', {
layout: 'fitColumns',
//pagination: 'local',
//paginationSize: 4,
addRowPos:"bottom",
columns: [
{formatter:'buttonCross', width:40, align:"center",sorter:"string", headerSort:false, cellClick:function(e, cell){cell.getRow().delete()}},
{ title: 'GUI name', field: 'gui_name', editor:true, validator:["required", "regex:[a-zA-Z]+"]},
{ title: 'XML name', field: 'xml_name', editor:true, validator:["required", "maxLength:30"] },
{ title: 'type', field: 'type', editor:"select", editorParams:{values:jsonDictionary['data_types']}, validator: "required",
tooltip:function(cell){
switch(cell.getValue()){
case 'text': return 'string type, with full line search'
case 'text1': return 'string type, with substring search'
case 'text2': return 'string type, with multiple substring search'
case 'number': return 'float type, with full match search'
case 'date': return 'date type, with full match search'
case 'categorical': return 'string type, with isin search'
case 'bool': return 'boolean type, with full match search'
}
}}
]
});
} | function special_fields_table(data){
return new Tabulator('#special_fields', {
layout: 'fitColumns',
//pagination: 'local',
//paginationSize: 4,
addRowPos:"bottom",
columns: [
{formatter:'buttonCross', width:40, align:"center",sorter:"string", headerSort:false, cellClick:function(e, cell){cell.getRow().delete()}},
{ title: 'GUI name', field: 'gui_name', editor:true, validator:["required", "regex:[a-zA-Z]+"]},
{ title: 'XML name', field: 'xml_name', editor:true, validator:["required", "maxLength:30"] },
{ title: 'type', field: 'type', editor:"select", editorParams:{values:jsonDictionary['data_types']}, validator: "required",
tooltip:function(cell){
switch(cell.getValue()){
case 'text': return 'string type, with full line search'
case 'text1': return 'string type, with substring search'
case 'text2': return 'string type, with multiple substring search'
case 'number': return 'float type, with full match search'
case 'date': return 'date type, with full match search'
case 'categorical': return 'string type, with isin search'
case 'bool': return 'boolean type, with full match search'
}
}}
]
});
} |
JavaScript | function lock_mode(single_mad, multiple_mod){
if(single_mad == true)
$("#menu-single-descr-mode").removeClass('disabled');
if(multiple_mod == true)
$("#menu-multiple-descr-mode").removeClass('disabled');
} | function lock_mode(single_mad, multiple_mod){
if(single_mad == true)
$("#menu-single-descr-mode").removeClass('disabled');
if(multiple_mod == true)
$("#menu-multiple-descr-mode").removeClass('disabled');
} |
JavaScript | finishLoading() {
setTimeout(
function() {
ref.setState({ loading: false });
},
500
); // enable the buttons later for a smoother animation
} | finishLoading() {
setTimeout(
function() {
ref.setState({ loading: false });
},
500
); // enable the buttons later for a smoother animation
} |
JavaScript | onTouchEnd() {
if (this._touchStarted === true) {
dismissKeyboard();
}
this._touchStarted = false;
} | onTouchEnd() {
if (this._touchStarted === true) {
dismissKeyboard();
}
this._touchStarted = false;
} |
JavaScript | static append(currentSlides = [], slides) {
if (!Array.isArray(slides)) {
slides = [slides];
}
return slides.concat(currentSlides);
} | static append(currentSlides = [], slides) {
if (!Array.isArray(slides)) {
slides = [slides];
}
return slides.concat(currentSlides);
} |
JavaScript | onTouchEnd() {
if (this._touchStarted === true) {
dismissKeyboard();
}
this._touchStarted = false;
} | onTouchEnd() {
if (this._touchStarted === true) {
dismissKeyboard();
}
this._touchStarted = false;
} |
JavaScript | parse() {
//console.log("=== text extraction ===")
let parsedTexts = [{children: this.text}];
this.patterns.forEach((patternOptions) => {
let newParts = [];
let {pattern, ...rest} = patternOptions
//console.log(rest.type)
//console.log(rest.style)
parsedTexts.forEach((parsedText) => {
// Only allow for now one parsing
if (parsedText._matched) {
newParts.push(parsedText);
return;
}
let parts = [];
let textLeft = parsedText.children;
while (textLeft) {
//console.log(`textLeft: ${textLeft}`)
//console.log(pattern, `${pattern}`)
let matches = pattern.exec(textLeft);
if (!matches) {
//console.log(`didn't match ${rest.type}`)
break;
}
//console.log(`matched ${rest.type}`)
let previousText = textLeft.substr(0, matches.index);
//console.log(`previousText: ${previousText}`)
parts.push({children: previousText});
parts.push(this.getMatchedPart(patternOptions, matches[0], matches));
textLeft = textLeft.substr(matches.index + matches[0].length);
}
parts.push({children: textLeft});
//console.log("parts:")
//console.log(parts)
newParts.push(...parts);
//console.log("newParts:")
//console.log(newParts)
});
parsedTexts = newParts;
//console.log("parsedTexts")
//console.log(parsedTexts)
});
// Remove _matched key.
parsedTexts.forEach((parsedText) => delete(parsedText._matched));
return parsedTexts.filter(t => !!t.children);
} | parse() {
//console.log("=== text extraction ===")
let parsedTexts = [{children: this.text}];
this.patterns.forEach((patternOptions) => {
let newParts = [];
let {pattern, ...rest} = patternOptions
//console.log(rest.type)
//console.log(rest.style)
parsedTexts.forEach((parsedText) => {
// Only allow for now one parsing
if (parsedText._matched) {
newParts.push(parsedText);
return;
}
let parts = [];
let textLeft = parsedText.children;
while (textLeft) {
//console.log(`textLeft: ${textLeft}`)
//console.log(pattern, `${pattern}`)
let matches = pattern.exec(textLeft);
if (!matches) {
//console.log(`didn't match ${rest.type}`)
break;
}
//console.log(`matched ${rest.type}`)
let previousText = textLeft.substr(0, matches.index);
//console.log(`previousText: ${previousText}`)
parts.push({children: previousText});
parts.push(this.getMatchedPart(patternOptions, matches[0], matches));
textLeft = textLeft.substr(matches.index + matches[0].length);
}
parts.push({children: textLeft});
//console.log("parts:")
//console.log(parts)
newParts.push(...parts);
//console.log("newParts:")
//console.log(newParts)
});
parsedTexts = newParts;
//console.log("parsedTexts")
//console.log(parsedTexts)
});
// Remove _matched key.
parsedTexts.forEach((parsedText) => delete(parsedText._matched));
return parsedTexts.filter(t => !!t.children);
} |
JavaScript | static append(currentSlides = [], slides) {
if (!Array.isArray(slides)) {
slides = [slides];
}
return slides.concat(currentSlides);
} | static append(currentSlides = [], slides) {
if (!Array.isArray(slides)) {
slides = [slides];
}
return slides.concat(currentSlides);
} |
JavaScript | function genID(bID, key) {
var table1 = document.getElementById('data1');
firebase.database().ref().child(`userData/`).on('child_added', snapshot => {
if(bID==snapshot.key){
db.ref(`userData/${bID}`).on('child_added',snapshot =>{
table1.innerHTML = fill(snapshot.val());
});
}
});
function fill( ad){
return `
<div class="wrap">
<img id="inbox-img" src=${ad.pic} alt="" />
<p>${ad.user}</p>
</div>
`
}
} | function genID(bID, key) {
var table1 = document.getElementById('data1');
firebase.database().ref().child(`userData/`).on('child_added', snapshot => {
if(bID==snapshot.key){
db.ref(`userData/${bID}`).on('child_added',snapshot =>{
table1.innerHTML = fill(snapshot.val());
});
}
});
function fill( ad){
return `
<div class="wrap">
<img id="inbox-img" src=${ad.pic} alt="" />
<p>${ad.user}</p>
</div>
`
}
} |
JavaScript | function approveTask(date, id) {
const url = markersURL + id;
const body = {
approve_date: Date.now(),
status: 3,
};
return dispatch =>
fetch(url, {
method: 'PUT',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
...(Object.keys(body).length ? { body: JSON.stringify(body) } : {}),
})
.then(() => dispatch(getMarkersList()))
.then(() => dispatch(closeApprove()));
} | function approveTask(date, id) {
const url = markersURL + id;
const body = {
approve_date: Date.now(),
status: 3,
};
return dispatch =>
fetch(url, {
method: 'PUT',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
...(Object.keys(body).length ? { body: JSON.stringify(body) } : {}),
})
.then(() => dispatch(getMarkersList()))
.then(() => dispatch(closeApprove()));
} |
JavaScript | function showModal() {
return dispatch =>
dispatch({
type: SHOW_MODAL,
payload: true,
});
} | function showModal() {
return dispatch =>
dispatch({
type: SHOW_MODAL,
payload: true,
});
} |
JavaScript | static serializeList(tokens) {
const ss = new SpanSerializer();
return tokens.map((token) => {
return [token.type, token.value, ss.serializeSpan(token.span)];
});
} | static serializeList(tokens) {
const ss = new SpanSerializer();
return tokens.map((token) => {
return [token.type, token.value, ss.serializeSpan(token.span)];
});
} |
JavaScript | readChar(what) {
if (this.pos < this.end && this.source[this.pos] === what) {
this.read();
return true;
}
else
return false;
} | readChar(what) {
if (this.pos < this.end && this.source[this.pos] === what) {
this.read();
return true;
}
else
return false;
} |
JavaScript | consumeToken(type) {
if (this.pos >= this.lexed.tokens.length)
return null;
const head = this.lexed.tokens[this.pos];
//console.log(this.lexed.tokens[this.pos].type, 'vs', type);
if (head.type !== type)
return null;
//console.log('Consume', this.lexed.tokens[0]);
if (head.span)
this.lastGoodSpan = head.span;
this.pos++;
return head;
} | consumeToken(type) {
if (this.pos >= this.lexed.tokens.length)
return null;
const head = this.lexed.tokens[this.pos];
//console.log(this.lexed.tokens[this.pos].type, 'vs', type);
if (head.type !== type)
return null;
//console.log('Consume', this.lexed.tokens[0]);
if (head.span)
this.lastGoodSpan = head.span;
this.pos++;
return head;
} |
JavaScript | function loadFILE(file,fn,attrs){
if(!attrs) attrs = {};
attrs['_file'] = file;
var error = "";
var xhr = new XMLHttpRequest();
if(attrs.error && typeof attrs.error==="function") error = function(e){ attrs.error.call((attrs.context ? attrs.context : this),e,attrs) }
if(error){
xhr.addEventListener("error", error, false);
xhr.addEventListener("abort", error, false);
}
xhr.onreadystatechange = function(){
if(xhr.readyState==4){
if(typeof fn==="function"){
fn.call((attrs.context ? attrs.context : this),xhr.responseText,attrs);
}
}
}
xhr.open("GET", file, true);
try {
xhr.send();
} catch(e) {
if(error) attrs.error.call((attrs.context ? attrs.context : this),e,attrs);
}
} | function loadFILE(file,fn,attrs){
if(!attrs) attrs = {};
attrs['_file'] = file;
var error = "";
var xhr = new XMLHttpRequest();
if(attrs.error && typeof attrs.error==="function") error = function(e){ attrs.error.call((attrs.context ? attrs.context : this),e,attrs) }
if(error){
xhr.addEventListener("error", error, false);
xhr.addEventListener("abort", error, false);
}
xhr.onreadystatechange = function(){
if(xhr.readyState==4){
if(typeof fn==="function"){
fn.call((attrs.context ? attrs.context : this),xhr.responseText,attrs);
}
}
}
xhr.open("GET", file, true);
try {
xhr.send();
} catch(e) {
if(error) attrs.error.call((attrs.context ? attrs.context : this),e,attrs);
}
} |
JavaScript | async startingAnimation() {
let obj = {
position: null,
clock: new THREE.Clock(true)
};
obj = await this.startingAnimation1(obj);
obj = await this.startingAnimation2(obj);
obj = await this.startingAnimation3(obj);
obj = await this.startingAnimation4(obj);
obj = await this.startingAnimation5(obj);
this.objects.introParticles.removeFromScene(this.scene);
return;
} | async startingAnimation() {
let obj = {
position: null,
clock: new THREE.Clock(true)
};
obj = await this.startingAnimation1(obj);
obj = await this.startingAnimation2(obj);
obj = await this.startingAnimation3(obj);
obj = await this.startingAnimation4(obj);
obj = await this.startingAnimation5(obj);
this.objects.introParticles.removeFromScene(this.scene);
return;
} |
JavaScript | turn(level) {
let self = this;
if (self.move.continue) {
if (self.move.left) {
self.objects.way.rotate(-Math.PI * 0.01);
self.objects.particles.rotate(-Math.PI * 0.01);
}
if (self.move.right) {
self.objects.way.rotate(Math.PI * 0.01);
self.objects.particles.rotate(Math.PI * 0.01);
}
if (self.move.up) self.objects.protagonist.jump();
if (self.move.boost && self.boostNotUsed && Cookies.get('powerup-4') == 'bought') {
level.powerupActiveDuration = self.objects.way.currentPosition.distance + 750;
level.powerupActive = true;
self.boostNotUsed = false;
}
}
} | turn(level) {
let self = this;
if (self.move.continue) {
if (self.move.left) {
self.objects.way.rotate(-Math.PI * 0.01);
self.objects.particles.rotate(-Math.PI * 0.01);
}
if (self.move.right) {
self.objects.way.rotate(Math.PI * 0.01);
self.objects.particles.rotate(Math.PI * 0.01);
}
if (self.move.up) self.objects.protagonist.jump();
if (self.move.boost && self.boostNotUsed && Cookies.get('powerup-4') == 'bought') {
level.powerupActiveDuration = self.objects.way.currentPosition.distance + 750;
level.powerupActive = true;
self.boostNotUsed = false;
}
}
} |
JavaScript | simpleIntro() {
this.camera.position.set(0, 50, 95);
this.objects.particles.position(0, 0, -500);
this.objects.particles.addToScene(this.scene);
this.objects.protagonist.position(0, 5, 0);
this.objects.protagonist.rotate('y', Math.PI);
this.objects.protagonist.addToScene(this.scene);
this.camera.lookAt(this.objects.protagonist.currentPosition);
} | simpleIntro() {
this.camera.position.set(0, 50, 95);
this.objects.particles.position(0, 0, -500);
this.objects.particles.addToScene(this.scene);
this.objects.protagonist.position(0, 5, 0);
this.objects.protagonist.rotate('y', Math.PI);
this.objects.protagonist.addToScene(this.scene);
this.camera.lookAt(this.objects.protagonist.currentPosition);
} |
JavaScript | function showSuccessScreen(obj) {
return new Promise(res => {
let html = templates.successScreen.render(obj);
$('body').append(html);
$('#successScreen').fadeIn(1000, res);
});
} | function showSuccessScreen(obj) {
return new Promise(res => {
let html = templates.successScreen.render(obj);
$('body').append(html);
$('#successScreen').fadeIn(1000, res);
});
} |
JavaScript | function showGameOverScreen(obj) {
return new Promise(res => {
let html = templates.gameoverScreen.render(obj);
$('body').append(html);
$('#gameoverScreen').fadeIn(1000, res);
});
} | function showGameOverScreen(obj) {
return new Promise(res => {
let html = templates.gameoverScreen.render(obj);
$('body').append(html);
$('#gameoverScreen').fadeIn(1000, res);
});
} |
JavaScript | async function startingAnimationFadeIn() {
return new Promise(res => {
$('.intro-text').fadeIn(1000, res);
});
} | async function startingAnimationFadeIn() {
return new Promise(res => {
$('.intro-text').fadeIn(1000, res);
});
} |
JavaScript | function updateNextLevelButton() {
if ($('.button.success.reload').length) {
$('.button.success.reload').removeClass('disabled');
$('.callout.alert').remove();
}
} | function updateNextLevelButton() {
if ($('.button.success.reload').length) {
$('.button.success.reload').removeClass('disabled');
$('.callout.alert').remove();
}
} |
JavaScript | static prepareForCollisionDetection(obstacle, r) {
return {
type: 'ring',
size: {
height: radius - 80
},
angle: {
center: 0,
min: 0,
max: 360
},
distance: {
center: obstacle.position.distance,
min: obstacle.position.distance -1,
max: obstacle.position.distance + 1
},
};
} | static prepareForCollisionDetection(obstacle, r) {
return {
type: 'ring',
size: {
height: radius - 80
},
angle: {
center: 0,
min: 0,
max: 360
},
distance: {
center: obstacle.position.distance,
min: obstacle.position.distance -1,
max: obstacle.position.distance + 1
},
};
} |
JavaScript | function generateFromArray(obstacles, wayLength, radius) {
const ret = obstacles.map(o => {
const obstacle = new _obstacleTypes[o.type](o);
obstacle.position(o.position.angle, o.position.distance, wayLength, radius);
const collisionData = _obstacleTypes[o.type].prepareForCollisionDetection(o, radius);
return new Obstacle(
o.type,
obstacle.mesh,
o.position.distance,
o.position.angle,
collisionData
);
});
return ret;
} | function generateFromArray(obstacles, wayLength, radius) {
const ret = obstacles.map(o => {
const obstacle = new _obstacleTypes[o.type](o);
obstacle.position(o.position.angle, o.position.distance, wayLength, radius);
const collisionData = _obstacleTypes[o.type].prepareForCollisionDetection(o, radius);
return new Obstacle(
o.type,
obstacle.mesh,
o.position.distance,
o.position.angle,
collisionData
);
});
return ret;
} |
JavaScript | static prepareForCollisionDetection(obstacle, radius) {
let b = obstacle.size.width * 0.5;
let angleRight = Math.atan(b / radius);
return {
type: 'box',
size: obstacle.size,
angle: {
center: obstacle.position.angle,
min: obstacle.position.angle - Util.convertRadiansToDegrees(angleRight),
max: obstacle.position.angle + Util.convertRadiansToDegrees(angleRight)
},
distance: {
center: obstacle.position.distance,
min: obstacle.position.distance - (0.5 * obstacle.size.length),
max: obstacle.position.distance + (0.5 * obstacle.size.length)
}
};
} | static prepareForCollisionDetection(obstacle, radius) {
let b = obstacle.size.width * 0.5;
let angleRight = Math.atan(b / radius);
return {
type: 'box',
size: obstacle.size,
angle: {
center: obstacle.position.angle,
min: obstacle.position.angle - Util.convertRadiansToDegrees(angleRight),
max: obstacle.position.angle + Util.convertRadiansToDegrees(angleRight)
},
distance: {
center: obstacle.position.distance,
min: obstacle.position.distance - (0.5 * obstacle.size.length),
max: obstacle.position.distance + (0.5 * obstacle.size.length)
}
};
} |
JavaScript | init() {
let self = this;
for (let i = 0; i < self.amount; i++) {
self.particle = new THREE.Mesh(
new THREE.SphereGeometry(1, 32, 32),
new THREE.MeshBasicMaterial()
);
self.particle.position.x = Particles.randomIntFromInterval(self.x.min, self.x.max);
self.particle.position.y = Particles.randomIntFromInterval(self.y.min, self.y.max);
self.particle.position.z = Particles.randomIntFromInterval(self.z.min, self.z.max);
self.group.add(self.particle);
}
} | init() {
let self = this;
for (let i = 0; i < self.amount; i++) {
self.particle = new THREE.Mesh(
new THREE.SphereGeometry(1, 32, 32),
new THREE.MeshBasicMaterial()
);
self.particle.position.x = Particles.randomIntFromInterval(self.x.min, self.x.max);
self.particle.position.y = Particles.randomIntFromInterval(self.y.min, self.y.max);
self.particle.position.z = Particles.randomIntFromInterval(self.z.min, self.z.max);
self.group.add(self.particle);
}
} |
JavaScript | checkCollision(protagonist) {
this.checkCollisionDetection = false;
let currentPosition = this.getCurrentPosition(protagonist);
let collObj = this.getCollisionObject(currentPosition);
switch (collObj.type) {
case 'box':
case 'ring':
case 'cone':
this.hitObstacle();
return true;
case 'diamond':
this.hitDiamond(collObj);
return false;
default:
return false;
}
} | checkCollision(protagonist) {
this.checkCollisionDetection = false;
let currentPosition = this.getCurrentPosition(protagonist);
let collObj = this.getCollisionObject(currentPosition);
switch (collObj.type) {
case 'box':
case 'ring':
case 'cone':
this.hitObstacle();
return true;
case 'diamond':
this.hitDiamond(collObj);
return false;
default:
return false;
}
} |
JavaScript | hitDiamond(collObj) {
if (this.lastDiamond && collObj.mesh.id === this.lastDiamond.mesh.id)
return;
Sound.play('hitDiamond');
this.lastDiamond = collObj;
this.diamonds++;
this.lastDiamond.mesh.visible = false;
GUI.setDiamondsInScoreBoard(this.diamonds);
} | hitDiamond(collObj) {
if (this.lastDiamond && collObj.mesh.id === this.lastDiamond.mesh.id)
return;
Sound.play('hitDiamond');
this.lastDiamond = collObj;
this.diamonds++;
this.lastDiamond.mesh.visible = false;
GUI.setDiamondsInScoreBoard(this.diamonds);
} |
JavaScript | async showGameOverScreen() {
await GUI.showGameOverScreen({
score: this.diamonds,
level: this.current
});
} | async showGameOverScreen() {
await GUI.showGameOverScreen({
score: this.diamonds,
level: this.current
});
} |
JavaScript | static async lastSuccessfulLevel() {
let docs = await Database.getSuccessfulLevels();
const levelID = docs
.filter(doc => doc.diamonds >= levels[doc.levelID - 1].requiredDiamonds)
.sort((a, b) => {
if (a.levelID > b.levelID) return 1;
else return -1;
})
.pop()
.levelID;
return levelID + 1;
} | static async lastSuccessfulLevel() {
let docs = await Database.getSuccessfulLevels();
const levelID = docs
.filter(doc => doc.diamonds >= levels[doc.levelID - 1].requiredDiamonds)
.sort((a, b) => {
if (a.levelID > b.levelID) return 1;
else return -1;
})
.pop()
.levelID;
return levelID + 1;
} |
JavaScript | groupBodyParts() {
this.body.position(0, 0, 0);
this.body.addToGroup(this.object3D);
this.head.position(0, 0.1, 0);
this.head.addToGroup(this.object3D);
this.right.leg.position(0.5, 0, 0);
this.right.leg.addToGroup(this.object3D);
this.left.leg.position(0, 0, 0);
this.left.leg.addToGroup(this.object3D);
} | groupBodyParts() {
this.body.position(0, 0, 0);
this.body.addToGroup(this.object3D);
this.head.position(0, 0.1, 0);
this.head.addToGroup(this.object3D);
this.right.leg.position(0.5, 0, 0);
this.right.leg.addToGroup(this.object3D);
this.left.leg.position(0, 0, 0);
this.left.leg.addToGroup(this.object3D);
} |
JavaScript | jump() {
let height = 40;
if (Cookies.get('powerup-2') == 'bought') height = 70;
let self = this;
if (!self.isJumping) {
self.isJumping = true;
let tween = new TWEEN
.Tween({
jump: 0
})
.to({
jump: Math.PI
}, 700)
.onUpdate(function() {
self.group.position.y = 70 * Math.sin(this.jump);
})
.start();
tween.onComplete(function() {
self.isJumping = false;
});
}
} | jump() {
let height = 40;
if (Cookies.get('powerup-2') == 'bought') height = 70;
let self = this;
if (!self.isJumping) {
self.isJumping = true;
let tween = new TWEEN
.Tween({
jump: 0
})
.to({
jump: Math.PI
}, 700)
.onUpdate(function() {
self.group.position.y = 70 * Math.sin(this.jump);
})
.start();
tween.onComplete(function() {
self.isJumping = false;
});
}
} |
JavaScript | static makeGroupTransparent(group, opacity) {
group.children.forEach(function(parts) {
parts.material.transparent = true;
parts.material.opacity = opacity;
});
} | static makeGroupTransparent(group, opacity) {
group.children.forEach(function(parts) {
parts.material.transparent = true;
parts.material.opacity = opacity;
});
} |
JavaScript | hitDiamond(collObj) {
if (this.lastDiamond && collObj.mesh.id === this.lastDiamond.mesh.id)
return;
Sound.play('hitDiamond');
this.lastDiamond = collObj;
this.diamonds++;
this.lastDiamond.mesh.visible = false;
// GUI.setDiamondsInScoreBoard(this.diamonds);
} | hitDiamond(collObj) {
if (this.lastDiamond && collObj.mesh.id === this.lastDiamond.mesh.id)
return;
Sound.play('hitDiamond');
this.lastDiamond = collObj;
this.diamonds++;
this.lastDiamond.mesh.visible = false;
// GUI.setDiamondsInScoreBoard(this.diamonds);
} |
JavaScript | async showGameOverScreen() {
/* await GUI.showGameOverScreen({
score: this.diamonds,
level: this.id
});*/
} | async showGameOverScreen() {
/* await GUI.showGameOverScreen({
score: this.diamonds,
level: this.id
});*/
} |
JavaScript | groupBodyParts() {
/*
this.body.position(0, 0, 0);
this.body.addToGroup(this.object3D);
this.right.leg.position(0.5, 0, 0);
this.right.leg.addToGroup(this.object3D);
this.left.leg.position(0, 0, 0);
this.left.leg.addToGroup(this.object3D);
*/
this.head.position.x = 0;
this.head.position.y = -10;
this.head.position.z = 0;
this.object3D.add(this.head);
// this.head.addToGroup(this.object3D);
} | groupBodyParts() {
/*
this.body.position(0, 0, 0);
this.body.addToGroup(this.object3D);
this.right.leg.position(0.5, 0, 0);
this.right.leg.addToGroup(this.object3D);
this.left.leg.position(0, 0, 0);
this.left.leg.addToGroup(this.object3D);
*/
this.head.position.x = 0;
this.head.position.y = -10;
this.head.position.z = 0;
this.object3D.add(this.head);
// this.head.addToGroup(this.object3D);
} |
JavaScript | jump() {
const height$ = new BehaviorSubject(this.object3D.position.y);
const jumpHeight = 70;
if (this.isJumping) return;
this.isJumping = true;
const self = this;
let tween = new TWEEN
.Tween({
jump: 0
})
.to({
jump: Math.PI
}, 700)
.onUpdate(function() {
const height = jumpHeight * Math.sin(this.jump);
self.object3D.position.y = height;
height$.next(height);
})
.start();
tween.onComplete(() => {
this.isJumping = false;
height$.complete();
});
return height$;
} | jump() {
const height$ = new BehaviorSubject(this.object3D.position.y);
const jumpHeight = 70;
if (this.isJumping) return;
this.isJumping = true;
const self = this;
let tween = new TWEEN
.Tween({
jump: 0
})
.to({
jump: Math.PI
}, 700)
.onUpdate(function() {
const height = jumpHeight * Math.sin(this.jump);
self.object3D.position.y = height;
height$.next(height);
})
.start();
tween.onComplete(() => {
this.isJumping = false;
height$.complete();
});
return height$;
} |
JavaScript | function isMusicOn() {
if (Cookies.get('sound') === 'on') return true;
if (Cookies.get('sound') === 'undefined') {
_setMusicSettings(true);
return true;
}
return false;
} | function isMusicOn() {
if (Cookies.get('sound') === 'on') return true;
if (Cookies.get('sound') === 'undefined') {
_setMusicSettings(true);
return true;
}
return false;
} |
JavaScript | collisionWithinDistance() {
if (
this.currentObstacle.collisionData.distance.min < this.currentPosition.distance &&
this.currentPosition.distance < this.currentObstacle.collisionData.distance.max
) return true;
return false;
} | collisionWithinDistance() {
if (
this.currentObstacle.collisionData.distance.min < this.currentPosition.distance &&
this.currentPosition.distance < this.currentObstacle.collisionData.distance.max
) return true;
return false;
} |
JavaScript | static prepareForCollisionDetection(obstacle, radius) {
let angle = 10;
return {
type: 'diamond',
size: {
height: heightFromWay
},
angle: {
center: obstacle.position.angle,
min: obstacle.position.angle - angle,
max: obstacle.position.angle + angle
},
distance: {
center: obstacle.position.distance,
min: obstacle.position.distance - 10,
max: obstacle.position.distance + 10
}
};
} | static prepareForCollisionDetection(obstacle, radius) {
let angle = 10;
return {
type: 'diamond',
size: {
height: heightFromWay
},
angle: {
center: obstacle.position.angle,
min: obstacle.position.angle - angle,
max: obstacle.position.angle + angle
},
distance: {
center: obstacle.position.distance,
min: obstacle.position.distance - 10,
max: obstacle.position.distance + 10
}
};
} |
JavaScript | position() {
this.group.rotation.x = Math.PI / 2;
this.group.position.y = -this.radius - 18;
this.group.position.z = -this.length * 0.5 + 50;
} | position() {
this.group.rotation.x = Math.PI / 2;
this.group.position.y = -this.radius - 18;
this.group.position.z = -this.length * 0.5 + 50;
} |
JavaScript | rotate(angle) {
if (Util.convertRadiansToDegrees(this.group.rotation.y) >= 360) this.group.rotation.y = 0;
if (Util.convertRadiansToDegrees(this.group.rotation.y) < 0) this.group.rotation.y = Util.convertDegreesToRadians(360);
this.group.rotation.y += angle;
this.currentPosition.angle = Util.convertRadiansToDegrees(this.group.rotation.y);
this.setCurrentPosition();
} | rotate(angle) {
if (Util.convertRadiansToDegrees(this.group.rotation.y) >= 360) this.group.rotation.y = 0;
if (Util.convertRadiansToDegrees(this.group.rotation.y) < 0) this.group.rotation.y = Util.convertDegreesToRadians(360);
this.group.rotation.y += angle;
this.currentPosition.angle = Util.convertRadiansToDegrees(this.group.rotation.y);
this.setCurrentPosition();
} |
JavaScript | async function showScreen() {
if (!level[currentLevel].gameOver) {
//success
await level[currentLevel].storeToDB(true);
await level[currentLevel].showSuccessScreen();
} else {
//gameover
await level[currentLevel].storeToDB(false);
await level[currentLevel].showGameOverScreen();
}
} | async function showScreen() {
if (!level[currentLevel].gameOver) {
//success
await level[currentLevel].storeToDB(true);
await level[currentLevel].showSuccessScreen();
} else {
//gameover
await level[currentLevel].storeToDB(false);
await level[currentLevel].showGameOverScreen();
}
} |
JavaScript | function isMusicOn() {
if (Cookies.get('sound') === 'on') return true;
if (Cookies.get('sound')) {
level[currentLevel].playSound = false;
return false;
}
setMusicSettings(true);
return true;
} | function isMusicOn() {
if (Cookies.get('sound') === 'on') return true;
if (Cookies.get('sound')) {
level[currentLevel].playSound = false;
return false;
}
setMusicSettings(true);
return true;
} |
JavaScript | moveForwardTillEnd(speed) {
this.group.position.z = this.group.position.z + speed;
this.currentPosition.distance = this.currentPosition.distance + speed;
this.moveRandomObstacles();
GUI.updateDistance(this.currentPosition.distance);
} | moveForwardTillEnd(speed) {
this.group.position.z = this.group.position.z + speed;
this.currentPosition.distance = this.currentPosition.distance + speed;
this.moveRandomObstacles();
GUI.updateDistance(this.currentPosition.distance);
} |
JavaScript | function createIndex(addFn) {
return lunr(/** @this */function() {
this.pipeline.remove(lunr.stopWordFilter);
this.ref('path');
this.field('titleWords', {boost: 100});
this.field('headingWords', {boost: 50});
this.field('members', {boost: 40});
this.field('keywords', {boost: 20});
addFn(this);
});
} | function createIndex(addFn) {
return lunr(/** @this */function() {
this.pipeline.remove(lunr.stopWordFilter);
this.ref('path');
this.field('titleWords', {boost: 100});
this.field('headingWords', {boost: 50});
this.field('members', {boost: 40});
this.field('keywords', {boost: 20});
addFn(this);
});
} |
JavaScript | function handleMessage(message) {
var type = message.data.type;
var id = message.data.id;
var payload = message.data.payload;
switch(type) {
case 'load-index':
makeRequest(SEARCH_TERMS_URL, function(searchInfo) {
index = createIndex(loadIndex(searchInfo));
self.postMessage({type: type, id: id, payload: true});
});
break;
case 'query-index':
self.postMessage({type: type, id: id, payload: {query: payload, results: queryIndex(payload)}});
break;
default:
self.postMessage({type: type, id: id, payload: {error: 'invalid message type'}})
}
} | function handleMessage(message) {
var type = message.data.type;
var id = message.data.id;
var payload = message.data.payload;
switch(type) {
case 'load-index':
makeRequest(SEARCH_TERMS_URL, function(searchInfo) {
index = createIndex(loadIndex(searchInfo));
self.postMessage({type: type, id: id, payload: true});
});
break;
case 'query-index':
self.postMessage({type: type, id: id, payload: {query: payload, results: queryIndex(payload)}});
break;
default:
self.postMessage({type: type, id: id, payload: {error: 'invalid message type'}})
}
} |
JavaScript | function makeRequest(url, callback) {
// The JSON file that is loaded should be an array of PageInfo:
var searchDataRequest = new XMLHttpRequest();
searchDataRequest.onload = function() {
callback(JSON.parse(this.responseText));
};
searchDataRequest.open('GET', url);
searchDataRequest.send();
} | function makeRequest(url, callback) {
// The JSON file that is loaded should be an array of PageInfo:
var searchDataRequest = new XMLHttpRequest();
searchDataRequest.onload = function() {
callback(JSON.parse(this.responseText));
};
searchDataRequest.open('GET', url);
searchDataRequest.send();
} |
JavaScript | function loadIndex(searchInfo /*: SearchInfo */) {
return function(index) {
// Store the pages data to be used in mapping query results back to pages
// Add search terms from each page to the search index
searchInfo.forEach(function(page /*: PageInfo */) {
index.add(page);
pages[page.path] = page;
});
};
} | function loadIndex(searchInfo /*: SearchInfo */) {
return function(index) {
// Store the pages data to be used in mapping query results back to pages
// Add search terms from each page to the search index
searchInfo.forEach(function(page /*: PageInfo */) {
index.add(page);
pages[page.path] = page;
});
};
} |
JavaScript | function queryIndex(query) {
try {
if (query.length) {
// Add a relaxed search in the title for the first word in the query
// E.g. if the search is "ngCont guide" then we search for "ngCont guide titleWords:ngCont*"
var titleQuery = 'titleWords:*' + query.split(' ', 1)[0] + '*';
var results = index.search(query + ' ' + titleQuery);
// Map the hits into info about each page to be returned as results
return results.map(function(hit) { return pages[hit.ref]; });
}
} catch(e) {
// If the search query cannot be parsed the index throws an error
// Log it and recover
console.log(e);
}
return [];
} | function queryIndex(query) {
try {
if (query.length) {
// Add a relaxed search in the title for the first word in the query
// E.g. if the search is "ngCont guide" then we search for "ngCont guide titleWords:ngCont*"
var titleQuery = 'titleWords:*' + query.split(' ', 1)[0] + '*';
var results = index.search(query + ' ' + titleQuery);
// Map the hits into info about each page to be returned as results
return results.map(function(hit) { return pages[hit.ref]; });
}
} catch(e) {
// If the search query cannot be parsed the index throws an error
// Log it and recover
console.log(e);
}
return [];
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.