alessandro trinca tornidor commited on
Commit ·
4614287
1
Parent(s): 9cb8062
feat: start refactoring the UI interface on mobile
Browse files- static/index.css +29 -6
- static/index.html +38 -25
- static/index.js +85 -16
static/index.css
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
margin-block-start: 5px;
|
| 6 |
margin-block-end: 5px;
|
| 7 |
}
|
| 8 |
-
#id-col1-editor > h4,#id-col2-words-frequency > div > div > h4 {
|
| 9 |
font-size: 18px;
|
| 10 |
margin-block-start: 2px;
|
| 11 |
margin-block-end: 2px;
|
|
@@ -23,7 +23,7 @@
|
|
| 23 |
.font-weight-bold {
|
| 24 |
font-weight: bolder;
|
| 25 |
}
|
| 26 |
-
.display-none {
|
| 27 |
display: none;
|
| 28 |
}
|
| 29 |
.display-block {
|
|
@@ -68,6 +68,9 @@
|
|
| 68 |
.margin10px {
|
| 69 |
margin: 10px;
|
| 70 |
}
|
|
|
|
|
|
|
|
|
|
| 71 |
.margin5px-left {
|
| 72 |
margin-left: 10px;
|
| 73 |
}
|
|
@@ -115,6 +118,10 @@
|
|
| 115 |
.id-orientation-message {
|
| 116 |
display: none;
|
| 117 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
/* Classic UI Main Text, lite.koboldai.net */
|
| 120 |
#gamescreen {
|
|
@@ -127,21 +134,23 @@
|
|
| 127 |
align-self: flex-end;
|
| 128 |
}
|
| 129 |
#gametext, #editor {
|
| 130 |
-
max-height: 100%;
|
| 131 |
width: 100%;
|
| 132 |
word-wrap: break-word;
|
| 133 |
padding: 10px;
|
| 134 |
overflow-y: auto;
|
| 135 |
white-space: pre-wrap;
|
| 136 |
-
height:
|
| 137 |
border: 1px solid black;
|
| 138 |
}
|
| 139 |
-
.
|
| 140 |
-
height: calc(
|
| 141 |
}
|
| 142 |
.calc96vh_less_240px {
|
| 143 |
height: calc(96vh - 240px);
|
| 144 |
}
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
@media (prefers-color-scheme: dark) {
|
| 147 |
.underlinedBlue {
|
|
@@ -155,6 +164,20 @@
|
|
| 155 |
text-decoration-color: violet;
|
| 156 |
}
|
| 157 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
@media screen and (max-width: 1024px) and (orientation: portrait) {
|
| 159 |
.id-orientation-message {
|
| 160 |
display: block;
|
|
|
|
| 5 |
margin-block-start: 5px;
|
| 6 |
margin-block-end: 5px;
|
| 7 |
}
|
| 8 |
+
#id-col1-editor > h4,#id-col2-words-frequency > div > div > h4, #id-col2-words-frequency > h4 {
|
| 9 |
font-size: 18px;
|
| 10 |
margin-block-start: 2px;
|
| 11 |
margin-block-end: 2px;
|
|
|
|
| 23 |
.font-weight-bold {
|
| 24 |
font-weight: bolder;
|
| 25 |
}
|
| 26 |
+
.display-none, .collapse {
|
| 27 |
display: none;
|
| 28 |
}
|
| 29 |
.display-block {
|
|
|
|
| 68 |
.margin10px {
|
| 69 |
margin: 10px;
|
| 70 |
}
|
| 71 |
+
.margin2px {
|
| 72 |
+
margin: 2px;
|
| 73 |
+
}
|
| 74 |
.margin5px-left {
|
| 75 |
margin-left: 10px;
|
| 76 |
}
|
|
|
|
| 118 |
.id-orientation-message {
|
| 119 |
display: none;
|
| 120 |
}
|
| 121 |
+
.scrollable-table-container {
|
| 122 |
+
max-height: calc(100vh - 200px);
|
| 123 |
+
overflow: auto;
|
| 124 |
+
}
|
| 125 |
|
| 126 |
/* Classic UI Main Text, lite.koboldai.net */
|
| 127 |
#gamescreen {
|
|
|
|
| 134 |
align-self: flex-end;
|
| 135 |
}
|
| 136 |
#gametext, #editor {
|
|
|
|
| 137 |
width: 100%;
|
| 138 |
word-wrap: break-word;
|
| 139 |
padding: 10px;
|
| 140 |
overflow-y: auto;
|
| 141 |
white-space: pre-wrap;
|
| 142 |
+
height: calc(100vh - 180px);
|
| 143 |
border: 1px solid black;
|
| 144 |
}
|
| 145 |
+
.calc100vh_less_150px {
|
| 146 |
+
height: calc(100vh - 150px);
|
| 147 |
}
|
| 148 |
.calc96vh_less_240px {
|
| 149 |
height: calc(96vh - 240px);
|
| 150 |
}
|
| 151 |
+
.calc100vh_less_200px {
|
| 152 |
+
height: calc(100vh - 200px);
|
| 153 |
+
}
|
| 154 |
|
| 155 |
@media (prefers-color-scheme: dark) {
|
| 156 |
.underlinedBlue {
|
|
|
|
| 164 |
text-decoration-color: violet;
|
| 165 |
}
|
| 166 |
}
|
| 167 |
+
@media screen and (max-height: 767px) {
|
| 168 |
+
#gametext, #editor {
|
| 169 |
+
height: calc(100vh - 122px);
|
| 170 |
+
}
|
| 171 |
+
#gamescreen {
|
| 172 |
+
height: calc(100vh - 100px) !important;
|
| 173 |
+
}
|
| 174 |
+
#words-frequency {
|
| 175 |
+
height: calc(100vh - 100px) !important;
|
| 176 |
+
}
|
| 177 |
+
.scrollable-table-container {
|
| 178 |
+
max-height: calc(100vh - 130px) !important;
|
| 179 |
+
}
|
| 180 |
+
}
|
| 181 |
@media screen and (max-width: 1024px) and (orientation: portrait) {
|
| 182 |
.id-orientation-message {
|
| 183 |
display: block;
|
static/index.html
CHANGED
|
@@ -8,31 +8,40 @@
|
|
| 8 |
<script src="/static/index.js"></script>
|
| 9 |
</head>
|
| 10 |
<body class="overflow-hidden">
|
| 11 |
-
|
| 12 |
-
<div id="id-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
</div>
|
|
|
|
| 31 |
<div id="id-container-row-global-editor-frequency" class="display-flex">
|
| 32 |
<div id="id-col1-editor" class="col-flex50 border-black padding10px margin10px overflow-hidden background-color-lightgray">
|
| 33 |
<h4>Text Editor</h4>
|
| 34 |
-
<div class="gamescreenbgnormal
|
| 35 |
-
<span id="editor" contenteditable="true" class="
|
| 36 |
<span>
|
| 37 |
"Hi Isabella. Do you know where Harry is?" The fairy said. She was shy since they never spoken before.<br>Another sentence with the word "She".<br><br>
|
| 38 |
"No, I don't know, but probably his father Harry Senior knows." Responded Isabella, a little unsure. She was afraid...<br>She was right?
|
|
@@ -55,13 +64,14 @@ Another row.<br>More one.<br>A last row, I hope.
|
|
| 55 |
</div>
|
| 56 |
|
| 57 |
<div id="id-col2-words-frequency" class="col-flex50 border-blue padding10px margin10px overflow-hidden background-color-lightgray">
|
| 58 |
-
<
|
| 59 |
-
|
| 60 |
-
|
|
|
|
| 61 |
<input type="text" id="filter-words-frequency" aria-label="filter-words-frequency" placeholder="Filter the output table..." class="width-80perc" onkeydown="updateWordsFreqIfPressEnterSimple()"/>
|
| 62 |
<button type="submit" id="btn-filter-words-frequency" aria-label="btn-filter-words-frequency" onclick="updateWordsFrequencyTables()">Submit</button>
|
| 63 |
</div>
|
| 64 |
-
<div class="display-flex width-50perc margin2px-bottom">
|
| 65 |
<form id="id-form-sort-by" aria-label="id-form-sort-by">
|
| 66 |
<fieldset>
|
| 67 |
<legend>Sort:</legend>
|
|
@@ -89,9 +99,12 @@ Another row.<br>More one.<br>A last row, I hope.
|
|
| 89 |
<span id="id-n-total-rows" aria-label="id-n-total-rows" class="display-none"></span>
|
| 90 |
<span id="waiting-for-be" class="display-none">waiting for backend response...</span>
|
| 91 |
<span id="waiting-for-be-error" class="display-none">Error!</span>
|
| 92 |
-
<div id="words-frequency" class="
|
| 93 |
<div id="id-list-of-words" class="margin10px overflow-auto" aria-label="id-list-of-words"></div>
|
| 94 |
-
<div id="id-current-table-of-words" class="
|
|
|
|
|
|
|
|
|
|
| 95 |
</div>
|
| 96 |
</div>
|
| 97 |
|
|
|
|
| 8 |
<script src="/static/index.js"></script>
|
| 9 |
</head>
|
| 10 |
<body class="overflow-hidden">
|
| 11 |
+
<div id="id-orientation-message" class="id-orientation-message" aria-hidden="true"><!-- ::before (Mobile users: use this project in landscape mode!) --></div>
|
| 12 |
+
<div id="id-container-menu">
|
| 13 |
+
<div id="id-container-mobile-menu" class="collapse">
|
| 14 |
+
<button id="id-menu-mobile-top" onclick="toggleElementWithClassById('id-container-desktop-menu')">Global menu' word freq. stats</button>
|
| 15 |
+
<button id="id-menu-mobile-filter-sort-order" onclick="toggleElementWithClassById('id-container-filter-sort-order')">Menu' filter word freq.</button>
|
| 16 |
+
</div>
|
| 17 |
+
<div id="id-container-desktop-menu">
|
| 18 |
+
<h1 id="id-title" class="h1">Word Frequency Statistics in text</h1>
|
| 19 |
+
<div class="margin10px">
|
| 20 |
+
<button id="btn4-get-words-frequency" aria-label="btn4-get-words-frequency" onclick="getWordsFrequency()" type="submit">get words frequency</button>
|
| 21 |
+
<label for="id-input-webserver-wordfreq-checkbox" class="margin5px-left">Use a custom webserver endpoint</label>
|
| 22 |
|
| 23 |
+
<input
|
| 24 |
+
type="checkbox"
|
| 25 |
+
id="id-input-webserver-wordfreq-checkbox"
|
| 26 |
+
aria-label="id-input-webserver-wordfreq-checkbox"
|
| 27 |
+
name="id-input-webserver-wordfreq-checkbox"
|
| 28 |
+
onchange="toggleWebserverCheckbox()"
|
| 29 |
+
checked
|
| 30 |
+
/>
|
| 31 |
+
<input type="URL" id="id-input-webserver-wordfreq" aria-label="id-input-webserver-wordfreq" value="http://localhost:7860" />
|
| 32 |
+
<span>Currently using: <span id="id-wordfreq-show-analyzer" aria-label="id-wordfreq-show-analyzer">webserver</span></span>
|
| 33 |
|
| 34 |
+
<label for="id-input-file-selector" class="margin5px-left">Text file selector</label>
|
| 35 |
+
<input type="file" onchange="previewFile()" id="id-input-file-selector" aria-label="id-input-file-selector" />
|
| 36 |
+
</div>
|
| 37 |
+
</div>
|
| 38 |
</div>
|
| 39 |
+
|
| 40 |
<div id="id-container-row-global-editor-frequency" class="display-flex">
|
| 41 |
<div id="id-col1-editor" class="col-flex50 border-black padding10px margin10px overflow-hidden background-color-lightgray">
|
| 42 |
<h4>Text Editor</h4>
|
| 43 |
+
<div class="gamescreenbgnormal calc100vh_less_150px" id="gamescreen">
|
| 44 |
+
<span id="editor" contenteditable="true" class="overflow-auto background-color-whitesmoke" aria-label="editor">Once upon a time, in the kingdom of Elwoodia, there lived a young and wise young Princess named Isabella. She loved nothing more than to explore the world around her and experience new things. One day, she set off on an adventure to find out about the mysterious and enchanting forest beyond the village gate.<br>As she journeyed through the woods, Isabella stumbled upon a large clearing where she saw a small group of woodland creatures gathered around something. Curious, she went over to take a look. There she noticed a large, red apple lying across the ground. It was so unusual that she had never seen anything like it before; its shape was round but oval, and it was larger than any fruit she'd ever seen.<br><br>The creatures surrounding the apple moved aside to let Isabella get a closer look. As she came closer, she saw a tiny fairy perched on top of the apple. The fairy flew to Isabella and spoke in a soft voice.<br><br><br><br>
|
| 45 |
<span>
|
| 46 |
"Hi Isabella. Do you know where Harry is?" The fairy said. She was shy since they never spoken before.<br>Another sentence with the word "She".<br><br>
|
| 47 |
"No, I don't know, but probably his father Harry Senior knows." Responded Isabella, a little unsure. She was afraid...<br>She was right?
|
|
|
|
| 64 |
</div>
|
| 65 |
|
| 66 |
<div id="id-col2-words-frequency" class="col-flex50 border-blue padding10px margin10px overflow-hidden background-color-lightgray">
|
| 67 |
+
<h4 id="id-words-frequency-table-title-mobile" aria-label="id-words-frequency-table-title" class="collapse">Words Freq. Stats</h4>
|
| 68 |
+
<div id="id-container-filter-sort-order" class="display-flex">
|
| 69 |
+
<div id="id-container-filter-word-list" class="width-50perc">
|
| 70 |
+
<h4 id="id-words-frequency-table-title" aria-label="id-words-frequency-table-title">Words Freq. Stats</h4>
|
| 71 |
<input type="text" id="filter-words-frequency" aria-label="filter-words-frequency" placeholder="Filter the output table..." class="width-80perc" onkeydown="updateWordsFreqIfPressEnterSimple()"/>
|
| 72 |
<button type="submit" id="btn-filter-words-frequency" aria-label="btn-filter-words-frequency" onclick="updateWordsFrequencyTables()">Submit</button>
|
| 73 |
</div>
|
| 74 |
+
<div id="id-container-sort-order-word-list" class="display-flex width-50perc margin2px-bottom">
|
| 75 |
<form id="id-form-sort-by" aria-label="id-form-sort-by">
|
| 76 |
<fieldset>
|
| 77 |
<legend>Sort:</legend>
|
|
|
|
| 99 |
<span id="id-n-total-rows" aria-label="id-n-total-rows" class="display-none"></span>
|
| 100 |
<span id="waiting-for-be" class="display-none">waiting for backend response...</span>
|
| 101 |
<span id="waiting-for-be-error" class="display-none">Error!</span>
|
| 102 |
+
<div id="words-frequency" class="calc100vh_less_200px overflow-hidden background-color-whitesmoke display-flex" aria-label="words-frequency">
|
| 103 |
<div id="id-list-of-words" class="margin10px overflow-auto" aria-label="id-list-of-words"></div>
|
| 104 |
+
<div id="id-current-table-of-words-container" class="">
|
| 105 |
+
<span id="id-current-table-of-words-title"></span>
|
| 106 |
+
<div id="id-current-table-of-words" class="overflow-auto" aria-label="id-current-table-of-words"></div>
|
| 107 |
+
</div>
|
| 108 |
</div>
|
| 109 |
</div>
|
| 110 |
|
static/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-
const wordsFrequencyTableTitleText = "Words
|
|
|
|
| 2 |
let wfo = {
|
| 3 |
"words_frequency": {},
|
| 4 |
"nTotalRows": null,
|
|
@@ -14,6 +15,7 @@ const objectChildNodeNamesToParse = {
|
|
| 14 |
"#text": "textContent",
|
| 15 |
"SPAN": "textContent"
|
| 16 |
}
|
|
|
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Object containing functions for word frequency analysis.
|
|
@@ -506,15 +508,23 @@ function parseWebserverDomain () {
|
|
| 506 |
* @function getWordsFrequency
|
| 507 |
*/
|
| 508 |
async function getWordsFrequency() {
|
|
|
|
|
|
|
|
|
|
| 509 |
let {validChildContent} = getValidChildNodesFromEditorById(editorFieldLabel)
|
| 510 |
setElementCssClassById("waiting-for-be-error", "display-none")
|
| 511 |
setElementCssClassById("waiting-for-be", "display-block")
|
| 512 |
let wordsFrequencyTableTitleEl = document.getElementById("id-words-frequency-table-title")
|
|
|
|
|
|
|
| 513 |
wordsFrequencyTableTitleEl.innerText = wordsFrequencyTableTitleText
|
|
|
|
| 514 |
let listOfWords = document.getElementById("id-list-of-words")
|
| 515 |
listOfWords.innerHTML = ""
|
| 516 |
let currentTableOfWords = document.getElementById("id-current-table-of-words")
|
| 517 |
currentTableOfWords.innerHTML = ""
|
|
|
|
|
|
|
| 518 |
const choiceWordFreqAnalyzerEl = document.getElementById('id-input-webserver-wordfreq-checkbox')
|
| 519 |
console.log("choiceWordFreqAnalyzerEl checked:", typeof choiceWordFreqAnalyzerEl.checked, choiceWordFreqAnalyzerEl.checked, "#")
|
| 520 |
switch (choiceWordFreqAnalyzerEl.checked) {
|
|
@@ -626,6 +636,9 @@ function updateWordsFrequencyTables() {
|
|
| 626 |
|
| 627 |
let wordsFrequencyTableTitleEl = document.getElementById("id-words-frequency-table-title")
|
| 628 |
wordsFrequencyTableTitleEl.innerText = `${wordsFrequencyTableTitleText} (${reduced.length} word groups, ${nTotalRows} rows)`
|
|
|
|
|
|
|
|
|
|
| 629 |
const wordListElement = document.createElement("list")
|
| 630 |
for (let i=0; i<reduced.length; i++ ) {
|
| 631 |
insertListOfWords(i, reduced[i], wordListElement, currentTableOfWords);
|
|
@@ -663,17 +676,22 @@ function insertCurrentTable(i, iReduced, currentTableOfWords) {
|
|
| 663 |
currentTableWordsFreq.setAttribute("id", `id-table-${i}-nth`)
|
| 664 |
currentTableWordsFreq.setAttribute("aria-label", `id-table-${i}-nth`)
|
| 665 |
|
| 666 |
-
let currentCaption = currentTableWordsFreq.createCaption()
|
| 667 |
-
currentCaption.setAttribute("aria-label", `id-table-${i}-caption`
|
| 668 |
-
|
| 669 |
-
|
| 670 |
let currentTBody = document.createElement("tbody")
|
| 671 |
let offsetsArray = iReduced.offsets_array
|
| 672 |
for (let ii = 0; ii < offsetsArray.length; ii++) {
|
| 673 |
insertCellIntoTRow(currentTBody, i, ii, offsetsArray[ii])
|
| 674 |
}
|
| 675 |
currentTableWordsFreq.appendChild(currentTBody)
|
| 676 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 677 |
}
|
| 678 |
|
| 679 |
/**
|
|
@@ -929,24 +947,33 @@ function getValidChildNodesFromEditorById(idElement) {
|
|
| 929 |
}
|
| 930 |
|
| 931 |
/** Needed by lite.koboldai.net */
|
| 932 |
-
function
|
| 933 |
-
let
|
| 934 |
-
if (
|
| 935 |
-
|
| 936 |
} else {
|
| 937 |
-
|
| 938 |
}
|
| 939 |
}
|
| 940 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 941 |
function closeWordsFreqTopNav(idElement) {
|
| 942 |
-
|
| 943 |
-
x.classList.add("collapse");
|
| 944 |
}
|
| 945 |
|
| 946 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 947 |
switch (boolFlag) {
|
| 948 |
case boolFlag === true:
|
| 949 |
-
|
| 950 |
break;
|
| 951 |
case boolFlag === false:
|
| 952 |
closeWordsFreqTopNav(idElement)
|
|
@@ -970,4 +997,46 @@ async function updateWordsFreqIfPressEnter() {
|
|
| 970 |
updateWordsFrequencyTables()
|
| 971 |
}
|
| 972 |
}
|
| 973 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const wordsFrequencyTableTitleText = "Words Freq. Stats"
|
| 2 |
+
const wordsFrequencyTableTitleMobileText = "Words Freq. Stats"
|
| 3 |
let wfo = {
|
| 4 |
"words_frequency": {},
|
| 5 |
"nTotalRows": null,
|
|
|
|
| 15 |
"#text": "textContent",
|
| 16 |
"SPAN": "textContent"
|
| 17 |
}
|
| 18 |
+
const mobileInnerSize = 767
|
| 19 |
|
| 20 |
/**
|
| 21 |
* Object containing functions for word frequency analysis.
|
|
|
|
| 508 |
* @function getWordsFrequency
|
| 509 |
*/
|
| 510 |
async function getWordsFrequency() {
|
| 511 |
+
if (isMobile()) {
|
| 512 |
+
toggleElementWithClassById('id-container-desktop-menu')
|
| 513 |
+
}
|
| 514 |
let {validChildContent} = getValidChildNodesFromEditorById(editorFieldLabel)
|
| 515 |
setElementCssClassById("waiting-for-be-error", "display-none")
|
| 516 |
setElementCssClassById("waiting-for-be", "display-block")
|
| 517 |
let wordsFrequencyTableTitleEl = document.getElementById("id-words-frequency-table-title")
|
| 518 |
+
let wordsFrequencyTableTitleElMobile = document.getElementById("id-words-frequency-table-title-mobile")
|
| 519 |
+
|
| 520 |
wordsFrequencyTableTitleEl.innerText = wordsFrequencyTableTitleText
|
| 521 |
+
wordsFrequencyTableTitleElMobile.innerText = wordsFrequencyTableTitleMobileText
|
| 522 |
let listOfWords = document.getElementById("id-list-of-words")
|
| 523 |
listOfWords.innerHTML = ""
|
| 524 |
let currentTableOfWords = document.getElementById("id-current-table-of-words")
|
| 525 |
currentTableOfWords.innerHTML = ""
|
| 526 |
+
let currentTableTitle = document.getElementById("id-current-table-of-words-title")
|
| 527 |
+
currentTableTitle.innerText = ""
|
| 528 |
const choiceWordFreqAnalyzerEl = document.getElementById('id-input-webserver-wordfreq-checkbox')
|
| 529 |
console.log("choiceWordFreqAnalyzerEl checked:", typeof choiceWordFreqAnalyzerEl.checked, choiceWordFreqAnalyzerEl.checked, "#")
|
| 530 |
switch (choiceWordFreqAnalyzerEl.checked) {
|
|
|
|
| 636 |
|
| 637 |
let wordsFrequencyTableTitleEl = document.getElementById("id-words-frequency-table-title")
|
| 638 |
wordsFrequencyTableTitleEl.innerText = `${wordsFrequencyTableTitleText} (${reduced.length} word groups, ${nTotalRows} rows)`
|
| 639 |
+
let wordsFrequencyTableTitleMobileEl = document.getElementById("id-words-frequency-table-title-mobile")
|
| 640 |
+
wordsFrequencyTableTitleMobileEl.innerText = `${wordsFrequencyTableTitleMobileText} (${reduced.length} word groups, ${nTotalRows} rows)`
|
| 641 |
+
|
| 642 |
const wordListElement = document.createElement("list")
|
| 643 |
for (let i=0; i<reduced.length; i++ ) {
|
| 644 |
insertListOfWords(i, reduced[i], wordListElement, currentTableOfWords);
|
|
|
|
| 676 |
currentTableWordsFreq.setAttribute("id", `id-table-${i}-nth`)
|
| 677 |
currentTableWordsFreq.setAttribute("aria-label", `id-table-${i}-nth`)
|
| 678 |
|
| 679 |
+
// let currentCaption = currentTableWordsFreq.createCaption()
|
| 680 |
+
// currentCaption.setAttribute("aria-label", `id-table-${i}-caption`
|
| 681 |
+
const titleCurrentTable = document.getElementById("id-current-table-of-words-title")
|
| 682 |
+
titleCurrentTable.innerText = `${iReduced["word_prefix"]}: ${iReduced["count"]} repetitions`
|
| 683 |
let currentTBody = document.createElement("tbody")
|
| 684 |
let offsetsArray = iReduced.offsets_array
|
| 685 |
for (let ii = 0; ii < offsetsArray.length; ii++) {
|
| 686 |
insertCellIntoTRow(currentTBody, i, ii, offsetsArray[ii])
|
| 687 |
}
|
| 688 |
currentTableWordsFreq.appendChild(currentTBody)
|
| 689 |
+
|
| 690 |
+
// Wrap the table in a scrollable container
|
| 691 |
+
let scrollableDiv = document.createElement("div")
|
| 692 |
+
scrollableDiv.className = "scrollable-table-container"
|
| 693 |
+
scrollableDiv.appendChild(currentTableWordsFreq)
|
| 694 |
+
currentTableOfWords.appendChild(scrollableDiv)
|
| 695 |
}
|
| 696 |
|
| 697 |
/**
|
|
|
|
| 947 |
}
|
| 948 |
|
| 949 |
/** Needed by lite.koboldai.net */
|
| 950 |
+
function toggleElementWithClassById(idElement, className="collapse") {
|
| 951 |
+
let elementWithClassToChange = document.getElementById(idElement)
|
| 952 |
+
if (elementWithClassToChange.classList.contains(className)) {
|
| 953 |
+
elementWithClassToChange.classList.remove(className);
|
| 954 |
} else {
|
| 955 |
+
elementWithClassToChange.classList.add(className);
|
| 956 |
}
|
| 957 |
}
|
| 958 |
|
| 959 |
+
function addClassById(idElement, className) {
|
| 960 |
+
let elementWithClassToChange = document.getElementById(idElement)
|
| 961 |
+
elementWithClassToChange.classList.add(className);
|
| 962 |
+
}
|
| 963 |
+
|
| 964 |
function closeWordsFreqTopNav(idElement) {
|
| 965 |
+
addClassById(idElement, "collapse")
|
|
|
|
| 966 |
}
|
| 967 |
|
| 968 |
+
function removeClassById(idElement, className) {
|
| 969 |
+
let elementWithClassToChange = document.getElementById(idElement)
|
| 970 |
+
elementWithClassToChange.classList.remove(className);
|
| 971 |
+
}
|
| 972 |
+
|
| 973 |
+
function toggleOrCloseByBoolAndId(idElement, boolFlag, className="collapse") {
|
| 974 |
switch (boolFlag) {
|
| 975 |
case boolFlag === true:
|
| 976 |
+
toggleElementWithClassById(idElement, className)
|
| 977 |
break;
|
| 978 |
case boolFlag === false:
|
| 979 |
closeWordsFreqTopNav(idElement)
|
|
|
|
| 997 |
updateWordsFrequencyTables()
|
| 998 |
}
|
| 999 |
}
|
| 1000 |
+
}
|
| 1001 |
+
|
| 1002 |
+
function toggleWebserverCheckbox() {
|
| 1003 |
+
document.getElementById('id-input-webserver-wordfreq').disabled=!this.checked;document.getElementById('id-wordfreq-show-analyzer').innerText=this.checked?'webserver':'embedded';
|
| 1004 |
+
if (isMobile()) {
|
| 1005 |
+
toggleElementWithClassById('id-container-desktop-menu')
|
| 1006 |
+
}
|
| 1007 |
+
}
|
| 1008 |
+
|
| 1009 |
+
function handleMobileWindow() {
|
| 1010 |
+
if (isMobile()) {
|
| 1011 |
+
closeWordsFreqTopNav("id-container-desktop-menu")
|
| 1012 |
+
closeWordsFreqTopNav("id-container-filter-sort-order")
|
| 1013 |
+
addClassById('id-words-frequency-table-title', "collapse");
|
| 1014 |
+
removeClassById('id-words-frequency-table-title-mobile', "collapse");
|
| 1015 |
+
removeClassById('id-container-mobile-menu', "collapse");
|
| 1016 |
+
removeClassById('id-container-filter-sort-order', "display-flex");
|
| 1017 |
+
removeClassById('id-container-filter-word-list', "width-50perc");
|
| 1018 |
+
removeClassById('id-container-sort-order-word-list', "width-50perc");
|
| 1019 |
+
|
| 1020 |
+
removeClassById('id-current-table-of-words-container', "margin10px");
|
| 1021 |
+
addClassById('id-current-table-of-words-container', "margin2px");
|
| 1022 |
+
} else {
|
| 1023 |
+
closeWordsFreqTopNav("id-container-mobile-menu")
|
| 1024 |
+
// Always show desktop container on desktop
|
| 1025 |
+
removeClassById('id-container-desktop-menu', "collapse");
|
| 1026 |
+
removeClassById('id-container-filter-sort-order', "collapse");
|
| 1027 |
+
addClassById('id-container-filter-sort-order', "display-flex");
|
| 1028 |
+
addClassById('id-words-frequency-table-title-mobile', "collapse");
|
| 1029 |
+
addClassById('id-container-filter-word-list', "width-50perc");
|
| 1030 |
+
removeClassById('id-words-frequency-table-title', "collapse");
|
| 1031 |
+
addClassById('id-current-table-of-words-container', "margin10px");
|
| 1032 |
+
removeClassById('id-current-table-of-words-container', "margin2px");
|
| 1033 |
+
}
|
| 1034 |
+
}
|
| 1035 |
+
|
| 1036 |
+
function isMobile() {
|
| 1037 |
+
return window.innerWidth <= mobileInnerSize || window.innerHeight <= mobileInnerSize;
|
| 1038 |
+
}
|
| 1039 |
+
|
| 1040 |
+
window.addEventListener('resize', handleMobileWindow);
|
| 1041 |
+
window.addEventListener('DOMContentLoaded', handleMobileWindow);
|
| 1042 |
+
console.log('DOMContentLoaded');
|