aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2015-03-06 21:29:56 +0100
committerArthurHoaro <arthur@hoa.ro>2015-03-12 20:27:16 +0100
commitbdd1715b249561ed919e4f03a06aec1f4c327335 (patch)
treeeb21225e95b1fd849a8404c7bfe9bff6f970a8cb /index.php
parent3a10fa0e3f0d0978dc359d1407b93fe425f44b25 (diff)
downloadShaarli-bdd1715b249561ed919e4f03a06aec1f4c327335.tar.gz
Shaarli-bdd1715b249561ed919e4f03a06aec1f4c327335.tar.zst
Shaarli-bdd1715b249561ed919e4f03a06aec1f4c327335.zip
Use awesomplete as autocomplete lib and remove jQuery - shaarli/Shaarli#148
* Add awesomplete dependancy (source + min + CSS) * Remove jQuery and jQuery-UI dependancy * Few CSS ajustements * Use tags complete list as RainTPL var (and display it as HTML) * Remove "disable jQuery" feature * Remove tag list web service
Diffstat (limited to 'index.php')
-rw-r--r--index.php43
1 files changed, 3 insertions, 40 deletions
diff --git a/index.php b/index.php
index cda918df..83a54f86 100644
--- a/index.php
+++ b/index.php
@@ -1491,6 +1491,7 @@ function renderPage()
1491 $PAGE = new pageBuilder; 1491 $PAGE = new pageBuilder;
1492 $PAGE->assign('linkcount',count($LINKSDB)); 1492 $PAGE->assign('linkcount',count($LINKSDB));
1493 $PAGE->assign('token',getToken()); 1493 $PAGE->assign('token',getToken());
1494 $PAGE->assign('tags', $LINKSDB->allTags());
1494 $PAGE->renderPage('changetag'); 1495 $PAGE->renderPage('changetag');
1495 exit; 1496 exit;
1496 } 1497 }
@@ -1634,6 +1635,7 @@ function renderPage()
1634 $PAGE->assign('link_is_new',false); 1635 $PAGE->assign('link_is_new',false);
1635 $PAGE->assign('token',getToken()); // XSRF protection. 1636 $PAGE->assign('token',getToken()); // XSRF protection.
1636 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); 1637 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''));
1638 $PAGE->assign('tags', $LINKSDB->allTags());
1637 $PAGE->renderPage('editlink'); 1639 $PAGE->renderPage('editlink');
1638 exit; 1640 exit;
1639 } 1641 }
@@ -1705,6 +1707,7 @@ function renderPage()
1705 $PAGE->assign('link_is_new',$link_is_new); 1707 $PAGE->assign('link_is_new',$link_is_new);
1706 $PAGE->assign('token',getToken()); // XSRF protection. 1708 $PAGE->assign('token',getToken()); // XSRF protection.
1707 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '')); 1709 $PAGE->assign('http_referer',(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''));
1710 $PAGE->assign('tags', $LINKSDB->allTags());
1708 $PAGE->renderPage('editlink'); 1711 $PAGE->renderPage('editlink');
1709 exit; 1712 exit;
1710 } 1713 }
@@ -2309,45 +2312,6 @@ if (!function_exists('json_encode')) {
2309 } 2312 }
2310} 2313}
2311 2314
2312// Webservices (for use with jQuery/jQueryUI)
2313// e.g. index.php?ws=tags&term=minecr
2314function processWS()
2315{
2316 if (empty($_GET['ws']) || empty($_GET['term'])) return;
2317 $term = $_GET['term'];
2318 $LINKSDB=new linkdb(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI']); // Read links from database (and filter private links if used it not logged in).
2319 header('Content-Type: application/json; charset=utf-8');
2320
2321 // Search in tags (case insensitive, cumulative search)
2322 if ($_GET['ws']=='tags')
2323 {
2324 $tags=explode(' ',str_replace(',',' ',$term)); $last = array_pop($tags); // Get the last term ("a b c d" ==> "a b c", "d")
2325 $addtags=''; if ($tags) $addtags=implode(' ',$tags).' '; // We will pre-pend previous tags
2326 $suggested=array();
2327 /* To speed up things, we store list of tags in session */
2328 if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags();
2329 foreach($_SESSION['tags'] as $key=>$value)
2330 {
2331 if (startsWith($key,$last,$case=false) && !in_array($key,$tags)) $suggested[$addtags.$key.' ']=0;
2332 }
2333 echo json_encode(array_keys($suggested));
2334 exit;
2335 }
2336
2337 // Search a single tag (case sensitive, single tag search)
2338 if ($_GET['ws']=='singletag')
2339 {
2340 /* To speed up things, we store list of tags in session */
2341 if (empty($_SESSION['tags'])) $_SESSION['tags'] = $LINKSDB->allTags();
2342 foreach($_SESSION['tags'] as $key=>$value)
2343 {
2344 if (startsWith($key,$term,$case=true)) $suggested[$key]=0;
2345 }
2346 echo json_encode(array_keys($suggested));
2347 exit;
2348 }
2349}
2350
2351// Re-write configuration file according to globals. 2315// Re-write configuration file according to globals.
2352// Requires some $GLOBALS to be set (login,hash,salt,title). 2316// Requires some $GLOBALS to be set (login,hash,salt,title).
2353// If the config file cannot be saved, an error message is displayed and the user is redirected to "Tools" menu. 2317// If the config file cannot be saved, an error message is displayed and the user is redirected to "Tools" menu.
@@ -2604,7 +2568,6 @@ if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=r
2604if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } 2568if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; }
2605if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } 2569if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; }
2606if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; } 2570if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=daily')) { showDaily(); exit; }
2607if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'ws=')) { processWS(); exit; } // Webservices (for jQuery/jQueryUI)
2608if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; 2571if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE'];
2609renderPage(); 2572renderPage();
2610?> 2573?>