scratch – Diff between revs 63 and 64
?pathlinks?
Rev 63 | Rev 64 | |||
---|---|---|---|---|
1 | <!DOCTYPE html> |
1 | <!DOCTYPE html> |
|
2 | <html lang="en"> |
2 | <html lang="en"> |
|
3 | <head> |
3 | <head> |
|
4 | <meta charset="utf-8"> |
4 | <meta charset="utf-8"> |
|
5 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
5 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|
6 | <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> |
6 | <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> |
|
7 | <meta http-equiv="Pragma" content="no-cache" /> |
7 | <meta http-equiv="Pragma" content="no-cache" /> |
|
8 | <meta http-equiv="Expires" content="0" /> |
8 | <meta http-equiv="Expires" content="0" /> |
|
9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
|
10 | <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> |
10 | <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> |
|
11 | <meta name="description" content="quick asset upload"> |
11 | <meta name="description" content="quick asset upload"> |
|
12 | <meta name="author" content="Wizardry and Steamworks"> |
12 | <meta name="author" content="Wizardry and Steamworks"> |
|
13 | <link rel="icon" href="favicon.ico"> |
13 | <link rel="icon" href="favicon.ico"> |
|
14 | |
14 | |
|
15 | <title>Scratch</title> |
15 | <title>scratch</title> |
|
16 | |
16 | |
|
17 | <!-- Bootstrap core CSS --> |
17 | <!-- Bootstrap core CSS --> |
|
18 | <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> |
18 | <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> |
|
19 | <!-- Trumbowyg --> |
19 | <!-- Trumbowyg --> |
|
20 | <link href="bower_components/trumbowyg/dist/ui/trumbowyg.min.css" rel="stylesheet"> |
20 | <link href="bower_components/trumbowyg/dist/ui/trumbowyg.min.css" rel="stylesheet"> |
|
21 | <!-- Local style --> |
21 | <!-- Local style --> |
|
22 | <link href="css/text/style.css" rel="stylesheet"> |
22 | <link href="css/text/style.css" rel="stylesheet"> |
|
23 | </head> |
23 | </head> |
|
24 | |
24 | |
|
25 | <body> |
25 | <body> |
|
26 | |
26 | |
|
27 | <div class="container"> |
27 | <div class="container"> |
|
28 | |
28 | |
|
29 | <!-- Main component for a primary marketing message or call to action --> |
29 | <!-- Main component for a primary marketing message or call to action --> |
|
30 | <div class="jumbotron"> |
30 | <div class="jumbotron"> |
|
31 | <h1>Scratch</h1> |
31 | <h1>Scratch</h1> |
|
32 | <p>Asset sharing platform.</p> |
32 | <p>Asset sharing platform.</p> |
|
33 | </div> |
33 | </div> |
|
34 | |
34 | |
|
35 | <ul class="nav nav-tabs"> |
35 | <ul class="nav nav-tabs"> |
|
36 | <li><a href="index.html">Home</a></li> |
36 | <li><a href="index.html">Home</a></li> |
|
37 | <li><a href="file.html">File</a></li> |
37 | <li><a href="file.html">File</a></li> |
|
38 | <li class="active"><a href="#">Text</a></li> |
38 | <li class="active"><a href="#">Text</a></li> |
|
39 | </ul> |
39 | </ul> |
|
40 | |
40 | |
|
41 | <div class="panel panel-default"> |
41 | <div class="panel panel-default"> |
|
42 | <div class="panel-heading"> |
42 | <div class="panel-heading"> |
|
43 | <div class="form-group"> |
43 | <div class="form-group"> |
|
44 | <div class="input-group"> |
44 | <div class="input-group"> |
|
45 | <span class="input-group-btn"> |
45 | <span class="input-group-btn"> |
|
46 | <button id="save" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Generate link."> |
46 | <button id="save" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Generate link."> |
|
47 | <i class="glyphicon glyphicon-share"></i> |
47 | <i class="glyphicon glyphicon-share"></i> |
|
48 | </button> |
48 | </button> |
|
49 | </span> |
49 | </span> |
|
50 | <input id="URL" type="text" class="form-control" readonly> |
50 | <input id="URL" type="text" class="form-control" readonly> |
|
51 | <span class="input-group-btn"> |
51 | <span class="input-group-btn"> |
|
52 | <button id="copy-url" class="btn btn-default" type="button" data-clipboard-target="#URL" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> |
52 | <button id="copy-url" class="btn btn-default" type="button" data-clipboard-target="#URL" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> |
|
53 | </span> |
53 | </span> |
|
54 | </div> |
54 | </div> |
|
55 | </div> |
55 | </div> |
|
56 | <form id="nick-form" role="form"> |
56 | <form id="nick-form" role="form"> |
|
57 | <div class="form-group has-feedback"> |
57 | <div class="form-group has-feedback"> |
|
58 | <div class="input-group"> |
58 | <div class="input-group"> |
|
59 | <span class="input-group-btn"> |
59 | <span class="input-group-btn"> |
|
60 | <button id="go" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Load document."> |
60 | <button id="go" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Load document."> |
|
61 | <i class="glyphicon glyphicon-play"></i> |
61 | <i class="glyphicon glyphicon-play"></i> |
|
62 | </button> |
62 | </button> |
|
63 | </span> |
63 | </span> |
|
64 | <span class="input-group-btn"> |
64 | <span class="input-group-btn"> |
|
65 | <button id="reset" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Reset document."> |
65 | <button id="reset" class="btn btn-default" type="button" data-toggle="tooltip" data-placement="auto" title="Reset document."> |
|
66 | <i id="home-icon" class="glyphicon glyphicon-home"></i> |
66 | <i id="home-icon" class="glyphicon glyphicon-home"></i> |
|
67 | </button> |
67 | </button> |
|
68 | </span> |
68 | </span> |
|
69 | <input id="nick" type="text" class="form-control" pattern="^[A-Za-z0-9]{32}$" maxlength="32"> |
69 | <input id="nick" type="text" class="form-control" pattern="^[A-Za-z0-9]{32}$" maxlength="32"> |
|
70 | <span class="input-group-btn"> |
70 | <span class="input-group-btn"> |
|
71 | <button id="copy-nick" class="btn btn-default" type="button" data-clipboard-target="#nick" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> |
71 | <button id="copy-nick" class="btn btn-default" type="button" data-clipboard-target="#nick" data-toggle="tooltip" data-placement="auto" title="Copy to clipboard."><i class="glyphicon glyphicon-paperclip"></i></button> |
|
72 | </span> |
72 | </span> |
|
73 | </div> |
73 | </div> |
|
74 | </div> |
74 | </div> |
|
75 | </form> |
75 | </form> |
|
76 | </div> |
76 | </div> |
|
77 | <div class="panel-body" id="editorpanel"> |
77 | <div class="panel-body" id="editorpanel"> |
|
78 | <div id="trumbowyg" style="display: none; font-family: monospace;"> |
78 | <div id="trumbowyg" style="display: none; font-family: monospace;"> |
|
79 | </div> |
79 | </div> |
|
80 | </div> |
80 | </div> |
|
81 | </div> |
81 | </div> |
|
82 | |
82 | |
|
83 | </div> <!-- /container --> |
83 | </div> <!-- /container --> |
|
84 | |
84 | |
|
85 | <div id="footer"> |
85 | <div id="footer"> |
|
86 | <div class="container"> |
86 | <div class="container"> |
|
87 | <p class="text-muted credit">Copyright <i class="glyphicon glyphicon-copyright-mark"></i> 2017 <a href="http://grimore.org">Wizardry and Steamworks</a>.</p> |
87 | <p class="text-muted credit">Copyright <i class="glyphicon glyphicon-copyright-mark"></i> 2017 <a href="http://grimore.org">Wizardry and Steamworks</a>.</p> |
|
88 | </div> |
88 | </div> |
|
89 | </div> |
89 | </div> |
|
90 | |
90 | |
|
91 | <!-- jQuery --> |
91 | <!-- jQuery --> |
|
92 | <script src="bower_components/jquery/dist/jquery.min.js"></script> |
92 | <script src="bower_components/jquery/dist/jquery.min.js"></script> |
|
93 | <!-- BootStrap --> |
93 | <!-- BootStrap --> |
|
94 | <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> |
94 | <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> |
|
95 | |
95 | |
|
96 | <!-- Trumbowyg --> |
96 | <!-- Trumbowyg --> |
|
97 | <script src="bower_components/trumbowyg/dist/trumbowyg.min.js"></script> |
97 | <script src="bower_components/trumbowyg/dist/trumbowyg.min.js"></script> |
|
98 | <!-- Clipboard --> |
98 | <!-- Clipboard --> |
|
99 | <script src="bower_components/clipboard/dist/clipboard.min.js"></script> |
99 | <script src="bower_components/clipboard/dist/clipboard.min.js"></script> |
|
100 | <!-- Fingerprint 2 --> |
100 | <!-- Fingerprint 2 --> |
|
101 | <script src="bower_components/fingerprintjs2/dist/fingerprint2.min.js"></script> |
101 | <script src="bower_components/fingerprintjs2/dist/fingerprint2.min.js"></script> |
|
102 | <!-- js-cookie --> |
102 | <!-- js-cookie --> |
|
103 | <script src="bower_components/js-cookie/src/js.cookie.js"></script> |
103 | <script src="bower_components/js-cookie/src/js.cookie.js"></script> |
|
104 | <!-- Bootstrap Validator --> |
104 | <!-- Bootstrap Validator --> |
|
105 | <script src="bower_components/bootstrap-validator/dist/validator.min.js"></script> |
105 | <script src="bower_components/bootstrap-validator/dist/validator.min.js"></script> |
|
106 | <script> |
106 | <script> |
|
107 | $(document).ready(() => { |
107 | $(document).ready(() => { |
|
108 | // Attach the form validator. |
108 | // Attach the form validator. |
|
109 | $('#nick-form').validator({ |
109 | $('#nick-form').validator({ |
|
110 | focus: false |
110 | focus: false |
|
111 | }); |
111 | }); |
|
112 | |
112 | |
|
113 | // Enable the Clipboard button. |
113 | // Enable the Clipboard button. |
|
114 | new Clipboard('#copy-url'); |
114 | new Clipboard('#copy-url'); |
|
115 | |
115 | |
|
116 | // Get the fingerprint. |
116 | // Get the fingerprint. |
|
117 | new Fingerprint2({ |
117 | new Fingerprint2({ |
|
118 | //excludeUserAgent: true, |
118 | //excludeUserAgent: true, |
|
119 | //excludeLanguage: true, |
119 | //excludeLanguage: true, |
|
120 | excludeColorDepth: true, |
120 | excludeColorDepth: true, |
|
121 | excludeScreenResolution: true, |
121 | excludeScreenResolution: true, |
|
122 | excludeAvailableScreenResolution: true, |
122 | excludeAvailableScreenResolution: true, |
|
123 | //excludeTimezoneOffset: true, |
123 | //excludeTimezoneOffset: true, |
|
124 | excludeSessionStorage: true, |
124 | excludeSessionStorage: true, |
|
125 | excludeIndexedDB: true, |
125 | excludeIndexedDB: true, |
|
126 | excludeAddBehavior: true, |
126 | excludeAddBehavior: true, |
|
127 | excludeOpenDatabase: true, |
127 | excludeOpenDatabase: true, |
|
128 | //excludeCpuClass: true, |
128 | //excludeCpuClass: true, |
|
129 | //excludePlatform: true, |
129 | //excludePlatform: true, |
|
130 | excludeDoNotTrack: true, |
130 | excludeDoNotTrack: true, |
|
131 | excludeCanvas: true, |
131 | excludeCanvas: true, |
|
132 | excludeWebGL: true, |
132 | excludeWebGL: true, |
|
133 | excludeAdBlock: true, |
133 | excludeAdBlock: true, |
|
134 | //excludeHasLiedLanguages: true, |
134 | //excludeHasLiedLanguages: true, |
|
135 | //excludeHasLiedResolution: true, |
135 | //excludeHasLiedResolution: true, |
|
136 | //excludeHasLiedOs: true, |
136 | //excludeHasLiedOs: true, |
|
137 | //excludeHasLiedBrowser: true, |
137 | //excludeHasLiedBrowser: true, |
|
138 | excludeJsFonts: true, |
138 | excludeJsFonts: true, |
|
139 | excludeFlashFonts: true, |
139 | excludeFlashFonts: true, |
|
140 | excludePlugins: true, |
140 | excludePlugins: true, |
|
141 | excludeIEPlugins: true, |
141 | excludeIEPlugins: true, |
|
142 | //excludeTouchSupport: true, |
142 | //excludeTouchSupport: true, |
|
143 | excludePixelRatio: true |
143 | excludePixelRatio: true |
|
144 | }).get((result, components) => { |
144 | }).get((result, components) => { |
|
145 | // Set the nick as a cookie. |
145 | // Set the nick as a cookie. |
|
146 | const fingerprint = result; |
146 | const fingerprint = result; |
|
147 | var nick = Cookies.get('nick'); |
147 | var nick = Cookies.get('nick'); |
|
148 | if(!nick || nick.length !== 32) { |
148 | if(!nick || nick.length !== 32) { |
|
149 | Cookies.set('nick', result, { path: '' }); |
149 | Cookies.set('nick', result, { path: '' }); |
|
150 | nick = result; |
150 | nick = result; |
|
151 | } |
151 | } |
|
152 | else |
152 | else |
|
153 | result = nick; |
153 | result = nick; |
|
154 | |
154 | |
|
155 | // Set the nick. |
155 | // Set the nick. |
|
156 | $('#nick').val(result); |
156 | $('#nick').val(result); |
|
157 | new Clipboard('#copy-nick'); |
157 | new Clipboard('#copy-nick'); |
|
158 | |
158 | |
|
159 | if(fingerprint == nick) |
159 | if(fingerprint == nick) |
|
160 | $('#home-icon').addClass("text-success"); |
160 | $('#home-icon').addClass("text-success"); |
|
161 | else |
161 | else |
|
162 | $('#home-icon').addClass("text-danger"); |
162 | $('#home-icon').addClass("text-danger"); |
|
163 | |
163 | |
|
164 | function saveTextFile() { |
164 | function saveTextFile() { |
|
165 | $.post('text.php', { |
165 | $.post('text.php', { |
|
166 | data: $('#trumbowyg').trumbowyg('html'), |
166 | data: $('#trumbowyg').trumbowyg('html'), |
|
167 | fingerprint: result, |
167 | fingerprint: result, |
|
168 | action: 'SAVE', |
168 | action: 'SAVE', |
|
169 | timeout: 0 |
169 | timeout: 0 |
|
170 | }); |
170 | }); |
|
171 | } |
171 | } |
|
172 | var autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
172 | var autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
|
173 | |
173 | |
|
174 | // Load the editor. |
174 | // Load the editor. |
|
175 | $('#trumbowyg').trumbowyg({ |
175 | $('#trumbowyg').trumbowyg({ |
|
176 | autogrow: true, |
176 | autogrow: true, |
|
177 | disabled: true |
177 | disabled: true |
|
178 | }).on('tbwchange', () => { |
178 | }).on('tbwchange', () => { |
|
179 | // Clear the value of the URL box because the URL will have changed. |
179 | // Clear the value of the URL box because the URL will have changed. |
|
180 | $('#URL').val(''); |
180 | $('#URL').val(''); |
|
181 | // Reschedule saving of the file. |
181 | // Reschedule saving of the file. |
|
182 | window.clearTimeout(autoSaveTimeoutID); |
182 | window.clearTimeout(autoSaveTimeoutID); |
|
183 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
183 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
|
184 | }); |
184 | }); |
|
185 | |
185 | |
|
186 | // Retrieve the contents of the shared file. |
186 | // Retrieve the contents of the shared file. |
|
187 | $('#trumbowyg').trumbowyg('disable'); |
187 | $('#trumbowyg').trumbowyg('disable'); |
|
188 | $.post('text.php', |
188 | $.post('text.php', |
|
189 | { |
189 | { |
|
190 | timestamp: window.performance.now(), |
190 | timestamp: window.performance.now(), |
|
191 | fingerprint: result, |
191 | fingerprint: result, |
|
192 | action: 'LOAD' |
192 | action: 'LOAD' |
|
193 | }).done((data) => {; |
193 | }).done((data) => {; |
|
194 | $('#trumbowyg') |
194 | $('#trumbowyg') |
|
195 | .trumbowyg('html', data); |
195 | .trumbowyg('html', data); |
|
196 | $('#trumbowyg').trumbowyg('enable'); |
196 | $('#trumbowyg').trumbowyg('enable'); |
|
197 | $('#trumbowyg').show(); |
197 | $('#trumbowyg').show(); |
|
198 | }).fail(() => { |
198 | }).fail(() => { |
|
199 | $('#trumbowyg').trumbowyg('enable'); |
199 | $('#trumbowyg').trumbowyg('enable'); |
|
200 | $('#trumbowyg').show(); |
200 | $('#trumbowyg').show(); |
|
201 | }); |
201 | }); |
|
202 | |
202 | |
|
203 | $('#save').click(() => { |
203 | $('#save').click(() => { |
|
204 | $('#editor').trumbowyg('disable'); |
204 | $('#editor').trumbowyg('disable'); |
|
205 | var formData = new FormData(); |
205 | var formData = new FormData(); |
|
206 | formData.append('file', new Blob( |
206 | formData.append('file', new Blob( |
|
207 | [ |
207 | [ |
|
208 | $('#trumbowyg').trumbowyg('html') |
208 | $('#trumbowyg').trumbowyg('html') |
|
209 | ] |
209 | ] |
|
210 | ), |
210 | ), |
|
211 | '.html' |
211 | '.html' |
|
212 | ); |
212 | ); |
|
213 | |
213 | |
|
214 | $.ajax({ |
214 | $.ajax({ |
|
215 | url: 'file.php', |
215 | url: 'file.php', |
|
216 | type: 'POST', |
216 | type: 'POST', |
|
217 | data: formData, |
217 | data: formData, |
|
218 | // cache: false // FF |
218 | // cache: false // FF |
|
219 | processData: false, |
219 | processData: false, |
|
220 | contentType: false |
220 | contentType: false |
|
221 | }).done((data) => { |
221 | }).done((data) => { |
|
222 | $('#URL').val(data); |
222 | $('#URL').val(data); |
|
223 | $('#trumbowyg').trumbowyg('enable'); |
223 | $('#trumbowyg').trumbowyg('enable'); |
|
224 | }).fail(() => { |
224 | }).fail(() => { |
|
225 | $('#trumbowyg').trumbowyg('enable'); |
225 | $('#trumbowyg').trumbowyg('enable'); |
|
226 | }); |
226 | }); |
|
227 | }); |
227 | }); |
|
228 | |
228 | |
|
229 | // When the button is clicked, navigate to the fingerprint. |
229 | // When the button is clicked, navigate to the fingerprint. |
|
230 | $('#go').click(() => { |
230 | $('#go').click(() => { |
|
231 | nick = $('#nick').val(); |
231 | nick = $('#nick').val(); |
|
232 | if(!nick || nick.length != 32) |
232 | if(!nick || nick.length != 32) |
|
233 | return; |
233 | return; |
|
234 | Cookies.set('nick', nick, { path: '' }); |
234 | Cookies.set('nick', nick, { path: '' }); |
|
235 | result = nick; |
235 | result = nick; |
|
236 | |
236 | |
|
237 | // Retrieve the contents of the shared file. |
237 | // Retrieve the contents of the shared file. |
|
238 | $('#editor').trumbowyg('disable'); |
238 | $('#editor').trumbowyg('disable'); |
|
239 | $.post('text.php', |
239 | $.post('text.php', |
|
240 | { |
240 | { |
|
241 | timestamp: window.performance.now(), |
241 | timestamp: window.performance.now(), |
|
242 | fingerprint: nick, |
242 | fingerprint: nick, |
|
243 | action: 'LOAD' |
243 | action: 'LOAD' |
|
244 | }).done((data) => {; |
244 | }).done((data) => {; |
|
245 | $('#trumbowyg') |
245 | $('#trumbowyg') |
|
246 | .trumbowyg('html', data); |
246 | .trumbowyg('html', data); |
|
247 | $('#trumbowyg').trumbowyg('enable'); |
247 | $('#trumbowyg').trumbowyg('enable'); |
|
248 | $('#trumbowyg').show(); |
248 | $('#trumbowyg').show(); |
|
249 | |
249 | |
|
250 | if(fingerprint == nick) |
250 | if(fingerprint == nick) |
|
251 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
251 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
|
252 | else |
252 | else |
|
253 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
253 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
254 | |
254 | |
|
255 | }).fail(() => { |
255 | }).fail(() => { |
|
256 | $('#trumbowyg').trumbowyg('enable'); |
256 | $('#trumbowyg').trumbowyg('enable'); |
|
257 | $('#trumbowyg').show(); |
257 | $('#trumbowyg').show(); |
|
258 | }); |
258 | }); |
|
259 | }); |
259 | }); |
|
260 | |
260 | |
|
261 | // When the form is submitted, naigate to the fingerprint. |
261 | // When the form is submitted, naigate to the fingerprint. |
|
262 | $('#nick-form').submit((e) => { |
262 | $('#nick-form').submit((e) => { |
|
263 | e.preventDefault(); |
263 | e.preventDefault(); |
|
264 | |
264 | |
|
265 | nick = $('#nick').val(); |
265 | nick = $('#nick').val(); |
|
266 | if(!nick || nick.length != 32) |
266 | if(!nick || nick.length != 32) |
|
267 | return; |
267 | return; |
|
268 | Cookies.set('nick', nick, { path: '' }); |
268 | Cookies.set('nick', nick, { path: '' }); |
|
269 | result = nick; |
269 | result = nick; |
|
270 | |
270 | |
|
271 | // Retrieve the contents of the shared file. |
271 | // Retrieve the contents of the shared file. |
|
272 | $('#editor').trumbowyg('disable'); |
272 | $('#editor').trumbowyg('disable'); |
|
273 | $.post('text.php', |
273 | $.post('text.php', |
|
274 | { |
274 | { |
|
275 | timestamp: window.performance.now(), |
275 | timestamp: window.performance.now(), |
|
276 | fingerprint: nick, |
276 | fingerprint: nick, |
|
277 | action: 'LOAD' |
277 | action: 'LOAD' |
|
278 | }).done((data) => {; |
278 | }).done((data) => {; |
|
279 | $('#trumbowyg') |
279 | $('#trumbowyg') |
|
280 | .trumbowyg('html', data); |
280 | .trumbowyg('html', data); |
|
281 | $('#trumbowyg').trumbowyg('enable'); |
281 | $('#trumbowyg').trumbowyg('enable'); |
|
282 | $('#trumbowyg').show(); |
282 | $('#trumbowyg').show(); |
|
283 | |
283 | |
|
284 | if(fingerprint == nick) |
284 | if(fingerprint == nick) |
|
285 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
285 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
|
286 | else |
286 | else |
|
287 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
287 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
288 | |
288 | |
|
289 | }).fail(() => { |
289 | }).fail(() => { |
|
290 | $('#trumbowyg').trumbowyg('enable'); |
290 | $('#trumbowyg').trumbowyg('enable'); |
|
291 | $('#trumbowyg').show(); |
291 | $('#trumbowyg').show(); |
|
292 | }); |
292 | }); |
|
293 | }); |
293 | }); |
|
294 | |
294 | |
|
295 | // While the nick is changing, navigate to the changed fingerprint. |
295 | // While the nick is changing, navigate to the changed fingerprint. |
|
296 | $("#nick").on('input', () => { |
296 | $("#nick").on('input', () => { |
|
297 | nick = $('#nick').val(); |
297 | nick = $('#nick').val(); |
|
298 | if(!nick || nick.length != 32) |
298 | if(!nick || nick.length != 32) |
|
299 | return; |
299 | return; |
|
300 | Cookies.set('nick', nick, { path: '' }); |
300 | Cookies.set('nick', nick, { path: '' }); |
|
301 | result = nick; |
301 | result = nick; |
|
302 | |
302 | |
|
303 | // Retrieve the contents of the shared file. |
303 | // Retrieve the contents of the shared file. |
|
304 | $('#editor').trumbowyg('disable'); |
304 | $('#editor').trumbowyg('disable'); |
|
305 | $.post('text.php', |
305 | $.post('text.php', |
|
306 | { |
306 | { |
|
307 | timestamp: window.performance.now(), |
307 | timestamp: window.performance.now(), |
|
308 | fingerprint: nick, |
308 | fingerprint: nick, |
|
309 | action: 'LOAD' |
309 | action: 'LOAD' |
|
310 | }).done((data) => {; |
310 | }).done((data) => {; |
|
311 | $('#trumbowyg') |
311 | $('#trumbowyg') |
|
312 | .trumbowyg('html', data); |
312 | .trumbowyg('html', data); |
|
313 | $('#trumbowyg').trumbowyg('enable'); |
313 | $('#trumbowyg').trumbowyg('enable'); |
|
314 | $('#trumbowyg').show(); |
314 | $('#trumbowyg').show(); |
|
315 | |
315 | |
|
316 | if(fingerprint == nick) |
316 | if(fingerprint == nick) |
|
317 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
317 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
|
318 | else |
318 | else |
|
319 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
319 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
320 | }).fail(() => { |
320 | }).fail(() => { |
|
321 | $('#trumbowyg').trumbowyg('enable'); |
321 | $('#trumbowyg').trumbowyg('enable'); |
|
322 | $('#trumbowyg').show(); |
322 | $('#trumbowyg').show(); |
|
323 | }); |
323 | }); |
|
324 | }); |
324 | }); |
|
325 | |
325 | |
|
326 | // When the reset button is pressed, navigate to the fingerprint. |
326 | // When the reset button is pressed, navigate to the fingerprint. |
|
327 | $('#reset').click(() => { |
327 | $('#reset').click(() => { |
|
328 | Cookies.set('nick', fingerprint, { path: '' }); |
328 | Cookies.set('nick', fingerprint, { path: '' }); |
|
329 | $('#nick').val(fingerprint); |
329 | $('#nick').val(fingerprint); |
|
330 | result = fingerprint; |
330 | result = fingerprint; |
|
331 | nick = fingerprint; |
331 | nick = fingerprint; |
|
332 | |
332 | |
|
333 | // Retrieve the contents of the shared file. |
333 | // Retrieve the contents of the shared file. |
|
334 | $('#editor').trumbowyg('disable'); |
334 | $('#editor').trumbowyg('disable'); |
|
335 | $.post('text.php', |
335 | $.post('text.php', |
|
336 | { |
336 | { |
|
337 | timestamp: window.performance.now(), |
337 | timestamp: window.performance.now(), |
|
338 | fingerprint: fingerprint, |
338 | fingerprint: fingerprint, |
|
339 | action: 'LOAD' |
339 | action: 'LOAD' |
|
340 | }).done((data) => {; |
340 | }).done((data) => {; |
|
341 | $('#trumbowyg') |
341 | $('#trumbowyg') |
|
342 | .trumbowyg('html', data); |
342 | .trumbowyg('html', data); |
|
343 | $('#trumbowyg').trumbowyg('enable'); |
343 | $('#trumbowyg').trumbowyg('enable'); |
|
344 | $('#trumbowyg').show(); |
344 | $('#trumbowyg').show(); |
|
345 | if(fingerprint == nick) |
345 | if(fingerprint == nick) |
|
346 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
346 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
|
347 | else |
347 | else |
|
348 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
348 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
|
349 | }).fail(() => { |
349 | }).fail(() => { |
|
350 | $('#trumbowyg').trumbowyg('enable'); |
350 | $('#trumbowyg').trumbowyg('enable'); |
|
351 | $('#trumbowyg').show(); |
351 | $('#trumbowyg').show(); |
|
352 | }); |
352 | }); |
|
353 | }); |
353 | }); |
|
354 | }); |
354 | }); |
|
355 | }); |
355 | }); |
|
356 | </script> |
356 | </script> |
|
357 | </body> |
357 | </body> |
|
358 | </html> |
358 | </html> |
|
359 | |
359 | |