Skip to content

Commit

Permalink
Added check browser method. Fixes #40.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Sep 3, 2013
1 parent f97a182 commit e482b72
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
12 changes: 4 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@

function toggle(dialogId)
{
if( $(dialogId).dialog('isOpen') )
{
$(dialogId).dialog('close');
}
else
{
$(dialogId).dialog('open');
}
if( $(dialogId).dialog('isOpen') ) $(dialogId).dialog('close');
else $(dialogId).dialog('open');
}

// check browser support
dwv.html.checkBrowser();
// main application
var app = new dwv.App();

Expand Down
2 changes: 2 additions & 0 deletions index.m.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@

<script type="text/javascript">

//check browser support
dwv.html.checkBrowser();
// main application
var app = new dwv.App(true);

Expand Down
27 changes: 27 additions & 0 deletions src/html/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,30 @@ dwv.html.toggleDisplay = function(id)
}
};

/**
* Browser checks to see if it can run dwv...
* TODO Maybe use http://modernizr.com/.
*/
dwv.html.checkBrowser = function()
{
var appnorun = "The application cannot be run.";
// Check for the File API support
if( !window.FileReader ) {
var message = "The File APIs are not supported in this browser. ";
alert(message+appnorun);
throw new Error(message);
}
// Check for XMLHttpRequest
if( !window.XMLHttpRequest || !("withCredentials" in new XMLHttpRequest) ) {
var message = "The XMLHttpRequest is not supported in this browser. ";
alert(message+appnorun);
throw new Error(message);
}
// Check typed array
if( !window.Uint8Array || !window.Uint16Array ) {
var message = "The Typed arrays are not supported in this browser. ";
alert(message+appnorun);
throw new Error(message);
}
};

0 comments on commit e482b72

Please sign in to comment.