Skip to content

Instantly share code, notes, and snippets.

@shanwixcode
Last active June 28, 2020 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanwixcode/95385c55ead92e05e69719bee79c80f0 to your computer and use it in GitHub Desktop.
Save shanwixcode/95385c55ead92e05e69719bee79c80f0 to your computer and use it in GitHub Desktop.
Wix Code - Web App For Google Calendar API
import {client, getAuthUrl, generateTokens} from 'backend/config.jsw';
export function clientConfig_keyPress(event) {
if (event.key === "Enter") {
let str = $w('#clientConfig').value;
if (str.length === 0)
return;
client(str).then(item => {
$w('#configUploaded').show();
enableCodeButton();
})
.catch(error => {
console.log(error);
});
}
}
export function enableCodeButton() {
if ($w('#configUploaded').hidden === false) {
getAuthUrl().then((url) => {
$w("#getCode").link = url;
$w("#getCode").enable();
}).catch(console.log);
}
}
export function authKey_keyPress(event) {
if (event.key === "Enter") {
let str = $w('#authKey').value;
if (str.length === 0)
return;
generateTokens(str).then(() => {
$w('#authSuccess').show();
})
.catch(error => {
console.log(error);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment