-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathai.html
More file actions
59 lines (56 loc) · 2.11 KB
/
ai.html
File metadata and controls
59 lines (56 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<title>AI-Generated Quotes</title>
<style>
.card {
transition: transform 0.2s;
}
.copy-btn {
cursor: pointer;
}
</style>
</head>
<body>
<div class="container mt-5">
<h1 class="text-center mb-4">AI-Generated Quotes</h1>
<div id="ai-quotes" class="row"></div>
</div>
<script>
const aiQuotes = JSON.parse(localStorage.getItem('aiQuotes')) || [];
const quotesContainer = document.getElementById('ai-quotes');
// Check if aiQuotes is empty and display a message
if (aiQuotes.length === 0) {
quotesContainer.innerHTML = '<p class="text-center">No quotes available. Please generate some first.</p>';
} else {
aiQuotes.forEach(quoteData => {
const quoteCard = `
<div class="col-md-4 mb-4">
<div class="card shadow-sm">
<div class="card-body">
<p class="card-text">${quoteData.quote}</p>
<button class="btn btn-primary copy-btn" onclick="copyQuote('${quoteData.quote.replace(/'/g, "\\'")}')">Copy Quote</button>
</div>
</div>
</div>
`;
quotesContainer.innerHTML += quoteCard;
});
}
// Function to copy the quote to the clipboard
function copyQuote(quote) {
navigator.clipboard.writeText(quote)
.then(() => {
alert('Quote copied to clipboard!');
})
.catch(err => {
console.error('Failed to copy: ', err);
alert('Failed to copy quote. Please try again.'); // Alert the user on failure
});
}
</script>
</body>
</html>