aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--index.php9
-rw-r--r--tpl/editlink.html24
2 files changed, 28 insertions, 5 deletions
diff --git a/index.php b/index.php
index bbe302a6..87d9116a 100644
--- a/index.php
+++ b/index.php
@@ -709,7 +709,7 @@ function showRSS()
709 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); 709 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
710 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); 710 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
711 else $linksToDisplay = $LINKSDB; 711 else $linksToDisplay = $LINKSDB;
712 712
713 $nblinksToDisplay = 50; // Number of links to display. 713 $nblinksToDisplay = 50; // Number of links to display.
714 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. 714 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
715 { 715 {
@@ -789,7 +789,7 @@ function showATOM()
789 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']); 789 if (!empty($_GET['searchterm'])) $linksToDisplay = $LINKSDB->filterFulltext($_GET['searchterm']);
790 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags'])); 790 else if (!empty($_GET['searchtags'])) $linksToDisplay = $LINKSDB->filterTags(trim($_GET['searchtags']));
791 else $linksToDisplay = $LINKSDB; 791 else $linksToDisplay = $LINKSDB;
792 792
793 $nblinksToDisplay = 50; // Number of links to display. 793 $nblinksToDisplay = 50; // Number of links to display.
794 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links. 794 if (!empty($_GET['nb'])) // In URL, you can specificy the number of links. Example: nb=200 or nb=all for all links.
795 { 795 {
@@ -1041,7 +1041,7 @@ function renderPage()
1041 if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']); 1041 if (!empty($_GET['searchterm'])) $links = $LINKSDB->filterFulltext($_GET['searchterm']);
1042 elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags'])); 1042 elseif (!empty($_GET['searchtags'])) $links = $LINKSDB->filterTags(trim($_GET['searchtags']));
1043 else $links = $LINKSDB; 1043 else $links = $LINKSDB;
1044 1044
1045 $body=''; 1045 $body='';
1046 $linksToDisplay=array(); 1046 $linksToDisplay=array();
1047 1047
@@ -1056,7 +1056,7 @@ function renderPage()
1056 $linksToDisplay[]=$link; // Add to array. 1056 $linksToDisplay[]=$link; // Add to array.
1057 } 1057 }
1058 } 1058 }
1059 1059
1060 $PAGE = new pageBuilder; 1060 $PAGE = new pageBuilder;
1061 $PAGE->assign('linkcount',count($LINKSDB)); 1061 $PAGE->assign('linkcount',count($LINKSDB));
1062 $PAGE->assign('linksToDisplay',$linksToDisplay); 1062 $PAGE->assign('linksToDisplay',$linksToDisplay);
@@ -1330,6 +1330,7 @@ function renderPage()
1330 { 1330 {
1331 if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away! 1331 if (!tokenOk($_POST['token'])) die('Wrong token.'); // Go away!
1332 $tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces. 1332 $tags = trim(preg_replace('/\s\s+/',' ', $_POST['lf_tags'])); // Remove multiple spaces.
1333 $tags = implode(' ', array_unique(explode(' ', $tags))); // Remove duplicates.
1333 $linkdate=$_POST['lf_linkdate']; 1334 $linkdate=$_POST['lf_linkdate'];
1334 $url = trim($_POST['lf_url']); 1335 $url = trim($_POST['lf_url']);
1335 if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?') && !startsWith($url,'javascript:')) 1336 if (!startsWith($url,'http:') && !startsWith($url,'https:') && !startsWith($url,'ftp:') && !startsWith($url,'magnet:') && !startsWith($url,'?') && !startsWith($url,'javascript:'))
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>