scratch – Blame information for rev 135

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 -->
133 office 21 <link href="bower_components/bootstrap-tokenfield/dist/css/bootstrap-tokenfield.min.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>
135 office 91 <div class="upload-details-column">
132 office 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">
133 office 115 <!-- <select id="file-tags" multiple class="form-control file-tags"></select> -->
116 <input type="text" class="form-control tokenfield file-tags" id="file-tags" data-minLength="3" data-delimiter=" "/>
24 office 117 </div>
132 office 118 <strong class="error text-danger" data-dz-errormessage></strong>
119 </div>
120 <div>
121 <p class="size" data-dz-size></p>
122 <div id="progress" class="progress active" role="progressbar">
123 <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 124 </div>
125 </div>
132 office 126 <div>
127 <button id="start" class="btn btn-default start">
128 <i class="glyphicon glyphicon-upload"></i>
129 <span>Upload</span>
130 </button>
131 <button id="cancel" data-dz-remove class="btn btn-warning cancel">
132 <i class="glyphicon glyphicon-ban-circle"></i>
133 <span>Cancel</span>
134 </button>
135 <button id="remove" data-dz-remove class="btn btn-danger remove">
136 <i class="glyphicon glyphicon-remove"></i>
137 <span>Remove</span>
138 </button>
139 </div>
24 office 140 </div>
132 office 141 </div>
142 </div>
143 <!-- The global file processing state -->
144 <div class="fileupload-process">
145 <div id="total-progress" class="progress active" role="progressbar">
146 <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 147 </div>
132 office 148 </div>
149 </div>
24 office 150 </div> <!-- /container -->
151  
152 <div id="footer">
153 <div class="container">
71 office 154 <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 155 </div>
156 </div>
157  
58 office 158 <!-- jQuery -->
159 <script src="bower_components/jquery/dist/jquery.min.js"></script>
125 office 160 <!-- Angular JS -->
161 <script src="bower_components/angular/angular.min.js"></script>
58 office 162 <!-- BootStrap -->
163 <script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
24 office 164 <!-- DropZone -->
58 office 165 <script src="bower_components/dropzone/dist/min/dropzone.min.js"></script>
24 office 166 <!-- Clipboard -->
58 office 167 <script src="bower_components/clipboard/dist/clipboard.min.js"></script>
125 office 168 <!-- TagsInput -->
133 office 169 <!-- <script src="bower_components/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js"></script> -->
170 <!-- BootStrap TokenField -->
171 <script src="bower_components/bootstrap-tokenfield/dist/bootstrap-tokenfield.min.js"></script>
125 office 172 <!-- Angular Initialization. -->
24 office 173 <script>
125 office 174 var app = angular.module('scratch', []);
175 </script>
176 <script>
26 office 177 $(document).ready(() => {
96 office 178 $.get('session.php').then((token) => {
179 // Get the template HTML and remove it from the doument
180 var previewNode = document
126 office 181 .querySelector('#template');
182 previewNode.id = '';
96 office 183 var previewTemplate = previewNode
184 .parentNode
185 .innerHTML;
186 previewNode
187 .parentNode
188 .removeChild(previewNode);
126 office 189  
96 office 190 var myDropzone = new Dropzone('.panel-body', { // Make the whole body a dropzone
191 url: 'file.php', // Set the url
192 paramName: 'file',
193 thumbnailWidth: 80,
194 thumbnailHeight: 80,
195 //parallelUploads: 20,
196 previewTemplate: previewTemplate,
197 autoQueue: false, // Make sure the files aren't queued until manually added
198 previewsContainer: '#previews', // Container to display the previews
199 clickable: [
200 '#uploadbutton',
201 '#uploadpanel'
202 ],
203 //clickable: "#uploadbutton" // Element that should be used as click trigger to select files.
204 }).on('sending', (file, xhr, formData) => {
205 // Append session token.
206 formData.append('token', token);
126 office 207  
208 // Append tags to the form data.
209 const tagsBoxID = file
210 .previewElement
129 office 211 .querySelector('.file-tags')
126 office 212 .getAttribute('id');
133 office 213  
126 office 214 const tags = $('#' + tagsBoxID)
133 office 215 .tokenfield('getTokens')
216 .map((token) => {
217 return token.value;
218 });
126 office 219  
220 formData.append('tags', JSON.stringify(tags));
128 office 221  
222 // And disable the tags bar.
133 office 223 $('#' + tagsBoxID).tokenfield('readonly');
224 $('#' + tagsBoxID).tokenfield('disable');
128 office 225  
96 office 226 }).on('addedfile', (file) => {
126 office 227 // Hookup the start button.
228 file.previewElement.querySelector('.start').onclick = () => {
96 office 229 myDropzone.enqueueFile(file);
230 };
125 office 231  
96 office 232 // Set the ID of the URL box.
233 const boxURLID = '_' + Math
234 .random()
235 .toString(36)
236 .substr(2, 9);
237 file
238 .previewElement
129 office 239 .querySelector('#file-upload-url')
240 .setAttribute('id', boxURLID);
241  
96 office 242 // Set the ID of the delete URL box.
243 const deleteBoxURLID = '_' + Math
244 .random()
245 .toString(36)
246 .substr(2, 9);
247 file
248 .previewElement
129 office 249 .querySelector('#file-delete-url')
250 .setAttribute('id', deleteBoxURLID);
251  
96 office 252 // Set the ID of the URL clipboard button.
253 const clipButtonID = '_' + Math
254 .random()
255 .toString(36)
256 .substr(2, 9);
257 file
258 .previewElement
126 office 259 .querySelector('#btn-clipboard')
96 office 260 .setAttribute('data-clipboard-target', '#' + boxURLID)
24 office 261  
96 office 262 file
263 .previewElement
126 office 264 .querySelector('#btn-clipboard')
96 office 265 .setAttribute('id', clipButtonID);
73 office 266  
96 office 267 new Clipboard('#' + clipButtonID);
72 office 268  
96 office 269 // Set the ID of the delete URL clipboard button.
270 const clipButtonDeleteID = '_' + Math
271 .random()
272 .toString(36)
273 .substr(2, 9);
274 file
275 .previewElement
126 office 276 .querySelector('#btn-clipboard-delete')
96 office 277 .setAttribute('data-clipboard-target', '#' + deleteBoxURLID)
73 office 278  
96 office 279 file
280 .previewElement
126 office 281 .querySelector('#btn-clipboard-delete')
96 office 282 .setAttribute('id', clipButtonDeleteID);
73 office 283  
96 office 284 new Clipboard('#' + clipButtonDeleteID);
73 office 285  
96 office 286 // Set the ID of the mailto button.
287 const mailToButtonID = '_' + Math
288 .random()
289 .toString(36)
290 .substr(2, 9);
72 office 291  
96 office 292 file
293 .previewElement
126 office 294 .querySelector('#btn-mailto')
96 office 295 .setAttribute('id', mailToButtonID);
129 office 296  
297 // Set the ID of the facebook button.
298 const faceBookButtonID = '_' + Math
299 .random()
300 .toString(36)
301 .substr(2, 9);
24 office 302  
96 office 303 file
304 .previewElement
129 office 305 .querySelector('#btn-facebook')
306 .setAttribute('id', faceBookButtonID);
307  
308 // Set the ID of the tags input.
309 const tagsBoxID = '_' + Math
310 .random()
311 .toString(36)
312 .substr(2, 9);
313  
314 file
315 .previewElement
316 .querySelector('#file-tags')
317 .setAttribute('id', tagsBoxID);
133 office 318  
319 $('#' + tagsBoxID).tokenfield();
129 office 320  
321 }).on('totaluploadprogress', (progress) => {
322 document
323 .querySelector('#total-progress .progress-bar')
324 .style
325 .width = progress + '%';
326 }).on('sending', (file) => {
327 // Show the total progress bar when upload starts
328 document.querySelector("#total-progress")
329 .style
330 .opacity = 1;
331  
332 // And disable the start button.
333 file
334 .previewElement
126 office 335 .querySelector('.start')
336 .setAttribute('disabled', 'disabled');
129 office 337 }).on('queuecomplete', (progress) => {
338 document.querySelector('#total-progress')
339 .style
340 .opacity = '0';
341 }).on('success', (file, data) => {
342 // Serialize JSON to object.
343 data = JSON.parse(data);
344  
96 office 345 file
346 .previewElement
129 office 347 .querySelector(".upload-url")
348 .value = location.protocol
349 .concat("//")
350 .concat(window.location.hostname)
351 .concat("/")
352 .concat(data.hash);
353  
354 file
355 .previewElement
356 .querySelector('.delete-url')
357 .value = location.protocol.concat('//')
358 .concat(window.location.hostname)
359 .concat('/')
360 .concat(data.timestamp)
361 .concat('/')
362 .concat(data.hash);
363  
364 file
365 .previewElement
366 .querySelector('.start')
367 .setAttribute('disabled', 'disabled');
368 file
369 .previewElement
126 office 370 .querySelector('.cancel')
371 .setAttribute('disabled', 'disabled');
129 office 372  
373 // Enable the mailto button.
374 $('.url-mailto-button').on('click', () => {
96 office 375 window.location.href = "mailto:?subject="+
376 encodeURIComponent("Can't scratch this!") + "&body=" +
129 office 377 encodeURIComponent($('.upload-url').val());
96 office 378 });
129 office 379  
380 // Enable or disable the facebook opengraph URL.
96 office 381 switch(data.opengraph) {
382 case true:
383 // Enable the facebook button.
384 file
385 .previewElement
129 office 386 .querySelector('.url-facebook-button')
126 office 387 .removeAttribute('disabled');
90 office 388  
96 office 389 // Change the URL when the user clicks the button.
129 office 390 $('.url-facebook-button').on('click', () => {
391 $('.upload-url')
96 office 392 .val(
126 office 393 location.protocol.concat('//')
96 office 394 .concat(window.location.hostname)
126 office 395 .concat('/')
396 .concat('og')
397 .concat('/')
96 office 398 .concat(data.hash)
399 );
400 });
401 break;
402 default:
403 // Disable the facebook button.
404 file
405 .previewElement
129 office 406 .querySelector('.url-facebook-button')
126 office 407 .setAttribute('disabled', 'disabled');
96 office 408 break;
409 }
410 });
411  
126 office 412 document.querySelector('#actions .start').onclick = () => {
96 office 413 myDropzone.enqueueFiles(
414 myDropzone
415 .getFilesWithStatus(Dropzone.ADDED));
416 };
417  
126 office 418 document.querySelector('#actions .cancel').onclick = () => {
96 office 419 myDropzone.removeAllFiles(true);
420 };
24 office 421 });
422  
84 office 423 // Scroll to the panel.
424 $('html, body').animate({
425 scrollTop: $('#main-panel').offset().top
426 }, 'slow');
24 office 427 });
428 </script>
71 office 429 <!-- Jumbotron parallax effect -->
70 office 430 <script>
71 office 431 const jumboHeight = $('.jumbotron').outerHeight();
70 office 432 function parallax(){
433 var scrolled = $(window).scrollTop();
434 $('.paralax-background').css('height', (jumboHeight-scrolled) + 'px');
435 }
436  
437 $(window).scroll(function(e){
438 parallax();
439 });
440 </script>
24 office 441 </body>
442 </html>