Browse Source

add random captchas and remove redundant code

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

17
js/rules-popup.js

@ -12,8 +12,11 @@
*
*/
$(function() {
if (typeof localStorage.rulesAccepted === "undefined") + function(c) {
if (typeof localStorage.rulesAccepted === "undefined") {
// generate a 7-character long random string
captcha = Math.random().toString(36).substring(2, 9)
var d = $("<div id='rules'>").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)
@ -34,8 +37,8 @@ $(function() {
"<div style='bottom: 0px; height: 80px; width: 100%; position: absolute;'>" +
"<div style='line-height: 40px;'>If you accept the rules, retype the captcha and press ACCEPT.</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='height: 40px;'><div style='display: inline-block; border: 1px solid white; font-family: serif; padding: 3px;'>" + captcha + "</div>" +
"<form onsubmit=\"if ($('#captcha').val() == '" + captcha + "') { localStorage.rulesAccepted = 1; $('#rules').remove(); } return false;\"" +
" style='display: inline-block;'>" +
"<input type='text' id='captcha' style='width: 100px;' />" +
"<input type='submit' value='ACCEPT' />" +
@ -45,7 +48,5 @@ $(function() {
"");
$("#rules-actual").load("/templates/rules.html");
}("faggotry1234");
});
$("#rules-actual").load("rules.html");
}

Loading…
Cancel
Save