Skip to content

Commit

Permalink
Added styling
Browse files Browse the repository at this point in the history
  • Loading branch information
kcalumpong committed Oct 5, 2019
1 parent 60c1655 commit b418da7
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 323 deletions.
168 changes: 2 additions & 166 deletions public/js/app.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,7 @@
// import { json } from "sequelize/types";

<<<<<<< HEAD
let notes = [];

let currentIndex = null;

$(".back-button").hide();
$(".update-button").hide();
$(".delete-button").hide();

$(document).on("click", ".delete-button", function() {
deleteNote(notes[currentIndex]);
notes.splice(currentIndex, 1);
renderNotes();

clearValue();
})

function renderNotes() {
$(".items").html("");
for (var i = 0; i < notes.length; i++) {
$(".items").append('<li><textarea class="items-input" data-index="' + i + '">' + notes[i].title + "\n" + notes[i].body.slice(0, 11) + '...</textarea></li>')
}
}

renderNotes();
clearValue();
// });

$(document).on("click", ".back-button", function() {
backButtonandSave();
});
=======
//all notes get pushed into here
let notes = [];
>>>>>>> f1732b191562ed10277a6c8a7cbd0040cbe32147

//the value of the notes in the editor
let currentIndex = null;
Expand All @@ -47,7 +14,6 @@ $(document).on("click", ".delete-button", function() {
deleteNote(notes[currentIndex]);
notes.splice(currentIndex, 1);
renderNotes();

clearValue();
});

