-
Notifications
You must be signed in to change notification settings - Fork 2
/
highlightCode.js
140 lines (113 loc) · 5.42 KB
/
highlightCode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
function showSourceJS()
{
var jsString = myScript.text
jsString = jsString.replace(/\</g, "<")
jsString = jsString.replace(/\>/g, ">")
jsCodeDiv.innerHTML = '<pre><code id="codeJS" class="javascript">'+jsString+'</code></pre>'
var aCode = document.getElementById('codeJS');
hljs.highlightBlock(aCode);
}
function showSourceSVG()
{
var svgString = svgDiv.innerHTML
svgString = svgString.replace(/\</g, "<")
svgString = svgString.replace(/\>/g, ">\n")
svgSourceDiv.innerHTML = '<pre><code id="codeSVG" class="xml">'+svgString+'</code></pre>'
var aCode = document.getElementById('codeSVG');
hljs.highlightBlock(aCode);
//svgSourceDiv.style.height = +svgSourceDiv.scrollHeight+"px"
}
function showSaveSVG()
{
svgSaveDiv.style.height="1px"
var saveSVG = mySVG.cloneNode(true)
saveSVG.setAttribute("id", "sideKickSVG")
saveSVG.removeAttribute("onmousedown")
saveSVG.removeAttribute("onmouseup")
saveSVG.removeAttribute("onmousemove")
saveSVG.removeAttribute("onclick")
for(var j = saveSVG.childNodes.length-1; j>=0; j--)
{
var elem = saveSVG.childNodes.item(j)
var id = elem.getAttribute("id")
if(id=="endArrowDefs")saveSVG.removeChild(elem)
if(id=="domActiveElemG")saveSVG.removeChild(elem)
if(id=="domWrapper")saveSVG.removeChild(elem)
if(id=="coverRect")saveSVG.removeChild(elem)
if(id=="dragDot")saveSVG.removeChild(elem)
if(id=="pvStripChart")saveSVG.removeChild(elem)
}
for(var k = saveSVG.childNodes.length-1; k>=0; k--)
{
var elem = saveSVG.childNodes.item(k)
if(elem.nodeName!="#text")
{
var id = elem.getAttribute("id")
elem.removeAttribute("pointer-events")
if(id=="zoomG")
{ elem.removeChild(elem.firstChild) //---grid---
var gGz=elem.childNodes
for (m=0;m<gGz.length;m++)
{
var elem=gGz.item(m)
var id = elem.getAttribute("id")
//---remove non needed attributes---
if(elem.id=="topG")
{
var pathG=elem.childNodes.item(0)
pathG.removeAttribute("pointer-events")
for(var p = 0; p<pathG.childNodes.length; p++)
{
pathG.childNodes.item(p).removeAttribute("onmousedown");
pathG.childNodes.item(p).removeAttribute("style");
pathG.childNodes.item(p).removeAttribute("class");
pathG.childNodes.item(p).removeAttribute("id")
pathG.childNodes.item(p).removeAttribute("vector-effect")
}
var elemG = elem.childNodes.item(1)
elemG.removeAttribute("pointer-events")
for(var e = 0; e<elemG.childNodes.length; e++)
{
elemG.childNodes.item(e).removeAttribute("onmousedown");
elemG.childNodes.item(e).removeAttribute("style");
elemG.childNodes.item(e).removeAttribute("class");
elemG.childNodes.item(e).removeAttribute("id")
elemG.childNodes.item(e).removeAttribute("cursor")
}
}
if(id=="domAddSymbolG")
{
//---remove non needed attributes---
for(var e = 0; e<elem.childNodes.length; e++)
{
elem.childNodes.item(e).removeAttribute("onmousedown");
elem.childNodes.item(e).removeAttribute("id");
elem.childNodes.item(e).removeAttribute("class");
elem.childNodes.item(e).removeAttribute("onclick")
elem.childNodes.item(e).removeAttribute("cursor")
}
}
if(id=="domAddIconG")
{
//---remove non needed attributes---
for(var e = 0; e<elem.childNodes.length; e++)
{
elem.childNodes.item(e).removeAttribute("onmousedown");
elem.childNodes.item(e).removeAttribute("id");
elem.childNodes.item(e).removeAttribute("class");
elem.childNodes.item(e).removeAttribute("onclick")
elem.childNodes.item(e).removeAttribute("cursor")
}
}
}
}
}
}
var svgString = new XMLSerializer().serializeToString(saveSVG)
svgString = svgString.replace(/\</g, "<")
svgString = svgString.replace(/\>/g, ">\n")
svgSaveDiv.innerHTML = '<pre><code id="saveSVG" class="xml">'+svgString+'</code></pre>'
var sCode = document.getElementById('saveSVG');
hljs.highlightBlock(sCode);
svgSaveDiv.style.height = +svgSaveDiv.scrollHeight+"px"
}