diff --git a/README.md b/README.md
index 58b47eb..d10fa40 100644
--- a/README.md
+++ b/README.md
@@ -97,3 +97,6 @@
- Ayush Poddar
- **[Portfolio](https://mr-magnificent.github.io/)**
+ - **[Socket.io (Chatisry)](https://chatistry.herokuapp.com/)**
+ - **[todo (with database)](https://dotodaytodo.herokuapp.com/)**
+ - **[Lyricist (spotify+lastFm+lyrics API)](https://lyricspot.herokuapp.com/)**
diff --git a/Summer2018/Ayush Poddar/Socket.io-chat/package.json b/Summer2018/Ayush Poddar/Socket.io-chat/package.json
new file mode 100644
index 0000000..05aa174
--- /dev/null
+++ b/Summer2018/Ayush Poddar/Socket.io-chat/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "sockt",
+ "version": "1.0.0",
+ "description": "Socket application with implimentation for chat",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "author": "Ayush Poddar",
+ "license": "ISC",
+ "dependencies": {
+ "express": "^4.16.3",
+ "socket.io": "^2.1.1"
+ },
+ "devDependencies": {}
+}
diff --git a/Summer2018/Ayush Poddar/Socket.io-chat/public/app.js b/Summer2018/Ayush Poddar/Socket.io-chat/public/app.js
new file mode 100644
index 0000000..b7bebd7
--- /dev/null
+++ b/Summer2018/Ayush Poddar/Socket.io-chat/public/app.js
@@ -0,0 +1,47 @@
+
+
+$(document).ready(function () {
+ let btn = $('#btn');
+ // let inp = $('#inp').val();
+ let list = $('#list');
+ let prmt;
+
+ while (!prmt) {
+ prmt = prompt("Please enter your name");
+ }
+
+ let socket = io();
+
+
+
+ socket.emit('name', prmt);
+
+ socket.on('initConnect', function (data) {
+ console.log(data);
+ $('#connected').text('');
+ for (let id in data) {
+ if (data.hasOwnProperty(id)) {
+ console.log(data[id]);
+ $('#connected').append(`
${data[id]}`);
+ }
+ }
+ });
+
+ socket.on('chat', function (data) {
+ data.forEach(function(chatItem) {
+ list.append(`${chatItem[1]}:- ${chatItem[0]}`);
+ })
+ });
+
+ btn.click(function () {
+ let inp = $('#inp').val();
+ console.log(inp);
+ socket.emit('message', [inp, prmt]);
+ list.append(`${prmt}:- ${inp}`);
+ });
+
+ socket.on('reciveData', function (data) {
+ console.log(data);
+ list.append(`${data[1]}:- ${data[0]}`);
+ })
+})
\ No newline at end of file
diff --git a/Summer2018/Ayush Poddar/Socket.io-chat/public/index.html b/Summer2018/Ayush Poddar/Socket.io-chat/public/index.html
new file mode 100644
index 0000000..fc93633
--- /dev/null
+++ b/Summer2018/Ayush Poddar/Socket.io-chat/public/index.html
@@ -0,0 +1,26 @@
+
+
+
+
+ Sock-t
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Summer2018/Ayush Poddar/Socket.io-chat/public/style.css b/Summer2018/Ayush Poddar/Socket.io-chat/public/style.css
new file mode 100644
index 0000000..79f57a9
--- /dev/null
+++ b/Summer2018/Ayush Poddar/Socket.io-chat/public/style.css
@@ -0,0 +1,33 @@
+.container {
+ display: flex;
+ flex-wrap: wrap;
+ width: 100%;
+ height: 100%;
+ margin: 0 auto;
+ font-size: 0;
+}
+
+.chat-area {
+ height: 75vh;
+ width: 74%;
+ font-size: initial;
+ border-right: black dashed;
+ border-bottom: black dashed;
+ margin: 0 auto;
+ overflow-y: scroll;
+}
+
+.connection-area {
+ height: 75vh;
+ width: 25%;
+ overflow-y: scroll;
+ font-size: initial;
+}
+
+.input-area {
+ height: 25vh;
+ width: 100%;
+ display: table-cell;
+ font-size: initial;
+ vertical-align: middle;
+}
\ No newline at end of file
diff --git a/Summer2018/Ayush Poddar/Socket.io-chat/public/username.html b/Summer2018/Ayush Poddar/Socket.io-chat/public/username.html
new file mode 100644
index 0000000..92f8649
--- /dev/null
+++ b/Summer2018/Ayush Poddar/Socket.io-chat/public/username.html
@@ -0,0 +1,10 @@
+
+
+
+ Username
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Summer2018/Ayush Poddar/Socket.io-chat/server.js b/Summer2018/Ayush Poddar/Socket.io-chat/server.js
new file mode 100644
index 0000000..0e80198
--- /dev/null
+++ b/Summer2018/Ayush Poddar/Socket.io-chat/server.js
@@ -0,0 +1,63 @@
+let express = require('express');
+let app = express();
+
+let server = require('http').Server(app);
+
+let io = require('socket.io')(server);
+
+let nameObj = {};
+let initChat = [];
+
+let PORT = process.env.PORT || 5000;
+/*
+console.log(app);
+console.log();
+console.log(server);
+console.log();
+console.log(io);
+console.log();
+*/
+
+
+app.use('/', express.static('./public'));
+
+
+io.on('connection', function (socket) {
+
+ socket.on('name', function (data) {
+ console.log(data);
+ nameObj[socket.id] = data;
+ console.log('name');
+ console.log(nameObj);
+ io.sockets.emit('initConnect', nameObj);
+ });
+
+
+ socket.emit('chat', initChat);
+
+ socket.on('message', function (data) {
+ socket.broadcast.emit('reciveData', data);
+ console.log(data);
+ initChat.push(data);
+ });
+
+ socket.on('disconnect', function () {
+ delete nameObj[socket.id];
+ console.log('disconnect');
+ console.log(nameObj);
+ io.sockets.emit('initConnect', nameObj);
+ console.log(Object.keys(nameObj).length);
+ if (Object.keys(nameObj).length === 0) {
+
+ initChat = [];
+ }
+
+ })
+});
+
+
+
+
+server.listen(PORT, function () {
+ console.log('Server is listening on port ' + PORT);
+});
diff --git a/Summer2018/Ayush Poddar/todoList-database/database.js b/Summer2018/Ayush Poddar/todoList-database/database.js
new file mode 100644
index 0000000..a821dac
--- /dev/null
+++ b/Summer2018/Ayush Poddar/todoList-database/database.js
@@ -0,0 +1,105 @@
+const mongodb = require('mongodb').MongoClient;
+let topUser = require('mongodb').ObjectID("5b637cfde7179a0733452cea");
+
+const uri = 'YOUR_DATABASE_URI';
+
+let database;
+let collection;
+
+function connectDb() {
+ console.log("inside connectDb");
+ mongodb.connect(uri, function (err, client) {
+ console.log("inside mongodb.connect");
+ if (err) {
+ console.log(err);
+ throw err;
+ }
+ database = client.db('todo');
+ collection = database.collection('collection');
+
+ // console.log(collection);
+
+ // global.insertNewUser = insertNewUser;
+ // global.insertTodo = insertTodo;
+ // global.retrieveAll = retrieveAll;
+ // global.deleteElement = deleteElement;
+ // global.updateElement = updateElement;
+ // global.deleteMul = deleteMul;
+ });
+}
+
+function insertNewUser (userID) {
+ collection.insertOne({
+ user: {
+ userId: userID
+ }
+ });
+}
+
+function getUserTop (callback) {
+ collection.find({"_id" : topUser}).toArray(function (err, result) {
+ if (err) {
+ console.log(err);
+ throw err;
+ }
+ console.log(result);
+ incrementUserTop(result);
+ callback(result);
+ })
+}
+
+function incrementUserTop(data) {
+ data = parseInt(data[0]['userTop']);
+ collection.updateOne({"userTop": data}, {$set :{'userTop' : ++data}});
+}
+
+
+
+function insertTodo(userID, task, status, callback) {
+ userID = parseInt(userID);
+ task = task.toString();
+ console.log(userID, task);
+ status = status.toString();
+ collection.updateOne({'user.userId': userID},{$set: {[task]: status}});
+ callback(task);
+}
+
+
+
+function retrieveAll(userID, callback) {
+ console.log(userID);
+ collection.find({"user.userId": userID}).toArray(function (err, result) {
+ if (err) {
+ console.log(err);
+ throw err;
+ }
+ console.log(result);
+ callback(result);
+ });
+}
+
+function deleteElement(userID, task) {
+ collection.updateOne({ "user.userId": userID}, { $unset: { [task]: ""}});
+}
+
+function updateElement(userID, task, newTask, callback) {
+ collection.updateOne({ "user.userId": userID}, { $rename: { [task]: newTask}});
+ callback(newTask);
+}
+
+function deleteMul(userID, taskArr) {
+ taskArr.forEach(function (task) {
+ collection.updateOne({ "user.userId": userID}, { $unset: { [task]: ""}});
+ })
+}
+
+module.exports = {
+ insertNewUser,
+ insertTodo,
+ retrieveAll,
+ deleteElement,
+ deleteMul,
+ updateElement,
+ connectDb,
+ getUserTop
+};
\ No newline at end of file
diff --git a/Summer2018/Ayush Poddar/todoList-database/package.json b/Summer2018/Ayush Poddar/todoList-database/package.json
new file mode 100644
index 0000000..621cbda
--- /dev/null
+++ b/Summer2018/Ayush Poddar/todoList-database/package.json
@@ -0,0 +1,18 @@
+{
+ "name": "database-integration",
+ "version": "1.0.0",
+ "description": "",
+ "main": "database.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "start": "node server.js"
+ },
+ "author": "",
+ "license": "ISC",
+ "dependencies": {
+ "body-parser": "^1.18.3",
+ "cookie-parser": "^1.4.3",
+ "express": "^4.16.3",
+ "mongodb": "^3.1.1"
+ }
+}
diff --git a/Summer2018/Ayush Poddar/todoList-database/public/app.js b/Summer2018/Ayush Poddar/todoList-database/public/app.js
new file mode 100644
index 0000000..6ddc32e
--- /dev/null
+++ b/Summer2018/Ayush Poddar/todoList-database/public/app.js
@@ -0,0 +1,243 @@
+let todoList = [{}];
+let delMul = [];
+let taskArr = [];
+let result = $('#list');
+let inp = $('#inp');
+// let userID;
+// let ind = 0;
+$(document).ready(function(){
+
+ (function () {
+ let userID = Cookies.get('userID');
+ console.log(userID);
+ if (!userID) {
+ let res = prompt("Are you a new user (y/n)");
+ if (res[0].toLowerCase() === 'y') {
+ $.ajax({
+ url: '/newuser',
+ method: 'get',
+ success: function (data) {
+ $('#userid').text(`${data}`);
+ // userID = data;
+ Cookies.set('userID', `${data}`);
+ document.location.reload(true);
+ }
+ })
+ }
+ else {
+ console.log("not a new user");
+ let userid;
+ while (!userid) {
+ userid = prompt("Enter you UserID");
+ }
+ userid = Number(userid);
+
+ if (userid.toString() !== 'NaN') {
+ console.log(userid);
+ Cookies.set('userID', userid.toString());
+ $('#userid').text(`${userid}`);
+ }
+ }
+ } else {
+ $('#userid').text(`${userID}`);
+ }
+ }());
+
+ display();
+
+ function display(){
+ let data = JSON.parse(localStorage.getItem('todo')) || [];
+ console.log(data);
+ if(data.length) {
+ render(data);
+ todoList = data;
+ }
+ else {
+ $.ajax({
+ url: '/display',
+ method: 'get',
+ success: function(data) {
+ localStorage.setItem('todo', JSON.stringify(data));
+ render(data);
+ todoList = data;
+ }
+ })
+ }
+ }
+});
+
+
+
+function makeRequest() {
+
+ let input = inp.val();
+ let tick = $('#tick');
+ tick.css('visibility', 'visible');
+
+ setTimeout(function () {
+ tick.css('visibility', 'hidden');
+ }, 400);
+
+ if (!input) {
+ return null;
+ }
+
+ let test = {
+ "task" : input,
+ "done": false
+ };
+
+ inp.val('');
+
+ $.ajax({
+ url: '/add',
+ method: 'post',
+ data: {todo: test},
+
+ success: function(data) {
+ todoList[0][data] = "false";
+ localStorage.setItem('todo', JSON.stringify(todoList));
+ result.append(`
+
+ ${data}
+
+
+ `
+ )
+ }
+ });
+}
+
+
+function render(data) {
+ console.log(data);
+ for(let prop in data[0]) {
+ if (prop === "user" || prop === "_id" || !data[0].hasOwnProperty(prop)) {
+ continue;
+ }
+ result.append(`
+
+ ${prop}
+
+
+ `)
+ }
+}
+
+
+/*
+*
+*
+* Used to
element
+*
+* */
+
+
+
+
+function deleteKey(element) {
+ let index = $(element).parent().index();
+ let task = $(element).prev().text();
+ console.log(task);
+
+ $.ajax({
+ url: '/delete',
+ method: 'post',
+ data: {todo: task},
+ success: function() {
+ $(element).parent().remove();
+ console.log(index);
+ console.log(todoList);
+ console.log(todoList[0][task]);
+ delete todoList[0][task];
+ localStorage.setItem('todo', JSON.stringify(todoList));
+ }
+ })
+
+}
+
+
+
+/*
+*
+*
+* This is code for updation of an element of
+* todo list
+*
+*
+* */
+
+
+function updateKey(element) {
+
+ let parent = $(element).parent();
+ let index = parent.index();
+ let prevVal = $(element).prev().prev().text();
+ let newVal = prompt('Enter New Value');
+ if (!newVal) {
+ return;
+ }
+ $.ajax({
+ url: '/update',
+ method: 'post',
+ data: {val: newVal, prevVal: prevVal},
+ success: function (data) {
+ parent.html(`
+ ${data}
+
+ `);
+ delete todoList[0][prevVal];
+ todoList[0][newVal] = false;
+ localStorage.setItem('todo', JSON.stringify(todoList));
+ }
+ })
+}
+
+
+function deleteMultiple() {
+ console.log(taskArr);
+ $.ajax ({
+ url: '/deleteMultiple',
+ method: 'POST',
+ data: {task: taskArr},
+ success: function(data) {
+ delMul.sort();
+ delMul.reverse();
+ for (let i = 0; i < delMul.length; i++) {
+ $('#list').children().eq(delMul[i]).remove();
+ delete todoList[0][taskArr[i]];
+ }
+ localStorage.setItem('todo', JSON.stringify(todoList));
+ delMul = taskArr = [];
+ }
+ });
+}
+
+function selMultiple(element) {
+ let index = $(element).parent().index();
+ console.log('hello');
+ if (!element.checked) {
+ console.log('hello');
+ for (let i = 0; i < delMul.length; i++) {
+ if (delMul[i] === index) {
+ delMul.splice(i, 1);
+ taskArr.splice(i, 1);
+ }
+ }
+ }
+ else {
+ delMul.push(index);
+ taskArr.push($(element).next().text());
+ }
+}
+
+// Call the function at the top, display()
+
+/*
+* function display() {
+*
+* Get Request at /display route
+* Loop that todoList and append on the page
+* }
+ *
+* */
\ No newline at end of file
diff --git a/Summer2018/Ayush Poddar/todoList-database/public/index.html b/Summer2018/Ayush Poddar/todoList-database/public/index.html
new file mode 100644
index 0000000..423b66e
--- /dev/null
+++ b/Summer2018/Ayush Poddar/todoList-database/public/index.html
@@ -0,0 +1,40 @@
+
+
+
+
+ DoToday
+
+
+
+
+
+
+
+
+
+
+
Do-Today
+
A simplistic ToDo List for everyday tasks
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Summer2018/Ayush Poddar/todoList-database/public/style.css b/Summer2018/Ayush Poddar/todoList-database/public/style.css
new file mode 100644
index 0000000..a048511
--- /dev/null
+++ b/Summer2018/Ayush Poddar/todoList-database/public/style.css
@@ -0,0 +1,164 @@
+body {
+ margin: 0 auto;
+}
+
+.body {
+ display: flex;
+ flex-wrap: wrap;
+ font-size: 0;
+ width: 100%;
+ height: 100vh;
+ margin:0 auto;
+}
+
+#delmul {
+ position: absolute;
+ top: 5px;
+ right: 10px;
+ display: none;
+}
+
+#delmul > button {
+ background-color: rgb(252, 29, 34);
+ border: 0;
+ border-radius: 5px;
+}
+
+* {
+ box-sizing: border-box;
+}
+
+.title {
+ width: 40%;
+ font-size: initial;
+ text-align: center;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ color: white;
+ background-color: rgb(60, 60, 60);
+}
+
+.title input {
+ width: 80%;
+ height: 30px;
+ border: none;
+ padding-left: 6%;
+ margin: 0;
+ background: transparent;
+}
+
+.title > div {
+ max-width: 90%;
+}
+
+.title > div > div {
+ background-color: white;
+ border-radius: 80px 80px 80px 80px;
+ position: relative;
+ top: 0;
+}
+
+#tick {
+ position: absolute;
+ left: 74%;
+ top: 21%;
+ visibility: hidden;
+ height: 19px;
+}
+
+.title > div > div > button {
+ height: 36px;
+ margin: 0 -1px 0 0;
+ width: 18%;
+ border: 0;
+ border-top-right-radius: 80px;
+ border-bottom-right-radius: 80px;
+ background-color: darkgrey;
+ cursor: pointer;
+}
+
+.title > div > button {
+ background-color: rgba(252, 29, 34, 0.58);
+ color: #ffffff;
+ border: 0;
+ border-radius: 5px;
+ cursor: pointer;
+}
+
+.title > div > button > * {
+ vertical-align: middle;
+}
+
+.title p {
+ margin-bottom: 30px;
+}
+
+.main {
+ width: 60%;
+ overflow-y: scroll;
+ height: 100vh;
+ font-size: initial;
+}
+
+#list {
+ margin-top: 30px;
+}
+
+#list > li {
+ padding-bottom: 15px;
+ max-width: 500px;
+ padding-left: 20px;
+}
+
+.updDel {
+ float: right;
+ opacity: 0;
+ transition: opacity 0.1s ease-in;
+}
+
+.updDel > img {
+ height: 16px;
+}
+
+li:hover .updDel{
+ opacity: 1;
+ transition: opacity 0.3s ease-in;
+}
+
+#userid {
+ color: rgba(185, 255, 193, 0.92);
+}
+
+@media screen and (max-width: 636px) {
+ .body {
+ display: flex;
+ flex-direction: column;
+ }
+
+ .main {
+ overflow-y: scroll;
+ /*over*/
+ order: 1;
+ width: 100%;
+ height: 60vh;
+ }
+
+ .title {
+ height: 40vh;
+ width: 100%;
+ order: 3;
+ }
+
+ .title p {
+ margin-bottom: 20px;
+ }
+
+ #delmul {
+ display: initial;
+ }
+
+ .title > div > button {
+ display: none;
+ }
+}
diff --git a/Summer2018/Ayush Poddar/todoList-database/server.js b/Summer2018/Ayush Poddar/todoList-database/server.js
new file mode 100644
index 0000000..79d1b0c
--- /dev/null
+++ b/Summer2018/Ayush Poddar/todoList-database/server.js
@@ -0,0 +1,147 @@
+const server = require('express');
+const app = server();
+
+
+
+const bodyParser = require('body-parser');
+
+const cookieParser = require('cookie-parser');
+
+/*
+*
+* This file creates the connection to the database
+*
+* */
+const db = require('./database');
+
+let PORT = process.env.PORT || 5000;
+
+// parse application/x-www-form-urlencoded
+app.use(cookieParser());
+app.use('/',server.static('public'));
+
+app.use(bodyParser.urlencoded({ extended: true }));
+// parse application/json
+app.use(bodyParser.json());
+
+
+/*
+*
+* since the elements are not stored on the server
+* we dont need todoList[]
+*
+* */
+// var todoList = [];
+
+app.get('/newuser', function (req, res) {
+ getUserTop(function (data) {
+ let userTop = parseInt(data[0]["userTop"]);
+ db.insertNewUser(++userTop);
+ res.cookie("userID", userTop, {
+ expires: new Date(2147483647000)
+ });
+ res.send(userTop.toString());
+ })
+
+});
+
+function getUserTop (callback) {
+ db.getUserTop(function (data) {
+ callback(data);
+ })
+}
+
+
+app.post('/add', function(req,res) {
+ let userID = req.cookies.userID;
+ let todo = req.body.todo;
+ console.log(todo);
+ // todo = JSON.parse(todo);
+ todo = todo.task;
+ console.log(todo, "inside /add: ", userID, "userID");
+ let done = false;
+
+ /*
+ *
+ * This send the new todo
+ * entry in the database
+ * and return the id of the data element
+ * in the database
+ *
+ *
+ * */
+ db.insertTodo(userID, todo, done, function (data) {
+ res.send(data);
+ });
+
+});
+
+
+
+
+app.post('/delete', function(req,res){
+ let userID = parseInt(req.cookies.userID);
+ let task = (req.body.todo).toString();
+ // task = task.task;
+ /*
+ *
+ * This deletes the index
+ *
+ *
+ * */
+ db.deleteElement(userID, task);
+ res.sendStatus(200);
+});
+
+
+
+
+
+app.get('/display', function(req,res) {
+ // Send TodoList Array to the client
+ // res.send(todoList);
+ /*
+ *
+ * since we need to send the data from the data base we can use telescoping
+ * that calls the display () in the database.js
+ *
+ * */
+ let userId = parseInt(req.cookies.userID);
+ console.log(userId, "inside display");
+ db.retrieveAll(userId, function (data) {
+ console.log(data);
+ res.send(data);
+ })
+});
+
+
+
+
+
+app.post ('/update', function (req, res) {
+ let newval = req.body.val.toString();
+ let prevVal = req.body.prevVal.toString();
+ let done = false;
+ let userID = parseInt(req.cookies.userID);
+
+ db.updateElement(userID, prevVal, newval, function (data) {
+ res.send(data);
+ })
+});
+
+
+
+
+
+app.post ('/deleteMultiple', function (req, res) {
+ let task = req.body.task;
+ let userID = parseInt(req.cookies.userID);
+ console.log(task);
+ db.deleteMul(userID, task);
+ res.sendStatus(200);
+});
+
+app.listen(PORT, function() {
+ console.log("Server running on port ", PORT);
+ db.connectDb();
+});
\ No newline at end of file