
Please check if this code is correct for a client-side Node.js document editor. Please fix if there are any errors
const url = "http://localhost:3000/POST";
let undoStack = [];
let redoStack = [];
function formatText(command) {
document.execCommand(command, false, null);
}
function changeColor() {
const color = prompt("Enter text color code:");
document.execCommand("foreColor", false, color);
}
function changeFont() {
const font = prompt("Enter font:");
document.execCommand("fontName", false, font);
}
function changeFontSize() {
const size = prompt("Enter font size:");
document.execCommand("fontSize", false, size);
}
function toUpperCase() {
const selectedText = window.getSelection().toString();
document.execCommand("insertText", false, selectedText.toUpperCase());
}
function toLowerCase() {
const selectedText = window.getSelection().toString();
document.execCommand("insertText", false, selectedText.toLowerCase());
}
function increaseImageSize() {
const selectedImage = document.querySelector('img.resizable');
if (selectedImage) {
const currentWidth = selectedImage.width;
selectedImage.style.width = (currentWidth * 1.2) + 'px';
}
}
function printDocument() {
const buttons = document.querySelectorAll("button");
buttons.forEach(button => {
button.style.display = "none";
});
const editorContent = document.getElementById("editor").innerHTML;
const printWindow = window.open("", "", "width=600,height=600");
printWindow.document.write("<html><head><title>Print</title><style>@media print { button { display: none; } }</style></head><body>");
printWindow.document.write(editorContent);
printWindow.document.write("</body></html>");
printWindow.document.close();
printWindow.print();
buttons.forEach(button => {
button.style.display = "";
});
}
function undo() {
if (undoStack.length > 0) {
redoStack.push(document.getElementById("editor").innerHTML);
document.getElementById("editor").innerHTML = undoStack.pop();
}
}
function redo() {
if (redoStack.length > 0) {
undoStack.push(document.getElementById("editor").innerHTML);
document.getElementById("editor").innerHTML = redoStack.pop();
}
}
function textAlign(align) {
document.execCommand('justify' + align);
}
function toggleSettings() {
const settingsBar = document.getElementById("settingsBar");
settingsBar.style.right = settingsBar.style.right === "0px" ? "-290px" : "0px";
}
function toggleMode() {
document.body.classList.toggle("light-mode");
document.body.classList.toggle("dark-mode");
}
document.addEventListener("DOMContentLoaded", function() {
const settingsIcon = document.getElementById("settingsIcon");
if (settingsIcon) {
settingsIcon.addEventListener("click", function() {
toggleSettings();
});
} else {
console.error("Settings icon not found.");
}
});
document.addEventListener("DOMContentLoaded", function() {
const popupBox = document.getElementById("popupBox");
const closePopup = document.getElementById("closePopup");
if (popupBox && closePopup) {
popupBox.style.display = "block";
closePopup.addEventListener("click", function() {
popupBox.style.display = "none";
});
} else {
console.error("Popup elements not found.");
}
});

Step by stepSolved in 2 steps

- Create a new file cart.html You must get and set the data on the web page by using document.getElementById( ). Each HTML element on the web page already has an id so it is easy. No need for a loop to go through the list of products, there is only 2 products and the info is hard coded on the web page. You must write the code for function cartTotal().arrow_forward2. A sequential circuit with two D flip-flops A and B, two inputs X and Y, and one output Z is specified by the following input and output equations: DA = AX+XY DB = BX + XY Z = AB a b. . C Draw the logic diagram of the circuit Derive the state table for the circuit Derive the state diagram for the circuit.arrow_forwardPlease check if this code is correct for a client-side Node.js document editor const url = "http://localhost:3000/POST"; let undoStack = []; let redoStack = []; function formatText(command) { document.execCommand(command, false, null); } function changeColor() { const color = prompt("Enter text color code:"); document.execCommand("foreColor", false, color); } function changeFont() { const font = prompt("Enter font:"); document.execCommand("fontName", false, font); } function changeFontSize() { const size = prompt("Enter font size:"); document.execCommand("fontSize", false, size); } function toUpperCase() { const selectedText = window.getSelection().toString(); document.execCommand("insertText", false, selectedText.toUpperCase()); } function toLowerCase() { const selectedText = window.getSelection().toString(); document.execCommand("insertText", false, selectedText.toLowerCase()); } function increaseImageSize() { const…arrow_forward
- DO NOT COPY FROM OTHER WEBSITESarrow_forwardFilename: runlength_decoder.py Starter code for data: hw4data.py Download hw4data.py Download hw4data.pyYou must provide a function named decode() that takes a list of RLE-encoded values as its single parameter, and returns a list containing the decoded values with the “runs” expanded. If we were to use Python annotations, the function signature would look similar to this:def decode(data : list) -> list: Run-length encoding (RLE) is a simple, “lossless” compression scheme in which “runs” of data. The same value in consecutive data elements are stored as a single occurrence of the data value, and a count of occurrences for the run. For example, using Python lists, the initial list: [‘P’,‘P’,‘P’,‘P’,‘P’,‘Y’,‘Y’,‘Y’,‘P’,‘G’,‘G’] would be encoded as: ['P', 5, 'Y', 3, ‘P’, 1, ‘G’, 2] So, instead of using 11 “units” of space (if we consider the space for a character/int 1 unit), we only use 8 “units”. In this small example, we don’t achieve much of a savings (and indeed the…arrow_forwardPlease provide explanation of codearrow_forward
- Please check if this code is correct for a client-side Node.js document editor const url = "http://localhost:3000/POST"; let undoStack = []; let redoStack = []; function formatText(command) { document.execCommand(command, false, null); } function changeColor() { const color = prompt("Enter text color code:"); document.execCommand("foreColor", false, color); } function changeFont() { const font = prompt("Enter font:"); document.execCommand("fontName", false, font); } function changeFontSize() { const size = prompt("Enter font size:"); document.execCommand("fontSize", false, size); } function toUpperCase() { const selectedText = window.getSelection().toString(); document.execCommand("insertText", false, selectedText.toUpperCase()); } function toLowerCase() { const selectedText = window.getSelection().toString(); document.execCommand("insertText", false, selectedText.toLowerCase()); } function increaseImageSize() { const…arrow_forwardWhat do the urlretrieve and urlopen functions do?arrow_forwardWhat happens when this code runs? newP = document.createElement("p");newP.setAttribute("id", "p3"); newP.innerHTML = "This is a paragraph";document.body.appendChild(newP); A new paragraph saying "This is a paragraph" is inserted at the bottom of the page. A new paragraph saying "This is a paragraph" is inserted at the top of the page.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





