国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

用html+javascript打造公文一鍵排版系統(tǒng)10:?jiǎn)我桓郊f(shuō)明排版

這篇具有很好參考價(jià)值的文章主要介紹了用html+javascript打造公文一鍵排版系統(tǒng)10:?jiǎn)我桓郊f(shuō)明排版。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

如果公文有附件,一般會(huì)在公文正文下作附件說(shuō)明。

一、附件說(shuō)明的格式

一般為:

公文如有附件,在正文下空一行左空二字編排"附件"二字,后標(biāo)全角冒號(hào)和附件名稱。如有多個(gè)附件,使用阿拉伯?dāng)?shù)字標(biāo)注附件順序號(hào)(如"附件:1. XXXXX");附件名稱后不加標(biāo)點(diǎn)符號(hào)。附件名稱較長(zhǎng)需回行時(shí),應(yīng)當(dāng)與上一行附件名稱的首字對(duì)齊。

二、單個(gè)附件說(shuō)明的檢測(cè)

如果只有一個(gè)附件,就是下面種形式的:

附件:河池市××關(guān)于××的通知?
?

在實(shí)際工作中我們還要多考慮三種情況:

1.摻雜空格

2.行末有標(biāo)點(diǎn)符號(hào)

3.附件后面的全角冒號(hào)錯(cuò)誤誤輸入為英文冒號(hào)

即:

附件:河池市××? 關(guān)于 ×× 的通知?
附件:河池市××關(guān)于××的通知。??

我們用正則表達(dá)式來(lái)檢測(cè):

<!DOCTYPE html>
<html>
<body>
 
<script>

//功能:判斷是否為中文或英文標(biāo)點(diǎn)符號(hào)
String.prototype.isPunctuation = function() 
{ 
	return ((/[\x21-\x2f\x3a-\x40\x5b-\x60\x7B-\x7F|\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/.test(this))); 
}

  
//功能:判斷是文本行是否為單個(gè)附件的附件說(shuō)明 is a single Attachment Description?
//輸入:p=字符串
//輸出:true=是,false=否
//更新:20230730創(chuàng)建
function isSingleAttDesc(p)
{
	return (/^(附){1}\s*(件){1}\s*(:|:){1}\s*[^0-9]+\s*/.test(p)) && !p[p.length-1].isPunctuation(); 
}
  
 
var s = ["附件:河池市××關(guān)于××的通知  ",  
         "附件:河池市××關(guān)于××的通知  ", 
         "附件:河池市××關(guān)于××的通知。",  
         "附件:1.河池市××關(guān)于××的通 知  ",
         "附件:1.河池市××關(guān)于××××的通 知 ",
         "2.河池市××關(guān)于×× ××的通 知 ",
         "3.河池市××關(guān)于×× ××的通 知 "
         ];

for (var i = 0; i < s.length; i++)
{
    document.write('[' + s[i] + ']  ' + isSingleAttDesc(s[i]) + "<br>");
}     
</script>
 
</body>
</html>

代碼運(yùn)行結(jié)果如下:

[附件:河池市××關(guān)于××的通知 ]  true
[附件:河池市××關(guān)于××的通知 ]  true
[附件:河池市××關(guān)于××的通知。]  false
[附件:1.河池市××關(guān)于××的通 知 ]  false
[附件:1.河池市××關(guān)于××××的通 知 ]  false
[2.河池市××關(guān)于×× ××的通 知 ]  false
[3.河池市××關(guān)于×× ××的通 知 ]  false

三、?單個(gè)附件說(shuō)明的排版

//功能:設(shè)置附件說(shuō)明格式 set attachment description format
//輸入:p=附件說(shuō)明字符串
//輸出:格式化的附件說(shuō)明格式
//更新:20230730創(chuàng)建
function setAtttDescFmt(p)
{
	var t = p;
	var a = '';
	if (-1 != t.indexOf(':'))//是半角冒號(hào)?
	{
		t = p.replace(':', ':');
		a = g_sWarmPromptLeft + g_sWarmPromptTxt + "已將半角冒號(hào)轉(zhuǎn)換為全角冒號(hào)" + g_sWarmPromptRight;	  //溫馨提示
	}

	//公文如有附件,在正文下空一行左空二字編排"附件"二字,后標(biāo)全角冒號(hào)和附件名稱。
	var sBlankLine = '<p style="margin:0px; line-height:' + rs + 'pt; font-family:' + mtfn + '; font-size:'+ mtfs + 'pt;">&nbsp;</p>';
	var t  =  '<p style="margin:0pt 0pt 0pt 32pt; line-height:' + rs + 'pt; font-family:' + mtfn + '; font-size:'+ mtfs + 'pt;">' + t;
	return  sBlankLine +  t + a;
}// setAtttDescFmt(p) 

把它加入到?setDocFmt():

//功能:設(shè)置公文格式Set document format
//輸入:無(wú)
//輸出:無(wú)
//記錄:20230726添加對(duì)附件及附件標(biāo)題格式的處理代碼
//           20230729添加對(duì)主送單位格式的處理代碼    
//           20230730添加對(duì)單個(gè)附件說(shuō)明格式的處理代碼    
function setDocFmt()
{
	taDbg.value += "\n---setDocFmt()\n";
 
	getArg(); //讀取預(yù)設(shè)參數(shù)
 
	var t = getClearInfoArray();
 
	//標(biāo)題
	if (cbDocTilte)
	{
		t[0]  = setDocTitle(t[0]) + '</p><p style="margin:0px; line-height:"' + rs +'">&nbsp;';
	}
 
	var i =  (cbDocTilte ? 1 : 0);//2023-07-26增加
	while (i < t.length)
	{

		if (i < t.length-1)//20230716增加
		{

			if (isBadging(t[i],t[i+1]))//是落款?
			{
				//落款前加空行
				t[i-1] += '</p><p style="margin:0px; line-height:"' + rs +'">&nbsp;';
				//設(shè)置落款
				t[i] = setBadging(t[i],t[i+1]);
				t[i+1] = null;
				taDbg.value += "\nt[" + (i-1) + "]=" + t[i-1] + "\nt[" + i +"]=" + t[i] + "\nt[" +(i+1) +"]=" + t[i+1];
				//i++;
				//i++;
				i += 2;
				continue;
			}

			if (isAttachmentTitle(t[i],t[i+1]))	  //是附件及附件標(biāo)題?
			{
				t[i] = setAttachmentTitleFmt(t[i],t[i+1]);
				t[i+1] = null;
				taDbg.value += "\nt[" + (i-1) + "]=" + t[i-1] + "\nt[" + i +"]=" + t[i] + "\nt[" +(i+1) +"]=" + t[i+1];
				//i++;
				//i++;
				i += 2;
				continue;
			}
		}//if

		if (isMainDeDe(t[i]))//是主送單位嗎?20230729增
		{
			t[i] = setMainDeDe(t[i]);//是
			i++;
			continue;
		}

		if (isSingleAttDesc(t[i])) //是單個(gè)附件說(shuō)明?20230730增加
		{
			t[i] = setAtttDescFmt(t[i]);
			i++;
			continue;
		}

		t[i] = setParaFmt(t[i]);
		i++;

	}//while()
	
	//alert(t.join(''));
	edRichBody.innerHTML = t.join(''); 
}//setDocFmt()   

?四、代碼運(yùn)行效果

如下:

用html+javascript打造公文一鍵排版系統(tǒng)10:?jiǎn)我桓郊f(shuō)明排版,原創(chuàng)作品,網(wǎng)頁(yè)制作,JavaScript,html,前端,JavaScript,正則表達(dá)式,公文排版,一鍵排版

