MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus HdRo-Wiki
Wechseln zu:Navigation, Suche
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 listDate = "4 15, 2020 1:00:00";
+
var eventDate1 = "4 15, 2020 1:00:00";
var countDownDate = new Date(listDate).getTime();
+
var countDownDate1 = new Date(eventDate1).getTime();
  
 
// Update the countdown every 1 second
 
// Update the countdown every 1 second
Zeile 53: Zeile 53:
  
 
// Find the distance between now and the countdown date
 
// Find the distance between now and the countdown date
var distance = countDownDate - now;
+
var distance1 = countDownDate1 - now;
  
 
// Time calculations for days, hours, minutes and seconds
 
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
+
var days1 = Math.floor(distance1 / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
+
var hours1 = Math.floor((distance1 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
+
var minutes1 = Math.floor((distance1 % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
+
var seconds1 = Math.floor((distance1 % (1000 * 60)) / 1000);
  
 
// If the dates are singular, change the text
 
// If the dates are singular, change the text
if (days == 1) {
+
if (days1 == 1) {
 
     var daytext = " Tag, ";
 
     var daytext = " Tag, ";
 
} else {
 
} else {
Zeile 68: Zeile 68:
 
}
 
}
  
if (hours == 1) {
+
if (hours1 == 1) {
 
     var hourtext = " Stunde, ";
 
     var hourtext = " Stunde, ";
 
} else {
 
} else {
Zeile 74: Zeile 74:
 
}
 
}
  
if (minutes == 1) {
+
if (minutes1 == 1) {
 
     var minutetext = " Minute und ";
 
     var minutetext = " Minute und ";
 
} else {
 
} else {
Zeile 80: Zeile 80:
 
}
 
}
  
if (seconds == 1) {
+
if (seconds1 == 1) {
 
     var secondtext = " Sekunde";
 
     var secondtext = " Sekunde";
 
} else {
 
} else {
Zeile 87: Zeile 87:
  
 
// Display the result in the element with id="demo"
 
// Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = days + daytext + hours + hourtext + minutes + minutetext + seconds + secondtext;
+
document.getElementById("event1").innerHTML = days1 + daytext + hours1 + hourtext + minutes1 + minutetext + seconds1 + secondtext;
  
 
// If the countdown is finished, write some text
 
// If the countdown is finished, write some text
if (distance < 0) {
+
if (distance1 < 0) {
 
     clearInterval(x);
 
     clearInterval(x);
     document.getElementById("demo").innerHTML = "Event beendet!";
+
     document.getElementById("event1").innerHTML = "Event beendet!";
 
}
 
}
 
}, 1000);
 
}, 1000);

Version vom 25. März 2020, 15:29 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 1:00:00";
var countDownDate1 = new Date(eventDate1).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;

// 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";
}

// Display the result in the element with id="demo"
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!";
}
}, 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 19, 2020 23:34:26"; // 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);