tingle / index.html
Ruboru00's picture
one from gender to be selected, one from age group to be selected and button with "Start Chatting" should help in redirecting to video chat using websocket insteadof random stimulate response - Follow Up Deployment
c3790e5 verified
Raw History Blame Contribute Delete
38.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Tingle - Anonymous video chat with strangers. Meet new people from around the world instantly through random video calls.">
<meta name="keywords" content="video chat, random chat, meet new people, anonymous chat, omegle alternative">
<title>Tingle - Anonymous Video Chat</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
--primary: #ff6b9d;
--secondary: #ff8fab;
--accent: #ffb3c6;
--dark: #2b2d42;
--light: #f8f9fa;
--success: #4cc9f0;
--warning: #f8961e;
--danger: #ef233c;
}
body {
background: linear-gradient(135deg, var(--primary), var(--secondary));
color: white;
font-family: 'Poppins', sans-serif;
}
.video-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
border-radius: 16px;
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.video-container video {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 16px;
}
.blur-effect {
filter: blur(12px);
-webkit-filter: blur(12px);
}
.typing-indicator::after {
content: '...';
animation: typing 1.5s infinite;
display: inline-block;
width: 0;
}
@keyframes typing {
0% { content: '.'; }
33% { content: '..'; }
66% { content: '...'; }
}
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.heart-pulse {
animation: pulse 1.5s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
.selection-card {
background: rgba(255,255,255,0.1);
backdrop-filter: blur(10px);
border: 1px solid rgba(255,255,255,0.2);
transition: all 0.3s ease;
}
.selection-card:hover {
transform: translateY(-5px);
box-shadow: 0 15px 30px rgba(0,0,0,0.3);
}
.selection-card.active {
background: var(--accent);
border-color: white;
}
</style>
</head>
<body class="bg-gray-900 text-white min-h-screen">
<!-- Navigation -->
<nav class="bg-white bg-opacity-10 py-4 px-6 shadow-lg backdrop-blur-md">
<div class="container mx-auto flex justify-between items-center">
<div class="flex items-center space-x-2">
<i class="fas fa-heart text-2xl text-white"></i>
<h1 class="text-xl font-bold">HeartChat</h1>
</div>
<div class="hidden md:flex space-x-6">
<a href="#" class="hover:text-purple-400">Home</a>
<a href="#" class="hover:text-purple-400">About</a>
<a href="#" class="hover:text-purple-400">Safety</a>
<a href="#" class="hover:text-purple-400">FAQ</a>
</div>
<div class="flex items-center space-x-4">
<button id="theme-toggle" class="p-2 rounded-full hover:bg-gray-700">
<i class="fas fa-moon"></i>
</button>
<button class="md:hidden" id="mobile-menu-button">
<i class="fas fa-bars text-xl"></i>
</button>
</div>
</div>
<!-- Mobile menu -->
<div id="mobile-menu" class="hidden md:hidden bg-gray-800 py-2 px-6">
<a href="#" class="block py-2 hover:text-purple-400">Home</a>
<a href="#" class="block py-2 hover:text-purple-400">About</a>
<a href="#" class="block py-2 hover:text-purple-400">Safety</a>
<a href="#" class="block py-2 hover:text-purple-400">FAQ</a>
</div>
</nav>
<!-- Preferences Modal -->
<div id="preferences-modal" class="fixed inset-0 bg-black bg-opacity-90 flex items-center justify-center z-50">
<div class="bg-white bg-opacity-10 rounded-2xl p-8 max-w-2xl w-full backdrop-blur-lg border border-white border-opacity-20">
<h2 class="text-3xl font-bold mb-6 text-center">Let's get started! 💖</h2>
<div class="mb-8">
<h3 class="text-xl font-semibold mb-4">I am looking for:</h3>
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
<div class="selection-card rounded-xl p-4 text-center cursor-pointer focus:ring-2 focus:ring-white focus:outline-none" tabindex="0" data-gender="male">
<i class="fas fa-mars text-3xl mb-2"></i>
<p>Male</p>
</div>
<div class="selection-card rounded-xl p-4 text-center cursor-pointer focus:ring-2 focus:ring-white focus:outline-none" tabindex="0" data-gender="female">
<i class="fas fa-venus text-3xl mb-2"></i>
<p>Female</p>
</div>
<div class="selection-card rounded-xl p-4 text-center cursor-pointer focus:ring-2 focus:ring-white focus:outline-none" tabindex="0" data-gender="non-binary">
<i class="fas fa-transgender text-3xl mb-2"></i>
<p>Non-binary</p>
</div>
<div class="selection-card rounded-xl p-4 text-center cursor-pointer focus:ring-2 focus:ring-white focus:outline-none" tabindex="0" data-gender="any">
<i class="fas fa-venus-mars text-3xl mb-2"></i>
<p>Anyone</p>
</div>
</div>
</div>
<div class="mb-8">
<h3 class="text-xl font-semibold mb-4">Age group:</h3>
<div class="grid grid-cols-2 md:grid-cols-3 gap-4">
<div class="selection-card rounded-xl p-4 text-center cursor-pointer focus:ring-2 focus:ring-white focus:outline-none" tabindex="0" data-age="18-24">
<p class="text-2xl font-bold">18-24</p>
</div>
<div class="selection-card rounded-xl p-4 text-center cursor-pointer focus:ring-2 focus:ring-white focus:outline-none" tabindex="0" data-age="25-34">
<p class="text-2xl font-bold">25-34</p>
</div>
<div class="selection-card rounded-xl p-4 text-center cursor-pointer focus:ring-2 focus:ring-white focus:outline-none" tabindex="0" data-age="35+">
<p class="text-2xl font-bold">35+</p>
</div>
</div>
</div>
<button id="start-chatting" tabindex="0" class="w-full bg-white text-pink-600 py-3 rounded-full font-bold text-lg hover:bg-pink-100 focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-pink-600 transition-all heart-pulse disabled:opacity-50 disabled:cursor-not-allowed" disabled>
Start Chatting! <i class="fas fa-heart ml-2"></i>
</button>
</div>
</div>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8 hidden">
<!-- Connection Status -->
<div id="status-container" class="bg-gray-800 rounded-lg p-4 mb-6 text-center">
<div id="status-message" class="text-lg font-semibold">Ready to connect with someone new!</div>
<div id="status-details" class="text-sm text-gray-400 mt-1">Click "Start" to begin your anonymous video chat</div>
</div>
<!-- Video Chat Area -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
<!-- Local Video -->
<div class="bg-gray-800 rounded-lg overflow-hidden shadow-lg">
<div class="bg-gray-900 p-2 flex justify-between items-center">
<span class="font-medium">You</span>
<div class="flex space-x-2">
<button id="mute-audio" class="p-2 rounded-full bg-gray-700 hover:bg-gray-600">
<i class="fas fa-microphone"></i>
</button>
<button id="mute-video" class="p-2 rounded-full bg-gray-700 hover:bg-gray-600">
<i class="fas fa-video"></i>
</button>
</div>
</div>
<div class="video-container">
<video id="local-video" autoplay muted class="bg-gray-700"></video>
</div>
</div>
<!-- Remote Video -->
<div class="bg-gray-800 rounded-lg overflow-hidden shadow-lg">
<div class="bg-gray-900 p-2 flex justify-between items-center">
<span class="font-medium">Stranger</span>
<div class="flex space-x-2">
<button id="report-user" class="p-2 rounded-full bg-red-600 hover:bg-red-500 text-xs">
<i class="fas fa-flag mr-1"></i> Report
</button>
</div>
</div>
<div class="video-container">
<video id="remote-video" autoplay class="bg-gray-700 blur-effect"></video>
<div id="waiting-screen" class="absolute inset-0 flex flex-col items-center justify-center bg-gray-900 bg-opacity-90">
<div class="animate-spin rounded-full h-16 w-16 border-t-2 border-b-2 border-purple-500 mb-4"></div>
<p class="text-lg">Looking for someone to chat with...</p>
<p class="text-sm text-gray-400 mt-2">This usually takes less than 10 seconds</p>
</div>
</div>
</div>
</div>
<!-- Controls -->
<div class="bg-gray-800 rounded-lg p-4 mb-6">
<div class="flex flex-wrap justify-center gap-4">
<button id="start-btn" class="bg-purple-600 hover:bg-purple-700 px-6 py-3 rounded-full font-bold flex items-center">
<i class="fas fa-play mr-2"></i> Start
</button>
<button id="stop-btn" class="bg-gray-700 hover:bg-gray-600 px-6 py-3 rounded-full font-bold flex items-center hidden">
<i class="fas fa-stop mr-2"></i> Stop
</button>
<button id="next-btn" class="bg-blue-600 hover:bg-blue-700 px-6 py-3 rounded-full font-bold flex items-center hidden">
<i class="fas fa-random mr-2"></i> Next
</button>
<div class="flex items-center space-x-2">
<label class="inline-flex items-center">
<input type="checkbox" id="video-toggle" class="form-checkbox h-5 w-5 text-purple-600" checked>
<span class="ml-2">Video</span>
</label>
<label class="inline-flex items-center">
<input type="checkbox" id="audio-toggle" class="form-checkbox h-5 w-5 text-purple-600" checked>
<span class="ml-2">Audio</span>
</label>
</div>
</div>
</div>
<!-- Chat Section -->
<div class="bg-gray-800 rounded-lg overflow-hidden shadow-lg mb-6 hidden" id="chat-container">
<div class="bg-gray-900 p-3 flex justify-between items-center">
<span class="font-medium">Chat</span>
<button id="toggle-chat" class="p-1 rounded-full hover:bg-gray-700">
<i class="fas fa-chevron-down"></i>
</button>
</div>
<div id="chat-messages" class="h-64 overflow-y-auto p-4 space-y-3">
<!-- Messages will appear here -->
</div>
<div class="p-3 border-t border-gray-700 flex">
<input type="text" id="chat-input" placeholder="Type a message..."
class="flex-grow bg-gray-700 rounded-l-full py-2 px-4 focus:outline-none focus:ring-2 focus:ring-purple-500">
<button id="send-btn" class="bg-purple-600 hover:bg-purple-700 px-4 rounded-r-full">
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>
<!-- Interests Filter -->
<div class="bg-gray-800 rounded-lg p-4 mb-6 hidden" id="interests-container">
<h3 class="text-lg font-semibold mb-3">Match with people who share your interests</h3>
<div class="flex flex-wrap gap-2">
<button class="interest-btn px-3 py-1 rounded-full bg-gray-700 hover:bg-purple-600">Music</button>
<button class="interest-btn px-3 py-1 rounded-full bg-gray-700 hover:bg-purple-600">Gaming</button>
<button class="interest-btn px-3 py-1 rounded-full bg-gray-700 hover:bg-purple-600">Sports</button>
<button class="interest-btn px-3 py-1 rounded-full bg-gray-700 hover:bg-purple-600">Movies</button>
<button class="interest-btn px-3 py-1 rounded-full bg-gray-700 hover:bg-purple-600">Technology</button>
<button class="interest-btn px-3 py-1 rounded-full bg-gray-700 hover:bg-purple-600">Travel</button>
<button class="interest-btn px-3 py-1 rounded-full bg-gray-700 hover:bg-purple-600">Art</button>
<button class="interest-btn px-3 py-1 rounded-full bg-gray-700 hover:bg-purple-600">Fitness</button>
</div>
</div>
<!-- Moderation Report Modal -->
<div id="report-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-gray-800 rounded-lg p-6 max-w-md w-full">
<h3 class="text-xl font-bold mb-4">Report User</h3>
<p class="mb-4">Please select the reason for reporting this user:</p>
<div class="space-y-2 mb-4">
<label class="flex items-center">
<input type="radio" name="report-reason" value="inappropriate" class="mr-2">
<span>Inappropriate behavior</span>
</label>
<label class="flex items-center">
<input type="radio" name="report-reason" value="underage" class="mr-2">
<span>Underage user</span>
</label>
<label class="flex items-center">
<input type="radio" name="report-reason" value="spam" class="mr-2">
<span>Spam or advertising</span>
</label>
<label class="flex items-center">
<input type="radio" name="report-reason" value="other" class="mr-2">
<span>Other</span>
</label>
</div>
<textarea id="report-description" placeholder="Additional details (optional)"
class="w-full bg-gray-700 rounded p-2 mb-4 h-20"></textarea>
<div class="flex justify-end space-x-3">
<button id="cancel-report" class="px-4 py-2 rounded bg-gray-700 hover:bg-gray-600">Cancel</button>
<button id="submit-report" class="px-4 py-2 rounded bg-red-600 hover:bg-red-500">Submit Report</button>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="bg-gray-800 py-6 px-4">
<div class="container mx-auto">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<div class="flex items-center space-x-2">
<i class="fas fa-video text-purple-500 text-xl"></i>
<span class="font-bold">Tingle</span>
</div>
<p class="text-sm text-gray-400 mt-1">Connect with strangers safely and anonymously</p>
</div>
<div class="flex space-x-6">
<a href="#" class="hover:text-purple-400">Terms</a>
<a href="#" class="hover:text-purple-400">Privacy</a>
<a href="#" class="hover:text-purple-400">Safety</a>
<a href="#" class="hover:text-purple-400">Contact</a>
</div>
</div>
<div class="mt-6 text-center text-sm text-gray-400">
<p>© 2023 Tingle. All rights reserved. For users 18+ only.</p>
<p class="mt-1">Use responsibly and respect others.</p>
</div>
</div>
</footer>
<script>
// DOM Elements
const localVideo = document.getElementById('local-video');
const remoteVideo = document.getElementById('remote-video');
const startBtn = document.getElementById('start-btn');
const stopBtn = document.getElementById('stop-btn');
const nextBtn = document.getElementById('next-btn');
const videoToggle = document.getElementById('video-toggle');
const audioToggle = document.getElementById('audio-toggle');
const muteAudioBtn = document.getElementById('mute-audio');
const muteVideoBtn = document.getElementById('mute-video');
const statusMessage = document.getElementById('status-message');
const statusDetails = document.getElementById('status-details');
const waitingScreen = document.getElementById('waiting-screen');
const chatContainer = document.getElementById('chat-container');
const chatMessages = document.getElementById('chat-messages');
const chatInput = document.getElementById('chat-input');
const sendBtn = document.getElementById('send-btn');
const toggleChatBtn = document.getElementById('toggle-chat');
const interestsContainer = document.getElementById('interests-container');
const reportUserBtn = document.getElementById('report-user');
const reportModal = document.getElementById('report-modal');
const cancelReportBtn = document.getElementById('cancel-report');
const submitReportBtn = document.getElementById('submit-report');
const mobileMenuButton = document.getElementById('mobile-menu-button');
const mobileMenu = document.getElementById('mobile-menu');
const themeToggle = document.getElementById('theme-toggle');
// State variables
let localStream;
let peerConnection;
let isConnected = false;
let isVideoOn = true;
let isAudioOn = true;
let chatHistory = [];
let selectedInterests = [];
let socket;
let userPreferences = {
gender: null,
ageGroup: null
};
// Initialize the app
document.addEventListener('DOMContentLoaded', () => {
// Setup preferences selection
function handleSelection(el, selector) {
document.querySelectorAll(selector).forEach(e => e.classList.remove('active'));
el.classList.add('active');
}
document.querySelectorAll('[data-gender]').forEach(el => {
el.addEventListener('click', () => {
handleSelection(el, '[data-gender]');
userPreferences.gender = el.dataset.gender;
updateStartButtonState();
});
el.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
handleSelection(el, '[data-gender]');
userPreferences.gender = el.dataset.gender;
updateStartButtonState();
}
});
});
document.querySelectorAll('[data-age]').forEach(el => {
el.addEventListener('click', () => {
handleSelection(el, '[data-age]');
userPreferences.ageGroup = el.dataset.age;
});
el.addEventListener('keydown', (e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
handleSelection(el, '[data-age]');
userPreferences.ageGroup = el.dataset.age;
}
});
});
// Enable start button only when both selections are made
function updateStartButtonState() {
const startBtn = document.getElementById('start-chatting');
startBtn.disabled = !(userPreferences.gender && userPreferences.ageGroup);
}
document.getElementById('start-chatting').addEventListener('click', async () => {
document.getElementById('preferences-modal').classList.add('hidden');
document.querySelector('main').classList.remove('hidden');
try {
// Request camera and microphone access
const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
localStream = stream;
localVideo.srcObject = stream;
// Initialize WebSocket connection
socket = new WebSocket('wss://your-websocket-server.com');
socket.onopen = () => {
console.log('WebSocket connected');
// Send user preferences to server
socket.send(JSON.stringify({
type: 'preferences',
gender: userPreferences.gender,
ageGroup: userPreferences.ageGroup
}));
startConnection();
};
socket.onmessage = (event) => {
const data = JSON.parse(event.data);
handleServerMessage(data);
};
socket.onerror = (error) => {
console.error('WebSocket error:', error);
statusMessage.textContent = 'Connection error';
statusDetails.textContent = 'Failed to connect to server';
};
socket.onclose = () => {
console.log('WebSocket disconnected');
statusMessage.textContent = 'Disconnected';
statusDetails.textContent = 'Connection to server lost';
};
// Set initial button states
muteAudioBtn.innerHTML = '<i class="fas fa-microphone"></i>';
muteVideoBtn.innerHTML = '<i class="fas fa-video"></i>';
} catch (err) {
console.error('Error accessing media devices:', err);
statusMessage.textContent = 'Error accessing camera/microphone';
statusDetails.textContent = 'Please allow camera and microphone access to use Tingle';
startBtn.disabled = true;
}
});
// Initialize WebSocket connection
socket = new WebSocket('wss://your-websocket-server.com');
socket.addEventListener('open', (event) => {
console.log('Connected to WebSocket server');
});
socket.addEventListener('message', (event) => {
const data = JSON.parse(event.data);
handleServerMessage(data);
});
socket.addEventListener('close', (event) => {
if (event.wasClean) {
console.log(`Connection closed cleanly, code=${event.code}, reason=${event.reason}`);
} else {
console.log('Connection died');
// Attempt to reconnect
setTimeout(connectWebSocket, 5000);
}
});
socket.addEventListener('error', (error) => {
console.log('WebSocket error:', error);
});
// Request camera and microphone access
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(stream => {
localStream = stream;
localVideo.srcObject = stream;
// Set initial button states
muteAudioBtn.innerHTML = '<i class="fas fa-microphone"></i>';
muteVideoBtn.innerHTML = '<i class="fas fa-video"></i>';
})
.catch(err => {
console.error('Error accessing media devices:', err);
statusMessage.textContent = 'Error accessing camera/microphone';
statusDetails.textContent = 'Please allow camera and microphone access to use Tingle';
startBtn.disabled = true;
});
// Event listeners
startBtn.addEventListener('click', startConnection);
stopBtn.addEventListener('click', stopConnection);
nextBtn.addEventListener('click', nextConnection);
videoToggle.addEventListener('change', toggleVideo);
audioToggle.addEventListener('change', toggleAudio);
muteAudioBtn.addEventListener('click', toggleMuteAudio);
muteVideoBtn.addEventListener('click', toggleMuteVideo);
sendBtn.addEventListener('click', sendMessage);
chatInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') sendMessage();
});
toggleChatBtn.addEventListener('click', toggleChat);
reportUserBtn.addEventListener('click', showReportModal);
cancelReportBtn.addEventListener('click', hideReportModal);
submitReportBtn.addEventListener('click', submitReport);
mobileMenuButton.addEventListener('click', toggleMobileMenu);
themeToggle.addEventListener('click', toggleTheme);
// Interest buttons
document.querySelectorAll('.interest-btn').forEach(btn => {
btn.addEventListener('click', () => {
btn.classList.toggle('bg-gray-700');
btn.classList.toggle('bg-purple-600');
const interest = btn.textContent;
if (selectedInterests.includes(interest)) {
selectedInterests = selectedInterests.filter(i => i !== interest);
} else {
selectedInterests.push(interest);
}
});
});
});
// Server message handler
function handleServerMessage(data) {
switch(data.type) {
case 'match_found':
handleMatchFound(data.peer);
break;
case 'offer':
// Handle WebRTC offer
break;
case 'answer':
// Handle WebRTC answer
break;
case 'ice_candidate':
// Handle ICE candidate
break;
case 'message':
addMessage(data.sender, data.message, false);
break;
case 'disconnect':
handleDisconnect(data.reason);
break;
case 'error':
showError(data.message);
break;
default:
console.log('Unknown message type:', data.type);
}
}
// Functions
function startConnection() {
if (socket.readyState !== WebSocket.OPEN) {
statusMessage.textContent = 'Connecting to server...';
statusDetails.textContent = 'Please wait while we establish connection';
return;
}
statusMessage.textContent = 'Finding a match...';
statusDetails.textContent = 'Looking for someone who matches your preferences';
startBtn.classList.add('hidden');
stopBtn.classList.remove('hidden');
waitingScreen.classList.remove('hidden');
remoteVideo.classList.add('blur-effect');
// Hide interests container
interestsContainer.classList.add('hidden');
// Request match from server
socket.send(JSON.stringify({
type: 'find_match',
preferences: userPreferences
}));
}
function handleMatchFound(peer) {
isConnected = true;
statusMessage.textContent = `Connected with ${peer.name || 'a stranger'}!`;
statusDetails.textContent = `Age ${peer.age} • ${peer.location || 'Somewhere magical'}`;
waitingScreen.classList.add('hidden');
remoteVideo.classList.remove('blur-effect');
nextBtn.classList.remove('hidden');
chatContainer.classList.remove('hidden');
// Initialize WebRTC connection with matched peer
initializePeerConnection(peer.id);
}
function initializePeerConnection(peerId) {
// WebRTC initialization logic here
// This would include creating offers/answers, ICE candidates etc.
console.log('Initializing connection with peer:', peerId);
}
function stopConnection() {
// Notify server we're disconnecting
if (socket.readyState === WebSocket.OPEN) {
socket.send(JSON.stringify({
type: 'disconnect'
}));
}
isConnected = false;
statusMessage.textContent = 'Disconnected';
statusDetails.textContent = 'Click "Start" to begin a new chat';
startBtn.classList.remove('hidden');
stopBtn.classList.add('hidden');
nextBtn.classList.add('hidden');
waitingScreen.classList.add('hidden');
chatContainer.classList.add('hidden');
interestsContainer.classList.remove('hidden');
// Clear remote video
if (remoteVideo.srcObject) {
remoteVideo.srcObject.getTracks().forEach(track => track.stop());
remoteVideo.srcObject = null;
}
// Clear chat
chatMessages.innerHTML = '';
chatHistory = [];
}
function nextConnection() {
statusMessage.textContent = 'Finding someone new...';
statusDetails.textContent = 'Please wait while we connect you to another stranger';
waitingScreen.classList.remove('hidden');
remoteVideo.classList.add('blur-effect');
chatMessages.innerHTML = '';
chatHistory = [];
// Simulate connecting to a new peer
setTimeout(() => {
statusMessage.textContent = 'Connected! Say hello!';
statusDetails.textContent = 'You are now chatting with a new stranger';
waitingScreen.classList.add('hidden');
remoteVideo.classList.remove('blur-effect');
// Simulate receiving a message
setTimeout(() => {
addMessage('Stranger', 'Hello! Nice to meet you!', false);
}, 1000);
}, 1500);
}
function toggleVideo() {
isVideoOn = !isVideoOn;
localStream.getVideoTracks().forEach(track => {
track.enabled = isVideoOn;
});
muteVideoBtn.innerHTML = isVideoOn ? '<i class="fas fa-video"></i>' : '<i class="fas fa-video-slash"></i>';
videoToggle.checked = isVideoOn;
}
function toggleAudio() {
isAudioOn = !isAudioOn;
localStream.getAudioTracks().forEach(track => {
track.enabled = isAudioOn;
});
muteAudioBtn.innerHTML = isAudioOn ? '<i class="fas fa-microphone"></i>' : '<i class="fas fa-microphone-slash"></i>';
audioToggle.checked = isAudioOn;
}
function toggleMuteVideo() {
toggleVideo();
}
function toggleMuteAudio() {
toggleAudio();
}
function addMessage(sender, message, isLocal) {
const messageDiv = document.createElement('div');
messageDiv.classList.add('flex', 'fade-in');
if (isLocal) {
messageDiv.classList.add('justify-end');
messageDiv.innerHTML = `
<div class="bg-purple-600 rounded-l-lg rounded-br-lg px-4 py-2 max-w-xs md:max-w-md">
<p>${message}</p>
</div>
`;
} else {
messageDiv.classList.add('justify-start');
messageDiv.innerHTML = `
<div class="bg-gray-700 rounded-r-lg rounded-bl-lg px-4 py-2 max-w-xs md:max-w-md">
<p class="font-semibold text-sm">${sender}</p>
<p>${message}</p>
</div>
`;
}
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
chatHistory.push({ sender, message, isLocal });
}
function sendMessage() {
const message = chatInput.value.trim();
if (message && isConnected) {
addMessage('You', message, true);
chatInput.value = '';
// Simulate response (in a real app, this would be sent via WebRTC data channel)
setTimeout(() => {
const responses = [
"That's interesting! Tell me more.",
"I see. What else do you like to do?",
"Cool! I'm enjoying our chat.",
"Nice weather we're having, isn't it?",
"Do you come here often? Just kidding!",
"I'm learning so much about you!",
"What's your favorite movie?",
"Do you have any pets?",
"What kind of music do you like?"
];
const randomResponse = responses[Math.floor(Math.random() * responses.length)];
addMessage('Stranger', randomResponse, false);
}, 1000 + Math.random() * 2000);
}
}
function toggleChat() {
const isHidden = chatMessages.classList.contains('hidden');
if (isHidden) {
chatMessages.classList.remove('hidden');
toggleChatBtn.innerHTML = '<i class="fas fa-chevron-down"></i>';
} else {
chatMessages.classList.add('hidden');
toggleChatBtn.innerHTML = '<i class="fas fa-chevron-up"></i>';
}
}
function showReportModal() {
reportModal.classList.remove('hidden');
}
function hideReportModal() {
reportModal.classList.add('hidden');
}
function submitReport() {
const reason = document.querySelector('input[name="report-reason"]:checked')?.value;
const description = document.getElementById('report-description').value;
if (!reason) {
alert('Please select a reason for reporting');
return;
}
// In a real app, this would send the report to your backend
console.log('Report submitted:', { reason, description });
// Show confirmation and disconnect
statusMessage.textContent = 'User reported. Disconnecting...';
statusDetails.textContent = 'Thank you for helping keep Tingle safe';
hideReportModal();
setTimeout(() => {
stopConnection();
}, 1500);
}
function toggleMobileMenu() {
mobileMenu.classList.toggle('hidden');
}
function toggleTheme() {
document.documentElement.classList.toggle('dark');
const isDark = document.documentElement.classList.contains('dark');
themeToggle.innerHTML = isDark ? '<i class="fas fa-sun"></i>' : '<i class="fas fa-moon"></i>';
}
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://deepsite.hf.co/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://deepsite.hf.co" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://deepsite.hf.co?remix=Ruboru00/tingle" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>