Skip to content

Instantly share code, notes, and snippets.

@pgilad
Created May 25, 2014 10:32
Show Gist options
  • Save pgilad/8ff4abde0dbac3bbcac9 to your computer and use it in GitHub Desktop.
Save pgilad/8ff4abde0dbac3bbcac9 to your computer and use it in GitHub Desktop.
Client exposes API

An API for website's Exposes

Purpose

Imagine you had a Chrome/Firefox/IE? extension that can use the same keys to handle the same basic actions throughout every web page you visit.

Lets assume your are visiting google.com and search for Js Slider. Now you want to move to the next page of results. Currently you have to click Next Page.

But what if Google implements their very own keyboard keys for their search. So they decide that if your press Ctrl+Alt+N you move to the next page. But what if Bing makes it Ctrl+Alt+P? And Yahoo makes it Cmd+Alt+N?

The solution? Expose your basic page functionality to the window object.

Specs

All basic functionality should be exposed under window.API.

Basic structure:

window.API = {
  page: {
    navigation: {
      next: function()
      back: function()
      first: function()
      last: function()
      jumpTo: function(page)
      content: function()
      nav: function()
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment