One of my JavaScript code snippets utilizes another external JavaScript source:
<body>
<script src="node_modules/node-vibrant/dist/vibrant.js"></script>
<script type="text/javascript">
function test(src) {
Vibrant.from(src).getPalette(function(err, swatches) {
if (err) throw err;
for (var key in swatches) {
if (key === "Vibrant") {
var swatch = swatches[key];
if (swatch) {
console.log("hex: " + swatch.getHex());
return (swatch.getHex());
}
}
}
});
}
test("Apples.jpg");
</script>
</body>
I am looking to call this JavaScript code from within Java. What would be the best approach to achieve this?
I attempted to use the ScriptManager
, but encountered an error message stating:
window is not defined