Post by Sav on Aug 12, 2010 2:48:01 GMT -8
Hi,
I am trying to allow users to put tabulated results tables in my board and am playing in the test area
barbilliards.proboards.com/index.cgi?board=test
I am using CSS sheets in the header there so that I do not spoil the main forum.
Proboards, as we know, does not display multiple spaces, even with a fixed width font such as Courier New. It is thus virtually impossible to tabulate data.
I have tried to show users how to replace spaces with the null character (ALT 255) in prn files from excel and that works fine,
but it is beyond the capability of most non techies. ALT 255 does not get condensed upon Proborads posting display and tabulation is retained.
The [ p r e ] tag is not much use as word wrapping is lost.
Links to jpegs in photobucket etc is not the way as they will certainly be lost as accounts get forgotten
I thus went hunting and found a code in the database
<script type="text/javascript">
/* Allow Spacing in Posts by hpmad */
if(document.postForm){
document.postForm.onsubmit = function(){
document.postForm.message.value = document.postForm.message.value.replace(/\n/g,'[br\]');
document.postForm.message.value = document.postForm.message.value.replace(/\s/g,' ');
}
}
if(location.href.match(/action=display/i)){
document.forms[0].name = 'quickReply';
document.quickReply.onsubmit = function(){
document.quickReply.message.value = document.quickReply.message.value.replace(/\n/g,'[br\]');
document.quickReply.message.value = document.quickReply.message.value.replace(/\s/g,' ');
}
}
</script>
This also strips the spaces out of quoted headers and they no longer work (note to admins to warn in the database)
Further searching found
<script type="text/javascript">
<!--
/*Open Source*/
if(document.postForm && document.postForm.message){
document.postForm.message.value=document.postForm.message.value.replace(new RegExp('&nb'+'sp;', 'g'), ' ');
if(document.addEventListener){
document.postForm.addEventListener('submit', function(){
document.postForm.message.value=document.postForm.message.value.replace(/ {2}/g, '&nb'+'sp; ')
}, false);
}
else{
document.postForm.attachEvent('onsubmit', function(){
document.postForm.message.value=document.postForm.message.value.replace(/ {2}/g, '&nb'+'sp; ')
});
}
}
This is neater because it appears to ignore single spaces and substitutes double spaces with the & n s p character and a space, resubmitting back on the edit screen. Quoting works with this script.
This one however fails with odd and even numbers of spaces because an odd number of spaces leaves two spaces together upon substitution (one susbstituted and one unaltered) at the end of the string of spaces. This is reduced to one on display as normal and tabulation is lost
I can understand what is going on but have little javascripting knowledge.
Can anyone thus amend the second code to cater for odd and even number of spaces please?? The obvious answer would be to replace <space><space> with <space><& n s p> instead of <& n s p><space> That would not leave two trailing spaces.
Even better and simpler might be substituting two alt 255 characters for any double spaces. If you do this you do not have to transpose back to allow editing because ALT 255 looks like a space. There may be side effects that I have not thought of.
Both answers appreciated
Chris.
I am trying to allow users to put tabulated results tables in my board and am playing in the test area
barbilliards.proboards.com/index.cgi?board=test
I am using CSS sheets in the header there so that I do not spoil the main forum.
Proboards, as we know, does not display multiple spaces, even with a fixed width font such as Courier New. It is thus virtually impossible to tabulate data.
I have tried to show users how to replace spaces with the null character (ALT 255) in prn files from excel and that works fine,
but it is beyond the capability of most non techies. ALT 255 does not get condensed upon Proborads posting display and tabulation is retained.
The [ p r e ] tag is not much use as word wrapping is lost.
Links to jpegs in photobucket etc is not the way as they will certainly be lost as accounts get forgotten
I thus went hunting and found a code in the database
<script type="text/javascript">
/* Allow Spacing in Posts by hpmad */
if(document.postForm){
document.postForm.onsubmit = function(){
document.postForm.message.value = document.postForm.message.value.replace(/\n/g,'[br\]');
document.postForm.message.value = document.postForm.message.value.replace(/\s/g,' ');
}
}
if(location.href.match(/action=display/i)){
document.forms[0].name = 'quickReply';
document.quickReply.onsubmit = function(){
document.quickReply.message.value = document.quickReply.message.value.replace(/\n/g,'[br\]');
document.quickReply.message.value = document.quickReply.message.value.replace(/\s/g,' ');
}
}
</script>
This also strips the spaces out of quoted headers and they no longer work (note to admins to warn in the database)
Further searching found
<script type="text/javascript">
<!--
/*Open Source*/
if(document.postForm && document.postForm.message){
document.postForm.message.value=document.postForm.message.value.replace(new RegExp('&nb'+'sp;', 'g'), ' ');
if(document.addEventListener){
document.postForm.addEventListener('submit', function(){
document.postForm.message.value=document.postForm.message.value.replace(/ {2}/g, '&nb'+'sp; ')
}, false);
}
else{
document.postForm.attachEvent('onsubmit', function(){
document.postForm.message.value=document.postForm.message.value.replace(/ {2}/g, '&nb'+'sp; ')
});
}
}
This is neater because it appears to ignore single spaces and substitutes double spaces with the & n s p character and a space, resubmitting back on the edit screen. Quoting works with this script.
This one however fails with odd and even numbers of spaces because an odd number of spaces leaves two spaces together upon substitution (one susbstituted and one unaltered) at the end of the string of spaces. This is reduced to one on display as normal and tabulation is lost
I can understand what is going on but have little javascripting knowledge.
Can anyone thus amend the second code to cater for odd and even number of spaces please?? The obvious answer would be to replace <space><space> with <space><& n s p> instead of <& n s p><space> That would not leave two trailing spaces.
Even better and simpler might be substituting two alt 255 characters for any double spaces. If you do this you do not have to transpose back to allow editing because ALT 255 looks like a space. There may be side effects that I have not thought of.
Both answers appreciated
Chris.