This file contains 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
/* | |
# Author: Andrew White | |
# Last updated: 26/06/2017 | |
# Purpose: Overrides generic icons in Munki update page depending on regex match. | |
*/ | |
// Future version probably has proper functions, icon array, nicer regex matches | |
dir = "custom/resources/" | |
apple_icon = dir + "macos-update.png"; | |
xerox_icon = dir + "xerox.png"; | |
window.onload=function() { | |
updateIcons(); | |
console.log("RSC custom onload running"); | |
} | |
function updateIcons() { | |
updateIcon("^macOS(.*)Update$", apple_icon); | |
updateIcon("^Fuji Xerox Printer Software Update", xerox_icon); | |
} | |
function updateIcon(regex, icon) { | |
artwork = document.getElementsByClassName("artwork"); | |
for (x=0;x<artwork.length;x++) { | |
if (artwork[x].tagName == "IMG") { | |
name = artwork[x].alt; | |
re = new RegExp(regex); | |
if (re.test(name)) { | |
document.getElementsByClassName("artwork")[x].src = icon; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment