control flow changes?
This commit is contained in:
1 parent
fbbb044b83
commit
6a56cc10a7
2 files changed
+57
-50
No files matched your search
+54
-48
@@ -29,9 +29,8 @@ function showPlaceholder() {
|
||||
}
|
||||
|
||||
function hidePlaceholder() {
|
||||
placeholder_message.style.display = "none";
|
||||
placeholder_message.style.display = "none";
|
||||
cal_ele.style.display = "block";
|
||||
|
||||
}
|
||||
|
||||
const new_tippy = (info) => {
|
||||
@@ -74,54 +73,58 @@ const tippy_die = (info) => {
|
||||
confirm_button.addEventListener("click", (_e) => {
|
||||
console.log("nawgh:", text_field.value);
|
||||
const url = create_url(text_field.value);
|
||||
if (url) {
|
||||
hidePlaceholder(); // Hide placeholder when loading starts
|
||||
if (calendar) calendar.destroy();
|
||||
calendar = new Calendar(cal_ele, {
|
||||
// calendar config
|
||||
plugins: [
|
||||
bootstrap5Plugin,
|
||||
listPlugin,
|
||||
iCalendarPlugin,
|
||||
timeGridPlugin,
|
||||
dayGridPlugin,
|
||||
],
|
||||
themeSystem: "bootstrap5", // Enable Bootstrap 5 theme
|
||||
initialView: "listWeek",
|
||||
// multiMonthMaxColumns: 1,
|
||||
navLinks: true,
|
||||
dayMaxEvents: true,
|
||||
eventMaxStack: 3,
|
||||
dayMaxEventRows: true,
|
||||
nowIndicator: true,
|
||||
weekNumbers: true,
|
||||
headerToolbar: {
|
||||
left: "prev,next",
|
||||
center: "title",
|
||||
right: "today dayGridMonth,timeGridWeek,timeGridDay,listMonth",
|
||||
// views
|
||||
},
|
||||
views: {
|
||||
dayGridMonth: { buttonText: "Month" },
|
||||
timeGridWeek: { buttonText: "Week" },
|
||||
timeGridDay: { buttonText: "Day" },
|
||||
listMonth: { buttonText: "List" },
|
||||
},
|
||||
if (!url && text_field.value) return alert("Please input valid url.");
|
||||
|
||||
events: {
|
||||
url: url,
|
||||
format: "ics",
|
||||
color: getNextColor(),
|
||||
},
|
||||
// eventClick: new_tippy,
|
||||
eventMouseEnter: new_tippy,
|
||||
eventMouseLeave: tippy_die,
|
||||
});
|
||||
// end calendar config
|
||||
calendar.render();
|
||||
} else if (!calendar) {
|
||||
if (calendar) calendar.destroy();
|
||||
|
||||
if (!text_field.value /* && !calendar */) {
|
||||
showPlaceholder(); // Show placeholder if no URL is provided
|
||||
return;
|
||||
}
|
||||
|
||||
hidePlaceholder(); // Hide placeholder when loading starts
|
||||
calendar = new Calendar(cal_ele, {
|
||||
// calendar config
|
||||
plugins: [
|
||||
bootstrap5Plugin,
|
||||
listPlugin,
|
||||
iCalendarPlugin,
|
||||
timeGridPlugin,
|
||||
dayGridPlugin,
|
||||
],
|
||||
themeSystem: "bootstrap5", // Enable Bootstrap 5 theme
|
||||
initialView: "listWeek",
|
||||
// multiMonthMaxColumns: 1,
|
||||
navLinks: true,
|
||||
dayMaxEvents: true,
|
||||
eventMaxStack: 3,
|
||||
dayMaxEventRows: true,
|
||||
nowIndicator: true,
|
||||
weekNumbers: true,
|
||||
headerToolbar: {
|
||||
left: "prev,next",
|
||||
center: "title",
|
||||
right: "today dayGridMonth,timeGridWeek,timeGridDay,listMonth",
|
||||
// views
|
||||
},
|
||||
views: {
|
||||
dayGridMonth: { buttonText: "Month" },
|
||||
timeGridWeek: { buttonText: "Week" },
|
||||
timeGridDay: { buttonText: "Day" },
|
||||
listMonth: { buttonText: "List" },
|
||||
},
|
||||
|
||||
events: {
|
||||
url: url,
|
||||
format: "ics",
|
||||
color: getNextColor(),
|
||||
},
|
||||
// eventClick: new_tippy,
|
||||
eventMouseEnter: new_tippy,
|
||||
eventMouseLeave: tippy_die,
|
||||
});
|
||||
// end calendar config
|
||||
calendar.render();
|
||||
});
|
||||
|
||||
// text_field.value = "http://127.0.0.1:8080/filtered-ics";
|
||||
@@ -129,7 +132,10 @@ confirm_button.addEventListener("click", (_e) => {
|
||||
// wow
|
||||
|
||||
add_button.addEventListener("click", () => {
|
||||
if (calendar && text_field.value) {
|
||||
if (calendar) {
|
||||
const url = create_url(text_field.value);
|
||||
if (!url)
|
||||
return text_field.value ? alert("Please input valid url.") : undefined;
|
||||
calendar.addEventSource({
|
||||
url: text_field.value,
|
||||
format: "ics",
|
||||
|
||||
+3
-2
@@ -1,9 +1,10 @@
|
||||
function create_url(url) {
|
||||
try {
|
||||
return new URL(url);
|
||||
} catch {
|
||||
} catch (e) {
|
||||
// console.info(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export { create_url }
|
||||
export { create_url };
|
||||
Reference in new issue
Block a user