Create a simple page that automatically displays a randomly selected text block with each refresh.
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 processesraw_text.txt
and generatesoutput_for_script.js
.raw_text.txt
: The source text file containing the various text blocks used in the project, one block per line.
-
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 ofraw_text.txt
into a JavaScript array and outputs it tooutput_for_script.js
.
- Place your desired text in
-
Integrate JavaScript Files:
- Paste the array from
output_for_script.js
intoscript.js
.
- Paste the array from
-
Load the Page:
- Open
index.html
in your web browser. The web page will automatically display a randomly selected text block fromscript.js
each time you reload or refresh the page.
- Open
- 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 fromoutput_for_script.js
intoscript.js
.