Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2019-01-05 02:45:44 +0300
committernachoparker <nacho@ownyourbits.com>2019-01-05 04:14:53 +0300
commitb1089418be6fd1c3cbbd8e28bd20f85787f749a9 (patch)
treef3f3b624ffb0ac73c0795189da2d0d258bbda72e /ncp-web
parent388fa77b374ffe673c20896178a7fc5b864ea8c1 (diff)
apply search filter upon reload sidebar
Diffstat (limited to 'ncp-web')
-rw-r--r--ncp-web/js/ncp.js67
1 files changed, 35 insertions, 32 deletions
diff --git a/ncp-web/js/ncp.js b/ncp-web/js/ncp.js
index 2b4a9ae5..4a5d1789 100644
--- a/ncp-web/js/ncp.js
+++ b/ncp-web/js/ncp.js
@@ -10,6 +10,8 @@
var MINI = require('minified');
var $ = MINI.$, $$ = MINI.$$, EE = MINI.EE;
var selectedID = null;
+var ncp_app_list = null;
+var search_box = null;
var lock = false;
// URL based navigation
@@ -121,15 +123,16 @@ function print_dashboard()
$('#loading-info-gif').hide();
$('#dashboard-table').ht( ret.table );
$('#dashboard-suggestions').ht( ret.suggestions );
- //reload_sidebar(); // TODO
+ reload_sidebar();
} ).error( errorMsg );
}
function reload_sidebar()
{
// request
- $.request('post', 'ncp-launcher.php', { action:'sidebar',
- csrf_token: $( '#csrf-token-ui' ).get( '.value' ) }).then(
+ $.request('post', 'ncp-launcher.php', { action:'sidebar',
+ csrf_token: $('#csrf-token-ui').get('.value') }
+ ).then(
function success( result )
{
var ret = $.parseJSON( result );
@@ -139,12 +142,37 @@ function reload_sidebar()
$('#ncp-options').ht( ret.output );
set_sidebar_click_handlers();
- //var ncp_app_list = $('.ncp-app-list-item');
- //filter_apps(); // TODO
+ ncp_app_list = $('.ncp-app-list-item');
+ filter_apps();
}
}).error( errorMsg );
}
+function filter_apps(e)
+{
+ if (e && e.key === 'Enter')
+ {
+ var match = ncp_app_list.find(function(app) { if (app.id.indexOf(search_box.value) !== -1) return app; });
+ if (!match) return;
+ app_clicked($('#' + match.id));
+ ncp_app_list.show();
+ search_box.value = '';
+ var input = $$('#' + match.id + '-config-box input');
+ input.focus();
+ input.selectionStart = input.selectionEnd = input.value.length;
+ $('#search-box').animate( {$width: '0px'}, 150 ).then(function() { $('#search-box').hide(); });
+ history.pushState(null, selectedID, "?app=" + selectedID);
+ return;
+ }
+
+ ncp_app_list.hide();
+ ncp_app_list.each( function(app){
+ if (app.id.indexOf(search_box.value) !== -1)
+ app.style.display = 'block';
+ }
+ );
+}
+
function app_clicked(item)
{
$('.details-box').hide();
@@ -281,7 +309,7 @@ $(function()
// request
$.request('post', 'ncp-launcher.php', { action:'path-exists',
value: this.get('.value'),
- csrf_token: $( '#csrf-token-cfg' ).get( '.value' ) }).then(
+ csrf_token: $('#csrf-token-cfg').get('.value') }).then(
function success( result )
{
var ret = $.parseJSON( result );
@@ -442,32 +470,7 @@ $(function()
} );
// search box
- function filter_apps(e)
- {
- if (e.key === 'Enter')
- {
- var match = ncp_app_list.find(function(app) { if (app.id.indexOf(search_box.value) !== -1) return app; });
- if (!match) return;
- app_clicked($('#' + match.id));
- ncp_app_list.show();
- search_box.value = '';
- var input = $$('#' + match.id + '-config-box input');
- input.focus();
- input.selectionStart = input.selectionEnd = input.value.length;
- $('#search-box').animate( {$width: '0px'}, 150 ).then(function() { $('#search-box').hide(); });
- history.pushState(null, selectedID, "?app=" + selectedID);
- return;
- }
-
- ncp_app_list.hide();
- ncp_app_list.each( function(app){
- if (app.id.indexOf(search_box.value) !== -1)
- app.style.display = 'block';
- }
- );
- }
-
- var search_box = $$('#search-box');
+ search_box = $$('#search-box');
ncp_app_list = $('.ncp-app-list-item');
$('#search-box').on('|keyup', filter_apps );
$('#search-box').on('|blur', function(e) {