Created
March 30, 2024 19:33
-
-
Save en9inerd/b4f185d6d3f5e51257d6e4051c619e1d to your computer and use it in GitHub Desktop.
Memory Address Manipulator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Memory Address Manipulator</title> | |
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> | |
</head> | |
<body> | |
<div class="container mt-5"> | |
<h1>Memory Address Manipulator</h1> | |
<div class="row mt-3"> | |
<div class="col"> | |
<label for="memoryAddress">Memory Address:</label> | |
<input type="text" id="memoryAddress" class="form-control"> | |
</div> | |
</div> | |
<div class="row mt-3"> | |
<div class="col"> | |
<button id="decrementBtn" class="btn btn-primary mr-2">Decrement</button> | |
<button id="incrementBtn" class="btn btn-primary">Increment</button> | |
</div> | |
</div> | |
<div class="row mt-3"> | |
<div class="col"> | |
<label for="themeSwitch">Dark Mode:</label> | |
<input type="checkbox" id="themeSwitch"> | |
</div> | |
</div> | |
</div> | |
<script> | |
// Function to toggle between dark and light mode | |
function toggleDarkMode() { | |
var darkModeEnabled = document.getElementById('themeSwitch').checked; | |
if (darkModeEnabled) { | |
document.body.classList.add('dark-mode'); | |
} else { | |
document.body.classList.remove('dark-mode'); | |
} | |
localStorage.setItem('darkModeEnabled', darkModeEnabled); | |
} | |
// Function to load theme setting from local storage | |
function loadThemeSetting() { | |
var darkModeEnabled = localStorage.getItem('darkModeEnabled'); | |
if (darkModeEnabled === 'true') { | |
document.getElementById('themeSwitch').checked = true; | |
toggleDarkMode(); | |
} | |
} | |
// Function to increment the memory address | |
function incrementMemory() { | |
var memoryAddress = parseInt(document.getElementById('memoryAddress').value, 16) || 0; | |
if (memoryAddress < parseInt('FFFFFFFF', 16)) { | |
memoryAddress++; | |
updateMemoryAddress(memoryAddress); | |
} | |
} | |
// Function to decrement the memory address | |
function decrementMemory() { | |
var memoryAddress = parseInt(document.getElementById('memoryAddress').value, 16) || 0; | |
if (memoryAddress > 0) { | |
memoryAddress--; | |
updateMemoryAddress(memoryAddress); | |
} | |
} | |
// Function to update memory address value and store it in local storage | |
function updateMemoryAddress(address) { | |
localStorage.setItem('memoryAddress', address.toString(16).toUpperCase().padStart(8, '0')); | |
document.getElementById('memoryAddress').value = '0x' + localStorage.getItem('memoryAddress'); | |
} | |
// Initial setup | |
document.getElementById('incrementBtn').addEventListener('click', incrementMemory); | |
document.getElementById('decrementBtn').addEventListener('click', decrementMemory); | |
document.getElementById('memoryAddress').addEventListener('input', function () { | |
var inputAddress = parseInt(this.value, 16); | |
if (isNaN(inputAddress)) { | |
this.value = ''; | |
} else { | |
updateMemoryAddress(inputAddress); | |
} | |
}); | |
document.getElementById('themeSwitch').addEventListener('change', toggleDarkMode); | |
loadThemeSetting(); | |
document.getElementById('memoryAddress').value = '0x' + (localStorage.getItem('memoryAddress') || '00000000'); | |
</script> | |
<style> | |
/* Dark mode styles */ | |
.dark-mode { | |
background-color: #333; | |
color: #fff; | |
} | |
</style> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment