mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-23 07:03:26 +03:00
Added try-catch block when activating google cal sync
This commit is contained in:
parent
8f974150c5
commit
34a7277a1e
1 changed files with 7 additions and 1 deletions
|
@ -47,6 +47,7 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {};
|
|||
// When the browser redirects to the google user consent page the "window.document" variable
|
||||
// becomes "undefined" and when it comes back to the redirect URL it changes back. So check
|
||||
// whether the variable is undefined to avoid javascript errors.
|
||||
try {
|
||||
if (windowHandle.document !== undefined) {
|
||||
if (windowHandle.document.URL.indexOf(redirectUrl) !== -1) {
|
||||
// The user has granted access to his data.
|
||||
|
@ -81,6 +82,11 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {};
|
|||
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
|
||||
}
|
||||
}
|
||||
} catch(Error) {
|
||||
// Accessing the document object before the window is loaded throws an error, but
|
||||
// it will only happen during the initialization of the window. Attaching "load"
|
||||
// event handling is not possible due to CORS restrictions.
|
||||
}
|
||||
}, 100);
|
||||
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue