@@ -6,14 +6,14 @@ document.addEventListener('DOMContentLoaded', function () {
66
77 let tableData = [
88 [ "Name" , "Month" , "Day" , "Year" , "Calendar_Type" ] ,
9- [ "New Year's Day " , "1" , "1" , "2026" , "solar" ] ,
10- [ "Chinese New Year's Day " , "1" , "1" , "2026" , "lunar" ] ,
9+ [ "New Year" , "1" , "1" , "2026" , "solar" ] ,
10+ [ "Chinese New Year" , "1" , "1" , "2026" , "lunar" ] ,
1111 [ "Women's Day" , "3" , "8" , "2026" , "solar" ] ,
12- [ "Children's Day" , "6" , "1" , "2026" , "solar" ] ,
1312 [ "Dragon Boat Festival" , "5" , "5" , "2026" , "lunar" ] ,
14- [ "Magpie Festival " , "7 " , "7 " , "2026" , "lunar " ] ,
13+ [ "Children's Day " , "6 " , "1 " , "2026" , "solar " ] ,
1514 [ "Mid-Autumn Festival" , "8" , "15" , "2026" , "lunar" ] ,
16- [ "Christmas Day" , "12" , "25" , "2026" , "solar" ]
15+ [ "Bruce Lee" , "11" , "27" , "1940" , "birthday_solar" ] ,
16+ [ "Bruce Lee" , "10" , "28" , "1940" , "birthday_lunar" ] ,
1717 ] ;
1818
1919 // Find column indexes once
@@ -61,7 +61,7 @@ document.addEventListener('DOMContentLoaded', function () {
6161 for ( let i = 1 ; i <= daysInMonth ; i ++ ) options += `<option value="${ i } " ${ i == cellText ? 'selected' : '' } >${ i } </option>` ;
6262 } else if ( colIndex === yearColIndex ) {
6363 const currentYear = new Date ( ) . getFullYear ( ) ;
64- for ( let i = currentYear - 50 ; i <= currentYear + 50 ; i ++ ) options += `<option value="${ i } " ${ i == cellText ? 'selected' : '' } >${ i } </option>` ;
64+ for ( let i = 1900 ; i <= 2100 ; i ++ ) options += `<option value="${ i } " ${ i == cellText ? 'selected' : '' } >${ i } </option>` ;
6565 } else if ( colIndex === calendarTypeColIndex ) {
6666 CALENDAR_TYPES . forEach ( type => options += `<option value="${ type } " ${ type === cellText ? 'selected' : '' } >${ type } </option>` ) ;
6767 }
@@ -133,12 +133,28 @@ document.addEventListener('DOMContentLoaded', function () {
133133 const link = document . createElement ( 'a' ) ;
134134 const url = URL . createObjectURL ( blob ) ;
135135 link . setAttribute ( 'href' , url ) ;
136- link . setAttribute ( 'download' , 'calendar .csv' ) ;
136+ link . setAttribute ( 'download' , 'csv-to-ical .csv' ) ;
137137 document . body . appendChild ( link ) ;
138138 link . click ( ) ;
139139 document . body . removeChild ( link ) ;
140140 } ) ;
141141
142+ const getLinkBtn = document . getElementById ( 'get-link-btn' ) ;
143+ if ( getLinkBtn ) {
144+ getLinkBtn . addEventListener ( 'click' , function ( ) {
145+ const csvContent = tableToCSV ( ) ;
146+ try {
147+ const base64Content = btoa ( csvContent ) ;
148+ const urlEncodedContent = encodeURIComponent ( base64Content ) ;
149+ const subscriptionLink = `https://csv-to-ical.fantasticmao.cn/remote?base64=${ urlEncodedContent } ` ;
150+ window . open ( subscriptionLink , '_blank' ) ;
151+ } catch ( e ) {
152+ console . error ( "Failed to encode CSV content: " , e ) ;
153+ alert ( "Could not generate link due to an encoding error." ) ;
154+ }
155+ } ) ;
156+ }
157+
142158 // Drag and Drop handlers
143159 function handleDragStart ( e ) {
144160 draggedRowIndex = parseInt ( e . target . dataset . rowIndex , 10 ) ;
0 commit comments