Hi, 

I'm trying to pass a value to a variable to a javascript macro I'm trying 
to write; the result keeps coming back NaN, and I belive it is because I am 
passing "$(bgcol)$" instead of "7" for v:

Is there some other way I ought to be passing this argument? 

<$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;
};

})();


-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/bb849cfd-8968-4753-a629-0d9aaf1d59ef%40googlegroups.com.

Reply via email to