|
|
@@ -135,12 +135,11 @@ export function getList(iterable, keys) { |
|
|
|
// Adapted from http://stackoverflow.com/a/2893259/454004 |
|
|
|
// Note: directly ported from CoffeeScript |
|
|
|
export function formatXml (xml) { |
|
|
|
var contexp, fn, formatted, indent, l, lastType, len, lines, ln, pad, reg, transitions, wsexp |
|
|
|
var contexp, fn, formatted, indent, l, lastType, len, lines, ln, reg, transitions, wsexp |
|
|
|
reg = /(>)(<)(\/*)/g |
|
|
|
wsexp = /[ ]*(.*)[ ]+\n/g |
|
|
|
contexp = /(<.+>)(.+\n)/g |
|
|
|
xml = xml.replace(/\r\n/g, "\n").replace(reg, "$1\n$2$3").replace(wsexp, "$1\n").replace(contexp, "$1\n$2") |
|
|
|
pad = 0 |
|
|
|
formatted = "" |
|
|
|
lines = xml.split("\n") |
|
|
|
indent = 0 |
|
|
@@ -164,7 +163,7 @@ export function formatXml (xml) { |
|
|
|
"other->other": 0 |
|
|
|
} |
|
|
|
fn = function(ln) { |
|
|
|
var fromTo, j, key, padding, type, types, value |
|
|
|
var fromTo, key, padding, type, types, value |
|
|
|
types = { |
|
|
|
single: Boolean(ln.match(/<.+\/>/)), |
|
|
|
closing: Boolean(ln.match(/<\/.+>/)), |
|
|
@@ -187,11 +186,13 @@ export function formatXml (xml) { |
|
|
|
padding = "" |
|
|
|
indent += transitions[fromTo] |
|
|
|
padding = ((function() { |
|
|
|
var m, ref1, results |
|
|
|
/* eslint-disable no-unused-vars */ |
|
|
|
var m, ref1, results, j |
|
|
|
results = [] |
|
|
|
for (j = m = 0, ref1 = indent; 0 <= ref1 ? m < ref1 : m > ref1; j = 0 <= ref1 ? ++m : --m) { |
|
|
|
results.push(" ") |
|
|
|
} |
|
|
|
/* eslint-enable no-unused-vars */ |
|
|
|
return results |
|
|
|
})()).join("") |
|
|
|
if (fromTo === "opening->closing") { |
|
|
@@ -215,19 +216,9 @@ export function formatXml (xml) { |
|
|
|
export function highlight (el) { |
|
|
|
const MAX_LENGTH = 5000 |
|
|
|
var |
|
|
|
_window = window, |
|
|
|
_document = document, |
|
|
|
appendChild = "appendChild", |
|
|
|
test = "test", |
|
|
|
// style and color templates |
|
|
|
textShadow = ";text-shadow:", |
|
|
|
opacity = "opacity:.", |
|
|
|
_0px_0px = " 0px 0px ", |
|
|
|
_3px_0px_5 = "3px 0px 5", |
|
|
|
brace = ")", |
|
|
|
|
|
|
|
i, |
|
|
|
microlighted |
|
|
|
test = "test" |
|
|
|
|
|
|
|
if (!el) return "" |
|
|
|
if (el.textContent.length > MAX_LENGTH) { return el.textContent } |
|
|
@@ -260,14 +251,7 @@ export function highlight (el) { |
|
|
|
lastTokenType, |
|
|
|
// flag determining if token is multi-character |
|
|
|
multichar, |
|
|
|
node, |
|
|
|
|
|
|
|
// calculating the colors for the style templates |
|
|
|
colorArr = /(\d*\, \d*\, \d*)(, ([.\d]*))?/g.exec( |
|
|
|
_window.getComputedStyle(el).color |
|
|
|
), |
|
|
|
pxColor = "px rgba("+colorArr[1]+",", |
|
|
|
alpha = colorArr[3]||1 |
|
|
|
node |
|
|
|
|
|
|
|
// running through characters and highlighting |
|
|
|
while (prev2 = prev1, |
|
|
@@ -468,6 +452,17 @@ export const propChecker = (props, nextProps, objectList=[], ignoreList=[]) => { |
|
|
|
|| objectList.some( objectPropName => !eq(props[objectPropName], nextProps[objectPropName]))) |
|
|
|
} |
|
|
|
|
|
|
|
const validateNumber = ( val ) => { |
|
|
|
if ( !/^\d+(.?\d+)?$/.test(val)) { |
|
|
|
return "Value must be a number" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const validateInteger = ( val ) => { |
|
|
|
if ( !/^\d+$/.test(val)) { |
|
|
|
return "Value must be integer" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// validation of parameters before execute |
|
|
|
export const validateParam = (param, isXml) => { |
|
|
@@ -517,22 +512,9 @@ export const validateParam = (param, isXml) => { |
|
|
|
return errors |
|
|
|
} |
|
|
|
|
|
|
|
const validateNumber = ( val ) => { |
|
|
|
if ( !/^\d+(.?\d+)?$/.test(val)) { |
|
|
|
return "Value must be a number" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const validateInteger = ( val ) => { |
|
|
|
if ( !/^\d+$/.test(val)) { |
|
|
|
return "Value must be integer" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export const getSampleSchema = (schema, contentType="", config={}) => { |
|
|
|
if (/xml/.test(contentType)) { |
|
|
|
if (!schema.xml || !schema.xml.name) { |
|
|
|
let name |
|
|
|
schema.xml = schema.xml || {} |
|
|
|
|
|
|
|
if (schema.$$ref) { |
|
|
@@ -564,4 +546,4 @@ export const parseSeach = () => { |
|
|
|
} |
|
|
|
|
|
|
|
return map |
|
|
|
} |
|
|
|
} |