diff --git a/Code.js b/Code.js index f531f03..95464da 100644 --- a/Code.js +++ b/Code.js @@ -1,31 +1,31 @@ // Emoji map for event types const emojiMap = { - 'interview': '🎙️', - 'flight': '🛫', - 'bus': '🚌', - 'journey': '🚆', - 'trip': '🚆', - 'stay': '🏠', - 'holy shred': '💪', - 'holy ride': '🚵', - 'holy wellness': '🧖', - 'padel': '🏸', - 'meeting': '🤝', - 'catch-up': '☕', - 'video call': '📹', - 'call': '📞', - 'ara': '📞', - 'sosyal aktivite': '🎉', - 'paris 2024': '🏅', - 'randevu': '📅', - 'reservation': '📅', - 'appointment': '📅', - 'tamir': '🛠️', - 'repair': '🛠️', - 'payment': '💸', - 'start date': '🏁', - 'gas and electricity': '🔌', - 'ticket': '🎫' + interview: "🎙️", + flight: "🛫", + bus: "🚌", + journey: "🚆", + trip: "🚆", + stay: "🏠", + "holy shred": "💪", + "holy ride": "🚵", + "holy wellness": "🧖", + padel: "🏸", + meeting: "🤝", + "catch-up": "☕", + "video call": "📹", + call: "📞", + ara: "📞", + "sosyal aktivite": "🎉", + "paris 2024": "🏅", + randevu: "📅", + reservation: "📅", + appointment: "📅", + tamir: "🛠️", + repair: "🛠️", + payment: "💸", + "start date": "🏁", + "gas and electricity": "🔌", + ticket: "🎫", }; function ColorEvents() { @@ -40,8 +40,8 @@ function ColorEvents() { // Development mode date range override if (isDevelopment) { - startDate = new Date('2023-08-01'); // YYYY-MM-DD - endDate = new Date('2024-08-31'); // YYYY-MM-DD + startDate = new Date("2023-08-01"); // YYYY-MM-DD + endDate = new Date("2024-08-31"); // YYYY-MM-DD } Logger.log("Date range: " + startDate + " to " + endDate); @@ -63,7 +63,7 @@ function ColorEvents() { // Check for matching event types and add emojis for (const [key, emoji] of Object.entries(emojiMap)) { - const regex = new RegExp(key, 'i'); // Case-insensitive match + const regex = new RegExp(key, "i"); // Case-insensitive match if (regex.test(title)) { if (!title.startsWith(emoji)) { title = `${emoji} ${title}`; @@ -77,60 +77,90 @@ function ColorEvents() { // Regular expressions for whole word matching const regexMap = { - "interview": /\binterview\b/i, - "flight": /\bflight\b/i, - "journey": /\bjourney\b/i, - "trip": /\btrip\b/i, - "bus": /\bbus\b/i, - "stay": /\bstay\b/i, - "reservation": /\breservation\b/i, + interview: /\binterview\b/i, + flight: /\bflight\b/i, + journey: /\bjourney\b/i, + trip: /\btrip\b/i, + bus: /\bbus\b/i, + stay: /\bstay\b/i, + reservation: /\breservation\b/i, "holy shred": /\bholy shred\b/i, "holy ride": /\bholy ride\b/i, "holy wellness": /\bholy wellness\b/i, - "padel": /\bpadel\b/i, - "meeting": /\bmeeting\b/i, + padel: /\bpadel\b/i, + meeting: /\bmeeting\b/i, "catch-up": /\bcatch-up\b/i, "video call": /\bvideo call\b/i, - "call": /\bcall\b/i, - "ara": /\bara\b/i, + call: /\bcall\b/i, + ara: /\bara\b/i, "sosyal aktivite": /\bsosyal aktivite\b/i, "paris 2024": /\bparis 2024\b/i, - "randevu": /\brandevu\b/i, - "appointment": /\bappointment\b/i, + randevu: /\brandevu\b/i, + appointment: /\bappointment\b/i, "start date": /\bstart date\b/i, "gas and electricity": /\bgas and electricity\b/i, - "tamir": /\btamir\b/i, - "repair": /\brepair\b/i, - "payment": /\bpayment\b/i, - "ticket": /\bticket\b/i + tamir: /\btamir\b/i, + repair: /\brepair\b/i, + payment: /\bpayment\b/i, + ticket: /\bticket\b/i, }; // Check the updated title for colorization using regex if (regexMap["interview"].test(lowerTitle)) { color = CalendarApp.EventColor.YELLOW; Logger.log("Title: " + title + " - Color to print: YELLOW"); - } else if (regexMap["flight"].test(lowerTitle) || regexMap["journey"].test(lowerTitle) || regexMap["trip"].test(lowerTitle) || regexMap["bus"].test(lowerTitle)) { + } else if ( + regexMap["flight"].test(lowerTitle) || + regexMap["journey"].test(lowerTitle) || + regexMap["trip"].test(lowerTitle) || + regexMap["bus"].test(lowerTitle) + ) { color = CalendarApp.EventColor.ORANGE; Logger.log("Title: " + title + " - Color to print: ORANGE"); - } else if (regexMap["stay"].test(lowerTitle) || regexMap["reservation"].test(lowerTitle)) { + } else if ( + regexMap["stay"].test(lowerTitle) || + regexMap["reservation"].test(lowerTitle) + ) { color = CalendarApp.EventColor.PALE_BLUE; Logger.log("Title: " + title + " - Color to print: PALE_BLUE"); - } else if (regexMap["holy shred"].test(lowerTitle) || regexMap["holy ride"].test(lowerTitle) || regexMap["holy wellness"].test(lowerTitle) || regexMap["padel"].test(lowerTitle)) { - color = CalendarApp.EventColor.RED; - Logger.log("Title: " + title + " - Color to print: RED"); - } else if (regexMap["meeting"].test(lowerTitle) || regexMap["catch-up"].test(lowerTitle) || regexMap["video call"].test(lowerTitle) || regexMap["call"].test(lowerTitle) || regexMap["ara"].test(lowerTitle)) { + } else if ( + regexMap["holy shred"].test(lowerTitle) || + regexMap["holy ride"].test(lowerTitle) || + regexMap["holy wellness"].test(lowerTitle) || + regexMap["padel"].test(lowerTitle) + ) { + color = CalendarApp.EventColor.BLUE; + Logger.log("Title: " + title + " - Color to print: BLUE"); + } else if ( + regexMap["meeting"].test(lowerTitle) || + regexMap["catch-up"].test(lowerTitle) || + regexMap["video call"].test(lowerTitle) || + regexMap["call"].test(lowerTitle) || + regexMap["ara"].test(lowerTitle) + ) { color = CalendarApp.EventColor.MAUVE; Logger.log("Title: " + title + " - Color to print: MAUVE"); - } else if (regexMap["sosyal aktivite"].test(lowerTitle) || regexMap["ticket"].test(lowerTitle)) { + } else if ( + regexMap["sosyal aktivite"].test(lowerTitle) || + regexMap["ticket"].test(lowerTitle) + ) { color = CalendarApp.EventColor.PALE_GREEN; Logger.log("Title: " + title + " - Color to print: PALE_GREEN"); } else if (regexMap["paris 2024"].test(lowerTitle)) { color = CalendarApp.EventColor.BLUE; Logger.log("Title: " + title + " - Color to print: BLUE"); - } else if (regexMap["randevu"].test(lowerTitle) || regexMap["appointment"].test(lowerTitle) || regexMap["gas and electricity"].test(lowerTitle) || regexMap["start date"].test(lowerTitle)) { + } else if ( + regexMap["randevu"].test(lowerTitle) || + regexMap["appointment"].test(lowerTitle) || + regexMap["gas and electricity"].test(lowerTitle) || + regexMap["start date"].test(lowerTitle) + ) { color = CalendarApp.EventColor.GRAY; Logger.log("Title: " + title + " - Color to print: GRAY"); - } else if (regexMap["tamir"].test(lowerTitle) || regexMap["repair"].test(lowerTitle)) { + } else if ( + regexMap["tamir"].test(lowerTitle) || + regexMap["repair"].test(lowerTitle) + ) { color = CalendarApp.EventColor.PINK; Logger.log("Title: " + title + " - Color to print: PINK"); } else if (regexMap["payment"].test(lowerTitle)) { @@ -151,11 +181,17 @@ function ColorEvents() { } } } catch (error) { - Logger.log("Error updating event: " + error.toString() + " - Title: " + originalTitle); + Logger.log( + "Error updating event: " + + error.toString() + + " - Title: " + + originalTitle, + ); // Optionally, you can continue with the next event continue; } } } } -} \ No newline at end of file +} +