Git Product home page Git Product logo

journey's Introduction

Journey

Journey is simple lib to manage your travel cards and get instructions for trip. To learn more, please visit the project page

Input data format

[
  {
      "from": "A",
      "to": "B",
      "ticket": {
        "type": "bus",
        "number": "848F",
        "spec": "",
        "seat": "98J"
      }
    },
    {
      "from": "D",
      "to": "B",
      "ticket": {
        "type": "airplane",
        "number": "FZ83",
        "spec": "",
        "seat": "30C",
        "gate": 35,
        "baggage": "auto"
      }
    }
]

Example

    var journey = new Journey(inputData); // creating your journey

    journey.printInstructions("#instructions"); // instructions will be append to #instructions element
    journey.printSimple("#simple"); // simple print without types, only point. From A to B.

    var instructions = journey.getInstructions(); // return array of instructions
    // ["Take bus 848F from A to B. Seat 98J.",
    //  "From B, take flight UF22 to C. Gate 5. Seat undefi… be automatically transferred from your last leg.",
    //  "Take bus 701C from C to D. Seat 36R.",
    //  "From D, take flight FZ83 to B. Gate 35. Seat undef… be automatically transferred from your last leg.",
    //  "From B, take flight YN11 to E. Gate 0. Seat undefi… be automatically transferred from your last leg."]

    var simpleInstruction = journey.getSimple(); // return array of simple instructions if you just want to know route
    // ["From A to  B", "From B to  C", "From C to  D", "From D to  B", "From B to  E"]

    var types = journey.getTypes();// return ["airplane", "train"] - it is default types

Add custom type example

   // add types before creating a Journey object
   Journey.fn.addTicketType("bus", function(card){
       let ticket = {
           number: card.ticket.number == "" ? "" : `${card.ticket.number} `,
           spec: card.ticket.spec == "" ? "" : `the ${card.ticket.spec} `,
           seat: card.ticket.seat == "" ? "No seat assignment." : `Seat ${card.ticket.seat}.`
       };
       return `Take ${ticket.spec}bus ${ticket.number}from ${card.from} to ${card.to}. ${ticket.seat}`;
   });

   var journey = new Journey(inputData);
   var types = journey.getTypes();// and now you can check that type was added, return ["airplane", "train", "bus"]

   // now you can print it
   journey.printInstructions("#instructions");

journey's People

Contributors

0777144 avatar

Watchers

 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.