Browse Source

add random captchas and remove redundant code

pull/40/head
Milosz Kwiatkowski 8 years ago
parent
commit
d550abed22
  1. 75
      js/rules-popup.js

75
js/rules-popup.js

@ -12,40 +12,41 @@
* *
*/ */
$(function() { if (typeof localStorage.rulesAccepted === "undefined") {
if (typeof localStorage.rulesAccepted === "undefined") + function(c) {
var d = $("<div id='rules'>").prependTo("body").width("80%").height("80%") // generate a 7-character long random string
.css("z-index", 9999).css("position", "fixed") captcha = Math.random().toString(36).substring(2, 9)
.css("top", "50%").css("bottom", 0).css("left", "50%").css("right", 0)
.css("margin-top", "-40vh").css("margin-left", "-40%") var d = $("<div id='rules'>").prependTo("body").width("80%").height("80%")
.css("background", "black") .css("z-index", 9999).css("position", "fixed")
.css("text-align", "center").css("font-family", "sans-serif") .css("top", "50%").css("bottom", 0).css("left", "50%").css("right", 0)
.css("font-size", "14px").css("color", "white") .css("margin-top", "-40vh").css("margin-left", "-40%")
.css("background", "black")
d.html("" + .css("text-align", "center").css("font-family", "sans-serif")
.css("font-size", "14px").css("color", "white")
"<div style='font-size: 40px; line-height: 60px; position: absolute; top: 0px; height: 60px; width: 100%;'>lainchan rule agreement</div>" +
d.html("" +
"<div style='text-align: left; position: absolute; bottom: 80px; top: 60px;" +
"width: 100%; background-color: #ddd; overflow: auto; font-family: serif; color: #444;'>" + "<div style='font-size: 40px; line-height: 60px; position: absolute; top: 0px; height: 60px; width: 100%;'>lainchan rule agreement</div>" +
"<div style='padding: 10px; font-size: 12px;' id='rules-actual'>" +
"</div>" + "<div style='text-align: left; position: absolute; bottom: 80px; top: 60px;" +
"</div>" + "width: 100%; background-color: #ddd; overflow: auto; font-family: serif; color: #444;'>" +
"<div style='padding: 10px; font-size: 12px;' id='rules-actual'>" +
"<div style='bottom: 0px; height: 80px; width: 100%; position: absolute;'>" + "</div>" +
"<div style='line-height: 40px;'>If you accept the rules, retype the captcha and press ACCEPT.</div>" + "</div>" +
"<div style='height: 40px;'><div style='display: inline-block; border: 1px solid white; font-family: serif; padding: 3px;'>" + c + "</div>" +
"<form onsubmit=\"if ($('#captcha').val() == '" + c + "') { localStorage.rulesAccepted = 1; $('#rules').remove(); } return false;\"" + "<div style='bottom: 0px; height: 80px; width: 100%; position: absolute;'>" +
" style='display: inline-block;'>" + "<div style='line-height: 40px;'>If you accept the rules, retype the captcha and press ACCEPT.</div>" +
"<input type='text' id='captcha' style='width: 100px;' />" + "<div style='height: 40px;'><div style='display: inline-block; border: 1px solid white; font-family: serif; padding: 3px;'>" + captcha + "</div>" +
"<input type='submit' value='ACCEPT' />" + "<form onsubmit=\"if ($('#captcha').val() == '" + captcha + "') { localStorage.rulesAccepted = 1; $('#rules').remove(); } return false;\"" +
"</form>" + " style='display: inline-block;'>" +
"</div>" + "<input type='text' id='captcha' style='width: 100px;' />" +
"</div>" + "<input type='submit' value='ACCEPT' />" +
"</form>" +
""); "</div>" +
"</div>" +
$("#rules-actual").load("/templates/rules.html");
"");
}("faggotry1234");
}); $("#rules-actual").load("rules.html");
}

Loading…
Cancel
Save