Simple Age Verification with jQuery

verificationSS

Today I will go over a simple age verification that I built during my downtime this morning. It uses basic jQuery functions to select, based on the users answer, whether they are of age to view the content of a website or not. This may be used in other ways as well in order to block content before the user decides to view it.

This is a common function on the web today so I decided to show a very easy way to accomplish the task.

I built this project online, and it can be viewed here. (jsfiddle)

I styled the page using HTML and CSS3.

Note: The styling was done without using tables as they are outdated and should rarely be used in modern web design.

In order to accomplish this task, We must include our jQuery file in between the head tags:

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>       

or at the bottom of your body:

<body>

...BODY CONTENT

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</body>

as shown above.

Then we write the jquery that will reference the linked document and give us the desired output. before we start coding the functionality, we  need to set our variables so the jQuery knows what we mean when we refer to “Denied” and “Welcome”

var Denied = "Access is denied.";
var Welcome = "Welcome! You are authorized to view age restricted content";

<script type="text/javascript">
$(document).ready(function () {
      $(".Yes").click(function () {
      if (alert(Welcome)) {
      } else {
        window.location.href ="http://www.jhauge.com"
        return false;
        }
    });

    $(".No").click(function () {
      if (alert(Denied)) {
      } else {
        window.location.href ="http://www.google.com"
        return false;
        }
    });

});
</script>

The script above is what the complete jQuery script looks like. Now I will break it down to explain the functionality.

$(document).ready(function () {
SCRIPT IN HERE
});

