digits: babylonian cuneiform numerals
[sheet.git] / latinsample.js
index b576f955514949eb24c59f3c4d93619824a6fe88..406cac12cdb355f3dd38070c9ccf7172ead633ec 100644 (file)
@@ -3,6 +3,10 @@ function appendsample() {
        for (var row of rows) {
                // append sample column
                var samplecol = row.getElementsByClassName('sample');
+               if (!this.value.length) {
+                       row.removeChild(samplecol[0]);
+                       continue;
+               }
                if (samplecol.length) {
                        samplecol = samplecol[0];
                }
@@ -22,6 +26,9 @@ function appendsample() {
                                cols[++col] = same;
                        }
                }
+               for (var col = 0; col < cols.length; col++) {
+                       cols[col] = cols[col].innerHTML.trimRight();
+               }
 
                // copy letters into sample
                var output = '';
@@ -32,14 +39,24 @@ function appendsample() {
                        else if (cols[28] && i && col == input.charCodeAt(i - 1) - 64) {
                                col = 28; // repetition char
                        }
-
-                       if (col < cols.length) {
-                               output += '<span>' + (cols[col].innerHTML.trimRight() || ' ') + '</span>';
+                       if (row.id == 'suetterlin' && col == 19) {
+                               var final = input.length == i + 1 || input[i + 1] == ' ';
+                               output += cols[col].split('&nbsp;')[final ? 1 : 0];
+                       }
+                       else if (col < cols.length) {
+                               output += '<span>' + (cols[col] || ' ') + '</span>';
                        }
                        else {
-                               output += ' ';
+                               output += '<b> </b>';
+                       }
+                       if (row.parentNode.tagName == 'THEAD') {
+                               output += col < 26 ? ' ' : 'ยท '; // number separator
                        }
                }
+               if (cols[29] && !cols[28]) {
+                       // circumfix sign if no repetition
+                       output = cols[29] + output + (cols[30] || cols[29]);
+               }
                samplecol.innerHTML = output;
        }
 };