-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindexOLD.html
More file actions
393 lines (349 loc) · 14.6 KB
/
indexOLD.html
File metadata and controls
393 lines (349 loc) · 14.6 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EFRO Story Catalog</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}
.navbar {
background-color: #007BFF;
color: #fff;
padding: 10px 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
.navbar h1 {
margin: 0;
}
.navbar a {
color: #fff;
text-decoration: none;
margin-left: 20px;
}
.navbar a:hover {
text-decoration: underline;
}
.catalog {
max-width: 800px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.story {
border-bottom: 1px solid #ddd;
padding: 10px 0;
}
.story:last-child {
border-bottom: none;
}
.story h2 {
margin: 0 0 10px;
font-size: 24px;
}
.story p {
margin: 0 0 10px;
}
.story a {
color: #007BFF;
text-decoration: none;
}
.story a:hover {
text-decoration: underline;
}
.search-bar {
margin-bottom: 20px;
display: flex;
justify-content: space-between;
align-items: center;
}
.search-bar input[type="text"] {
width: calc(100% - 120px);
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.search-bar button {
padding: 10px 20px;
margin-left: 10px;
border: none;
border-radius: 4px;
background-color: #007BFF;
color: #fff;
cursor: pointer;
}
.search-bar button.active {
background-color: #0056b3;
}
.tags {
margin-bottom: 20px;
}
.tag {
display: inline-block;
background-color: #007BFF;
color: #fff;
padding: 5px 10px;
margin-right: 5px;
border-radius: 3px;
cursor: pointer;
}
.tag.selected {
background-color: #0056b3;
}
.faded {
color: #888; /* Faded text color */
}
.matches-section {
margin-bottom: 20px;
}
.matches-section h3 {
margin: 0 0 10px;
font-size: 20px;
}
</style>
</head>
<body>
<div class="navbar">
<h1>Story Catalog</h1>
<nav>
<a href="/EFROTales/hub.html">Stories</a>
<a href="/hub.html">EFRO.AI</a>
<a href="/EFROTales/editor.html">Editor & Uploading</a>
<a href="https://discord.gg/E7TRzsEMkD">Discord</a>
<a href="/EFROTales/features.html">Upcoming Features</a>
</nav>
</div>
<div class="catalog">
<!-- Search Bar -->
<div class="search-bar">
<input type="text" id="searchInput" placeholder="Search for stories...">
</div>
<!-- Tagging System -->
<div class="tags">
<span class="tag" onclick="toggleTagSelection(this, 'Reader-Insert')">{Reader-Insert}</span>
<span class="tag" onclick="toggleTagSelection(this, 'Skunk')">Skunk</span>
<span class="tag" onclick="toggleTagSelection(this, 'Fart')">Fart</span>
<span class="tag" onclick="toggleTagSelection(this, 'Burp')">Burp</span>
<span class="tag" onclick="toggleTagSelection(this, 'Fantasy')">Fantasy</span>
<span class="tag" onclick="toggleTagSelection(this, 'Romantic Comedy')">Romantic Comedy</span>
<span class="tag" onclick="toggleTagSelection(this, 'Adventure')">Adventure</span>
</div>
<!-- Matches Sections -->
<div class="matches-section" id="exactMatches">
<h3>Exact Matches</h3>
</div>
<div class="matches-section" id="nearMatches">
<h3>Near Matches</h3>
</div>
<div class="matches-section" id="closeMatches">
<h3>Close Matches</h3>
</div>
<div class="matches-section" id="looseMatches">
<h3>Partial Matches</h3>
</div>
<div class="matches-section" id="possibleMatches">
<h3>Could this be what you're looking for?</h3>
</div>
<div class="story" data-tags="{{Reader-Insert}}, [Skunks]">
<h2><a href="/EFROTales/Stories/The Pillory.html">The Pillory</a></h2>
<p><b>Author:</b> SolamenteCelia</p>
<p><i>Topics:</i> {{Reader-Insert}}, Skunk</p>
<p>When a rotten man is locked up in the pillory, a skunk he'd wronged takes the opportunity to get her revenge on him.</p>
</div>
<!-- Story List -->
<div class="story" data-tags="{{Reader-Insert}}, [Skunks], [Farts], [Burps]">
<h2><a href="/EFROTales/Stories/Skunked by a Dare - An Unexpected Romance.html">Skunked by a Dare: An Unexpected Romance</a></h2>
<p><b>Author:</b> TigerT2173</p>
<p><i>Topics:</i> {{Reader-Insert}}, [Skunks], [Farts], [Burps]</p>
<p>During a game of Truth or Dare, homeless skunk girl, Aimee is dared to ask you out!</p>
</div>
<div class="story" data-tags="Fantasy">
<h2><a href="story1.html">The Skunk Hybrid's Dilemma</a></h2>
<p><i>Genre:</i> Fantasy</p>
<p>A tale of a skunk hybrid girl navigating a world where she's seen as an outcast due to her unique abilities and challenges.</p>
</div>
<div class="story" data-tags="Romantic Comedy">
<h2><a href="story2.html">Midnight at MicroCenter</a></h2>
<p><i>Genre:</i> Romantic Comedy</p>
<p>A quirky romance unfolds when two socially awkward individuals meet at a computer store after hours.</p>
</div>
<div class="story" data-tags="Adventure">
<h2><a href="story3.html">The Quest for the Perfect PC</a></h2>
<p><i>Genre:</i> Adventure</p>
<p>Follow a group of friends as they embark on an epic journey to build the ultimate gaming PC, facing unexpected challenges along the way.</p>
</div>
<!-- Add more stories as needed -->
</div>
<script>
let selectedTags = new Set();
let searchInTitle = false; // Default to searching all content
document.getElementById('searchInput').addEventListener('keyup', function() {
const input = this.value.toLowerCase();
filterStories(input, selectedTags);
});
function toggleTagSelection(tagElement, tag) {
if (selectedTags.has(tag)) {
selectedTags.delete(tag);
tagElement.classList.remove('selected');
} else {
selectedTags.add(tag);
tagElement.classList.add('selected');
}
filterStories(document.getElementById('searchInput').value.toLowerCase(), selectedTags);
}
function filterStories(input, tags) {
const stories = document.getElementsByClassName('story');
const storiesArray = Array.from(stories);
const exactMatches = [];
const nearMatches = [];
const closeMatches = [];
const looseMatches = [];
const possibleMatches = [];
let anyStoryVisible = true;
// Normalize input
const normalizedInput = input.toLowerCase().trim();
// Create a regular expression for the input, ignoring case
const regex = new RegExp(normalizedInput.split(' ').map(word => `(?=.*${word})`).join(''), 'i');
storiesArray.forEach(story => {
const title = story.querySelector('h2').innerText.toLowerCase();
const content = story.innerText.toLowerCase();
const storyTags = story.getAttribute('data-tags').split(', ').map(tag => tag.toLowerCase());
// Normalize tags for matching
const normalizedTags = storyTags.map(tag => tag.trim());
//For percent Revelvance
const numberOfSelectedTags = tags.size;
let matchCount = 0;
tags.forEach(tag => {
const normalizedTag = tag.toLowerCase().replace(/s$/, '');
if (normalizedTags.some(storyTag => storyTag.includes(normalizedTag))) {
matchCount++;
}
});
// Check if the normalized input partially matches any tag
const matchesATag = Array.from(tags).some(tag => normalizedTags.some(storyTag => storyTag.includes(tag.toLowerCase())));
//const matchesATags = Array.from(tags).some(tag => storyTags.includes(tag));
const matchesTags = Array.from(tags).every(tag => normalizedTags.some(storyTag => storyTag.includes(tag.toLowerCase())));
//const matchesTags = Array.from(tags).every(tag => storyTags.includes(tag));
const matchesContent = searchInTitle ? regex.test(title) : regex.test(content);
if (matchesATag || matchesTags || matchesContent) {
let score = 0;
let isExactMatch = false;
let isNearMatch = false;
let isCloseMatch = false;
let isPossibleMatch = false;
const percentofselectedtags = (matchCount/numberOfSelectedTags)*100;
// Check for exact matches
// Slider functionality
if (searchInTitle && title.includes(input) && matchesTags) {
score = 2; // Full match on title
isExactMatch = true;
} else if (!searchInTitle && content.includes(input) && matchesTags) {
score = 2; // Full match on content
isExactMatch = true;
} else if (searchInTitle && title.includes(input) && percentofselectedtags > 90) {
score = 2; // Full match on title
isExactMatch = true;
} else if (!searchInTitle && content.includes(input) && percentofselectedtags > 90) {
score = 2; // Full match on content
isExactMatch = true;
} else if (searchInTitle && title.includes(input) && percentofselectedtags > 60) {
score = 2; // Full match on title
isNearMatch = true;
} else if (!searchInTitle && content.includes(input) && percentofselectedtags > 60) {
score = 2; // Full match on content
isNearMatch = true;
} else if (searchInTitle && title.includes(input) && percentofselectedtags > 30) {
score = 2; // Full match on title
isCloseMatch = true;
} else if (!searchInTitle && content.includes(input) && percentofselectedtags > 30) {
score = 2; // Full match on content
isCloseMatch = true;
} else if (searchInTitle && title.includes(input) && percentofselectedtags > 1) {
score = 1; // Partial match on title
isPossibleMatch = true;
} else if (!searchInTitle && content.includes(input) && percentofselectedtags > 1) {
score = content.startsWith(input) ? 2 : 1; // Full or partial match on content
isPossibleMatch = true;
}
if (isExactMatch) {
exactMatches.push(story);
} else if (isNearMatch) {
nearMatches.push(story);
} else if (isCloseMatch) {
closeMatches.push(story);
} else if (isPossibleMatch) {
looseMatches.push(story);
} else if (matchesContent) {
possibleMatches.push(story);
}
anyStoryVisible = true;
}
});
// Clear previous results
//document.getElementById('exactMatches').innerHTML = '<h3>Exact Matches</h3>';
// document.getElementById('closeMatches').innerHTML = '<h3>Close Matches</h3>';
// Display exact matches
exactMatches.forEach(story => {
document.getElementById('exactMatches').appendChild(story);
});
// Display near matches
nearMatches.forEach(story => {
document.getElementById('nearMatches').appendChild(story);
});
// Display close matches
closeMatches.forEach(story => {
document.getElementById('closeMatches').appendChild(story);
});
possibleMatches.forEach(story => {
document.getElementById('possibleMatches').appendChild(story);
});
looseMatches.forEach(story => {
document.getElementById('looseMatches').appendChild(story);
});
// Ensure all stories not in either match section are displayed if no filter is applied
storiesArray.forEach(story => {
if (!exactMatches.includes(story) && !nearMatches.includes(story) && !closeMatches.includes(story) && !possibleMatches.includes(story) && !looseMatches.includes(story)) {
story.style.display = 'none';
} else {
story.style.display = '';
}
});
// If no filters are applied, ensure all stories are visible
if (!anyStoryVisible) {
storiesArray.forEach(story => {
story.style.display = '';
});
}
}
</script>
<script>
const socket = new WebSocket('wss://efroai.net'); // Update with your domain
// Connection opened
socket.addEventListener('open', (event) => {
console.log('Connected to WebSocket server');
});
// Listen for messages
socket.addEventListener('message', (event) => {
console.log('Message from server:', event.data);
// Handle ping or any other messages from the server
if (event.data === 'ping') {
// You can respond to pings if needed
socket.send('pong'); // Example response
}
});
// Connection closed
socket.addEventListener('close', (event) => {
console.log('Disconnected from WebSocket server');
});
</script>
</body>
</html>