Coder Social home page Coder Social logo

iamjuniorpeter / awesomstar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pinceladasdaweb/awesomstar

0.0 1.0 0.0 880 KB

Awesome (star)rating system with PHP, MySQL and pure JavaScript.

License: MIT License

JavaScript 28.18% PHP 50.47% Smarty 5.92% CSS 15.42%

awesomstar's Introduction

Awesomstar

Awesome (star)rating system with PHP, MySQL and pure JavaScript.

Getting Started

# Get the latest snapshot
$ git clone --depth=1 https://github.com/pinceladasdaweb/Awesomstar.git

Add the following javascript in your page:

<script src="path/to/awesomstar.min.js"></script>
<script>
    new Awesomstar({
        endpoint: 'your_api_endpoint_here'
    });
</script>

The script depends on the following HTML markup:

<span class="rating" data-rating-id="1" data-rating-val="3">
    <input class="star" type="radio" name="star" id="star-1" value="1"><label for="star-1">1</label>
    <input class="star" type="radio" name="star" id="star-2" value="2"><label for="star-2">2</label>
    <input class="star" type="radio" name="star" id="star-3" value="3"><label for="star-3">3</label>
    <input class="star" type="radio" name="star" id="star-4" value="4"><label for="star-4">4</label>
    <input class="star" type="radio" name="star" id="star-5" value="5"><label for="star-5">5</label>
</span>

The values below are sent from the database for the JavaScript to update the status of the rating of each element:

Value Description
data-rating-id The id of the element in the database.
data-rating-val The average value of the vote.

After the user clicks the value of the desired rating, is sent via POST to the back end the following values:

Value Description
id The id of the element in the database.
rating The value of the rating ranges from 1 to 5.

How to run a callback function after vote:

<script>
    new Awesomstar({
        endpoint: 'your_api_endpoint_here',
        callback: function (data) {
            console.log(data);
        }
    });
</script>

An error message or success is returned, providing feedback to the user.

Browser support

IE Chrome Firefox Opera Safari
IE 9+ ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔

Contributing

Check CONTRIBUTING.md for more information.

History

Check Releases for detailed changelog.

License

MIT

awesomstar's People

Contributors

pinceladasdaweb avatar

Watchers

Junior Peter 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.