-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsession.html
More file actions
164 lines (132 loc) · 6.79 KB
/
session.html
File metadata and controls
164 lines (132 loc) · 6.79 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<html>
<head>
<!-- Base head -->
<!--
customer_name=Adam&to_number=+19995551212&product_name=Star%20Wars%20Collectables&product_url=a.co/d/3MQCqlN
-->
<title>Session Demo</title>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="assets/base.css">
<script language="javascript">
function submitToAPI(e) {
$("#response").html("");
e.preventDefault();
var URL = $("#gateway_url").val();
var id = $("#id").val();
var value = $("#value").val();
var key = $("#key").val();
var data = {
session_id : id,
session_data : value,
key : key
};
// alert("Ready to send to: "+ to_number +" body: "+ body);
$.ajax({
type: "POST",
url : URL,
dataType: "json",
crossDomain: "true",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
success: function (data) {
console.log(data)
if(data.statusCode == 200) {
alert("Fantastic, response: "+ data.body);
} else {
$("#response").html("Error: "+ data.statusCode +", error: "+ data.body);
}
// document.getElementById("contact-form").reset();
// location.reload();
},
error: function (data) {
$("#response").html("Error: "+ data.body);
// show an error message
alert("Sorry, we had a problem: "+ data.statusCode);
}
});
}
function getSession(e) {
$("#get_response").html("");
e.preventDefault();
var URL = $("#cache_url").val();
var id = $("#get_id").val();
var key = $("#key").val();
var data = {
session_id : id,
key : key
};
// alert("Ready to send to: "+ to_number +" body: "+ body);
$.ajax({
type: "GET",
url : URL,
crossDomain: "true",
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: data,
success: function (data) {
console.log(data)
if(data.statusCode == 200) {
alert("Fantastic, response: "+ data.body);
$("#get_response").html("Response: "+ data.body);
} else {
$("#get_response").html("Error: "+ data.statusCode +", error: "+ data.body);
}
// document.getElementById("contact-form").reset();
// location.reload();
},
error: function (data) {
$("#get_response").html("Error: "+ data.body);
// show an error message
alert("Sorry, we had a problem: "+ data.statusCode);
}
});
}
</script>
</head>
<table style="width:100%;margin:40px auto;">
<tr>
<td colspan=2>
<div style="width:400px; margin: 10px auto;">
API Gateway Url: <input id=gateway_url type="text">
</div>
</td>
</tr>
<tr>
<td>
<div style="width:400px; margin: 10px auto;">
<div style="margin:15px auto; width:300;">
Store Sessions!<br>
</div>
<div style="margin:15px auto; width:500; font-family:Arial, Helvetica, sans-serif">
<!-- notes can go here -->
</div>
<form id="sendform" class="signup-form auth-form" >
<div class="input-element"><label class="input-element__label">Session ID</label><input class="input-element__input" type="text" id="id" placeholder="ID" value=""><span class="input-element__error"> </span><div class="input-element__helper"></div></div>
<div class="input-element"><label class="input-element__label">Session Value</label><input class="input-element__input" type="text" id="value" placeholder="value" value=""><span class="input-element__error"> </span><div class="input-element__helper"></div></div>
<input class="" type="hidden" id="key" value="key123">
<span class="select-element__error"> </span>
<button class="button-element button-element--primary signup-form-submit-button" type="button" onClick="submitToAPI(event)" style="margin-top:20px;"><span class="text">Send!</span></button>
<div style="padding:40px" id="response">Any error info will go here</div>
</form>
</div>
</td>
<td>
<div style="width:400px; margin: 10px auto;">
<div style="margin:15px auto; width:300;">
Get Sessions!<br>
</div>
<div style="margin:15px auto; width:500; font-family:Arial, Helvetica, sans-serif">
<!-- notes can go here -->
</div>
<form id="sendform" class="signup-form auth-form" >
<div class="input-element"><label class="input-element__label">Session ID</label><input class="input-element__input" type="text" id="get_id" placeholder="ID" value=""><span class="input-element__error"> </span><div class="input-element__helper"></div></div>
<input class="" type="hidden" id="key" value="key123">
<span class="select-element__error"> </span>
<button class="button-element button-element--primary signup-form-submit-button" type="button" onClick="getSession(event)" style="margin-top:20px;"><span class="text">GET!</span></button>
<div style="padding:40px" id="get_response">Any error info will go here</div>
</form>
</div>
</td>
</tr>
</table>
</html>