diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 23b3720d08..4c4db4c133 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -8,5 +8,6 @@ - [URL Routing](routing.md) - [CSS & Style](style.md) - [Components](components.md) +- [JavaScript Interop](js.md) - [Integrations](integrations.md) - [Frequently Asked Questions](faq.md) diff --git a/docs/src/js.md b/docs/src/js.md new file mode 100644 index 0000000000..f1b2c58d3f --- /dev/null +++ b/docs/src/js.md @@ -0,0 +1,6 @@ +# JavaScript Interop + +While Kweb speaks Kotlin to you, it speaks JavaScript to the browser. Kweb's DOM interaction functionality is +build on top of two functions, [Element.callJsFunction()](https://docs.kweb.io/api/kweb-core/kweb/-element/call-js-function.html), +and [Element.callJsFunctionWithResult()](https://docs.kweb.io/api/kweb-core/kweb/-element/call-js-function-with-result.html). + diff --git a/src/main/kotlin/kweb/Kweb.kt b/src/main/kotlin/kweb/Kweb.kt index 7fe605fb32..85f3c416e6 100755 --- a/src/main/kotlin/kweb/Kweb.kt +++ b/src/main/kotlin/kweb/Kweb.kt @@ -47,7 +47,7 @@ class Kweb private constructor( // This StaticFilesPlugin is used to serve static files required by Kweb and bundled plugins, it's // added to the plugin list implicitly. - val plugins = plugins + StaticFilesPlugin(ResourceFolder("kweb.static"), "/static") + val plugins = plugins + StaticFilesPlugin(ResourceFolder("kweb.static"), "/kweb_static") /** * diff --git a/src/main/kotlin/kweb/html/HtmlDocumentSupplier.kt b/src/main/kotlin/kweb/html/HtmlDocumentSupplier.kt index b9183ff152..368b2a12f3 100644 --- a/src/main/kotlin/kweb/html/HtmlDocumentSupplier.kt +++ b/src/main/kotlin/kweb/html/HtmlDocumentSupplier.kt @@ -41,7 +41,7 @@ internal object HtmlDocumentSupplier { head.appendElement("link") .attr("rel", "stylesheet") - .attr("href", "/static/toastify/toastify.min.css") + .attr("href", "/kweb_static/toastify/toastify.min.css") } html.appendElement("body").let { body: Element -> @@ -55,7 +55,7 @@ internal object HtmlDocumentSupplier { | This page is built with Kweb, which | requires JavaScript to be enabled.""".trimMargin()) body.appendElement("script") - .attr("src", "/static/toastify/toastify.js") + .attr("src", "/kweb_static/toastify/toastify.js") } } diff --git a/src/main/kotlin/kweb/plugins/fomanticUI/FomanticUIPlugin.kt b/src/main/kotlin/kweb/plugins/fomanticUI/FomanticUIPlugin.kt index fae9520565..adb84d5ca6 100755 --- a/src/main/kotlin/kweb/plugins/fomanticUI/FomanticUIPlugin.kt +++ b/src/main/kotlin/kweb/plugins/fomanticUI/FomanticUIPlugin.kt @@ -18,10 +18,10 @@ class FomanticUIPlugin : KwebPlugin(dependsOn = setOf(jqueryCore) doc.head().appendElement("link") .attr("rel", "stylesheet") .attr("type", "text/css") - .attr("href", "/static/plugins/fomantic/semantic.min.css") + .attr("href", "/kweb_static/plugins/fomantic/semantic.min.css") doc.head().appendElement("script") - .attr("src", "/static/plugins/fomantic/semantic.min.js") + .attr("src", "/kweb_static/plugins/fomantic/semantic.min.js") } diff --git a/src/main/kotlin/kweb/plugins/jqueryCore/JQueryCorePlugin.kt b/src/main/kotlin/kweb/plugins/jqueryCore/JQueryCorePlugin.kt index 43d0bdb0d3..db0a601eb9 100755 --- a/src/main/kotlin/kweb/plugins/jqueryCore/JQueryCorePlugin.kt +++ b/src/main/kotlin/kweb/plugins/jqueryCore/JQueryCorePlugin.kt @@ -12,7 +12,7 @@ import org.jsoup.nodes.Document class JQueryCorePlugin : KwebPlugin() { override fun decorate(doc: Document) { doc.head().appendElement("script") - .attr("src", "/static/plugins/jquery/jquery-3.4.1.min.js") + .attr("src", "/kweb_static/plugins/jquery/jquery-3.4.1.min.js") .attr("crossorigin", "anonymous") } }