Welcome to the Cumulus Support forum.

Latest Cumulus MX V4 release 4.4.2 (build 4085) - 12 March 2025

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Legacy Cumulus 1 release 1.9.4 (build 1099) - 28 November 2014
(a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

If you are posting a new Topic about an error or if you need help PLEASE read this first viewtopic.php?p=164080#p164080

MinutesSinceLastRainTip

Other discussion about creating web sites for Cumulus that doesn't have a specific subforum

Moderator: daj

User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: MinutesSinceLastRainTip

Post by ace2 »

both produce the same results??
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: MinutesSinceLastRainTip

Post by mcrossley »

steve wrote:Thanks, Mark, that's much more elegant than my effort would have been!
Actually not very elegant - now I have a keyboard! - more elegant would be to put it in a closure (=anonymous function - to avoid polluting/clashing with the global namespace) and cater for zero values...

Code: Select all

<script type="text/javascript">
(function(){
  var days = Math.floor(<#MinutesSinceLastRainTip>/24/60);
  var hrs = Math.floor(<#MinutesSinceLastRainTip>/60%24);
  var mins = Math.floor(<#MinutesSinceLastRainTip>%60);
  function plur(x){return x === 1 ? '' : 's'};
  document.write(days + ' Day' + plur(days) + ' : ' + hrs + ' Hr' + plur(hrs) + ' : ' + mins + ' Min' + plur(mins));
}());
</script>
Edit: Added enclosing <script> tags.
Last edited by mcrossley on Sun 23 Feb 2014 10:56 am, edited 1 time in total.
User avatar
mcrossley
Posts: 14388
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2/WLL
Operating System: Bullseye Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: MinutesSinceLastRainTip

Post by mcrossley »

ace2 wrote:both produce the same results??
Not sure what you mean? Your home page still has Steve's original JS code in it?
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: MinutesSinceLastRainTip

Post by ace2 »

just wondering if the results would be the same, that's all. and yes I'm using Steve's code.

mcrossley code should have the same output result???
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
User avatar
steve
Cumulus Author
Posts: 26672
Joined: Mon 02 Jun 2008 6:49 pm
Weather Station: None
Operating System: None
Location: Vienne, France
Contact:

Re: MinutesSinceLastRainTip

Post by steve »

Mark's code adds the enhancement to display the singular form for day/hour/minute when the value is 1.
Steve
User avatar
ace2
Posts: 679
Joined: Tue 14 Jan 2014 12:38 pm
Weather Station: maxkon ws-1081pc
Operating System: windows 7 & 8
Location: Adelaide, south Australia, Australia
Contact:

Re: MinutesSinceLastRainTip

Post by ace2 »

steve wrote:Mark's code adds the enhancement to display the singular form for day/hour/minute when the value is 1.

mm, which one do I steal now??
CHRIS
Image
web site
http://www.ace2weather.com
Follow me on Twitter
http://tinyurl.com/kwlr9re
YouTube channel
http://tinyurl.com/lehwpgp
Facebook page
http://tinyurl.com/k3sap4s
Tiny URL links used
Alan
Posts: 51
Joined: Sun 14 Mar 2010 9:41 am
Weather Station: WH1091
Operating System: Win 7
Location: Sydney

Re: MinutesSinceLastRainTip

Post by Alan »

Hello Mark, Your code works beautifully.
Between when Steve supplied his code and when you supplied your more elegant version I had managed to modify Steve's code to return only that which has value (ie if only minutes value then only minutes displayed and of course if only minutes and hours value then only minutes and hours displayed and so on... somewhat akin to auto ranging on a measuring instrument). This was fine but of course it only had plural nomenclature.
However, no matter how much I try I can not replicate the same action in your code (post probably because your version is beyond me... many things in it that I don't understand at this stage). Do you have any suggestions as to how this could be achieved?
Regards
Alan

PS
Please delete reference to the above as I have now managed to cobble together the appropriate code.
In any event I wish to thank you for the code you supplied and for your time and effort.
All the best.
Alan
Post Reply