scratch – Blame information for rev 132

Subversion Repositories:
Rev:
Rev Author Line No. Line
24 office 1 <!DOCTYPE html>
125 office 2 <html lang="en" ng-app="scratch">
24 office 3 <head>
4 <meta charset="utf-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 <meta name="viewport" content="width=device-width, initial-scale=1">
7 <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
8 <meta name="description" content="quick asset upload">
9 <meta name="author" content="Wizardry and Steamworks">
10 <link rel="icon" href="favicon.ico">
11  
64 office 12 <title>scratch</title>
96 office 13  
24 office 14 <!-- Bootstrap core CSS -->
58 office 15 <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
65 office 16 <!-- Font Awesome -->
17 <link href="bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet">
24 office 18 <!-- DropZone -->
58 office 19 <link href="bower_components/dropzone/dist/min/dropzone.min.css" rel="stylesheet">
125 office 20 <!-- TagsInput -->
21 <link href="bower_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.css" rel="stylesheet">
71 office 22  
23 <!-- Site-wide style CCS -->
24 <link href="css/style.css" rel="stylesheet">
25  
24 office 26 <!-- Local style -->
27 <link href="css/files/style.css" rel="stylesheet">
125 office 28  
29 <!-- Scratch Angular Includes -->
30 <ng-include src="'html/scratch-head-last.html'"></ng-include>
24 office 31 </head>
32  
33 <body>
125 office 34  
35 <!-- Scratch Angular Includes -->
36 <ng-include src="'html/scratch-body-first.html'"></ng-include>
24 office 37  
71 office 38 <!-- Main component for a primary marketing message or call to action -->
39 <div class="paralax-background"></div>
40 <div class="jumbotron">
41 <h1>scratch copy</h1>
42 <p class="quote">the asset sharer</p>
43 </div>
44  
24 office 45 <div class="container">
132 office 46  
24 office 47 <ul class="nav nav-tabs">
48 <li><a href="index.html">Home</a></li>
56 office 49 <li class="active"><a href="#">File</a></li>
24 office 50 <li><a href="text.html">Text</a></li>
84 office 51 <li><a href="draw.html">Draw</a></li>
91 office 52 <li><a href="link.html">Link</a></li>
121 office 53 <li><a href="view.html">View</a></li>
24 office 54 </ul>
55  
132 office 56 <div id="main-panel" class="panel panel-default">
57 <div class="panel-heading">
58 <div id="actions" class="row">
59 <div class="col-lg-5">
60 <div class="btn-group btn-group-justified" role="group">
61 <!-- The fileinput-button span is used to style the file input field as button -->
62 <div class="btn-group" role="group">
63 <button id="uploadbutton" type="button" class="btn btn-default">
64 <i class="glyphicon glyphicon-plus"></i>
65 <span>Add...</span>
66 </button>
67 </div>
68 <div class="btn-group" role="group">
69 <button type="submit" class="btn btn-default start">
70 <i class="glyphicon glyphicon-upload"></i>
71 <span>Upload All</span>
72 </button>
73 </div>
74 <div class="btn-group" role="group">
75 <button type="reset" class="btn btn-danger cancel">
76 <i class="glyphicon glyphicon-ban-circle"></i>
77 <span>Cancel All</span>
78 </button>
79 </div>
24 office 80 </div>
132 office 81 </div>
82 </div>
83 </div>
84 <div class="panel-body" id="uploadpanel">
85 <div class="table table-striped files" id="previews">
86 <div id="template" class="file-row">
87 <!-- This is used as the file preview template -->
88 <div>
89 <span class="preview"><img src="img/fileholder.svg" width="58" alt="Upload file thumbnail" data-dz-thumbnail></span>
24 office 90 </div>
132 office 91 <div>
92 <p class="upload-filename" data-dz-name></p>
93 <label for="file-upload-url">Download URL:</label>
94 <div class="input-group">
95 <input id="file-upload-url" type="text" class="form-control upload-url" readonly>
96 <span class="input-group-btn">
97 <button id="btn-mailto" class="btn btn-default url-mailto-button" type="button"><i class="glyphicon glyphicon-envelope"></i></button>
98 </span>
99 <span class="input-group-btn">
100 <button id="btn-facebook" class="btn btn-default url-facebook-button" type="button" disabled><i class="fa fa-facebook"></i></button>
101 </span>
102 <span class="input-group-btn">
103 <button id="btn-clipboard" class="btn btn-default url-clipboard-button" type="button"><i class="glyphicon glyphicon-paperclip"></i></button>
104 </span>
24 office 105 </div>
132 office 106 <label for="file-upload-url">Delete URL:</label>
107 <div class="input-group">
108 <input id="file-delete-url" type="text" class="form-control delete-url" readonly>
109 <span class="input-group-btn">
110 <button id="btn-clipboard-delete" class="btn btn-default delete-cliboard-button" type="button"><i class="glyphicon glyphicon-paperclip"></i></button>
111 </span>
24 office 112 </div>
132 office 113 <label for="file-tags">Tags:</label>
114 <div class="input-group">
115 <select id="file-tags" multiple class="form-control file-tags"></select>
24 office 116 </div>
132 office 117 <strong class="error text-danger" data-dz-errormessage></strong>
118 </div>
119 <div>
120 <p class="size" data-dz-size></p>
121 <div id="progress" class="progress active" role="progressbar">
122 <div class="progress-bar progress-bar-custom" style="width:0%;" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" data-dz-uploadprogress></div>
24 office 123 </div>
124 </div>
132 office 125 <div>
126 <button id="start" class="btn btn-default start">
127 <i class="glyphicon glyphicon-upload"></i>
128 <span>Upload</span>
129 </button>
130 <button id="cancel" data-dz-remove class="btn btn-warning cancel">
131 <i class="glyphicon glyphicon-ban-circle"></i>
132 <span>Cancel</span>
133 </button>
134 <button id="remove" data-dz-remove class="btn btn-danger remove">
135 <i class="glyphicon glyphicon-remove"></i>
136 <span>Remove</span>
137 </button>
138 </div>
24 office 139 </div>
132 office 140 </div>
141 </div>
142 <!-- The global file processing state -->
143 <div class="fileupload-process">
144 <div id="total-progress" class="progress active" role="progressbar">
145 <div class="progress-bar progress-bar-custom" style="width:0%;" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" data-dz-uploadprogress></div>
24 office 146 </div>
132 office 147 </div>
148 </div>
24 office 149 </div> <!-- /container -->
150  
151 <div id="footer">
152 <div class="container">
71 office 153 <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>
24 office 154 </div>
155 </div>
156  
58 office 157 <!-- jQuery -->
158 <script src="bower_components/jquery/dist/jquery.min.js"></script>
125 office 159 <!-- Angular JS -->
160 <script src="bower_components/angular/angular.min.js"></script>
58 office 161 <!-- BootStrap -->
162 <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
24 office 163 <!-- DropZone -->
58 office 164 <script src="bower_components/dropzone/dist/min/dropzone.min.js"></script>
24 office 165 <!-- Clipboard -->
58 office 166 <script src="bower_components/clipboard/dist/clipboard.min.js"></script>
125 office 167 <!-- TagsInput -->
168 <script src="bower_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js"></script>
169 <!-- Angular Initialization. -->
24 office 170 <script>
125 office 171 var app = angular.module('scratch', []);
172 </script>
173 <script>
26 office 174 $(document).ready(() => {
96 office 175 $.get('session.php').then((token) => {
176 // Get the template HTML and remove it from the doument
177 var previewNode = document
126 office 178 .querySelector('#template');
179 previewNode.id = '';
96 office 180 var previewTemplate = previewNode
181 .parentNode
182 .innerHTML;
183 previewNode
184 .parentNode
185 .removeChild(previewNode);
126 office 186  
96 office 187 var myDropzone = new Dropzone('.panel-body', { // Make the whole body a dropzone
188 url: 'file.php', // Set the url
189 paramName: 'file',
190 thumbnailWidth: 80,
191 thumbnailHeight: 80,
192 //parallelUploads: 20,
193 previewTemplate: previewTemplate,
194 autoQueue: false, // Make sure the files aren't queued until manually added
195 previewsContainer: '#previews', // Container to display the previews
196 clickable: [
197 '#uploadbutton',
198 '#uploadpanel'
199 ],
200 //clickable: "#uploadbutton" // Element that should be used as click trigger to select files.
201 }).on('sending', (file, xhr, formData) => {
202 // Append session token.
203 formData.append('token', token);
126 office 204  
205 // Append tags to the form data.
206 const tagsBoxID = file
207 .previewElement
129 office 208 .querySelector('.file-tags')
126 office 209 .getAttribute('id');
210  
211 const tags = $('#' + tagsBoxID)
212 .tagsinput('items');
213  
214 formData.append('tags', JSON.stringify(tags));
128 office 215  
216 // And disable the tags bar.
131 office 217 const tagsContainerID = file
128 office 218 .previewElement
131 office 219 .querySelector('.bootstrap-tagsinput')
220 .getAttribute('id');
221  
132 office 222 $('#' + tagsBoxID).attr('readonly', 'readonly');
223 $('#' + tagsBoxID).attr('disabled', 'disabled');
131 office 224 $('#' + tagsContainerID).attr('readonly', 'readonly');
225 $('#' + tagsContainerID).attr('disabled', 'disabled');
128 office 226  
96 office 227 }).on('addedfile', (file) => {
126 office 228 // Hookup the start button.
229 file.previewElement.querySelector('.start').onclick = () => {
96 office 230 myDropzone.enqueueFile(file);
231 };
125 office 232  
96 office 233 // Set the ID of the URL box.
234 const boxURLID = '_' + Math
235 .random()
236 .toString(36)
237 .substr(2, 9);
238 file
239 .previewElement
129 office 240 .querySelector('#file-upload-url')
241 .setAttribute('id', boxURLID);
242  
96 office 243 // Set the ID of the delete URL box.
244 const deleteBoxURLID = '_' + Math
245 .random()
246 .toString(36)
247 .substr(2, 9);
248 file
249 .previewElement
129 office 250 .querySelector('#file-delete-url')
251 .setAttribute('id', deleteBoxURLID);
252  
96 office 253 // Set the ID of the URL clipboard button.
254 const clipButtonID = '_' + Math
255 .random()
256 .toString(36)
257 .substr(2, 9);
258 file
259 .previewElement
126 office 260 .querySelector('#btn-clipboard')
96 office 261 .setAttribute('data-clipboard-target', '#' + boxURLID)
24 office 262  
96 office 263 file
264 .previewElement
126 office 265 .querySelector('#btn-clipboard')
96 office 266 .setAttribute('id', clipButtonID);
73 office 267  
96 office 268 new Clipboard('#' + clipButtonID);
72 office 269  
96 office 270 // Set the ID of the delete URL clipboard button.
271 const clipButtonDeleteID = '_' + Math
272 .random()
273 .toString(36)
274 .substr(2, 9);
275 file
276 .previewElement
126 office 277 .querySelector('#btn-clipboard-delete')
96 office 278 .setAttribute('data-clipboard-target', '#' + deleteBoxURLID)
73 office 279  
96 office 280 file
281 .previewElement
126 office 282 .querySelector('#btn-clipboard-delete')
96 office 283 .setAttribute('id', clipButtonDeleteID);
73 office 284  
96 office 285 new Clipboard('#' + clipButtonDeleteID);
73 office 286  
96 office 287 // Set the ID of the mailto button.
288 const mailToButtonID = '_' + Math
289 .random()
290 .toString(36)
291 .substr(2, 9);
72 office 292  
96 office 293 file
294 .previewElement
126 office 295 .querySelector('#btn-mailto')
96 office 296 .setAttribute('id', mailToButtonID);
129 office 297  
298 // Set the ID of the facebook button.
299 const faceBookButtonID = '_' + Math
300 .random()
301 .toString(36)
302 .substr(2, 9);
24 office 303  
96 office 304 file
305 .previewElement
129 office 306 .querySelector('#btn-facebook')
307 .setAttribute('id', faceBookButtonID);
308  
309 // Set the ID of the tags input.
310 const tagsBoxID = '_' + Math
311 .random()
312 .toString(36)
313 .substr(2, 9);
314  
315 file
316 .previewElement
317 .querySelector('#file-tags')
318 .setAttribute('id', tagsBoxID);
319  
320 $('#' + tagsBoxID).tagsinput('refresh');
321  
131 office 322 // Set the ID of the tags div.
323 const tagsContainerID = '_' + Math
324 .random()
325 .toString(36)
326 .substr(2, 9);
327  
328 // Add form control to tags list.
329 file
330 .previewElement
331 .querySelector('.bootstrap-tagsinput')
332 .classList
333 .add('form-control');
334  
335 file
336 .previewElement
337 .querySelector('.bootstrap-tagsinput')
338 .setAttribute('id', tagsContainerID);
339  
129 office 340 }).on('totaluploadprogress', (progress) => {
341 document
342 .querySelector('#total-progress .progress-bar')
343 .style
344 .width = progress + '%';
345 }).on('sending', (file) => {
346 // Show the total progress bar when upload starts
347 document.querySelector("#total-progress")
348 .style
349 .opacity = 1;
350  
351 // And disable the start button.
352 file
353 .previewElement
126 office 354 .querySelector('.start')
355 .setAttribute('disabled', 'disabled');
129 office 356 }).on('queuecomplete', (progress) => {
357 document.querySelector('#total-progress')
358 .style
359 .opacity = '0';
360 }).on('success', (file, data) => {
361 // Serialize JSON to object.
362 data = JSON.parse(data);
363  
96 office 364 file
365 .previewElement
129 office 366 .querySelector(".upload-url")
367 .value = location.protocol
368 .concat("//")
369 .concat(window.location.hostname)
370 .concat("/")
371 .concat(data.hash);
372  
373 file
374 .previewElement
375 .querySelector('.delete-url')
376 .value = location.protocol.concat('//')
377 .concat(window.location.hostname)
378 .concat('/')
379 .concat(data.timestamp)
380 .concat('/')
381 .concat(data.hash);
382  
383 file
384 .previewElement
385 .querySelector('.start')
386 .setAttribute('disabled', 'disabled');
387 file
388 .previewElement
126 office 389 .querySelector('.cancel')
390 .setAttribute('disabled', 'disabled');
129 office 391  
392 // Enable the mailto button.
393 $('.url-mailto-button').on('click', () => {
96 office 394 window.location.href = "mailto:?subject="+
395 encodeURIComponent("Can't scratch this!") + "&body=" +
129 office 396 encodeURIComponent($('.upload-url').val());
96 office 397 });
129 office 398  
399 // Enable or disable the facebook opengraph URL.
96 office 400 switch(data.opengraph) {
401 case true:
402 // Enable the facebook button.
403 file
404 .previewElement
129 office 405 .querySelector('.url-facebook-button')
126 office 406 .removeAttribute('disabled');
90 office 407  
96 office 408 // Change the URL when the user clicks the button.
129 office 409 $('.url-facebook-button').on('click', () => {
410 $('.upload-url')
96 office 411 .val(
126 office 412 location.protocol.concat('//')
96 office 413 .concat(window.location.hostname)
126 office 414 .concat('/')
415 .concat('og')
416 .concat('/')
96 office 417 .concat(data.hash)
418 );
419 });
420 break;
421 default:
422 // Disable the facebook button.
423 file
424 .previewElement
129 office 425 .querySelector('.url-facebook-button')
126 office 426 .setAttribute('disabled', 'disabled');
96 office 427 break;
428 }
429 });
430  
126 office 431 document.querySelector('#actions .start').onclick = () => {
96 office 432 myDropzone.enqueueFiles(
433 myDropzone
434 .getFilesWithStatus(Dropzone.ADDED));
435 };
436  
126 office 437 document.querySelector('#actions .cancel').onclick = () => {
96 office 438 myDropzone.removeAllFiles(true);
439 };
24 office 440 });
441  
84 office 442 // Scroll to the panel.
443 $('html, body').animate({
444 scrollTop: $('#main-panel').offset().top
445 }, 'slow');
24 office 446 });
447 </script>
71 office 448 <!-- Jumbotron parallax effect -->
70 office 449 <script>
71 office 450 const jumboHeight = $('.jumbotron').outerHeight();
70 office 451 function parallax(){
452 var scrolled = $(window).scrollTop();
453 $('.paralax-background').css('height', (jumboHeight-scrolled) + 'px');
454 }
455  
456 $(window).scroll(function(e){
457 parallax();
458 });
459 </script>
24 office 460 </body>
461 </html>