-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot-oauth.js
More file actions
55 lines (50 loc) · 1.67 KB
/
Copy pathbot-oauth.js
File metadata and controls
55 lines (50 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var MainPage = {
init() {
Aj.state.allowMsg = true;
$('.tm-row-toggle').on('click', function () {
var toggleEl = this.querySelector('.tm-toggle');
var value = toggleEl.classList.toggle('tm-toggle-on');
Aj.state.allowMsg = value;
WebApp.HapticFeedback.impactOccurred('soft');
});
var sent = false;
var accept = (allow_phone = false) => Aj.apiRequest('confirm', {qtoken: Aj.state.qtoken, accept_allow_phone: allow_phone, accept_allow_write: Aj.state.allowMsg}, res => {
if (res) {
if (res.ok) {
WebApp.HapticFeedback.notificationOccurred('success');
if (res.redirect) {
const webApp = WebApp;
webApp.openLink(res.redirect);
}
WebApp.close();
}
}
});
Aj.state.onMainButton = () => {
sent = true;
if (Aj.state.request_phone) {
WebApp.showPopup({
title: l('WEB_FALLBACK_REQUEST_PHONE', 'Allow access?'),
message: l('WEB_FALLBACK_REQUEST_PHONE_BODY', {
phone: Aj.state.request_phone,
domain: Aj.state.request_domain,
}),
buttons: [
{type: 'default', id: 'ok', text: 'Allow'},
{type: 'destructive', id: 'deny', text: 'Deny'},
]
}, button_id => {
accept(button_id == 'ok')
});
} else {
accept();
}
};
WebApp.MainButton.setText('Log In');
WebApp.MainButton.show();
WebApp.SecondaryButton.onClick(() => WebApp.close());
WebApp.SecondaryButton.setText('Cancel');
WebApp.SecondaryButton.setParams({ color: '#CC5D52', text_color: '#FFFFFF' })
WebApp.SecondaryButton.show();
},
}