File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,16 @@ <h1 class="font-bold text-2xl text-center flex items-baseline justify-center spa
8484 < input type ="submit " id ="btn-process " value ="Process " class ="w-full mt-5 bg-indigo-600 text-white py-2 px-4 rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 ">
8585 </ form >
8686
87- < div id ="equation-result " class ="mt-8 "> </ div >
87+ < div id ="equation-result-container " class ="hidden flex-col items-start w-full sm:w-auto mt-5 p-6 bg-gray-100 border border-gray-300 rounded-lg shadow-lg ">
88+ < p > Equation result</ p >
89+ < div class ="flex items-center justify-between w-full ">
90+ < p id ="equation-result " class ="text-2xl sm:text-4xl text-indigo-600 font-mono font-semibold ">
91+ </ p >
92+ < button id ="btn-copy " class ="text-sm sm:text-lg text-white bg-indigo-600 py-2 px-4 rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 ">
93+ Copy
94+ </ button >
95+ </ div >
96+ </ div >
8897 </ section >
8998
9099
Original file line number Diff line number Diff line change @@ -20,7 +20,11 @@ const featureSelect = document.getElementById('feature-select')
2020const labelSelectionContainer = document . getElementById ( 'label-selection-container' )
2121const labelSelect = document . getElementById ( 'label-select' )
2222
23+ const equationResultContainer = document . getElementById ( 'equation-result-container' )
2324const equationResult = document . getElementById ( 'equation-result' )
25+ const btnCopy = document . getElementById ( 'btn-copy' )
26+
27+
2428/**
2529 * Linear equation result based on data processing
2630 *
@@ -253,7 +257,9 @@ function singleFeatureProcess(feature, label) {
253257
254258 equation = ( x ) => a + ( b * x )
255259
256- equationResult . textContent = `Equation result: y = ${ a } + ${ b } x`
260+ equationResultContainer . classList . remove ( 'hidden' )
261+ equationResultContainer . classList . add ( 'flex' )
262+ equationResult . textContent = `y = ${ a } + ${ b } x`
257263}
258264
259265
@@ -270,3 +276,13 @@ function multiFeatureProcess(features, label) {
270276 console . log ( 'hey its me multi' )
271277 console . log ( fileData )
272278}
279+
280+
281+ btnCopy . addEventListener ( 'click' , ( ) => {
282+ navigator . clipboard . writeText ( equationResult . textContent ) . then ( ( ) => {
283+ alert ( 'Copied to clipboard!' )
284+ } ) . catch ( err => {
285+ console . error ( err )
286+ alert ( 'Failed to copy text!' )
287+ } )
288+ } )
You can’t perform that action at this time.
0 commit comments