Skip to content
Open
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
20 changes: 12 additions & 8 deletions twoter/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var express = require('express');
var index = require('./routes/index');
// clean up the dependencies you're not using!
// also, run `npm init` when you start so you have a `package.json` file --
// that way, when you run `npm install --save whatever` the dependency info will
// end up in the `package.json`, and people who work on/give you feedback on your app
// will be able to run just `npm install` to get all of your dependencies in the same form you have them.
var app = express();
var session = require('express-session')
var twote = require('./routes/twote');
Expand Down Expand Up @@ -50,7 +54,7 @@ app.use(express.static(__dirname + '/public'));
app.use(express.static(path.join(__dirname, 'public')));


app.use(session({
app.use(session({
secret: 'superS3CRE7',
resave: false,
saveUninitialized: false ,
Expand All @@ -59,11 +63,11 @@ app.use(session({

app.get('/', twote.getUsers);
app.get('/login', twote.login);
app.get('/newUser', twote.addUser)
app.get('/logout', twote.logout)
app.get('/getLogged', twote.getLogged)
app.get('/addPost', twote.addPost)
app.get('/removePost', twote.removePost)
app.get('/newUser', twote.addUser); // technically this should be a post -- changes the server/database state
app.get('/logout', twote.logout);
app.get('/getLogged', twote.getLogged);
app.get('/addPost', twote.addPost); // technically this should be a post
app.get('/removePost', twote.removePost); // technically this should be a post
app.post('/login', twote.postLogin);

app.get('/auth/facebook',
Expand All @@ -76,4 +80,4 @@ app.get('/auth/facebook/callback',



app.listen(3000);
app.listen(3000);
24 changes: 24 additions & 0 deletions twoter/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "twoter",
"version": "1.0.0",
"description": "",
"main": "app.js",
"dependencies": {
"body-parser": "^1.15.0",
"cookie-parser": "^1.4.1",
"express": "^4.13.4",
"express-handlebars": "^3.0.0",
"express-session": "^1.13.0",
"mongoose": "^4.4.7",
"mongoose-times": "^0.1.0",
"morgan": "^1.7.0",
"passport": "^0.3.2",
"passport-facebook": "^2.1.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
17 changes: 9 additions & 8 deletions twoter/public/javascripts/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var $form1 = $("#ajax-form");
var $form2 = $("#ajax-form2");
var $form2 = $("#ajax-form2"); // more descriptive names, maybe? I have to go cross-reference the index.html file to figure out what these do
var $form3 = $("#ajax-form3");
var $form4 = $("#ajax-form4");
var $form5 = $("#ajax-form5");
Expand Down Expand Up @@ -34,16 +34,17 @@ var onSuccess3 = function(data, status) {
};

var onSuccess4 = function(data, status) {
// Check out https://jsfiddle.net/swalters4925/e8gzd6h9/1/ for the way I like to add structured HTML to a page -- it's an option!
$("li[id|='posts']").prepend("<li id = '"+data.author+"'>post: "+data.author+" posted: "+data.post+"</li>")
console.log(data.post)

};

var onSuccess5 = function(data, status) {
//$("button[value|='"+data.post+"']").prop('disabled', true);
$("button[value|='"+data.post+"']").hide();
$("ul[name|='"+data.post+"']").replaceWith("");

};

// var onSuccess6 = function(data, status) {
Expand All @@ -63,7 +64,7 @@ $form1.submit(function(event) {
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
request.send(data);
var name = $form1.find("[type='text']").val();

console.log(name);
$.get("newUser", {
name: name
Expand All @@ -85,7 +86,7 @@ $("input[name|='twote']").on("click", function(){
$form2.submit(function(event) {
event.preventDefault();
//var name = $form1.find("[type='submit']").val();

//console.log(name);
$.get("logout", {
name: name
Expand Down Expand Up @@ -118,13 +119,13 @@ $("button[id|='remove']").on("click",function(event) {
//var author = $("h3[id|='user']").val();
var author = $(this).attr("name");
var post = $(this).attr("value");
console.log("I tried");
console.log("I tried"); // yes indeed!
console.log(author);
console.log(post);
//var post = $("input[name|='twote']").val();
//console.log("clicked!")
//console.log("this"+author);

$.get("removePost", {
author: author,
post: post
Expand Down Expand Up @@ -233,7 +234,7 @@ $("button[id|='remove']").on("click",function(event) {
// //$form4.submit(function(event) {
// event.preventDefault();
// //var name = $form4.find( "button[type='submit']" ).attr("name");
// var name = $(this).attr("name");
// var name = $(this).attr("name");
// console.log(name);
// $.get("complete", {
// name: name
Expand Down
46 changes: 0 additions & 46 deletions twoter/routes/index.js

This file was deleted.

47 changes: 0 additions & 47 deletions twoter/routes/order.js

This file was deleted.

Loading