quoslibero
Version:
FusionCharts JavaScript charting framework
1 lines • 1.67 kB
JavaScript
export default function(a){let b=[{reg:/xmlns\=\"http\:\/\/www.w3.org\/2000\/svg\"/ig,repStr:''},{reg:/^.*<svg /,repStr:'<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" '},{reg:/\/svg>.*$/,repStr:'/svg>'},{reg:/<desc\>[^<]*<\/desc\>/,repStr:''},{reg:/zIndex="[^"]+"/g,repStr:''},{reg:/url\((\\?[\'\"])[^#]+#/g,repStr:'url($1#'},{reg:/ href=/g,repStr:' xlink:href='},{reg:/(id|class|width|height)=([^" >]+)/g,repStr:'$1="$2"'},{reg:/:(path|rect)/g,repStr:'$1'},{reg:/<ima?ge? ([^\>]+?[^\/])\>/gi,repStr:'<image $1 />'},{reg:/<\/ima?ge?\>/g,repStr:''},{reg:/style="([^"]+)"/g,repStr:function(a){return a.toLowerCase()}},{reg:/NS\d+\:href=/g,repStr:'xlink:href='}],c=function(a){var b=JSON.stringify(a);return b=b.replace(/([a-z]+)([A-Z]+)([a-z]+)/g,function(a,b,c,d){return b+'-'+c.toLowerCase()+d}),b=b.replace(/\"\,\"/g,'";"'),b=b.replace(/\"/g,' '),b=b=b.replace(/\{|\}/g,''),b},d=function(a,b){var d,e,f,g,h,i,j,k=function(a){return a=a.match(/style\s*=/)?a.replace(/(style\s*=")([^"]+)/g,function(a,b,c){return b+g+c}):a.replace(/class\s*="[^"]*"/i,function(a){return a+' style="'+g+'" '}),a};for(d in b)if(b.hasOwnProperty(d))for(i in e=/\s+/,f=d.split(e),g=c(b[d]),f)f.hasOwnProperty(i)&&(h=f[i].trim().replace('.',''),j=new RegExp('<[^>]+('+h+')[^>]+','g'),a=a.replace(j,k));return a};a.svg&&(a.fn.toSVG=function(a){var c,e=this,f='',g=0,h=b.length;if(e.canvas&&e.canvas.parentNode){for(f=e.canvas.parentNode.innerHTML;g<h;g+=1)c=b[g],f=f.replace(c.reg,c.repStr);e._stylesheet&&e._stylesheet.rules&&(f=d(f,e._stylesheet.rules))}return a||(f=f.replace(/<image[^\>]*\>/gi,function(a){return a.match(/href=\"data\:image/i)?a:''})),f})}