diff --git a/resources/report/css/style.css b/resources/report/css/style.css index 54771b3a..faf160c2 100644 --- a/resources/report/css/style.css +++ b/resources/report/css/style.css @@ -66,6 +66,9 @@ paper-item > a { left: 0; right: 0; } +#searchBox { + display: block; +} #container { position: fixed; top: 64px; diff --git a/resources/report/js/script.js b/resources/report/js/script.js index c576b592..1173c037 100644 --- a/resources/report/js/script.js +++ b/resources/report/js/script.js @@ -522,6 +522,28 @@ function applyFilters(evt) { document.getElementById('hiddenPluginNo').textContent = hiddenPluginNo; }); } + +function searchFilter(plugins) { + var search = document.getElementById('searchBox').value.toLowerCase(); + if (search.length > 0) { + var hiddenPluginNo = 0; + var hiddenMessageNo = 0; + var filteredPlugins = []; + /* Check each plugin entry to see if the current search string exists in + its name, version, crc, Bash Tag or message strings. */ + for (var i = 0; i < plugins.length; ++i) { + if (plugins[i].name.toLowerCase().indexOf(search) != -1 + || plugins[i].getCrcString().toLowerCase().indexOf(search) != -1) { + filteredPlugins.push(plugins[i]); + } + } + + return filteredPlugins; + } else { + return plugins; + } +} + function showMessageDialog(title, text, yesNo, closeCallback) { var dialog = document.createElement('loot-message-dialog'); if (yesNo) { @@ -982,34 +1004,9 @@ function showSettingsDialog(evt) { document.getElementById('settingsDialog').showModal(); } -function startSearch(evt) { - var findNext = false; - if (evt.type == 'keyup') { - if (evt.keyCode != 13) { - // Don't do anything for keyboard events that aren't enter - if valid, the input event will handle them. - return; - } else { - findNext = true; - } - } - if (evt.target.inputValue == '') { - loot.query('cancelFind').then(function(result){ - evt.target.focus(); - }).catch(processCefError); - } else { - var request = JSON.stringify({ - name: 'find', - args: [ - evt.target.value, - findNext - ] - }); - - loot.query(request).then(function(result){ - evt.target.focus(); - }).catch(processCefError); - } - +function handleSearch(evt) { + document.getElementById('cardsNav').lastElementChild.data = searchFilter(loot.game.plugins); + document.getElementById('main').lastElementChild.data = searchFilter(loot.game.plugins); } function focusSearch(evt) { if (evt.ctrlKey && evt.keyCode == 70) { //'f' @@ -1229,9 +1226,7 @@ function setupEventHandlers() { settings.getElementsByClassName('cancel')[0].addEventListener('click', closeSettingsDialog, false); /* Set up event handlers for content search. */ - var searchBox = document.getElementById('searchBox'); - searchBox.addEventListener('input', startSearch, false); - searchBox.addEventListener('keyup', startSearch, false); + document.getElementById('searchBox').addEventListener('change', handleSearch, false); window.addEventListener('keyup', focusSearch, false); /* Set up handler for opening and closing editors. */ diff --git a/resources/report/report.html b/resources/report/report.html index 6b2cd1e1..1f02b43c 100644 --- a/resources/report/report.html +++ b/resources/report/report.html @@ -28,7 +28,6 @@ - @@ -139,10 +138,8 @@ - - - - + +
diff --git a/src/gui/handler.cpp b/src/gui/handler.cpp index 7bf9e033..8d70d448 100644 --- a/src/gui/handler.cpp +++ b/src/gui/handler.cpp @@ -196,19 +196,7 @@ namespace loot { CefRefPtr callback) { const string requestName = request["name"].as(); - if (requestName == "find") { - // Has one arg, which is the search string. - try { - Find(browser, request["args"][0].as(), request["args"][1].as()); - callback->Success(""); - } - catch (std::exception& e) { - BOOST_LOG_TRIVIAL(error) << "Failed to perform search. Details: " << e.what(); - callback->Failure(-1, string("Failed to perform search. Details: ") + e.what()); - } - return true; - } - else if (requestName == "changeGame") { + if (requestName == "changeGame") { try { // Has one arg, which is the folder name of the new game. g_app_state.ChangeGame(request["args"][0].as()); @@ -340,13 +328,6 @@ namespace loot { return false; } - void Handler::Find(CefRefPtr browser, const std::string& search, bool findNext) { - // Only one search at a time is allowed, so give a constant identifier, - // and we want case-insensitive forward searching, with no repeated - // searches. - browser->GetHost()->Find(0, search, true, false, findNext); - } - void Handler::GetConflictingPlugins(const std::string& pluginName, CefRefPtr frame, CefRefPtr callback) { BOOST_LOG_TRIVIAL(debug) << "Searching for plugins that conflict with " << pluginName; diff --git a/src/gui/handler.h b/src/gui/handler.h index 60a3cccf..69d3fd7f 100644 --- a/src/gui/handler.h +++ b/src/gui/handler.h @@ -66,7 +66,6 @@ namespace loot { YAML::Node& request, CefRefPtr callback); - void Find(CefRefPtr browser, const std::string& search, bool findNext); void GetConflictingPlugins(const std::string& pluginName, CefRefPtr frame, CefRefPtr callback); void CopyMetadata(const std::string& pluginName); std::string ClearPluginMetadata(const std::string& pluginName);