function Run() { var versionNum="2.7"; var range,el,el2,el3,saveNextAfterEl,saveNextAfterEl2; var elParent,i,j,divs,ps,saveClassName; var randomNum=Math.floor((Math.random()*9)).toString()+Math.floor((Math.random()*9)).toString()+ Math.floor((Math.random()*9)).toString()+Math.floor((Math.random()*9)).toString()+ Math.floor((Math.random()*9)).toString()+Math.floor((Math.random()*9)).toString(); var selectionBeginId="removePoemOrCiteBeginId_"+randomNum; var selectionEndId="removePoemOrCiteEndId"+randomNum; var fbw_body=document.getElementById("fbw_body"); if (!fbw_body) return; if (document.selection.type.toLowerCase()!="none" && document.selection.type.toLowerCase()!="text") return; var tr=document.selection.createRange(); tr.collapse(true); window.external.BeginUndoUnit(document,"снятие форматирования блочным элементом (v"+versionNum+")"); tr.pasteHTML(""); el=document.getElementById(selectionBeginId); var selectionIsNone=tr.compareEndPoints("StartToEnd",tr)==0; if (selectionIsNone && fbw_body.contains(el)) { while (!(el.nodeName=="BODY" || (el.nodeName=="DIV" && (el.className=="poem" || el.className=="epigraph" || el.className=="cite" || el.className=="title" || el.className=="annotation" || el.className=="table") ) )) el=el.parentNode; if (el.nodeName=="DIV" && el.className=="title" && el.parentNode.nodeName=="DIV" && el.parentNode.className=="poem") el=el.parentNode; else if (el.nodeName=="DIV" && el.className=="epigraph" && el.parentNode.nodeName=="DIV" && el.parentNode.className=="poem") el=el.parentNode; if (el.nodeName!="BODY") { saveClassName=el.className; elParent=el.parentNode; var el3=el; if ((el.className=="title" || el.className=="epigraph" || el.className=="annotation") && (elParent.className=="section" || elParent.className=="body")) { var el3=el; while (el3 && el3.nodeName=="DIV" && (el3.className=="title" || el3.className=="epigraph" || el3.className=="annotation")) el3=el3.nextSibling; } else el3=null; if (el3 && el3.nodeName=="DIV" && el3.className=="section") { var sectionChild=el3.firstChild; var targetSection; //alert("sectionChild: "+sectionChild.outerHTML); if (sectionChild && (sectionChild.nodeName!="DIV" || sectionChild.className=="cite" || sectionChild.className=="poem" || sectionChild.className=="table")) { targetSection=el3; var el4=el3.previousSibling; //alert("lkj1"); //alert("el4: "+el4.outerHTML); } else { //alert("lkj2"); var newSection=document.createElement("DIV"); newSection.className="section"; newSection=el3.insertAdjacentElement("beforeBegin",newSection); targetSection=newSection; var el4=targetSection.previousSibling; } //alert("targetSection: "+targetSection.outerHTML); var previousNode; var savedPrevousNode=el.previousSibling; var newNode; while (el4 && el4!=savedPrevousNode) { //alert("el4 в цикле: "+el4.outerHTML); previousNode=el4.previousSibling; el4=el4.removeNode(true); newNode=targetSection.insertAdjacentElement("afterBegin",el4); unformatDivsAndParagraphsInsideElement(newNode); if (newNode.className!="image" && newNode.className!="section") newNode.removeNode(false); el4=previousNode; } } else if (el.className=="poem") { el2=el.firstChild; while (el2!=el) { saveNextAfterEl2=el2; if (saveNextAfterEl2.firstChild && saveNextAfterEl2.nodeName!="P") saveNextAfterEl2=saveNextAfterEl2.firstChild; else { while (saveNextAfterEl2!=el && saveNextAfterEl2.nextSibling==null) saveNextAfterEl2=saveNextAfterEl2.parentNode; if (saveNextAfterEl2!=el) saveNextAfterEl2=saveNextAfterEl2.nextSibling; } if (el2.nodeName=="DIV" && el2.className=="stanza") { if (el2.nextSibling) if (el2.nextSibling.nodeName=="DIV" && el2.nextSibling.className=="stanza") { el2.insertAdjacentHTML("beforeEnd","
<"+"/P>");
InflateIt(el2);
}
el2.removeNode(false);
}
el2=saveNextAfterEl2;
}
unformatDivsAndParagraphsInsideElement(el);
} else if (el.className=="cite") {
unformatDivsAndParagraphsInsideElement(el);
} else if (el.className=="epigraph") {
var el3=el;
var nextNode3=el3.nextSibling;
while (el3 && el3.className && (el3.className=="epigraph" || el3.className=="annotation")) {
unformatDivsAndParagraphsInsideElement(el3);
el3.removeNode(false);
el3=nextNode3;
nextNode3=el3.nextSibling;
}
} else if (el.className=="title") {
var el3=el.nextSibling;
var nextNode3=el3.nextSibling;
while (el3 && el3.className && (el3.className=="epigraph" || el3.className=="annotation")) {
unformatDivsAndParagraphsInsideElement(el3);
el3.removeNode(false);
el3=nextNode3;
nextNode3=el3.nextSibling;
}
unformatDivsAndParagraphsInsideElement(el);
} else if (el.className=="table") {
divs=el.getElementsByTagName("DIV");
for (var i=divs.length-1; i>=0; i--)
if (divs[i].nodeName=="DIV" && divs[i].className && divs[i].className=="tr")
divs[i].removeNode(false);
ps=el.getElementsByTagName("P");
for (j=0; j