/Text-Block-Randomizer

Create a block of randomized text for any webpage

Primary LanguageJavaScript

Random Text Display Web Page

Create a simple page that automatically displays a randomly selected text block with each refresh.

File Structure

  • index.html: Open this page in your browser.
  • script.js: The JavaScript file responsible for handling the logic to display random text.
  • output_for_script.js: A JavaScript file generated by the Python script, containing an array of text options.
  • raw_to_array.py: A Python script that processes raw_text.txt and generates output_for_script.js.
  • raw_text.txt: The source text file containing the various text blocks used in the project, one block per line.

Setup and Execution

  1. Prepare the Text Data:

    • Place your desired text in raw_text.txt. Each line in this file will be a separate entry in the array.
    • Run the raw_to_array.py Python script. This script converts the contents of raw_text.txt into a JavaScript array and outputs it to output_for_script.js.
  2. Integrate JavaScript Files:

    • Paste the array from output_for_script.js into script.js.
  3. Load the Page:

    • Open index.html in your web browser. The web page will automatically display a randomly selected text block from script.js each time you reload or refresh the page.

Randomized Text, Reloaded

Notes

  • This project does not require a server setup. It can run locally in your web browser.
  • Ensure that all files are in the same directory for the scripts to work correctly.
  • You can customize the text in raw_text.txt to change the displayed content.
  • There's probably a simpler step for running the python script and generating script.js in its entirety, saving a step, but for now, you need to copy/paste the resulting array from output_for_script.js into script.js.