Post by Thesealion on Dec 5, 2012 20:20:30 GMT -8
Been working on this for far too long today Anyway this plugin is supposed to check a key if you're logged in and local storage if you're not. When logged in it works great and posts when the key is right. When logged out I can't get it to submit the post once it figures out the local storage is there...
Here is the code, but I'll also attach the plugin in case you anyone just wants to test it out themselves...
//check key
function lionRuleSystem_keycheck() {
var rulesstorage = localStorage.pbsrules;
var rules = proboards.plugin.key('rulesystem').get()
if (yootil.user.logged_in()) {
if (rules != "accepted") {
var d = confirm("Before browsing the site you must agree to rules.");
if (d == true) {
window.location = "/page/rules"
} else {
window.location = "/logout"
alert("You have been logged out.");
}
return false;
}
this.submit();
}
if (!yootil.user.logged_in()) {
if (rulesstorage != "Accept") {
var d = confirm("Before browsing the site you must agree to rules.");
if (d == true) {
window.location = "/page/rules"
} else {
window.location = "/logout"
alert("You have been logged out.");
}
return false;
}
this.submit();
}
}
//Check Key Before Posting
$(document).ready(function () {
//if (yootil.user.logged_in()) {
if (yootil.location.check.posting() || yootil.location.check.thread()) {
var the_form;
if (yootil.location.check.posting()) {
the_form = yootil.form.post_form();
} else if (yootil.location.check.thread()) {
the_form = yootil.form.post_quick_reply_form();
}
if (the_form.length) {
the_form.bind("validated", function (event) {
lionRuleSystem_keycheck();
});
}
}
//}
//Update Key after reading rules
if (location.href.match(/\/lionrules/) && document.referrer.match(/page\/rules/)) {
proboards.plugin.key('rulesystem').set('accepted');
localStorage.pbsrules="Accept";
alert('Thank you for agreeing to the rules. You may now post on the forum.');
}
});
Here is the code, but I'll also attach the plugin in case you anyone just wants to test it out themselves...
//check key
function lionRuleSystem_keycheck() {
var rulesstorage = localStorage.pbsrules;
var rules = proboards.plugin.key('rulesystem').get()
if (yootil.user.logged_in()) {
if (rules != "accepted") {
var d = confirm("Before browsing the site you must agree to rules.");
if (d == true) {
window.location = "/page/rules"
} else {
window.location = "/logout"
alert("You have been logged out.");
}
return false;
}
this.submit();
}
if (!yootil.user.logged_in()) {
if (rulesstorage != "Accept") {
var d = confirm("Before browsing the site you must agree to rules.");
if (d == true) {
window.location = "/page/rules"
} else {
window.location = "/logout"
alert("You have been logged out.");
}
return false;
}
this.submit();
}
}
//Check Key Before Posting
$(document).ready(function () {
//if (yootil.user.logged_in()) {
if (yootil.location.check.posting() || yootil.location.check.thread()) {
var the_form;
if (yootil.location.check.posting()) {
the_form = yootil.form.post_form();
} else if (yootil.location.check.thread()) {
the_form = yootil.form.post_quick_reply_form();
}
if (the_form.length) {
the_form.bind("validated", function (event) {
lionRuleSystem_keycheck();
});
}
}
//}
//Update Key after reading rules
if (location.href.match(/\/lionrules/) && document.referrer.match(/page\/rules/)) {
proboards.plugin.key('rulesystem').set('accepted');
localStorage.pbsrules="Accept";
alert('Thank you for agreeing to the rules. You may now post on the forum.');
}
});