G’day,
I need anybody who knows about javascript macros to lay their eyeballs on the code below.
- As much as I dislike javascript, sometimes there just doesn’t seem to be any choice but to go there. The javascript is easy: copy paste from wherever whatever is needed.
- Having a tendency to avoid javascript as if it was like the plague, I don’t particularly want to learn the mechanics of creating javascript macros in TiddlyWiki.
For the code below, I just copied now.js and setup the javascript I needed. Seems to work A-1, but I’d like to know if there is anything wise for me to change (i.e. “infrastructure” stuff re TiddlyWiki and javascript macros.) Let’s not think for a second that I have any clue what I’m doing…
If you have a moment to scrutinize the following, THANK-YOU !!!
/*\
title: Random Number
type: application/javascript
module-type: macro
Macro to return a random number
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "random";
exports.params = [
{name: "maxvalue"}
];
/*
Run the macro
*/
exports.run = function(maxvalue) {
return Math.floor(Math.random() * maxvalue)+1;
};
})();