-
-
Save Kshioshita/694a9d7aeede304d8c229f9d03fc7bb1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a new div | |
var div=document.createElement("div"); | |
// add message to div | |
var divtext=document.createTextNode(data); | |
div.appendChild(divtext); | |
// set color of div depending on length of message, time, and ASCII code of the message | |
var length=data.length; | |
var ranlen=Math.round((length*2550)/255); | |
var today=new Date(); | |
var second=Math.round(today.getSeconds()*4.25); | |
var numdata=data.charCodeAt(0); | |
div.style.backgroundColor='rgb('+ ranlen +',' +second+','+numdata+')'; | |
//place the div in a random spot on the page | |
var hposSec=Math.round(Math.random()*810); | |
var vposSec=Math.round(Math.random()*600); | |
div.style.position="absolute"; | |
div.style.left=hposSec+"px"; | |
div.style.top=vposSec+"px"; | |
// basic css of the newly created div | |
div.style.textAlign="center"; | |
div.style.fontSize="2em"; | |
div.style.padding="20px"; | |
div.style.borderRadius="100%"; | |
div.style.zIndex="-1"; | |
div.style.color="white"; | |
div.style.opacity="0.7"; | |
// add the newly created div to the html | |
document.getElementById("main").appendChild(div); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment