Skip to content

Commit

Permalink
Make NN parsing work on uppercase NNs (#51)
Browse files Browse the repository at this point in the history
This makes nn713, OR NN713 work.
  • Loading branch information
WillNilges authored Dec 10, 2023
1 parent 30ac088 commit dc7b1c8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions static/scripts/parse_nn.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
window.onload = function() {
// Define a regular expression to match the "nn713" format
var regex = /nn(\d+)/g;
var capRegex = /NN(\d+)/g;

// Get the HTML content of the entire page
var pageContent = document.body.innerHTML;

// Replace all occurrences of "nn713" with the link
var replacedContent = pageContent.replace(regex, function(match, number) {
return '<a target="_blank" href="https://www.nycmesh.net/map/nodes/' + number + '">' + match + '</a>';
});
var replacedContent = pageContent.replace(regex, parseNode);
replacedContent = replacedContent.replace(capRegex, parseNode);

// Update the HTML content of the page with the modified content
document.body.innerHTML = replacedContent;
};
};

function parseNode(match, number) {
return '<a target="_blank" href="https://www.nycmesh.net/map/nodes/' + number + '">' + match + '</a>';
}

0 comments on commit dc7b1c8

Please sign in to comment.