Post by Sirie on Mar 30, 2009 23:12:41 GMT -8
This code.
Is there any particular reason why this edited version of the code is not working? I placed it in the board footer, both with the use of the hack manager and without, and it still didn't work. Since I'm clueless when it comes to JavaScript, I was hoping one of your guys could see if I messed something up editing it..or if you can think of another reason it doesn't work.
Thanks.
p.s - I use the newest version of FF.
Is there any particular reason why this edited version of the code is not working? I placed it in the board footer, both with the use of the hack manager and without, and it still didn't work. Since I'm clueless when it comes to JavaScript, I was hoping one of your guys could see if I messed something up editing it..or if you can think of another reason it doesn't work.
<script type="text/javascript">
<!--
/* Predefined Posting Template/Form
Created by Ross of PBS
Please do not repost outside of PBS without permission */
var _title = 'Shinobi';
var _description = 'Please ensure you have a read of the <a href="http://www.naruto-tc.proboards.com/index.cgi?action=display&board=shinobi&thread=10">Rules</a> before posting';
var _fields = new Array(); var _f = 0;
_fields[_f++] = new Array('input', 'Name:', ['size', 40, 'maxLength', 50], '', 'Please provide your character's full name here. No nicknames.', true);
_fields[_f++] = new Array('select', 'Gender:', [], ['Male', 'Female'], 'Please select a gender for your character', true);
_fields[_f++] = new Array('input', 'Age:', ['size', 40, 'maxLength', 50], '', 'Please list your character's age. Everyone has one.', true);
_fields[_f++] = new Array('input', 'Village:', ['size', 40, 'maxLength', 50], 'Default Value filled in when the form loads. Can be left blank', 'A short description of what the field is for', false);
_fields[_f++] = new Array('select', 'Rank', [], ['Student', 'Genin', 'Chunin', 'Jounin', 'Sennin', 'Rogue', 'Hunter', 'Medic', true);
_fields[_f++] = new Array('textarea', 'History:', ['cols', 40, 'rows', 20], '', 'Please list your character's full life history here. It must be in 3rd person biography format!', true);
_fields[_f++] = new Array('textarea', 'Appearance:', ['cols', 40, 'rows', 10], '', 'Please describe what your character looks like or provide a picture LINK.', true);
_fields[_f++] = new Array('textarea', 'Personality:', ['cols', 40, 'rows', 10], '', 'Please describe your character's personality.', true);
_fields[_f++] = new Array('select', 'Chakra Element 1:', [], ['Fire', 'Water', 'Lightning', 'Wind', 'Earth', 'None'], 'Please list your character's chakra element.', true);
_fields[_f++] = new Array('select', 'Chakra Element 2:', [], ['Fire', 'Water', 'Lightning', 'Wind', 'Earth', 'None'], 'Please list your character's second chakra element if he/she is chunin or above.', true);
_fields[_f++] = new Array('select', 'Chakra Element 3:', [], ['Fire', 'Water', 'Lightning', 'Wind', 'Earth', 'None'], 'Please list your character's third chakra element if he/she is jounin or above.', true);
_fields[_f++] = new Array('select', 'Chakra Element 4:', [], ['Fire', 'Water', 'Lightning', 'Wind', 'Earth', 'None'], 'Please list your character's fourth chakra element if he/she is jounin or above.', true);
_fields[_f++] = new Array('select', 'Chakra Element 5:', [], ['Fire', 'Water', 'Lightning', 'Wind', 'Earth', 'None'], 'Please list your character's fifth chakra element if he/she is jounin or above.', true);
_fields[_f++] = new Array('textarea', 'Clan:', ['cols', 40, 'rows', 10], '', 'Please describe or name your character's clan here. It CAN be left blank.', false);
_fields[_f++] = new Array('textarea', 'Jutsu/Items:', ['cols', 40, 'rows', 10], 'N/A', 'Please link to your character's jutsu and item templates here. You can leave this blank and modify it later.', false);
var _widths = ['100%', '20%', '40%', '40%'];
var _posting_form = {
errors: new Array(),
init: function() {
this.create_form();
},
create_form: function() {
// Create new post layout
var _holder = document.createElement('table');
_holder.setAttribute('className', 'bordercolor');
_holder.setAttribute('class', 'bordercolor');
_holder.setAttribute('cellSpacing','1');
_holder.setAttribute('cellPadding', '4');
_holder.setAttribute('align', 'center');
_holder.setAttribute('width', _widths[0]);
_holder.setAttribute('id', 'post_form_holder');
_holder.appendChild(document.createElement('tbody'));
_holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
_holder.firstChild.lastChild.lastChild.className = 'titlebg';
_holder.firstChild.lastChild.lastChild.colSpan = '3';
_holder.firstChild.lastChild.lastChild.lastChild.size = '2';
_holder.firstChild.lastChild.lastChild.lastChild.appendChild(document.createTextNode(_title));
if(_description) {
_holder.firstChild.appendChild( document.createElement('tr') ).appendChild( document.createElement('td') ).appendChild( document.createElement('font') );
_holder.firstChild.lastChild.lastChild.setAttribute('className', 'windowbg');
_holder.firstChild.lastChild.lastChild.setAttribute('class', 'windowbg');
_holder.firstChild.lastChild.lastChild.setAttribute('colSpan', '3');
_holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
_holder.firstChild.lastChild.lastChild.lastChild.innerHTML = _description;
}
for(_f=0; _f<_fields.length; _f++) {
switch(_fields[_f][0]) {
case 'textarea' :
var _tmp = document.createElement('textarea');
break;
case 'select' :
var _tmp = document.createElement('select');
for(_o=0; _o<_fields[_f][3].length; _o++) {
_tmp.options[_o] = new Option(_fields[_f][3][_o], _fields[_f][3][_o]);
}
break;
default :
var _tmp = document.createElement('input');
_tmp.type = 'text';
if("undefined" != typeof _fields[_f][3] && _fields[_f][3] != "")
_tmp.setAttribute('value', _fields[_f][3]);
break;
}
_tmp.setAttribute('id', _f);
if("undefined" != typeof _fields[_f][2] && _fields[_f][2].length > 0) {
for(_a=0; _a<_fields[_f][2].length; _a++) {
_tmp.setAttribute(_fields[_f][2][_a++], _fields[_f][2][_a]);
}
}
var _class = 'windowbg' + ((_f % 2 == 0)? '2' : '');
var _row = document.createElement('tr');
_row.appendChild(document.createElement('td'));
_row.lastChild.setAttribute('class', _class);
_row.lastChild.setAttribute('className', _class);
_row.lastChild.setAttribute('vAlign', 'top');
_row.lastChild.setAttribute('width', _widths[1]);
_row.lastChild.appendChild(document.createElement('font'));
_row.lastChild.lastChild.setAttribute('size', '2');
_row.lastChild.lastChild.style.fontWeight = 'bold';
_row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][1] + ':'));
_row.appendChild(document.createElement('td'));
_row.lastChild.setAttribute('class', _class);
_row.lastChild.setAttribute('className', _class);
_row.lastChild.setAttribute('width', _widths[2]);
_row.lastChild.appendChild(document.createElement('font'));
_row.lastChild.lastChild.setAttribute('size', '2');
_row.lastChild.lastChild.appendChild(_tmp);
_row.appendChild(document.createElement('td'));
_row.lastChild.setAttribute('class', _class);
_row.lastChild.setAttribute('className', _class);
_row.lastChild.setAttribute('vAlign', 'top');
_row.lastChild.setAttribute('width', _widths[3]);
_row.lastChild.appendChild(document.createElement('font'));
_row.lastChild.lastChild.size = '1';
_row.lastChild.lastChild.appendChild(document.createTextNode(_fields[_f][4]));
_holder.firstChild.appendChild(_row);
}
var _submit = document.createElement('tr');
_submit.appendChild(document.createElement('td'));
_submit.lastChild.setAttribute('class', 'windowbg' + (((_f+1) % 2 == 0)? '' : '2'));
_submit.lastChild.setAttribute('className', 'windowbg' + (((_f+1) % 2 == 0)? '' : '2'));
_submit.lastChild.setAttribute('align', 'center');
_submit.lastChild.setAttribute('colSpan', 3);
var _button = document.createElement('input');
_button.setAttribute('type', 'button');
_button.setAttribute('value', 'Post Message');
_button.onclick = function() { _posting_form.post_it(); };
_submit.lastChild.appendChild(_button);
_holder.firstChild.appendChild(_submit);
var _tables = document.getElementsByTagName('table');
for(_t=0; _t<_tables.length; _t++) {
if(_tables.item(_t).cellPadding == '0' && _tables.item(_t).className == 'bordercolor' && _tables.item(_t).firstChild.nodeName.toLowerCase() == 'form') {
_tables.item(_t).style.display = 'none';
_tables.item(_t).parentNode.insertBefore(_holder, _tables.item(_t));
break;
}
}
},
post_it: function() {
// create message and attempt to post it
this.errors = new Array();
document.postForm.message.value = document.postForm.subject.value = '';
var _sub = document.getElementById('0').value;
_fields[0][5] = true;
document.postForm.subject.value = _sub;
for(_f=0; _f<_fields.length; _f++) {
if(document.getElementById(_f)) {
_value = document.getElementById(_f).value;
if(!_value || _value.match(/^\s*$/)) {
if(_f > 0 && _fields[_f][5])
this.show_error('You have left the ' + _fields[_f][1] + ' option empty. This is a required field and as such must contain a value.');
else
_value = '[i]None[/i]';
}
document.postForm.message.value += '[b]' + _fields[_f][1] + ':[/b] ' + _value + '\n\n';
}
}
if(this.errors.length == 0)
document.postForm.submit(true);
else
this.show_error();
},
show_error: function() {
if("undefined" != typeof arguments[0] && arguments[0]) {
this.errors.push(arguments[0]);
} else {
// Show Errors
if(document.getElementById('error_holder')) {
document.getElementById('error_holder').innerHTML = this.errors.join("<br />");
} else {
var _error_holder = document.createElement('table');
_error_holder.className = 'bordercolor';
_error_holder.cellSpacing= '1';
_error_holder.cellPadding = '4';
_error_holder.align = 'center';
_error_holder.width = _widths[0];
_error_holder.appendChild(document.createElement('tbody'));
_error_holder.firstChild.appendChild(document.createElement('tr')).appendChild(document.createElement('td')).appendChild (document.createElement('font'));
_error_holder.firstChild.lastChild.lastChild.setAttribute('className', 'titlebg');
_error_holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
_error_holder.firstChild.lastChild.lastChild.lastChild.setAttribute('innerHTML', 'An Error Has Occured');
_error_holder.firstChild.appendChild(document.createElement('tr')).appendChild(document.createElement('td')).appendChild (document.createElement('font'));
_error_holder.firstChild.lastChild.lastChild.setAttribute('className', 'windowbg');
_error_holder.firstChild.lastChild.lastChild.lastChild.setAttribute('size', '2');
_error_holder.firstChild.lastChild.lastChild.lastChild.setAttribute('id', 'error_holder');
_error_holder.firstChild.lastChild.lastChild.lastChild.setAttribute('innerHTML', this.errors.join("<br />") );
var _holder = document.getElementById('post_form_holder');
_holder.parentNode.insertBefore(_error_holder, _holder);
_holder.parentNode.insertBefore(document.createElement('br'), _holder);
}
}
}
}
if(document.postForm && location.href.match(/action=post(#\w+)?$/) && pb_username != 'Guest') {
_posting_form.init();
}
//-->
</script>
Thanks.
p.s - I use the newest version of FF.