alessandro trinca tornidor
commited on
Commit
·
304cdac
1
Parent(s):
9c1561c
feat: improve compatibility with lite.koboldai.net
Browse files- static/index-dark.css +105 -0
- static/index.css +14 -2
- static/index.html +2 -0
- static/index.js +11 -7
static/index-dark.css
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.display-none {
|
| 2 |
+
display: none;
|
| 3 |
+
}
|
| 4 |
+
.display-block {
|
| 5 |
+
display: block;
|
| 6 |
+
}
|
| 7 |
+
.underlinedDarkTurquoise {
|
| 8 |
+
text-decoration: underline;
|
| 9 |
+
text-decoration-color: darkturquoise;
|
| 10 |
+
text-decoration-style: wavy;
|
| 11 |
+
}
|
| 12 |
+
.underlinedYellow {
|
| 13 |
+
color: yellow;
|
| 14 |
+
text-decoration: underline;
|
| 15 |
+
text-decoration-color: yellow;
|
| 16 |
+
}
|
| 17 |
+
.underlinedViolet {
|
| 18 |
+
color: violet;
|
| 19 |
+
text-decoration: underline;
|
| 20 |
+
text-decoration-color: violet;
|
| 21 |
+
}
|
| 22 |
+
.display-flex {
|
| 23 |
+
display: flex;
|
| 24 |
+
}
|
| 25 |
+
.col-flex30 {
|
| 26 |
+
flex: 30%;
|
| 27 |
+
}
|
| 28 |
+
.col-flex50 {
|
| 29 |
+
flex: 50%;
|
| 30 |
+
}
|
| 31 |
+
.border-green {
|
| 32 |
+
border: 1px solid green;
|
| 33 |
+
}
|
| 34 |
+
.border-blue {
|
| 35 |
+
border: 1px solid blue;
|
| 36 |
+
}
|
| 37 |
+
.border-black {
|
| 38 |
+
border: 1px solid black;
|
| 39 |
+
}
|
| 40 |
+
.padding10px {
|
| 41 |
+
padding: 10px;
|
| 42 |
+
}
|
| 43 |
+
.margin10px {
|
| 44 |
+
margin: 10px;
|
| 45 |
+
}
|
| 46 |
+
.margin5px-left {
|
| 47 |
+
margin-left: 10px;
|
| 48 |
+
}
|
| 49 |
+
.margin5px-right {
|
| 50 |
+
margin-right: 10px;
|
| 51 |
+
}
|
| 52 |
+
.margin5px-top {
|
| 53 |
+
margin-top: 5px;
|
| 54 |
+
}
|
| 55 |
+
.margin2px-bottom {
|
| 56 |
+
margin-bottom: 2px;
|
| 57 |
+
}
|
| 58 |
+
.background-color-lightgray {
|
| 59 |
+
background-color: lightgray;
|
| 60 |
+
}
|
| 61 |
+
.background-color-whitesmoke {
|
| 62 |
+
background-color: whitesmoke;
|
| 63 |
+
}
|
| 64 |
+
.max-height-90vh {
|
| 65 |
+
max-height: 90vh;
|
| 66 |
+
}
|
| 67 |
+
.max-height-80vh {
|
| 68 |
+
max-height: 80vh;
|
| 69 |
+
}
|
| 70 |
+
.overflow-hidden {
|
| 71 |
+
/* needed for scroll bar*/
|
| 72 |
+
overflow: hidden;
|
| 73 |
+
}
|
| 74 |
+
.overflow-auto {
|
| 75 |
+
/* needed for scroll bar*/
|
| 76 |
+
overflow: auto;
|
| 77 |
+
}
|
| 78 |
+
.width-50perc {
|
| 79 |
+
width: 50%;
|
| 80 |
+
}
|
| 81 |
+
.width-80perc {
|
| 82 |
+
width: 80%;
|
| 83 |
+
}
|
| 84 |
+
#id-landscape-message {
|
| 85 |
+
display: none;
|
| 86 |
+
}
|
| 87 |
+
.id-orientation-message {
|
| 88 |
+
display: none;
|
| 89 |
+
}
|
| 90 |
+
.background-color-verydarkgrey {
|
| 91 |
+
background-color: #404040;
|
| 92 |
+
}
|
| 93 |
+
.font-size-12px {
|
| 94 |
+
font-size: small;
|
| 95 |
+
}
|
| 96 |
+
@media screen and (max-width: 1024px) and (orientation: portrait) {
|
| 97 |
+
.id-orientation-message {
|
| 98 |
+
display: block;
|
| 99 |
+
text-align: center;
|
| 100 |
+
}
|
| 101 |
+
.id-orientation-message:before {
|
| 102 |
+
color: red;
|
| 103 |
+
content: "(Mobile users: use this in landscape mode!)"
|
| 104 |
+
}
|
| 105 |
+
}
|
static/index.css
CHANGED
|
@@ -37,9 +37,9 @@ td {
|
|
| 37 |
text-decoration-color: blue;
|
| 38 |
}
|
| 39 |
.underlinedDarkViolet {
|
| 40 |
-
color:
|
| 41 |
text-decoration: underline;
|
| 42 |
-
text-decoration-color:
|
| 43 |
}
|
| 44 |
.display-flex {
|
| 45 |
display: flex;
|
|
@@ -109,6 +109,18 @@ td {
|
|
| 109 |
.id-orientation-message {
|
| 110 |
display: none;
|
| 111 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
@media screen and (max-width: 1024px) and (orientation: portrait) {
|
| 113 |
.id-orientation-message {
|
| 114 |
display: block;
|
|
|
|
| 37 |
text-decoration-color: blue;
|
| 38 |
}
|
| 39 |
.underlinedDarkViolet {
|
| 40 |
+
color: violet;
|
| 41 |
text-decoration: underline;
|
| 42 |
+
text-decoration-color: violet;
|
| 43 |
}
|
| 44 |
.display-flex {
|
| 45 |
display: flex;
|
|
|
|
| 109 |
.id-orientation-message {
|
| 110 |
display: none;
|
| 111 |
}
|
| 112 |
+
@media (prefers-color-scheme: dark) {
|
| 113 |
+
.underlinedBlue {
|
| 114 |
+
color: yellow;
|
| 115 |
+
text-decoration: underline;
|
| 116 |
+
text-decoration-color: yellow;
|
| 117 |
+
}
|
| 118 |
+
.underlinedDarkViolet {
|
| 119 |
+
color: violet;
|
| 120 |
+
text-decoration: underline;
|
| 121 |
+
text-decoration-color: violet;
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
@media screen and (max-width: 1024px) and (orientation: portrait) {
|
| 125 |
.id-orientation-message {
|
| 126 |
display: block;
|
static/index.html
CHANGED
|
@@ -22,6 +22,7 @@
|
|
| 22 |
Hi there, how are you? There are some pasties for you. Can you give me also... Take a pasty from the table there!
|
| 23 |
</div>
|
| 24 |
</div>
|
|
|
|
| 25 |
<div id="id-col2-words-frequency" class="col-flex50 border-blue padding10px margin10px overflow-hidden background-color-lightgray">
|
| 26 |
<div class="display-flex">
|
| 27 |
<div class="width-50perc">
|
|
@@ -59,6 +60,7 @@
|
|
| 59 |
<span id="waiting-for-be-error" class="display-none">Error!</span>
|
| 60 |
<div id="words-frequency" class="max-height-80vh overflow-auto background-color-whitesmoke" aria-label="words-frequency"></div>
|
| 61 |
</div>
|
|
|
|
| 62 |
</div>
|
| 63 |
</body>
|
| 64 |
</html>
|
|
|
|
| 22 |
Hi there, how are you? There are some pasties for you. Can you give me also... Take a pasty from the table there!
|
| 23 |
</div>
|
| 24 |
</div>
|
| 25 |
+
|
| 26 |
<div id="id-col2-words-frequency" class="col-flex50 border-blue padding10px margin10px overflow-hidden background-color-lightgray">
|
| 27 |
<div class="display-flex">
|
| 28 |
<div class="width-50perc">
|
|
|
|
| 60 |
<span id="waiting-for-be-error" class="display-none">Error!</span>
|
| 61 |
<div id="words-frequency" class="max-height-80vh overflow-auto background-color-whitesmoke" aria-label="words-frequency"></div>
|
| 62 |
</div>
|
| 63 |
+
|
| 64 |
</div>
|
| 65 |
</body>
|
| 66 |
</html>
|
static/index.js
CHANGED
|
@@ -3,6 +3,10 @@ let wfo = {
|
|
| 3 |
"words_frequency": {},
|
| 4 |
"nTotalRows": null
|
| 5 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
const getFormDataByKey = (formId, key) => {
|
| 8 |
let formElement = document.getElementById(formId)
|
|
@@ -19,7 +23,7 @@ const getFormDataByKey = (formId, key) => {
|
|
| 19 |
* @param {none}
|
| 20 |
*/
|
| 21 |
const previewFile = () => {
|
| 22 |
-
const editor = document.getElementById(
|
| 23 |
const [file] = document.querySelector("input[type=file]").files;
|
| 24 |
const reader = new FileReader();
|
| 25 |
reader.addEventListener("load", () => {
|
|
@@ -63,7 +67,7 @@ const scrollToGivenPoint = (editorElement, line, nTotalRows, negativeOffsetPerc=
|
|
| 63 |
* @param {number} [negativeOffsetPerc=0.12] - A percentage value used to offset the vertical scroll position (default: 0.12).
|
| 64 |
*/
|
| 65 |
const setCaret = (line, offsetColumn, nTotalRows, negativeOffsetPerc=0.12) => {
|
| 66 |
-
let editorElement = document.getElementById(
|
| 67 |
let validChildNodes = []
|
| 68 |
// use a for loop because of better performance
|
| 69 |
for (let i=0; i < editorElement.childNodes.length; i++) {
|
|
@@ -102,7 +106,7 @@ const setElementCssClass = (elementId, currentClass) => {
|
|
| 102 |
* @function getWordsFrequency
|
| 103 |
*/
|
| 104 |
const getWordsFrequency = async () => {
|
| 105 |
-
let text = document.getElementById(
|
| 106 |
// replace repeated newlines to prepare setCaret() use
|
| 107 |
text.innerText = text.innerText.replace(/[\r\n]+/g, '\n')
|
| 108 |
let bodyRequest = {"text": text.innerText}
|
|
@@ -113,7 +117,7 @@ const getWordsFrequency = async () => {
|
|
| 113 |
let wordsFrequency = document.getElementById("words-frequency")
|
| 114 |
wordsFrequency.innerHTML = ""
|
| 115 |
try {
|
| 116 |
-
let response = await fetch(
|
| 117 |
method: "POST",
|
| 118 |
body: JSON.stringify(bodyRequest)
|
| 119 |
})
|
|
@@ -256,13 +260,13 @@ const insertCellIntoTRow = (currentTBody, i, ii, nthOffset, nTotalRows) => {
|
|
| 256 |
setCaret(nRow, offsetWord, nTotalRows)
|
| 257 |
try {
|
| 258 |
let oldClassElement = document.getElementsByClassName('underlinedDarkViolet')
|
| 259 |
-
oldClassElement[0].className =
|
| 260 |
} catch {
|
| 261 |
console.log("first click...")
|
| 262 |
}
|
| 263 |
-
currentUrl.className =
|
| 264 |
})
|
| 265 |
-
currentUrl.className =
|
| 266 |
currentUrl.innerText = nthOffset["word"]
|
| 267 |
currentCell.appendChild(currentUrl)
|
| 268 |
nthRowBody.insertCell().textContent = nthOffset["n_row"]
|
|
|
|
| 3 |
"words_frequency": {},
|
| 4 |
"nTotalRows": null
|
| 5 |
}
|
| 6 |
+
const editorFieldLabel = "editor"
|
| 7 |
+
const remoteWebServer = ""
|
| 8 |
+
const underlinedPrimary = "underlinedBlue"
|
| 9 |
+
const underlinedClicked = "underlinedDarkViolet"
|
| 10 |
|
| 11 |
const getFormDataByKey = (formId, key) => {
|
| 12 |
let formElement = document.getElementById(formId)
|
|
|
|
| 23 |
* @param {none}
|
| 24 |
*/
|
| 25 |
const previewFile = () => {
|
| 26 |
+
const editor = document.getElementById(editorFieldLabel);
|
| 27 |
const [file] = document.querySelector("input[type=file]").files;
|
| 28 |
const reader = new FileReader();
|
| 29 |
reader.addEventListener("load", () => {
|
|
|
|
| 67 |
* @param {number} [negativeOffsetPerc=0.12] - A percentage value used to offset the vertical scroll position (default: 0.12).
|
| 68 |
*/
|
| 69 |
const setCaret = (line, offsetColumn, nTotalRows, negativeOffsetPerc=0.12) => {
|
| 70 |
+
let editorElement = document.getElementById(editorFieldLabel);
|
| 71 |
let validChildNodes = []
|
| 72 |
// use a for loop because of better performance
|
| 73 |
for (let i=0; i < editorElement.childNodes.length; i++) {
|
|
|
|
| 106 |
* @function getWordsFrequency
|
| 107 |
*/
|
| 108 |
const getWordsFrequency = async () => {
|
| 109 |
+
let text = document.getElementById(editorFieldLabel)
|
| 110 |
// replace repeated newlines to prepare setCaret() use
|
| 111 |
text.innerText = text.innerText.replace(/[\r\n]+/g, '\n')
|
| 112 |
let bodyRequest = {"text": text.innerText}
|
|
|
|
| 117 |
let wordsFrequency = document.getElementById("words-frequency")
|
| 118 |
wordsFrequency.innerHTML = ""
|
| 119 |
try {
|
| 120 |
+
let response = await fetch(`${remoteWebServer}/words-frequency`, {
|
| 121 |
method: "POST",
|
| 122 |
body: JSON.stringify(bodyRequest)
|
| 123 |
})
|
|
|
|
| 260 |
setCaret(nRow, offsetWord, nTotalRows)
|
| 261 |
try {
|
| 262 |
let oldClassElement = document.getElementsByClassName('underlinedDarkViolet')
|
| 263 |
+
oldClassElement[0].className = underlinedPrimary
|
| 264 |
} catch {
|
| 265 |
console.log("first click...")
|
| 266 |
}
|
| 267 |
+
currentUrl.className = underlinedClicked
|
| 268 |
})
|
| 269 |
+
currentUrl.className = underlinedPrimary
|
| 270 |
currentUrl.innerText = nthOffset["word"]
|
| 271 |
currentCell.appendChild(currentUrl)
|
| 272 |
nthRowBody.insertCell().textContent = nthOffset["n_row"]
|