addLoadEvent(code2);
function code2() {
window.lab0=document.createElement("P");
window.labtext=document.createTextNode("Код конструкции:");
window.lab0.appendChild(labtext);
window.listmain={
kw2: /()\b(class|false|true|null|function|new|var|\/[img]+)\b/g,
kw4: /(\/)([img]{1,3})/g,
kw3: /()\b(action|addEventListener|alert|align|alt|appendChild|author|axis|azimuth|background|backgroundColor|backgroundImage|backgroundPosition|backgroundRepeat|baseURI|body|border|borderBottom|borderBottomColor|borderBottomStyle|borderBottomWidth|borderCollapse|borderColor|borderLeft|borderLeftColor|borderLeftStyle|borderLeftWidth|borderRight|borderRightColor|borderRightStyle|borderRightWidth|borderSpacing|borderStyle|borderTop|borderTopColor|borderTopStyle|borderTopWidth|borderWidth|bottom|caption|captionSide|captureEvents|cellIndex|cellPadding|cells|cellSpacing|characterSet|checked|childNodes|className|clear|clearInterval|clearTimeout|clientHeight|clientLeft|clientTop|clientWidth|clip|cloneNode|close|closed|color|cols|colSpan|confirm|content|contentEditable|contentType|cookie|createAttribute|createAttributeNS|createCaption|createCDATASection|createComment|createDocument|createDocumentFragment|createDocumentType|createElement|createElementNS|createEntityReference|createEvent|createExpression|createRange|createTextNode|cssFloat|cssText|cursor|data|deleteCaption|deleteCell|deleteData|deleteRow|designMode|dir|direction|disabled|dispatchEvent|display|doctype|document|documentElement|documentURI|elements|emptyCells|encoding|enctype|entities|execCommand|firstChild|font|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|form|forms|frame|frameElement|frames|fullScreen|getAttribute|getAttributeNode|getAttributeNodeNS|getAttributeNS|getBoundingClientRect|getComputedStyle|getElementById|getElementsByClassName|getElementsByName|getElementsByTagName|getElementsByTagNameNS|getFeature|getInterface|getNamedItem|getNamedItemNS|getprop|getPropertyCSSValue|getPropertyPriority|getPropertyValue|getSelection|hasAttribute|hasAttributeNS|hasAttributes|hasChildNodes|hasFeature|hasFocus|headers|height|history|home|id|images|implementation|importNode|innerHeight|innerHTML|innerWidth|insertBefore|insertCell|insertData|insertRow|isEqualNode|isSameNode|isSupported|item|lang|lastChild|lastModified|lastStyleSheetSet|left|length|letterSpacing|lineHeight|link|linkColor|links|listStyle|listStyleImage|listStylePosition|listStyleType|location|margin|marginBottom|marginLeft|marginRight|marginTop|maxHeight|maxLength|maxWidth|menubar|method|minHeight|minWidth|moveTo|name|namedItem|namespaceURI|navigator|netscape|nextSibling|nodeName|nodeType|nodeValue|noWrap|offsetHeight|offsetLeft|offsetParent|offsetTop|offsetWidth|ondblclick|onkeyup|opacity|open|openDialog|opener|outerHeight|outerWidth|outline|outlineColor|outlineOffset|outlineStyle|outlineWidth|overflow|overflowX|overflowY|padding|paddingBottom|paddingLeft|paddingRight|paddingTop|page|pageBreakAfter|pageBreakBefore|pageBreakInside|pageXOffset|pageYOffset|parent|parentNode|parentRule|pause|pauseAfter|pauseBefore|osition|prefix|previousSibling|print|prompt|quotes|readOnly|referrer|releaseEvents|removeAttribute|removeAttributeNode|removeAttributeNS|removeBinding|removeChild|removeEventListener|removeNamedItem|removeNamedItemNS|removeProperty|renameNode|replaceChild|replaceData|reset|resizeBy|resizeTo|right|rowIndex|rows|rowSpan|rules|scope|screen|screenX|screenY|scroll|scrollbars|scrollBy|scrollByLines|scrollByPages|scrollHeight|scrollLeft|scrollMaxX|scrollMaxY|scrollTo|scrollTop|scrollWidth|scrollX|scrollY|sectionRowIndex|select|selectedStyleSheetSet|selectionEnd|selectionStart|self|setAttribute|setAttributeNode|setAttributeNodeNS|setAttributeNS|setInterval|setNamedItem|setNamedItemNS|setProperty|setResizable|setSelectionRange|setTimeout|setUserData|showModalDialog|showprop|showpropbody|size|sizeToContent|speak|speakHeader|speakNumeral|speakPunctuation|speechRate|spellcheck|splitText|src|status|statusbar|stop|stress|strictErrorChecking|style|styleSheets|styleSheetSets|submit|substringData|tabIndex|tableLayout|tagName|target|textAlign|textDecoration|textIndent|textLength|textname|textShadow|textTransform|tFoot|tHead|title|toolbar|top|topic|type|unicodeBidi|updateCommands|URL|useMap|value|version|verticalAlign|visibility|voiceFamily|volume|whiteSpace|width|window|wordSpacing|write|writeln|xmlEncoding|xmlStandalone|xmlVersion|zIndex|onblur|onfocus|onload|onresize|onscroll|onunload|onclick|ondblclick|onmousedown|onmouseup|onmousemove|onmouseover|onmouseout|onchange|onreset|onselect|onsubmit|onkeydown|onkeypress|onkeyup|onerror)\b/g,
kw1: /()\b(if|else|for|while|return|break|continue|do|try|catch|throw|finally|this|delete|instanceof|typeof|void|in|case)\b/g,
me1: /(\.)(\w+)/g,
br0: /()([\(\)\{\}\[\]])/g,
nu0: /()\b([0-9]+)\b/g
}
window.list0=[
{name:"st0", val:/(\"[^\"]*\")/g},
{name:"st0", val:/(\'[^\']*\')/g},
{name:"co1", val:/(\/\/.*)/g},
{name:"co1", val:/(\/\*[\s\S]*?\*\/)/g}
]
window.list1={
}
var box = document.getElementById('inart');
var tex=box.getElementsByTagName("DIV");
codwork(tex);
var tex=box.getElementsByTagName("PRE");
codwork(tex);
//чисто javascript
tex=box.getElementsByTagName("TEXTAREA");
codwork(tex);
//внутри строк
tex=box.getElementsByTagName("SAMP");
codwork(tex);
}
function codwork(tex) {
function rep1(str, p1, p2) {
var p11;
p11=('co1'==obj.name)?p1:p1.replace(/(\\\w)/ig, "$1");
aBi++; aBvG[aBi]=""+p11+"";
return("aBvG"+aBi);
}
function rep2(str, p1) {
return(aBvG[p1]);
}
for (var el in tex) {
var elem=tex[el];
if (!elem || 1!=elem.nodeType || !elem.className || elem.className.indexOf("hl")>-1) {
continue;
}
if (elem.tagName=="DIV" && elem.className.indexOf("html")!=0) {
continue;
}
var codecont =("SAMP"==elem.tagName)?"CODE":"PRE";
var newval=elem.value || elem.innerHTML;
newval=newval.replace(/nbsp/ig, "amp;nbsp");
/* //чёртов ИЕ!!
var strokneed=Math.round(newval.length/80);
var strok=newval.match(/\r?\n/g);
strok=Number(strok && strok.length)+1;
if (strokneed>strok) {
newval=newval.replace(/\<\;/ig, "@%%@");
newval=newval.replace(/(\;\s*)(?![\"\']|\)/g, "$1\r\n");
newval=newval.replace(/\@\%\%\@/g, "<");
}
*/ //чёртов ИЕ!! конец фрагмента
//деактивация и подсвечивание HTML-тэгов
newval=newval.replace(/(\<|\<\;)(\/?[a-z0-9\!\?\;\&\#]+)/ig, "<$2");
//защита
newval=newval.replace(/\\\'/g, "@%@");
newval=newval.replace(/\\\"/g, "@%%@");
newval=newval.replace(/aBvG/g, "aBvGh#");
//защита конец
var aBvG=new Array();
var aBi=0;
for (var re in list0) {
var obj=list0[re];
newval=newval.replace(obj.val, rep1);
}
for (var re in listmain) {
newval=newval.replace(listmain[re], "$1$2");
}
newval=newval.replace(/(\\\w)/g, "\$1");
newval=newval.replace(/aBvG(\d+)/g, rep2);
newval=newval.replace(/aBvG(\d+)/g, rep2); //вложенные кавычки
newval=newval.replace(/aBvGh\#/g, "aBvG"); //защита вернуть
newval=newval.replace(/\@\%\@/g, "\\\'"); //защита вернуть
newval=newval.replace(/\@\%\%\@/g, "\\\""); //защита вернуть
var pare=elem.parentNode;
// var p=document.createElement("DIR");
var code=document.createElement(codecont);
code.innerHTML=newval;
var testval=code.innerHTML
//чёртов ИЕ!!
if (!/\r?\n/.test(testval)) {
try {
newval=newval.replace(/(\r?\n)/g, "
$1");
newval=newval.replace(/(\r?\n)( )/g, "$1 ");
code.innerHTML=newval;
}
catch(e) {
// alert(code.innerHTML);
}
}
//чёртов ИЕ!! конец
if (elem.className.indexOf("html")!=0) {
elem.style.display="none";
pare.insertBefore(code, elem);
}
else {
pare.insertBefore(code, elem.nextSibling);
// elem.className+=" deja";
}
if ("inline"==elem.className) {
code.className+=" icode";
}
else {
code.className="hl h20em oscroll";
if (code.scrollHeight<=code.offsetHeight)
code.className=code.className.replace(/ h20em\b/i,"")
if (code.scrollWidth<=code.offsetWidth && -1==code.className.search(/ h20em\b/i))
code.className=code.className.replace(/ oscroll\b/i,"")
}
if ("js"==elem.className) {
elem.className+=" disnone";
}
else if (elem.className.indexOf("html")==0) {
var lab=lab0.cloneNode(true);
pare.insertBefore(lab,code);
}
}
}
//оформление кода конец