Spaces:
Running
Running
File size: 963 Bytes
0aabf7d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
function saveToUserStorage(force = false) {
const currentTime = new Date().getTime();
const lastSaveTimestamp = parseInt(localStorage.getItem('lastSaveTimestamp') || '0');
if (!force && currentTime - lastSaveTimestamp < 5000) {
return;
}
const data = {};
document.querySelectorAll('input, textarea, select').forEach(input => {
data[input.id] = input.value;
});
localStorage.setItem('gemini_prompt', JSON.stringify(data));
localStorage.setItem('lastSaveTimestamp', currentTime.toString());
return true;
}
function loadFromUserStorage() {
const data = JSON.parse(localStorage.getItem('gemini_prompt')) || {};
document.querySelectorAll('input, textarea, select').forEach(input => {
let v = data[input.id] || "";
if (v) {
if (input.type === "number") {
v = parseInt(v);
}
input.value = v;
}
});
}
|