kotlinjs build improvement
test post fetch for index
This commit is contained in:
1 parent
16939c7b6a
commit
af321c8aad
11 files changed
+52
-15
No files matched your search
+3
-10
@@ -24,13 +24,13 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileKotlin2Js {
|
compileKotlin2Js {
|
||||||
kotlinOptions.outputFile = "${projectDir}/web/lib/WasteInformationServer.js"
|
kotlinOptions.outputFile = "${projectDir}/build/web/WasteInformationServer.js"
|
||||||
kotlinOptions.moduleKind = "amd"
|
kotlinOptions.moduleKind = "plain"
|
||||||
kotlinOptions.sourceMap = true
|
kotlinOptions.sourceMap = true
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTestKotlin2Js {
|
compileTestKotlin2Js {
|
||||||
kotlinOptions.moduleKind = "amd"
|
kotlinOptions.moduleKind = "plain"
|
||||||
kotlinOptions.sourceMap = true
|
kotlinOptions.sourceMap = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,11 +91,4 @@ build.doLast() {
|
|||||||
from new File("build/classes/test")
|
from new File("build/classes/test")
|
||||||
into "${web_dir}/lib"
|
into "${web_dir}/lib"
|
||||||
}
|
}
|
||||||
|
|
||||||
copy {
|
|
||||||
includeEmptyDirs = false
|
|
||||||
from new File("build/resources/test")
|
|
||||||
into "${web_dir}"
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,33 @@
|
|||||||
|
import org.w3c.dom.HTMLInputElement
|
||||||
|
import org.w3c.fetch.RequestInit
|
||||||
|
import org.w3c.xhr.XMLHttpRequest
|
||||||
|
import kotlin.browser.document
|
||||||
|
import kotlin.browser.window
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
println("success execute main")
|
val callurl = window.document.URL
|
||||||
|
if(callurl.contains("sec.html")){
|
||||||
|
document.write("Hello, in document 2!")
|
||||||
|
}else {
|
||||||
|
window.onload = {
|
||||||
|
println("loaded sucessfully")
|
||||||
|
document.getElementById("loginbtn")?.addEventListener("click",{
|
||||||
|
it.preventDefault()
|
||||||
|
println("clicked!!!")
|
||||||
|
|
||||||
|
val username = document.getElementById("userfield") as HTMLInputElement
|
||||||
|
val passfield = document.getElementById("passfield") as HTMLInputElement
|
||||||
|
println(username.value)
|
||||||
|
|
||||||
|
console.log("fetch 'data.json' with 'post'")
|
||||||
|
window.fetch("/senddata/loginget", RequestInit(method = "POST", body = "username=${username.value}&password=${passfield.value}")).then {
|
||||||
|
it.text().then { println(it) }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
document.write("Hello, world!")
|
||||||
|
|
||||||
|
val req = Requester()
|
||||||
|
req.request()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import org.w3c.xhr.XMLHttpRequest
|
||||||
|
|
||||||
|
class Requester {
|
||||||
|
fun request(){
|
||||||
|
val test = XMLHttpRequest()
|
||||||
|
|
||||||
|
test.open("GET","https://api.ipify.org?format=json")
|
||||||
|
|
||||||
|
test.onload = {
|
||||||
|
println(test.responseText)
|
||||||
|
}
|
||||||
|
|
||||||
|
test.send()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,18 +24,17 @@
|
|||||||
<!--Custom styles-->
|
<!--Custom styles-->
|
||||||
<link rel="stylesheet" type="text/css" href="css/index.css">
|
<link rel="stylesheet" type="text/css" href="css/index.css">
|
||||||
|
|
||||||
<script type="text/javascript" src="js/index.js"></script>
|
|
||||||
|
|
||||||
<script src="lib/AdminLTE/plugins/sweetalert2/sweetalert2.all.js"></script>
|
<script src="lib/AdminLTE/plugins/sweetalert2/sweetalert2.all.js"></script>
|
||||||
|
|
||||||
<link rel="manifest" href="/manifest.json">
|
<link rel="manifest" href="/manifest.json">
|
||||||
|
|
||||||
<link rel="icon" type="image/png" href="/favicon.png">
|
<link rel="icon" type="image/png" href="/favicon.png">
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<script type="text/javascript" src="js/lib/kotlin.js"></script>
|
<script type="text/javascript" src="js/lib/kotlin.js"></script>
|
||||||
<script type="text/javascript" src="js/WasteInformationServer.js"></script>
|
<script type="text/javascript" src="js/WasteInformationServer.js"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="d-flex justify-content-center h-100">
|
<div class="d-flex justify-content-center h-100">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user