Skip to content

gui: Add warning when JavaScript is disabled in Web browser (fixes #7099) - #7102

Merged
calmh merged 3 commits into
syncthing:mainfrom
tomasz1986:tomasz86-guinoscript
Nov 9, 2020
Merged

calmh merged 3 commits into
syncthing:mainfrom
tomasz1986:tomasz86-guinoscript

Conversation

@tomasz1986

@tomasz1986 tomasz1986 commented Nov 9, 2020 •

Copy link
Copy Markdown
Member

When using a Web browser with JavaScript either disabled or unavailable,
show a warning to let the user know that the Web GUI requires JS in
order to operate.

To achieve this, add a div that wraps both the navbar and the main
content, and then move the CSS class ng-cloak from the html element to
that div. This way, only the JavaScript-dependent part is hidden when
JS is unavailable, and not the whole website, as it is the case right
now. Then, add a <noscript> element right at the start of the body
element, so that the warning is also shown right away in text-based Web
browsers. The noscript element includes a stripped down version of the
navbar showing only the Syncthing logo, and then a container with the
warning itself. Lastly, leave the footer untouched and always visible,
because it does not rely on JavaScript at all.

Signed-off-by: Tomasz Wilczyński [email protected]

@tomasz1986

tomasz1986 commented Nov 9, 2020 •

Copy link
Copy Markdown
Member Author

This is how the warning looks like:

image

I have opted for an approach to add the <noscript> element right at the beginning of the <body>, so that even in text-based Web browsers it will be shown first. I then wrapped the JS-dependent content in a new <div> that is hidden using the ng-cloak class that is currently used to hide the whole <html>. I have left the footer out of it, because it does not need JS to display (and having those links always displayed is useful anyway).

The default diff on GitHub looks huge, but if you hide white-space changes related to the indentation, then there is not much in it.

@tomasz1986
tomasz1986 force-pushed the tomasz86-guinoscript branch from 825d38b to b2e9298 Compare November 9, 2020 04:11
@tomasz1986
tomasz1986 marked this pull request as draft November 9, 2020 04:29
@tomasz1986
tomasz1986 marked this pull request as ready for review November 9, 2020 04:33
@tomasz1986
tomasz1986 marked this pull request as draft November 9, 2020 04:58
When using a Web browser with JavaScript either disabled or unavailable,
show a warning to let the user know that the Web GUI requires JS in
order to operate.

To achieve this, add a <div> that wraps both the navbar and the main
content, and then move the CSS class ng-cloak from the <html> element to
that <div>. This way, only the JavaScript-dependent part is hidden when
JS is unavailable, and not the whole website, as it is the case right
now. Then, add a <noscript> element right at the start of the <body>
element, so that the warning is also shown right away in text-based Web
browsers. The <noscript> element includes a stripped down version of the
navbar showing only the Syncthing logo, and then a container with the
warning itself. Lastly, leave the footer untouched and always visible,
because it does not rely on JavaScript at all.

Signed-off-by: Tomasz Wilczyński <[email protected]>
@tomasz1986
tomasz1986 force-pushed the tomasz86-guinoscript branch from 8405fa3 to d083d40 Compare November 9, 2020 07:02
@tomasz1986
tomasz1986 marked this pull request as ready for review November 9, 2020 07:17
Comment thread gui/default/index.html Resolved
calmh
calmh previously approved these changes Nov 9, 2020
Comment thread gui/default/index.html Resolved
@calmh
calmh merged commit 0fb7cc1 into syncthing:main Nov 9, 2020
calmh added a commit that referenced this pull request Nov 9, 2020
* main:
  gui: Add warning when JavaScript is disabled in Web browser (fixes #7099) (#7102)
  lib/model: Add done chan to track folder-lifetime (fixes #6664) (#7094)
  lib/model: Send indexes for newly shared folder (fixes #7098) (#7100)
@calmh calmh added this to the v1.12.0 milestone Nov 9, 2020
Comment thread gui/default/index.html
<div class="panel-icon">
<span class="fas fa-exclamation-circle"></span>
</div>
<span translate>Warning!</span>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already merged, but I guess that there should be no translate here either, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed; fixed.

@tomasz1986
tomasz1986 deleted the tomasz86-guinoscript branch November 10, 2020 14:04
calmh added a commit to calmh/syncthing that referenced this pull request Nov 11, 2020
* main: (42 commits)
  gui: Initialise sharing when accepting new device (fixes syncthing#7113) (syncthing#7114)
  gui: Initialise sharing when accepting new device (fixes syncthing#7113) (syncthing#7114)
  lib/model: Prevent test deadlock (syncthing#7110)
  lib/api, lib/db: Add file debug endpoint (syncthing#7095)
  gui: Add advance config port mapping to gui (fixes syncthing#4824) (syncthing#7017)
  lib/tlsutil: Add O and OU to generated certificates (fixes syncthing#7108) (syncthing#7109)
  all: Add untrusted folders behind feature flag (ref syncthing#62) (syncthing#7055)
  build: Update notify (fixes syncthing#5360) (syncthing#7106)
  lib/model: Fix locking when resending cluster-configs (syncthing#7107)
  gui: Remove superfluous translate in previous (ref syncthing#7102)
  gui: Add warning when JavaScript is disabled in Web browser (fixes syncthing#7099) (syncthing#7102)
  lib/model: Add done chan to track folder-lifetime (fixes syncthing#6664) (syncthing#7094)
  lib/model: Send indexes for newly shared folder (fixes syncthing#7098) (syncthing#7100)
  lib/folder: Clear pull errors when nothing is needed anymore (syncthing#7093)
  lib/api: Fix debug endpoints (ref syncthing#7001) (syncthing#7092)
  gui, man, authors: Update docs, translations, and contributors
  lib/config: Sanity checks on MaxConcurrentWrites (ref syncthing#7064) (syncthing#7069)
  lib/ur: Fix panics in failure-reporting (fixes syncthing#7090) (syncthing#7091)
  lib/ur: Fix panics in failure-reporting (fixes syncthing#7090) (syncthing#7091)
  build: Update dependencies (syncthing#7088)
  ...
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Nov 10, 2021
@syncthing syncthing locked and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants