From what I'm seeing, context.client.isOffline is available in both model and canvas apps.
I don't see anything in the documentation that is a definitive indicator as to whether you're in a model or a canvas app, which is surprising. So you're probably better off choosing something that I wouldn't expect to show up in canvas apps, for example getGlobalContextObject. I'd recommend checking that like this:
var inModelApp = window.hasOwnProperty('getGlobalContextObject');
if (inModelApp){
// do model app specific things
}
@ben-thompson: If you can forgive me getting on my soapbox for a second, please don't ever check if an object is undefined in this way:
if (x === undefined) { ... }
The most correct version to test this would be something like this:
if (typeof x === 'undefined') { ... }
Why you may ask? Quite simply, undefined isn't a keyword in JavaScript, so you can set it to whatever you want. What can that lead to? Try it out for yourself:
var undefined = 'x';
var x = undefined;
if (x === undefined) { alert('Surprise!'); }
If anyone knows of a supported way to detect whether you're in a canvas app or a model app, please let us know. Otherwise, please cast your vote here.
Hope this helps!