Expand All @@ -60,11 +26,6 @@ function renderNotes() {

renderNotes();
clearValue();
// });

$(document).on("click", ".back-button", function() {
backButtonandSave();
});

$(document).on("click", ".log-out", function() {
window.location.assign("/");
Expand All @@ -91,56 +52,18 @@ function renderNotes() {

//// SENDING INFO TO BACK END

<<<<<<< HEAD
///saving the note

// Submits a new post and brings user to blog page upon completion
// eslint-disable-next-line no-unused-vars
// function submitNote(note) {
// // $.post("/api/notes/", Note, function() {
// // window.location.reload();
// // });
// console.log(note);
// fetch("http://localhost:3000/api/user/notes", {
// method: "POST",
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify(note)
// })
// .then(res => res.json())
// .then(renderNotes);
// }
// }); // to close document ready function


function submitNote(note) {
$.ajax({
method: "POST",
url: "/api/user/notes",
data: note
}).then(function(response) {
console.log(response)
window.location.href = "/index";
});
=======
var titleInput = $("#title-name");
var bodyInput = $("#write-notes");
var noteId;
var updating = false;

// if (url.indexOf("?post_id=") !== -1) {
// noteId = url.split("=")[1];
// getNoteData(noteId);
// }

// getNoteData(noteId);
getNoteData();

$(".save-button").on("click", function handleFormSubmit(event) {
event.preventDefault();
// Wont submit the post if we are missing a body or a title
if (titleInput.val().trim() === "" || bodyInput.val().trim() === "") {
return;
>>>>>>> f1732b191562ed10277a6c8a7cbd0040cbe32147
}
// Constructing a newPost object to hand to the database
var newNote = {
Expand Down Expand Up @@ -177,34 +100,11 @@ function getNoteData() {
fetch("http://localhost:3000/api/user/notes")
.then(res => res.json())
.then(data => data.map(item => notes.push(item)))
// .then(data => {
// titleInput.val(data.title);
// bodyInput.val(data.body);
// // If we have a post with this id, set a flag for us to know to update the post
// // when we hit submit
// updating = true;
// })

.then(renderNotes)
.catch(err => console.error(err));
}

///saving the note

// Submits a new post and brings user to blog page upon completion
// eslint-disable-next-line no-unused-vars
// function submitNote(note) {
// // $.post("/api/notes/", Note, function() {
// // window.location.reload();
// // });
// console.log(note);
// fetch("http://localhost:3000/api/user/notes", {
// method: "POST",
// headers: { "Content-Type": "application/json" },
// body: JSON.stringify(note)
// })
// .then(res => res.json())
// .then(renderNotes);
// }

function submitNote(note) {
$.ajax({
Expand All @@ -227,66 +127,6 @@ function deleteNote(note) {
}
// }); // to close document ready function

<<<<<<< HEAD

//notes
$(".save-note-button").on("click", function (event) {
event.preventDefault();

var title = $("#title-name").val();
var content = $("#write-notes").val();

const note = {
title,
content
};

notes.push(note);
renderNotes();
// renderNotesEditor();
clearValue();
notes.push(note);
renderNotes();

submitNote({
title: title,
body: content
});

clearValue();

})

//Title and Name show up again after being clicked
$(document).on("click", ".items-input", function () {

const index = $(this).data("index");
currentIndex = index;
$("#title-name").val(notes[index].title);
$("#write-notes").val(notes[index].body);
console.log(notes[index].body)
$(".delete-button").show();

// renderNotesEditor();
});
// });

function clearValue() {
$("#title-name").val("");
$("#write-notes").val("");
}





=======
function renderNotesEditor() {
if (currentIndex) {
notes[currentIndex];
}
renderNotesEditor();
}

//notes
$(".save-note-button").on("click", function (event) {
Expand Down Expand Up @@ -317,13 +157,9 @@ $(document).on("click", ".items-input", function () {
currentIndex = index;
$("#title-name").val(notes[index].title);
$("#write-notes").val(notes[index].body);
console.log(notes[index].body);
$(".delete-button").show();

renderNotesEditor();
});
// });
>>>>>>> f1732b191562ed10277a6c8a7cbd0040cbe32147


function clearValue() {
$("#title-name").val("");
Expand Down
3 changes: 0 additions & 3 deletions public/js/snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ $(document).ready(function () {


$(".delete-button").show();


// renderNotesEditor();

});

Expand Down
13 changes: 3 additions & 10 deletions public/styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ textarea {
margin-top: 15px;
}


h2 {
color: rgb(136, 132, 132);
font-size: 20px;
Expand Down Expand Up @@ -61,7 +60,7 @@ h5 {
flex-direction: column;
justify-content: flex-start;
align-items: center;
background-color: rgba(0, 0, 0, .9);
background-color: #696974;
}

.circle {
Expand All @@ -75,7 +74,7 @@ h5 {

.delete-button {
font-size: 18px;
background-color: black;
background-color: #696974;
color: white;
text-decoration: none;
position: fixed;
Expand Down Expand Up @@ -116,7 +115,6 @@ h5 {
.notes-nav {
border: none;
padding: 10px;

width: 90%;
margin-left: 11px;
border: none;
Expand Down Expand Up @@ -187,7 +185,6 @@ hr {
height: 100vh;
}


.right, .left{
justify-content: center;
align-items: center;
Expand Down Expand Up @@ -260,15 +257,14 @@ hr {
flex-wrap: wrap;
}


.landing-page-background {
background-color: #696974;
}

.save-button, .save-note-button {
padding: 7px;
font-size: 18px;
background-color: black;
background-color: #696974;
color: white;
text-decoration: none;
position: fixed;
Expand Down Expand Up @@ -300,7 +296,6 @@ hr {

.right a {
color: #0062FF;
/* text-decoration: none; */
font-size: 12px;
font-family: 'Poppins', sans-serif;
}
Expand All @@ -313,7 +308,6 @@ font-family: 'Poppins', sans-serif;

/* Code Snippet */


#editor {
position: absolute;
top: 57px;
Expand All @@ -329,7 +323,6 @@ font-family: 'Quicksand', sans-serif;
margin-top: 15px;
}


@media only screen and (max-width: 909px) {
.logo {
visibility: hidden;
Expand Down
7 changes: 1 addition & 6 deletions routes/apiRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module.exports = function(app) {
db.User.findOne({ where: { username: data.username } })
// eslint-disable-next-line prettier/prettier
.then(function (user) {
// console.log("USER PRINT", user.dataValues);
// eslint-disable-next-line no-unused-vars
var hashedPw = passwordHash.generate(req.body.password);
// console.log("HASHED PW!!!", hashedPw);
Expand All @@ -48,11 +47,7 @@ module.exports = function(app) {
res.send({ success: true });
// session saved
});
// console.log("works");
// res.send("works!");

// res.send(JSON.stringify({ success: true }));
// res.send("works");

} else {
res.status(401).send();
}
Expand Down
3 changes: 0 additions & 3 deletions routes/htmlRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ module.exports = function(app) {
res.json(user);
// res.sendFile(path.join(__dirname, "../views", "index.html", user);
});
// If this function gets called, the user alsready has a password
// res.sendFile(path.join(__dirname, "../views", "index.html"));
// res.send();

// If this function gets called, the user alsready has a password
res.sendFile(path.join(__dirname, "../views", "snippet.html"));
Expand Down
Loading

0 comments on commit b418da7

Please sign in to comment.