latin: circumfix mark for code 39
[sheet.git] / latinsample.js
index cff51e38b9e295869fca2bde87eb49b0037509df..fa6b0f1ca60af7e6cae33a5dce46eb2b0fb8df5a 100644 (file)
@@ -22,6 +22,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 = '';
@@ -29,13 +32,21 @@ function appendsample() {
                for (var i = 0; i < input.length; i++) {
                        var col = input.charCodeAt(i) - 64;
                        if (col < 1) col = 27; // space
+                       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>';
+                               output += '<span>' + (cols[col] || ' ') + '</span>';
                        }
                        else {
                                output += ' ';
                        }
                }
+               if (cols[29] && !cols[28]) {
+                       // circumfix sign if no repetition
+                       output = cols[29] + output + cols[29];
+               }
                samplecol.innerHTML = output;
        }
 };