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