Skip to content

Commit

Permalink
Refactor termly code to its own helper, and tweak it to work in Vue e…
Browse files Browse the repository at this point in the history
…nvironment
  • Loading branch information
audiodude committed Jan 9, 2025
1 parent a243b51 commit 9395b43
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
10 changes: 10 additions & 0 deletions rainfall-frontend/src/helpers/termly.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export function embedTermly() {
(function (d, s, id) {
var js;
if (d.getElementById(id)) return;
js = d.createElement(s) as HTMLScriptElement;
js.id = id;
js.src = 'https://app.termly.io/embed-policy.min.js';
document.head.appendChild(js);
})(document, 'script', 'termly-jssdk');
}
18 changes: 8 additions & 10 deletions rainfall-frontend/src/views/CookiePolicyView.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<script type="text/javascript">
(function (d, s, id) {
var js,
tjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = 'https://app.termly.io/embed-policy.min.js';
tjs.parentNode.insertBefore(js, tjs);
})(document, 'script', 'termly-jssdk');
<script lang="ts">
import { embedTermly } from '@/helpers/termly';
export default {
created() {
embedTermly();
},
};
</script>

<template>
Expand Down
18 changes: 8 additions & 10 deletions rainfall-frontend/src/views/PrivacyPolicyView.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<script>
(function (d, s, id) {
var js,
tjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = 'https://app.termly.io/embed-policy.min.js';
tjs.parentNode.insertBefore(js, tjs);
})(document, 'script', 'termly-jssdk');
<script lang="ts">
import { embedTermly } from '@/helpers/termly';
export default {
created() {
embedTermly();
},
};
</script>

<template>
Expand Down
19 changes: 9 additions & 10 deletions rainfall-frontend/src/views/TermsOfUseView.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<script type="text/javascript">
(function (d, s, id) {
var js,
tjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = 'https://app.termly.io/embed-policy.min.js';
tjs.parentNode.insertBefore(js, tjs);
})(document, 'script', 'termly-jssdk');
<script lang="ts">
import { embedTermly } from '@/helpers/termly';
export default {
created() {
embedTermly();
},
};
</script>

<template>
<div class="bg-white">
<div name="termly-embed" data-id="8d548f55-b957-4759-a0aa-807d9934d6c1"></div>
Expand Down

0 comments on commit 9395b43

Please sign in to comment.