forked from HakkanShah/VerifyAI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
150 lines (137 loc) · 5.91 KB
/
Copy pathscript.js
File metadata and controls
150 lines (137 loc) · 5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
document.addEventListener('DOMContentLoaded', () => {
const analyzeTextBtn = document.getElementById('analyze-text-btn');
const analyzeVideoBtn = document.getElementById('analyze-video-btn');
const analyzeImageBtn = document.getElementById('analyze-image-btn');
const textInput = document.getElementById('text-input');
const videoUrlInput = document.getElementById('video-url');
const imageInput = document.getElementById('image-input');
const resultOutput = document.getElementById('result-output');
const resultSection = document.getElementById('result-section');
const heroSection = document.getElementById('hero-section');
const tabsSection = document.getElementById('tabs');
const startBtn = document.getElementById('start-btn');
const tabButtons = document.querySelectorAll('.tab-btn');
const tabContents = document.querySelectorAll('.tab-content');
function getRandomConfidence() {
const levels = ['Low', 'Medium', 'High'];
return levels[Math.floor(Math.random() * levels.length)];
}
function getRandomProbability() {
return Math.floor(Math.random() * 101);
}
function analyzeText(text) {
if (!text.trim()) {
return "Please enter some text to analyze.";
}
const probability = getRandomProbability();
const confidence = getRandomConfidence();
return `Analysis Result for Text:\n- Fake News Probability: ${probability}%\n- Confidence: ${confidence}\n\n(Note: Backend integration pending)`;
}
function analyzeVideo(url) {
if (!url.trim()) {
return "Please enter a video URL to analyze.";
}
const probability = getRandomProbability();
const confidence = getRandomConfidence();
return `Analysis Result for Video URL:\n- Deepfake Probability: ${probability}%\n- Confidence: ${confidence}\n\n(Note: Backend integration pending)`;
}
function analyzeImage(file) {
if (!file) {
return "Please select an image file to analyze.";
}
const probability = getRandomProbability();
const confidence = getRandomConfidence();
return `Analysis Result for Image:\n- Deepfake Probability: ${probability}%\n- Confidence: ${confidence}\n\n(Note: Backend integration pending)`;
}
function showLoading() {
resultOutput.textContent = "Analyzing";
let dots = 0;
const interval = setInterval(() => {
dots = (dots + 1) % 4;
resultOutput.textContent = "Analyzing" + ".".repeat(dots);
}, 500);
return interval;
}
function scrollToResult() {
resultSection.scrollIntoView({ behavior: 'smooth' });
}
startBtn.addEventListener('click', () => {
heroSection.style.display = 'none';
tabsSection.style.display = 'block';
});
tabButtons.forEach(button => {
button.addEventListener('click', () => {
const targetTab = button.getAttribute('data-tab');
tabButtons.forEach(btn => btn.classList.remove('active'));
button.classList.add('active');
tabContents.forEach(content => {
if (content.id === targetTab) {
content.classList.add('active');
} else {
content.classList.remove('active');
}
});
// Hide result section on tab switch
resultSection.style.display = 'none';
});
});
analyzeTextBtn.addEventListener('click', () => {
const text = textInput.value;
const spinner = analyzeTextBtn.querySelector('.loading-spinner');
spinner.style.display = 'inline-block';
const loadingInterval = showLoading();
// Hide result section before analysis
resultSection.style.display = 'none';
setTimeout(() => {
clearInterval(loadingInterval);
spinner.style.display = 'none';
const result = analyzeText(text);
resultOutput.innerHTML = addEmojiToResult(result);
resultSection.style.display = 'block';
scrollToResult(); // Scroll after showing result
}, 1500);
});
analyzeVideoBtn.addEventListener('click', () => {
const url = videoUrlInput.value;
const spinner = analyzeVideoBtn.querySelector('.loading-spinner');
spinner.style.display = 'inline-block';
const loadingInterval = showLoading();
scrollToResult();
// Show result section only after analysis
resultSection.style.display = 'none';
setTimeout(() => {
clearInterval(loadingInterval);
spinner.style.display = 'none';
const result = analyzeVideo(url);
resultOutput.innerHTML = addEmojiToResult(result);
resultSection.style.display = 'block';
}, 1500);
});
analyzeImageBtn.addEventListener('click', () => {
const file = imageInput.files[0];
const spinner = analyzeImageBtn.querySelector('.loading-spinner');
spinner.style.display = 'inline-block';
const loadingInterval = showLoading();
scrollToResult();
// Show result section only after analysis
resultSection.style.display = 'none';
setTimeout(() => {
clearInterval(loadingInterval);
spinner.style.display = 'none';
const result = analyzeImage(file);
resultOutput.innerHTML = addEmojiToResult(result);
resultSection.style.display = 'block';
}, 1500);
});
function addEmojiToResult(resultText) {
let emoji = '❓';
if (resultText.includes('High')) {
emoji = '🔥';
} else if (resultText.includes('Medium')) {
emoji = '⚠️';
} else if (resultText.includes('Low')) {
emoji = '✅';
}
return `<span class="result-emoji">${emoji}</span>${resultText.replace(/\n/g, '<br>')}`;
}
});