Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseCode2DataAndOptions(code, callback) {
code = trimKeepingTabs(code);
const [firstCode, secondCode] = code.split(/\n{2,}/);
// try to parse first code block as `options`
let options = parseCode2ChartOption(firstCode);
const url = options && options.editorChart && options.editorChart.url;
// if first code block is `options` and has `url` option, fetch data from url
let dataAndOptions;
if (util.isString(url)) {
// url option provided
// fetch data from url
const success = dataCode => {
dataAndOptions = _parseCode2DataAndOptions(dataCode, firstCode);
callback(dataAndOptions);
};
const fail = () => callback(null);
$.get(url).done(success).fail(fail);
} else {
// else first block is `data`
dataAndOptions = _parseCode2DataAndOptions(firstCode, secondCode);
callback(dataAndOptions);
}
}
function parseCode2DataAndOptions(code, callback) {
code = trimKeepingTabs(code);
const [firstCode, secondCode] = code.split(/\n{2,}/);
// try to parse first code block as `options`
let options = parseCode2ChartOption(firstCode);
const url = options && options.editorChart && options.editorChart.url;
// if first code block is `options` and has `url` option, fetch data from url
let dataAndOptions;
if (util.isString(url)) {
// url option provided
// fetch data from url
const success = dataCode => {
dataAndOptions = _parseCode2DataAndOptions(dataCode, firstCode);
callback(dataAndOptions);
};
const fail = () => callback(null);
$.get(url).done(success).fail(fail);
} else {
// else first block is `data`
dataAndOptions = _parseCode2DataAndOptions(firstCode, secondCode);
callback(dataAndOptions);
}
}
resetContent(content) {
this.oldTextContent = (util.isString(content) ? content : null);
}
indexOfItem(item) {
let index;
if (item instanceof ToolbarItem) {
index = this._items.indexOf(item);
} else if (util.isString(item)) {
const itemName = item;
index = this._items.map(itemToTest => itemToTest.getName()).indexOf(itemName);
}
return index;
}
const getParentUntil = function(node, untilNode) {
let foundedNode;
if (util.isString(untilNode)) {
foundedNode = getParentUntilBy(node, targetNode => untilNode === getNodeName(targetNode));
} else {
foundedNode = getParentUntilBy(node, targetNode => untilNode === targetNode);
}
return foundedNode;
};
find: function(selector, root, multiple) {
var result = [],
found = false,
isFirst = util.isUndefined(multiple) || multiple === false,
isFilter = util.isFunction(multiple);
if (util.isString(root)) {
root = domutil.get(root);
}
root = root || window.document.body;
/**
* Function for recursive find specific node
* @param {HTMLElement} el - element to search
* @param {string} selector - selector
*/
function recurse(el, selector) {
var childNodes = el.childNodes,
i = 0,
len = childNodes.length,
cursor;
hasTreeColumn: function() {
return snippet.isString(this.get('treeColumnOptions').name);
},
_isDetectedLabel(position) {
const labelElement = document.elementFromPoint(position.left, position.top);
return snippet.isString(labelElement.className);
}