Get started, instantly
One script. One call. Interactive, highlighted code—no setup hassle.
Here’s the minimal HTML setup you can drop into any page. It just loads the stylesheet and the script, then runs auto-init so existing .PWAxcode blocks upgrade themselves.
Include the CSS (in <head>)Include the JS (right before <body>)
That’s it—no bundler required. You can add per-snippet options via data-* attributes, or switch to programmatic control later with new PWAxcode(el, {...}).
// https://www.geeksforgeeks.org/javascript/how-to-build-notes-app-using-html-css-javascript/
const addBtn = document.querySelector("#addBtn");
const main = document.querySelector("#main");
// Click event listener
addBtn.addEventListener("click", function () {
addNote();
});
// Save button function
const saveNotes = () => {
// Select content textareas
const notes =
document.querySelectorAll(".note .content");
// Select title textareas
const titles =
document.querySelectorAll(".note .title");
const data = [];
notes.forEach((note, index) => {
const content = note.value;
const title = titles[index].value;
console.log(title);
if (content.trim() !== "") {
data.push({ title, content });
}
});
const titlesData =
data.map((item) => item.title);
console.log(titlesData);
localStorage.setItem(
"titles", JSON.stringify(titlesData));
const contentData =
data.map((item) => item.content);
localStorage.setItem(
"notes", JSON.stringify(contentData));
};
// Addnote button function
const addNote = (text = "", title = "") => {
const note = document.createElement("div");
note.classList.add("note");
note.innerHTML = `
`;
function handleTrashClick() {
note.remove();
saveNotes();
}
function handleSaveClick() {
saveNotes();
}
const delBtn = note.querySelector(".trash");
const saveButton = note.querySelector(".save");
const textareas = note.querySelectorAll("textarea");
delBtn.addEventListener("click", handleTrashClick);
saveButton.addEventListener("click", handleSaveClick);
main.appendChild(note);
saveNotes();
};
// Loading all the notes those are saved in
// the localstorage
function loadNotes() {
const titlesData =
JSON.parse(localStorage.getItem("titles")) || [];
const contentData =
JSON.parse(localStorage.getItem("notes")) || [];
for (let i = 0;
i < Math.max(
titlesData.length, contentData.length); i++) {
addNote(contentData[i], titlesData[i]);
}
}
loadNotes();
Drop the CSS/JS in your page and you’re done: call PWAxcode.autoInit() to upgrade all your snippets, or create a single instance with new PWAxcode(el, { bare:true, highlight:true }). No build step, no framework lock-in. Start simple and layer options later—theme, line numbers, ruler, search, and the Player—without changing your markup. Works out of the box for JS/HTML/CSS/JSON/SQL, and you can extend languages via the plugin API.
