X-Git-Url: https://git.p6c8.net/jirafeau_mojo42.git/blobdiff_plain/f89474388394d7a7fd7dbb41f089956454e4957f..0a8d6bb0971bfbae457dd740da4797dc5e295c5c:/lib/functions.js?ds=inline

diff --git a/lib/functions.js b/lib/functions.js
index fee0b50..24c7df3 100755
--- a/lib/functions.js
+++ b/lib/functions.js
@@ -16,13 +16,21 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-function show_link (url, reference, delete_code, date)
+function show_link (url, reference, delete_code, crypt_key, date)
 {
-    var download_link = url + 'file.php?h=' + reference;
-    var delete_link = download_link + '&amp;d=' + delete_code;
-    var delete_link_href = download_link + '&d=' + delete_code;
+    var download_link = url + 'f.php?h=' + reference;
+    var download_link_href = url + 'f.php?h=' + reference;
+    if (crypt_key.length > 0)
+    {
+        download_link += '&amp;k=' + crypt_key;
+        download_link_href += '&k=' + crypt_key;
+    }
+
+    var delete_link = url + 'f.php?h=' + reference + '&amp;d=' + delete_code;
+    var delete_link_href = url + 'f.php?h=' + reference + '&d=' + delete_code;
+
     document.getElementById('upload_link').innerHTML = download_link;
-    document.getElementById('upload_link').href = download_link;
+    document.getElementById('upload_link').href = download_link_href;
     document.getElementById('delete_link').innerHTML = delete_link;
     document.getElementById('delete_link').href = delete_link_href;
     if (date)
@@ -36,6 +44,7 @@ function show_link (url, reference, delete_code, date)
     document.getElementById('uploading').style.display = 'none';
     document.getElementById('upload').style.display = 'none';
     document.getElementById('upload_finished').style.display = '';
+    document.title = 'Jirafeau - 100%';
 }
 
 function show_upload_progression (p)
@@ -51,8 +60,11 @@ function upload_progress (e)
     /* Show the user the operation do not reach 100%, the server need time
      * to give a response before providing the link.
      */
-    var p = Math.round (e.loaded * 99 / e.total);
-    show_upload_progression (p.toString() + '%');
+    var p = Math.round (e.loaded * 100 / e.total);
+    if (p == 100)
+        show_upload_progression (' ');
+    else
+        show_upload_progression (p.toString() + '%');
 }
 
 function upload_failed (e)
@@ -90,10 +102,10 @@ function classic_upload (url, file, time, password, one_time)
                     d.setSeconds (d.getSeconds() + 2419200);
                 else
                     return;
-                show_link (url, res[0], res[1], d.toString());
+                show_link (url, res[0], res[1], res[2], d.toString());
             }
             else
-                show_link (url, res[0], res[1]);
+                show_link (url, res[0], res[1], res[2]);
         }
     }
     req.open ("POST", url + 'script.php' , true);
@@ -166,8 +178,11 @@ function async_upload_progress (e)
 {
     if (!e.lengthComputable && async_global_file.size != 0)
         return;
-    var p = Math.round ((e.loaded + async_global_transfered) * 99 / (async_global_file.size));
-    show_upload_progression (p.toString() + '%');
+    var p = Math.round ((e.loaded + async_global_transfered) * 100 / (async_global_file.size));
+    if (p == 100)
+        show_upload_progression (' ');
+    else
+        show_upload_progression (p.toString() + '%');
 }
 
 function async_upload_push (code)
@@ -196,7 +211,7 @@ function async_upload_push (code)
     }
     req.open ("POST", async_global_url + 'script.php?push_async' , true);
 
-    var chunk_size = parseInt (async_global_max_size * 0.90);
+    var chunk_size = parseInt (async_global_max_size * 0.50);
     var start = async_global_transfered;
     var end = start + chunk_size;
     if (end >= async_global_file.size)
@@ -239,10 +254,10 @@ function async_upload_end (code)
                     d.setSeconds (d.getSeconds() + 2419200);
                 else
                     return;
-                show_link (async_global_url, res[0], res[1], d.toString());
+                show_link (async_global_url, res[0], res[1], res[2], d.toString());
             }
             else
-                show_link (async_global_url, res[0], res[1]);
+                show_link (async_global_url, res[0], res[1], res[2]);
         }
     }
     req.open ("POST", async_global_url + 'script.php?end_async' , true);