XenoBot Forums - Powered by vBulletin

User Tag List

Results 1 to 3 of 3

Thread: Java Script Help

  1. #1

    Join Date
    Sep 2015
    Location
    Sweden
    Posts
    98
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Java Script Help

    Hello guys. I am asking you for a huge favour today, since I have no clue how to use javascript and I need this urgent.


    I'm looking for somone to code me a script that will do the following.

    First off all, I am creating a rashid timer. I want it to display where rashid is in TEXT format, every day, and the days should switch at server save(10.00 CET GMT+1)

    So basicly I want this to be coded.

    On Mondays you can find him in Svargrond
    On Tuesdays you can find him in Liberty Bay
    On Wednesdays you can find him in Port Hope
    On Thursdays you can find him in Ankrahmun
    On Fridays you can find him in Darashia
    On Saturdays you can find him in Edron
    On Sundays you can find him in Carlin

    So for example, if its monday now (23:43) it should say Svargrond on the text, and when it turns 10:00(server save) tommorow it should automaticlly switch to Liberty Bay, and the following day at serversave the text should switch to Port Hope.

    I hope my explanation is good enough, thanks alot!


    If possible, it would be awesome if you could let us use images instead of texts, that way we could pick any font we want etc. So basicly images change daily instead of text changing daily, thanks.
    Last edited by sandeep0592; 02-16-2016 at 10:46 PM.

  2. #2

    Join Date
    May 2015
    Posts
    156
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    I'm not a pro, but this is like 99% done.
    Not entirely sure if getUTCDay() and getUTCHours() is the correct way of doing it (it probably isn't!).
    Using getDay() and getHours() would only get the user's local time though, so it can't be that.

    html code:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Rashid</title>
    </head>
    <body>

    <div id="rashid-info">

    </div>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
    <script type="text/javascript">
    // Variables for date and text
    var day = new Date().getUTCDay();
    var hour = new Date().getUTCHours() + 1;
    var rashidText = "";

    // 0 = Sunday, 1 = Monday, etc.
    var messages = [
    "On Sundays you can find him in Carlin",
    "On Mondays you can find him in Svargrond",
    "On Tuesdays you can find him in Liberty Bay",
    "On Wednesdays you can find him in Port Hope",
    "On Thursdays you can find him in Ankrahmun",
    "On Fridays you can find him in Darashia",
    "On Saturdays you can find him in Edron"
    ];

    // If hour is 00:00-09:59 CET go back one day
    if (hour < 10) {
    rashidText = messages[day-1];
    } else {
    rashidText = messages[day];
    }

    // Output the text to the div-element
    $('#rashid-info').text(rashidText);
    </script>
    </body>
    </html>



    edit: also make a check if day=0 (sunday), and then go back to day=6 (saturday). -1 doesnt work on first one in array.
    Last edited by texmex47; 02-21-2016 at 02:11 AM.

  3. #3

    Join Date
    Feb 2016
    Posts
    22
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Why not use AJAX for this?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •