Skip to content

Commit f17fc96

Browse files
committed
copy to clipboard
1 parent 5832265 commit f17fc96

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

spring/src/main/kotlin/com/fractalwrench/json2kotlin/ConversionController.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff 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)) {

spring/src/main/kotlin/com/fractalwrench/json2kotlin/KotlinConversionService.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.fractalwrench.json2kotlin
22

3+
import org.springframework.cache.annotation.Cacheable
34
import org.springframework.stereotype.Service
45
import java.io.ByteArrayInputStream
56
import java.io.ByteArrayOutputStream

spring/src/main/resources/templates/conversion.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff 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>
8897
window.location = '#results'; // autoscroll to results
8998

9099
</script>
91-
92100
</body>
93101
</html>
94102
<!-- TODO GA -->

0 commit comments

Comments
 (0)