Help me with this java script (Event counter)

Results 1 to 2 of 2
  1. #1
    Newbie SirJacky is offline
    MemberRank
    Jan 2018 Join Date
    2Posts

    Help me with this java script (Event counter)

    hey, i want to modify that script so i can edit the date of the events like (Jan 20, 2018 08:30) instead of 08:30 because not all the events are every day
    Code:
    var MuEvents = {};
    MuEvents.text = [
            [lang[0], lang[1]],
            [lang[2], lang[3]]
    ];
    
    MuEvents.sked = [
      ['Blood Castle',        0,      '00:30', '02:30', '04:30', '06:30',  '08:30', '10:30', '12:30', '14:30', '16:30', '18:30', '20:30', '22:30',  ],
      ['Chaos Castle',        0,      '01:30', '03:30', '05:30', '07:30',  '09:30', '11:30', '13:30', '15:30', '17:30', '19:30', '21:30', '23:30'],
      ['Devil Square',        0,      '01:00', '05:00', '09:00', '13:00', '17:00', '21:00'],
      ['Illusion Temple',     0,      '02:00', '06:00', '10:00', '14:00', '18:00', '22:00'],
      ['White Wizard',        1,      '02:15', '06:15', '10:15', '14:15', '18:15', '22:15'],
      ['Golden Invasion',     1,      '02:30', '08:30', '14:30', '20:30'],
      ['Red Dragon Invasion', 1,      '02:40', '06:40', '10:40', '14:40', '18:40', '22:40'],
      ['Castle Deep',             0,          '04:30', '12:30', '20:30'],
      ['Moss Merchant',             0,          '02:30', '08:30', '14:30', '20:30'],
      ['Event Drop',             0,          '20:30'],
      ['Arca Batalla',             0,          '00:30', '02:30', '04:30', '06:30', '08:30', '10:30', '12:30', '14:30', '16:30'],
    ];
    
    MuEvents.init = function (e) {
    
            if (typeof e == "string") 
            var g = new Date(new Date().toString().replace(/\date('H')+:\date('i')+:\date('s')+/g, e));
            var f = (typeof e == "number" ? e : (g.getHours() * 60 +  g.getMinutes()) * 60 + g.getSeconds()), q = MuEvents.sked, j = [];        
            
            for (var a = 0; a < q.length; a++) {
                    var n = q[a];
                    for (var k = 2; k < q[a].length; k++) {
                            var b = 0, p = q[a][k].split(":"), o = (p[0] * 60 + p[1] * 1) * 60, c = q[a][2].split(":");
                            if (q[a].length - 1 == k && (o - f) < 0) b = 1;
                            var r = b ? (1440 * 60 - f) + ((c[0] * 60 + c[1] * 1) * 60) : o - f;
                            if (f <= o || b) {
                                    var l = Math.floor((r / 60) / 60), l = l  < 10 ? "0" + l : l, d = Math.floor((r / 60) % 60), d = d < 10 ?  "0" + d : d, u = r % 60, u = u < 10 ? "0" + u : u;
                                    j.push('<dt class="event">' + (l  == 0 && !q[a][1] && d < 5 ? '<img  src="http://forum.ragezone.com/images/online.png" />' : '') + '<b  class="rightfloat">' + q[a][b ? 2 : k] + "</b><b>" + n[0]  + '</b><span><div class="rightfloat">' + (l + ":" + d  + ":" + u) + "</div>" + (MuEvents.text[q[a][1]][+(l == 0  && d < (q[a][1] ? 1 : 5))]) + "</span>");
                                    break;
                            };
                    };
            };
            document.getElementById("events").innerHTML = j.join("");
            setTimeout(function () {
                    MuEvents.init(f == 86400 ? 1 : ++f);
            }, 1000);
    };

    html:
    PHP Code:
    <dl id="events"
                    <
    script type="text/javascript" src="js/time.js"></script> 
                    <script type="text/javascript">MuEvents.init('00:00');</script> 
                  </dl> 
                </div> 


  2. #2
    :-) s-p-n is offline
    DeveloperRank
    Jun 2007 Join Date
    Next DoorLocation
    2,156Posts

    Post Re: Help me with this java script (Event counter)

    What have you tried,
    what happened when you tried those things,
    and what is `MuEvents.sked`? Is that where you edit the times? The last time seems to be what is displayed, I am guessing that the code is supposed to show the closest event that is at a future time, based on your image. But I'm wondering (concerning the 2nd index in each sub-array- the one after the name), some have a '0' and some have a '1', what does that mean?



Advertisement