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
- Ổ 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
- Google sheet webapp|Nhập liệu-Quản lý khách hàng – Click tên hiển thị popup thông tin thêm – Print
- Google sheet webapp | Multi Load table data từ google sheet lên web và frezee header of table.
- HTML WEBAPP CSS -Mô phỏng hệ mặt trời -Trái đất -Mặt trăng đơn giản trên nền vũ trụ đen sao lấp lánh
- Google sheet Webapp Script | Tìm kiếm, lọc và In chi tiết thông tin sản phẩm của mã Khách hàng
- Google sheet Apps script | Data Entry Popup From – Thêm mới – Chỉnh sửa – Xóa
- Google sheet Webapp Script | Quản lý đặt xe cho chuyến đi – Tài xế cập nhật hoàn thành thông tin
- Apps script Webapp | Lấy giá trị Input hiển thị lên – Web Get value input field display on web
- Google sheet Apps script | Todo List and Send mail – Tạo danh sách nhắc việc và gửi mail
- Web App Script | Bộ Icon CSS Rất dễ lập trình cho giao diện webapp
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>