五、完整代碼

如下:?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-619105.html

<!DOCTYPE HTML>
<HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" content="PurpleEndurer">
<title>公文一鍵排版系統(tǒng)</title>
<!--
20230729 1.將 text-indent的值從 2em,改為 32pt
                 2.增加主送單位格式排版
20230730 添加對(duì)單個(gè)附件說(shuō)明格式的處理代碼    
//--> 
<script type="text/javascript">
var aFontName = [
	"方正小標(biāo)宋簡(jiǎn)體",//0
	"黑體",//1
	"微軟雅黑",//2
	"仿宋_GB2312",//3
	"仿宋",//4
	"楷體_GB2312",//5
	"楷體",//6
	"宋體",//7
	"Arial",//8
	"Wingdings 2"http://9
];
 
//sId:select control id, iDefSel:default selected
function showFontNameSel(sId, iDefSel)
{
	document.write('<select id="', sId, '" width="50">');
	for (var i = 0; i < aFontName.length; i++)
	{
		document.write('<option value="', aFontName[i], '"');
		document.write(i==iDefSel ? ' selected>' : '>');
		document.write(aFontName[i],'</option>');
	}
	document.write('</select>');
}
 
var aFontSize = [
	['初號(hào)', 42],//0
	['小初', 36],//1
	['一號(hào)', 26],//2
	['小一', 24],//3
	['二號(hào)', 22],//4
	['小二', 18],//5
	['三號(hào)', 16],//6
	['小三', 15],//7
	['四號(hào)', 14],//8
	['小四', 12],//9
	['五號(hào)', 10.5], //10
	['小五', 9],//11
	['六號(hào)', 7.5],//12
	['小六', 6.5],//13
	['七號(hào)', 5.5],//14
	['八號(hào)', 5]//15
];

var aAlign = [
	["左對(duì)齊","left"],//0
	["居中對(duì)齊","center"],//1
	["右對(duì)齊","right"],//2
	["兩端分散對(duì)齊","justify"]//3
];

var g_sWarmPromptLeft = '<span style="color:red; font-style:italic;padding-left:15pt">';//2023年7月29增
var g_sWarmPromptTxt = "*公文一鍵排版系統(tǒng)溫馨提示:";//2023年7月29增
var g_sWarmPromptRight = '</span>';//2023年7月29增


