-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
169 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,84 @@ | ||
<head> | ||
<script src="snow-6.js" type="text/javascript"></script> | ||
<script src="hexa.js" type="text/javascript"></script> | ||
<!-- dirty trick to test stand alone, | ||
in markdown you have to include both js and html | ||
--> | ||
</head> | ||
|
||
<form> | ||
<input value="tc,rclcrc,clcrcl,ct" spellcheck="false"> | ||
<input id="replacement" value="tc,rclcrc,clcrcl,ct" spellcheck="false"> | ||
<span style="display: inline-block"> | ||
flip: | ||
<button>↔</button> | ||
<button>↕</button> | ||
<button>both</button> | ||
<button onclick="flip_b2d('replacement')" disabled>↔</button> | ||
<button onclick="flip_b2p('replacement')" disabled>↕</button> | ||
<button onclick="flip_b2d('replacement');flip_b2p('replacement')" disabled>both</button> | ||
</span> | ||
</form> | ||
<br> | ||
|
||
<svg id="svg2" width="78.556015" height="90.708672" xmlns="http://www.w3.org/2000/svg"> | ||
<defs | ||
id="defs11"> | ||
<marker style="overflow:visible" id="Arrow1Send-0" refX="0" refY="0" orient="auto"> | ||
<path | ||
transform="matrix(-0.2,0,0,-0.2,-1.2,0)" | ||
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt" | ||
d="M 0,0 5,-5 -12.5,0 5,5 Z" | ||
id="path1212-9" /> | ||
</marker> | ||
</defs> | ||
<path | ||
style="fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 72.009683,18.897637 -9.8195,17.007874" | ||
id="path1096" /> | ||
<path | ||
style="opacity:0.2;fill:#ff0202;stroke-width:7.93701;stroke-linecap:round;stroke-linejoin:round" | ||
d="m 65.463353,15.118109 13.09266,7.559055 V 37.795275 L 65.463353,45.35433 52.370683,37.795275 V 22.677164 Z" | ||
id="path962" /> | ||
<path | ||
style="fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 32.731663,34.015748 9.8195,17.007874" | ||
id="path1622" /> | ||
<path | ||
style="opacity:0.2;fill:#ff0202;stroke-width:7.93701;stroke-linecap:round;stroke-linejoin:round" | ||
d="m 39.277993,30.23622 -13.09266,7.559055 v 15.118111 l 13.09266,7.559052 13.09267,-7.559052 V 37.795275 Z" | ||
id="path1620" /> | ||
<path | ||
style="fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 58.917013,49.133858 9.8195,17.00787" | ||
id="path1646" /> | ||
<path | ||
style="opacity:0.2;fill:#ff0202;stroke-width:7.93701;stroke-linecap:round;stroke-linejoin:round" | ||
d="m 65.463343,45.35433 -13.09266,7.559055 v 15.118113 l 13.09266,7.55905 13.09267,-7.55905 V 52.913385 Z" | ||
id="path1648" /> | ||
<path | ||
style="fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 32.731673,3.779528 9.8195,17.007874" | ||
id="path1652" /> | ||
<path | ||
style="opacity:0.2;fill:#ff0202;stroke-width:7.93701;stroke-linecap:round;stroke-linejoin:round" | ||
d="m 39.278003,0 -13.09266,7.559055 v 15.118111 l 13.09266,7.559055 13.09267,-7.559055 V 7.559055 Z" | ||
id="path1654" /> | ||
<path | ||
style="opacity:0.3;fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="M 19.639,49.133859 9.8195,66.141728" | ||
id="path2031" /> | ||
<path | ||
style="opacity:0.2;fill:#ff0202;stroke-width:7.93701;stroke-linecap:round;stroke-linejoin:round" | ||
d="m 13.09267,45.354331 13.092663,7.559055 V 68.031498 L 13.09267,75.590548 0,68.031498 V 52.913386 Z" | ||
id="path2033" /> | ||
<path | ||
style="opacity:0.3;fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 32.731663,64.251978 9.8195,17.00787" | ||
id="path2331" /> | ||
<path | ||
style="opacity:0.2;fill:#ff0202;stroke-width:7.93701;stroke-linecap:round;stroke-linejoin:round" | ||
d="m 39.277993,60.472448 -13.09266,7.55906 v 15.11811 l 13.09266,7.55905 13.09267,-7.55905 v -15.11811 z" | ||
id="path2333" /> | ||
<path | ||
style="opacity:0.3;fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 6.54634,18.897638 9.8195,17.007874" | ||
id="path2337" /> | ||
<path | ||
style="opacity:0.2;fill:#ff0202;stroke-width:7.93701;stroke-linecap:round;stroke-linejoin:round" | ||
d="M 13.09267,15.11811 1e-5,22.677165 v 15.118111 l 13.09266,7.559055 13.092673,-7.559055 V 22.677165 Z" | ||
id="path2339" /> | ||
</svg> | ||
<svg id="svg2" width="78.556015" height="90.708672" xmlns="http://www.w3.org/2000/svg"> | ||
<defs | ||
id="defs11"> | ||
<marker style="overflow:visible" id="Arrow1Send-0" refX="0" refY="0" orient="auto"> | ||
<path | ||
transform="matrix(-0.2,0,0,-0.2,-1.2,0)" | ||
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt" | ||
d="M 0,0 5,-5 -12.5,0 5,5 Z" | ||
id="path1212-9"/> | ||
</marker> | ||
</defs> | ||
<path | ||
style="fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 72.009683,18.897637 -9.8195,17.007874"/> | ||
<path | ||
style="opacity:0.2;fill:#ff0202" | ||
d="m 65.463353,15.118109 13.09266,7.559055 V 37.795275 L 65.463353,45.35433 52.370683,37.795275 V 22.677164 Z" | ||
onclick="setHref(this.id, 'replacement','toDiagrams')" id="hexaNE"/> | ||
<path | ||
style="fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 32.731663,34.015748 9.8195,17.007874"/> | ||
<path | ||
style="opacity:0.2;fill:#ff0202" | ||
d="m 39.277993,30.23622 -13.09266,7.559055 v 15.118111 l 13.09266,7.559052 13.09267,-7.559052 V 37.795275 Z" | ||
onclick="setHref(this.id, 'replacement', 'toDiagrams')" id="hexaCenter"/> | ||
<path | ||
style="fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 58.917013,49.133858 9.8195,17.00787"/> | ||
<path | ||
style="opacity:0.2;fill:#ff0202" | ||
d="m 65.463343,45.35433 -13.09266,7.559055 v 15.118113 l 13.09266,7.55905 13.09267,-7.55905 V 52.913385 Z" | ||
onclick="setHref(this.id, 'replacement', 'toDiagrams')" id="hexaSE"/> | ||
<path | ||
style="fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 32.731673,3.779528 9.8195,17.007874"/> | ||
<path | ||
style="opacity:0.2;fill:#ff0202" | ||
d="m 39.278003,0 -13.09266,7.559055 v 15.118111 l 13.09266,7.559055 13.09267,-7.559055 V 7.559055 Z" | ||
onclick="setHref(this.id, 'replacement', 'toDiagrams')" id="hexaN"/> | ||
<path | ||
style="opacity:0.3;fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="M 19.639,49.133859 9.8195,66.141728"/> | ||
<path | ||
style="opacity:0.2;fill:#ff0202" | ||
d="m 13.09267,45.354331 13.092663,7.559055 V 68.031498 L 13.09267,75.590548 0,68.031498 V 52.913386 Z" | ||
onclick="setHref(this.id, 'replacement', 'toDiagrams')" id="hexaSW"/> | ||
<path | ||
style="opacity:0.3;fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 32.731663,64.251978 9.8195,17.00787"/> | ||
<path | ||
style="opacity:0.2;fill:#ff0202" | ||
d="m 39.277993,60.472448 -13.09266,7.55906 v 15.11811 l 13.09266,7.55905 13.09267,-7.55905 v -15.11811 z" | ||
onclick="setHref(this.id, 'replacement', 'toDiagrams')" id="hexaS"/> | ||
<path | ||
style="opacity:0.3;fill:#ff0202;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Send-0)" | ||
d="m 6.54634,18.897638 9.8195,17.007874"/> | ||
<path | ||
style="opacity:0.2;fill:#ff0202" | ||
d="M 13.09267,15.11811 1e-5,22.677165 v 15.118111 l 13.09266,7.559055 13.092673,-7.559055 V 22.677165 Z" | ||
onclick="setHref(this.id, 'replacement', 'toDiagrams')" id="hexaNW"/> | ||
</svg> | ||
<button> | ||
<a id="toDiagrams" target="_blank" href="https://d-bl.github.io/GroundForge/stitches?patchWidth=11&patchHeight=10&footside=b,-,b,-&tile=3217,1783,3248,1731,&headside=7,8,-,c&shiftColsSW=0&shiftRowsSW=4&shiftColsSE=4&shiftRowsSE=2&m1=llctt&e1=ctc&d1=rc&c1=tc&b1=lcrclc&a1=rrctt&m2=llctt&e2=ctc&d2=cr&c2=crclcr&b2=ct&e3=lc&d3=ctc&c3=cr&b3=ctc&a3=rrctt&m4=llctt&e4=cl&d4=ctc&c4=ctc&b4=lc"> | ||
to diagrams | ||
</a> | ||
</button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
function flip_b2d(id) { | ||
const n = document.getElementById(id); | ||
n.value = n.value.toLowerCase().replace(/l/g,"R").replace(/r/g,"L").toLowerCase(); | ||
n.focus(); | ||
} | ||
|
||
function flip_b2p(id) { | ||
const n = document.getElementById(id); | ||
n.value = n.value.toLowerCase().split("").reverse().join("") | ||
n.focus() | ||
} | ||
|
||
function setHref(hexaId, stitchesId, hrefId) { | ||
const hrefNode = document.getElementById(hrefId); | ||
const stitchArray = document.getElementById(stitchesId).value.toLowerCase().split(","); | ||
const nrOfStitches = stitchArray.length; | ||
if (nrOfStitches !== 4) { | ||
alert("Sorry, replacement only works for 4 stitches in the text field "+stitchArray) | ||
return | ||
} | ||
const q = getQueryParams(hrefNode.getAttribute("href")); | ||
switch (hexaId) { | ||
// S and Z represent the working orders of the stitches | ||
// | ||
// b1,c1 | ||
// S center | ||
// b2,c2 d2,e2 | ||
// Z SE/NW | ||
// b3,c3 d3,e3 | ||
// S N/S | ||
// b4,c4 d4,e4 | ||
// S NE/SW | ||
// d1,e1 | ||
case "hexaCenter": | ||
q.set("c1", stitchArray[0]); | ||
q.set("b1", stitchArray[1]); | ||
q.set("c2", stitchArray[2]); | ||
q.set("b2", stitchArray[3]); | ||
break; | ||
case "hexaNW": | ||
case "hexaSE": | ||
q.set("d2", stitchArray[0]); | ||
q.set("e2", stitchArray[1]); | ||
q.set("d3", stitchArray[2]); | ||
q.set("e3", stitchArray[3]); | ||
break; | ||
case "hexaN": | ||
case "hexaS": | ||
q.set("c3", stitchArray[0]); | ||
q.set("b3", stitchArray[1]); | ||
q.set("c4", stitchArray[2]); | ||
q.set("b4", stitchArray[3]); | ||
break; | ||
case "hexaNE": | ||
case "hexaSW": | ||
q.set("e4", stitchArray[0]); | ||
q.set("d4", stitchArray[1]); | ||
q.set("e1", stitchArray[2]); | ||
q.set("d1", stitchArray[3]); | ||
break; | ||
} | ||
let newQ = Array | ||
.from(q.entries()) | ||
.map(([key, value]) => `${encodeURIComponent(key)}=${value.replace(/%2C/g, ',').replace(/%2D/g, '-')}`) | ||
.join('&'); | ||
console.log(newQ); | ||
hrefNode.setAttribute('href', "https://d-bl.github.io/GroundForge/stitches?" + newQ); | ||
} | ||
|
||
function getQueryParams(url) { | ||
const queryParams = new Map(); | ||
const queryString = url.split('?')[1]; | ||
if (queryString) { | ||
const pairs = queryString.split('&'); | ||
pairs.forEach(pair => { | ||
const [key, value] = pair.split('='); | ||
queryParams.set(decodeURIComponent(key), decodeURIComponent(value)); | ||
}); | ||
} | ||
return queryParams; | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters