scratch – Blame information for rev 58
?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 | |||
58 | 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. |
117 | new Fingerprint2().get((result, components) => { |
||
118 | // Set the nick as a cookie. |
||
38 | office | 119 | const fingerprint = result; |
37 | office | 120 | var nick = Cookies.get('nick'); |
43 | office | 121 | if(!nick || nick.length !== 32) { |
37 | office | 122 | Cookies.set('nick', result, { path: '' }); |
43 | office | 123 | nick = result; |
124 | } |
||
37 | office | 125 | else |
126 | result = nick; |
||
127 | |||
128 | // Set the nick. |
||
129 | $('#nick').val(result); |
||
130 | new Clipboard('#copy-nick'); |
||
131 | |||
42 | office | 132 | if(fingerprint == nick) |
133 | $('#home-icon').addClass("text-success"); |
||
134 | else |
||
135 | $('#home-icon').addClass("text-danger"); |
||
136 | |||
54 | office | 137 | function saveTextFile() { |
49 | office | 138 | $.post('text.php', { |
37 | office | 139 | data: $('#trumbowyg').trumbowyg('html'), |
140 | fingerprint: result, |
||
51 | office | 141 | action: 'SAVE', |
142 | timeout: 0 |
||
37 | office | 143 | }); |
54 | office | 144 | } |
145 | var autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
||
146 | |||
147 | // Load the editor. |
||
148 | $('#trumbowyg').trumbowyg({ |
||
149 | autogrow: true, |
||
150 | disabled: true |
||
151 | }).on('tbwchange', () => { |
||
152 | // Clear the value of the URL box because the URL will have changed. |
||
153 | $('#URL').val(''); |
||
154 | // Reschedule saving of the file. |
||
155 | window.clearTimeout(autoSaveTimeoutID); |
||
156 | autoSaveTimeoutID = window.setTimeout(saveTextFile, 250); |
||
37 | office | 157 | }); |
54 | office | 158 | |
37 | office | 159 | // Retrieve the contents of the shared file. |
54 | office | 160 | $('#trumbowyg').trumbowyg('disable'); |
49 | office | 161 | $.post('text.php', |
37 | office | 162 | { |
163 | timestamp: window.performance.now(), |
||
164 | fingerprint: result, |
||
165 | action: 'LOAD' |
||
166 | }).done((data) => {; |
||
167 | $('#trumbowyg') |
||
168 | .trumbowyg('html', data); |
||
29 | office | 169 | $('#trumbowyg').trumbowyg('enable'); |
37 | office | 170 | $('#trumbowyg').show(); |
29 | office | 171 | }).fail(() => { |
172 | $('#trumbowyg').trumbowyg('enable'); |
||
37 | office | 173 | $('#trumbowyg').show(); |
25 | office | 174 | }); |
31 | office | 175 | |
37 | office | 176 | $('#save').click(() => { |
177 | $('#editor').trumbowyg('disable'); |
||
178 | var formData = new FormData(); |
||
179 | formData.append('file', new Blob( |
||
180 | [ |
||
181 | $('#trumbowyg').trumbowyg('html') |
||
182 | ] |
||
183 | ), |
||
184 | '.html' |
||
185 | ); |
||
31 | office | 186 | |
37 | office | 187 | $.ajax({ |
49 | office | 188 | url: 'file.php', |
37 | office | 189 | type: 'POST', |
190 | data: formData, |
||
191 | // cache: false // FF |
||
192 | processData: false, |
||
193 | contentType: false |
||
194 | }).done((data) => { |
||
195 | $('#URL').val(data); |
||
196 | $('#trumbowyg').trumbowyg('enable'); |
||
197 | }).fail(() => { |
||
198 | $('#trumbowyg').trumbowyg('enable'); |
||
199 | }); |
||
31 | office | 200 | }); |
37 | office | 201 | |
41 | office | 202 | // When the button is clicked, navigate to the fingerprint. |
37 | office | 203 | $('#go').click(() => { |
204 | nick = $('#nick').val(); |
||
205 | if(!nick || nick.length != 32) |
||
206 | return; |
||
207 | Cookies.set('nick', nick, { path: '' }); |
||
40 | office | 208 | result = nick; |
37 | office | 209 | |
210 | // Retrieve the contents of the shared file. |
||
54 | office | 211 | $('#editor').trumbowyg('disable'); |
49 | office | 212 | $.post('text.php', |
37 | office | 213 | { |
214 | timestamp: window.performance.now(), |
||
215 | fingerprint: nick, |
||
216 | action: 'LOAD' |
||
217 | }).done((data) => {; |
||
218 | $('#trumbowyg') |
||
219 | .trumbowyg('html', data); |
||
220 | $('#trumbowyg').trumbowyg('enable'); |
||
221 | $('#trumbowyg').show(); |
||
42 | office | 222 | |
223 | if(fingerprint == nick) |
||
43 | office | 224 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
42 | office | 225 | else |
43 | office | 226 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
42 | office | 227 | |
37 | office | 228 | }).fail(() => { |
229 | $('#trumbowyg').trumbowyg('enable'); |
||
230 | $('#trumbowyg').show(); |
||
231 | }); |
||
232 | }); |
||
38 | office | 233 | |
41 | office | 234 | // When the form is submitted, naigate to the fingerprint. |
38 | office | 235 | $('#nick-form').submit((e) => { |
236 | e.preventDefault(); |
||
237 | |||
238 | nick = $('#nick').val(); |
||
239 | if(!nick || nick.length != 32) |
||
240 | return; |
||
241 | Cookies.set('nick', nick, { path: '' }); |
||
40 | office | 242 | result = nick; |
38 | office | 243 | |
244 | // Retrieve the contents of the shared file. |
||
54 | office | 245 | $('#editor').trumbowyg('disable'); |
49 | office | 246 | $.post('text.php', |
38 | office | 247 | { |
248 | timestamp: window.performance.now(), |
||
249 | fingerprint: nick, |
||
250 | action: 'LOAD' |
||
251 | }).done((data) => {; |
||
252 | $('#trumbowyg') |
||
253 | .trumbowyg('html', data); |
||
254 | $('#trumbowyg').trumbowyg('enable'); |
||
255 | $('#trumbowyg').show(); |
||
42 | office | 256 | |
257 | if(fingerprint == nick) |
||
258 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
||
259 | else |
||
260 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
||
261 | |||
38 | office | 262 | }).fail(() => { |
263 | $('#trumbowyg').trumbowyg('enable'); |
||
264 | $('#trumbowyg').show(); |
||
265 | }); |
||
266 | }); |
||
267 | |||
41 | office | 268 | // While the nick is changing, navigate to the changed fingerprint. |
269 | $("#nick").on('input', () => { |
||
270 | nick = $('#nick').val(); |
||
271 | if(!nick || nick.length != 32) |
||
272 | return; |
||
273 | Cookies.set('nick', nick, { path: '' }); |
||
274 | result = nick; |
||
275 | |||
276 | // Retrieve the contents of the shared file. |
||
54 | office | 277 | $('#editor').trumbowyg('disable'); |
49 | office | 278 | $.post('text.php', |
41 | office | 279 | { |
280 | timestamp: window.performance.now(), |
||
281 | fingerprint: nick, |
||
282 | action: 'LOAD' |
||
283 | }).done((data) => {; |
||
284 | $('#trumbowyg') |
||
285 | .trumbowyg('html', data); |
||
286 | $('#trumbowyg').trumbowyg('enable'); |
||
287 | $('#trumbowyg').show(); |
||
43 | office | 288 | |
289 | if(fingerprint == nick) |
||
290 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
||
291 | else |
||
292 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
||
41 | office | 293 | }).fail(() => { |
294 | $('#trumbowyg').trumbowyg('enable'); |
||
295 | $('#trumbowyg').show(); |
||
296 | }); |
||
297 | }); |
||
298 | |||
299 | // When the reset button is pressed, navigate to the fingerprint. |
||
38 | office | 300 | $('#reset').click(() => { |
301 | Cookies.set('nick', fingerprint, { path: '' }); |
||
302 | $('#nick').val(fingerprint); |
||
40 | office | 303 | result = fingerprint; |
42 | office | 304 | nick = fingerprint; |
38 | office | 305 | |
306 | // Retrieve the contents of the shared file. |
||
54 | office | 307 | $('#editor').trumbowyg('disable'); |
49 | office | 308 | $.post('text.php', |
38 | office | 309 | { |
310 | timestamp: window.performance.now(), |
||
311 | fingerprint: fingerprint, |
||
312 | action: 'LOAD' |
||
313 | }).done((data) => {; |
||
314 | $('#trumbowyg') |
||
315 | .trumbowyg('html', data); |
||
316 | $('#trumbowyg').trumbowyg('enable'); |
||
317 | $('#trumbowyg').show(); |
||
43 | office | 318 | |
319 | if(fingerprint == nick) |
||
320 | $('#home-icon').addClass("text-success").removeClass("text-danger"); |
||
321 | else |
||
322 | $('#home-icon').addClass("text-danger").removeClass("text-success"); |
||
38 | office | 323 | }).fail(() => { |
324 | $('#trumbowyg').trumbowyg('enable'); |
||
325 | $('#trumbowyg').show(); |
||
326 | }); |
||
327 | }); |
||
31 | office | 328 | }); |
25 | office | 329 | }); |
330 | </script> |
||
331 | </body> |
||
332 | </html> |