Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
techcow2 authored Aug 17, 2024
1 parent 11c7b6c commit 98b7d74
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ const loadingTexts = [
"Untangling the world wide web..."
];

function checkRateLimit(action, limit, timeFrame) {
const now = Date.now();
const actionKey = `rateLimit_${action}`;
const storedData = JSON.parse(sessionStorage.getItem(actionKey) || '[]');


const validData = storedData.filter(timestamp => now - timestamp < timeFrame);

if (validData.length >= limit) {
return false;
}


validData.push(now);
sessionStorage.setItem(actionKey, JSON.stringify(validData));
return true;
}
function clearInputAndSetPlaceholder() {
document.getElementById('addressbar').value = '';
document.getElementById('addressbar').placeholder = "Enter text here to update or make changes to your project";
Expand Down Expand Up @@ -60,25 +77,19 @@ function initializeApp() {
window.open(url, '_blank');
}

// Ensure the bookmarks panel hides on outside clicks
document.addEventListener('click', function(event) {
if (!event.target.closest('#bookmarks-panel') && !event.target.closest('.btn[onclick="toggleBookmarks()"]')) {
hideBookmarks();
}
});


ldb.get('netsim_history', function(value) {
history = JSON.parse(LZString.decompressFromUTF16(value) || '[]');
});


const frame = document.getElementById('simulation-frame');
if (frame && frame.contentDocument) {
frame.contentDocument.addEventListener('contextmenu', handleRightClick);
frame.contentDocument.addEventListener('click', handleLeftClick);
}
}


function showLoadingOverlay() {
const content = document.getElementById('content');
content.innerHTML = `
Expand Down Expand Up @@ -142,6 +153,11 @@ async function handleAddressBarSubmit() {
}

async function loadPage(input) {
if (!checkRateLimit('loadPage', 10, 60000)) {
alert("You've made too many requests. Please wait a moment before trying again.");
return;
}

showLoadingOverlay();
updateStatusBar("Creating web application...");

Expand Down Expand Up @@ -179,8 +195,8 @@ Key requirements:
20. There is no limit to the creativity, the type of code used, or the libraries used to produce the code for the generated simulations. The results should always aim to be of the highest quality, never aiming for simple generations but rather highly interactive, fully working, and complete generations.
21. Use only the provided Pixabay images for static content. Each image object contains a 'url' and 'alt' property. Use these properties to add relevant images to the generated content.
22. For interactive elements or custom visuals that require specific designs (like game elements, custom UI components, etc.), create these using code (SVG, Canvas, WebGL) or appropriate libraries rather than relying on static images.
23. Do not use placeholder comments. Always generate the full, working code.
22 For interactive elements or custom visuals that require specific designs (like game elements, custom UI components, etc.), create these using code (SVG, Canvas, WebGL) or appropriate libraries rather than relying on static images.
23 Do not use placeholder comments. Always generate the full, working code.
Your primary objective is to create a fully functional, creative, visually appealing, and highly detailed web application or website that matches the user's description. Pay meticulous attention to both the visual design and the underlying functionality. The result should be a rich, engaging, and realistic web experience that could pass for a genuine, professionally developed web application. Never be afraid to add your own creative additions to the simulation. It's critical that every single generation is full of content, is interactive and has a rich, immersive UI.
Expand Down

0 comments on commit 98b7d74

Please sign in to comment.