diff --git a/Activity 2/apidata.html b/Activity 2/apidata.html new file mode 100644 index 0000000..f4a389f --- /dev/null +++ b/Activity 2/apidata.html @@ -0,0 +1,29 @@ + + + + + + + Document + + + + +

+
+

Store Product

+
+
+
+
+
+
+ +
+
+ + + + \ No newline at end of file diff --git a/Activity 2/apidata.js b/Activity 2/apidata.js new file mode 100644 index 0000000..aa4f38e --- /dev/null +++ b/Activity 2/apidata.js @@ -0,0 +1,36 @@ +const urlDemo = "https://portal.tycoonstats.com/api/demo/1"; +const urlProduct = "https://fakestoreapi.com/products"; +const btnDemo = document.getElementById('demo'); +const btnProduct = document.getElementById('btuProduct'); + +btnDemo.addEventListener("click", + async ()=>{ + const response = await fetch(urlDemo); + var data = await response.json(); + document.getElementById("txtData").innerHTML = data.content ; + } +) + +btnProduct.addEventListener("click", + async ()=>{ + const response = await fetch(urlProduct); + var data = await response.json(); + var temp= + ""; + var count = 0; + data.forEach(function (arrayItem) { + count = count+1; + if(count<=10){ + temp = temp.concat(""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + "") + } + }); + document.getElementById("divProduct").innerHTML = "
IdTitlePriceDescriptionCategoryImage
"+arrayItem.id+""+arrayItem.title+""+arrayItem.price+""+arrayItem.description+""+arrayItem.category+""+"" +"
"+temp; + } +) \ No newline at end of file diff --git a/Activity/number_checker.js b/Activity/number_checker.js new file mode 100644 index 0000000..336bc0e --- /dev/null +++ b/Activity/number_checker.js @@ -0,0 +1,27 @@ +const btnCheck = document.getElementById('btnCheck'); + +let count = 0; +let randomNumber = Math.floor(Math.random() * 10); +let newText=""; + +btnCheck.addEventListener("click",()=>{ + const no = document.getElementById("inputNumber").value; + var txt = document.getElementById("txtresult"); + count = count+1; + + if(no>randomNumber){ + txt.innerHTML = "Number is greater then random number"; + } + else if(no + + + + + Number Checker + + + + + +
+

Guess The Number(between 0 to 9)

+
+ +

+
+ + + + + \ No newline at end of file diff --git a/Day 2/Activity 2/spsGame.html b/Day 2/Activity 2/spsGame.html new file mode 100644 index 0000000..c024f7b --- /dev/null +++ b/Day 2/Activity 2/spsGame.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Day 2/Activity 2/spsGame.js b/Day 2/Activity 2/spsGame.js new file mode 100644 index 0000000..057a02b --- /dev/null +++ b/Day 2/Activity 2/spsGame.js @@ -0,0 +1,169 @@ + +const {Component, mount, xml, useState, reactive, useEnv } = owl; + +const finalData = () => { + const counter = useEnv(); + return useState(counter.store); +} +class DataList{ + count=0; + updateCount(){this.count++;} + getCount(){ return this.count;} + scoreCountGuest = 0; + scoreCountComputer = 0; + matchCount = 0; + guestMatchCount = 0; + updatescoreCountComputer(){ this.scoreCountComputer++; } + getScoreCountComputer(){ return this.scoreCountComputer } + updatescoreCountGuest(){ this.scoreCountGuest++; } + getScoreCountGuest(){ return this.scoreCountGuest } + updatematchCount(){ this.matchCount++ } + getmatchCount(){ return this.matchCount } + updateGuestMatchCount(){ this.guestMatchCount++ } + getGuestMatchCount(){ return this.guestMatchCount } + +} + +class MatchComponent extends Component{ + static template=xml` +

Matches

+
+ + + + + + + + + +
GuestComputer
00
+ `; +} + + +class ScoreComponent extends Component{ + static template=xml` +

Scores

+ + + + + + + + + +
GuestComputer
00
+ `; +} + +class ResultComponent extends Component{ + static template=xml` +

Result of this trial

+

+ `; + +} + +class Root extends Component{ + static template=xml` +
+

Rock Paper Scissors

+ Enter your Choice:
+ 1. Rock
+ 2. Paper
+ 3. Scissors
+ + + + +
+ `; + + setup(){ + this.counter = finalData(); + } + + + myChoice(ev){ + let arr = [1,2,3]; + this.counter.updateCount(); + if(this.counter.getCount()>5){ + this.counter.updatematchCount(); + if(this.counter.scoreCountComputer>this.counter.scoreCountGuest){ + alert("Sorry, Better luck next time"); + } + else if(this.counter.scoreCountComputer { + return reactive(new DataList()); +} + +const env = { store: createData() }; + +mount(Root,document.body,{dev: true, env}); \ No newline at end of file diff --git a/Day 2/Activity/gueessNumber.js b/Day 2/Activity/gueessNumber.js new file mode 100644 index 0000000..2a3e049 --- /dev/null +++ b/Day 2/Activity/gueessNumber.js @@ -0,0 +1,74 @@ + +const {Component, mount, xml, useState, reactive, useEnv } = owl; + +const finalData = () => { + const counter = useEnv(); + return useState(counter.store); +} + +class DataList{ + count=0; + updateCount(){ this.count++; } + getCount(){ return this.count;} +} +class Second extends Component{ + static template=xml` +
+ Please Guess the number: + +

+ `; + + setup(){ + this.counter = finalData(); + } + + static props=["randomNumber"]; + checkMe(ev){ + let no = ev.target.value; + let newText = ""; + this.counter.updateCount(); + console.log(this.props.randomNumber.randomNumber,"random no"); + console.log(no, "user no"); + console.log(this.counter.getCount(), "counter value"); + + if(no>this.props.randomNumber.randomNumber){ + newText = "Number is greater then random number"; + } + else if(noComputer Guess: + + `; + setup(){ + let x = Math.floor((Math.random() * 10) + 1); + console.log(x) + this.data=useState({randomNumber:x}) + + } + static components={Second}; + +} + +const createData = () => { + return reactive(new DataList()); +} + +const env = { store: createData() }; + +mount(Root,document.body,{dev: true, env}); \ No newline at end of file diff --git a/Day 2/Activity/guessNumber.html b/Day 2/Activity/guessNumber.html new file mode 100644 index 0000000..cecc045 --- /dev/null +++ b/Day 2/Activity/guessNumber.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file