»
AnglaisFran�aisVietnamien

Imprimer - PostPrep v1.10 - JavaScriptBank.com

Version compl�te: jsB@nk » Utilitaire » Générateur » PostPrep v1.10
URL: https://www.javascriptbank.com/postprep.html

PostPrep v1.10 © JavaScriptBank.comPrépare le code pour l'affichage dans un html-enabled forum .

Version compl�te: jsB@nk » Utilitaire » Générateur » PostPrep v1.10
URL: https://www.javascriptbank.com/postprep.html



CSS
<style type="text/css"><!--body { font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; background: #ffffff; margin:0; padding:10; }td { font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; background: #ffffff; margin:0; padding:0; }.defStyle { font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; background: #ffffff; margin:0; padding:0; }textarea { width:90%; font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; background: #ffffff; margin:0; padding:0; }a:link, a:visited, a:active { font-family: verdana, arial, sans-serif; font-size:12px; color:#3333ff; }a:hover { font-family: verdana, arial, sans-serif; font-size:12px; color:#ff3333; }.t3 { font-family: verdana, arial, sans-serif; font-size: 28px; color: #0000ff; background: #ffffff; }.t5 { font-family: verdana, arial, sans-serif; font-size: 12px; color: #000000; background: #ffffff; }--></style><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<script type="text/javascript"><!--var  version='v1.10',  container='',  containerStyle='';  defaultSize = '12px',  defaultColor = '#000080',  defaultBkgnd = 'transparent';window.onload = function() {  setDefaultValues();}function convert() {  var lineNumber=1, j,c,cnvBuffer='', cnvCount=0,totCount=0;  var src = document.form1.ta1.value, newline=true, indenting=false;  if (document.form1.radEle[0].checked) container="div";  else container="span";  if (!getContainerStyle()) return;  if (document.form1.chkHR1.checked) cnvBuffer = "<hr>";  if (document.form1.chkEnclose.checked)    cnvBuffer += "<" + container + " style='" + containerStyle + "'>";  if (document.form1.chkLineNum.checked) cnvBuffer += '&nbsp;&nbsp;1:&nbsp;'  for (j=0; j<src.length; ++j) {    c = src.charAt(j);    if (newline && c == ' ') indenting = true;    if (indenting && c != ' ') indenting = false;    newline = false;    switch(c) {      case '<':        if (document.form1.chkLT.checked) { cnvBuffer += '&lt;'; ++cnvCount; }        else cnvBuffer += c;        break;      case '>':        if (document.form1.chkGT.checked) { cnvBuffer += '&gt;'; ++cnvCount; }        else cnvBuffer += c;        break;      case '&':        if (document.form1.chkAmp.checked) { cnvBuffer += '&amp;'; ++cnvCount; }        else cnvBuffer += c;        break;      case '[':        if (document.form1.chkLSB.checked) { cnvBuffer += '&#' + src.charCodeAt(j) + ';'; ++cnvCount; }        else cnvBuffer += c;        break;      case ']':        if (document.form1.chkRSB.checked) { cnvBuffer += '&#' + src.charCodeAt(j) + ';'; ++cnvCount; }        else cnvBuffer += c;        break;      case '(':        if (document.form1.chkLP.checked) { cnvBuffer += '&#' + src.charCodeAt(j) + ';'; ++cnvCount; }        else cnvBuffer += c;        break;      case ')':        if (document.form1.chkRP.checked) { cnvBuffer += '&#' + src.charCodeAt(j) + ';'; ++cnvCount; }        else cnvBuffer += c;        break;      case ' ':        if (indenting && document.form1.chkIndent.checked) { cnvBuffer += '&nbsp;'; ++cnvCount; }        else cnvBuffer += c;        break;      case '\r':        if (src.charAt(j+1) == '\n') ++j;        if (document.form1.chkAppendBr.checked) {          cnvBuffer += '<BR>';          ++cnvCount;        }        else {          cnvBuffer += '\r\n';        }        newline = true;        break;      case '\n':        // will this ever happen?        if (document.form1.chkAppendBr.checked) {          cnvBuffer += '<BR>';          ++cnvCount;        }        else {          cnvBuffer += c;        }        newline = true;        break;      default:        cnvBuffer += c;    }    ++totCount;    if (newline && document.form1.chkLineNum.checked) {      ++lineNumber;      if (lineNumber > 99)        cnvBuffer += lineNumber + ':&nbsp;';      else if (lineNumber > 9)        cnvBuffer += '&nbsp;' + lineNumber + ':&nbsp;';      else        cnvBuffer += '&nbsp;&nbsp;' + lineNumber + ':&nbsp;';    }  } // end for loop  if (document.form1.chkEnclose.checked) cnvBuffer += '</' + container + '>';  if (document.form1.chkHR2.checked) cnvBuffer += '<hr>';  document.form1.ta2.value = cnvBuffer;  selectAll();  alert('PostPrep '+version+'\n\nConversion Complete\n\nConverted '+cnvCount+' of '+totCount+' characters');}function getContainerStyle() {  var f="", s = document.form1.txtSize.value;  if (s == "") s = document.form1.txtSize.value = defaultSize;  var i = parseInt(s);  if (!i || i < 1 || i > 20) {    alert('PostPrep '+version+'\n\nError: Invalid font-size');    return false;  }  var c = document.form1.txtColor.value;  if (c == "") c = document.form1.txtColor.value = defaultColor;  if (c.indexOf('#') == -1) c = '#' + c;  var b = document.form1.txtBkgnd.value;  if (b == "") b = document.form1.txtBkgnd.value = defaultBkgnd;  if (b.indexOf('transparent') == -1) {    if (b.indexOf('#') == -1) b = '#' + b;    if (b.length != 7) {      alert('PostPrep '+version+'\n\nError: Color values must have 6 hex digits');      return false;    }  }  if (c.length != 7) {    alert('PostPrep '+version+'\n\nError: Color values must have 6 hex digits');    return false;  }  if (document.form1.radFont[1].checked) f = "font-family:monospace;";  else if (document.form1.radFont[2].checked) f = "font-family:verdana,arial,sans-serif;";  else if (document.form1.radFont[3].checked) f = "font-family:georgia,'times new roman',serif;";  containerStyle = f + "font-size:" + s + ";color:" + c + ";background:" + b;  return true;}function loadOptions() {  var ppCookie = getCookie("PostPrep");  if (!ppCookie) {    alert('PostPrep '+version+"\n\nError: Options not saved in cookie.");    return;  }  var c = ppCookie.split(',');  if (c.length != 23) {    alert('PostPrep '+version+"\n\nError: Invalid cookie.");    return;  }  if (c[0] != version) {    alert('PostPrep '+version+"\n\nError: Version mismatch.\nCannot load version " + v + " options.");    return;  }  document.form1.chkIndent.checked  = eval(c[1]);  document.form1.chkLineNum.checked = eval(c[2]);  document.form1.chkAppendBr.checked= eval(c[3]);  document.form1.chkHR1.checked     = eval(c[4]);  document.form1.chkHR2.checked     = eval(c[5]);  document.form1.chkLT.checked      = eval(c[6]);  document.form1.chkGT.checked      = eval(c[7]);  document.form1.chkLSB.checked     = eval(c[8]);  document.form1.chkRSB.checked     = eval(c[9]);  document.form1.chkLP.checked      = eval(c[10]);  document.form1.chkRP.checked      = eval(c[11]);  document.form1.chkAmp.checked     = eval(c[12]);  document.form1.chkEnclose.checked = eval(c[13]);  document.form1.radEle[0].checked  = eval(c[14]);  document.form1.radEle[1].checked  = eval(c[15]);  document.form1.radFont[0].checked = eval(c[16]);  document.form1.radFont[1].checked = eval(c[17]);  document.form1.radFont[2].checked = eval(c[18]);  document.form1.radFont[3].checked = eval(c[19]);  document.form1.txtSize.value      = c[20];  document.form1.txtColor.value     = c[21];  document.form1.txtBkgnd.value     = c[22];  encloseHandler();  alert("PostPrep "+version+"\n\nOptions loaded from cookie");}function saveOptions() {  var today = new Date();  var expire = new Date();  expire.setTime(today.getTime() + 1000*60*60*24*365);  var ppCookie = version  + "," +  document.form1.chkIndent.checked    + "," +  document.form1.chkLineNum.checked   + "," +  document.form1.chkAppendBr.checked  + "," +  document.form1.chkHR1.checked       + "," +  document.form1.chkHR2.checked       + "," +  document.form1.chkLT.checked        + "," +  document.form1.chkGT.checked        + "," +  document.form1.chkLSB.checked       + "," +  document.form1.chkRSB.checked       + "," +  document.form1.chkLP.checked        + "," +  document.form1.chkRP.checked        + "," +  document.form1.chkAmp.checked       + "," +  document.form1.chkEnclose.checked   + "," +  document.form1.radEle[0].checked    + "," +  document.form1.radEle[1].checked    + "," +  document.form1.radFont[0].checked   + "," +  document.form1.radFont[1].checked   + "," +  document.form1.radFont[2].checked   + "," +  document.form1.radFont[3].checked   + "," +  document.form1.txtSize.value   + "," +  document.form1.txtColor.value  + "," +  document.form1.txtBkgnd.value;  setCookie("PostPrep", ppCookie, expire);  alert("PostPrep "+version+"\n\nCurrent options saved in cookie");}function setDefaultValues() {  document.form1.chkIndent.checked = true;  document.form1.chkLineNum.checked = false;  document.form1.chkAppendBr.checked = false;  document.form1.chkHR1.checked = false;  document.form1.chkHR2.checked = false;  document.form1.chkLT.checked = true;  document.form1.chkGT.checked = true;  document.form1.chkLSB.checked = true;  document.form1.chkRSB.checked = true;  document.form1.chkLP.checked = false;  document.form1.chkRP.checked = false;  document.form1.chkAmp.checked = true;  document.form1.chkEnclose.checked = true;  document.form1.radEle[0].checked = true;  document.form1.radEle[1].checked = false;  document.form1.radFont[0].checked = false;  document.form1.radFont[1].checked = true;  document.form1.radFont[2].checked = false;  document.form1.radFont[3].checked = false;  document.form1.txtSize.value = defaultSize;  document.form1.txtColor.value = defaultColor;  document.form1.txtBkgnd.value = defaultBkgnd;  encloseHandler();}function encloseHandler() {  if (document.form1.chkEnclose.checked) {    document.form1.radEle[0].disabled = false;    document.form1.radEle[1].disabled = false;    document.form1.radFont[0].disabled = false;    document.form1.radFont[1].disabled = false;    document.form1.radFont[2].disabled = false;    document.form1.radFont[3].disabled = false;    document.form1.txtSize.disabled = false;    document.form1.txtColor.disabled = false;    document.form1.txtBkgnd.disabled = false;  }  else {    document.form1.radEle[0].disabled = true;    document.form1.radFont[0].disabled = true;    document.form1.radFont[1].disabled = true;    document.form1.radFont[2].disabled = true;    document.form1.radFont[3].disabled = true;    document.form1.radEle[1].disabled = true;    document.form1.txtSize.disabled = true;    document.form1.txtColor.disabled = true;    document.form1.txtBkgnd.disabled = true;  }}function selectAll() {  document.form1.ta2.select();  document.form1.ta2.focus();}function clearAll() {  document.form1.ta1.value = '';  document.form1.ta2.value = '';  document.form1.ta1.focus();}function setCookie(name, value, expire) {  document.cookie = name + "=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));}function getCookie(name) {  var search = name + "=";  if (document.cookie.length > 0) {    var offset = document.cookie.indexOf(search);    if (offset != -1) {      offset += search.length;      var end = document.cookie.indexOf(";", offset);      if (end == -1)        end = document.cookie.length;      return unescape(document.cookie.substring(offset, end));    }  }}//--></script><script type="text/javascript"><!--if(document.layers) document.write("<body marginwidth='0' marginheight='0'>");else document.write("<body>");//--></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<a name="linkTop"></a><div align="left"><script type="text/javascript"><!--//document.write("<span class='t3'>PostPrep " + version + "</span>")//--></script></div><div align="right"><a href="#linkOptions">Options</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#linkHelp">Help</a></div><form name="form1">  <b>Source</b><br>  <textarea name="ta1" rows="10" cols="40" wrap="soft"></textarea><br><br>  <input type="button" value="Convert" onclick="convert()">&nbsp;&nbsp;  <input type="button" value="Clear" onclick="clearAll()"><br><br>  <b>Result</b><br>  <textarea name="ta2" rows="10" cols="40" wrap="soft"></textarea><br><br>  <input type="button" value="Select" onclick="selectAll()"><br><br>  <hr>  <div align="right"><a name="linkOptions" href="#linkTop">Top</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#linkHelp">Help</a></div>  <h3>Options</h3>  <table border="0" cellspacing="10" cellpadding="0"><tbody><tr><td valign="top">    <input type="checkbox" name="chkIndent" value="ON">Preserve indentation<br>    <input type="checkbox" name="chkLineNum" value="ON">Include line numbers<br>    <input type="checkbox" name="chkAppendBr" value="ON">Replace newline with &lt;BR&gt;<br>    <input type="checkbox" name="chkHR1" value="ON">Precede with a horizontal rule<br>    <input type="checkbox" name="chkHR2" value="ON">Follow with a horizontal rule<br>  </td></tr></tbody></table>  <br>Convert these characters to their entity references:<br>  <table border="0" cellspacing="10" cellpadding="0"><tbody><tr><td valign="top">    <input type="checkbox" name="chkLT" value="ON">&lt; Less Than<br>    <input type="checkbox" name="chkGT" value="ON">&gt; Greater Than<br>    <input type="checkbox" name="chkLSB" value="ON">[ Left Square Bracket<br>    <input type="checkbox" name="chkRSB" value="ON">] Right Square Bracket  </td><td valign="top">    <input type="checkbox" name="chkLP" value="ON">( Left Parentheses<br>    <input type="checkbox" name="chkRP" value="ON">) Right Parentheses<br>    <input type="checkbox" name="chkAmp" value="ON">&amp; Ampersand<br>  </td></tr></tbody></table>  <br>  <input type="checkbox" name="chkEnclose" onclick="encloseHandler()" value="ON">  Enclose the result in a  <input type="radio" name="radEle" checked="checked">DIV&nbsp;&nbsp;  <input type="radio" name="radEle">SPAN&nbsp;&nbsp; with the following style:<br>  <table border="0" cellspacing="10" cellpadding="0">    <tbody><tr><td>Font</td><td>      <input type="radio" name="radFont">Default&nbsp;&nbsp;      <input type="radio" name="radFont" checked="checked">Monospace&nbsp;&nbsp;      <input type="radio" name="radFont">Verdana&nbsp;&nbsp;      <input type="radio" name="radFont">Georgia</td>    </tr><tr><td>Font Size</td><td><input class="defStyle" type="text" name="txtSize" size="15" value=""></td></tr>    <tr><td>Color</td><td><input class="defStyle" type="text" name="txtColor" size="15" value=""></td></tr>    <tr><td>Background</td><td><input class="defStyle" type="text" name="txtBkgnd" size="15" value=""></td></tr>  </tbody></table>  <br>  <input type="button" value="Default" onclick="setDefaultValues()">&nbsp;&nbsp;  <input type="button" value="Save" onclick="saveOptions()">&nbsp;&nbsp;  <input type="button" value="Load" onclick="loadOptions()"></form><br><hr><div align="right"><a name="linkHelp" href="#linkTop">Top</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#linkOptions">Options</a></div><h3>Help</h3><ul style="text-align: left;">  <li>PostPrep prepares code or text for posting in an html-enabled forum. Paste or type your code into the <i>Source</i> box, click the <b>Convert</b> button, and your converted code will appear in the <i>Result</i> box, ready to copy and paste into a forum editor.   </li><li>The <b>Convert</b> button converts text in the <i>Source</i> box and displays it in the <i>Result</i> box.   </li><li>The <b>Clear</b> button deletes all text in both boxes.   </li><li>The <b>Select</b> button selects (for copying) all text in the <i>Result</i> box.   </li><li>The <b>Default</b> button sets all options to their default values.   </li><li>The <b>Save</b> button saves the current options in cookies.   </li><li>The <b>Load</b> button loads options from cookies.   </li><li>If you want <i>markup</i> in your code that&#39;s being posted, use UBB Code ([i]italic[/i] and [b]bold[/b]) and <i>uncheck</i> the options to convert those characters. Or, just add the markup after the conversion.   </li><li>When posting code, normally you should disable smilies.   </li><li>PostPrep has been tested on W2K with IE5.0, and on W98 with IE5.5, NN4.75, NS6.01, and Opera5.12.</li></ul></fieldset><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->