diff options
| author | Michael Walker <mike@barrucadu.co.uk> | 2016-08-21 20:01:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-21 20:01:10 +0100 |
| commit | 1b7a081e59a98f422610d72027ffc4296770dc6b (patch) | |
| tree | 249d1792c871a02e4159259b092cca252877d560 /js | |
| parent | fd9f51dda6bdaf63609256b30b252a0374e83e0e (diff) | |
| parent | 315c376976bafb3a08efec9783c744e80914306d (diff) | |
Merge pull request #61 from mkwia/rules-agreement-page
add rules agreement page
Diffstat (limited to 'js')
| -rw-r--r-- | js/rules-popup.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/js/rules-popup.js b/js/rules-popup.js new file mode 100644 index 00000000..515c5b71 --- /dev/null +++ b/js/rules-popup.js @@ -0,0 +1,42 @@ +/* + * rules-popup.js + * https://github.com/mkwia/lainchan/js/rules-popup.js + * + * Forces user to accept rules from /templates/rules.html on first welcome + * + * 2016 mkwia <github.com/mkwia> + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/rules-popup.js'; + * + */ + +if (typeof localStorage.rulesAccepted === "undefined") { + + // generate a 7-character long random string + captcha = Math.random().toString(36).substring(2, 9) + + $("<div id='rules-popup'>") + .prependTo("body"); + + $("#rules-popup") + .append("<div class='rules-popup-top'>lainchan rule agreement</div>") + .append("<div class='rules-popup-content-wrapper'></div>") + .append("<div class='rules-popup-bottom'></div>"); + + $(".rules-popup-content-wrapper") + .append("<div id='rules-popup-content'></div>"); + $("#rules-popup-content") + .load("/templates/rules.html"); + + $(".rules-popup-bottom") + .append("<div class='rules-popup-bottom-instructions'>If you accept the rules, retype the captcha and press ACCEPT.</div>") + .append("<div class='rules-popup-captcha-wrapper'></div>"); + $(".rules-popup-captcha-wrapper") + .append("<div class='rules-popup-captcha'>" + captcha + "</div>") + .append("<form class='rules-popup-form' onsubmit=\"if ($('#captcha').val() == '" + captcha + "') { localStorage.rulesAccepted = 1; $('#rules-popup').remove(); } return false;\"></form>"); + $(".rules-popup-form") + .append("<input class='rules-popup-form-input' type='text' id='captcha' />") + .append("<input type='submit' value='ACCEPT' />"); +}
\ No newline at end of file |
