js

The js folder has the following files:

  • main.js

  • start.js

  • static.js

main.js

The following is the sample of the main.js file:

define(["exports", "knockout", "oap/core/services/factory", "oap/core/portal/config"], function (exports, ko, services, config) {
    var Main = (function() {
        function _main(container, element) {
            this.container = container;
            this.element = element;
            this.apis = ko.observableArray([]);
            this.developersGuide = container.documentationUrl;
        }
        _main.prototype.go = function() {
            var self = this;
            self.container.controller.showPanelLoading(self.container, true);
            services.getApiService().getApis()
                .done(function(data) {
                    self.apis(data.items);
                })
                .always(function() {
                    $(".example-page").css("display", "block");
                    self.container.controller.showPanelLoading(self.container, false);
                });
        };
        return _main;
    }());
    exports.Main = Main;
});

start.js

The following is the sample of the start.js file:

define(["home/js/main"], function (main) {
    var page = {
        init: function (container, element) {
            var m = new main.Main(container, element);
            this.pageViewModel = m;
            m.go();
        }
    }
    return page;
});

static.js

The following is the sample of the static.js file:

var staticLibrary = {
   displayMessage: function (element, message) {
         $(element).append("<p>" + message +"</p>");
    }
}