Title: Frozen Notes with The Frozen Ground and Clipboard API
Level: Intermediate (Secure context required: https:// or http://localhost)
Description:
Inspired by Nicolas Cage’s intense role in The Frozen Ground, this project uses the Clipboard API to create a web application for managing and organizing text snippets and notes. The application captures the meticulous and investigative spirit of Cage’s character, Jack Halcombe, allowing users to copy, paste, and manage clipboard data efficiently. The project emphasizes security and precision, ensuring users can handle sensitive information with care, much like the investigative process depicted in the film.
Features:
- Clipboard Interaction: Copy text to the clipboard and paste from it.
- Note Management: Save, edit, and delete notes with ease.
- Secure Handling: Ensure secure handling of clipboard data, mirroring the careful investigation in The Frozen Ground.
Starting Code:
Beginner Hints:
- Create a single
index.htmlfile. - Copy the full HTML code block into that file.
- Open
index.htmlin your browser. If something doesn’t work, try a local server likepython -m http.server. - Open DevTools Console to spot errors and typos quickly.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Frozen Notes with The Frozen Ground</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #e0f7fa;
color: #333;
text-align: center;
padding: 20px;
}
#note-container {
display: flex;
flex-direction: column;
align-items: center;
}
.note {
background-color: #ffffff;
border: 1px solid #cccccc;
border-radius: 5px;
padding: 10px;
margin: 10px;
width: 300px;
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
}
textarea {
width: 80%;
height: 100px;
margin: 10px 0;
}
button {
background-color: #00796b;
color: white;
border: none;
padding: 10px 20px;
cursor: pointer;
border-radius: 5px;
font-size: 16px;
margin: 5px;
}
button:hover {
background-color: #004d40;
}
</style>
</head>
<body>
<h1>Frozen Notes with The Frozen Ground</h1>
<p>Efficiently manage and organize your notes inspired by investigative precision.</p>
<div>
<textarea id="clipboard-input" placeholder="Type your note here..."></textarea>
<div>
<button onclick="copyToClipboard()">Copy to Clipboard</button>
<button onclick="pasteFromClipboard()">Paste from Clipboard</button>
<button onclick="saveNote()">Save Note</button>
</div>
</div>
<div id="note-container"></div>
<script>
async function copyToClipboard() {
const text = document.getElementById('clipboard-input').value;
try {
await navigator.clipboard.writeText(text);
alert('Text copied to clipboard!');
} catch (err) {
alert('Failed to copy text: ' + err);
}
}
async function pasteFromClipboard() {
try {
const text = await navigator.clipboard.readText();
document.getElementById('clipboard-input').value = text;
alert('Text pasted from clipboard!');
} catch (err) {
alert('Failed to read clipboard contents: ' + err);
}
}
function saveNote() {
const text = document.getElementById('clipboard-input').value;
if (text) {
const noteContainer = document.getElementById('note-container');
const note = document.createElement('div');
note.className = 'note';
note.textContent = text;
noteContainer.appendChild(note);
document.getElementById('clipboard-input').value = '';
} else {
alert('Please enter some text to save.');
}
}
</script>
</body>
</html>
References:
Project Overview:
This project blends the meticulous investigative spirit of The Frozen Ground with the functional capabilities of the Clipboard API. Users can efficiently manage their notes, copying, pasting, and securely handling clipboard data. The application’s design and functionality reflect the precision and care required in an investigation, making the learning process both engaging and practical. Embrace the spirit of Nicolas Cage’s determined character to master clipboard management and note-taking. Praise Cage!