From 45904d9ff6e1b54563218007bbd436fab2ef2662 Mon Sep 17 00:00:00 2001 From: Maurycy Damian Wasilewski Date: Mon, 20 Aug 2012 18:00:41 +0200 Subject: [PATCH 1/2] Cleanup & consistency fixes --- client/demo.htm | 42 +-- client/fileuploader.js | 656 ++++++++++++++++++++--------------------- server/php.php | 87 +++--- 3 files changed, 387 insertions(+), 398 deletions(-) diff --git a/client/demo.htm b/client/demo.htm index b7b0697d5..628a23b84 100644 --- a/client/demo.htm +++ b/client/demo.htm @@ -2,37 +2,37 @@ - - + + - +

Back to project page

- -

To upload a file, click on the button below. Drag-and-drop is supported in FF, Chrome.

-

Progress-bar is supported in FF3.6+, Chrome6+, Safari4+

- -
- -
-
Drop files here too
- +

To upload a file, click on the button below. Drag-and-drop is supported in FF, Chrome.

+

Progress-bar is supported in FF3.6+, Chrome6+, Safari4+

+ +
+ +
+ +
Drop files here too
+ - \ No newline at end of file +

ColdFusion File Uploader Demo

Back to project page

To upload a file, click on the button below. Drag-and-drop is supported in FF, Chrome.

Progress-bar is supported in FF3.6+, Chrome6+, Safari4+

