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

Fixes Issue#29, Issue#30, Issue#33, Issue#35. #64

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes
81 changes: 38 additions & 43 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,38 @@
<script src='https://kit.fontawesome.com/49a2f38d1d.js' crossorigin='anonymous'></script>
<title>Notes app</title>

<link rel = "icon" href = "notes-1.png" type = "image/x-icon">
<link rel="icon" href="images/notes-1.png" type="image/x-icon">

<link rel="stylesheet" href="style.css">
<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://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" crossorigin="anonymous">
<style>
body{background: var(--color-secondary)}

.toast{
color: white;
background: var(--color-secondary);
}
.fade {
transition-duration: 1s;
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
crossorigin="anonymous">

<script defer src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script defer src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<script src="scripts/getInitialProps.js"></script>
<script defer src="scripts/app.js"></script>
<script defer src="scripts/initialMuteState.js"></script>
</head>

<body>
<body style="background: var(--color-secondary)">
<div class="scroll-up-btn">
<i class="fas fa-angle-up"></i>
</div>
<!-- navbar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">


<img class="logo" src="notes-1.png" alt="">
<img class="logo" src="images/notes-1.png" alt="">

<a class="navbar-brand" href="#">Notes</a>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" id="searchTxt">
Expand All @@ -54,7 +57,7 @@
</li>

</ul>
<i id="mute-button" onclick="toggleMute()" class='fas fa-volume-up blue-mute'></i>
<i id="mute-button" onclick="toggleMute()" class='fas blue-mute'></i>
<form class="form-inline my-2 my-lg-0">

<!-- theme switcher -->
Expand Down Expand Up @@ -85,13 +88,12 @@ <h5 class="card-title" style="color: rgb(134, 153, 237);">Add a note
</h5>
<div class="form-group">
<input class="form-control" id="heading" rows="1" placeholder="Title"
onkeydown="if(event.keyCode==13 && !event.ctrlKey && !event.shiftKey){document.getElementById('addTxt').focus(); return false;}"
></input> <br>
onkeydown="if(event.keyCode==13 && !event.ctrlKey && !event.shiftKey){document.getElementById('addTxt').focus(); return false;}"></input>
<br>
<!-- Adding checkbox in HTML -->
<input type="checkbox" id="useDefaultTitle"> Use Default Title<br>
<textarea class="form-control" id="addTxt" rows="3" placeholder="Note"
onkeydown="if(event.keyCode==13 && !event.ctrlKey && !event.shiftKey){document.getElementById('addBtn').click(); return false;}"
></textarea>
<input type="checkbox" id="useDefaultTitle"> Use Default Title<br>
<textarea class="form-control" id="addTxt" rows="3" placeholder="Note"
onkeydown="if(event.keyCode==13 && !event.ctrlKey && !event.shiftKey){document.getElementById('addBtn').click(); return false;}"></textarea>

</div>
<button class="btn btn-primary" id="addBtn" style="margin-top: 7px;">Add Note</button>
Expand All @@ -101,26 +103,19 @@ <h5 class="card-title" style="color: rgb(134, 153, 237);">Add a note
<h3 style="color: rgb(134, 153, 237); margin-top: 8px;">Your Notes</h3>
<div id="notes" class="row container-fluid"> </div>
</div>
</div>


<!-- *** Toast Message *** -->
<div id="" role="alert" aria-live="assertive" aria-atomic="true" class="toast" data-animation="true" data-autohide="true" data-delay="1000" style="position: absolute; top:90vh; right:18px;color: var(--font-color); ">
<img src="images/check-mark.png" class="rounded mr-2" width="23px">
<span>Note Created Successfully!</span>
</div>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<script src="app.js"></script>
</div>


<!-- *** Toast Message *** -->
<div id="" role="alert" aria-live="assertive" aria-atomic="true" class="toast" data-animation="true"
data-autohide="true" data-delay="1000"
style="position: absolute; top:90vh; right:18px;color: var(--font-color); ">
<img src="images/check-mark.png" class="rounded mr-2" width="23px">
<span>Note Created Successfully!</span>
</div>



</body>

</html>
</html>
80 changes: 41 additions & 39 deletions app.js → scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ addbtn.addEventListener("click", addaNote);
searchTxt.addEventListener("keypress", function (event) {
if (event.key === 'Enter') {
event.preventDefault();
searchtext();
searchtext();
}
});

//Functions
// let notesArray=[]
function showNotes(searchTerm="") {
function showNotes(searchTerm = "") {
let notes = localStorage.getItem("notes");
if (notes == null) {
notesArray = [];
Expand Down Expand Up @@ -71,45 +71,45 @@ function addaNote() {
}
let useDefaultTitle = document.getElementById("useDefaultTitle").checked;
if (addtext.value !== "") {
if (heading.value === "" && useDefaultTitle){
if (heading.value === "" && useDefaultTitle) {
let title = getDefaultTitle(addtext.value);
notesArray.push([title, addtext.value]);
localStorage.setItem("notes", JSON.stringify(notesArray));
addtext.value = "";
heading.value = "";
$(".toast").toast("show");
if (volumeButton.classList.contains('fa-volume-up')) {
audio.play();
if (volumeButton.classList.contains('fa-volume-up')) {
audio.play();
}
}
}
else if(heading.value === "" && !useDefaultTitle){
else if (heading.value === "" && !useDefaultTitle) {
styledTitle.innerHTML =
'<div class="alert alert-warning" role="alert" style="background: #b5f2fb;">Title cannot be empty! Please enter a title or check the below box for default title</div>';
setTimeout(() => {
styledTitle.innerHTML = "";
}
, 4000);
}
else {
let title = heading.value;
notesArray.push([title, addtext.value]);
localStorage.setItem("notes", JSON.stringify(notesArray));
addtext.value = "";
heading.value = "";
$(".toast").toast("show");
if (volumeButton.classList.contains('fa-volume-up')) {
audio.play();
, 4000);
}
}

} else {
styledMessageContainer.innerHTML =
'<div class="alert alert-warning" role="alert">Notes cannot be empty!</div>';
setTimeout(() => {
styledMessageContainer.innerHTML = "";
else {
let title = heading.value;
notesArray.push([title, addtext.value]);
localStorage.setItem("notes", JSON.stringify(notesArray));
addtext.value = "";
heading.value = "";
$(".toast").toast("show");
if (volumeButton.classList.contains('fa-volume-up')) {
audio.play();
}
}

} else {
styledMessageContainer.innerHTML =
'<div class="alert alert-warning" role="alert">Notes cannot be empty!</div>';
setTimeout(() => {
styledMessageContainer.innerHTML = "";
}
, 2000);

}
showNotes();
}
Expand Down Expand Up @@ -138,7 +138,7 @@ function editNote(index) {
const update = [heading.value + " (Edited) " + " " + n, addtext.value];
console.log(update);


if (update.length > 0) {
notesObj.splice(index, 1, update);

Expand Down Expand Up @@ -175,7 +175,7 @@ function deleteNote(index) {
function searchtext() {
let inputVal = searchTxt.value.toLowerCase();

const cardy=document.getElementsByClassName("card");
const cardy = document.getElementsByClassName("card");
for (let i = 0; i < cardy.length; i++) {
cardy[i].style.display = "none";
}
Expand Down Expand Up @@ -216,25 +216,27 @@ function toggleTheme() {

function toggleMute() {
if (volumeButton.classList.contains("fa-volume-mute")) {
localStorage.setItem("isMuted", "unmute");
volumeButton.classList.remove("fa-volume-mute");
volumeButton.classList.add("fa-volume-up");
} else {
localStorage.setItem("isMuted", "mute");
volumeButton.classList.remove("fa-volume-up");
volumeButton.classList.add("fa-volume-mute");
}
}
document.addEventListener("DOMContentLoaded", function() {
window.addEventListener("scroll", function() {
var scrollY = window.scrollY || document.documentElement.scrollTop;

if (scrollY > 200) {
document.querySelector('.scroll-up-btn').classList.add("show");
} else {
document.querySelector('.scroll-up-btn').classList.remove("show");
}
document.addEventListener("DOMContentLoaded", function () {
window.addEventListener("scroll", function () {
var scrollY = window.scrollY || document.documentElement.scrollTop;

if (scrollY > 200) {
document.querySelector('.scroll-up-btn').classList.add("show");
} else {
document.querySelector('.scroll-up-btn').classList.remove("show");
}
});

document.querySelector('.scroll-up-btn').addEventListener("click", function() {
window.scrollTo({ top: 0, behavior: 'smooth' });
document.querySelector('.scroll-up-btn').addEventListener("click", function () {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
});
1 change: 1 addition & 0 deletions scripts/getInitialProps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const isMuted = localStorage.getItem("isMuted");
5 changes: 5 additions & 0 deletions scripts/initialMuteState.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (isMuted == "mute") {
volumeButton.classList.add("fa-volume-mute");
} else {
volumeButton.classList.add("fa-volume-up");
}
12 changes: 8 additions & 4 deletions style.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
body {
background: var(--color-secondary);
}

body{background: var(--color-secondary)}

.toast{
color: white;
background: var(--color-secondary);
}
.fade {
transition-duration: 1s;
}
.theme-light {
--color-primary: #17ed90;
--color-secondary: #fbfbfe;
Expand Down