ameenmarashi commited on
Commit
a8c92ec
·
verified ·
1 Parent(s): b6c05bd

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +12 -7
index.html CHANGED
@@ -89,8 +89,11 @@
89
  <button onclick="login()">Login</button>
90
  <p id="login-error" style="color: red;"></p>
91
  </div>
92
- </header>
93
- <p id="promptCountDisplay">Prompt used Count: </p>
 
 
 
94
  <h2>Reset Prompts</h2>
95
  </header>
96
 
@@ -136,15 +139,17 @@
136
  document.getElementById("login-error").innerText = error.message;
137
  });
138
  }
139
- // Monitor authentication state and display the prompt count
140
- auth.onAuthStateChanged(async (user) => {
 
141
  if (user) {
142
  const promptCount = await countPromptsUsage(user.uid);
143
- document.getElementById("promptCountDisplay").textContent = `Prompt used Count: ${promptCount}`;
144
  } else {
145
- document.getElementById("promptCountDisplay").textContent = "Please log in to see your prompt count.";
146
  }
147
- });
 
148
  // Function to count the usage of prompts for a specific user
149
  async function countPromptsUsage(userId) {
150
  try {
 
89
  <button onclick="login()">Login</button>
90
  <p id="login-error" style="color: red;"></p>
91
  </div>
92
+ main>
93
+ <h1>Prompt Usage Counter</h1>
94
+ <p id="promptCountDisplay">Prompt used Count: </p>
95
+ <button id="checkPromptCountButton" onclick="showPromptCount()">Check Prompt Count</button>
96
+
97
  <h2>Reset Prompts</h2>
98
  </header>
99
 
 
139
  document.getElementById("login-error").innerText = error.message;
140
  });
141
  }
142
+ // Function to display prompt count on button press
143
+ async function showPromptCount() {
144
+ const user = auth.currentUser;
145
  if (user) {
146
  const promptCount = await countPromptsUsage(user.uid);
147
+ alert(`You have used ${promptCount} prompts.`);
148
  } else {
149
+ alert("Please log in to check your prompt count.");
150
  }
151
+ }
152
+
153
  // Function to count the usage of prompts for a specific user
154
  async function countPromptsUsage(userId) {
155
  try {