Viewing a single comment thread. View all comments

twovests wrote

I also want to figure out how to have randomized "splash" text on my index page like Minecraft. That should be pretty simple I figure, but I am no good with javascript so it's eluded me lol

Is your site a static page (just html+css+js files and folders) or did you take the Route Of Pain and use something like php? You can definitely do this with JavaScript

2

WRETCHEDSORCERESS OP wrote

yup! it's just static pages. masochistic though my predispositions may be, I did not walk the fell route of php

2

twovests wrote (edited )

Also I decided to implement this, if you don't want the Thrill of Discovery and would rather just have someone tell you how to do it. (Which is okay + 100% cool to do)

1

twovests wrote

<script>
  document.addEventListener
  (
    // The webpage "document" listens for an event titled "DOMContentLoaded".
    "DOMContentLoaded",
    // When this happens, it runs this "anonymous function"
    // It takes no parameters, `()`, and runs everything inside the { }
    () => {
      // An array of splash text,
      splashes = [
        "born 2 post",
        "Now with 100% more post!",
        "Where's The Dog Honey?",
        "I love you thiiiiiiis much",
        "﷽﷽﷽﷽",
      ];
      // And now, inside the webpage "document", find our "splash", and set its text.
      // What do we set it to? splashes[ some_random_index ]
      document.getElementById("splash").textContent = splashes[
         Math.floor(Math.random() * splashes.length)
      ];
      // Most programming languages have something like "Math.randrange(0, splashes.length)"
      // But JavaScript hates you
    }
  );
</script>
<p id="splash"></p>

behold

1