Socket
Socket
Sign inDemoInstall

ip-geolocation-api-jquery-sdk

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-geolocation-api-jquery-sdk - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

81

ipgeolocation.js
var _ipgeolocation = function() {
var useSessionStorage = false;
var asyncCall = true;
var isHostname = false;
var isLiveHostname = false;
var isHostnameFallbackLive = false;
var isSecurity = false;
var isUserAgent = false;
var ipAddress = "";

@@ -11,6 +16,9 @@ var excludes = "";

var longitude = "";
var location = "";
var geolocationEndpoint = "ipgeo";
var timezoneEndpoint = "timezone";
var useragentEndpoint = "user-agent";
var geolocationResponseName = "_ipgeolocation_geolocation";
var timezoneResponseName = "_ipgeolocation_timezone";
var useragentResponseName = "_ipgeolocation_useragent";

@@ -25,2 +33,5 @@ function request(subUrl, callback, apiKey = "") {

return;
} else if (subUrl == useragentEndpoint && sessionStorage.getItem(useragentResponseName) && callback) {
callback(JSON.parse(sessionStorage.getItem(useragentResponseName)));
return;
}

@@ -51,3 +62,33 @@ }

}
if(isHostname || isSecurity || isUserAgent){
var val = "";
var includeHost = false;
if(isHostname){
val = "hostname";
includeHost = true;
} else if(isHostnameFallbackLive) {
val = "hostnameFallbackLive";
includeHost = true;
} else if(isLiveHostname) {
val = "liveHostname";
includeHost = true;
}
if(isSecurity){
if(includeHost){
val = val + ",security";
} else{
val = "security";
}
}
if(isUserAgent){
if(includeHost || isSecurity){
val = val + ",useragent";
} else{
val = "useragent";
}
}
urlParameters = addUrlParameter(urlParameters, "include", val);
}
if (lang) {

@@ -65,2 +106,6 @@ urlParameters = addUrlParameter(urlParameters, "lang", lang);

}
if(location){
urlParameters = addUrlParameter(urlParameters, "location", location);
}

@@ -115,6 +160,19 @@ var httpRequest;

},
setIPAddress: function(ip = "") {
ipAddress = ip;
includeHostname: function(h = false) {
isHostname = h;
},
includeHostnameFallbackLive: function(h = false) {
isHostnameFallbackLive = h;
},
includeLiveHostname: function(h = false) {
isLiveHostname = h;
},
includeSecurity: function(s = false) {
isSecurity = s;
},
includeUserAgent: function(u = false) {
isUserAgent = u;
},
setFields: function(f = "") {
console.log("set");
fields = f;

@@ -128,9 +186,15 @@ },

},
setIPAddress: function(ip = "") {
ipAddress = ip;
},
setTimeZone: function(t = "") {
tz = t;
},
setCoordinates: function(latitude = "", longitude = "") {
latitudeParameter = latitude;
longitudeParameter = longitude;
setCoordinates: function(la = "", lo = "") {
latitude = la;
longitude = lo;
},
setLocation: function(loc = "") {
location = loc;
},
getGeolocation: function(callback, apiKey = "") {

@@ -141,4 +205,7 @@ request(geolocationEndpoint, callback, apiKey);

request(timezoneEndpoint, callback, apikey);
},
getUserAgent: function(callback, apikey = "") {
request(useragentEndpoint, callback, apikey);
}
}
};
}();

25

package.json
{
"_from": "ip-geolocation-api-jquery-sdk",
"_inBundle": false,
"_integrity": "sha512-mmwTYe04ioiUcnOaMiPYD5SFIBoqvnRgeC/YkrYe5B9VGxRd1gdXVmDAaXRoHacDvgnqhW+CDMXnyEvvgXtj0g==",
"_location": "/ip-geolocation-api-jquery-sdk",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "ip-geolocation-api-jquery-sdk",
"name": "ip-geolocation-api-jquery-sdk",
"escapedName": "ip-geolocation-api-jquery-sdk",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/ip-geolocation-api-jquery-sdk/-/ip-geolocation-api-jquery-sdk-1.1.0.tgz",
"_shasum": "7afe1f670ee1309eb9effb25818c481c5d855593",
"_spec": "ip-geolocation-api-jquery-sdk",
"_where": "/home/developer/jQry/npm",
"author": "ipgeolocation",

@@ -48,3 +25,3 @@ "deprecated": false,

},
"version": "1.1.0",
"version": "1.1.1",
"repository": {

@@ -51,0 +28,0 @@ "type": "git",

@@ -7,3 +7,3 @@ # IP Geolocation API JQuery SDK

Note: This SDK is compatible with Vanilla JS and doesn't require JQuery as we have dropped the JQuery dependencies from v1.1.0 in this SDK.
**Note:** This SDK is compatible with Vanilla JS and doesn't require JQuery as we have dropped the JQuery dependencies from v1.1.1 in this SDK.

@@ -30,2 +30,6 @@ Developers can use this JQuery SDK for software and web projects related to, but not limited to:

## Documentation
Use the following URL to visit documentation
[https://ipgeolocation.io/documentation.html](https://ipgeolocation.io/documentation.html)
## Installation

@@ -37,3 +41,3 @@ ### CDN Link

```html
<script src="https://cdn.jsdelivr.net/npm/ip-geolocation-api-jquery-sdk@1.1.0/ipgeolocation.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ip-geolocation-api-jquery-sdk@1.1.1/ipgeolocation.min.js"></script>
```

@@ -83,2 +87,8 @@

_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");
// Get geolocation along with hostname, security detail and user-agent detail.
_ipgeolocation.includeHostname(true);
_ipgeolocation.includeSecurity(true);
_ipgeolocation.includeUserAgent(true);
_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");
```

@@ -120,4 +130,29 @@ ## Time Zone API

_ipgeolocation.getTimezone(handleResponse, "YOUR_API_KEY");
// Get time zone information by location
_ipgeolocation.setLocation("Amman, Jordan");
_ipgeolocation.getTimezone(handleResponse, "YOUR_API_KEY");
```
## Time Zone API
Here are a few examples to query Time Zone information from Timezone API.
```javascript
// Function to handle the response from IP Geolocation API.
// "response" is a JSON object returned from IP Geolocation API.
function handleResponse(response) {
console.log(response);
}
// Toggle sessionStorage usage to store API response on client-side. (This is very handy as it will help users to avoid making duplicate API calls for a single visitor.)
_ipgeolocation.enableSessionStorage(true);
// Toggle API calls' async behavior. By default, async is true.
_ipgeolocation.makeAsyncCallsToAPI(false);
// Get User Agent detail.
_ipgeolocation.getUserAgent(handleResponse, "YOUR_API_KEY");
```
## Example

@@ -128,3 +163,3 @@

```javascript
<script src="https://cdn.jsdelivr.net/npm/ip-geolocation-api-jquery-sdk@1.1.0/ipgeolocation.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ip-geolocation-api-jquery-sdk@1.1.1/ipgeolocation.min.js"></script>

@@ -168,2 +203,2 @@ <script>

By default, geolocation information is returned in English. Response in a language other than English is available to paid users only.
By default, geolocation information is returned into English. Response in a language other than English is available to paid users only.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc