aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl/editlink.html
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2015-07-08 16:28:31 +0200
committerArthurHoaro <arthur@hoa.ro>2015-07-12 10:34:29 +0200
commit781e8aadea7590dc87b61915b6e65ec52f7d250e (patch)
tree75cd698987e2d73ae050135a7fde15ceb7e6880e /tpl/editlink.html
parenteee711c0a8583e1c2ea2186544795d59fa41d9f6 (diff)
downloadShaarli-781e8aadea7590dc87b61915b6e65ec52f7d250e.tar.gz
Shaarli-781e8aadea7590dc87b61915b6e65ec52f7d250e.tar.zst
Shaarli-781e8aadea7590dc87b61915b6e65ec52f7d250e.zip
Avoid tag duplicates
* Prevent duplicate client side with awesomplete * Prevent duplicate server side (save_edit processing) Fixes #261
Diffstat (limited to 'tpl/editlink.html')
-rw-r--r--tpl/editlink.html24
1 files changed, 23 insertions, 1 deletions
diff --git a/tpl/editlink.html b/tpl/editlink.html
index a32748ab..3733ca21 100644
--- a/tpl/editlink.html
+++ b/tpl/editlink.html
@@ -42,7 +42,7 @@
42{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn())"} 42{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn())"}
43<script> 43<script>
44 $ = Awesomplete.$; 44 $ = Awesomplete.$;
45 new Awesomplete($('input[data-multiple]'), { 45 awesomplete = new Awesomplete($('input[data-multiple]'), {
46 filter: function(text, input) { 46 filter: function(text, input) {
47 return Awesomplete.FILTER_CONTAINS(text, input.match(/[^ ]*$/)[0]); 47 return Awesomplete.FILTER_CONTAINS(text, input.match(/[^ ]*$/)[0]);
48 }, 48 },
@@ -52,6 +52,28 @@
52 }, 52 },
53 minChars: 1 53 minChars: 1
54 }); 54 });
55
56 /**
57 * Remove already selected items from autocompletion list.
58 * HTML list is never updated, so removing a tag will add it back to awesomplete.
59 *
60 * FIXME: This a workaround waiting for awesomplete to handle this.
61 * https://github.com/LeaVerou/awesomplete/issues/16749
62 */
63 var input = document.querySelector('#lf_tags');
64 input.addEventListener('input', function()
65 {
66 proposedTags = input.getAttribute('data-list').replace(/,/g, '').split(' ');
67 reg = /(\w+) /g;
68 while((match = reg.exec(input.value)) !== null) {
69 id = proposedTags.indexOf(match[1]);
70 if(id != -1 ) {
71 proposedTags.splice(id, 1);
72 }
73 }
74
75 awesomplete.list = proposedTags;
76 });
55</script> 77</script>
56{/if} 78{/if}
57</body> 79</body>