{
  "schemaVersion": 1,
  "id": "texto-noche-de-brujas-en-diabuluz",
  "language": "en",
  "canonical": "https://paynalton.tech/en/works/noche-de-brujas-en-diabuluz/",
  "title": "Halloween Night in Diäbuluz",
  "summary": "Explain a script for effects for a forum on Halloween dates.",
  "author": "Paynalton",
  "format": "technical",
  "year": 2009,
  "source": "https://paynalton.blogspot.com/2009/10/noche-de-brujas-en-diabuluz.html",
  "partial": false,
  "topics": [
    {
      "title": "Technical texts",
      "url": "https://paynalton.tech/en/topics/lectura-categoria-tecnicos/"
    },
    {
      "title": "Technical text",
      "url": "https://paynalton.tech/en/topics/lectura-texto-tecnico/"
    },
    {
      "title": "Tutorial",
      "url": "https://paynalton.tech/en/topics/lectura-tutorial/"
    },
    {
      "title": "Programming",
      "url": "https://paynalton.tech/en/topics/lectura-programacion/"
    },
    {
      "title": "Visual effects",
      "url": "https://paynalton.tech/en/topics/lectura-efectos-visuales/"
    }
  ],
  "body": "Halloween Night in Diäbuluz<br><br>Well, the Day of the Dead is approaching and to celebrate these dates on the forum [Diäbuluz in Mëxico](http://magodeozmexico.com/ \"Diäbuluz in Mëxico\") I've placed a small script that I designed.<br><br>The script performs the following tasks:<br><br>First, it creates a random variable that determines whether the visual effect will be shown or not, as well as how long it will take to appear.<br><br>I do this because seeing the same effect all the time is annoying, and one of the effects is meant to scare the visitor, jejej.<br><br>Once the time is determined, it checks if the time is even or odd and from there decides whether to present the scare or the flying witch.<br><br>If the scare is chosen, it will create an interval, and when the visitor least expects it, PUF!, a child with a devilish face appears for an instant in the center of the screen.<br><br>If the witch's flight is chosen, it creates another random value to decide which of all the images will be displayed. Once decided, it will load and make it visible in a corner of the screen.<br><br>The images I chose for this were animated GIFs, so that as they move across the screen it seems like they are flying. Especially I liked how the bat looked.<br><br>This script is this:<br><em><strong><br>        var intervalo;<br>        function espanta()<br>            {<br>            var espanto=document.getElementById(\"espanto\");<br>            espanto.style.display=\"block\";<br>           ` setTimeout(\"document.getElementById(\\'espanto\\').style.display=\\'none\\';\",1000);`<br>            }<br>        function vuela()<br>            {<br>            var bruja=document.getElementById(\"bruja\");<br>            var x=bruja.style.top;<br>            var y=bruja.style.left;<br>            x=x.split(\"p\");<br>            y=y.split(\"p\");<br>            x=(x[0]*1)+5;<br>            y=(y[0]*1)+10;<br>            bruja.style.top=x+\"px\";<br>            bruja.style.left=y+\"px\";<br>            if(x>2000)<br>                {<br>                clearInterval(intervalo);<br>                }<br>            }<br>        function bruja()<br>            {<br>            document.getElementById(\"bruja\").style.display=\"block\";<br>            var fact=Math.round((Math.random())*10);<br>            switch(fact)<br>                {<br>                case 1:<br>                    var img=\"skull.gif\";<br>                    break;<br>                case 2:<br>                    var img=\"mur.gif\";<br>                    break;<br>                case 3:<br>                    var img=\"bruja2.gif\";<br>                    break;<br>                case 4:<br>                    var img=\"esq.gif\";<br>                    break;<br>                case 5:<br>                    var img=\"fan.gif\";<br>                    break;<br>                case 6:<br>                    var img=\"cria.gif\";<br>                    break;<br>                case 7:<br>                    var img=\"bruja.gif\";<br>                    break;<br>                case 8:<br>                    var img=\"bruja.gif\";<br>                    break;<br>                case 9:<br>                    var img=\"bruja.gif\";<br>                    break;<br>                case 10:<br>                    var img=\"bruja.gif\";<br>                    break;<br>                default:<br>                    var img=\"bruja.gif\";<br>                    break;<br>                }<br>            document.getElementById(\"brujaimg\").src=img;<br>            intervalo=setInterval(vuela,80);<br>            }<br>        function esPar(num)<br>            {<br>            res=num%2;<br>            if(res)<br>                {<br>                return(false);<br>                }<br>            else<br>                {<br>                return(true);<br>                }<br>            }<br>        function asustame()<br>            {<br>            var factor2=(Math.random())\\*3000000;<br>            //var factor2=(Math.random())\\*100;<br>            var factor=(Math.random())\\*factor2;<br>            var tiempo=Math.round((Math.random())\\*factor);<br>            if(tiempo&lt;60000)<br>                {<br>                if(esPar(tiempo))<br>                    {<br>                    setTimeout(bruja,tiempo);<br>                    }<br>                else<br>                    {<br>                    setTimeout(espanta,tiempo);<br>                    }<br>                }<br>            }</strong></em><br><br><br>To make it work, you need to add some elements to the HTML:<br><br><em><strong>&lt;br>&lt;div id=\"espanto\" `style=\"z-index:10000;width:100%;height:100%;background:url(\\'espanto.jpg\\')` center no-repeat;display:none;position:fixed;top:0;left:0\"\\><br>&lt;/div\\><br>&lt;div id=\"bruja\" style=\"z-index:10000;display:none;position:fixed;top:0px;left:-50px\"\\>\\&lt;/div\\></strong></em><br><br><br>And add the images we are going to display in the indicated directory.<br><br>Finally, modify the body to make it load the script automatically:<br><strong><br>&lt;body onload=\"javascript:asustame()\"\\></strong><br><br>I'm signing off. If in the future someone finds this useful, I'll improve it next year so that it has better effects. I'd like to have a monster tear the page, add some sounds, or make the window start bleeding. But that will be for the next time.<br>\n"
}
