This JavaScript library gives website users more ways to interact with written ITU call signs, including for amateur radio.
See a live example at https://phieri.github.io/callsign.js/
Upload callsign.js and callsign.css from src/ to the same directory on your web server and include the script on the page. The library creates a shadow root for each rendered call sign and loads the stylesheet beside the script automatically unless you override it with data-css-path.
<script id="callsign-js" src="callsign.js" defer></script>Tag the call signs with the custom HTML tag <call-sign>:
<p>I had contact with <call-sign>SM8AYA</call-sign> on shortwave.</p>Options can be set as attributes in the <script> tag.
| Name | Default | Description |
|---|---|---|
data-flag |
true |
Show a country flag before the call sign. |
data-monospace |
true |
Render the call sign with a monospace font. |
data-phonetic |
true |
Add phonetic information for screen readers and tooltips. |
data-search |
false |
Find and mark up untagged call signs in the document. |
data-css-path |
callsign.css beside the script |
Optional page-relative or absolute same-origin HTTP(S) stylesheet URL. Invalid or cross-origin overrides fall back to the default. |
The parser supports a 1–3 character alphanumeric prefix, one area digit, and a 1–3 letter suffix, optionally followed by /0–/9, /P, /M, /MM, /AM, or /QRP. Explicit tags accept lowercase text and display it in uppercase. Unsupported formats remain visible unchanged; arbitrary text inside a tag is never truncated to a partial match.
Automatic detection is deliberately uppercase-only and matches complete tokens, including next to punctuation. It skips existing <call-sign> elements; <script>, <style>, <code>, <pre>, <textarea>, <select>, <option>, <noscript>, and <template> elements; SVG and MathML; and elements with a contenteditable value other than false, including their descendants.
Prefix matching is a heuristic, not proof that a station is licensed. The bundled table is not a complete or continuously updated registry of all ITU assignments or DXCC entities. More-specific entries take priority (for example, HB0 for Liechtenstein and XX9 for Macau); other flags reflect the allocated country rather than a precise operating location. Formats such as EA8/W1AW and special-event calls outside the grammar are not automatically detected.
Elements created with document.createElement('call-sign') render when inserted and update when their text changes. Auto-search runs once on DOM readiness; after adding new untagged content, call window.Callsign.searchCallsigns() again. Repeated searches do not nest or duplicate tags. Options are read once from the script and are not reactive.
You can customize the appearance by overriding the CSS custom properties on the <call-sign> host element. These values flow into the shadow DOM that wraps each rendered call sign:
call-sign {
--cs-border-color: #007acc;
--cs-background-color: #e0f0ff;
--cs-border-radius: 5px;
}The project uses Jest for unit tests, ESLint for code quality checks, and manual browser validation for the rendered shadow-DOM output.
# Install dependencies
npm install
# Run all tests
npm test
# Run linting
npm run lintThe current suite covers the library's core behavior in browser-like conditions:
- call sign parsing and validation
- country prefix lookups and flag generation
- phonetic expansion
- auto-detection of untagged call signs in text content
The test files are located in the tests/ directory.
For browser validation, run python3 -m http.server 8081 from the repository root and open http://localhost:8081/test-validation.html. Check flags, phonetic labels/tooltips, monospace styling, portable indicators, and auto-detected elements. Use HTTP rather than file://. There is no build step or hardware dependency; GitHub Pages deployment copies src/ assets into docs/.
The files are intentionally not provided minified. Amateur radio is about learning and experimenting. Minified files makes it drastically harder to understand the code.
The PREFIX_TABLE mapping is a bundled subset of allocations. Consult the current ITU call sign series table when updating it:
- ITU Radio Regulations Appendix 42 – Table of allocation of international call sign series - Official ITU allocation table
- ITU Radiocommunication Bureau Circular - Current call sign assignments and updates
- ARRL International Call Sign Series - Comprehensive amateur radio call sign reference
- ITU Master International Frequency Register (MIFR) - Official frequency and call sign database
- Country-specific amateur radio licensing authorities - National regulatory bodies via IARU member societies
- Radio-Electronics.com Call Sign Database - Cross-reference for prefix verification
- ITU Radio Regulations Article 19 – Identification of stations
- ITU prefix – Wikipedia
- International Amateur Radio Union (IARU) - Global amateur radio coordination