From 858c5c2b43ce16f6d4b388725ef2d7a95e4a1986 Mon Sep 17 00:00:00 2001 From: Sebastien SAUVAGE Date: Fri, 1 Mar 2013 22:21:10 +0100 Subject: Added option to disable jQuery and heavy javascript Shaarli uses light Javascript in its normal operation, and some jQuery for some features (autocomplete in tags, QR-Code popup...). jQuery can be slow on small computers. An option has been added in configuration screen to disable javascript features which are hard on CPU. (Note that the Picture Wall is awfully heavy *without* jQuery.) (Side note: A *LOT* of users want Shaarli to work without javasript at all, if possible. That's why I try to use as few javascript as possible: It keeps Shaarli pages fast.) --- index.php | 17 ++++++++++++----- tpl/configure.html | 17 +++++++++++++---- tpl/includes.html | 2 +- tpl/linklist.html | 5 ++++- tpl/page.footer.html | 2 +- tpl/picwall.html | 6 +++++- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/index.php b/index.php index f84ec17f..8a456357 100644 --- a/index.php +++ b/index.php @@ -96,6 +96,8 @@ require $GLOBALS['config']['CONFIG_FILE']; // Read login/password hash into $GL if (empty($GLOBALS['title'])) $GLOBALS['title']='Shared links on '.htmlspecialchars(indexUrl()); if (empty($GLOBALS['timezone'])) $GLOBALS['timezone']=date_default_timezone_get(); if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false; +if (empty($GLOBALS['disablejquery'])) $GLOBALS['disablejquery']=false; +// I really need to rewrite Shaarli with a proper configuation manager. autoLocale(); // Sniff browser language and set date format accordingly. header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper international characters handling. @@ -1350,6 +1352,7 @@ function renderPage() $GLOBALS['title']=$_POST['title']; $GLOBALS['redirector']=$_POST['redirector']; $GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']); + $GLOBALS['disablejquery']=!empty($_POST['disablejquery']); writeConfig(); echo ''; exit; @@ -1951,6 +1954,11 @@ function lazyThumbnail($url,$href=false) $html=''; // Lazy image (only loaded by javascript when in the viewport). + if (!empty($GLOBALS['disablejquery'])) // (except if jQuery is disabled) + $html.=''.$continent.''; $cities_html = $cities[$pcontinent]; - $timezone_form = "Continent:

"; - $timezone_form .= "City:

"; + $timezone_form = "Continent: "; + $timezone_form .= "    City:
"; $timezone_js = " +{if="empty($GLOBALS['disablejquery'])"}{/if} diff --git a/tpl/linklist.html b/tpl/linklist.html index 45bd478f..3a703512 100644 --- a/tpl/linklist.html +++ b/tpl/linklist.html @@ -48,7 +48,8 @@ {else}
permalink - {/if} -
- +
- {$value.url|htmlspecialchars}
{if="$value.tags"}
@@ -65,6 +66,7 @@
{include="page.footer"} +{if="empty($GLOBALS['disablejquery'])"} +{/if} \ No newline at end of file diff --git a/tpl/page.footer.html b/tpl/page.footer.html index 7fe15017..13b566ae 100644 --- a/tpl/page.footer.html +++ b/tpl/page.footer.html @@ -8,7 +8,7 @@ {/if} -{if="$GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()"} +{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"} +{if="empty($GLOBALS['disablejquery'])"} + +{/if} @@ -16,9 +18,11 @@ {include="page.footer"} +{if="empty($GLOBALS['disablejquery'])"} +{/if} \ No newline at end of file -- cgit v1.2.3