diff --git a/assets/donate/donate.js b/assets/donate/donate.js index 533d8bd..e6931a8 100644 --- a/assets/donate/donate.js +++ b/assets/donate/donate.js @@ -79,7 +79,7 @@ bar.setAttribute('aria-valuenow', String(pct)); bar.setAttribute('aria-valuetext', p.reached ? (PT.reached || '') : of + ' (' + pct + '%)'); bar.setAttribute('aria-label', String(PT.label || '%s').replace('%s', function () { return p.title; })); - bar.firstChild.style.width = pct + '%'; + bar.firstChild.style.width = ((pct < 2 && (parseInt(p.raised_minor, 10) || 0) > 0) ? 2 : pct) + '%'; box.querySelector('.sg-progress-amounts').textContent = of; box.querySelector('.sg-progress-pct').textContent = pct + '%'; var tier = box.querySelector('.sg-progress-tier'), done = box.querySelector('.sg-progress-done'); @@ -110,7 +110,7 @@ refreshAll(true); // a cached page may hold old numbers } // After a successful donation: refresh now, and again shortly (a pending capture can finalize a moment later). - function afterDonation() { refreshAll(true); setTimeout(function () { refreshAll(true); }, 5000); } + function afterDonation() { refreshAll(true); [1500, 5000, 12000].forEach(function (ms) { setTimeout(function () { refreshAll(true); }, ms); }); } function init(root) { var pinned = parseInt(root.getAttribute('data-goal'), 10) || 0; diff --git a/includes/Overlay/Progress.php b/includes/Overlay/Progress.php index 1291000..ff28b3f 100644 --- a/includes/Overlay/Progress.php +++ b/includes/Overlay/Progress.php @@ -76,13 +76,14 @@ final class Progress { public static function html( array $p, array $labels ): string { $e = static fn( string $s ): string => htmlspecialchars( $s, ENT_QUOTES, 'UTF-8' ); $pct = max( 0, min( 100, (int) $p['percent'] ) ); + $fill = ( $pct < 2 && (int) ( $p['raised_minor'] ?? 0 ) > 0 ) ? 2 : $pct; // a first small donation still shows $sub = static fn( string $tpl, array $v ): string => (string) preg_replace_callback( '/%(\d)\$s/', static fn( array $m ): string => $v[ (int) $m[1] - 1 ] ?? '', $tpl ); $of = $sub( $labels['of'] ?? '%1$s / %2$s', array( $p['raised_display'], $p['target_display'] ) ); $out = '
'; $out .= '
' - . '
'; + . '
'; $out .= '
' . $e( $of ) . ' ' . $pct . '%
'; $out .= '

' . ( $p['tier'] ? $e( $sub( $labels['tier'] ?? '%1$s (%2$s)', array( $p['tier']['title'], $p['tier']['target_display'] ) ) ) : '' ) . '

'; diff --git a/includes/Rest/DonateController.php b/includes/Rest/DonateController.php index c54543e..e8da5e7 100644 --- a/includes/Rest/DonateController.php +++ b/includes/Rest/DonateController.php @@ -85,6 +85,7 @@ final class DonateController { $res = rest_ensure_response( self::progress_for( $goal ) ); // Short shared cache lets a CDN collapse bursts; the page JS adds a cache-busting parameter after a donation. $res->header( 'Cache-Control', 'public, max-age=10, s-maxage=10' ); + $res->header( 'X-LiteSpeed-Cache-Control', 'no-cache' ); // LiteSpeed would otherwise hold REST responses for days return $res; }