Giter Site home page Giter Site logo

dawoody / astrology-js Goto Github PK

View Code? Open in Web Editor NEW
46.0 9.0 21.0 40 KB

An open source javascript project to create a class for easy distribution and access to astrological information in web-applications/web-pages

JavaScript 75.90% HTML 24.10%
javascript zodiac-sign library astrology

astrology-js's Introduction

Astrology

An open source javascript project to simply getting general astrological information within web-applications

npm version Download

Version Information


Check out the version information page for more information.

License


This software is distributed as Open Source software following the GNU General Public License, version 3 (GPL-3.0)

Description


This project is aimed to be an open source project to design a simple javascript class that could be used to generate general astrological information to individuals based on birth date information and such. The idea is that the class could be instantiated and used in a general web-project and then accessed through a set of different public methods that add data, do calculations and present information back to the user. Currently the class is meant to load some general information data about the different zodiac signs from a json resource. The default settings is to load the data from a json-files to get the specific date information for each zodiac signs aswell as a more detailed description about what a specific zodiac sign entails. The source for the json data could be altered through providing a connectionObject to the constructor method as explained below.

How to use the Astrology class


Within the web-pages/applications you would like to use the class, you should include the script, within the <head>..</head> section or preferably within the last section of the <body>..</body> section, such as for instance

...
<script src="../js/astrology.js"></script>
</body>
</html>

Then within an actual javascript file, (could be within a jquery statement aswell), the class should be instantiated with an optional connectionObject parameter being passed to the constructor like:

var astrology = new Astrology();

or..

var connectionObject = {
     dateDataUrl: url_to_where_to_fetch_the_date_data,
     descriptionDataUrl: url_to_where_to_fetch_the_description_data
 }

var astrology = new Astrology(connectionObject);

When interacting with the class there are three methods that saves the date needed to find out the zodiac sign. First there is the method addDay(dayNumber) that takes in a number between 1-31 as a valid day number in a month, and then there is addMonth(monthNameOrMonthNumber) which takes in a string with a valid month-name such as for example january, february etc... or a valid month-number string ranging from 1-12, such as 1, 12 or 01, 07 for instance. Then there is also a method called addFullDateString(dateString) which takes in a date string in the format YYYY-MM-DD. This is naturally supported as the output from the native html5-method <input type="date"> , which in turn is supported by most modern browsers, except Internet Explorer. Read more here.

astrology.addDay(dayNumber);

astrology.addMonth(monthNameOrMonthNumber);

astrology.addFullDateString(dateString)

To actually get the zodiac sign or the zodiac sign description from an astrology object, the methods fetchZodiacSign and fetchZodiacSignDescription both fetches different strings that could be used within the DOM-structure or as the user see fit. The fetchZodiacSignDescription method returns a description and the fetchZodiacSign returns the zodiac name, both in the format of a string. They are called upon such as:

astrology.fetchZodiacSign();
astrology.fetchZodiacSignDescription();

To get a more hands on example on how to implement the class and use it within an actual web-application check out the Html implementation code example

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.