forked from J3ranch/J3ranch.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scholarship-host.js
76 lines (61 loc) · 1.73 KB
/
scholarship-host.js
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
firebase.auth().onAuthStateChanged(function(user) {
if (user)
{
console.log("Logged in");
document.getElementById("search-box").value = user.email;
}
else
{
console.log("Not logged in");
window.location='../index.html';
}
});
function logout() {
console.log("Logout")
firebase.auth().signOut();
}
// Get the modal
var modal = document.getElementById('scholarship-modal');
var btns;
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
function applyButtons() {
btns = document.getElementsByClassName("scholarship");
for (var i = 0; i < btns.length; i++) {
btns[i].onclick = function() {
modal.style.display = "flex";
}
btns[i].addEventListener("keyup", function(event) {
// Cancel the default action, if needed
event.preventDefault();
// Number 13 is the "Enter" key on the keyboard
if (event.keyCode === 13) {
// Trigger the button element with a click
event.target.click();
}
});
}
}
applyButtons();
if (window.addEventListener) {
window.addEventListener("message", onMessage, false);
}
else if (window.attachEvent) {
window.attachEvent("onmessage", onMessage, false);
}
function onMessage(event) {
// Check sender origin to be trusted
//if (event.origin !== "http://example.com") return;
var data = event.data;
if (typeof(window[data.func]) == "function") {
window[data.func].call();
}
}
// Function to be called from iframe
function closeOverlay() {
modal.style.display = "none";
}