arch-kiosk / arch-kiosk-office

💼 central place for collaboration
GNU Affero General Public License v3.0
1 stars 0 forks source link

get rid of global javascript and restructure the whole javascript development #1218

Open urapadmin opened 3 years ago

urapadmin commented 3 years ago

ES6 is not really compatible with old global js style. As soon as I use an import a script becomes a module and so all global functions become local. They cannot be called anymore from somewhere else. So I cannot use methods that are exported in global scripts. Don't really know how to handle this. I need to learn about how to properly organize javascript (but dynamically because we have plugins using their own javascripts).

Ergo: The whole javascript structure needs to go. Complete restart of javascript.

For the time being I have to keep things disconnected. Which means horrible code duplication.

urapadmin commented 3 years ago

well, meanwhile I did find a workaround. All global javascript functions are in fact accessible using the window object. I use this in the new kioskprodstarter.js, which is a module but needs to use getRoutefor:

export class ProdKioskApi extends KioskApi {
    getApiUrl(apiAddress = "") {
        if (apiAddress) {
            return `${window.getRoutefor("api")}/v1/${apiAddress}`;
        } else {
            return window.getRoutefor("api");
        }
    }

I still find this all pretty hacky and so in the end the task stays the same: All the JS development needs to be bumped up to ES6 standards.