hubspot / offline Goto Github PK
View Code? Open in Web Editor NEWAutomatically display online/offline indication to your users
Home Page: http://github.hubspot.com/offline/docs/welcome
License: MIT License
Automatically display online/offline indication to your users
Home Page: http://github.hubspot.com/offline/docs/welcome
License: MIT License
When i go offline i see the offline ui message, try to make some requests (getting exceptions in console) and when i connect my internet connection i don't see the ajax requests being remade, although i see the message disappears. Working in Rails/Angularjs environment.
Thanks in advance.
http://dqakt69vkj09v.cloudfront.net/are-we-online.gif
gives access denied for me, so my app thinks i am always offline
I tried to integrate offline js with my existing https webapp. My Verisign certification is getting removed since offline js making calls to "http://dqakt69vkj09v.cloudfront.net/are-we-online.gif....".
Any considerations for mobile support, preferably iOS? As of now, it doesn't work.
when i include offline.min.js and theme css to my page, and shut down the server, nothing happend when ajax request was failed. what's wrong with it?
Could you restore the last deprecated cloudfront hosted file (http://dqakt69vkj09v.cloudfront.net/are-we-online.gif) to avoid 404 errors to preserve previous version usage of the library?
I know you recommend to update to the last version but the presence of the file helps a lot in the transition.
Thanks.
I am a newbie, please let me know the code to put after the script to disable requests (false) thanks.
HEAD http://[my domain]/offline-test-request/498128607
404 Not Found
36ms
I am constantly getting bombarded with those errors in firebug. Is this intended? IMHO it should not show errors when checking.
I've updated to the newest version so that I am no longer referencing the cloudfront asset. In the console of all my browsers, I am seeing the request at the specified intervals, but once I disconnect my internet connection, the requests continue without error (and without an OK response as well) so I never see the offline banner. What could be causing this?
I was very excited to use this, and it seems to have a lot of potential, but there are a lot of small issues:
Also, the documentation was confusing. Some important things left out, contradictions, etc.
Will come back in a month and check it out though :)
Can you move localization strings from CSS and JS to one place?
Texts for ui and time before reconnecting now in separate place and this is not comfortably, especially when files not in UTF8 encoding,
Thanks!
A bower.json
file is fairly trivial (along the lines of package.json
) and would permit registering offline with the Bower registry.
Which would be super-cool.
"Your computer lost its internet connection" message stays up after reconnecting to the internet.
this is the options:
Offline.options = {
checks: {
xhr: {url: 'http://google.com'}
},
active: 'xhr'
};
however offlinejs still tries to work with the image approach.
I have the latest version of the library and when the application first loads I'd like it to not check for favicon.ico. Is that possible?
I have reasons for asking this, but it's a side issue and not worth discussing here.
Here's the code pattern I'm using and I would expect this to only use the url I have specified:
Offline.options = {
checks: {
image: {
url: function() {
return 'http://etc.something.etc/subdir/tiny-image.png?_=' + (Math.floor(Math.random() * 1000000000));
}
},
active: 'image'
}
}
Offline.check();
Heya,
your documentation (http://github.hubspot.com/offline/) show's "Offine" instead of "Offline" (the 'l' is missing).. :)
./cereal
Does not work on Firefox 24 Mac
Can I know how to attach it to a joomla based website?
Hi
can you please help to get offline work with turbolinks https://github.com/rails/turbolinks/. when i use turbolinks to fetch pages there is no offline-ui class in body tag. i know this could be a problem with how turbolinks work, but is there any work around to get it working.
Thanks
From an i18n approach texts should be modifiable in config like other parameters, for using in foreign languages. I didn't find the non minimized version to work on, so I made an issue.
Do you manage to add a WebSockets monitoring in addition to the Ajax monitoring ?
Maybe a proxy in front of the browser websockets API is necessary. Anyway, a «send again the websockets messages» feature would be fantastic.
When sending multiple XRH requests during a period of no connection, only the last one is being sent to the flush function. I believe that the requests
array being set on line 53 (of requests.js) is being overwritten with each pass of the for loop.
To temporarily fix this on my site, I replaced that line with:
makeRequest(request);
and removed the second for loop from the function (lines 55-58 of requests.js)
Hi, (sorry for english) how to use setTimeout do check internet connection after 45sec and, if connection is up, set window.location.reload(true);, else, recheck after 10sec until connection is up again, and so, reload page.
thanks!
hi , i want to know can i use this in interanet that havent any internet connection and only have local connections?
By default, it appears to send requests to someones cloudfront endpoint.
It'd probably be good if that configuration option was documented up front so folks know there users will be making requests to an "uncontrolled" domain. I don't see a mention of that behavior anywhere in the README as it stands.
Thank you! This is great.
I dont want to remake requests which fail while the connection is down. So, I tried to disable the 'requests' option in my application, but i am unable do so.
My code looks like:
<script src="../offline.min.js"></script>
<link rel="stylesheet" href="../themes/offline-theme-chrome.css" />
<script>
Offline.options={
requests : false,
checkOnLoad: true,
interceptRequests: true,
reconnect: {
initialDelay: 3,
delay: 32
}
}
</script>
I have tried to modify the offline.js and gave requests: false in defaultOptions, then i acheived it.
Can you please help me in doing this?
Hi,
I am getting a JavaScript error when ui.js or offline.min.js is rendered only in Internet Explorer browser.
Error message was
Object doesn't support this property or method ui.js, line 85 character 7
it was complaining about el.querySelector('.offline-ui-retry')
Please help me in fixing this.
Hi guys and first of all thanks for this nice script.
Strangely, even tough everything works fine on Chrome, FF, IE10 & IE11, when I try to open my site using IE9 it goes into a reconnecting loop (which starts normally with the disconnected message), downloads the image I've set up fine (IE returns a proper 200 status), but all I get is the attempting to reconnect loop forever. Same goes with the settings I've given and with the default ones.
Unfortunately I'm not a Coffeescript guy so I can't mess with the code, so I'm just asking for ideas here...
I'll try to debug using the compiled JS files (God help me debug on IE). I know that I'll burn in hell or something for even mentioning IE9, but hey... customers still use it, so we gotta play along.
Thanks in advance for any help you can provide.
How can I make the first message, that your connection is lost last longer.
I feel that it disappears and moves to the reconnecting message too quickly. It doesn't give the user enough time to read and seems suspicious.
I use jQuery to make my AJAX requests, and found that offline.js was not working at all in IE9, yet FF works great.
I tracked it down to line 166 in offline.js: in my case xhr.onprogress was "undefined" as opposed to null. When I added the check for undefined, it works in IE.
Also, it looks like jQuery always sets readyState to "1" before sending the XHR, so the check for 0 on line 175 may not always work. I've seen other examples simply testing for != 4.
I found this strange bug, when I insert the offlinejs lib I get the following error from angular:
illegal access
I think one of the global window methods is causing this, but can't figure out which.
In one of my applications I keep getting the following error right after the application loads. It doesn't seem to affect the library's functionality:
HEAD http://web.local/offline-test-request/330485281 404 (Not Found)
I noticed the error corresponds to this line of code:
https://github.com/HubSpot/offline/blob/master/js/offline.js#L32
Is this a bug? Maybe this is old code from when you hosted the tiny image in the cloud?
Here's my code:
Offline.options = {
checks: {
image: {
url: function() {
return 'http://something.etc.etc/tiny-image.png?_=' + (Math.floor(Math.random() * 1000000000));
}
},
active: 'image'
}
}
Is there any way to make the request to check the connection through https?
Thank you.
Hello,
I downloaded the min file from the main offline.js site, however the link on http://github.hubspot.com/offline/docs/welcome/ links to:
https://raw.github.com/HubSpot/offline/v0.4.4/offline.min.js
Which differs from:
https://raw.github.com/HubSpot/offline/master/offline.min.js
This meant it didn't work as expected and as per the offline.js site when I installed the script i.e. not correctly picking up offline/online window events. Reconnect button not showing (Chrome 30)
Cheers
Allow for only the requests handling without any UI indicator.
Expose a config setting to launch a function when the UI would normally change.
Seems your demo and my site both won't produce this in Safari - great in chrome however!
http://yoyo.io/css
Hello, i would like, on connection lost, fire a bootstrap 3 modal preventing user to continue. In modal there will be the connection status info.
Is it possible in some way?
Riccardo
If you want to use an image rather than the default offline-test-request
url the documentation recommends:
Offline.options = {checks: {image: {url: 'my-image.gif'}}};
If you do that, the image URL is ignored and it just keeps trying the offline-test-request
url. You need to add {active: 'image'}
for it to work.
By the way, I use /favicon.ico
as the image.
Hello,
We have just add offline to twittstrap resources list
http://www.twittstrap.com/resources/details/offline
Under : Javascript
Regards
I see this yellow bar with no message. http://i.imgur.com/8F34NqG.png
I use Fedora & Chrome.
it looks like IE9 doesn't have document.body initialized when document.readyState === 'interactive'. as a result, the reference to document.body.appendChild in ui.js#render SOMETIMES has a null reference error:
render = function() {
var button, handler;
el = createFromHTML(TEMPLATE);
document.body.appendChild(el);
we fixed it by making this modification in ui.js:
if (((_ref = document.readyState) === 'interactive' || _ref === 'complete' ) && document.body) {
init();
(we understand we'd need to modify the coffeescript to do this properly, but are unfamiliar with the build process/tools at this point.)
if this fix makes sense, let us know and we can submit a proper pull request. if the fix doesn't make sense, an alternate fix or suggestions would be great.
I could not find a way to modify this at a runtime. There should definitely be an option to check in synchronous mode, for example, check(true) or something. Therefore it would be possible to use Offline to prevent some user actions while offline.
Hi, I like your project. I don't know if you're interested in supporting PhoneGap, but if you are, there are several PhoneGap/Cordova APIs that are available to more reliably determine the state of the network connection:
Detecting PhoneGap is also quite simple:
if(window.device && window.device.cordova) { ... }
Currently in Firefox (version 28 also tried in version 27.01) the offline status doesn't update to show when the browser goes offline. You can see this in your current implementation while running Firefox (http://github.hubspot.com/offline/docs/welcome/), it does not update statuses on the UI when you're offline. However, this behaves correctly in Chrome and IE.
Hi all,
I'm trying to set a custom image URL in the Offline.options. Just to test, I'm using the same cloudfront gif Offline uses, but with https because I host an ssl site.
Offline.options = {checks: {image: {url: 'https://dqakt69vkj09v.cloudfront.net/are-we-online.gif'}}};
The problem seems to be that, with a custom image url, there seems to be no "cachebreaker" query string, while I can see it with the default image url. This makes the browser respond a 304 - not modified and offline.js stops detecting a connection lost.
Please note that the problem is not https. Even with this gif, the cachebreaker is not sent and offline does not work:
Offline.options = {checks: {image: {url: 'http://dqakt69vkj09v.cloudfront.net/are-we-online.gif'}}};
Hi,
I'm trying to include this library into my project which uses requirejs to asynchronously download dependencies.
I've noticed that in the ui.coffee file it makes an assumption that the file will be downloaded before the domcontentloaded
event is fired.
if document.addEventListener?
document.addEventListener 'DOMContentLoaded', init, false
else
# IE8
_onreadystatechange = document.onreadystatechange
document.onreadystatechange = ->
if document.readyState is 'complete'
init()
_onreadystatechange?(arguments...)
This is not always the case if you downloading your assets asynchronously. Was this is a deliberate design issue? Or would you be happy to change the logic so that it first checks if the DOM has already been loaded?
The default URL should be something we know exists, such as an empty HTML file or similar. Error handling is usually much heavier on the web server than serving an existing static file. I'm thinking about exception handling, logging and such, which may cause unnecessary syscalls and complex error routines. Looking for a new filename every time is even worse since it forces an fsync on the server to see if the file exists, circumventing any file caching on the server.
I understand that you try to circumvent client caching with the random filename, but then it's better to include a querystring parameter such as the one used by JQuery: ?_=1382690388689
.
socket
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.