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

moving stuff around

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