GithubHelp home page GithubHelp logo

kevinselwyn / cats Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 5.45 MB

Cats is a Javascript plugin that will replace all <img>s on a page with pictures of cats when a certain URL hash criteria is met.

License: GNU General Public License v3.0

JavaScript 29.76% HTML 70.24%

cats's Introduction

Cats

Cats is a Javascript plugin that will replace all <img>s on a page with pictures of cats when a certain URL hash criteria is met.

Usage

Include the following in the <head> of your document:

<script src="cats.js"></script>

To initialize the plugin, add the following to your document:

<script type="text/javascript">
    Cats.init();
</script>

Take care to call Cats.init() after the page has been fully loaded with either:

window.onload = function () {
    Cats.init();
};

Or with jQuery:

$(function () {
    Cats.init();
});

When the URL hash changes to #cats, it will trigger the plugin to replace all <img>s with pictures of cats.

The plugin will revert back to the original images if the hash no longer matches #cats.

Configuration

There are a number of configurable aspects of this plugin.

Hash

By default, the URL hash that the plugin is waiting for is #cats. This can be changed by accessing that variable directly:

Cats.hash = "dogs";

Note: Leave the octothorpe (#) out. It will be added automatically.

URL

While this plugin is meant to replace images with cat pictures, any other type of placeholder image library may be used, provided that it follows the same URL scheme as the default image library that is being used: placekitten.com

URLs are formatted like this, where 200 is the width and 300 is the height:

http://placekitten.com/200/300

Here are a few other libraries that use the same URL scheme:

Access the variable directly to change the image library:

Cats.url = "placesheen.com"

Cutoff

You may not want all images to be replaced. Some smaller images or icons might look distorted when replaced. You may set the minimum dimensions of images you want to be replaced. By default, any image with a width or height less than 100px will not be replaced.

Cats.cutoff = 200;

Tested Environments

Tested and working on:

  • Google Chrome (Mac + PC)
  • Firefox (Mac + PC)
  • Safari (Mac + PC)
  • Opera (Mac + PC)

cats's People

Contributors

kevinselwyn avatar

Stargazers

 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.