This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aha-api.html
92 lines (79 loc) · 2.86 KB
/
aha-api.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<html>
<head>
<title>Example of Aha! Javascript API</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" type="text/css"></link>
<script type="text/javascript" charset="utf-8" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script src="//ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script type="text/javascript" charset="utf-8" src="https://secure.aha.io/assets/javascript_api/aha-api.latest.js"></script>
<style>
.feature {
border-top: 1px solid #0073cf;
margin-top: 10px;
margin-bottom: 30px;
}
.feature .reference-num {
float: left;
padding-right: 10px;
}
.feature .name {
float: left;
font-weight: bold;
}
.feature > .description {
clear: left;
margin-left: 20px;
}
.requirement {
position: relative;
margin-top: 15px;
margin-left: 20px;
}
.requirement .reference-num {
position: absolute;
font-weight: bold;
}
.requirement .description {
margin-left: 120px;
}
</style>
</head>
<body class="container">
<form id="controls">
<input type="text" placeholder="Aha! subdomain" id="subdomain"></input>
<input type="text" placeholder="Product key" id="product-key"></input>
<input type="submit" class="btn" value="Load features"></input>
</form>
<script id="feature-template" type="text/x-jquery-tmpl">
<div class="feature">
<div class="reference-num">${reference_num}</div>
<div class="name">${name}</div>
<div class="description">{{html description.body}} </div>
{{each requirements}}
<div class="requirement">
<div class="reference-num">${reference_num}</div>
<div class="description">{{html description.body}}</div>
</div>
{{/each}}
</div>
</script>
<div id="features"></div>
<script>
$("#controls").submit(function() {
new AhaApi({
accountDomain: $("#subdomain").val(),
clientId: "e8e0c10544012f37b16b09e1e65135f13cf7d57e13eb16dc111888e8a0d60bb8", // NOTE: replace this with your client ID.
redirectUri: "https://buildingbridge.github.io/IDX_Publisher/aha-api.html"
}).authenticate(function(api, success, message) {
var productKey = $("#product-key").val();
// Hide the controls.
$("#controls").remove();
// Fetch up to 200 features in one big fetch.
api.get("/products/" + productKey + "/features", {per_page: 200, fields: 'reference_num,name,description,requirements'}, function(response) {
$("#feature-template").tmpl(response.features).appendTo("#features");
});
});
return false;
});
</script>
</body>