-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
314 lines (272 loc) · 12 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gunzip</title>
<style>
::-webkit-scrollbar {
width: 0px; /* Remove scrollbar space */
background: transparent; /* Optional: just make scrollbar invisible */
}
::-webkit-scrollbar-thumb {
background: #FF0000;
}
</style>
<script src="main.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="frameworks/materialize.min.js">
</script>
<script src="frameworks/jquery.js">
</script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="frameworks/materialize.css">
<script src="https://www.gstatic.com/firebasejs/8.1.2/firebase.js"></script>
</head>
<body class="blue darken-3" style="width: 100%;height: auto;">
<ul id="slide-out" class="sidenav">
<li><a class="mainmenu btn">Your Menu</a></li>
<li><a class="projectmenu btn">Community Projects</a></li>
<li><a class="posts btn">Community Posts</a></li>
</ul>
<div class="navbar-fixed">
<nav>
<div class="nav-wrapper green">
<a style="margin:0%;padding:0;height:50%;" href="https://editor.gunzip.repl.co/" class="brand-logo"><img loading="lazy" src="images/logo.gif"/></a>
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li><a id="mainmenu">Your Menu</a></li>
<li><a id="projectmenu" href="#">Community Projects</a></li>
<li><a id="posts">Community Posts</a></li>
</ul>
</div>
</nav>
</div>
<div style="background:url(https://cdn.dribbble.com/users/1585453/screenshots/6732255/comp_1.gif);" id="uploadProject" class="modal">
<div class="modal-content">
<h1 align="center" class="waves-effect">Put your html file here</h1>
<hr>
<label class="btn green white-text">
Choose File [Html]
<input accept=".html,.txt,.gunz.html" id="project" style="display:none" type="file">
</label><br>
<label>Project's Name :<input id="exportToWebName" type="text" placeholder="My Project"/></label>
<br>
<button class="btn waves-effect green-text white modal-close" id="uploadProjectToWeb">Upload</button>
</div>
<div class="modal-footer">
<div class="waves-effect">[✔] By Uploading You accept that it is doesnt voilate any child.</div>
</div>
</div>
<div id="projectAdvancedSection">
<div style="marign:0%;padding:0%;width:100%;height:auto;" class="white green-text waves-effect ">
<img id="userPhoto" class="left responsive-img circle" style="width:8%;height:auto;border-radius:190%;" alt="">
<h4 id="userName"> Anonymous</h4>
</div>
<a style="width:50%;" class="btn waves-effect lighten-1 grey left modal-trigger" target="_blank" href="./2d.html">Open Editor</a>
<label style="width:50%;" class="btn purple left large">
<input id="projectPicker" type="file" single style="width:20%;display: none;" value="open Project"
class="btn grey waves-effect darken-1 left" />
Open Project
</label>
<div class="label green lighten-2 white-text center-align">Templates</div>
<div style="border:8px solid black;width:100%;overflow:hidden;height:100%;positon:relative;" id="localprojects">
<div style="height:40px" class="green white-text">Platformer Template</div>
<img src="https://thumbs.gfycat.com/OptimalSlipperyAzurewingedmagpie-size_restricted.gif" style="width:100%;" alt="">
<div class="btn white green-text waves-effect right-align" style="width:100%" id="platformerDownload">Download</div><br>
</div>
</div>
<div id="postsContainer">
<textarea style="height:80px;width:100%;resize:none;" placeholder="Share framework cdns , frameworks , codebits,etc" class="textarea" id="postText"># This is Markdown h1 tag</textarea>
<button style="width:100%" class="btn btn-plain white blue-text" id="uploadPostOfUser">Post it</button>
<div id="userPostsContainer">
<div id="userPosts">
<img src="https://i.pinimg.com/originals/e9/29/1e/e9291eaddacd460280a34a151dcc5cc4.gif" alt="">
</div>
</div>
</div>
<div id="projectContainer">
<button class="btn black modal-trigger" data-target="uploadProject" href="uploadProject" style="width:100%;margin:0%;" >Upload Project</button>
<div id="projects" class="splide" style="width:100%;height:20%;overflow:auto;direction:ltr;"><img style="width:100%;height:500px;position:relative;" src="https://i2.wp.com/onemansblog.com/wp-content/uploads/2016/05/Octopus-Loading.gif?fit=800%2C600&ssl=1" alt=""></div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('.sidenav');
var instances = M.Sidenav.init(elems);
var elems = document.querySelectorAll('.modal');
var instances = M.Modal.init(elems);
});
// window.onerror =()=> location.reload()
var firebaseConfig = {
apiKey: "AIzaSyCAKdFF5_hgM3FnytEW45sQty5UzFFSiXQ",
authDomain: "gunzipz.firebaseapp.com",
databaseURL: "https://gunzipz.firebaseio.com",
projectId: "gunzipz",
storageBucket: "gunzipz.appspot.com",
messagingSenderId: "255063467474",
appId: "1:255063467474:web:c6ab4f3923071b4ce5d40b",
measurementId: "G-SBE6QXGMPH"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics()
console.log(firebase.auth())
var userofsite = firebase.auth().currentUser;
if (userofsite != null) {
document.getElementById("userPhoto").src = userofsite.photoURL.toString() || "https://hackernoon.com/images/0*QdX-f4eHiimvQZoZ.gif"
}else{
document.getElementById("userPhoto").src ="https://hackernoon.com/images/0*QdX-f4eHiimvQZoZ.gif"
}
if(localStorage.getItem("gunzipserveruserName") == undefined || localStorage.getItem("gunzipserveruserName") == null){
providerOfGoogle = new firebase.auth.GoogleAuthProvider()
firebase.auth().signInWithPopup(providerOfGoogle).then(function(result) {
window.user = result.user.displayName;
photoURL = result.user.photoURL;
user = result.user.displayName;
localStorage.setItem("gunzipserveruserName",result.user.displayName.toString())
localStorage.setItem("gunzipserveruserPhoto",result.user.photoURL.toString())
document.getElementById("userPhoto").src = result.user.photoURL.toString() || "https://hackernoon.com/images/0*QdX-f4eHiimvQZoZ.gif";
M.toast({html: 'Logged In as : ' + window.user.toString()})
}).catch(function(error) {
M.toast({html: error.message+'.'})
});
}else{
document.getElementById("userName").innerText = localStorage.getItem("gunzipserveruserName") || "Anonymous"
document.getElementById("userPhoto").src = localStorage.getItem("gunzipserveruserPhoto").toString() || "https://hackernoon.com/images/0*QdX-f4eHiimvQZoZ.gif"
}
function uploadToWeb(a){
firebase.database().ref("projects/").push({
name : document.getElementById("exportToWebName").value,
codeHtml : a.toString(),
vote : 0,
})
}
function UploadProject(){
file = document.getElementById("project")
const reader = new FileReader();
reader.addEventListener('load', (event) => {
const result = event.target.result;
uploadToWeb(result.toString());
alert("Success")
});
reader.readAsText(file.files[0]);
}
function deploy(){
var ref = firebase.database().ref("projects/");
ref.on("value", function(snapshot) {
document.getElementById("projects").innerHTML = ""
snapshot.forEach((it,id)=>{
var storage = firebase.storage().ref("/websites/"+it.val().name.toString())
storage.put(new File([it.val().codeHtml.toString()],it.val().name.toString(), {
type: "text/html",
})).on("state_changed",(snap)=>{
},(e)=>{
alert(e.toString() + " Happened 😯")
},()=>{
})
var container = document.createElement("div")
var likeButton = document.createElement("button")
var dislikeButton = document.createElement("button")
var playButton = document.createElement("button")
var projectName = document.createElement("p")
container.style = "overflow:hidden;border:2px solid black;border-radius:5.0%;overflow:auto;overflow:hidden;width:25%;align:left;display:inline-block;"
container.className = "card left waves-effect"
var image = document.createElement("img")
image.loading = "lazy"
image.className = "waves-effect"
image.style = "width:100%"
image.src = "https://cdn.lowgif.com/full/42213d6862f9fa9c-gif-animated-character-on-pinterest-pusheen-cartoon.gif"
projectName.className='left-align bold center-align'
projectName.style='width:100%;font-size:100%;font-weight:bold;'
projectName.innerHTML = it.val().name.toString()
projectName.innerHTML += "<br><i>Votes : </i>" + it.val().vote.toString()
likeButton.className="btn green left waves-effect"
likeButton.innerText = "👍"
likeButton.style.display = "none"
likeButton.addEventListener("click",(ev)=>{
if(localStorage.getItem("liked"+it.key.toString()) == undefined){
var johnRef = firebase.database().ref("projects/"+it.key.toString());
johnRef.update ({
"vote": it.val().vote + 1
});
ev.preventDefault()
localStorage.setItem("liked"+it.key.toString(),"I liked Lol")
localStorage.removeItem("disliked"+it.key.toString())
}else{
M.toast({html: 'Sorry You already liked it.'})
}
})
dislikeButton.addEventListener("click",(ev)=>{
if(localStorage.getItem("disliked"+it.key.toString()) == undefined){
var johnRef = firebase.database().ref("projects/"+it.key.toString());
johnRef.update ({
"vote": it.val().vote - 1
});
ev.preventDefault()
localStorage.setItem("disliked"+it.key.toString(),"I disliked Lol")
localStorage.removeItem("liked"+it.key.toString())
}else{
M.toast({html: 'Sorry You already disliked it.'})
}
})
dislikeButton.className="btn red left waves-effect"
dislikeButton.innerText = "👎"
playButton.className="material-icons btn blue white-text waves-effect"
playButton.innerText = "▶"
dislikeButton.style = "margin:0%;"
likeButton.style = "margin:0%;"
playButton.style = "width:70%;margin:0%;"
playButton.onclick = ()=>{
window.open('https://firebasestorage.googleapis.com/v0/b/gunzipz.appspot.com/o/websites%2F'+it.val().name.toString() + "?alt=media&token=9ac0b502-3ac6-4870-bf43-2cd2e82dacc7",'/Bibekz') //.document.write(it.val().codeHtml.toString());
}
container.appendChild(projectName)
container.appendChild(image)
container.appendChild(likeButton)
container.appendChild(playButton)
container.appendChild(dislikeButton)
document.getElementById("projects").appendChild(container)
})
}, function (error) {
console.log("Error: " + error.code);
});
}
deploy()
document.getElementById("uploadProjectToWeb").onclick = ()=>{
UploadProject()
}
</script>
<script>
var picker = document.getElementById("projectPicker")
picker.addEventListener('change', () => {
let files = picker.files;
if (files.length == 0) return;
const file = files[0];
let reader = new FileReader();
reader.onload = (e) => {
var file = e.target.result;
eval(file.toString())
document.href = "https://ed.gunzip.repl.co/2d.html"
};
reader.onerror = (e) => alert(e.target.error.name);
reader.readAsText(file);
});
window.onbeforeunload = function (e) {
e.preventDefault();
e.returnValue = 'You want to open the editor?';
};
document.addEventListener('contextmenu', event => event.preventDefault());
document.onkeydown = function (e) {
e = e || window.event;
if (!e.ctrlKey) return;
var code = e.which || e.keyCode;
switch (code) {
case 83:
case 87:
e.preventDefault();
e.stopPropagation();
break;
}
};
</script>
</body>
</html>