Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/javve/hash.js
Hash.js is a 0.5 KB script that lets you in a super simple way manipulate everything behind # in urls.
https://github.com/javve/hash.js
Last synced: 24 days ago
JSON representation
Hash.js is a 0.5 KB script that lets you in a super simple way manipulate everything behind # in urls.
- Host: GitHub
- URL: https://github.com/javve/hash.js
- Owner: javve
- Created: 2012-02-06T20:51:23.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2014-07-29T12:47:52.000Z (over 10 years ago)
- Last Synced: 2024-10-14T10:51:03.495Z (about 1 month ago)
- Language: JavaScript
- Homepage: http://jonnystromberg.com/hash-js
- Size: 145 KB
- Stars: 156
- Watchers: 10
- Forks: 28
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Hash.js - URL Hash Manipulation
Hash.js is a 0.5 KB script that lets you in a super simple way manipulate
everything behind `#` in urls. Tested in latest Chrome, Safari, Firefox and IE7,8,9.See example page at [jonnystromberg.com/hash-js](http://jonnystromberg.com/hash-js) or see it
in action at [PNGTextures.com](http://pngtextures.com).Btw, [follow me (@javve) at Twitter](http://twitter.com/javve) and checkout my other project [List.js](http://listjs.com)
**Notice**: The main focus of Hash.js is simplicity. This is no tool for your super-ajax-native-feeling-app-with-google-bot-support. If
that's your usage situation, use the awesome [History.js](https://github.com/balupton/history.js).## Usage
Just include `hash.min.js` or `hash.js` at your site and then a `hash` object will become available.
hash.add({foo: "bar" }); // Url becomes http://url.com#foo=bar
</scrtip>## Methods
* **hash.add(params)**
Add parameter to hashhash.add({ foo: "bar" }); // http://url.com#foo=bar
hash.add({ car: "dar", sar: "par" }); // http://url.com#foo=bar&car=dar&sar=par* **hash.get(param)** or **hash.get()**
Returns value of paramter in hash. If `param` is `undefined` then all values are returned.var fooValue = hash.get('foo'); // fooValue == "bar"
var allValues = hash.get(); // allValues == { foo: "bar", car: "dar", sar: "par"}* **hash.remove(param)**
Removes the value with name `param`.hash.remove('foo'); // http://url.com#car=dar&sar=par
* **hash.clear()**
Clears entire hash.hash.clear(); // http://url.com#
## License
DON'T BE A DICK PUBLIC LICENSE
Version 1, December 2009
Copyright (C) 2011
[Jonny Strömberg](http://jonnystromberg.com) [@javve](http://twitter.com/javve)Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.DON'T BE A DICK PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION1. Do whatever you like with the original work, just don't be a dick.
Being a dick includes - but is not limited to - the following instances:1a. Outright copyright infringement - Don't just copy this and change the name.
1b. Selling the unmodified original with no work done what-so-ever, that's REALLY being a dick.
1c. Modifying the original work to contain hidden harmful content. That would make you a PROPER dick.
2. If you become rich through modifications, related works/services, or supporting the original work,
share the love. Only a dick would make loads off this work and not buy the original works
creator(s) a pint.3. Code is provided with no warranty. Using somebody else's code and bitching when it goes wrong makes
you a DONKEY dick. Fix the problem yourself. A non-dick would submit the fix back.