-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvcalendar.js
1 lines (1 loc) · 7.02 KB
/
vcalendar.js
1
function EventList(){this.events={},this.todos={},this.displayEventsArray={},this.displayTodosArray={},this.repeatable={},this.repeatableTodo={},this.reset=function(){this.events={},this.todos={},this.repeatable={},this.repeatableTodo={},this.displayEventsArray={},this.displayTodosArray={}},this.getNewUID=function(){return generateUID()},this.getSortKey=function(e){var t=("\r\n"+e).match(RegExp("\r\n"+vCalendar.re.contentline_N,"m"));if(null!=t&&1==t.length){var l=t[0].match(RegExp("\r\n"+vCalendar.re.contentline_parse,"m")),o=vcalendarSplitValue(l[4],";");if(""!=o[0]||""!=o[1]){""!=(n=o[0])&&""!=o[1]&&(n+=" "),n+=o[1]}else{var a=("\r\n"+e).match(RegExp("\r\n"+vCalendar.re.contentline_FN,"m"));if(null!=a&&1==a.length)var n=(l=a[0].match(RegExp("\r\n"+vCalendar.re.contentline_parse,"m")))[4]}return n}return!1},this.insertEvent=function(e,t,l,o,a,n){makeActive=null;var i=l.uid.substring(0,l.uid.lastIndexOf("/")+1),s={};if(null!=(s=a?globalEventList.events:globalEventList.todos)[i][l.uid]){if(s[i][l.uid].etag==l.etag)return checkEventLoader(globalResourceCalDAVList.counterList[t.uid+" "+t.listType],!1),0;this.removeOldEvent(l.uid,!1,a),makeActive=l.uid}if(a){var d=getvCalendarstart(l);if(0==d||-1==d||null==d||null==d)return console.log("Error: '"+l.uid+"': unable to parse vEvent"),checkEventLoader(globalResourceCalDAVList.counterList[t.uid+" "+t.listType],!0),!1;l.sortStart=d,globalEventList.events[i][l.uid]=l}else globalEventList.todos[i][l.uid]=l;if(null!=makeActive)return globalEventList.loadEventByUID(makeActive,a,n),0;var r=l.uid;if(i=r.substring(0,r.lastIndexOf("/")+1),a?0==vcalendarToData(t,l,!0)&&console.log("Error: '"+l.uid+"': unable to parse vEvent"):0==vcalendarTodoData(t,l,!0)&&console.log("Error: '"+l.uid+"': unable to parse vTodo"),a){if(null==l.counter)if(-1!=globalVisibleCalDAVCollections.indexOf(i)||globalSettings.displayhiddenevents.value)refetchCalendarEvents();else{var v=$("#main").width()-$("#calendar").width();$("#calendar").fullCalendar("removeEvents","fooUID");var c=$("#main").width()-$("#calendar").width();rerenderCalendar(v!=c)}}else null==l.counter&&(-1!=globalVisibleCalDAVTODOCollections.indexOf(i)||globalSettings.displayhiddenevents.value)&&refetchTodoEvents();null!=l.counter&&checkEventLoader(globalResourceCalDAVList.counterList[t.uid+" "+t.listType],!0),e&&!a&&$("#todoList").fullCalendar("selectEvent",$('[data-id="'+l.uid+'"]'))},this.checkAndTouchIfExists=function(e,t,l,o){return null!=globalEventList.events[e]&&null!=globalEventList.events[e][t]?(globalEventList.events[e][t].timestamp=o,globalEventList.events[e][t].etag==l):null!=globalEventList.todos[e]&&null!=globalEventList.todos[e][t]&&(globalEventList.todos[e][t].timestamp=o,globalEventList.todos[e][t].etag==l)},this.removeOldEvents=function(e,t,l){if(l){for(var o=0;o<globalResourceCalDAVList.collections.length;o++)if(null!=globalResourceCalDAVList.collections[o].uid)for(var a in globalEventList.events[globalResourceCalDAVList.collections[o].uid]){null!=(n=globalEventList.events[globalResourceCalDAVList.collections[o].uid][a]).timestamp&&0==n.uid.indexOf(e)&&n.timestamp<t&&globalEventList.removeOldEvent(n.uid,!0,l)}}else for(o=0;o<globalResourceCalDAVList.TodoCollections.length;o++)if(null!=globalResourceCalDAVList.TodoCollections[o].uid)for(var a in globalEventList.todos[globalResourceCalDAVList.TodoCollections[o].uid]){var n;null!=(n=globalEventList.todos[globalResourceCalDAVList.TodoCollections[o].uid][a]).timestamp&&0==n.uid.indexOf(e)&&n.timestamp<t&&globalEventList.removeOldEvent(n.uid,!0,l)}},this.removeOldEvent=function(e,t,l){var o=e.substring(0,e.lastIndexOf("/")+1),a=null;l=!0;if(null!=globalEventList.events[o]&&null!=globalEventList.events[o][e]?(a=e,delete globalEventList.events[o][e],l=!0):null!=globalEventList.todos[o]&&null!=globalEventList.todos[o][e]&&(a=e,delete globalEventList.todos[o][e],l=!1),null!=a){if(t)if(deleteEventFromArray(a),l)refetchCalendarEvents();else{var n="";null!=globalCalTodo&&(n=$(".fc-view-todo .fc-list-day").find(".fc-event:visible").index($('[data-repeat-hash="'+globalCalTodo.repeatHash+'"]'))),refetchTodoEvents(),-1!=n&&$(".fc-view-todo .fc-list-day").find(".fc-event:visible").length>0&&n>$(".fc-view-todo .fc-list-day").find(".fc-event:visible").length-1?$("#todoList").fullCalendar("selectEvent",$($(".fc-view-todo .fc-list-day").find(".fc-event:visible").get($(".fc-view-todo .fc-list-day").find(".fc-event:visible").length-1))):-1!=n&&$(".fc-view-todo .fc-list-day").find(".fc-event:visible").length>0&&n<=$(".fc-view-todo .fc-list-day").find(".fc-event:visible").length-1?$("#todoList").fullCalendar("selectEvent",$($(".fc-view-todo .fc-list-day").find(".fc-event:visible").get(n))):$("#CATodo").attr("style","display:none")}l?delete globalEventList.repeatable[e]:delete globalEventList.repeatableTodo[e]}},this.loadEventByUID=function(e,t,l){var o="";if("/"!=e.charAt(e.length-1))if(o=e.substring(0,e.lastIndexOf("/")+1),t){if(null!=globalEventList.events[o][e].uid){var a="";globalCalDAVInitLoad||(a=findEventInArray(globalEventList.events[o][e].uid,t)),""!=a&&a.etag!=globalEventList.events[o][e].etag&&(vcalendarToData(globalResourceCalDAVList.getCollectionByUID(o),globalEventList.events[o][e],!1),l||-1==globalVisibleCalDAVCollections.indexOf(o)&&!globalSettings.displayhiddenevents.value?l&&checkEventLoader(globalResourceCalDAVList.counterList[o+" "+globalResourceCalDAVList.getCollectionByUID(o).listType],!0):refetchCalendarEvents())}}else if(null!=globalEventList.todos[o][e].uid){a="";if(globalCalDAVInitLoad||(a=findEventInArray(globalEventList.todos[o][e].uid,t)),""!=a&&a.etag!=globalEventList.todos[o][e].etag&&(vcalendarTodoData(globalResourceCalDAVList.getCollectionByUID(o),globalEventList.todos[o][e],!1),-1!=globalVisibleCalDAVTODOCollections.indexOf(o)||globalSettings.displayhiddenevents.value))if($("#todoList").fullCalendar("allowSelectEvent",!1),refetchTodoEvents(),$("#todoList").fullCalendar("allowSelectEvent",!0),$("#showTODO").val()==e){var n=findEventInArray(globalEventList.todos[o][e].uid,!1,null!=globalCalTodo?globalCalTodo.repeatHash:null);if(""!=n){if(null!=globalCalTodo)if(!l||$("#showTODO").val()!=e||"true"!=$("#repeatTodo").val()&&""==$("#recurrenceIDTODO").val())$($(".fc-view-todo .fc-list-day").find('.fc-event[data-repeat-hash="'+$("#todoList").fullCalendar("getView").selectedElement+'"]')).length>0?$("#todoList").fullCalendar("selectEvent",$($(".fc-view-todo .fc-list-day").find('.fc-event[data-repeat-hash="'+$("#todoList").fullCalendar("getView").selectedElement+'"]'))):showTodoForm(globalCalTodo,"show");else if(globalCalTodo.repeatHash!=n.repeatHash){var i=globalCalTodo.title;showTodoForm({title:i,id:e},"show","",!0),$("#editAllTODO").css("visibility","hidden"),$("#editFutureTODO").css("visibility","hidden"),$("#editOnlyOneTODO").css("visibility","hidden"),$("#repeatConfirmBoxContentTODO").html("<b>"+i+"</b> "+localization[globalInterfaceLanguage].repeatChangeTxt),$("#repeatConfirmBoxQuestionTODO").html(localization[globalInterfaceLanguage].repeatTodoChangeTxtClose)}else $("#todoList").fullCalendar("selectEvent")}else $("#CATodo").attr("style","display:none")}else $("#todoList").fullCalendar("selectEvent",null,!0)}}}