]> git.mxchange.org Git - simple-upload.git/commitdiff
Better code style, more clear and tighter variable scopes + saved one
authorRoland Häder <roland@mxchange.org>
Tue, 29 Mar 2016 14:25:28 +0000 (16:25 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 29 Mar 2016 14:25:28 +0000 (16:25 +0200)
(len).

index.php

index 3bbc62558575ec8805964dd4f22a86abdc8612f1..2cc58d0b1c177319dcdd8e013566fcdf53467893 100644 (file)
--- a/index.php
+++ b/index.php
                ?>
                <script type="text/javascript">
                <!--
-                       var target_form = document.getElementById('simpleupload-form'),
-                               target_ul = document.getElementById('simpleupload-ul'),
-                               target_input = document.getElementById('simpleupload-input');
+                       var target_form  = document.getElementById('simpleupload-form');
+                       var target_ul    = document.getElementById('simpleupload-ul');
+                       var target_input = document.getElementById('simpleupload-input');
 
                        target_form.addEventListener('dragover', function (event) {
                                event.preventDefault();
                        }, false);
 
-                       function AddFileLi (name, info) {
+                       function addFileLi (name, info) {
                                target_form.style.display = 'none';
 
                                var new_li = document.createElement('li');
                                target_ul.insertBefore(new_li, target_ul.firstChild);
                        }
 
-                       function HandleFiles (event) {
+                       function handleFiles (event) {
                                event.preventDefault();
 
-                               var i = 0,
-                                       files = event.dataTransfer.files,
-                                       len = files.length;
+                               var files = event.dataTransfer.files;
 
                                var form = new FormData();
 
-                               for (; i < len; i++) {
+                               for (var i = 0; i < files.length; i++) {
                                        form.append('file[]', files[i]);
-                                       AddFileLi(files[i].name, files[i].size + ' bytes');
+                                       addFileLi(files[i].name, files[i].size + ' bytes');
                                }
 
                                var xhr = new XMLHttpRequest();
                                xhr.send(form);
                        }
 
-                       target_form.addEventListener('drop', HandleFiles, false);
+                       target_form.addEventListener('drop', handleFiles, false);
 
                        document.getElementById('simpleupload-input').onchange = function () {
-                               AddFileLi('Uploading...', '');
+                               addFileLi('Uploading...', '');
                                target_form.submit();
                        };
                //-->