Procházet zdrojové kódy

fixing error message display revealed by testing remaining time display function

El RIDO před 8 roky
rodič
revize
73bc685178
4 změnil soubory, kde provedl 46 přidání a 4 odebrání
  1. 2 2
      js/privatebin.js
  2. 42 0
      js/test.js
  3. 1 1
      tpl/bootstrap.php
  4. 1 1
      tpl/page.php

+ 2 - 2
js/privatebin.js

@@ -1365,7 +1365,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
                     ];
                     ];
 
 
                 Alert.showRemaining([expirationLabel, expiration[0]]);
                 Alert.showRemaining([expirationLabel, expiration[0]]);
-                $remainingTime.removeClass('foryoureyesonly')
+                $remainingTime.removeClass('foryoureyesonly');
             } else {
             } else {
                 // never expires
                 // never expires
                 return;
                 return;
@@ -3982,7 +3982,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
             Uploader.setUnencryptedData('deletetoken', deleteToken);
             Uploader.setUnencryptedData('deletetoken', deleteToken);
 
 
             Uploader.setFailure(function () {
             Uploader.setFailure(function () {
-                Controller.showError(I18n._('Could not delete the paste, it was not stored in burn after reading mode.'));
+                Alert.showError(I18n._('Could not delete the paste, it was not stored in burn after reading mode.'));
             })
             })
             Uploader.run();
             Uploader.run();
         }
         }

+ 42 - 0
js/test.js

@@ -1198,5 +1198,47 @@ describe('PasteStatus', function () {
             }
             }
         );
         );
     });
     });
+
+    describe('showRemainingTime', function () {
+        this.timeout(30000);
+        before(function () {
+            cleanup();
+        });
+
+        jsc.property(
+            'shows burn after reading message or remaining time',
+            'bool',
+            'nat',
+            jsc.nearray(jsc.elements(a2zString)),
+            jsc.nearray(jsc.elements(a2zString)),
+            jsc.array(jsc.elements(queryString)),
+            'string',
+            function (
+                burnafterreading, remaining_time,
+                schema, address, query, fragment
+            ) {
+                var clean = jsdom('', {
+                        url: schema.join('') + '://' + address.join('') +
+                             '/?' + queryString + '#' + fragment
+                    });
+                $('body').html('<div id="remainingtime" class="hidden"></div>');
+                $.PrivateBin.PasteStatus.init();
+                $.PrivateBin.PasteStatus.showRemainingTime({
+                    'burnafterreading': burnafterreading,
+                    'remaining_time': remaining_time,
+                    'expire_date': ((new Date()).getTime() / 1000) + remaining_time
+                });
+                if (burnafterreading) {
+                    var result = $('#remainingtime').hasClass('foryoureyesonly') &&
+                                !$('#remainingtime').hasClass('hidden');
+                } else {
+                    var result =!$('#remainingtime').hasClass('foryoureyesonly') &&
+                                !$('#remainingtime').hasClass('hidden');
+                }
+                clean();
+                return result;
+            }
+        );
+    });
 });
 });
 
 

+ 1 - 1
tpl/bootstrap.php

@@ -69,7 +69,7 @@ if ($MARKDOWN):
 <?php
 <?php
 endif;
 endif;
 ?>
 ?>
-		<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-o8cPnAUDs/kjS8bCGGJk43T9OCGpS3qaJny4xvMMXzWV4jvoXB8GKWlHeRe3mb5MagYcu1rkmcyN9mP1TqE6ng==" crossorigin="anonymous"></script>
+		<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-cOGGzUWy00SQ6bKzceNOd9+tGo584PTWclR+J+uQE7Rux/jkJVW6yEj7sbIIoalACxC+8QngzxdEfpy8iO9CkA==" crossorigin="anonymous"></script>
 		<!--[if lt IE 10]>
 		<!--[if lt IE 10]>
 		<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
 		<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
 		<![endif]-->
 		<![endif]-->

+ 1 - 1
tpl/page.php

@@ -47,7 +47,7 @@ if ($MARKDOWN):
 <?php
 <?php
 endif;
 endif;
 ?>
 ?>
-		<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-o8cPnAUDs/kjS8bCGGJk43T9OCGpS3qaJny4xvMMXzWV4jvoXB8GKWlHeRe3mb5MagYcu1rkmcyN9mP1TqE6ng==" crossorigin="anonymous"></script>
+		<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-cOGGzUWy00SQ6bKzceNOd9+tGo584PTWclR+J+uQE7Rux/jkJVW6yEj7sbIIoalACxC+8QngzxdEfpy8iO9CkA==" crossorigin="anonymous"></script>
 		<!--[if lt IE 10]>
 		<!--[if lt IE 10]>
 		<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
 		<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
 		<![endif]-->
 		<![endif]-->