Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1 --add default message #2

Merged
merged 1 commit into from Sep 20, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -1,68 +1,80 @@
<!doctype html>
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<head>
<meta charset="utf-8" />
<title>My Web Note</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="https://fonts.google.com/specimen/Josefin+Sans">
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://fonts.google.com/specimen/Josefin+Sans"
/>
<style>
body {
background-image: url("https://ak0.picdn.net/shutterstock/videos/935170/thumb/1.jpg");
}
body {
background-image: url("https://ak0.picdn.net/shutterstock/videos/935170/thumb/1.jpg");
}
</style>
</head>
</head>

<body>
<body>
<div class=" container">
<div class="raw" style="font-family: Josefin Sans, serif">
<h1 class="font-weight-bold text-center mt-5 mb-4">Take Notes Here!!!</h1>
<div class="border rounded" id="note" style="overflow-y: scroll; height: 200px; background-color: white" contenteditable></div>
</div>
<div class="raw">
<div class="text-right my-3">
<button id="clear" class="btn btn-primary px-4">Clear</button>
<button id="save" class="btn btn-primary px-4">Save</button>
</div>
<div class="raw" style="font-family: Josefin Sans, serif">
<h1 class="font-weight-bold text-center mt-5 mb-4">
Take Notes Here!!!
</h1>
<div
class="border rounded"
id="note"
style="overflow-y: scroll; height: 200px; background-color: white"
contenteditable
></div>
</div>
<div class="raw">
<div class="text-right my-3">
<button id="clear" class="btn btn-primary px-4">Clear</button>
<button id="save" class="btn btn-primary px-4">Save</button>
</div>
</div>
</div>

<script src="https://unpkg.com/filer/dist/filer.min.js"></script>
<script>
const fs = new Filer.FileSystem();
var note = document.querySelector('#note');
const fs = new Filer.FileSystem();
var note = document.querySelector("#note");
window.addEventListener('DOMContentLoaded', (event) => {
note.focus();
fs.readFile('/note', 'utf8', function (err, data) {
if (err) {
console.log("Welcome to my notepad!");
throw err;
}
if (data) note.innerHTML = data;
});
document.querySelector('#clear').addEventListener("click", clearContent);
document.querySelector('#save').addEventListener("click", saveContent);
window.addEventListener("DOMContentLoaded", event => {
fs.readFile("/note", "utf8", function(err, data) {
if (err) {
throw err;
}
if (data) note.innerHTML = data;
else note.innerHTML = "Welcome to my notepad!";

This comment has been minimized.

Copy link
@mpark86

mpark86 Sep 23, 2019

Owner

Good point! Very simple way to display a default message if there is no data.

});
function saveContent() {
fs.writeFile('/note', note.innerHTML, function (err) {
if (err) throw err;
document
.querySelector("#clear")
.addEventListener("click", clearContent);
document.querySelector("#save").addEventListener("click", saveContent);
});
if (note.innerHTML)
alert("Contents saved!");
});
}
function saveContent() {
fs.writeFile("/note", note.innerHTML, function(err) {
if (err) throw err;
function clearContent() {
fs.writeFile('/note', "", function (err) {
if (err) throw err;
note.innerHTML = "";
});
}
</script>
</body>
if (note.innerHTML) alert("Contents saved!");
});
}
</html>
function clearContent() {
fs.writeFile("/note", "", function(err) {
if (err) throw err;
note.innerHTML = "";
});
}
</script>
</body>
</html>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.