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