-
Notifications
You must be signed in to change notification settings - Fork 0
/
thirukkural.html
97 lines (69 loc) · 2.24 KB
/
thirukkural.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
93
94
95
96
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hackathon - POC</title>
<meta name="description" content="Hackathon POC">
<meta name="author" content="Mani">
<link rel="stylesheet" href="style.css">
<script src="jquery-1.11.3.min.js"></script>
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
<script type="text/javascript">
$(document).ready(function() {
getThirukkural();
});
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function getThirukkural(){
var tno = getRandomInt(1, 1330);
console.log('in getThirukkural');
//pass number
//http://52.36.211.72:5555/gateway/Thirukkural/1.0/{number}
//Query Params
//{'appid','x5mwe55oderut'}
//Auth-Header
//x-Gateway-APIKey => 4fbacb53-4a39-407e-816c-a691dd3839e0
var apiKey = "4fbacb53-4a39-407e-816c-a691dd3839e0";
var apiurl="http://52.36.211.72:5555/gateway/Thirukkural/1.0/"+ tno+ "?APIKey=" + apiKey;
var paramData = {'appid':'x5mwe55oderut'};
//callAPI(apiurl, httpType, apiKey, paramData, successCallBack, errorCallBack)
$.ajax({
url: apiurl,
//headers: {"x-Gateway-APIKey" : apiKey},
// if you using below proxy passes use --> url: '/xxx',
type: 'GET', //or GET
crossDomain : true,
data:paramData
}).then(function(xmlData) {
console.log('call complete');
//var xml = $.parseXML(xmlData);
//alert(xmlData);
var line1 = $(xmlData).find("Kural").find("Line1").text();
var line2 = $(xmlData).find("Kural").find("Line2").text();
var enTranslation = $(xmlData).find("Kural").find("Translation").text();
console.log(line1);
console.log(line2);
console.log(enTranslation);
var tdiv = $("<div/>");
tdiv.append($("<p/>").html("Kural No : " + tno));
tdiv.append($("<p/>").html(line1));
tdiv.append($("<p/>").html(line2));
tdiv.append($("<p/>").html(enTranslation));
$("#result_thirukkural").html('').append(tdiv);
});
}
</script>
</head>
<body>
<div id="container">
<div class="row">
<p>thirukkural Demo</p>
<div id="result_thirukkural"></div>
<div class="thirukkural"></div>
</div>
</div>
</body>
</html>