\ No newline at end of file diff --git a/tests/action-acceptance.php b/tests/action-acceptance.php index fc9583f21..ff2a8c0b3 100644 --- a/tests/action-acceptance.php +++ b/tests/action-acceptance.php @@ -7,15 +7,15 @@ if (isset($_GET['qqfile'])){ $fileName = $_GET['qqfile']; - - // xhr request - $headers = apache_request_headers(); - $fileSize = (int)$headers['Content-Length']; + + // xhr request + $headers = apache_request_headers(); + $fileSize = (int)$headers['Content-Length']; } elseif (isset($_FILES['qqfile'])){ $fileName = basename($_FILES['qqfile']['name']); $fileSize = $_FILES['qqfile']['size']; } else { - die ('{error: "server-error file not passed"}'); + die ('{error: "server-error file not passed"}'); } if ($fileName == '4text.txt'){ @@ -36,11 +36,11 @@ if (count($_GET)){ array_merge($_GET, array('fileName'=>$fileName)); - + $response = array_merge($_GET, array('success'=>true, 'fileName'=>$fileName)); - - // to pass data through iframe you will need to encode all html tags - echo htmlspecialchars(json_encode($response), ENT_NOQUOTES); + + // to pass data through iframe you will need to encode all html tags + echo htmlspecialchars(json_encode($response), ENT_NOQUOTES); } else { - die ('{error: "server-error query params not passed"}'); + die ('{error: "server-error query params not passed"}'); } diff --git a/tests/action-handler-queue-test.php b/tests/action-handler-queue-test.php index ff13576dd..bcc4d627e 100644 --- a/tests/action-handler-queue-test.php +++ b/tests/action-handler-queue-test.php @@ -6,26 +6,26 @@ if (isset($_GET['qqfile'])){ $fileName = $_GET['qqfile']; - - // xhr request - $headers = apache_request_headers(); - if ((int)$headers['Content-Length'] == 0){ - die ('{error: "content length is zero"}'); - } + + // xhr request + $headers = apache_request_headers(); + if ((int)$headers['Content-Length'] == 0){ + die ('{error: "content length is zero"}'); + } } elseif (isset($_FILES['qqfile'])){ $fileName = basename($_FILES['qqfile']['name']); - - // form request - if ($_FILES['qqfile']['size'] == 0){ - die ('{error: "file size is zero"}'); - } + + // form request + if ($_FILES['qqfile']['size'] == 0){ + die ('{error: "file size is zero"}'); + } } else { - die ('{error: "file not passed"}'); + die ('{error: "file not passed"}'); } if (count($_GET)){ $_GET['success'] = true; - echo json_encode(array_merge($_GET)); + echo json_encode(array_merge($_GET)); } else { - die ('{error: "query params not passed"}'); + die ('{error: "query params not passed"}'); } diff --git a/tests/action-handler-test.php b/tests/action-handler-test.php index 24466b122..e27c297cd 100644 --- a/tests/action-handler-test.php +++ b/tests/action-handler-test.php @@ -6,26 +6,26 @@ if (isset($_GET['qqfile'])){ $fileName = $_GET['qqfile']; - - // xhr request - $headers = apache_request_headers(); - if ((int)$headers['Content-Length'] == 0){ - die ('{error: "content length is zero"}'); - } + + // xhr request + $headers = apache_request_headers(); + if ((int)$headers['Content-Length'] == 0){ + die ('{error: "content length is zero"}'); + } } elseif (isset($_FILES['qqfile'])){ $fileName = basename($_FILES['qqfile']['name']); - - // form request - if ($_FILES['qqfile']['size'] == 0){ - die ('{error: "file size is zero"}'); - } + + // form request + if ($_FILES['qqfile']['size'] == 0){ + die ('{error: "file size is zero"}'); + } } else { - die ('{error: "file not passed"}'); + die ('{error: "file not passed"}'); } if (count($_GET)){ - //return query params - echo json_encode(array_merge($_GET, array('fileName'=>$fileName))); + //return query params + echo json_encode(array_merge($_GET, array('fileName'=>$fileName))); } else { - die ('{error: "query params not passed"}'); + die ('{error: "query params not passed"}'); } diff --git a/tests/browser-bugs/safari-bug1.htm b/tests/browser-bugs/safari-bug1.htm index ef0eb0b1b..3b3ed4922 100644 --- a/tests/browser-bugs/safari-bug1.htm +++ b/tests/browser-bugs/safari-bug1.htm @@ -2,7 +2,7 @@ - +

Drag multiple files into input field. (Win7)

Result: One file is selected multiple times. Expected: Multiple files are selected.

diff --git a/tests/browser-bugs/safari-bug2.htm b/tests/browser-bugs/safari-bug2.htm index 57f7bc013..12492cf2f 100644 --- a/tests/browser-bugs/safari-bug2.htm +++ b/tests/browser-bugs/safari-bug2.htm @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/tests/iframe-content-tests/text-html-large.php b/tests/iframe-content-tests/text-html-large.php index ac9682be9..4bc50999a 100644 --- a/tests/iframe-content-tests/text-html-large.php +++ b/tests/iframe-content-tests/text-html-large.php @@ -1,6 +1,6 @@ "&a, to download means to receive data to a local system from a remote system, or to initiate such a data transfer. Examples of a remote system from which a download might be performed include a webserver, FTP server, email server, or other similar systems. A download can mean either any file that is offered for downloading or that has been downloaded, or the process of receiving such a file.The inverse operation, uploading, can refer to the sending of data from a local system to a remote system such as a server or another client with the intent that the remote system should store a copy of the data being transferred, or the initiation of such a process. The words first came into popular usage among computer users with the increased popularity of Bulletin Board Systems (BBSs), facilitated by the widespread distribution and implementation of dial-up access the in the 1970s", - 'sub' => array('arr'=>array(10,20,30), 'boo'=>false) - ); - echo htmlspecialchars(json_encode($data), ENT_NOQUOTES); + header('Content-type: text/html'); + $data = array( + 'example' => "&a, to download means to receive data to a local system from a remote system, or to initiate such a data transfer. Examples of a remote system from which a download might be performed include a webserver, FTP server, email server, or other similar systems. A download can mean either any file that is offered for downloading or that has been downloaded, or the process of receiving such a file.The inverse operation, uploading, can refer to the sending of data from a local system to a remote system such as a server or another client with the intent that the remote system should store a copy of the data being transferred, or the initiation of such a process. The words first came into popular usage among computer users with the increased popularity of Bulletin Board Systems (BBSs), facilitated by the widespread distribution and implementation of dial-up access the in the 1970s", + 'sub' => array('arr'=>array(10,20,30), 'boo'=>false) + ); + echo htmlspecialchars(json_encode($data), ENT_NOQUOTES); diff --git a/tests/qunit/package.json b/tests/qunit/package.json index b6044c887..fd65dfbab 100644 --- a/tests/qunit/package.json +++ b/tests/qunit/package.json @@ -1,21 +1,21 @@ { - "name": "qunit", - "author": { - "name": "John Resig", - "email": "jeresig@gmail.com", - "url": "http://ejohn.org/" - }, - "maintainer": { - "name": "Jörn Zaefferer", - "email": "joern.zaefferer@googlemail.com", - "url": "http://bassistance.de/" - }, - "url": "http://docs.jquery.com/QUnit", - "license": { - "name": "MIT", - "url": "http://www.opensource.org/licenses/mit-license.php" - }, - "description": "An easy-to-use JavaScript Unit Testing framework.", - "keywords": [ "testing", "unit", "jquery" ], - "lib": "qunit" + "name": "qunit", + "author": { + "name": "John Resig", + "email": "jeresig@gmail.com", + "url": "http://ejohn.org/" + }, + "maintainer": { + "name": "Jörn Zaefferer", + "email": "joern.zaefferer@googlemail.com", + "url": "http://bassistance.de/" + }, + "url": "http://docs.jquery.com/QUnit", + "license": { + "name": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + }, + "description": "An easy-to-use JavaScript Unit Testing framework.", + "keywords": [ "testing", "unit", "jquery" ], + "lib": "qunit" } diff --git a/tests/qunit/test/index.html b/tests/qunit/test/index.html index 8a9f86500..51fc0b25d 100644 --- a/tests/qunit/test/index.html +++ b/tests/qunit/test/index.html @@ -1,17 +1,17 @@ - QUnit Test Suite - - - - + QUnit Test Suite + + + + -

