multiple calendar / display fixes
This commit is contained in:
parent
6a9655543a
commit
b9c3974070
2 changed files with 14 additions and 4 deletions
|
@ -3,6 +3,9 @@
|
|||
Modernization by @kleinesfilmroellchen
|
||||
*/
|
||||
|
||||
const uriRegex =
|
||||
/(https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w\/\-_\.\:]*(\?\S+)?)?)?)/gi;
|
||||
|
||||
export default function hackcal(e, p = 1) {
|
||||
if (!document.getElementById("dbkcalendar")) return;
|
||||
|
||||
|
@ -41,8 +44,10 @@ export default function hackcal(e, p = 1) {
|
|||
|
||||
// use description as link on summary if it's a valid URL
|
||||
const summaryItem = entryItem.querySelector(".summary");
|
||||
const possibleUri = uriRegex.exec(event.description)?.[0];
|
||||
const cleanedDescription = event.description.replaceAll(uriRegex, "");
|
||||
try {
|
||||
const descriptionUri = new URL(event.description);
|
||||
const descriptionUri = new URL(possibleUri);
|
||||
const descriptionLink = document.createElement("a");
|
||||
descriptionLink.href = descriptionUri;
|
||||
descriptionLink.target = "_blank";
|
||||
|
@ -50,9 +55,9 @@ export default function hackcal(e, p = 1) {
|
|||
summaryItem.appendChild(descriptionLink);
|
||||
} catch (e) {
|
||||
summaryItem.innerText = event.summary;
|
||||
entryItem.querySelector(".description").innerText =
|
||||
event.description;
|
||||
}
|
||||
entryItem.querySelector(".description").innerText =
|
||||
cleanedDescription;
|
||||
|
||||
// self-link location if it's a valid URL
|
||||
const locationItem = entryItem.querySelector(".location");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue