Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurisonawane07 authored Jun 20, 2024
0 parents commit d59755b
Show file tree
Hide file tree
Showing 24 changed files with 702 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Apirequest.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body style="background-color: #212121; color : #e4e1eff5">
0 UNSENT Client has been created. open() not called yet.
1 OPENED open() has been called.
2 HEADERS_RECEIVED send() has been called, and headers and status are available.
3 LOADING Downloading; responseText holds partial data.
4 DONE The operation is complete.
<button id="button">Card</button>

</body>
<script>
const button = document.querySelector('#button')
const requestUrl = 'https://api.github.com/users/gaurisonawane07'
const xhr = new XMLHttpRequest();
xhr.open('GET',requestUrl)
xhr.onreadystatechange = function(){
console.log(xhr.readyState);
if(xhr.readyState === 4){
const data = JSON.parse(this.responseText)
console.log(this.responseText);
console.log(data.avatar_url);
}
}
const event = xhr.send()


</script>
</html>
14 changes: 14 additions & 0 deletions call.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function SetUserName(username){
//complex DB calls
this.username = username
}

function createUser(username,email,password){

SetUserName.call(this,username)

this.email = email
this.password = password
}
const chai = new createUser("chai","[email protected]","12345")
console.log(chai);
35 changes: 35 additions & 0 deletions classes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//ES6

// class User{
// constructor(username,email,password){
// this.username = username;
// this.email = email;
// this.password = password
// }

// encryptPassword(){
// return `${this.password}abc`
// }
// changeUserName(){
// return `${this.username.toUpperCase()}`
// }
// }
// const chai = new User("gauri","[email protected]","123")
// console.log(chai.encryptPassword());
// console.log(chai.changeUserName());

//behind the scene
function User(username,email,password){
this.username = username;
this.email = email;
this.password = password
}
User.prototype.encryptPassword = function(){
return`${this.password}abc`
}
User.prototype.changeUserName = function(){
return`${this.password}abc`
}
const tea = new User("tea","njhgyddn.com","123")
console.log(tea.encryptPassword());
console.log(tea.changeUserName());
41 changes: 41 additions & 0 deletions five.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// const coding = ["js","ruby","java","python","cpp"]
// const values = coding.forEach((item)=>{
// console.log(item);


// })

// console.log(values);

const myNums = [1,2,3,4,5,6,7,8,9]
// const newNums = myNums.filter((num)=>{
// return num>4;
// })
// console.log(newNums);

const newNums = []
myNums.forEach((num)=>{
if(num>2){
newNums.push(num)
}
})
//console.log(newNums);

const books = [
{title:'book one',genre:'fiction',publish:1981,
edition:2004 },
{title:'book two',genre:'Non-fiction',publish:1992,
edition:2008 },
{title:'book three',genre:'History',publish:1999,
edition:2007},
{title:'book four',genre:'spiritual',publish:1989,
edition:2010 },
{title:'book five',genre:'self help',publish:2009,
edition:2014 },
{title:'book six',genre:'History',publish:1987,
edition:2010 },
{title:'book seven',genre:'motivational',publish:1986,
edition:1996 },
];
const userBooks = books.filter((bk)=>bk.publish > 2000)
console.log(userBooks);
42 changes: 42 additions & 0 deletions four.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 name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM with chai aur code</title>
</head>
<body style="background-color: black; color: aliceblue;">
<ul class = "language">
<li>javascript</li>

</ul>
</body>
<script>
function addLanguage(langname) {
const li = document.createElement('li');
li.innerHTML = `${langname}`
document.querySelector('.language').
appendChild(li)
}
addLanguage("python")


function addoptiLanguage(langname) {
const li = document.createElement('li')
li.appendChild(document.createTextNode(langname))
document.querySelector('.language').appendChild(li)
}
addoptiLanguage("Golang")

//EDIT
const secondLang = document.querySelector("li:nth-child(2)")
const newli = document.createElement('li')
newli.textContent = "Mojo"
secondLang.replaceWith(newli)

//REMOVE
const lastLang = document.querySelector('li:last-child')
lastLang.remove()

</script>
</html>
32 changes: 32 additions & 0 deletions four.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//for in
const myObject = {
js:'javascript',
cpp:'c++',
rb:'ruby',
swift:'swift by apple'

}
for (const key in myObject) {
console.log(myObject[key]);

}
//for each

const myCoding = [
{
languageName:"Javascript",
fileName:"js"
},
{
languageName:"C++",
fileName:"Cpp"
},
{
languageName:"python",
fileName:"py"
}
]
myCoding.forEach((item)=>{

console.log(item.languageName);
})
21 changes: 21 additions & 0 deletions getter_setter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class User {
constructor(email,password){
this.email = email;
this.password = password
}

get email(){
return this._email.toUpperCase()
}
set email(value){
this._email = value
}
get password(){
return this._password.toUpperCase()
}
set password(value){
this._password = value
}
}
const gauri = new User("[email protected]","123")
console.log(gauri.password);
22 changes: 22 additions & 0 deletions inheritance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class User {
constructor(username){
this.username = username
}
logMe() {
console.log(`USERNAME is ${this.username}`);
}
}

class Teacher extends User{
constructor(username,email,password){
super(username)
this.email = email;
this.password = password
}

addCourse(){
console.log(`new course was added by ${this.username}`);
}
}
const chai = new Teacher("chai","[email protected]","123")
chai.addCourse()
16 changes: 16 additions & 0 deletions mathpi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// const descriptor = Object.getOwnPropertyDescriptor(Math,"PI")

// console.log(descriptor);

const chai ={
name:"ginger chai",
price:250,
isAvailable:true
}
console.log(Object.getOwnPropertyDescriptor(chai,"name"));

Object.defineProperty(chai,'name',{
writable:false,
enumerable:false
})
console.log(Object.getOwnPropertyDescriptor(chai,"name"));
24 changes: 24 additions & 0 deletions nodes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Javascript and classes
# OOP


# object
-collection of properties and methods
-toLowerCase
-toUpperCase

## why use OOP
# parts of OOP
Object literal

-Constructor function
-Prototypes
-Classes
Instances(new,this)


# 4 pillars
Abstraction
Encapsulation
Inheritance
Polymorphism
21 changes: 21 additions & 0 deletions object.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function multiplyBy5(num){
return num*5;
}
multiplyBy5.power = 2
console.log(multiplyBy5(5));
console.log(multiplyBy5.power);
console.log(multiplyBy5.prototype);

function createUser(username,score){
this.username = username
this.score = score
}
createUser.prototype.increment = function(){
this.score++
}
createUser.prototype.printMe = function(){
console.log(`score is ${this.score}`);
}
const chai = new createUser("Chai",25)
const tea = new createUser("tea",50)
chai.printMe()
61 changes: 61 additions & 0 deletions one.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML Events </title>
</head>
<body style="background-color: #414141; color: aliceblue;">
<h2>Amazing images</h2>
<div>
<ul id = "images">
<li><img width="200px" id = "japan" src="https://t3.ftcdn.net/jpg/02/65/23/70/360_F_265237090_Muthvb72m2POYFjyx7F5UCQLh9JdBtKN.jpg"
alt = "japan"></li>
<li><img width="200px" id = "river" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQfcKfALItDqcrOumBPIQNthPKLTbnxgaPtdw&s"
alt = ""></li>
<li><img width="200px" id = "owl" src="https://media.istockphoto.com/id/1323187200/photo/spotted-owlet.jpg?s=612x612&w=0&k=20&c=Y0103wykL7LJBhBNUi2HH3uNlCuRZ3I2xVrZcUgryt4="
alt = ""></li>
<li><img width="200px" id = "Heritage" src="https://images1.wionews.com/images/wion/900x1600/2023/7/26/1690369684694_ChittorgarhFort.jpg"
alt = ""></li>
<li><img width="200px" id = "amazon" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQNFcXpp9xQrh49zStTLTQIUPAa1F-FbCz9Ng&s"
alt = ""></li>
<li><a style="color: aqua;" href="https://google.com" id = "google">Google</a>
</ul>
</div>
</body>
<script>
// document.getElementById('owl').onclick = function() {
// alert("owl")
// }
//attachEvent()
//type,timestamp,default prevented
//target,toelement,srcElement
//clientX,clientY,screenX,screenY
//altKey,ctrKey,shiftKey,keyCode
document.getElementById('images').addEventListener('click',function(e){
console.log("Clicked inside the ul");
e.stopPropagation()
},false)
document.getElementById('owl').addEventListener('click',function(e){
console.log(" Owl Clicked ");
},false)

document.getElementById('google').addEventListener('click',function(e){
console.log("google clicked");
e.preventDefault();
e.stopPropagation()
})
document.querySelector('#images').addEventListener('click',function(e){
console.log(e.target.tagName);
if(e.target.tagName === 'IMG'){
let removeIt = e.target.parentNode
removeIt.remove()
//removeIt.parentNode.removeChild(removeIt)
}
},false)




</script>
</html>
Loading

0 comments on commit d59755b

Please sign in to comment.