From 8c7b36fecae17a7b07348a8e2f12c7ac473033d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20Ro=20M=C3=B8ltoft=20Christensen?= Date: Sat, 21 Jan 2017 16:10:55 +0100 Subject: [PATCH] Counter when searching is now getting updated. It's also possible to use ENTER when focusing the search input (Will call search func). --- http/modules/install/jscript/install.js | 38 +++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/http/modules/install/jscript/install.js b/http/modules/install/jscript/install.js index 0a6bff5..980f7db 100644 --- a/http/modules/install/jscript/install.js +++ b/http/modules/install/jscript/install.js @@ -56,7 +56,7 @@ install.start = function() { var submenu = ['', '', - '', + '', '', '', '', @@ -90,7 +90,14 @@ install.start = function() { ], function() { // Finally, loadchannels - install.loadChannels(true); + install.loadChannels(true); + + //on ENTER pressed when focusing the search input -> Search + $("#search").on('keyup', function (e) { + if (e.keyCode == 13) { + install.search_apps(); + } + }); }) launcher.start(); @@ -124,12 +131,31 @@ install.search_apps = function () { tempArray = webtools.searchBundle(tempArray, searchValue); + //Resseting total amount and installed amount + for (var categorykey in install.categories) { + install.categories[categorykey].total = 0; + install.categories[categorykey].installed = 0; + } + install.allBundles = {}; tempArray.forEach(function (object) { var tempkey = object.key; delete object.key; install.allBundles[tempkey] = object; - }) + + object.type.forEach(function (categorykey) { + if (object.date !== "") install.categories[categorykey].installed++; //Puhaa.. It's getting better with 3.0... + install.categories[categorykey].total++ + }); + }); + + //Again. This can be done way easier with ang. + //Getting each category and finding the installed and total span. + for (var categorykey in install.categories) { + $("#" + categorykey.trim().replace(' ', '')).find("#categoriesInstalled").text(install.categories[categorykey].installed); + $("#" + categorykey.trim().replace(' ', '')).find("#categoriesTotal").text(install.categories[categorykey].total); + } + install.showChannels($('#channelmenu>button.btn-active'), $('#channelmenu>button.btn-active').attr('id')); } @@ -286,7 +312,7 @@ install.loadChannels = function (InitalRun) { type: 'GET', success: function(data) { - install.categories = data; + install.categories = data; //install.categories.sort(); callback(); }, @@ -312,9 +338,9 @@ install.loadChannels = function (InitalRun) { for (var categorykey in install.categories) { if ((install.categories[categorykey].installed > 0) || (install.showOnlyInstalled === false)) { if ((typeof(elementToHighlight) == 'undefined') && (categorykey.trim() == 'Application')) { - menu += ' ' + menu += ' ' } else { - menu += ' ' + menu += ' ' } } }