MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus HdRo-Wiki
Wechseln zu:Navigation, Suche
(5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 43: Zeile 43:
 
// Sommerzeit beachten!
 
// Sommerzeit beachten!
 
// Format: Monat Tag (+1), Jahr Uhrzeit (bei Sommerzeit: 2 Uhr)
 
// Format: Monat Tag (+1), Jahr Uhrzeit (bei Sommerzeit: 2 Uhr)
var eventDate1 = "4 15, 2020 1:00:00";
+
var eventDate1 = "4 15, 2020 2:00:00";
 
var countDownDate1 = new Date(eventDate1).getTime();
 
var countDownDate1 = new Date(eventDate1).getTime();
 +
var eventDate2 = "4 07, 2020 2:00:00";
 +
var countDownDate2 = new Date(eventDate2).getTime();
  
 
// Update the countdown every 1 second
 
// Update the countdown every 1 second
Zeile 54: Zeile 56:
 
// Find the distance between now and the countdown date
 
// Find the distance between now and the countdown date
 
var distance1 = countDownDate1 - now;
 
var distance1 = countDownDate1 - now;
 +
var distance2 = countDownDate2 - now;
  
 
// Time calculations for days, hours, minutes and seconds
 
// Time calculations for days, hours, minutes and seconds
Zeile 86: Zeile 89:
 
}
 
}
  
// Display the result in the element with id="demo"
+
// Time calculations for days, hours, minutes and seconds
 +
var days2 = Math.floor(distance2 / (1000 * 60 * 60 * 24));
 +
var hours2 = Math.floor((distance2 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
 +
var minutes2 = Math.floor((distance2 % (1000 * 60 * 60)) / (1000 * 60));
 +
var seconds2 = Math.floor((distance2 % (1000 * 60)) / 1000);
 +
 
 +
// If the dates are singular, change the text
 +
if (days2 == 1) {
 +
    var daytext = " Tag, ";
 +
} else {
 +
    var daytext = " Tage, ";
 +
}
 +
 
 +
if (hours2 == 1) {
 +
    var hourtext = " Stunde, ";
 +
} else {
 +
    var hourtext = " Stunden, ";
 +
}
 +
 
 +
if (minutes2 == 1) {
 +
    var minutetext = " Minute und ";
 +
} else {
 +
    var minutetext = " Minuten und ";
 +
}
 +
 
 +
if (seconds2 == 1) {
 +
    var secondtext = " Sekunde";
 +
} else {
 +
    var secondtext = " Sekunden";
 +
}
 +
 
 +
// Display the result in the element with id="event1"
 
document.getElementById("event1").innerHTML = days1 + daytext + hours1 + hourtext + minutes1 + minutetext + seconds1 + secondtext;
 
document.getElementById("event1").innerHTML = days1 + daytext + hours1 + hourtext + minutes1 + minutetext + seconds1 + secondtext;
  
Zeile 94: Zeile 128:
 
     document.getElementById("event1").innerHTML = "Event beendet!";
 
     document.getElementById("event1").innerHTML = "Event beendet!";
 
}
 
}
 +
 +
// Display the result in the element with id="event2"
 +
document.getElementById("event2").innerHTML = days2 + daytext + hours2 + hourtext + minutes2 + minutetext + seconds2 + secondtext;
 +
 +
// If the countdown is finished, write some text
 +
if (distance2 < 0) {
 +
    clearInterval(x);
 +
    document.getElementById("event2").innerHTML = "Event beendet!";
 +
}
 +
 
}, 1000);
 
}, 1000);
  
Zeile 168: Zeile 212:
 
// Set the date we're counting up from
 
// Set the date we're counting up from
 
// Format: Monat Tag, Jahr Uhrzeit (# #, #### #:##:##)
 
// Format: Monat Tag, Jahr Uhrzeit (# #, #### #:##:##)
var dayDate = "3 19, 2020 23:34:26"; // genauer Start eines IG-Tages ("Morgendämmerung")
+
var dayDate = "3 26, 2020 10:36:43"; // genauer Start eines IG-Tages ("Morgendämmerung")
 
var countUpDate = new Date(dayDate).getTime();
 
var countUpDate = new Date(dayDate).getTime();
  

Version vom 27. März 2020, 06:53 Uhr

/* Das folgende JavaScript wird für alle Benutzer geladen. */

/* Countdown */
/*
mw.loader.load( '/index.php?title=MediaWiki:Countdown.js&action=raw&ctype=text/javascript' );
*/

/* Countdown 2 */
/*
mw.loader.load( '/index.php?title=MediaWiki:Countdown2.js&action=raw&ctype=text/javascript' );
*/

/* Countdown 3 */
/*
mw.loader.load( '/index.php?title=MediaWiki:Countdown3.js&action=raw&ctype=text/javascript' );
*/


