-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaffAssignment.html
More file actions
173 lines (155 loc) · 4.59 KB
/
staffAssignment.html
File metadata and controls
173 lines (155 loc) · 4.59 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
165
166
167
168
169
170
171
172
173
<!DOCTYPE Html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>OAS</title>
<link rel="stylesheet" href="css/semantic.min.css"></link>
<style>
img{
margin-bottom:-10px;
margin-top:-10px;
}
body{
padding:20px;
}
</style>
</head>
<body>
<div class="ui container">
<div id="entry">
<!-- -->
<table class="ui table" >
<thead>
<tr>
<th>Course id</th>
<th>Course Name</th>
<th>Faculty id</th>
</tr>
</thead>
<tbody id="tableBody">
<!--tr>
<td>
<div class="ui input"><input type="text" placeholder="Subject name.." name="subject" >
</div>
</td>
<td>
<div class="ui input"><input type="text" placeholder="Faculty name.." name="faculty" >
</div>
</td>
</tr-->
</tbody>
</table>
<center>
<button class="ui green button" onclick="save()">Save</button>
<button class="ui green button" onClick="call()">Add new</button>
</center>
</div>
<!-- -->
<div id="current">
<span id="currentLabel">Current Entry</span>
<table class="ui table" id = "currentTable">
</table>
</div>
</div>
<script src="js/jquery-3.1.1.min.js"></script>
<!--jquery should be loaded before sematic and your custom javascript -->
<script src="js/semantic.min.js"></script>
<script>
$(document).ready(function() {
$('.ui.selection.dropdown').dropdown();
});
var height = $("body").innerHeight();
var hgt = height*0.15;
$('.margin').height(hgt);
$('.tabular.menu .item').tab();
count = 5;
function call(){
console.log(count); //debugging
count++;
i = count - 1;
s = `<tr><td>
<div class="ui input"><input type="text" placeholder="Course id `+(i+1)+`" id="courseId` + i + `" ></div>
</td>
<td>
<div class="ui input"><input type="text" placeholder="Course name `+(i+1)+`" id="courseName` + i + `" ></div>
</td>
<td>
<div class="ui input"><input type="text" placeholder="Faculty id `+(i+1)+`" id="facultyId` + i + `" ></div>
</td></tr>`
$("#tableBody").append(s);
}
function hideEntry(a){
if(a == true){
$("#entry").hide();
$("#current").show();
}else{
$("#entry").show();
$("#current").hide();
}
}
$("#current").hide();
$.get("getTimetable",{},function(result){
if(result.message == "done"){
data = result.timetable;
if (data.length > 0 ){
hideEntry(true);
s = "<thead><tr><th>Course Id</th><th>Course Name</th><th>Faculty</th><tbody>";
for ( i in data){
s = s + "<tr><td>"+data[i].subjectCode +"</td><td>"+ data[i].courseName + "</td><td>" + data[i].facultyId +"</td></tr>";
}
s = s + "</tbody>";
$("#currentTable").html(s);
}else{
}
}
});
function save(){
//count = document.getElementById('count').value;
arr = [];
for ( i=0; i < count;i++){
obj = {};
ci = $("#courseId"+i).val();
fi = $("#facultyId"+i).val();
cn = $("#courseName"+i).val();
obj.courseName = cn;
obj.facultyId = fi;
obj.courseCode = ci;
arr.push(obj);
}
console.log(arr);
data = {};
data.facultyAssignment = arr;
console.log(data);
jsonData = JSON.stringify(data);
$.get("timetable",{data:jsonData},function(result){
//alert(result.message);
console.log(result);
if(result.message == "done"){
alert(result.message);
}else{
alert("Error saving try again");
console.log(result.error);
}
});
}
loadTable();
function loadTable(){
s = "";
for ( i = 0 ; i < 5; i++){
s = s + `<tr><td>
<div class="ui input"><input type="text" placeholder="Course id `+(i+1)+`" id="courseId` + i + `" ></div>
</td>
<td>
<div class="ui input"><input type="text" placeholder="Course name `+(i+1)+`" id="courseName` + i + `" ></div>
</td>
<td>
<div class="ui input"><input type="text" placeholder="Faculty id `+(i+1)+`" id="facultyId` + i + `" ></div>
</td></tr>`
}
$("#tableBody").html(s);
}
</script>
</body>
</html>