The version of vichan running on lainchan.org
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.

45 lines
1.7KB

  1. /*
  2. * rules-popup.js
  3. * https://github.com/mkwia/lainchan/js/rules-popup.js
  4. *
  5. * Forces user to accept rules from /templates/rules.html on first welcome
  6. *
  7. * 2016 mkwia <github.com/mkwia>
  8. *
  9. * Usage:
  10. * $config['additional_javascript'][] = 'js/jquery.min.js';
  11. * $config['additional_javascript'][] = 'js/rules-popup.js';
  12. *
  13. */
  14. $(window).ready(function() {
  15. if (typeof localStorage.rulesAccepted === "undefined") {
  16. // generate a 7-character long random string
  17. captcha = Math.random().toString(36).substring(2, 9)
  18. $("body")
  19. .prepend("<div id='rules-popup'>");
  20. $("#rules-popup")
  21. .append("<div class='rules-popup-top'>lainchan rule agreement</div>")
  22. .append("<div class='rules-popup-content-wrapper'></div>")
  23. .append("<div class='rules-popup-bottom'></div>");
  24. $(".rules-popup-content-wrapper")
  25. .append("<div id='rules-popup-content'></div>");
  26. $("#rules-popup-content")
  27. .load("/templates/rules.html");
  28. $(".rules-popup-bottom")
  29. .append("<div class='rules-popup-bottom-instructions'>If you accept the rules, retype the captcha and press ACCEPT.</div>")
  30. .append("<div class='rules-popup-captcha-wrapper'></div>");
  31. $(".rules-popup-captcha-wrapper")
  32. .append("<div class='rules-popup-captcha'>" + captcha + "</div>")
  33. .append("<form class='rules-popup-form' onsubmit=\"if ($('#captcha').val() == '" + captcha + "') { localStorage.rulesAccepted = 1; $('#rules-popup').remove(); } return false;\"></form>");
  34. $(".rules-popup-form")
  35. .append("<input class='rules-popup-form-input' type='text' id='captcha' />")
  36. .append("<input type='submit' value='ACCEPT' />");
  37. }
  38. })