Skip to content

Connection Detector helps the user or audience that visits or makes use of your application to know when he or she has an active internet connection.

License

Notifications You must be signed in to change notification settings

emmamartins/connection-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connection Detector

Connection Detector module asynchronously checks if there exists an internet connection on your browser and triggers 'an internet connection loss error message' when it goes offline. It is a vanilla JAVASCRIPT module and does not require dependency to use.

Why do need?

Connection Detector helps your application users to know exactly when they do not have an active internet connection, rather than blaming it on your app for taking too long to load.

Sample Screen

Support

Most of the browsers today, if not all ships with inbuilt support for javascript, hence a wide range of support across different browsers for both personal computers and mobile browsers: - Safari, Opera, Mozilla, Chrome, Explorer, etc.

Note:

Calling the direct function might cause conflict if there is another module in your application that uses the same function name isClient() and isActive(). if you encounter any conflict or function name already exist or already defined then you have to call it as an Object.

Installation

npm

npm i connection-detector

git

git clone https://github.com/emmamartins/connection-detector.git

Getting started

Include css and js into the head of the web page

<link href="css/connection-detector.css" rel="stylesheet" type="text/css" />
<script src="js/connection-detector.js"></script>

Call

<script>
    isClient();
</script>

Default Parameters

    url;  // Default Application url. it can be replaced with url of your choice
    theme = 'Black' 

Color and Themes

Connection detector default color theme is set to Black

  • Black
  • Blue
  • Green
  • Orange
  • Red

Set Customize Theme

Call as an object

    <script>
        let connection = new Connection();
        connection.isClient({
            theme: 'blue' // or Blue
        });
    </script>

Call as function

    <script>
        isClient({
            theme: 'blue' // or Blue
        });
    </script>

Check Connection

Call as an object

    <script>
        let connection = new Connection();
        if(connection.isActive() === true){
        //  Do What you want here 
            }else{
                // Do What you want here
            }
</script>

Call as function

    <script>
    if(isActive() === true){
        //  Do What you want here 
    }else{
        // Do What you want here
    }
</script>

Author

👤 Raphael Essien

🤝 Contributing

Contributions, issues and feature requests are welcome!

Show your support

Give a ⭐️ if you like this project!

About

Connection Detector helps the user or audience that visits or makes use of your application to know when he or she has an active internet connection.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published