Network connection JavaScript module with online and offline events