diff --git a/Resources/static/js/receive.js b/Resources/static/js/receive.js deleted file mode 100644 index 487b8e1..0000000 --- a/Resources/static/js/receive.js +++ /dev/null @@ -1,141 +0,0 @@ -$(function () { - // Add a flash message - var flash = function (category, message) { - $('#flashes').append($('
  • ').addClass(category).text(message)); - }; - - var scriptSrc = document.getElementById('receive-script').src; - var staticImgPath = scriptSrc.substr(0, scriptSrc.lastIndexOf('/') + 1).replace('js', 'img'); - - // Intercept submitting the form - $('#send').submit(function (event) { - event.preventDefault(); - - // Build the form data - var formData = new FormData(); - - // Files - var filenames = []; - var $fileSelect = $('#file-select'); - if ($fileSelect.length > 0) { - var files = $fileSelect.get(0).files; - for (var i = 0; i < files.length; i++) { - var file = files[i]; - filenames.push(file.name); - formData.append('file[]', file, file.name); - } - } - - // Text message - var $text = $('#text'); - if ($text.length > 0) { - formData.append("text", $text.val()) - } - - // Reset the upload form - $('#send').get(0).reset(); - - // Don't use jQuery for ajax request, because the upload progress event doesn't - // have access to the the XMLHttpRequest object - var ajax = new XMLHttpRequest(); - - ajax.upload.addEventListener('progress', function (event) { - // Update progress bar for this specific upload - if (event.lengthComputable) { - $('progress', ajax.$upload_div).attr({ - value: event.loaded, - max: event.total, - }); - } - - // If it's finished sending all data to the first Tor node, remove cancel button - // and update the status - if (event.loaded == event.total) { - $('.cancel', ajax.$upload_div).remove(); - $('.upload-status', ajax.$upload_div).html(' Waiting for data to finish traversing Tor network ...'); - } - }, false); - - ajax.addEventListener('load', function (event) { - // Remove the upload div - ajax.$upload_div.remove(); - - // Parse response - try { - var response = JSON.parse(ajax.response); - - // The 'new_body' response replaces the whole HTML document and ends - if ('new_body' in response) { - $('body').html(response['new_body']); - return; - } - - // Show error flashes - if ('error_flashes' in response) { - for (var i = 0; i < response['error_flashes'].length; i++) { - flash('error', response['error_flashes'][i]); - } - } - - // Show info flashes - if ('info_flashes' in response) { - for (var i = 0; i < response['info_flashes'].length; i++) { - flash('info', response['info_flashes'][i]); - } - } - } catch (e) { - flash('error', 'Invalid response from server: ' + data); - } - }, false); - - ajax.addEventListener('error', function (event) { - flash('error', 'Error uploading: ' + filenames.join(', ')); - - // Remove the upload div - ajax.$upload_div.remove() - }, false); - - ajax.addEventListener('abort', function (event) { - flash('error', 'Upload aborted: ' + filenames.join(', ')); - }, false); - - // Make the upload div - - /* The DOM for an upload looks something like this: -
    -
    - -
    educational-video.mp4, secret-plans.pdf
    -
    Sending to first Tor node ...
    -
    - -
    */ - var $progress = $('').attr({ value: '0', max: 100 }); - var $cancel_button = $('').addClass('cancel').attr({ type: 'button', value: 'Cancel' }); - var $upload_filename = $('
    ').addClass('upload-filename').text(filenames.join(', ')); - var $upload_status = $('
    ').addClass('upload-status').text('Sending data to initial Tor node ...'); - - var $upload_div = $('
    ') - .addClass('upload') - .append( - $('
    ').addClass('upload-meta') - .append($cancel_button) - .append($upload_filename) - .append($upload_status) - ) - .append($progress); - - $cancel_button.click(function () { - // Abort the upload, and remove the upload div - ajax.abort(); - $upload_div.remove() - }); - - ajax.$upload_div = $upload_div; - $('#uploads').append($upload_div); - - // Send the request - ajax.open('POST', '/upload-ajax', true); - ajax.send(formData); - }); -}); diff --git a/Resources/templates/receive.html b/Resources/templates/receive.html deleted file mode 100644 index 386f4ae..0000000 --- a/Resources/templates/receive.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - {% if title %}{{ title }}{% else %}{{ app_name }} Dropbox{% endif %} - - - - - - - - -
    - -

    {% if title %}{{ title }}{% else %}{{ app_name }} Dropbox{% endif %}

    -
    - -
    -

    - - {% if not disable_text and not disable_files %} -

    Submit Files or Messages

    -

    You can submit files, a message, or both.

    -

    Remember, you are accessing this service anonymously! Provide contact info if you want a response to the message.

    - {% endif %} - {% if not disable_text and disable_files %} -

    Submit Messages

    -

    You can submit a message.

    -

    Remember, you are accessing this service anonymously! Provide contact info if you want a response to the message.

    - {% endif %} - {% if disable_text and not disable_files %} -

    Submit Files

    -

    You can submit files

    - {% endif %} - -
    - -
    -
      - {% with messages = get_flashed_messages(with_categories=true) %} - {% if messages %} - {% for category, message in messages %} -
    • {{ message }}
    • - {% endfor %} - {% endif %} - {% endwith %} -
    -
    - -
    - {% if not disable_files %} -

    - {% endif %} - {% if not disable_text %} -

    - {% endif %} -

    -
    - -
    - - - - -