Apps script Webapp CSS – HTML – JS | Tạo ứng dụng Ghi chú trên nền tảng webapp – website
Giaoan.link chia sẻ một project về “Apps script Webapp CSS – HTML – JS | Tạo ứng dụng Ghi chú trên nền tảng webapp – website”. Đây là ứng dụng css, html, js nên bạn cũng có thể sử dụng trên nền tảng website, blog. Ghi chú có chức năng tạo mới và xóa. Dữ liệu được lưu trữ trên máy cục bộ (trên trình duyệt của bạn). Dưới đây là link video hướng dẫn, demo. Phần bên dưới là mã code trong project.
Bạn truy cập trang tổng hợp các projet excel, googlesheet, apps script.
Các Project ngẫu nhiên
- Tạo hóa đơn trên Google sheet – Gửi email đính kèm hóa đơn pdf – Quản lý url hóa đơn trên danh sách
- Google sheet Ứng dụng theo dõi đơn hàng – Danh sách sản phẩm mua, trạng thái đơn hàng
- Tip on Ms Word Hướng dẫn tạo ngắt trang, xóa ngắt trang đơn lẽ hoặc toàn bộ ngắt trang trên file doc
- Google sheet | Generate QR Codes – Mã hóa nội dung Cell – Thêm hình ở giữa mã QR code
- Google sheet App Script | Tạo custom menu – Xóa tất cả dòng Rỗng trên vùng dữ liệu Nhanh chống
- Google Script Web | From upload file – Kiểm tra trùng lặp – Ghi đè hoặc Tạo phiên bản mới cho file
- Google Script Web | Trang Tìm kiếm nhiều điều kiên riêng lẽ hoặc hết hợp – Print, Xuất file PDF
- Hướng dẫn kiểm tra Bàn phím, Tháo và thay bàn phím mới cho Dell Inspirion 15 3000 series
- Google sheet webapp | Quản lý bán hàng – Chức nằn trả góp, In thông tin
- Ổ C đầy Di chuyển dữ liệu ZALO sang Ổ D hoặc ổ khác một cách dễ dàng Không lo zalo báo đầy ổ đĩa
Code trên trang “Code.gs”
function doGet() {
return HtmlService.createTemplateFromFile('note')
.evaluate()
.addMetaTag('viewport', 'width=device-width, initial-scale=1')
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename).getContent();
}
Code trên trang “note.html”
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<?!= include('css'); ?>
</head>
<body>
<div class="container">
<h1><img src="https://lh3.googleusercontent.com/d/1IIqdNulapU4p7hR014ov3C0tLt2vo2-I=w1000?authuser=0"> Ghi chú trên nền webapp</h1>
<button class="btn"><img src="https://lh3.googleusercontent.com/d/1LCZzGgsp6go5Y2eOlFAQ4U1mu0bLkQqL=w1000?authuser=0">Tạo ghi chú</button>
<div class="notes-container">
<!--<p contenteditable="true" class="input-box">
<img src="https://lh3.googleusercontent.com/d/1l7BxmvRg-rstOFayyvpEP85ZSAWvncVq=w1000?authuser=0">
</p> -->
</div>
</div>
<?!= include('javascript'); ?>
</body>
</html>
Code trên trang “css.html”
<style>
*{
margin: 0;
padding: 0;
font-family: 'Poppins', sans-serif;
box-sizing: border-box;
}
.container{
width: 100%;
min-height: 100vh;
background: linear-gradient(130deg, #cc02fe, #fadbf8);
color: #ffffff;
padding-top: 4%;
padding-left: 10%;
}
.container h1{
display: flex;
align-items: center;
font-size: 35 px;
font-weight: bold;
color: yellow;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
.container h1 img{
width: 80px;
}
.container button img{
width: 25px;
margin-right: 8px;
}
.container button{
display: flex;
align-items: center;
background: linear-gradient(#9418fd, #571094);
color: #ffffff;
font-size: 18px;
outline: 0;
border: 0;
border-radius: 40px;
padding: 10px 15px;
margin: 30px 0 20px;
cursor: pointer;
}
.input-box{
position: relative;
width: 100%;
max-width: 500px;
min-height: 150px;
background: #f1e97e;
font-size: 18px;
color: #333;
padding: 20px;
margin: 20px 0;
outline:0;
border: 1px solid #000;
box-shadow: 2px 2px 5px #464444;
border-radius: 10px;
}
.input-box img{
width: 35px;
position: absolute;
bottom: 15px;
right: 15px;
cursor: pointer;
}
</style>
Code trên trang “javascript.html”
<script>
const notesContainer = document.querySelector(".notes-container");
const createBtn = document.querySelector(".btn");
let notes = document.querySelectorAll(".input-box");
function showNotes(){
notesContainer.innerHTML = localStorage.getItem("notes");
}
showNotes();
function updateStorage(){
localStorage.setItem("notes",notesContainer.innerHTML);
}
createBtn.addEventListener("click", ()=>{
let inputBox = document.createElement("p");
let img = document.createElement("img");
inputBox.className = "input-box";
inputBox.setAttribute("contenteditable","true");
img.src = "https://lh3.googleusercontent.com/d/1Sk2OgS6gR3QMRum7Cx5kVPFzMjiIZAGi=w1000?authuser=0";
notesContainer.appendChild(inputBox).appendChild(img);
})
notesContainer.addEventListener("click", function(e){
if(e.target.tagName === "IMG"){
e.target.parentElement.remove();
updateStorage();
}else if(e.target.tagName === "P"){
notes = document.querySelectorAll(".input-box");
notes.forEach(nt =>{
nt.onkeyup = function(){
updateStorage();
}
})
}
})
document.addEventListener("keydown", event =>{
if(event.key === "Enter"){
document.execCommand("insertLineBreak");
event.preventDefault();
}
})
</script>