function fetchConfigFile(){
    console.log("Fetching Config");
    var file = "txt/config.txt";

    $.ajax({
        url: file,
        success: function(data){
            var configInitializeInt = 0;
            var configFileInput = data.split('\n');
            var isComment;
            var apiKeyString = "";
            var authDomainString = "";
            var databaseURLString = "";
            var projectIdString = "";
            var storageBucketString = "";
            var messagingSenderIdString = "";
            var appIdString = "";
            var measurementIdString = "";

            for(var i = 0; i < configFileInput.length; i++){
                isComment = false;
                if (configFileInput[i].charAt(0) == "#" || configFileInput[i].charAt(0) == "") {
                    isComment = true;
                }
                if (!isComment) {
                    if (configFileInput[i].includes("apiKey:")){
                        configInitializeInt++;
                        apiKeyString = configFileInput[i].substr(7, configFileInput[i].length);
                        apiKeyString = apiKeyString.replace(/"/g, '');
                        apiKeyString = apiKeyString.replace(/,/g, '');
                        apiKeyString = apiKeyString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("authDomain:")){
                        configInitializeInt++;
                        authDomainString = configFileInput[i].substr(11, configFileInput[i].length);
                        authDomainString = authDomainString.replace(/"/g, '');
                        authDomainString = authDomainString.replace(/,/g, '');
                        authDomainString = authDomainString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("databaseURL:")){
                        configInitializeInt++;
                        databaseURLString = configFileInput[i].substr(12, configFileInput[i].length);
                        databaseURLString = databaseURLString.replace(/"/g, '');
                        databaseURLString = databaseURLString.replace(/,/g, '');
                        databaseURLString = databaseURLString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("projectId:")){
                        configInitializeInt++;
                        projectIdString = configFileInput[i].substr(10, configFileInput[i].length);
                        projectIdString = projectIdString.replace(/"/g, '');
                        projectIdString = projectIdString.replace(/,/g, '');
                        projectIdString = projectIdString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("storageBucket:")){
                        configInitializeInt++;
                        storageBucketString = configFileInput[i].substr(14, configFileInput[i].length);
                        storageBucketString = storageBucketString.replace(/"/g, '');
                        storageBucketString = storageBucketString.replace(/,/g, '');
                        storageBucketString = storageBucketString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("messagingSenderId:")){
                        configInitializeInt++;
                        messagingSenderIdString = configFileInput[i].substr(18, configFileInput[i].length);
                        messagingSenderIdString = messagingSenderIdString.replace(/"/g, '');
                        messagingSenderIdString = messagingSenderIdString.replace(/,/g, '');
                        messagingSenderIdString = messagingSenderIdString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("appId:")){
                        configInitializeInt++;
                        appIdString = configFileInput[i].substr(6, configFileInput[i].length);
                        appIdString = appIdString.replace(/"/g, '');
                        appIdString = appIdString.replace(/,/g, '');
                        appIdString = appIdString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("measurementId:")){
                        configInitializeInt++;
                        measurementIdString = configFileInput[i].substr(14, configFileInput[i].length);
                        measurementIdString = measurementIdString.replace(/"/g, '');
                        measurementIdString = measurementIdString.replace(/,/g, '');
                        measurementIdString = measurementIdString.replace(/ /g, '');
                    } else {
                        //console.log("Unknown Config String, Please Advise:");
                        //console.log(configFileInput[i]);
                    }
                } else {
                    //console.log("Comment Found!");
                }
            }

            if(configInitializeInt == 8){     //Checks to see if any of the previous data was missed
                if (apiKeyString == "" || authDomainString == "" || databaseURLString == "" || projectIdString == "" ||
                    storageBucketString == "" || messagingSenderIdString == "" || appIdString == "" || measurementIdString == "") {
                    alert("Config not properly initialized! Please contact an administrator!");
                    console.log("Config Not Initialized! Are You Using The Default Config File?");
                } else {
                    configObj = {
                        apiKey: apiKeyString,
                        authDomain: authDomainString,
                        databaseURL: databaseURLString,
                        projectId: projectIdString,
                        storageBucket: storageBucketString,
                        messagingSenderId: messagingSenderIdString,
                        appId: appIdString,
                        measurementId: measurementIdString
                    };
                    console.log("Config Successfully Initialized!");

                    sessionStorage.setItem("config", JSON.stringify(configObj));
                    initializeDatabase();
                }
            }
        }
    });
}
//Once the necessary data has been retrieved from the config file, the database is initialized.
Once the necessary data has been retrieved from the config file, the database is initialized.
Once the necessary data has been retrieved from the config file the database is initialized .
function fetchConfigFile(){
    console.log("Fetching Config");
    var file = "txt/config.txt";
    $.ajax({
        url: file,
        success: function(data){
            var configInitializeInt = 0;
            var configFileInput = data.split('\n');
            var isComment;
            var apiKeyString = "";
            var authDomainString = "";
            var databaseURLString = "";
            var projectIdString = "";
            var storageBucketString = "";
            var messagingSenderIdString = "";
            var appIdString = "";
            var measurementIdString = "";
            for(var i = 0; i < configFileInput.length; i++){
                isComment = false;
                if (configFileInput[i].charAt(0) == "#" || configFileInput[i].charAt(0) == "") {
                    isComment = true;
                }
                if (!isComment) {
                    if (configFileInput[i].includes("apiKey:")){
                        configInitializeInt++;
                        apiKeyString = configFileInput[i].substr(7, configFileInput[i].length);
                        apiKeyString = apiKeyString.replace(/"/g, '');
                        apiKeyString = apiKeyString.replace(/,/g, '');
                        apiKeyString = apiKeyString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("authDomain:")){
                        configInitializeInt++;
                        authDomainString = configFileInput[i].substr(11, configFileInput[i].length);
                        authDomainString = authDomainString.replace(/"/g, '');
                        authDomainString = authDomainString.replace(/,/g, '');
                        authDomainString = authDomainString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("databaseURL:")){
                        configInitializeInt++;
                        databaseURLString = configFileInput[i].substr(12, configFileInput[i].length);
                        databaseURLString = databaseURLString.replace(/"/g, '');
                        databaseURLString = databaseURLString.replace(/,/g, '');
                        databaseURLString = databaseURLString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("projectId:")){
                        configInitializeInt++;
                        projectIdString = configFileInput[i].substr(10, configFileInput[i].length);
                        projectIdString = projectIdString.replace(/"/g, '');
                        projectIdString = projectIdString.replace(/,/g, '');
                        projectIdString = projectIdString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("storageBucket:")){
                        configInitializeInt++;
                        storageBucketString = configFileInput[i].substr(14, configFileInput[i].length);
                        storageBucketString = storageBucketString.replace(/"/g, '');
                        storageBucketString = storageBucketString.replace(/,/g, '');
                        storageBucketString = storageBucketString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("messagingSenderId:")){
                        configInitializeInt++;
                        messagingSenderIdString = configFileInput[i].substr(18, configFileInput[i].length);
                        messagingSenderIdString = messagingSenderIdString.replace(/"/g, '');
                        messagingSenderIdString = messagingSenderIdString.replace(/,/g, '');
                        messagingSenderIdString = messagingSenderIdString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("appId:")){
                        configInitializeInt++;
                        appIdString = configFileInput[i].substr(6, configFileInput[i].length);
                        appIdString = appIdString.replace(/"/g, '');
                        appIdString = appIdString.replace(/,/g, '');
                        appIdString = appIdString.replace(/ /g, '');
                    } else if (configFileInput[i].includes("measurementId:")){
                        configInitializeInt++;
                        measurementIdString = configFileInput[i].substr(14, configFileInput[i].length);
                        measurementIdString = measurementIdString.replace(/"/g, '');
                        measurementIdString = measurementIdString.replace(/,/g, '');
                        measurementIdString = measurementIdString.replace(/ /g, '');
                    } else {
                    }
                } else {
                }
            }
            if(configInitializeInt == 8){     
                if (apiKeyString == "" || authDomainString == "" || databaseURLString == "" || projectIdString == "" ||
                    storageBucketString == "" || messagingSenderIdString == "" || appIdString == "" || measurementIdString == "") {
                    alert("Config not properly initialized! Please contact an administrator!");
                    console.log("Config Not Initialized! Are You Using The Default Config File?");
                } else {
                    configObj = {
                        apiKey: apiKeyString,
                        authDomain: authDomainString,
                        databaseURL: databaseURLString,
                        projectId: projectIdString,
                        storageBucket: storageBucketString,
                        messagingSenderId: messagingSenderIdString,
                        appId: appIdString,
                        measurementId: measurementIdString
                    };
                    console.log("Config Successfully Initialized!");
                    sessionStorage.setItem("config", JSON.stringify(configObj));
                    initializeDatabase();
                }
            }
        }
    });
}
function fetchConfigFile ( ) { console . log ( "Fetching Config" ) ; var file = "txt/config.txt" ; $ . ajax ( { url : file , success : function ( data ) { var configInitializeInt = 0 ; var configFileInput = data . split ( '\n' ) ; var isComment ; var apiKeyString = "" ; var authDomainString = "" ; var databaseURLString = "" ; var projectIdString = "" ; var storageBucketString = "" ; var messagingSenderIdString = "" ; var appIdString = "" ; var measurementIdString = "" ; for ( var i = 0 ; i < configFileInput . length ; i ++ ) { isComment = false ; if ( configFileInput [ i ] . charAt ( 0 ) == "#" || configFileInput [ i ] . charAt ( 0 ) == "" ) { isComment = true ; } if ( ! isComment ) { if ( configFileInput [ i ] . includes ( "apiKey:" ) ) { configInitializeInt ++ ; apiKeyString = configFileInput [ i ] . substr ( 7 , configFileInput [ i ] . length ) ; apiKeyString = apiKeyString . replace ( / " / g , '' ) ; apiKeyString = apiKeyString . replace ( / , / g , '' ) ; apiKeyString = apiKeyString . replace ( / / g , '' ) ; } else if ( configFileInput [ i ] . includes ( "authDomain:" ) ) { configInitializeInt ++ ; authDomainString = configFileInput [ i ] . substr ( 11 , configFileInput [ i ] . length ) ; authDomainString = authDomainString . replace ( / " / g , '' ) ; authDomainString = authDomainString . replace ( / , / g , '' ) ; authDomainString = authDomainString . replace ( / / g , '' ) ; } else if ( configFileInput [ i ] . includes ( "databaseURL:" ) ) { configInitializeInt ++ ; databaseURLString = configFileInput [ i ] . substr ( 12 , configFileInput [ i ] . length ) ; databaseURLString = databaseURLString . replace ( / " / g , '' ) ; databaseURLString = databaseURLString . replace ( / , / g , '' ) ; databaseURLString = databaseURLString . replace ( / / g , '' ) ; } else if ( configFileInput [ i ] . includes ( "projectId:" ) ) { configInitializeInt ++ ; projectIdString = configFileInput [ i ] . substr ( 10 , configFileInput [ i ] . length ) ; projectIdString = projectIdString . replace ( / " / g , '' ) ; projectIdString = projectIdString . replace ( / , / g , '' ) ; projectIdString = projectIdString . replace ( / / g , '' ) ; } else if ( configFileInput [ i ] . includes ( "storageBucket:" ) ) { configInitializeInt ++ ; storageBucketString = configFileInput [ i ] . substr ( 14 , configFileInput [ i ] . length ) ; storageBucketString = storageBucketString . replace ( / " / g , '' ) ; storageBucketString = storageBucketString . replace ( / , / g , '' ) ; storageBucketString = storageBucketString . replace ( / / g , '' ) ; } else if ( configFileInput [ i ] . includes ( "messagingSenderId:" ) ) { configInitializeInt ++ ; messagingSenderIdString = configFileInput [ i ] . substr ( 18 , configFileInput [ i ] . length ) ; messagingSenderIdString = messagingSenderIdString . replace ( / " / g , '' ) ; messagingSenderIdString = messagingSenderIdString . replace ( / , / g , '' ) ; messagingSenderIdString = messagingSenderIdString . replace ( / / g , '' ) ; } else if ( configFileInput [ i ] . includes ( "appId:" ) ) { configInitializeInt ++ ; appIdString = configFileInput [ i ] . substr ( 6 , configFileInput [ i ] . length ) ; appIdString = appIdString . replace ( / " / g , '' ) ; appIdString = appIdString . replace ( / , / g , '' ) ; appIdString = appIdString . replace ( / / g , '' ) ; } else if ( configFileInput [ i ] . includes ( "measurementId:" ) ) { configInitializeInt ++ ; measurementIdString = configFileInput [ i ] . substr ( 14 , configFileInput [ i ] . length ) ; measurementIdString = measurementIdString . replace ( / " / g , '' ) ; measurementIdString = measurementIdString . replace ( / , / g , '' ) ; measurementIdString = measurementIdString . replace ( / / g , '' ) ; } else { } } else { } } if ( configInitializeInt == 8 ) { if ( apiKeyString == "" || authDomainString == "" || databaseURLString == "" || projectIdString == "" || storageBucketString == "" || messagingSenderIdString == "" || appIdString == "" || measurementIdString == "" ) { alert ( "Config not properly initialized! Please contact an administrator!" ) ; console . log ( "Config Not Initialized! Are You Using The Default Config File?" ) ; } else { configObj = { apiKey : apiKeyString , authDomain : authDomainString , databaseURL : databaseURLString , projectId : projectIdString , storageBucket : storageBucketString , messagingSenderId : messagingSenderIdString , appId : appIdString , measurementId : measurementIdString } ; console . log ( "Config Successfully Initialized!" ) ; sessionStorage . setItem ( "config" , JSON . stringify ( configObj ) ) ; initializeDatabase ( ) ; } } } } ) ; }
Once the necessary data has been retrieved from the config file, the database is initialized.
Once the necessary data has been retrieved from the config file the database is initialized .
//console.log("Unknown Config String, Please Advise:"); //console.log(configFileInput[i]); //console.log("Comment Found!"); //Checks to see if any of the previous data was missed