forked from benc-uk/csa-widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
widget-skeleton.html
44 lines (34 loc) · 998 Bytes
/
widget-skeleton.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
<!-- HTML and widget display -->
<div id="my_widget">
<h4>Widget Title</h4>
<hr/>
<div id="my_content">
</div>
</div>
<!-- Javascript and main code -->
<script type="text/javascript">
// Start here, call some API
makeApiCall();
// Make AJAX call to external API, using jQuery
function makeApiCall(svc_id, node_id) {
$.ajax({
type: "GET",
url: "http://api.nonsense.com/api/blah/12345",
success: processResult,
error: errorLog
});
}
// Callback function used to process data returned by the API
function processResult(data, textStatus, apiXHR) {
var result = data.something;
$('#my_content').append("Hello World "+ result);
}
// Simple error logging
function errorLog(apiXHR, textStatus, errorThrown) {
console.log("API Error: " + errorThrown);
}
</script>
<!-- Stylesheet -->
<style type="text/css">>
#my_widget {background-color:#73B9FF; padding:5px; color:white;}
</style>