]> git.p6c8.net - jirafeau_project.git/commitdiff
lib: simplify link deisplay function
authorJerome Jutteau <mojo@couak.net>
Sat, 25 Apr 2015 09:21:49 +0000 (11:21 +0200)
committerJerome Jutteau <mojo@couak.net>
Sat, 25 Apr 2015 09:26:35 +0000 (11:26 +0200)
why this was so complicated ?

Signed-off-by: Jerome Jutteau <mojo@couak.net>
index.php
lib/functions_v5.js [moved from lib/functions_v4.js with 94% similarity]
lib/template/header.php

index dade552fd4940c8844c5b90950ba3bc7b34b4d78..e06086fec7c5534ec602f5d27edcfbf466554e3d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -103,12 +103,6 @@ if (jirafeau_has_upload_password ($cfg))
     <br />
     </div>
 
     <br />
     </div>
 
-    <div id="upload_password_page">
-    <p><?php echo t('Download page') ?>:</p>
-    <p><a id="password_link" href=""></a></p>
-    <br />
-    </div>
-
     <?php if ($cfg['preview'] == true) { ?>
     <div id="upload_finished_preview">
     <p><?php echo t('View link') ?>:</p>
     <?php if ($cfg['preview'] == true) { ?>
     <div id="upload_finished_preview">
     <p><?php echo t('View link') ?>:</p>
similarity index 94%
rename from lib/functions_v4.js
rename to lib/functions_v5.js
index 801489cf2baeae4e3b09a22b0428ff0a8ceb857e..031e7f410b8dd52e17ecf0fee4ede03f4db21b5d 100644 (file)
 
 function show_link (url, reference, delete_code, crypt_key, date)
 {
 
 function show_link (url, reference, delete_code, crypt_key, date)
 {
-    // Download page if element exists
+    // Upload finished
+    document.getElementById('uploading').style.display = 'none';
+    document.getElementById('upload').style.display = 'none';
+    document.getElementById('upload_finished').style.display = '';
+    document.title = 'Jirafeau - 100%';
+
+    // Download page
     var download_link = url + 'f.php?h=' + reference;
     var download_link_href = url + 'f.php?h=' + reference;
     if (crypt_key.length > 0)
     var download_link = url + 'f.php?h=' + reference;
     var download_link_href = url + 'f.php?h=' + reference;
     if (crypt_key.length > 0)
@@ -32,7 +38,22 @@ function show_link (url, reference, delete_code, crypt_key, date)
         document.getElementById('upload_link').href = download_link_href;
     }
 
         document.getElementById('upload_link').href = download_link_href;
     }
 
-    // Is the preview allowed ?
+    // Delete link
+    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('delete_link').innerHTML = delete_link;
+    document.getElementById('delete_link').href = delete_link_href;
+
+    // Validity date
+    if (date)
+    {
+        document.getElementById('date').innerHTML = date;
+        document.getElementById('validity').style.display = '';
+    }
+    else
+        document.getElementById('validity').style.display = 'none';
+
+    // Preview link (if allowed)
     if (!!document.getElementById('preview_link'))
     {
         document.getElementById('upload_finished_preview').style.display = 'none';
     if (!!document.getElementById('preview_link'))
     {
         document.getElementById('upload_finished_preview').style.display = 'none';
@@ -57,52 +78,25 @@ function show_link (url, reference, delete_code, crypt_key, date)
          }
     }
 
          }
     }
 
-    // Only show link to password page if password is set
-    document.getElementById('upload_password_page').style.display = 'none';
-    if (document.getElementById('input_key').value.length > 0)
-    {
-        if (!!document.getElementById('upload_finished_download_page'))
-            document.getElementById('upload_finished_download_page').style.display = 'none';
-        document.getElementById('upload_password_page').style.display = '';
-        if (!!document.getElementById('upload_finished_preview'))
-            document.getElementById('upload_finished_preview').style.display = 'none';
-        document.getElementById('upload_direct_download').style.display = 'none';
-
-        document.getElementById('password_link').innerHTML = download_link;
-        document.getElementById('password_link').href = download_link_href;
-    }
     // Direct download link
     // Direct download link
-    else
+    var direct_download_link = url + 'f.php?h=' + reference + '&amp;d=1';
+    var direct_download_link_href = url + 'f.php?h=' + reference + '&d=1';
+    if (crypt_key.length > 0)
     {
     {
-        var direct_download_link = url + 'f.php?h=' + reference + '&amp;d=1';
-        var direct_download_link_href = url + 'f.php?h=' + reference + '&d=1';
-        if (crypt_key.length > 0)
-        {
-            direct_download_link += '&amp;k=' + crypt_key;
-            direct_download_link_href += '&k=' + crypt_key;
-        }
-        document.getElementById('direct_link').innerHTML = direct_download_link;
-        document.getElementById('direct_link').href = direct_download_link_href;
+        direct_download_link += '&amp;k=' + crypt_key;
+        direct_download_link_href += '&k=' + crypt_key;
     }
     }
+    document.getElementById('direct_link').innerHTML = direct_download_link;
+    document.getElementById('direct_link').href = direct_download_link_href;
 
 
-    // Delete link
-    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('delete_link').innerHTML = delete_link;
-    document.getElementById('delete_link').href = delete_link_href;
 
 
-    if (date)
+    // Hide preview and direct download link if password is set
+    if (document.getElementById('input_key').value.length > 0)
     {
     {
-        document.getElementById('date').innerHTML = date;
-        document.getElementById('validity').style.display = '';
+        if (!!document.getElementById('preview_link'))
+            document.getElementById('upload_finished_preview').style.display = 'none';
+        document.getElementById('upload_direct_download').style.display = 'none';
     }
     }
-    else
-        document.getElementById('validity').style.display = 'none';
-
-    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 (percentage, speed, time_left)
 }
 
 function show_upload_progression (percentage, speed, time_left)
index 83cc6ba5796d8dde5f8d42ae9e17a58131521308..2aab081eaa60b4a7b84e72b47202f2907f77716b 100644 (file)
@@ -35,6 +35,6 @@ else
   <link href="<?php echo $web_root . 'media/' . $style . '/style.css.php'; ?>" rel="stylesheet" type="text/css" />
 </head>
 <body>
   <link href="<?php echo $web_root . 'media/' . $style . '/style.css.php'; ?>" rel="stylesheet" type="text/css" />
 </head>
 <body>
-<script language="Javascript" src="lib/functions_v4.js"></script>
+<script language="Javascript" src="lib/functions_v5.js"></script>
 <div id="content">
 <h1><a href="<?php echo $web_root; ?>"><?php echo t('Jirafeau, your web file repository'); ?></a></h1>
 <div id="content">
 <h1><a href="<?php echo $web_root; ?>"><?php echo t('Jirafeau, your web file repository'); ?></a></h1>

patrick-canterino.de