forked from zendesk/demo_apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (24 loc) · 793 Bytes
/
app.js
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
(function() {
return {
resources: {
// Pattern for "subdomain.zendesk.com" extraction.
PATTERN: /[a-zA-Z0-9]+\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+/
},
events: {
'pane.activated': 'showAppSettings'
},
showAppSettings: function(e) {
this.switchTo('mainPage', {
settings: this.settings, // An object that contains all the setting key-value pairs
email: this.currentUser().email(),
uri: this.getDomainFromURL(e.currentTarget.baseURI), // This gets the matched URL
installation_id: this.installationId()
});
},
getDomainFromURL: function(baseURI) {
// Run regular expression to extract domain url
var regexResult = this.resources.PATTERN.exec(baseURI);
return regexResult[0];
}
};
}());