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