File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed
kotlin/com/fractalwrench/json2kotlin Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,6 @@ class ConversionController {
1919 @Autowired
2020 lateinit var conversionService: KotlinConversionService
2121
22-
23-
24-
2522 @GetMapping(" /" )
2623 fun displayConversionForm (model : Model ): String {
2724 if (! model.containsAttribute(formKey)) {
Original file line number Diff line number Diff line change 11package com.fractalwrench.json2kotlin
22
3+ import org.springframework.cache.annotation.Cacheable
34import org.springframework.stereotype.Service
45import java.io.ByteArrayInputStream
56import java.io.ByteArrayOutputStream
Original file line number Diff line number Diff line change @@ -35,15 +35,20 @@ <h1>Convert JSON to Kotlin Data Class</h1>
3535 </ div >
3636 < div class ="j2kcontainer " th:if ="${kotlin != null} ">
3737 < h2 id ="results "> Generated Kotlin</ h2 >
38- < pre > < code class =" language-kotlin hljs " th:text ="${kotlin} "> </ code > </ pre >
38+ < textarea id =" kotlinText " th:text ="${kotlin} "> </ textarea >
3939
4040 < form id ="downloadForm " action ="# " method ="post " onsubmit ="return validateForm() ">
41- < p > < input type ="button " value ="Copy to Clipboard "/> < input type ="button " value ="Download "/> </ p >
41+ < p >
42+ < input type ="button " value ="Copy to Clipboard "
43+ onclick ="copyToClipboard() " />
44+ < input type ="button " value ="Download "/>
45+ </ p >
4246 </ form >
4347 </ div >
4448 < div class ="j2kcontainer ">
4549 <!-- TODO -->
4650 </ div >
51+ </ div >
4752< footer >
4853 < div >
4954 < ul class ="list-inline ">
@@ -77,7 +82,11 @@ <h2 id="results">Generated Kotlin</h2>
7782 }
7883 }
7984
80-
85+ function copyToClipboard ( ) {
86+ var kotlinSource = document . getElementById ( "kotlinText" ) ;
87+ kotlinSource . select ( ) ;
88+ document . execCommand ( "Copy" ) ;
89+ }
8190</ script >
8291
8392< script src ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js "> </ script >
@@ -88,7 +97,6 @@ <h2 id="results">Generated Kotlin</h2>
8897window . location = '#results' ; // autoscroll to results
8998
9099</ script >
91-
92100</ body >
93101</ html >
94102<!-- TODO GA -->
You can’t perform that action at this time.
0 commit comments