11// Quick poc for view full screen
22
3- window . addEventListener ( "load" , ( event ) => {
4- var fullScreenParamName = "fullscreen" ;
5- var urlParams = new URLSearchParams ( document . location . search ) ;
6- var param = urlParams . get ( fullScreenParamName ) ;
3+ window . addEventListener ( "load" , ( ) => {
4+ const fullScreenParamName = "fullscreen" ;
5+ const urlParams = new URLSearchParams ( document . location . search ) ;
6+ const param = urlParams . get ( fullScreenParamName ) ;
77 if ( param ) {
88 tempViewFullScreen ( ) ;
99 } else {
1010 setViewAtStart ( ) ;
1111 }
1212} ) ;
1313
14- let nhsNotify = nhsNotifyDefaults ( ) ;
14+ const nhsNotify = nhsNotifyDefaults ( ) ;
1515
1616function nhsNotifyDefaults ( ) {
17- var defaults = { } ;
17+ const defaults = { } ;
1818 defaults . storageName = "cb-checked" ;
1919 defaults . buttonName = "fullScreenButton" ;
2020 defaults . standard = "Standard" ;
@@ -24,16 +24,16 @@ function nhsNotifyDefaults() {
2424
2525function tempViewFullScreen ( ) {
2626 viewFullScreen ( ) ;
27- var buttons = document . getElementsByName ( nhsNotify . buttonName ) ;
27+ const buttons = document . getElementsByName ( nhsNotify . buttonName ) ;
2828 buttons . forEach ( ( item ) => {
2929 item . style . display = "none" ;
3030 } ) ;
3131}
3232
3333function viewFullScreen ( ) {
34- var sideBar = document . getElementsByClassName ( "side-bar" ) [ 0 ] ;
35- var main = document . getElementsByClassName ( "main" ) [ 0 ] ;
36- var pageInfo = document . getElementsByClassName ( "page-info" ) [ 0 ] ;
34+ const sideBar = document . getElementsByClassName ( "side-bar" ) [ 0 ] ;
35+ const main = document . getElementsByClassName ( "main" ) [ 0 ] ;
36+ const pageInfo = document . getElementsByClassName ( "page-info" ) [ 0 ] ;
3737 sideBar . style . display = "none" ;
3838 main . style . maxWidth = "100%" ;
3939 main . style . marginLeft = "0px" ;
@@ -45,9 +45,9 @@ function setFullScreen() {
4545}
4646
4747function setStandard ( ) {
48- var sideBar = document . getElementsByClassName ( "side-bar" ) [ 0 ] ;
49- var main = document . getElementsByClassName ( "main" ) [ 0 ] ;
50- var pageInfo = document . getElementsByClassName ( "page-info" ) [ 0 ] ;
48+ const sideBar = document . getElementsByClassName ( "side-bar" ) [ 0 ] ;
49+ const main = document . getElementsByClassName ( "main" ) [ 0 ] ;
50+ const pageInfo = document . getElementsByClassName ( "page-info" ) [ 0 ] ;
5151 sideBar . style . display = "" ;
5252 main . style . maxWidth = "" ;
5353 main . style . marginLeft = "" ;
@@ -56,7 +56,7 @@ function setStandard() {
5656}
5757
5858function setViewAtStart ( ) {
59- var currentStatus = localStorage . getItem ( nhsNotify . storageName ) ;
59+ const currentStatus = localStorage . getItem ( nhsNotify . storageName ) ;
6060 if ( currentStatus == nhsNotify . fullScreen ) makeChange ( currentStatus ) ;
6161}
6262
@@ -69,41 +69,27 @@ function makeChange(newStatus) {
6969}
7070
7171function afterChange ( currentStatus , newStatus ) {
72- var storageName = nhsNotify . storageName ;
73- var buttonName = nhsNotify . buttonName ;
74- var buttons = document . getElementsByName ( buttonName ) ;
75- localStorage . setItem ( storageName , newStatus ) ;
72+ const buttons = document . getElementsByName ( nhsNotify . buttonName ) ;
73+ localStorage . setItem ( nhsNotify . storageName , newStatus ) ;
7674
7775 buttons . forEach ( ( item ) => {
7876 item . textContent = currentStatus + " View" ;
7977 } ) ;
8078}
8179
8280function fullScreenToggle ( ) {
83- var standard = nhsNotify . standard ;
84- var fullScreen = nhsNotify . fullScreen ;
85- var storageName = nhsNotify . storageName ;
86- var currentStatus = "" ;
87- var newStatus = "" ;
88-
89- currentStatus = localStorage . getItem ( storageName ) ;
81+ const { standard, fullScreen, storageName } = nhsNotify ;
82+ let currentStatus = localStorage . getItem ( storageName ) ;
9083
9184 if (
9285 currentStatus == "false" ||
9386 currentStatus == "undefined" ||
9487 currentStatus == null
9588 ) {
9689 currentStatus = standard ;
97- newStatus = fullScreen ;
9890 }
9991
100- if ( currentStatus == standard ) {
101- newStatus = fullScreen ;
102- currentStatus = standard ;
103- } else {
104- newStatus = standard ;
105- currentStatus = fullScreen ;
106- }
92+ const newStatus = currentStatus == standard ? fullScreen : standard ;
10793
10894 makeChange ( newStatus ) ;
10995}
0 commit comments