This repository has been archived by the owner on Dec 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: format code with Prettier and StandardJS
This commit fixes the style issues introduced in e23f01a according to the output from Prettier and StandardJS. Details: #343
- Loading branch information
1 parent
e23f01a
commit cca202e
Showing
1 changed file
with
19 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
const wordElement = document.getElementById("random-word"); | ||
//Fetch a random word for page title and downloads | ||
async function fetchRandomWord() { | ||
const wordElement = document.getElementById('random-word') | ||
// Fetch a random word for page title and downloads | ||
async function fetchRandomWord () { | ||
try { | ||
const response = await fetch("https://random-word-api.herokuapp.com/word"); | ||
const data = await response.json(); | ||
const response = await fetch('https://random-word-api.herokuapp.com/word') | ||
const data = await response.json() | ||
|
||
document.title = "SLF — " + data; // Set the page title to the random word | ||
document.title = 'SLF — ' + data // Set the page title to the random word | ||
} catch (error) { | ||
console.error("Error fetching word:", error); | ||
console.error('Error fetching word:', error) | ||
} | ||
} | ||
|
||
// Call the function to fetch a random word on page load | ||
fetchRandomWord(); | ||
fetchRandomWord() | ||
// prettier-ignore | ||
{ | ||
document.getElementById("udate").innerHTML = document.getElementById("udate").innerHTML + document.lastModified; | ||
document.getElementById('udate').innerHTML = document.getElementById('udate').innerHTML + document.lastModified | ||
} | ||
// Fetch last modified date and apply it to the udate element that is on some | ||
// pages. | ||
|
||
// Defined the copyToClipboard function, that is used on some pages | ||
function copyToClipboard(text) { | ||
var textarea = document.createElement("textarea"); | ||
textarea.textContent = text; | ||
textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge. | ||
document.body.appendChild(textarea); | ||
textarea.select(); | ||
function copyToClipboard (text) { | ||
const textarea = document.createElement('textarea') | ||
textarea.textContent = text | ||
textarea.style.position = 'fixed' // Prevent scrolling to bottom of page in MS Edge. | ||
document.body.appendChild(textarea) | ||
textarea.select() | ||
try { | ||
return document.execCommand("copy"); // Security exception may be thrown by some browsers. | ||
return document.execCommand('copy') // Security exception may be thrown by some browsers. | ||
} catch (ex) { | ||
console.warn("Copy to clipboard failed.", ex); | ||
return false; | ||
console.warn('Copy to clipboard failed.', ex) | ||
return false | ||
} finally { | ||
document.body.removeChild(textarea); | ||
document.body.removeChild(textarea) | ||
} | ||
} |