×
Create a new article
Write your page title here:
We currently have 3,036 articles on YumeWiki. Type your article name above or click on one of the titles below and start writing!



YumeWiki
3,036Articles

MediaWiki:SeasonCalculator.js: Difference between revisions

No edit summary
No edit summary
 
Line 1: Line 1:
switch (mw.config.get('wgPageName')) {
$(document).ready(function() {
    case 'Yume_2kki:Randomizers':
    $("#calculatorDiv").empty();
$(document).ready(function() {
    $("#calculatorDiv").append('<input type="number" id="calculator"></input>');   
$("#calculatorDiv").empty();
    $('#calculator').keyup(calculateSeason);
    $("#calculatorDiv").append('<input type="number" id="calculator"></input>');   
    $('#calculator').change(calculateSeason);      
$('#calculator').keyup(calculateSeason);
});  
$('#calculator').change(calculateSeason);      
 
});  
function calculateSeason() {
    if ($(this).val().match(/^\d+$/)) {
function calculateSeason(){
        var season = 'Unknown';
    if ($(this).val().match(/^\d+$/)) {
        var sleepTimes = parseInt($(this).val());
        var season = 'Unknown';
        sleepTimes = (sleepTimes + 1) % 554400;
        var sleepTimes = parseInt($(this).val());
        var seasonNumber = Math.floor((sleepTimes + 4)/ 3) % 4;
        sleepTimes = (sleepTimes + 1) % 554400;
        switch (seasonNumber){
        var seasonNumber = Math.floor((sleepTimes + 4)/ 3) % 4;
            case 0:
        switch (seasonNumber){
                season = 'Winter';
            case 0:
                break;
                season = 'Winter';
            case 1:
                break;
                season = 'Spring';
            case 1:
                break;
                season = 'Spring';
            case 2:
                break;
                season = 'Summer';
            case 2:
                break;
                season = 'Summer';
            case 3:
                break;
                season = 'Fall';
            case 3:
                break;                         
                season = 'Fall';
        }
                break;                         
        var limite = false;
        }
        var i = 1;
        var limite = false;
        while (!limite) {
        var i = 1;
            sleepTimes++;
        while (!limite) {
            seasonNumberTest = (Math.floor((sleepTimes + 4)/ 3)) % 4;
            sleepTimes++;
            if (seasonNumberTest == seasonNumber) i++;
            seasonNumberTest = (Math.floor((sleepTimes + 4)/ 3)) % 4;
            else limite = true;
            if (seasonNumberTest == seasonNumber) i++;
        }
            else limite = true;
        $("#results").empty();
        }
        $("#results").append('The season in your next dream will be <b>' + season + '</b>. ');
        $("#results").empty();
        if (i == 1) {
        $("#results").append('The season in your next dream will be <b>' + season + '</b>. ');
            $("#results").append('This is the last day of the season.');
        if (i == 1) {
        }
            $("#results").append('This is the last day of the season.');
        else {
        }
            $("#results").append('This season will last for ' + i + ' more days.');             
        else {
        }
            $("#results").append('This season will last for ' + i + ' more days.');             
    }
        }
    else {
    }
        $(this).val('');
    else {
        $("#results").empty();
        $(this).val('');
        $("#results").append('Type a valid positive integer on the input field.');         
        $("#results").empty();
    }
        $("#results").append('Type a valid positive integer on the input field.');         
    }
}  
        break;
}
}

Latest revision as of 06:40, 13 December 2022

$(document).ready(function() {
    $("#calculatorDiv").empty();
    $("#calculatorDiv").append('<input type="number" id="calculator"></input>');   
    $('#calculator').keyup(calculateSeason);
    $('#calculator').change(calculateSeason);		    
}); 

function calculateSeason() {
    if ($(this).val().match(/^\d+$/)) {
        var season = 'Unknown';
        var sleepTimes = parseInt($(this).val());
        sleepTimes = (sleepTimes + 1) % 554400;
        var seasonNumber = Math.floor((sleepTimes + 4)/ 3) % 4;
        switch (seasonNumber){
            case 0:
                season = 'Winter';
                break;
            case 1:
                season = 'Spring';
                break;
            case 2:
                season = 'Summer';
                break;
            case 3:
                season = 'Fall';
                break;                        
        }
        var limite = false;
        var i = 1;
        while (!limite) {
            sleepTimes++;
            seasonNumberTest = (Math.floor((sleepTimes + 4)/ 3)) % 4;
            if (seasonNumberTest == seasonNumber) i++;
            else limite = true;
        }
        $("#results").empty();
        $("#results").append('The season in your next dream will be <b>' + season + '</b>. ');
        if (i == 1) {
            $("#results").append('This is the last day of the season.');
        }
        else {
            $("#results").append('This season will last for ' + i + ' more days.');            
        }
    }
    else {
        $(this).val('');
        $("#results").empty();
        $("#results").append('Type a valid positive integer on the input field.');         
    }
}