31 lines
866 B
JavaScript
31 lines
866 B
JavaScript
/**
|
|
* Application State Management
|
|
* Central state for the entire application
|
|
* Apenas funções utilitárias - estados são gerenciados em app.js
|
|
*/
|
|
|
|
/**
|
|
* Check if localStorage is available and has space
|
|
* @returns {object} Storage status
|
|
*/
|
|
function checkStorage() {
|
|
try {
|
|
var testKey = '__storage_test__';
|
|
localStorage.setItem(testKey, testKey);
|
|
localStorage.removeItem(testKey);
|
|
|
|
var totalSize = 0;
|
|
for (var key in localStorage) {
|
|
if (localStorage.hasOwnProperty(key)) {
|
|
totalSize += localStorage[key].length * 2;
|
|
}
|
|
}
|
|
|
|
return { available: true, usedBytes: totalSize };
|
|
} catch (error) {
|
|
return { available: false, error: error.message };
|
|
}
|
|
}
|
|
|
|
// Make available globally (only functions)
|
|
window.checkStorage = checkStorage; |