Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c641ffc
created files and configured heroku
yeahbq Jan 17, 2017
9c6489c
fixed bugs on server.js
yeahbq Jan 17, 2017
572026a
heroku app configured
yeahbq Jan 17, 2017
66945e3
updated main.js
yeahbq Jan 17, 2017
8362a7d
added ejs to index.html
yeahbq Jan 17, 2017
d5c5e74
fixed syntax on main.js
yeahbq Jan 17, 2017
67f671b
created /teams page
yeahbq Jan 17, 2017
4b91084
created delete button and fixed input fields to deny blank strings
yeahbq Jan 17, 2017
74d92a4
added bootstraps css and nav bar
yeahbq Jan 17, 2017
19c519c
added skeleton for all pages (/teams, /roster, /results, /schedule)
yeahbq Jan 18, 2017
199728c
added volleyball favicon
yeahbq Jan 18, 2017
92a9f8f
added throw err messages, working on post requests
yeahbq Jan 18, 2017
736f3e3
button event listeners working
yeahbq Jan 18, 2017
5941d18
added form which now accepts teams and roster
yeahbq Jan 18, 2017
87a6c3b
cleaned up db names and documents
yeahbq Jan 18, 2017
3e54891
cleaned up all html files to match new naming conventions
yeahbq Jan 18, 2017
06f646f
unified style on htmls
yeahbq Jan 18, 2017
15539c4
delete button now removes dom parent node on client side
yeahbq Jan 18, 2017
4762313
The D in CRUD has been completed
yeahbq Jan 19, 2017
0be1343
updated roster page to render tables according to roster content
yeahbq Jan 19, 2017
ec4cf87
added edit button to create input field, need to allow for submit but…
yeahbq Jan 19, 2017
80ae808
edit button adds 2 input fields and button. clicking submit edit curr…
yeahbq Jan 19, 2017
464bd50
edit button now renders edited text, AssertionError: 1 == 0 from server
yeahbq Jan 19, 2017
c4b2d96
U in CRUD complete on index.html. Full crud functionality
yeahbq Jan 19, 2017
ff344e2
cleaned up /teams/:name page to work with current naming conventions …
yeahbq Jan 19, 2017
2c9adb8
saving before making new branch to experiment with css
yeahbq Jan 19, 2017
3bc993e
fixing edit post to allow changing team name or roster. if name chang…
yeahbq Jan 19, 2017
3dbdccc
object id now saved to id of li when created
yeahbq Jan 20, 2017
0de012b
I've got the keysssss
yeahbq Jan 20, 2017
6d5910e
MVP achieved again
yeahbq Jan 20, 2017
e253f99
made edit and obj id apply to team and roster html pages
yeahbq Jan 20, 2017
212daea
tables now displaying correctly
yeahbq Jan 20, 2017
a91889f
roster.html tables now updated after edits
yeahbq Jan 20, 2017
55b64aa
cleaned up css for everything to allign correctly
yeahbq Jan 20, 2017
b5c5830
added gettingstarted.md
yeahbq Jan 20, 2017
ba9dab2
updated gettingstarted.md
yeahbq Jan 20, 2017
0d29252
started cleaning up code
yeahbq Jan 20, 2017
54ab7f4
added css backgrounds and more wrappers
yeahbq Jan 20, 2017
b3dedae
cleaned up code and removed console.logs and other irrelevant code
yeahbq Jan 20, 2017
8da9a9d
fixed bug with html title
yeahbq Jan 20, 2017
7ea75e0
added start to package.json
yeahbq Jan 20, 2017
414fe23
fixed package json
yeahbq Feb 3, 2017
9801a48
formatted readme and added screenshot
yeahbq Mar 23, 2017
fbddd39
removed original readme to be replaced with getting started
yeahbq Mar 23, 2017
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
Binary file added home-page-wireframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "project_02_crud_app",
"version": "1.0.0",
"description": "#### Overview",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/yeahbq/project_02_crud_app.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/yeahbq/project_02_crud_app/issues"
},
"homepage": "https://github.com/yeahbq/project_02_crud_app#readme",
"dependencies": {
"body-parser": "^1.15.2",
"ejs": "^2.5.5",
"express": "^4.14.0",
"express-handlebars": "^3.0.0",
"handlebars": "^4.0.6",
"mongodb": "^2.2.21",
"morgan": "^1.7.0"
}
}
Binary file added project3-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicon.ico
Binary file not shown.
Binary file added public/images/starlings_orig.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<title>Sports Team Manager</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <title>Proj 2 crud</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script
src="https://code.jquery.com/jquery-3.1.1.js"
integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
crossorigin="anonymous">
</script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>

