Namespace example.txt
var centre = (function () {
        var s = "<a href=\"javascript: centre.loadElements();\" class=\"btn btn-warning btn-xs\">View</a>";
        return {
            addButton: function () {
                $("#dataTable tbody").find("tr").each(function () {
                    $(this).find("td:last").append(s);
                });
            },
            loadElements: function () {
                $("input[name='centreEnabled']").bootstrapSwitch({ state: true, size: "small", offColor: "danger", onColor: "success", onText: "ACTIVE", offText: "STOPPED", labelWidth: 10 });
                $("#centreModal").modal({ backdrop: "static", keyboard: false });
                if (typeof (table1) == "undefined") {
                    table1 = $("#staffTable").DataTable({
                        searching: true,
                        paging: true,
                        scrollY: 200,
                        scroller: true,
                        sortable: true,
                        scrollCollapse: false,
                        dom: 'rt<"bottom"i><"clear">'
                    });
                }
            },
            handleModalClose: function () {
                $("#centreModal").modal('hide');
                table1.destroy();
            },
            handleMessage: function (idx) {
                handleMessage(idx);
                $("#centreModal").modal('hide');
                table1.destroy();
            }
        }
    }());