From Dark and Darker Wiki

m (Added another example)
(Trying to understand the issue...)
Line 7: Line 7:
}
}
var countDownDate = new Date('<!--{$date|escape:'quotes'}-->').getTime();
var countDownDate = new Date('<!--{$date|escape:'quotes'}-->').getTime();
var id = "<!--{$uniqueId|default:'timer'|escape:'html'}-->"
var x = setIntOnStart( _ => {
var x = setIntOnStart( _ => {
  var now = new Date().getTime();
    var now = new Date().getTime();
  var distance = countDownDate - now;
    var distance = countDownDate - now;
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
    var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);
    var seconds = Math.floor((distance % (1000 * 60)) / 1000);


  document.getElementById("<!--{$uniqueId|default:'timer'|escape:'html'}-->").innerHTML = days + "d " + hours + "h "
    document.getElementById(id).innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
  + minutes + "m " + seconds + "s ";


  if (distance < 0) {
    if (distance < 0) {
    clearInterval(x);
        clearInterval(x);
    document.getElementById("<!--{$uniqueId|default:'timer'|escape:'html'}-->").innerHTML = "LIVE NOW";
        document.getElementById(id).innerHTML = "LIVE NOW";
  }
    }
}, 1000);
}, 1000);
</script>
</script>
Line 36: Line 36:


==Example 1==
==Example 1==
<pre>{{#widget:Countdown|uniqueId=Test1|date=2024-12-31 23:59:59}}</pre>
<pre>{{#widget:Countdown|uniqueId=A|date=2024-08-26 23:59:59}}</pre>
{{#widget:Countdown|uniqueId=Test1|date=2024-12-31 23:59:59}}
{{#widget:Countdown|uniqueId=A|date=2024-08-26 23:59:59}}
==Example 2==
==Example 2==
<pre>{{#widget:Countdown|uniqueId=Test2|date=2024-11-10 11:59:59}}</pre>
<pre>{{#widget:Countdown|uniqueId=B|date=2024-08-25 23:59:59}}</pre>
{{#widget:Countdown|uniqueId=Test2|date=2024-11-10 11:59:59}}
{{#widget:Countdown|uniqueId=B|date=2024-08-25 23:59:59}}
==Example 3==
==Example 3==
<pre>{{#widget:Countdown|uniqueId=Test2|date=2024-8-10 11:59:59}}</pre>
<pre>{{#widget:Countdown|uniqueId=C|date=2024-08-24 23:59:59}}</pre>
{{#widget:Countdown|uniqueId=Test2|date=2024-8-10 11:59:59}}
{{#widget:Countdown|uniqueId=C|date=2024-08-24 23:59:59}}
</noinclude>
</noinclude>

Revision as of 00:53, 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}}