diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-03-12 12:45:32 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-03-12 12:45:32 +0100 |
commit | b9b41d25e319f44f9fb8259a0237a8ee81ad394b (patch) | |
tree | 2926d2d9c5fdf0310372efa02c11efcf0bd0d428 /tpl/default | |
parent | 196808e14f4df44faea4d010c062c09f36095d9b (diff) | |
download | Shaarli-b9b41d25e319f44f9fb8259a0237a8ee81ad394b.tar.gz Shaarli-b9b41d25e319f44f9fb8259a0237a8ee81ad394b.tar.zst Shaarli-b9b41d25e319f44f9fb8259a0237a8ee81ad394b.zip |
Remove inline JS and add LibreJS headers in JS files
Fixes #33 (wow!)
Relates to #395
Diffstat (limited to 'tpl/default')
-rw-r--r-- | tpl/default/configure.html | 13 | ||||
-rw-r--r-- | tpl/default/editlink.html | 28 | ||||
-rw-r--r-- | tpl/default/install.html | 13 | ||||
-rw-r--r-- | tpl/default/js/shaarli.js | 130 | ||||
-rw-r--r-- | tpl/default/loginform.html | 11 | ||||
-rw-r--r-- | tpl/default/picwall.html | 5 | ||||
-rw-r--r-- | tpl/default/pluginsadmin.html | 10 | ||||
-rw-r--r-- | tpl/default/tools.html | 42 |
8 files changed, 142 insertions, 110 deletions
diff --git a/tpl/default/configure.html b/tpl/default/configure.html index 2f54a085..f24ac435 100644 --- a/tpl/default/configure.html +++ b/tpl/default/configure.html | |||
@@ -222,19 +222,6 @@ | |||
222 | </form> | 222 | </form> |
223 | 223 | ||
224 | {include="page.footer"} | 224 | {include="page.footer"} |
225 | |||
226 | <script> | ||
227 | (function (window, document) { | ||
228 | var toRemove = document.getElementById('timezone-remove'); | ||
229 | var firstSelect = toRemove.getElementsByTagName('select')[0]; | ||
230 | var secondSelect = toRemove.getElementsByTagName('select')[1]; | ||
231 | toRemove.parentNode.removeChild(toRemove); | ||
232 | var toAdd = document.getElementById('timezone-add'); | ||
233 | var newTimezone = '<span class="timezone-continent">Continent ' + firstSelect.outerHTML + '</span>'; | ||
234 | newTimezone += ' <span class="timezone-country">Country ' + secondSelect.outerHTML + '</span>'; | ||
235 | toAdd.innerHTML = newTimezone; | ||
236 | })(this, this.document); | ||
237 | </script> | ||
238 | </body> | 225 | </body> |
239 | </html> | 226 | </html> |
240 | 227 | ||
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 @@ | |||
4 | {include="includes"} | 4 | {include="includes"} |
5 | </head> | 5 | </head> |
6 | <body> | 6 | <body> |
7 | {if="$source !== 'firefoxsocialapi' && $source !== 'bookmarklet'"} | 7 | {include="page.header"} |
8 | {include="page.header"} | ||
9 | {else} | ||
10 | <div class="center">Shaare to: {$shaarlititle}</div> | ||
11 | {/if} | ||
12 | <div id="editlinkform" class="pure-g"> | 8 | <div id="editlinkform" class="pure-g"> |
13 | <div class="pure-u-lg-1-5 pure-u-1-24"></div> | 9 | <div class="pure-u-lg-1-5 pure-u-1-24"></div> |
14 | <form method="post" name="linkform" class="page-form pure-u-lg-3-5 pure-u-22-24 page-form page-form-light"> | 10 | <form method="post" name="linkform" class="page-form pure-u-lg-3-5 pure-u-22-24 page-form page-form-light"> |
@@ -21,25 +17,25 @@ | |||
21 | <label for="lf_url">{'URL'|t}</label> | 17 | <label for="lf_url">{'URL'|t}</label> |
22 | </div> | 18 | </div> |
23 | <div> | 19 | <div> |
24 | <input type="text" name="lf_url" id="lf_url" value="{$link.url}" class="lf_input"> | 20 | <input type="text" name="lf_url" id="lf_url" value="{$link.url}" class="lf_input autofocus"> |
25 | </div> | 21 | </div> |
26 | <div> | 22 | <div> |
27 | <label for="lf_title">{'Title'|t}</label> | 23 | <label for="lf_title">{'Title'|t}</label> |
28 | </div> | 24 | </div> |
29 | <div> | 25 | <div> |
30 | <input type="text" name="lf_title" id="lf_title" value="{$link.title}" class="lf_input"> | 26 | <input type="text" name="lf_title" id="lf_title" value="{$link.title}" class="lf_input autofocus"> |
31 | </div> | 27 | </div> |
32 | <div> | 28 | <div> |
33 | <label for="lf_description">{'Description'|t}</label> | 29 | <label for="lf_description">{'Description'|t}</label> |
34 | </div> | 30 | </div> |
35 | <div> | 31 | <div> |
36 | <textarea name="lf_description" id="lf_description">{$link.description}</textarea> | 32 | <textarea name="lf_description" id="lf_description" class="autofocus">{$link.description}</textarea> |
37 | </div> | 33 | </div> |
38 | <div> | 34 | <div> |
39 | <label for="lf_tags">{'Tags'|t}</label> | 35 | <label for="lf_tags">{'Tags'|t}</label> |
40 | </div> | 36 | </div> |
41 | <div> | 37 | <div> |
42 | <input type="text" name="lf_tags" id="lf_tags" value="{$link.tags}" class="lf_input" | 38 | <input type="text" name="lf_tags" id="lf_tags" value="{$link.tags}" class="lf_input autofocus" |
43 | data-list="{loop="$tags"}{$key}, {/loop}" data-multiple autocomplete="off" > | 39 | data-list="{loop="$tags"}{$key}, {/loop}" data-multiple autocomplete="off" > |
44 | </div> | 40 | </div> |
45 | 41 | ||
@@ -74,18 +70,6 @@ | |||
74 | {/if} | 70 | {/if} |
75 | </form> | 71 | </form> |
76 | </div> | 72 | </div> |
77 | {if="$source !== 'firefoxsocialapi' && $source !== 'bookmarklet'"} | 73 | {include="page.footer"} |
78 | {include="page.footer"} | ||
79 | {/if} | ||
80 | <script> | ||
81 | awesompleteUniqueTag('#lf_tags'); | ||
82 | if (!document.linkform.lf_title.value) { | ||
83 | document.linkform.lf_title.focus(); | ||
84 | } else if (!document.linkform.lf_description.value) { | ||
85 | document.linkform.lf_description.focus(); | ||
86 | } else { | ||
87 | document.linkform.lf_tags.focus(); | ||
88 | } | ||
89 | </script> | ||
90 | </body> | 74 | </body> |
91 | </html> | 75 | </html> |
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 @@ | |||
105 | </div> | 105 | </div> |
106 | </form> | 106 | </form> |
107 | {include="page.footer"} | 107 | {include="page.footer"} |
108 | <script> | ||
109 | // FIXME! | ||
110 | (function (window, document) { | ||
111 | var toRemove = document.getElementById('timezone-remove'); | ||
112 | var firstSelect = toRemove.getElementsByTagName('select')[0]; | ||
113 | var secondSelect = toRemove.getElementsByTagName('select')[1]; | ||
114 | toRemove.parentNode.removeChild(toRemove); | ||
115 | var toAdd = document.getElementById('timezone-add'); | ||
116 | var newTimezone = '<span class="timezone-continent">Continent ' + firstSelect.outerHTML + '</span>'; | ||
117 | newTimezone += ' <span class="timezone-country">Country ' + secondSelect.outerHTML + '</span>'; | ||
118 | toAdd.innerHTML = newTimezone; | ||
119 | })(this, this.document); | ||
120 | </script> | ||
121 | </body> | 108 | </body> |
122 | </html> | 109 | </html> |
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 @@ | |||
1 | /** @licstart The following is the entire license notice for the | ||
2 | * JavaScript code in this page. | ||
3 | * | ||
4 | * Copyright: (c) 2011-2015 Sébastien SAUVAGE <sebsauvage@sebsauvage.net> | ||
5 | * (c) 2011-2017 The Shaarli Community, see AUTHORS | ||
6 | * | ||
7 | * This software is provided 'as-is', without any express or implied warranty. | ||
8 | * In no event will the authors be held liable for any damages arising from | ||
9 | * the use of this software. | ||
10 | * | ||
11 | * Permission is granted to anyone to use this software for any purpose, | ||
12 | * including commercial applications, and to alter it and redistribute it | ||
13 | * freely, subject to the following restrictions: | ||
14 | * | ||
15 | * 1. The origin of this software must not be misrepresented; you must not | ||
16 | * claim that you wrote the original software. If you use this software | ||
17 | * in a product, an acknowledgment in the product documentation would | ||
18 | * be appreciated but is not required. | ||
19 | * | ||
20 | * 2. Altered source versions must be plainly marked as such, and must | ||
21 | * not be misrepresented as being the original software. | ||
22 | * | ||
23 | * 3. This notice may not be removed or altered from any source distribution. | ||
24 | * | ||
25 | * @licend The above is the entire license notice | ||
26 | * for the JavaScript code in this page. | ||
27 | */ | ||
28 | |||
1 | window.onload = function () { | 29 | window.onload = function () { |
2 | 30 | ||
3 | /** | 31 | /** |
@@ -185,9 +213,13 @@ window.onload = function () { | |||
185 | /** | 213 | /** |
186 | * Autofocus text fields | 214 | * Autofocus text fields |
187 | */ | 215 | */ |
188 | var autofocusElements = document.querySelector('.autofocus'); | 216 | // ES6 syntax |
189 | if (autofocusElements != null) { | 217 | let autofocusElements = document.querySelectorAll('.autofocus'); |
190 | autofocusElements.focus(); | 218 | for (let autofocusElement of autofocusElements) { |
219 | if (autofocusElement.value == '') { | ||
220 | autofocusElement.focus(); | ||
221 | break; | ||
222 | } | ||
191 | } | 223 | } |
192 | 224 | ||
193 | /** | 225 | /** |
@@ -266,4 +298,96 @@ window.onload = function () { | |||
266 | } | 298 | } |
267 | }); | 299 | }); |
268 | } | 300 | } |
301 | |||
302 | /** | ||
303 | * TimeZome select | ||
304 | * FIXME! way too hackish | ||
305 | */ | ||
306 | var toRemove = document.getElementById('timezone-remove'); | ||
307 | if (toRemove != null) { | ||
308 | var firstSelect = toRemove.getElementsByTagName('select')[0]; | ||
309 | var secondSelect = toRemove.getElementsByTagName('select')[1]; | ||
310 | toRemove.parentNode.removeChild(toRemove); | ||
311 | var toAdd = document.getElementById('timezone-add'); | ||
312 | var newTimezone = '<span class="timezone-continent">Continent ' + firstSelect.outerHTML + '</span>'; | ||
313 | newTimezone += ' <span class="timezone-country">Country ' + secondSelect.outerHTML + '</span>'; | ||
314 | toAdd.innerHTML = newTimezone; | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * Awesomplete trigger. | ||
319 | */ | ||
320 | var tags = document.getElementById('lf_tags'); | ||
321 | if (tags != null) { | ||
322 | awesompleteUniqueTag('#lf_tags'); | ||
323 | } | ||
324 | |||
325 | /** | ||
326 | * bLazy trigger | ||
327 | */ | ||
328 | var picwall = document.getElementById('picwall_container'); | ||
329 | if (picwall != null) { | ||
330 | var bLazy = new Blazy(); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Bookmarklet alert | ||
335 | */ | ||
336 | var bookmarkletLinks = document.querySelectorAll('.bookmarklet-link'); | ||
337 | var bkmMessage = document.getElementById('bookmarklet-alert'); | ||
338 | [].forEach.call(bookmarkletLinks, function(link) { | ||
339 | link.addEventListener('click', function(event) { | ||
340 | event.preventDefault(); | ||
341 | alert(bkmMessage.value); | ||
342 | }); | ||
343 | }); | ||
344 | |||
345 | /** | ||
346 | * Firefox Social | ||
347 | */ | ||
348 | var ffButton = document.getElementById('ff-social-button'); | ||
349 | if (ffButton != null) { | ||
350 | ffButton.addEventListener('click', function(event) { | ||
351 | activateFirefoxSocial(event.target); | ||
352 | }); | ||
353 | } | ||
354 | |||
355 | /** | ||
356 | * Plugin admin order | ||
357 | */ | ||
358 | var orderPA = document.querySelectorAll('.order'); | ||
359 | [].forEach.call(orderPA, function(link) { | ||
360 | link.addEventListener('click', function(event) { | ||
361 | event.preventDefault(); | ||
362 | if (event.target.classList.contains('order-up')) { | ||
363 | return orderUp(event.target.parentNode.parentNode.getAttribute('data-order')); | ||
364 | } else if (event.target.classList.contains('order-down')) { | ||
365 | return orderDown(event.target.parentNode.parentNode.getAttribute('data-order')); | ||
366 | } | ||
367 | }); | ||
368 | }); | ||
269 | }; | 369 | }; |
370 | |||
371 | function activateFirefoxSocial(node) { | ||
372 | var loc = location.href; | ||
373 | var baseURL = loc.substring(0, loc.lastIndexOf("/")); | ||
374 | |||
375 | // Keeping the data separated (ie. not in the DOM) so that it's maintainable and diffable. | ||
376 | var data = { | ||
377 | name: "{$shaarlititle}", | ||
378 | description: "The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community.", | ||
379 | author: "Shaarli", | ||
380 | version: "1.0.0", | ||
381 | |||
382 | iconURL: baseURL + "/images/favicon.ico", | ||
383 | icon32URL: baseURL + "/images/favicon.ico", | ||
384 | icon64URL: baseURL + "/images/favicon.ico", | ||
385 | |||
386 | shareURL: baseURL + "{noparse}?post=%{url}&title=%{title}&description=%{text}&source=firefoxsocialapi{/noparse}", | ||
387 | homepageURL: baseURL | ||
388 | }; | ||
389 | node.setAttribute("data-service", JSON.stringify(data)); | ||
390 | |||
391 | var activate = new CustomEvent("ActivateSocialFeature"); | ||
392 | node.dispatchEvent(activate); | ||
393 | } | ||
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 @@ | |||
26 | {if="!empty($username)"}value="{$username}"{/if} class="autofocus" tabindex="20"> | 26 | {if="!empty($username)"}value="{$username}"{/if} class="autofocus" tabindex="20"> |
27 | </div> | 27 | </div> |
28 | <div> | 28 | <div> |
29 | <input type="password" name="password" placeholder="{'Password'|t}" tabindex="21"> | 29 | <input type="password" name="password" placeholder="{'Password'|t}" class="autofocus" tabindex="21"> |
30 | </div> | 30 | </div> |
31 | <div class="remember-me"> | 31 | <div class="remember-me"> |
32 | <input type="checkbox" name="longlastingsession" id="longlastingsessionform" | 32 | <input type="checkbox" name="longlastingsession" id="longlastingsessionform" |
@@ -45,15 +45,6 @@ | |||
45 | {/if} | 45 | {/if} |
46 | 46 | ||
47 | {include="page.footer"} | 47 | {include="page.footer"} |
48 | <script> | ||
49 | {if="ban_canLogin($conf) && ! empty($username)"} | ||
50 | // Focus password on load if the username is set. | ||
51 | var passwords = document.getElementsByName('password'); | ||
52 | if (passwords.length == 2) { | ||
53 | passwords[1].focus(); | ||
54 | } | ||
55 | {/if} | ||
56 | </script> | ||
57 | </body> | 48 | </body> |
58 | </html> | 49 | </html> |
59 | 50 | ||
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 @@ | |||
40 | 40 | ||
41 | {include="page.footer"} | 41 | {include="page.footer"} |
42 | <script src="inc/blazy-1.3.1.min.js#"></script> | 42 | <script src="inc/blazy-1.3.1.min.js#"></script> |
43 | <script> | ||
44 | window.onload = function() { | ||
45 | var bLazy = new Blazy(); | ||
46 | } | ||
47 | </script> | ||
48 | </body> | 43 | </body> |
49 | </html> | 44 | </html> |
50 | 45 | ||
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 @@ | |||
48 | <td><div class="pure-u-0 pure-u-lg-visible"><label for="{$key}">{$value.description}</label></div></td> | 48 | <td><div class="pure-u-0 pure-u-lg-visible"><label for="{$key}">{$value.description}</label></div></td> |
49 | <td class="center"> | 49 | <td class="center"> |
50 | {if="count($enabledPlugins)>1"} | 50 | {if="count($enabledPlugins)>1"} |
51 | <a href="#" class="order" | 51 | <a href="#" class="order order-up">▲</a> |
52 | onclick="return orderUp(this.parentNode.parentNode.getAttribute('data-order'));"> | 52 | <a href="#" class="order order-down">▼</a> |
53 | ▲ | ||
54 | </a> | ||
55 | <a href="#" class="order" | ||
56 | onclick="return orderDown(this.parentNode.parentNode.getAttribute('data-order'));"> | ||
57 | ▼ | ||
58 | </a> | ||
59 | {/if} | 53 | {/if} |
60 | <input type="hidden" name="order_{$key}" value="{$counter}"> | 54 | <input type="hidden" name="order_{$key}" value="{$counter}"> |
61 | </td> | 55 | </td> |
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 @@ | |||
67 | <div class="tools-item"> | 67 | <div class="tools-item"> |
68 | <a title="{'Drag this link to your bookmarks toolbar or right-click it and Bookmark This Link'|t}, | 68 | <a title="{'Drag this link to your bookmarks toolbar or right-click it and Bookmark This Link'|t}, |
69 | {'then click ✚Shaare link button in any page you want to share'|t}" | 69 | {'then click ✚Shaare link button in any page you want to share'|t}" |
70 | onclick="return alertBookmarklet();" | 70 | class="bookmarklet-link" |
71 | href="javascript:( | 71 | href="javascript:( |
72 | function(){ | 72 | function(){ |
73 | var%20url%20=%20location.href; | 73 | var%20url%20=%20location.href; |
@@ -86,8 +86,8 @@ | |||
86 | <div class="tools-item"> | 86 | <div class="tools-item"> |
87 | <a title="{'Drag this link to your bookmarks toolbar or right-click it and Bookmark This Link'|t}, | 87 | <a title="{'Drag this link to your bookmarks toolbar or right-click it and Bookmark This Link'|t}, |
88 | {'Then click ✚Add Note button anytime to start composing a private Note (text post) to your Shaarli'|t}" | 88 | {'Then click ✚Add Note button anytime to start composing a private Note (text post) to your Shaarli'|t}" |
89 | onclick="return alertBookmarklet();" | 89 | href="?private=1&post=" |
90 | href="?private=1&post="> | 90 | class="bookmarklet-link"> |
91 | <span class="pure-button pure-u-lg-2-3 pure-u-3-4">✚ {'Add Note'|t}</span> | 91 | <span class="pure-button pure-u-lg-2-3 pure-u-3-4">✚ {'Add Note'|t}</span> |
92 | </a> | 92 | </a> |
93 | </div> | 93 | </div> |
@@ -103,7 +103,7 @@ | |||
103 | 103 | ||
104 | <div class="tools-item"> | 104 | <div class="tools-item"> |
105 | <a title="{'Click on this button to add Shaarli to the 'Share this page' button in Firefox" | 105 | <a title="{'Click on this button to add Shaarli to the 'Share this page' button in Firefox" |
106 | onclick="activateFirefoxSocial(this)"> | 106 | id="ff-social-button"> |
107 | <span class="pure-button pure-u-lg-2-3 pure-u-3-4">✚ {'Add to'|t} Firefox Social</span> | 107 | <span class="pure-button pure-u-lg-2-3 pure-u-3-4">✚ {'Add to'|t} Firefox Social</span> |
108 | </a> | 108 | </a> |
109 | </div> | 109 | </div> |
@@ -142,38 +142,8 @@ | |||
142 | </div> | 142 | </div> |
143 | 143 | ||
144 | {include="page.footer"} | 144 | {include="page.footer"} |
145 | 145 | <input type="hidden" id="bookmarklet-alert" | |
146 | <script> | 146 | value="{'Drag this link to your bookmarks toolbar, or right-click it and choose Bookmark This Link'|t}"> |
147 | {if="$sslenabled"} | ||
148 | function activateFirefoxSocial(node) { | ||
149 | var loc = location.href; | ||
150 | var baseURL = loc.substring(0, loc.lastIndexOf("/")); | ||
151 | |||
152 | // Keeping the data separated (ie. not in the DOM) so that it's maintainable and diffable. | ||
153 | var data = { | ||
154 | name: "{$shaarlititle}", | ||
155 | description: "The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community.", | ||
156 | author: "Shaarli", | ||
157 | version: "1.0.0", | ||
158 | |||
159 | iconURL: baseURL + "/images/favicon.ico", | ||
160 | icon32URL: baseURL + "/images/favicon.ico", | ||
161 | icon64URL: baseURL + "/images/favicon.ico", | ||
162 | |||
163 | shareURL: baseURL + "{noparse}?post=%{url}&title=%{title}&description=%{text}&source=firefoxsocialapi{/noparse}", | ||
164 | homepageURL: baseURL | ||
165 | }; | ||
166 | node.setAttribute("data-service", JSON.stringify(data)); | ||
167 | |||
168 | var activate = new CustomEvent("ActivateSocialFeature"); | ||
169 | node.dispatchEvent(activate); | ||
170 | } | ||
171 | {/if} | ||
172 | function alertBookmarklet() { | ||
173 | alert({"'Drag this link to your bookmarks toolbar, or right-click it and choose Bookmark This Link'"|t}); | ||
174 | return false; | ||
175 | } | ||
176 | </script> | ||
177 | </body> | 147 | </body> |
178 | </html> | 148 | </html> |
179 | 149 | ||