scratch – Diff between revs 51 and 54
?pathlinks?
Rev 51 | Rev 54 | |||
---|---|---|---|---|
Line 149... | Line 149... | |||
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"); |
|
Line 153... | Line -... | |||
153 | |
- | ||
154 | // Load the editor. |
- | ||
155 | $('#trumbowyg').trumbowyg({ |
- | ||
156 | autogrow: true, |
- | ||
157 | disabled: true |
153 | |
|
158 | }).on('tbwchange', () => { |
- | ||
159 | $('#editor').trumbowyg('disable'); |
154 | function saveTextFile() { |
|
160 | $.post('text.php', { |
155 | $.post('text.php', { |
|
161 | data: $('#trumbowyg').trumbowyg('html'), |
156 | data: $('#trumbowyg').trumbowyg('html'), |
|
162 | fingerprint: result, |
157 | fingerprint: result, |
|
163 | action: 'SAVE', |
158 | action: 'SAVE', |
|
164 | timeout: 0 |
- | ||
165 | }).done((data) => { |
- | ||
166 | $('#trumbowyg').trumbowyg('enable'); |
- | ||
167 | }).fail(() => { |
- | ||
168 | $('#trumbowyg').trumbowyg('enable'); |
159 | timeout: 0 |
|
- | 160 | }); |
||
- | 161 | } |
||
- | 162 | var autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
||
- | 163 | |
||
- | 164 | // Load the editor. |
||
- | 165 | $('#trumbowyg').trumbowyg({ |
||
- | 166 | autogrow: true, |
||
- | 167 | disabled: true |
||
- | 168 | }).on('tbwchange', () => { |
||
- | 169 | // Clear the value of the URL box because the URL will have changed. |
||
- | 170 | $('#URL').val(''); |
||
- | 171 | // Reschedule saving of the file. |
||
- | 172 | window.clearTimeout(autoSaveTimeoutID); |
||
169 | }); |
173 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
|
170 | }); |
174 | }); |
|
171 | |
175 | |
|
- | 176 | // Retrieve the contents of the shared file. |
||
172 | // Retrieve the contents of the shared file. |
177 | $('#trumbowyg').trumbowyg('disable'); |
|
173 | $.post('text.php', |
178 | $.post('text.php', |
|
174 | { |
179 | { |
|
175 | timestamp: window.performance.now(), |
180 | timestamp: window.performance.now(), |
|
176 | fingerprint: result, |
181 | fingerprint: result, |
|
Line 185... | Line 190... | |||
185 | $('#trumbowyg').show(); |
190 | $('#trumbowyg').show(); |
|
186 | }); |
191 | }); |
|
Line 187... | Line 192... | |||
187 | |
192 | |
|
188 | $('#save').click(() => { |
193 | $('#save').click(() => { |
|
189 | $('#editor').trumbowyg('disable'); |
- | ||
190 | |
194 | $('#editor').trumbowyg('disable'); |
|
191 | var formData = new FormData(); |
195 | var formData = new FormData(); |
|
192 | formData.append('file', new Blob( |
196 | formData.append('file', new Blob( |
|
193 | [ |
197 | [ |
|
194 | $('#trumbowyg').trumbowyg('html') |
198 | $('#trumbowyg').trumbowyg('html') |
|
Line 219... | Line 223... | |||
219 | return; |
223 | return; |
|
220 | Cookies.set('nick', nick, { path: '' }); |
224 | Cookies.set('nick', nick, { path: '' }); |
|
221 | result = nick; |
225 | result = nick; |
|
Line 222... | Line 226... | |||
222 | |
226 | |
|
- | 227 | // Retrieve the contents of the shared file. |
||
223 | // Retrieve the contents of the shared file. |
228 | $('#editor').trumbowyg('disable'); |
|
224 | $.post('text.php', |
229 | $.post('text.php', |
|
225 | { |
230 | { |
|
226 | timestamp: window.performance.now(), |
231 | timestamp: window.performance.now(), |
|
227 | fingerprint: nick, |
232 | fingerprint: nick, |
|
Line 252... | Line 257... | |||
252 | return; |
257 | return; |
|
253 | Cookies.set('nick', nick, { path: '' }); |
258 | Cookies.set('nick', nick, { path: '' }); |
|
254 | result = nick; |
259 | result = nick; |
|
Line 255... | Line 260... | |||
255 | |
260 | |
|
- | 261 | // Retrieve the contents of the shared file. |
||
256 | // Retrieve the contents of the shared file. |
262 | $('#editor').trumbowyg('disable'); |
|
257 | $.post('text.php', |
263 | $.post('text.php', |
|
258 | { |
264 | { |
|
259 | timestamp: window.performance.now(), |
265 | timestamp: window.performance.now(), |
|
260 | fingerprint: nick, |
266 | fingerprint: nick, |
|
Line 283... | Line 289... | |||
283 | return; |
289 | return; |
|
284 | Cookies.set('nick', nick, { path: '' }); |
290 | Cookies.set('nick', nick, { path: '' }); |
|
285 | result = nick; |
291 | result = nick; |
|
Line 286... | Line 292... | |||
286 | |
292 | |
|
- | 293 | // Retrieve the contents of the shared file. |
||
287 | // Retrieve the contents of the shared file. |
294 | $('#editor').trumbowyg('disable'); |
|
288 | $.post('text.php', |
295 | $.post('text.php', |
|
289 | { |
296 | { |
|
290 | timestamp: window.performance.now(), |
297 | timestamp: window.performance.now(), |
|
291 | fingerprint: nick, |
298 | fingerprint: nick, |
|
Line 312... | Line 319... | |||
312 | $('#nick').val(fingerprint); |
319 | $('#nick').val(fingerprint); |
|
313 | result = fingerprint; |
320 | result = fingerprint; |
|
314 | nick = fingerprint; |
321 | nick = fingerprint; |
|
Line 315... | Line 322... | |||
315 | |
322 | |
|
- | 323 | // Retrieve the contents of the shared file. |
||
316 | // Retrieve the contents of the shared file. |
324 | $('#editor').trumbowyg('disable'); |
|
317 | $.post('text.php', |
325 | $.post('text.php', |
|
318 | { |
326 | { |
|
319 | timestamp: window.performance.now(), |
327 | timestamp: window.performance.now(), |
|
320 | fingerprint: fingerprint, |
328 | fingerprint: fingerprint, |