aboutsummaryrefslogtreecommitdiff
path: root/app/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/controllers/thing_controller.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/javascript/controllers/thing_controller.js b/app/javascript/controllers/thing_controller.js
new file mode 100644
index 0000000..1518216
--- /dev/null
+++ b/app/javascript/controllers/thing_controller.js
@@ -0,0 +1,17 @@
+import { Controller } from "@hotwired/stimulus"
+
+// Gathers all the methods that are relevant when manipulating things.
+export default class extends Controller {
+ // Update the external link depending on the changed value. The link will also
+ // be hidden/shown depending if the current URL is empty or not.
+ updateLink() {
+ let cur = document.getElementById("thing_url").value.trim();
+
+ if (cur === "") {
+ document.getElementById("thing-external-url-id").classList.add('hidden');
+ } else {
+ document.getElementById("thing-external-url-id").classList.remove('hidden');
+ document.getElementById("thing-external-url-id").href = cur;
+ }
+ }
+}