Refactor HTML definition in detail view
All checks were successful
Pull Request / build (pull_request) Successful in 3m31s
All checks were successful
Pull Request / build (pull_request) Successful in 3m31s
This commit is contained in:
parent
30f88c9e3e
commit
cdcfd92f60
@ -8,6 +8,12 @@ import javafx.scene.control.Label
|
|||||||
import javafx.scene.control.ListView
|
import javafx.scene.control.ListView
|
||||||
import javafx.scene.control.TabPane
|
import javafx.scene.control.TabPane
|
||||||
import javafx.scene.web.WebView
|
import javafx.scene.web.WebView
|
||||||
|
import kotlinx.html.body
|
||||||
|
import kotlinx.html.h1
|
||||||
|
import kotlinx.html.html
|
||||||
|
import kotlinx.html.li
|
||||||
|
import kotlinx.html.ol
|
||||||
|
import kotlinx.html.stream.createHTML
|
||||||
|
|
||||||
class DetailsController(private val model: Model) {
|
class DetailsController(private val model: Model) {
|
||||||
@FXML
|
@FXML
|
||||||
@ -64,19 +70,19 @@ class DetailsController(private val model: Model) {
|
|||||||
return@addListener
|
return@addListener
|
||||||
}
|
}
|
||||||
webViewDefinition.engine.loadContent(
|
webViewDefinition.engine.loadContent(
|
||||||
buildString {
|
createHTML().html {
|
||||||
append("<html>")
|
body {
|
||||||
append("<body>")
|
h1 {
|
||||||
append("<h1>CC-CEDICT</h1>")
|
+"CC-CEDICT"
|
||||||
append("<ol>")
|
}
|
||||||
for (definition in newValue.definitions) {
|
ol {
|
||||||
append("<li>")
|
for (definition in newValue.definitions) {
|
||||||
append(definition.joinToString(separator = "; "))
|
li {
|
||||||
append("</li>")
|
+definition.joinToString(separator = "; ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
append("</ol>")
|
|
||||||
append("</body>")
|
|
||||||
append("</html>")
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,11 @@ h1 {
|
|||||||
font-size: 1.25em;
|
font-size: 1.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ol {
|
||||||
|
padding-left: 0;
|
||||||
|
list-style-position: inside;
|
||||||
|
}
|
||||||
|
|
||||||
ol li:only-child {
|
ol li:only-child {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user