-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.html
139 lines (121 loc) · 5.9 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>XMind Embed Viewer (Development)</title>
</head>
<body>
<div style="max-width: 1280px">
<p>The earliest known appearance of the phrase is from <i><a href="/wiki/The_Boston_Journal" title="The Boston Journal">The
Boston Journal</a></i>. In an article titled "Current Notes" in the February 9, 1885, edition, the phrase is mentioned
as a good practice <a href="/wiki/Sentence_(linguistics)" title="Sentence (linguistics)">sentence</a> for writing
students: "A favorite copy set by writing teachers for their pupils is the following, because it contains every letter
of the alphabet: 'A quick brown fox jumps over the lazy dog.'"<sup id="cite_ref-2" class="reference"><a
href="#cite_note-2">[2]</a></sup> Dozens of other newspapers published the phrase over the next few months, all
using the version of the sentence starting with "A" rather than "The".<sup id="cite_ref-:0_3-0" class="reference"><a
href="#cite_note-:0-3">[3]</a></sup> The earliest known use of the phrase starting with "The" is from the 1888 book
<i>Illustrative Shorthand</i> by Linda Bronson.<sup id="cite_ref-4" class="reference"><a
href="#cite_note-4">[4]</a></sup> The modern form (starting with "The") became more common despite the fact that it
is slightly longer than the original (starting with "A").
</p>
<div id="mount">
</div>
</div>
</body>
<script src="xmind-embed-viewer.js"></script>
<script>
const selectFileFromLocal = async (ext) => {
const fileSelector = document.createElement('input')
fileSelector.style.display = 'none'
document.body.appendChild(fileSelector)
await new Promise(resolve => {
fileSelector.setAttribute('type', 'file')
fileSelector.setAttribute('accept', ext)
fileSelector.addEventListener('change', () => {
resolve()
})
fileSelector.click()
}).finally(() => {
document.body.removeChild(fileSelector)
})
if (!fileSelector.files || !fileSelector.files.length) {
return
}
return fileSelector.files[0]
}
const init = async () => {
const region = new URL(window.location.href).searchParams.get('region')
const res = await fetch('test-1.xmind')
const viewer = new XMindEmbedViewer({
el: '#mount',
file: await res.arrayBuffer(),
region: region === 'cn' ? 'cn' : 'global',
styles: {
'height': '500px',
'width': '100%'
}
})
const eventLogsElement = document.createElement('div')
eventLogsElement.style.height = '500px'
eventLogsElement.style.overflow = 'scroll'
const log = (type, message) => eventLogsElement.innerHTML += `<div style="margin-top: 8px">[${type}] ${typeof message === 'object' && message ? JSON.stringify(message, null, 2) : message}</div>`
viewer.addEventListener('sheet-switch', payload => log('event: sheet-switch', payload))
viewer.addEventListener('zoom-scale-change', payload => log('event: zoom-scale-change', payload))
viewer.addEventListener('sheets-change', payload => log('event: sheets-change', payload))
viewer.addEventListener('map-ready', payload => log('event: map-ready', payload))
const loadFile1Button = document.createElement('button')
loadFile1Button.textContent = 'Load File 1'
loadFile1Button.addEventListener('click', async () => {
const res = await fetch('test-1.xmind')
viewer.load(await res.arrayBuffer())
})
const loadFile2Button = document.createElement('button')
loadFile2Button.textContent = 'Load File 2'
loadFile2Button.addEventListener('click', async () => {
const res = await fetch('test-2.xmind')
viewer.load(await res.arrayBuffer())
})
const loadFileFromComputerButton = document.createElement('button')
loadFileFromComputerButton.textContent = 'Open Local File'
loadFileFromComputerButton.addEventListener('click', async () => {
const file = await selectFileFromLocal('.xmind')
if (!file) return
viewer.load(await file.arrayBuffer())
})
document.body.appendChild(loadFile1Button)
document.body.appendChild(loadFile2Button)
document.body.appendChild(loadFileFromComputerButton)
const zoomScaleInput = document.createElement('input')
zoomScaleInput.setAttribute('type', 'number')
zoomScaleInput.placeholder = 'Zoom Scale'
const zoomScaleConfirm = document.createElement('button')
zoomScaleConfirm.textContent = 'Update Zoom Scale'
zoomScaleConfirm.addEventListener('click', () => viewer.setZoomScale(parseInt(zoomScaleInput.value)))
const fitMapButton = document.createElement('button')
fitMapButton.textContent = 'Zoom Scale Fit Map'
fitMapButton.addEventListener('click', () => viewer.setFitMap())
document.body.appendChild(zoomScaleInput)
document.body.appendChild(zoomScaleConfirm)
document.body.appendChild(fitMapButton)
const sheetIdInput = document.createElement('input')
sheetIdInput.placeholder = 'Target Sheet Id'
const sheetIdConfirm = document.createElement('button')
sheetIdConfirm.textContent = 'Switch to Sheet Id'
sheetIdConfirm.addEventListener('click', () => viewer.switchSheet(sheetIdInput.value))
document.body.appendChild(sheetIdInput)
document.body.appendChild(sheetIdConfirm)
const switchRegionButton = document.createElement('button')
switchRegionButton.textContent = region === 'cn' ? 'Switch to global' : '页面速度慢?切到国内源'
switchRegionButton.title = region === 'cn' ? '' : '具体如何初始化切换请查看 readme.md 或者 html 代码。'
switchRegionButton.addEventListener('click', () => {
const url = new URL(window.location.href)
url.searchParams.set('region', region === 'cn' ? 'global' : 'cn')
window.location.href = url.toString()
})
document.body.appendChild(switchRegionButton)
document.body.appendChild(eventLogsElement)
window.viewer = viewer
}
init()
</script>
</html>