-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.html
110 lines (100 loc) · 3.55 KB
/
export.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
<!DOCTYPE html>
<html>
<head>
<title>Competency Ranking Report</title>
<script src="https://www.gstatic.com/firebasejs/live/3.0/firebase.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="Downloadify/js/swfobject.js"></script>
<script type="text/javascript" src="Downloadify/js/downloadify.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body onload="load()">
<noscript><h1>This page requires javascript, which is disabled.</h1></noscript>
<div class="top"><img src="https://octa.net/Images/global/OCTA15_logo.png" class="logo" /><h1>Competency Ranking Report</h1><span style="min-width: 1in;"></span></div>
<div class="container" style="text-align:center;">
<div id="login" style="display:none;">
<form action="#" target="none" onsubmit="login()">
<table style="width:50%;margin:auto;">
<tr><td>Email:</td><td><input type="text" id="email" /></td></tr>
<tr><td>Password:</td><td><input type="password" id="pass" /></td></tr>
</table>
<p><button type="submit">Log In</button></p>
</form>
</div>
<div id="download" style="display:inherit;padding:1em;">
<h2 style="margin-bottom:.5em;">Competency Ranking Report.csv</h2>
<table>
<tr><!--<td>Flash</td>--><td id="downloadify">You must have Flash 10 installed to download this file.</td></tr>
<!--<tr><td>HTML5 (New browsers only, Edge 13+):</td><td><a download="Competency Ranking Report.csv" id="htmldown">Download</a></td></tr>-->
</table>
</div>
</div>
<div style="position:absolute;bottom:0;">
<a href="Downloadify/LICENSE.txt">Downloadify License</a>
</div>
<script>
function load() {
// Initialize Firebase
var config = {
apiKey: "AIzaSyAR5mkKau0nYAF7BCrYdB1_EnqmFPlyPf4",
authDomain: "hirschbergsort.firebaseapp.com",
databaseURL: "https://hirschbergsort.firebaseio.com",
storageBucket: "hirschbergsort.appspot.com",
};
firebase.initializeApp(config);
getData();
}
function login() {
firebase.auth().signInWithEmailAndPassword($("#email").val(),
$("#pass").val()).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
throw errorMessage;
});
getData();
$("#login").remove();
$("#download").css("display", "inherit");
}
function esc(text) {
console.log(text);
var reg = /"/g;
if (!text) { text = "Undefined"; }
return text.replace(reg, "\"\"");
}
function getData() {
var reg = /"/g;
var dataurl = "data:text/csv;charset=utf-8,";
var newline = "\r\n"
var data = "Competency Ranking Report" + newline + newline +
"Date,Position,Manager,Number,Results" + newline;
var ref=firebase.database().ref("Results/");
ref.once("value").then(function(snapshot) {
snapshot.forEach(function(child) {
data += "\"" + esc(child.val().Date) + "\",";
data += "\"" + esc(child.val().Position) + "\",";
data += "\"" + esc(child.val().Manager) + "\",";
data += "\"" + esc(child.val().ReqNumber) + "\",";
child.val().Results.forEach(function(res) {
data += "\"" + esc(res) + "\",";
});
data += newline;
})
dataurl += encodeURIComponent(data);
Downloadify.create("downloadify", {
filename: "Competency Ranking Report.csv",
data: data,
swf: 'Downloadify/media/downloadify.swf',
downloadImage: 'Downloadify/images/download.png',
width: 100,
height: 30,
transparent: true,
append: false
});
//$("#htmldown").attr("href", dataurl);
});
}
</script>
<iframe style="display:none;" name="none"></iframe>
</body>
</html>