Browse Source

Slicer update

Manuel Gall 2 years ago
parent
commit
c4dc522c73
3 changed files with 38 additions and 48 deletions
  1. 12 1
      ui/index.html
  2. 2 46
      ui/js/imageSlicer.js
  3. 24 1
      ui/js/settings.js

+ 12 - 1
ui/index.html

@@ -53,6 +53,7 @@
     <link   rel="stylesheet"      href="css/settings.css" type="text/css"/>
     
     
+    <script type="text/javascript" src="js/PatternForm.js"></script>
     <script type="text/javascript" src="js/config.js"></script>
     <script type="text/javascript" src="js/design.js"></script>
     <script type="text/javascript" src="js/imageSlicer.js"></script>
@@ -606,12 +607,22 @@
         </div>
       </template>
       
-      Json Files:
+      
+      <h1>Edit Json Files</h1>
       
       <div id="JsonFiles">
       
       </div>
       
+      
+      <h1>Create Productcode String</h1>
+      <form id="createProductcodeString"  onsubmit="createProductcodeString()">
+        <div id="FormPattern3">
+        </div>
+        <input class="width100" type="submit" value="Create Productcode">
+      </form><br>
+      Code: <input data-class="input" id="showcreatedProductcodeString" type="text" maxlength="60" size="60" value="Productcode">
+      
     </ui-area>
       
       <!--<ui-resizehandle data-belongs-to-tab="cutter" data-label="drag to resize" ></ui-resizehandle>-->

+ 2 - 46
ui/js/imageSlicer.js

@@ -1,8 +1,7 @@
 
 rectID = 0;
 colors = ["#edd400","#73d216","#cc0000","#f57900","#3465a4","#c17d11","#75507b","#fce94f","#8ae234","#ef2929","#fcaf3e","#729fcf","#eeeeec","#e9b96e","#ad7fa8","#888a85","#c4a000","#4e9a06","#a40000","#ce5c00","#204a87","#babdb6","#8f5902","#5c3566","#2e3436"].map(i => i + "70"); //Tango Colors with opacity
-abk = [];
-fullpattern = [];
+
 
 function addRectangle(){
   addRectangle1("", 0,0,1000,100)
@@ -259,50 +258,7 @@ function addRectangle1(id,x,y,w,h,pattern,idtext,assignmentsstation,assignments)
   });
 }
 
-function createPatternForm(){
-  /* Load pattern config */
-  //Create form for WAS/Stations/Pattern and WAS/Slicer
-
-  var populate = ["FormPattern","FormPattern2","FormPatternAssignment"]
-  
-  var first = true;
-  populate.forEach(function(populate2){
-    $.getJSON( "../server/json/ProductCode.json", function( data ) {
-      fullpattern = data;
-      $.each( data["pattern"], function(i, item){
-        var clone = document.importNode(document.querySelector('#PatternFormInit').content,true);
-        $('[data-class=Name]',clone).text(item["name"]);
-        $('[data-class=Abkürzung]',clone).text(item["abk"]);
-        if(first)
-          abk.push(item["abk"])
-        $('[data-class=Optionen]',clone).attr("name",item["abk"])
-        $.each( item["types"], function(i, item){        
-          $('[data-class=Optionen]',clone).append('<option value="' + item +'">' + item +'</option>');
-        });
-        $('[data-class=Optionen]',clone).attr("id", populate2 + "_Form_" + item["abk"]);
-        
-        $('#' + populate2).append(clone);
-      });
-      //Add "Text" to abk to show it within rects
-      first = false;
-      
-      //on Patternform2 change trigger assignment default reset
-      if(populate2 == "FormPattern2"){
-        abk.forEach(function(localabk){
-          $("#FormPattern2_Form_" + localabk).change(refreshassignments);
-        });
-      }
-    });
-  });
-  abk.length = 0;
-  
-  //get Save locations
-  $.getJSON( "../server/json/SlicerConfig.json", function( data ) {
-    $.each( data["saveLocation"], function(i, item){
-      $("#savelocation").append('<option value="' + item +'">' + item +'</option>');
-    });
-  });
-}
+
 
 function updateSlicerPatternForm(){
   

+ 24 - 1
ui/js/settings.js

@@ -47,7 +47,25 @@ function openjson(filename){
     $('#jsonfileform').attr('onsubmit','submitJson("' + filename + '");');
   });
 }
-  
+
+
+function createProductcodeString(){
+  ret = ""
+  abk.forEach(function(item){
+    if(typeof $("#FormPattern3_Form_" + item).val() !== 'undefined' && typeof $("#FormPattern3_Form_" + item).val() !== 'undefined'){
+
+        //if rectangle is checked but nothing has been selected
+        if($("#FormPattern3_Form_" + item).find(":selected").text() == ""){
+          ret += ".";
+        }
+        else{
+          ret += $("#FormPattern3_Form_" + item).find(":selected").text() + ".";
+        }
+    }
+  });
+  $("#showcreatedProductcodeString").val(ret.slice(0, -1));
+}
+
   
 $(document).ready(function() {
   $(document).on('submit', '#jsonfileform', function() { //prevent page reload on form submit
@@ -55,4 +73,9 @@ $(document).ready(function() {
   });
   $('#jsonfiletxtarea').val("");
   showjsonfiles();
+  
+  
+  $(document).on('submit', '#createProductcodeString', function() { //prevent page reload on form submit
+    return false;
+  });
 });