-
Notifications
You must be signed in to change notification settings - Fork 829
/
index.html
110 lines (91 loc) · 2.85 KB
/
index.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<html>
<head>
<meta charset="utf-8">
<title>Employee table listing</title>
<link rel="stylesheet" type="text/css" href="css/app.css" >
<style>
iframe:focus {
outline: none;
}
iframe[seamless] {
display: block;
}
</style>
</head>
<body>
<div id="sideNav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()" class="staff">×</a>
<a href="javascript:switchSrc('listAll.html')" class="staff">List All</a>
<a href="javascript:switchSrc('listById.html')" class="staff">Search By Id</a>
<a href="javascript:switchSrc('listByName.html')" class="manager">Update Employee Record</a>
<a href="javascript:switchSrc('incrementSalary.html')" class="manager">Increment Salary</a>
<a href="javascript:switchSrc('about.html')">About</a>
</div>
<div id="main">
<div align="right">
<div
id="myrole"
style="display:inline; color:#393318; display: block; background-color:#eff0f1;position: absolute; top: 20px; right: 8%;"
>myrole</div>
<a href="javascript:void(0)"
onclick="logout()"
class="staff"
style="display: block; position: absolute; top: 20px; right: 1%">Logout</a>
</div>
<div>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ Java 2 Days HR Web Application </span>
</div>
<div>
<iframe id="content"
src="about.html"
frameborder="0"
style="overflow:hidden;height:100%;width:100%"
height="100%"
width="100%"></iframe>
</div>
</div>
<script>
function openNav() {
document.getElementById("sideNav").style.width = "256px";
document.getElementById("main").style.marginLeft = "256px";
}
function closeNav() {
document.getElementById("sideNav").style.width = "0";
document.getElementById("main").style.marginLeft= "0";
}
function switchSrc(src) {
document.getElementById('content').src = src;
}
function logout() {
var xmllogout = new XMLHttpRequest();
xmllogout.open("GET", "WebController?logout=true", true, "_", "_");
xmllogout.withCredentials = true;
// Invlalid credentials to fake logout
xmllogout.setRequestHeader("Authorization", "Basic 00001");
xmllogout.send();
xmllogout.onreadystatechange = function() {
window.location.replace("index.html");
}
return true;
}
var xmlhttp = new XMLHttpRequest();
var url = "getrole";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
role = xmlhttp.responseText;
console.log("role: " +role);
if (role == "staff") {
console.log ("disabling manager");
var x = document.getElementsByClassName('manager');
for(i = 0; i < x.length; ++i) {
x[i].style.display = 'none';
}
}
document.getElementById('myrole').innerHTML = ' '+role+' ';
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
</script>
</body>
</html>