<body>
<div class="header">
<ul class="nav nav-pills">
<li role="presentation" class="active"><a href="/">Home</a></li>
<li role="presentation"><a href="/teams.html">Teams</a></li>
<li role="presentation"><a href="/roster.html">Roster</a></li>
</ul>
<h1>Starlings San Gabriel Team Manager</h1>
</div>


<form accept-charset="utf-8">
<input type="text" placeholder="Enter Team (12s, 14s)" id="teamName">
<input type="text" placeholder="Enter Roster" id="roster">
</form>
<button id="createPost">Add Team Info</button>

<div class="dynamicContent">
<div id="posts">
<script id="posts-template" type="text/template">
<ul id="teamslist">
<% posts.forEach(function(post) { %>
<li class="list" id="<%=post._id %>"><%= post.name %>:<%= post.roster %>
<button type="button" class="edit" aria-label="Left Align">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</button>
<button type="button" class="x" aria-label="Left Align"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
</li>
<% }) %>
</ul>
</script>
</div>

<p>Enter your team's <b>name</b> and <b>roster</b> (seperated by a comma). To edit, click the pencil icon. To delete, click the 'X' button</p>
</div>
<div class="bgimg">
</div>

<script src="main.js"></script>
</body>
</html>
103 changes: 103 additions & 0 deletions public/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//~~VARIABLES~~//

var teamInput = '<input type="text" placeholder="Enter Team (12s, 14s)" id="teamName">'
var rosterInput = '<input type="text" placeholder="Enter Roster" id="roster">'
var submit = '<button id="createPost">Add Team Info</button>'
var editButton = '<button type="button" class="edit" aria-label="Left Align"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></button>';
var xButton = '<button type="button" class="x" aria-label="Left Align"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>'


//~~FUNCTIONS//

//when the add team info button is clicked, the data from the two input forms is
//created on db and appended to page
$('#createPost').on('click', function(evt) {
var teamName = $('#teamName');
var roster = $('#roster');
var obj = {};
obj.name = teamName.val();
obj.roster = roster.val();
if(teamName.val() === '' || roster.val() === '') return;
else {
$.post('/posts', obj, function(res) {
if (res.status === 200) {
var makeId = "id:" + res.id;
obj.id = makeId;
$('#teamslist').append('<li class="list" ' + 'id="' + makeId + '">' + teamName.val() + ": " + roster.val() + editButton + xButton + '</li>');
document.querySelector('#teamName').value = "";
document.querySelector('#roster').value = "";
} else {
console.log('server error, returning')
return;
}
});
}
});

//takes no parameters and used when combined with an event listener listening on the entire document
//When edit team info button is clicked, does a post request to /posts/edit

function editPost (evt) {
var btn = this;
var form = this.previousElementSibling;
var li = this.parentElement;
var editName = form.children[0].value;
var changeName = editName;
var editRoster = form.children[1].value;
var obj = {};
obj.name = editName;
obj.roster = editRoster;
obj.id = this.parentNode.getAttribute('id');
li.innerHTML = editName + ": " + editRoster + editButton + xButton;
$.post('/posts/edit', obj, function(res) {
console.log(obj, 'edited and saved')
});

if ($('#renderTable')){
window.location.reload();
}
}

//turns the list items into two input fields to edit
function editClick (evt) {
var target = this;
var team = target.parentElement.textContent;
roster = team.split(':')[1];
teamName = team.split(':')[0];
var objId = this.parentElement.getAttribute('id');
this.parentNode.innerHTML = '<form id="'+ objId + '"><input type="text" placeholder="Edit Team (12s, 14s)" id="editName">' + ' ' + '<input type="text" placeholder="Edit Roster" id="editRoster"></form>' + ' ' + '<button id="editPost">Edit Team Info</button>';
document.querySelector('#editName').value = teamName;
document.querySelector('#editRoster').value = roster;
}

//deletes list item from page and also from database
function xClick (evt) {
var target = this;
var team = target.parentElement.textContent;
var teamName = team.split(':')[0];
var obj = {};
obj.name = teamName;

$.post('/posts/delete', obj, function(res) {
console.log('object containing', obj, 'deleted')
})

if ($('#renderTable')){
window.location.reload();
}
this.parentNode.remove()
}

//EVENT LISTENERS search entire document for elements created after load
$(document).on('click', '.edit', editClick);
$(document).on('click', '.x', xClick);
$(document).on('click', '#editPost', editPost);

