aboutsummaryrefslogtreecommitdiff
path: root/p/scripts/global_view.js
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2021-10-21 11:44:03 +0200
committerGravatar GitHub <noreply@github.com> 2021-10-21 11:44:03 +0200
commitb438d8bb3d4b3dea6d28d0b0c73da9393c9d8299 (patch)
treefe3c9550c2f3cd46edefae7ceda56407c80d8e36 /p/scripts/global_view.js
parentcfd625c5596f2ce20ab4341bb04ddb263552e417 (diff)
ESLint upgrade from JSHint (#3906)
* ESLint upgrade from JSHint * commit corresponding package.json * `npm run fix` for automatic JS and CSS fixes * Keep JSHint config for now
Diffstat (limited to 'p/scripts/global_view.js')
-rw-r--r--p/scripts/global_view.js121
1 files changed, 60 insertions, 61 deletions
diff --git a/p/scripts/global_view.js b/p/scripts/global_view.js
index e9515be6a..e3a07382a 100644
--- a/p/scripts/global_view.js
+++ b/p/scripts/global_view.js
@@ -1,9 +1,8 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
-"use strict";
+'use strict';
/* globals context, init_load_more, init_posts, init_stream */
-/* jshint esversion:6, strict:global */
-var panel_loading = false;
+let panel_loading = false;
function load_panel(link) {
if (panel_loading) {
@@ -16,63 +15,63 @@ function load_panel(link) {
req.open('GET', link, true);
req.responseType = 'document';
req.onload = function (e) {
- if (this.status != 200) {
- return;
+ if (this.status != 200) {
+ return;
+ }
+ const html = this.response;
+ const foreign = html.querySelectorAll('.nav_menu, #stream .day, #stream .flux, #stream .pagination, #stream.prompt');
+ const panel = document.getElementById('panel');
+ foreign.forEach(function (el) {
+ panel.appendChild(document.adoptNode(el));
+ });
+ panel.querySelectorAll('.nav_menu > :not([id="nav_menu_read_all"])').forEach(function (el) {
+ el.remove();
+ });
+
+ init_load_more(panel);
+ init_posts();
+
+ document.getElementById('overlay').classList.add('visible');
+ panel.classList.add('visible');
+
+ // force le démarrage du scroll en haut.
+ // Sans ça, si l'on scroll en lisant une catégorie par exemple,
+ // en en ouvrant une autre ensuite, on se retrouve au même point de scroll
+ panel.scrollTop = 0;
+ document.documentElement.scrollTop = 0;
+
+ // We already have a click listener in main.js
+ panel.addEventListener('click', function (ev) {
+ const b = ev.target.closest('#nav_menu_read_all button, #bigMarkAsRead');
+ if (b) {
+ console.log(b.formAction);
+
+ const req2 = new XMLHttpRequest();
+ req2.open('POST', b.formAction, false);
+ req2.setRequestHeader('Content-Type', 'application/json');
+ req2.send(JSON.stringify({
+ _csrf: context.csrf,
+ }));
+ if (req2.status == 200) {
+ location.reload(false);
+ return false;
+ }
}
- const html = this.response,
- foreign = html.querySelectorAll('.nav_menu, #stream .day, #stream .flux, #stream .pagination, #stream.prompt'),
- panel = document.getElementById('panel');
- foreign.forEach(function (el) {
- panel.appendChild(document.adoptNode(el));
- });
- panel.querySelectorAll('.nav_menu > :not([id="nav_menu_read_all"])').forEach(function (el) {
- el.remove();
- });
-
- init_load_more(panel);
- init_posts();
-
- document.getElementById('overlay').classList.add('visible');
- panel.classList.add('visible');
-
- // force le démarrage du scroll en haut.
- // Sans ça, si l'on scroll en lisant une catégorie par exemple,
- // en en ouvrant une autre ensuite, on se retrouve au même point de scroll
- panel.scrollTop = 0;
- document.documentElement.scrollTop = 0;
-
- //We already have a click listener in main.js
- panel.addEventListener('click', function (ev) {
- const b = ev.target.closest('#nav_menu_read_all button, #bigMarkAsRead');
- if (b) {
- console.log(b.formAction);
-
- const req2 = new XMLHttpRequest();
- req2.open('POST', b.formAction, false);
- req2.setRequestHeader('Content-Type', 'application/json');
- req2.send(JSON.stringify({
- _csrf: context.csrf,
- }));
- if (req2.status == 200) {
- location.reload(false);
- return false;
- }
- }
- });
-
- panel_loading = false;
- };
+ });
+
+ panel_loading = false;
+ };
req.send();
}
function init_close_panel() {
const panel = document.getElementById('panel');
document.querySelector('#overlay .close').onclick = function (ev) {
- panel.innerHTML = '';
- panel.classList.remove('visible');
- document.getElementById('overlay').classList.remove('visible');
- return false;
- };
+ panel.innerHTML = '';
+ panel.classList.remove('visible');
+ document.getElementById('overlay').classList.remove('visible');
+ return false;
+ };
document.addEventListener('keydown', ev => {
const k = (ev.key.trim() || ev.code).toUpperCase();
if (k === 'ESCAPE' || k === 'ESC') {
@@ -85,15 +84,15 @@ function init_close_panel() {
function init_global_view() {
// TODO: should be based on generic classes
document.querySelectorAll('.box a').forEach(function (a) {
- a.onclick = function (ev) {
- load_panel(a.href);
- return false;
- };
- });
+ a.onclick = function (ev) {
+ load_panel(a.href);
+ return false;
+ };
+ });
document.querySelectorAll('.nav_menu #nav_menu_read_all, .nav_menu .toggle_aside').forEach(function (el) {
- el.remove();
- });
+ el.remove();
+ });
const panel = document.getElementById('panel');
init_stream(panel);
@@ -104,7 +103,7 @@ function init_all_global_view() {
if (window.console) {
console.log('FreshRSS Global view waiting for JS…');
}
- window.setTimeout(init_all_global_view, 50); //Wait for all js to be loaded
+ window.setTimeout(init_all_global_view, 50); // Wait for all js to be loaded
return;
}
init_global_view();