Skip to content

Instantly share code, notes, and snippets.

@EliJDonahue
Created November 2, 2016 23:41
Show Gist options
  • Save EliJDonahue/30c32c047838a6bec44cbf1e41d259c9 to your computer and use it in GitHub Desktop.
Save EliJDonahue/30c32c047838a6bec44cbf1e41d259c9 to your computer and use it in GitHub Desktop.
[ArasLabs/custom-form-css] Show contents of custom_icon form field
<img id="myIcon" name="myIcon" src="../customer/svg/package.svg" vspace="20" hspace="20" />
<script>
chooseIcon = function()
{
var icn = "../customer/svg/";
// get classification, gets "none" if getProperty returns null
var thisItem = document.thisItem;
var classification = thisItem.getProperty("classification","none");
// get icon fields
var defIcon = document.getElementById("large_icon_img");
var myIcon = document.getElementById("myIcon");
// choose file name
switch (classification)
{
case "none":
// choose part icon file
icn = defIcon.getAttribute("src");
break;
case "Assembly":
icn += "package.svg";
break;
case "Component":
icn += "circuit-board.svg";
break;
case "Material":
icn += "beaker.svg";
break;
case "Software":
icn += "file-binary.svg";
break;
}
// style custom icon
myIcon.setAttribute("src",icn);
myIcon.style.visibility = "visible";
myIcon.style.display = "block";
// hide default icon element
defIcon.style.visibility = "hidden";
}
// choose icon onLoad
window.addEventListener("load", chooseIcon);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment