1

We already have an up and running Roomle integration on https://flashfox.ch/usm-haller-konfigurator/

Since there's a new version of the API we tried to upgrade. We used the documentation from https://docs.roomle.com/web/embedding/#getting-started

We don't use npm, so we tried the following code:

<body>
    <div id="configurator-container"></div>
    <script src="./roomle-configurator-api.es.min.js" type="module"></script>
    <script type="module">
        import RoomleConfiguratorApi from './roomle-configurator-api.es.min.js';
        (async ()=> {
            const options = {
                id: 'usm:frame',
            };
            const configurator = await RoomleConfiguratorApi.create(
                'demoConfigurator',
                document.getElementById('configurator-container'),
                options,
            );
        })();
    </script>
</body>

The path ./roomle-configurator-api.es.min.js obviously doesn't work. What would be the correct Path to the .js of the latest version?

In case it helps, this is part of the code we currently run:

<script src="https://www.roomle.com/t/embedding/roomle-configurator-api.js"></script>

<script>
var wfPartsList;
var flashfoxImg;
var PartsMailer;
function startPartsMailer() {
    PartsMailer = '...html...';
}
function endPartsMailer() {
    PartsMailer += '...html...';
};
document.addEventListener('DOMContentLoaded', async function () {
    try {
        RoomleConfigurator.addChangeListener((parts) => {
            (async function () { 
                const {perspectiveImage} = await RoomleConfigurator.requestAddToCart();
                console.log(perspectiveImage);
                flashfoxImg = perspectiveImage;
            }())
            startPartsMailer()
            var i = 1;
            wfPartsList = parts.partList;
            parts.partList.forEach((part)=> {
                var style = '';
                if (i % 2 == 0) {
                    style = 'background-color: #ececec';
                }
                PartsMailer += '... html ...';
                ++i;
                part.parameters.forEach((param)=> {
                    
                });
            });
        });
        await RoomleConfigurator.init('«name»', 'configurator-container', 'usm:«name»', {
        skin: {
            'color-on-secondary': 'white',
            'brand-logo': 'https://path...'
        }
        });
    } catch(error) {
        console.error(error);
    }
});
</script>
Jqx
  • 11
  • 1

1 Answers1

3

Basically we recommend managing your dependencies with a package manager like npm. If you do not like npm there is also yarn.

If you do not want to use any package manager at all you can download the source code from the npm registry and just add it to your git project.

If it's okay to install npm locally on one machine, the easiest way would be to download the library with npm.

After installing npm you can run the following bash commands on your machine (tested on Mac, on Windows it's probably slightly different):

mkdir project
cd project
npm init # just say yes to all the questions (hit enter)
npm i @roomle/embedding-lib --save-dev
cp -r node_modules/@roomle/embedding-lib ../my-git-repo-on-local-machine/roomle-embedding-lib
cd ../my-git-repo-on-local-machine/
cd git add -A
cd git commit -am "Add roomle files"
tschoartschi
  • 1,453
  • 2
  • 14
  • 23