From Dark and Darker Wiki

m (Typo)
(changing scope of inner variables)
Line 7: Line 7:
}
}
var x = setIntOnStart( _ => {
var x = setIntOnStart( _ => {
     var id = "<!--{$uniqueId|default:'timer'|escape:'html'}-->";
     let id = "<!--{$uniqueId|default:'timer'|escape:'html'}-->";
     var countDownDate = new Date('<!--{$date|escape:'quotes'}-->').getTime();
     let countDownDate = new Date('<!--{$date|escape:'quotes'}-->').getTime();
     var now = new Date().getTime();
     let now = new Date().getTime();
     var distance = countDownDate - now;
     let distance = countDownDate - now;
     var days = Math.floor(distance / (1000 * 60 * 60 * 24));
     let days = Math.floor(distance / (1000 * 60 * 60 * 24));
     var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
     let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
     var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
     let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
     var seconds = Math.floor((distance % (1000 * 60)) / 1000);
     let seconds = Math.floor((distance % (1000 * 60)) / 1000);


     document.getElementById(id).innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
     document.getElementById(id).innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s ";

Revision as of 01:27, 26 August 2024

Parameters

uniqueId
  • Determines element id name
  • Name needs to be unique if multiple widgets are to be displayed on the same page.
  • Default: timer
date
  • String of text indicating a date and time.
    • Example:2024-12-31 23:59:59


Example 1

{{#widget:Countdown|uniqueId=A|date=2024-08-26 23:59:59}}

Example 2

{{#widget:Countdown|uniqueId=B|date=2024-08-25 23:59:59}}

Example 3

{{#widget:Countdown|uniqueId=C|date=2024-08-24 23:59:59}}