(function () { function deleteDevice(page, id) { var msg = Globalize.translate('DeleteDeviceConfirmation'); Dashboard.confirm(msg, Globalize.translate('HeaderDeleteDevice'), function (result) { if (result) { Dashboard.showLoadingMsg(); ApiClient.ajax({ type: "DELETE", url: ApiClient.getUrl('Devices', { Id: id }) }).done(function () { loadData(page); }); } }); } function load(page, devices) { var html = ''; if (devices.length) { html += '
'; } html += devices.map(function (d) { var deviceHtml = ''; deviceHtml += ''; deviceHtml += ''; deviceHtml += ''; deviceHtml += ''; deviceHtml += '
'; deviceHtml += d.Name; deviceHtml += '
'; if (d.AppName) { deviceHtml += '
'; deviceHtml += d.AppName; deviceHtml += '
'; } if (d.LastUserName) { deviceHtml += '
'; deviceHtml += Globalize.translate('DeviceLastUsedByUserName', d.LastUserName); deviceHtml += '
'; } deviceHtml += '
'; deviceHtml += '
'; deviceHtml += ''; deviceHtml += '
'; return deviceHtml; }).join(''); if (devices.length) { html += '
'; } var elem = $('.devicesList', page).html(html).trigger('create'); $('.btnDeleteDevice', elem).on('click', function () { deleteDevice(page, this.getAttribute('data-id')); }); } function loadData(page) { Dashboard.showLoadingMsg(); ApiClient.getJSON(ApiClient.getUrl('Devices', { SupportsPersistentIdentifier: true })).done(function (result) { load(page, result.Items); Dashboard.hideLoadingMsg(); }); } $(document).on('pageshow', "#devicesPage", function () { var page = this; loadData(page); }); })();