scratch – Blame information for rev 76

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