@@ -63,47 +63,6 @@ <h1>Demo Server</h1>
6363 </ tbody >
6464 </ table >
6565 < script src ="/assets/js/jsOTP.js "> </ script >
66- < script >
67- // Add "copy to clipboard" functionality to all copy buttons
68- document . querySelectorAll ( ".copy-btn" ) . forEach ( btn => {
69- btn . addEventListener ( "click" , ( ) => {
70- const selector = btn . dataset . target ;
71- const text = document . querySelector ( selector ) . textContent . trim ( ) ;
72- navigator . clipboard . writeText ( text ) ;
73-
74- // Display exactly one ephemeral success message
75- const cell = btn . parentNode ;
76- const existing = cell . querySelector ( ".copiedtip" ) ;
77- if ( existing ) {
78- existing . remove ( ) ;
79- }
80- const tip = document . createElement ( "span" ) ;
81- tip . className = "copiedtip" ;
82- tip . textContent = "Copied to clipboard!" ;
83- cell . appendChild ( tip ) ;
84- setTimeout ( ( ) => tip . remove ( ) , 2500 ) ;
85- } ) ;
86- } ) ;
87-
88- // Cycle through TOTP codes
89- function updateOTP ( ) {
90- const secret = document . getElementById ( "totpsecretvalue" ) . textContent . trim ( ) ;
91- const totp = new jsOTP . totp ( ) ;
92- document . getElementById ( "totpvalue" ) . textContent = totp . getOtp ( secret ) ;
93-
94- const epoch = Math . round ( new Date ( ) . getTime ( ) / 1000.0 ) ;
95- const remaining = 30 - ( epoch % 30 ) ;
96- const seconds = `${ remaining } ` . padStart ( 2 , "0" ) ;
97- document . getElementById ( "totpttl" ) . textContent = `(:${ seconds } remaining)` ;
98-
99- if ( remaining < 10 ) {
100- document . getElementById ( "totp" ) . classList . add ( "expiring" ) ;
101- } else {
102- document . getElementById ( "totp" ) . classList . remove ( "expiring" ) ;
103- }
104- }
105- updateOTP ( ) ;
106- setInterval ( updateOTP , 1000 ) ;
107- </ script >
66+ < script src ="/assets/js/demo.js "> </ script >
10867 </ body >
10968</ html >
0 commit comments