{"size": 2542, "ext": "js", "max_stars_repo_path": "servlet/src/main/webapp/index.js", "max_stars_repo_name": "jhrabows/autopipes2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "servlet/src/main/webapp/index.js", "max_issues_repo_name": "jhrabows/autopipes2", "max_issues_repo_issues_event_min_datetime": "2021-02-03T19:30:45.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T08:17:15.000Z", "max_forks_repo_path": "soapserver/src/main/resources/static/index.js", "max_forks_repo_name": "jhrabows/autopipes", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 29.2183908046, "max_line_length": 94, "alphanum_fraction": 0.6223446105}
var g_currentDwg;

function init(){
  dwr.util.removeAllOptions('drawing');
  g_currentDwg = null;
  Storage.findAllDrawings(displayDrawingNames);
  
    function displayDrawingNames(drawings){
        dwr.util.addOptions("drawing", [ { id: 0, dwgName: '-select-'} ], "id", "dwgName");
        dwr.util.addOptions("drawing", drawings, "id", "dwgName");
    }
}

function deleteDrawing(){
    var id = dwr.util.getValue("drawing");
    if(id > 0){
      Storage.deleteDrawing(id, processDeleteDrawing);
    }
    function processDeleteDrawing(){
      init();
    }
}
function deleteArea(){
    var id = dwr.util.getValue("drawing");
    var aid = dwr.util.getValue("area");
    if(id > 0){
      Storage.deleteArea(id, aid, processDeleteArea);
    }
    function processDeleteArea(){
      var id = dwr.util.getValue("drawing");
      Storage.findDrawingAreas(id, displayAreaNames);
    }
}
function processChangeDrawing(){
    var id = dwr.util.getValue("drawing");
//    alert('Selected: [' + id + ']');
    if(id > 0){
      Storage.findDrawingAreas(id, displayAreaNames);
      Storage.findOneDrawing(id, displayDrawing);
    }else{
        dwr.util.removeAllOptions("area");
        dwr.util.removeAllOptions("layer");
    }
    
    function displayDrawing(drawing){
        g_currentDwg = drawing;       
       // var layers = drawing.optionsRoot.layer;
       // dwr.util.addOptions("layer", layers, "name");
    }
}

function displayAreaNames(areas){
    dwr.util.removeAllOptions("area");
    dwr.util.addOptions("area", areas, "areaId", "areaName");
    processChangeArea();
}

function processChangeArea(){
    var id = dwr.util.getValue("drawing");
    var areaId = dwr.util.getValue("area");
//    alert('Selected Area: [' + id + ':' + areaId + ']');
    Storage.findOneDrawingArea(id, areaId, false, false, displayArea);
    
    function displayArea(area){
        dwr.util.setValue("readiness", area.areaReadiness);
    }
}

function processCutSheet(debug){
    var id = dwr.util.getValue("drawing");
    var areaId = dwr.util.getValue("area");
    var selType = dwr.util.getValue("csType");
    var selTypeSplit = selType.split('_');
    var rtl = 'N';
    var csType = selType;
    
    if(selTypeSplit.length > 1){
    	csType = selTypeSplit[0];
    	rtl = selTypeSplit[1];
    }
      
    var href = 'cutsheet.jsp?type=' + csType + '&rtl=' + rtl
       + '&dwgId=' + id + '&areaId=' + areaId + '&debug=' + debug;
    
    window.open(href, 'mywin', 'width=500, height=500, toolbar=1, scrollbars=1, resizable=1');
}    
