scratch – Diff between revs 91 and 96

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 91 Rev 96
Line 8... Line 8...
8 <meta name="description" content="quick asset upload"> 8 <meta name="description" content="quick asset upload">
9 <meta name="author" content="Wizardry and Steamworks"> 9 <meta name="author" content="Wizardry and Steamworks">
10 <link rel="icon" href="favicon.ico"> 10 <link rel="icon" href="favicon.ico">
Line 11... Line 11...
11   11  
12 <title>scratch</title> 12 <title>scratch</title>
13   13
14 <!-- Bootstrap core CSS --> 14 <!-- Bootstrap core CSS -->
15 <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> 15 <link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
16 <!-- Font Awesome --> 16 <!-- Font Awesome -->
Line 62... Line 62...
62 <i class="glyphicon glyphicon-upload"></i> 62 <i class="glyphicon glyphicon-upload"></i>
63 <span>Upload All</span> 63 <span>Upload All</span>
64 </button> 64 </button>
65 </div> 65 </div>
66 <div class="btn-group" role="group"> 66 <div class="btn-group" role="group">
67 <button type="reset" class="btn btn-default cancel"> 67 <button type="reset" class="btn btn-danger cancel">
68 <i class="glyphicon glyphicon-ban-circle"></i> 68 <i class="glyphicon glyphicon-ban-circle"></i>
69 <span>Cancel All</span> 69 <span>Cancel All</span>
70 </button> 70 </button>
71 </div> 71 </div>
72 </div> 72 </div>
Line 111... Line 111...
111 <div> 111 <div>
112 <button id="start" class="btn btn-default start"> 112 <button id="start" class="btn btn-default start">
113 <i class="glyphicon glyphicon-upload"></i> 113 <i class="glyphicon glyphicon-upload"></i>
114 <span>Upload</span> 114 <span>Upload</span>
115 </button> 115 </button>
116 <button id="cancel" data-dz-cancel class="btn btn-default cancel"> 116 <button id="cancel" data-dz-remove class="btn btn-warning cancel">
117 <i class="glyphicon glyphicon-ban-circle"></i> 117 <i class="glyphicon glyphicon-ban-circle"></i>
118 <span>Cancel</span> 118 <span>Cancel</span>
119 </button> 119 </button>
120 <button id="remove" data-dz-remove class="btn btn-danger remove"> 120 <button id="remove" data-dz-remove class="btn btn-danger remove">
121 <i class="glyphicon glyphicon-remove"></i> 121 <i class="glyphicon glyphicon-remove"></i>
Line 150... Line 150...
150 <script src="bower_components/dropzone/dist/min/dropzone.min.js"></script> 150 <script src="bower_components/dropzone/dist/min/dropzone.min.js"></script>
151 <!-- Clipboard --> 151 <!-- Clipboard -->
152 <script src="bower_components/clipboard/dist/clipboard.min.js"></script> 152 <script src="bower_components/clipboard/dist/clipboard.min.js"></script>
153 <script> 153 <script>
154 $(document).ready(() => { 154 $(document).ready(() => {
-   155 $.get('session.php').then((token) => {
155 // Get the template HTML and remove it from the doument 156 // Get the template HTML and remove it from the doument
156 var previewNode = document 157 var previewNode = document
157 .querySelector("#template"); 158 .querySelector("#template");
158 previewNode.id = ""; 159 previewNode.id = "";
159 var previewTemplate = previewNode 160 var previewTemplate = previewNode
160 .parentNode 161 .parentNode
161 .innerHTML; 162 .innerHTML;
162 previewNode 163 previewNode
163 .parentNode 164 .parentNode
164 .removeChild(previewNode); 165 .removeChild(previewNode);
165   166
166 var myDropzone = new Dropzone('.panel-body', { // Make the whole body a dropzone 167 var myDropzone = new Dropzone('.panel-body', { // Make the whole body a dropzone
167 url: "file.php", // Set the url 168 url: 'file.php', // Set the url
168 paramName: "file", 169 paramName: 'file',
169 thumbnailWidth: 80, 170 thumbnailWidth: 80,
170 thumbnailHeight: 80, 171 thumbnailHeight: 80,
171 //parallelUploads: 20, 172 //parallelUploads: 20,
172 previewTemplate: previewTemplate, 173 previewTemplate: previewTemplate,
173 autoQueue: false, // Make sure the files aren't queued until manually added 174 autoQueue: false, // Make sure the files aren't queued until manually added
174 previewsContainer: "#previews", // Container to display the previews 175 previewsContainer: '#previews', // Container to display the previews
175 clickable: [ 176 clickable: [
176 "#uploadbutton", 177 '#uploadbutton',
177 "#uploadpanel" 178 '#uploadpanel'
178 ], 179 ],
179 //clickable: "#uploadbutton" // Element that should be used as click trigger to select files. 180 //clickable: "#uploadbutton" // Element that should be used as click trigger to select files.
-   181 }).on('sending', (file, xhr, formData) => {
-   182 // Append session token.
-   183 formData.append('token', token);
180 }).on("addedfile", (file) => { 184 }).on('addedfile', (file) => {
181 // Hookup the start button 185 // Hookup the start button
182 file.previewElement.querySelector(".start").onclick = () => { 186 file.previewElement.querySelector(".start").onclick = () => {
183 myDropzone.enqueueFile(file); 187 myDropzone.enqueueFile(file);
184 }; 188 };
185 }).on("totaluploadprogress", (progress) => { 189 }).on('totaluploadprogress', (progress) => {
186 document 190 document
187 .querySelector("#total-progress .progress-bar") 191 .querySelector('#total-progress .progress-bar')
-   192 .style
-   193 .width = progress + "%";
-   194 }).on('sending', (file) => {
-   195 // Show the total progress bar when upload starts
-   196 document.querySelector("#total-progress")
188 .style 197 .style
189 .width = progress + "%"; -  
190 }).on("sending", (file) => { -  
191 // Show the total progress bar when upload starts -  
192 document.querySelector("#total-progress") -  
193 .style -  
194 .opacity = 1; 198 .opacity = 1;
Line 195... Line 199...
195 199
196 // And disable the start button. 200 // And disable the start button.
197 file 201 file
198 .previewElement 202 .previewElement
199 .querySelector(".start") 203 .querySelector(".start")
200 .setAttribute("disabled", "disabled"); 204 .setAttribute("disabled", "disabled");
201 }).on("queuecomplete", (progress) => { 205 }).on('queuecomplete', (progress) => {
202 document.querySelector("#total-progress") 206 document.querySelector("#total-progress")
203 .style 207 .style
204 .opacity = "0"; 208 .opacity = "0";
205 }).on("success", (file, data) => { 209 }).on('success', (file, data) => {
206 // Serialize JSON to object. 210 // Serialize JSON to object.
Line 207... Line 211...
207 data = JSON.parse(data); 211 data = JSON.parse(data);
208 212
209 // Set the ID of the URL box. 213 // Set the ID of the URL box.
210 const boxURLID = '_' + Math 214 const boxURLID = '_' + Math
211 .random() 215 .random()
212 .toString(36) 216 .toString(36)
213 .substr(2, 9); 217 .substr(2, 9);
214 file 218 file
215 .previewElement 219 .previewElement
216 .querySelector("#URL") 220 .querySelector("#URL")
217 .value = location.protocol 221 .value = location.protocol
218 .concat("//") 222 .concat("//")
219 .concat(window.location.hostname) 223 .concat(window.location.hostname)
Line 220... Line 224...
220 .concat("/") 224 .concat("/")
221 .concat(data.hash); 225 .concat(data.hash);
222 226
223 file 227 file
224 .previewElement 228 .previewElement
225 .querySelector("#URL") 229 .querySelector("#URL")
226 .setAttribute('id', boxURLID) 230 .setAttribute('id', boxURLID)
227   231  
228 // Set the ID of the delete URL box. 232 // Set the ID of the delete URL box.
229 const deleteBoxURLID = '_' + Math 233 const deleteBoxURLID = '_' + Math
230 .random() 234 .random()
231 .toString(36) 235 .toString(36)
232 .substr(2, 9); 236 .substr(2, 9);
233 file 237 file
234 .previewElement 238 .previewElement
235 .querySelector("#deleteURL") 239 .querySelector("#deleteURL")
236 .value = location.protocol.concat("//") 240 .value = location.protocol.concat("//")
237 .concat(window.location.hostname) 241 .concat(window.location.hostname)
238 .concat("/") 242 .concat("/")
Line 239... Line 243...
239 .concat(data.timestamp) 243 .concat(data.timestamp)
240 .concat("/") 244 .concat("/")
241 .concat(data.hash); 245 .concat(data.hash);
242 246
Line 243... Line 247...
243 file 247 file
244 .previewElement 248 .previewElement
245 .querySelector("#deleteURL") 249 .querySelector("#deleteURL")
246 .setAttribute('id', deleteBoxURLID) 250 .setAttribute('id', deleteBoxURLID)
247 251
248 // Set the ID of the URL clipboard button. 252 // Set the ID of the URL clipboard button.
249 const clipButtonID = '_' + Math 253 const clipButtonID = '_' + Math
250 .random() 254 .random()
251 .toString(36) 255 .toString(36)
Line 252... Line 256...
252 .substr(2, 9); 256 .substr(2, 9);
253 file 257 file
254 .previewElement 258 .previewElement
255 .querySelector("#btn-clipboard") 259 .querySelector("#btn-clipboard")
Line 256... Line 260...
256 .setAttribute('data-clipboard-target', '#' + boxURLID) 260 .setAttribute('data-clipboard-target', '#' + boxURLID)
Line 257... Line 261...
257 261
258 file 262 file
259 .previewElement 263 .previewElement
260 .querySelector("#btn-clipboard") 264 .querySelector("#btn-clipboard")
261 .setAttribute('id', clipButtonID); 265 .setAttribute('id', clipButtonID);
262 266
263 new Clipboard('#' + clipButtonID); 267 new Clipboard('#' + clipButtonID);
264 268
265 // Set the ID of the delete URL clipboard button. 269 // Set the ID of the delete URL clipboard button.
Line 266... Line 270...
266 const clipButtonDeleteID = '_' + Math 270 const clipButtonDeleteID = '_' + Math
267 .random() 271 .random()
268 .toString(36) 272 .toString(36)
269 .substr(2, 9); 273 .substr(2, 9);
Line 270... Line 274...
270 file 274 file
Line 271... Line 275...
271 .previewElement 275 .previewElement
272 .querySelector("#btn-clipboard-delete") 276 .querySelector("#btn-clipboard-delete")
273 .setAttribute('data-clipboard-target', '#' + deleteBoxURLID) 277 .setAttribute('data-clipboard-target', '#' + deleteBoxURLID)
274 278
275 file 279 file
Line 276... Line 280...
276 .previewElement 280 .previewElement
277 .querySelector("#btn-clipboard-delete") 281 .querySelector("#btn-clipboard-delete")
278 .setAttribute('id', clipButtonDeleteID); 282 .setAttribute('id', clipButtonDeleteID);
279 283
280 new Clipboard('#' + clipButtonDeleteID); 284 new Clipboard('#' + clipButtonDeleteID);
281 285
282 // Set the ID of the mailto button. 286 // Set the ID of the mailto button.
283 const mailToButtonID = '_' + Math 287 const mailToButtonID = '_' + Math
284 .random() 288 .random()
285 .toString(36) 289 .toString(36)
286 .substr(2, 9); 290 .substr(2, 9);
287 291
288 file 292 file
Line 289... Line 293...
289 .previewElement 293 .previewElement
290 .querySelector("#btn-mailto") 294 .querySelector("#btn-mailto")
291 .setAttribute('id', mailToButtonID); 295 .setAttribute('id', mailToButtonID);
292   296  
293 file 297 file
Line 294... Line 298...
294 .previewElement 298 .previewElement
295 .querySelector(".start") 299 .querySelector(".start")
296 .setAttribute("disabled", "disabled"); 300 .setAttribute("disabled", "disabled");
297 file 301 file
298 .previewElement 302 .previewElement
299 .querySelector(".cancel") 303 .querySelector(".cancel")
300 .setAttribute("disabled", "disabled"); 304 .setAttribute("disabled", "disabled");
301 305
302 $('#' + mailToButtonID).on('click', () => { 306 $('#' + mailToButtonID).on('click', () => {
303 window.location.href = "mailto:?subject="+ 307 window.location.href = "mailto:?subject="+
Line 304... Line 308...
304 encodeURIComponent("Can't scratch this!") + "&body=" + 308 encodeURIComponent("Can't scratch this!") + "&body=" +
305 encodeURIComponent($('#' + boxURLID).val()); 309 encodeURIComponent($('#' + boxURLID).val());
306 }); 310 });
307 311
308 // Set the ID of the facebook button. 312 // Set the ID of the facebook button.
309 const faceBookButtonID = '_' + Math 313 const faceBookButtonID = '_' + Math
310 .random() 314 .random()
Line 311... Line 315...
311 .toString(36) 315 .toString(36)
312 .substr(2, 9); 316 .substr(2, 9);
313   317  
314 file 318 file
315 .previewElement 319 .previewElement
316 .querySelector("#btn-facebook") 320 .querySelector("#btn-facebook")
317 .setAttribute('id', faceBookButtonID); 321 .setAttribute('id', faceBookButtonID);
318 322
319 switch(data.opengraph) { 323 switch(data.opengraph) {
320 case true: 324 case true:
321 // Enable the facebook button. 325 // Enable the facebook button.
322 file 326 file
323 .previewElement 327 .previewElement
324 .querySelector('#' + faceBookButtonID) 328 .querySelector('#' + faceBookButtonID)
325 .removeAttribute("disabled"); 329 .removeAttribute("disabled");
326 330
327 // Change the URL when the user clicks the button. 331 // Change the URL when the user clicks the button.
328 $('#' + faceBookButtonID).on('click', () => { 332 $('#' + faceBookButtonID).on('click', () => {
329 $('#' + boxURLID) 333 $('#' + boxURLID)
330 .val( 334 .val(
331 location.protocol.concat("//") 335 location.protocol.concat("//")
332 .concat(window.location.hostname) 336 .concat(window.location.hostname)
333 .concat("/") 337 .concat("/")
334 .concat("og") 338 .concat("og")
335 .concat("/") 339 .concat("/")
336 .concat(data.hash) 340 .concat(data.hash)
337 ); 341 );
338 }); 342 });
Line 339... Line 343...
339 break; 343 break;
340 default: 344 default:
-   345 // Disable the facebook button.
341 // Disable the facebook button. 346 file
Line 342... Line 347...
342 file 347 .previewElement
343 .previewElement 348 .querySelector('#' + faceBookButtonID)
344 .querySelector('#' + faceBookButtonID) 349 .setAttribute("disabled", "disabled");
345 .setAttribute("disabled", "disabled"); 350 break;