App-MFILE-WWW

 view release on metacpan or  search on metacpan

share/js/core/start.js  view on Meta::CPAN

                if (typeof opts !== 'object' || opts === null) {
                    opts = {};
                }
                opts.resultLine = ('resultLine' in opts) ? opts.resultLine : "&nbsp";
                opts.resultLine = (opts.resultLine === null) ? "&nbsp" : opts.resultLine;
                if (! obj) {
                    obj = stack.getState();
                }
                $('#mainarea').html(dco.source);
                if (dco.hasOwnProperty('callback')) {
                    $('#dcallback').html(dco.callback(obj, dco.title, dco.preamble));
                }
                if (dco.hasOwnProperty('htmlCallback')) {
                    $('#dcallback').html(dco.htmlCallback(obj, dco.title, dco.preamble));
                }
                if (dco.hasOwnProperty('populateCallback')) {
                    dco.populateCallback(obj);
                }
                $('input[name="sel"]').val('').focus();
                $('#submitButton').on("click", function (event) {
                    event.preventDefault;
                    console.log("Submitting form " + dcn);
                    mmSubmit(obj);
                });
                $('#' + dcn).on("keydown", mmKeyListener);
                coreLib.displayResult(opts.resultLine);
            };
        }, // dcallback

        dform: function (dfn) {
            var dfo = target.pull(dfn);
            return function (state, opts) {
                currentTarget = dfo;
                console.log('Entering start method of target ' + dfn + ', unadulterated opts', opts);
                var entry,
                    i,
                    msg,
                    populateArray = [];
                if (typeof opts !== 'object') {
                    opts = {};
                }
                opts.populate = ('populate' in opts) ? opts.populate : "true";
                opts.resultLine = ('resultLine' in opts) ? opts.resultLine : "&nbsp";
                opts.inputId = ('inputId' in opts) ? opts.inputId : null;
                console.log("opts", opts);
                // determine dform "state" (i.e. starting content of form entries)
                if (! state) {
                    state = stack.getState();
                }
                console.log('The object we are working with is:', state);
                // generate and display dform html
                $('#mainarea').html(dfo.source(state));
                // assemble array of entries with "populate" property
                for (i = 0; i < dfo.entriesRead.length; i += 1) {
                    entry = dfo.entriesRead[i];
                    if (entry.hasOwnProperty("populate")) {
                        if (typeof entry.populate === 'function') {
                            populateArray.push(entry.populate);
                        } else {
                            msg = "CRITICAL ERROR: bad populate property in entry " + entry.name;
                            throw msg;
                        }
                    }
                }
                // call first populate function to trigger sequential,
                // asynchronous population of all entries with "populate" property
                coreLib.displayResult(opts.resultLine);
                if (opts.populate && populateArray.length > 0) {
                    populate.bootstrap(populateArray);
                }
                // listen for user input in form
                dformListen(dfn, state, opts.inputId);
            };
        }, // dform

        dmenu: function (dmn) {
            // dmn is dmenu name
            // dmo is dmenu object
            var dmo = target.pull(dmn);
            return function (state, opts) {
                currentTarget = dmo;
                console.log('Entering start.dmenu with argument: ' + dmn);
                // coreLib.clearResult();
                stack.setFlag();
                if (typeof opts !== 'object' || opts === null) {
                    opts = {};
                }
                opts.resultLine = ('resultLine' in opts) ? opts.resultLine : "&nbsp";
                opts.resultLine = (opts.resultLine === null) ? "&nbsp" : opts.resultLine;
                $('#mainarea').html(dmo.source);
                $('input[name="sel"]').val('').focus();
                $('#' + dmn).submit(dmenuSubmitEvent(dmn));
                $('input[name="sel"]').keydown(dmenuKeyListener(dmn));
                coreLib.displayResult(opts.resultLine);
            };
        }, // dmenu

        dnotice: function (dnn) {
            var dno = target.pull(dnn);
            return function (state, opts) {
                // state is a string to be displayed on the screen
                currentTarget = dno;
                console.log("Entering start.dnotice with argument: " + dnn);
                if (! state) {
                    state = stack.getState();
                }
                coreLib.clearResult();
                $('#mainarea').html(dno.source()); // write HTML to screen
                $("#noticeText").html(state);
                $('input[name="sel"]').focus();
                dnoticeListen(dno);
            };
        }, // dnotice

        drowselect: function (drsn) {
            var drso = target.pull(drsn);
            if (drsn) {
                // when called with drsn (drowselect name) argument, we assume
                // that we are being called from the second stage of drowselect
                // initialization (i.e., one-time event) -- generate and
                // return the start function for this drowselect



( run in 1.163 second using v1.01-cache-2.11-cpan-39bf76dae61 )