//sId=select control id, iDefSel=default selected
function showFontSizeSel(sId, iDefSel)
{
	document.write('<select id="', sId, '">');
	for (var i = 0; i < aFontSize.length; i++)
	{
		document.write('<option value="',aFontSize[i][1], '"');
		document.write(i==iDefSel ? ' selected>' : '>');
		document.write(aFontSize[i][0],'</option>');
	}
	document.write('</select>');
}

 
//sId=select control id, iDefSel=default selected
function showAlignSel(sId, iDefSel)
{
	document.write('<select id="', sId, '">');
	for (var i = 0; i < aAlign.length; i++)
	{
		document.write('<option value="',aAlign[i][1], '"');
		document.write(i==iDefSel ? ' selected>' : '>');
		document.write(aAlign[i][0],'</option>');
	}
	document.write('</select>');
}//showAlignSel()
 
 
function setDocTitle(s)
{
	//dtfn = 標(biāo)題字體名 font name
	//dtfs = 標(biāo)題字號(hào) font size
	//dtta = 標(biāo)題對(duì)齊方式 text align
	//rs = 行距 row spacing
	
	return '<p style="margin:0px; font-family:' + dtfn + ';font-size:' + dtfs +'pt; text-align:' + dtta + '; line-height:' +  rs + 'pt;">' + s;
}//setDocTitle()
 
 
//去除<P>中的屬性
function stripPattribs(s)
{
	var i = s.indexOf('>');
	return ((-1 != i) ? s.substr(i+1) : s);
}

 
//去除HTML代碼
String.prototype.stripHTML = function() 
{
    //var reTag = /<(?:.|\s)*?>/g;  
	//var reTag = /<[^>]+>/gi;	//過(guò)濾所有html標(biāo)簽,但不包括html標(biāo)簽內(nèi)的內(nèi)容 
 
    return this.replace(/<(?:.|\s)*?>/g,"");
}

 
String.prototype.trim = function() 
{//去除首尾空格
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

 
String.prototype.ltrim = function() 
{ 
	return this.replace(/(^\s*)/g, ""); 
} 

 
String.prototype.rtrim = function() 
{ 
	return this.replace(/(\s*$)/g, ""); 
} 

 
//判斷是否為中文標(biāo)點(diǎn)符號(hào)
String.prototype.isCnPunctuation = function() 
{ 
	return (/[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/.test(this)); //20230730修改
}

 
//判斷是否為英文標(biāo)點(diǎn)符號(hào)
String.prototype.isEnPunctuation = function() 
{ 
	return /[\x21-\x2f\x3a-\x40\x5b-\x60\x7B-\x7F]/.test(this);
}
 

//功能:判斷是否為中文或英文標(biāo)點(diǎn)符號(hào)
String.prototype.isPunctuation = function() 
{ 
	return ((/[\x21-\x2f\x3a-\x40\x5b-\x60\x7B-\x7F|\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/.test(this))); 
	//return (this.isEnPunctuation() || this.isCnPunctuation()) ? true : false; //20230730停用
	//return (this.isEnPunctuation() || this.isCnPunctuation()); //20230730增加
}
 

//判斷是否為純半角阿拉伯?dāng)?shù)字串
String.prototype.isArabicNumEn = function() 
{
    return  /^\d+$/.test(this);
}
 
 
//判斷是否為純?nèi)前⒗當(dāng)?shù)字串
String.prototype.isArabicNumCn = function() 
{
	//[\uff10|\uff11|\uff12|\uff13|\uff14|\uff15|\uff16|\uff17|\uff18|\uff19]=[0|1|2|3|4|5|6|7|8|9]
	return (/^[\uff10|\uff11|\uff12|\uff13|\uff14|\uff15|\uff16|\uff17|\uff18|\uff19]+$/.test(this));
}
 
 
//判斷是否為純?nèi)腔蚣儼虢前⒗當(dāng)?shù)字串
String.prototype.isPureArabicNum = function() 
{
	//[\uff10|\uff11|\uff12|\uff13|\uff14|\uff15|\uff16|\uff17|\uff18|\uff19]=[0|1|2|3|4|5|6|7|8|9]
	return (this.isArabicNumEn() || this.isArabicNumCn());
}
 
 
//判斷是否為全阿拉伯?dāng)?shù)字串(全角或半角阿拉伯?dāng)?shù)字均可)
String.prototype.isArabicNum = function() 
{
	//[\uff10|\uff11|\uff12|\uff13|\uff14|\uff15|\uff16|\uff17|\uff18|\uff19]=[0|1|2|3|4|5|6|7|8|9]
	return (/^[\d|\uff10|\uff11|\uff12|\uff13|\uff14|\uff15|\uff16|\uff17|\uff18|\uff19]+$/.test(this));
}


//功能:將edRichBody內(nèi)容分解成字符串?dāng)?shù)組并清除其中的多余字符:空格、HTML代碼等
//輸入:無(wú)
//輸出:清后多余字符的字符串?dāng)?shù)組
//記錄:20230729增加清除溫馨提示信息,將多個(gè)循環(huán)整合到一個(gè)循環(huán)內(nèi)
function getClearInfoArray()
{
	var s = edRichBody.innerHTML.replace(/<br(?:.|\s)*?>/gi,'</p><p>');
	var t = s.split('<p');
 
	taDbg.value += "\n---getClearInfoArray()\n";
	for (var i=0; i < t.length; i++)
	{
		taDbg.value += "\nt[" + i + "]=" + t[i];
	}    

	s = 0;
	while (s < t.length)
	{
		t[s] = stripPattribs(t[s]);
		t[s] = t[s].stripHTML();
 
		//以下兩句順序不能顛倒
		t[s] = t[s].replace(/&nbsp;/ig, ''); //去除空格代碼	  &nbsp;
		t[s] = t[s].trim(); //去除首尾空格

 		var j = t[s].indexOf(g_sWarmPromptTxt);//20230729增加清除溫馨提示信息
		if (-1 != j)
		{
			t[s] = t[s].substring(0,j);
		}

		if (t[s].length==0 || t[s]=='></p>' || t[s]==null)
		{
			taDbg.value += "\nsplice: t[" + s + ']=' + t[s];
			t.splice(s,1);
		}
		else
		{
			s++;
		}
	}//while()

	taDbg.value += "\n---\n";
	for (var i=0; i < t.length; i++)
	{
		taDbg.value += "\nt[" + i + "]=" + t[i];
	} 
	 
	return t;
}
 
 
function clearDocFmt()
{
	var s = '<p>' + getClearInfoArray().join('</p><p>');
 
	//alert(s);
	edRichBody.innerHTML = s;
	//alert(edRichBody.innerHTML);
}

 
//功能:是否以標(biāo)點(diǎn)符號(hào)結(jié)束Is aunctuation at the end of the string
String.prototype.isEndWithPunctuation = function()
{
/*
	var c = this.substring(this.length-1);
	return c.isPunctuation();
*/
	return this.substring(this.length-1).isPunctuation();
}
 
 
//語(yǔ)句結(jié)束符號(hào)字符串,考慮到三級(jí)標(biāo)題序號(hào)可能包括英語(yǔ)句號(hào),此處不將英語(yǔ)句號(hào)列為語(yǔ)句結(jié)束符號(hào)
var sStatementEndPunctuation = '。!?…!?';
 

//功能:獲取段落文字中的第一個(gè)語(yǔ)句結(jié)束符號(hào)位置
//輸入:p:字符串
//輸出:第一個(gè)語(yǔ)句結(jié)束符號(hào)位置
//記錄:20230729更新
function getFirstPunctuationPos(p)
{
	//taDbg.value += '\n ---getFirstPunctuationPos(' + p + ')\n';
	var r = p.length, n;
 
	for (var i = 0; i < sStatementEndPunctuation.length; i++)
	{
		n = p.indexOf(sStatementEndPunctuation[i]);
		if ( (-1 != n) && (n < r) )
		{
			r = n;
			break;//20230729增加
			//taDbg.value += '\n' + p[i] + ': n=' + n + '    r=' + r;
		}
	}
	return r;
}//getFirstPunctuationPos(p)
 
 
//功能:判斷字符串是否只有一句話
//輸入:p=字符串
//輸出:true=是一句話;false=不是一句話
function isAstatement(p)
{
/*
	for  (var i = 0; i < sStatementEndPunctuation.length; i++)
	{
		var n = p.indexOf(sStatementEndPunctuation[i]);
		if  (n !=-1 &&  n == p.length-1) 
		{
			return  true;
		}
	}
	return false;
*/
	var n = getFirstPunctuationPos(p);
	return  ((( -1 != n) && (n == p.length-1)) ? true : false);
}
 
/*
//功能:標(biāo)題是否單獨(dú)成行 Is paragraph title a single line?	 
//輸入:t=文字
//輸出:true=是獨(dú)立標(biāo)題行,false=不是獨(dú)立標(biāo)題行
function ptIsALine(t)
{
	return isAstatement(t) ;
} //ptIsALine(t)    
*/
 
//功能:設(shè)置一級(jí)標(biāo)題set paragraph format with primay title 
//輸入:t=文字
//輸出:格式化字符串
function setParaTitle1(t)
{
	var r;
	if (isAstatement(t))	//(ptIsALine(t))	 //標(biāo)題是否單獨(dú)成行
	{
		//return '<p style="font-family:' + fn + ';font-size:' + fs +'pt; text-align:' + ta + '; line-height:' +  rs + 'pt;">' + s;
		r = '<p style="margin:0; font-family:' + pt1fn + ';font-size:' + pt1fs +'pt; line-height:' +  rs + 'pt; text-indent: '+ sn +'pt;">' + t;
	}
	else
	{
		//標(biāo)題不單獨(dú)成行
		var n = getFirstPunctuationPos(t);//t.indexOf('。');
		r = '<p style="margin:0; line-height:' +  rs + 'pt; text-indent: '+ sn + 'pt; font-family:' + mtfn + '"><span style="font-family:' + pt1fn + ';font-size:' + pt1fs +'pt;" >' + t.substring(0, n) + '</span>' + 	t.substring(n);
	}
 
	taDbg.value += "\n---setParaTitle1:" + r;
	
	return r;
} //setParaTitle1(t)
 
 
//功能:設(shè)置二級(jí)標(biāo)題set paragraph format with secondary title 
//輸入:t=文字
//輸出:格式化字符串
function setParaTitle2(t)
{
	taDbg.value += "\n---setParaTitle2:" + t;
	var r;
	//var b = document.getElementById("cbSecondaryTitleStrong").checked; //是否加粗
	if  (isAstatement(t))//(ptIsALine(t))	 //標(biāo)題是否單獨(dú)成行
	{
		//return '<p style="font-family:' + fn + ';font-size:' + fs +'pt; text-align:' + ta + '; line-height:' +  rs + 'pt;">' + s;
		r = '<p style="margin:0; font-family:' + st2fn + ';font-size:' + st2fs +'pt; line-height:' +  rs + 'pt; text-indent: '+ sn +'pt;' + (st2Strong ? 'font-weight: bold;' : '') + '">' + t;
	}
	else
	{
		//標(biāo)題不單獨(dú)成行
		var n = getFirstPunctuationPos(t);
		r = '<p style="margin:0; line-height:' +  rs + 'pt; text-indent: '+ sn +'em; font-size:' + st2fs +'pt; font-family:' + mtfn + '"><span style="font-family:' + st2fn +  (st2Strong ? ';font-weight: bold;' : '') + '" >' + t.substring(0, n) + '</span>' + 	t.substring(n);
	}
 
	return r;
}//setParaTitle2(t)
 
 
//功能:在段落文本末尾添加缺少標(biāo)點(diǎn)符號(hào)的提示文本
//輸入:q=待添加提示的文本
//輸出:添加提示后的文本
//記錄:20230726修改變量strMissPunctuation
//      20230729 停用
/*
function appendMissPunctuationPrompt(q)
{
	//const strMissPunctuation = "*公文一鍵排版系統(tǒng)溫馨提示:此處是否遺漏標(biāo)點(diǎn)符號(hào)";
	const strMissPunctuation = g_sWarmPromptTxtLeft + g_sWarmPromptTxt + '此處是否遺漏標(biāo)點(diǎn)符號(hào)' + g_sWarmPromptRight;

	var k = q.lastIndexOf(strMissPunctuation); 
 
	//q = (-1 != k ?  q.substring(0, k) : q) +   '<span style="color:red; font-weight:bold;">' + strMissPunctuation + '</span>';
	q = (-1 != k ?  q.substring(0, k) : q) +  strMissPunctuation;
	return q;
	//return (-1 != k ?  q.substring(0, k) : q) +   '<span style="color:red; font-weight:bold;">' + strMissPunctuation + '</span>';
}//appendMissPunctuationPrompt()
*/ 
 
//功能:設(shè)置三級(jí)標(biāo)題set paragraph format with third title 
//輸入:t=文字
//輸出:格式化字符串
function setParaTitle3(t)
{
	taDbg.value += "\n---setParaTitle3:" + t;
	var r;
	//var b = document.getElementById("cbThirdTitleString").checked; //是否加粗
	if  (isAstatement(t))//(ptIsALine(t))	 //標(biāo)題是否單獨(dú)成行
	{
		//return '<p style="font-family:' + fn + ';font-size:' + fs +'pt; text-align:' + ta + '; line-height:' +  rs + 'pt;">' + s;
		r = '<p style="margin:0; font-family:' + mtfn + ';font-size:' + mtfs +'pt; line-height:' +  rs + 'pt; text-indent: '+ sn +'pt;' + (tt3Strong ? 'font-weight: bold;' : '') + '">' + t;
	}
	else
	{
		//標(biāo)題不單獨(dú)成行
		var n = getFirstPunctuationPos(t);

		r = '<p style="margin:0; line-height:' +  rs + 'pt; text-indent: '+ sn + 'pt; font-size:' + mtfs + 'pt; font-family:' + mtfn + '">' + (tt3Strong ? '<span style="font-weight: bold;">' : '')  + t.substring(0, n) + (tt3Strong ? '</span>' : '') + t.substring(n);

		if ( !r.isEndWithPunctuation())
		{
			//r = appendMissPunctuationPrompt(r);20230729停用
			r += g_sWarmPromptLeft + g_sWarmPromptTxt + '此處是否遺漏標(biāo)點(diǎn)符號(hào)' + g_sWarmPromptRight;
		}
	}//if
 
	return r;
}//setParaTitle3(t)
 
 
//是否為只包含一二三四五六七八九十的字符串
String.prototype.isCnNum = function() 
{
	//[\u4e00|\u4e8c|\u4e09|\u56db|\u4e94|\u516d|\u4e03|\u516b|\u4e5d|\u5341] = [一二三四五六七八九十]
	return (/^[\u4e00|\u4e8c|\u4e09|\u56db|\u4e94|\u516d|\u4e03|\u516b|\u4e5d|\u5341]+$/.test(this));
}
 
 
//Is the paragraph with primary title?一級(jí)標(biāo)題
function isIncludePrimaryTitle(p)
{
	var t = p.indexOf('、');
	return ((-1 != t) && (p.substring(0,t).isCnNum())) ? true : false;
	//return /^[\u4e00|\u4e8c|\u4e09|\u56db|\u4e94|\u516d|\u4e03|\u516b|\u4e5d|\u5341]+[\u3001]{1}/.test(p); //可匹配“ 十一、三四”中的“十一、”
	//return /^\s*[\u4e00|\u4e8c|\u4e09|\u56db|\u4e94|\u516d|\u4e03|\u516b|\u4e5d|\u5341]+[\u3001]{1}/.test(p); //可匹配“   十一、三四”或“ 十一、三四”中的“十一、”
	//(\b[\u4e00|\u4e8c|\u4e09|\u56db|\u4e94|\u516d|\u4e03|\u516b|\u4e5d|\u5341])*[\u3001]{1},可匹配“十一、三四”中的頓號(hào)
	//\b[\u4e00|\u4e8c|\u4e09|\u56db|\u4e94|\u516d|\u4e03|\u516b|\u4e5d|\u5341]*[\u3001]{1},可匹配“a十一、三四”中的“十一、”
}//isIncludePrimaryTitle(p)
 
 
//Is a secondary title serial number with parenthesis是帶小括號(hào)的二級(jí)標(biāo)題序號(hào)嗎?
function isT2SNwithParenthesis(p)
{
	var t = p[0];
	if (t == '(')
	{
		t = p.indexOf(')');
		if ((-1 != t) && ((p.substring(1,t)).isCnNum())) 
		{
			return true;
		}
	}//if
 
	if (t == '(')
	{
		t= p.indexOf(')');
		if ((-1 != t) && (p.substring(1,t).isCnNum())) 
		{
			return true;
		}
	}//if
 
	return false;//二級(jí)標(biāo)題	
}//isSNwithParenthesis(p)
 
 
//Is the paragraph with secondary title?二級(jí)標(biāo)題
function isIncludeSecondaryTitle(p)
{
	var t = p[0];//t = p.substring(0, 1);
	if (-1!= "㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩".indexOf(t))
	{
		return true;
	}
 
	if (isT2SNwithParenthesis(p))
	{
		return true;//二級(jí)標(biāo)題
	}
 
	return false;
}//isIncludeSecondaryTitle(p)
 
 
//Is the paragraph with third title?三級(jí)標(biāo)題
function isIncludeThirdTitle(p)
{
	var t = p.indexOf('.');
	if (-1==t)
	{
		t = p.indexOf('.');
	}
	return ((-1 != t) && p.substring(0,t).isPureArabicNum()) ? true : false;
}//isIncludeThirdTitle(p)
 
 
//功能:獲取文字串的標(biāo)題級(jí)別
//輸入:p:文字串
//輸出:1:一級(jí)標(biāo)題,2:二級(jí)標(biāo)題,3:三級(jí)標(biāo)題,0:其它
function getTitleLevel(p)
{
	taDbg.value += "\n---getTitleLevel:" + p;
 
	//var t = p[0];//t = p.substring(0, 1);
	if  (isIncludeSecondaryTitle(p))//(t=='(' || t=='(' )
	{
		//alert(t);
		return 2;//二級(jí)標(biāo)題
	}
	
	if (isIncludePrimaryTitle(p))//一級(jí)標(biāo)題
	{
		return 1;
	}
 
	if (isIncludeThirdTitle(p))//三級(jí)標(biāo)題
	{
		return 3;
	}
 
	return 0;
}//getTitleLevel(p)
 

//功能:設(shè)置段落格式set paragraph format
//輸入:p:段落文字
//輸出:設(shè)置格式的文本
function setParaFmt(p)
{
	switch (getTitleLevel(p))
	{
		case 1:
			t = setParaTitle1(p);//一級(jí)標(biāo)題
			break;
		case 2:
			t = setParaTitle2(p);//二級(jí)標(biāo)題
			break;
		case 3:
			t = setParaTitle3(p);//三級(jí)標(biāo)題
			break;
		default:	//main text正文
			t = '<p style="margin:0px; line-height:' +  rs + 'pt; text-indent: ' + sn + 'pt;font-family:' + mtfn + '; font-size:'+ mtfs + 'pt;">' + p;
	}//switch
 
	//taDbg.value += "\n---setParaFmt:" + t;
 
	return t;
}//setParaFmt(p)
 
 
function getArg()
{
	// 排版內(nèi)容包括公文標(biāo)題
	cbDocTilte  = document.getElementById('cbDocTilte').checked;
	//標(biāo)題字體名 document title font name
	dtfn = document.getElementById('selDocTitleFontName').value;
	//alert(fn);
	//標(biāo)題字號(hào) document title font size
	dtfs = document.getElementById('selDocTitleFontSize').value;
	//alert(fs);
	//標(biāo)題對(duì)齊方式 document title text align
	dtta = document.getElementById('selDocTitleAlign').value;
 
	//一級(jí)標(biāo)題字號(hào) primary title font name
	pt1fn = document.getElementById('selPrimaryTitleFontName').value;
	//一級(jí)標(biāo)題字號(hào)  primary titlefont size
	pt1fs = document.getElementById('selPrimaryTitleFontSize').value;
 
	//二級(jí)標(biāo)題字號(hào) psecondary title font name
	st2fn = document.getElementById('selSecondaryTitleFontName').value;
	//二級(jí)標(biāo)題字號(hào)  secondary title font size
	st2fs = document.getElementById('selSecondaryTitleFontSize').value;
	//二級(jí)標(biāo)題字體加粗  secondary title strong
	st2Strong	 = document.getElementById('cbSecondaryTitleStrong').checked;
 
	//三級(jí)標(biāo)題字體加粗  third title strong
	tt3Strong = document.getElementById('cbThirdTitleStrong').checked;
 
	//正文字體名稱
	mtfn = document.getElementById('selMainTextFontName').value;
	//正文字體字號(hào)
	mtfs = document.getElementById('selMainTextFontSize').value;
 
	//行距 row spacing
	rs  = document.getElementById('tbRowSp').value;
	//首行行首空格數(shù)
	sn  = document.getElementById('tbLeadSpNum').value*16;//20230729增加*16
}//	  getArg()
 
 
//判斷dddd年dd月dd日是否符合閏年等規(guī)則
//記錄:2023-07-16創(chuàng)建
String.prototype.isRightDateCn = function()
{
  return (/^(?:(?!0000)[0-9]{4}([年]{1})(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([月]{1})0?2\2(?:29))([日]{1})$/.test(this));
}
 
 
//功能:判斷是否為dddd年dd月dd日格式
//記錄:2023-07-16創(chuàng)建
String.prototype.isDateCn = function()
{
	//年=\u5e74,月=\u6708,日=\u65e5
	//return (/^(\d{4})([\u5e74]{1})(\d{1,2})([\u6708]{1})\d{1,2}([\u65e5]{1})$/.test(this)); 
	return (/^(\d{4})([年]{1})(\d{1,2})([月]{1})\d{1,2}([日]{1})$/.test(this)); 
}
 
 
//功能:判斷是否為落款
//輸入:t1=落款單位,t2=落款日期
//輸出:true=是落款;false=非落款
//記錄:2023-07-16創(chuàng)建
function isBadging(t1,t2)
{
	if (isAstatement(t1))//落款單位末尾是否帶符號(hào)?
	{
		return false;//帶符號(hào),不是落款
	}
	taDbg.value += "\n--- isBadging()\n" + t1 + '\n' + t2;
	return (t2.isDateCn());
}//isBadging(t1,t2)
 

//功能:利用canvas取字符串寬度
//輸入:s=字符串,f=字體
//輸出:字符串寬度
//記錄:2023-07-22創(chuàng)建
function getStrWidth(s, f)
{
  //alert(s);
  var canvas = getStrWidth.canvas || (getStrWidth.canvas = document.createElement("canvas"));
  var ctx = canvas.getContext("2d"); 
  ctx.font = f;
  return ctx.measureText(s).width;
}//geStrWidth()
 
 
//功能:設(shè)置落款格式
//輸入:t1=落款單位,t2=落款日期
//輸出:格式化后的落款單位和落款日期代碼
//紀(jì)錄:2023-07-16創(chuàng)建
//      2023-07-22修改
function setBadging(t1,t2)
{
	var r = new Array();
	var f =  mtfs+ 'pt' + ' '+ mtfn;//順序不能顛倒!
	//noSeal
	var iSize1 = getStrWidth(t1, f);
	var iSize2 = getStrWidth(t2, f);
	//document.write('<p>' + iSize1 + "  "  + iSize2);
	if (iSize2 > iSize1)
	{
		//如成文日期長(zhǎng)于發(fā)文機(jī)關(guān)署名,應(yīng)當(dāng)使成文日期右空二字編排,并相應(yīng)增加發(fā)文機(jī)關(guān)署名右空字?jǐn)?shù)。
		r[0] = '<p style="line-height:' + rs + 'pt; font-family:' + mtfn + ';font-size:' + mtfs + 'pt; text-align:right; margin:0 ' + Math.ceil((iSize2 - iSize1)/2 + 48) + 'px 0 0">' + t1;//1em=16px,36pt=32px,3em=48px
		r[1] = '<p style="line-height:' + rs + 'pt; font-family:' + mtfn + ';font-size:' + mtfs + 'pt; text-align:right; margin:0 36pt 0 0">' + t2;
	}
	else
	{
		//單一機(jī)關(guān)行文時(shí),在正文(或附件說(shuō)明)下空一行右空二字編排發(fā)文機(jī)關(guān)署名,在發(fā)文機(jī)關(guān)署名下一行編排成文日期,首字比發(fā)文機(jī)關(guān)署名首字右移二字
		r[0] = '<p style="line-height:' + rs + 'pt; font-family:' + mtfn + ';font-size:' + mtfs + 'pt; text-align:right; margin:0 36pt 0 0">' + t1;
		r[1] = '<p style="line-height:' + rs + 'pt; font-family:' + mtfn + ';font-size:' + mtfs + 'pt; text-align:right; margin: 0 ' + (iSize1 - iSize2) + 'px 0 0">' + t2;
	}
 
	return r.join('');
}//setBadging()
 

 
//功能:判斷字符串是否為“附件:”
//輸入:p=字符串
//輸出:true=是;false=否
//記錄:20230726創(chuàng)建
function isAttachmentWithColon(p) 
{
	return "附件:"==p.substr(0, 3) ? true : false;
}

//功能:判斷字符串中是否包含空白字符,包括空格、制表符、換頁(yè)符等等。等價(jià)于 [ \f\n\r\t\v]
//輸入:p=字符串
//輸出:true=是;false=否
//記錄:20230729創(chuàng)建
function isIncludeSpace(p) 
{
	//return "附件"==p ? true : false;
	return (-1!=p.search(/\s+/g) ? true : false); 
}


//功能:判斷字符串是否為“附s件”“附s件x”“附s件x-x”,其中s為空格,x為阿拉伯?dāng)?shù)字
//輸入:p=字符串
//輸出:true=是;false=否
//記錄:20230726創(chuàng)建
//      20230729改用isIncludeSpace()   
function isAttachmentWithSpace(p) 
{
	//return (/^(附){1}\s+(件){1}([\d|-]*)$/.test(p)); 
	return isIncludeSpace(p);
}


//功能:判斷字符串是否為“附件”“附件x”“附件x-x”,其中x為阿拉伯?dāng)?shù)字
//輸入:p=字符串
//輸出:true=是;false=否
//記錄:20230726創(chuàng)建
function isAttachment(p) 
{
	//return "附件"==p ? true : false;
	//return (/^(附件){1}([\d|-]*)$/.test(p)); 
 	return (/^(附){1}\s*(件){1}([\d|-]*)$/.test(p)); 
}


//功能:判斷相連兩段文字是否為附件及標(biāo)題
//輸入:p1=前一段;p2=后一段
//輸出:true=是;false=否
//記錄:20230726創(chuàng)建
function isAttachmentTitle(p1, p2)
{
	if (! isAttachment(p1))//前一段內(nèi)容是“附件”?
	{
		return false;//不是
	}

	return (! isAstatement(p2));	//后一段是否為一句話
}//isAttachmentTitle()    


//功能:刪除字符串中的所有空格
//記錄:20230726創(chuàng)建
String.prototype.eliminateSpace = function()
{
	return this.replace(/\s*/g,"");
}


//功能:設(shè)置附件及附件標(biāo)題格式
//輸入:p1=附件;p2=附件標(biāo)題
//輸出:附件及附件標(biāo)題格式化后的字符串
//記錄:20230726創(chuàng)建
function setAttachmentTitleFmt(p1, p2)
{
	//附件 與 附件標(biāo)題之間要間隔一行
	//return '<p style="margin:0px; font-family:黑體; font-size:' + mtfs + 'pt; line-height:"'	+ rs +'">' + p1 + '</p><p style="margin:0px; font-size:28pt; line-height:"'	+ rs +'">&nbsp;</p><p style="margin:0px; text-align:center; font-family:' + dtfn + '; font-size:' + dtfs + 'pt; line-height:"'	+ rs +'">' + p2 + '</p>';

	return '<p style="margin:0px; font-family:黑體; font-size:' + mtfs + 'pt; line-height:'	+ rs + 'pt">'  +  (isAttachmentWithSpace(p1) ? (p1.eliminateSpace() + g_sWarmPromptLeft + g_sWarmPromptTxt + '本行多余的空格已刪除' + g_sWarmPromptRight) : p1) + '</p><p style="margin:0px; font-size:' + mtfs + 'pt; line-height:' + rs + 'pt">&nbsp;</p><p style="margin:0px; text-align:center; font-family:' + dtfn + '; font-size:' + dtfs + 'pt; line-height:' + rs +'pt">' + p2 + '</p>';
}//setAttachmentTitleFmt(p1, p2)


//功能:判斷是否為以半角冒號(hào)結(jié)束的主送機(jī)關(guān)main delivery department
//輸入:p=字符串
//輸出:true=是,false=否
//更新:20230729創(chuàng)建
function isMainDeDeWithColonEn(p)
{
	return /.*(:){1}\s*$/gi.test(p);
}  
  
//功能:判斷是否為以全角冒號(hào)結(jié)束的主送機(jī)關(guān)main delivery department
//輸入:p=字符串
//輸出:true=是,false=否
//更新:20230729創(chuàng)建
function isMainDeDeWithColonCn(p)
{
   	//return (':'==p.substring(p.length-1) ? true : false);
	return /.*(:){1}\s*$/gi.test(p);
}
  

//功能:設(shè)置主送機(jī)關(guān)行格式main delivery department
//輸入:p=送機(jī)關(guān)行字符串
//輸出:主送機(jī)關(guān)行格式化字符串
//記錄:20230729創(chuàng)建
function setMainDeDe(s)
{
	taDbg.value += "\n---setMainDeDe()\n";
	var p = s;
	var a = null;
	
	if (isIncludeSpace(p))
	{
		p = p.eliminateSpace();
		a = '已刪除多余的字符';
	}

	if (isMainDeDeWithColonEn(p))
	{
		p = p.replaceAll(':', ':');
		a += ((null==a) ? null : ';') + '半角冒號(hào)已轉(zhuǎn)為全角冒號(hào)';
	}

	p = '<p style="margin:0px; line-height:' + rs + 'pt; font-family:' + mtfn + '; font-size:'+ mtfs + 'pt;">' + p;
	if (null != a)
	{
		p += g_sWarmPromptLeft + g_sWarmPromptTxt + a + g_sWarmPromptRight;
	}
	taDbg.value += p + "\n";
	return p;
}//setMainDeDe()


//功能:判斷是否為以全角冒號(hào)結(jié)束的主送機(jī)關(guān)main delivery department
//輸入:p=字符串
//輸出:true=是,false=否
//更新:20230729創(chuàng)建
function isMainDeDe(p)
{
   	//return (isMainDeDeWithColonCn(p) | isMainDeDeWithColonEn(p) ? true : false);
	return /.*(:|:){1}\s*$/gi.test(p);
}  


//功能:判斷是文本行是否為多個(gè)附件的頭1個(gè)附件說(shuō)明 is the firest multi attachment description?
//輸入:p=字符串
//輸出:true=是,false=否
//更新:20230730創(chuàng)建
function isMultiAttDesc1(p)
{
		return (/^(附){1}\s*(件){1}\s*(:|:){1}\s*\d+(.|.){1}\s*/.test(p)) && !p[p.length-1].isPunctuation();  
}  //isMultiAttDesc1(p)

//功能:判斷是文本行是否為單個(gè)附件的附件說(shuō)明 is a single Attachment Description?
//輸入:p=字符串
//輸出:true=是,false=否
//更新:20230730創(chuàng)建
function isSingleAttDesc(p)
{
	return (/^(附){1}\s*(件){1}\s*(:|:){1}\s*[^0-9]+\s*/.test(p)) && !p[p.length-1].isPunctuation(); 
}


//功能:判斷是文本行是否為附件說(shuō)明 is Attachment Description?
//輸入:p=字符串
//輸出:true=是,false=否
//更新:20230730創(chuàng)建
function isAttachmentDescription(p)
{
	//return (/^(附){1}\s*(件){1}\s*(:){1}\s*(\d. | \d.)*/.test(p)) & !p[p.length-1].isPunctuation(); 
	return (/^(附){1}\s*(件){1}\s*(:|:){1}\s*/.test(p)) && !p[p.length-1].isPunctuation();  
} 


//功能:設(shè)置附件說(shuō)明格式 set attachment description format
//輸入:p=附件說(shuō)明字符串
//輸出:格式化的附件說(shuō)明格式
//更新:20230730創(chuàng)建
function setAtttDescFmt(p)
{
	var t = p;
	var a = '';
	if (-1 != t.indexOf(':'))//是半角冒號(hào)?
	{
		t = p.replace(':', ':');
		a = g_sWarmPromptLeft + g_sWarmPromptTxt + "已將半角冒號(hào)轉(zhuǎn)換為全角冒號(hào)" + g_sWarmPromptRight;	  //溫馨提示
	}

	//公文如有附件,在正文下空一行左空二字編排"附件"二字,后標(biāo)全角冒號(hào)和附件名稱。
	var sBlankLine = '<p style="margin:0px; line-height:' + rs + 'pt; font-family:' + mtfn + '; font-size:'+ mtfs + 'pt;">&nbsp;</p>';
	var t  =  '<p style="margin:0pt 0pt 0pt 32pt; line-height:' + rs + 'pt; font-family:' + mtfn + '; font-size:'+ mtfs + 'pt;">' + t;
	return  sBlankLine +  t + a;
}// setAtttDescFmt(p)


//功能:設(shè)置公文格式Set document format
//輸入:無(wú)
//輸出:無(wú)
//記錄:20230726添加對(duì)附件及附件標(biāo)題格式的處理代碼
//           20230729添加對(duì)主送單位格式的處理代碼    
//           20230730添加對(duì)單個(gè)附件說(shuō)明格式的處理代碼    
function setDocFmt()
{
	taDbg.value += "\n---setDocFmt()\n";
 
	getArg(); //讀取預(yù)設(shè)參數(shù)
 
	var t = getClearInfoArray();
 
	//標(biāo)題
	if (cbDocTilte)
	{
		t[0]  = setDocTitle(t[0]) + '</p><p style="margin:0px; line-height:"' + rs +'">&nbsp;';
	}
 
	var i =  (cbDocTilte ? 1 : 0);//2023-07-26增加
	while (i < t.length)
	{

		if (i < t.length-1)//20230716增加
		{

			if (isBadging(t[i],t[i+1]))//是落款?
			{
				//落款前加空行
				t[i-1] += '</p><p style="margin:0px; line-height:"' + rs +'">&nbsp;';
				//設(shè)置落款
				t[i] = setBadging(t[i],t[i+1]);
				t[i+1] = null;
				taDbg.value += "\nt[" + (i-1) + "]=" + t[i-1] + "\nt[" + i +"]=" + t[i] + "\nt[" +(i+1) +"]=" + t[i+1];
				//i++;
				//i++;
				i += 2;
				continue;
			}

			if (isAttachmentTitle(t[i],t[i+1]))	  //是附件及附件標(biāo)題?
			{
				t[i] = setAttachmentTitleFmt(t[i],t[i+1]);
				t[i+1] = null;
				taDbg.value += "\nt[" + (i-1) + "]=" + t[i-1] + "\nt[" + i +"]=" + t[i] + "\nt[" +(i+1) +"]=" + t[i+1];
				//i++;
				//i++;
				i += 2;
				continue;
			}
		}//if

		if (isMainDeDe(t[i]))//是主送單位嗎?20230729增
		{
			t[i] = setMainDeDe(t[i]);//是
			i++;
			continue;
		}

		if (isSingleAttDesc(t[i])) //是單個(gè)附件說(shuō)明?20230730增加
		{
			t[i] = setAtttDescFmt(t[i]);
			i++;
			continue;
		}

		t[i] = setParaFmt(t[i]);
		i++;

	}//while()
	
	//alert(t.join(''));
	edRichBody.innerHTML = t.join(''); 
}//setDocFmt() 
 
</script>
 
</head>
 
<body>
<fieldset  style="width: 1100px;">
 <legend>實(shí)時(shí)編輯區(qū)</legend>
<iframe id="editor" width="1200px" height="400px" style="border: solid 1px;"></iframe>
</fieldset>
<p>
	<input type="button" id="btnclearDocFmt" value="清除格式" onclick="clearDocFmt()"   style="background:cyan;  border-radius: 25px;"  />
	<input type="button" id="btnsetDocFmt" value="一鍵排版" onclick="setDocFmt()"  style="background:purple; color:white; border-radius: 25px;" />
	<input type="button" id="btnShowSrc" value="顯示源碼" onclick="showSrc()" style="background:yellow; border-radius: 25px;" />
	<input type="button" id="btnB" value="B" title="加粗/正常"  style="font-weight:bolder" onclick="execCmd('bold',false,null)" />
	<input type="button" id="btnItalic" value="I" title="斜體/正常"  style="font-weight:bolder;font-style:italic" onclick="execCmd('italic',false,null)" />
	<input type="button" id="btnUnderline" value="I" title="下劃線"  style="font-weight:bolder;text-decoration:underline" onclick="execCmd('underline',false,null)" />
</p>
<fieldset style="width: 1200px;">
  <legend>參數(shù)設(shè)置</legend>
	公文標(biāo)題:<input type="checkbox" checked id="cbDocTilte">排版內(nèi)容包括公文標(biāo)題
	<script>
		showFontNameSel("selDocTitleFontName", 0);
		document.write(' ');
		showFontSizeSel("selDocTitleFontSize", 4);
		document.write(' ');
		showAlignSel("selDocTitleAlign", 1);
	</script>
 
	<p>正文一級(jí)標(biāo)題:
	<script>
		showFontNameSel("selPrimaryTitleFontName", 1);
		document.write(' ');
		showFontSizeSel("selPrimaryTitleFontSize", 6);
	</script>
	</p>
 
 	<p>正文二級(jí)標(biāo)題:
	<script>
		showFontNameSel("selSecondaryTitleFontName", 5);
		document.write(' ');
		showFontSizeSel("selSecondaryTitleFontSize", 6);
	</script>
		<input type="checkbox" checked id="cbSecondaryTitleStrong">粗體
	</p>
 
 	<p>正文三級(jí)標(biāo)題:
		<input type="checkbox" checked id="cbThirdTitleStrong">粗體
	</p>
 
 	<p>正文:	
		<script>
			showFontNameSel("selMainTextFontName", 3);
			document.write(' ');
			showFontSizeSel("selMainTextFontSize", 6);
			document.write(' ');
		</script>
		行距(行間距):<input type="text" id="tbRowSp" value="28" size="2"><!--  row spacing//-->  段落首行行首空格數(shù):<input type="text" id="tbLeadSpNum" value="2" size="2">
	</P>
 </fieldset>
 
<p>調(diào)試信息</p>
<textarea id="taDbg" style="width: 1225px; height: 200px">調(diào)試信息</textarea>
 
<script type="text/javascript">
 
const edRich = document.getElementById("editor");
const taDbg = document.getElementById("taDbg");
const btnShowSrc = document.getElementById("btnShowSrc");
 
//排版內(nèi)容是否包括公文標(biāo)題
var cbDocTilte;		//  = document.getElementById('cbDocTilte').value;
//標(biāo)題字體名 document title font name
var dtfn;	// = document.getElementById('selDocTitleFontName').value;
//標(biāo)題字號(hào) document title font size
var dtfs;	// = document.getElementById('selDocTitleFontSize').value;
//標(biāo)題對(duì)齊方式 document title text align
var dtta;// = document.getElementById('selDocTitleAlign').value;
 
//一級(jí)標(biāo)題字號(hào) font name
var pt1fn;	// = document.getElementById('selPrimaryTitleFontName').value;
//一級(jí)標(biāo)題字號(hào) font size
var pt1fs;	// = document.getElementById('selPrimaryTitleFontSize').value;
 
//二級(jí)標(biāo)題字號(hào) psecondary title font name
var st2fn;	// = document.getElementById('selSecondaryTitleFontName').value;
//二級(jí)標(biāo)題字號(hào)  secondary title font size
var st2fs;	// = document.getElementById('selSecondaryTitleFontSize').value;
//二級(jí)標(biāo)題字體加粗  secondary title strong
var st2Strong;	// = document.getElementById('cbSecondaryTitleStrong').value;
 
//三級(jí)標(biāo)題字體加粗  third title strong
var tt3Strong;	//	 = document.getElementById('cbThirdTitleStrong').value;
 
//行距 row spacing
 var rs;		//  = document.getElementById('tbRowSp').value;
//首行行首空格數(shù)
 var sn;		//  = document.getElementById('tbLeadSpNum').value;
 
//正文字體名稱
var mtfn;	// = document.getElementById('selMainTextFontName').value;
	//正文字體字號(hào)
var mtfs;	// = document.getElementById('selMainTextFontSize').value;       
var edRichDoc;
var edRichBody;
//var edRichHTML;
if (typeof(edRich) !="undefined")
 {
	edRichDoc = edRich.contentWindow.document;
	edRichDoc.designMode = "on";
	edRichDoc.contentEditable = true;
	edRichBody = edRichDoc.body;
	edRichBody.innerHTML = '<p><a >http://blog.csdn.net/purpleendurer</a></p><p></p><p style="font-family:方正小標(biāo)宋簡(jiǎn)體;font-size:22pt; text-align:center; line-height:28pt;"><p align="center" style="text-align:center;text-indent:24.0pt;line-height:28.0pt"><span lang="EN-US" style="font-size:22.0pt;font-family:方正小標(biāo)宋簡(jiǎn)體;mso-hansi-font-family:黑體;color:black">SQL</span><span style="font-size:22.0pt;font-family:方正小標(biāo)宋簡(jiǎn)體;mso-hansi-font-family:黑體;color:black">注入基礎(chǔ)<span lang="EN-US"><o:p></o:p></span></span></p><p style="text-indent:2em;">河池市××局、        市×× 局:   </p><p style="text-indent:24.0pt;line-height:28.0pt;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px"><span style="font-size:16.0pt;font-family:黑體;color:black">一、<span lang="EN-US">SQL</span>注入分類<span lang="EN-US"><o:p></o:p></span></span></p><p style="text-indent:24.0pt;line-height:28.0pt;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px"><b><span style="font-size:16.0pt;font-family:楷體_GB2312;color:black">(一)什么是<span lang="EN-US">SQL</span>注入<span lang="EN-US">?<o:p></o:p></span></span></b></p><p style="text-indent:24.0pt;line-height:28.0pt;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px"><span lang="EN-US" style="font-size:16.0pt;font-family:仿宋_GB2312;color:black">SLQ</span><span style="font-size:16.0pt;font-family:仿宋_GB2312;color:black">注入<span lang="EN-US">(</span>英文<span lang="EN-US">: Sqlinject)</span>:當(dāng)<span lang="EN-US">web</span>應(yīng)用向后臺(tái)數(shù)據(jù)庫(kù)傳遞<span lang="EN-US">SQL</span>語(yǔ)句進(jìn)行數(shù)據(jù)庫(kù)操作時(shí),如果對(duì)用戶輸入的參數(shù)沒(méi)有經(jīng)過(guò)嚴(yán)格的過(guò)濾,那么用戶可以構(gòu)造特殊的<span lang="EN-US">sq1</span>語(yǔ)句,從而帶入到數(shù)據(jù)庫(kù)中執(zhí)行,獲取或修改數(shù)據(jù)庫(kù)中的數(shù)據(jù)。<span lang="EN-US"><o:p></o:p></span></span></p><p style="text-indent:24.0pt;line-height:28.0pt;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px"><span style="font-size:16.0pt;color:black">&nbsp;&nbsp;1.加強(qiáng)技術(shù)學(xué)習(xí)。一要<span lang="EN-US"><o:p></o:p></span></span></p><p style="text-indent:24.0pt;line-height:28.0pt;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px"><span style="font-size:16.0pt;color:black">&nbsp;&nbsp;2.強(qiáng)化安全保障。一要。<span lang="EN-US"><o:p></o:p></span></span></p><p>附件:河池市××關(guān)于××的通知</p><p>附件:河池市××關(guān)于××的通知</p><p>附件:河池市××關(guān)于××的通知。</p><p>附件:1.河池市××關(guān)于××的通 知</p><p>附件:1.河池市××關(guān)于××××的通 知 </p><p>2.河池市××關(guān)于×× ××的通 知 </p><p>3.河池市××關(guān)于×× ××的通 知</p><p>測(cè)試1</p><p style="text-indent:24.0pt;line-height:28.0pt;font-variant-ligatures: normal;font-variant-caps: normal;orphans: 2;text-align:start;widows: 2;-webkit-text-stroke-width: 0px;text-decoration-thickness: initial;text-decoration-style: initial;text-decoration-color: initial;word-spacing:0px">河池市××××局</p><p>2023年7月22日</p><p>測(cè)試2</p><p>廣西壯族自治區(qū)河池市××××局</p><p>2023年7月22日</p><p>測(cè)試3</p><p>河池市××局</p><p>2023年7月22日</p><p>測(cè)試4</p><p>河池市×局</p><p>2023年7月22日</p><p>附件</p><p>附件標(biāo)題</p><p>附件:</p><p>附件標(biāo)題</p><p>附  件</p><p>附件標(biāo)題</p>';
}
else
{
	window.alert("undefined");
}
 
function replaceStr(s1,s2)
{
	try
	{
		var r = document.body.createTextRange();
		if (r.findText(s1))
		{
			r.expand('charactor');
			r.select();
			r.text = s2;
			r.scrollIntoView();
		}
		else
		{
			alert('"'+s+'" not found!');
		}
	}
	catch (e)
	{
		alert(e.description);
	}
}
 
 
function showSrc()
{
	if (btnShowSrc.value=="顯示源碼")
	{
		edRichBody.innerText = edRichBody.innerHTML;
		//edRichBody.innerText = edRichBody.innerHTML.replace('</p>','</p>'+chr(10));	  
		//edRichBody.innerText = edRichBody.innerText.replace('<\/p>','<\/p>'+chr(10)+chr(13));	  
 
		btnShowSrc.value = "顯示預(yù)覽";
		btnShowSrc.style.background = "cyan";
	}
	else
	{
		edRichBody.innerHTML = edRichBody.innerText;
		//edRichBody.innerHTML = edRichBody.innerText.replace(chr(10)+chr(13),'');
		btnShowSrc.value = "顯示源碼";
		btnShowSrc.style.background = "yellow";
	}
}
 
 
function execCmd(cmd,f,v)
{
	edRichDoc.execCommand(cmd,f,v);
}
</script>
</body>
</html>

到了這里,關(guān)于用html+javascript打造公文一鍵排版系統(tǒng)10:?jiǎn)我桓郊f(shuō)明排版的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包