First we reference the attached jquery file letting it know we are going to be calling a function. Then we reference our div with the class of .Yes (letting the jquery know what to perform the function on) and then we call the function we want to use, in this case it’s .click().

 $(".Yes").click(function () {
      if (alert(Welcome)) {
      } else {
        window.location.href ="http://www.LINK.com"
        return false;
        }

After the function is called, the next step is to perform an action when that function is completed. For our purposes, we have an alert box pop up when yes is selected by the user telling them that access has been granted, and it forwards them to the page that was hidden using the function window.location.href .

The same was done for the div with the class of .No in order to make the no button functional. The difference is that if no is clicked, the user is directed to a search engine instead of to the protected content, leading those who are underage away from the protected content.

I hope you found this tutorial useful. Thanks for stopping by!

Cool, Easily Customizable Map Resources

Lately on many B2B websites and company websites that have been redesigned within the past year or so, there has been a rash of large map areas that are in custom colors to match the branding of the website. These maps may be used next to contact information or even as a background on the contact page itself. This is a really cool idea because it really makes the contact information stand out and helps someone who is looking for directions to find you quickly and easily.

 

The first one I am going to go over is called MapBox. http://www.mapbox.com

MapBox is a website that allows you to completely customize maps to exactly the colors and styles you want. They have premium plans and free ones, and they offer mapbox.js, and some API’s for developers so you can insert your map directly into your website. I am not entirely sure of the range of use of this program, but it is definitely easier to implement than taking a Google Map and altering it to your desired colors and exactly your specifications.  I have not used it (as of yet) but i plan on trying it out as soon as I get a project that it will work within!

*Please note that this platform does not use Google Maps service, so there may be variations from a map through MapBox and a map through Google Maps.

 

Another custom map website that I found while perusing the internet is SnazzyMaps http://snazzymaps.com/

SnazzyMaps is a repository for Google Maps that have already been modified to different color schemes. Check through the large library of pre-customized maps and if any work for you, they are easily implemented using Google Maps API and the code snippets that are found with each color theme. IF you want to include a custom Google Mapp on your website, this is definitely a great place to look to cut off some time in production!

HTML5

Good quick read on HTML5 and different applications that it has been developed for. Very informative and to the point. Check it out.

Real World Software

HTML5 is a specification which is used for developing web browsers like Internet Explorer.  It helps to define what the browser should do.

What is the point of HTML5?

Compatibility Issues

The problem with web development is that there are significant differences between various web browsers.  This includes differences between newer versions of a specific browsers such as Internet Explorer and differences between rival browsers.  Also there are a number of plug-in tools (e.g. Flash) which may need to be installed.

View original post 357 more words

Customize Font on the Web using Free Google Webfonts

One of the things that you may be looking to do is add a particular style font face to your website to complete the look and feel you are designing for. If none of the fonts that are preloaded into the browser seem to complete the look, there is a very simple API that has been developed by Google that allows you to choose from hundreds of different fonts to use in your website.

There are other sources that have similar API’s but Google will most likely stay around for the duration that you are using their hosted files while I cannot say the same about any other company as easily.

In order to include a font from Google’s web font library, go to http://www.google.com/fonts. Choose a font that you want to use and click the Quick-Use button in the bottom right hand corner of the chosen fonts section on the page. Scroll to the bottom of the page and copy the

<link href='http://fonts.googleapis.com/css?family=Orbitron:400,500' rel='stylesheet' type='text/css' />

and paste it into the head of your document between your <head> </head> tags.

This tells your browser to load that font from the Google web fonts library. Now you just need to tell the browser where to use the font in your page. We do this in our CSS file. We can put it in our body tag, p tag, h1 tag, etc.

body {
    font-family:'Orbitron', sans-serif;
    font-weight: 400;
}

You can copy and paste this code directly from the font’s page on the Google API website as well.

This will allow you to complete the feel of your website with custom typography.

Animate with jQuery: Create a Heartbeat/Pulsing Effect on Text or Links

Within the jQuery library, there are thousands upon thousands of different effects that can be applied to your page to create a unique and dynamic user experience. Animation using mark-up has become more and more prevalent as of late, since animation that uses flash is losing its relevance and its place in modern web (An explanation that I will save for another post).

jQuery is a library that we have used before to create a smooth scroll effect so we have already learned how to call a jQuery library into your page. If you do not remember, Google has uploaded and hosts versions of jQuery right on their website.

We will start off by linking to the jQuery library version 1.9.1 . This goes in the <head></head> tags in your HTML mark-up.

<head>
<title> PAGE TITLE </title>   
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>

Now that we have linked the correct version of the jQuery library to our HTML page, we now need to add jQuery to our page so that we can create the animation. I will break the script we will use down into pieces and explain the parts of the script and what they do.

** The script can be put in the <head></head> tags under your jQuery library call, but for a faster page load time, I suggest adding it to the very bottom of your HTML page, under your content right before you close your <body></body> tag.

So we start by opening our <script type=”text/javascript”> tag and telling the page to look at the jQuery library and call/set our function:

 <script type="text/javascript">
        $(document).ready(function animateHeart() {

We then set the class (for this example we will set our class as heart) we will use to identify the p, span, h1, a, etc. that will use the function and we set our class to the jQuery function .animate :

 $('.heart').animate({

Lastly, we need to set the font size we will start off with, and the size we wish to have our text shrink to and repeat the size we start with so that we get a bouncing or pulsating effect. We set our animation speed, and apply our function so the effect will act the way we set it. Dont forget to close your </script> tag at the end!

fontSize: $('.heart').css('fontSize') == '60px' ? '55px' : '60px'
            }, 500, animateHeart);
        });
        </script>

All together, the script appears as:

<script type="text/javascript">
        $(document).ready(function animateHeart() {
            $('.heart').animate({
                fontSize: $('.heart').css('fontSize') == '60px' ? '55px' : '60px'
            }, 500, animateHeart);
        });
        </script>

In order for this effect to work, make sure you dont forget to apply the class to a section in your HTML!

<a href="#about" class="heart">V</a>

Using this bit of jQuery, you can help improve the UX on your website and add pull the users eye to information that may be of importance or to links they should be clicking on.

Thanks for stopping by, as always. Good Luck and have fun developing!