const HEIGHT_COL = 1;
const WIDTH_COL = 2;
const MESSAGE_COL = 3;

jOmnis.callbackObject = {
    height: 0,
    width: 0,
    message: "",
    omnisGetCurrentLine: function() { return 1; },
    omnisSetData: function(data) {
        if (data instanceof omnis_list && data.getRowCount() == 1) {
            this.height = data.getData(HEIGHT_COL,1);
            this.width = data.getData(WIDTH_COL,1);
            this.message = data.getData(MESSAGE_COL,1);
        }

        this.positionFields();
        this.setMessage();
    },
    omnisOnLoad: function() {
        this.height = 0;
        this.width = 0;
        this.message = "Saving...";
    },
    positionFields: function() {
        mainElement = document.getElementById("main");
        mainElement.style.paddingTop = ((this.height-200)/2) + "px"; /* the offset height appears to fluctuate; setting it to a static 200 prevents this */
        mainElement.style.paddingLeft = ((this.width-mainElement.offsetWidth)/2) + "px";
        mainElement.style.visibility = "visible";
    },
    setMessage: function() {
        if (this.message != "") {
            if (document.getElementById("message") == null) {
                document.getElementById("main").insertBefore(document.createElement("h2"), document.getElementById("main").firstChild)
                document.getElementsByTagName("H2")[0].setAttribute("id","message")
            }
            document.getElementById("message").innerHTML = this.message;
        }
    }
};