dvRevealScript top-level constant

String const dvRevealScript

What pressing the document's eye does: flips the field it controls between hidden and shown, and says which in aria-pressed. Inline, so the button works before the application's own script has loaded.

A browser with scripting off cannot change an input's type at all, so there the eye is not drawn (dvRevealNoscriptCss) rather than drawn and dead.

Implementation

const String dvRevealScript =
    "var f=document.getElementById(this.getAttribute('aria-controls')),"
    "s=f.type=='password';f.type=s?'text':'password';"
    "this.setAttribute('aria-pressed',s)";