working on quotes again
This commit is contained in:
parent
dc41d19150
commit
3c927453a2
@ -11,6 +11,7 @@
|
|||||||
<META CONTENT="https://ia601509.us.archive.org/31/items/trinitydotmoe88x31/trinitydotmoe88x31.bmp" NAME="og:image" />
|
<META CONTENT="https://ia601509.us.archive.org/31/items/trinitydotmoe88x31/trinitydotmoe88x31.bmp" NAME="og:image" />
|
||||||
<META CONTENT="noindex" NAME="googlebot" /> <!-- FUCK GOOGLE -->
|
<META CONTENT="noindex" NAME="googlebot" /> <!-- FUCK GOOGLE -->
|
||||||
<META CONTENT="interest-cohort=()" HTTP-EQUIV="Permissions-Policy" /> <!-- FUCK GOOGLE -->
|
<META CONTENT="interest-cohort=()" HTTP-EQUIV="Permissions-Policy" /> <!-- FUCK GOOGLE -->
|
||||||
|
<SCRIPT SRC="/js/quotes.js" TYPE="module"></SCRIPT>
|
||||||
<STYLE></STYLE>
|
<STYLE></STYLE>
|
||||||
<TITLE>trinity dot moe</TITLE> <!-- Also considered: 1945-07-16T05:26-06:00 -->
|
<TITLE>trinity dot moe</TITLE> <!-- Also considered: 1945-07-16T05:26-06:00 -->
|
||||||
</HEAD>
|
</HEAD>
|
||||||
@ -337,6 +338,11 @@ WIDTH="88px" <BR />
|
|||||||
|
|
||||||
<HR ALIGN="left" SIZE="1" WIDTH="25%" />
|
<HR ALIGN="left" SIZE="1" WIDTH="25%" />
|
||||||
|
|
||||||
|
<P ID="quote_value">QUOTE</P>
|
||||||
|
<P ID="quote_author">QUOTE AUTHOR</P>
|
||||||
|
|
||||||
|
<HR ALIGN="left" SIZE="1" WIDTH="25%" />
|
||||||
|
|
||||||
<P>
|
<P>
|
||||||
This site is written in vim and tested in the latest Firefox.
|
This site is written in vim and tested in the latest Firefox.
|
||||||
No rights reserved, all rights exercised, rights turned to lefts, left in this corner of the web.
|
No rights reserved, all rights exercised, rights turned to lefts, left in this corner of the web.
|
||||||
|
@ -1,44 +1,31 @@
|
|||||||
/* quotes.js; Deven Blake 2021; Public Domain */
|
/* quotes.js; Deven Blake 2021-2022; Public Domain */
|
||||||
/* With thanks to Ками on Discord. */
|
/* With thanks to Ками on Discord. */
|
||||||
/*********** CURRENTLY DOESN'T WORK ***********/
|
|
||||||
/* To use:
|
/* To use:
|
||||||
* - add two P elements with the IDs QUOTE_AUTHOR_ID (see code) and
|
* - <SCRIPT SRC="quotes.js" TYPE="module"></SCRIPT>
|
||||||
|
* - add two elements with the IDs QUOTE_AUTHOR_ID (see code) and
|
||||||
* QUOTE_VALUE_ID (see code) respectively
|
* QUOTE_VALUE_ID (see code) respectively
|
||||||
* - call window.quote_initialize() on page load.
|
* - use window.quote_new() to get a new quote. */
|
||||||
* - use window.quote_pick() to get a new quote. */
|
|
||||||
|
|
||||||
/* Will set window.quotes to the list of quotes and window.quote to 0 (to
|
import quotes from './quotes.json';
|
||||||
* indicate a quote hasn't yet been generated). */
|
window.quotes = quotes;
|
||||||
window.quote_initialize = function(){
|
window.QUOTES_L_QUOTE_MARK = '"';
|
||||||
|
window.QUOTES_R_QUOTE_MARK = '"';
|
||||||
|
window.QUOTES_QUOTE_AUTHOR_ID = "quote_author";
|
||||||
|
window.QUOTES_QUOTE_AUTHOR_PREFIX = "~ ";
|
||||||
|
window.QUOTES_QUOTE_VALUE_ID = "quote_value";
|
||||||
|
|
||||||
/* What needs to be done here is it needs to fetch the `quotes` object
|
|
||||||
* from /js/quotes.json and load it into `window.quotes`. The issue is
|
|
||||||
* I haven't figured out how to load JSON into JS yet without external
|
|
||||||
* libraries. */
|
|
||||||
|
|
||||||
window.quote = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Will not give you the same quote twice in a row! */
|
/* Will not give you the same quote twice in a row! */
|
||||||
window.quote_pick = function(){
|
window.quote_new = function(){
|
||||||
/* Customizeable constants */
|
|
||||||
var L_QUOTE_MARK = '"';
|
|
||||||
var R_QUOTE_MARK = '"';
|
|
||||||
var QUOTE_AUTHOR_ID = "quote_author";
|
|
||||||
var QUOTE_AUTHOR_PREFIX = "~ "
|
|
||||||
var QUOTE_VALUE_ID = "quote_value";
|
|
||||||
/* Could be `const`, but not supported in IE6-10:
|
|
||||||
* https://caniuse.com/const */
|
|
||||||
|
|
||||||
window.quote_old = window.quote; /* The quote currently in use. */
|
window.quote_old = window.quote; /* The quote currently in use. */
|
||||||
quoteIndex = Math.floor(Math.random() * window.quotes.length);
|
quoteIndex = Math.floor(Math.random() * window.quotes.length);
|
||||||
window.quote = window.quotes.splice(quoteIndex, 1)[0];
|
window.quote = window.quotes.splice(quoteIndex, 1)[0];
|
||||||
if(window.quote_old)
|
if(window.quote_old)
|
||||||
window.quotes.push(window.quote_old);
|
window.quotes.push(window.quote_old);
|
||||||
|
|
||||||
if(quote_text = document.getElementById(QUOTE_VALUE_ID))
|
if(quote_text = document.getElementById(window.QUOTES_QUOTE_VALUE_ID))
|
||||||
quote_text.textContent = L_QUOTE_MARK + window.quote[0] + R_QUOTE_MARK;
|
quote_text.textContent = window.QUOTES_L_QUOTE_MARK + window.quote[0] + R_QUOTE_MARK;
|
||||||
|
|
||||||
if(quote_author = document.getElementById(QUOTE_AUTHOR_ID))
|
if(quote_author = document.getElementById(window.QUOTES_QUOTE_AUTHOR_ID))
|
||||||
quoteAuthorText.textContent = QUOTE_AUTHOR_PREFIX + window.quote[1];
|
quoteAuthorText.textContent = window.QUOTES_QUOTE_AUTHOR_PREFIX + window.quote[1];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user