-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
207 lines (173 loc) · 5.75 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test</title>
</head>
<style>
#bottomNav{
position:fixed;
bottom:0px;
left:0px;
width:100vw;
padding:20px;
font-size:20px;
display:flex;
box-sizing: border-box;
}
button{
font-size:20px;
flex-grow:2;
}
img {
width:20px;
}
#helpToggleOnButton{
padding-left:5px;
}
.hide{
display:none;
}
#helpSection{
top:0;
left:0;
height:100vh;
width:100vw;
position:fixed;
z-index:10000;
background:white;
box-sizing: border-box;
transition: 1s;
overflow: auto;
border: solid;
padding: 15px;
}
.offScreenTran{
transform: translateX(100%);
}
#helpToggleOffButton{
float:right;
margin-right: 20px;
}
#errorMessage{
width:100vw;
position:fixed;
bottom:80px;
background:#ffc9c9;
padding:20px;
left:0px;
display:flex;
box-sizing: border-box;
align-items: center;
transition: 0.5s;
}
.indentText{
text-indent: 20px;
}
:root{
//these set variables inside the webcomponent
--math-equation-handle-display:none;
--math-equation-button-minimize-display:none;
--math-equation-button-setting-display:none;
--math-equation-button-github-display:none;
--math-equation-button-exit-display:none;
}
</style>
<body>
<?!= include('Math_Equation_Component'); ?>
<?!= include('pngConverter'); ?>
<p>testing this out<p/>
<math-equation-component id="mathComponent"></math-equation-component>
<div id="errorMessage" class="offScreenTran">
<p>
<span style="font-weight: bold">[Error Message]</span>
<span id="errorMessageText"> um has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to</span>
<p>
<div id="closeErrorMessage" style="cursor: pointer;">
X
</div>
</div>
<?!= include('helpPage'); ?>
<?!= include('bottomNavBar'); ?>
<script>
/*Globals*/
let imageIdBind = ""
let imageBinded = false;
/*Global Tags*/
let bindButton = document.getElementById("bindImage");
let mathComponent = document.getElementById("mathComponent");
let unBindButton = document.getElementById("unBind");
let helpSectionToggleOnButton = document.getElementById("helpToggleOnButton");
let helpSectionToggleOffButton = document.getElementById("helpToggleOffButton");
let helpSectionUIPage = document.getElementById("helpSection");
let errorMessage = document.getElementById("errorMessage");
let errorMessageText = document.getElementById("errorMessageText");
let closeErrorMessage = document.getElementById("closeErrorMessage");
//general ui stuff
helpSectionToggleOnButton.addEventListener("click",function(){
helpSectionUIPage.classList.toggle("offScreenTran");
})
helpSectionToggleOffButton.addEventListener("click",function(){
helpSectionUIPage.classList.toggle("offScreenTran");
});
errorMessageText.addEventListener("click",function(){
errorMessage.classList.remove("offScreenTran")
});
closeErrorMessage.addEventListener("click", function(){
errorMessage.classList.add("offScreenTran")
})
var error = function(error){
console.log("[ERROR]----------------------------")
console.log(error);
errorMessageText.innerHTML = error;
errorMessage.classList.remove("offScreenTran")
console.log("[End ERROR]----------------------------")
}
//Grab image from slideshow and put it into component
bindButton.addEventListener("click",function(){
console.log("-----------------------CLicked")
google.script.run.withSuccessHandler(function(results)
{
console.log(results);
imageIdBind = results["id"]
imageBinded = true;
let mathEquationProps = results["imageProps"];
mathComponent.mathType = mathEquationProps["mathType"];
mathComponent.color = mathEquationProps["color"];
mathComponent.text = mathEquationProps["text"];
mathComponent.height = mathEquationProps["height"];
unBindButton.classList.toggle("hide");
}).withFailureHandler(error).loadImage();
})
unBindButton.addEventListener("click",function(){
imageIdBind = ""
imageBinded = false;
unBindButton.classList.toggle("hide");
});
//take component out and put it into slideshow
const convert_blobToBase64String = async (blob) => {
const base64url = await new Promise((r) => {
const reader = new FileReader()
reader.onload = () => r(reader.result)
reader.readAsDataURL(blob);
})
return base64url;
}
mathComponent.addEventListener("math-equation-gen-image",function(mathData){
console.log("got a event")
console.log(mathData.detail)
let imageBlob = mathData.detail.blob;
let imageData = mathData.detail.equationProps;
//deleting this deleted it in the component
//delete imageData["height"]; //don't need height it will be manage by the slide itself
convert_blobToBase64String(imageBlob).then(function(blobString){
console.log(blobString.split("base64,"))
console.log("got here-------------")
google.script.run.withSuccessHandler(function(results){
}).withFailureHandler(error).addImage(blobString.split("base64,")[1], imageData, imageIdBind);
})
})
</script>
</body>
</html>