Commit 060f6b04 authored by amandaghassaei's avatar amandaghassaei
Browse files

errors

parent e084fa93
......@@ -278,3 +278,8 @@ svg{
.hexVal{
border-width:4px;
}
#warningMessage{
text-align: center;
margin: 0 18px;
}
......@@ -397,9 +397,8 @@
<li><a href="#" class="demo" data-url="Curved/creaseMesh.txt">Curved Crease 1</a></li>
</ul>
</li>
<li><a class="loadFile" href="#">Import .txt...</a></li>
<li><a class="loadFile" href="#">Import SVG...</a></li>
<li class="divider"></li>
<li><a class="loadFile" href="#">Import... (SVG / FOLD / txt)</a></li>
<!--<li><a id="saveSVG" href="#">Save Pattern as SVG...</a></li>-->
<li><a id="exportSTL" href="#">Save Simulation as STL...</a></li>
</ul>
......@@ -551,5 +550,33 @@
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="modal fade" id="importFoldModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-med">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<p><b>Import FOLD</b><br/><br/>
use angles as targets
</p>
</div>
<div class="modal-footer">
<button id="doImportFold" type="button" class="btn btn-success">Import</button>
<button type="button" class="btn btn default" data-dismiss="modal">Cancel</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="modal fade" id="warningModal" tabindex="-1" role="dialog">
<div class="modal-dialog sm">
<div class="modal-content">
<div class="modal-body">
<p id="warningMessage">
</p>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>
\ No newline at end of file
......@@ -28,6 +28,11 @@ function initControls(globals){
setLink("#navPattern", function(){
if (globals.extension == "fold"){
$("#warningMessage").html("No crease pattern available for FOLD format.");
$("#warningModal").modal("show");
return;
}
globals.navMode = "pattern";
$("#navPattern").parent().addClass("open");
$("#navSimulation").parent().removeClass("open");
......@@ -98,16 +103,25 @@ function initControls(globals){
var url = $(e.target).data("url");
if (url) {
var extension = url.split(".");
var name = extension.split("/");
name = name[name.length-1];
extension = extension[extension.length-1];
if (extension == "txt"){
$.getJSON( "assets/"+url, function( json ) {
parseTXTjson(json);
globals.filename = name;
globals.extension = extension;
});
} else globals.pattern.loadSVG("assets/" + url);
}
});
function warnUnableToLoad(){
$("#warningMessage").html("Unable to load file.");
$("#warningModal").modal("show");
}
$("#fileSelector").change(function(e) {
var files = e.target.files; // FileList object
if (files.length < 1) {
......@@ -124,28 +138,45 @@ function initControls(globals){
if (extension == "txt") {
reader.onload = function () {
return function (e) {
if (!reader.result) return;
if (!reader.result) {
warnUnableToLoad();
return;
}
parseTXTjson(JSON.parse(reader.result));
globals.filename = name;
globals.extension = extension;
}
}(file);
reader.readAsText(file);
} else if (extension == "svg") {
reader.onload = function () {
return function (e) {
globals.pattern.loadSVG(e.target.result);
if (!reader.result) {
warnUnableToLoad();
return;
}
globals.pattern.loadSVG(reader.result);
globals.filename = name;
globals.extension = extension;
}
}(file);
reader.readAsDataURL(file);
} else if (extension == "fold"){
reader.onload = function () {
return function (e) {
if (!reader.result) return;
if (!reader.result) {
warnUnableToLoad();
return;
}
parseFoldJSON(JSON.parse(reader.result));
globals.filename = name;
globals.extension = extension;
}
}(file);
reader.readAsText(file);
} else {
console.warn("unknown extension: " + extension);
$("#warningMessage").html('Unknown file extension: .' + extension);
$("#warningModal").modal("show");
return null;
}
......
......@@ -45,7 +45,10 @@ function initGlobals(){
density: 1,
//import pattern settings
vertTol: 3//vertex merge tolerange
vertTol: 3,//vertex merge tolerance
filename: null,
extension: null
};
......
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