Skip to content

Commit e0dfa8f

Browse files
committed
support 5 calendars & Fix date sort again
1 parent 91f5c00 commit e0dfa8f

2 files changed

Lines changed: 61 additions & 15 deletions

File tree

index.ts

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ const settingsTemplate:SettingSchemaDesc[] = [{
2222
title: "Optional: A second block under the event",
2323
description: "Optionally insert a second block indented under the event. Leave blank if you don't want to insert a second blockYou can use placeholder variables to customize the block. The following variables are available: {Description}, {Date}, {Start}, {End}, {Title}, {Location}.",
2424
},
25+
{
26+
key: "timeFormat",
27+
type: 'enum',
28+
default: ["12 hour time", "24 hour time"],
29+
title: "Select between 12 and 24 hour time",
30+
description: "Select between 12 and 24 hour time. This option will be followed whenever you call {end} or {start} in the template.",
31+
enumChoices: ["12 hour time", "24 hour time"],
32+
enumPicker: 'select'
33+
},
2534
{
2635
key: "calendar1Name",
2736
type: 'string',
@@ -65,22 +74,41 @@ const settingsTemplate:SettingSchemaDesc[] = [{
6574
description: "Optional: Leave blank if you don't want this calendar to be inserted",
6675
},
6776
{
68-
key: "timeFormat",
69-
type: 'enum',
70-
default: ["12 hour time", "24 hour time"],
71-
title: "Select between 12 and 24 hour time",
72-
description: "Select between 12 and 24 hour time. This option will be followed whenever you call {end} or {start} in the template.",
73-
enumChoices: ["12 hour time", "24 hour time"],
74-
enumPicker: 'select'
77+
key: "calendar4Name",
78+
type: 'string',
79+
default: "",
80+
title: "Optional: What would you like to name the calendar?",
81+
description: "Optional: Leave blank if you don't want this calendar to be inserted",
82+
},
83+
{
84+
key: "calendar4URL",
85+
type: 'string',
86+
default: "",
87+
title: "Optional: enter the iCAL URL for calendar 4",
88+
description: "Optional: Leave blank if you don't want this calendar to be inserted",
89+
},
90+
{
91+
key: "calendar5Name",
92+
type: 'string',
93+
default: "",
94+
title: "Optional: What would you like to name the calendar?",
95+
description: "Optional: Leave blank if you don't want this calendar to be inserted",
96+
},
97+
{
98+
key: "calendar5URL",
99+
type: 'string',
100+
default: "",
101+
title: "Optional: enter the iCAL URL for calendar 3",
102+
description: "Optional: Leave blank if you don't want this calendar to be inserted",
75103
}]
76104
logseq.useSettingsSchema(settingsTemplate)
77105

78106

79-
// function sortDate(data){
80-
// return data.sort(function(a, b){return (Math.round(new Date(a.start).getTime()/1000)
81-
// - (Math.round(new Date(b.start).getTime()/1000)))}
82-
// )
83-
// }
107+
function sortDate(data){
108+
return data.sort(function(a, b){return (Math.round(new Date(a.start).getTime()/1000)
109+
- (Math.round(new Date(b.start).getTime()/1000)))}
110+
)
111+
}
84112
async function findDate(preferredDateFormat){
85113
const hello = 1
86114
if (await logseq.Editor.getCurrentPage()!=null){
@@ -111,8 +139,8 @@ function rawParser(rawData) {
111139
}
112140
console.log(eventsArray)
113141
// console.log(sortDate(eventsArray))
114-
// return sortDate(eventsArray);
115-
return eventsArray
142+
return sortDate(eventsArray);
143+
// return eventsArray
116144
}
117145

118146
function templateFormatter(template, description = "No Description", date = "No Date", start = "No Start", end = "No End", title = "No Title", location = "No Location"){
@@ -253,6 +281,12 @@ async function main () {
253281
if (initialSettings.calendar1Name != "" && initialSettings.calendar1URL != ""){
254282
accounts2[initialSettings.calendar1Name] = initialSettings.calendar1URL
255283
}
284+
if (initialSettings.calendar4Name != "" && initialSettings.calendar4URL != ""){
285+
accounts2[initialSettings.calendar4Name] = initialSettings.calendar4URL
286+
}
287+
if (initialSettings.calendar5Name != "" && initialSettings.calendar5URL != ""){
288+
accounts2[initialSettings.calendar5Name] = initialSettings.calendar5URL
289+
}
256290
// logseq.updateSettings({"accounts": {}})
257291
// logseq.updateSettings({"accounts": accounts2})
258292
const userConfigs = await logseq.App.getUserConfigs();
@@ -272,6 +306,12 @@ if (initialSettings.calendar2Name != "" && initialSettings.calendar2URL != ""){
272306
}
273307
if (initialSettings.calendar1Name != "" && initialSettings.calendar1URL != ""){
274308
accounts2[initialSettings.calendar1Name] = [initialSettings.calendar1URL]
309+
}
310+
if (initialSettings.calendar4Name != "" && initialSettings.calendar4URL != ""){
311+
accounts2[initialSettings.calendar4Name] = initialSettings.calendar4URL
312+
}
313+
if (initialSettings.calendar5Name != "" && initialSettings.calendar5URL != ""){
314+
accounts2[initialSettings.calendar5Name] = initialSettings.calendar5URL
275315
}
276316
initialSettings = await logseq.settings
277317
// logseq.updateSettings({"accounts": {}})
@@ -294,6 +334,12 @@ if (initialSettings.calendar3Name != "" && initialSettings.calendar3URL != ""){
294334
}
295335
if (initialSettings.calendar1Name != "" && initialSettings.calendar1URL != ""){
296336
accounts2[initialSettings.calendar1Name] = [initialSettings.calendar1URL]
337+
}
338+
if (initialSettings.calendar4Name != "" && initialSettings.calendar4URL != ""){
339+
accounts2[initialSettings.calendar4Name] = initialSettings.calendar4URL
340+
}
341+
if (initialSettings.calendar5Name != "" && initialSettings.calendar5URL != ""){
342+
accounts2[initialSettings.calendar5Name] = initialSettings.calendar5URL
297343
}
298344
let accountSetting = accounts2[accountName]
299345
logseq.App.registerCommandPalette(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "logseq-calendars-plugin",
3-
"version": "2.0.4",
3+
"version": "2.1.0",
44
"description": "Import GCal, iCloud,and Outlook calendars to your logseq daily note",
55
"main": "dist/index.html",
66
"targets": {

0 commit comments

Comments
 (0)