forked from fortydays/website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrainees.html
More file actions
88 lines (73 loc) · 4.89 KB
/
trainees.html
File metadata and controls
88 lines (73 loc) · 4.89 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
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Language" content="ar" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<script src="https://code.jquery.com/jquery-1.8.3.min.js" integrity="sha256-YcbK69I5IXQftf/mYD8WY0/KmEDCv1asggHpJk1trM8=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="https://cdn.rawgit.com/afshinm/Json-to-HTML-Table/master/json-to-table.js"></script>
<link rel="stylesheet" type="text/css" href="hanadi.css" />
<title>أنظمة غيمة - Cloud Systems - التصويت لمتقدّم</title>
<style>
#content{margin-top: 10px;}
table{border-collapse: collapse;}
td{padding: 4px; border: 1px solid #ccc;}
th{padding: 4px; border: 1px solid #ccc; background-color: #f1f1f1;}
</style>
</head>
<body>
<nav>
<ul>
<li>
<a href="index.html">الرئيسيّة</a>
</li>
<li>
<a id="logout" href="#">تسجيل الخروج</a>
</li>
</ul>
</nav>
<div id="trainees"></div>
<div class="container">
<div id="content"></div>
</div>
<script type="text/javascript">
redirectToProfileIfNotLoggedIn();
var traineesTable = document.getElementById('trainees');
// http://json2table.com
function isArray(a){return"[object Array]"===Object.prototype.toString.call(a)}
function isEven(a){return 0==a%2}
function buildArray(a){var e=document.createElement("table"),d,b,c=!1,p=!1,m={},h=-1,n=0,l;l="";if(0==a.length)return"<div></div>";d=e.insertRow(-1);for(var f=0;f<a.length;f++)if("object"!=typeof a[f]||isArray(a[f]))"object"==typeof a[f]&&isArray(a[f])?(b=d.insertCell(h),b.colSpan=2,b.innerHTML='<div class="td_head"></div><table style="width:100%">'+$(buildArray(a[f]),!1).html()+"</table>",c=!0):p||(h+=1,p=!0,b=d.insertCell(h),m.empty=h,b.innerHTML="<div class='td_head'> </div>");else for(var k in a[f])l=
"-"+k,l in m||(c=!0,h+=1,b=d.insertCell(h),m[l]=h,b.innerHTML="<div class='td_head'>"+encodeText(k)+"</div>");c||e.deleteRow(0);n=h+1;for(f=0;f<a.length;f++)if(d=e.insertRow(-1),td_class=isEven(f)?"td_row_even":"td_row_odd","object"!=typeof a[f]||isArray(a[f]))if("object"==typeof a[f]&&isArray(a[f]))for(h=m.empty,c=0;c<n;c++)b=d.insertCell(c),b.className=td_class,l=c==h?'<table style="width:100%">'+$(buildArray(a[f]),!1).html()+"</table>":" ",b.innerHTML="<div class='"+td_class+"'>"+encodeText(l)+
"</div>";else for(h=m.empty,c=0;c<n;c++)b=d.insertCell(c),l=c==h?a[f]:" ",b.className=td_class,b.innerHTML="<div class='"+td_class+"'>"+encodeText(l)+"</div>";else{for(c=0;c<n;c++)b=d.insertCell(c),b.className=td_class,b.innerHTML="<div class='"+td_class+"'> </div>";for(k in a[f])c=a[f],l="-"+k,h=m[l],b=d.cells[h],b.className=td_class,"object"!=typeof c[k]||isArray(c[k])?"object"==typeof c[k]&&isArray(c[k])?b.innerHTML='<table style="width:100%">'+$(buildArray(c[k]),!1).html()+"</table>":b.innerHTML=
"<div class='"+td_class+"'>"+encodeText(c[k])+"</div>":b.innerHTML='<table style="width:100%">'+$(buildTable(c[k]),!1).html()+"</table>"}return e}
function encodeText(a){return $("<div />").text(a).html()}
function buildTable(a){var e=document.createElement("table"),d,b;if(isArray(a))return buildArray(a);for(var c in a)"object"!=typeof a[c]||isArray(a[c])?"object"==typeof a[c]&&isArray(a[c])?(d=e.insertRow(-1),b=d.insertCell(-1),b.colSpan=2,b.innerHTML='<div class="td_head">'+encodeText(c)+'</div><table style="width:100%">'+$(buildArray(a[c]),!1).html()+"</table>"):(d=e.insertRow(-1),b=d.insertCell(-1),b.innerHTML="<div class='td_head'>"+encodeText(c)+"</div>",d=d.insertCell(-1),d.innerHTML="<div class='td_row_even'>"+
encodeText(a[c])+"</div>"):(d=e.insertRow(-1),b=d.insertCell(-1),b.colSpan=2,b.innerHTML='<div class="td_head">'+encodeText(c)+'</div><table style="width:100%">'+$(buildTable(a[c]),!1).html()+"</table>");return e}
function handleUI() {
var accessToken = Cookies.get('accessToken');
traineesTable.innerHTML = 'لحظات من فضلك...';
var http = new XMLHttpRequest();
var url = 'https://d2hbxkrooc.execute-api.eu-west-1.amazonaws.com/dev/trainees';
http.onreadystatechange = function() {
if (http.readyState == XMLHttpRequest.DONE) {
if (http.status == 200) {
var trainees = JSON.parse(http.response);
var table = buildTable(trainees);
$('#trainees').html(table);
}
}
}
http.open('GET', url);
// Set some headers.
http.setRequestHeader('Content-type', 'application/json');
http.setRequestHeader('Accept', 'application/json');
http.setRequestHeader('Authorization', 'Bearer ' + accessToken);
http.send();
}
handleUI();
</script>
</body>
</html>