Commit 2b5e55b6 by Don Mitchell

Use try/catch to detect undefined globals for canvas

parent 6bbe82b6
...@@ -3339,7 +3339,9 @@ schematic = (function() { ...@@ -3339,7 +3339,9 @@ schematic = (function() {
} }
// add method to canvas to compute relative coords for event // add method to canvas to compute relative coords for event
if (HTMLCanvasElement) HTMLCanvasElement.prototype.relMouseCoords = function(event){ try {
if (HTMLCanvasElement)
HTMLCanvasElement.prototype.relMouseCoords = function(event){
// run up the DOM tree to figure out coords for top,left of canvas // run up the DOM tree to figure out coords for top,left of canvas
var totalOffsetX = 0; var totalOffsetX = 0;
var totalOffsetY = 0; var totalOffsetY = 0;
...@@ -3357,6 +3359,9 @@ schematic = (function() { ...@@ -3357,6 +3359,9 @@ schematic = (function() {
this.page_x = event.pageX; this.page_x = event.pageX;
this.page_y = event.pageY; this.page_y = event.pageY;
} }
}
catch (err) { // ignore
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
...@@ -4091,6 +4096,8 @@ schematic = (function() { ...@@ -4091,6 +4096,8 @@ schematic = (function() {
// add dashed lines! // add dashed lines!
// from http://davidowens.wordpress.com/2010/09/07/html-5-canvas-and-dashed-lines/ // from http://davidowens.wordpress.com/2010/09/07/html-5-canvas-and-dashed-lines/
try {
if (CanvasRenderingContext2D)
CanvasRenderingContext2D.prototype.dashedLineTo = function(fromX, fromY, toX, toY, pattern) { CanvasRenderingContext2D.prototype.dashedLineTo = function(fromX, fromY, toX, toY, pattern) {
// Our growth rate for our line can be one of the following: // Our growth rate for our line can be one of the following:
// (+,+), (+,-), (-,+), (-,-) // (+,+), (+,-), (-,+), (-,-)
...@@ -4132,7 +4139,9 @@ schematic = (function() { ...@@ -4132,7 +4139,9 @@ schematic = (function() {
dash = !dash; dash = !dash;
} }
}; };
}
catch (err) { //noop
}
// given a range of values, return a new range [vmin',vmax'] where the limits // given a range of values, return a new range [vmin',vmax'] where the limits
// have been chosen "nicely". Taken from matplotlib.ticker.LinearLocator // have been chosen "nicely". Taken from matplotlib.ticker.LinearLocator
function view_limits(vmin,vmax) { function view_limits(vmin,vmax) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment