/NetworkInformation-Library

JS Library to check Network information in front end

Primary LanguageHTMLMIT LicenseMIT

NetworkInformationJS

A Javascript Library to check the network information and download speed of client. Using the principle of front end.

For the network information, it use IP-API for user network basic information and Google Maps to corroborate his data. And for the speed test, it use a fork of detectClientSpeed to allow progress checking.

The original files are NI.js who uses javascript classes. His successor was NI-allbrowsers.js, who was factorized and separated in three classes: Heimdal.js, NetworkInformation.js and SpeedTest.js.

Classes

Heimdal

Main class who administrate the use of NetworkInformation & SpeedTest classes

NetworkInformation

Class who get the information of the client network

NetworkUtilities

Class with network utilities, as ping method. WARNING: This class is experimental, the methods contained here probably require a server.

SpeedTest

Class in charge of make Speed Tests

Heimdal

Main class who administrate the use of NetworkInformation & SpeedTest classes

Kind: global class

new Heimdal(server)

Heimdal - Main class who administrate the use of NetworkInformation & SpeedTest classes

Param Type Description
server string URL of the server where the JSON will be send

Heimdal.init(callback) ⇒ undefined

init - Call to NetworkInformation to init his params and execute the callback function

Kind: static method of Heimdal

Param Type Description
callback function function when the network information was ready

Heimdal.runTest(on, file) ⇒ undefined

runTest - Start the Speed test

Kind: static method of Heimdal

Param Type Description
on function progress function. For loading stuff
file file used in the test

Heimdal.sendData() ⇒ undefined

sendData - Send all the data to the server

Kind: static method of Heimdal

Heimdal.pingTestSecuentialVersion(callback, earlycall) ⇒ undefined

pingTestSecuentialVersion - Start the ping test to top sites

Kind: static method of Heimdal

Param Type Description
callback function The callback function when the ping test was ready.
earlycall function The function called when an individual ping test was ready.

Heimdal.pingTestConcurrentVersion(callback, earlycall) ⇒ undefined

pingTestConcurrentVersion - Start the ping test to top sites

Kind: static method of Heimdal

Param Type Description
callback function The callback function when the ping test was ready.
earlycall function The function called when an individual ping test was ready.

Heimdal.getNetworkInfo() ⇒ NetworkInformation

getNetworkInfo - Return the NetworkInformation object

Kind: static method of Heimdal
Returns: NetworkInformation - Inner NetworkInformation object

Heimdal.getSpeedTests() ⇒ SpeedTest

getSpeedTests - Return the SpeedTest object

Kind: static method of Heimdal
Returns: SpeedTest - Inner SpeedTest object

Heimdal.getUtilities() ⇒ NetworkUtilities

getUtilities - Return the NetworkUtilities object

Kind: static method of Heimdal
Returns: NetworkUtilities - Inner NetworkUtilities object

Heimdal.addUserParam(varname, vardata) ⇒ undefined

addUserParam - Add param to user data.

Kind: static method of Heimdal

Param Type Description
varname string the name of the new var
vardata string the data of the new var

NetworkInformation

Class who get the information of the client network

Kind: global class

new NetworkInformation()

NetworkInformation - Class who get the information of the client network

NetworkInformation.getGoogleInfo(tail, callback, lat, lon) ⇒ undefined

getGoogleInfo - receive the data from google and set in the internal vars

Kind: static method of NetworkInformation

Param Type Description
tail function The tail function.
callback function The callback function.
lat number latitude
lon number longitude

NetworkInformation.setInformation(readyMethod) ⇒ undefined

setInformation - Set all the information to the class. Requesting to the navigator, google and ip-api

Kind: static method of NetworkInformation

Param Type Description
readyMethod function function called when the information was setted

this.setInformation~getHtml5Geolocation(tail_method, callbackfunction) ⇒ undefined

getHtml5Geolocation - get the geolocalitation from the navigator

Kind: inner method of this.setInformation

Param Type Description
tail_method function next function to be called.
callbackfunction function callback function

this.setInformation~getIpApiInformation(callbackfunction) ⇒ undefined

getIpApiInformation - get the network information from ip-api

Kind: inner method of this.setInformation

Param Type Description
callbackfunction function callback function

NetworkInformation.getAS() ⇒ string

getAS - Get Autonomous system

Kind: static method of NetworkInformation
Returns: string - Autonomous system

NetworkInformation.getCity() ⇒ string

getCity - Get city

Kind: static method of NetworkInformation
Returns: string - city

NetworkInformation.getCountry() ⇒ string

getCountry - Get country

Kind: static method of NetworkInformation
Returns: string - country

NetworkInformation.getCountryCode() ⇒ string

getCountryCode - Get country code

Kind: static method of NetworkInformation
Returns: string - country code

NetworkInformation.getIsp() ⇒ string

getIsp - Get the ISP

Kind: static method of NetworkInformation
Returns: string - ISP

NetworkInformation.getCoordinates() ⇒ Array

getCoordinates - Get Latlong of client.

Kind: static method of NetworkInformation
Returns: Array - [Latitude, Longitude]

NetworkInformation.getOrganization() ⇒ string

getOrganization - Get organization (or ISP if didn't exists)

Kind: static method of NetworkInformation
Returns: string - organization

NetworkInformation.useProxy() ⇒ boolean

useProxy - Check if the user use a proxy

Kind: static method of NetworkInformation
Returns: boolean - True if the user use a proxy

NetworkInformation.getIp() ⇒ string

getIp - Get IP

Kind: static method of NetworkInformation
Returns: string - IP

NetworkInformation.getRegion() ⇒ string

getRegion - Get region

Kind: static method of NetworkInformation
Returns: string - Region

NetworkInformation.getRegionName() ⇒ string

getRegionName - Get region's name

Kind: static method of NetworkInformation
Returns: string - Region's name

NetworkInformation.getReverseDNS() ⇒ string

getReverseDNS - Get the reverse of the DNS

Kind: static method of NetworkInformation
Returns: string - Reverse of the DNS

NetworkInformation.isSuccessful() ⇒ boolean

isSuccessful - Check if the connection was successful

Kind: static method of NetworkInformation
Returns: boolean - True if the connection was successful

NetworkInformation.getTimezone() ⇒ string

getTimezone - Get timezone

Kind: static method of NetworkInformation
Returns: string - Timezone

NetworkInformation.isAndroid() ⇒ boolean

isAndroid - Check if the device is Android

Kind: static method of NetworkInformation
Returns: boolean - True if the device is Android

NetworkInformation.isMobile() ⇒ boolean

isMobile - Check if the device is mobile

Kind: static method of NetworkInformation
Returns: boolean - True if the device is mobile

NetworkInformation.checkConnectionType() ⇒ string

checkConnectionType - If its avalaible, check the connection type. (Only work on Android)

Kind: static method of NetworkInformation
Returns: string - Connection Type

NetworkInformation.getOS() ⇒ string

getOS - Get the OS of the client

Kind: static method of NetworkInformation
Returns: string - Operative System

NetworkInformation.behindNAT() ⇒ boolean

behindNAT - Check if the client is behind NAT

Kind: static method of NetworkInformation
Returns: boolean - True if the client is behind NAT

NetworkUtilities

Class with network utilities, as ping method. WARNING: This class is experimental, the methods contained here probably require a server.

Kind: global class

new NetworkUtilities()

NetworkUtilities - Class with network utilities, as ping method. WARNING: This class is experimental, the methods contained here probably require a server.

NetworkUtilities.ping(url, callback) ⇒ undefined

ping - ping to a url. WARNING: THIS REQUIRED A SERVER TO CHECK IF A URL REALLY EXISTS. OTHERWISE THE PING SUCCESS WITH FALSE POSITIVE.

Kind: static method of NetworkUtilities

Param Type Description
url string the url to be pinged
callback function Callback function when the specific ping as done. Receive a ping object with the time, the status and the url.

NetworkUtilities.getPings() ⇒ Array

getPings - Get an array with pings.

Kind: static method of NetworkUtilities
Returns: Array - Pings

NetworkUtilities.pingTopSecuentialVersion(earlycall, callback) ⇒ undefined

pingTestSecuentialVersion - Make a secuencial ping to TOP_CL urls

Kind: static method of NetworkUtilities

Param Type Description
earlycall function The function called when an individual ping test was ready.
callback function The callback function when the process finish.

NetworkUtilities.pingTopConcurrentVersion(earlycall, callback) ⇒ undefined

pingTestConcurrentVersion - Make a concurrent ping to TOP_CL urls

Kind: static method of NetworkUtilities

Param Type Description
earlycall function The function called when an individual ping test was ready.
callback function The callback function when the process finish.

NetworkUtilities.checkNAT(url, callback) ⇒ undefined

checkNAT - Send a request to a specific server to check if the client is behind NAT. With callback function.

Kind: static method of NetworkUtilities

Param Type Description
url string The url of the server.
callback function The callback function. Receive server answer as param.

SpeedTest

Class in charge of make Speed Tests

Kind: global class

new SpeedTest(file_url)

SpeedTest - Class in charge of make Speed Tests

Param Type Description
file_url string URL of the file used in the download speed test

SpeedTest.getDownloadSpeed() ⇒ number

getDownloadSpeed - Get the download speed

Kind: static method of SpeedTest
Returns: number - download speed

SpeedTest.getLatency() ⇒ number

getLatency - Get the latency

Kind: static method of SpeedTest
Returns: number - latency

SpeedTest.getLatencyType() ⇒ string

getLatencyType - Get the equivalence of latency

Kind: static method of SpeedTest
Returns: string - Latency speed class name

SpeedTest.getThroughput() ⇒ number

getThroughput - Get the throughput

Kind: static method of SpeedTest
Returns: number - throughput

SpeedTest.getThroughputType() ⇒ string

getThroughputType - Get the equivalenceof throughput

Kind: static method of SpeedTest
Returns: string - Throughput speed class name

SpeedTest.getTestTime() ⇒ number

getTestTime - Get the total time of the test

Kind: static method of SpeedTest
Returns: number - duration of test

SpeedTest.startSpeedTest(onprogress) ⇒ undefined

startSpeedTest - start the speed test

Kind: static method of SpeedTest

Param Type Description
onprogress function on progress function