diff --git a/src/jsMain/kotlin/gapi/Gapi.kt b/src/jsMain/kotlin/gapi/Gapi.kt index 8818aa7475917f88a24d6d90d2b76a4b366f7b9b..85c406183ed57b1644b76065c76e90799aa48970 100644 --- a/src/jsMain/kotlin/gapi/Gapi.kt +++ b/src/jsMain/kotlin/gapi/Gapi.kt @@ -121,6 +121,7 @@ private fun inited() { // Skip display of account chooser and consent dialog for an existing session. tokenClient.requestAccessToken(js("{prompt: ''}")) } + Unit } logOut = { diff --git a/src/jsMain/kotlin/pekstuff/PekNote.kt b/src/jsMain/kotlin/pekstuff/PekNote.kt index f269845d034e3b9c40013a118725d2c52d905b5c..7e3cafba77e09fbe3321d972f0abb61e86d3d684 100644 --- a/src/jsMain/kotlin/pekstuff/PekNote.kt +++ b/src/jsMain/kotlin/pekstuff/PekNote.kt @@ -15,24 +15,33 @@ object PekNote { .toList().lastOrNull() as? HTMLAnchorElement private val noteCnt get() = document.getElementById("comment-textarea") as? HTMLTextAreaElement private 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 + ?: document.querySelector("#comment-container > div > form.new_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 origCnt = noteCnt val edit = editBtn if (edit != null) { edit.click() - delay(1000) + while (noteCnt == origCnt) { + delay(50) + } } - if (noteCnt!!.value == value) { + val realValue = value.ifBlank { "⠀" } + if (noteCnt!!.value == value || noteCnt!!.value == realValue) { return } - noteCnt!!.value = value + noteCnt!!.value = realValue btn!!.click() + val origBtn = btn + while (btn == origBtn || btn!!.disabled) { + delay(50) + } } suspend fun waitUntilLoaded(person: String, principle: String) { val expected = "$person - $principle" while (noteName != expected) { - delay(100) + delay(50) } } } \ No newline at end of file diff --git a/src/jsMain/kotlin/pekstuff/Utils.kt b/src/jsMain/kotlin/pekstuff/Utils.kt index e0b6967766e28357bcf188326e61acdd9a1cfbd4..f7831a40e945083affe1eef55c9e90909ae64405 100644 --- a/src/jsMain/kotlin/pekstuff/Utils.kt +++ b/src/jsMain/kotlin/pekstuff/Utils.kt @@ -75,10 +75,13 @@ suspend fun PekTable.clear( progress: (Double) -> Unit = {} ) { progress(0.0) + showComments() people.forEachIndexed { i, person -> principles.forEachIndexed { j, principle -> PekTable[person, principle] = 0 PekDelay() + PekNote.waitUntilLoaded(person, principle) + PekNote.setNote("") progress(calcProgress(i, j, people.size, principles.size)) }