-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinputValues.php
More file actions
108 lines (107 loc) · 3.77 KB
/
inputValues.php
File metadata and controls
108 lines (107 loc) · 3.77 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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>
Kreegur - input values
</title>
<style>
* {
box-sizing: border-box;
}
body {
font-family:arial;
}
td {
padding:5px;
}
</style>
<link href="css/jquery-ui.css" rel="stylesheet">
</head>
<body>
<table>
<thead>
<tr>
<td>
Name
</td>
<td>
Value
</td>
<td>
Action
</td>
</tr>
</thead>
<tbody id="latestValues">
</tbody>
</table>
<input type="text" id="inputNewTagName">
<button class="myButtons" id="buttonNewTag">Add new tag</button>
<script src = "js/jquery-3.3.1.min.js"></script>
<script src = "js/jquery-ui.min.js"></script>
<script>
var nodeId = -1;
$(document).ready(function(){
//alert("working");
$('body').on('click','.updateValue',function(){
var tagName = $(this).attr('id');
var value = $("#input"+tagName).val();
//alert("Should update tagName: "+tagName+" to value: "+value);
$.post(
'api/updateTag.php',
{
tagName: tagName,
value: value
},
function(data){
console.log(JSON.stringify(data));
},
'json'
);
});
$("#buttonNewTag").click(function(){
var tagName = $("#inputNewTagName").val();
value = '0.0';
if(tagName.length > 0){
$.post(
'api/updateTag.php',
{
tagName: tagName,
value: value
},
function(data){
console.log(JSON.stringify(data));
$("#inputNewTagName").val('');
updateValues();
},
'json'
);
} else {
alert("Must enter new tag name");
}
});
updateValues();
});
function updateValues(){
$.post(
'api/latestValues.php',
function(data){
console.log(JSON.stringify(data));
$("#latestValues").empty();
$.each(data.values,function(index, value){
var html = '<tr>';
html += '<td>'+value.name+'</td>';
html += '<td><input type="text" id="input'+value.name+'" value="'+value.value+'"></td>';
html += '<td><button class="myButtons updateValue" id="'+value.name+'">Update</button></td>';
html += '</tr>';
$("#latestValues").append(html);
});
$(".myButtons").button();
},
'json'
);
}
</script>
</body></html>