LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

Broken Greetings

CSS
.link {
    display: block;
    float: left;
    text-align: center;
    padding: 5px;
    border: 1px solid #ccc;
    margin: 5px 5px 0 0;
    font-family: sans-serif;
    cursor: pointer;
    text-decoration: none;
    color: #000;
}

.link:first-child {
    margin-left: 5px;
}

.link:hover {
    background-color: #ddd;
}
JS
var debug = new Boolean(false);

//Broken greeting
(function() {
  var language = "spanish"; //set a default language.
  if (navigator.language == "en-US" || navigator.language == "en") {
    changeLanguage("english");
  }
  
  function changeLanguage(lang) {
    language = lang;
    function currentLanguage() {
      console.log(lang);
    }
    if (debug) {
      currentLanguage();
    }
  };
  var greet = function(name) {
    var languages = {
      english: "Hello ",
      french: "Bonjour ",
      spanish: "Hola "
    };
    alert(languages[language] + name);
  };
  
//   Greeting click function
  $("#greeting").click(function() {
    if (debug) {
      console.log("Debugging:", $(".name"));
    } else {
      var person = $("#name").val();
      console.log(person)
      greet(person);
    }
  });
  
})();
Term
Sat, 01/13/2018 - 16:18

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv