@@ -48,6 +48,7 @@ document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
4848
4949type DetectionResult = {
5050 library : string
51+ libraryUrl : string
5152 encoding : string
5253 confidence ?: number
5354}
@@ -116,6 +117,7 @@ const detectWithJschardet = async (bytes: Uint8Array): Promise<DetectionResult[]
116117 . filter ( ( entry ) => Boolean ( entry . encoding ) )
117118 . map ( ( entry ) => ( {
118119 library : 'jschardet' ,
120+ libraryUrl : 'https://www.npmjs.com/package/jschardet' ,
119121 encoding : entry . encoding ,
120122 confidence : entry . confidence ?? 0 ,
121123 } ) )
@@ -151,6 +153,7 @@ const detectWithEncodingJs = async (bytes: Uint8Array): Promise<DetectionResult[
151153 return [
152154 {
153155 library : 'encoding.js' ,
156+ libraryUrl : 'https://www.npmjs.com/package/encoding-japanese' ,
154157 encoding : detected ,
155158 } ,
156159 ]
@@ -166,6 +169,7 @@ const detectWithChardet = async (bytes: Uint8Array): Promise<DetectionResult[]>
166169 if ( analysed . length > 0 ) {
167170 return analysed . map ( ( entry ) => ( {
168171 library : 'chardet' ,
172+ libraryUrl : 'https://www.npmjs.com/package/chardet' ,
169173 encoding : entry . name ,
170174 confidence : entry . confidence ,
171175 } ) )
@@ -179,6 +183,7 @@ const detectWithChardet = async (bytes: Uint8Array): Promise<DetectionResult[]>
179183 return [
180184 {
181185 library : 'chardet' ,
186+ libraryUrl : 'https://www.npmjs.com/package/chardet' ,
182187 encoding : primary ,
183188 } ,
184189 ]
@@ -194,7 +199,7 @@ const renderResults = (results: DetectionResult[], fileSize: number) => {
194199 . slice ( 0 , 30 )
195200 . map (
196201 ( result ) =>
197- `<tr><td>${ result . library } </td><td>${ result . encoding } </td><td class="text-right">${ formatConfidence ( result . confidence ) } </td></tr>` ,
202+ `<tr><td><a class="link link-primary" href=" ${ result . libraryUrl } "> ${ result . library } </a> </td><td>${ result . encoding } </td><td class="text-right">${ formatConfidence ( result . confidence ) } </td></tr>` ,
198203 )
199204 . join ( '' )
200205 : '<tr><td colspan="3">No result</td></tr>'
@@ -212,6 +217,10 @@ clearResultsButton?.addEventListener('click', () => {
212217 resultsSummary . textContent = ''
213218 }
214219
220+ if ( fileInput ) {
221+ fileInput . value = ''
222+ }
223+
215224 resultsSection ?. classList . add ( 'hidden' )
216225} )
217226
@@ -252,7 +261,6 @@ fileInput?.addEventListener('change', async () => {
252261 } finally {
253262 if ( fileInput ) {
254263 fileInput . disabled = false
255- fileInput . value = ''
256264 }
257265 }
258266} )
0 commit comments