You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I've writen my version of plugin
Because I need to implement my notes with my custom properties
Such as:
Time (in ISO format)
duration (format 1d5h17m, if val is 'x' the default duration is 1h30m
And this is my version of calendar with using Dataviewjs and FullCalendar
But I am facing some problems
when I edit smth in calendar or note view update and scroll sets null
how to create notes in this view
I think I need to convert it into plugin
But may be there is another way
(I don't want to learn how to create plugins)
`dataviewjs
this.container.style.minHeight="100vh";constFORMAT_DEFAULT_ADD='x'constFORMAT_DAY='d'constFORMAT_HOUR='h'constFORMAT_MINUTE='m'constDAY_REG=/\d+d/constHOUR_REG=/\d+h/constMINUTE_REG=/\d+m/constDEFAULT_ADD={d: 0,h: 1,m: 30}constMillisecsInSecond=1000constSecsInMinute=60constMinutesInHour=60constHoursInDay=24constMillisecsInMinute=MillisecsInSecond*SecsInMinuteconstMillisecsInHour=MillisecsInMinute*MinutesInHourconstMillisecsInDay=MillisecsInHour*HoursInDayconstDEFAULT_ADD_IN_MILLISEC=DEFAULT_ADD.d*MillisecsInDay+DEFAULT_ADD.h*MillisecsInHour+DEFAULT_ADD.m*MillisecsInMinuteconst{ renderCalendar }=app.plugins.plugins["obsidian-full-calendar"];constMDCache=app.metadataCacheconstmillisecToString=(millisec)=>{constdays=Math.floor(millisec/(MillisecsInDay))millisec-=days*MillisecsInDayconsthours=Math.floor(millisec/(MillisecsInHour))millisec-=hours*MillisecsInHourconstminutes=Math.floor(millisec/(MillisecsInMinute))millisec-=minutes*MillisecsInMinuteletresString=''if(days)resString+=days.toString()+FORMAT_DAYif(hours)resString+=hours.toString()+FORMAT_HOURif(minutes)resString+=minutes.toString()+FORMAT_MINUTEreturnresString}constgetEvents=()=>{letevents=[]letpages=dv.pages('"databases"')for(leti=0;i<pages.length;++i){letpage=pages.values[i]if(!page.date){continue}conststructure={id: page.file.path,title: page.file.name,start: newDate(page.date),allDay: true,// TODO // color: "red",editable: true,}if(page.duration===FORMAT_DEFAULT_ADD){structure.allDay=falselettmpTime=newDate(page.date)tmpTime.setMinutes(tmpTime.getMinutes()+DEFAULT_ADD.m)tmpTime.setHours(tmpTime.getHours()+DEFAULT_ADD.h)tmpTime.setDate(tmpTime.getDate()+DEFAULT_ADD.d)structure.end=tmpTime}elseif(page.duration){constduration=page.duration.valuesstructure.allDay=falselettmpTime=newDate(page.date)if(duration.minutes)tmpTime.setMinutes(tmpTime.getMinutes()+duration.minutes)if(duration.hours)tmpTime.setHours(tmpTime.getHours()+duration.hours)if(duration.days)tmpTime.setDate(tmpTime.getDate()+duration.days)structure.end=tmpTime}events.push(structure)}returnevents}constsettings={firstDay: 1,weekNumbers:true,eventClick: (info)=>{consttFile=MDCache.getFirstLinkpathDest(info.event.id,'')// false = open in the current tabconstleaf=this.app.workspace.getLeaf(!app.isMobile)leaf.openFile(tFile)},modifyEvent: async(newPos,oldPos)=>{lettmpTime=newDate(newPos.start)tmpTime.setMinutes(tmpTime.getMinutes()-tmpTime.getTimezoneOffset())constnewTime=tmpTime.toISOString().slice(0,-5)consttFile=MDCache.getFirstLinkpathDest(newPos.id,'')awaitapp.fileManager.processFrontMatter(tFile,(property)=>{property['date']=newTimeletresDurationif(newPos.allDay){resDuration=''}elseif(oldPos.allDay){resDuration=FORMAT_DEFAULT_ADD}else{constsrcMillisec=newPos.end-newPos.startresDuration=DEFAULT_ADD_IN_MILLISEC===srcMillisec
? FORMAT_DEFAULT_ADD : millisecToString(srcMillisec)}property['duration']=resDuration})// true for update place in Calendarreturn1;}}constcalendar=renderCalendar(this.container,{events: getEvents()},settings,)calendar.setOption('weekNumbers',true)// to fix bug first renderwindow.setTimeout(_=>{if(app.isMobile)calendar.changeView('timeGrid3Days')elsecalendar.changeView('timeGridWeek')},1)calendar.render()
`dataviewjs
U can paste this code using notes with properties 'date' (for example 2024-03-07T22:00:00) and 'duration' (1h30m)
This is my first public share on GitHub.
(Maybe it should be in the discussions)
The text was updated successfully, but these errors were encountered:
So I've writen my version of plugin
Because I need to implement my notes with my custom properties
Such as:
And this is my version of calendar with using Dataviewjs and FullCalendar
But I am facing some problems
I think I need to convert it into plugin
But may be there is another way
(I don't want to learn how to create plugins)
`dataviewjs
`dataviewjs
U can paste this code using notes with properties 'date' (for example 2024-03-07T22:00:00) and 'duration' (1h30m)
This is my first public share on GitHub.
(Maybe it should be in the discussions)
The text was updated successfully, but these errors were encountered: