Просмотр исходного кода

- fixing JS errors when syntax highlighting is disabled (point 1. #15)
- fixing missing url conversion in highlighted text (point 2. # 15)

El RIDO 11 лет назад
Родитель
Сommit
be91afa042
1 измененных файлов с 7 добавлено и 3 удалено
  1. 7 3
      js/zerobin.js

+ 7 - 3
js/zerobin.js

@@ -192,8 +192,10 @@ function displayMessages(key, comments) {
     }
     }
     setElementText($('#cleartext'), cleartext);
     setElementText($('#cleartext'), cleartext);
     setElementText($('#prettyprint'), cleartext);
     setElementText($('#prettyprint'), cleartext);
-    urls2links($('#cleartext')); // Convert URLs to clickable links.
-    prettyPrint();
+    // Convert URLs to clickable links.
+    urls2links($('#cleartext'));
+    urls2links($('#prettyprint'));
+    if (typeof prettyPrint == 'function') prettyPrint();
 
 
     // Display paste expiration.
     // Display paste expiration.
     if (comments[0].meta.expire_date) $('#remainingtime').removeClass('foryoureyesonly').text('This document will expire in '+secondsToHuman(comments[0].meta.remaining_time)+'.').removeClass('hidden');
     if (comments[0].meta.expire_date) $('#remainingtime').removeClass('foryoureyesonly').text('This document will expire in '+secondsToHuman(comments[0].meta.remaining_time)+'.').removeClass('hidden');
@@ -354,9 +356,11 @@ function send_data() {
 
 
             setElementText($('#cleartext'), $('#message').val());
             setElementText($('#cleartext'), $('#message').val());
             setElementText($('#prettyprint'), $('#message').val());
             setElementText($('#prettyprint'), $('#message').val());
+            // Convert URLs to clickable links.
             urls2links($('#cleartext'));
             urls2links($('#cleartext'));
+            urls2links($('#prettyprint'));
             showStatus('');
             showStatus('');
-            prettyPrint();
+            if (typeof prettyPrint == 'function') prettyPrint();
         }
         }
         else if (data.status==1) {
         else if (data.status==1) {
             showError('Could not create paste: '+data.message);
             showError('Could not create paste: '+data.message);