From a7da3cd6a0f847820efd71a7aa2f58fb4fcf05a0 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Sat, 16 Apr 2011 22:56:40 +0200 Subject: [PATCH] basic file upload reimplemented --- files/css/files.css | 8 ++++++++ files/index.php | 1 + files/js/files.js | 21 +++++++++++++++++++++ files/templates/index.php | 14 +++++++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/files/css/files.css b/files/css/files.css index 8ab07d45241..160c9307409 100644 --- a/files/css/files.css +++ b/files/css/files.css @@ -19,6 +19,14 @@ text-decoration: none; } +#file_upload_form { + display: none; +} + +#file_upload_target { + display: none; +} + /* FILE TABLE */ table td.filesize, table td.date diff --git a/files/index.php b/files/index.php index a68ae9c0bb4..7f6a11ff03c 100644 --- a/files/index.php +++ b/files/index.php @@ -59,6 +59,7 @@ foreach( explode( "/", $dir ) as $i ){ $tmpl = new OC_TEMPLATE( "files", "index", "user" ); $tmpl->assign( "files", $files ); $tmpl->assign( "breadcrumb", $breadcrumb ); +$tmpl->assign( 'dir', $dir); $tmpl->printPage(); ?> diff --git a/files/js/files.js b/files/js/files.js index 9ab573ee92b..ba08e254349 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -36,4 +36,25 @@ $(document).ready(function() { // Uncheck all $('.browser input:checkbox').attr('checked', false); }); + + // Shows and hides file upload form + $('#file_upload_button').toggle(function() { + $('#file_upload_form').css({"display":"block"}); + }, function() { + $('#file_upload_form').css({"display":"none"}); + }); + + $('#file_upload_start').click(function() { + $('#file_upload_target').load(uploadFinished); + }); }); + +function uploadFinished() { + result = $('#file_upload_target').contents().text(); + result = eval("(" + result + ");"); + if(result.status == "error") { + alert('An error occcured, upload failed.'); + } else { + location.href = 'index.php?dir=' + $('#dir').val(); + } +} diff --git a/files/templates/index.php b/files/templates/index.php index f1fdafc27cc..94d3769c9ac 100644 --- a/files/templates/index.php +++ b/files/templates/index.php @@ -7,8 +7,20 @@

- UploadNew folderDownloadDelete + UploadNew folderDownloadDelete

+
+
" id="dir">
+