Skip to content

Commit 5dde3ce

Browse files
committed
Merge develop into main
2 parents e73a2bf + 6a03baa commit 5dde3ce

File tree

4 files changed

+48
-80
lines changed

4 files changed

+48
-80
lines changed

git_gui_state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"repo_url": "https://github.com/Unity-Lab-AI/Unity-Lab-AI.github.io.git", "repo_name": "unity.unityailab.com", "feature_branch": "feature/UnityWebApp5a"}
1+
{"repo_url": "https://github.com/Unity-Lab-AI/Unity-Lab-AI.github.io.git", "repo_name": "unity.unityailab.com", "feature_branch": "feature/UnitywabApp5b"}

index.html

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,7 @@
911911
<select class="model-select" title="Select AI Model">
912912
<!-- existing options remain the same -->
913913
</select>
914-
<div id="visitor-counter" class="visitor-counter">
915-
<span class="visitor-icon">👥</span>
916-
<span class="visitor-count">0</span>
917-
</div>
914+
<div class="visitor-counter">Visitors: <span id="visitor-count">Loading...</span></div>
918915
</div>
919916
</div>
920917
</div>
@@ -931,10 +928,53 @@
931928

932929

933930
<script src="js/nav-loader.js"></script>
934-
<script src="visitorTracker.js"></script>
931+
<script>
932+
// Visitor Tracker Logic with File System Access API
933+
async function visitorTracker() {
934+
const fileName = "visitorCount.txt";
935+
const visitorCountElement = document.getElementById("visitor-count");
936+
let visitorCount = 0;
935937

938+
try {
939+
// Request permission to access a file
940+
const fileHandle = await window.showSaveFilePicker({
941+
suggestedName: fileName,
942+
types: [
943+
{
944+
description: "Text Files",
945+
accept: {
946+
"text/plain": [".txt"],
947+
},
948+
},
949+
],
950+
});
951+
952+
// Try to read the file if it exists
953+
const file = await fileHandle.getFile();
954+
const text = await file.text();
955+
visitorCount = parseInt(text, 10) || 0;
956+
957+
// Increment visitor count
958+
visitorCount += 1;
959+
960+
// Save the updated count back to the file
961+
const writable = await fileHandle.createWritable();
962+
await writable.write(visitorCount.toString());
963+
await writable.close();
964+
965+
// Update the visitor count display
966+
visitorCountElement.textContent = visitorCount;
967+
} catch (error) {
968+
console.error("Error handling visitor count:", error);
969+
visitorCountElement.textContent = "Error!";
970+
}
971+
}
972+
973+
// Initialize the visitor tracker on page load
974+
document.addEventListener("DOMContentLoaded", () => {
975+
visitorTracker();
976+
});
936977

937-
<script>
938978
const DEFAULT_INSTRUCTION = "All code must be wrapped in [CODE]...[/CODE] tags." +
939979
"When using images, show them using format: https://image.pollinations.ai/prompt/your%20image-prompt-with-visual-style%20here?width=512&height=512&nologo=true&private=true&seed={random}&enhance=false&model=Unity plus your response.\n\n" +
940980
"Code format: [CODE]code here[/CODE] with your response.\n\n" +

visitorCount.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

visitorTracker.js

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)