File tree Expand file tree Collapse file tree 1 file changed +72
-0
lines changed
Expand file tree Collapse file tree 1 file changed +72
-0
lines changed Original file line number Diff line number Diff line change 1+ const README_URL =
2+ "https://raw.githubusercontent.com/ProStore-iOS/certificates/refs/heads/main/README.md" ;
3+
4+ fetch ( README_URL )
5+ . then ( res => res . text ( ) )
6+ . then ( md => {
7+ renderRecommended ( md ) ;
8+ renderTable ( md ) ;
9+ renderUpdates ( md ) ;
10+ } ) ;
11+
12+ function renderRecommended ( md ) {
13+ const match = md . match ( / # R e c o m m e n d C e r t i f i c a t e \s + \* \* ( .+ ?) \* \* / ) ;
14+ if ( ! match ) return ;
15+
16+ document . getElementById ( "recommended" ) . innerHTML = `
17+ <h2>⭐ Recommended Certificate</h2>
18+ <p>${ match [ 1 ] } </p>
19+ ` ;
20+ }
21+
22+ function renderTable ( md ) {
23+ const tableMatch = md . match ( / \| C o m p a n y \| [ \s \S ] * ?\n \n / ) ;
24+ if ( ! tableMatch ) return ;
25+
26+ const lines = tableMatch [ 0 ] . trim ( ) . split ( "\n" ) . slice ( 2 ) ;
27+ let rows = "" ;
28+
29+ lines . forEach ( line => {
30+ const cols = line . split ( "|" ) . map ( c => c . trim ( ) ) . filter ( Boolean ) ;
31+ if ( cols . length < 6 ) return ;
32+
33+ rows += `
34+ <tr>
35+ <td>${ cols [ 0 ] } </td>
36+ <td>${ cols [ 1 ] } </td>
37+ <td class="status revoked">❌ Revoked</td>
38+ <td>${ cols [ 3 ] } </td>
39+ <td>${ cols [ 4 ] } </td>
40+ <td>${ cols [ 5 ] } </td>
41+ </tr>
42+ ` ;
43+ } ) ;
44+
45+ document . getElementById ( "certTable" ) . innerHTML = `
46+ <table class="cert-table">
47+ <thead>
48+ <tr>
49+ <th>Company</th>
50+ <th>Type</th>
51+ <th>Status</th>
52+ <th>Valid From</th>
53+ <th>Valid To</th>
54+ <th>Download</th>
55+ </tr>
56+ </thead>
57+ <tbody>${ rows } </tbody>
58+ </table>
59+ ` ;
60+ }
61+
62+ function renderUpdates ( md ) {
63+ const section = md . split ( "# Updates" ) [ 1 ] ;
64+ if ( ! section ) return ;
65+
66+ const lines = section . split ( "\n" ) . filter ( l => l . startsWith ( "**" ) ) ;
67+
68+ document . getElementById ( "updates" ) . innerHTML = `
69+ <h2>📰 Updates</h2>
70+ ${ lines . map ( l => `<div class="update-item">${ l } </div>` ) . join ( "" ) }
71+ ` ;
72+ }
You can’t perform that action at this time.
0 commit comments