-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs05_publish.js
171 lines (129 loc) · 5.36 KB
/
js05_publish.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
function publishMap(id)
{
var xhr = new XMLHttpRequest();
xhr.open("GET", "Library/Map.svg", true);
xhr.onload = function()
{
var xmlString = this.responseText
//---DOMParser---
var parser = new DOMParser();
MapDoc = parser.parseFromString(xmlString, "text/xml").documentElement;
var groups = MapDoc.childNodes
for(var k = 0; k<groups.length; k++)
{
var group = groups.item(k)
if(group.nodeName!="#text")
{
var mapId = group.getAttribute("id")
if(mapId==id)
{
publishG=group.cloneNode(true)
for(k=0;k<publishG.childNodes.length;k++)
{
var elem=publishG.childNodes.item(k)
elem.removeAttribute("onmouseover")
elem.removeAttribute("onmouseout")
elem.removeAttribute("onmousedown")
}
var svgString= new XMLSerializer().serializeToString(publishG)
var xhr = new XMLHttpRequest();
xhr.open("POST", "_ASP/publishMap.asp", true);
xhr.onload = function()
{
if (this.status == 200)
{
closeMapTable()
publishValue.value = "<!DOCTYPE HTML>\n"+
"<html>\n"+
"<script>\n"+
" window.open('http://svg-deep-caves.com/PUBLISH/index.htm\\?id="+mapId+"','_self')\n"+
"</script>\n"+
"</html>"
publishMapDiv.style.visibility="visible"
publishCave(mapId)
}
};
xhr.send(svgString);
break
}
}
}
}
xhr.send()
}
//---get all caves contained within border----
function publishCave(mapId)
{
var MapDoc
var xhr = new XMLHttpRequest();
xhr.open("GET", "Library/Map.svg", true);
xhr.onload = function()
{
var xmlString = this.responseText
//---DOMParser---
var parser = new DOMParser();
MapDoc = parser.parseFromString(xmlString, "text/xml").documentElement;
var gs=MapDoc.childNodes
for(var k=0;k<gs.length;k++)
{
var elemG=gs.item(k)
if(elemG.id==mapId)
{
var ulLat=+elemG.getAttribute("MyMapLatUL")
var ulLng=+elemG.getAttribute("MyMapLngUL")
var lrLat=+elemG.getAttribute("MyMapLatLR")
var lrLng=+elemG.getAttribute("MyMapLngLR")
MyMap.fitBounds([[ulLat, ulLng],[lrLat, lrLng]]);
BoundsRect.attr("InitZoom",elemG.getAttribute("boundsRect-InitZoom"))
BoundsRect.attr("rectX",elemG.getAttribute("boundsRect-rectX"))
BoundsRect.attr("rectY",elemG.getAttribute("boundsRect-rectY"))
BoundsRect.attr("lat",elemG.getAttribute("boundsRect-lat"))
BoundsRect.attr("lng",elemG.getAttribute("boundsRect-lng"))
BoundsRect.attr("width",elemG.getAttribute("boundsRect-width") )
BoundsRect.attr("height",elemG.getAttribute("boundsRect-height"))
BoundsRect.style("visibility","visible")
break
}
}
var caveId="cavePublish"+mapId.split("map")[1]
var cavePublishG=document.createElementNS(NS,"g")
cavePublishG.id=caveId
var bb=domWrapper.appendChild(boundsRect).getBBox()
mySVG.appendChild(boundsRect)
var r = mySVG.createSVGRect();
r.x = bb.x;
r.y = bb.y;
r.width = bb.width;
r.height = bb.height;
var nodeList = mySVG.getIntersectionList(r, null);
var arr = Array.from(nodeList);
for(var k=0;k<arr.length;k++)
{
var elem=arr[k].parentNode
var myClass=elem.getAttribute("class")
if(myClass=="caveElem")
{
elem.removeAttribute("onmousedown")
cavePublishG.appendChild(elem.cloneNode(true))
}
else if(myClass=="cavePublicElem")
{
elem.removeAttribute("onmousedown")
cavePublishG.appendChild(elem.cloneNode(true))
k++
}
}
var svgString= new XMLSerializer().serializeToString(cavePublishG)
var xhr = new XMLHttpRequest();
xhr.open("POST", "_ASP/publishCave.asp", true);
xhr.onload = function()
{
if (this.status == 500)
{
console.log(this.responseText)
}
};
xhr.send(svgString);
}
xhr.send();
}