diff options
Diffstat (limited to 'static/js/single-text-align.js')
-rw-r--r-- | static/js/single-text-align.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/static/js/single-text-align.js b/static/js/single-text-align.js new file mode 100644 index 0000000..bdcc15e --- /dev/null +++ b/static/js/single-text-align.js @@ -0,0 +1,19 @@ +// Wait for the page to load first +window.onload = function() { + + //Get a reference to the link on the page + var aLeft = document.getElementById("alignLeft"); + var aJustify = document.getElementById("alignJustify"); + + //Set code to run when the link is clicked + aJustify.onclick = function() { + if (document.getElementById("article-body").className.match(/(?:^|\s)article-body-left(?!\S)/) ) { + document.getElementById("article-body").className = document.getElementById("article-body").className.replace( /(?:^|\s)article-body-left(?!\S)/g , '' ) + } + } + aLeft.onclick = function() { + if (!document.getElementById("article-body").className.match(/(?:^|\s)article-body-left(?!\S)/) ) { + document.getElementById("article-body").className += "article-body-left"; + } + } +} |