Giter Club home page Giter Club logo

photo-comp's Introduction

Photo Comparison Voting Application

Introduction

This is a JavaScript-based photo pair voting application. The application displays two photos at a time and allows users to vote for their favorite photo. The votes are stored in the browser's local storage and are updated each time a user votes.

You can find a demo here (https://costantinos.github.io/photo-comp/).

Features

  1. Display two photos at a time
  2. Allow users to vote for their favorite photo
  3. Store votes in the browser's local storage
  4. Display the current vote count for each photo
  5. Display the total vote count for all photo pairs when all photo pairs have been displayed

Requirements

  • A modern web browser that supports JavaScript and local storage
  • Two directories containing photos to be used in the voting process
    • You need a server for the fetch to work correctly (e.g., python -m http.server 8081)

Usage

  1. Call the createPairs function with the two directories containing the photos. This will create an array of photo pairs to be displayed.
  2. Call the updateDisplay function to display the first photo pair and initialize the vote count display.
  3. Use the "Next" button to display the next photo pair.
  4. Use the "Vote 1" and "Vote 2" buttons to vote for the photos.

Implementation Details

  1. The getPhotos function retrieves the list of photos from a directory and returns an array of photo URLs.
  2. The createPairs function retrieves the photos from two directories and creates an array of photo pairs by taking the minimum of the number of photos in each directory.
  3. The updateDisplay function updates the photo display and vote count display. It also adds click event listeners to the "Vote 1" and "Vote 2" buttons to allow users to vote.
  4. The "Next" button has a click event listener that advances to the next photo pair.
  5. The votes for each photo are stored in the browser's local storage using the key photo1-${currentPair}-votes for photo 1 and photo2-${currentPair}-votes for photo 2. The vote count for each photo is updated each time a user votes.
  6. The total vote count for all photo pairs is displayed when all photo pairs have been displayed.

photo-comp's People

Contributors

costantinos avatar

Watchers

 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.