Skip to content
Snippets Groups Projects
Commit 2085d71e authored by Tóth Miklós Tibor's avatar Tóth Miklós Tibor :shrug:
Browse files

Edit comment instead of adding a new one

parent 7ca85102
No related branches found
No related tags found
No related merge requests found
Pipeline #30546 passed
......@@ -2,6 +2,7 @@ package pekstuff
import kotlinx.browser.document
import kotlinx.coroutines.delay
import org.w3c.dom.HTMLAnchorElement
import org.w3c.dom.HTMLInputElement
import org.w3c.dom.HTMLTextAreaElement
......@@ -9,11 +10,21 @@ object PekNote {
val noteNameCnt get() = document.querySelector("#comment-container > div.uk-padding.uk-text-center")
val noteName get() = noteNameCnt?.textContent
val editBtn get() =
document.querySelectorAll("#comment-container > article.uk-comment > header.uk-comment-header > div.uk-comment-meta > a")
.toList().lastOrNull() as? HTMLAnchorElement
val noteCnt get() = document.getElementById("comment-textarea") as? HTMLTextAreaElement
val btn get() = document.querySelector("#new_point_detail_comment > article > div.uk-clearfix > div.uk-float-right > input.uk-button") as? HTMLInputElement
var note
get() = noteCnt!!.value
set(value) {
val btn get() = document.querySelector("#comment-container > div > form.edit_point_detail_comment > article.uk-comment > div.uk-clearfix > div.uk-float-right > input.uk-button") as? HTMLInputElement
fun getNote() = noteCnt!!.value
suspend fun setNote(value: String) {
val edit = editBtn
if (edit != null) {
edit.click()
delay(1000)
}
if (noteCnt!!.value == value) {
return
}
noteCnt!!.value = value
btn!!.click()
}
......
......@@ -42,7 +42,7 @@ suspend fun DataSource.process(
PekDelay()
if (this is NoteDataSource) {
PekNote.waitUntilLoaded(pekPerson, pekPrinciple)
PekNote.note = getNote(person, principle)
PekNote.setNote(getNote(person, principle))
}
progress(calcProgress(i, j, people.size, principles.size))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment