From b9b41d25e319f44f9fb8259a0237a8ee81ad394b Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 12 Mar 2017 12:45:32 +0100 Subject: Remove inline JS and add LibreJS headers in JS files Fixes #33 (wow!) Relates to #395 --- COPYING | 4 + inc/awesomplete-multiple-tags.js | 28 +++++++ inc/plugin_admin.js | 28 +++++++ plugins/piwik/piwik.html | 28 +++++++ plugins/playvideos/youtube_playlist.js | 28 +++++++ plugins/qrcode/shaarli-qrcode.js | 28 +++++++ tpl/default/configure.html | 13 ---- tpl/default/editlink.html | 28 ++----- tpl/default/install.html | 13 ---- tpl/default/js/shaarli.js | 130 ++++++++++++++++++++++++++++++++- tpl/default/loginform.html | 11 +-- tpl/default/picwall.html | 5 -- tpl/default/pluginsadmin.html | 10 +-- tpl/default/tools.html | 42 ++--------- 14 files changed, 286 insertions(+), 110 deletions(-) diff --git a/COPYING b/COPYING index 4bbdf2b3..05202152 100644 --- a/COPYING +++ b/COPYING @@ -46,6 +46,10 @@ Files: plugins/wallabag/wallabag.png License: MIT License (http://opensource.org/licenses/MIT) Copyright: (C) 2015 Nicolas Lœuillet - https://github.com/wallabag/wallabag +Files: tpl/default/sad_star.png +License: MIT License (http://opensource.org/licenses/MIT) +Copyright: (C) 2015 kalvn - https://github.com/kalvn/Shaarli-Material + ---------------------------------------------------- ZLIB/LIBPNG LICENSE diff --git a/inc/awesomplete-multiple-tags.js b/inc/awesomplete-multiple-tags.js index faecb417..c38dc38e 100644 --- a/inc/awesomplete-multiple-tags.js +++ b/inc/awesomplete-multiple-tags.js @@ -1,3 +1,31 @@ +/** @licstart The following is the entire license notice for the + * JavaScript code in this page. + * + * Copyright: (c) 2011-2015 Sébastien SAUVAGE + * (c) 2011-2017 The Shaarli Community, see AUTHORS + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would + * be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must + * not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * @licend The above is the entire license notice + * for the JavaScript code in this page. + */ + var awp = Awesomplete.$; var autocompleteFields = document.querySelectorAll('input[data-multiple]'); [].forEach.call(autocompleteFields, function(autocompleteField) { diff --git a/inc/plugin_admin.js b/inc/plugin_admin.js index 055ac285..4b55e0f3 100644 --- a/inc/plugin_admin.js +++ b/inc/plugin_admin.js @@ -1,3 +1,31 @@ +/** @licstart The following is the entire license notice for the + * JavaScript code in this page. + * + * Copyright: (c) 2011-2015 Sébastien SAUVAGE + * (c) 2011-2017 The Shaarli Community, see AUTHORS + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would + * be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must + * not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * @licend The above is the entire license notice + * for the JavaScript code in this page. + */ + /** * Change the position counter of a row. * diff --git a/plugins/piwik/piwik.html b/plugins/piwik/piwik.html index 0881d7c8..f4bc358a 100644 --- a/plugins/piwik/piwik.html +++ b/plugins/piwik/piwik.html @@ -1,5 +1,33 @@ diff --git a/tpl/default/editlink.html b/tpl/default/editlink.html index 2180c080..491f1da0 100644 --- a/tpl/default/editlink.html +++ b/tpl/default/editlink.html @@ -4,11 +4,7 @@ {include="includes"} - {if="$source !== 'firefoxsocialapi' && $source !== 'bookmarklet'"} - {include="page.header"} - {else} -
Shaare to: {$shaarlititle}
- {/if} + {include="page.header"}
@@ -21,25 +17,25 @@
- +
- +
- +
-
@@ -74,18 +70,6 @@ {/if} - {if="$source !== 'firefoxsocialapi' && $source !== 'bookmarklet'"} - {include="page.footer"} - {/if} - + {include="page.footer"} diff --git a/tpl/default/install.html b/tpl/default/install.html index 0bd8a635..33f8a453 100644 --- a/tpl/default/install.html +++ b/tpl/default/install.html @@ -105,18 +105,5 @@ {include="page.footer"} - diff --git a/tpl/default/js/shaarli.js b/tpl/default/js/shaarli.js index f7de0a49..30d8ed6f 100644 --- a/tpl/default/js/shaarli.js +++ b/tpl/default/js/shaarli.js @@ -1,3 +1,31 @@ +/** @licstart The following is the entire license notice for the + * JavaScript code in this page. + * + * Copyright: (c) 2011-2015 Sébastien SAUVAGE + * (c) 2011-2017 The Shaarli Community, see AUTHORS + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would + * be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must + * not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source distribution. + * + * @licend The above is the entire license notice + * for the JavaScript code in this page. + */ + window.onload = function () { /** @@ -185,9 +213,13 @@ window.onload = function () { /** * Autofocus text fields */ - var autofocusElements = document.querySelector('.autofocus'); - if (autofocusElements != null) { - autofocusElements.focus(); + // ES6 syntax + let autofocusElements = document.querySelectorAll('.autofocus'); + for (let autofocusElement of autofocusElements) { + if (autofocusElement.value == '') { + autofocusElement.focus(); + break; + } } /** @@ -266,4 +298,96 @@ window.onload = function () { } }); } + + /** + * TimeZome select + * FIXME! way too hackish + */ + var toRemove = document.getElementById('timezone-remove'); + if (toRemove != null) { + var firstSelect = toRemove.getElementsByTagName('select')[0]; + var secondSelect = toRemove.getElementsByTagName('select')[1]; + toRemove.parentNode.removeChild(toRemove); + var toAdd = document.getElementById('timezone-add'); + var newTimezone = 'Continent ' + firstSelect.outerHTML + ''; + newTimezone += ' Country ' + secondSelect.outerHTML + ''; + toAdd.innerHTML = newTimezone; + } + + /** + * Awesomplete trigger. + */ + var tags = document.getElementById('lf_tags'); + if (tags != null) { + awesompleteUniqueTag('#lf_tags'); + } + + /** + * bLazy trigger + */ + var picwall = document.getElementById('picwall_container'); + if (picwall != null) { + var bLazy = new Blazy(); + } + + /** + * Bookmarklet alert + */ + var bookmarkletLinks = document.querySelectorAll('.bookmarklet-link'); + var bkmMessage = document.getElementById('bookmarklet-alert'); + [].forEach.call(bookmarkletLinks, function(link) { + link.addEventListener('click', function(event) { + event.preventDefault(); + alert(bkmMessage.value); + }); + }); + + /** + * Firefox Social + */ + var ffButton = document.getElementById('ff-social-button'); + if (ffButton != null) { + ffButton.addEventListener('click', function(event) { + activateFirefoxSocial(event.target); + }); + } + + /** + * Plugin admin order + */ + var orderPA = document.querySelectorAll('.order'); + [].forEach.call(orderPA, function(link) { + link.addEventListener('click', function(event) { + event.preventDefault(); + if (event.target.classList.contains('order-up')) { + return orderUp(event.target.parentNode.parentNode.getAttribute('data-order')); + } else if (event.target.classList.contains('order-down')) { + return orderDown(event.target.parentNode.parentNode.getAttribute('data-order')); + } + }); + }); }; + +function activateFirefoxSocial(node) { + var loc = location.href; + var baseURL = loc.substring(0, loc.lastIndexOf("/")); + + // Keeping the data separated (ie. not in the DOM) so that it's maintainable and diffable. + var data = { + name: "{$shaarlititle}", + description: "The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community.", + author: "Shaarli", + version: "1.0.0", + + iconURL: baseURL + "/images/favicon.ico", + icon32URL: baseURL + "/images/favicon.ico", + icon64URL: baseURL + "/images/favicon.ico", + + shareURL: baseURL + "{noparse}?post=%{url}&title=%{title}&description=%{text}&source=firefoxsocialapi{/noparse}", + homepageURL: baseURL + }; + node.setAttribute("data-service", JSON.stringify(data)); + + var activate = new CustomEvent("ActivateSocialFeature"); + node.dispatchEvent(activate); +} diff --git a/tpl/default/loginform.html b/tpl/default/loginform.html index 2ad3fe9c..eb6d8378 100644 --- a/tpl/default/loginform.html +++ b/tpl/default/loginform.html @@ -26,7 +26,7 @@ {if="!empty($username)"}value="{$username}"{/if} class="autofocus" tabindex="20">
- +
- {if="ban_canLogin($conf) && ! empty($username)"} - // Focus password on load if the username is set. - var passwords = document.getElementsByName('password'); - if (passwords.length == 2) { - passwords[1].focus(); - } - {/if} - diff --git a/tpl/default/picwall.html b/tpl/default/picwall.html index b9ae2f2e..248e56df 100644 --- a/tpl/default/picwall.html +++ b/tpl/default/picwall.html @@ -40,11 +40,6 @@ {include="page.footer"} - diff --git a/tpl/default/pluginsadmin.html b/tpl/default/pluginsadmin.html index 92af2eef..5cc1802f 100644 --- a/tpl/default/pluginsadmin.html +++ b/tpl/default/pluginsadmin.html @@ -48,14 +48,8 @@
{if="count($enabledPlugins)>1"} - - ▲ - - - ▼ - + + {/if} diff --git a/tpl/default/tools.html b/tpl/default/tools.html index b9df32d9..baa033af 100644 --- a/tpl/default/tools.html +++ b/tpl/default/tools.html @@ -67,7 +67,7 @@ @@ -103,7 +103,7 @@ @@ -142,38 +142,8 @@
{include="page.footer"} - - + -- cgit v1.2.3