Active-CSS / active-css

The epic event-driven browser language for UI with functionality in one-liner CSS. Over 100 incredible CSS commands for DOM manipulation, ajax, reactive variables, single-page application routing, and lots more. Could CSS be the JavaScript framework of the future?
https://activecss.org
Other
42 stars 7 forks source link

Expand {$RAND} variable type - so that it can do a whole lot more (baby yeah). #117

Closed bob2517 closed 3 years ago

bob2517 commented 3 years ago

I've got this random ID run command JavaScript thing which generates a string of numbers and letters slapped in the middle of my todos example for generating IDs for the 2.5.0 release on the docs website (which incidentally needs only 49 targeted action commands for full functionality). There's also a few other examples on the docs where you need random numbers of varying lengths and you need JavaScript to do it. That just won't do.

Expand the {$RAND} variable so that it handles stuff like this:

{$RAND} - defaults to 8 char length full of numbers so existing functionality works everywhere. {$RANDSTR} - 8 chars of random a-zA-Z0-9 goodness {$RAND12} - what? Did you want 12 random digits? Ok. {$RANDSTR12} - what? Did you want 12 random digits and a-zA-Z? Ok. {$RAND0-100} - returns a random number up to 100.

I might do another variant which includes a random "-" but I can't be arsed at the moment. Will add it if it's essential later.

I think that should cover the basics. There must be a million random string generators that developers have written over the years.

bob2517 commented 3 years ago

Done offline, will do a commit in a sec.

bob2517 commented 3 years ago

As an aside, I really need to implement a @for loop. Will do that after 2.5.0 unless I can do it quickly by the end of the weekend along with the memory clean-up issue.

bob2517 commented 3 years ago

Done on branch. Found a disrelated error while re-jigging an example to do with delays on custom event triggers which I'm sorting out now, but it's got nothing to do with this issue so I hereby pronounce it closed.