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

Clean up project

parent 5748d429
Branches
No related tags found
No related merge requests found
...@@ -7,10 +7,9 @@ import gapi.sheets ...@@ -7,10 +7,9 @@ import gapi.sheets
import kotlinx.browser.window import kotlinx.browser.window
import pekstuff.trimAsPrinciple import pekstuff.trimAsPrinciple
import kotlin.coroutines.resume import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine import kotlin.coroutines.suspendCoroutine
class GSheet private constructor(private val sheet: sheets.Spreadsheet): DataSource, NoteDataSource { class GSheet private constructor(sheet: sheets.Spreadsheet): DataSource, NoteDataSource {
companion object { companion object {
private val filterList = listOf( private val filterList = listOf(
"szumma", "színes belépő" "szumma", "színes belépő"
......
...@@ -3,7 +3,6 @@ package gapi ...@@ -3,7 +3,6 @@ package gapi
import androidx.compose.runtime.NoLiveLiterals import androidx.compose.runtime.NoLiveLiterals
import kotlinx.browser.document import kotlinx.browser.document
import kotlinx.browser.localStorage import kotlinx.browser.localStorage
import kotlinx.browser.window
import org.w3c.dom.HTMLScriptElement import org.w3c.dom.HTMLScriptElement
import org.w3c.dom.get import org.w3c.dom.get
import org.w3c.dom.set import org.w3c.dom.set
...@@ -11,7 +10,7 @@ import kotlin.coroutines.resume ...@@ -11,7 +10,7 @@ import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine import kotlin.coroutines.suspendCoroutine
object gapiObj: client.AuthType { object GapiInitObj: client.AuthType {
override var apiKey: String? = ApiKey override var apiKey: String? = ApiKey
override var discoveryDocs: Array<String>? = arrayOf("https://sheets.googleapis.com/\$discovery/rest?version=v4") override var discoveryDocs: Array<String>? = arrayOf("https://sheets.googleapis.com/\$discovery/rest?version=v4")
} }
...@@ -122,14 +121,13 @@ private fun inited() { ...@@ -122,14 +121,13 @@ private fun inited() {
// Skip display of account chooser and consent dialog for an existing session. // Skip display of account chooser and consent dialog for an existing session.
tokenClient.requestAccessToken(js("{prompt: ''}")) tokenClient.requestAccessToken(js("{prompt: ''}"))
} }
Unit
} }
logOut = { logOut = {
val token = gapi.client.getToken() val token = gapi.client.getToken()
if (token !== null) { if (token !== null) {
google.accounts.oauth2.revoke(token.access_token); google.accounts.oauth2.revoke(token.access_token)
gapi.client.setToken(""); gapi.client.setToken("")
isSignedIn = false isSignedIn = false
} }
handleLoginEvent() handleLoginEvent()
...@@ -139,7 +137,7 @@ private fun inited() { ...@@ -139,7 +137,7 @@ private fun inited() {
} }
private suspend fun initGapi() = suspendCoroutine<Unit> { cont -> private suspend fun initGapi() = suspendCoroutine<Unit> { cont ->
gapi.client.init(gapiObj).then({ gapi.client.init(GapiInitObj).then({
gapiInited = true gapiInited = true
cont.resume(Unit) cont.resume(Unit)
}, { error -> }, { error ->
......
...@@ -12,7 +12,7 @@ object PekDelay { ...@@ -12,7 +12,7 @@ object PekDelay {
private val saveIconElem = document.getElementById("save-icon") as HTMLDivElement private val saveIconElem = document.getElementById("save-icon") as HTMLDivElement
private val isUpdating get() = saveIconElem.style.display == "block" private val isUpdating get() = saveIconElem.style.display == "block"
private val continuations = mutableListOf<Continuation<Unit>>() private val continuations = mutableSetOf<Continuation<Unit>>()
private var skips = 0 private var skips = 0
fun skipNext() { fun skipNext() {
...@@ -21,7 +21,7 @@ object PekDelay { ...@@ -21,7 +21,7 @@ object PekDelay {
private val observer = MutationObserver { _, _ -> private val observer = MutationObserver { _, _ ->
if (!isUpdating) { if (!isUpdating) {
val conts = continuations.toList() val conts = continuations.toSet()
conts.forEach { it.resume(Unit) } conts.forEach { it.resume(Unit) }
continuations.removeAll(conts) continuations.removeAll(conts)
} }
......
...@@ -7,14 +7,14 @@ import org.w3c.dom.HTMLInputElement ...@@ -7,14 +7,14 @@ import org.w3c.dom.HTMLInputElement
import org.w3c.dom.HTMLTextAreaElement import org.w3c.dom.HTMLTextAreaElement
object PekNote { object PekNote {
val noteNameCnt get() = document.querySelector("#comment-container > div.uk-padding.uk-text-center") private val noteNameCnt get() = document.querySelector("#comment-container > div.uk-padding.uk-text-center")
val noteName get() = noteNameCnt?.textContent private val noteName get() = noteNameCnt?.textContent
val editBtn get() = private val editBtn get() =
document.querySelectorAll("#comment-container > article.uk-comment > header.uk-comment-header > div.uk-comment-meta > a") document.querySelectorAll("#comment-container > article.uk-comment > header.uk-comment-header > div.uk-comment-meta > a")
.toList().lastOrNull() as? HTMLAnchorElement .toList().lastOrNull() as? HTMLAnchorElement
val noteCnt get() = document.getElementById("comment-textarea") as? HTMLTextAreaElement private val noteCnt get() = document.getElementById("comment-textarea") as? HTMLTextAreaElement
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 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
fun getNote() = noteCnt!!.value fun getNote() = noteCnt!!.value
suspend fun setNote(value: String) { suspend fun setNote(value: String) {
val edit = editBtn val edit = editBtn
......
package pekstuff package pekstuff
import kotlinx.browser.document import kotlinx.browser.document
import kotlinx.browser.window import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.* import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.w3c.dom.Element import org.w3c.dom.Element
import org.w3c.dom.HTMLInputElement import org.w3c.dom.HTMLInputElement
import org.w3c.dom.HTMLTableElement import org.w3c.dom.HTMLTableElement
......
import androidx.compose.runtime.* import androidx.compose.runtime.*
import gapi.loadAndInit import gapi.loadAndInit
import kotlinx.browser.document import kotlinx.browser.document
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.jetbrains.compose.web.attributes.disabled import org.jetbrains.compose.web.attributes.disabled
import org.jetbrains.compose.web.dom.Button import org.jetbrains.compose.web.dom.Button
......
...@@ -2,7 +2,6 @@ package processing ...@@ -2,7 +2,6 @@ package processing
import datasources.DataSource import datasources.DataSource
import datasources.NoteDataSource import datasources.NoteDataSource
import kotlinx.coroutines.delay
import pekstuff.PekDelay import pekstuff.PekDelay
import pekstuff.PekNote import pekstuff.PekNote
import pekstuff.PekTable import pekstuff.PekTable
...@@ -71,8 +70,8 @@ fun List<String>.findClosestMatch( ...@@ -71,8 +70,8 @@ fun List<String>.findClosestMatch(
val needleInHaystack = currParts.count { part -> string.contains(part) } val needleInHaystack = currParts.count { part -> string.contains(part) }
val haystackInNeedle = parts.count { part -> it.contains(part) } val haystackInNeedle = parts.count { part -> it.contains(part) }
it to when { it to when (it) {
it == string -> Int.MAX_VALUE string -> Int.MAX_VALUE
else -> max(needleInHaystack, haystackInNeedle) else -> max(needleInHaystack, haystackInNeedle)
} }
}.filter { it.second != 0 }.maxByOrNull { it.second }?.first }.filter { it.second != 0 }.maxByOrNull { it.second }?.first
......
...@@ -14,11 +14,12 @@ import org.jetbrains.compose.web.dom.* ...@@ -14,11 +14,12 @@ import org.jetbrains.compose.web.dom.*
import org.w3c.dom.HTMLElement import org.w3c.dom.HTMLElement
import processing.process import processing.process
private object csvModal: ModalType { private object CSVModal: ModalType {
override val title = "CSV import" override val title = "CSV import"
override val tutorial = "Válassz ki egy CSV filet, ami megfelel a következő követelményeknek:" override val tutorial = "Válassz ki egy CSV filet, ami megfelel a következő követelményeknek:"
override @Composable fun content( @Composable
override fun content(
closeId: String, closeId: String,
setState: (State) -> Unit, setState: (State) -> Unit,
hint: String, hint: String,
...@@ -79,5 +80,5 @@ private object csvModal: ModalType { ...@@ -79,5 +80,5 @@ private object csvModal: ModalType {
@Composable @Composable
fun csvModal(setState: (State) -> Unit) { fun csvModal(setState: (State) -> Unit) {
modal(csvModal, setState) modal(CSVModal, setState)
} }
\ No newline at end of file
...@@ -15,7 +15,8 @@ private object SheetsModal: ModalType { ...@@ -15,7 +15,8 @@ private object SheetsModal: ModalType {
override val title = "Google Sheets import" override val title = "Google Sheets import"
override val tutorial = "Jelentkezz be, majd illesz be egy linket egy Google Sheetre, ami megfelel a következő követelményeknek:" override val tutorial = "Jelentkezz be, majd illesz be egy linket egy Google Sheetre, ami megfelel a következő követelményeknek:"
override @Composable fun content( @Composable
override fun content(
closeId: String, closeId: String,
setState: (State) -> Unit, setState: (State) -> Unit,
hint: String, hint: String,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment