-
Notifications
You must be signed in to change notification settings - Fork 15
/
functions.js
executable file
·2843 lines (2030 loc) · 111 KB
/
functions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// provide values for trace variables in the debug.js file
if (typeof traceSet === 'undefined') traceSet = new Set([])
// GLOBALS - see also the manifest file under /shared
var index = {} // holds information needed to build index; used by makeIndexObject, makeMarkupForSection
// set accessibility defaults
access = {
fontsize: 15,
contrast: 'low'
}
function addPageFeatures () {
if (traceSet.has('addPageFeatures') || traceSet.has('all')) console.log('Globals(','blockDirectoryName:',window.blockDirectoryName, 'langTag:',window.langTag, 'scriptSummaryTableName:',window.scriptSummaryTableName, 'orthogFilePath:',window.orthogFilePath,')')
//set accessibility defaults
if (localStorage['docsAccess']) access = JSON.parse(localStorage['docsAccess'])
if (access.contrast === 'high') {
document.querySelector('body').classList.add('contrast')
document.getElementById('contrastLow').classList.remove('access_selected')
document.getElementById('contrastDark').classList.remove('access_selected')
document.getElementById('contrastHigh').classList.add('access_selected')
}
else if (access.contrast === 'dark') {
document.querySelector('body').classList.add('dark')
document.getElementById('contrastLow').classList.remove('access_selected')
document.getElementById('contrastHigh').classList.remove('access_selected')
document.getElementById('contrastDark').classList.add('access_selected')
}
document.querySelector('html').style.fontSize = access.fontsize+'px'
document.getElementById('accessFontsize').value = access.fontsize
//console.log(access.fontsize,document.getElementById('accessFontsize').value)
doHeadersFooters(window.orthogFilePath) // links at page top/bottom
makeIndexIntro(document.getElementById('index_intro')) // write page intro
makeTables(langTag) // Create the lists of characters in yellow, etc. boxes
expandCharMarkup() // Expand spans with ch classes to full character markup
addExamples(langTag) // Convert all .eg items to full markup. (egcode.js)
initialiseShowNames(document, blockDirectoryName, '') // Add onclick function to all .ex elements to display in panel
// create translit data in autoTranslitArray
makeAutoTranslitArray (langTag)
initialiseSummary (window.blockDirectoryName, window.langTag, window.scriptSummaryTableName, window.orthogFilePath)
//autoTransliterate(langTag)
checkParameters()
// autogenerate the index
makeIndexObject()
makeMarkupForSection('index_letters')
makeMarkupForSection('index_cchars')
makeMarkupForSection('index_numbers')
makeMarkupForSection('index_punctuation')
makeMarkupForSection('index_symbols')
makeMarkupForSection('index_other')
window.index = {}
makeCharDataObj()
pointToSummaryPages()
marks = new Set()
setMarks()
// empty large global variables
window.fontDB = []
defList = []
fontInfo = {}
copyIntroInfo()
addResources()
// create dialog popup window (displays details after clicking on code point names)
var node = document.querySelector('header')
dialog = document.createElement('dialog')
dialog.open = false
dialog.id = 'dialogBox'
node.appendChild(dialog)
dialog = document.createElement('dialog')
dialog.open = false
dialog.id = 'ipaDialogBox'
node.appendChild(dialog)
document.querySelector("body").addEventListener('keydown', closeDialogEsc)
// set event trigger on all .ipa elements - opens description box on click
var ipaNodes = document.querySelectorAll(".ipa, .listIPA, .allophone")
for (i=0;i<ipaNodes.length;i++) ipaNodes[i].onclick = showIPAPhoneEvt
// set up show composition to show composition in panel
summaryNodes = document.querySelectorAll('.figureSub summary')
for (i=0;i<summaryNodes.length;i++) summaryNodes[i].onclick = function(){ this.parentNode.querySelector('bdi').click() }
// show all sections to be added
summaryNodes = document.querySelectorAll('.sectionAside details')
//for (i=0;i<summaryNodes.length;i++) summaryNodes[i].open = true
for (i=0;i<summaryNodes.length;i++) if (summaryNodes[i].parentNode.parentNode.id !== 'page') summaryNodes[i].open = true
}
function expandCharMarkup () {
if (traceSet.has('expandCharMarkup') || traceSet.has('all')) console.log('expandCharMarkup(',') Convert char markup to .codepoint spans (has to be done before the indexing)')
// convert char markup to .codepoint spans (has to be done before the indexing)
// the .ch and .hx classes should only be used for characters in the
// spreadsheet. For other characters, generate the markup in a picker
// if the svg class is appended, use an svg image to display the char
// if the split class used, the characters will be separated by +
var charMarkup, unicodeNames, unicodeChars, charlist, split, svg, img, hex, ch, block, initial, medial, final, circle, noname, coda
// split puts + signs between the characters in a sequence
// init, medi, fina produce positional forms of cursive text using zwj
// skip puts a circle before a mark, and zwj between it and the following consonant
// circle puts a dotted circle before the item - used for combining marks
// coda puts a dotted circle after the item - used for closed syllables
// noname prevents the production of the Unicode name
// convert .hx markup (one or more hex codes)
charMarkup = document.querySelectorAll('.hex, .hx')
for (i=0;i<charMarkup.length;i++) {
charMarkup[i].classList.contains('split')? split=true: split=false
charMarkup[i].classList.contains('svg')? svg=true: svg=false
charMarkup[i].classList.contains('img')? img=true: img=false
charMarkup[i].classList.contains('init')? initial=true: initial=false
charMarkup[i].classList.contains('medi')? medial=true: medial=false
charMarkup[i].classList.contains('fina')? final=true: final=false
charMarkup[i].classList.contains('skip')? skipDiacritic=true: skipDiacritic=false
charMarkup[i].classList.contains('circle')? circle=true: circle=false
charMarkup[i].classList.contains('coda')? coda='◌': coda=''
charMarkup[i].classList.contains('noname')? noname=true: noname=false
if (charMarkup[i].lang === '') var language = window.langTag
else language = charMarkup[i].lang
charlist = charMarkup[i].textContent.trim().split(' ')
if (charlist[0] === '') continue
unicodeNames = ''
unicodeChars = ''
out = ''
if (final || medial) unicodeChars += '\u200D' // the space is needed for Safari to work
if (circle) unicodeChars = '\u25CC' + unicodeChars
for (c=0;c<charlist.length;c++) {
hex = charlist[c]
dec = parseInt(hex,16)
if (Number.isNaN(dec)) {
console.log('%c' + 'Error! The link text "'+charMarkup[i].textContent+'" is not a number!. (expandCharMarkup)', 'color:' + 'red' + ';font-weight:bold;')
continue
}
//console.log('>>>',charMarkup[i].classList,charMarkup[i].textContent, hex, dec)
ch = String.fromCodePoint(dec)
if (! spreadsheetRows[ch]) {
unicodeNames += `<span style="color:red">${ ch } NOT IN DB! (expandCharMarkup)</span>`
unicodeChars += ch
continue
}
if (hex !== '25CC') {
if (c > 0) unicodeNames += ' + '
unicodeNames += spreadsheetRows[ch][cols['ucsName']].replace(/:/,'')
}
if (split && c > 0) unicodeChars += `</bdi> + <bdi lang="${ language }">`
if (svg) {
block = getScriptGroup(dec, false)
unicodeChars += `<img src="../../c/${ block }/${ hex }.svg" alt="${ ch }" style="height:2rem;">`
}
else if (img) {
block = getScriptGroup(dec, false)
unicodeChars += `<img src="../../c/${ block }/large/${ hex }.png" alt="${ ch }" style="height:2rem;">`
}
else unicodeChars += `&#x${ hex };`
if (skipDiacritic && c == 0) unicodeChars += '‍'
}
if (initial || medial) unicodeChars += '\u200D '
out += `<span class="codepoint" translate="no"><bdi lang="${ language }"`
//if (blockDirection === 'rtl') out += ` dir="rtl"`
if (img || svg) out += ' style="margin:0;" '
out += `>${ unicodeChars }${ coda }</bdi>`
if (noname) {}
else out += `<a href="javascript:void(0)"><span class="uname">${ unicodeNames }</span></a></span>`
if (window.hideBlockName) {
let re = new RegExp(window.hideBlockName, 'g')
charMarkup[i].outerHTML = out.replace(re,'')
}
else charMarkup[i].outerHTML = out
}
// convert .ch markup (one or more characters using Unicode code points)
charMarkup = document.querySelectorAll('.ch')
for (i=0;i<charMarkup.length;i++) {
charMarkup[i].classList.contains('split')? split=true: split=false
charMarkup[i].classList.contains('svg')? svg=true: svg=false
charMarkup[i].classList.contains('img')? img=true: img=false
charMarkup[i].classList.contains('init')? initial=true: initial=false
charMarkup[i].classList.contains('medi')? medial=true: medial=false
charMarkup[i].classList.contains('fina')? final=true: final=false
charMarkup[i].classList.contains('circle')? circle=true: circle=false
charMarkup[i].classList.contains('coda')? coda='◌': coda=''
charMarkup[i].classList.contains('noname')? noname=true: noname=false
if (charMarkup[i].lang === '') var language = window.langTag
else language = charMarkup[i].lang
charlist = [... charMarkup[i].textContent]
unicodeNames = ''
unicodeChars = ''
out = ''
if (final || medial) unicodeChars += ' \u200D'
for (c=0;c<charlist.length;c++) {
dec = charlist[c].codePointAt(0)
hex = dec.toString(16).toUpperCase()
while (hex.length < 4) hex = '0'+hex
if (! spreadsheetRows[charlist[c]]) {
unicodeChars += charlist[c]
unicodeNames += `<span style="color:red"> ${ charlist[c] } NOT IN DB!</span> `
continue
}
if (c > 0) unicodeNames += ' + '
unicodeNames += spreadsheetRows[charlist[c]][cols['ucsName']].replace(/:/,'')
if (split && c > 0) unicodeChars += `</bdi> + <bdi lang="${ language }">`
if (svg) {
block = getScriptGroup(dec, false)
unicodeChars += `<img src="../../c/${ block }/${ hex }.svg" alt="${ charlist[c] }" style="height:2rem;">`
}
else if (img) {
block = getScriptGroup(dec, false)
unicodeChars += `<img src="../../c/${ block }/large/${ hex }.png" alt="${ charlist[c] }" style="height:2rem;">`
}
else unicodeChars += charlist[c]
}
if (initial || medial) unicodeChars += '\u200D '
if (circle) unicodeChars = '\u25CC' + unicodeChars
out += `<span class="codepoint" translate="no"><bdi lang="${ language }"`
if (blockDirection === 'rtl') out += ` dir="rtl"`
if (img || svg) out += ' style="margin:0;" '
out += `>${ unicodeChars }${ coda }</bdi>`
if (noname) {}
else out += `<a href="javascript:void(0)"><span class="uname">${ unicodeNames }</span></a></span>`
if (window.hideBlockName) {
let re = new RegExp(window.hideBlockName, 'g')
charMarkup[i].outerHTML = out.replace(re,'')
}
else charMarkup[i].outerHTML = out
}
}
function closeDialogEsc (e) {
// closes the dialog box and panel when escape is pressed
if (e.code === 'Escape') {
document.getElementById('dialogBox').open = false
document.getElementById('ipaDialogBox').open = false
document.getElementById('panel').style.display = 'none'
document.getElementById('tocPanel').style.display = 'none'
}
}
function initialiseSummary (blockDirectory, lang, tableName, orthogNotesFile) {
if (traceSet.has('initialiseSummary') || traceSet.has('all')) console.log('initialiseSummary(',blockDirectory, lang, tableName, orthogNotesFile,')')
if (document.getElementById('features')) document.getElementById('features').innerHTML = makeSidePanel(tableName,"")
createtoc(3)
removeEditorNotes()
addDefinitions()
//if (typeof(contentPrompts) !== 'undefined') setContentPrompts()
setContentPrompts()
setFindIPA() // Make ipa characters in sounds charts indicate locations they are used
setupBlockLinks() // Set target attribute for links that point to characters in the block page
setTranslitToggle() // Add checkboxes and links to the fixed position selector
setCharOnclicks() // All links with target=c should open descriptions in the panel
if (typeof reflist !== 'undefined') createReferences(lang)
var body = document.querySelector('body')
var tocPanel = document.createElement('div')
tocPanel.id = 'tocPanel'
tocPanel.style.display = 'none'
body.appendChild(tocPanel)
createtocPanel(4)
}
function initialiseIndex () {
// called from index.html pages to set up page after load
// add fragids for legacy URLs to all links to orthography descriptions
olinks = document.querySelectorAll('#olinks a')
for (i=0;i<olinks.length;i++) olinks[i].href += window.location.hash
}
function setMarks () {
// sets the global variable marks as a set containing all combining marks in the spreadsheet
for (var char in spreadsheetRows) {
if (spreadsheetRows[char][1] === 'key') continue
if (typeof spreadsheetRows[char][cols['class']] === 'undefined') console.log('%c' + 'Error! General category not found in setMarks() for '+spreadsheetRows[char], 'color:' + 'red' + ';font-weight:bold;')
if (spreadsheetRows[char][cols['class']].startsWith('M')) window.marks.add(char)
}
return
}
function setCharOnclicks () {
// all links with target=c should open descriptions in the panel
if (traceSet.has('setCharOnclicks') || traceSet.has('all')) console.log('setCharOnclicks(',') All links with target=c should open descriptions in the panel')
var links = document.querySelectorAll('.codepoint a, .codepoint code')
for (i=0;i<links.length;i++) {
links[i].onclick = showCharDetailsInPanel
links[i].href = 'javascript:void(0)'
links[i].target = ''
}
}
function setupBlockLinks () {
// set target attribute for links that point to characters in the block page
if (traceSet.has('setupBlockLinks') || traceSet.has('all')) console.log('setupBlockLinks(',') Set target attribute for links that point to characters in the block page')
var links = document.querySelectorAll('.codepoint a, .codepoint code')
for (var i=0;i<links.length;i++) if (links[i].target != null) links[i].target = 'c'
}
function setFindIPA () { // test extension to map stuff
// makes ipa characters in sounds charts indicate locations they are used
// and also sets up codepoint elements
if (traceSet.has('setFindIPA') || traceSet.has('all')) console.log('setFindIPA(',') Make ipa characters in sounds charts indicate locations they are used')
var listItems = document.querySelectorAll('.codepoint span, .codepoint bdi')
for (var i=0;i<listItems.length;i++) {
if (listItems[i].parentNode.classList.contains('codepoint')) listItems[i].onclick = makeFootnoteIndex
}
//var listItems = document.querySelectorAll('.ipaTable .ipa, .ipaTable .allophone')
//for (i=0;i<listItems.length;i++) listItems[i].onclick = findIPA
var listItems = document.querySelectorAll('.ipaTable .ipa, .ipaTable .allophone, .diphthongTable .ipa, .diphthongTable .allophone')
for (i=0;i<listItems.length;i++) listItems[i].click = findIPA
var listItems = document.querySelectorAll('.ipaSVG .ipa, .ipaSVG .allophone')
for (i=0;i<listItems.length;i++) listItems[i].click = findIPA
}
function shareCodeLinks (charList, script, charApp) {
// provides some of the repetitive code for listAllIndexCharacters
charList = charList.replace(/%/g,'%25')
out = `<td class="indexShareLinks" style="position:relative;"
onmouseover="this.lastChild.style.display='block'"
onmouseout="this.lastChild.style.display='none'"><img src="../common29/icons/transfer.svg" alt="Send characters." title="Send characters." class="ulink" style="height: 1.2rem;">
<div class="popup" style="position: absolute; right: 0px; display: none;">
<div><a href="../../app-analysestring/index.html?chars=`+charList+`" target="_blank">Analyse string</a></div>
<div><a href="../../scripts/apps/listcategories/index.html?chars=`+charList+`" target="_blank">General Category</a></div>
<div><a href="../../uniview/index.html?charlist=`+charList+`" target="_blank">Show characters in UniView</a></div>
<div><a href="../../app-listcharacters/index.html?chars=`+charList+`" target="_blank">List characters by block</a></div>
<div><a href="../../scripts/fontlist/index.html?script=`+script+`&text=`+charList+`" target="_blank">Send to Font lister</a></div>
<div><a target="_blank" href="../../pickers/`+charApp+`/index.html?showFonts=true&text=`+charList+`">Show in character app</a></div></td>`
return out
}
function listAllIndexCharacters (scriptISO, pickerName) {
// creates the showStats table
var out = '<table>'
var list
// find all the characters in the index sorted by common, rare, and not used
allPageChars = [...allchars]
// get a list of all (unique) characters in the index, ignore if not a single codepoint
allIndexChars = []
var indexNodes = document.getElementById('index').querySelectorAll('.listItem')
for (i=0;i<indexNodes.length;i++) {
if ([...indexNodes[i].textContent].length === 1) allIndexChars.push(indexNodes[i].textContent)
}
var uniqueSet = new Set(allIndexChars)
allIndexChars = [...uniqueSet].sort()
if (indexNodes.length !== [...uniqueSet].length) console.log('NOTE: Index contains ',indexNodes.length,' items, but only ',[...uniqueSet].length,' unique characters.')
// get a list of all Index characters used by the orthography & all ascii characters
mainIndexArray = []
asciiIndexArray = []
unusedIndexArray = []
tbcIndexArray = []
for (i=0;i<indexNodes.length;i++) {
// gather not used, obsolete, archaic, & deprecated
if (indexNodes[i].parentNode.classList.contains('index_notused') || indexNodes[i].parentNode.classList.contains('index_unused') || indexNodes[i].parentNode.classList.contains('index_obsolete') || indexNodes[i].parentNode.classList.contains('index_archaic') || indexNodes[i].parentNode.classList.contains('index_deprecated'))
unusedIndexArray.push(indexNodes[i].textContent)
// gather to be investigated
else if (indexNodes[i].parentNode.classList.contains('index_tbc'))
tbcIndexArray.push(indexNodes[i].textContent)
else if ([...indexNodes[i].textContent].length === 1) {
if (indexNodes[i].textContent.codePointAt(0) < 129) {
asciiIndexArray.push(indexNodes[i].textContent)
mainIndexArray.push(indexNodes[i].textContent)
}
else mainIndexArray.push(indexNodes[i].textContent)
}
}
var uniqueSet = new Set(mainIndexArray)
mainIndexArray = [...uniqueSet].sort()
var uniqueSet = new Set(asciiIndexArray)
asciiIndexArray = [...uniqueSet].sort()
var uniqueSet = new Set(unusedIndexArray)
unusedIndexArray = [...uniqueSet].sort()
var uniqueSet = new Set(tbcIndexArray)
tbcIndexArray = [...uniqueSet].sort()
// page/index diff
pageYesIndexNo = ''
for (var t=0;t<[...allPageChars].length; t++) {
if (! allIndexChars.includes(allPageChars[t])) pageYesIndexNo += allPageChars[t]
}
pageNoIndexYes = ''
for (var t=0;t<allIndexChars.length; t++) {
if (! allPageChars.includes(allIndexChars[t])) pageNoIndexYes += allIndexChars[t]
}
var charlist = listCharsInSpreadsheet('all')
allSpreadsheetChars = [...charlist].sort()
var charlistused = listCharsInSpreadsheet('allused')
usedSpreadsheetChars = [...charlistused].sort()
var charlistunused = listCharsInSpreadsheet('unused')
unusedSpreadsheetChars = [...charlistunused].sort()
var charlisttbc = listCharsInSpreadsheet('possibles')
tbcSpreadsheetChars = [...charlisttbc].sort()
// get block file entries
var blockChars = []
for (ch in charDetails) blockChars.push(ch)
console.log('block chars', blockChars)
/* SPREADSHEET */
// get information about the spreadsheet
out += '<tr><th></th><th colspan="2" style="text-align:start">Spreadsheet</th></tr>'
out += `<tr><th>All</th><td id="allSpreadsheetList" style="word-break:break-all;">${ allSpreadsheetChars.join('') }</td><td id="allSpreadsheetListTotal">${ allSpreadsheetChars.length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('allSpreadsheetList').textContent)"></td>${ shareCodeLinks(allSpreadsheetChars.join(''),scriptISO,pickerName) }</tr>`
out += `<tr><th>Used</th><td id="usedSpreadsheetList" style="word-break:break-all;">${ usedSpreadsheetChars.join('') }</td><td id="usedSpreadsheetListTotal">${ usedSpreadsheetChars.length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('usedSpreadsheetList').textContent)"></td>${ shareCodeLinks(usedSpreadsheetChars.join(''),scriptISO,pickerName) }</tr>`
out += `<tr><th>Unused</th><td id="ssCharListUsed" style="word-break:break-all;">${ unusedSpreadsheetChars.join('') }</td><td id="ssCharListUsedTotal">${ unusedSpreadsheetChars.length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('ssCharListUsed').textContent)"></td>${ shareCodeLinks(unusedSpreadsheetChars.join(''),scriptISO,pickerName) }</tr>`
out += `<tr><th>Investigate</th><td id="ssCharListUsed" style="word-break:break-all;">${ tbcSpreadsheetChars.join('') }</td><td id="ssCharListUsedTotal">${ tbcSpreadsheetChars.length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('ssCharListUsed').textContent)"></td>${ shareCodeLinks(tbcSpreadsheetChars.join(''),scriptISO,pickerName) }</tr>`
out += '<tr><th colspan="3" style="font-weight:bold; text-align:start;"> </td></tr>'
/* ACTION TO TAKE */
out += '<tr><th></th><th colspan="2" style="text-align:start">Actions to take for new characters</th></tr>'
// what's in the spreadsheet but not in the index
result = ''
for (var t=0;t<usedSpreadsheetChars.length; t++) {
if (! mainIndexArray.includes(usedSpreadsheetChars[t])) result += usedSpreadsheetChars[t]
}
out += `<tr><th>Add to index</th><td id="spreadsheetExtras" style="word-break:break-all;">${ result }</td><td id="spreadsheetExtrasTotal">${ [...result.replace(/ /g,'')].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('spreadsheetExtras').textContent)"></td>${ shareCodeLinks(result,scriptISO,pickerName) }</tr>`
// what's in the spreadsheet but not in the xx-details file
result = ''
for (var t=0;t<usedSpreadsheetChars.length; t++) {
if (! blockChars.includes(usedSpreadsheetChars[t])) result += usedSpreadsheetChars[t]
}
out += `<tr><th>Add to xx‑details</th><td id="detailsNeeds" style="word-break:break-all;">${ result }</td><td id="spreadsheetExtrasTotal">${ [...result.replace(/ /g,'')].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('spreadsheetExtras').textContent)"></td>${ shareCodeLinks(result,scriptISO,pickerName) }</tr>`
out += `<tr><th></th><td colspan="2" style="text-align:start"><a target="_blank" href="../_tools/generate_details_page_stubs.html?q=${ result }">Details creator</a></td></tr>`
// find out what's in the unused spreadsheet but not in the unused index
/*
result = ''
for (var t=0;t<unusedSpreadsheetChars.length; t++) {
if (! unusedIndexArray.includes(unusedSpreadsheetChars[t])) result += unusedSpreadsheetChars[t]
}
out += `<tr><th>Unused ssheet extras</th><td id="spreadsheetExtras" style="word-break:break-all;">${ result }</td><td id="spreadsheetExtrasTotal">${ [...result.replace(/ /g,'')].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('spreadsheetExtras').textContent)"></td>${ shareCodeLinks(result,scriptISO,pickerName) }</tr>`
// find out what's in the unused index but not in the unused spreadsheet
result = ''
for (var t=0;t<unusedIndexArray.length; t++) {
if (! unusedSpreadsheetChars.includes(unusedIndexArray[t])) result += unusedIndexArray[t]
}
out += `<tr><th>Unused index extras</th><td id="indexSurplus" style="word-break:break-all;">${ result }</td><td id="indexSurplusTotal">${ [...result.replace(/ /g,'')].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('indexSurplus').textContent)"></td>${ shareCodeLinks(result,scriptISO,pickerName) }</tr>`
*/
out += '<tr><th colspan="3" style="font-weight:bold; text-align:start;"> </td></tr>'
out += `<tr><th>Add new characters to picker</th><td style="text-align:start"><a target="_blank" href="../../pickers/${ pickerDir }/index.html">Picker</a></td></tr>`
out += '<tr><th colspan="3" style="font-weight:bold; text-align:start;"> </td></tr>'
out += '<tr><th></th><th colspan="2" style="text-align:start"> </th></tr>'
/* CHARACTER USE */
var langdata = 'Update the following in xx-langdata.js: '
if (typeof langs[charUsageBCP] === 'undefined') alert("Can't create entry for character use because there's no Character Usage entry yet.")
// create entry for character use
usedNonASCII = ''
out += `<tr><th>Update Character usage</th><td id="cUsage" style="word-break:break-all;">`
result = listCharsInSpreadsheet('letters').join('')
out += `letter:"${ result }", `
if (langs[charUsageBCP].letter && result !== langs[charUsageBCP].letter) langdata += 'letter '
usedNonASCII += result
result = listCharsInSpreadsheet('auxletters').join('')
if (result !== '') out += `letteraux:"${ result }", `
if (langs[charUsageBCP].letteraux && result !== langs[charUsageBCP].letteraux) langdata += 'letteraux '
usedNonASCII += result
result = listCharsInSpreadsheet('marks').join('')
out += `mark:"${ result }", `
if (langs[charUsageBCP].mark && result !== langs[charUsageBCP].mark) langdata += 'mark '
usedNonASCII += result
result = listCharsInSpreadsheet('auxmarks').join('')
if (result !== '') out += `markaux:"${ result }", `
if (langs[charUsageBCP].markaux && result !== langs[charUsageBCP].markaux) langdata += 'markaux '
usedNonASCII += result
result = listCharsInSpreadsheet('numbers').join('')
out += `number:"${ result }", `
if (langs[charUsageBCP].numbers && result !== langs[charUsageBCP].numbers) langdata += 'numbers '
usedNonASCII += result
result = listCharsInSpreadsheet('auxnumbers').join('')
if (result !== '') out += `numberaux:"${ result }", `
if (langs[charUsageBCP].numbersaux && result !== langs[charUsageBCP].numbersaux) langdata += 'numbersaux '
usedNonASCII += result
result = listCharsInSpreadsheet('punctuation').join('')
out += `punctuation:"${ result }", `
if (langs[charUsageBCP].punctuation && result !== langs[charUsageBCP].punctuation) langdata += 'punctuation '
usedNonASCII += result
result = listCharsInSpreadsheet('auxpunctuation').join('')
if (result !== '') out += `punctuationaux:"${ result }", `
if (langs[charUsageBCP].punctuationaux && result !== langs[charUsageBCP].punctuationaux) langdata += 'punctuationaux '
usedNonASCII += result
result = listCharsInSpreadsheet('symbols').join('')
out += `symbol:"${ result }", `
if (langs[charUsageBCP].symbol && result !== langs[charUsageBCP].symbol) langdata += 'symbol '
usedNonASCII += result
result = listCharsInSpreadsheet('auxsymbols').join('')
if (result !== '') out += `symbolaux:"${ result }", `
if (langs[charUsageBCP].symbolaux && result !== langs[charUsageBCP].symbolaux) langdata += 'symbolaux '
usedNonASCII += result
result = listCharsInSpreadsheet('other').join('')
out += `other:"${ result }", `
//if (langs[charUsageBCP].other && result !== langs[charUsageBCP].other) langdata += 'other '
result = listCharsInSpreadsheet('auxother').join('')
if (result !== '') out += `otheraux:"${ result }", `
//if (langs[charUsageBCP].auxother && result !== langs[charUsageBCP].auxother) langdata += 'auxother '
out += `</td>
<td id="ssCharListTotal">${ result.length }</td>
<td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('cUsage').textContent)"></td>${ shareCodeLinks(usedNonASCII,scriptISO,pickerName) }</tr>`
if (langdata !== 'Update the following in xx-langdata.js: ') out += `<tr><th></th><th colspan="2" style="text-align:start; color:red;">${ langdata }</th></tr>`
else out += `<tr><th></th><th colspan="2" style="text-align:start">${ langTag }-langdata.js matches!</th></tr>`
// out += `<tr><th></th><th colspan="2" style="text-align:start">Also update xx-langdata.js</th></tr>`
out += '<tr><th colspan="3" style="font-weight:bold; text-align:start;"> </td></tr>'
// create entry for character use
/*out += '<tr><th colspan="3">Possible additions from the spreadsheet</th></tr>'
result = listCharsInSpreadsheet('possibles').join('')
out += `<tr><th>TBC</th><td id="toInvestigate" style="word-break:break-all;">${ result }</td><td id="toInvestigateTotal">${ result.length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('toInvestigate').textContent)"></td>${ shareCodeLinks(result,scriptISO,pickerName) }</tr>`*/
out += `</table>`
out += `<details><summary>More details</summary>`
out += `<table style="margin-inline-start:7.5%; margin-inline-end:32%;">`
// BLOCK PAGE
out += '<tr><th></th><th colspan="2" style="text-align:start"> </th></tr>'
out += '<tr><th></th><th colspan="2" style="text-align:start">Block details</th></tr>'
// show unique characters in the xx-details.html file
out += `<tr><th>All</th><td id="allPageList" style="word-break:break-all;">${ blockChars.join('') }</td><td id="allPageListTotal">${ blockChars.length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1rem;" onclick="navigator.clipboard.writeText(document.getElementById('allPageList').textContent)"></td>${ shareCodeLinks(blockChars.join(''),scriptISO,pickerName) }</tr>`
out += '<tr><th colspan="3" style="font-weight:bold; text-align:start;"> </td></tr>'
// THIS PAGE
// find out what's in the index but not in the spreadsheet
result = ''
for (var t=0;t<mainIndexArray.length; t++) {
if (! usedSpreadsheetChars.includes(mainIndexArray[t])) result += mainIndexArray[t]
}
out += `<tr><th>Used index extras</th><td id="indexSurplus" style="word-break:break-all;">${ result }</td><td id="indexSurplusTotal">${ [...result.replace(/ /g,'')].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('indexSurplus').textContent)"></td>${ shareCodeLinks(result,scriptISO,pickerName) }</tr>`
out += '<tr><th></th><th colspan="2" style="text-align:start"> </th></tr>'
out += '<tr><th></th><th colspan="2" style="text-align:start">This page</th></tr>'
// show unique characters in .codepoint or .listItem throughout the page
// the list allchars is assembled as a string elsewhere - convert to an array for supp chars
out += `<tr><th>All</th><td id="allPageList" style="word-break:break-all;">${ allPageChars.join('') }</td><td id="allPageListTotal">${ allPageChars.length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1rem;" onclick="navigator.clipboard.writeText(document.getElementById('allPageList').textContent)"></td>${ shareCodeLinks(allPageChars.join(''),scriptISO,pickerName) }</tr>`
out += '<tr><th colspan="3" style="font-weight:bold; text-align:start;"> </td></tr>'
// INDEX
out += '<tr><th></th><th colspan="2" style="text-align:start">Index</th></tr>'
// show all index characters
out += `<tr><th>All</th><td id="allIndexList" style="word-break:break-all;">${ allIndexChars.join('') }</td><td id="allIndexListTotal">${ allIndexChars.length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1rem;" onclick="navigator.clipboard.writeText(document.getElementById('allIndexList').textContent)"></td>${ shareCodeLinks(allIndexChars.join(''),scriptISO,pickerName) }</tr>`
// all index items
out += `<tr><th>Used</th><td id="usedIndexList" style="word-break:break-all;">${ mainIndexArray.join('') }</td><td id="usedIndexListTotal">${ [...mainIndexArray].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1rem;" onclick="navigator.clipboard.writeText(document.getElementById('usedIndexList').textContent)"></td>${ shareCodeLinks(mainIndexArray.join(''),scriptISO,pickerName) }</tr>`
// unused items in index
out += `<tr><th>Unused</th><td id="asciiIndexList" style="word-break:break-all;">${ unusedIndexArray.join('') }</td><td id="asciiIndexListTotal">${ [...unusedIndexArray].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1rem;" onclick="navigator.clipboard.writeText(document.getElementById('asciiIndexList').textContent)"></td>${ shareCodeLinks(unusedIndexArray.join(''),scriptISO,pickerName) }</tr>`
// to be investigated items in index
out += `<tr><th>TBC</th><td id="asciiIndexList" style="word-break:break-all;">${ tbcIndexArray.join('') }</td><td id="tbcIndexListTotal">${ [...tbcIndexArray].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1rem;" onclick="navigator.clipboard.writeText(document.getElementById('asciiIndexList').textContent)"></td>${ shareCodeLinks(tbcIndexArray.join(''),scriptISO,pickerName) }</tr>`
// what's in the page but not in the index
out += '<tr><th colspan="3" style="font-weight:bold; text-align:start;"> </td></tr>'
out += '<tr><th></th><th colspan="2" style="text-align:start">Page & Index differences</th></tr>'
out += `<tr><th>Page extras</th><td id="pageExtras" style="word-break:break-all;">${ pageYesIndexNo }</td><td id="pageExtrasTotal">${ [...pageYesIndexNo.replace(/ /g,'')].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('pageExtras').textContent)"></td>${ shareCodeLinks(pageYesIndexNo,scriptISO,pickerName) }</tr>`
out += `<tr><th>Index extras</th><td id="indexExtras" style="word-break:break-all;">${ pageNoIndexYes }</td><td id="indexExtrasTotal">${ [...pageNoIndexYes.replace(/ /g,'')].length }</td><td class="indexShareLinks"><img src="../common29/icons/copytiny.svg" alt="Copy" style="height:1.2rem;" onclick="navigator.clipboard.writeText(document.getElementById('indexExtras').textContent)"></td>${ shareCodeLinks(pageNoIndexYes,scriptISO,pickerName) }</tr>`
out += '<tr><th colspan="3" style="font-weight:bold; text-align:start;"> </td></tr>'
out += `</table></details>`
out += `</tr>`
document.getElementById('charCountList').innerHTML = out
}
function listCharsInSpreadsheet (howmuch) {
// provide a list of characters in the spreadsheet, sorted by category
var all = []
var allused = []
var unused = []
var letters = []
var selection = []
var letters = []
var marks = []
var numbers = []
var punctuation = []
var symbols = []
var other = []
var possibles = []
// get a starting point of all unique characters (but exclude ASCII)
for (row in spreadsheetRows) {
if ([...row].length === 1) {
chars = [...row]
for (j=0;j<chars.length;j++) all.push(chars[j])
var uniqueSet = new Set(all)
all = [...uniqueSet].sort()
}
}
if (howmuch === 'all') return all
// get a list that excludes unused items
for (k=0;k<all.length;k++) {
if (spreadsheetRows[all[k]][cols['status']][0] !== 'u'
&& spreadsheetRows[all[k]][cols['status']][0] !== '?'
&& spreadsheetRows[all[k]][cols['status']][0] !== 'd'
&& spreadsheetRows[all[k]][cols['status']][0] !== 'a'
&& spreadsheetRows[all[k]][cols['status']][0] !== 'o'
) allused.push(all[k])
}
if (howmuch === 'allused') return allused
// get a list of unused items
for (k=0;k<all.length;k++) {
if (spreadsheetRows[all[k]][cols['status']][0] === 'u'
//|| spreadsheetRows[all[k]][cols['status']][0] === '?'
|| spreadsheetRows[all[k]][cols['status']][0] === 'd'
|| spreadsheetRows[all[k]][cols['status']][0] === 'a'
|| spreadsheetRows[all[k]][cols['status']][0] === 'o'
) unused.push(all[k])
}
if (howmuch === 'unused') return unused
// for other types, extract a list from allused
if (howmuch === 'letters') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'L' && spreadsheetRows[allused[k]][cols['status']][0] !== 'r' && spreadsheetRows[allused[k]][cols['status']][0] !== 'x') selection.push(allused[k])
}
}
if (howmuch === 'auxletters') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'L' && (spreadsheetRows[allused[k]][cols['status']][0] === 'r' || spreadsheetRows[allused[k]][cols['status']][0] === 'x')) selection.push(allused[k])
}
}
if (howmuch === 'marks') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'M' && spreadsheetRows[allused[k]][cols['status']][0] !== 'r' && spreadsheetRows[allused[k]][cols['status']][0] !== 'x') selection.push(allused[k])
}
}
if (howmuch === 'auxmarks') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'M' && (spreadsheetRows[allused[k]][cols['status']][0] === 'r' || spreadsheetRows[allused[k]][cols['status']][0] === 'x')) selection.push(allused[k])
}
}
if (howmuch === 'numbers') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'N' && spreadsheetRows[allused[k]][cols['status']][0] !== 'r' && spreadsheetRows[allused[k]][cols['status']][0] !== 'x') selection.push(allused[k])
}
}
if (howmuch === 'auxnumbers') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'N' && (spreadsheetRows[allused[k]][cols['status']][0] === 'r' || spreadsheetRows[allused[k]][cols['status']][0] === 'x')) selection.push(allused[k])
}
}
if (howmuch === 'punctuation') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'P' && spreadsheetRows[allused[k]][cols['status']][0] !== 'r' && spreadsheetRows[allused[k]][cols['status']][0] !== 'x') selection.push(allused[k])
}
}
if (howmuch === 'auxpunctuation') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'P' && (spreadsheetRows[allused[k]][cols['status']][0] === 'r' || spreadsheetRows[allused[k]][cols['status']][0] === 'x')) selection.push(allused[k])
}
}
if (howmuch === 'symbols') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'S' && spreadsheetRows[allused[k]][cols['status']][0] !== 'r' && spreadsheetRows[allused[k]][cols['status']][0] !== 'x') selection.push(allused[k])
}
}
if (howmuch === 'auxsymbols') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'S' && (spreadsheetRows[allused[k]][cols['status']][0] === 'r' || spreadsheetRows[allused[k]][cols['status']][0] === 'x')) selection.push(allused[k])
}
}
if (howmuch === 'other') {
for (k=0;k<allused.length;k++) {
if (allused[k] > '¡' && spreadsheetRows[allused[k]][cols['class']][0] === 'C') selection.push(allused[k])
}
for (x=0;x<selection.length;x++) selection[x] = selection[x].codePointAt(0).toString(16).toUpperCase()
for (x=0;x<selection.length;x++) while (selection[x].length < 4) selection[x] = '0'+selection[x]
for (x=0;x<selection.length;x++) selection[x] = '\\u'+selection[x]
}
if (howmuch === 'possibles') {
for (k=0;k<all.length;k++) {
if (spreadsheetRows[all[k]][cols['status']] === '?') selection.push(all[k])
}
}
return selection
}
function getOrthographyList (type, location, spaced=false) {
// this is a modified version of runCharCount, adapted to harvest characters after the
// page has been rendered, and used by the links in the Basic Summary section on click
// it requires the presence of #index
var charlists, out
if (document.getElementById('index') == null) {
alert('No #index element (in getOrthographyList)')
return
}
else charlists = document.querySelectorAll('#index '+type+' .listItem')
var chars = ''
for (let i=0;i<charlists.length;i++) chars += charlists[i].textContent
var charlistArray = [...chars]
const uniqueSet = new Set(charlistArray)
var uniqueArray = [...uniqueSet]
if (spaced) out = uniqueArray.toString().replace(/,/g,' ')
else out = uniqueArray.toString().replace(/,/g,'')
return out
}
function pointToSummaryPages () {
// create links for various anchors such as line-breaking properties etc
if (document.getElementById('showLinebreaks')) document.getElementById('showLinebreaks').href = '../apps/listlinebreak/index.html?chars='+encodeURI(getOrthographyList('.characterBox', 'index', true) + getOrthographyList('.auxiliaryBox', 'index', true))
if (document.getElementById('showBidiClass')) document.getElementById('showBidiClass').href = '../apps/listbidi/index.html?chars='+encodeURI(getOrthographyList('.characterBox', 'index', true) + getOrthographyList('.auxiliaryBox', 'index', true))
}
function doHeadersFooters (orthogNotesFile) {
if (traceSet.has('doHeadersFooters') || traceSet.has('all')) console.log('doHeadersFooters(',orthogNotesFile,') Add links to top of document')
// adds links to top of document
// orthogNotesFile is of the form arabic/arb or arabic/ur
if (document.getElementById('versionTop') === null) return
//parse the orthogNotesFile
var filename = ''
var directory = ''
var path = orthogNotesFile.split('/')
directory = path[0]
if (path.length === 1) {
filename = path[0]
}
else {
filename = path[1]
}