From d550abed22f9c2f0c2d521a47a9105096d129e8b Mon Sep 17 00:00:00 2001 From: Milosz Kwiatkowski Date: Sun, 21 Aug 2016 14:29:11 +0100 Subject: [PATCH] add random captchas and remove redundant code --- js/rules-popup.js | 61 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/js/rules-popup.js b/js/rules-popup.js index 5f1b5615..1702ff68 100644 --- a/js/rules-popup.js +++ b/js/rules-popup.js @@ -12,40 +12,41 @@ * */ -$(function() { - if (typeof localStorage.rulesAccepted === "undefined") + function(c) { - var d = $("
").prependTo("body").width("80%").height("80%") - .css("z-index", 9999).css("position", "fixed") - .css("top", "50%").css("bottom", 0).css("left", "50%").css("right", 0) - .css("margin-top", "-40vh").css("margin-left", "-40%") - .css("background", "black") - .css("text-align", "center").css("font-family", "sans-serif") - .css("font-size", "14px").css("color", "white") +if (typeof localStorage.rulesAccepted === "undefined") { - d.html("" + + // generate a 7-character long random string + captcha = Math.random().toString(36).substring(2, 9) - "
lainchan rule agreement
" + + var d = $("
").prependTo("body").width("80%").height("80%") + .css("z-index", 9999).css("position", "fixed") + .css("top", "50%").css("bottom", 0).css("left", "50%").css("right", 0) + .css("margin-top", "-40vh").css("margin-left", "-40%") + .css("background", "black") + .css("text-align", "center").css("font-family", "sans-serif") + .css("font-size", "14px").css("color", "white") - "
" + - "
" + - "
" + - "
" + + d.html("" + - "
" + - "
If you accept the rules, retype the captcha and press ACCEPT.
" + - "
" + c + "
" + - "
" + - "" + - "" + - "
" + - "
" + - "
" + + "
lainchan rule agreement
" + - ""); + "
" + + "
" + + "
" + + "
" + - $("#rules-actual").load("/templates/rules.html"); + "
" + + "
If you accept the rules, retype the captcha and press ACCEPT.
" + + "
" + captcha + "
" + + "
" + + "" + + "" + + "
" + + "
" + + "
" + - }("faggotry1234"); -}); + ""); + + $("#rules-actual").load("rules.html"); +}