diff --git a/panther2d.js b/panther2d.js index 18f5aae74599192ee2bf1d07525d8941422ddef4..d8fd3c20b7ea1098e33f1eeec61293822426c6e3 100644 --- a/panther2d.js +++ b/panther2d.js @@ -98,6 +98,8 @@ const pow10 = Math.pow(10, Math.round(Math.log10(dist))-1); $('#measurementLine').attr('x2', x); $('#measurementLine').attr('y2', y); + $('#measurementLineStroke').attr('x2', x); + $('#measurementLineStroke').attr('y2', y); for (let i=1; i<32; i++) { if (i<dist/pow10 && distPixel>50) setTick(x, y, cx, cy, dist, distPixel, i, pow10); else setTick(x, y, x, y, dist, distPixel, i, pow10); } @@ -155,6 +157,10 @@ $('#measurementLine').attr('y1', cy); $('#measurementLine').attr('x2', cx); $('#measurementLine').attr('y2', cy); + $('#measurementLineStroke').attr('x1', cx); + $('#measurementLineStroke').attr('y1', cy); + $('#measurementLineStroke').attr('x2', cx); + $('#measurementLineStroke').attr('y2', cy); $('#measurementSide1').attr('x1', cx); $('#measurementSide1').attr('y1', cy); $('#measurementSide1').attr('x2', cx); @@ -177,13 +183,14 @@ if (!measurementStart) { // appendSvg("circle", {id: 'measurementStart', cx: cx, cy: cy, r:8, style:"display: block", fill:"none", stroke:"red","stroke-width":2}); if ($('#measurementLine').length==0) { - appendSvg("line", {id: 'measurementLine', x1: cx, y1: cy, x2: cx, y2: cy, style:"display: block", fill:"none", stroke:"yellow","stroke-width":2}); + appendSvg("line", {id: 'measurementLineStroke', x1: cx, y1: cy, x2: cx, y2: cy, style:"display: block", fill:"yellow", stroke:"black","stroke-width":4}); + appendSvg("line", {id: 'measurementLine', x1: cx, y1: cy, x2: cx, y2: cy, style:"display: block", fill:"yellow", stroke:"yellow","stroke-width":2}); appendSvg("path", {d: '', fill: "none", stroke: "limegreen", "stroke-width": 3, id:"beam"}); appendSvg("line", {id: 'measurementSide1', x1: cx, y1: cy, x2: cx, y2: cy, style:"display: block", fill:"none", stroke:"pink","stroke-width":2}); appendSvg("line", {id: 'measurementSide2', x1: cx, y1: cy, x2: cx, y2: cy, style:"display: block", fill:"none", stroke:"pink","stroke-width":2}); for (let i=1; i<32; i++) { - appendSvg("line", {id: 'tick'+i, x1: cx, y1: cy, x2: cx, y2: cy, style:"display: block", fill:"none", stroke:"yellow","stroke-width":2}); - appendSvg("text", {id: 'tickLabel'+i, x: cx, y: cy, fill:"white", stroke:"#eeeeee","stroke-width":1, "font-family":"Arial", "font-size":12, "font-weight":"bold", "text-anchor": "start"}); + appendSvg("line", {id: 'tick'+i, x1: cx, y1: cy, x2: cx, y2: cy, style:"display: block", fill:"yellow", stroke:"black","stroke-width":1}); + appendSvg("text", {id: 'tickLabel'+i, x: cx, y: cy, fill:"white", stroke:"black","stroke-width":1, "font-family":"Arial", "font-size":20, "font-weight":"bold", "text-anchor": "start"}); } } else { @@ -195,6 +202,8 @@ // $('#measurementStart').attr('cx', cx); $('#measurementStart').attr('cy', cy); $('#measurementLine').attr('x1', cx); $('#measurementLine').attr('y1', cy); + $('#measurementLineStroke').attr('x1', cx); + $('#measurementLineStroke').attr('y1', cy); } main.addEventListener('mousemove', function(e) { getCursorPosition(main, e); @@ -256,11 +265,13 @@ measurementDisable(); measurementType = true; measurementEnable(); + $('#bm').hide(); } else { measurementDisable(); measurementType = [msg]; measurementEnable(); + $('#bm').show(); } } @@ -320,7 +331,7 @@ } function searchText(e) { console.log('searchText()', e, e.keyCode || e.which, $("#sname").val().toUpperCase().replace('.','_')); - if (e.keyCode == 13) findComponent($("#sname").val().toUpperCase().replace('.','_')); + if (e.keyCode == 13) findComponent($("#sname").val().toUpperCase()); // return -1; } function shrinkName(name) { @@ -342,6 +353,9 @@ sstring.attr('name', 'sname'); sstring.addClass("form-control sname"); function findComponent(name) { + // https://stackoverflow.com/questions/5497318/replace-last-occurrence-of-character-in-string + if (name.indexOf('.')==-1 && name.indexOf('_')>-1) name = name.replace(/_([^_]*)$/, '.' + '$1'); + if (document.location.search.indexOf('debugfind')>-1) {console.log('findComponent('+name+')'); return 'OK';} let servicearea = false; console.log('lattice', lattice); if (lattice.servicearea) for (let i in lattice.servicearea.sections) { @@ -358,17 +372,18 @@ } if (name==null) name = document.getElementById('sname').value; for (let i=0; i<alias.length; i++) if (alias[i][1]==name) name = alias[i][0]; + let id = name.replace('.', '_'); document.getElementById('sname').value = name; console.log(name, typeof $('#'+name)[0], shrinkName(name), shrinkedNames.indexOf(shrinkName(name))); - if (typeof $('#'+name)[0] == 'undefined') { - const sindex = shrinkedNames.indexOf(shrinkName(name)); - if (sindex>-1) name = names[sindex]; else return name+' Not found'; + if (typeof $('#'+id)[0] == 'undefined') { + const sindex = shrinkedNames.indexOf(shrinkName(id)); + if (sindex>-1) id = names[sindex]; else return name+' Not found'; } - console.log(name, window.innerWidth/2, $('#'+name)[0].getCTM().e, $('#'+name)[0].getCTM().f); + console.log(name, window.innerWidth/2, $('#'+id)[0].getCTM().e, $('#'+id)[0].getCTM().f); // panZoomPanther.zoomAtPoint(10, {x: window.innerWidth/2 - $('#'+name)[0].getCTM().e, y: window.innerHeight/2 - $('#'+name)[0].getCTM().f}) panZoomPanther.zoom(10); // leave a delay between zoom and pan - setTimeout(mypan, 1200, name); + setTimeout(mypan, 1200, id); return 'OK'; } function mypan(name) { @@ -463,9 +478,9 @@ } gui.add(params, 'measurement device', measurementDevice).onChange(measurementFacility); if (document.location.search.indexOf('measurement')==-1) measurementToggle(false); - bpmInit(facilities); if (document.location.search.indexOf('servicearea')>-1) initSearch(lattice.servicearea.sections, 'servicearea'); if (typeof blm != 'undefined') blmMenu(lattice, facilities, params); + bpmInit(facilities); if (typeof bpmData != 'undefined') bpmMenu(lattice, facilities, params); params.gotoAdmin = function() {document.location = './admin.php';}; gui.add(params, 'gotoAdmin').name('Admin'); @@ -557,11 +572,12 @@ } function showStatus(i, stat) { if (stat == 0 || stat == 'null' || stat == '' || stat == 'ON' || stat == 'RUNNING' || (!fel1 && $('#'+status[i].name)[0].classList[0]=='fel1') || (!fel2 && $('#'+status[i].name)[0].classList[0]=='fel2')) {$('#'+status[i].name).hide();} - else {$('#'+status[i].name).show(); document.getElementById(status[i].name).style.fill = conf.stateLabelColor[stat];} + else if (stat == 'ON' || stat == 'RUNNING') {$('#'+status[i].name).show();document.getElementById(status[i].name).style.fill = conf.stateLabelColor[stat];$('#'+status[i].name).addClass('noblink');} + else {$('#'+status[i].name).show(); document.getElementById(status[i].name).style.fill = conf.stateLabelColor[stat];$('#'+status[i].name).removeClass('noblink');} // console.log(i, status[i], stat); } function clearStatus() { - $('.ps').hide(); + $('.ps:not(.noblink)').hide(); } function updateStatus() { fetch(conf.stateUrl, {cache: "no-store"}).then((response) => {return response.text();}).then((data) => { @@ -602,10 +618,11 @@ function openTooltip(event) { if (document.location.search.indexOf('debug')==-1) { const type = this.href? this.href.baseVal.replace('#',''): (this.id.indexOf('BLM')>-1 || this.id.indexOf('BERGOZ')>-1? 'blm': '???'); - console.log('openTooltip()',type, this, event, event.clientY); + console.log('openTooltip()',type, this.id, this, event, event.clientY); $('#tooltip').css('left', event.clientX+30); $('#tooltip').css('top', event.clientY+30); - document.getElementById('tooltipFrame').src = conf.tooltipApp+'?s='+type.replace('fast', '')+'¶m='+this.id+(typeof this.dataset.embedded == 'undefined'? '': ','+this.dataset.embedded); + const embedded = (typeof this.dataset.embedded == 'undefined' || this.id[0]=='R')? '': ','+this.dataset.embedded; + document.getElementById('tooltipFrame').src = conf.tooltipApp+'?s='+type.replace('fast', '')+'¶m='+this.id + embedded; console.log('openTooltip(event)', type.toLowerCase(), type.toLowerCase().indexOf('beamline')); document.getElementById('tooltip').style.display = 'block'; if (hideTimeout!==false) clearTimeout(hideTimeout); @@ -661,7 +678,7 @@ appendSvg("text", { id: id+'label', class: labelclass, - x:0, y:0, style:"display: "+display, fill:"white", stroke:"#eeeeee","stroke-width":5, "font-family":"Arial", "font-size":100, "font-weight":"bold", + x:0, y:0, style:"display: "+display, fill:"white", stroke:"#101020","stroke-width":5, "font-family":"Arial", "font-size":100, "font-weight":"900", "text-anchor": (labelReverse? "end": "start"), transform: transformLabel(x, y, beta, labelReverse) }, false, id); @@ -678,7 +695,7 @@ appendSvg("text", { id: id+'label', class: labelclass, - x:0, y:0, style:"display: block", fill:"red", stroke:"pink","stroke-width":5, "font-family":"Arial", "font-size":fontsize, "font-weight":"bold", + x:0, y:0, style:"display: block", fill:"red", stroke:"pink","stroke-width":5, "font-family":"Arial", "font-size":fontsize, "font-weight":"900", "text-anchor": (labelReverse? "end": "start"), transform: transformLabel(x, y, beta, labelReverse) }, false, id);