Minor change
This commit is contained in:
@@ -487,8 +487,11 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
|
||||
this.paste = function(e)
|
||||
{
|
||||
var data = e.clipboardData.getData("text/source");
|
||||
data = JSON.parse(data.trim());
|
||||
dotgrid.tool.import(data);
|
||||
if(is_json(data)){
|
||||
data = JSON.parse(data.trim());
|
||||
dotgrid.tool.import(data);
|
||||
}
|
||||
|
||||
this.draw();
|
||||
}
|
||||
|
||||
@@ -513,6 +516,18 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y)
|
||||
return {x:x,y:y};
|
||||
}
|
||||
|
||||
|
||||
function is_json(text)
|
||||
{
|
||||
try{
|
||||
JSON.parse(text);
|
||||
return true;
|
||||
}
|
||||
catch (error){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function pos_is_equal(a,b){ return a && b && a.x == b.x && a.y == b.y }
|
||||
function clamp(v, min, max) { return v < min ? min : v > max ? max : v; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user