0

I tried to embed auto internet connection detection and server availability in my nitrogen driven application by including the script in the template bare.html available at http://github.hubspot.com/offline/ like this example below

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" .......">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
     <!-- default tags in the bare.html template here -->

    <!-- start of the block of code embedded -->

      <script src="/js/offline-0.7.3/offline.min.js"></script>

      <link rel="stylesheet" href="/js/offline-0.7.3/themes/offline-theme-chrome.css" />
      <link rel="stylesheet" href="/js/offline-0.7.3/themes/offline-language-english.css" />
    <script>
      var run = function(){
        var req = new XMLHttpRequest();
        req.timeout = 5000;
        req.open('GET', 'http://mysite/favico.ico', true);
        req.send();
      }
     setInterval(run, 3000);
   </script>
  <!-- End of the block of code -->
</head>

<body>
   [[[page:body()]]]
  <script>[[[script]]] </script> 
</body>
</html>

I down loaded the zip file from the site mentioned above and unzipped it from the nitrogen/site/static/js directory.

I rendered the page and then disconnected the internet, no notification appeared!!

I followed the example in the ./test/index.html file of the test directory of the unzipped directory offline-0.7.3.zip

Any help or alternative solution is highly welcomed

  • So, are you getting any errors in the console? – Cerbrus Jun 20 '14 at 13:56
  • **No** any error! I commanded view source from the rendered page to see if the script and themes can be pulled - and it was positive. Now i wonder what is not happening! Is something wrong with my implementation or? – Vianney Sserwanga Jun 20 '14 at 14:04
  • Are you running this server locally, or on a remote machine/VM? If this particular server is being run locally, then the requests will complete even if internet is disconnected. Beyond that, it doesn't look like you're doing anything wrong. – chops Jun 20 '14 at 18:22
  • It works actually!!! This is one of the easiest way of adding auto internet connection status and server availability detection to a nitrogen driven application – Vianney Sserwanga Jun 26 '14 at 09:40

0 Answers0