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

daily assignments #18

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
34 changes: 34 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const bodyParser = require("body-parser");
const path = require("path");
const express = require("express");
//Auths
// const auth = require("./middlewares/Auth/auth");
// require("dotenv").config({
// path: "./config.env"
// });


// Init app
// Init app
const app = express();
app.use(express.json());
app.use(bodyParser.json());

// Home api
app.get('/', (req, res) => {
res.status(200).send('Hello World!');
});

// user api
app.use('/api/register', require('./scripts/auth/register'));
app.use('/api/authenticate', require('./scripts/auth/signin'));
app.use('/api/users', require('./scripts/user/all'));
app.use('/api/users', require('./scripts/user/profile'));
app.use('/api/users', require('./scripts/user/updateUser'));
app.use('/api/users', require('./scripts/user/deleteUser'));

// food api
app.use('/api/food', require('./scripts/food/add'));
app.use('/api/food', require('./scripts/food/get'));

module.exports = app;
13 changes: 13 additions & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../scripts/index.js"></script>
<title>ipp</title>
</head>
<body>

</body>
</html>
42 changes: 42 additions & 0 deletions day1/day1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./day1.js"></script>
<script type="text/javascript">
var x;
function update() {
x = document.getElementById("text");
console.log("Inside the update function!");
x.innerHTML = document.getElementById("inp").value;
}
</script>
<title>Day 1</title>
</head>
<body>
<!-- inline -->
<div id="div1">
<button onclick="alert('inline script!')">click!</button>
</div>
<br />
<!-- internal -->
<div id="div2">
<h4 id="text"></h4>
<input type="text" id="inp" value="">
<input type="submit" value="submit" onclick="update()">
</div>
<br />
<!-- external -->
<div id="div3">
<input type="text" id="write" value="">
<button onclick="writeText(document.getElementById('write').value)">write</button>
</div>
<br />
<form>
<input type="button" value="Print"
onclick="window.print()" />
</form>
</body>
</html>
3 changes: 3 additions & 0 deletions day1/day1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function writeText(text) {
document.write(text);
}
25 changes: 25 additions & 0 deletions day2/day2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./day2.js"></script>
<title>Day 2</title>
</head>
<body>
<!-- DAY 2: modify innerHTML, style.fontSize,
style.display, style.visibility,
document.getElementById(“test”).value; -->
<div id="container">
<div id="text" onclick="modifyInnerHTML(id, 'Swiggy')">Write something here!</div>
<div id="fname" ondblclick="modifyFontSize(id)">Ashish</div>
<div id="mname" onclick="toggleVis(id)">Kumar</div>
<div id="lname" onclick="modifyDisplay(id)">Panigrahy</div>
<br>
<input id="test" onclick="changeValue(id, 'clicked')" value="Something!" type="button">
<button onclick="toggleColor('container')">Toggle Colour!</button>
</div>

</body>
</html>
36 changes: 36 additions & 0 deletions day2/day2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function modifyInnerHTML(id, value) {
console.log(document.getElementById(id).innerHTML);
document.getElementById(id).innerHTML = value;
}

function toggleVis(id) {
document.getElementById(id).style.visibility = 'hidden';
}

function modifyFontSize(id) {
document.getElementById(id).style.fontSize = '25px';
}

function modifyDisplay(id) {
document.getElementById(id).style.display = 'none';
}

function changeValue(id, val) {
document.getElementById(id).value = val;
}

function toggleColor(id) {
const x = document.getElementById(id).style.color;
if (!x || x === 'black') document.getElementById(id).style.color = 'red';
else if (x === 'red') document.getElementById(id).style.color = 'green';
else if (x === 'green') document.getElementById(id).style.color = 'black';
}

const dbl = (item, index, arr) => {
arr[index] += item;
};
let arr = [1, 5, 2, 8, 92, 29];
arr.forEach(dbl);
console.log(arr);
console.log(arr.splice(1, 3));
console.log(arr.reduce((prev, curr) => curr - prev));
3 changes: 3 additions & 0 deletions day3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules

.env
1 change: 1 addition & 0 deletions day3/day3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Day 3 Assignments completed!</h1><br><p>Hello World!</p>
33 changes: 33 additions & 0 deletions day3/day3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const http = require('http');
const fs = require('fs');
const path = require('path');
const formidable = require('formidable');
const write = require('./writefile');
const del = require('./deletefile');
const htmlData = '<h1>Day 3 Assignments completed!</h1><br><p>Hello World!</p>';
write.write(htmlData);
del('./uploadfile.js');
// Create a server
http.createServer((req, res) => {
if (req.url == '/fileupload') {
var form = new formidable.IncomingForm();
form.parse(req, function (err, fields, files) {
var oldpath = files.filetoupload.filepath;
var newpath = path.join(__dirname, 'newFiles', files.filetoupload.originalFilename);
fs.rename(oldpath, newpath, function (err) {
if (err) throw err;
res.write('File uploaded and moved!');
res.end();
});
});
} else {
res.writeHead(200, {
'Content-Type': 'text/html'
});
res.write('<form action="fileupload" method="post" enctype="multipart/form-data">');
res.write('<input type="file" name="filetoupload"><br>');
res.write('<input type="submit">');
res.write('</form>');
return res.end();
}
}).listen(4001);
11 changes: 11 additions & 0 deletions day3/deletefile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const fs = require('fs');

const delFile = (filePath) => {
fs.unlinkSync(filePath, (err) => {
if (err) throw err;
console.log('File deleted successfully!');
});

};

module.exports = delFile;
Empty file added day3/mailer.js
Empty file.
Binary file added day3/newFiles/Problem Statement 2_food-app.pdf
Binary file not shown.
Loading