Skip to content

New Feature: Copy Deep-Link URL for Components and Nets#556

Open
dani007200964 wants to merge 4 commits into
openscopeproject:masterfrom
dani007200964:master
Open

New Feature: Copy Deep-Link URL for Components and Nets#556
dani007200964 wants to merge 4 commits into
openscopeproject:masterfrom
dani007200964:master

Conversation

@dani007200964

Copy link
Copy Markdown

Summary

Added copy functionality for generating properly encoded deep-link URLs to components and nets in Interactive HTML BOM.

ibom_link_example

Implementation Details

  • URL linking support: Nets and components can be linked via URL parameters (ibom.html?net="GND" or ibom.html?ref="R1")
  • Mode-specific copy buttons:
    • Copy icon/button added next to component references in ungrouped mode
    • Copy icon/button added next to net names in netlist mode
  • Proper encoding: All special characters (including +, spaces, quotes) are correctly URL-encoded using encodeURIComponent()
  • Clipboard integration: Generated URLs are automatically copied to clipboard

Examples

  • Component reference R12ibom.html?ref=R12
  • Net name +3V3ibom.html?net=%2B3V3
  • Net name "GND"ibom.html?net=%22GND%22

Usage

In ungrouped BOM mode, click the link icon next to component references to copy a deep-link URL. In netlist mode, click the link icon next to net names to copy a deep-link URL.

Motivation behind this feature

This feature provides flexibility for documentation generation and assembly reference without requiring screenshots. The implementation resolves encoding issues that would otherwise prevent proper deep-linking of special character names.

Demo

I also created a demo, to demonstrate the new features. The live demo found here: https://dani007200964.github.io/InteractiveHtmlBom-Deep-Linking-Demo/

Usage

You can create URL liks to components and nets like this:

  • Link to R1: ibom.html?ref=R1 -> link
  • Link to VCC: ibom.html?net=VCC -> link

Because html rules there are some specia characters, like + or - symbols and so on. It is really a pain, because PCB designs often has these characters( +3V3, -5V and so on... ). For this reason some URL woodoo is needed to 'escape' these characters. For this reason a copy link button added next to each net and component name, that makes things simple.

- Parse URL parameters in window.onload function to look for 'ref' or 'component' parameters
- Add selectComponentByReference() function that finds components by reference and triggers selection
- Use existing highlightHandlers and footprintIndexToHandler mechanisms
- Center the view on selected components using smoothScrollToRow()
- Handle gracefully when component references are not found
- Support both 'ref=' and 'component=' parameter names for flexibility

@qu1ck qu1ck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You need to urlencode the net name instead of adding quotes.
  2. You should use encoded (id, ref) pair instead of just reference for components. References are not always unique. Rely on id for uniqueness, double check that ref matches pcbdata for that id, show a warning if it does not. It can change between various board revisions and if someone uses stale link they will get a heads up.
  3. Make sure copy bom to clipboard does not insert "null"s instead of the deeplink button, best to just omit that element.

}

.copy-link-button {
font-size: 12px;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "em" based size

}

.copy-link-button:hover {
opacity: 0.7;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather have the transparency be reversed i.e. more opaque when hovered.

copyButton.className = "copy-link-button";
copyButton.title = "Copy deep-link URL";
copyButton.innerHTML = "🔗";
copyButton.style.cssText = "margin-left: 5px; font-size: 10pt; border: none; background: transparent; cursor: pointer; height: 100%";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are duplicated and overriding properties here, move everything to css.

e.stopPropagation();
var url = new URL(window.location.href);
url.searchParams.set("net", "\"" + currentNetname + "\"");
copyToClipboard(url.toString());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change window location to the url as well, will give more visual clues that the click action worked.

Comment on lines +746 to +765
// Add copy button for component references in ungrouped mode
if (settings.bommode === "ungrouped") {
var copyButton = document.createElement("button");
copyButton.className = "copy-link-button";
copyButton.title = "Copy deep-link URL";
copyButton.innerHTML = "🔗";
copyButton.style.cssText = "margin-left: 5px; font-size: 10pt; border: none; background: transparent; cursor: pointer; height: 100%";
var refName = references[0][0];
(function(currentRefname) {
copyButton.onclick = function(e) {
e.stopPropagation();
// Get the first reference to create URL (since we have multiple refs, we'll use the first one)
var url = new URL(window.location.href);
url.searchParams.set("ref", "\"" + currentRefname + "\"");
copyToClipboard(url.toString());

};
})(refName);
td.appendChild(copyButton);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of code duplication here with the copy button for nets. Extract it into a helper that creates button based on type (net/ref) and value (net name/ref name)

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.

2 participants