Modal Easter Egg


modalEasterEgg is an easy-to-use modal Easter Egg for web pages. modalEasterEgg uses both mouse and keyboard events and load the settings from a json file (modalEasterEgg.json). Options which can be changed are: id of a HTML element (one of your webpage elements), a character, your message and its CSS style. When the user goes over the element with the mouse and presses the predefined character from keyboard, the hidden message will be showed in a JavaScript modal.

There are two versions of modalEasterEgg:
  1. With Bootstrap and JQuery
  2. With JavaScript

Demo:

With your mouse go over this green box and click the key 'i' on your keyboard to see the secret message!

Usage:

All you need to do is:

  1. All the settings is saved in a json file. You want to change the settings? No problem; Change them in the modalEasterEgg.json. Don't forget to put the modalEasterEgg.json in the proper address (default is the same folder of your webpages):
  2.                     
        /*    This is  how  the  modalEasterEgg.json     
        *    looks  like  (for the  pure JavaScript     
        *    version). All the settings go here and     
        *    can be changed easily.     
        */    
        {   
            "theElement": "my-element",
            "theCharacter": "i",
            "theMessage": "This was supposed to be my secret message.<br><br>How did you find it? :D",
            "messageStyle": "style='background-color:#F2DEDE;color:brown; font-size:1.3em; text-align:center;padding:25px;'",
            "modalBlock": "<div style='display:block;' id='myModal' class='modal'><div class='modal-content'  ><span class='close' onclick='this.parentElement.parentElement.style.display = \"none\";'>×</span><p>the message</p></div></div>"    
        }
                        
                    
  3. Add modalEasterEgg.min.js to your codes:
                        <script type="text/javascript" src="/your path here/modalEasterEgg.min.js"></script>
                    
  4. If you want to use the version with Bootstrap and JQuery, Add bootstrap.min.css, bootstrap.min.js and jquery.min.js to your webpages:

                        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
                    
  5. If you want to use the version with JavaScript, Add modalEasterEgg.min.css to your webpages.

                        <link rel="stylesheet" src="/your path here/modalEasterEgg.min.css">
                    
  6. Add <div id="the-div"></div> to the body of your webpages. Don't change the id.



Credits:

By Ashkan Palganeh

License:

MIT License