Skip to content

Instantly share code, notes, and snippets.

@shanwixcode
Last active Jun 28, 2020
Embed
What would you like to do?
Wix Code - Google Calendar API Page Code
import {insertNewEvent} from 'backend/createEvent.jsw';
$w.onReady(function () {
});
var startdateNumber;
var startmonth;
var startyear;
var starttime;
var enddateNumber;
var endmonth;
var endyear;
var endtime;
var attendees = [];
export function startDate_change(event) {
let date = $w("#startDate").value;
startdateNumber = date.getDate();
let month = date.getMonth();
startmonth = month + 1;
startyear = date.getFullYear();
}
export function startTime_change(event) {
starttime = $w("#startTime").value;
}
export function endDate_change(event) {
let date = $w("#endDate").value;
enddateNumber = date.getDate();
let month = date.getMonth();
endmonth = month + 1;
endyear = date.getFullYear();
}
export function endTime_change(event) {
endtime = $w("#endTime").value;
}
export async function insertEvent_click(event) {
let start = startyear + '-' + startmonth + '-' + startdateNumber + 'T' + starttime + ':00' + '+05:30'; //+05:30 is GMT +05:30 which is my timezone, replace it with your own timezone
let end = endyear + '-' + endmonth + '-' + enddateNumber + 'T' + endtime + ':00' + '+05:30'; //+05:30 is GMT +05:30 which is my timezone, replace it with your own timezone
let summary = $w('#summary').value;
let location = $w('#location').value;
let description = $w('#desc').value;
let data = {
email: $w("#email1").value
};
await attendees.push(data);
pushAnother(summary, location, description, start, end);
}
async function pushAnother(summary, location, description, start, end) {
let data = {
email: $w("#email2").value
};
await attendees.push(data);
insertNewEvent(summary, location, description, start, end, attendees);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment