Skip to content

phieri/callsign.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

292 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

callsign.js

This JavaScript library gives website users more ways to interact with written ITU call signs, including for amateur radio.

Demo

See a live example at https://phieri.github.io/callsign.js/

Usage

Upload callsign.js and callsign.css to your web server and include the script on the page. The library creates a shadow root for each rendered call sign and injects the stylesheet 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

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 Path to the stylesheet that the library injects into each shadow root.

Customization

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;
}

Testing

The project uses Jest for unit tests, ESLint for code quality checks, and manual browser validation for the rendered shadow-DOM output.

Running Tests

# Install dependencies
npm install

# Run all tests
npm test

# Run linting
npm run lint

Test Coverage

The 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.

Minification

The files are intentionally not provided minified. Amateur radio is about learning and experimenting. Minified files makes it drastically harder to understand the code.

References

ITU Prefix Table Data Sources

The PREFIX_TABLE mapping in this library is compiled from multiple authoritative sources to ensure accuracy across all 160 countries:

General References

About

📻 Highlight call signs in web pages with this JavaScript library

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Contributors