wordpress-turnstile

Wordpress paywall plugin
Log | Files | Refs | README | LICENSE

admin.js (1555B)


      1 /**
      2  * Admin JavaScript for Taler Turnstile
      3  */
      4 
      5 (function($) {
      6     'use strict';
      7 
      8     $(document).ready(function() {
      9 
     10         // Validate payment backend URL format
     11         $('input[name="taler_turnstile_payment_backend_url"]').on('blur', function() {
     12             var url = $(this).val().trim();
     13             if (url !== '' && !url.endsWith('/')) {
     14                 alert('Payment backend URL must end with a "/".');
     15             }
     16         });
     17 
     18         // Validate access token format
     19         $('input[name="taler_turnstile_access_token"]').on('blur', function() {
     20             var token = $(this).val().trim();
     21             if (token !== '' && !token.startsWith('secret-token:')) {
     22                 alert('Access token must begin with "secret-token:".');
     23             }
     24         });
     25 
     26         // Confirm deletion
     27         $('.delete-price-category').on('click', function(e) {
     28             if (!confirm('Are you sure you want to delete this price category?')) {
     29                 e.preventDefault();
     30                 return false;
     31             }
     32         });
     33 
     34         // Toggle subscription details
     35         $('.postbox .hndle').on('click', function() {
     36             $(this).closest('.postbox').toggleClass('closed');
     37         });
     38 
     39         // Add visual feedback for negative prices
     40         $('input[type="number"][min="0"]').on('input', function() {
     41             if (parseFloat($(this).val()) < 0) {
     42                 $(this).css('border-color', '#d63638');
     43             } else {
     44                 $(this).css('border-color', '');
     45             }
     46         });
     47     });
     48 
     49 })(jQuery);