Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Sep 7, 2021
1 parent 41ea0e6 commit 8c83919
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 71 deletions.
4 changes: 0 additions & 4 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@
*~
*.log
node_modules
*.env
.DS_Store
package-lock.json
.bloggify/*
15 changes: 4 additions & 11 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ You can see below the API reference of this module.
Finds the value of parameter passed in first argument.

#### Params

- **String** `name`: The parameter name.
- **Boolean** `notDecoded`: If `true`, the result will be encoded.

Expand All @@ -20,7 +19,6 @@ the parameter is there, but it doesn't have a value, the value will
be `true`.

#### Params

- **String** `search`: An optional string that should be parsed (default: `window.location.search`).

#### Return
Expand All @@ -30,7 +28,6 @@ be `true`.
Stringifies a query object.

#### Params

- **Object** `queryObj`: The object that should be stringified.

#### Return
Expand All @@ -40,7 +37,6 @@ Stringifies a query object.
Adds, updates or deletes a parameter (without page refresh).

#### Params

- **String|Object** `param`: The parameter name or name-value pairs as object.
- **String** `value`: The parameter value. If `undefined`, the parameter will be removed.
- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
Expand All @@ -50,17 +46,19 @@ will not bring you to the old location.
#### Return
- **Url** The `Url` object.

### `getLocation()`
### `getLocation(excludeHash)`
Returns the page url, but not including the domain name.

#### Params
- **Boolean** `excludeHash`: If `true`, the location hash will not be appended in the result.

#### Return
- **String** The page url (without domain).

### `hash(newHash, triggerPopState)`
Sets/gets the hash value.

#### Params

- **String** `newHash`: The hash to set.
- **Boolean** `triggerPopState`: Triggers the popstate handlers (by default falsly).

Expand All @@ -71,7 +69,6 @@ Sets/gets the hash value.
Update the full url (pathname, search, hash).

#### Params

- **String** `s`: The new url to set.
- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
will not bring you to the old location.
Expand All @@ -85,7 +82,6 @@ pathname
Sets/gets the pathname.

#### Params

- **String** `pathname`: The pathname to set.
- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
will not bring you to the old location.
Expand All @@ -101,14 +97,12 @@ Calls the popstate handlers.
Adds a popstate handler.

#### Params

- **Function** `cb`: The callback function.

### `removeHash(push, trigger)`
Removes the hash from the url.

#### Params

- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
will not bring you to the old location.
- **Boolean** `trigger`: Triggers the popstate handlers (by default falsly).
Expand All @@ -117,7 +111,6 @@ will not bring you to the old location.
Removes the querystring parameters from the url.

#### Params

- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
will not bring you to the old location.
- **Boolean** `trigger`: Triggers the popstate handlers (by default falsly).
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-20 jillix <[email protected]> (http://jillix.com)
Copyright (c) 2014-21 jillix <[email protected]> (http://jillix.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
78 changes: 24 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,58 @@
<!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->


# url.js

[![Version](https://img.shields.io/npm/v/urljs.svg)](https://www.npmjs.com/package/urljs) [![Downloads](https://img.shields.io/npm/dt/urljs.svg)](https://www.npmjs.com/package/urljs)

> A lightweight JavaScript library to manipulate the page url.

## Demo


Browse the demos on http://jillix.github.io/url.js/


[![](http://i.imgur.com/BYxaxU1.png)](http://jillix.github.io/url.js/)

## CDN


The library is available on [CDNJS](https://cdnjs.com/libraries/urljs) as well. To use it, just do:

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/urljs/1.2.0/url.min.js"></script>
```

## Usage

```html
<script src="path/to/url.js"></script>
<!-- or use the cdn
<script src="https://cdnjs.cloudflare.com/ajax/libs/urljs/1.2.0/url.min.js"></script>
-->
<script>
Url.updateSearchParam("answer", 42);
</script>
```

## CommonJS-compatible


The library is CommonJS-compatible. You can `require("url.js")` in your files.
# urljs

A lightweight JavaScript library to manipulate the page url.

## :cloud: Installation


Check out the [`src`](/src) directory to download the needed files and include them on your page.

If you're using this module in a CommonJS environment, you can install it using `npm` or `yarn` and `require` it:
## Installation

```sh
# Using npm
npm install --save urljs

# Using yarn
yarn add urljs
$ npm i urljs
```





## :question: Get Help

There are few ways to get help:

1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
2. For bug reports and feature requests, open issues. :bug:




## :memo: Documentation





## Documentation





### `queryString(name, notDecoded)`
Finds the value of parameter passed in first argument.

#### Params

- **String** `name`: The parameter name.
- **Boolean** `notDecoded`: If `true`, the result will be encoded.

Expand All @@ -92,7 +66,6 @@ the parameter is there, but it doesn't have a value, the value will
be `true`.

#### Params

- **String** `search`: An optional string that should be parsed (default: `window.location.search`).

#### Return
Expand All @@ -102,7 +75,6 @@ be `true`.
Stringifies a query object.

#### Params

- **Object** `queryObj`: The object that should be stringified.

#### Return
Expand All @@ -112,7 +84,6 @@ Stringifies a query object.
Adds, updates or deletes a parameter (without page refresh).

#### Params

- **String|Object** `param`: The parameter name or name-value pairs as object.
- **String** `value`: The parameter value. If `undefined`, the parameter will be removed.
- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
Expand All @@ -122,17 +93,19 @@ will not bring you to the old location.
#### Return
- **Url** The `Url` object.

### `getLocation()`
### `getLocation(excludeHash)`
Returns the page url, but not including the domain name.

#### Params
- **Boolean** `excludeHash`: If `true`, the location hash will not be appended in the result.

#### Return
- **String** The page url (without domain).

### `hash(newHash, triggerPopState)`
Sets/gets the hash value.

#### Params

- **String** `newHash`: The hash to set.
- **Boolean** `triggerPopState`: Triggers the popstate handlers (by default falsly).

Expand All @@ -143,7 +116,6 @@ Sets/gets the hash value.
Update the full url (pathname, search, hash).

#### Params

- **String** `s`: The new url to set.
- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
will not bring you to the old location.
Expand All @@ -157,7 +129,6 @@ pathname
Sets/gets the pathname.

#### Params

- **String** `pathname`: The pathname to set.
- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
will not bring you to the old location.
Expand All @@ -173,14 +144,12 @@ Calls the popstate handlers.
Adds a popstate handler.

#### Params

- **Function** `cb`: The callback function.

### `removeHash(push, trigger)`
Removes the hash from the url.

#### Params

- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
will not bring you to the old location.
- **Boolean** `trigger`: Triggers the popstate handlers (by default falsly).
Expand All @@ -189,23 +158,24 @@ will not bring you to the old location.
Removes the querystring parameters from the url.

#### Params

- **Boolean** `push`: If `true`, the page will be kept in the history, otherwise the location will be changed but by pressing the back button
will not bring you to the old location.
- **Boolean** `trigger`: Triggers the popstate handlers (by default falsly).



## :yum: How to contribute



## How to contribute
Have an idea? Found a bug? See [how to contribute][contributing].



## :scroll: License
## License
See the [LICENSE][license] file.

[MIT][license] © [jillix][website]

[license]: http://showalicense.com/?fullname=jillix%20%3Ccontact%40jillix.com%3E%20(http%3A%2F%2Fjillix.com)&year=2014#license-mit
[website]: http://jillix.com
[license]: /LICENSE
[contributing]: /CONTRIBUTING.md
[docs]: /DOCUMENTATION.md
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@
}
]
}
}
}

0 comments on commit 8c83919

Please sign in to comment.