function getUserConfiguration(){
    let userConfiguration = [];
    for(let i = 0; i < localStorage.length; i++){
        userConfiguration.push(JSON.parse(localStorage.getItem(localStorage.key(i))));
    }
    return userConfiguration;
}

function saveUserConfiguration(userConfiguration){
    for(let i = 0; i < userConfiguration.length; i++){
        localStorage.setItem(i, JSON.stringify(userConfiguration[i]));
    }
}

function getFormattedUserConfigurationFromLocalStorage(){
    let formatedUserConfiguration = {};

    for(let configurationLineObject of getUserConfiguration()){
        // Every entry in the localStorage has a variable field and at least one field cat, color or unit,
        // so there is no need to check their presence
        
        let key = configurationLineObject["variable"];
        delete configurationLineObject["variable"];
        if(configurationLineObject.hasOwnProperty("parameter")){
            key +=  (configurationLineObject["parameter"] != "value") ? "." + configurationLineObject["parameter"] : "";
            delete configurationLineObject["parameter"];
        }
        formatedUserConfiguration[key] = configurationLineObject;                        
    }
    return formatedUserConfiguration;
}