website/src/MapPage/map.js
/**
      * Sets up component state the first time for the selected image represented by id
      * @param {int} id - object ID of the initial piece of art to generate an image for
      */
Sets up component state the first time for the selected image represented by id
@param {int} id - object ID of the initial piece of art to generate an image for
Sets up component state the first time for the selected image represented by id @param { int } id - object ID of the initial piece of art to generate an image for
function firstTimeGenImage(id) {
        const baseMetUrl = 'https://collectionapi.metmuseum.org/public/collection/v1/objects/';
        const metApiUrl = baseMetUrl + id;
        const Http = new XMLHttpRequest();
        Http.open("GET", metApiUrl);
        Http.send();
        Http.onreadystatechange = (e) => {
            if (Http.readyState === 4) {
                try {
                    const response = JSON.parse(Http.responseText);
                    stateHolder.setState({
                        imgData: response.primaryImage,
                        apiData: response
                    })
                    const imageToSeedUrl = "https://mmlsparkdemo.blob.core.windows.net/met/inverted/biggan1/seeds/";
                    const fileName = response.objectID.toString() + ".json";
                    const Http2 = new XMLHttpRequest();
                    Http2.open("GET", imageToSeedUrl + fileName);
                    Http2.send();
                    Http2.onreadystatechange = (e) => {
                        if (Http2.readyState === 4) {
                            try {
                                let response = JSON.parse(Http2.responseText);
                                let seed = [response.latents].toString();
                                seed = `[[${seed}]]`;
                                let label = response.labels;
                                stateHolder.setState({
                                    genSeed: twoDArrayStringToOneDArray(seed),
                                    genLabel: response.labels
                                });
                                getGenImage(seed, label);
                            } catch (err) {
                                console.log('malformed request:' + Http2.responseText);
                            }
                        }
                    }
                } catch (err) {;
                    console.log('malformed request:' + Http.responseText);
                }
            }
        }
    }
function firstTimeGenImage ( id ) { const baseMetUrl = 'https://collectionapi.metmuseum.org/public/collection/v1/objects/' ; const metApiUrl = baseMetUrl + id ; const Http = new XMLHttpRequest ( ) ; Http . open ( "GET" , metApiUrl ) ; Http . send ( ) ; Http . onreadystatechange = ( e ) => { if ( Http . readyState === 4 ) { try { const response = JSON . parse ( Http . responseText ) ; stateHolder . setState ( { imgData : response . primaryImage , apiData : response } ) const imageToSeedUrl = "https://mmlsparkdemo.blob.core.windows.net/met/inverted/biggan1/seeds/" ; const fileName = response . objectID . toString ( ) + ".json" ; const Http2 = new XMLHttpRequest ( ) ; Http2 . open ( "GET" , imageToSeedUrl + fileName ) ; Http2 . send ( ) ; Http2 . onreadystatechange = ( e ) => { if ( Http2 . readyState === 4 ) { try { let response = JSON . parse ( Http2 . responseText ) ; let seed = [ response . latents ] . toString ( ) ; seed = ` ${ seed } ` ; let label = response . labels ; stateHolder . setState ( { genSeed : twoDArrayStringToOneDArray ( seed ) , genLabel : response . labels } ) ; getGenImage ( seed , label ) ; } catch ( err ) { console . log ( 'malformed request:' + Http2 . responseText ) ; } } } } catch ( err ) { ; console . log ( 'malformed request:' + Http . responseText ) ; } } } }
Sets up component state the first time for the selected image represented by id
 @param {int} id - object ID of the initial piece of art to generate an image for
Sets up component state the first time for the selected image represented by id @param { int } id - object ID of the initial piece of art to generate an image for