Skip to content

Instantly share code, notes, and snippets.

@karanjitsingh
Last active August 27, 2020 09:30
Show Gist options
  • Select an option

  • Save karanjitsingh/e46e083c5230a959a6a571c9ccc6ccde to your computer and use it in GitHub Desktop.

Select an option

Save karanjitsingh/e46e083c5230a959a6a571c9ccc6ccde to your computer and use it in GitHub Desktop.
<html>
<style>
body{background:#111;margin:0;padding:0;font-family:'Segoe UI',Tahoma,Geneva,Verdana,sans-serif;font-weight:300}.gif{position:absolute;left:0;top:0;height:100%;width:100%;background-size:cover;background-repeat:no-repeat;background-position:center;z-index:-1}.full{position:absolute;left:0;top:0;height:100%;width:100%}.container{display:flex;flex-direction:column;justify-content:center}.refresh{color:#fff;display:flex;line-height:144px;justify-content:center;font-size:60px}.refresh a{background-image:url(https://images-na.ssl-images-amazon.com/images/I/41JYhXXa+rL._SX328_BO1,204,203,200_.jpg);display:inline-block;width:100px;height:144px;background-size:cover;margin-left:30px}div{text-align:center}.text{font-size:30px;width:700px;padding:10px;background:none;border:#fff 1px solid;border-radius:1000px;outline:none;text-align:center;margin-top:120px;color:#fff;font-weight:100}.text::placeholder{color:rgba(255,255,255,0.4)}.sent{color:#fff;margin-top:18px;font-size:20px;opacity:0}@keyframes hide{from{opacity:1}to{opacity:0}}
.button {
font-size: 18px;
width: 85px;
padding: 8px;
background: rgba(255,255,255,0.1);
border: #fff 1px solid;
border-radius: 1000px;
outline: none;
text-align: center;
margin-top: 2px;
color: #fff;
font-weight: 100;
cursor: pointer;
}
</style>
<!--
____ _____ ____
/ _ \ / \ / ___\
( <_> ) Y Y \/ /_/ >
\____/|__|_| /\___ /
\//_____/
YOU OPENED THE SOURCE. TRUE NERD. RESPECT.
-->
<script type="text/javascript">
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
var gifponse;
function setBackground()
{
httpGetAsync("https://api.giphy.com/v1/gifs/search?api_key=19NGnnPCWuXsv6nylh57bwX1VnHXSMHe&q=train&limit=1&offset=" + parseInt(Math.random()*200) + "&rating=g&lang=en", (text) =>{
gifponse = JSON.parse(text);
document.querySelector(".gif").style.backgroundImage = "url(" + gifponse["data"][0]["images"]["original"]["url"] + ")";
});
}
var sentindex = -1;
var sent = ["cool", "got it", "sent", "i'll reply, tots", "i will, i promise", "don't send so many messages", "gg", "stop", "stop it!", "okay"]
var sending = false;
function send(text, callback)
{
callback = callback || (() => {});
sending = true;
var element = document.querySelector(".sent");
element.style.opacity = 1;
element.innerHTML = "sending...";
httpGetAsync("choochoo.php?choochoo=" + encodeURIComponent(text), () => {
sending = false;
callback();
sentindex = (sentindex + 1) % sent.length;
element.innerHTML = sent[sentindex];
animate((t) => t,(t) => {
element.style.opacity = 1-t;
}, 3000);
setBackground();
});
}
function enter(event, text)
{
if (event.key !== "Enter" || sending == true)
return;
var textbox = document.querySelector(".text");
var text = textbox.value;
if(textbox.value.trim() == "")
return;
send(text, () => {
textbox.value = "";
});
}
function animate(timing, draw, duration) {
let start = performance.now();
requestAnimationFrame(function animate(time) {
let timeFraction = (time - start) / duration;
if (timeFraction > 1) timeFraction = 1;
let progress = timing(timeFraction)
draw(progress);
if (timeFraction < 1) {
requestAnimationFrame(animate);
}
});
}
setBackground()
</script>
<div class="gif full"></div>
<div class="full" style="background: rgba(0,0,0,0.5);"></div>
<div class="container full">
<div class="refresh"><span>Don't get it yet?</span><a href="#" onclick="setBackground()"></a></div>
<div class="message"><input class="text" spellcheck="false" type="text" onkeyup="enter(event)" placeholder="you can leave a message, i'll tots reply"/></div>
<div class="message2" style="
color: white;
font-size: 20px;
display: flex;
line-height: 40px;
justify-content: center;
margin-top: 30px;
"><span>If you'd like to continue treasure hunt click -&gt;&nbsp;</span><input class="button" spellcheck="false" type="button" value="yes" onclick="send('more tresure hunt!!')" placeholder="you can leave a message, i'll tots reply"></div>
<div class="sent animate">&nbsp;</div>
</div>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment