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

Day 1 Assignment #14

Open
wants to merge 3 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
49 changes: 49 additions & 0 deletions Day 1 : JS BASICS/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<html>
<head>
<script src="index.js"></script>
<script>
function showSelection(data){
var selection = data;
window.alert(selection);
document.getElementById("sel").innerHTML = selection;

var num1 = parseInt(document.getElementById("input1").value);
var num2 = parseInt(document.getElementById("input2").value);

console.log("Number 1",num1);
console.log("Number 2",num2);

var result = 0;
if (selection == "Addition") result = add(num1,num2);
else if (selection == "Subtraction") result = sub(num1,num2);
else if (selection == "Multiplication") result = mul(num1,num2);

//document.write(result);
document.getElementById("result").innerHTML = result;
}
</script>

</head>
<body>
<h1>Swiggy i++ : Day 1 : Calculator</h1>
<div>
<p><b>Number 1 : </b></p>
<input id="input1" type="number">
<p><b>Number 2 : </b></p>
<input id="input2" type="number">
<p><b>Operator : </b></p>
<button id="add" value="Addition" onclick="showSelection(this.value);">+</button>
<button id="sub" value="Subtraction" onclick="showSelection(this.value);">-</button>
<button id="mul" value="Multiplication" onclick="showSelection(this.value);">*</button>
</div>
<div>
<p><b>The User Selected : </b></p>
<p id="sel"></p>
<p><b>Result : </b></p>
<p id="result"></p>
</div>
<div>
<button onclick="window.print()">Print !</button>
</div>
</body>
</html>
21 changes: 21 additions & 0 deletions Day 1 : JS BASICS/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

function add(num1,num2){
console.log("Add Called !");
//var add = parseInt(num1) + parseInt(num2);
return (num1 + num2);
}

function sub(num1,num2){
console.log("Sub Called !");
return (num1 - num2);
}

function mul(num1,num2){
console.log("Multiply Called !");
return (num1 * num2);
}

//function print(){
// console.log("Print Called !");
// window.print();
//}
10 changes: 10 additions & 0 deletions Day 1 : JS BASICS/problem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1.
create a basic html page,
write an inline script, internal script,
import 1 external javascript file,

2.
use javascript display methods
(
innerHTML, document.write, alert(),print(),console.log()
)
Binary file added Day 2 : JS Intermediate/image/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions Day 2 : JS Intermediate/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<html>

<head>
<script src="index.js"></script>
<script>
function addItems(data) {

var arr = [{ id: 1, name: "Sugar" }, { id: 2, name: "Rice" }, { id: 3, name: "Oil" }];

var itemid = parseInt(document.getElementById("item").value);
var itemtext = extractValue(arr, itemid);
console.log(itemtext);
document.getElementById("itemtxt").style.fontSize = 32;
document.getElementById("itemtxt").innerText = itemtext;
}
</script>

</head>

<body>
<h1>Swiggy i++ : Day 2 : Billing Machine</h1>
<div>
<p><b>First Name : </b>
<input id="fname" type="string">
</p>
<p><b>Last Name : </b>
<input id="lname" type="string">
</p>
<p><b>Item Number : </b>
<input id="item" type="number">
</p>
<p><b>Quantity : </b>
<input id="quant" type="number">
</p>
<p><b>Rate </b>
<input id="rate" type="number" onblur="showBillAmount(),addItems()">
</p>
<p id="billtext"><b>Bill Amount </b></p>
<p id="itemtxt"></p>
<p id="billamt"></p>
</div>
<div>
<p>
<img id="logo" src="./image/logo.jpg" width="200" height="200" onload="hideImage()"></img>
</p>
<p>
<button onclick="displayImage()">Display Image</button>
<button onclick="hideImage()">Hide Image</button>
</p>
</div>
<div>
<button onclick="window.print()">Print Bill !</button>
</div>
</body>

</html>
45 changes: 45 additions & 0 deletions Day 2 : JS Intermediate/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function extractValue(arr, id) {

for (let i = 0; i < arr.length; ++i) {
// extract value from property
if (arr[i]['id'] == id) {
return (arr[i]['name']);
}
}
window.alert("Item not found in the Register !")
return ("");
}

function showBillAmount() {
console.log("Bill Amount Called !");

var rate = parseInt(document.getElementById("rate").value);
var quant = parseInt(document.getElementById("quant").value);

console.log(rate);
console.log(quant);

if (rate == NaN) window.alert("Rate Missing !");
else if (quant == NaN) window.alert("Quantity Missing !");
else {
//window.alert("Quantity Missing !");
var total = rate * quant;

console.log(total);

document.getElementById("billtext").style.display = "";
document.getElementById("billamt").style.display = "";
document.getElementById("billamt").style.fontSize = 72;
document.getElementById("billamt").innerText = total;
}
}

function displayImage() {
document.getElementById("logo").style.display = "";
}

function hideImage() {

document.getElementById("logo").style.display = "None";

}
6 changes: 6 additions & 0 deletions Day 2 : JS Intermediate/problem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
§
Modify innerHTML,
style.fontSize,
style.display,
style.visibility,
document.getElementById(“test”).value;
3 changes: 3 additions & 0 deletions Day 3 : NodeJS/datemodule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.myDateTime = function () {
return Date();
};
43 changes: 43 additions & 0 deletions Day 3 : NodeJS/filemodule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var fs = require('fs');

// Append File
exports.append = function (data) {
fs.appendFile('file.txt', data, function (err) {
if (err) throw err;
console.log('Append File !');
//return ('Append File, File -->','file.txt');
})
};

// Open File
exports.open = function (mode) {
fs.open('file2.txt', mode, function (err, file) {
if (err) throw err;
console.log('Opened!');
//return ('Opened File, File -->','file.txt');
})
};

//Write a File
exports.write = function (data) {
fs.writeFile('file.txt', data, function (err) {
if (err) throw err;
console.log('Saved!');
})
};

//Delete a File
exports.delete = function () {
fs.unlink('file2.txt', function (err) {
if (err) throw err;
console.log('Deleted!');
})
};

//Rename a File
exports.rename = function () {
fs.rename('file.txt', 'renamedfile.txt', function (err) {
if (err) throw err;
console.log('File Renamed!');
})
};
20 changes: 20 additions & 0 deletions Day 3 : NodeJS/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html>
<head>
<script src="server.js"></script>
<style>
h1 {text-align: center;}
</style>
</head>
<body>
<h1 >
Swiggy i++ : Day 3 : NodeJS
</h1>
<div>
<input id="content" type="string">
</div>
<div>

</div>

</body>
</html>
70 changes: 70 additions & 0 deletions Day 3 : NodeJS/node_modules/asap/CHANGES.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions Day 3 : NodeJS/node_modules/asap/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading