Skip to content

Glossary and contributor wall duplicate the same fetch-render-filter logic #53

Description

@pushpam2404

Context

js/wall.js and js/glossary.js are the same program twice: fetch JSON, sort, render a list, filter on input, show a count, show an error if the fetch fails. The duplicate escapeHtml is the clearest symptom. A fix to one will not reach the other.

What to change

Files: js/wall.js, js/glossary.js, a new shared file

Requirements:

  • Extract the shared behaviour into one module both pages use
  • Keep the two pages rendering differently — the card markup is genuinely different and should stay so
  • No build step. Plain scripts, loaded with <script>, as everything else on this site is
  • Both pages must behave exactly as they do now

Acceptance criteria

  • escapeHtml exists in exactly one place
  • Both pages load, render, filter and count as before
  • The error path still works — test by renaming the JSON
  • No build tooling introduced
  • Net lines of code go down

How to verify locally

python3 -m http.server 8000

Then open http://localhost:8000.

Difficulty

Intermediate. Good practice at refactoring without changing behaviour.


New here? Comment /claim on this issue and a bot will assign it to you. Then read CONTRIBUTING.md.

Stuck at any point? Comment here saying what you have tried and where it stopped working — that is not an admission of failure, it is how we find out the instructions were unclear. You can also come to a PR Debug Clinic (Oct 12 or Oct 21).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions