Skip to content

Commit

Permalink
Create/Migrate launchDisqus function in pure JS
Browse files Browse the repository at this point in the history
  • Loading branch information
somnisomni committed Nov 25, 2022
1 parent 5a60894 commit 2e15275
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion assets/js/script.js

Large diffs are not rendered by default.

12 changes: 1 addition & 11 deletions post.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,7 @@
});
{{#if @custom.disqus_shortname}}
var disqus = '{{@custom.disqus_shortname}}';
function launchDisqus() {
$.ajax({
type: "GET",
url: "//" + disqus + ".disqus.com/embed.js",
dataType: "script",
cache: true
});
$(this).parent().addClass('activated');
}
launchDisqus();
launchDisqus("{{@custom.disqus_shortname}}");
{{/if}}
});
</script>
Expand Down
9 changes: 9 additions & 0 deletions src/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,12 @@
$ael(window, "resize", parallax);
$ael(window, "orientationchange", parallax);
})();

/* === Functions callable from outside === */
function launchDisqus(disqusShortname) {
const disqusScript = document.createElement("script");
disqusScript.src = `//${disqusShortname}.disqus.com/embed.js`;
disqusScript.async = true;
disqusScript.defer = true;
document.body.append(disqusScript);
}

0 comments on commit 2e15275

Please sign in to comment.