Phoenicis Scripts Documentation logo Phoenicis Scripts Documentation

Most components inside the scripts are implemented as JavaScript prototype classes. To allow an easier understanding of the code and to be more inline with the Phoenicis application implementation classes should be implemented using the new ECMAScript 2015 syntax.

Structure

A class defined with this newer syntax has the following structure:

class ClassName extends ParentClassName {
    constructor(<arguments>) {
        super(<super-arguments>);

        // object initialization
    }

    foo(<arguments>) {
        // method body

        return <result>;
    }

    bar() {
        // method body
    }
}

Where:

Example

class ShortcutReader {
    constructor() {
        // do nothing
    }

    /**
     * sets shortcut
     * @param {string} shortcut shortcut
     * @returns {void}
     */
    of(shortcut) {
        const shortcutContentParsed = JSON.parse(shortcut.script);

        if (shortcutContentParsed.type == "WINE") {
            this.runner = new WineShortcutReader(shortcut);
        }
    }

    /**
     * returns container of shortcut
     * @returns {string} container
     */
    get container() {
        return this.runner.container();
    }

    /**
     * runs shortcut
     * @param {array} userArguments arguments
     * @returns {void}
     */
    run(userArguments) {
        this.runner.run(userArguments);
    }

    /**
     * stops running shortcut
     * @returns {void}
     */
    stop() {
        this.runner.stop();
    }

    /**
     * uninstalls shortcut
     * @returns {void}
     */
    uninstall() {
        this.runner.uninstall();
    }
}