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