diff --git a/Atharv/Chat app/.vscode/settings.json b/Atharv/Chat app/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/Atharv/Chat app/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/Atharv/Chat app/index.html b/Atharv/Chat app/index.html new file mode 100644 index 0000000..0352eb6 --- /dev/null +++ b/Atharv/Chat app/index.html @@ -0,0 +1,37 @@ + + + + Chat App + + + +
+

Enter your API key here

+ +

Select the model that you want to use

+ +

Chat History

+ +
+
+

ChatGPT

+ +
+
+
+ + +
+
+
+ + + diff --git a/Atharv/Chat app/script.js b/Atharv/Chat app/script.js new file mode 100644 index 0000000..f44dfaa --- /dev/null +++ b/Atharv/Chat app/script.js @@ -0,0 +1,155 @@ +const input=document.querySelector("#user-input"); +const enter=document.querySelector("#enter-btn"); +const key=document.querySelector("#api-key"); +const modelname=document.querySelector("#drop-down"); +const chatBox=document.querySelector("#chat-box"); +const newChatBtn=document.querySelector("#new-chat-btn"); +const historyList=document.querySelector("#history-list"); + +let allThreads=JSON.parse(localStorage.getItem("chatThreads"))||[]; +let currentThreadIndex=allThreads.length; +let currentChat=[]; +let decoder=new TextDecoder("utf-8"); + +window.addEventListener("load",()=>{ + updateHistory(); + if(currentThreadIndex{ + if(!key.value) { + alert("Please enter the API key first"); + return; + } + const userMessage=input.value.trim(); + if(userMessage==="")return; + input.value=""; + addMessage("You",userMessage); + currentChat.push({sender:"You",message:userMessage}); + dataHandling(userMessage); +}); + +newChatBtn.addEventListener("click",()=>{ + currentChat=[]; + currentThreadIndex=allThreads.length; + chatBox.innerHTML=""; + chatBox.scrollTop=0; +}); + +async function dataHandling(message){ + const model=modelname.value; + const apiKey=key.value; + + const aiMsgDiv=document.createElement("div"); + aiMsgDiv.classList.add("message","ai-message"); + const aiMsgText=document.createElement("p"); + aiMsgDiv.appendChild(aiMsgText); + chatBox.appendChild(aiMsgDiv); + chatBox.scrollTop=chatBox.scrollHeight; + try{ + const response=await fetch("https://openrouter.ai/api/v1/chat/completions", { + method:"POST", + headers:{ + "Content-Type":"application/json", + "Authorization":`Bearer ${apiKey}`, + "X-Title":"LLM Chat App" + }, + body:JSON.stringify({ + model:model, + messages:[{role:"user",content:message}], + stream:true + }) + }); + if(!response.ok){ + const errorText=`${response.status} ${response.statusText}`; + addMessage("AI", errorText); + return; + } + const reader=response.body.getReader(); + let fullReply=""; + while(true){ + const{value,done}=await reader.read(); + if(done)break; + + const chunk=decoder.decode(value); + let lines=chunk.split('\n'); + for(let line of lines){ + if(line.startsWith("data: ")){ + const jsonData=line.replace("data: ","").trim(); + if(jsonData==="[DONE]"){ + break; + } + try{ + const parsed=await JSON.parse(jsonData); + delta=parsed.choices[0]?.delta?.content; + if(delta){ + aiMsgText.innerHTML+=delta; + fullReply+=delta; + } + }catch(e){ + } + } + } + } + const aiReply=await markDown(fullReply); + aiMsgText.innerHTML=aiReply; + currentChat.push({sender:"AI",message:aiReply}); + allThreads[currentThreadIndex]=currentChat; + localStorage.setItem("chatThreads",JSON.stringify(allThreads)); + updateHistory(); + }catch(error) { + console.error("Fetch error:",error); + const errorMsg =`Fetch failed: ${error.message}`; + addMessage("AI",errorMsg); + currentChat.push({sender:"AI",message:errorMsg}); + } +} + +async function addMessage(sender, message){ + const messageDiv=document.createElement("div"); + messageDiv.classList.add("message",sender==="You"?"user-message":"ai-message"); + const messageText=document.createElement("p"); + messageText.innerHTML=message; + messageDiv.appendChild(messageText); + chatBox.appendChild(messageDiv); + chatBox.scrollTop=chatBox.scrollHeight; +} + +function renderChat(messages){ + chatBox.innerHTML = ""; + messages.forEach(msg => addMessage(msg.sender, msg.message)); + chatBox.scrollTop = chatBox.scrollHeight; +} + +function updateHistory(){ + historyList.innerHTML=""; + allThreads.forEach((thread,index)=>{ + const li=document.createElement("li"); + const preview=thread[0]?.message?.slice(0, 30)||"Empty Chat"; + li.textContent=`Chat ${index + 1}: ${preview}`; + li.addEventListener("click",()=>{ + currentThreadIndex=index; + currentChat=[...thread]; + renderChat(currentChat); + }); + historyList.appendChild(li); + }); +} + +async function markDown(message){ + const markDownedHTML=await fetch('https://api.github.com/markdown',{ + method:'POST', + headers:{ + 'Content-Type':'application/json' + }, + body:JSON.stringify({ + text:message, + model:"markDown" + }) + }) + let markDownedText=await markDownedHTML.text(); + return markDownedText; +} diff --git a/Atharv/Chat app/style.css b/Atharv/Chat app/style.css new file mode 100644 index 0000000..28e91af --- /dev/null +++ b/Atharv/Chat app/style.css @@ -0,0 +1,122 @@ +html, body { + width: 100%; + height: 100%; + overflow: hidden; + font-family: sans-serif; + background: white; + display: flex; +} + +#left-section { + height: 100vh; + width: 25vw; + border-right: 2px solid black; + padding: 20px; +} + +#right-section { + height: 100vh; + width: 75vw; + display: flex; + flex-direction: column; + align-items: center; + padding: 20px; +} + +#heading { + margin: 0; +} + +#new-chat-btn { + background-color: #0092e0; + color: white; + border-radius: 10px; + padding: 10px 20px; + margin-bottom: 15px; + cursor: pointer; + font-size: 16px; + align-self: flex-end; +} + +#app { + width: 100%; + height: 80vh; +} + +#chat-box { + display: flex; + flex-direction: column; + height: 80%; + width: 100%; + padding: 10px; + overflow-y: auto; + margin-bottom: 50px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); +} + +#input-area { + display: flex; + flex-direction: row; + width: 100%; +} + +#user-input { + width: 90%; + height: 40px; + border: 2px solid black; + border-radius: 10px; + margin-right: 5%; + font-size: 16px; +} + +#enter-btn { + width: 5%; + background: none; + border: none; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; +} + +#enter-btn img { + width: 30px; + height: 30px; +} + +.message { + max-width: 70%; + margin: 10px; + padding: 10px 15px; + border-radius: 15px; + font-size: 16px; + word-wrap: break-word; + display: inline-block; +} + +.user-message { + background-color: #dcf8c6; + align-self: flex-end; + margin-left: auto; + text-align: right; +} + +.ai-message { + background-color: #f1f0f0; + align-self: flex-start; + margin-right: auto; + text-align: left; +} + +#history-list { + overflow-y: auto; + border: 1px solid #ccc; + border-radius: 8px; + margin-top: 10px; +} + +#history-list li { + padding: 8px 8px; + border-bottom: 1px solid #eee; + cursor: pointer; +} diff --git a/Atharv/Snappy site/index.html b/Atharv/Snappy site/index.html new file mode 100644 index 0000000..a8b1fc5 --- /dev/null +++ b/Atharv/Snappy site/index.html @@ -0,0 +1,26 @@ + + + + + Snappy Ecommerce + + + +
+ + + + +
+
+ + + + + + + diff --git a/Atharv/Snappy site/script.js b/Atharv/Snappy site/script.js new file mode 100644 index 0000000..0b708af --- /dev/null +++ b/Atharv/Snappy site/script.js @@ -0,0 +1,95 @@ +let dataItems=[]; +let dataCategories=[]; +let currentPage=1; +const itemsPerPage=10; +let filteredItems=[]; + +async function fetchItems(){ + try{ + const responseItems=await fetch('http://43.205.110.71:8000/items'); + dataItems=await responseItems.json(); + const responseCategories=await fetch('http://43.205.110.71:8000/categories'); + dataCategories=await responseCategories.json(); + displayItems(); + }catch(error){ + console.error('Fetch error:',error); + } +} + +fetchItems(); + +function displayItems(){ + const tagsDropdown=document.querySelector('#tag'); + const categoriesDropdown=document.querySelector('#category'); + const uniqueTags=new Set(); + dataItems.forEach(item=>{ + if(item.tags)item.tags.split('|').forEach(tag => uniqueTags.add(tag)); + }); + tagsDropdown.innerHTML=``; + uniqueTags.forEach(tag=>{ + tagsDropdown.innerHTML+=``; + }); + categoriesDropdown.innerHTML=``; + dataCategories.forEach(cat=>{ + categoriesDropdown.innerHTML+=``; + }); + renderFilteredItems('all','all'); + tagsDropdown.addEventListener('change',()=>{ + currentPage=1; + renderFilteredItems(categoriesDropdown.value, tagsDropdown.value); + }); + categoriesDropdown.addEventListener('change',()=>{ + currentPage=1; + renderFilteredItems(categoriesDropdown.value,tagsDropdown.value); + }); + document.querySelector('#prev').addEventListener('click',()=>{ + if(currentPage>1) { + currentPage--; + renderPage(); + } + }); + document.querySelector('#next').addEventListener('click',()=>{ + const totalPages=Math.ceil(filteredItems.length/itemsPerPage); + if(currentPage{ + const matchCategory=categorySelected==='all'||item.category===categorySelected; + const matchTag=tagSelected==='all'||(item.tags && item.tags.includes(tagSelected)); + return matchCategory && matchTag; + }); + renderPage(); +} + +function renderPage(){ + const container=document.querySelector('#items'); + container.innerHTML=''; + const start=(currentPage-1)*itemsPerPage; + const end=start+itemsPerPage; + const pageItems=filteredItems.slice(start,end); + pageItems.forEach(item=>{ + const div=document.createElement('div'); + div.className='item-card'; + div.innerHTML=` +

${item.name}

+

Brand: ${item.brand}

+

Price: ₹${item.price}

+

Tags: ${item.tags}

+

Category: ${item.category}

+ `; + container.appendChild(div); + }); + updatePaginationInfo(); +} + +function updatePaginationInfo() { + const totalPages=Math.ceil(filteredItems.length/itemsPerPage); + document.getElementById('page-info').textContent=`Page ${currentPage} of ${totalPages}`; + document.getElementById('prev').disabled=currentPage===1; + document.getElementById('next').disabled=currentPage===totalPages; +} diff --git a/Atharv/Snappy site/style.css b/Atharv/Snappy site/style.css new file mode 100644 index 0000000..465416d --- /dev/null +++ b/Atharv/Snappy site/style.css @@ -0,0 +1,51 @@ +body { + padding:20px; + background-color: white; +} + +.selectors { + display:flex; + justify-content:center; + gap:20px; + margin-bottom:30px; +} + +#category, #tag { + padding:6px 12px; + font-size:14px; + border-radius:6px; + border:1px solid #ccc; +} + +#items { + display:grid; + grid-template-columns:1fr 1fr 1fr 1fr 1fr; + gap:20px; + padding:10px; +} + +.item-card{ + background: white; + padding:15px; + border-radius:10px; + box-shadow:0 4px 12px rgba(0,0,0,0.1); +} + +.pagination{ + display:flex; + justify-content:center; + gap:10px; + margin-top:20px; +} + +.pagination button { + padding:6px 12px; + background-color: blue; + color: white; + border-radius:6px; +} + +#page-info { + padding:6px 12px; + font-size:14px; +} \ No newline at end of file diff --git a/Atharv/lumber jack game/assets/Player1.png b/Atharv/lumber jack game/assets/Player1.png new file mode 100644 index 0000000..90b2c73 Binary files /dev/null and b/Atharv/lumber jack game/assets/Player1.png differ diff --git a/Atharv/lumber jack game/assets/Player2.png b/Atharv/lumber jack game/assets/Player2.png new file mode 100644 index 0000000..a2fb210 Binary files /dev/null and b/Atharv/lumber jack game/assets/Player2.png differ diff --git a/Atharv/lumber jack game/assets/Player3.png b/Atharv/lumber jack game/assets/Player3.png new file mode 100644 index 0000000..29a7f97 Binary files /dev/null and b/Atharv/lumber jack game/assets/Player3.png differ diff --git a/Atharv/lumber jack game/assets/apple.png b/Atharv/lumber jack game/assets/apple.png new file mode 100644 index 0000000..1665f0b Binary files /dev/null and b/Atharv/lumber jack game/assets/apple.png differ diff --git a/Atharv/lumber jack game/assets/background.png b/Atharv/lumber jack game/assets/background.png new file mode 100644 index 0000000..f335acf Binary files /dev/null and b/Atharv/lumber jack game/assets/background.png differ diff --git a/Atharv/lumber jack game/assets/bgmusic.mp3 b/Atharv/lumber jack game/assets/bgmusic.mp3 new file mode 100644 index 0000000..38c3a0a Binary files /dev/null and b/Atharv/lumber jack game/assets/bgmusic.mp3 differ diff --git a/Atharv/lumber jack game/assets/character2.png b/Atharv/lumber jack game/assets/character2.png new file mode 100644 index 0000000..54373c0 Binary files /dev/null and b/Atharv/lumber jack game/assets/character2.png differ diff --git a/Atharv/lumber jack game/assets/character3.png b/Atharv/lumber jack game/assets/character3.png new file mode 100644 index 0000000..b92ee43 Binary files /dev/null and b/Atharv/lumber jack game/assets/character3.png differ diff --git a/Atharv/lumber jack game/assets/choppingtree.mp3 b/Atharv/lumber jack game/assets/choppingtree.mp3 new file mode 100644 index 0000000..33739a4 Binary files /dev/null and b/Atharv/lumber jack game/assets/choppingtree.mp3 differ diff --git a/Atharv/lumber jack game/assets/left-branch.png b/Atharv/lumber jack game/assets/left-branch.png new file mode 100644 index 0000000..37409b8 Binary files /dev/null and b/Atharv/lumber jack game/assets/left-branch.png differ diff --git a/Atharv/lumber jack game/assets/right-branch.png b/Atharv/lumber jack game/assets/right-branch.png new file mode 100644 index 0000000..5f14949 Binary files /dev/null and b/Atharv/lumber jack game/assets/right-branch.png differ diff --git a/Atharv/lumber jack game/assets/trunk3.png b/Atharv/lumber jack game/assets/trunk3.png new file mode 100644 index 0000000..1322412 Binary files /dev/null and b/Atharv/lumber jack game/assets/trunk3.png differ diff --git a/Atharv/lumber jack game/index.html b/Atharv/lumber jack game/index.html new file mode 100644 index 0000000..5afb4e0 --- /dev/null +++ b/Atharv/lumber jack game/index.html @@ -0,0 +1,28 @@ + + + + + Lumberjack Game + + + +
+

Lumberjack Game

+

+ Press ArrowLeft to chop left, ArrowRight to chop right.
+ Avoid branches on your side! If you hit one you will be paused for 4 seconds. You can collect apples to shield you from your mistakes. To collect Apples click on the wrong side for the apple branch
+ Enter game duration and hit Start. +

+ + + +
+ +
+

Game Over

+

+ +
+ + + diff --git a/Atharv/lumber jack game/script.js b/Atharv/lumber jack game/script.js new file mode 100644 index 0000000..a2f9806 --- /dev/null +++ b/Atharv/lumber jack game/script.js @@ -0,0 +1,252 @@ +const canvas=document.getElementById("gameCanvas"); +const ctx=canvas.getContext("2d"); +canvas.width=window.innerWidth; +canvas.height=window.innerHeight; + +const ground=new Image(); +const trunk=new Image(); +const leftbranch=new Image(); +const rightbranch=new Image(); +const lumberjack=new Image(); +const punishedLumberjack=new Image(); +const choppingLumberjack=new Image(); +const apple=new Image(); +const bgmusic=new Audio("assets/bgmusic.mp3"); +const choppingtree=new Audio("assets/choppingtree.mp3") + +apple.src="assets/apple.png" +ground.src="assets/background.png"; +trunk.src="assets/trunk3.png"; +leftbranch.src="assets/left-branch.png"; +rightbranch.src="assets/right-branch.png"; +lumberjack.src="assets/player1.png"; +punishedLumberjack.src="assets/player3.png"; +choppingLumberjack.src="assets/player2.png"; + +let segments=1000; +const trunkWidth=300; +const trunkHeight=80; +const treeX=(canvas.width-trunkWidth)/2; + +let fulltree=[]; +let apples=[]; +let playerSide="left"; +let isPunished=false; +let isChopping=false; +let elapsedTime=0; +let score=0; +let punishCount=0; +let gameTime=30; +let gameInterval=null; +let timerInterval=null; +let gameEnded=false; +bgmusic.loop=true; +bgmusic.volume=0.5; +let applesCollected=0; + +function generateTree(){ + fulltree=[]; + for(let i=0;i0) { + applesCollected--; + isWrong=false; + }else{ + isPunished=true; + punishCount++; + drawScene(); + setTimeout(()=>{ + isPunished=false; + drawScene(); + },4000); + return; + } + } + choppingtree.currentTime=0; + choppingtree.play(); + fulltree.pop(); + apples.pop(); + playerSide=side; + score++; + isChopping=true; + drawScene(); + setTimeout(()=>{ + isChopping=false; + drawScene(); + },200); +} + + + +function startGame(){ + gameTime=parseInt(document.getElementById("timeInput").value)||30; + document.getElementById("startScreen").style.display="none"; + document.getElementById("gameCanvas").style.display="block"; + document.getElementById("endScreen").style.display="none"; + + generateTree(); + generateApple(); + applesCollected=0; + playerSide="left"; + isPunished=false; + isChopping=false; + elapsedTime=0; + score=0; + punishCount=0; + gameEnded=false; + bgmusic.play(); + + gameInterval=setTimeout(()=>{ + gameEnded=true; + clearInterval(timerInterval); + document.getElementById("gameCanvas").style.display="none"; + document.getElementById("endScreen").style.display="block"; + document.getElementById("finalScore").innerText= + `šŸŖ“ Final Score: ${score}\nāŒ Times Punished: ${punishCount}`; + bgmusic.pause(); + bgmusic.currentTime=0; + },gameTime*1000); + + timerInterval=setInterval(()=>{ + elapsedTime++; + drawScene(); + },1000); + + drawScene(); +} + +function restartGame(){ + clearInterval(timerInterval); + clearTimeout(gameInterval); + document.getElementById("endScreen").style.display="none"; + document.getElementById("startScreen").style.display="block"; +} + +window.addEventListener("keydown",(e)=>{ + if(e.key==="ArrowLeft")handleChop("left"); + else if (e.key==="ArrowRight") handleChop("right"); +}); + +let imagesLoaded=0; +function onImageLoad(){ + imagesLoaded++; + if(imagesLoaded===8) { + document.getElementById("startScreen").style.display="block"; + document.getElementById("gameCanvas").style.display="none"; + document.getElementById("endScreen").style.display="none"; + } +} + +ground.onload=onImageLoad; +trunk.onload=onImageLoad; +leftbranch.onload=onImageLoad; +rightbranch.onload=onImageLoad; +lumberjack.onload=onImageLoad; +punishedLumberjack.onload=onImageLoad; +choppingLumberjack.onload=onImageLoad; +apple.onload=onImageLoad; diff --git a/Atharv/lumber jack game/style.css b/Atharv/lumber jack game/style.css new file mode 100644 index 0000000..868b6fc --- /dev/null +++ b/Atharv/lumber jack game/style.css @@ -0,0 +1,49 @@ +html, body { + margin:0; + padding:0; + height:100%; + background-color: black; + color: white; + display:flex; + justify-content:center; + align-items:center; + text-align:center; +} + +#startScreen,#endScreen { + background-color:#111; + padding:40px; + border-radius:12px; + box-shadow:0 0 20px rgba(0, 255, 255, 0.5); +} + + +#startScreen h1 { + margin-bottom:10px; + color:#00ffcc; +} + +#startScreen p { + margin-bottom:20px; + line-height:1.6; +} + +#startScreen input { + padding:8px; + font-size:16px; + width:100px; + margin-bottom:10px; +} + +#startScreen button, +#endScreen button { + padding:10px 20px; + font-size:16px; + background-color:#00ffcc; + color:black; + border-radius: 6px; +} + +#endScreen h2 { + color: #ffcc00; +} diff --git a/Atharv_Garg b/Atharv_Garg new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Atharv_Garg @@ -0,0 +1 @@ +