-
Notifications
You must be signed in to change notification settings - Fork 0
/
clopen.html
126 lines (104 loc) · 3.43 KB
/
clopen.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="icon" href="images/icon.ico">
<title>clopen</title>
</head>
<body>
<div class="graphic">
<svg viewBox="0 0 1400 800">
<defs>
<pattern id="door" width="1" height="1">
<image href="images/door.jpg" width="330" height="730" x="0" y="0" />
</pattern>
<pattern id="sky" patternUnits="userSpaceOnUse" width="3376" height="1698">
<image href="images/sky.jpg" x="0" y="0" width="3376" height="1698" />
</pattern>
</defs>
<rect id="universe" width="100%" height="100%" style="fill: url(#sky)" />
<rect id="boundary" width="350" height="740" x="325" y="90" style="fill: white" />
<rect id="interior" width="330" height="730" x="335" y="100" style="fill: white" />
</svg>
</div>
<div class="pageButton">
<h1 id="openButton" onclick="openFnc()">open</h1>
<h1 id="closeButton" onclick="closeFnc()">close</h1>
</div>
<div class="backButton"><a href="index.html">back</a></div>
<script>
var openQ = false;
var closedQ = false;
function openFnc() {
if (openQ && closedQ) {
closedNotOpen()
} else if (openQ && !closedQ) {
notOpenNotClosed()
} else if (!openQ && closedQ) {
openClosed()
} else {
openNotClosed()
}
toggleOpen(openQ);
};
function closeFnc() {
if (openQ && closedQ) {
openNotClosed()
} else if (openQ && !closedQ) {
openClosed()
} else if (!openQ && closedQ) {
notOpenNotClosed()
} else {
closedNotOpen()
}
toggleClosed(closedQ);
};
// buttons
function toggleOpen(openVal) {
if (openVal) {
openQ = false;
document.getElementById("openButton").style.color = "black";
} else {
openQ = true;
document.getElementById("openButton").style.color = "tomato";
}
};
function toggleClosed(closedVal) {
if (closedVal) {
closedQ = false;
document.getElementById("closeButton").style.color = "black";
} else {
closedQ = true;
document.getElementById("closeButton").style.color = "red";
}
};
// graphic
function openNotClosed() {
console.log("open and !closed");
document.getElementById("interior").style.fill = "url(#sky)"
document.getElementById("boundary").style.fill = "white"
document.getElementById("universe").style.fill = "black"
};
function closedNotOpen() {
console.log("!open and closed");
document.getElementById("interior").style.fill = "url(#door)"
document.getElementById("boundary").style.fill = "white"
document.getElementById("universe").style.fill = "black"
};
function openClosed() {
console.log("open and closed");
document.getElementById("interior").style.fill = "black";
document.getElementById("boundary").style.fill = "url(#sky)"
document.getElementById("universe").style.fill = "black"
};
function notOpenNotClosed() {
console.log("!open and !closed");
document.getElementById("interior").style.fill = "white"
document.getElementById("boundary").style.fill = "white"
document.getElementById("universe").style.fill = "url(#sky)"
};
</script>
</body>
</html>