fix: remove state.js duplicado - app.js gerencia seus próprios estados
This commit is contained in:
@@ -557,7 +557,6 @@
|
|||||||
|
|
||||||
<!-- Utils (global) -->
|
<!-- Utils (global) -->
|
||||||
<script src="/js/utils/logger.js"></script>
|
<script src="/js/utils/logger.js"></script>
|
||||||
<script src="/js/core/state.js"></script>
|
|
||||||
|
|
||||||
<!-- Main app (legacy - mantido para compatibilidade) -->
|
<!-- Main app (legacy - mantido para compatibilidade) -->
|
||||||
<script src="/app.js"></script>
|
<script src="/app.js"></script>
|
||||||
|
|||||||
@@ -1,121 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* Application State Management
|
* Application State Management
|
||||||
* Central state for the entire application
|
* Central state for the entire application
|
||||||
|
* Apenas funções utilitárias - estados são gerenciados em app.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Main application state
|
|
||||||
var appState = {
|
|
||||||
history: [],
|
|
||||||
favorites: [],
|
|
||||||
budgetItems: [],
|
|
||||||
currentSection: 'cev',
|
|
||||||
currentTheme: 'dark',
|
|
||||||
expertMode: false,
|
|
||||||
currentSidebarTab: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
// User preferences (persisted to localStorage)
|
|
||||||
var userPreferences = {
|
|
||||||
theme: 'dark',
|
|
||||||
colorScheme: 'default',
|
|
||||||
fontSize: 'medium',
|
|
||||||
fontFamily: 'default'
|
|
||||||
};
|
|
||||||
|
|
||||||
// Load preferences from localStorage
|
|
||||||
function loadPreferences() {
|
|
||||||
try {
|
|
||||||
var saved = localStorage.getItem('acoCalcPreferences');
|
|
||||||
if (saved) {
|
|
||||||
var parsed = JSON.parse(saved);
|
|
||||||
for (var key in parsed) {
|
|
||||||
if (parsed.hasOwnProperty(key)) {
|
|
||||||
userPreferences[key] = parsed[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.warn('Nao foi possivel carregar preferencias:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save preferences to localStorage
|
|
||||||
function savePreferences() {
|
|
||||||
try {
|
|
||||||
localStorage.setItem('acoCalcPreferences', JSON.stringify(userPreferences));
|
|
||||||
} catch (e) {
|
|
||||||
console.warn('Nao foi possivel salvar preferencias:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Admin configuration
|
|
||||||
var adminConfig = {
|
|
||||||
appName: 'SteelBase',
|
|
||||||
appSubtitle: 'Plataforma Tecnica com Base de Dados de Materiais Brasileiros',
|
|
||||||
footerText: '© 2025 SteelBase v7.5 PROFESSIONAL EDITION - Plataforma Tecnica com Base de Dados de Materiais Brasileiros',
|
|
||||||
themeDefault: 'escuro',
|
|
||||||
modeDefault: 'simples',
|
|
||||||
toolsVisibility: {
|
|
||||||
'cev': true,
|
|
||||||
'seletor': true,
|
|
||||||
'equivalencias': false,
|
|
||||||
'comparativo': false,
|
|
||||||
'parafusos': true,
|
|
||||||
'layout': true,
|
|
||||||
'parafuso-vs-solda': false,
|
|
||||||
'preaquecimento': true,
|
|
||||||
'dureza': true,
|
|
||||||
'charpy': true,
|
|
||||||
'certificado': false,
|
|
||||||
'ultrassom': false,
|
|
||||||
'area-pintura': true,
|
|
||||||
'consumo-tinta': true,
|
|
||||||
'galvanizacao': false,
|
|
||||||
'custo-pintura': true,
|
|
||||||
'secagem': false,
|
|
||||||
'inspecao-pintura': false,
|
|
||||||
'orcamento': true,
|
|
||||||
'peso-rigging': false,
|
|
||||||
'referencia': false
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update app state
|
|
||||||
* @param {string} key - State key
|
|
||||||
* @param {any} value - New value
|
|
||||||
*/
|
|
||||||
function updateState(key, value) {
|
|
||||||
appState[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get state value
|
|
||||||
* @param {string} key - State key
|
|
||||||
* @returns {any} State value
|
|
||||||
*/
|
|
||||||
function getState(key) {
|
|
||||||
return appState[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update user preferences
|
|
||||||
* @param {string} key - Preference key
|
|
||||||
* @param {any} value - New value
|
|
||||||
*/
|
|
||||||
function updatePreference(key, value) {
|
|
||||||
userPreferences[key] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get preference value
|
|
||||||
* @param {string} key - Preference key
|
|
||||||
* @returns {any} Preference value
|
|
||||||
*/
|
|
||||||
function getPreference(key) {
|
|
||||||
return userPreferences[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if localStorage is available and has space
|
* Check if localStorage is available and has space
|
||||||
* @returns {object} Storage status
|
* @returns {object} Storage status
|
||||||
@@ -139,14 +27,5 @@ function checkStorage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make available globally
|
// Make available globally (only functions)
|
||||||
window.appState = appState;
|
|
||||||
window.userPreferences = userPreferences;
|
|
||||||
window.loadPreferences = loadPreferences;
|
|
||||||
window.savePreferences = savePreferences;
|
|
||||||
window.adminConfig = adminConfig;
|
|
||||||
window.updateState = updateState;
|
|
||||||
window.getState = getState;
|
|
||||||
window.updatePreference = updatePreference;
|
|
||||||
window.getPreference = getPreference;
|
|
||||||
window.checkStorage = checkStorage;
|
window.checkStorage = checkStorage;
|
||||||
Reference in New Issue
Block a user