diff options
author | Frankie B <git@diskfloppy.me> | 2024-06-11 18:02:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-11 18:02:01 +0100 |
commit | 0f52d80ca67a49258b235f5831163dd72fbd54cf (patch) | |
tree | 9c5cd36b6e0a233e09ac88a4409fb68c63e4781a /resources/js | |
parent | a64bcc2c4639d5804b6dada23151bfcb8b198121 (diff) |
Merge MVC rewrite into master (#21)
* Just commit it all
* Require auth
* crap
* Update homepage
* Block AI scrapers
* Update cache update script
* Add dummy file
* Remove unnecessary lastfm config var
* Use withQueryParameters for LastFM API
* Fix embeds
* Update example env
* Smard
Diffstat (limited to 'resources/js')
-rw-r--r-- | resources/js/neverSaid.js | 35 | ||||
-rw-r--r-- | resources/js/schemeSwap.js | 70 |
2 files changed, 105 insertions, 0 deletions
diff --git a/resources/js/neverSaid.js b/resources/js/neverSaid.js new file mode 100644 index 0000000..5b58d60 --- /dev/null +++ b/resources/js/neverSaid.js @@ -0,0 +1,35 @@ +// Define an array of strings +const neverSaid = [ + "<td style=\"width: 105px\"><strong>ASM:</strong></td> <td>The Director liked all the props we got today.</td>", + "<td style=\"width: 105px\"><strong>PM:</strong></td> <td>Ah ha, a revolve. Terrific.</td>", + "<td style=\"width: 105px\"><strong>Chippie:</strong></td> <td>I don't know, let's look at the ground plan.</td>", + "<td style=\"width: 105px\"><strong>Set Designer:</strong></td> <td>Well, let's just have whatever is cheaper.</td>", + "<td style=\"width: 105px\"><strong>Sound:</strong></td> <td>Better turn that down a bit. We don't want to deafen them.</td>", + "<td style=\"width: 105px\"><strong>Director:</strong></td> <td>Sorry, my mistake.</td>", + "<td style=\"width: 105px\"><strong>Electrics:</strong></td> <td>This equipment is more complicated than we need.</td>", + "<td style=\"width: 105px\"><strong>Performer:</strong></td> <td>I really think my big scene should be cut.</td>", + "<td style=\"width: 105px\"><strong>SM:</strong></td> <td>Can we doo that scene change again please?", + "<td style=\"width: 105px\"><strong>LX designer:</strong></td> <td>Bit more light from those big chaps at the side. Yes that's right, the ones on stalks whatever they are called.</td>", + "<td style=\"width: 105px\"><strong>Electrics:</strong></td> <td>All the equipment works perfectly.</td>", + "<td style=\"width: 105px\"><strong>Musicians:</strong></td> <td>So what if that's the end of a call. Let's just finish this bit off.</td>", + "<td style=\"width: 105px\"><strong>Wardrobe:</strong></td> <td>Now, when exactly is the first dress rehearsal?", + "<td style=\"width: 105px\"><strong>Workshop:</strong></td> <td>I don't want anyone to know, but if you insist then yes, I admit it, I have just done an all-nighter.</td>", + "<td style=\"width: 105px\"><strong>Performer:</strong></td> <td>This costume is so comfortable.</td>", + "<td style=\"width: 105px\"><strong>Admin:</strong></td> <td>The level of overtime payments here are simply unacceptable. Our backstage staff deserve better.</td>", + "<td style=\"width: 105px\"><strong>Box Office:</strong></td> <td>Comps? No problem.</td>", + "<td style=\"width: 105px\"><strong>Set Designer:</strong></td> <td>You're right, it looks dreadful.</td>", + "<td style=\"width: 105px\"><strong>Flyman:</strong></td> <td>No, my lips are sealed. What I may or may not have seen remains a secret.</td>", + "<td style=\"width: 105px\"><strong>Electrics:</strong></td> <td>That had nothing to do with the computer, it was my fault.</td>", + "<td style=\"width: 105px\"><strong>Crew:</strong></td> <td>No, no, I'm sure that's our job.</td>", + "<td style=\"width: 105px\"><strong>SMgt:</strong></td> <td>Thanks, but I don't drink", + "<td style=\"width: 105px\"><strong>Performer:</strong></td> <td>Let me stand down here with my back to the audience.</td>", + "<td style=\"width: 105px\"><strong>Chippie:</strong></td> <td>I can't really manage those big fast power tools myself.</td>", + "<td style=\"width: 105px\"><strong>Chippie:</strong></td> <td>I prefer to use these little hand drills.</td>", + "<td style=\"width: 105px\"><strong>All:</strong></td> <td>Let's go and ask the Production Manager. He'll know.</td>" +] + +// Generate a random index into the array +const randomIndex = Math.floor(Math.random() * neverSaid.length); + +// Use document.write to output the random string +document.write(neverSaid[randomIndex]); diff --git a/resources/js/schemeSwap.js b/resources/js/schemeSwap.js new file mode 100644 index 0000000..3baa09b --- /dev/null +++ b/resources/js/schemeSwap.js @@ -0,0 +1,70 @@ +/** + * Retrieves a cookies value + * @param {string} cname Cookie name + * @returns {string} Cookie value + */ +function getCookie(cname) { + let name = cname + "="; + let decodedCookie = decodeURIComponent(document.cookie); + let ca = decodedCookie.split(';'); + for(let i = 0; i <ca.length; i++) { + let c = ca[i]; + while (c.charAt(0) === ' ') { + c = c.substring(1); + } + if (c.indexOf(name) === 0) { + return c.substring(name.length, c.length); + } + } + return ""; +} + +/** + * Sets/creates a cookie + * @param {string} cname Cookie name + * @param {string} cvalue Cookie value + * @param {number} exdays Cookie lifespan (days) + */ +function setCookie(cname, cvalue, exdays) { + const d = new Date(); + d.setTime(d.getTime() + (exdays*24*60*60*1000)); + let expires = "expires="+ d.toUTCString(); + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/;SameSite=Strict;Domain=.diskfloppy.me"; +} + +/** + * Checks if a cookie exists + * @param {string} cname Cookie name + * @returns {boolean} If cookie exists or not + */ +function cookieExists(cname) { + const cvalue = getCookie(cname); + return cvalue !== ""; +} + +/** + * Swaps the colorscheme + * @param {string} scheme Color scheme ID + */ +function swapScheme(scheme) { + setCookie("colorscheme", scheme, 90); + document.getElementById("css-colorscheme").href = `/css/colorschemes/${scheme}.css`; + console.log(`Set colorscheme to ${getCookie("colorscheme")}`) +} + +function setSchemeSelector() { + if (!cookieExists("colorscheme")) { + setCookie("colorscheme", "catppuccin-macchiato", 90); + } else { + const scheme = getCookie("colorscheme"); + const scheme_selector = document.getElementById("scheme-selector"); + if (scheme && scheme_selector) { + for (let option of scheme_selector.options) { + if (option.value === scheme) { + option.selected = true; + break; + } + } + } + } +} |