rtic/book/en/wavedrom.min.js

3 lines
46 KiB
JavaScript
Raw Normal View History

2023-02-04 00:39:10 +01:00
/*! wavedrom 2.6.8 2020-5-26 PDT */
!function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,(function(r){return o(e[i][1][r]||r)}),p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(require,module,exports){"use strict";module.exports=function(index,output){var div,menu;function closeMenu(e){var left=parseInt(menu.style.left,10),top=parseInt(menu.style.top,10);(e.x<left||e.x>left+menu.offsetWidth||e.y<top||e.y>top+menu.offsetHeight)&&(menu.parentNode.removeChild(menu),document.body.removeEventListener("mousedown",closeMenu,!1))}(div=document.getElementById(output+index)).childNodes[0].addEventListener("contextmenu",(function(e){var list,savePng,saveSvg;(menu=document.createElement("div")).className="wavedromMenu",menu.style.top=e.y+"px",menu.style.left=e.x+"px",list=document.createElement("ul"),(savePng=document.createElement("li")).innerHTML="Save as PNG",list.appendChild(savePng),(saveSvg=document.createElement("li")).innerHTML="Save as SVG",list.appendChild(saveSvg),menu.appendChild(list),document.body.appendChild(menu),savePng.addEventListener("click",(function(){var html,firstDiv,svgdata,img,canvas,pngdata,a;html="",0!==index&&(html+=(firstDiv=document.getElementById(output+0)).innerHTML.substring(166,firstDiv.innerHTML.indexOf('<g id="waves_0">'))),html=[div.innerHTML.slice(0,166),html,div.innerHTML.slice(166)].join(""),svgdata="data:image/svg+xml;base64,"+btoa(html),(img=new Image).src=svgdata,(canvas=document.createElement("canvas")).width=img.width,canvas.height=img.height,canvas.getContext("2d").drawImage(img,0,0),pngdata=canvas.toDataURL("image/png"),(a=document.createElement("a")).href=pngdata,a.download="wavedrom.png",a.click(),menu.parentNode.removeChild(menu),document.body.removeEventListener("mousedown",closeMenu,!1)}),!1),saveSvg.addEventListener("click",(function(){var html,firstDiv,svgdata,a;html="",0!==index&&(html+=(firstDiv=document.getElementById(output+0)).innerHTML.substring(166,firstDiv.innerHTML.indexOf('<g id="waves_0">'))),html=[div.innerHTML.slice(0,166),html,div.innerHTML.slice(166)].join(""),svgdata="data:image/svg+xml;base64,"+btoa(html),(a=document.createElement("a")).href=svgdata,a.download="wavedrom.svg",a.click(),menu.parentNode.removeChild(menu),document.body.removeEventListener("mousedown",closeMenu,!1)}),!1),menu.addEventListener("contextmenu",(function(ee){ee.preventDefault()}),!1),document.body.addEventListener("mousedown",closeMenu,!1),e.preventDefault()}),!1)}},{}],2:[function(require,module,exports){"use strict";module.exports=function(Edge,from,to){var d,style,dx=to.x-from.x,dy=to.y-from.y,lx=(from.x+to.x)/2,ly=(from.y+to.y)/2;switch(Edge.shape){case"-":break;case"~":d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+.3*dx+", "+dy+" "+dx+", "+dy;break;case"-~":d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+dx+", "+dy+" "+dx+", "+dy,Edge.label&&(lx=from.x+.75*(to.x-from.x));break;case"~-":d="M "+from.x+","+from.y+" c 0, 0 "+.3*dx+", "+dy+" "+dx+", "+dy,Edge.label&&(lx=from.x+.25*(to.x-from.x));break;case"-|":d="m "+from.x+","+from.y+" "+dx+",0 0,"+dy,Edge.label&&(lx=to.x);break;case"|-":d="m "+from.x+","+from.y+" 0,"+dy+" "+dx+",0",Edge.label&&(lx=from.x);break;case"-|-":d="m "+from.x+","+from.y+" "+dx/2+",0 0,"+dy+" "+dx/2+",0";break;case"->":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none";break;case"~>":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none",d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+.3*dx+", "+dy+" "+dx+", "+dy;break;case"-~>":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none",d="M "+from.x+","+from.y+" c "+.7*dx+", 0 "+dx+", "+dy+" "+dx+", "+dy,Edge.label&&(lx=from.x+.75*(to.x-from.x));break;case"~->":style="marker-end:url(#arrowhead);stroke:#0041c4;stroke-width:1;fill:none",d="M "+from.x+","+from.y+" c 0, 0 "+.3*dx+", "+dy+" "+dx+", "+dy,