-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
72 lines (60 loc) · 2.87 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
type="image/gif">
<title>YackBox with Dual Chatrooms Example</title>
<!-- Include Bootstrap CSS file -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- Include Yackbox Chat CSS file -->
<style>
ul {
list-style-type: none;
}
li {
left: 0;
}
</style>
</head>
<body>
<div class="container">
<h2 class="mb-8">yackbox examples</h2>
<p>The following examples can help in getting started with using yackbox</p>
<div id="examples"></div>
</div>
<script>
let ln = (title, url, desc) => {
return `<div class="md-col-5"><a href="${url}">${title}</a><br>${desc}</div><br>`;
}
function getCurrentPath() {
// Create a new URL object based on the current window location
const url = new URL(window.location.href);
// Get the pathname from the URL
let pathname = url.pathname;
// Check if the pathname includes a file name by looking for a dot followed by a file extension at the end
if (pathname.includes('.')) {
// Remove the file name by truncating the pathname at the last slash
pathname = pathname.substring(0, pathname.lastIndexOf('/') + 1);
}
// Reconstruct the URL without the filename
url.pathname = pathname;
let path = url.toString();
path = path.endsWith("/") ? path : path + "/";
// Return the modified URL as a string
return path;
}
// this hack is so that this works both local host and github pages w/o needing extra libraries
let examples = [
{ title: "Simple Yackbox from local dist", url: "basic-umd/index.html", desc: "Quick example of using yackbox from the CDN with random responses" },
{ title: "Simple Yackbox using ESM/ES6 Module syntax", url: "basic-esm/index.html", desc: "Quick example of using yackbox by importing it as a module" },
{ title: "Ollama Basic JS", url: "ollama-basic-js/simple_ollama.html", desc: "A simple demo of how to user yackbox for both completions or streaming results" },
{ title: "Dual Chatrooms", url: "dual-chatrooms/index.html", desc: "Dual chat rooms on the same screen, each can send messages to each other." }
], content = "";
for (i in examples)
content += ln(examples[i].title, getCurrentPath()+examples[i].url, examples[i].desc);
document.getElementById("examples").innerHTML = content;
</script>
</body>
</html>