Skip to content

Refactor json-string-extractor.html to use fragment ID for loading example#71

Merged
simonw merged 3 commits intomainfrom
copilot/refactor-json-string-extractor
Oct 18, 2025
Merged

Refactor json-string-extractor.html to use fragment ID for loading example#71
simonw merged 3 commits intomainfrom
copilot/refactor-json-string-extractor

Conversation

Copy link
Contributor

Copilot AI commented Oct 18, 2025

Refactored the "Load example JSON" functionality to reuse the existing Gist loading mechanism via fragment IDs instead of having a separate function that fetches the example.

Previously, clicking "Load example JSON" triggered an async function that directly fetched a Gist URL. Now it simply links to #gist=1d1013ba059af76461153722005a039d, which leverages the existing loadGistFromHash() mechanism.

Changes:

  • Converted the "Load example JSON" button to a link with fragment ID #gist=1d1013ba059af76461153722005a039d
  • Removed the loadExampleJSON() function (22 lines)
  • Added a hashchange event listener to trigger Gist loading when the fragment changes
  • Removed the button's event listener that called the old function

This makes the code more consistent and reduces duplication by reusing the existing Gist loading infrastructure.

Fixes #69

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor json-string-extractor.html</issue_title>
<issue_description>The loadExampleJSON function should reuse the new mechanism. That load example should just link to the page with the fragment ID.

Refs:

<agent_instructions>Don't bother updating the markdown documentation, just change the html file</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #70


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: simonw <9599+simonw@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 18, 2025

Deploying tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: df11d7c
Status: ✅  Deploy successful!
Preview URL: https://d698702a.tools-b1q.pages.dev
Branch Preview URL: https://copilot-refactor-json-string.tools-b1q.pages.dev

View logs

Co-authored-by: simonw <9599+simonw@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor loadExampleJSON function in json-string-extractor.html Refactor json-string-extractor.html to use fragment ID for loading example Oct 18, 2025
Copilot AI requested a review from simonw October 18, 2025 18:23
@simonw
Copy link
Owner

simonw commented Oct 18, 2025

@simonw simonw marked this pull request as ready for review October 18, 2025 19:03
@simonw simonw merged commit 6fbfc69 into main Oct 18, 2025
1 check passed
@simonw simonw deleted the copilot/refactor-json-string-extractor branch October 18, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor json-string-extractor.html

2 participants