Commit 2bdd5a4e authored by amandaghassaei's avatar amandaghassaei
Browse files

moving stuff around

parent 060f6b04
......@@ -28,9 +28,8 @@ function initControls(globals){
setLink("#navPattern", function(){
if (globals.extension == "fold"){
$("#warningMessage").html("No crease pattern available for FOLD format.");
$("#warningModal").modal("show");
if (globals.noCreasePatternAvailable()){
globals.warn("No crease pattern available for FOLD format.");
return;
}
globals.navMode = "pattern";
......@@ -103,14 +102,14 @@ function initControls(globals){
var url = $(e.target).data("url");
if (url) {
var extension = url.split(".");
var name = extension.split("/");
var name = extension[extension.length-2].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;
parseTXTjson(json);
});
} else globals.pattern.loadSVG("assets/" + url);
......@@ -118,14 +117,12 @@ function initControls(globals){
});
function warnUnableToLoad(){
$("#warningMessage").html("Unable to load file.");
$("#warningModal").modal("show");
globals.warn("Unable to load file.");
}
$("#fileSelector").change(function(e) {
var files = e.target.files; // FileList object
if (files.length < 1) {
console.warn("no files");
return;
}
......@@ -142,9 +139,9 @@ function initControls(globals){
warnUnableToLoad();
return;
}
parseTXTjson(JSON.parse(reader.result));
globals.filename = name;
globals.extension = extension;
parseTXTjson(JSON.parse(reader.result));
}
}(file);
reader.readAsText(file);
......@@ -155,9 +152,9 @@ function initControls(globals){
warnUnableToLoad();
return;
}
globals.pattern.loadSVG(reader.result);
globals.filename = name;
globals.extension = extension;
globals.pattern.loadSVG(reader.result);
}
}(file);
reader.readAsDataURL(file);
......@@ -168,15 +165,14 @@ function initControls(globals){
warnUnableToLoad();
return;
}
parseFoldJSON(JSON.parse(reader.result));
globals.filename = name;
globals.extension = extension;
parseFoldJSON(JSON.parse(reader.result));
}
}(file);
reader.readAsText(file);
} else {
$("#warningMessage").html('Unknown file extension: .' + extension);
$("#warningModal").modal("show");
globals.warn('Unknown file extension: .' + extension);
return null;
}
......
......@@ -52,6 +52,17 @@ function initGlobals(){
};
function warn(msg){
$("#warningMessage").html(msg);
$("#warningModal").modal("show");
}
_globals.warn = warn;
function noCreasePatternAvailable(){
return _globals.extension == "fold";
}
_globals.noCreasePatternAvailable = noCreasePatternAvailable;
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
......
......@@ -222,6 +222,14 @@ function initModel(globals){
// globals.staticSolver.syncNodesAndEdges();
updateEdgeVisibility();
updateMeshVisibility();
if (globals.noCreasePatternAvailable() && globals.navMode == "pattern"){
//switch to simulation mode
$("#navSimulation").parent().addClass("open");
$("#navPattern").parent().removeClass("open");
$("#svgViewer").hide();
globals.navMode = "simulation";
}
}
function getNodes(){
......
......@@ -6,7 +6,7 @@ function saveSTL(){
var geo = globals.model.getGeometry();
if (geo.vertices.length == 0) {
console.warn("no geo");
globals.warn("No geometry to save.");
return;
}
......
Supports Markdown
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