latin: css to break tap code parts
[sheet.git] / latin.plp
index 6de3fa5ce9e5eccf12a1686e2af2a4807cf51ec6..78b52cb2ef9da531089d99c0d613aedd3f9e61f8 100644 (file)
--- a/latin.plp
+++ b/latin.plp
@@ -25,15 +25,30 @@ Html({
        #tap-code td,
        #tap-simplified td {
                line-height: 1ex;
+               white-space: normal;
+               word-spacing: 5em; /* force line break between words */
        }
+       #pigpen {
+               stroke-linecap: square;
+       }
+       #nyctographs,
        #old-roman-cursive {
                stroke-linecap: round;
                stroke-linejoin: round;
        }
-       #code-39 {
+       td {
                white-space: nowrap;
        }
 
+       #pigpen .sample > svg {
+               margin-right: 0.1em;
+       }
+       #nyctographs .sample > svg {
+               background: rgba(0,0,0, .1);
+               padding: 0.1em;
+               margin-right: 0.2em;
+       }
+
        svg path:not([fill]) {
                stroke: currentColor;
                fill: none;
@@ -90,3 +105,45 @@ else {
 
 :></div>
 
+<script>
+var inputel = document.createElement('INPUT');
+inputel.oninput = function () {
+       var rows = document.getElementsByClassName('glyphs')[0].rows;
+       for (var row of rows) {
+               cols = [ row.cells[0] ];
+               for (var col = 1; col <= 26; col++) {
+                       cols[col] = cols[ col - 1 ].nextSibling;
+                       for (var span = 1; span < cols[col].colSpan; span++) {
+                               var same = cols[col];
+                               cols[++col] = same;
+                       }
+               }
+               var samplecol = row.getElementsByClassName('sample');
+               if (samplecol.length) {
+                       samplecol = samplecol[0];
+               }
+               else {
+                       samplecol = row.appendChild(document.createElement('TD'));
+                       samplecol.className = 'sample';
+               }
+
+               var output = '';
+               var input = inputel.value.toUpperCase();
+               for (var i = 0; i < input.length; i++) {
+                       var col = input.charCodeAt(i) - 64;
+                       if (col < 1 || col > 26) {
+                               output += ' &nbsp; ';
+                       }
+                       else {
+                               output += cols[col].innerHTML.trimRight();
+                       }
+               }
+               samplecol.innerHTML = output;
+       }
+};
+
+var container = document.createElement('P');
+container.appendChild(inputel);
+document.body.appendChild(container);
+
+</script>