This is an HTML, CSS, and JavaScript code snippet that appears to be a custom web page for a digital writer named Suresh. The page includes a scrolling text section, a table with a single blue row header, and buttons for copying, downloading, editing, and sharing the content.
Here's a breakdown of the code:
HTML Section
- The HTML code defines the structure of the web page. It includes:
- A scrolling text section with the text "Digital writer Suresh".
- A table with a single blue row header and three rows of data.
- Four buttons for copying, downloading, editing, and sharing the content.
- A notifications container for displaying messages to the user.
CSS Section
- The CSS code defines the styles for the web page. It includes:
- Styles for the custom buttons, including their width, height, border radius, border, color, cursor, and text alignment.
- Styles for the buttons' background colors.
JavaScript Section
- The JavaScript code defines the functionality of the web page. It includes:
- A function updateScrollingText() that updates the scrolling text section with a new message and animation.
- A function copyCode() that copies the content of the table to the clipboard.
- A function downloadCode() that downloads the content of the table as a PDF file.
- A function toggleEditMode() that toggles the edit mode of the table.
- A function sharePage() that shares the page URL.
- A function showNotification() that displays a notification message to the user.
| Digital Writer Suresh | ||
| Row 1, Cell 1 | Row 1, Cell 2 | Row 1, Cell 3 |
| Row 2, Cell 1 | Row 2, Cell 2 | Row 2, Cell 3 |
| Row 3, Cell 1 | Row 3, Cell 2 | Row 3, Cell 3 |
Overall, this code snippet appears to be a custom web page for a digital writer, providing features for copying, downloading, editing, and sharing content.
Download the table code:
<p> </p><p><br /></p><p><div style="border-radius: 10px; border: 3px solid rgb(136, 136, 136); margin: 20px; padding: 10px;">
<!--Scrolling text section-->
<div style="background-color: #f0f0f0; border-radius: 5px; margin-bottom: 10px; overflow: hidden; padding: 5px; width: 100%;">
<div id="scrollingText" style="color: #4caf50; font-size: 16px; font-weight: bold; text-align: center; white-space: nowrap;">
Digital writer Suresh
</div>
</div>
<!--Top bar with buttons arranged in two rows-->
<div style="display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;">
<div style="display: flex; gap: 10px;">
<button class="custom-button" onclick="copyCode()">Copy</button>
<button class="custom-button" onclick="downloadCode()">Download</button>
</div>
<div style="display: flex; gap: 10px; margin-top: 10px;">
<button class="custom-button" id="editButton" onclick="toggleEditMode()">Edit</button>
<button class="custom-button" onclick="sharePage()">Share</button>
</div>
</div>
<!--3x3 Table with a single blue row header-->
<div style="background-color: white; border: 1px solid rgb(221, 221, 221); margin-top: 10px; padding: 10px;">
<table contenteditable="false" id="codeTable" style="border-collapse: collapse; font-family: monospace; font-size: 14px; width: 100%;">
<tbody>
<tr style="background-color: #e0f7fa;">
<td colspan="3" style="border: 1px solid rgb(221, 221, 221); color: blue; font-weight: bold; padding: 8px; text-align: center;">
Digital Writer Suresh
</td>
</tr>
<tr style="background-color: #f9f9f9;">
<td style="border: 1px solid rgb(221, 221, 221); padding: 8px;"><span style="color: red;">Row 1, Cell 1</span></td>
<td style="border: 1px solid rgb(221, 221, 221); padding: 8px;"><span style="color: red;">Row 1, Cell 2</span></td>
<td style="border: 1px solid rgb(221, 221, 221); padding: 8px;"><span style="color: red;">Row 1, Cell 3</span></td>
</tr>
<tr style="background-color: #eaeaea;">
<td style="border: 1px solid rgb(221, 221, 221); padding: 8px;">Row 2, Cell 1</td>
<td style="border: 1px solid rgb(221, 221, 221); padding: 8px;">Row 2, Cell 2</td>
<td style="border: 1px solid rgb(221, 221, 221); padding: 8px;">Row 2, Cell 3</td>
</tr>
<tr style="background-color: #f9f9f9;">
<td style="border: 1px solid rgb(221, 221, 221); padding: 8px;">Row 3, Cell 1</td>
<td style="border: 1px solid rgb(221, 221, 221); padding: 8px;">Row 3, Cell 2</td>
<td style="border: 1px solid rgb(221, 221, 221); padding: 8px;">Row 3, Cell 3</td>
</tr>
</tbody>
</table>
</div>
<div id="notificationsContainer" style="align-items: center; display: flex; flex-direction: column; gap: 10px; left: 50%; position: fixed; top: 50%; transform: translate(-50%, -50%);"></div>
<script>
let isEditing = false;
function updateScrollingText() {
const scrollingText = document.getElementById("scrollingText");
scrollingText.textContent = "Digital writer Suresh";
scrollingText.style.color = "#4caf50";
scrollingText.style.animation = "scrollingText 5s linear";
setTimeout(() => {
scrollingText.style.animation = "none";
scrollingText.textContent = "Download the code";
scrollingText.style.color = "#ff5722";
setTimeout(() => {
scrollingText.style.opacity = "0";
setTimeout(() => {
scrollingText.style.opacity = "1";
updateScrollingText();
}, 1000);
}, 1000);
}, 5000);
}
updateScrollingText();
function copyCode() {
var copyText = document.getElementById("codeTable").innerText;
navigator.clipboard.writeText(copyText).then(function() {
showNotification("Copied successfully", "#4caf50");
}, function(err) {
alert("Failed to copy the code!");
});
}
function downloadCode() {
var codeTableHtml = document.getElementById("codeTable").outerHTML;
var watermark = "<p style='color: gray; font-size: 12px; text-align: center;'>--- Digital Writer Suresh ---</p>";
var fileContent = "<html><body>" + codeTableHtml + watermark + "</body></html>";
var pageTitle = document.title;
var timestamp = new Date().toLocaleString("en-GB", {
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', second: '2-digit',
hour12: false
}).replace(/[\/, :]/g, '-');
var milliseconds = new Date().getMilliseconds();
var fileName = `${pageTitle} - DigitalWriterSuresh - ${timestamp}-${milliseconds}.pdf`;
// Convert to PDF
var pdfWindow = window.open("", "_blank");
pdfWindow.document.write(`
<html>
<head>
<title>${fileName}</title>
</head>
<body>${codeTableHtml}${watermark}</body>
</html>
`);
pdfWindow.document.close();
pdfWindow.print();
showNotification("Downloaded successfully with watermark", "#ff9800");
}
function toggleEditMode() {
var codeTable = document.getElementById("codeTable");
var editButton = document.getElementById("editButton");
if (!isEditing) {
codeTable.contentEditable = "true";
codeTable.style.border = "1px dashed #2196F3";
editButton.textContent = "Save";
showNotification("Now in edit mode", "#2196f3");
} else {
codeTable.contentEditable = "false";
codeTable.style.border = "1px solid rgb(221, 221, 221)";
editButton.textContent = "Edit";
showNotification("Saved successfully", "#4caf50");
}
isEditing = !isEditing;
}
function sharePage() {
var pageUrl = window.location.href;
navigator.clipboard.writeText(pageUrl).then(function() {
showNotification("Page URL copied for sharing", "#673ab7");
}).catch((error) => {
showNotification("Error sharing the page", "red");
});
}
function showNotification(message, color) {
const notification = document.createElement("div");
notification.textContent = message;
notification.style.backgroundColor = color;
notification.style.color = "white";
notification.style.padding = "10px 20px";
notification.style.borderRadius = "5px";
notification.style.opacity = "1";
notification.style.transition = "opacity 0.5s ease";
const notificationsContainer = document.getElementById("notificationsContainer");
notificationsContainer.appendChild(notification);
setTimeout(function() {
notification.style.opacity = "0";
setTimeout(function() {
notificationsContainer.removeChild(notification);
}, 500);
}, 2000);
}
</script>
</div>
<style>
.custom-button { width: 120px; height: 40px; border-radius: 5px; border: none; color: white; cursor: pointer; text-align: center; }
.custom-button:nth-child(1) { background-color: #FF6347; }
.custom-button:nth-child(2) { background-color: #4682B4; }
.custom-button:nth-child(3) { background-color: #32CD32; }
.custom-button:nth
</style></p><p><br /></p><p><br /></p>
Tags:
Blogger
