Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
[ Smells ] : Cleanup code for DST (#343)
Browse files Browse the repository at this point in the history
* JSD1001 on star

#342

Signed-off-by: Damian Swan <damian.swan@st.gactc.edu>

* 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

* JS0246 @ cca202e

Signed-off-by: Damian Swan <damian.swan@st.gactc.edu>

* Restyled [ Smells ] : Cleanup code for DST (#344)

Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>

* Restyled [ Smells ] : Cleanup code for DST (#345)

* Restyled by clang-format

* Restyled by prettier

* style: format code with Prettier and StandardJS

This commit fixes the style issues introduced in 07efd94 according to the output
from Prettier and StandardJS.

Details: #345

---------

Co-authored-by: Restyled.io <commits@restyled.io>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>

---------

Signed-off-by: Damian Swan <damian.swan@st.gactc.edu>
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
4 people authored Aug 15, 2024
1 parent 9dc89dd commit b72ddf8
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions docs/star.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
const wordElement = document.getElementById("random-word");

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)
}
}

0 comments on commit b72ddf8

Please sign in to comment.