File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1+ document . getElementById ( "search" ) . addEventListener ( "click" , async function ( ) {
2+ let search = document . getElementById ( "searchText" ) . value ;
3+ let searchUrl = "https://mc-backend-six.vercel.app/api/search?q=" + encodeURIComponent ( search )
4+ const searchResult = await fetch ( searchUrl )
5+ const data = await searchResult . json ( )
6+ let result = data . hits
7+ let resultDiv = document . getElementById ( "result" )
8+ resultDiv . innerHTML = ""
9+ for ( var i = 0 ; i < result . length ; i ++ ) {
10+ let project = result [ i ]
11+ let projectDiv = document . createElement ( "div" )
12+ projectDiv . className = "project"
13+ projectDiv . innerHTML = `
14+ <img src="${ project . icon_url } " alt="${ project . title } ">
15+ <h3>${ project . title } </h3>
16+ <p>${ project . description } </p>
17+ <p>Downloads: ${ project . downloads } </p>
18+ <p>Follows: ${ project . follows } </p>
19+ <a href="https://modrinth.com/${ project . project_type } /${ project . slug } " target="_blank">View on Modrinth</a>
20+ `
21+ resultDiv . appendChild ( projectDiv )
22+ }
23+ } ) ;
Original file line number Diff line number Diff line change @@ -24,5 +24,5 @@ <h2>Mod Details</h2>
2424 </ div >
2525 </ section >
2626 </ main >
27- < script src ="../js/moddashboard.js " defer > </ script >
27+ < script src ="../js/moddashboard.js " defer type =" module " > </ script >
2828</ html >
You can’t perform that action at this time.
0 commit comments