diff --git a/Bhavy/GAME/index.html b/Bhavy/GAME/index.html
new file mode 100644
index 0000000..358484d
--- /dev/null
+++ b/Bhavy/GAME/index.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+ Platform Game
+
+
+ Score: 0
+ High Score : 0
+
+
Welcome to the Game!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Bhavy/GAME/script.js b/Bhavy/GAME/script.js
new file mode 100644
index 0000000..29e1f6e
--- /dev/null
+++ b/Bhavy/GAME/script.js
@@ -0,0 +1,472 @@
+document.addEventListener('DOMContentLoaded', function() {
+ let blocks = document.querySelectorAll('.block');
+ let cloudBlocks = document.querySelectorAll('.cloudBlock');
+ let startingText = document.querySelector('.startingText');
+ let startButton = document.querySelector('#startButton');
+ let game = document.querySelector('.game');
+ let h1 = document.querySelector('h1');
+
+
+ //coins stuff
+ let coinCollected =0;
+ NoOfCloudCoins=0;
+ let Highscore=0;
+
+ if (localStorage.getItem('gameHighScore')) {
+ Highscore = parseInt(localStorage.getItem('gameHighScore'), 10) || 0;
+ const highScoreDiv = document.getElementById("highScore");
+ if (highScoreDiv) {
+ highScoreDiv.textContent = `High Score : ${Highscore}`;
+ }
+ }
+
+ function updateHighScore(newScore) {
+ Highscore = newScore;
+ localStorage.setItem('gameHighScore', Highscore);
+ const highScoreDiv = document.getElementById("highScore");
+ if (highScoreDiv) {
+ highScoreDiv.textContent = `High Score : ${Highscore}`;
+ }
+ }
+
+
+ let cameraX=0;
+ let cameraSpeed=0.3;
+ let cameraAcc=0.001;
+
+ let CoinProbability = 0.4; // 10% chance to spawn a coin
+ let AirCoinProbability = 0.05; // 5% chance to spawn an air coin
+
+ // Loudness setup
+ let audioContext, analyser, microphone, dataArray;
+ let loudJumpThreshold = 5;
+ let lastJumpTime = 0;
+ let jumpCooldown = 10;
+
+ let doubleJumpUsed = false;
+
+ let score = 0;
+
+
+
+ // For demo: Uncomment to test score increment every 2 seconds
+ // setInterval(collectCoin, 2000);
+
+ function setupAudio() {
+ if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
+ navigator.mediaDevices.getUserMedia({ audio: true })
+ .then(function(stream) {
+ audioContext = new (window.AudioContext || window.webkitAudioContext)();
+ analyser = audioContext.createAnalyser();
+ microphone = audioContext.createMediaStreamSource(stream);
+ microphone.connect(analyser);
+ analyser.fftSize = 256;
+ dataArray = new Uint8Array(analyser.frequencyBinCount);
+ detectLoudness();
+ })
+ .catch(function(err) {
+ console.error('Microphone error:', err);
+ });
+ } else {
+ alert('getUserMedia not supported in this browser.');
+ }
+ }
+
+ setupAudio();
+ function detectLoudness() {
+ analyser.getByteTimeDomainData(dataArray);
+ let sum = 0;
+ for (let i = 0; i < dataArray.length; i++) {
+ let val = (dataArray[i] - 128) / 128;
+ sum += val * val;
+ }
+ let rms = Math.sqrt(sum / dataArray.length);
+ let volume = rms * 100;
+
+ let now = Date.now();
+ if (volume > loudJumpThreshold && now - lastJumpTime > jumpCooldown) {
+ if (isOnGround > 0) {
+ jump(volume**2);
+ } else if (isOnGround === 1 && !doubleJumpUsed) {
+ doubleJump();
+ doubleJumpUsed = true;
+ }
+ lastJumpTime = now;
+ }
+
+ requestAnimationFrame(detectLoudness);
+ }
+
+ let Player = document.createElement('div');
+ Player.style.width = '0.6rem';
+ Player.style.height = '0.6rem';
+ Player.style.backgroundColor = 'orange';
+ Player.style.position = 'absolute';
+ Player.style.left = '60px';
+ Player.style.top = '300px';
+ Player.style.borderRadius = '50%';
+ Player.style.zIndex = '2';
+ document.body.appendChild(Player);
+
+ let xSpeed = 0;
+ let ySpeed = 0;
+ let g = 0.08;
+ let Yacc = g;
+ let Xacc = -0.007;
+ let isOnGround = 0;
+ let x = 60;
+ let y = 300;
+
+ function jump(holdTime = 0) {
+ if (holdTime > 2000) {
+ holdTime = 2000; t
+ }
+ if (isOnGround > 0) {
+ ySpeed = -1.5 - (holdTime / 200);
+ xSpeed = 0.8 + (holdTime / 400);
+ isOnGround--;
+ }
+
+ }
+
+ function doubleJump() {
+ if (isOnGround === 1 && !doubleJumpUsed) {
+ ySpeed = -2.7;
+ xSpeed = 1.3;
+ isOnGround--;
+ doubleJumpUsed = true;
+ }
+ }
+
+ let keyDownTime = 0;
+
+ document.addEventListener('keydown', (key) => {
+ if (key.code === 'Space') {
+ if (!key.repeat && isOnGround > 0) {
+ keyDownTime = Date.now();
+ }
+ else if (isOnGround === 1 && !doubleJumpUsed) {
+ doubleJump();
+ }
+ }
+ });
+
+ document.addEventListener('keyup', (key) => {
+ if (key.code === 'Space') {
+ let keyHoldDuration = Date.now() - keyDownTime;
+ if (isOnGround > 0) {
+ jump(keyHoldDuration);
+ }
+ }
+ });
+
+ function moving() {
+ ySpeed += Yacc;
+ y += ySpeed;
+
+ if (!(xSpeed > -0.2 && xSpeed < 0.1)) {
+ xSpeed += Xacc;
+ x += xSpeed;
+ Player.style.left = x + 'px';
+ }
+
+ Player.style.top = y + 'px';
+
+ if (y + Player.offsetHeight >= window.innerHeight) {
+ y = window.innerHeight - Player.offsetHeight;
+ ySpeed = 0;
+ xSpeed=0;
+ Player.style.top = y + 'px';
+ if (h1) h1.innerText = 'HAHAHA YOU LOOSE';
+ }
+
+ if (x + Player.offsetWidth >= window.innerWidth) {
+ // x = window.innerWidth - Player.offsetWidth;
+ // Bounce back
+
+ // If player crosses the right boundary, wrap to left edge with same speed and height
+ x = 0;
+ Player.style.left = x + 'px';
+
+
+ }
+
+ cloudBlocks.forEach((block, index) => {
+ let rect = block.getBoundingClientRect();
+ let playerBottom = y + Player.offsetHeight;
+ let playerLeft = x;
+ let playerRight = x + Player.offsetWidth;
+ //above colison
+ if (
+ playerBottom >= rect.top &&
+ playerBottom <= rect.top + 10 &&
+ playerRight > rect.left &&
+ playerLeft < rect.right
+ ) {
+ if (ySpeed > 0) {
+ y = rect.top - Player.offsetHeight;
+ ySpeed = 0;
+ Player.style.top = y + 'px';
+ isOnGround = 2;
+ doubleJumpUsed = false;
+ }
+ if (xSpeed>0){
+ xSpeed=xSpeed/1.043;
+
+ }
+ }
+ //botton colison
+
+ let playerTop = y;
+ if (
+ playerTop <= rect.bottom &&
+ playerTop >= rect.bottom - 10 &&
+ playerRight > rect.left &&
+ playerLeft < rect.right
+ ) {
+ ySpeed = -ySpeed * 0.1;
+ }
+ // Side collision
+ if (
+ playerRight >= rect.left &&
+ playerLeft <= rect.right &&
+ y + Player.offsetHeight > rect.top &&
+ y < rect.bottom
+ ) {
+ if (xSpeed > 0) {
+ x = rect.left - Player.offsetWidth;
+ xSpeed = 0;
+ Player.style.left = x + 'px';
+ } else if (xSpeed < 0) {
+ x = rect.right;
+ xSpeed = 0;
+ Player.style.left = x + 'px';
+ }
+ }
+ });
+
+ blocks.forEach((block, index) => {
+ let rect = block.getBoundingClientRect();
+ let playerBottom = y + Player.offsetHeight;
+ let playerLeft = x;
+ let playerRight = x + Player.offsetWidth;
+ //above colison
+ if (
+ playerBottom >= rect.top &&
+ playerBottom <= rect.top + 10 &&
+ playerRight > rect.left &&
+ playerLeft < rect.right
+ ) {
+ if (ySpeed > 0) {
+ y = rect.top - Player.offsetHeight;
+ ySpeed = 0;
+ Player.style.top = y + 'px';
+ isOnGround = 2;
+ doubleJumpUsed = false;
+ }
+ if (xSpeed>0){
+ xSpeed=xSpeed/1.043;
+ }
+ if(index===18){
+ if (h1) h1.innerText = 'YOU WONNNNN';
+ }
+ }
+ //botton colison
+
+ let playerTop = y;
+ if (
+ playerTop <= rect.bottom &&
+ playerTop >= rect.bottom - 10 &&
+ playerRight > rect.left &&
+ playerLeft < rect.right
+ ) {
+ ySpeed = -ySpeed * 0.1;
+ }
+ // Side collision
+ if (
+ playerRight >= rect.left &&
+ playerLeft <= rect.right &&
+ y + Player.offsetHeight > rect.top &&
+ y < rect.bottom
+ ) {
+ if (xSpeed > 0) {
+ x = rect.left - Player.offsetWidth;
+ xSpeed = 0;
+ Player.style.left = x + 'px';
+ } else if (xSpeed < 0) {
+ x = rect.right;
+ xSpeed = 0;
+ Player.style.left = x + 'px';
+ }
+ }
+ });
+
+ // Coin collection logic
+ let coinElements = document.querySelectorAll('.coin');
+ coinElements.forEach((coin, idx) => {
+ // Only check visible coins (not already collected)
+ if (coin.style.visibility === "hidden") return;
+
+ let coinRect = coin.getBoundingClientRect();
+ let playerRect = Player.getBoundingClientRect();
+
+ // Simple AABB collision detection
+ if (
+ playerRect.right > coinRect.left &&
+ playerRect.left < coinRect.right &&
+ playerRect.bottom > coinRect.top &&
+ playerRect.top < coinRect.bottom
+ ) {
+ // Collect the coin
+ coin.style.visibility = "hidden";
+ coinCollected++;
+ score += 1;
+ const scoreDiv = document.getElementById('score');
+ if (scoreDiv) {
+ scoreDiv.textContent = `Score: ${score}`;
+ if (score > Highscore) {
+ Highscore = score;
+ const highScoreDiv = document.getElementById("highScore");
+ if (highScoreDiv) {
+ highScoreDiv.textContent = `High Score : ${Highscore}`;
+ updateHighScore(score);
+ }
+ }
+ }
+ // e.g. document.getElementById('score').innerText = coinCollected;
+ }
+ });
+
+ let CloudCoinsElements = document.querySelectorAll('.CloudCoin');
+ CloudCoinsElements.forEach((coin, idx) => {
+ // Only check visible coins (not already collected)
+ if (coin.style.visibility === "hidden") return;
+
+ let coinRect = coin.getBoundingClientRect();
+ let playerRect = Player.getBoundingClientRect();
+
+ // Simple AABB collision detection
+ if (
+ playerRect.right > coinRect.left &&
+ playerRect.left < coinRect.right &&
+ playerRect.bottom > coinRect.top &&
+ playerRect.top < coinRect.bottom
+ ) {
+ // Collect the coin
+ coin.style.visibility = "hidden";
+ coinCollected++;
+ score += 10;
+ const scoreDiv = document.getElementById('score');
+ if (scoreDiv) {
+ scoreDiv.textContent = `Score: ${score}`;
+ if (score > Highscore) {
+ Highscore = score;
+ const highScoreDiv = document.getElementById("highScore");
+ if (highScoreDiv) {
+ highScoreDiv.textContent = `High Score : ${Highscore}`;
+ updateHighScore(score);
+ }
+ }
+ }
+ // e.g. document.getElementById('score').innerText = coinCollected;
+ }
+ });
+
+ }
+
+ function getLastBlockX() {
+ const lastBlock = document.querySelectorAll('.block');
+ if (lastBlock.length === 0) return 0;
+ const lastBlockRect = lastBlock[lastBlock.length - 1].getBoundingClientRect();
+ return lastBlockRect.right + cameraX;
+ }
+
+
+ function cameraMoving() {
+ cameraX += cameraSpeed;
+
+ game.style.transform = `translateX(${-cameraX}px)`;
+ }
+
+ function generateBlocks() {
+ const lastBlockX = getLastBlockX();
+ const spawnThreshold = window.innerWidth * 1.2;
+
+ if (cameraX + spawnThreshold > lastBlockX) {
+ const block = document.createElement('div');
+ block.className = 'block';
+ block.style.width = `${Math.random() * 50 + 50}px`;
+ block.style.height = `${Math.random() * 200 + 20}px`;
+ const blockHolder = document.createElement('div');
+ blockHolder.className = 'blockHolder';
+
+ // Add a coin with a certain probability (e.g., 40%)
+ if (Math.random() < 0.4) {
+ const Coin = document.createElement('div');
+ Coin.className = `coin`;
+ blockHolder.appendChild(Coin);
+ }
+
+ if (Math.random() < 0.1 && NoOfCloudCoins< 10) {
+ const CloudCoin = document.createElement('div');
+ CloudCoin.className = 'CloudCoin';
+ CloudCoin.style.top = `${Math.random() * 200 + 50}px`;
+ CloudCoin.style.left = `${Math.random() * 100}%`;
+ NoOfCloudCoins++;
+ document.body.appendChild(CloudCoin);
+ }
+
+ blockHolder.appendChild(block);
+ game.appendChild(blockHolder);
+ blocks = document.querySelectorAll('.block');
+ }
+ }
+
+ // function deleteBlocks() {
+ // blocks.forEach((block) => {
+ // const rect = block.getBoundingClientRect();
+ // if (rect.right < 0 || rect.left > window.innerWidth) {
+ // block.remove();
+ // }
+ // });
+ // }
+
+ function gameLoop(){
+ cameraMoving();
+ moving();
+ generateBlocks();
+ // deleteBlocks();
+ requestAnimationFrame(gameLoop);
+ }
+
+ if (startButton) {
+ startButton.addEventListener('click', () => {
+ startButton.blur();
+ if(startButton.innerText!="Reset"){
+ console.log('Button clicked!');
+ startButton.innerText="Reset";
+ if (analyser) {
+ detectLoudness();
+ }
+ gameLoop();
+ }
+ if (startButton.innerText === "Reset") {
+ Player.style.left = '60px';
+ Player.style.top = '300px';
+ cameraX = 0;
+ game.style.transform = 'translateX(0px)';
+ x = 60;
+ y = 300;
+ xSpeed = 0;
+ ySpeed = 0;
+ isOnGround = 0;
+ coinCollected = 0;
+ score = 0;
+ document.getElementById('score').textContent = `Score: ${score}`;
+ doubleJumpUsed = false;
+ }
+ });
+ } else {
+ console.error('Start button not found!');
+ }
+});
\ No newline at end of file
diff --git a/Bhavy/GAME/style.css b/Bhavy/GAME/style.css
new file mode 100644
index 0000000..f84b743
--- /dev/null
+++ b/Bhavy/GAME/style.css
@@ -0,0 +1,233 @@
+body {
+ font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
+ margin: 0;
+ padding: 0;
+}
+
+html {
+ font-size: 1.6rem;
+}
+
+.startingText {
+ height: 100%;
+ background: rgba(255,255,255,0.8);
+ border-radius: 20px;
+ box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
+ margin: 40px auto;
+ max-width: 400px;
+ padding: 1rem;
+ height: 12rem;
+ display: flex;
+ z-index: 2;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+}
+
+.startingText h1 {
+ font-size: 2.2rem;
+ color: #e63946;
+ margin-bottom: 10px;
+ text-shadow: 2px 2px 0 #fff, 4px 4px 0 #000;
+}
+
+#startButton {
+ font-family: inherit;
+ font-size: 1.1rem;
+ padding: 12px 32px;
+ background: #43aa8b;
+ color: #fff;
+ border: none;
+ border-radius: 8px;
+ z-index: 1;
+ box-shadow: 0 4px #2d6a4f;
+ cursor: pointer;
+ transition: transform 0.1s;
+}
+
+#startButton:hover {
+ transform: translateY(-2px);
+}
+
+#startButton:active {
+ transform: translateY(2px);
+ box-shadow: 0 2px #2d6a4f;
+}
+
+.game {
+ display: flex;
+ background:linear-gradient(to bottom, #ffe602 0%, #f0e68c 100%);;
+ justify-content: space-around;
+ align-items: flex-end;
+ position: fixed;
+ bottom: 40px;
+ left: 0;
+ height: 100rem;
+ gap: 40px;
+ margin: 0;
+ z-index: -1;
+}
+
+.block {
+ background: #f9c74f;
+ border: 4px solid #f9844a;
+ border-radius: 8px 8px 0 0;
+ box-shadow: 0 4px #f3722c, 0 0 0 4px #fff inset;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-direction: column;
+ font-size: 0.85rem;
+ flex-shrink: 0;
+ font-weight: 700;;
+ color: #f47e00;
+ margin: 0 2px;
+ transition: transform 0.1s;
+}
+
+.blockHolder {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ gap:0.6rem;
+ align-items: center;
+}
+
+#block1 { width: 110px; height: 40px; }
+#block2 { width: 180px; height: 50px; }
+#block3 { width: 100px; height: 100px; }
+#block4 { width: 80px; height: 45px; }
+#block5 { width: 90px; height: 55px; }
+#block6 { width: 175px; height: 50px; }
+#block7 { width: 75px; height: 40px; }
+#block8 { width: 100px; height: 100px; }
+#block9 { width: 85px; height: 48px; }
+#block10 { width: 120px; height: 60px; }
+
+.block:active {
+ transform: scale(0.97);
+ box-shadow: 0 2px #f3722c;
+}
+
+.water {
+ position: fixed;
+ left: 0;
+ bottom: 0;
+ width: 100%;
+ height: 2rem;
+ background-color: #6a2d2d;
+ z-index: 4;
+}
+
+.cloud-block {
+ background: linear-gradient(135deg, #e0f7fa 60%, #b2ebf2 100%);
+ border-radius: 30px 30px 40px 40px;
+ box-shadow: 0 4px 12px 0 rgba(0,0,0,0.08), 0 0 0 2px #b2ebf2 inset;
+ border: 2px solid #b2ebf2;
+ opacity: 0.92;
+ position: absolute;
+ z-index: 1;
+ display: block;
+}
+
+.cloud-block.positioned {
+ z-index: 3;
+}
+
+.coin {
+ width: 12px;
+ height: 12px;
+ background: radial-gradient(circle at 30% 30%, #f8f9fa 70%, #e0e0e0 100%);
+ border-radius: 50%;
+ border: 2px solid #b0b0b0;
+ box-shadow: 0 1px 4px rgba(0,0,0,0.10), 0 0 0 2px #f5f5f5 inset;
+ position: relative;
+ margin: 10px auto;
+ animation: spin 1.2s linear infinite;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.coin::before {
+ content: "";
+ position: absolute;
+ left: 3px;
+ top: 3px;
+ width: 5px;
+ height: 5px;
+ border-radius: 50%;
+ background: radial-gradient(circle at 40% 40%, #ffffff 60%, #e0e0e0 100%);
+ border: 1px solid #e0e0e0;
+ z-index: 2;
+}
+
+.coin::after {
+ content: "";
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 12px;
+ height: 12px;
+ border-radius: 50%;
+ box-shadow: 0 0 4px 1px #e0e0e0 inset;
+ z-index: 1;
+ pointer-events: none;
+}
+
+@keyframes spin {
+ 0% {
+ transform: rotateY(0deg);
+ }
+ 100% {
+ transform: rotateY(360deg);
+ }
+}
+
+#score {
+ position: fixed;
+ top: 18px;
+ right: 32px;
+ background: rgba(255,255,255,0.85);
+ color: #222;
+ font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
+ font-size: 1.1rem;
+ padding: 10px 22px;
+ border-radius: 12px;
+ box-shadow: 0 2px 8px rgba(0,0,0,0.10);
+ z-index: 100;
+ font-weight: bold;
+ letter-spacing: 1px;
+}
+
+
+#highScore {
+ position: fixed;
+ top: 88px;
+ right: 32px;
+ background: rgba(255,255,255,0.85);
+ color: #222;
+ font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
+ font-size: 1.1rem;
+ padding: 10px 22px;
+ border-radius: 12px;
+ box-shadow: 0 2px 8px rgba(0,0,0,0.10);
+ z-index: 100;
+ font-weight: bold;
+ letter-spacing: 1px;
+}
+
+
+
+.CloudCoin {
+ width: 24px;
+ height: 24px;
+ background: radial-gradient(circle at 30% 30%, #bdd5ec 70%, #e0e0e0 100%);
+ border-radius: 50%;
+ position: fixed;
+ border: 2px solid #b0b0b0;
+ box-shadow: 0 1px 4px rgba(0,0,0,0.10), 0 0 0 2px #f5f5f5 inset;
+ margin: 10px auto;
+ animation: spin 1.2s linear infinite;
+ z-index: 5;
+}
diff --git a/Bhavy/LLM_CHAT/Index.html b/Bhavy/LLM_CHAT/Index.html
new file mode 100644
index 0000000..4bc2c41
--- /dev/null
+++ b/Bhavy/LLM_CHAT/Index.html
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ Document
+
+
+ AI Chat Bot
+ ,
+
+ What can I help you with
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Bhavy/LLM_CHAT/script.js b/Bhavy/LLM_CHAT/script.js
new file mode 100644
index 0000000..dca83fd
--- /dev/null
+++ b/Bhavy/LLM_CHAT/script.js
@@ -0,0 +1,188 @@
+let inputButton = document.querySelector(".sendButton button");
+let inputText=document.querySelector(".inputText input");
+let ChatBox=document.querySelector(".chats");
+let clear = document.querySelector("#clear");
+let localStorageKey = "chatHistory";
+let chatHistory = JSON.parse(localStorage.getItem(localStorageKey) || "[]");
+
+
+function formatMarkdown(text) {
+ text = text.replace(/\n/g, '
');
+
+ text = text.replace(/```(\w*)\n([\s\S]*?)\n```/g,
+ '$2
');
+
+ text = text.replace(/`([^`]+?)`/g, '$1');
+
+ text = text.replace(/\*\*(.*?)\*\*/g, '$1');
+
+ text = text.replace(/(\*|_)(.*?)\1/g, '$2');
+
+ text = text.replace(/^### (.*$)/gm, '$1
');
+ text = text.replace(/^## (.*$)/gm, '$1
');
+ text = text.replace(/^# (.*$)/gm, '$1
');
+
+ text = text.replace(/^(\d+\.|-)\s(.*$)/gm, '$2');
+ text = text.replace(/^(.*<\/li>)+/gm, '');
+
+ text = text.replace(/^>\s(.*$)/gm, '$1
');
+
+ text = text.replace(/^(\*\*\*|---)$/gm, '
');
+
+ text = text.replace(/(
\s*){2,}/g, '');
+ text = '
' + text + '
';
+
+ return text;
+}
+
+
+if (chatHistory.length > 0) {
+ chatHistory.forEach(chat => {
+ let chatObj = document.createElement("div");
+ chatObj.classList.add("chat", chat.origin === "user" ? "Me" : "AI");
+ chatObj.style.justifyContent = chat.origin === "user" ? "flex-end" : "flex-start";
+ chatObj.innerHTML = chat.text;
+ ChatBox.prepend(chatObj);
+ });
+}
+
+let model; //defult
+class ChatMessage {
+ constructor(origin, text, model) {
+ this.origin = origin;
+ this.text = text;
+ this.model = model;
+ }
+}
+
+// Helper function to stream text
+async function streamText(element, text, delay = 30) {
+ element.innerHTML = "";
+ let i = 0;
+ while (i < text.length) {
+ // Add next character (or word, if you want word-by-word)
+ element.innerHTML += text[i];
+ i++;
+ await new Promise(res => setTimeout(res, delay));
+ }
+}
+
+async function aiFetch(prompt, model, key) {
+ let aichat = new ChatMessage("ai", "", model);
+ let aiResponse = document.createElement("div");
+ aiResponse.classList.add("chat", "AI");
+ aiResponse.style.backgroundColor = "#145f68";
+ aiResponse.innerHTML = "Thinking . .. ...";
+ ChatBox.prepend(aiResponse);
+
+ const response = await fetch('https://openrouter.ai/api/v1/chat/completions', {
+ method: 'POST',
+ headers: {
+ 'Authorization': 'Bearer ' + key,
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ model: model,
+ messages: [
+ {
+ role: 'user',
+ content: prompt,
+ },
+ ],
+ stream: true
+ })
+ });
+
+ if (!response.ok) {
+ aiResponse.innerHTML = "API Error";
+ return;
+ }
+
+ // Streaming logic
+ const reader = response.body.getReader();
+ const decoder = new TextDecoder("utf-8");
+ let buffer = "";
+ let fullMessage = "";
+
+ while (true) {
+ const { value, done } = await reader.read();
+ if (done) break;
+ buffer += decoder.decode(value, { stream: true });
+
+ let lines = buffer.split('\n');
+ buffer = lines.pop();
+
+ for (let line of lines) {
+ line = line.trim();
+ if (line.startsWith("data:")) {
+ let data = line.replace("data:", "").trim();
+ if (data === "[DONE]") continue;
+ try {
+ let parsed = JSON.parse(data);
+ let delta = parsed.choices?.[0]?.delta?.content || "";
+ if (delta) {
+ fullMessage += delta;
+ aiResponse.innerHTML = formatMarkdown(fullMessage);
+ }
+ } catch (e) {
+
+ }
+ }
+ }
+ }
+
+ // Save to history
+ aichat.text = formatMarkdown(fullMessage);
+ chatHistory.push(aichat);
+ localStorage.setItem(localStorageKey, JSON.stringify(chatHistory));
+}
+
+inputButton.addEventListener("click", () => {
+ let apiKey = document.querySelector("#ApiKey").value;
+ if(apiKey === ""){
+ document.querySelector("#ApiKey").setAttribute("placeholder", "Please enter your API key");
+ alert("API KEY NOT FOUND");
+ return;
+ }
+ if(inputText.value === ""){
+ inputText.setAttribute("placeholder", "Please enter a message");
+ return;
+ } else {
+ model = document.querySelector(".modelSelector select").value;
+ let prompt = inputText.value;
+ let newChat = new ChatMessage("user", prompt, model);
+
+ let chatObj = document.createElement("div");
+ chatObj.classList.add("chat","Me");
+ chatObj.style.justifyContent = "flex-end";
+ chatObj.textContent = prompt;
+
+ ChatBox.prepend(chatObj);
+
+ chatHistory.push(newChat);
+ localStorage.setItem(localStorageKey, JSON.stringify(chatHistory));
+
+ //ai work
+
+
+ aiFetch(prompt, model, apiKey);
+ inputText.value="";
+
+
+ }
+});
+
+inputText.addEventListener("keypress", (e) => {
+ if(e.key === "Enter") {
+ inputButton.click();
+ }
+});
+
+
+clear.addEventListener("click", () => {
+ const chatElements = document.querySelectorAll('.chat');
+ chatElements.forEach(element => element.remove());
+ chatHistory = [];
+ localStorage.setItem(localStorageKey, JSON.stringify([]));
+});
+
diff --git a/Bhavy/LLM_CHAT/style.css b/Bhavy/LLM_CHAT/style.css
new file mode 100644
index 0000000..0ccbf6d
--- /dev/null
+++ b/Bhavy/LLM_CHAT/style.css
@@ -0,0 +1,182 @@
+body {
+ font-family: Arial, sans-serif;
+ background-color: #28272a;
+ color: #d6d6d6;
+ margin: 0;
+ padding: 2rem
+}
+html {
+ font-size: 16px;
+}
+
+.Heading {
+ font-size: 5rem;
+ font-weight: bold;
+ top :10%;
+ left: 50%;
+ text-align: center;
+}
+
+pre {
+ background: #f6f8fa;
+ padding: 12px;
+ border-radius: 6px;
+ overflow-x: auto;
+}
+code {
+ font-family: "Courier New", monospace;
+ background: #f6f8fa;
+ padding: 2px 4px;
+ border-radius: 3px;
+}
+blockquote {
+ border-left: 3px solid #ddd;
+ padding-left: 12px;
+ color: #666;
+}
+
+#ApiKey{
+ left:50%;
+ top:25%;
+ height: 2rem;
+ width:50%;
+ border-radius: 1rem;
+ background-color: #645f68;
+ color:#ffffff;
+ &::placeholder {
+ color: #bbbbbb;
+ }
+ position: absolute;
+
+ transform: translate(-50%, -50%);
+}
+.startingText {
+ font-size: 2rem;
+ font-weight: bold;
+ top: 45%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ position: absolute;
+ text-align: center;
+}
+
+.inputBox {
+ width: 70%;
+ height: 2.5rem;
+ padding: 0.625rem;
+ top : 55%;
+ left: 50%;
+ transform: translate(-50%, -50%);
+ position: absolute;
+ font-size: 1rem;
+ border: 0.0625rem solid #8f8d8d;
+ border-radius: 0.3125rem;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.inputText {
+ height: 2rem;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 1rem;
+ border-top-left-radius: 0.3125rem;
+ border-bottom-left-radius: 0.3125rem;
+ flex:auto;
+ box-sizing: border-box;
+ border: 0.0625rem solid #131313;
+ background-color: #474444;
+ color: #ffffff;
+}
+
+.sendButton {
+ width: 10%;
+ height: 2rem;
+ background-color: #48454b;
+ border: 0.125rem solid #ccc;
+ color: white;
+ border: none;
+ border-top-right-radius: 0.3125rem;
+ border-bottom-right-radius: 0.3125rem;
+ cursor: pointer;
+ font-size: 1rem;
+}
+
+.sendButton button:hover {
+ background-color: #7f7b84;
+}
+.sendButton button {
+ width: 100%;
+ height: 2rem;
+ background-color: #48454b;
+ border: 0.125rem solid #ccc;
+ color: white;
+ border: none;
+ border-top-right-radius: 0.3125rem;
+ border-bottom-right-radius: 0.3125rem;
+ cursor: pointer;
+ font-size: 1rem;
+}
+
+#clear{
+ background-color: #645f68;
+ position: absolute;
+ top: 62%;
+ left:84%;
+ transform: translate(-50%,-50%);
+ height: 2rem;
+ border-radius: 0.7rem;
+ border:2px #4b4949 solid;
+
+}
+.chats{
+ border-radius: 0.3125rem;
+ position: absolute;
+ top: 65%;
+ left: 50%;
+ transform: translate(-50%,0%);
+ min-height: 30%;
+ min-width: 80%;
+ background-color: #474444;
+ display: flex;
+ padding: 1rem;
+ flex-direction: column;
+}
+
+.chat {
+ background-color: #7d758465;
+ border-radius: 0.3125rem;
+ min-height: 2rem;
+
+ max-width: 70%;
+ margin: 0.3125rem ;
+ /* display: flex; */
+ padding: 0.2rem;
+ line-height: 1.5rem;
+ padding: 15px;
+
+}
+
+.AI{
+ align-self: flex-start;
+ background-color:#0f454b;
+}
+
+.Me{
+ align-self:flex-end;
+}
+
+.modelSelector {
+ font-size: 0.75rem;
+ height: 2rem;
+ background-color: #645f68;
+ color: #d6d6d6;
+ font-weight: bold;
+}
+
+.modelSelector:hover {
+ background-color: #7f7b84;
+}
+
diff --git a/Bhavy/index.html b/Bhavy/index.html
new file mode 100644
index 0000000..ecf9bc7
--- /dev/null
+++ b/Bhavy/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+ Document
+
+
+ ChatBot
+ Game
+ Snapped
+
+
\ No newline at end of file
diff --git a/Bhavy/read_me b/Bhavy/read_me
new file mode 100644
index 0000000..e69de29
diff --git a/Bhavy/snapped/index.html b/Bhavy/snapped/index.html
new file mode 100644
index 0000000..c44e7cf
--- /dev/null
+++ b/Bhavy/snapped/index.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+ Document
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Bhavy/snapped/script.js b/Bhavy/snapped/script.js
new file mode 100644
index 0000000..9c8af42
--- /dev/null
+++ b/Bhavy/snapped/script.js
@@ -0,0 +1,181 @@
+let dataItems;
+let dataCategories;
+let itemsPerPage = 15;
+let totalPages = 0;
+let pageNo = 1;
+const itemsContainer = document.querySelector('.content');
+
+async function fetchItems() {
+ try {
+ let response = await fetch('http://43.205.110.71:8000/items');
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
+ }
+ dataItems = await response.json();
+
+ let response2 = await fetch('http://43.205.110.71:8000/categories');
+ if (!response.ok) {
+ throw new Error('Network response was not ok');
+ }
+ dataCategories = await response2.json();
+ SetUp();
+ } catch (error) {
+ console.error('Fetch error:', error);
+ }
+}
+
+
+function displayItems(categorySelected = 'all', tagSelected = 'all')
+{
+ let filteredItems = dataItems.filter(item => {
+ if (categorySelected !== 'all' && item.category !== categorySelected) {
+ return false;
+ }
+ if (tagSelected !== 'all' && !item.tags.includes(tagSelected)) {
+ return false;
+ }
+ return true;
+ });
+
+ let page = document.querySelector('.page.selected');
+ if (!page) {
+ let NoOfItems = filteredItems.length;
+ const pagesContainer = document.querySelector('.pages');
+ totalPages = Math.ceil(NoOfItems / itemsPerPage);
+ for (let i = 1; i <= totalPages; i++) {
+ const page = document.createElement('button');
+ page.className = 'page';
+ page.id = i;
+ page.textContent = i;
+ if (i === pageNo) {
+ page.classList.add('selected');
+ }
+ pagesContainer.appendChild(page);
+ }
+ pageNo = 1;
+ let AllPages = document.querySelectorAll('.page');
+ const AddEventToPages = () => {
+ AllPages.forEach((page) => {
+
+ page.addEventListener('click', function() {
+
+ pageNo = this.id;
+ AllPages.forEach((p) => p.classList.remove('selected'));
+ this.classList.add('selected');
+ itemsContainer.innerHTML = '';
+ displayItems(categorySelected, tagSelected);
+ });
+ })
+ }
+ AddEventToPages();
+
+ }else{
+ pageNo = parseInt(page.id);
+ }
+
+ const startIndex = (pageNo - 1) * itemsPerPage;
+ const endIndex = startIndex + itemsPerPage;
+ const paginatedItems = dataItems.slice(startIndex, endIndex);
+ itemsContainer.innerHTML = '';
+
+ paginatedItems.forEach((item) => {
+ const container = document.createElement('div');
+ container.className = 'elements';
+ container.innerHTML = `
+
+ ${item.name}
+ description: ${item.description}
+ price:${item.price}
+ category:${item.category}
+ `;
+ itemsContainer.appendChild(container);
+ });
+}
+
+fetchItems();
+
+
+
+
+
+
+function SetUp() {
+ const tags = document.querySelector("#tags");
+ const uniqueTags = new Set();
+
+
+ dataItems.forEach((item) => {
+ // Populate tags dropdown
+ dataItems.forEach((item) => {
+ item.tags.split('|').forEach(tag => uniqueTags.add(tag));
+ });
+ });
+ uniqueTags.forEach(tag => {
+ tags.innerHTML += ``;
+ });
+
+ // Populate categories dropdown
+
+ const categoriesContainer = document.querySelector('#category');
+
+ dataCategories.forEach((item) => {
+ categoriesContainer.innerHTML += ``;
+ });
+
+
+ let NoOfItems = dataItems.length;
+ const pagesContainer = document.querySelector('.pages');
+ totalPages = Math.ceil(NoOfItems / itemsPerPage);
+ for (let i = 1; i <= totalPages; i++) {
+ const page = document.createElement('button');
+ page.className = 'page';
+ page.id = i;
+ page.textContent = i;
+ if (i === pageNo) {
+ page.classList.add('selected');
+ }
+ pagesContainer.appendChild(page);
+ }
+
+ displayItems();
+
+ let AllPages = document.querySelectorAll('.page');
+ const AddEventToPages = () => {
+ AllPages.forEach((page) => {
+
+ page.addEventListener('click', function() {
+ let tagSelected = tags.value;
+ let categorySelected = categoriesContainer.value;
+ pageNo = this.id;
+ AllPages.forEach((p) => p.classList.remove('selected'));
+ this.classList.add('selected');
+ itemsContainer.innerHTML = '';
+ displayItems(categorySelected, tagSelected);
+ });
+ })
+ }
+ AddEventToPages();
+ tags.addEventListener('change', function() {
+
+ tagSelected = tags.value;
+ categorySelected = categoriesContainer.value;
+ itemsContainer.innerHTML = '';
+ pagesContainer.innerHTML = '';
+ pageNo = 1; // Reset to first page when tag changes
+ AllPages.forEach((p) => p.classList.remove('selected'));
+ displayItems(categorySelected, tagSelected);
+
+ });
+
+
+ categoriesContainer.addEventListener('change', function() {
+ let tagSelected = tags.value;
+ let categorySelected = categoriesContainer.value;
+ itemsContainer.innerHTML = '';
+ pagesContainer.innerHTML = '';
+ pageNo = 1; // Reset to first page when category changes
+ AllPages.forEach((p) => p.classList.remove('selected'));
+ displayItems(categorySelected, tagSelected);
+ });
+}
+
diff --git a/Bhavy/snapped/style.css b/Bhavy/snapped/style.css
new file mode 100644
index 0000000..ec62c67
--- /dev/null
+++ b/Bhavy/snapped/style.css
@@ -0,0 +1,138 @@
+body {
+ background-color: #588157;
+
+}
+
+html {
+ font-size: 16px;
+}
+
+.header {
+ font-size: 2rem;
+ font-weight: bold;
+ display: flex;
+ justify-content: space-between;
+ padding-left:2rem;
+ align-items: center;
+ top: 10%;
+
+ left: 50%;
+ background-color: #a3b18a;
+ text-align: center;
+ color: #344e41;
+ border-radius: 2rem;
+}
+
+.siteName {
+ font-size: 2rem;
+ font-weight: bold;
+ color: #344e41;
+ flex-grow: 0;
+
+}
+.search {
+ display: flex;
+ flex-direction: row;
+ justify-content: flex-end;
+ padding: 2rem;
+ gap: 1rem;
+ width: 50rem;
+ align-items: center;
+ flex-grow: 0;
+ text-align: center;
+ color: #ffffff;
+
+}
+
+
+
+#category {
+ width: 12rem;
+ height: 2.7rem;
+ border-radius: 1rem;
+ background-color: #283618;
+ color: #fefae0;
+
+}
+
+
+
+#tags {
+ width: 12rem;
+ height: 2.7rem;
+ border-radius: 1rem;
+ background-color: #283618;
+ color: #fefae0;
+}
+
+
+.content {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(15rem, 15rem));
+ gap: 2rem;
+ padding-top: 2rem;
+ justify-content: center;
+
+}
+
+.elements {
+ background-color: #dad7cd;
+ border-radius: 1rem;
+ padding: 1rem;
+ box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
+ transition: transform 0.3s ease;
+}
+
+.elements:hover {
+ transform: translateY(-0.5rem);
+}
+
+.image {
+ width: 90%;
+ border-radius: 1rem;
+ object-fit: cover;
+}
+
+.name{
+ font-size: 1.5rem;
+ font-weight: bold;
+ color: #283618;
+ margin-top: 0.5rem;
+}
+
+.description {
+ font-size: 1rem;
+ color: #606c38;
+ margin-top: 0.5rem;
+ overflow: hidden;
+}
+
+.categoryInItem {
+ font-size: 0.9rem;
+ color: #606c38;
+ margin-top: 0.5rem;
+}
+
+
+.pages {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ margin-top: 2rem;
+}
+
+.page {
+ width: 2rem;
+ height: 2rem;
+ border-radius: 50%;
+ background-color: #a3b18a;
+ color: #fff;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ margin: 0 0.5rem;
+ cursor: pointer;
+}
+.page.selected {
+ background-color: #648159;
+}
diff --git a/tempCodeRunnerFile.cpp b/tempCodeRunnerFile.cpp
new file mode 100644
index 0000000..2bff42f
--- /dev/null
+++ b/tempCodeRunnerFile.cpp
@@ -0,0 +1,15 @@
+#include
+using namespace std;
+
+int main(){
+ int n ,k;
+ cin >> n >> k;
+ vector a(n);
+ for(int i = 0; i < n; i++){
+ cin >> a[i];
+ }
+ sort(a.begin(), a.end());
+ cout << a[k-1] << endl;
+ return 0;
+
+}
\ No newline at end of file