(function ($, document, window) { var query = { StartIndex: 0, Limit: 100000 }; var currentResult; function reloadList(page) { Dashboard.showLoadingMsg(); ApiClient.getSmartMatchInfos(query).done(function (infos) { currentResult = infos; populateList(page, infos); Dashboard.hideLoadingMsg(); }); } function populateList(page, result) { var infos = result.Items; if (infos.length > 0) { infos = infos.sort(function (a, b) { a = a.OrganizerType + " " + a.Name; b = b.OrganizerType + " " + b.Name; if (a == b) { return 0; } if (a < b) { return -1; } return 1; }); } var html = ""; var currentType; for (var i = 0, length = infos.length; i < length; i++) { var info = infos[i]; if (info.OrganizerType != currentType) { currentType = info.OrganizerType; if (html.length > 0) { html += ""; } html += "

" + currentType + "

"; html += '"; $('.divMatchInfos', page).html(html).trigger('create'); } $(document).on('pageinit', "#libraryFileOrganizerSmartMatchPage", function () { var page = this; $('.divMatchInfos', page).on('click', '.btnDeleteMatchEntry', function () { var button = this; var id = button.getAttribute('data-id'); var options = { MatchString: button.getAttribute('data-matchstring') }; ApiClient.deleteSmartMatchEntry(id, options).done(function () { reloadList(page); }); }); }).on('pageshowready', "#libraryFileOrganizerSmartMatchPage", function () { var page = this; Dashboard.showLoadingMsg(); reloadList(page); }).on('pagebeforehide', "#libraryFileOrganizerSmartMatchPage", function () { var page = this; currentResult = null; }); })(jQuery, document, window);