diff --git a/docs/JAVASCRIPT.md b/docs/JAVASCRIPT.md index 7e4e9ea..df45336 100644 --- a/docs/JAVASCRIPT.md +++ b/docs/JAVASCRIPT.md @@ -8,17 +8,12 @@ This project minimizes JavaScript usage, preferring pure CSS solutions where pos - Use `
` elements for toggles instead of JS - External SDKs loaded only when payment method is enabled - No build step - vanilla JS only -- jQuery used minimally (legacy, being phased out) +- No jQuery - all vanilla JavaScript ## Static JavaScript Files Located in `make_post_sell/static/js/`: -### jquery-3.6.0.min.js -- jQuery library (legacy dependency) -- Used by: Stripe card form, markdown preview -- Loaded via `snippets/optional-javascript.j2` and `snippets/stripe.j2` - ### qrcode.min.js - QRious library for QR code generation - Used by: Crypto checkout page @@ -27,7 +22,7 @@ Located in `make_post_sell/static/js/`: ### custom.js - Markdown preview functionality - Functions: `previewAjax()`, `sendPreview()` -- Uses jQuery for AJAX calls to `/markup-editor-preview` +- Uses fetch API for AJAX calls to `/markup-editor-preview` ## Inline JavaScript by Template @@ -43,7 +38,7 @@ Located in `make_post_sell/static/js/`: - Crypto wallets toggle (checkbox + localStorage) - Theme preview for shop default theme radio buttons -- Note: Payment provider toggles now use pure CSS `
` elements +- Note: Payment provider toggles use pure CSS `
` elements ### user_settings.j2 **Purpose:** User theme preference sync @@ -80,7 +75,7 @@ Located in `make_post_sell/static/js/`: - Loads Stripe.js SDK - Creates Payment Element for card input - Handles `stripe.confirmSetup()` flow -- Requires jQuery +- Uses vanilla JS with `DOMContentLoaded` ### snippets/analytics.j2 **Purpose:** Analytics tracking (optional) @@ -92,7 +87,7 @@ Located in `make_post_sell/static/js/`: ### snippets/optional-javascript.j2 **Purpose:** Optional JS loading -- Loads jQuery and custom.js async +- Loads custom.js async - Used for markdown preview functionality ## External SDKs @@ -119,6 +114,5 @@ Pages work without JavaScript where possible: ## Future Improvements -- Remove jQuery dependency (replace with vanilla JS) - Convert remaining checkbox toggles to `
` elements - Consider removing Google Analytics option (privacy) diff --git a/make_post_sell/static/js/custom.js b/make_post_sell/static/js/custom.js index c225e91..de4c251 100644 --- a/make_post_sell/static/js/custom.js +++ b/make_post_sell/static/js/custom.js @@ -1,30 +1,52 @@ -// post_preview -// previewTimer must live outside the functions. +// Markdown preview functionality (vanilla JS, no jQuery) var previewTimer = null; -function previewAjax(textarea, div, show_raw = false){ - // set div to raw textarea while waiting for remote Markdown rendering. +function previewAjax(textareaId, divId, show_raw = false) { + var textarea = document.getElementById(textareaId); + var div = document.getElementById(divId); + + if (!textarea || !div) return; + + // Show raw textarea content while waiting for server-rendered Markdown if (show_raw) { - // bust HTML tags like diff --git a/make_post_sell/templates/snippets/stripe.j2 b/make_post_sell/templates/snippets/stripe.j2 index 49b0d04..69255a1 100644 --- a/make_post_sell/templates/snippets/stripe.j2 +++ b/make_post_sell/templates/snippets/stripe.j2 @@ -42,7 +42,6 @@ {% macro new_card() %} -
{% include 'snippets/csrf.j2' %} @@ -51,13 +50,10 @@
- - + - @@ -66,49 +62,31 @@
{% endmacro %}