-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataupdate.html
More file actions
72 lines (68 loc) · 2.65 KB
/
dataupdate.html
File metadata and controls
72 lines (68 loc) · 2.65 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
<body><p>
Remote MyJSON Chip/Virus Data Updater: Paste the updated JSON data here.
</p>
<textarea id="update" rows="20" cols="40"></textarea>
<br />
<p>
<span id="up_area">
<input type="radio" name="area" value="chip" checked> Chip <input type="radio" name="area" value="mvl"> Canon Virus<br> <input type="radio" name="area" value="cvl"> Custom/Meta Virus<br><br>
</span>
API Link for Target Data:
</p>
<textarea id="targeturl" rows="1" cols="40">https://api.myjson.com/bins/1c6zx</textarea>
<br />
<p>
API Link for Target Timestamp Data:
</p>
<textarea id="targettimeurl" rows="1" cols="40">https://api.myjson.com/bins/10uw9</textarea>
<br />
<p>
Status:
</p>
<textarea id="data" rows="1" cols="40"></textarea>
<br />
<input id="clickMe" type="button" value="Upload Data" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$("input[name='area']").change(function(){
switch($("input[name='area']:checked").val()) {
case "chip": $('#targeturl').val('https://api.myjson.com/bins/1c6zx');
$('#targettimeurl').val('https://api.myjson.com/bins/10uw9');
break;
case "mvl": $('#targeturl').val('https://api.myjson.com/bins/58zld');
$('#targettimeurl').val('https://api.myjson.com/bins/42wgx');
break;
case "cvl": $('#targeturl').val('https://api.myjson.com/bins/4ioie');
$('#targettimeurl').val('https://api.myjson.com/bins/1683a');
break;
}
});
var time = { "textStatus": "", "timestamp": 0, "timestring": "" };
$("#clickMe").click(function () {
//var updatedObj = update.value;
var updatedData = update.value;
// do update
var updateOK = $.ajax({
url: targeturl.value,
type: "PUT",
data: updatedData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data, textStatus, jqXHR) {}
});
updateOK.done(function(){
time.textStatus = "success";
time.timestamp = $.now();
time.timestring = new Date(time.timestamp).toISOString();
$("#data").val("success: " + time.timestamp + " (" + time.timestring + ")");
$.ajax({
url: targettimeurl.value,
type: "PUT",
data: JSON.stringify(time),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data, textStatus, jqXHR) {}
});
});
});</script>
</body>