can export calendar into ics file, still having issues with mac recurring
This commit is contained in:
@@ -10,7 +10,11 @@
|
||||
|
||||
<body>
|
||||
<div id='calendar' style=" width: 75%; margin-left:auto; margin-right:auto;"></div>
|
||||
<button id="export" class="matbut" style="font-size:medium; background:#4CAF50;margin: 10px;">Export Schedule</button>
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
|
||||
<script src='js/calendar.js'></script>
|
||||
<script src='js/ics.min.js'></script>
|
||||
@@ -41,18 +41,25 @@ chrome.runtime.onMessage.addListener(function (request, sender, response) {
|
||||
|
||||
/* Initially set the course data in storage */
|
||||
chrome.runtime.onInstalled.addListener(function (details) {
|
||||
if (details.reason == "install" || details.reason == "update") {
|
||||
var arr = new Array();
|
||||
chrome.storage.sync.set({
|
||||
savedCourses: arr
|
||||
}, function () {
|
||||
console.log('initial course list');
|
||||
});
|
||||
chrome.storage.sync.set({
|
||||
courseConflictHighlight: true
|
||||
}, function () {
|
||||
console.log('initial highlighting: true');
|
||||
if (details.reason == "install") {
|
||||
chrome.storage.sync.get('savedCourses', function(data){
|
||||
if(!data.savedCourses){
|
||||
console.log(data.savedCourses);
|
||||
var arr = new Array();
|
||||
chrome.storage.sync.set({
|
||||
savedCourses: arr
|
||||
}, function () {
|
||||
console.log('initial course list');
|
||||
});
|
||||
chrome.storage.sync.set({
|
||||
courseConflictHighlight: true
|
||||
}, function () {
|
||||
console.log('initial highlighting: true');
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if(details.reason == "update"){
|
||||
console.log("updated");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -74,34 +74,7 @@ $(function () {
|
||||
} else {
|
||||
$("#register").text("Register").css("background-color", "#4CAF50");
|
||||
}
|
||||
var cal = ics();
|
||||
for (i in savedCourses) {
|
||||
let course = savedCourses[i];
|
||||
var dtmap = makeMap(course.datetimearr);
|
||||
var timearr = Array.from(dtmap.keys());
|
||||
var dayarr = Array.from(dtmap.values());
|
||||
console.log(timearr);
|
||||
console.log(dayarr);
|
||||
for (var i = 0; i < dayarr.length; i++) {
|
||||
var place = findLoc(dayarr[i], timearr[i], course.datetimearr);
|
||||
var building = place.substring(0, place.search(/\d/) - 1);
|
||||
if (building == "") {
|
||||
building = "Undecided Location";
|
||||
|
||||
}
|
||||
//cal.addEvent(subject, description, location, begin, end, rrule)
|
||||
let rrurle = {
|
||||
freq: "WEEKLY",
|
||||
interval: 1,
|
||||
byday: [""]
|
||||
|
||||
}
|
||||
// cal.addEvent(course.coursename, `with${course.profname}`, building, '', '', '');
|
||||
// output += `<p class='time'><span>${dayarr[i]}</span>: ${timearr[i].split(",")[0]} to ${timearr[i].split(",")[1]}<span style='float:right';><a target='_blank' href='https://maps.utexas.edu/buildings/UTM/${building}'>${place}</a></span></p>`;
|
||||
}
|
||||
|
||||
}
|
||||
cal.download();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -145,6 +118,47 @@ $(function () {
|
||||
}
|
||||
});
|
||||
|
||||
$("#export").click(function(){
|
||||
var cal = ics();
|
||||
var calendarEvents = $('#calendar').fullCalendar('clientEvents');
|
||||
console.log(calendarEvents);
|
||||
for(i in calendarEvents){
|
||||
let event = calendarEvents[i];
|
||||
var title = event.title;
|
||||
var classname = title.substring(0, title.indexOf('with'));
|
||||
var description = title.substring(title.indexOf('with'));
|
||||
var time = event.start._d.toUTCString();
|
||||
console.log(event.start._i);
|
||||
let rrule = {
|
||||
freq: "WEEKLY",
|
||||
interval: 1,
|
||||
byday: [time.substring(0, time.indexOf(",")-1).toUpperCase()]
|
||||
}
|
||||
cal.addEvent(classname, description, event.building, event.start._i, event.end._i, rrule);
|
||||
}
|
||||
// for (i in savedCourses) {
|
||||
// let course = savedCourses[i];
|
||||
// var dtmap = makeMap(course.datetimearr);
|
||||
// var timearr = Array.from(dtmap.keys());
|
||||
// var dayarr = Array.from(dtmap.values());
|
||||
// console.log(timearr);
|
||||
// console.log(dayarr);
|
||||
// for (var i = 0; i < dayarr.length; i++) {
|
||||
// var place = findLoc(dayarr[i], timearr[i], course.datetimearr);
|
||||
// var building = place.substring(0, place.search(/\d/) - 1);
|
||||
// if (building == "") {
|
||||
// building = "Undecided Location";
|
||||
|
||||
// }
|
||||
// //cal.addEvent(subject, description, location, begin, end, rrule)
|
||||
// cal.addEvent(course.coursename, `with${course.profname}`, building, '', '', '');
|
||||
// // output += `<p class='time'><span>${dayarr[i]}</span>: ${timearr[i].split(",")[0]} to ${timearr[i].split(",")[1]}<span style='float:right';><a target='_blank' href='https://maps.utexas.edu/buildings/UTM/${building}'>${place}</a></span></p>`;
|
||||
// }
|
||||
|
||||
// }
|
||||
cal.download();
|
||||
});
|
||||
|
||||
/* convert from the dtarr and maek the time lines*/
|
||||
function makeLine(datetimearr) {
|
||||
$(".time").remove();
|
||||
@@ -239,13 +253,13 @@ $(function () {
|
||||
// console.log(moment().day(fullday));
|
||||
var fullday = days.get(session[0]);
|
||||
var classInfo = savedCourses[i];
|
||||
console.log(session);
|
||||
var department = classInfo.coursename.substring(0, classInfo.coursename.search(/\d/) - 2);
|
||||
var course_nbr = classInfo.coursename.substring(classInfo.coursename.search(/\d/), classInfo.coursename.indexOf(" ", classInfo.coursename.search(/\d/)));
|
||||
var uncapProf = prettifyName(classInfo.profname);
|
||||
if (uncapProf == "") {
|
||||
uncapProf = "Undecided";
|
||||
}
|
||||
|
||||
var year = moment().day(fullday)._d.toString().split(" ")[3];
|
||||
var monthNum = moment(moment().day(fullday)._d.toString().split(" ")[1], "MMM").format('MM');
|
||||
var beg = `${year}-${monthNum}-`;
|
||||
@@ -268,6 +282,7 @@ $(function () {
|
||||
session[1][1] +
|
||||
":00",
|
||||
color: materialColors[colorCounter],
|
||||
building: session[2],
|
||||
index: i,
|
||||
allday: false
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user