You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
991 B

  1. console.log("Favoriting URL: <?= $this->url ?>");
  2. var css = document.createElement('link');
  3. css.rel="stylesheet";
  4. css.type="text/css";
  5. css.href="<?= Config::$base_url ?>css/favorite.css";
  6. document.body.appendChild(css);
  7. function show_star() {
  8. var star = document.createElement('img');
  9. star.id="quill-star";
  10. star.src="<?= Config::$base_url ?>images/<?= $this->like_url ? 'star' : 'red-x' ?>.svg";
  11. star.onload=function() {
  12. setTimeout(function(){
  13. document.getElementById('quill-star').classList.add('hidden');
  14. var el = document.getElementById('quill-star');
  15. el.parentNode.removeChild(el);
  16. if(typeof favorite_finished == "function") {
  17. favorite_finished();
  18. } else {
  19. // For now, redirect the user to the URL of their favorite so they can see it posted.
  20. // Might want to change this later.
  21. window.location = "<?= $this->like_url ?>";
  22. }
  23. }, 1200);
  24. }
  25. document.body.appendChild(star);
  26. }
  27. show_star();