QUnit Test Suite

-

-
-

-
    +

    QUnit Test Suite

    +

    +
    +

    +
      diff --git a/tests/qunit/test/same.js b/tests/qunit/test/same.js index 8f1b5630f..7e43c9e7a 100644 --- a/tests/qunit/test/same.js +++ b/tests/qunit/test/same.js @@ -451,7 +451,7 @@ test("Complex Objects.", function() { function fn2() { return "fn2"; } - + // Try to invert the order of some properties to make sure it is covered. // It can failed when properties are compared between unsorted arrays. equals(QUnit.equiv( diff --git a/tests/separate-file-list.htm b/tests/separate-file-list.htm index 424142942..8fc6421b9 100644 --- a/tests/separate-file-list.htm +++ b/tests/separate-file-list.htm @@ -2,23 +2,23 @@ - + - - -
      -
        - + + +
        +
          + - + }); + } + window.onload = createUploader; + \ No newline at end of file diff --git a/tests/test-acceptance.htm b/tests/test-acceptance.htm index 985c20b03..dbbb083b5 100644 --- a/tests/test-acceptance.htm +++ b/tests/test-acceptance.htm @@ -1,27 +1,27 @@ - + - + - - + + + - +

          File uploader tests

          @@ -95,12 +95,12 @@

          In FF,Chrome, select all files using drag-and-drop, only 1 error should appear. - +
          File uploader inside a dialog -
          -
          - +
          + + diff --git a/tests/test-detach-handlers.htm b/tests/test-detach-handlers.htm index 8f3fdf5aa..e24f1fa6b 100644 --- a/tests/test-detach-handlers.htm +++ b/tests/test-detach-handlers.htm @@ -1,52 +1,52 @@ - + - - - - - + + + - + + - +

          drop-zone1

          -

          drop-zone2

          - +

          drop-zone2

          + diff --git a/tests/test-handler-queue.htm b/tests/test-handler-queue.htm index 52e3b3a58..892f2d9bf 100644 --- a/tests/test-handler-queue.htm +++ b/tests/test-handler-queue.htm @@ -1,81 +1,81 @@ - + - + - + + - -

          File uploader tests

          -

          -

          + +

          File uploader tests

          +

          +

            - +

            Please select a file for each input below, should be less than 4 sec, between selection.

            - + - - + + diff --git a/tests/test-upload-handlers.htm b/tests/test-upload-handlers.htm index 9cf74fe7e..92684a0e6 100644 --- a/tests/test-upload-handlers.htm +++ b/tests/test-upload-handlers.htm @@ -1,13 +1,13 @@ - - - - - - - - + + + + + + + -

            File uploader tests

            -

            -

            -
              - -

              - Open this page via https connection, and make sure that loading bar is not acting strange after all tests are run. - Back button test fails in Opera. -

              - -

              Please select a file for each input below (in order)

              +

              File uploader tests

              +

              +

              +
                + +

                + Open this page via https connection, and make sure that loading bar is not acting strange after all tests are run. + Back button test fails in Opera. +

                + +

                Please select a file for each input below (in order)

                qq.FileUploader

                - -

                qq.UploadHandlerForm

                - - - -

                qq.UploadHandlerXhr

                - - - - + +

                qq.UploadHandlerForm

                + + + +

                qq.UploadHandlerXhr

                + + + +