1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+ < title > Spotify Track QR Generator</ title >
5+ < script src ="
https://cdn.jsdelivr.net/npm/[email protected] /qrcode.min.js "
> </ script > 6+ < script src ="https://cdn.tailwindcss.com "> </ script >
7+ </ head >
8+ < body class ="bg-gray-100 min-h-screen flex items-center justify-center ">
9+ < div class ="max-w-md w-full mx-auto p-6 ">
10+ < div class ="bg-white rounded-lg shadow-xl p-8 ">
11+ < h1 class ="text-2xl font-bold text-center mb-6 text-gray-800 "> Spotify Track QR Generator</ h1 >
12+
13+ < div class ="space-y-6 ">
14+ < div >
15+ < label for ="trackId " class ="block text-sm font-medium text-gray-700 mb-2 ">
16+ Enter Spotify Track ID
17+ </ label >
18+ < input
19+ type ="text "
20+ id ="trackId "
21+ placeholder ="e.g., 11dFghVXANMlKmJXsNCbNl "
22+ class ="w-full px-4 py-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-green-500 focus:border-green-500 outline-none transition "
23+ >
24+ </ div >
25+
26+ < button
27+ onclick ="generateQR() "
28+ class ="w-full bg-green-500 text-white py-2 px-4 rounded-md hover:bg-green-600 transition duration-200 font-medium "
29+ >
30+ Generate QR Code
31+ </ button >
32+
33+ < div id ="qrOutput " class ="flex justify-center ">
34+ < canvas id ="qrcode " class ="hidden "> </ canvas >
35+ </ div >
36+
37+ < div id ="downloadButton " class ="text-center hidden ">
38+ < a
39+ id ="downloadLink "
40+ class ="inline-block bg-gray-800 text-white py-2 px-4 rounded-md hover:bg-gray-900 transition duration-200 font-medium "
41+ download ="spotify-track-qr.png "
42+ >
43+ Download QR Code
44+ </ a >
45+ </ div >
46+ </ div >
47+ </ div >
48+ </ div >
49+
50+ < script >
51+ function generateQR ( ) {
52+ const trackId = document . getElementById ( 'trackId' ) . value . trim ( ) ;
53+ if ( ! trackId ) {
54+ alert ( 'Please enter a track ID' ) ;
55+ return ;
56+ }
57+
58+ const url = `https://www.gptgames.dev/tools/spotify_test.html?track=${ trackId } ` ;
59+ const qrcode = document . getElementById ( 'qrcode' ) ;
60+ const downloadButton = document . getElementById ( 'downloadButton' ) ;
61+
62+ // Clear previous QR code
63+ qrcode . innerHTML = '' ;
64+
65+ // Generate new QR code
66+ QRCode . toCanvas ( qrcode , url , {
67+ width : 256 ,
68+ margin : 2 ,
69+ color : {
70+ dark : '#000000' ,
71+ light : '#ffffff'
72+ }
73+ } , function ( error ) {
74+ if ( error ) {
75+ console . error ( error ) ;
76+ alert ( 'Error generating QR code' ) ;
77+ return ;
78+ }
79+
80+ // Show QR code and download button
81+ qrcode . classList . remove ( 'hidden' ) ;
82+ downloadButton . classList . remove ( 'hidden' ) ;
83+
84+ // Update download link
85+ const downloadLink = document . getElementById ( 'downloadLink' ) ;
86+ downloadLink . href = qrcode . toDataURL ( 'image/png' ) ;
87+ } ) ;
88+ }
89+ </ script >
90+ </ body >
91+ </ html >
0 commit comments