/*
$(function () {

  var myElement = document.getElementById('mw-countdown-01');
  myElement.innerHTML = '<span class="countdown" style="display:none;">Dauer des Jubiläums-Festes: <span class="countdowndate">May 13 2018 23:59:59</span></span><span class="nocountdown">Das Jubiläums-Fest 2018 ist beendet!</span>';

});


$( document ).ready(function() {
  getSeconds();
});

$(function () {

  var myElement = document.getElementById('mw-countdown-02');
  myElement.innerHTML = '<span id="days3"></span> Days, <span id="hours3"></span> Hours, <span id="minutes3"></span> Minutes, <span id="seconds3"></span> Seconds';

});
*/


/* Countdown Timer for Events */
// Set the date we're counting down to
// Sommerzeit beachten!
// Format: Monat Tag (+1), Jahr Uhrzeit (bei Sommerzeit: 2 Uhr)
var eventDate1 = "4 15, 2020 2:00:00";
var countDownDate1 = new Date(eventDate1).getTime();
var eventDate2 = "4 07, 2020 2:00:00";
var countDownDate2 = new Date(eventDate2).getTime();

// Update the countdown every 1 second
var x = setInterval(function() {

// Get today's date and time
var now = new Date().getTime();

// Find the distance between now and the countdown date
var distance1 = countDownDate1 - now;
var distance2 = countDownDate2 - now;

// Time calculations for days, hours, minutes and seconds
var days1 = Math.floor(distance1 / (1000 * 60 * 60 * 24));
var hours1 = Math.floor((distance1 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes1 = Math.floor((distance1 % (1000 * 60 * 60)) / (1000 * 60));
var seconds1 = Math.floor((distance1 % (1000 * 60)) / 1000);

// If the dates are singular, change the text
if (days1 == 1) {
    var daytext = " Tag, ";
} else {
    var daytext = " Tage, ";
}

if (hours1 == 1) {
    var hourtext = " Stunde, ";
} else {
    var hourtext = " Stunden, ";
}

if (minutes1 == 1) {
    var minutetext = " Minute und ";
} else {
    var minutetext = " Minuten und ";
}

if (seconds1 == 1) {
    var secondtext = " Sekunde";
} else {
    var secondtext = " Sekunden";
}

// Time calculations for days, hours, minutes and seconds
var days2 = Math.floor(distance2 / (1000 * 60 * 60 * 24));
var hours2 = Math.floor((distance2 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes2 = Math.floor((distance2 % (1000 * 60 * 60)) / (1000 * 60));
var seconds2 = Math.floor((distance2 % (1000 * 60)) / 1000);

// If the dates are singular, change the text
if (days2 == 1) {
    var daytext = " Tag, ";
} else {
    var daytext = " Tage, ";
}

if (hours2 == 1) {
    var hourtext = " Stunde, ";
} else {
    var hourtext = " Stunden, ";
}

if (minutes2 == 1) {
    var minutetext = " Minute und ";
} else {
    var minutetext = " Minuten und ";
}

if (seconds2 == 1) {
    var secondtext = " Sekunde";
} else {
    var secondtext = " Sekunden";
}

// Display the result in the element with id="event1"
document.getElementById("event1").innerHTML = days1 + daytext + hours1 + hourtext + minutes1 + minutetext + seconds1 + secondtext;

// If the countdown is finished, write some text
if (distance1 < 0) {
    clearInterval(x);
    document.getElementById("event1").innerHTML = "Event beendet!";
}

// Display the result in the element with id="event2"
document.getElementById("event2").innerHTML = days2 + daytext + hours2 + hourtext + minutes2 + minutetext + seconds2 + secondtext;

// If the countdown is finished, write some text
if (distance2 < 0) {
    clearInterval(x);
    document.getElementById("event2").innerHTML = "Event beendet!";
}

}, 1000);


// Daily Resets Timer
setInterval(function time(){
  var ndt = new Date();
  var dhours = 23 - ndt.getHours() + 6; //Taten-Reset um 6 Uhr und Sommerzeit +1 Std.
  if(dhours >= 24){ // verhindert die Anzeige von 25+ Std.
    dhours = dhours - 24;
  }
  var dmin = 59 - ndt.getMinutes();
  if((dmin + '').length == 1){
    dmin = '0' + dmin;
  }
  var dsec = 59 - ndt.getSeconds();
  if((dsec + '').length == 1){
        dsec = '0' + dsec;
  }

  var dit = new Date();
  var dihours = 23 - dit.getHours() + 12; //Instanzen-Reset um 12 Uhr und Sommerzeit +1 Std.
  if(dihours >= 24){ // verhindert die Anzeige von 25+ Std.
    dihours = dihours - 24;
  }
  var dimin = 59 - dit.getMinutes();
  if((dimin + '').length == 1){
    dimin = '0' + dimin;
  }
  var disec = 59 - dit.getSeconds();
  if((disec + '').length == 1){
        disec = '0' + disec;
  }

  var dqst = new Date();
  var dqhours = 23 - dqst.getHours() + 8; //Quest-Reset um 8 Uhr und Sommerzeit +1 Std.
  if(dqhours >= 24){ // verhindert die Anzeige von 25+ Std.
    dqhours = dqhours - 24;
  }
  var dqmin = 59 - dqst.getMinutes();
  if((dqmin + '').length == 1){
    dqmin = '0' + dqmin;
  }
  var dqsec = 59 - dqst.getSeconds();
  if((dqsec + '').length == 1){
        dqsec = '0' + dqsec;
  }

/*
  var dwt = new Date();
  var dwhours = 23 - dwt.getHours() + 1; //Reset um 1 Uhr und Sommerzeit +1 Std.
  if(dwhours >= 24){ // verhindert die Anzeige von 25+ Std.
    dwhours = dwhours - 24;
  }
  var dwmin = 59 - dwt.getMinutes();
  if((dwmin + '').length == 1){
    dwmin = '0' + dwmin;
  }
  var dwsec = 59 - dwt.getSeconds();
  if((dwsec + '').length == 1){
        dwsec = '0' + dwsec;
  }
*/

document.getElementById("dailydeed").innerHTML = dhours + " Std., " + dmin + " Min., " + dsec +" Sek.";
document.getElementById("dailyquest").innerHTML = dqhours + " Std., " + dqmin + " Min., " + dqsec +" Sek.";
document.getElementById("dailyinstance").innerHTML = dihours + " Std., " + dimin + " Min., " + disec +" Sek.";
/* document.getElementById("dailyend").innerHTML = dwhours + " Std., " + dwmin + " Min., " + dwsec +" Sek.";*/
}, 1000);



// Daytime Timer
// Set the date we're counting up from
// Format: Monat Tag, Jahr Uhrzeit (# #, #### #:##:##)
var dayDate = "3 26, 2020 10:36:43"; // genauer Start eines IG-Tages ("Morgendämmerung")
var countUpDate = new Date(dayDate).getTime();

// Update the countdown every 1 second
var xt = setInterval(function() {

// Get today's date and time
var daynow = new Date().getTime();

// Find the distance between daynow and the countup date
var xdaydistance = daynow - countUpDate;

var tday = (6140 - 1) * 1000; // IG-Tag in Millisekunden
var tnight = (5020 - 1) * 1000; // IG-Nacht in Millisekunden
var dt = (tday + tnight);
var daydistance = xdaydistance % dt;

if (daydistance > tday) {
    var newdaydistance = tnight - (daydistance - tday);
    document.getElementById("daytime").innerHTML = "<img src=\"https://www.hdro-wiki.de/images/9/9c/Time_nighttime.png\" alt=\"Nacht\"> Nacht<br><small>(Tag in </small>" + hours + hourtext + minutes + minutetext + seconds + secondtext + ")";
} else {
    var newdaydistance = tday - daydistance;
    document.getElementById("daytime").innerHTML = "<img src=\"https://www.hdro-wiki.de/images/d/d3/Time_daytime.png\" alt=\"Tag\"> Tag<br><small>(Nacht in </small>" + hours + hourtext + minutes + minutetext + seconds + secondtext + ")";
}

// Time calculations for hours, minutes and seconds
var hours = Math.floor(newdaydistance / (1000 * 60 * 60));
var minutes = Math.floor((newdaydistance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((newdaydistance % (1000 * 60)) / 1000);

// If the dates are singular, change the text
if (hours == 1) {
    var hourtext = " Stunde, ";
} else {
    var hourtext = " Stunden, ";
}

if (minutes == 1) {
    var minutetext = " Minute und ";
} else {
    var minutetext = " Minuten und ";
}

if (seconds == 1) {
    var secondtext = " Sekunde";
} else {
    var secondtext = " Sekunden";
}


if (daydistance > tday) {
    var newdaydistance = tnight - (daydistance - tday);
    document.getElementById("daytime").innerHTML = "<img src=\"https://www.hdro-wiki.de/images/9/9c/Time_nighttime.png\" alt=\"Nacht\"> Nacht";
} else {
    var newdaydistance = tday - daydistance;
    document.getElementById("daytime").innerHTML = "<img src=\"https://www.hdro-wiki.de/images/d/d3/Time_daytime.png\" alt=\"Tag\"> Tag";
}

// Display the result in the element with id="xdaytime"
document.getElementById("xdaytime").innerHTML = "<small>(Wechsel in " + hours + hourtext + minutes + minutetext + seconds + secondtext + ")</small>";

}, 1000);