//AJAX REQUESTS
//creates html from /posts and saves it to id #posts which gets loaded up by ejs
$.get('/posts', function(res) {
var template = $('#posts-template').html() ;
var compiled = _.template(template);
var html = compiled({posts: res.posts});
$('#posts').html(html);
});
51 changes: 51 additions & 0 deletions public/results.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <title>Proj 2 crud</title>
<script
src="https://code.jquery.com/jquery-3.1.1.js"
integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body>

<div class="header">
<ul class="nav nav-pills">
<li role="presentation"><a href="/">Home</a></li>
<li role="presentation"><a href="/teams.html">Teams</a></li>
<li role="presentation"><a href="/roster.html">Roster</a></li>
<li role="presentation" class="active"><a href="/results.html">Results</a></li>
<li role="presentation"><a href="/schedule.html">Schedule</a></li>
</ul>
</div>


<h1>Results</h1>

<!-- <input type="text" placeholder="Enter Results (3-0)" id="results">
<button id="createPost">Create</button>
-->

<div id="posts">
<script id="posts-template" type="text/template">
<ul>
<% posts.forEach(function(post) { %>
<% var teams = post.teams %>
<li><%= teams.teamName + ": " + teams.roster + editButton + xButton%></li>
<% }) %>
</ul>
</div>

<p>Enter your team's Results (for example Q1: 3-0, 1st Place)</p>


</script>
<script src ="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="main.js"></script>
</body>
</html>
69 changes: 69 additions & 0 deletions public/roster.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<title>Sports Team Manager</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <title>Proj 2 crud</title>
<script
src="https://code.jquery.com/jquery-3.1.1.js"
integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header">
<ul class="nav nav-pills">
<li role="presentation"><a href="/">Home</a></li>
<li role="presentation"><a href="/teams.html">Teams</a></li>
<li role="presentation" class="active"><a href="/roster.html">Roster</a></li>
</ul>
</div>
<h1>Roster</h1>
<p>Starlings '16-'17 Team Rosters</p>

<div id="posts">
<script id="posts-template" type="text/template">
<ul id="teamslist">
<% var editButton = '<button type="button" class="edit" aria-label="Left Align"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></button>'%>
<% var xButton = '<button type="button" class="x" aria-label="Left Align"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>' %>
<% var html; %>
<% posts.forEach(function(post) { %>
<% html ='<li class="list" id="' + post._id + '">' + post.name + ": " + post.roster + editButton + xButton + '</li>' %>
<%= html %>
<% }) %>
</ul>

<table id="renderTable" class="table table-striped table-bordered">
<caption class="tableTeam">Make sure members in roster are seperated by a comma when editing</caption>
<thead>
<tr>
<th>Team Name</th><th>Name</th>
</tr>
</thead>
<tbody>
<% console.log(posts) %>
<% posts.forEach(function(post) { %>
<% var html; %>
<% var rosterArr = post.roster.split(',') %>
<% console.log(rosterArr) %>
<% rosterArr.forEach(function(roster) { %>
<% html ='<tr><td>' + post.name + '</td>' %>
<% html += '<td>' + roster + '</td><tr>' %>
<%= html %>
<% }) %>
<% }) %>
</tbody>
</table>
</script>
</div>

<div class="bgimg">
</div>

<script src ="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="main.js"></script>
</body>
</html>
50 changes: 50 additions & 0 deletions public/schedule.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <title>Proj 2 crud</title>
<script
src="https://code.jquery.com/jquery-3.1.1.js"
integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
</head>
<body>

<div class="header">
<ul class="nav nav-pills">
<li role="presentation"><a href="/">Home</a></li>
<li role="presentation"><a href="/teams.html">Teams</a></li>
<li role="presentation"><a href="/roster.html">Roster</a></li>
<li role="presentation"><a href="/results.html">Results</a></li>
<li role="presentation" class="active"><a href="/schedule.html">Schedule</a></li>
</ul>
</div>


<h1>Schedule</h1>

<!-- <input type="text" placeholder="Enter Schdule" id="sch">
<button id="createSch">Create Schedule</button> -->

<div id="posts">
<script id="posts-template" type="text/template">
<ul>
<% posts.forEach(function(post) { %>
<% var teams = post.teams %>
<li><%= teams.teamName + ": " + teams.roster + editButton + xButton%></li>
<% }) %>
</ul>
</script>
</div>

<p>Enter your teams Schedule (Mandatory 1: 2/4/17)</p>


<script src ="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="main.js"></script>
</body>
</html>
Loading