Navigation Menu

Skip to content

ironfroggy/hashtrack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hashtrack

The hashtrack.js library provides an implementation of state-hashes in
Javascript application, which is backwards compatible with pre-hashchange
browsers. It also provides much more powerful facilities to utilize the same
structure of a full URL inside the hash, including paths and querystrings.

API of hashtrack.

hashtrack
    The only exposed name. The entire API is under this name.

hashtrack.init()
    Begins the hashtrack usage. Must be called once after the page has loaded.

hashtrack.onhashchange(callback, callnow)
    Registers a callback to be invoked when the hash value changes.
    If callnow == true, the callback should be invoked immediately with
    the current hash value.

hashtrack.onhashvarchange(varname, callback, callnow)
    Registers a callback to be invoked when a specific hash-query variable
    changes. This value is parsed out of a query-string syntax segment in the
    hash value. For example, the URL

        http://colorapp.com/#?color=red

    Might call hashtrack.onhashvarchange("color", callback) and callback("red")
    would be called.

hashtrack.getAllVars()
    Returns an object mapping all hash-query variable names to their values.
    The above example URL would return {"color": "red"}

hashtrack.getVar(name)
    Returns one variable, by name.

hashtrack.setVar(name, value)
    Changes the value of a specific variable in the hash-querystring

hashtrack.getPath()
    Returns the path portion of the hash value.

hashtrack.setPath(path)
    Changes the path portion of the hash value, but leaves the querystring alone.

About

A Javascript library for triggering callbacks on #hash changes in the URL and parsing like a querystring

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published