<$set name=bgcol value="7">
<div style=<<nowandthen m:11 v:2>>><<nowandthen m:11 v:"$(bgcol)$">>"$(bgcol)$"</div>
</$set>
/*\
title: $:/core/modules/macros/nowandthen.js
type: application/javascript
module-type: macro
Macro to return a formatted version of the current time
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "nowandthen";
exports.params = [
{name: "m"},
{name: "v"}
];
/*
Run the macro
m: is the highest value in the data set.
v: is the value to render.
*/
exports.run = function(m, v) {
let out = "background-color: rgb(";
try {
m = parseFloat(m);
v = parseFloat(v);
console.log("m:" + typeof(m));
console.log("m:" + m);
console.log("v:" + typeof(v));
console.log("v:" + v);
let huh = v/m;
let where = huh*255;
console.log("huh: " + typeof(huh));
console.log("huh: " + huh);
console.log("where: " + typeof(where));
console.log("where: " + where);
} catch(e) {
console.log("error: " + e);
}
for(var i =0; i < 3; i++) {
let wha = ((parseFloat(v)/parseFloat(m)));
out = out + (Math.floor(wha*255)) + ", ";
}
out = (out.slice(0,-2)) + ");color:rgb(150,150,150);";
return out;
};
})();
<div style=<<nowandthen m:11 v:2>>><<nowandthen m:11 v:"$(bgcol)$">>"$(bgcol)$"</div>
inside its own macro like:
\define misnamedmacro()
<div style=<<nowandthen m:11 v:2>>><<nowandthen m:11 v:"$(bgcol)$">>"$(bgcol)$"</div>
\end
and call it:
<$set name=bgcol value="7">
<<misnamedmacro>></$set>
Of course, there could be other things inside the JS macro that are wrong, but that's what's wrong out of the box.
Good luck!