Created
November 5, 2025 12:56
-
-
Save timolaine/01d9619b89a2f9aed5a99d94f523759e to your computer and use it in GitHub Desktop.
Add consecutive ID to selection in #jArchi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Add consecutive ID to selection | |
| * (c) 2025 Timo Laine www.timoroso.com | |
| */ | |
| console.log("Add consecutive ID to selection"); | |
| var propName = window.prompt("To which property do you want to add a consecutive ID for selected elements or relations? (leave empty to cancel)?", ""); | |
| if (propName) { | |
| var initialValue = window.prompt("Which value do you want to set for the initial value (leave empty to cancel)?", "0"); | |
| if (initialValue) { | |
| var idlength = $(selection).size().toString().length; | |
| var propValue = Number(initialValue); | |
| $(selection).each(function(sel) { | |
| var propString = propValue.toString(); | |
| while (propString.length < idlength) { | |
| propString = "0" + propString; | |
| } | |
| sel.prop(propName, propString); | |
| propValue = propValue + 1; | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment