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
|
// 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
|
// 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.
|
// whether the variable is undefined to avoid javascript errors.
|
||||||
|
try {
|
||||||
if (windowHandle.document !== undefined) {
|
if (windowHandle.document !== undefined) {
|
||||||
if (windowHandle.document.URL.indexOf(redirectUrl) !== -1) {
|
if (windowHandle.document.URL.indexOf(redirectUrl) !== -1) {
|
||||||
// The user has granted access to his data.
|
// The user has granted access to his data.
|
||||||
|
@ -81,6 +82,11 @@ window.BackendCalendarGoogleSync = window.BackendCalendarGoogleSync || {};
|
||||||
}, 'json').fail(GeneralFunctions.ajaxFailureHandler);
|
}, '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);
|
}, 100);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue