Code Monkey home page Code Monkey logo

greetr's Introduction

greetr.js

greetr.js is a very simple JavaScript library that supplies user greetings.

  • When given a first name, last name, and language (optional), a formal or casual greeting is generated
  • Provide a jQuery object and Greetr fills the element with the greeting

library use

This library mimics jQuery structure by generating an object referenced by G$

  • G$() - returns an object ('new' keyword not required) containing chainable methods
  • HTMLGreeting() - places formal or casual greeting in HTML element

Two Main Methods:

G$(firstname, lastname, language);

HTMLGreeting(jQuery_selector, boolean)

example usage:

Example 1

G$('Joe', 'Schmo', 'en');
HTMLGreeting('#greeting');

<div id="greeting">Hello, Joe!</div>

Example 2

G$('Joe', 'Schmo', 'en');
HTMLGreeting('#greeting', true);

<div id="greeting">Greetings, Joe Schmo!</div>

Example 3

$("#login").click(function login() {
    const firstname = $("#firstname").val();
    const lastname = $("#lastname").val();
    const formality = $("#formality").is(":checked");

    const loginGrtr = G$(firstname, lastname);  // create new obj

    loginGrtr.setLang($('#lang').val()).HTMLGreeting('#greeting', formality).log();
});

All Methods (chainable) & Parameters

G$(firstname, lastname, language)

  • firstname
  • lastname
  • language (optional; defaults to 'en')
    • 'en' = English
    • 'es' = Spanish

HTMLGreeting(selector, boolean)

  • jQuery selector
  • boolean (optional; defaults to false)
    • true = formal greeting
    • false = casual greeting

setLang(language)

  • optional way to set language

greet()

  • prints greeting to console w/ all chainable methods available

log()

  • prints log to console

greetr's People

Contributors

red-french avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.