@mapgis/webclient-mapboxgl-plugin 17.0.0 → 17.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,3 +9,101 @@ function toggleLinkDetail(id) {
9
9
  _arrow.style.transform = _dom.style.display === 'block' ? 'rotate(360deg)' : 'rotate(180deg)'
10
10
  _dom.style.display = _dom.style.display === 'block' ? 'none' : 'block'
11
11
  }
12
+
13
+ function getTypeHTML(e) {
14
+ var link = e.target.getAttribute('link')
15
+ var goto = e.target.getAttribute('goto')
16
+ const _baseUrl = getBaseUrl(window.location.href)
17
+ fetch(_baseUrl + '/' + link, {
18
+ method: 'GET',
19
+ })
20
+ .then(response => response.text())
21
+ .then(data => {
22
+ const _contentDom = document.getElementById('main-content')
23
+ if (_contentDom) {
24
+ _contentDom.innerHTML = data
25
+ gotoTop(goto)
26
+ }
27
+ })
28
+ .catch(error => console.error('Error:', error))
29
+ }
30
+
31
+ function gotoTop(id) {
32
+ id = id || 'main-content'
33
+ const _aDom = document.createElement('a');
34
+ _aDom.href = '#' + id
35
+ _aDom.click()
36
+ }
37
+
38
+ function getBaseUrl(url) {
39
+ const regex1 = /^(http:|https:)\/\/[0-9a-zA-Z.]+:[0-9]+/
40
+ const regex2 = /^(http:|https:)\/\/[0-9a-zA-Z.]+/
41
+ let match = url.match(regex1)
42
+ if (match && match[0]) {
43
+ return match[0]
44
+ } else {
45
+ match = url.match(regex2)
46
+ if (match && match[0]) {
47
+ return match[0]
48
+ }
49
+ }
50
+ return ''
51
+ }
52
+
53
+ (function() {
54
+ const targets = [ ...document.querySelectorAll('#sidebarNav li.mapgis-link a')]
55
+ targets.forEach(function (_target) {
56
+ _target.addEventListener('click', function (e) {
57
+ const _baseUrl = getBaseUrl(window.location.href)
58
+ fetch(_baseUrl + e.target.attributes[1].value, {
59
+ method: 'GET',
60
+ })
61
+ .then(response => response.text())
62
+ .then(data => {
63
+ const _contentDom = document.getElementById('main-content')
64
+ if (_contentDom) {
65
+ _contentDom.innerHTML = data
66
+ gotoTop()
67
+ }
68
+ })
69
+ .catch(error => console.error('Error:', error))
70
+ })
71
+ })
72
+ const targets2 = [ ...document.querySelectorAll('#sidebarNav div div a#api-fold')]
73
+ targets2.forEach(function (_target) {
74
+ _target.addEventListener('click', function (e) {
75
+ const _baseUrl = getBaseUrl(window.location.href)
76
+ fetch(_baseUrl + e.target.attributes[1].value, {
77
+ method: 'GET',
78
+ })
79
+ .then(response => response.text())
80
+ .then(data => {
81
+ const _contentDom = document.getElementById('main-content')
82
+ if (_contentDom) {
83
+ _contentDom.innerHTML = data
84
+ gotoTop()
85
+ }
86
+ })
87
+ .catch(error => console.error('Error:', error))
88
+ })
89
+ })
90
+
91
+ const targets3 = [ ...document.querySelectorAll('#sidebarNav div div ul li a#api-member')]
92
+ targets3.forEach(function (_target) {
93
+ _target.addEventListener('click', function (e) {
94
+ const _baseUrl = getBaseUrl(window.location.href)
95
+ fetch(_baseUrl + e.target.attributes[1].value, {
96
+ method: 'GET',
97
+ })
98
+ .then(response => response.text())
99
+ .then(data => {
100
+ const _contentDom = document.getElementById('main-content')
101
+ if (_contentDom) {
102
+ _contentDom.innerHTML = data
103
+ gotoTop()
104
+ }
105
+ })
106
+ .catch(error => console.error('Error:', error))
107
+ })
108
+ })
109
+ })()