i did things
This commit is contained in:
+18
-14
@@ -1,9 +1,10 @@
|
||||
// Initialize Userbase
|
||||
//Userbase
|
||||
userbase.init({ appId: '7cd8e25b-723d-4af7-8bdf-ef558bd0dfcc' }); // Replace with your Userbase app ID
|
||||
|
||||
let currentUser; // Variable to hold the current user object
|
||||
let isDatabaseOpen = false; // Flag to check if the database is open
|
||||
|
||||
|
||||
document.getElementById('signup-form').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const username = document.getElementById('signup-username').value; // Email as username
|
||||
@@ -12,12 +13,14 @@ document.getElementById('signup-form').addEventListener('submit', async (e) => {
|
||||
try {
|
||||
const user = await userbase.signUp({ username: username, password });
|
||||
alert('Signup successful!');
|
||||
await logout(); // Log out the user immediately after signup
|
||||
} catch (error) {
|
||||
console.error('Signup error:', error);
|
||||
alert('Signup failed: ' + error.message);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
document.getElementById('login-form').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const username = document.getElementById('login-username').value; // Email as username
|
||||
@@ -187,7 +190,6 @@ document.getElementById('save-cookies-cloud').addEventListener('click', async ()
|
||||
}
|
||||
});
|
||||
|
||||
// Function to load cookies from the cloud
|
||||
async function loadCookiesFromCloud() {
|
||||
try {
|
||||
// Ensure the database is open
|
||||
@@ -195,11 +197,6 @@ async function loadCookiesFromCloud() {
|
||||
await openUserbaseDatabase();
|
||||
}
|
||||
|
||||
// Clear existing cookies
|
||||
document.cookie.split(";").forEach((cookie) => {
|
||||
document.cookie = cookie.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/");
|
||||
});
|
||||
|
||||
// Fetch cookies from the cloud
|
||||
const items = await userbase.getDatabaseItems({ databaseName: 'notes-database' });
|
||||
let cookiesFromCloud = '';
|
||||
@@ -207,19 +204,26 @@ async function loadCookiesFromCloud() {
|
||||
cookiesFromCloud += item.item.text;
|
||||
});
|
||||
|
||||
// Save cookies to the page
|
||||
document.cookie = `userCookies=${cookiesFromCloud}; path=/`;
|
||||
// Replace the current cookies with the loaded ones
|
||||
document.cookie.split(";").forEach((cookie) => {
|
||||
document.cookie = cookie.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/");
|
||||
});
|
||||
|
||||
// Display the cookies on the page
|
||||
document.getElementById('cookies-display').innerText = cookiesFromCloud;
|
||||
// Alert the user that the cookies have been loaded
|
||||
alert('Cookies loaded from cloud!');
|
||||
const cookies = cookiesFromCloud.split('\n');
|
||||
cookies.forEach(cookie => {
|
||||
document.cookie = cookie.trim();
|
||||
});
|
||||
|
||||
// Display the cookies in the text box
|
||||
document.getElementById('cookies-input').value = cookiesFromCloud;
|
||||
|
||||
// Alert the user that the cookies have been loaded and replaced
|
||||
alert('Cookies loaded from cloud and replaced!');
|
||||
} catch (error) {
|
||||
console.error('Error loading cookies from cloud:', error);
|
||||
alert('Failed to load cookies from cloud: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Add event listener to the "Load Cookies from Cloud" button
|
||||
document.getElementById('load-cookies-cloud').addEventListener('click', loadCookiesFromCloud);
|
||||
|
||||
+8
-1
@@ -25,9 +25,16 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="note-management" style="display: none;">
|
||||
<h2>cookies-save</h2>
|
||||
<h2>Note Management</h2>
|
||||
<input type="text" id="note-input" placeholder="Write your note here..." />
|
||||
<button id="save-note">Save Note</button>
|
||||
<button id="logout-button">Logout</button>
|
||||
<ul id="notes-list" style="margin-top: 20px;"></ul>
|
||||
<div id="cookies-container">
|
||||
<h2>Cookies</h2>
|
||||
<p id="cookies-display"></p>
|
||||
<textarea id="cookies-input" placeholder="Edit your cookies here..."></textarea>
|
||||
<button id="save-cookies">Save Cookies</button>
|
||||
<button id="save-cookies-cloud">Save Cookies to Cloud</button>
|
||||
<button id="load-cookies-cloud">Load Cookies from Cloud</button>
|
||||
</div>
|
||||
+2
-2
@@ -67,7 +67,7 @@ const mainContentData = [
|
||||
{
|
||||
name: "Credits",
|
||||
image: "images1.png",
|
||||
link: "/credits.html",
|
||||
link: "/pass.html",
|
||||
},
|
||||
{
|
||||
name: "Games That Are Comeing Soon",
|
||||
@@ -87,7 +87,7 @@ const mainContentData = [
|
||||
{
|
||||
name: "save to cloud",
|
||||
image: "/WebGames-master/WebGames-master/assets/save-to-cloud-2.png",
|
||||
link: "/WebGames-master/WebGames-master/userlogins-for-fun-miles-main/index.html",
|
||||
link: "/WebGames-master/WebGames-master/userlogins-for-fun-miles-main (2).zip_unzipped/userlogins-for-fun-miles-main/index.html",
|
||||
},
|
||||
];
|
||||
mainContentData.forEach(item => {
|
||||
|
||||
Reference in New Issue
Block a user