diff options
author | Vinzenz <vinzenz.rosenkranz@gmail.com> | 2016-09-06 20:11:20 +0300 |
---|---|---|
committer | Vinzenz <vinzenz.rosenkranz@gmail.com> | 2016-09-06 20:11:20 +0300 |
commit | f5fadde9e27795a3d48a8101d24135bc50e445a2 (patch) | |
tree | 04771ada44f18c693846d42eafc336c2b2f94af8 /js | |
parent | 4f9dcded6140ea317476cecc45dc127f99e0b53e (diff) |
only display groups based on search string
Diffstat (limited to 'js')
-rw-r--r-- | js/create_edit.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/js/create_edit.js b/js/create_edit.js index ca07ecc2..74cef561 100644 --- a/js/create_edit.js +++ b/js/create_edit.js @@ -242,6 +242,48 @@ $(document).ready(function () { } }); + $('#group-search-box').on('input', function() { + var val = $(this).val(); + if(val.length < 3) return; + var groupUl = document.getElementById('live-search-list-group-id'); + while(groupUl.firstChild) { + groupUl.removeChild(groupUl.firstChild); + } + $.post(OC.generateUrl('/apps/polls/search/groups'), { searchTerm: val }, function(data) { + for(var i=0; i<data.length; i++) { + var gid = data[i]; + var li = document.createElement('li'); + li.setAttribute('id', 'group_' + gid); + li.setAttribute('class', 'cl_group_item cl_access_item'); + li.appendChild(document.createTextNode(gid)); + groupUl.appendChild(li); + } + }); + }); + + $('#user-search-box').on('input', function() { + var val = $(this).val(); + if(val.length < 3) return; + var userUl = document.getElementById('live-search-list-user-id'); + while(userUl.firstChild) { + userUl.removeChild(userUl.firstChild); + } + $.post(OC.generateUrl('/apps/polls/search/users'), { searchTerm: val }, function(data) { + for(var i=0; i<data.length; i++) { + var user = data[i]; + var li = document.createElement('li'); + var span = document.createElement('span'); + li.setAttribute('id', 'user_' + user.uid); + li.setAttribute('class', 'cl_user_item cl_access_item'); + li.appendChild(document.createTextNode(user.displayName)); + span.setAttribute('id', 'sec_name'); + span.appendChild(document.createTextNode(user.uid)); + li.appendChild(span); + userUl.appendChild(li); + } + }); + }); + $('.live-search-list-user li').each(function(){ $(this).attr('data-search-term', $(this).text().toLowerCase()); }); |