
        function InitDatatable() {
            $('#datatable-1').on('xhr.dt', function (e, settings, json) {
                if (typeof (json.data) == 'object' && json.data.length >0) {
                    var date;
                    for (var i in json.data) {
                        {% if attribute(app, 'ownKeyTranslate') is defined %}
                        if (json.data[i]['license_key'] == '{{ app.ownKeyTranslate.key }}') {
                            json.data[i]['license_key'] = '{{ app.ownKeyTranslate.translate }}';
                        }
                        {% endif %}
                        date = json.data[i]['added'];
                        if (date > 0) {
                            date = new Date(date * 1000);
                            json.data[i]['added'] = date.toLocaleFormat("%b %d, %Y %H:%M");
                        }

                        {% if attribute(app, 'current_user_id') is not defined %}
                        json.data[i].operations = "<div class='col-xs-3 col-sm-8'>\n\
                                                        <a href='#' class='dropdown-toggle no_context_menu' data-toggle='dropdown'>\n\
                                                            <i class='pull-right fa fa-cog'></i>\n\
                                                        </a>\n\
                                                        <ul class='dropdown-menu pull-right'>\n\
                                                            <li>\n\
                                                                <a href='{{ app.request_context.baseUrl }}/users/edit-users?id=" + json.data[i]['user_id'] + "'>\n\
                                                                    <span>{{ 'Show current user'|trans }}</span>\n\
                                                                </a>\n\
                                                            </li>\n\
                                                            <li>\n\
                                                                <a href='{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/{{ app.action_alias }}?user_id=" + json.data[i]['user_id'] + "'>\n\
                                                                    <span>{{ 'Show current user\'s devices'|trans }}</span>\n\
                                                                </a>\n\
                                                            </li>\n\
                                                        </ul>\n\
                                                    </div>";
                        {% endif %}
                        json.data[i]['user_id'] = '<a href="{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/{{ app.action_alias }}?user_id=' + json.data[i]['user_id'] + '">'+ json.data[i]['user_id'] +'</a>';
                    }
                }
            }).dataTable({
                "processing": true,
                "serverSide": true,
                "ajax": {
                    "url": "{{ app.request_context.baseUrl }}/{{ app.controller_alias }}/stat-users-devices-json"
                },
                "language": {
                    "url": "{{ app.datatable_lang_file }}"
                },
                {% if attribute(app, 'dropdownAttribute') is defined %}
                {{ main_macro.get_datatable_column(app['dropdownAttribute']) }}
                {% endif %}
                "bFilter": true,
                "bPaginate": true,
                "lengthChange": true,
                "bInfo": true,

                "fixedHeader": {
                    header: true,
                    headerOffset: $('header.navbar').height()
                },

                "aoColumnDefs": [
                    {% if attribute(app, 'current_user_id') is not defined %}
                    {"searchable": false, "targets": [-1, -2]},
                    {"sortable": false, "targets": [-1]},
                    {className: "action-menu", "targets": [-1]}
                    {% else %}
                    {"searchable": false, "targets": [-1]},
                    {% endif %}
                ]
            }).prev('.dataTables_processing').hide();
        }

        function yelp() {
            $(document).ready(function () {
                LoadDataTablesScripts(InitDatatable);
            });
        }

        document.addEventListener("DOMContentLoaded", yelp, false);
