-
Notifications
You must be signed in to change notification settings - Fork 1
/
notes.html
189 lines (126 loc) · 6.94 KB
/
notes.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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../color_styles.css" />
<link rel="stylesheet" type="text/css" href="node_modules/@toast-ui/editor/dist/toastui-editor.css" />
<style>
iframe {
width: var(--vw);
height: var(--vh);
border : 0px;
transform: scale( var(--windowScaling) );
transform-origin: top left;
position: absolute;
}
.myButton {
margin: 10px;
font-size: 13px;
border: 1px solid #dadde6;
border-radius: 3px;
padding: 5px;
}
.notes-popup-text {
color: var(--notes-popup-text);
font-weight: 600;
}
</style>
<script>
let root = document.documentElement;
root.style.setProperty('--windowScaling', global.state.zoom);
root.style.setProperty('--vw', Math.round( 100 * (1 / global.state.zoom ) ) + 'vw') ;
root.style.setProperty('--vh', Math.round( 100 * (1 / global.state.zoom ) ) + 'vh') ;
</script>
</head>
<body class="light" style = "margin: 0px; overflow:hidden">
<script>
if (global.localState.dark){
document.body.classList.remove('light');
document.body.classList.add('dark');
}
</script>
<iframe id="iframe" src="notes_iframe.html"></iframe>
<script>
window.addEventListener('DOMContentLoaded', (event) => {
let root = document.documentElement;
root.style.setProperty('--windowScaling', global.state.zoom);
root.style.setProperty('--vw', Math.round( 100 * (1 / global.state.zoom ) ) + 'vw') ;
root.style.setProperty('--vh', Math.round( 100 * (1 / global.state.zoom ) ) + 'vh') ;
}
);
// Close
window.addEventListener('unload', (event) => {
console.log('notes.html :DOM fully unloaded -- maybe window closed ');
//closeWindow(window);
document.getElementById('iframe').contentWindow.closeWindow(window)
}
);
</script>
<div id="historyMenu" class="toastui-editor-popup" aria-role="dialog" style="display: none; width: fit-content; right: 100px; top: 39px;">
<div class="toastui-editor-popup-body">
<div aria-label="Previous versions of this file">
<div class="toastui-editor-button-container" style="text-align: center; margin: 0px">
<span class="notes-popup-text">Version: </span><br>
<button id="forward" class="myButton" onClick="newerVersion();">Newer</button><br>
<button id="back" class="myButton" onClick="olderVersion();">Older</button><br>
<div id="info" class="notes-popup-text" style="text-align: center;" > newest <br> </div><br>
<button id="original" class="myButton" onClick="resetHistory();">Original</button>
</div>
</div>
</div>
</div>
<script>
function olderVersion(){
document.getElementById("iframe").contentWindow.historyNumber = document.getElementById("iframe").contentWindow.historyNumber + 1;
document.getElementById("iframe").contentWindow.getHistoricalNote();
// Set button visibility
historyButtonVisibility();
}
function newerVersion(){
document.getElementById("iframe").contentWindow.historyNumber = document.getElementById("iframe").contentWindow.historyNumber - 1;
document.getElementById("iframe").contentWindow.getHistoricalNote();
// Get latest or
if (document.getElementById("iframe").contentWindow.historyNumber < 0){
resetHistory();
}else{
// Set button visibility
historyButtonVisibility();
}
}
function resetHistory(){
// Read saved file
try{
let text = require('fs').readFileSync( document.getElementById("iframe").contentWindow.filePath, 'utf8' );
document.getElementById("iframe").contentWindow.historyNumber = - 1;
// Set editor text
document.getElementById("iframe").contentWindow.editor.setMarkdown(text);
document.getElementById("iframe").contentWindow.editor.moveCursorToStart();
// Set menu text
document.getElementById('info').innerHTML = 'newest' + '<br>';
// Set button visibility
historyButtonVisibility();
}catch(err){
}
}
function historyButtonVisibility(){
let historyNumber = document.getElementById("iframe").contentWindow.historyNumber;
let cachedHistory = document.getElementById("iframe").contentWindow.cachedHistory;
// Guess both back and forward
document.getElementById("back").disabled = false;
document.getElementById("forward").disabled = false;
document.getElementById("original").disabled = false;
// Only back
if (historyNumber < 0){
document.getElementById("back").disabled = false;
document.getElementById("forward").disabled = true;
document.getElementById("original").disabled = false;
}
// Only forward
if (historyNumber >= ( cachedHistory.length - 1 ) ){
document.getElementById("back").disabled = true;
document.getElementById("forward").disabled = false;
document.getElementById("original").disabled = false;
}
}
</script>
</body>
</html>